From d276e6d255d480a68bbc08cbfff26ea065b18c17 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Tue, 8 Oct 2024 23:32:37 +0700 Subject: [PATCH] initial network config --- .../lib/ESPMegaPRO/ESPMegaCommon.hpp | 2 +- ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaIoT.cpp | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaCommon.hpp b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaCommon.hpp index 59e98d2..9b29fe3 100644 --- a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaCommon.hpp +++ b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaCommon.hpp @@ -1,3 +1,3 @@ #pragma once -#define SDK_VESRION "2.9.5" \ No newline at end of file +#define SDK_VESRION "2.9.6" \ No newline at end of file diff --git a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaIoT.cpp b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaIoT.cpp index 51ffd56..04c55d8 100644 --- a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaIoT.cpp +++ b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaIoT.cpp @@ -625,6 +625,21 @@ void ESPMegaIoT::loadNetworkConfig() network_config.wifiUseAuth = fram->read8(IOT_FRAM_ADDRESS + 54); fram->read(IOT_FRAM_ADDRESS + 55, (uint8_t *)network_config.ssid, 32); fram->read(IOT_FRAM_ADDRESS + 87, (uint8_t *)network_config.password, 32); + + // If ip,gateway,subnet,dns1,dns2 is 0, the device is not configured + // set to default values + // ip: 192.168.0.99 + // gateway: 192.168.0.1 + // subnet: 255.255.255.0 + // dns1: 1.1.1.1 + // dns2: 9.9.9.9 + if (network_config.ip == 0 && network_config.gateway == 0 && network_config.subnet == 0 && network_config.dns1 == 0 && network_config.dns2 == 0) + { + network_config.ip = IPAddress(192, 168, 0, 99); + network_config.gateway = IPAddress(192, 168, 0, 1); + network_config.subnet = IPAddress(255, 255, 255, 0); + network_config.dns1 = IPAddress(1, 1, 1, 1); + } } /**