Skip to content

Commit

Permalink
Fix initial Wifi setup
Browse files Browse the repository at this point in the history
  • Loading branch information
dzungpv committed Sep 29, 2019
1 parent cbde601 commit 4a33b79
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
18 changes: 12 additions & 6 deletions src/mitsubishi2mqtt/html_init.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@ String html_init_setup = R"====(
<noscript>To user Mitsubishi2MQTT, you need to activate Javascript<br/></noscript>
<h3>_UNIT_NAME_</h3>
</div>
<p><form action='/mqtt' method='get'><button>MQTT</button></form></p>
<p><form action='/wifi' method='get'><button>WIFI</button></form></p>
<p><form action='/others' method='get'><button>Others</button></form></p>
<p><form><button type='submit' name='RESET' class='button bred'>Reset configuration</button></form></p>
<p><form action='/' method='get'><button>Back</button></form></p>
<div id='l1' name='l1'></div>
<fieldset>
<legend><b>&nbsp;Initial setup&nbsp;</b></legend>
<form method='get' action='save'>
<p><b>Hostname</b><br/><input id='hn' name='hn' placeholder=' ' value='_UNIT_NAME_'></p>
<p><b>SSID</b> ()<br/><input id='ssid' name='ssid' placeholder=' '></p>
<p><b>PSK</b> ()<br/><input id='psk' name='psk' placeholder=' '></p>
<p><b>OTA Password</b><br/><input id='otapwd' name='otapwd' placeholder=' '></p>
</p><br/><button name='submit' type='submit' class='button bgrn'>Save & Reboot</button>
</form>
</fieldset>
)====";

String html_init_save = R"====(
Expand All @@ -22,4 +28,4 @@ String html_init_save = R"====(

<p>Rebooting and connecting to your WiFi network! You should see it listed in on your access point.</p>

)====";
)====";
17 changes: 9 additions & 8 deletions src/mitsubishi2mqtt/mitsubishi2mqtt.ino
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,19 @@ void setup() {
ha_debug_topic = mqtt_topic + "/" + mqtt_fn + "/debug";
ha_debug_set_topic = mqtt_topic + "/" + mqtt_fn + "/debug/set";
ha_config_topic = "homeassistant/climate/" + mqtt_fn + "/config";
// startup mqtt connection
// startup mqtt connection
init_MQTT();
Serial.println("Connection to HVAC. Stop serial log.");
//write_log("Connection to HVAC");
hp.setSettingsChangedCallback(hpSettingsChanged);
hp.setStatusChangedCallback(hpStatusChanged);
hp.setPacketCallback(hpPacketDebug);
hp.connect(&Serial);
lastTempSend = millis();
}
else {
//write_log("Not found MQTT config go to configuration page");
}
Serial.println("Connection to HVAC. Stop serial log.");
//write_log("Connection to HVAC");
hp.setSettingsChangedCallback(hpSettingsChanged);
hp.setStatusChangedCallback(hpStatusChanged);
hp.setPacketCallback(hpPacketDebug);
hp.connect(&Serial);
lastTempSend = millis();
}
else {
dnsServer.start(DNS_PORT, "*", apIP);
Expand Down Expand Up @@ -293,6 +293,7 @@ boolean init_wifi() {
Serial.print("IP address: ");
Serial.println(WiFi.softAPIP());
//ticker.attach(0.2, tick); // Start LED to flash rapidly to indicate we are ready for setting up the wifi-connection (entered captive portal).
wifi_config = false;
return false;
}
else {
Expand Down

0 comments on commit 4a33b79

Please sign in to comment.