@@ -148,23 +148,50 @@ static void handle_wifi_disconnect_result(struct net_mgmt_event_callback *cb)
148148 }
149149}
150150
151+ static void print_twt_params (uint8_t dialog_token , uint8_t flow_id ,
152+ enum wifi_twt_negotiation_type negotiation_type ,
153+ bool responder , bool implicit , bool announce ,
154+ bool trigger , uint32_t twt_wake_interval ,
155+ uint64_t twt_interval )
156+ {
157+ shell_fprintf (context .sh , SHELL_NORMAL , "TWT Dialog token: %d\n" ,
158+ dialog_token );
159+ shell_fprintf (context .sh , SHELL_NORMAL , "TWT flow ID: %d\n" ,
160+ flow_id );
161+ shell_fprintf (context .sh , SHELL_NORMAL , "TWT negotiation type: %s\n" ,
162+ wifi_twt_negotiation_type2str [negotiation_type ]);
163+ shell_fprintf (context .sh , SHELL_NORMAL , "TWT responder: %s\n" ,
164+ responder ? "true" : "false" );
165+ shell_fprintf (context .sh , SHELL_NORMAL , "TWT implicit: %s\n" ,
166+ implicit ? "true" : "false" );
167+ shell_fprintf (context .sh , SHELL_NORMAL , "TWT announce: %s\n" ,
168+ announce ? "true" : "false" );
169+ shell_fprintf (context .sh , SHELL_NORMAL , "TWT trigger: %s\n" ,
170+ trigger ? "true" : "false" );
171+ shell_fprintf (context .sh , SHELL_NORMAL , "TWT wake interval: %d us\n" ,
172+ twt_wake_interval );
173+ shell_fprintf (context .sh , SHELL_NORMAL , "TWT interval: %lld us\n" ,
174+ twt_interval );
175+ shell_fprintf (context .sh , SHELL_NORMAL , "========================\n" );
176+ }
177+
151178static void handle_wifi_twt_event (struct net_mgmt_event_callback * cb )
152179{
153180 const struct wifi_twt_params * resp =
154181 (const struct wifi_twt_params * )cb -> info ;
155182
156183 if (resp -> resp_status == WIFI_TWT_RESP_RECEIVED ) {
157- print (context .sh , SHELL_NORMAL , "TWT response: %s for dialog: %d and flow: %d \n" ,
158- wifi_twt_setup_cmd2str [resp -> setup_cmd ], resp -> dialog_token , resp -> flow_id );
159-
160- /* If accepted, then no need to print TWT params */
161- if ( resp -> setup_cmd != WIFI_TWT_SETUP_CMD_ACCEPT ) {
162- print ( context . sh , SHELL_NORMAL ,
163- "TWT parameters: trigger: %s wake_interval: %d us, interval: %lld us\n" ,
164- resp -> setup .trigger ? "trigger" : "no_trigger" ,
165- resp -> setup .twt_wake_interval ,
166- resp -> setup .twt_interval );
167- }
184+ print (context .sh , SHELL_NORMAL , "TWT response: %s\n" ,
185+ wifi_twt_setup_cmd2str [resp -> setup_cmd ]);
186+ print_twt_params ( resp -> dialog_token ,
187+ resp -> flow_id ,
188+ resp -> negotiation_type ,
189+ resp -> setup . responder ,
190+ resp -> setup . implicit ,
191+ resp -> setup .announce ,
192+ resp -> setup .trigger ,
193+ resp -> setup .twt_wake_interval ,
194+ resp -> setup . twt_interval );
168195 } else {
169196 print (context .sh , SHELL_NORMAL , "TWT response timed out\n" );
170197 }
@@ -465,26 +492,16 @@ static int cmd_wifi_ps(const struct shell *sh, size_t argc, char *argv[])
465492 shell_fprintf (sh , SHELL_NORMAL , "No TWT flows\n" );
466493 } else {
467494 for (int i = 0 ; i < config .num_twt_flows ; i ++ ) {
468- shell_fprintf (sh , SHELL_NORMAL , "TWT Dialog token: %d\n" ,
469- config .twt_flows [i ].dialog_token );
470- shell_fprintf (sh , SHELL_NORMAL , "TWT flow ID: %d\n" ,
471- config .twt_flows [i ].flow_id );
472- shell_fprintf (sh , SHELL_NORMAL , "TWT negotiation type: %s\n" ,
473- wifi_twt_negotiation_type2str [
474- config .twt_flows [i ].negotiation_type ]);
475- shell_fprintf (sh , SHELL_NORMAL , "TWT responder: %s\n" ,
476- config .twt_flows [i ].responder ? "true" : "false" );
477- shell_fprintf (sh , SHELL_NORMAL , "TWT implicit: %s\n" ,
478- config .twt_flows [i ].implicit ? "true" : "false" );
479- shell_fprintf (sh , SHELL_NORMAL , "TWT trigger: %s\n" ,
480- config .twt_flows [i ].trigger ? "true" : "false" );
481- shell_fprintf (sh , SHELL_NORMAL , "TWT announce: %s\n" ,
482- config .twt_flows [i ].announce ? "true" : "false" );
483- shell_fprintf (sh , SHELL_NORMAL , "TWT wake interval: %d us\n" ,
484- config .twt_flows [i ].twt_wake_interval );
485- shell_fprintf (sh , SHELL_NORMAL , "TWT interval: %lld us\n" ,
495+ print_twt_params (
496+ config .twt_flows [i ].dialog_token ,
497+ config .twt_flows [i ].flow_id ,
498+ config .twt_flows [i ].negotiation_type ,
499+ config .twt_flows [i ].responder ,
500+ config .twt_flows [i ].implicit ,
501+ config .twt_flows [i ].announce ,
502+ config .twt_flows [i ].trigger ,
503+ config .twt_flows [i ].twt_wake_interval ,
486504 config .twt_flows [i ].twt_interval );
487- shell_fprintf (sh , SHELL_NORMAL , "========================\n" );
488505 }
489506 }
490507 return 0 ;
0 commit comments