diff --git a/subsys/net/l2/wifi/wifi_shell.c b/subsys/net/l2/wifi/wifi_shell.c index 91a6ec5e9b6d4c2..18a5a1250fdcfe5 100644 --- a/subsys/net/l2/wifi/wifi_shell.c +++ b/subsys/net/l2/wifi/wifi_shell.c @@ -1505,6 +1505,10 @@ static int cmd_wifi_twt_setup_quick(const struct shell *sh, size_t argc, struct wifi_twt_params params = { 0 }; int idx = 1; long value; + double twt_mantissa_scale = 0.0; + double twt_interval_scale = 0.0; + uint16_t scale = 1000; + int exponent = 0; context.sh = sh; @@ -1529,6 +1533,13 @@ static int cmd_wifi_twt_setup_quick(const struct shell *sh, size_t argc, } params.setup.twt_interval = (uint64_t)value; + /* control the region of mantissa filed */ + twt_interval_scale = (double)(params.setup.twt_interval / scale); + /* derive mantissa and exponent from interval */ + twt_mantissa_scale = frexp(twt_interval_scale, &exponent); + params.setup.twt_mantissa = ceil(twt_mantissa_scale * scale); + params.setup.twt_exponent = exponent; + if (net_mgmt(NET_REQUEST_WIFI_TWT, iface, ¶ms, sizeof(params))) { PR_WARNING("%s with %s failed, reason : %s\n", wifi_twt_operation_txt(params.operation),