Nimbin[12]?Embedded / esp_garden / commits / d3f8af0

esp_garden git · master

Distributed ESP sensor and actuator system (garden)

esp32 esp-idf iot sensors c++ sql · first commit 2025-10-15 · last commit 2026-01-20 (8 months ago) · synced 3 days ago · upstream: git.ide3.de/hsnr/mic/esp_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.gz

Update logging

Chris esp · 2025-11-02 20:33 · d3f8af06ab1d320054a1c178159c70aeb801ac1a

 client_sensor/main/ClientSensor.cpp | 34 ++++++++++++++++------------------
 1 file changed, 16 insertions(+), 18 deletions(-)

diff --git a/client_sensor/main/ClientSensor.cpp b/client_sensor/main/ClientSensor.cpp
index 2463fd2..77d656a 100644
--- a/client_sensor/main/ClientSensor.cpp
+++ b/client_sensor/main/ClientSensor.cpp
@@ -23,9 +23,9 @@ uint8_t config_request_attempts = 0;
 // ----------------------------------------------------------------------------
 // Helper
 // ----------------------------------------------------------------------------
-void printMac(const uint8_t* mac) {
+void printMac(const char *TAG, const uint8_t* mac) {
     if (!mac) return;
-    ESP_LOGI("         ", "%02X:%02X:%02X:%02X:%02X:%02X",
+    ESP_LOGI(TAG, "%02X:%02X:%02X:%02X:%02X:%02X",
              mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
 }
 
@@ -100,7 +100,7 @@ void print_SensorConfig(const SensorConfig_s& cfg) {
     ESP_LOGI(TAG, "  notification_name: %s", cfg.notification_name);
     ESP_LOGI(TAG, "  pumping_delay_sec: %d", cfg.pumping_delay_sec);
     ESP_LOGI(TAG, "  pumping_duration: %d", cfg.pumping_duration);
-    ESP_LOGI(TAG, "  pump_mac: "); printMac(cfg.pump_mac);
+    ESP_LOGI(TAG, "  pump_mac: "); printMac(TAG, cfg.pump_mac);
     ESP_LOGI(TAG, "  delay_ms: %d", cfg.delay_ms);
     ESP_LOGI(TAG, "  use_time: %s", cfg.use_time ? "true" : "false");
     ESP_LOGI(TAG, "  time_count: %u", cfg.time_count);
@@ -199,7 +199,7 @@ void on_DataSent(const wifi_tx_info_t* info, esp_now_send_status_t status) {
     static const char *TAG = "on_DataSent";
 
     ESP_LOGI(TAG, "Packet to ");
-    printMac(info->des_addr);
+    printMac(TAG, info->des_addr);
 
     if (status == ESP_NOW_SEND_SUCCESS)
         ESP_LOGI(TAG, " queued successfully");
@@ -342,11 +342,11 @@ void print_AllPeers() {
     for (int i = 0; i < peerCount.total_num; i++) {
         esp_now_peer_info_t peerInfo;
         res = esp_now_fetch_peer(i, &peerInfo);
+        printMac(TAG, peerInfo.peer_addr);
         if (res == ESP_OK) {
-            ESP_LOGI(TAG, "Peer %d: ", i);
-            printMac(peerInfo.peer_addr);
+            ESP_LOGI(TAG, "Peer is active");
         } else {
-            ESP_LOGE(TAG, "Failed to fetch peer %d", i);
+            ESP_LOGE(TAG, "Failed to fetch peer");
         }
     }
 }
@@ -355,7 +355,7 @@ void add_Peer(const uint8_t* addr, int32_t channel) {
     static const char *TAG = "print_AllPeers";
 
     ESP_LOGI(TAG, "add_Peer: ");
-    printMac(addr);
+    printMac(TAG, addr);
     if (!addr) {
         ESP_LOGE(TAG, "ERROR: null MAC address!");
         return;
@@ -381,11 +381,9 @@ void add_Peer(const uint8_t* addr, int32_t channel) {
 
     esp_err_t res = esp_now_add_peer(&peer);
     if (res == ESP_OK) {
-        ESP_LOGI(TAG, "Added peer: ");
-        printMac(addr);
+        ESP_LOGI(TAG, "Peer added");
     } else {
-        ESP_LOGE(TAG, "Failed to add peer: ");
-        printMac(addr);
+        ESP_LOGE(TAG, "Failed to add");
         ESP_LOGE(TAG, " (ESP_ERR: %d)", res);
     }
 }
@@ -416,7 +414,7 @@ bool send_Message(const uint8_t* peer, const char* message) {
     static const char *TAG = "send_Message";
 
     ESP_LOGI(TAG, "send_Message to");
-    printMac(peer);
+    printMac(TAG, peer);
     ESP_LOGI(TAG, "  %s", message);
     if (!esp_now_is_peer_exist(peer)) {
         ESP_LOGE(TAG, "ERROR: peer doese not exist!");
@@ -446,7 +444,7 @@ bool send_AndWaitResponse(const uint8_t* peer, const char* message, uint32_t tim
 
     if (!response_received) {
         ESP_LOGE(TAG, "No Response received from ");
-        printMac(peer);
+        printMac(TAG, peer);
         return false;
     }
 
@@ -620,7 +618,7 @@ void on_DataRecvSensorConfig(const esp_now_recv_info* info, const uint8_t* data,
     static const char *TAG = "on_DataRecvSensorConfig";
 
     if (!info || !data || len <= 0) return;
-    printMac(info->src_addr);
+    printMac(TAG, info->src_addr);
     if (memcmp(info->src_addr, PEER_SERVER, 6) != 0) return;
 
     int copylen = len < (int)sizeof(sensor_config_message) - 1 ? len : (int)sizeof(sensor_config_message) - 1;
@@ -825,7 +823,7 @@ void send_DataToPumpAndServer(size_t config_id, uint32_t value, bool shall_pump)
 
     char message[64];
 
-    ESP_LOGI(TAG, "Sending to Pump: "); printMac(p.pump_mac);
+    ESP_LOGI(TAG, "Sending to Pump: "); printMac(TAG, p.pump_mac);
     snprintf(message, sizeof(message), "p:%lld:%s:%d:%d:%lld",
             get_CurrentUnix(),
             p.notification_name,
@@ -842,7 +840,7 @@ void send_DataToPumpAndServer(size_t config_id, uint32_t value, bool shall_pump)
     while (!send_response_process_complete)
             vTaskDelay(pdMS_TO_TICKS(100));
 
-    ESP_LOGI(TAG, "Sending to Server: "); printMac(PEER_SERVER);
+    ESP_LOGI(TAG, "Sending to Server: "); printMac(TAG, PEER_SERVER);
     snprintf(message, sizeof(message), "%s:%lu:%lld:%d",
             p.sensor_name,
             value,
@@ -866,7 +864,7 @@ void send_NextSensorReadToPeer(const uint8_t* mac, int64_t unix_time) {
     snprintf(message, sizeof(message), "next_read:%lld", unix_time);
 
     ESP_LOGI(TAG, "Sending to peer: ");
-    printMac(mac);
+    printMac(TAG, mac);
     if (!send_Message(mac, message)) {
         ESP_LOGE(TAG, "Delivery failed or peer offline!");
     }