@@ -664,7 +664,7 @@ static void handleRoot() {
664664 " label{display:block;margin-top:.8em;font-weight:600}input{width:100%;padding:.55em;box-sizing:border-box;font-size:1em;border:1px solid #ccc;border-radius:6px}"
665665 " input[type=file]{padding:.3em 0;border:0}input[type=checkbox]{width:auto;margin-right:.45em}"
666666 " .checkline{display:flex;align-items:center;gap:.35em;margin-top:.8em}button{margin-top:.9em;padding:.6em 1em;background:#2f6f5e;color:#fff;border:0;border-radius:6px;cursor:pointer}"
667- " code{font-family:ui-monospace,SFMono-Regular,monospace;background:#f3f3f3;padding:.1em .35em;border-radius:4px}"
667+ " button.danger{background:#b3261e} code{font-family:ui-monospace,SFMono-Regular,monospace;background:#f3f3f3;padding:.1em .35em;border-radius:4px}"
668668 " @media (max-width:640px){body{padding:0 .75em}}</style></head><body>" );
669669 body += " <h2>" + title + " </h2>" ;
670670 body += " <div class='summary'><p><strong>mDNS</strong> " + hostname + " .local</p>" ;
@@ -749,6 +749,12 @@ static void handleRoot() {
749749 " <button type='submit'>Save password</button>"
750750 " </form><p class='m'>Password changes take effect on the next request.</p></div></details>" );
751751
752+ body += F (" <details><summary>Wi-Fi Setup Mode</summary><div class='inside'>"
753+ " <p>Clear the saved modem configuration and reboot into the open <code>LoRa-Modem-XXXX</code> setup AP.</p>"
754+ " <form method='POST' action='/wifi-reset' onsubmit=\" return confirm('Clear saved modem configuration and reboot into Wi-Fi setup AP?');\" >"
755+ " <button class='danger' type='submit'>Enter Wi-Fi Setup Mode</button>"
756+ " </form><p class='m'>Use this before moving the modem to a different Wi-Fi network.</p></div></details>" );
757+
752758 body += F (" <details><summary>Reboot</summary><div class='inside'>"
753759 " <p>Restart the modem without changing any settings.</p>"
754760 " <form method='POST' action='/reboot'>"
@@ -969,6 +975,18 @@ static void handleApiReboot() {
969975 ESP .restart ();
970976}
971977
978+ static void handleWifiReset () {
979+ if (!checkAuth ()) return ;
980+
981+ Serial.printf (" [OTA] Wi-Fi setup reset requested by %s\n " ,
982+ httpServer->client ().remoteIP ().toString ().c_str ());
983+ sendSimplePage (F (" Entering Wi-Fi setup mode" ),
984+ F (" Entering Wi-Fi setup mode" ),
985+ F (" Saved modem configuration is being cleared. The modem will reboot into the open LoRa-Modem setup AP." ));
986+ delay (500 );
987+ WifiManager::factoryReset (); // does not return
988+ }
989+
972990static void handleHostnameSave () {
973991 if (!checkAuth ()) return ;
974992
@@ -1230,6 +1248,7 @@ void begin(const String& hn, const String& tk) {
12301248 httpServer->on (" /gps" , HTTP_POST , handleGpsSave);
12311249 httpServer->on (" /token" , HTTP_POST , handleTokenSave);
12321250 httpServer->on (" /auth" , HTTP_POST , handleAuthSave);
1251+ httpServer->on (" /wifi-reset" , HTTP_POST , handleWifiReset);
12331252 httpServer->on (" /reboot" , HTTP_POST , handleReboot);
12341253 httpServer->on (" /update" , HTTP_POST , handleUpdateResult, handleUpdateUpload);
12351254 httpServer->onNotFound ([]() { httpServer->send (404 , " text/plain" , " Not found" ); });
0 commit comments