From f5efcdf33ae86b79237e89fcff09939f476e0ce6 Mon Sep 17 00:00:00 2001
From: Moritz Perschke <moritz.perschke@uibk.ac.at>
Date: Wed, 3 Aug 2022 13:42:50 +0200
Subject: [PATCH] cleanup

---
 client/client/lib/espnow/src/espnow.cpp | 9 ++++-----
 host/esp32/lib/espnow/src/espnow.cpp    | 4 ----
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/client/client/lib/espnow/src/espnow.cpp b/client/client/lib/espnow/src/espnow.cpp
index 25e45c3..7ebf2b6 100644
--- a/client/client/lib/espnow/src/espnow.cpp
+++ b/client/client/lib/espnow/src/espnow.cpp
@@ -4,8 +4,7 @@
 #include "WiFi.h"
 #include "espnow.hpp"
 
-uint8_t A_MAC[] = {0x58, 0xCF, 0x79, 0x04, 0x37, 0x38};
-bool host_defined = false;
+uint8_t BROADCAST_MAC[] = {0x58, 0xCF, 0x79, 0x04, 0x37, 0x38};
 esp_now_peer_info_t hostInfo;
 Preferences preferences;
 ESP32Time rtc;
@@ -47,9 +46,9 @@ esp_err_t espnow_setup(){
         Serial.println("Mac used from flash");
     }
     else{
-        memcpy(hostInfo.peer_addr, A_MAC, sizeof(hostInfo.peer_addr));
+        memcpy(hostInfo.peer_addr, BROADCAST_MAC, sizeof(hostInfo.peer_addr));
     }
-    preferences.end();
+    preferences.end(); // check if there is a host saved in flash mem, broadcast otherwise
 
     hostInfo.channel = 0;
     hostInfo.encrypt = 0;
@@ -95,7 +94,7 @@ Message :: Message(){
         preferences.getBytes("host", recipient, sizeof(uint8_t) * 6);
     }
     else{
-        memcpy(recipient, A_MAC, sizeof(A_MAC));
+        memcpy(recipient, BROADCAST_MAC, sizeof(BROADCAST_MAC));
         Serial.println("backup mac used");
     }
     preferences.end();
diff --git a/host/esp32/lib/espnow/src/espnow.cpp b/host/esp32/lib/espnow/src/espnow.cpp
index 71f8c96..a8730cf 100644
--- a/host/esp32/lib/espnow/src/espnow.cpp
+++ b/host/esp32/lib/espnow/src/espnow.cpp
@@ -17,10 +17,6 @@ void on_data_recv(const uint8_t *mac, const uint8_t *incomingData, int len){
     data_struct lastData;
     memcpy(&lastData, incomingData, sizeof(lastData));
     Serial.println("message copied");
-    // for(int i=0; i<lastData.amountData; i++){
-    //     Serial.print((String) lastData.identifiers[i] + ": ");
-    //     Serial.println((String) lastData.values[i]);
-    // }
     Serial.println((String) lastData.values[0]);
     Serial.println((String) "sent time: " + lastData.timestamp);
     Serial.println((String) "RTC time: " + rtc.getMillis());
-- 
GitLab