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

ram caching implemented, not compiling: 'ArduinoJson.h file not found'

parent f8318530
No related branches found
No related tags found
4 merge requests!39Merge Develop into Main,!19development into master,!17Inital Host, initial Client,!6Espnow
#include "ram_caching.hpp" #include "ram_caching.hpp"
// 2D array of 20 Strings with maxLength of 251
RTC_DATA_ATTR char storage[maxSize_][maxLength_];
RTC_DATA_ATTR int headElement = 0;
RTC_DATA_ATTR int tailElement = 0;
static const char* TAG = "CACHING"; static const char* TAG = "CACHING";
const int NUM_SENSORS = 10;
void put(ClientDataPackage data){
// turn data into char array
const char* jsonString = data.getDataPackageAsMinifiedJsonString().c_str();
// move head to beginning of new element
// head = (head + (sizeof(char) * 251)) % sizeof(storage);
headElement = (headElement + 1) % maxSize_;
// copy data to earliest free block
memcpy( &storage + headElement*maxSize_,
jsonString,
sizeof(jsonString)
);
}
String get_from_storage(){
// remove element pointed at by tail
String buf = "";
char current;
for(int i = 0; i<251; i++){
// i dont like this
memcpy(&current, &storage + (tailElement*maxSize_) + i, sizeof(char));
buf += current;
if(current = '\0'){
break;
}
}
// move tail to next element
tailElement = (tailElement + 1) % maxLength_;
Serial.println(buf);
return buf;
}
//RTC_DATA_ATTR int cachedAmount = -1; //RTC_DATA_ATTR int cachedAmount = -1;
//RTC_DATA_ATTR ClientDataPackage backup[NUM_SENSORS]; //RTC_DATA_ATTR ClientDataPackage backup[NUM_SENSORS];
......
#ifndef _RAM_CACHE #ifndef _RAM_CACHE
#define _RAM_CACHE #define _RAM_CACHE
//#include "ClientDataPackage.hpp" #include <ClientDataPackage.hpp>
#include "esp_log.h" #include "esp_log.h"
#include <ESP32Time.h> #include <ESP32Time.h>
bool ram_cache_is_empty(); #define maxSize_ 20
bool ram_cache_is_full(); #define maxLength_ 251
//void ram_cache_push(ClientDataPackage data);
//ClientDataPackage ram_cache_pop(); void put(ClientDataPackage data);
ClientDataPackage get();
// bool ram_cache_is_empty();
// bool ram_cache_is_full();
// void ram(ClientDataPackage data);
// ClientDataPackage ram_cache_pop();
#endif #endif
\ No newline at end of file
#pragma once #pragma once
#include "ArduinoJson.h" #include <ArduinoJson.h>
#include "MeasurementData.hpp" #include "MeasurementData.hpp"
#include "Protocol.hpp" #include "Protocol.hpp"
#include "SensorInformation.hpp" #include "SensorInformation.hpp"
......
  • Developer

    Compile error:

    Compiling .pio/build/esp32-c3-devkitm-1/lib2f0/caching/ram_caching.cpp.o
    In file included from lib/caching/src/ram_caching.hpp:3,
                     from lib/caching/src/ram_caching.cpp:1:
    lib/espnow/src/ClientDataPackage.hpp:3:10: fatal error: ArduinoJson.h: No such file or directory 

    I do not know why this happens. The library is installed and including ClientDataPackage in other libs (e.g. deep sleep) does not throw this error...

    Edited by Moritz Perschke
  • Maintainer

    Ill try building it. From my experience, this error can be solved by cleaning the project build files and rebuilding.

    Edited by Zoe Pfister
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