mirror of
https://gitlab.com/wirelos/sprocket-lib.git
synced 2025-12-16 05:24:30 +01:00
stuff
This commit is contained in:
@@ -52,7 +52,6 @@ struct JsonStruct {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void fromFile(const char* path) {
|
void fromFile(const char* path) {
|
||||||
Serial.println("read json");
|
|
||||||
File configFile = SPIFFS.open(path, "r");
|
File configFile = SPIFFS.open(path, "r");
|
||||||
String cfgFileStr = configFile.readString();
|
String cfgFileStr = configFile.readString();
|
||||||
|
|
||||||
@@ -68,11 +67,10 @@ struct JsonStruct {
|
|||||||
valid = verifyJsonObject(json);
|
valid = verifyJsonObject(json);
|
||||||
|
|
||||||
if(configFile) {
|
if(configFile) {
|
||||||
Serial.println("map json object");
|
|
||||||
fromJsonObject(json);
|
fromJsonObject(json);
|
||||||
}
|
}
|
||||||
if(!valid){
|
if(!valid){
|
||||||
Serial.println("read json failed");
|
Serial.println("ERROR: read failed for " + String(path));
|
||||||
}
|
}
|
||||||
configFile.close();
|
configFile.close();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,28 +22,14 @@ class MeshSprocket : public Sprocket {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void onChangedConnections(){};
|
|
||||||
virtual void onNewConnection(){};
|
|
||||||
|
|
||||||
Sprocket* activate(Scheduler* scheduler, Network* network) {
|
Sprocket* activate(Scheduler* scheduler, Network* network) {
|
||||||
Sprocket::activate(scheduler, network);
|
Sprocket::activate(scheduler, network);
|
||||||
net = static_cast<MeshNet*>(network);
|
net = static_cast<MeshNet*>(network);
|
||||||
net->onReceive(bind(&MeshSprocket::dispatch,this, _1, _2));
|
net->onReceive(bind(&MeshSprocket::dispatch,this, _1, _2));
|
||||||
net->mesh.onNewConnection(bind(&MeshSprocket::newConnection,this, _1));
|
|
||||||
net->mesh.onChangedConnections(bind(&MeshSprocket::connectionChanged,this));
|
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
} using Sprocket::activate;
|
} using Sprocket::activate;
|
||||||
|
|
||||||
virtual void newConnection(uint32_t nodeId){
|
|
||||||
PRINT_MSG(Serial, "MeshSprocket", "connected to %u", nodeId);
|
|
||||||
onNewConnection();
|
|
||||||
}
|
|
||||||
virtual void connectionChanged(){
|
|
||||||
PRINT_MSG(Serial, "MeshSprocket", "connection changed");
|
|
||||||
onChangedConnections();
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void onMessage(uint32_t from, String &msg) {
|
virtual void onMessage(uint32_t from, String &msg) {
|
||||||
Serial.printf("MeshSprocket onMessage: received from %u msg=%s\n", from, msg.c_str());
|
Serial.printf("MeshSprocket onMessage: received from %u msg=%s\n", from, msg.c_str());
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user