diff --git a/.gitignore b/.gitignore index 84fdf05e..d936712c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ .code-workspace .helper/ /sd-card/htm./.vscode/ +/code/build CMakeLists.txt.user CMakeCache.txt diff --git a/README.md b/README.md index 05857edc..0a71ef45 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,13 @@ 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! +##### 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) diff --git a/code/components/connect_wlan/connect_wlan.cpp b/code/components/connect_wlan/connect_wlan.cpp index 07b5bc6e..432d9698 100644 --- a/code/components/connect_wlan/connect_wlan.cpp +++ b/code/components/connect_wlan/connect_wlan.cpp @@ -11,6 +11,10 @@ #include #include #include +#include +#include + +#include #include "Helper.h" @@ -23,6 +27,9 @@ std::string ssid; std::string passphrase; std::string hostname; std::string ipaddress; +std::string gw; +std::string netmask; +std::string dns; std::string std_hostname = "watermeter"; @@ -86,7 +93,7 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) { switch(event->event_id) { case SYSTEM_EVENT_STA_START: - blinkstatus(200, 5); + blinkstatus(200, 1); wifi_connect(); break; case SYSTEM_EVENT_STA_GOT_IP: @@ -125,10 +132,97 @@ void initialise_wifi(std::string _ssid, std::string _passphrase, std::string _ho tcpip_adapter_ip_info_t ip_info; ESP_ERROR_CHECK(tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &ip_info)); ipaddress = std::string(ip4addr_ntoa(&ip_info.ip)); + netmask = std::string(ip4addr_ntoa(&ip_info.netmask)); + gw = std::string(ip4addr_ntoa(&ip_info.gw)); printf("IPv4 : %s\n", ip4addr_ntoa(&ip_info.ip)); printf("HostName : %s\n", hostname.c_str()); } +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// + +void strinttoip4(std::string ip, int &a, int &b, int &c, int &d) { + std::stringstream s(ip); + char ch; //to temporarily store the '.' + 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, std::string _dns) +{ + + ssid = _ssid; + passphrase = _passphrase; + hostname = _hostname; + dns = _dns; + + wifi_event_group = xEventGroupCreate(); + + ESP_ERROR_CHECK(esp_netif_init()); + ESP_ERROR_CHECK(esp_event_loop_create_default()); + + esp_netif_t *my_sta = esp_netif_create_default_wifi_sta(); + + esp_netif_dhcpc_stop(my_sta); + + esp_netif_ip_info_t ip_info; + + int a, b, c, d; + + strinttoip4(_ip, a, b, c, d); + IP4_ADDR(&ip_info.ip, a, b, c, d); + + strinttoip4(_gw, a, b, c, d); + IP4_ADDR(&ip_info.gw, a, b, c, d); + + strinttoip4(_netmask, a, b, c, d); + IP4_ADDR(&ip_info.netmask, a, b, c, d); + + esp_netif_set_ip_info(my_sta, &ip_info); + + wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); + 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) ); + + wifi_config_t wifi_config = { }; + strcpy((char*)wifi_config.sta.ssid, (const char*)ssid.c_str()); + strcpy((char*)wifi_config.sta.password, (const char*)passphrase.c_str()); + + ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA) ); + ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config) ); + ESP_ERROR_CHECK(esp_wifi_start() ); + + ESP_LOGI(MAIN_TAG, "wifi_init_sta finished."); + + EventBits_t bits = xEventGroupWaitBits(wifi_event_group,CONNECTED_BIT,true,true,portMAX_DELAY); + + if (bits & CONNECTED_BIT) { + ESP_LOGI(MAIN_TAG, "connected to ap SSID:%s password:%s", + ssid.c_str(), passphrase.c_str()); + } else { + ESP_LOGI(MAIN_TAG, "Failed to connect to SSID:%s, password:%s", + 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)); + + 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, std::string &_dns) void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphrase, std::string &_hostname) { @@ -140,6 +234,8 @@ void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphra fn = FormatFileName(fn); pFile = fopen(fn.c_str(), "r"); + printf("file loaded\n"); + if (pFile == NULL) return; @@ -149,7 +245,7 @@ void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphra while ((line.size() > 0) || !(feof(pFile))) { -// printf("%s", line.c_str()); + printf("%s", line.c_str()); zerlegt = ZerlegeZeile(line, "="); zerlegt[0] = trim(zerlegt[0], " "); @@ -174,6 +270,37 @@ void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphra } } +/* + 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 = ""; @@ -204,3 +331,12 @@ std::string getIPAddress(){ std::string getSSID(){ return ssid; } + +std::string getNetMask(){ + return netmask; +} + +std::string getGW(){ + return gw; +} + diff --git a/code/components/connect_wlan/connect_wlan.h b/code/components/connect_wlan/connect_wlan.h index 3bc740d8..6e707d0f 100644 --- a/code/components/connect_wlan/connect_wlan.h +++ b/code/components/connect_wlan/connect_wlan.h @@ -7,11 +7,16 @@ const int CONNECTED_BIT = BIT0; 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, std::string _dns = ""); + 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 getIPAddress(); std::string getSSID(); +std::string getNetMask(); +std::string getGW(); #endif \ No newline at end of file diff --git a/code/components/jomjol_controlcamera/ClassControllCamera.cpp b/code/components/jomjol_controlcamera/ClassControllCamera.cpp index bd6eec6b..b24c8831 100644 --- a/code/components/jomjol_controlcamera/ClassControllCamera.cpp +++ b/code/components/jomjol_controlcamera/ClassControllCamera.cpp @@ -137,6 +137,7 @@ CCamera Camera; #define FLASH_GPIO GPIO_NUM_4 +#define BLINK_GPIO GPIO_NUM_33 typedef struct { httpd_req_t *req; @@ -207,6 +208,8 @@ esp_err_t CCamera::CaptureToFile(std::string nm, int delay) // nm = "/sdcard/josef_zw.bmp"; string ftype; + LEDOnOff(true); + if (delay > 0) { LightOnOff(true); @@ -217,8 +220,11 @@ esp_err_t CCamera::CaptureToFile(std::string nm, int delay) camera_fb_t * fb = esp_camera_fb_get(); if (!fb) { ESP_LOGE(TAGCAMERACLASS, "Camera Capture Failed"); + LEDOnOff(false); return ESP_FAIL; } + LEDOnOff(false); + printf("w %d, h %d, size %d\n", fb->width, fb->height, fb->len); nm = FormatFileName(nm); @@ -322,6 +328,20 @@ void CCamera::LightOnOff(bool status) gpio_set_level(FLASH_GPIO, 0); } +void CCamera::LEDOnOff(bool status) +{ + // Init the GPIO + gpio_pad_select_gpio(BLINK_GPIO); + /* Set the GPIO as a push/pull output */ + gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT); + + if (!status) + gpio_set_level(BLINK_GPIO, 1); + else + gpio_set_level(BLINK_GPIO, 0); +} + + void CCamera::GetCameraParameter(httpd_req_t *req, int &qual, framesize_t &resol) { char _query[100]; diff --git a/code/components/jomjol_controlcamera/ClassControllCamera.h b/code/components/jomjol_controlcamera/ClassControllCamera.h index 07e63e2f..7ccfae19 100644 --- a/code/components/jomjol_controlcamera/ClassControllCamera.h +++ b/code/components/jomjol_controlcamera/ClassControllCamera.h @@ -28,6 +28,7 @@ class CCamera { esp_err_t InitCam(); void LightOnOff(bool status); + void LEDOnOff(bool status); esp_err_t CaptureToHTTP(httpd_req_t *req, int delay = 0); void SetQualitySize(int qual, framesize_t resol); void GetCameraParameter(httpd_req_t *req, int &qual, framesize_t &resol); diff --git a/code/components/jomjol_flowcontroll/ClassFlowControll.cpp b/code/components/jomjol_flowcontroll/ClassFlowControll.cpp index 68f3dce6..2eb72fe6 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowControll.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowControll.cpp @@ -66,6 +66,7 @@ std::vector ClassFlowControll::GetAllAnalog() void ClassFlowControll::SetInitialParameter(void) { AutoStart = false; + SetupModeActive = false; AutoIntervall = 10; } @@ -156,6 +157,22 @@ std::string ClassFlowControll::getActStatus(){ return aktstatus; } +void ClassFlowControll::doFlowMakeImageOnly(string time){ + bool result = true; + std::string zw_time; + int repeat = 0; + + for (int i = 0; i < FlowControll.size(); ++i) + { + if (FlowControll[i]->name() == "ClassFlowMakeImage") { + zw_time = gettimestring("%Y%m%d-%H%M%S"); + aktstatus = zw_time + ": " + FlowControll[i]->name(); + string zw = "FlowControll.doFlowMakeImageOnly - " + FlowControll[i]->name(); + FlowControll[i]->doFlow(time); + } + } +} + bool ClassFlowControll::doFlow(string time) { // CleanTempFolder(); // dazu muss man noch eine Rolling einführen @@ -303,12 +320,16 @@ bool ClassFlowControll::ReadParameter(FILE* pfile, string& aktparamgraph) setTimeZone(zerlegt[1]); } - if ((toUpper(zerlegt[0]) == "TIMEUPDATEINTERVALL") && (zerlegt.size() > 1)) + if ((toUpper(zerlegt[0]) == "SETUPMODE") && (zerlegt.size() > 1)) { - TimeUpdateIntervall = stof(zerlegt[1]); - xTaskCreate(&task_doTimeSync, "update_time", configMINIMAL_STACK_SIZE * 16, &TimeUpdateIntervall, tskIDLE_PRIORITY, NULL); + if (toUpper(zerlegt[1]) == "TRUE") + { + SetupModeActive = true; + } } + + } return true; } diff --git a/code/components/jomjol_flowcontroll/ClassFlowControll.h b/code/components/jomjol_flowcontroll/ClassFlowControll.h index aceb79cc..adf7ef6a 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowControll.h +++ b/code/components/jomjol_flowcontroll/ClassFlowControll.h @@ -21,14 +21,15 @@ protected: bool AutoStart; float AutoIntervall; + bool SetupModeActive; void SetInitialParameter(void); std::string aktstatus; - int TimeUpdateIntervall; - public: void InitFlow(std::string config); bool doFlow(string time); + void doFlowMakeImageOnly(string time); + bool getStatusSetupModus(){return SetupModeActive;}; string getReadout(bool _rawvalue, bool _noerror); string UpdatePrevalue(std::string _newvalue); string GetPrevalue(); diff --git a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp index a4dbbfad..abe02045 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp @@ -313,7 +313,6 @@ bool ClassFlowPostProcessing::doFlow(string zwtime) ReturnRawValue = ShiftDecimal(ReturnRawValue, DecimalShift); - if (!PreValueUse || !PreValueOkay) { ReturnValue = ReturnRawValue; @@ -391,6 +390,9 @@ string ClassFlowPostProcessing::getReadoutParam(bool _rawValue, bool _noerror) string ClassFlowPostProcessing::RundeOutput(float _in, int _anzNachkomma){ std::stringstream stream; + if (_anzNachkomma < 0) { + _anzNachkomma = 0; + } stream << std::fixed << std::setprecision(_anzNachkomma) << _in; return stream.str(); } diff --git a/code/components/jomjol_tfliteclass/server_tflite.cpp b/code/components/jomjol_tfliteclass/server_tflite.cpp index b579ac59..efe6ab21 100644 --- a/code/components/jomjol_tfliteclass/server_tflite.cpp +++ b/code/components/jomjol_tfliteclass/server_tflite.cpp @@ -29,6 +29,12 @@ bool flowisrunning = false; long auto_intervall = 0; bool auto_isrunning = false; +bool isSetupModusActive() { + return tfliteflow.getStatusSetupModus(); + return false; +} + + void KillTFliteTasks() { printf("Handle: xHandleblink_task_doFlow: %ld\n", (long) xHandleblink_task_doFlow); @@ -419,6 +425,13 @@ void task_autodoFlow(void *pvParameter) auto_isrunning = tfliteflow.isAutoStart(auto_intervall); + if (isSetupModusActive()) { + auto_isrunning = false; + std::string zw_time = gettimestring(LOGFILE_TIME_FORMAT); + tfliteflow.doFlowMakeImageOnly(zw_time); + + } + while (auto_isrunning) { LogFile.WriteToFile("task_autodoFlow - next round"); diff --git a/code/components/jomjol_tfliteclass/server_tflite.h b/code/components/jomjol_tfliteclass/server_tflite.h index d34510e0..68fc1dbc 100644 --- a/code/components/jomjol_tfliteclass/server_tflite.h +++ b/code/components/jomjol_tfliteclass/server_tflite.h @@ -10,4 +10,6 @@ void register_server_tflite_uri(httpd_handle_t server); void KillTFliteTasks(); -void TFliteDoAutoStart(); \ No newline at end of file +void TFliteDoAutoStart(); + +bool isSetupModusActive(); \ No newline at end of file diff --git a/code/components/jomjol_time_sntp/time_sntp.cpp b/code/components/jomjol_time_sntp/time_sntp.cpp index 9f4562b2..da746ebd 100644 --- a/code/components/jomjol_time_sntp/time_sntp.cpp +++ b/code/components/jomjol_time_sntp/time_sntp.cpp @@ -29,17 +29,13 @@ RTC_DATA_ATTR int boot_count = 0; bool setTimeAlwaysOnReboot = true; -/* Variable holding number of times ESP32 restarted since first boot. - * It is placed into RTC memory using RTC_DATA_ATTR and - * maintains its value when ESP32 wakes from deep sleep. - */ - static void obtain_time(void); static void initialize_sntp(void); void time_sync_notification_cb(struct timeval *tv) { +// LogFile.WriteToFile("Notification of a time synchronization event"); ESP_LOGI(TAG, "Notification of a time synchronization event"); } @@ -115,11 +111,11 @@ static void obtain_time(void) vTaskDelay(2000 / portTICK_PERIOD_MS); } if (retry == retry_count) { - LogFile.WriteToFile("Time Synchzronisation nicht erfolgreich ..."); +// LogFile.WriteToFile("Time Synchzronisation nicht erfolgreich ..."); } else { - LogFile.WriteToFile("Time erfolgreich ..."); +// LogFile.WriteToFile("Time erfolgreich ..."); } time(&now); @@ -131,35 +127,6 @@ static void initialize_sntp(void) ESP_LOGI(TAG, "Initializing SNTP"); sntp_setoperatingmode(SNTP_OPMODE_POLL); sntp_setservername(0, "pool.ntp.org"); - sntp_set_time_sync_notification_cb(time_sync_notification_cb); +// sntp_set_time_sync_notification_cb(time_sync_notification_cb); sntp_init(); -} - - -void task_doTimeSync(void *pvParameter) -{ - time_t now; - struct tm timeinfo; - char strftime_buf[64]; - int *zw_int = (int*) pvParameter; - - printf("Start Autoupdate Time every: %d Stunden\n", *zw_int ); - TickType_t xDelay = ((*zw_int) * 60 * 60 * 1000) / portTICK_PERIOD_MS; - - while (1) - { - obtain_time(); - localtime_r(&now, &timeinfo); - strftime(strftime_buf, sizeof(strftime_buf), "%c", &timeinfo); - ESP_LOGI(TAG, "The current date/time in Berlin is: %s", strftime_buf); - - strftime(strftime_buf, sizeof(strftime_buf), "%Y-%m-%d_%H:%M", &timeinfo); - ESP_LOGI(TAG, "The current date/time in Berlin is: %s", strftime_buf); - - std::string zw = gettimestring("%Y%m%d-%H%M%S"); - printf("time %s\n", zw.c_str()); - - vTaskDelay( xDelay ); - } - vTaskDelete(NULL); //Delete this task if it exits from the loop above } \ No newline at end of file diff --git a/code/components/jomjol_time_sntp/time_sntp.h b/code/components/jomjol_time_sntp/time_sntp.h index 62847c97..3238e68a 100644 --- a/code/components/jomjol_time_sntp/time_sntp.h +++ b/code/components/jomjol_time_sntp/time_sntp.h @@ -12,11 +12,7 @@ // #include "nvs_flash.h" #include "esp_sntp.h" - -extern int boot_count; - void setup_time(void); std::string gettimestring(const char * frm); -void task_doTimeSync(void *pvParameter); void setTimeZone(std::string _tzstring); \ No newline at end of file diff --git a/code/src/CMakeLists.txt b/code/main/CMakeLists.txt similarity index 97% rename from code/src/CMakeLists.txt rename to code/main/CMakeLists.txt index 64236268..9e34818e 100644 --- a/code/src/CMakeLists.txt +++ b/code/main/CMakeLists.txt @@ -53,7 +53,7 @@ endif() ####################################################################### -FILE(GLOB_RECURSE app_sources ${CMAKE_SOURCE_DIR}/src/*.*) +FILE(GLOB_RECURSE app_sources ${CMAKE_SOURCE_DIR}/main/*.*) # idf_component_register(SRCS ${app_sources}) diff --git a/code/src/favicon.ico b/code/main/favicon.ico similarity index 100% rename from code/src/favicon.ico rename to code/main/favicon.ico diff --git a/code/src/gitversion.cmake b/code/main/gitversion.cmake similarity index 100% rename from code/src/gitversion.cmake rename to code/main/gitversion.cmake diff --git a/code/src/main.cpp b/code/main/main.cpp similarity index 84% rename from code/src/main.cpp rename to code/main/main.cpp index e8721196..11b26e79 100644 --- a/code/src/main.cpp +++ b/code/main/main.cpp @@ -81,13 +81,31 @@ extern "C" void app_main(void) std::string ssid = ""; std::string password = ""; std::string hostname = ""; + std::string ip = ""; + std::string gw = ""; + std::string netmask = ""; + std::string dns = ""; +// LoadWlanFromFile("/sdcard/wlan.ini", ssid, password, hostname, ip, gw, netmask, dns); LoadWlanFromFile("/sdcard/wlan.ini", ssid, password, hostname); + // 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()); - initialise_wifi(ssid, password, hostname); + if (ip.length() == 0 || gw.length() == 0 || netmask.length() == 0) + { + initialise_wifi(ssid, password, hostname); + } + else + { + 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()); + + // LogFile.WriteToFile("Startsequence 05"); TickType_t xDelay; diff --git a/code/src/server_main.cpp b/code/main/server_main.cpp similarity index 97% rename from code/src/server_main.cpp rename to code/main/server_main.cpp index e67d47a8..084dca5d 100644 --- a/code/src/server_main.cpp +++ b/code/main/server_main.cpp @@ -13,6 +13,8 @@ #include "esp_wifi.h" +#include "server_tflite.h" + httpd_handle_t server = NULL; @@ -152,7 +154,9 @@ esp_err_t hello_main_handler(httpd_req_t *req) if ((strcmp(req->uri, "/") == 0)) { - filetosend = filetosend + "/html/index.html"; + { + filetosend = filetosend + "/html/index.html"; + } } else { @@ -163,6 +167,11 @@ esp_err_t hello_main_handler(httpd_req_t *req) } } + if (filetosend == "/sdcard/html/index.html" && isSetupModusActive()) { + printf("System ist im Setupmodus --> index.html --> setup.html"); + filetosend = "/sdcard/html/setup.html"; + } + printf("Filename: %s\n", filename); printf("File requested: %s\n", filetosend.c_str()); diff --git a/code/src/server_main.h b/code/main/server_main.h similarity index 100% rename from code/src/server_main.h rename to code/main/server_main.h diff --git a/code/main/version.cpp b/code/main/version.cpp new file mode 100644 index 00000000..2a508b91 --- /dev/null +++ b/code/main/version.cpp @@ -0,0 +1,4 @@ +const char* GIT_REV="f616643"; +const char* GIT_TAG=""; +const char* GIT_BRANCH="rolling"; +const char* BUILD_TIME="2020-12-06 19:22"; \ No newline at end of file diff --git a/code/src/version.h b/code/main/version.h similarity index 100% rename from code/src/version.h rename to code/main/version.h diff --git a/code/platformio.ini b/code/platformio.ini index 44019c36..43ce1528 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -9,6 +9,8 @@ ; https://docs.platformio.org/page/projectconf.html +[platformio] +src_dir = main [env:esp32cam] @@ -17,12 +19,14 @@ board = esp32cam framework = espidf board_build.embed_files = - src/favicon.ico + main/favicon.ico ;board_build.partitions = partitions_singleapp.csv board_build.partitions = partitions.csv + + lib_deps = jomjol_helper connect_wlan diff --git a/code/sdkconfig b/code/sdkconfig index deb81b3d..dd11c44e 100644 --- a/code/sdkconfig +++ b/code/sdkconfig @@ -83,11 +83,11 @@ CONFIG_ESPTOOLPY_FLASHFREQ_40M=y # CONFIG_ESPTOOLPY_FLASHFREQ_20M is not set CONFIG_ESPTOOLPY_FLASHFREQ="40m" # CONFIG_ESPTOOLPY_FLASHSIZE_1MB is not set -CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y -# CONFIG_ESPTOOLPY_FLASHSIZE_4MB is not set +# CONFIG_ESPTOOLPY_FLASHSIZE_2MB is not set +CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y # CONFIG_ESPTOOLPY_FLASHSIZE_8MB is not set # CONFIG_ESPTOOLPY_FLASHSIZE_16MB is not set -CONFIG_ESPTOOLPY_FLASHSIZE="2MB" +CONFIG_ESPTOOLPY_FLASHSIZE="4MB" CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y CONFIG_ESPTOOLPY_BEFORE_RESET=y # CONFIG_ESPTOOLPY_BEFORE_NORESET is not set @@ -109,11 +109,11 @@ CONFIG_ESPTOOLPY_MONITOR_BAUD=115200 # # Partition Table # -CONFIG_PARTITION_TABLE_SINGLE_APP=y +# CONFIG_PARTITION_TABLE_SINGLE_APP is not set # CONFIG_PARTITION_TABLE_TWO_OTA is not set -# CONFIG_PARTITION_TABLE_CUSTOM is not set +CONFIG_PARTITION_TABLE_CUSTOM=y CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" -CONFIG_PARTITION_TABLE_FILENAME="partitions_singleapp.csv" +CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" CONFIG_PARTITION_TABLE_OFFSET=0x8000 CONFIG_PARTITION_TABLE_MD5=y # end of Partition Table diff --git a/code/sdkconfig.old b/code/sdkconfig.old index 7a6190d3..88827b07 100644 --- a/code/sdkconfig.old +++ b/code/sdkconfig.old @@ -109,11 +109,11 @@ CONFIG_ESPTOOLPY_MONITOR_BAUD=115200 # # Partition Table # -CONFIG_PARTITION_TABLE_SINGLE_APP=y +# CONFIG_PARTITION_TABLE_SINGLE_APP is not set # CONFIG_PARTITION_TABLE_TWO_OTA is not set -# CONFIG_PARTITION_TABLE_CUSTOM is not set +CONFIG_PARTITION_TABLE_CUSTOM=y CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" -CONFIG_PARTITION_TABLE_FILENAME="partitions_singleapp.csv" +CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" CONFIG_PARTITION_TABLE_OFFSET=0x8000 CONFIG_PARTITION_TABLE_MD5=y # end of Partition Table @@ -537,7 +537,7 @@ CONFIG_FATFS_MAX_LFN=255 CONFIG_FATFS_API_ENCODING_ANSI_OEM=y # CONFIG_FATFS_API_ENCODING_UTF_16 is not set # CONFIG_FATFS_API_ENCODING_UTF_8 is not set -CONFIG_FATFS_FS_LOCK=2 +CONFIG_FATFS_FS_LOCK=5 CONFIG_FATFS_TIMEOUT_MS=10000 CONFIG_FATFS_PER_FILE_CACHE=y CONFIG_FATFS_ALLOC_PREFER_EXTRAM=y diff --git a/code/src/version.cpp b/code/src/version.cpp deleted file mode 100644 index ba1b9571..00000000 --- a/code/src/version.cpp +++ /dev/null @@ -1,4 +0,0 @@ -const char* GIT_REV="ffc15aa"; -const char* GIT_TAG=""; -const char* GIT_BRANCH="master"; -const char* BUILD_TIME="2020-12-02 21:56"; \ No newline at end of file diff --git a/code/version.cpp b/code/version.cpp index 1afca8ab..2a508b91 100644 --- a/code/version.cpp +++ b/code/version.cpp @@ -1,4 +1,4 @@ -const char* GIT_REV="ffc15aa"; +const char* GIT_REV="f616643"; const char* GIT_TAG=""; -const char* GIT_BRANCH="master"; -const char* BUILD_TIME="2020-12-02 21:55"; \ No newline at end of file +const char* GIT_BRANCH="rolling"; +const char* BUILD_TIME="2020-12-06 19:22"; \ No newline at end of file diff --git a/firmware/bootloader.bin b/firmware/bootloader.bin index 79065325..5241288a 100644 Binary files a/firmware/bootloader.bin and b/firmware/bootloader.bin differ diff --git a/firmware/firmware.bin b/firmware/firmware.bin index 546b3783..83d29ed0 100644 Binary files a/firmware/firmware.bin and b/firmware/firmware.bin differ diff --git a/firmware/html.zip b/firmware/html.zip index 9314fadd..8694e078 100644 Binary files a/firmware/html.zip and b/firmware/html.zip differ diff --git a/sd-card/config/config.ini b/sd-card/config/config.ini index 4d14d2e5..a7e80a44 100644 --- a/sd-card/config/config.ini +++ b/sd-card/config/config.ini @@ -59,5 +59,6 @@ LogfileRetentionInDays = 3 [System] TimeZone = CET-1CEST,M3.5.0,M10.5.0/3 +SetupMode = true [Ende] \ No newline at end of file diff --git a/sd-card/html/cnn_images.jpg b/sd-card/html/cnn_images.jpg new file mode 100644 index 00000000..fd66b508 Binary files /dev/null and b/sd-card/html/cnn_images.jpg differ diff --git a/sd-card/html/debug.log b/sd-card/html/debug.log new file mode 100644 index 00000000..7ae006a6 --- /dev/null +++ b/sd-card/html/debug.log @@ -0,0 +1 @@ +[1204/185120.033:ERROR:directory_reader_win.cc(43)] FindFirstFile: Das System kann den angegebenen Pfad nicht finden. (0x3) diff --git a/sd-card/html/edit_explain_0.html b/sd-card/html/edit_explain_0.html new file mode 100644 index 00000000..dfb1eb4a --- /dev/null +++ b/sd-card/html/edit_explain_0.html @@ -0,0 +1,66 @@ + + + +jomjol - AI on the edge + + + + + + + + +

