Enable or disable TWT with notification

I am studying Lesson 6/wifi fund_1ess6uexer2 and I can run the provided code normally.

(academy.nordicsemi.com/.../)
But I still want to control whether to send packets by pressing button 2 when turning off the TWT function.
As shown in step 3 of the diagram, when I turn off TWT, I press button 2 to enable the send package, but no data packet is sent. I tried to modify the code as shown in step 4 of the diagram, but couldn't. Could you please provide some help and guidance? Thank you very much!

  • I captured the package by wireshark, the track is shown in figure below, I tried to analyze the reason for the peak.

    I think the peak is caused by the "QoS null function" package.

    do you think it is reasonable or not?

  • Hi,

    Can you share the sniffer log as a pcap file?

    It seems like TWT is not set up correctly based on this log:

    [00:01:15.231,933] <inf> Lesson6_Exercise2: TWT interval: 0 s (100000 us)

    For some reason, TWT is set up with a TWT interval of 0.1 seconds, which could explain the high current consumption. If you have not made any changes to the code, then the interval should be 7 seconds.

    Also, which version of the nRF Connect SDK are you using?

    Best regards,
    Marte

  • Oh, i am so sorry  that i modify the twt interval 100ms.

    The nRF Connect SDK is v2.7.0.

    nordic TWT.pcapng

  • Hi,

    Why are you setting the TWT interval to 100 ms? With your current configurations, the device will only be asleep for 35 ms for each TWT service period since the wake interval is 65 ms and the TWT interval (wake + sleep) is 100 ms. This will result in a higher current consumption than when using legacy power save mode. Can you try increasing the TWT interval to see if you get the same behavior?

    Best regards,
    Marte

  • I want to compare the power consumption of TWT and legacy power save mode under the same conditions, as the legacy power save mode is 100 ms.

    As you said, the legacy power save mode is 1.78mA, and TWT is 40.95mA, as shown in picture 1 and picture 2.

    But when I send a package the legacy power save mode consumes more power than TWT.

    as shown in picture 3 and picture 4.  TWT average is 44.35mA, and the legacy power save mode is 58.31mA  in 100ms.

    So, why does the legacy power save mode consume more power than the TWT mode when sending a package?

    picture 1 (the legacy power mode ):

    picture 2 (TWT mode ):

    picture 3 (the legacy power mode with send a package):

    picture 4 (the TWT mode with send a package):

    The code is from lesson 6/wifi fund_1ess6uexer2, and put the button 2 to send a "hello"

    package. the high peak power in Figure 3 and Figure 4 is caused by the package. the code change is as:

     

    static void button_handler(uint32_t button_state, uint32_t has_changed)
    {
    	uint32_t button = button_state & has_changed;
    
    	/* STEP 5.1 - Call wifi_set_twt() to enable or disable TWT when button 1 is pressed. */
    	if (button & DK_BTN1_MSK) {
    		wifi_set_twt();
    	}
    
    	/* STEP 5.2 - Enable or disable sending packets during TWT awake when button 2 is pressed.
    	 */
    	if (button & DK_BTN2_MSK) {
    		send_packet();
    	}
    }

Related