Skip to content

Commit ab948b0

Browse files
Rex-Chen-NXPkartben
authored andcommitted
net: wifi: shell: fix twt setup quick failed issue
The default exponent is 0, will cause twt setup quick failed, set exponent value derived from twt interval to fix it. Signed-off-by: Rex Chen <[email protected]>
1 parent 0406f9b commit ab948b0

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

subsys/net/l2/wifi/wifi_shell.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,6 +1533,10 @@ static int cmd_wifi_twt_setup_quick(const struct shell *sh, size_t argc,
15331533
struct wifi_twt_params params = { 0 };
15341534
int idx = 1;
15351535
long value;
1536+
double twt_mantissa_scale = 0.0;
1537+
double twt_interval_scale = 0.0;
1538+
uint16_t scale = 1000;
1539+
int exponent = 0;
15361540

15371541
context.sh = sh;
15381542

@@ -1557,6 +1561,13 @@ static int cmd_wifi_twt_setup_quick(const struct shell *sh, size_t argc,
15571561
}
15581562
params.setup.twt_interval = (uint64_t)value;
15591563

1564+
/* control the region of mantissa filed */
1565+
twt_interval_scale = (double)(params.setup.twt_interval / scale);
1566+
/* derive mantissa and exponent from interval */
1567+
twt_mantissa_scale = frexp(twt_interval_scale, &exponent);
1568+
params.setup.twt_mantissa = ceil(twt_mantissa_scale * scale);
1569+
params.setup.twt_exponent = exponent;
1570+
15601571
if (net_mgmt(NET_REQUEST_WIFI_TWT, iface, &params, sizeof(params))) {
15611572
PR_WARNING("%s with %s failed, reason : %s\n",
15621573
wifi_twt_operation_txt(params.operation),

0 commit comments

Comments
 (0)