добавил посылку событий в сокеты

This commit is contained in:
Dmitry Borisenko
2022-02-02 21:40:45 +01:00
parent a2f5927172
commit bd1d25d79a
3 changed files with 5 additions and 2 deletions

View File

@@ -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);

View File

@@ -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) {

View File

@@ -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 + "'");
}