moar topics

This commit is contained in:
2018-09-17 15:34:24 +02:00
parent 939f167dad
commit ad8ba61986
7 changed files with 91 additions and 12 deletions

View File

@@ -53,6 +53,7 @@ class IlluCat : public MeshSprocket {
pixelConfig.defaultColor = 100;
}
// TDOO remove
virtual void scanningAnimation() {
pixels->Scanner(pixels->Wheel(COLOR_NOT_CONNECTED), pixelConfig.updateInterval);
//pixels->Fade(0, pixels->Color(255,255,255), 4, pixelConfig.updateInterval, FORWARD);
@@ -97,7 +98,8 @@ class IlluCat : public MeshSprocket {
server->addHandler(ws);
// FIXME OnDisable is triggered after last scan, aprx. 10 sec
net->mesh.stationScan.task.setOnDisable(bind(&IlluCat::defaultAnimation,this));
// FIXME chck if this is also triggered when new connection arrives
//net->mesh.stationScan.task.setOnDisable(bind(&IlluCat::defaultAnimation,this));
return MeshSprocket::activate(scheduler, network);
} using MeshSprocket::activate;
@@ -113,9 +115,15 @@ class IlluCat : public MeshSprocket {
virtual void onWsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventType type, void * arg, uint8_t *data, size_t len) {
if(type == WS_EVT_DATA){
String frame = WsUtils::parseFrameAsString(type, arg, data, len, 0);
onMessage(0, frame);
net->mesh.sendBroadcast(frame);
client->text(String(millis()));
//onMessage(0, frame);
NeoPatternMsg msg;
msg.fromJsonString(frame);
if(msg.valid){
// TODO convert message to send to mesh
//net->mesh.sendBroadcast(frame);
publish(msg.topic, msg.payload);
client->text(String(millis()));
}
}
}