diff --git a/CMakeLists.txt b/CMakeLists.txt index d37a744..1f2a35a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,10 +2,12 @@ include(${CMAKE_CURRENT_LIST_DIR}/extlibs/jReadWrite/include.cmake) include(${CMAKE_CURRENT_LIST_DIR}/extlibs/libespfs/cmake/include.cmake) if(CONFIG_WEBGUIAPP_LORAWAN_ENABLE) -include(${CMAKE_CURRENT_LIST_DIR}/extlibs/ttn-esp32/include.cmake) - set(lora_SRCS "lorawan/LoRaWAN.c") + set(lora_SRCS "src/LoRaWAN.c") endif() +if(CONFIG_WEBGUIAPP_GPRS_ENABLE) + set(gprs_SRCS "src/GSMTransport.c") +endif() idf_component_register( @@ -13,16 +15,17 @@ idf_component_register( INCLUDE_DIRS ${jreadwrite_INCLUDE_DIRS} SRCS ${lora_SRCS} - SRC_DIRS ${lora_SRC_DIRS} - PRIV_REQUIRES ${lora_PRIV_REQUIRES} - INCLUDE_DIRS ${lora_INCLUDE_DIRS} + REQUIRES ttn-esp32 + + SRCS ${gprs_SRCS} + REQUIRES esp_modem SRCS ${libespfs_SRCS} INCLUDE_DIRS ${libespfs_INCLUDE_DIRS} PRIV_INCLUDE_DIRS ${libespfs_PRIV_INCLUDE_DIRS} PRIV_REQUIRES ${libespfs_PRIV_REQUIRES} - SRCS "src/SystemConfiguration.c" + SRCS "src/WebGUIAppMain.c" "src/romfs.c" "src/spifs.c" "src/HTTPServer.c" @@ -32,7 +35,6 @@ idf_component_register( "src/Helpers.c" "src/NetTransport.c" "src/WiFiTransport.c" - "src/GSMTransport.c" "src/ETHTransport.c" "src/SNTP.c" "src/MQTT.c" @@ -44,9 +46,6 @@ idf_component_register( "include" "src" "extlibs/jReadWrite" - - - EMBED_FILES "upload_script.html" REQUIRES nvs_flash spiffs @@ -54,10 +53,9 @@ idf_component_register( mbedtls lwip mqtt - esp_modem esp_https_ota app_update - + EMBED_FILES "upload_script.html" ) \ No newline at end of file diff --git a/include/HTTPServer.h b/include/HTTPServer.h index 6257e16..41fd938 100644 --- a/include/HTTPServer.h +++ b/include/HTTPServer.h @@ -34,7 +34,6 @@ #include #include "Helpers.h" -#include "SystemConfiguration.h" #include "romfs.h" #include "NetTransport.h" @@ -42,6 +41,7 @@ #include "esp_netif.h" #include "esp_eth.h" #include "mbedtls/base64.h" +#include "WebGUIAppMain.h" #define MAX_DYNVAR_NAME_LENGTH 32 #define MAX_DYNVAR_LENGTH 256 diff --git a/include/SystemConfiguration.h b/include/WebGUIAppMain.h similarity index 100% rename from include/SystemConfiguration.h rename to include/WebGUIAppMain.h diff --git a/src/ETHTransport.c b/src/ETHTransport.c index f973480..2ce7929 100644 --- a/src/ETHTransport.c +++ b/src/ETHTransport.c @@ -19,9 +19,9 @@ * Description: */ -#include "SystemConfiguration.h" #include #include +#include #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "esp_netif.h" diff --git a/src/GSMTransport.c b/src/GSMTransport.c index 3636f74..aeea2a0 100644 --- a/src/GSMTransport.c +++ b/src/GSMTransport.c @@ -20,6 +20,8 @@ */ #include + +#include "../include/WebGUIAppMain.h" #include "freertos/FreeRTOS.h" #include "freertos/event_groups.h" #include "freertos/task.h" @@ -29,7 +31,6 @@ #include "esp_modem_api.h" #include "esp_log.h" #include "driver/gpio.h" -#include "SystemConfiguration.h" #include "NetTransport.h" #if CONFIG_WEBGUIAPP_GPRS_ENABLE diff --git a/src/HTTPPrintSystem.c b/src/HTTPPrintSystem.c index 169e61e..de694b3 100644 --- a/src/HTTPPrintSystem.c +++ b/src/HTTPPrintSystem.c @@ -397,13 +397,12 @@ static void HTTPPrint_emacadr(char *VarData, void *arg) #endif +#if CONFIG_WEBGUIAPP_GPRS_ENABLE +/*GSM MODEM*/ void HTTPPrint_gsmstat(char *VarData, void *arg) { PrintInterfaceState(VarData, arg, GetPPPNetifAdapter()); } - -#if CONFIG_WEBGUIAPP_GPRS_ENABLE -/*GSM MODEM*/ void HTTPPrint_gsmen(char *VarData, void *arg) { PrintCheckbox(VarData, arg, GetSysConf()->gsmSettings.Flags1.bIsGSMEnabled); @@ -720,12 +719,12 @@ dyn_var_handler_t HANDLERS_ARRAY[] = { { "emacadr", sizeof("emacadr") - 1, &HTTPPrint_emacadr }, #endif - { "gsmstat", sizeof("gsmstat") - 1, &HTTPPrint_gsmstat }, + #if CONFIG_WEBGUIAPP_GPRS_ENABLE /*GSM modem*/ { "gsmen", sizeof("gsmen") - 1, &HTTPPrint_gsmen }, - + { "gsmstat", sizeof("gsmstat") - 1, &HTTPPrint_gsmstat }, { "gsmmod", sizeof("gsmmod") - 1, &HTTPPrint_gsmmod }, { "gsmopr", sizeof("gsmopr") - 1, &HTTPPrint_gsmopr }, { "gimei", sizeof("gimei") - 1, &HTTPPrint_gimei }, diff --git a/lorawan/LoRaWAN.c b/src/LoRaWAN.c similarity index 99% rename from lorawan/LoRaWAN.c rename to src/LoRaWAN.c index 4ce1a99..e661972 100644 --- a/lorawan/LoRaWAN.c +++ b/src/LoRaWAN.c @@ -25,10 +25,10 @@ #include "freertos/task.h" #include "driver/gpio.h" #include "Helpers.h" -#include "SystemConfiguration.h" #include "NetTransport.h" #include "webguiapp.h" #include "LoRaWAN.h" +#include "../include/WebGUIAppMain.h" // Pins and other resources /*Defined in global configuration*/ diff --git a/src/MQTT.c b/src/MQTT.c index c2d19cd..c0f6c5b 100644 --- a/src/MQTT.c +++ b/src/MQTT.c @@ -18,10 +18,9 @@ * Author: Bogdan Pilyugin * Description: */ +#include #include "esp_log.h" #include "Helpers.h" -#include "SystemConfiguration.h" - #include "NetTransport.h" #include "MQTT.h" diff --git a/src/NetTransport.c b/src/NetTransport.c index 057244b..f225d70 100644 --- a/src/NetTransport.c +++ b/src/NetTransport.c @@ -19,8 +19,8 @@ * Description: */ +#include #include "NetTransport.h" -#include "SystemConfiguration.h" #include "sdkconfig.h" #include "lwip/netif.h" diff --git a/src/OTA.c b/src/OTA.c index 0c57996..5e6ce96 100644 --- a/src/OTA.c +++ b/src/OTA.c @@ -29,10 +29,10 @@ #include "esp_https_ota.h" #include #include "sdkconfig.h" -#include "SystemConfiguration.h" #include "romfs.h" #include +#include #include "NetTransport.h" TaskHandle_t ota_task_handle; diff --git a/src/SystemConfiguration.c b/src/WebGUIAppMain.c similarity index 98% rename from src/SystemConfiguration.c rename to src/WebGUIAppMain.c index f08bf39..261b661 100644 --- a/src/SystemConfiguration.c +++ b/src/WebGUIAppMain.c @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * \file SystemConfiguration.c + * \file WebGUIAppMain.c * \version 1.0 * \date 2022-08-13 * \author Bogdan Pilyugin @@ -21,6 +21,8 @@ * \copyright Apache License, Version 2.0 */ +#include "WebGUIAppMain.h" + #include #include "stdlib.h" #include "string.h" @@ -31,7 +33,6 @@ #include "driver/adc.h" #include "driver/i2c.h" -#include "SystemConfiguration.h" #include "romfs.h" #include "spifs.h" #include "NetTransport.h" @@ -167,9 +168,16 @@ esp_err_t WebGuiAppInit(void) { //start all services /*Wait for interfaces connected*/ - while (!(isPPPConnected() || + while (!( +#ifdef CONFIG_WEBGUIAPP_GPRS_ENABLE + isPPPConnected() || +#endif +#ifdef CONFIG_WEBGUIAPP_WIFI_ENABLE isWIFIConnected() || +#endif +#ifdef CONFIG_WEBGUIAPP_ETHERNET_ENABLE isETHConnected() || +#endif ++NetworkStartTimeout >= NETWORK_START_TIMEOUT)) vTaskDelay(pdMS_TO_TICKS(1000)); diff --git a/src/WiFiTransport.c b/src/WiFiTransport.c index e6d695b..dfb2a44 100644 --- a/src/WiFiTransport.c +++ b/src/WiFiTransport.c @@ -19,7 +19,7 @@ * Description: */ -#include "SystemConfiguration.h" +#include #include "esp_log.h" #include "Helpers.h" #include "esp_system.h"