From fbd34dac0feb82336205d199bc33dfe0883ab388 Mon Sep 17 00:00:00 2001 From: Kapil Bhatt Date: Tue, 15 Jul 2025 06:51:42 +0000 Subject: [PATCH] wifi: Fix fractional part of Tx rate by converting to float The Tx rate was previously stored as an integer, which caused loss of precision for rates like 8.6 Mbps or 34.4 Mbps due to integer division. The change will update data type to float. Signed-off-by: Kapil Bhatt --- include/zephyr/net/wifi_mgmt.h | 2 +- subsys/net/l2/wifi/wifi_shell.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/zephyr/net/wifi_mgmt.h b/include/zephyr/net/wifi_mgmt.h index de0b37cc641..0d24278b20d 100644 --- a/include/zephyr/net/wifi_mgmt.h +++ b/include/zephyr/net/wifi_mgmt.h @@ -788,7 +788,7 @@ struct wifi_iface_status { /** is TWT capable? */ bool twt_capable; /** The current 802.11 PHY TX data rate (in Mbps) */ - int current_phy_tx_rate; + float current_phy_tx_rate; }; /** @brief Wi-Fi power save parameters */ diff --git a/subsys/net/l2/wifi/wifi_shell.c b/subsys/net/l2/wifi/wifi_shell.c index a62d8e0eb82..5e0a8ec78fc 100644 --- a/subsys/net/l2/wifi/wifi_shell.c +++ b/subsys/net/l2/wifi/wifi_shell.c @@ -1489,7 +1489,7 @@ static int cmd_wifi_status(const struct shell *sh, size_t argc, char *argv[]) PR("DTIM: %d\n", status.dtim_period); PR("TWT: %s\n", status.twt_capable ? "Supported" : "Not supported"); - PR("Current PHY TX rate (Mbps) : %d\n", status.current_phy_tx_rate); + PR("Current PHY TX rate (Mbps) : %.1f\n", (double)status.current_phy_tx_rate); } return 0;