Skip to content

Commit

Permalink
net: wifi: shell: fix twt setup quick failed issue
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Rex-Chen-NXP committed Dec 11, 2024
1 parent 168973d commit 9b152d2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions subsys/net/l2/wifi/wifi_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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, &params, sizeof(params))) {
PR_WARNING("%s with %s failed, reason : %s\n",
wifi_twt_operation_txt(params.operation),
Expand Down

0 comments on commit 9b152d2

Please sign in to comment.