diff --git a/include/WsServer.h b/include/WsServer.h index 829e3845..6a395402 100644 --- a/include/WsServer.h +++ b/include/WsServer.h @@ -10,6 +10,7 @@ extern void hexdump(const void* mem, uint32_t len, uint8_t cols); #endif void sendFileToWs5(const char* filename, uint8_t num, size_t frameSize); +void publishStatusWs(const String& topic, const String& data); // void sendMark(const char* filename, const char* mark, uint8_t num); // void sendFileToWs3(const String& filename, uint8_t num); // void sendFileToWs4(const String& filename, uint8_t num); \ No newline at end of file diff --git a/src/WsServer.cpp b/src/WsServer.cpp index 6fafa10b..995b29be 100644 --- a/src/WsServer.cpp +++ b/src/WsServer.cpp @@ -127,8 +127,8 @@ void publishStatusWs(const String& topic, const String& data) { String path = mqttRootDevice + "/" + topic + "/status"; String json = "{}"; jsonWriteStr(json, "status", data); - // standWebSocket.sendTXT(num, json); - // mqtt.publish(path.c_str(), json.c_str(), false); + jsonWriteStr(json, "topic", path); + standWebSocket.broadcastTXT(json); } // void sendMark(const char* filename, const char* mark, uint8_t num) { diff --git a/src/classes/IoTSensor.cpp b/src/classes/IoTSensor.cpp index 3cd33cde..6db2b6b2 100644 --- a/src/classes/IoTSensor.cpp +++ b/src/classes/IoTSensor.cpp @@ -2,6 +2,7 @@ #include "Utils/SerialPrint.h" #include "Classes/ScenarioClass3.h" #include "Classes/IoTSensor.h" +#include "WsServer.h" IoTSensor::IoTSensor(String parameters) { jsonRead(parameters, "int", _interval); @@ -44,6 +45,7 @@ void IoTSensor::regEvent(String value, String consoleInfo = "") { eventGen2(_id, value); jsonWriteStr(paramsFlashJson, _id, value); publishStatusMqtt(_id, value); + publishStatusWs(_id, value); SerialPrint("I", "Sensor " + consoleInfo, "'" + _id + "' data: " + value + "'"); }