Welcome to the Setup of the Digitizer

+ + +

+ +

+ +

+ This is the first time you the digitizer. You have been automatically routed to the initial setup procedure. + This procedure should adjust the setting to your local counter. Basically you can customize your settings in five steps. +
+ In the final step the inital setup will be disabled and it will restart to the normal mode. +
+
+ Just use the buttons "Next" and "Previous" to nagivate through the process. +
+

+

+ Follow the instructions: +

+ +

+

    +
  1. Create reference image
    + Basis for the position references and the marking of the digits and counters.
  2. +
  3. Define two unique references
    + Used to align the individual camera shot and identify the absolut positions
  4. +
  5. Define the digits
    + Digital digits to be recognized
  6. +
  7. Define the analog counters
    + Analog counters to be identified
  8. +
  9. General settings
    + Most can stay to the default value - also MQTT connection can be specified here
  10. +
+

+ +After step 5 you switch of the setup mode, reboot and start in normal mode! + +

Have fun with the digitizer!

+ + + + \ No newline at end of file diff --git a/sd-card/html/edit_explain_6.html b/sd-card/html/edit_explain_6.html new file mode 100644 index 00000000..1cccc582 --- /dev/null +++ b/sd-card/html/edit_explain_6.html @@ -0,0 +1,81 @@ + + + +jomjol - AI on the edge + + + + + + + + +

