mirror of
https://gitlab.com/wirelos/sprocket-lib.git
synced 2025-12-16 05:24:30 +01:00
37 lines
700 B
C++
37 lines
700 B
C++
#include "Sprocket.h"
|
|
|
|
Sprocket::Sprocket(){
|
|
Serial.println("init sprocket");
|
|
}
|
|
|
|
Sprocket::Sprocket(SprocketConfig cfg){
|
|
config = cfg;
|
|
init(cfg);
|
|
}
|
|
|
|
Sprocket* Sprocket::init(SprocketConfig cfg){
|
|
delay(cfg.startupDelay);
|
|
Serial.begin(cfg.serialBaudRate);
|
|
SPIFFS.begin();
|
|
return this;
|
|
}
|
|
Sprocket* Sprocket::activate() {
|
|
return activate(&scheduler);
|
|
}
|
|
|
|
Sprocket* Sprocket::join(Network& net){
|
|
Serial.println("join network");
|
|
net.init(&scheduler);
|
|
net.connect();
|
|
return activate(&scheduler, &net);
|
|
}
|
|
|
|
Sprocket* Sprocket::addTask(Task& tsk){
|
|
scheduler.addTask(tsk);
|
|
tsk.enable();
|
|
return this;
|
|
}
|
|
|
|
void Sprocket::loop(){
|
|
scheduler.execute();
|
|
} |