From 82aac08b7cf3c9f11a9228eb21bca6a9514eb162 Mon Sep 17 00:00:00 2001 From: masoud-iranmehr Date: Thu, 22 Oct 2020 21:48:20 -0700 Subject: [PATCH 1/5] change handle_getParameters() to show parameters in a valid format NOT RAW! --- src/mavesp8266_httpd.cpp | 108 ++++++++++++++++++++++++++++++---- src/mavesp8266_parameters.cpp | 6 ++ src/mavesp8266_parameters.h | 2 + 3 files changed, 103 insertions(+), 13 deletions(-) diff --git a/src/mavesp8266_httpd.cpp b/src/mavesp8266_httpd.cpp index efcb286..22a41b5 100644 --- a/src/mavesp8266_httpd.cpp +++ b/src/mavesp8266_httpd.cpp @@ -180,19 +180,101 @@ void handle_getParameters() String message = FPSTR(kHEADER); message += "

Parameters

"; for(int i = 0; i < MavESP8266Parameters::ID_COUNT; i++) { - message += ""; - unsigned long val = 0; - if(getWorld()->getParameters()->getAt(i)->type == MAV_PARAM_TYPE_UINT32) - val = (unsigned long)*((uint32_t*)getWorld()->getParameters()->getAt(i)->value); - else if(getWorld()->getParameters()->getAt(i)->type == MAV_PARAM_TYPE_UINT16) - val = (unsigned long)*((uint16_t*)getWorld()->getParameters()->getAt(i)->value); - else - val = (unsigned long)*((int8_t*)getWorld()->getParameters()->getAt(i)->value); - message += ""; + if(i == getWorld()->getParameters()->ID_FWVER) + { + message += ""; + message += ""; + } + else if(i == getWorld()->getParameters()->ID_MODE) + { + message += ""; + message += ""; + } + else if(i == getWorld()->getParameters()->ID_IPADDRESS) + { + message += ""; + message += ""; + } + else if(i == getWorld()->getParameters()->ID_SSID1) + { + message += ""; + message += ""; + } + else if(i > getWorld()->getParameters()->ID_SSID1 && i <= getWorld()->getParameters()->ID_SSID4) {} + else if(i == getWorld()->getParameters()->ID_PASS1) + { + message += ""; + message += ""; + } + else if(i > getWorld()->getParameters()->ID_PASS1 && i <= getWorld()->getParameters()->ID_PASS4) {} + else if(i == getWorld()->getParameters()->ID_SSIDSTA1) + { + message += ""; + message += ""; + } + else if(i > getWorld()->getParameters()->ID_SSIDSTA1 && i <= getWorld()->getParameters()->ID_SSIDSTA4) {} + else if(i == getWorld()->getParameters()->ID_PASSSTA1) + { + message += ""; + message += ""; + } + else if(i > getWorld()->getParameters()->ID_PASSSTA1 && i <= getWorld()->getParameters()->ID_PASSSTA4) {} + else // integer values + { + message += ""; + unsigned long val = 0; + if(getWorld()->getParameters()->getAt(i)->type == MAV_PARAM_TYPE_UINT32) + val = (unsigned long)*((uint32_t*)getWorld()->getParameters()->getAt(i)->value); + else if(getWorld()->getParameters()->getAt(i)->type == MAV_PARAM_TYPE_UINT16) + val = (unsigned long)*((uint16_t*)getWorld()->getParameters()->getAt(i)->value); + else + val = (unsigned long)*((int8_t*)getWorld()->getParameters()->getAt(i)->value); + + message += ""; + } } message += "
NameValue
"; - message += getWorld()->getParameters()->getAt(i)->id; - message += ""; - message += val; - message += "
"; + message += getWorld()->getParameters()->getAt(i)->id; + message += ""; + message += MAVESP8266_VERSION_MAJOR; + message += "."; + message += MAVESP8266_VERSION_MINOR; + message += "."; + message += MAVESP8266_VERSION_BUILD; + message += "
"; + message += getWorld()->getParameters()->getAt(i)->id; + message += ""; + if(getWorld()->getParameters()->getWifiMode() == WIFI_MODE_AP) + { + message += "AP"; + } + else + { + message += "STA"; + } + message += "
"; + message += getWorld()->getParameters()->getAt(i)->id; + message += ""; + message += getWorld()->getParameters()->getLocalIPAddressInString(); + message += "
"; + message += getWorld()->getParameters()->getAt(i)->id; + message += ""; + message += getWorld()->getParameters()->getWifiSsid(); + message += "
"; + message += getWorld()->getParameters()->getAt(i)->id; + message += ""; + message += getWorld()->getParameters()->getWifiPassword(); + message += "
"; + message += getWorld()->getParameters()->getAt(i)->id; + message += ""; + message += getWorld()->getParameters()->getWifiStaSsid(); + message += "
"; + message += getWorld()->getParameters()->getAt(i)->id; + message += ""; + message += getWorld()->getParameters()->getWifiStaPassword(); + message += "
"; + message += getWorld()->getParameters()->getAt(i)->id; + message += ""; + message += val; + message += "
"; message += ""; diff --git a/src/mavesp8266_parameters.cpp b/src/mavesp8266_parameters.cpp index 3062198..e955d42 100644 --- a/src/mavesp8266_parameters.cpp +++ b/src/mavesp8266_parameters.cpp @@ -65,6 +65,8 @@ uint32_t _wifi_subnetsta; uint32_t _uart_baud_rate; uint32_t _flash_left; +String _wifi_ip_addr_string; + //-- Parameters // No string support in parameters so we stash a char[16] into 4 uint32_t struct stMavEspParameters mavParameters[] = { @@ -152,6 +154,10 @@ uint32_t MavESP8266Parameters::getWifiStaGateway () { return _wifi_gatewaysta uint32_t MavESP8266Parameters::getWifiStaSubnet () { return _wifi_subnetsta; } uint32_t MavESP8266Parameters::getUartBaudRate () { return _uart_baud_rate; } +String MavESP8266Parameters::getLocalIPAddressInString() +{ + return(_wifi_ip_addr_string); +} //--------------------------------------------------------------------------------- //-- Reset all to defaults void diff --git a/src/mavesp8266_parameters.h b/src/mavesp8266_parameters.h index e613552..c7cd28b 100644 --- a/src/mavesp8266_parameters.h +++ b/src/mavesp8266_parameters.h @@ -113,6 +113,8 @@ class MavESP8266Parameters { uint32_t getWifiStaSubnet (); uint32_t getUartBaudRate (); + String getLocalIPAddressInString (); + void setDebugEnabled (int8_t enabled); void setWifiMode (int8_t mode); void setWifiChannel (uint32_t channel); From b1cb47f63d3d855d21e52bd6daa70af3fe68e44d Mon Sep 17 00:00:00 2001 From: Stavros Korokithakis Date: Sat, 2 Oct 2021 16:42:58 +0300 Subject: [PATCH 2/5] Extend password to 32 chars --- src/mavesp8266_parameters.cpp | 6 +++++- src/mavesp8266_parameters.h | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/mavesp8266_parameters.cpp b/src/mavesp8266_parameters.cpp index 3062198..c5c3eb7 100644 --- a/src/mavesp8266_parameters.cpp +++ b/src/mavesp8266_parameters.cpp @@ -58,7 +58,7 @@ uint32_t _wifi_ip_address; char _wifi_ssid[16]; char _wifi_password[16]; char _wifi_ssidsta[16]; -char _wifi_passwordsta[16]; +char _wifi_passwordsta[32]; uint32_t _wifi_ipsta; uint32_t _wifi_gatewaysta; uint32_t _wifi_subnetsta; @@ -91,6 +91,10 @@ uint32_t _flash_left; {"WIFI_PWDSTA2", &_wifi_passwordsta[4], MavESP8266Parameters::ID_PASSSTA2, sizeof(uint32_t), MAV_PARAM_TYPE_UINT32, false}, {"WIFI_PWDSTA3", &_wifi_passwordsta[8], MavESP8266Parameters::ID_PASSSTA3, sizeof(uint32_t), MAV_PARAM_TYPE_UINT32, false}, {"WIFI_PWDSTA4", &_wifi_passwordsta[12], MavESP8266Parameters::ID_PASSSTA4, sizeof(uint32_t), MAV_PARAM_TYPE_UINT32, false}, + {"WIFI_PWDSTA5", &_wifi_passwordsta[16], MavESP8266Parameters::ID_PASSSTA5, sizeof(uint32_t), MAV_PARAM_TYPE_UINT32, false}, + {"WIFI_PWDSTA6", &_wifi_passwordsta[20], MavESP8266Parameters::ID_PASSSTA6, sizeof(uint32_t), MAV_PARAM_TYPE_UINT32, false}, + {"WIFI_PWDSTA7", &_wifi_passwordsta[24], MavESP8266Parameters::ID_PASSSTA7, sizeof(uint32_t), MAV_PARAM_TYPE_UINT32, false}, + {"WIFI_PWDSTA8", &_wifi_passwordsta[28], MavESP8266Parameters::ID_PASSSTA8, sizeof(uint32_t), MAV_PARAM_TYPE_UINT32, false}, {"WIFI_IPSTA", &_wifi_ipsta, MavESP8266Parameters::ID_IPSTA, sizeof(uint32_t), MAV_PARAM_TYPE_UINT32, false}, {"WIFI_GATEWAYSTA", &_wifi_gatewaysta, MavESP8266Parameters::ID_GATEWAYSTA,sizeof(uint32_t), MAV_PARAM_TYPE_UINT32, false}, {"WIFI_SUBNET_STA", &_wifi_subnetsta, MavESP8266Parameters::ID_SUBNETSTA, sizeof(uint32_t), MAV_PARAM_TYPE_UINT32, false}, diff --git a/src/mavesp8266_parameters.h b/src/mavesp8266_parameters.h index e613552..b46b6f1 100644 --- a/src/mavesp8266_parameters.h +++ b/src/mavesp8266_parameters.h @@ -85,6 +85,10 @@ class MavESP8266Parameters { ID_PASSSTA2, ID_PASSSTA3, ID_PASSSTA4, + ID_PASSSTA5, + ID_PASSSTA6, + ID_PASSSTA7, + ID_PASSSTA8, ID_IPSTA, ID_GATEWAYSTA, ID_SUBNETSTA, From 05a007a9328a46b7d41cd405f590a56227ec3c33 Mon Sep 17 00:00:00 2001 From: Stavros Korokithakis Date: Sat, 2 Oct 2021 16:57:42 +0300 Subject: [PATCH 3/5] Make HTML responsive --- platformio.ini | 4 +--- src/mavesp8266_httpd.cpp | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/platformio.ini b/platformio.ini index a4a4e87..c3fe190 100644 --- a/platformio.ini +++ b/platformio.ini @@ -36,10 +36,8 @@ extra_scripts = pre:platformio_prebuild.py [env:esp12e] board = esp12e +upload_speed = 921600 build_flags = ${env.build_flags} -Wl,-Tesp8266.flash.4m.ld [env:esp01_1m] board = esp01_1m - -[env:esp01] -board = esp01 diff --git a/src/mavesp8266_httpd.cpp b/src/mavesp8266_httpd.cpp index efcb286..3ea4bb0 100644 --- a/src/mavesp8266_httpd.cpp +++ b/src/mavesp8266_httpd.cpp @@ -47,7 +47,7 @@ const char PROGMEM kTEXTPLAIN[] = "text/plain"; const char PROGMEM kTEXTHTML[] = "text/html"; const char PROGMEM kACCESSCTL[] = "Access-Control-Allow-Origin"; const char PROGMEM kUPLOADFORM[] = "

