Skip to content

Commit e7feee3

Browse files
kapbhcarlescufi
authored andcommitted
[noup] zephyr: Fix fractional part of Tx rate by converting to float
The Tx rate was divided by 1000 using integer division, which truncated the decimal part (8600 bps → 8 Mbps instead of 8.6 Mbps). This change ensures the result is stored as a float to retain precision in Mbps. Signed-off-by: Kapil Bhatt <[email protected]>
1 parent 3fb1cea commit e7feee3

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

wpa_supplicant/ctrl_iface.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8403,9 +8403,9 @@ static int wpa_supplicant_signal_poll(struct wpa_supplicant *wpa_s, char *buf,
84038403
pos = buf;
84048404
end = buf + buflen;
84058405

8406-
ret = os_snprintf(pos, end - pos, "RSSI=%d\nLINKSPEED=%lu\n"
8406+
ret = os_snprintf(pos, end - pos, "RSSI=%d\nLINKSPEED=%.1f\n"
84078407
"NOISE=%d\nFREQUENCY=%u\n",
8408-
si.data.signal, si.data.current_tx_rate / 1000,
8408+
si.data.signal, (double)si.data.current_tx_rate / 1000,
84098409
si.current_noise, si.frequency);
84108410
if (os_snprintf_error(end - pos, ret))
84118411
return -1;

wpa_supplicant/wpa_cli_zephyr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ int z_wpa_ctrl_signal_poll(struct signal_poll_resp *resp)
383383
return ret;
384384
}
385385

386-
ret = sscanf((const char *)buf, "RSSI=%d\nLINKSPEED=%d\n", &resp->rssi, &resp->current_txrate);
386+
ret = sscanf((const char *)buf, "RSSI=%d\nLINKSPEED=%f\n", &resp->rssi, &resp->current_txrate);
387387
if (ret < 0) {
388388
wpa_printf(MSG_INFO, "Failed to parse SIGNAL_POLL response: %s",
389389
strerror(errno));

wpa_supplicant/wpa_cli_zephyr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ struct add_network_resp {
1818

1919
struct signal_poll_resp {
2020
int rssi;
21-
int current_txrate;
21+
float current_txrate;
2222
};
2323

2424
struct status_resp {

0 commit comments

Comments
 (0)