Skip to content

Commit

Permalink
Reduce ram usage by 30% percent by use PROGMEM. Fix login password se…
Browse files Browse the repository at this point in the history
…t to null. Breaking change: Set your temperature unit after update in SETUP->ADVANCE if you use Fahrenheit
  • Loading branch information
dzungpv committed Feb 28, 2020
1 parent e77e444 commit 800c209
Show file tree
Hide file tree
Showing 7 changed files with 154 additions and 57 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ How to use:
- Step 4: set Wifi information, save & reboot. Fall back to AP mode if WiFi connection fails (AP password sets to default SSID name from step 2).
- Step 5: find the device IP with last 4 character MAC address in your router
- Step 6: (optional): Set MQTT information for use with Home Assistant
- Step 7: (optional): Set Login password to prevent unwanted access in SETUP->ADVANCE->Login Password
4 changes: 2 additions & 2 deletions src/mitsubishi2mqtt/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
*
*/

String m2mqtt_version = "0.4.8.1";
String m2mqtt_version = "0.4.9";

//Define global variables for files
String wifi_conf = "wifi.json";
String mqtt_conf = "mqtt.json";
String advance_conf = "unit.json"; //we can use advance.json but keep old name for backward comparity with version 0.4.8
String advance_conf = "advance.json";
String console_file = "console.log";
String others_conf = "others.json";

Expand Down
4 changes: 2 additions & 2 deletions src/mitsubishi2mqtt/html_common.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
String html_common_header = R"====(<!DOCTYPE html>
const char html_common_header[] PROGMEM = R"====(<!DOCTYPE html>
<html lang="fr" class="">
<head><meta charset='utf-8'>
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no"/>
Expand Down Expand Up @@ -27,7 +27,7 @@ String html_common_header = R"====(<!DOCTYPE html>
</head>
)====";

String html_common_footer = R"====(
const char html_common_footer[] PROGMEM = R"====(
<br/>
<div style='text-align:right;font-size:10px;color: grey;'>
<hr/>Mitsubishi2MQTT _VERSION_</div></div></body></html>
Expand Down
6 changes: 3 additions & 3 deletions src/mitsubishi2mqtt/html_init.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
String html_init_setup = R"====(
const char html_init_setup[] PROGMEM = R"====(
<body>
<div style='text-align:left;display:inline-block;min-width:340px;'>
<div style='text-align:center;'>
Expand All @@ -23,7 +23,7 @@ String html_init_setup = R"====(
</fieldset>
)====";

String html_init_save = R"====(
const char html_init_save[] PROGMEM = R"====(
<body>
<div style='text-align:left;display:inline-block;min-width:340px;'>
<div style='text-align:center;'>
Expand All @@ -35,7 +35,7 @@ String html_init_save = R"====(

)====";

String html_init_reboot = R"====(
const char html_init_reboot[] PROGMEM = R"====(
<body>
<div style='text-align:left;display:inline-block;min-width:340px;'>
<div style='text-align:center;'>
Expand Down
25 changes: 18 additions & 7 deletions src/mitsubishi2mqtt/html_menu.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
String html_menu_root = R"====(
const char html_menu_root[] PROGMEM = R"====(
<body>
<script>
var showLogout = _SHOW_LOGOUT_;
document.onreadystatechange = function(){
if (document.readyState === "complete") {
if(showLogout==0){
var element = document.getElementById("logout");
element.parentNode.removeChild(element);
}
}
}
</script>
<div style='text-align:left;display:inline-block;min-width:340px;'>
<div style='text-align:center;'>
<noscript>To user Mitsubishi2MQTT, you need to activate Javascript<br/></noscript>
<h3>_UNIT_NAME_</h3>
</div>
<p><form action='/control' method='get'><button>Control</button></form></p>
<p><form action='/setup' method='get'><button>Setup</button></form></p>
<p><form action='/status' method='get'><button>Status</button></form></p>
<p><form action='/login?LOGOUT=YES' method='post'><button type='submit' name='Logout' class='button bred'>Logout</button></form></p>
<p><form><button type='submit' name='REBOOT' class='button bred'>Reboot</button></form></p>
<div><form action='/control' method='get'><button>Control</button></form></div>
<div><form action='/setup' method='get'><button>Setup</button></form></div>
<div><form action='/status' method='get'><button>Status</button></form></div>
<div><form><button type='submit' name='REBOOT' class='button bred'>Reboot</button></form></div>
<div id="logout"><form action='/login?LOGOUT=YES' method='post'><button type='submit' name='Logout' class='button bred'>Logout</button></form></div>
)====";


