Cleanup JSON message

This commit is contained in:
Theo Arends 2022-08-07 14:23:27 +02:00
parent 4037184ee0
commit e327c6194f
2 changed files with 6 additions and 6 deletions

View File

@ -129,8 +129,8 @@ void CmndWifiScan(void)
char stemp1[20];
ResponseAppend_P(PSTR("{"));
for (uint32_t i = 0; i < WiFi.scanComplete(); i++) {
ResponseAppend_P(PSTR("\"" D_STATUS5_NETWORK "%d\":{\"" D_SSID "\":\"%s\", \"" D_BSSID "\":\"%s\", \"" D_CHANNEL
"\":\"%d\", \"" D_JSON_SIGNAL "\":\"%d\", \"" D_RSSI "\":\"%d\", \"" D_JSON_ENCRYPTION "\":\"%s\"}"),
ResponseAppend_P(PSTR("\"" D_STATUS5_NETWORK "%d\":{\"" D_SSID "\":\"%s\",\"" D_BSSID "\":\"%s\",\"" D_CHANNEL
"\":\"%d\",\"" D_JSON_SIGNAL "\":\"%d\",\"" D_RSSI "\":\"%d\",\"" D_JSON_ENCRYPTION "\":\"%s\"}"),
i+1,
WiFi.SSID(indexes[i]).c_str(),
WiFi.BSSIDstr(indexes[i]).c_str(),
@ -139,7 +139,7 @@ void CmndWifiScan(void)
WifiGetRssiAsQuality(WiFi.RSSI(indexes[i])),
GetTextIndexed(stemp1, sizeof(stemp1), WiFi.encryptionType(indexes[i]), kWifiEncryptionTypes));
if ( ResponseSize() < ResponseLength() + 300 ) { break; }
if ( i < WiFi.scanComplete() -1 ) { ResponseAppend_P(PSTR(", ")); }
if ( i < WiFi.scanComplete() -1 ) { ResponseAppend_P(PSTR(",")); }
//AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI "MAX SIZE: %d, SIZE: %d"),ResponseSize(),ResponseLength());
}
ResponseJsonEnd();

View File

@ -358,7 +358,7 @@ void WifiBeginAfterScan(void)
Wifi.scan_state++;
ResponseClear();
uint32_t initial_item = (Wifi.scan_state - 9)*10;
if ( wifi_scan_result > initial_item ) {
@ -380,8 +380,8 @@ void WifiBeginAfterScan(void)
char stemp1[20];
uint32_t end_item = ( wifi_scan_result > initial_item + 10 ) ? initial_item + 10 : wifi_scan_result;
for (uint32_t i = initial_item; i < end_item; i++) {
Response_P(PSTR("{\"" D_CMND_WIFISCAN "\":{\"" D_STATUS5_NETWORK "%d\":{\"" D_SSID "\":\"%s\", \"" D_BSSID "\":\"%s\", \"" D_CHANNEL
"\":\"%d\", \"" D_JSON_SIGNAL "\":\"%d\", \"" D_RSSI "\":\"%d\", \"" D_JSON_ENCRYPTION "\":\"%s\"}}}"),
Response_P(PSTR("{\"" D_CMND_WIFISCAN "\":{\"" D_STATUS5_NETWORK "%d\":{\"" D_SSID "\":\"%s\",\"" D_BSSID "\":\"%s\",\"" D_CHANNEL
"\":\"%d\",\"" D_JSON_SIGNAL "\":\"%d\",\"" D_RSSI "\":\"%d\",\"" D_JSON_ENCRYPTION "\":\"%s\"}}}"),
i+1,
WiFi.SSID(indexes[i]).c_str(),
WiFi.BSSIDstr(indexes[i]).c_str(),