configuration page
This commit is contained in:
		
							parent
							
								
									1128de9297
								
							
						
					
					
						commit
						7ecd601073
					
				
					 16 changed files with 97 additions and 32 deletions
				
			
		|  | @ -259,6 +259,25 @@ void ota_begin() | |||
|     otabuffer+=String("Yes"); | ||||
|     otabuffer+=ota_part2_3+ota_part3; | ||||
|     otaserver.send(200, "text/html", otabuffer); }); | ||||
|   otaserver.on("/config", HTTP_GET, []() | ||||
|                { | ||||
|     otaserver.sendHeader("Connection", "close"); | ||||
|     String configbuffer = config_part1; | ||||
|     configbuffer += config_part1; | ||||
|     configbuffer+=config_txt_part1+"IP Address"+config_txt_part2+"text"+config_txt_part3+"dev_ip"+config_txt_part4+"dev_ip"+config_txt_part5+IP.toString()+config_txt_part6; | ||||
|     configbuffer+=config_txt_part1+"Network Mask"+config_txt_part2+"text"+config_txt_part3+"netmask"+config_txt_part4+"netmask"+config_txt_part5+IP.toString()+config_txt_part6; | ||||
|     configbuffer+=config_txt_part1+"Gateway"+config_txt_part2+"text"+config_txt_part3+"gateway"+config_txt_part4+"gateway"+config_txt_part5+GATEWAY.toString()+config_txt_part6; | ||||
|     configbuffer+=config_txt_part1+"DNS Server"+config_txt_part2+"text"+config_txt_part3+"dns"+config_txt_part4+"dns"+config_txt_part5+DNS.toString()+config_txt_part6; | ||||
|     configbuffer+=config_txt_part1+"Hostname"+config_txt_part2+"text"+config_txt_part3+"hostname"+config_txt_part4+"hostname"+config_txt_part5+String(HOSTNAME)+config_txt_part6; | ||||
|     configbuffer+=config_txt_part1+"BMS Server - IP Address"+config_txt_part2+"text"+config_txt_part3+"bms_ip"+config_txt_part4+"bms_ip"+config_txt_part5+MQTT_SERVER.toString()+config_txt_part6; | ||||
|     configbuffer+=config_txt_part1+"BMS Server - Port"+config_txt_part2+"text"+config_txt_part3+"bms_port"+config_txt_part4+"bms_port"+config_txt_part5+String(MQTT_PORT)+config_txt_part6; | ||||
|     configbuffer+=config_auth_part1+(MQTT_USE_AUTH?"yes":"no")+config_auth_part2; | ||||
|     configbuffer+=config_txt_part1+"BMS Server - Username"+config_txt_part2+"text"+config_txt_part3+"bms_username"+config_txt_part4+"bms_username"+config_txt_part5+String(MQTT_USERNAME)+config_txt_part6; | ||||
|     configbuffer+=config_txt_part1+"BMS Server - Password"+config_txt_part2+"password"+config_txt_part3+"bms_password"+config_txt_part4+"bms_password"+config_txt_part5+String(MQTT_PASSWORD)+config_txt_part6; | ||||
|     configbuffer+=config_txt_part1+"BMS Server - Endpoint"+config_txt_part2+"text"+config_txt_part3+"bms_endpoint"+config_txt_part4+"bms_endpoint"+config_txt_part5+String(MQTT_BASE_TOPIC)+config_txt_part6; | ||||
|     configbuffer+=config_part2; | ||||
|     otaserver.send(200, "text/html", configbuffer); }); | ||||
|    | ||||
|   otaserver.on( | ||||
|       "/update", HTTP_POST, []() | ||||
|       { | ||||
|  |  | |||
|  | @ -14,4 +14,35 @@ const String ota_part2_3 = { | |||
| }; | ||||
| const String ota_part3 = { | ||||
| #include "ota_html/ota-part3.html" | ||||
| }; | ||||
| 
 | ||||
| const String config_part1 = { | ||||
| #include "ota_html/config-part1.html" | ||||
| }; | ||||
| const String config_part2 = { | ||||
| #include "ota_html/config-part2.html" | ||||
| }; | ||||
| const String config_txt_part1 = { | ||||
| #include "ota_html/config-textfield-part1.html" | ||||
| }; | ||||
| const String config_txt_part2 = { | ||||
| #include "ota_html/config-textfield-part2.html" | ||||
| }; | ||||
| const String config_txt_part3 = { | ||||
| #include "ota_html/config-textfield-part3.html" | ||||
| }; | ||||
| const String config_txt_part4 = { | ||||
| #include "ota_html/config-textfield-part4.html" | ||||
| }; | ||||
| const String config_txt_part5 = { | ||||
| #include "ota_html/config-textfield-part5.html" | ||||
| }; | ||||
| const String config_txt_part6 = { | ||||
| #include "ota_html/config-textfield-part6.html" | ||||
| }; | ||||
| const String config_auth_part1 = { | ||||
| #include "ota_html/config-auth-part1.html" | ||||
| }; | ||||
| const String config_auth_part2 = { | ||||
| #include "ota_html/config-auth-part2.html" | ||||
| }; | ||||
|  | @ -5,3 +5,13 @@ extern const String ota_part2_1; | |||
| extern const String ota_part2_2; | ||||
| extern const String ota_part2_3; | ||||
| extern const String ota_part3; | ||||
| extern const String config_part1; | ||||
| extern const String config_part2; | ||||
| extern const String config_txt_part1; | ||||
| extern const String config_txt_part2; | ||||
| extern const String config_txt_part3; | ||||
| extern const String config_txt_part4; | ||||
| extern const String config_txt_part5; | ||||
| extern const String config_txt_part6; | ||||
| extern const String config_auth_part1; | ||||
| extern const String config_auth_part2; | ||||
|  |  | |||
							
								
								
									
										2
									
								
								src/ota_html/config-auth-part1.html
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								src/ota_html/config-auth-part1.html
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,2 @@ | |||
| R"=====(<label class="container">Authentication | ||||
|     <input type="checkbox" name="bms_useauth"  id="bms_useauth" checked="checked" value=")=====" | ||||
							
								
								
									
										3
									
								
								src/ota_html/config-auth-part2.html
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								src/ota_html/config-auth-part2.html
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,3 @@ | |||
| R"=====("> | ||||
|     <span class="checkmark"></span> | ||||
|   </label>)=====" | ||||
							
								
								
									
										4
									
								
								src/ota_html/config-part1.html
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								src/ota_html/config-part1.html
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,4 @@ | |||
| R"=====(<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> | ||||
| <form enctype="multipart/form-data" id="config_form" onsubmit="send_config()" action="/save_config"> | ||||
|   <h1>ESPMega PRO</h1> | ||||
|   <h3>Device Configurations</h3>)=====" | ||||
|  | @ -1,32 +1,5 @@ | |||
| <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> | ||||
| <form enctype="multipart/form-data" id="config_form" onsubmit="send_config()" action="/save_config"> | ||||
|   <h1>ESPMega PRO</h1> | ||||
|   <h3>Device Configurations</h3> | ||||
|   <p class="config_title">IP Address</p> | ||||
|   <input type="text" id="dev_ip" name="dev_ip" class="conf_txt" value="0.0.0.0"><br> | ||||
|   <p class="config_title">Network Mask</p> | ||||
|   <input type="text" id="netmask" name="netmask" class="conf_txt" value="0.0.0.0"><br> | ||||
|   <p class="config_title">Gateway</p> | ||||
|   <input type="text" id="gateway" name="gateway" class="conf_txt" value="0.0.0.0"><br> | ||||
|   <p class="config_title">DNS Server</p> | ||||
|   <input type="text" id="dns" name="dns" class="conf_txt" value="0.0.0.0"><br> | ||||
|   <p class="config_title">Hostname</p> | ||||
|   <input type="text" id="hostname" name="hostname" class="conf_txt" value="ESPMegaPRO"><br> | ||||
|   <p class="config_title">BMS Server - IP Address</p> | ||||
|   <input type="text" id="bms_ip" name="bms_ip" class="conf_txt" value="0.0.0.0"><br> | ||||
|   <p class="config_title">BMS Server - Port</p> | ||||
|   <input type="text" id="bms_port" name="bms_port" class="conf_txt" value="1883"><br> | ||||
|   <label class="container">Authentication | ||||
|     <input type="checkbox" name="bms_useauth"  id="bms_useauth" checked="checked" value="yes"> | ||||
|     <span class="checkmark"></span> | ||||
|   </label> | ||||
|   <p class="config_title">BMS Server - Username</p> | ||||
|   <input type="text" id="bms_username" name="bms_username" class="conf_txt" value="user"><br> | ||||
|   <p class="config_title">BMS Server - Password</p> | ||||
|   <input type="password" id="bms_password" name="bms_password" class="conf_txt" value="password"><br> | ||||
|   <p class="config_title">BMS Server - Endpoint</p> | ||||
|   <input type="text" id="bms_endpoint" name="bms_endpoint" class="conf_txt" value="/espmegapro"><br> | ||||
|   <input type="submit" class="btn" value="Save"> | ||||
| R"=====(  <input type="submit" class="btn" value="Save"> | ||||
|   <button type="button" class="conf" onclick="window.location.href='/'">Back</button><br /><br /> | ||||
|   <b>SIWAT SYSTEM 2023</b> | ||||
| </form> | ||||
| <style> | ||||
|  | @ -117,6 +90,12 @@ | |||
|     background: #417df3; | ||||
|     color: #fff; | ||||
|     cursor: pointer; | ||||
|     width: 100%; | ||||
|     height: 44px; | ||||
|     border-radius: 4px; | ||||
|     margin: 10px auto; | ||||
|     font-size: 15px; | ||||
|     border: 0; | ||||
|   } | ||||
|   .conf_txt { | ||||
|     background-color: #e2e2e2; | ||||
|  | @ -185,4 +164,4 @@ | |||
|   -ms-transform: rotate(45deg); | ||||
|   transform: rotate(45deg); | ||||
| } | ||||
| </style> | ||||
| </style>)=====" | ||||
							
								
								
									
										1
									
								
								src/ota_html/config-textfield-part1.html
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								src/ota_html/config-textfield-part1.html
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1 @@ | |||
| R"=====(<p class="config_title">)=====" | ||||
							
								
								
									
										2
									
								
								src/ota_html/config-textfield-part2.html
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								src/ota_html/config-textfield-part2.html
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,2 @@ | |||
| R"=====(</p> | ||||
|   <input type=")=====" | ||||
							
								
								
									
										1
									
								
								src/ota_html/config-textfield-part3.html
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								src/ota_html/config-textfield-part3.html
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1 @@ | |||
| R"=====(" id=")=====" | ||||
							
								
								
									
										1
									
								
								src/ota_html/config-textfield-part4.html
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								src/ota_html/config-textfield-part4.html
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1 @@ | |||
| R"=====(" name=")=====" | ||||
							
								
								
									
										1
									
								
								src/ota_html/config-textfield-part5.html
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								src/ota_html/config-textfield-part5.html
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1 @@ | |||
| R"=====(" class="conf_txt" value=")=====" | ||||
							
								
								
									
										1
									
								
								src/ota_html/config-textfield-part6.html
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								src/ota_html/config-textfield-part6.html
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1 @@ | |||
| R"=====("><br>)=====" | ||||
|  | @ -27,9 +27,13 @@ | |||
|   <p class="config_title">BMS Server - Endpoint</p> | ||||
|   <input type="text" id="bms_endpoint" name="bms_endpoint" class="conf_txt" value="/espmegapro"><br> | ||||
|   <input type="submit" class="btn" value="Save"> | ||||
|   <button type="button" class="conf" onclick="window.location.href='/'">Back</button><br /><br /> | ||||
|   <b>SIWAT SYSTEM 2023</b> | ||||
| </form> | ||||
| <style> | ||||
|    | ||||
| 
 | ||||
