@@ -62,44 +62,49 @@ static void (*s_connect_callback)(void) = NULL;
62
62
static void (* s_disconnect_callback )(void ) = NULL ;
63
63
64
64
// HTML for the configuration page
65
- static const char * s_html_page = "<!DOCTYPE html>"
66
- "<html>"
67
- "<head>"
68
- "<title>Tronbyt WiFi Setup</title>"
69
- "<meta name='viewport' content='width=device-width, initial-scale=1'>"
70
- "<style>"
71
- "body { font-family: Arial, sans-serif; margin: 0; padding: 20px; }"
72
- "h1 { color: #333; }"
73
- ".form-container { max-width: 400px; margin: 0 auto; }"
74
- ".form-group { margin-bottom: 15px; }"
75
- "label { display: block; margin-bottom: 5px; font-weight: bold; }"
76
- "input[type='text'], input[type='password'] { width: 100%; padding: 8px; box-sizing: border-box; }"
77
- "button { background-color: #4CAF50; color: white; padding: 10px 15px; border: none; cursor: pointer; }"
78
- "button:hover { background-color: #45a049; }"
79
- ".networks { margin-top: 20px; }"
80
- "</style>"
81
- "</head>"
82
- "<body>"
83
- "<div class='form-container'>"
84
- "<h1>Tronbyt WiFi Setup</h1>"
85
- "<form action='/save' method='post' enctype='application/x-www-form-urlencoded'>"
86
- "<div class='form-group'>"
87
- "<label for='ssid'>WiFi Network Name:</label>"
88
- "<input type='text' id='ssid' name='ssid' maxlength='32' required>"
89
- "</div>"
90
- "<div class='form-group'>"
91
- "<label for='password'>WiFi Password:</label>"
92
- "<input type='text' id='password' name='password' maxlength='64'>"
93
- "</div>"
94
- "<div class='form-group'>"
95
- "<label for='image_url'>Image URL:</label>"
96
- "<input type='text' id='image_url' name='image_url' maxlength='256'>"
97
- "</div>"
98
- "<button type='submit'>Save and Connect</button>"
99
- "</form>"
100
- "</div>"
101
- "</body>"
102
- "</html>" ;
65
+ static const char * s_html_page =
66
+ "<!DOCTYPE html>"
67
+ "<html>"
68
+ "<head>"
69
+ "<title>Tronbyt WiFi Setup</title>"
70
+ "<meta name='viewport' content='width=device-width, initial-scale=1'>"
71
+ "<style>"
72
+ "body { font-family: Arial, sans-serif; margin: 0; padding: 20px; }"
73
+ "h1 { color: #333; }"
74
+ ".form-container { max-width: 400px; margin: 0 auto; }"
75
+ ".form-group { margin-bottom: 15px; }"
76
+ "label { display: block; margin-bottom: 5px; font-weight: bold; }"
77
+ "input[type='text'], input[type='password'] { width: 100%; padding: 8px; "
78
+ "box-sizing: border-box; }"
79
+ "button { background-color: #4CAF50; color: white; padding: 10px 15px; "
80
+ "border: none; cursor: pointer; }"
81
+ "button:hover { background-color: #45a049; }"
82
+ ".networks { margin-top: 20px; }"
83
+ "</style>"
84
+ "</head>"
85
+ "<body>"
86
+ "<div class='form-container'>"
87
+ "<h1>Tronbyt WiFi Setup</h1>"
88
+ "<form action='/save' method='post' "
89
+ "enctype='application/x-www-form-urlencoded'>"
90
+ "<div class='form-group'>"
91
+ "<label for='ssid'>WiFi Network Name:</label>"
92
+ "<input type='text' id='ssid' name='ssid' maxlength='32' required>"
93
+ "</div>"
94
+ "<div class='form-group'>"
95
+ "<label for='password'>WiFi Password:</label>"
96
+ "<input type='text' id='password' name='password' maxlength='64'>"
97
+ "</div>"
98
+ "<div class='form-group'>"
99
+ "<label for='image_url'>Image URL:</label>"
100
+ "<input type='text' id='image_url' name='image_url' maxlength='256'>"
101
+ "( If modifying Image URL reboot Tronbyt after saving. )"
102
+ "</div>"
103
+ "<button type='submit'>Save and Connect</button>"
104
+ "</form>"
105
+ "</div>"
106
+ "</body>"
107
+ "</html>" ;
103
108
104
109
// Success page HTML
105
110
static const char * s_success_html = "<!DOCTYPE html>"
@@ -117,6 +122,7 @@ static const char *s_success_html = "<!DOCTYPE html>"
117
122
"<h1>Configuration Saved!</h1>"
118
123
"<p>WiFi credentials and image URL have been saved.</p>"
119
124
"<p>The device will now attempt to connect to the WiFi network.</p>"
125
+ "<p>If you modified a previously saved Image URL please manually reboot your tron for the changes to take effect."
120
126
"<p>You can close this page.</p>"
121
127
"</body>"
122
128
"</html>" ;
@@ -295,6 +301,13 @@ static bool has_saved_config = false;
295
301
return 0 ;
296
302
}
297
303
304
+ // Shutdown the AP by switching wifi mode to STA
305
+ void wifi_shutdown_ap (TimerHandle_t xTimer ) {
306
+ ESP_LOGI (TAG , "Shutting down config portal" );
307
+ stop_webserver ();
308
+ esp_wifi_set_mode (WIFI_MODE_STA );
309
+ }
310
+
298
311
// Shutdown WiFi
299
312
void wifi_shutdown () {
300
313
// Stop the web server if it's running
@@ -737,8 +750,8 @@ static void url_decode(char *str) {
737
750
* dst = (char )strtol (hex , NULL , 16 );
738
751
src += 3 ;
739
752
} else if (* src == '+' ) {
740
- * dst = ' ' ;
741
- src ++ ;
753
+ * dst = ' ' ;
754
+ src ++ ;
742
755
} else {
743
756
* dst = * src ;
744
757
src ++ ;
0 commit comments