diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 4c76fa80..00000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "files.associations": { - "array": "cpp", - "deque": "cpp", - "list": "cpp", - "string": "cpp", - "unordered_map": "cpp", - "vector": "cpp", - "string_view": "cpp", - "initializer_list": "cpp", - "ranges": "cpp", - "thread": "cpp", - "optional": "cpp", - "istream": "cpp", - "ostream": "cpp", - "ratio": "cpp", - "system_error": "cpp", - "functional": "cpp", - "tuple": "cpp", - "type_traits": "cpp", - "utility": "cpp" - } -} \ No newline at end of file diff --git a/include/WsServer.h b/include/WsServer.h index fb5efbef..8c88e92d 100644 --- a/include/WsServer.h +++ b/include/WsServer.h @@ -21,7 +21,7 @@ void periodicWsSend(); void publishChartToWs(String filename, int num, size_t frameSize, int maxCount, String id); void sendFileToWsByFrames(const String& filename, const String& header, const String& json, uint8_t client_id, size_t frameSize); -void sendStringToWs(const String& header, String& payload, uint8_t client_id); +void sendStringToWs(const String& header, String& payload, int client_id); // void sendMark(const char* filename, const char* mark, uint8_t num); // void sendFileToWs3(const String& filename, uint8_t num); diff --git a/lib/WebSockets/src/WebSocketsServer.cpp b/lib/WebSockets/src/WebSocketsServer.cpp index 5c5abea8..e864bfe2 100644 --- a/lib/WebSockets/src/WebSocketsServer.cpp +++ b/lib/WebSockets/src/WebSocketsServer.cpp @@ -251,13 +251,13 @@ bool WebSocketsServerCore::sendBIN(uint8_t num, const uint8_t * payload, size_t * @param headerToPayload bool (see sendFrame for more details) * @return true if ok */ -bool WebSocketsServerCore::broadcastBIN(uint8_t * payload, size_t length, bool fin, bool headerToPayload) { +bool WebSocketsServerCore::broadcastBIN(uint8_t * payload, size_t length, bool fin, bool continuation, bool headerToPayload) { WSclient_t * client; bool ret = true; for(uint8_t i = 0; i < WEBSOCKETS_SERVER_CLIENT_MAX; i++) { client = &_clients[i]; if(clientIsConnected(client)) { - if(!sendFrame(client, WSop_binary, payload, length, true, headerToPayload)) { + if(!sendFrame(client, WSop_binary, payload, length, fin, headerToPayload)) { ret = false; } } diff --git a/lib/WebSockets/src/WebSocketsServer.h b/lib/WebSockets/src/WebSocketsServer.h index cd224dd2..a8472a5b 100644 --- a/lib/WebSockets/src/WebSocketsServer.h +++ b/lib/WebSockets/src/WebSocketsServer.h @@ -68,7 +68,7 @@ class WebSocketsServerCore : protected WebSockets { bool sendBIN(uint8_t num, uint8_t * payload, size_t length, bool fin = true, bool continuation = false, bool headerToPayload = false); bool sendBIN(uint8_t num, const uint8_t * payload, size_t length); - bool broadcastBIN(uint8_t * payload, size_t length, bool fin = true, bool headerToPayload = false); + bool broadcastBIN(uint8_t * payload, size_t length, bool fin = true, bool continuation = false, bool headerToPayload = false); bool broadcastBIN(const uint8_t * payload, size_t length); bool sendPing(uint8_t num, uint8_t * payload = NULL, size_t length = 0); diff --git a/src/WsServer.cpp b/src/WsServer.cpp index 4a1398bb..dbcdc553 100644 --- a/src/WsServer.cpp +++ b/src/WsServer.cpp @@ -98,13 +98,6 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length) sendFileToWsByFrames("/config.json", "config", "", num, WEB_SOCKETS_FRAME_SIZE); sendFileToWsByFrames("/scenario.txt", "scenar", "", num, WEB_SOCKETS_FRAME_SIZE); sendStringToWs("settin", settingsFlashJson, num); - - //шлется для того что бы получить топик устройства - // standWebSocket.sendTXT(num, settingsFlashJson); - } - - //отправляем все графики в веб для экспорта - if (headerStr == "/expcharts|") { } //обработка кнопки сохранить @@ -130,9 +123,9 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length) //отвечаем данными на запрос страницы if (headerStr == "/connection|") { - standWebSocket.sendTXT(num, settingsFlashJson); - standWebSocket.sendTXT(num, ssidListHeapJson); - standWebSocket.sendTXT(num, errorsHeapJson); + sendStringToWs("settin", settingsFlashJson, num); + sendStringToWs("ssidli", ssidListHeapJson, num); + sendStringToWs("errors", errorsHeapJson, num); // запуск асинхронного сканирования wifi сетей при переходе на страницу соединений // RouterFind(jsonReadStr(settingsFlashJson, F("routerssid"))); } @@ -166,7 +159,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length) //отвечаем данными на запрос страницы if (headerStr == "/list|") { - standWebSocket.sendTXT(num, devListHeapJson); + sendStringToWs("devlis", devListHeapJson, num); } //----------------------------------------------------------------------// @@ -175,8 +168,8 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length) //отвечаем данными на запрос страницы if (headerStr == "/system|") { - standWebSocket.sendTXT(num, errorsHeapJson); - standWebSocket.sendTXT(num, settingsFlashJson); + sendStringToWs("errors", errorsHeapJson, num); + sendStringToWs("settin", settingsFlashJson, num); } //----------------------------------------------------------------------// @@ -297,9 +290,9 @@ void publishChartWs(int num, String& path) { //данные которые мы отправляем в сокеты переодически void periodicWsSend() { - // standWebSocket.broadcastTXT(devListHeapJson); - // standWebSocket.broadcastTXT(ssidListHeapJson); - // standWebSocket.broadcastTXT(errorsHeapJson); + sendStringToWs("ssidli", ssidListHeapJson, -1); + sendStringToWs("errors", errorsHeapJson, -1); + sendStringToWs("devlis", devListHeapJson, -1); } #ifdef ESP32 @@ -469,7 +462,7 @@ void sendFileToWsByFrames(const String& filename, const String& header, const St file.close(); } -void sendStringToWs(const String& header, String& payload, uint8_t client_id) { +void sendStringToWs(const String& header, String& payload, int client_id) { if (header.length() != 6) { SerialPrint("E", "FS", F("wrong header size")); return; @@ -481,7 +474,11 @@ void sendStringToWs(const String& header, String& payload, uint8_t client_id) { char dataArray[totalSize]; msg.toCharArray(dataArray, totalSize + 1); - standWebSocket.sendBIN(client_id, (uint8_t*)dataArray, totalSize); + if (client_id == -1) { + standWebSocket.broadcastBIN((uint8_t*)dataArray, totalSize); + } else { + standWebSocket.sendBIN(client_id, (uint8_t*)dataArray, totalSize); + } } // void sendFileToWsByFrames(const String& filename, const String& header, const String& json, uint8_t client_id, size_t frameSize) { diff --git a/src/modules/virtual/Loging/Loging (1).cpp b/src/modules/virtual/Loging/Loging (1).cpp deleted file mode 100644 index cd6697a1..00000000 --- a/src/modules/virtual/Loging/Loging (1).cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "Global.h" -#include "classes/IoTItem.h" - -class Loging : public IoTItem { - private: - String logval; - - public: - Loging(String parameters) : IoTItem(parameters) { - jsonRead(parameters, F("logid"), logval); - } - - // void setValue(IoTValue Value) { - // value = Value; - // regEvent((String)(int)value.valD, "Loging"); - // } - - void doByInterval() { - String value = getItemValue(logval); - if (value == "") { - SerialPrint("E", F("Logging"), F("no value set")); - } else { - regEvent(value, "Logging"); - } - } -}; - -void* getAPI_Loging(String subtype, String param) { - if (subtype == F("Loging")) { - return new Loging(param); - } else { - return nullptr; - } -}