From 7f59cd090466a0ecdf204f9fb917582c9f4a8675 Mon Sep 17 00:00:00 2001 From: Bogdan Pilyugin Date: Tue, 1 Aug 2023 15:59:16 +0200 Subject: [PATCH] wifi related rest api implemented --- include/SysConfiguration.h | 56 ++++++-------------------------------- src/RestApiHandler.c | 33 ++++++++++++++-------- 2 files changed, 30 insertions(+), 59 deletions(-) diff --git a/include/SysConfiguration.h b/include/SysConfiguration.h index cdca841..2f5d328 100644 --- a/include/SysConfiguration.h +++ b/include/SysConfiguration.h @@ -89,14 +89,7 @@ typedef struct char SntpServer3Adr[33]; struct { - char b1 :1; - char b2 :1; - char b3 :1; - char b4 :1; - char b5 :1; - char b6 :1; - char b7 :1; - char bIsGlobalEnabled :1; + bool bIsGlobalEnabled; } Flags1; } sntpClient; @@ -112,14 +105,7 @@ typedef struct char UserPass[32]; struct { - char b0 :1; - char b1 :1; - char b2 :1; - char b3 :1; - char b4 :1; - char b5 :1; - char b6 :1; - char bIsGlobalEnabled :1; + bool bIsGlobalEnabled; } Flags1; } mqttStation[CONFIG_WEBGUIAPP_MQTT_CLIENTS_NUM]; #endif @@ -137,14 +123,8 @@ typedef struct struct { - char bIsDHCPEnabled :1; - char b1 :1; - char b2 :1; - char b3 :1; - char b4 :1; - char b5 :1; - char b6 :1; - char bIsETHEnabled :1; + bool bIsDHCPEnabled; + bool bIsETHEnabled; } Flags1; // Flag structure } ethSettings; @@ -172,14 +152,8 @@ typedef struct struct { - char bIsDHCPEnabled :1; - char b1 :1; - char b2 :1; - char b3 :1; - char b4 :1; - char b5 :1; - char b6 :1; - char bIsWiFiEnabled :1; + bool bIsDHCPEnabled :1; + bool bIsWiFiEnabled :1; } Flags1; // Flag structure uint8_t MaxPower; } wifiSettings; @@ -197,14 +171,7 @@ typedef struct uint8_t MACAddr[6]; // MAC address struct { - char b0 :1; - char b1 :1; - char b2 :1; - char b3 :1; - char b4 :1; - char b5 :1; - char b6 :1; - char bIsGSMEnabled :1; + bool bIsGSMEnabled; } Flags1; // Flag structure } gsmSettings; @@ -218,14 +185,7 @@ typedef struct struct { - char b0 :1; - char b1 :1; - char b2 :1; - char b3 :1; - char b4 :1; - char b5 :1; - char b6 :1; - char bIsLoRaWANEnabled :1; + bool bIsLoRaWANEnabled; } Flags1; // Flag structure } lorawanSettings; diff --git a/src/RestApiHandler.c b/src/RestApiHandler.c index c41dce8..0d129ae 100644 --- a/src/RestApiHandler.c +++ b/src/RestApiHandler.c @@ -62,17 +62,28 @@ static void funct_wifiscanres(char *argres) const rest_var_t ConfigVariables[] = { { 0, "netname", &SysConfig.NetBIOSName, VAR_STRING, 3, 31 }, - { 1, "otaurl", &SysConfig.OTAURL, VAR_STRING, 3, 128 }, - { 2, "ledenab", &SysConfig.Flags1.bIsLedsEnabled, VAR_BOOL, 0, 1 }, - { 3, "otaint", &SysConfig.OTAAutoInt, VAR_INT, 0, 65535 }, - { 4, "time", &funct_time, VAR_FUNCT, 0, 0 }, - { 5, "addone", &funct_addone, VAR_FUNCT, 0, 0 }, - { 6, "wifiscan", &funct_wifiscan, VAR_FUNCT, 0, 0 }, - { 7, "wifiscanres", &funct_wifiscanres, VAR_FUNCT, 0, 0 }, - { 8, "wifi-sta-ip", &SysConfig.wifiSettings.InfIPAddr, VAR_IPADDR, 0, 0 }, - { 9, "wifi-ap-ip", &SysConfig.wifiSettings.ApIPAddr, VAR_IPADDR, 0, 0 }, - { 9, "wifi-sta-mask", &SysConfig.wifiSettings.InfMask, VAR_IPADDR, 0, 0 }, - { 9, "wifi-sta-gw", &SysConfig.wifiSettings.InfGateway, VAR_IPADDR, 0, 0 } + { 0, "otaurl", &SysConfig.OTAURL, VAR_STRING, 3, 128 }, + { 0, "ledenab", &SysConfig.Flags1.bIsLedsEnabled, VAR_BOOL, 0, 1 }, + { 0, "otaint", &SysConfig.OTAAutoInt, VAR_INT, 0, 65535 }, + { 0, "time", &funct_time, VAR_FUNCT, 0, 0 }, + { 0, "addone", &funct_addone, VAR_FUNCT, 0, 0 }, + + { 0, "wifiscan", &funct_wifiscan, VAR_FUNCT, 0, 0 }, + { 0, "wifiscanres", &funct_wifiscanres, VAR_FUNCT, 0, 0 }, + + { 0, "wifi-mode", &SysConfig.wifiSettings.WiFiMode, VAR_INT, 0, 0 }, + { 0, "wifi-sta-ip", &SysConfig.wifiSettings.InfIPAddr, VAR_IPADDR, 0, 0 }, + { 0, "wifi-sta-mask", &SysConfig.wifiSettings.InfMask, VAR_IPADDR, 0, 0 }, + { 0, "wifi-sta-gw", &SysConfig.wifiSettings.InfGateway, VAR_IPADDR, 0, 0 }, + { 0, "wifi-ap-ip", &SysConfig.wifiSettings.ApIPAddr, VAR_IPADDR, 0, 0 }, + { 0, "wifi-dns1", &SysConfig.wifiSettings.DNSAddr1, VAR_IPADDR, 0, 0 }, + { 0, "wifi-dns2", &SysConfig.wifiSettings.DNSAddr2, VAR_IPADDR, 0, 0 }, + { 0, "wifi-dns3", &SysConfig.wifiSettings.DNSAddr3, VAR_IPADDR, 0, 0 }, + { 0, "wifi-sta-ssid", &SysConfig.wifiSettings.InfSSID, VAR_STRING, 3, 31 }, + { 0, "wifi-sta-key", &SysConfig.wifiSettings.InfSSID, VAR_STRING, 8, 31 }, + { 0, "wifi-ap-ssid", &SysConfig.wifiSettings.InfSSID, VAR_STRING, 3, 31 }, + { 0, "wifi-ap-key", &SysConfig.wifiSettings.InfSSID, VAR_STRING, 8, 31 }, + };