esp_garden git · master
Distributed ESP sensor and actuator system (garden)
C++ 70.7% Markdown 18% C 10.7%git clone https://git.christianimmanuel.de/embedded/esp_garden.gitwget https://git.christianimmanuel.de/embedded/esp_garden/archive/esp_garden.tar.gzUpdate dont send config mac from Web, they are going to handshake over esp-server now
client_sensor/ClientSensor.cpp | 12 ++++++++---- post_server/WiFiManager.cpp | 6 +++--- server/Server.cpp | 3 +-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/client_sensor/ClientSensor.cpp b/client_sensor/ClientSensor.cpp index 3f48519..4d2f953 100644 --- a/client_sensor/ClientSensor.cpp +++ b/client_sensor/ClientSensor.cpp @@ -578,16 +578,18 @@ bool request_SensorConfig(const char* sensor_name) { cfg->notification_name[sizeof(cfg->notification_name)-1] = '\0'; cfg->pumping_delay_sec = atoi(tokens[5]); cfg->pumping_duration = atoi(tokens[6]); + /* uint8_t new_mac[6]; sscanf(tokens[7], "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &new_mac[0], &new_mac[1], &new_mac[2], &new_mac[3], &new_mac[4], &new_mac[5]); - cfg->delay_ms = atoi(tokens[8]); - cfg->use_time = atoi(tokens[9]) != 0; + */ + cfg->delay_ms = atoi(tokens[7]); + cfg->use_time = atoi(tokens[8]) != 0; // times cfg->time_count = 0; - if (cfg->use_time && count_token > 10 && strncmp(tokens[10], "times=", 6) == 0) { - char *time_str = tokens[10] + 6; + if (cfg->use_time && count_token > 9 && strncmp(tokens[9], "times=", 6) == 0) { + char *time_str = tokens[9] + 6; char *time_tok = strtok(time_str, "|"); while (time_tok && cfg->time_count < 8) { cfg->times[cfg->time_count++] = (uint16_t)atoi(time_tok); @@ -595,6 +597,7 @@ bool request_SensorConfig(const char* sensor_name) { } } + /* for (int i = 0; i < 6; i++) { if (new_mac[i] != cfg->pump_mac[i]) { DBG_PRINTLN("New mac address!"); @@ -610,6 +613,7 @@ bool request_SensorConfig(const char* sensor_name) { break; } } + */ if (cfg->last_sensor_read == 0) { DBG_PRINTLN("RESETTING last_sensor_read"); diff --git a/post_server/WiFiManager.cpp b/post_server/WiFiManager.cpp index c2c1a5e..3d0489b 100644 --- a/post_server/WiFiManager.cpp +++ b/post_server/WiFiManager.cpp @@ -132,7 +132,7 @@ bool WIFI_GetSensorConfigServer(const char* sensor_name, SensorConfigServer_s &c cfg.is_active = extractBool("is_active"); extractString("notification_name", cfg.notification_name, sizeof(cfg.notification_name)); - extractString("pump_mac", cfg.pump_mac, sizeof(cfg.pump_mac)); + //extractString("pump_mac", cfg.pump_mac, sizeof(cfg.pump_mac)); cfg.pumping_delay_sec = extractInt("pumping_delay_sec"); cfg.pumping_duration = extractInt("pumping_duration"); @@ -164,8 +164,8 @@ bool WIFI_GetSensorConfigServer(const char* sensor_name, SensorConfigServer_s &c DBG_PRINTF("Parsed: success=%d pin=%d min=%d delay=%d use_time=%d time_count=%u\n", cfg.success, cfg.pin, cfg.min_moisture, cfg.delay_ms, cfg.use_time, cfg.time_count); - DBG_PRINTF("sensor_name='%s' notification='%s' pump_mac='%s' pumping_delay_sec='%d' pumping_duration='%d'\n", - cfg.sensor_name, cfg.notification_name, cfg.pump_mac, cfg.pumping_delay_sec, cfg.pumping_duration); + DBG_PRINTF("sensor_name='%s' notification='%s' pumping_delay_sec='%d' pumping_duration='%d'\n", + cfg.sensor_name, cfg.notification_name, cfg.pumping_delay_sec, cfg.pumping_duration); return cfg.success; } diff --git a/server/Server.cpp b/server/Server.cpp index b301b96..2dcd39e 100644 --- a/server/Server.cpp +++ b/server/Server.cpp @@ -290,7 +290,7 @@ void get_PendingConfigFromServer() { if (WIFI_GetSensorConfigServer(pending_config.sensor_name, cfg_response)) { char response[250]; int len_out = snprintf(response, sizeof(response), - "cfg:%s,%d,%d,%d,%s,%d,%d,%s,%d,%d", + "cfg:%s,%d,%d,%d,%s,%d,%d,%d,%d", cfg_response.sensor_name, cfg_response.is_active, cfg_response.pin, @@ -298,7 +298,6 @@ void get_PendingConfigFromServer() { cfg_response.notification_name, cfg_response.pumping_delay_sec, cfg_response.pumping_duration, - cfg_response.pump_mac, cfg_response.delay_ms, cfg_response.use_time);