diff --git a/client/client/lib/caching/src/ram_caching.cpp b/client/client/lib/caching/src/ram_caching.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f40da863249828ed6b5cba436682a68cbb972078 --- /dev/null +++ b/client/client/lib/caching/src/ram_caching.cpp @@ -0,0 +1,21 @@ +#include <Arduino.h> +#include "espnow.hpp" + +RTC_DATA_ATTR int cachedAmount = -1; +RTC_DATA_ATTR data_struct backup[10]; + +data_struct ram_cache_pop(){ + return backup[cachedAmount--]; +} + +bool ram_cache_push(data_struct data){ + backup[++cachedAmount] = data; +} + +bool ram_cache_is_empty(){ + return cachedAmount == -1; +} + +bool ram_cache_is_full(){ + return cachedAmount == 9; +} \ No newline at end of file diff --git a/client/client/lib/caching/src/ram_caching.hpp b/client/client/lib/caching/src/ram_caching.hpp new file mode 100644 index 0000000000000000000000000000000000000000..888719bf212b7275cd0fefc594017e51a16768cd --- /dev/null +++ b/client/client/lib/caching/src/ram_caching.hpp @@ -0,0 +1,10 @@ +#ifndef _RAM_CACHE +#define _RAM_CACHE +#include "espnow.hpp" + +bool ram_cache_push(data_struct data); +bool ram_cache_is_empty(); +bool ram_cache_is_full(); +data_struct ram_cache_pop(); + +#endif \ No newline at end of file diff --git a/client/client/lib/espnow/src/espnow.hpp b/client/client/lib/espnow/src/espnow.hpp index 7fa8ff003755d1be4b8e8890e033a6d6e1770327..50f65ab05c96a16d8a5a83f247be11dc8cc80c0f 100644 --- a/client/client/lib/espnow/src/espnow.hpp +++ b/client/client/lib/espnow/src/espnow.hpp @@ -22,6 +22,7 @@ typedef struct config{ class Message{ public: Message(); + Message(data_struct old_data); void add_data(float value, int identifier); esp_err_t send();