diff --git a/include/SysConfiguration.h b/include/SysConfiguration.h index 66f11b5..39bbc11 100644 --- a/include/SysConfiguration.h +++ b/include/SysConfiguration.h @@ -186,6 +186,10 @@ typedef struct bool bIsGSMEnabled; } Flags1; // Flag structure + char APN[32]; + char login[32]; + char password[32]; + } gsmSettings; #endif diff --git a/src/GSMTransport.c b/src/GSMTransport.c index b2c8ab9..5e383aa 100644 --- a/src/GSMTransport.c +++ b/src/GSMTransport.c @@ -188,7 +188,7 @@ static void GSMInitTask(void *pvParameter) dte_config.task_priority = CONFIG_MODEM_UART_EVENT_TASK_PRIORITY; dte_config.dte_buffer_size = CONFIG_MODEM_UART_RX_BUFFER_SIZE / 2; /* Configure the DCE */ - esp_modem_dce_config_t dce_config = ESP_MODEM_DCE_DEFAULT_CONFIG(CONFIG_MODEM_PPP_APN); + esp_modem_dce_config_t dce_config = ESP_MODEM_DCE_DEFAULT_CONFIG(GetSysConf()->gsmSettings.APN); /* Configure the PPP netif */ esp_netif_inherent_config_t esp_netif_conf = ESP_NETIF_INHERENT_DEFAULT_PPP(); @@ -196,6 +196,7 @@ static void GSMInitTask(void *pvParameter) esp_netif_config_t netif_ppp_config = ESP_NETIF_DEFAULT_PPP(); netif_ppp_config.base = &esp_netif_conf; + /* Init netif object */ ppp_netif = esp_netif_new(&netif_ppp_config); assert(ppp_netif); diff --git a/src/RestApiHandler.c b/src/RestApiHandler.c index c0415a6..9b904ab 100644 --- a/src/RestApiHandler.c +++ b/src/RestApiHandler.c @@ -474,6 +474,9 @@ const rest_var_t SystemVariables[] = #if CONFIG_WEBGUIAPP_GPRS_ENABLE { 0, "gsm_enab", &SysConfig.gsmSettings.Flags1.bIsGSMEnabled, VAR_BOOL, RW, 0, 1 }, + { 0, "gsm_apn", &SysConfig.gsmSettings.APN, VAR_STRING, RW, 3, 31 }, + { 0, "gsm_apn_login", &SysConfig.gsmSettings.login, VAR_STRING, RW, 3, 31 }, + { 0, "gsm_apn_password", &SysConfig.gsmSettings.password, VAR_STRING, RW, 3, 31 }, { 0, "gsm_module", &funct_gsm_module, VAR_FUNCT, R, 0, 0 }, { 0, "gsm_operator", &funct_gsm_operator, VAR_FUNCT, R, 0, 0 }, { 0, "gsm_imei", &funct_gsm_imei, VAR_FUNCT, R, 0, 0 }, diff --git a/src/SysConfiguration.c b/src/SysConfiguration.c index 920a08b..c0758fc 100644 --- a/src/SysConfiguration.c +++ b/src/SysConfiguration.c @@ -334,6 +334,10 @@ esp_netif_str_to_ip4(CONFIG_WEBGUIAPP_DNS3_ADDRESS_DEFAULT, (esp_ip4_addr_t*) &C #if CONFIG_WEBGUIAPP_GPRS_ENABLE Conf->gsmSettings.Flags1.bIsGSMEnabled = true; +memcpy(Conf->gsmSettings.APN, CONFIG_MODEM_PPP_APN,sizeof(CONFIG_MODEM_PPP_APN)); +memcpy(Conf->gsmSettings.login, CONFIG_MODEM_PPP_APN,sizeof(CONFIG_MODEM_PPP_APN)); +memcpy(Conf->gsmSettings.password, CONFIG_MODEM_PPP_APN,sizeof(CONFIG_MODEM_PPP_APN)); + esp_netif_str_to_ip4(CONFIG_WEBGUIAPP_DNS1_ADDRESS_DEFAULT, (esp_ip4_addr_t*) &Conf->gsmSettings.DNSAddr1); esp_netif_str_to_ip4(CONFIG_WEBGUIAPP_DNS2_ADDRESS_DEFAULT, (esp_ip4_addr_t*) &Conf->gsmSettings.DNSAddr2); esp_netif_str_to_ip4(CONFIG_WEBGUIAPP_DNS3_ADDRESS_DEFAULT, (esp_ip4_addr_t*) &Conf->gsmSettings.DNSAddr3);