package to sync tasks with clock and calculate timestamp of next execution
Autorequests are stored in a JsonDocument with the following structure
doc_alarm = {[
ref : {
"period" : period,
"timeout" : timeout
}]
}
bool add(String ref, uint32_t period)
bool check(String ref, bool(*callback)(String))
Run programs inside examples folder to check how it works
Add autorequests and then check it forever
Add autorequests and then check it forever. If autorequest timed out registered callback is called
Check how many autorequests can be handled with actual parameters
chmod u+x make.sh
./make.sh
If needed uncomment DEBUG FLAGS in Makefile
..
return true if has succeed
bool AUTOREQUEST::add(String ref, uint32_t period)
if(!Ar.add("sensor2",300)){
Serial.println("!! Error adding sensor2 autorequest");
}
return true if it is time to execute autorequest
bool AUTOREQUEST::check(String ref)
String ref = "sensor1"
Ar.check(ref);
return true if is in autorequest
call callback function if autorequest goes out of the range limit or returns to the range limit
bool AUTOREQUEST::check(String ref, bool(*callback)(String))
bool (*callback)(String);
bool calledInAutorequest(String ref){
Serial.println("autorequest was changed");
return true;
}
callback = &calledInAutorequest;
Ar.check(ref,callback);
void AUTOREQUEST::list()
Ar.list();
JsonObject AUTOREQUEST::get(String ref)
JsonObject object = Ar.get("sensor1");