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:
Robert Strouse 2023-02-20 09:07:20 -08:00
parent 16e85d5e08
commit 028cce5d8f
7 changed files with 9 additions and 9 deletions

View file

@ -2,7 +2,7 @@
#ifndef configsettings_h
#define configsettings_h
#define FW_VERSION "v1.2.1"
#define FW_VERSION "v1.2.2"
enum DeviceStatus {
DS_OK = 0,
DS_ERROR = 1,

View file

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

Binary file not shown.

Binary file not shown.

View file

@ -3,10 +3,10 @@
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="UTF-8">
<link rel="stylesheet" href="main.css?v=1.2.1" type="text/css" />
<link rel="stylesheet" href="icons.css?v=1.2.1" type="text/css" />
<link rel="stylesheet" href="main.css?v=1.2.2" type="text/css" />
<link rel="stylesheet" href="icons.css?v=1.2.2" type="text/css" />
<link rel="icon" type="image/png" href="favicon.png" />
<script type="text/javascript" src="index.js?v=1.2.1"></script>
<script type="text/javascript" src="index.js?v=1.2.2"></script>
</head>
<body>
<div id="divContainer" class="container" style="user-select:none;position:relative;">

View file

@ -328,7 +328,7 @@ async function reopenSocket() {
await initSockets();
}
class General {
appVersion = 'v1.2.1';
appVersion = 'v1.2.2';
reloadApp = false;
async init() {
this.setAppVersion();

View file

@ -601,7 +601,7 @@ div.waitoverlay > .lds-roller {
width:100%;
background-color:gainsboro;
color:gray;
height:60px;
min-height:60px;
top:0px;
padding-left:7px;
padding-right:7px;