The client does not enter sleep mode as expected.

We are using the Nordic Semiconductor nRF7002-DK. In this board, both PS-Poll and No-PS-Poll power-saving modes are working as expected. However, when running in TWT (Target Wake Time) power mode using the following command:-wifi twt setup 0 0 2 2 0 1 1 1 1000 60000, the client does not enter sleep mode as expected. Can you help us to enter the device into sleep mode.
Applications Versions: 
  1. nRF connection Desktop v5.2.0
  2. Toolchain Manager v1.6.0
  3. Visual studio cade v2.9.2
  4. Windows 11 pro Platform
Parents Reply Children
  • Hi Marte,

    As you advised, we followed the link https://github.com/nrfconnect/sdk-nrf/blob/v2.9.2/samples/wifi/twt/src/main.c#L306, However, we were unable to find a solution to our issue.

    Kindly provide a clear and proper process to resolve the issue.

    Thanks & Regards,

    Naveen P

  • Hi Marte,

    Please find the attached screenshot for your reference .

  • Hi Naveen,

    If you add logging inside NET_EVENT_WIFI_TWT_SLEEP_STATE you should be able to see if it enters sleep state. For example, you can add this line after retrieving the twt_state:

    LOG_INF("TWT sleep state: %s", *twt_state ? "awake" : "sleeping" );

    So the full function will look like this:

    static void wifi_mgmt_event_handler(struct net_mgmt_event_callback *cb,
    				     uint32_t mgmt_event, struct net_if *iface)
    {
    	switch (mgmt_event) {
    	case NET_EVENT_WIFI_CONNECT_RESULT:
    		handle_wifi_connect_result(cb);
    		break;
    	case NET_EVENT_WIFI_DISCONNECT_RESULT:
    		handle_wifi_disconnect_result(cb);
    		break;
    	case NET_EVENT_WIFI_TWT:
    		handle_wifi_twt_event(cb);
    		break;
    #ifdef CONFIG_SCHEDULED_TX
    	case NET_EVENT_WIFI_TWT_SLEEP_STATE: {
    		int *twt_state;
    
    		twt_state = (int *)(cb->info);
    		LOG_INF("TWT sleep state: %s", *twt_state ? "awake" : "sleeping" );
    		if (*twt_state == WIFI_TWT_STATE_SLEEP) {
    			traffic_gen_pause(&tg_config);
    		} else if (*twt_state == WIFI_TWT_STATE_AWAKE)  {
    			traffic_gen_resume(&tg_config);
    		} else {
    			LOG_INF("UNKNOWN TWT STATE %d", *twt_state);
    		}
    	}
    		break;
    #endif
    	default:
    		break;
    	}
    }

    With this, you should see log similar to this, which shows that the device enters sleep state:

    TWT sleep state: sleeping
    TWT sleep state: awake
    TWT sleep state: sleeping
    TWT sleep state: awake
    TWT sleep state: sleeping

    However, the best way to test whether it goes into sleep mode is to measure power consumption. If you have a PPK2 or another tool for measuring power consumption, I recommend doing so. The power consumption should look similar to this if it enters sleep mode:

    Best regards,
    Marte

  • Hi Marte,

    As you advised, we followed the steps to collect the logs, but we are still not able to see the logs as expected.Please find the attached screenshot for your reference.

    Additionally, we do not have a PPK2 device available to measure power consumption.

    Thanks & Regards,

    Naveen P

  • Hi Naveen,

    The ifdef for CONFIG_SCHEDULED_TX should not have been included in the previous function, so I apologize for that.
    Please try this instead:

    static void wifi_mgmt_event_handler(struct net_mgmt_event_callback *cb,
    				     uint32_t mgmt_event, struct net_if *iface)
    {
    	switch (mgmt_event) {
    	case NET_EVENT_WIFI_CONNECT_RESULT:
    		handle_wifi_connect_result(cb);
    		break;
    	case NET_EVENT_WIFI_DISCONNECT_RESULT:
    		handle_wifi_disconnect_result(cb);
    		break;
    	case NET_EVENT_WIFI_TWT:
    		handle_wifi_twt_event(cb);
    		break;
    	case NET_EVENT_WIFI_TWT_SLEEP_STATE: {
    		int *twt_state;
    
    		twt_state = (int *)(cb->info);
    		LOG_INF("TWT sleep state: %s", *twt_state ? "awake" : "sleeping" );
    		if (*twt_state == WIFI_TWT_STATE_SLEEP) {
    			traffic_gen_pause(&tg_config);
    		} else if (*twt_state == WIFI_TWT_STATE_AWAKE)  {
    			traffic_gen_resume(&tg_config);
    		} else {
    			LOG_INF("UNKNOWN TWT STATE %d", *twt_state);
    		}
    	}
    		break;
    	default:
    		break;
    	}
    }

    You can also remove the traffic_gen_pause() and traffic_gen_resume() functions. The most important part is to log the sleep state:

    static void wifi_mgmt_event_handler(struct net_mgmt_event_callback *cb,
    				     uint32_t mgmt_event, struct net_if *iface)
    {
    	switch (mgmt_event) {
    	case NET_EVENT_WIFI_CONNECT_RESULT:
    		handle_wifi_connect_result(cb);
    		break;
    	case NET_EVENT_WIFI_DISCONNECT_RESULT:
    		handle_wifi_disconnect_result(cb);
    		break;
    	case NET_EVENT_WIFI_TWT:
    		handle_wifi_twt_event(cb);
    		break;
    	case NET_EVENT_WIFI_TWT_SLEEP_STATE: {
    		int *twt_state;
    
    		twt_state = (int *)(cb->info);
    		LOG_INF("TWT sleep state: %s", *twt_state ? "awake" : "sleeping" );
    	}
    		break;
    	default:
    		break;
    	}
    }

    Best regards,
    Marte

Related