Skip to content
Snippets Groups Projects
Commit 0aeede80 authored by Moritz Perschke's avatar Moritz Perschke
Browse files

Message::send() now caches data

parent 969e7ded
No related branches found
No related tags found
5 merge requests!39Merge Develop into Main,!19development into master,!17Inital Host, initial Client,!3Merge Branch `develop` into `sensor_readout`,!1Espnow
...@@ -8,7 +8,7 @@ data_struct ram_cache_pop(){ ...@@ -8,7 +8,7 @@ data_struct ram_cache_pop(){
return backup[cachedAmount--]; return backup[cachedAmount--];
} }
bool ram_cache_push(data_struct data){ void ram_cache_push(data_struct data){
backup[++cachedAmount] = data; backup[++cachedAmount] = data;
} }
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
#define _RAM_CACHE #define _RAM_CACHE
#include "espnow.hpp" #include "espnow.hpp"
bool ram_cache_push(data_struct data);
bool ram_cache_is_empty(); bool ram_cache_is_empty();
bool ram_cache_is_full(); bool ram_cache_is_full();
void ram_cache_push(data_struct data);
data_struct ram_cache_pop(); data_struct ram_cache_pop();
#endif #endif
\ No newline at end of file
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <ESP32Time.h> #include <ESP32Time.h>
#include "WiFi.h" #include "WiFi.h"
#include "espnow.hpp" #include "espnow.hpp"
#include "ram_caching.hpp"
uint8_t BROADCAST_MAC[] = {0x58, 0xCF, 0x79, 0x04, 0x37, 0x38}; uint8_t BROADCAST_MAC[] = {0x58, 0xCF, 0x79, 0x04, 0x37, 0x38};
esp_now_peer_info_t hostInfo; esp_now_peer_info_t hostInfo;
...@@ -72,7 +73,11 @@ esp_err_t Message::send(){ ...@@ -72,7 +73,11 @@ esp_err_t Message::send(){
Serial.println("sending Message"); Serial.println("sending Message");
esp_err_t success; esp_err_t success;
success = esp_now_send(recipient, (uint8_t *) &data, sizeof(data)); 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++){ for(int i=0; i<data->amountData; i++){
Serial.println(data->values[i]); Serial.println(data->values[i]);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment