Prepare for v5.0.0

This commit is contained in:
jomjol
2020-12-06 19:28:17 +01:00
parent f616643335
commit e988215d8a
9 changed files with 45 additions and 42 deletions

View File

@@ -25,25 +25,11 @@ 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! **General remark:** Beside the `firmware.bin`, typically also the content of `/html` needs to be updated!
##### Rolling - (2020-12-06) ##### 5.0.0 Setup Modus - (2020-12-06)
* Update of the initial setup routine * Implementation of intial setup modus for fresh installation
* frequent time synchronization
2020-12-04
* Implementation of a setup modus at the beginning of a new installation. It guides the user through a check of the parameters and setting and disables at the end automatically.
Special modus is entered if `SetupMode=true` in section `[System]`
* Bug fix: wrong rounding in case of no analog counters and decimal shift
2020-12-03
* Move source code to `/main` to full compatibility between pure ESP-IDF and Platformio w/ espressif
* based on Main v4.1.1 (2020-12-02)
* Code restructuring (full compatibility between pure ESP-IDF and Platformio w/ espressif)
##### 4.1.1 Configuration editor - (2020-12-02) ##### 4.1.1 Configuration editor - (2020-12-02)

View File

@@ -29,6 +29,7 @@ std::string hostname;
std::string ipaddress; std::string ipaddress;
std::string gw; std::string gw;
std::string netmask; std::string netmask;
std::string dns;
std::string std_hostname = "watermeter"; std::string std_hostname = "watermeter";
@@ -146,12 +147,13 @@ void strinttoip4(std::string ip, int &a, int &b, int &c, int &d) {
s >> a >> ch >> b >> ch >> c >> ch >> d; s >> a >> ch >> b >> ch >> c >> ch >> d;
} }
void initialise_wifi_fixed_ip(std::string _ip, std::string _gw, std::string _netmask, std::string _ssid, std::string _passphrase, std::string _hostname) void initialise_wifi_fixed_ip(std::string _ip, std::string _gw, std::string _netmask, std::string _ssid, std::string _passphrase, std::string _hostname, std::string _dns)
{ {
ssid = _ssid; ssid = _ssid;
passphrase = _passphrase; passphrase = _passphrase;
hostname = _hostname; hostname = _hostname;
dns = _dns;
wifi_event_group = xEventGroupCreate(); wifi_event_group = xEventGroupCreate();
@@ -180,12 +182,16 @@ void initialise_wifi_fixed_ip(std::string _ip, std::string _gw, std::string _net
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&cfg)); ESP_ERROR_CHECK(esp_wifi_init(&cfg));
if (dns.length() > 0) {
esp_netif_dns_info_t dns_info;
ip4_addr_t ip;
ip.addr = esp_ip4addr_aton(dns.c_str());
ip_addr_set_ip4_u32(&dns_info.ip, ip.addr);
ESP_ERROR_CHECK(esp_netif_set_dns_info(my_sta, ESP_NETIF_DNS_MAIN, &dns_info));
}
ESP_ERROR_CHECK(esp_event_loop_init(event_handler, NULL) ); ESP_ERROR_CHECK(esp_event_loop_init(event_handler, NULL) );
// ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL));
// ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &event_handler, NULL));
wifi_config_t wifi_config = { }; wifi_config_t wifi_config = { };
strcpy((char*)wifi_config.sta.ssid, (const char*)ssid.c_str()); strcpy((char*)wifi_config.sta.ssid, (const char*)ssid.c_str());
strcpy((char*)wifi_config.sta.password, (const char*)passphrase.c_str()); strcpy((char*)wifi_config.sta.password, (const char*)passphrase.c_str());
@@ -198,12 +204,6 @@ void initialise_wifi_fixed_ip(std::string _ip, std::string _gw, std::string _net
EventBits_t bits = xEventGroupWaitBits(wifi_event_group,CONNECTED_BIT,true,true,portMAX_DELAY); EventBits_t bits = xEventGroupWaitBits(wifi_event_group,CONNECTED_BIT,true,true,portMAX_DELAY);
// EventBits_t bits = xEventGroupWaitBits(wifi_event_group,
// WIFI_CONNECTED_BIT | WIFI_FAIL_BIT,
// pdFALSE,
// pdFALSE,
// portMAX_DELAY);
if (bits & CONNECTED_BIT) { if (bits & CONNECTED_BIT) {
ESP_LOGI(MAIN_TAG, "connected to ap SSID:%s password:%s", ESP_LOGI(MAIN_TAG, "connected to ap SSID:%s password:%s",
ssid.c_str(), passphrase.c_str()); ssid.c_str(), passphrase.c_str());
@@ -211,16 +211,20 @@ void initialise_wifi_fixed_ip(std::string _ip, std::string _gw, std::string _net
ESP_LOGI(MAIN_TAG, "Failed to connect to SSID:%s, password:%s", ESP_LOGI(MAIN_TAG, "Failed to connect to SSID:%s, password:%s",
ssid.c_str(), passphrase.c_str()); ssid.c_str(), passphrase.c_str());
} }
tcpip_adapter_ip_info_t ip_info2;
ESP_ERROR_CHECK(tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &ip_info2));
ipaddress = std::string(ip4addr_ntoa(&ip_info2.ip));
netmask = std::string(ip4addr_ntoa(&ip_info2.netmask));
gw = std::string(ip4addr_ntoa(&ip_info2.gw));
// ESP_ERROR_CHECK(esp_event_handler_unregister(IP_EVENT, IP_EVENT_STA_GOT_IP, &event_handler));
// ESP_ERROR_CHECK(esp_event_handler_unregister(WIFI_EVENT, ESP_EVENT_ANY_ID, &event_handler));
vEventGroupDelete(wifi_event_group); vEventGroupDelete(wifi_event_group);
} }
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphrase, std::string &_hostname, std::string &_ip, std::string &_gw, std::string &_netmask) //void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphrase, std::string &_hostname, std::string &_ip, std::string &_gw, std::string &_netmask, std::string &_dns)
void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphrase, std::string &_hostname)
{ {
string line = ""; string line = "";
std::vector<string> zerlegt; std::vector<string> zerlegt;
@@ -230,6 +234,8 @@ void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphra
fn = FormatFileName(fn); fn = FormatFileName(fn);
pFile = fopen(fn.c_str(), "r"); pFile = fopen(fn.c_str(), "r");
printf("file loaded\n");
if (pFile == NULL) if (pFile == NULL)
return; return;
@@ -239,7 +245,7 @@ void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphra
while ((line.size() > 0) || !(feof(pFile))) while ((line.size() > 0) || !(feof(pFile)))
{ {
// printf("%s", line.c_str()); printf("%s", line.c_str());
zerlegt = ZerlegeZeile(line, "="); zerlegt = ZerlegeZeile(line, "=");
zerlegt[0] = trim(zerlegt[0], " "); zerlegt[0] = trim(zerlegt[0], " ");
@@ -264,6 +270,7 @@ void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphra
} }
} }
/*
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "IP")){ if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "IP")){
_ip = zerlegt[1]; _ip = zerlegt[1];
if ((_ip[0] == '"') && (_ip[_ip.length()-1] == '"')){ if ((_ip[0] == '"') && (_ip[_ip.length()-1] == '"')){
@@ -285,6 +292,14 @@ void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphra
} }
} }
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) if (fgets(zw, 1024, pFile) == NULL)
{ {

View File

@@ -7,10 +7,11 @@
const int CONNECTED_BIT = BIT0; const int CONNECTED_BIT = BIT0;
void initialise_wifi(std::string _ssid, std::string _passphrase, std::string _hostname); void initialise_wifi(std::string _ssid, std::string _passphrase, std::string _hostname);
void initialise_wifi_fixed_ip(std::string _ip, std::string _gw, std::string _netmask, std::string _ssid, std::string _passphrase, std::string _hostname); void initialise_wifi_fixed_ip(std::string _ip, std::string _gw, std::string _netmask, std::string _ssid, std::string _passphrase, std::string _hostname, std::string _dns = "");
void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphrase, std::string &_hostname, std::string &_ip, std::string &_gw, std::string &_netmask); 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);
std::string getHostname(); std::string getHostname();
std::string getIPAddress(); std::string getIPAddress();

View File

@@ -84,9 +84,10 @@ extern "C" void app_main(void)
std::string ip = ""; std::string ip = "";
std::string gw = ""; std::string gw = "";
std::string netmask = ""; std::string netmask = "";
std::string dns = "";
LoadWlanFromFile("/sdcard/wlan.ini", ssid, password, hostname, ip, gw, netmask); // LoadWlanFromFile("/sdcard/wlan.ini", ssid, password, hostname, ip, gw, netmask, dns);
LoadWlanFromFile("/sdcard/wlan.ini", ssid, password, hostname);
// LogFile.WriteToFile("Startsequence 04"); // LogFile.WriteToFile("Startsequence 04");
printf("To use WLan: %s, %s\n", ssid.c_str(), password.c_str()); printf("To use WLan: %s, %s\n", ssid.c_str(), password.c_str());
@@ -99,7 +100,7 @@ extern "C" void app_main(void)
} }
else else
{ {
initialise_wifi_fixed_ip(ip, gw, netmask, ssid, password, hostname); initialise_wifi_fixed_ip(ip, gw, netmask, ssid, password, hostname, dns);
} }
printf("Netparameter: IP: %s - GW: %s - NetMask %s\n", getIPAddress().c_str(), getGW().c_str(), getNetMask().c_str()); printf("Netparameter: IP: %s - GW: %s - NetMask %s\n", getIPAddress().c_str(), getGW().c_str(), getNetMask().c_str());

View File

@@ -1,4 +1,4 @@
const char* GIT_REV="816f932"; const char* GIT_REV="f616643";
const char* GIT_TAG=""; const char* GIT_TAG="";
const char* GIT_BRANCH="rolling"; const char* GIT_BRANCH="rolling";
const char* BUILD_TIME="2020-12-06 08:08"; const char* BUILD_TIME="2020-12-06 19:22";

View File

@@ -1,4 +1,4 @@
const char* GIT_REV="816f932"; const char* GIT_REV="f616643";
const char* GIT_TAG=""; const char* GIT_TAG="";
const char* GIT_BRANCH="rolling"; const char* GIT_BRANCH="rolling";
const char* BUILD_TIME="2020-12-06 08:07"; const char* BUILD_TIME="2020-12-06 19:22";

Binary file not shown.

Binary file not shown.

Binary file not shown.