Skip to content

Commit 4694672

Browse files
committed
access point: add manual entry page
1 parent 6ffd9f7 commit 4694672

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

noisemeter-device/access-point-html.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,33 @@ const char *HTML_FOOTER = R"html(
7474
)html";
7575

7676
const char *HTML_BODY_FORM_HEADER = R"html(
77-
<p>Enter the wifi network name and password for your home network, which the sensor can connect to to get online:<br/><br/></p>
77+
<p>Select your home WiFi network below and enter its password to get the sensor online:<br><br></p>
7878
<form method='POST' action='/submit' enctype='multipart/form-data'>
79-
<label for='ssid'>Wifi network name (&#x1f512; = password required):</label><br>
79+
<label for='ssid'>Wifi network name:</label><br>
8080
<select name='ssid' id='ssid' required>
8181
)html";
8282

8383
const char *HTML_BODY_FORM_FOOTER = R"html(
84-
</select><br>
85-
<label for='psk'>Wifi network password:</label><br>
84+
</select>
85+
<p style="font-size: 0.75em">(&#x1f512; = password required)<br>(Don't see your network? <a href="/manual">Enter it manually</a>)</p>
86+
<br><label for='psk'>Wifi network password:</label><br>
8687
<input type='password' name='psk' id='psk'/><br>
8788
<label for='email'>Your Email (also your username for logging into the tRacket portal):</label><br>
8889
<input type='email' name='email' id='email'/><br>
8990
<p><input type='submit' value='Connect'/></p>
9091
</form>
9192
)html";
9293

94+
const char *HTML_BODY_FORM_MANUAL = R"html(
95+
<p>Enter the wifi network name and password for your home network, which the sensor can connect to to get online:<br/><br/></p>
96+
<form method='POST' action='/submit' enctype='multipart/form-data'>
97+
<p>Wifi network name:</p>
98+
<input type='text' name='ssid' autocorrect='off' autocapitalize='none' autocomplete='off' required/>
99+
<p>Wifi network password:</p>
100+
<input type='password' name='psk'/>
101+
<p>Your Email (also your username for logging into the tRacket portal):</p>
102+
<input type='email' name='email'/>
103+
<p><input type='submit' value='Connect'/></p>
104+
</form>
105+
)html";
106+

noisemeter-device/access-point-html.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ extern const char *HTML_CONTAINER;
33
extern const char *HTML_FOOTER;
44
extern const char *HTML_BODY_FORM_HEADER;
55
extern const char *HTML_BODY_FORM_FOOTER;
6-
6+
extern const char *HTML_BODY_FORM_MANUAL;

noisemeter-device/access-point.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,15 @@ bool AccessPoint::handle(WebServer& server, HTTPMethod method, String uri)
178178
response += HTML_BODY_FORM_FOOTER;
179179
response += HTML_FOOTER;
180180

181+
timeout = DAY_TO_SEC(30);
182+
server.send_P(200, PSTR("text/html"), response.c_str());
183+
} else if (uri == "/manual") {
184+
String response;
185+
response.reserve(2048);
186+
response += HTML_HEADER;
187+
response += HTML_CONTAINER;
188+
response += HTML_BODY_FORM_MANUAL;
189+
response += HTML_FOOTER;
181190
timeout = DAY_TO_SEC(30);
182191
server.send_P(200, PSTR("text/html"), response.c_str());
183192
} else if (uri == "/connecttest.txt") {

0 commit comments

Comments
 (0)