# HG changeset patch # User Michiel Broek # Date 1696411729 -7200 # Node ID 715785443a9505270fb99cf43846540422b846aa # Parent 332e855693397bbc5be34a266ab13c2da683e154 Version 0.3.1. Remove obsolete files from spiffs filesystem. Removed obsolete wifi stations.conf file and functions. Removed obsolete user screens. diff -r 332e85569339 -r 715785443a95 CMakeLists.txt --- a/CMakeLists.txt Tue Oct 03 19:55:34 2023 +0200 +++ b/CMakeLists.txt Wed Oct 04 11:28:49 2023 +0200 @@ -2,7 +2,7 @@ # in this exact order for cmake to work correctly cmake_minimum_required(VERSION 3.5) -set(PROJECT_VER "0.3.0") +set(PROJECT_VER "0.3.1") set(PROJECT_NAME "co2meter") set(EXTRA_COMPONENT_DIRS components/esp32-ds18b20 components/esp32-owb components/esp32-rotary-encoder components/u8g2) diff -r 332e85569339 -r 715785443a95 main/co2meter.c --- a/main/co2meter.c Tue Oct 03 19:55:34 2023 +0200 +++ b/main/co2meter.c Wed Oct 04 11:28:49 2023 +0200 @@ -118,8 +118,6 @@ /* * Read or create configuration */ -// unlink("/spiffs/config.conf"); -// read_config(); read_units(); vTaskDelay(500 / portTICK_PERIOD_MS); @@ -139,7 +137,6 @@ xTaskCreate(&task_user, "task_user", 4096, NULL,10, &xTaskUser); xTaskCreate(&task_ds18b20, "task_ds18b20", 2560, NULL, 8, &xTaskDS18B20); xTaskCreate(&task_adc, "task_adc", 2560, NULL, 8, &xTaskADC); -// esp_log_level_set("MQTT_CLIENT", ESP_LOG_ERROR); xTaskCreate(&task_mqtt, "task_mqtt", 4096, NULL, 5, &xTaskMQTT); esp_log_level_set("wifi", ESP_LOG_ERROR); xTaskCreate(&task_wifi, "task_wifi", 4096, NULL, 3, &xTaskWifi); @@ -186,7 +183,7 @@ user_refresh(); if (! ready_mqtt()) connect_mqtt(true); - ESP_LOGI(TAG, "Loop => ML1_MQTT_CONNECT"); + ESP_LOGD(TAG, "Loop => ML1_MQTT_CONNECT"); } break; @@ -263,14 +260,14 @@ ESP_LOGE(TAG, "ML1_MQTT_CONNECT write_units lock error"); } user_refresh(); - ESP_LOGI(TAG, "Loop => ML1_MQTT_WAITCON"); + ESP_LOGD(TAG, "Loop => ML1_MQTT_WAITCON"); } break; case ML1_WAITCON: if (ready_mqtt()) { Main_Loop1 = ML1_SEND; - ESP_LOGI(TAG, "Loop => ML1_SEND"); + ESP_LOGD(TAG, "Loop => ML1_SEND"); } break; @@ -279,7 +276,7 @@ publishUnits(); publishLogs(); Main_Loop1 = ML1_WAITACK; - ESP_LOGI(TAG, "Loop => ML1_WAITACK"); + ESP_LOGD(TAG, "Loop => ML1_WAITACK"); break; case ML1_WAITACK: @@ -288,7 +285,7 @@ ESP_LOGD(TAG, "Main loop: Done, user busy: %s", user_busy() ? "true":"false"); Main_Loop1 = ML1_STATUS; user_refresh(); - ESP_LOGI(TAG, "Loop => ML1_STATUS"); + ESP_LOGD(TAG, "Loop => ML1_STATUS"); } break; @@ -302,14 +299,14 @@ ESP_LOGI(TAG, "Loop => ML1_SCAN"); } else { Main_Loop1 = ML1_DONE; - ESP_LOGI(TAG, "Loop => ML1_DONE"); + ESP_LOGD(TAG, "Loop => ML1_DONE"); } break; case ML1_SCAN: if (_wifi_ScanDone == true) { Main_Loop1 = ML1_DONE; - ESP_LOGI(TAG, "Loop => ML1_DONE"); + ESP_LOGD(TAG, "Loop => ML1_DONE"); } break; diff -r 332e85569339 -r 715785443a95 main/config.c --- a/main/config.c Tue Oct 03 19:55:34 2023 +0200 +++ b/main/config.c Wed Oct 04 11:28:49 2023 +0200 @@ -10,7 +10,7 @@ unit_t units[3]; ///< Pressure test units SemaphoreHandle_t xSemaphoreUnits = NULL; ///< Semaphore Units records -wifiStation_t wifiStation; +//wifiStation_t wifiStation; @@ -76,114 +76,3 @@ } - -int add_station(uint8_t *SSID, uint8_t *Password) -{ - FILE *f; - uint8_t *dst = (uint8_t *)&wifiStation; - - if (read_station(SSID) >= 0) { - ESP_LOGE(TAG, "add_station %s already exists", SSID); - return -1; - } - - f = fopen("/spiffs/stations.conf", "a+"); - if (f == NULL) { - ESP_LOGE(TAG, "write /spiffs/stations.conf failed"); - return -1; - } - memset(dst, 0, sizeof(wifiStation)); - sprintf(wifiStation.SSID, "%s", (char *)SSID); - sprintf(wifiStation.Password, "%s", (char *)Password); - fwrite(dst, 1, sizeof(wifiStation), f); - fclose(f); - - ESP_LOGI(TAG, "add_station %s record: %d", (char *)SSID, read_station(SSID)); - /* Return the record number */ - return read_station(SSID); -} - - - -int read_station(uint8_t *SSID) -{ - uint8_t *dst = (uint8_t *)&wifiStation; - static int rc; - FILE *f; - size_t bytes; - - if ((SSID == NULL) || (strlen((char *)SSID) == 0)) { - ESP_LOGI(TAG, "read_station(NULL)"); - return -1; - } - - memset(dst, 0, sizeof(wifiStation)); - f = fopen("/spiffs/stations.conf", "r+"); - if (f == NULL) { - f = fopen("/spiffs/stations.conf", "w+"); - fclose(f); - ESP_LOGI(TAG, "/spiffs/stations.conf created, return -1"); - return -1; - } - - rc = 0; - fseek(f, 0, SEEK_SET); - - while (1) { - bytes = fread(dst, 1, sizeof(wifiStation), f); - ESP_LOGI(TAG, " read_station bytes %d size %d", bytes, sizeof(wifiStation)); - if (bytes < sizeof(wifiStation)) { - fclose(f); - memset(dst, 0, sizeof(wifiStation)); - return -1; - } - if (strcmp(wifiStation.SSID, (char *)SSID) == 0) { - // Fount it - fclose(f); - return rc; - } - rc++; - } - return -1; -} - - - -void remove_station(uint8_t *SSID) -{ - FILE *n, *o; - uint8_t *dst; - size_t bytes; - - n = fopen("/spiffs/stations.new", "a"); - if (n == NULL) { - ESP_LOGE(TAG, "cannot create /spiffs/stations.new"); - return; - } - o = fopen("/spiffs/stations.conf", "r"); - if (o == NULL) { - ESP_LOGE(TAG, "cannot open spiffs/stations.conf for reading"); - fclose(n); - return; - } - - dst = (uint8_t*)&wifiStation; - while (true) { - bytes = fread(dst, 1, sizeof(wifiStation), o); - if (bytes == 0) - break; - - if ((strcmp((char *)SSID, wifiStation.SSID) == 0) || (strlen(wifiStation.SSID) == 0)) { - ESP_LOGI(TAG, "remove station %s", (char *)SSID); - } else { - fwrite(dst, 1, sizeof(wifiStation), n); - } - } - fclose(o); - fclose(n); - - rename("/spiffs/stations.conf", "/spiffs/stations.old"); - rename("/spiffs/stations.new", "/spiffs/stations.conf"); - unlink("/spiffs/stations.old"); -} - diff -r 332e85569339 -r 715785443a95 main/config.h --- a/main/config.h Tue Oct 03 19:55:34 2023 +0200 +++ b/main/config.h Wed Oct 04 11:28:49 2023 +0200 @@ -115,39 +115,6 @@ /** - * @brief Records with WiFi stations we have succesfully connected. - */ -typedef struct { - char SSID[32]; ///< Station SSID - char Password[64]; ///< Station password - bool xhide; ///< Hide from AP scan. -} wifiStation_t; ///< Station record. - - -/** - * @brief Add a new station record. - * @param SSID The SSID - * @param Password The password for this SSID - * @return The record number, or -1 if error. - */ -int add_station(uint8_t *SSID, uint8_t *Password); - -/** - * @brief Read station info record. - * @param SSID Search for the SSID and load the record if found. - * @return Return -1 if not found, else the record number and the wifiStation record is filled. - */ -int read_station(uint8_t *SSID); - -/** - * @brief Remove station record. - * @param SSID The SSID to remove. - */ -void remove_station(uint8_t *SSID); - - - -/** * @brief Records that describes the carbonation units, */ typedef struct { diff -r 332e85569339 -r 715785443a95 main/task_user.c --- a/main/task_user.c Tue Oct 03 19:55:34 2023 +0200 +++ b/main/task_user.c Wed Oct 04 11:28:49 2023 +0200 @@ -23,10 +23,6 @@ QueueHandle_t event_queue; ///< Events queue QueueHandle_t gpio_evt_queue = NULL; ///< Rotary pushbutton queue static int PushDuration = 0; ///< Duration of the pushed button -wifiStation_t APs[10]; ///< List of APs we know -int edit_ssid = 0; ///< SSID being edited -int num_ssids = 0; ///< Number of SSIDs we know -wifiStation_t editAP; ///< Data of station to edit char sensors[DS18B20_MAX][17]; ///< Sensors to select uint32_t err_connect = 0; ///< Connect error count uint32_t err_alarm = 0; ///< Alarm watchdog error count @@ -45,7 +41,6 @@ extern int Main_Loop1; ///< Main measure loop extern int update_running; ///< If update is running extern int num_sensors; ///< Detected DS18B20 sensors -extern wifiStation_t wifiStation; extern char hostname[]; @@ -75,7 +70,7 @@ } if (UserTimer == 1) { - ESP_LOGI(TAG, "User inactivity timeout"); + ESP_LOGI(TAG, "UserTimer timeout"); xEventGroupClearBits(xEventGroupUser, TASK_USER_BUSY); u8g2_SetPowerSave(&u8g2, 1); } @@ -84,7 +79,7 @@ } if (LoopTimer == 1) { - ESP_LOGI(TAG, "Alarm Timer timeout"); + ESP_LOGD(TAG, "LoopTimer timeout"); Main_Loop1 = ML1_INIT; } @@ -530,85 +525,6 @@ /** - * @brief The WiFi setup menu. - * @param sub The submenu entry to hilite. - */ -/*void screen_wifi_setup(int sub) -{ - screen_top("WiFi AP setup"); - menu_line(sub == 0, 1, 25, "Lijst AP"); - menu_line(sub == 1, 1, 37, "Nieuw AP"); - menu_line(sub == 2, 1, 49, "Terug"); - u8g2_SendBuffer(&u8g2); -}*/ - - - -/** - * @brief Show the list if WiFi Access Points. - * @param sub The sub entry line. - * @param offset The offset in the list. - */ -/*void screen_list_aps(int sub, int offset) -{ - int i; - wifiStation_t ap; - uint8_t *dst = (uint8_t *)≈ - FILE *f; - size_t bytes; - - num_ssids = 0; - memset(dst, 0, sizeof(ap)); - f = fopen("/spiffs/stations.conf", "r"); - if (f) { - while (1) { - bytes = fread(dst, 1, sizeof(ap), f); - if (bytes < sizeof(ap)) { - fclose(f); - break; - } - memcpy(APs[num_ssids].SSID, ap.SSID, 32); - memcpy(APs[num_ssids].Password, ap.Password, 64); - num_ssids++; - } - } - - screen_top("WiFi AP lijst"); - if (num_ssids == 0) { - menu_line(0, 1, 25, "Geen AP's"); - } else { - for (i = 0; i < num_ssids; i++) { - menu_line(sub == i, 1, 25 + (i * 12), APs[i + offset].SSID); - if (i == 3) - break; - } - if ((i + offset) == num_ssids) - menu_line(sub == i, 1, 25 + (i * 12), "Terug"); - } - u8g2_SendBuffer(&u8g2); -}*/ - - - -/** - * @brief Edit WiFi AP menu. - * @param sub The menu entry to hilite. - */ -/*void screen_edit_ap(int sub) -{ - screen_top("WiFi wijzig AP"); - menu_line(sub == 0, 1, 25, "SSID %s", editAP.SSID); - menu_line(sub == 1, 1, 37, "PSK %s", editAP.Password); - menu_line(sub == 2, 1, 49, "Opslaan"); - if (edit_ssid >= 0) { - menu_line(sub == 3, 1, 61, "Verwijder"); - } - u8g2_SendBuffer(&u8g2); -}*/ - - - -/** * @brief The network status screen. */ void screen_network()