Fix correct JSON display of WifiPower float

This commit is contained in:
Theo Arends 2023-05-19 17:41:18 +02:00
parent f3cc8997b0
commit f5d6578fb5
2 changed files with 7 additions and 9 deletions

View File

@ -883,8 +883,9 @@ void CmndStatus(void)
#endif // USE_IPV6
#endif // USE_ETHERNET
ResponseAppend_P(PSTR(",\"" D_CMND_WEBSERVER "\":%d,\"HTTP_API\":%d,\"" D_CMND_WIFICONFIG "\":%d,\"" D_CMND_WIFIPOWER "\":%s}}"),
Settings->webserver, Settings->flag5.disable_referer_chk, Settings->sta_config, WifiGetOutputPower().c_str());
float wifi_tx_power = WifiGetOutputPower();
ResponseAppend_P(PSTR(",\"" D_CMND_WEBSERVER "\":%d,\"HTTP_API\":%d,\"" D_CMND_WIFICONFIG "\":%d,\"" D_CMND_WIFIPOWER "\":%1_f}}"),
Settings->webserver, Settings->flag5.disable_referer_chk, Settings->sta_config, &wifi_tx_power);
CmndStatusResponse(5);
}
@ -2535,7 +2536,7 @@ void CmndWifiPower(void) {
}
WifiSetOutputPower();
}
ResponseCmndChar(WifiGetOutputPower().c_str());
ResponseCmndFloat(WifiGetOutputPower(), 1);
}
void CmndWifi(void)

View File

@ -974,14 +974,11 @@ int WifiState(void)
return state;
}
String WifiGetOutputPower(void) {
char stemp1[TOPSZ];
float WifiGetOutputPower(void) {
if (Settings->wifi_output_power) {
dtostrfd((float)(Settings->wifi_output_power) / 10, 1, stemp1);
} else {
dtostrfd((float)(Wifi.last_tx_pwr) / 10, 0, stemp1); // No decimal to indicate dynamic tx power
Wifi.last_tx_pwr = Settings->wifi_output_power;
}
return String(stemp1);
return (float)(Wifi.last_tx_pwr) / 10;
}
void WifiSetOutputPower(void) {