diff --git a/client/client/src/main.cpp b/client/client/src/main.cpp index 3f34c4f4c06b4ce50c9c02b3433f77cf9f6a7149..2412091516891d5e7e56f22caa7aab4e466fc624 100644 --- a/client/client/src/main.cpp +++ b/client/client/src/main.cpp @@ -38,17 +38,17 @@ void loop() new_data.add_data(++counter * 1.1, 0); new_data.add_data(counter * 1.2, 1); new_data.add_data(counter * 1.3, 2); - new_data.send(); + espnow_send_message(new_data); // if(!ram_cache_is_empty()){ // ClientDataPackage old_data = ram_cache_pop(); // Message* resend_message = new Message(old_data); // resend_message->send(); - // delete resend_message; + // delete resend_message;u // } Serial.println(esptime::rtc.getMillis()); Serial.println("delaying..."); Serial.flush(); delay(5000); // 5 second receive window - deep_sleep(900); // go to sleep for 15 mins (900s) + // deep_sleep(900); // go to sleep for 15 mins (900s) } \ No newline at end of file diff --git a/host/fipy/lib/espnow.py b/host/fipy/lib/espnow.py index 6afe2a8b0c2d766e626dd864c493e6a3dd8ab6e7..21f4d5738e7c234d0b8b7b855a42e9e4f85a1409 100644 --- a/host/fipy/lib/espnow.py +++ b/host/fipy/lib/espnow.py @@ -41,6 +41,10 @@ def espnow_recv(result): espnow_respond(mac) +def espnow_broadcast_config(): + msg = struct.pack("<6sl", self_mac, time.time()) + ESPNOW.send(None, msg) + def bytes_to_data(msg): # turn bytes from message into 22-tuple of integers(identifiers), floats(values), integer(amount) and long(timestamp) data = struct.unpack("<10i10fil", bytes(msg)) diff --git a/host/fipy/main.py b/host/fipy/main.py index 020d027e0345c701725c418eade7e55179d05551..2d0fb65cc905211b1e7dfdf9a647f8658e4f4c90 100644 --- a/host/fipy/main.py +++ b/host/fipy/main.py @@ -2,7 +2,7 @@ # from network import ESPNOW from time import sleep from lib.server_transfer import DataTransferWiFi -from lib.espnow import Forte_ESPNOW +from lib.espnow import Forte_ESPNOW, espnow_broadcast_config from lib.rtc_time import RTCTime # data = DataTransferWiFi() @@ -14,6 +14,7 @@ from lib.rtc_time import RTCTime # rtc_time = RTCTime((2014, 5, 1, 4, 13, 0, 0, 0)) espnow = Forte_ESPNOW() +espnow_broadcast_config() while True: sleep(5) pass