Rolling - fixed IP

This commit is contained in:
jomjol
2020-12-06 21:13:27 +01:00
parent a8fb2e37d5
commit 793f928e6e
9 changed files with 92 additions and 11 deletions

View File

@@ -25,6 +25,14 @@ 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
@@ -32,12 +40,12 @@ A 3d-printable housing can be found here: https://www.thingiverse.com/thing:4571
* 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)
* Implementation of configuration editor (including basic and expert mode)
@@ -54,7 +62,6 @@ A 3d-printable housing can be found here: https://www.thingiverse.com/thing:4571
##### 4.0.0 Tflite Core - (2020-11-15)
* Implementation of rolling log-files

View File

@@ -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<string> 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;

View File

@@ -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();

View File

@@ -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)
{

View File

@@ -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";
const char* GIT_BRANCH="rolling";
const char* BUILD_TIME="2020-12-06 21:10";

View File

@@ -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";
const char* GIT_BRANCH="rolling";
const char* BUILD_TIME="2020-12-06 21:10";

Binary file not shown.

Binary file not shown.

View File

@@ -2,3 +2,11 @@ ssid = "SSID"
password = "PASSWORD"
hostname = "watermeter"
;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"