diff --git a/client/client/lib/espnow/src/ESPNow.cpp b/client/client/lib/espnow/src/ESPNow.cpp index 200c1b47846a006fe8af4335f6b4d18277dcb260..a92f79b459369a84d7b7cea564f5955bcfe9122d 100644 --- a/client/client/lib/espnow/src/ESPNow.cpp +++ b/client/client/lib/espnow/src/ESPNow.cpp @@ -39,6 +39,7 @@ void on_data_recv(const uint8_t *mac, const uint8_t *incomingData, int len) if (!preferences.isKey("host")) { preferences.putBytes("host", new_config.host, sizeof(new_config.host)); ESP_LOGI(TAG, "host MAC address saved to flash"); + // add host to peers esp_now_peer_info_t host; memset(&host, 0, sizeof(host)); @@ -48,13 +49,12 @@ void on_data_recv(const uint8_t *mac, const uint8_t *incomingData, int len) if(esp_now_add_peer(&host) != ESP_OK){ ESP_LOGE(TAG, "Adding host to peers failed"); } + } // host change shouldn't be an issue preferences.end(); // sync time Time::getInstance().setTime( - new_config.time_millis); // see https://www.esp32.com/viewtopic.php?t=9965, maybe this needs an offset - Serial.println("received time: " + (String) new_config.time_millis); - Serial.println("new time: " + (String) Time::getInstance().getMillis()); + new_config.epoch_seconds); // see https://www.esp32.com/viewtopic.php?t=9965, maybe this needs an offset } esp_err_t espnow_setup() diff --git a/client/client/lib/espnow/src/ESPNow.hpp b/client/client/lib/espnow/src/ESPNow.hpp index c28cfe2ba1c2ee181c0950695381aa938000c13b..df2289925df6eb57f8b3e8e114f9812e5d23dbe3 100644 --- a/client/client/lib/espnow/src/ESPNow.hpp +++ b/client/client/lib/espnow/src/ESPNow.hpp @@ -13,7 +13,7 @@ typedef struct config { uint8_t host[6]; - long time_millis; + long epoch_seconds; } config; esp_err_t espnow_setup();