Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zimbora/esp32-autorequest
Library to sync tasks with clock and calculate timestamp of next execution
https://github.com/zimbora/esp32-autorequest
Last synced: 2 days ago
JSON representation
Library to sync tasks with clock and calculate timestamp of next execution
- Host: GitHub
- URL: https://github.com/zimbora/esp32-autorequest
- Owner: zimbora
- License: mit
- Created: 2022-10-28T09:23:46.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-04T18:19:21.000Z (about 1 year ago)
- Last Synced: 2024-04-29T22:42:01.791Z (7 months ago)
- Language: C++
- Size: 149 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# esp32-autorequest
## Description
package to sync tasks with clock and calculate timestamp of next execution## Implementation
Autorequests are stored in a JsonDocument with the following structure
```
doc_alarm = {[
ref : {
"period" : period,
"timeout" : timeout
}]
}
```
## Public Methods
[bool add(String ref, uint32_t period)](#Add-object-1)[bool check(String ref)](#Check-Autorequest-1)
[bool check(String ref, bool(*callback)(String))](#Check-Autorequest-2)
[void list()](#List)
[JsonObject get(String ref)](#Get)
## Examples
Run programs inside examples folder to check how it works
### demo
Add autorequests and then check it forever
### demo_callback
Add autorequests and then check it forever. If autorequest timed out registered callback is called
### test_limits
Check how many autorequests can be handled with actual parameters## Unit Test with clang
>> chmod u+x make.sh>> ./make.sh
If needed uncomment DEBUG FLAGS in Makefile
## TODO
..## Public Methods - Extension
### Add object 1
return true if has succeed
```
bool AUTOREQUEST::add(String ref, uint32_t period)
```
#### Example
```
if(!Ar.add("sensor2",300)){
Serial.println("!! Error adding sensor2 autorequest");
}
```### Check Autorequest 1
return true if it is time to execute autorequest
```
bool AUTOREQUEST::check(String ref)
```
#### Example
```
String ref = "sensor1"
Ar.check(ref);
```### Check Autorequest 2
return true if is in autorequestcall callback function if autorequest goes out of the range limit or returns to the range limit
```
bool AUTOREQUEST::check(String ref, bool(*callback)(String))
```
#### Example
```
bool (*callback)(String);
bool calledInAutorequest(String ref){
Serial.println("autorequest was changed");
return true;
}callback = &calledInAutorequest;
Ar.check(ref,callback);
```### List
```
void AUTOREQUEST::list()
```
#### Example
```
Ar.list();
```### Get
```
JsonObject AUTOREQUEST::get(String ref)
```
#### Example
```
JsonObject object = Ar.get("sensor1");
```