String html_menu_setup = R"====(
const char html_menu_setup[] PROGMEM = R"====(
<body>
<div style='text-align:left;display:inline-block;min-width:340px;'>
<div style='text-align:center;'>
Expand Down
46 changes: 34 additions & 12 deletions src/mitsubishi2mqtt/html_pages.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
String html_page_reboot = R"====(
const char html_page_reboot[] PROGMEM = R"====(
<body>
<div style='text-align:left;display:inline-block;min-width:340px;'>
<div style='text-align:center;'>
Expand All @@ -14,7 +14,7 @@ String html_page_reboot = R"====(
</script>
)====";

String html_page_reset = R"====(
const char html_page_reset[] PROGMEM = R"====(
<body>
<div style='text-align:left;display:inline-block;min-width:340px;'>
<div style='text-align:center;'>
Expand All @@ -26,7 +26,7 @@ String html_page_reset = R"====(
)====";


String html_page_save_reboot = R"====(
const char html_page_save_reboot[] PROGMEM = R"====(
<body>
<div style='text-align:left;display:inline-block;min-width:340px;'>
<div style='text-align:center;'>
Expand All @@ -43,7 +43,7 @@ String html_page_save_reboot = R"====(

)====";

String html_page_mqtt = R"====(
const char html_page_mqtt[] PROGMEM = R"====(
<body>
<div style='text-align:left;display:inline-block;min-width:340px;'>
<div style='text-align:center;'>
Expand All @@ -69,7 +69,7 @@ String html_page_mqtt = R"====(
<p><form action='/setup' method='get'><button>Back</button></form></p>
)====";

String html_page_others = R"====(
const char html_page_others[] PROGMEM = R"====(
<body>
<div style='text-align:left;display:inline-block;min-width:340px;'>
<div style='text-align:center;'>
Expand Down Expand Up @@ -100,7 +100,7 @@ String html_page_others = R"====(
<p><form action='/setup' method='get'><button>Back</button></form></p>
)====";

String html_page_status = R"====(
const char html_page_status[] PROGMEM = R"====(
<body>
<div style='text-align:left;display:inline-block;min-width:340px;'>
<div style='text-align:center;'>
Expand All @@ -117,7 +117,7 @@ String html_page_status = R"====(
<p><form action='/' method='get'><button>Back</button></form></p>
)====";

String html_page_wifi = R"====(
const char html_page_wifi[] PROGMEM = R"====(
<body>
<div style='text-align:left;display:inline-block;min-width:340px;'>
<div style='text-align:center;'>
Expand All @@ -139,7 +139,7 @@ String html_page_wifi = R"====(
)====";


String html_page_control = R"====(
const char html_page_control[] PROGMEM = R"====(
<body>
<script>
function $_GET(param) {
Expand Down Expand Up @@ -268,7 +268,7 @@ document.onreadystatechange = function(){

)====";

String html_page_advance = R"====(
const char html_page_advance[] PROGMEM = R"====(
<body>


Expand All @@ -295,13 +295,35 @@ String html_page_advance = R"====(
</select>
</p>
<p>
<b>Login Password</b>
<p><b>Password</b><br/><input id='lpw' name='lpw' type='password' placeholder=' ' value='_LOGIN_PASSWORD_'></p>
<p>Default user is <b>admin</b></p>
<p><b>Login Password</b><br/><input id='lpw' name='lpw' type='password' placeholder=' ' value='_LOGIN_PASSWORD_'></p>
<p>Note: Default login user is <b>admin</b></p>
</p>
<br/><button name='save' type='submit' class='button bgrn'>Save & Reboot</button>
</form>
</fieldset>
<p><form action='/setup' method='get'><button class="back">Back</button></form></p>

)====";

const char html_page_login[] PROGMEM = R"====(
<body>


<div style='text-align:left;display:inline-block;min-width:340px;'>
<div style='text-align:center;'>
<noscript>To user Mitsubishi2MQTT, you need to activate Javascript<br/></noscript>
<h3>_UNIT_NAME_</h3>
<fieldset>
<legend><b>&nbsp;LOGIN&nbsp;</b></legend>
<form action='/login' method='post'>
<p>To log in, please user : <b>admin</b> and password</p>
<p><b>User</b><input type='text' name='USERNAME' placeholder='user name'></p>
<p><b>Password</b><input type='password' name='PASSWORD' placeholder='password'></p>
<br/><button name='SUBMIT' type='submit' class='button bgrn'>SUBMIT</button>
</form><br>
You can go to <a href='/status'>status page</a><br>
<p>_LOGIN_MSG_</p>

</fieldset>

)====";
Loading

0 comments on commit 800c209

Please sign in to comment.