Skip to content
This repository has been archived by the owner on Nov 18, 2020. It is now read-only.

Commit

Permalink
Expose Name variable to rename device
Browse files Browse the repository at this point in the history
  • Loading branch information
jennytoo committed Dec 16, 2019
1 parent 3605f1d commit ed08f37
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
17 changes: 16 additions & 1 deletion Super_Simple_RGB_WiFi_Lamp/Web_Page.ino
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ const char websiteSource[] PROGMEM =
" // console.log(\"Found Mode Message\")\n"
" handleModeMessage(jsonMessage.Mode)\n"
" }\n"
" if (\"Name\" in jsonMessage) {\n"
" // console.log(\"Found Name Message\")\n"
" handleNameMessage(jsonMessage.Name)\n"
" }\n"
" if (\"State\" in jsonMessage) {\n"
" // console.log(\"Found State Message\")\n"
" handleStateMessage(jsonMessage.State)\n"
Expand Down Expand Up @@ -110,6 +114,13 @@ const char websiteSource[] PROGMEM =
" }\n"
" }\n"
"\n"
" function handleNameMessage(jsonMessage) {\n"
" // console.log(jsonMessage)\n"
" if (typeof jsonMessage === \"string\") {\n"
" $(\"#NameInput\").val(jsonMessage)\n"
" }\n"
" }\n"
"\n"
" function handleStateMessage(jsonMessage) {\n"
" // console.log(jsonMessage)\n"
" if (typeof jsonMessage === \"boolean\") {\n"
Expand Down Expand Up @@ -1502,6 +1513,10 @@ const char websiteSource[] PROGMEM =
"\n"
" <div id=\"wifiConfigForm\">\n"
" <div class=\"form-group\">\n"
" <label for=\"NameInput\">Name</label>\n"
" <input id=\"NameInput\" class=\"form-control\" placeholder=\"Name\" type=\"text\">\n"
" </div>\n"
" <div class=\"form-group\">\n"
" <label for=\"SSIDInput\">SSID</label>\n"
" <input id=\"SSIDInput\" class=\"form-control\" placeholder=\"SSID\" type=\"text\">\n"
" </div>\n"
Expand Down Expand Up @@ -1537,6 +1552,7 @@ const char websiteSource[] PROGMEM =
"\n"
" function onSubmitWifiEvent() {\n"
" msg = {\n"
" \"Name\": $(\"#NameInput\").val(),\n"
" \"Wifi\": {\n"
" \"SSID\": $(\"#SSIDInput\").val(),\n"
" \"Password\": $(\"#PassInput\").val()\n"
Expand All @@ -1555,6 +1571,5 @@ const char websiteSource[] PROGMEM =
" </div>\n"
" </div>\n"
"</body>\n"
"\n"
"</html>\n"
;
19 changes: 17 additions & 2 deletions Website/Website.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
// console.log("Found Mode Message")
handleModeMessage(jsonMessage.Mode)
}
if ("Name" in jsonMessage) {
// console.log("Found Name Message")
handleNameMessage(jsonMessage.Name)
}
if ("State" in jsonMessage) {
// console.log("Found State Message")
handleStateMessage(jsonMessage.State)
Expand Down Expand Up @@ -108,6 +112,13 @@
}
}

function handleNameMessage(jsonMessage) {
// console.log(jsonMessage)
if (typeof jsonMessage === "string") {
$("#NameInput").val(jsonMessage)
}
}

function handleStateMessage(jsonMessage) {
// console.log(jsonMessage)
if (typeof jsonMessage === "boolean") {
Expand Down Expand Up @@ -1499,6 +1510,10 @@ <h2>Wifi Configuration</h2>
<button id="rescanButton" class="col mb-2 mx-2 btn btn-lg btn-outline-light">Rescan</button>

<div id="wifiConfigForm">
<div class="form-group">
<label for="NameInput">Name</label>
<input id="NameInput" class="form-control" placeholder="Name" type="text">
</div>
<div class="form-group">
<label for="SSIDInput">SSID</label>
<input id="SSIDInput" class="form-control" placeholder="SSID" type="text">
Expand Down Expand Up @@ -1535,6 +1550,7 @@ <h2>Wifi Configuration</h2>

function onSubmitWifiEvent() {
msg = {
"Name": $("#NameInput").val(),
"Wifi": {
"SSID": $("#SSIDInput").val(),
"Password": $("#PassInput").val()
Expand All @@ -1553,5 +1569,4 @@ <h2>Wifi Configuration</h2>
</div>
</div>
</body>

</html>
</html>

0 comments on commit ed08f37

Please sign in to comment.