mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2025-12-13 02:52:11 +01:00
Bug Fix for network emits
Originally the address used for the SSID would become inconsistent because of the way the ESP32 uses the string class to store the SSID. This would eventually end in an emit that crashed the socket from the client with an inconsistent UTF-8 byte. The fix was to convert the string to a pointer for the emits.
This commit is contained in:
parent
16e85d5e08
commit
028cce5d8f
7 changed files with 9 additions and 9 deletions
|
|
@ -59,9 +59,9 @@ void Network::loop() {
|
|||
}
|
||||
void Network::emitSockets() {
|
||||
if(WiFi.status() == WL_CONNECTED) {
|
||||
if(abs(abs(WiFi.RSSI()) - abs(this->lastRSSI)) > 2 || WiFi.channel() != this->lastChannel) {
|
||||
if(abs(abs(WiFi.RSSI()) - abs(this->lastRSSI)) > 1 || WiFi.channel() != this->lastChannel) {
|
||||
char buf[128];
|
||||
snprintf(buf, sizeof(buf), "{\"ssid\":\"%s\",\"strength\":%d,\"channel\":%d}", WiFi.SSID(), WiFi.RSSI(), WiFi.channel());
|
||||
snprintf(buf, sizeof(buf), "{\"ssid\":\"%s\",\"strength\":%d,\"channel\":%d}", WiFi.SSID().c_str(), WiFi.RSSI(), WiFi.channel());
|
||||
sockEmit.sendToClients("wifiStrength", buf);
|
||||
this->lastRSSI = WiFi.RSSI();
|
||||
this->lastChannel = WiFi.channel();
|
||||
|
|
@ -73,7 +73,7 @@ void Network::emitSockets() {
|
|||
void Network::emitSockets(uint8_t num) {
|
||||
if(WiFi.status() == WL_CONNECTED) {
|
||||
char buf[128];
|
||||
snprintf(buf, sizeof(buf), "{\"ssid\":\"%s\",\"strength\":%d,\"channel\":%d}", WiFi.SSID(), WiFi.RSSI(), WiFi.channel());
|
||||
snprintf(buf, sizeof(buf), "{\"ssid\":\"%s\",\"strength\":%d,\"channel\":%d}", WiFi.SSID().c_str(), WiFi.RSSI(), WiFi.channel());
|
||||
sockEmit.sendToClient(num, "wifiStrength", buf);
|
||||
this->lastRSSI = WiFi.RSSI();
|
||||
this->lastChannel = WiFi.channel();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue