mirror of
https://gitlab.com/wirelos/sprocket-lib.git
synced 2025-12-16 13:25:03 +01:00
28 lines
892 B
C++
28 lines
892 B
C++
#ifndef __NETWORK_H__
|
|
#define __NETWORK_H__
|
|
|
|
#include <Arduino.h>
|
|
#include <TaskSchedulerDeclarations.h>
|
|
|
|
typedef std::function<void(uint32_t from, String &msg)> msgReceived_cb;
|
|
|
|
class Network {
|
|
public:
|
|
uint32_t id = 0;
|
|
Scheduler* scheduler;
|
|
virtual Network* init() { return this; };
|
|
virtual Network* init(Scheduler* s) { scheduler = s; return init(); };
|
|
virtual Network* connect() { return this; };
|
|
virtual Network* connectStation() { return this; };
|
|
virtual int isConnected(){ return 0; };
|
|
virtual void update() {};
|
|
virtual void broadcast(String msg){};
|
|
virtual void sendTo(uint32_t target, String msg) {};
|
|
virtual void onReceive(std::function<void(uint32_t from, String &msg)>);
|
|
Network* setScheduler(Scheduler* s) {
|
|
scheduler = s;
|
|
return this;
|
|
}
|
|
};
|
|
|
|
#endif |