MAVLink WiFi Bridge


"; -const char PROGMEM kHEADER[] = "MavLink Bridge

MAVLink WiFi Bridge

"; +const char PROGMEM kHEADER[] = "MavLink Bridge

MAVLink WiFi Bridge

"; const char PROGMEM kBADARG[] = "BAD ARGS"; const char PROGMEM kAPPJSON[] = "application/json"; From b2299c9c6caf678d091e1877abe43d0d3a7d5c87 Mon Sep 17 00:00:00 2001 From: Stavros Korokithakis Date: Sat, 2 Oct 2021 17:18:10 +0300 Subject: [PATCH 4/5] Make uploading faster --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index c3fe190..3e81f08 100644 --- a/platformio.ini +++ b/platformio.ini @@ -31,12 +31,12 @@ platform = espressif8266@1.8.0 framework = arduino build_flags = !echo "-DPIO_SRC_REV="$(git rev-parse HEAD) "-DPIO_BUILD_DATE="$(date +%%Y-%%m-%%d) "-DPIO_BUILD_TIME="$(date +%%H:%%M:%%S) ${version_env.version_flags} extra_scripts = pre:platformio_prebuild.py +upload_speed = 921600 # Platform specific settings [env:esp12e] board = esp12e -upload_speed = 921600 build_flags = ${env.build_flags} -Wl,-Tesp8266.flash.4m.ld [env:esp01_1m] From 81d498b4538caf0a7519375bbfe29ccaeb06e00e Mon Sep 17 00:00:00 2001 From: Stavros Korokithakis Date: Sat, 2 Oct 2021 17:32:08 +0300 Subject: [PATCH 5/5] Add ESP8285 environment --- platformio.ini | 3 +++ 1 file changed, 3 insertions(+) diff --git a/platformio.ini b/platformio.ini index 3e81f08..9a01854 100644 --- a/platformio.ini +++ b/platformio.ini @@ -41,3 +41,6 @@ build_flags = ${env.build_flags} -Wl,-Tesp8266.flash.4m.ld [env:esp01_1m] board = esp01_1m + +[env:esp8285] +board = esp8285