diff --git a/README.md b/README.md index 0a71ef45..42ecb4b9 100644 --- a/README.md +++ b/README.md @@ -25,18 +25,26 @@ A 3d-printable housing can be found here: https://www.thingiverse.com/thing:4571 **General remark:** Beside the `firmware.bin`, typically also the content of `/html` needs to be updated! +##### Rolling - (2020-12-06) + +* Option for fixed IP settings in `wlan.ini` - description see inside file + +* based on v5.0.05 (2020-12-06) + + + ##### 5.0.0 Setup Modus - (2020-12-06) * Implementation of intial setup modus for fresh installation * Code restructuring (full compatibility between pure ESP-IDF and Platformio w/ espressif) + ##### 4.1.1 Configuration editor - (2020-12-02) * Bug fixing: internal improvement of file handling (reduce not responding) - ##### 4.1.0 Configuration editor - (2020-11-30) @@ -52,7 +60,6 @@ A 3d-printable housing can be found here: https://www.thingiverse.com/thing:4571 * Bug fixing: truncation error, CheckDigitConsistency & PreValue implementation - ##### 4.0.0 Tflite Core - (2020-11-15) diff --git a/code/components/connect_wlan/connect_wlan.cpp b/code/components/connect_wlan/connect_wlan.cpp index 432d9698..0e75413e 100644 --- a/code/components/connect_wlan/connect_wlan.cpp +++ b/code/components/connect_wlan/connect_wlan.cpp @@ -319,6 +319,71 @@ void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphra } } +void LoadNetConfigFromFile(std::string fn, std::string &_ip, std::string &_gw, std::string &_netmask, std::string &_dns) +{ + string line = ""; + std::vector zerlegt; + + FILE* pFile; + fn = FormatFileName(fn); + pFile = fopen(fn.c_str(), "r"); + + printf("file loaded\n"); + + if (pFile == NULL) + return; + + char zw[1024]; + fgets(zw, 1024, pFile); + line = std::string(zw); + + while ((line.size() > 0) || !(feof(pFile))) + { + printf("%s", line.c_str()); + zerlegt = ZerlegeZeile(line, "="); + zerlegt[0] = trim(zerlegt[0], " "); + + if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "IP")){ + _ip = zerlegt[1]; + if ((_ip[0] == '"') && (_ip[_ip.length()-1] == '"')){ + _ip = _ip.substr(1, _ip.length()-2); + } + } + + if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "GATEWAY")){ + _gw = zerlegt[1]; + if ((_gw[0] == '"') && (_gw[_gw.length()-1] == '"')){ + _gw = _gw.substr(1, _gw.length()-2); + } + } + + if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "NETMASK")){ + _netmask = zerlegt[1]; + if ((_netmask[0] == '"') && (_netmask[_netmask.length()-1] == '"')){ + _netmask = _netmask.substr(1, _netmask.length()-2); + } + } + + if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "DNS")){ + _dns = zerlegt[1]; + if ((_dns[0] == '"') && (_dns[_dns.length()-1] == '"')){ + _dns = _dns.substr(1, _dns.length()-2); + } + } + + if (fgets(zw, 1024, pFile) == NULL) + { + line = ""; + } + else + { + line = std::string(zw); + } + } + + fclose(pFile); +} + std::string getHostname(){ return hostname; diff --git a/code/components/connect_wlan/connect_wlan.h b/code/components/connect_wlan/connect_wlan.h index 6e707d0f..066901ed 100644 --- a/code/components/connect_wlan/connect_wlan.h +++ b/code/components/connect_wlan/connect_wlan.h @@ -11,7 +11,7 @@ void initialise_wifi_fixed_ip(std::string _ip, std::string _gw, std::string _net void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphrase, std::string &_hostname); -void LoadNetConfigFromFile(std::string &_ip, std::string &_gw, std::string &_netmask, std::string &_dns); +void LoadNetConfigFromFile(std::string fn, std::string &_ip, std::string &_gw, std::string &_netmask, std::string &_dns); std::string getHostname(); std::string getIPAddress(); diff --git a/code/main/main.cpp b/code/main/main.cpp index 11b26e79..b44e58c3 100644 --- a/code/main/main.cpp +++ b/code/main/main.cpp @@ -88,11 +88,12 @@ extern "C" void app_main(void) // LoadWlanFromFile("/sdcard/wlan.ini", ssid, password, hostname, ip, gw, netmask, dns); LoadWlanFromFile("/sdcard/wlan.ini", ssid, password, hostname); + LoadNetConfigFromFile("/sdcard/wlan.ini", ip, gw, netmask, dns); // LogFile.WriteToFile("Startsequence 04"); printf("To use WLan: %s, %s\n", ssid.c_str(), password.c_str()); printf("To set Hostename: %s\n", hostname.c_str()); - printf("Fixed IP: %s, Gateway %s, Netmask %s\n", ip.c_str(), gw.c_str(), netmask.c_str()); + printf("Fixed IP: %s, Gateway %s, Netmask %s, DNS %s\n", ip.c_str(), gw.c_str(), netmask.c_str(), dns.c_str()); if (ip.length() == 0 || gw.length() == 0 || netmask.length() == 0) { diff --git a/code/main/version.cpp b/code/main/version.cpp index 20df4b18..8fe82fff 100644 --- a/code/main/version.cpp +++ b/code/main/version.cpp @@ -1,4 +1,4 @@ -const char* GIT_REV="bcdd0c6"; +const char* GIT_REV="a8fb2e3"; const char* GIT_TAG=""; -const char* GIT_BRANCH="master"; -const char* BUILD_TIME="2020-12-06 19:32"; \ No newline at end of file +const char* GIT_BRANCH="rolling"; +const char* BUILD_TIME="2020-12-06 21:10"; \ No newline at end of file diff --git a/code/version.cpp b/code/version.cpp index 20df4b18..8fe82fff 100644 --- a/code/version.cpp +++ b/code/version.cpp @@ -1,4 +1,4 @@ -const char* GIT_REV="bcdd0c6"; +const char* GIT_REV="a8fb2e3"; const char* GIT_TAG=""; -const char* GIT_BRANCH="master"; -const char* BUILD_TIME="2020-12-06 19:32"; \ No newline at end of file +const char* GIT_BRANCH="rolling"; +const char* BUILD_TIME="2020-12-06 21:10"; \ No newline at end of file diff --git a/firmware/bootloader.bin b/firmware/bootloader.bin index ce3a6d8f..94019446 100644 Binary files a/firmware/bootloader.bin and b/firmware/bootloader.bin differ diff --git a/firmware/firmware.bin b/firmware/firmware.bin index 8a751444..dc33e4dd 100644 Binary files a/firmware/firmware.bin and b/firmware/firmware.bin differ diff --git a/sd-card/wlan.ini b/sd-card/wlan.ini index fac2d609..ad22bba3 100644 --- a/sd-card/wlan.ini +++ b/sd-card/wlan.ini @@ -1,4 +1,12 @@ ssid = "SSID" password = "PASSWORD" hostname = "watermeter" -;hostname is optional \ No newline at end of file +;hostname is optional + +;if you want to use a fixed IP you need to specify the following 3 parameters (ip, gateway, netmask) with IP4-Addresses "123.456.789.012" +ip = "IP4-ADDRESS" +gateway = "IP4-ADDRESS" +netmask = "255.255.255.0" + +;in some cases you want to specify the DNS server as well (especially, if it is not identical to the gateway - this is optional for a fixed IP +dns = "IP4-ADDRESS" \ No newline at end of file