Finished!

+ +

+ Now you are finished with the setup and ready to reboot to the normal mode. +
+ Once you have pushed below button, the setup modus will be left and the digitizer start to normal operation mode. +
+ After a view seconds you can reload this page again and will go to normal operation mode. +
+ All settings can be changed later on as well in the configuration menue. +

+ +

+ +

+ + + + + + + + \ No newline at end of file diff --git a/sd-card/html/edit_reference.html b/sd-card/html/edit_reference.html index 2da7a872..34e02678 100644 --- a/sd-card/html/edit_reference.html +++ b/sd-card/html/edit_reference.html @@ -39,7 +39,7 @@ table { - + diff --git a/sd-card/html/explain_0.html b/sd-card/html/explain_0.html new file mode 100644 index 00000000..75f66304 --- /dev/null +++ b/sd-card/html/explain_0.html @@ -0,0 +1,29 @@ + + + +jomjol - AI on the edge + + + + + + + + +

Introduction

+

+Read below! + + + \ No newline at end of file diff --git a/sd-card/html/explain_1.html b/sd-card/html/explain_1.html new file mode 100644 index 00000000..8b098219 --- /dev/null +++ b/sd-card/html/explain_1.html @@ -0,0 +1,33 @@ + + + +jomjol - AI on the edge + + + + + + + + +

Reference Image

+The reference image is needed to define the digits, counters and references for alignment. +

+ The last taken raw image from the camera is taken. Use the Button "Create New Reference" to make your own reference.
+ Most important feature is a straight alignment of the image. Use the Pre roate Angle and the fine alignment to fine tune the rotation of the image
+ Finish the step by pushing "Update Reference Image". +

+ + + \ No newline at end of file diff --git a/sd-card/html/explain_2.html b/sd-card/html/explain_2.html new file mode 100644 index 00000000..976738ed --- /dev/null +++ b/sd-card/html/explain_2.html @@ -0,0 +1,36 @@ + + + +jomjol - AI on the edge + + + + + + + + +

Alignment References

+Two opposite alignment references are needed to identify unique fix points on the image. +

+ Mark the reference by drag and dop with the mouse or with the coordinates and push "Update Reference". +
+ You can switch between the two reference with "Select Reference". +

+

+ Don't forget to save your changes with "Save to Config.ini"!. +

+ + + \ No newline at end of file diff --git a/sd-card/html/explain_3.html b/sd-card/html/explain_3.html new file mode 100644 index 00000000..077a6a9e --- /dev/null +++ b/sd-card/html/explain_3.html @@ -0,0 +1,37 @@ + + + +jomjol - AI on the edge + + + + + + + + +

Define Digits

+Here you define your digits you want to read. +

+ With the drop down menue "ROI x" you can change between the different digits. Mark them with the mouse or the coordinates. +
+ To create new ROIs use "New ROIs". The order of the ROIs defines the positon within the reading.
+ You can change it with "move Next" / "move Previous". +

+

+ Don't forget to save your changes with "Save all to Config.ini"!. +

+ + + \ No newline at end of file diff --git a/sd-card/html/explain_4.html b/sd-card/html/explain_4.html new file mode 100644 index 00000000..546376a3 --- /dev/null +++ b/sd-card/html/explain_4.html @@ -0,0 +1,37 @@ + + + +jomjol - AI on the edge + + + + + + + + +

Define Digits

+Here you define your analog counters you want to read. If you do not have analog counters delete all ROIs. +

+ With the drop down menue "ROI x" you can change between the different counters. Mark them with the mouse or the coordinates. +
+ To create new ROIs use "New ROIs". The order of the ROIs defines the positon within the reading.
+ You can change it with "move Next" / "move Previous". +

+

+ Don't forget to save your changes with "Save all to Config.ini"!. +

+ + + \ No newline at end of file diff --git a/sd-card/html/explain_5.html b/sd-card/html/explain_5.html new file mode 100644 index 00000000..8ae3bae0 --- /dev/null +++ b/sd-card/html/explain_5.html @@ -0,0 +1,35 @@ + + + +jomjol - AI on the edge + + + + + + + + +

General configuration parameters

+Here you define additional setting. The settings should fit for a normal setup.

+

+ Only if you want to connect to a MQTT-broker you need to adjust the corresponding parameters. +

+

+ Don't forget to save your changes with "Update Config.ini"!. +
You should not reboot here, but leave the setup modus on the next page. +

+ + + \ No newline at end of file diff --git a/sd-card/html/explain_6.html b/sd-card/html/explain_6.html new file mode 100644 index 00000000..a617db25 --- /dev/null +++ b/sd-card/html/explain_6.html @@ -0,0 +1,27 @@ + + + +jomjol - AI on the edge + + + + + + + + +

Finished!

+Read below! + + \ No newline at end of file diff --git a/sd-card/html/flow_overview.jpg b/sd-card/html/flow_overview.jpg new file mode 100644 index 00000000..adccf396 Binary files /dev/null and b/sd-card/html/flow_overview.jpg differ diff --git a/sd-card/html/gethost.js b/sd-card/html/gethost.js index 79750188..90d993d7 100644 --- a/sd-card/html/gethost.js +++ b/sd-card/html/gethost.js @@ -7,8 +7,8 @@ function getbasepath(){ var host = window.location.hostname; if ((host == "127.0.0.1") || (host == "localhost")) { -// host = "http://192.168.178.26"; // jomjol interner test - host = "http://192.168.178.22"; // jomjol interner Real + host = "http://192.168.178.26"; // jomjol interner test +// host = "http://192.168.178.22"; // jomjol interner Real // host = "."; // jomjol interner localhost } else diff --git a/sd-card/html/index.html b/sd-card/html/index.html index 78e55a9d..3212111e 100644 --- a/sd-card/html/index.html +++ b/sd-card/html/index.html @@ -97,6 +97,7 @@ li.dropdown {

+

diff --git a/sd-card/html/readconfigparam.js b/sd-card/html/readconfigparam.js index 72b8fe39..ddd5903e 100644 --- a/sd-card/html/readconfigparam.js +++ b/sd-card/html/readconfigparam.js @@ -73,7 +73,8 @@ function ParseConfig() { param[catname] = new Object(); ParamAddValue(param, catname, "TimeZone"); ParamAddValue(param, catname, "AutoAdjustSummertime"); - ParamAddValue(param, catname, "TimeUpdateIntervall"); + ParamAddValue(param, catname, "TimeUpdateIntervall"); + ParamAddValue(param, catname, "SetupMode"); while (aktline < config_split.length){ if (config_split[aktline].trim().toUpperCase() == "[MAKEIMAGE]") { @@ -150,6 +151,7 @@ function ParseConfigParamSystem(_aktline){ ParamExtractValue(param, linesplit, catname, "TimeZone", _aktline, isCom); ParamExtractValue(param, linesplit, catname, "AutoAdjustSummertime", _aktline, isCom); ParamExtractValue(param, linesplit, catname, "TimeUpdateIntervall", _aktline, isCom); + ParamExtractValue(param, linesplit, catname, "SetupMode", _aktline, isCom); ++_aktline; } diff --git a/sd-card/html/setup - Kopie.html b/sd-card/html/setup - Kopie.html new file mode 100644 index 00000000..598d3b49 --- /dev/null +++ b/sd-card/html/setup - Kopie.html @@ -0,0 +1,40 @@ + + + +jomjol - AI on the edge + + + + + + + +
+ + +
+ + + + \ No newline at end of file diff --git a/sd-card/html/setup.html b/sd-card/html/setup.html new file mode 100644 index 00000000..846a786d --- /dev/null +++ b/sd-card/html/setup.html @@ -0,0 +1,141 @@ + + + +jomjol - AI on the edge + + + + + + + + +

Digitizer - Initial Setup

+ + + + +
+ + +
+ + +
+ +
+ +
+ +
+ + + + + + + + + + \ No newline at end of file diff --git a/sd-card/html/version.txt b/sd-card/html/version.txt index 7ec1d6db..4a36342f 100644 --- a/sd-card/html/version.txt +++ b/sd-card/html/version.txt @@ -1 +1 @@ -2.1.0 +3.0.0