mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
список устройств исправление
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -4,12 +4,12 @@
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||
|
||||
<title>IoT Manager 4.4.5</title>
|
||||
<title>IoT Manager 4.4.6</title>
|
||||
|
||||
<link rel="icon" type="image/png" href="/favicon.ico" />
|
||||
<link rel="stylesheet" href="/build/bundle.css?445" />
|
||||
<link rel="stylesheet" href="/build/bundle.css?446" />
|
||||
|
||||
<script defer src="/build/bundle.js?445"></script>
|
||||
<script defer src="/build/bundle.js?446"></script>
|
||||
</head>
|
||||
|
||||
<body></body>
|
||||
|
||||
@@ -37,10 +37,10 @@ void addThisDeviceToList() {
|
||||
AsyncUDP asyncUdp;
|
||||
|
||||
void udpListningInit() {
|
||||
// если был включен автоматический поиск устройств
|
||||
if (jsonReadInt(settingsFlashJson, F("udps")) != 0) {
|
||||
if (asyncUdp.listenMulticast(IPAddress(239, 255, 255, 255), 4210)) {
|
||||
asyncUdp.onPacket([](AsyncUDPPacket packet) {
|
||||
if (asyncUdp.listenMulticast(IPAddress(239, 255, 255, 255), 4210)) {
|
||||
asyncUdp.onPacket([](AsyncUDPPacket packet) {
|
||||
// если был включен автоматический поиск устройств то начнем запись в оперативную память
|
||||
if (jsonReadInt(settingsFlashJson, F("udps")) != 0) {
|
||||
// Serial.print("UDP Packet Type: ");
|
||||
// Serial.println(packet.isBroadcast() ? "Broadcast" : packet.isMulticast() ? "Multicast" : "Unicast");
|
||||
// Serial.print("From: ");
|
||||
@@ -55,8 +55,8 @@ void udpListningInit() {
|
||||
// Serial.print(packet.length());
|
||||
// Serial.print(", Data: ");
|
||||
// Serial.write(packet.data(), packet.length());
|
||||
|
||||
// String data = {packet.data(), packet.length()}; // для ESP32 подходит как замена uint8tToString, но 8266 не переваривает
|
||||
|
||||
String data = uint8tToString(packet.data(), packet.length());
|
||||
String remoteWorkgroup = "";
|
||||
data.replace("[", "");
|
||||
@@ -67,21 +67,25 @@ void udpListningInit() {
|
||||
if (remoteWorkgroup == loacalWorkgroup) {
|
||||
SerialPrint("i", F("UDP"), "IP: " + packet.remoteIP().toString() + ":" + String(packet.remotePort()));
|
||||
jsonMergeArrays(devListHeapJson, data);
|
||||
// эксперементальный вариант отправки нового списка сразу по приходу
|
||||
// sendStringToWs("devlis", devListHeapJson, -1);
|
||||
}
|
||||
} else {
|
||||
SerialPrint("E", F("UDP"), F("Udp packet invalid"));
|
||||
}
|
||||
|
||||
// reply to the client
|
||||
// String ip = WiFi.localIP().toString();
|
||||
// asyncUdp.broadcastTo(ip.c_str(), packet.remotePort());
|
||||
// packet.printf(ip.c_str(), packet.length());
|
||||
});
|
||||
}
|
||||
|
||||
SerialPrint("i", F("UDP"), F("Udp listning inited"));
|
||||
} else {
|
||||
devListHeapJson = "";
|
||||
} else {
|
||||
devListHeapJson = "";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
SerialPrint("i", F("UDP"), F("Udp listning inited"));
|
||||
}
|
||||
|
||||
void udpBroadcastInit() {
|
||||
|
||||
@@ -428,10 +428,11 @@ void sendStringToWs(const String& header, String& payload, int client_id) {
|
||||
void sendDeviceList(uint8_t num) {
|
||||
if (jsonReadInt(settingsFlashJson, F("udps")) != 0) {
|
||||
// если включен автопоиск то отдаем список из оперативной памяти
|
||||
SerialPrint("E", "FS", devListHeapJson);
|
||||
SerialPrint("i", "FS", "heap list");
|
||||
sendStringToWs("devlis", devListHeapJson, num);
|
||||
} else {
|
||||
// если выключен автопоиск то отдаем список из флешь памяти
|
||||
sendFileToWsByFrames("/devlist.json", "devlis", "", num, WEB_SOCKETS_FRAME_SIZE);
|
||||
SerialPrint("i", "FS", "flash list");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user