|    | ||||
|   p.config_title { | ||||
|     font-size: 12; | ||||
|     font-weight: bold; | ||||
|  | @ -117,6 +121,12 @@ | |||
|     background: #417df3; | ||||
|     color: #fff; | ||||
|     cursor: pointer; | ||||
|     width: 100%; | ||||
|     height: 44px; | ||||
|     border-radius: 4px; | ||||
|     margin: 10px auto; | ||||
|     font-size: 15px; | ||||
|     border: 0; | ||||
|   } | ||||
|   .conf_txt { | ||||
|     background-color: #e2e2e2; | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| R"=====(<button type="button" class="conf" onclick="window.location.href='config.html'">Settings</button><br /><br /> | ||||
| R"=====(<button type="button" class="conf" onclick="window.location.href='config'">Settings</button><br /><br /> | ||||
|   <hr> | ||||
|   <h3>Upload Software Package</h3> | ||||
|   <input type="file" name="update" id="file" onchange="sub(this)" style="display: none" /> | ||||
|  |  | |||
|  | @ -30,7 +30,7 @@ | |||
|     Centrally Managed | ||||
|     <span style="float: right">Yes</span> | ||||
|   </p> | ||||
|   <button type="button" class="conf" onclick="window.location.href='config.html'">Settings</button><br /><br /> | ||||
|   <button type="button" class="conf" onclick="window.location.href='config'">Settings</button><br /><br /> | ||||
|   <hr> | ||||
|   <h3>Upload Software Package</h3> | ||||
|   <input type="file" name="update" id="file" onchange="sub(this)" style="display: none" /> | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue