diff --git a/client/client/lib/caching/src/ram_caching.cpp b/client/client/lib/caching/src/ram_caching.cpp index f40da863249828ed6b5cba436682a68cbb972078..7b3e4372177608b2392c703dbd352e6a7b47cabb 100644 --- a/client/client/lib/caching/src/ram_caching.cpp +++ b/client/client/lib/caching/src/ram_caching.cpp @@ -8,7 +8,7 @@ data_struct ram_cache_pop(){ return backup[cachedAmount--]; } -bool ram_cache_push(data_struct data){ +void ram_cache_push(data_struct data){ backup[++cachedAmount] = data; } diff --git a/client/client/lib/caching/src/ram_caching.hpp b/client/client/lib/caching/src/ram_caching.hpp index 888719bf212b7275cd0fefc594017e51a16768cd..979e8496faf9599c0621300b8714fd359321f05b 100644 --- a/client/client/lib/caching/src/ram_caching.hpp +++ b/client/client/lib/caching/src/ram_caching.hpp @@ -2,9 +2,9 @@ #define _RAM_CACHE #include "espnow.hpp" -bool ram_cache_push(data_struct data); bool ram_cache_is_empty(); bool ram_cache_is_full(); +void ram_cache_push(data_struct data); data_struct ram_cache_pop(); #endif \ No newline at end of file diff --git a/client/client/lib/espnow/src/espnow.cpp b/client/client/lib/espnow/src/espnow.cpp index 7ebf2b6bbc81bc6551a3b38c4330fd1117638adc..01673d71390d380bdfd56c26473bd5557d383bfd 100644 --- a/client/client/lib/espnow/src/espnow.cpp +++ b/client/client/lib/espnow/src/espnow.cpp @@ -3,6 +3,7 @@ #include <ESP32Time.h> #include "WiFi.h" #include "espnow.hpp" +#include "ram_caching.hpp" uint8_t BROADCAST_MAC[] = {0x58, 0xCF, 0x79, 0x04, 0x37, 0x38}; esp_now_peer_info_t hostInfo; @@ -72,7 +73,11 @@ esp_err_t Message::send(){ Serial.println("sending Message"); esp_err_t success; success = esp_now_send(recipient, (uint8_t *) &data, sizeof(data)); - + if(success != ESP_OK){ + if(!ram_cache_is_full()){ + ram_cache_push(*data); + } + } for(int i=0; i<data->amountData; i++){ Serial.println(data->values[i]); }