Skip to content

Commit 7ee6fe7

Browse files
committed
WebSockets: Add webSockets to the messages
1 parent b40af67 commit 7ee6fe7

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

Firmware/RTK_Everywhere/WebSockets.ino

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ void webSocketsCreateFirmwareVersionString(char *settingsCSV)
105105
if (firmwareVersionIsReportedNewer(otaReportedVersion, currentVersion) == true)
106106
{
107107
if (settings.debugWebServer == true)
108-
systemPrintln("New version detected");
108+
systemPrintln("WebSockets: New firmware version detected");
109109
snprintf(newVersionCSV, sizeof(newVersionCSV), "%s,", otaReportedVersion);
110110
}
111111
else
@@ -136,7 +136,8 @@ static esp_err_t webSocketsHandler(httpd_req_t *req)
136136
last_ws_fd = httpd_req_to_sockfd(req);
137137

138138
if (settings.debugWebServer == true)
139-
systemPrintf("Handshake done, the new ws connection was opened with fd %d\r\n", last_ws_fd);
139+
systemPrintf("webSockets: Added client, _request: %p, _socketFD: %d\r\n",
140+
client->_request, client->_socketFD);
140141

141142
webSocketsConnected = true;
142143
lastDynamicDataUpdate = millis();
@@ -153,26 +154,26 @@ static esp_err_t webSocketsHandler(httpd_req_t *req)
153154
esp_err_t ret = httpd_ws_recv_frame(req, &ws_pkt, 0);
154155
if (ret != ESP_OK)
155156
{
156-
systemPrintf("httpd_ws_recv_frame failed to get frame len with %d\r\n", ret);
157+
systemPrintf("WebSockets: httpd_ws_recv_frame failed to get frame len with %d\r\n", ret);
157158
return ret;
158159
}
159160
if (settings.debugWebServer == true)
160-
systemPrintf("frame len is %d\r\n", ws_pkt.len);
161+
systemPrintf("WebSockets: frame len is %d\r\n", ws_pkt.len);
161162
if (ws_pkt.len)
162163
{
163164
/* ws_pkt.len + 1 is for NULL termination as we are expecting a string */
164165
buf = (uint8_t *)rtkMalloc(ws_pkt.len + 1, "Payload buffer (buf)");
165166
if (buf == NULL)
166167
{
167-
systemPrintln("Failed to malloc memory for buf");
168+
systemPrintln("WebSockets: Failed to malloc memory for buf");
168169
return ESP_ERR_NO_MEM;
169170
}
170171
ws_pkt.payload = buf;
171172
/* Set max_len = ws_pkt.len to get the frame payload */
172173
ret = httpd_ws_recv_frame(req, &ws_pkt, ws_pkt.len);
173174
if (ret != ESP_OK)
174175
{
175-
systemPrintf("httpd_ws_recv_frame failed with %d\r\n", ret);
176+
systemPrintf("WebSockets: httpd_ws_recv_frame failed with %d\r\n", ret);
176177
rtkFree(buf, "Payload buffer (buf)");
177178
return ret;
178179
}
@@ -205,7 +206,7 @@ static esp_err_t webSocketsHandler(httpd_req_t *req)
205206
pktType = "HTTPD_WS_TYPE_PONG";
206207
break;
207208
}
208-
systemPrintf("Packet: %p, %d bytes, type: %d%s%s%s\r\n", ws_pkt.payload, length, ws_pkt.type,
209+
systemPrintf("WebSockets: Packet: %p, %d bytes, type: %d%s%s%s\r\n", ws_pkt.payload, length, ws_pkt.type,
209210
pktType ? " (" : "", pktType ? pktType : "", pktType ? ")" : "");
210211
if (length > 0x40)
211212
length = 0x40;
@@ -220,21 +221,21 @@ static esp_err_t webSocketsHandler(httpd_req_t *req)
220221
{
221222
incomingSettings[incomingSettingsSpot++] = ws_pkt.payload[i];
222223
if (incomingSettingsSpot == AP_CONFIG_SETTING_SIZE)
223-
systemPrintln("incomingSettings wrap-around. Increase AP_CONFIG_SETTING_SIZE");
224+
systemPrintln("WebSockets: incomingSettings wrap-around. Increase AP_CONFIG_SETTING_SIZE");
224225
incomingSettingsSpot %= AP_CONFIG_SETTING_SIZE;
225226
}
226227
timeSinceLastIncomingSetting = millis();
227228
}
228229
else
229230
{
230231
if (settings.debugWebServer == true)
231-
systemPrintln("Ignoring packet due to parsing block");
232+
systemPrintln("WebSockets: Ignoring packet due to parsing block");
232233
}
233234
}
234235
else if (ws_pkt.type == HTTPD_WS_TYPE_CLOSE)
235236
{
236237
if (settings.debugWebServer == true)
237-
systemPrintln("Client closed or refreshed the web page");
238+
systemPrintln("WebSockets: Client closed or refreshed the web page");
238239

239240
createSettingsString(settingsCSV);
240241
webSocketsConnected = false;
@@ -260,7 +261,7 @@ void webSocketsSendFirmwareVersion(void)
260261
webSocketsCreateFirmwareVersionString(settingsCSV);
261262

262263
if (settings.debugWebServer)
263-
systemPrintf("WebServer: Firmware version requested. Sending: %s\r\n", settingsCSV);
264+
systemPrintf("WebSockets: Firmware version requested. Sending: %s\r\n", settingsCSV);
264265

265266
webSocketsSendString(settingsCSV);
266267
}
@@ -304,7 +305,7 @@ void webSocketsSendString(const char *stringToSend)
304305
esp_err_t ret = httpd_ws_send_frame_async(webSocketsHandle, last_ws_fd, &ws_pkt);
305306
if (ret != ESP_OK)
306307
{
307-
systemPrintf("httpd_ws_send_frame failed with %d\r\n", ret);
308+
systemPrintf("WebSockets: httpd_ws_send_frame failed with %d\r\n", ret);
308309
}
309310
else
310311
{

0 commit comments

Comments
 (0)