trying to wrap my head around data storage. I have a string that will publish, but what if there is no connection to the cloud at the time. I would like to store the data temporarily (without overloading the heap). it seems the EEPROM storage would work, but I cannot find an example I can understand. I am logging data from the assettracker and publishing every 2 minutes the vehicle is moving. Due to the cellular signal in my area, i may need up to 10 (20 min) of data stored and sent out when particle connects again. Each string is roughly 80 bytes.
// begin code
if(Particle.connected()) {
lat = (t.readLatDeg());
lon = (t.readLonDeg());
speedKnots = t.getSpeed();
speedMph = speedKnots*1.151;
if(speedMph < 2.5) {
speedMph = 0; }
Pconn = "yes";
devHour = Time.hour();
devMin = Time.minute();
devSec = Time.second();
devYear = Time.year();
devMonth = Time.month();
devDay = Time.day();
char data[256];
snprintf(data, sizeof(data), "{%f,%f,%.2f,%.2f,%s,%i,%i,%i,%i,%i,%i,%i,%s}", lat, lon, speedMph, fuel.getVCell(), devicepre , unitId, devHour, devMin, devSec, devYear, devMonth, devDay, Pconn);
Particle.publish("CELL", data, PRIVATE);
lastPublish = millis();
lastPubSpeed = speedMph;
pubOffset = 0;
increaseTime = 0;
} else {
lat = (t.readLatDeg());
lon = (t.readLonDeg());
speedKnots = t.getSpeed();
speedMph = speedKnots*1.151;
if(speedMph < 2) {
speedMph = 0; }
Pconn = "no";
devHour = Time.hour();
devMin = Time.minute();
devSec = Time.second();
devYear = Time.year();
devMonth = Time.month();
devDay = Time.day();
//SD is Saved Data
if(SD < 10) {
// the problem with this is you would only the last string that wasn't published or the 10th depending how long service wasn't avail
SD=SD+1;
char data[256];
snprintf(data, sizeof(data), "{%f,%f,%.2f,%.2f,%s,%i,%i,%i,%i,%i,%i,%i,%s}", lat, lon, speedMph, fuel.getVCell(), devicepre , unitId, devHour, devMin, devSec, devYear, devMonth, devDay, Pconn);
Sdata = data;
lastPubSpeed = speedMph;
lastPublish = millis();
pubOffset = 0;
increaseTime = 0;
}
// now i need some sort of a way to break up the individual data stored and send them in intervals when the cloud is connected.
if(SD>0 && Particle.connected() {
for(int d=1;d<SD;d=d++) {
/* still i have only one string to send , i have tried Sdata[d] but i don't think that is anywhere close to being correct. in PHP I can parse a large string by delimitators, but i cannot figure that out in c++ i tried adding Sdata = Sdata + " : " + NewData , something similar i have tried a lot of different things */
char data[256];
snprintf(data, sizeof(data), Sdata);
Particle.publish("CELL", data, PRIVATE);
delay(2000); // could delay longer here
}
SD=0;
}
// end code
any help is very much appreciated