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!

Parents
  • Hi,

    This is due to how the exercise is implemented in such a way that it only sends a message during the awake state when TWT is enabled:

    If you want to be able to send packets when TWT is not enabled, you can call the function to send the packet directly in the button_handler() or schedule that it should be called. This code snippet shows how to call it directly in the button_handler():

    If you want to schedule it, you can take a look at the TWT example here: https://github.com/martelmy/NCS_examples/blob/main/wifi/twt_provisioning_demo. In this example, pressing button 2 will schedule a ping that will either be sent immediately when TWT is not enabled or during the next wakeup when TWT is enabled. You can use work queue to schedule the UDP packet in the DevAcademy exercise in a similar way.
    Please note that this example is not official and should be considered provided “as-is”.

    Best regards,
    Marte

  • Thank you, . Your guidance is detailed and easy to understand.

    I still have questions, as shown in the picture, TWT mode and DTIM mode. How is the peak in the image caused in TWT mode? 

  • Hi,

    Have you configured the device to use DTIM or listen interval as wakeup mode? You can change this by sending a wakeup mode request, as described in step 5 in Lesson 6, exercise 1 - Enabling power save modes in the Wi-Fi Fundamental course.

    Best regards,
    Marte

  • no, I am not, it is the default.

    so, why capture  listen interval is 0x000a (10 beacon about 1 second), but the picture 3 is 100ms

    are there some misunderstandings?

    the code is from:

    github.com/.../main.c

  • Hi,

    Because the device is using DTIM and not listen interval. If you want the device to use listen interval as wakeup mode you must change it by sending a wakeup mode request to the AP. You can do so like this:

    Best regards,
    Marte

  • hello, ,I want to send voice traffic, game traffic, or video traffic through TWT. Do you have any examples of this?

  • Hi,

    Can you clarify what you want to achieve? Do you want the device to send or receive the traffic, and do you want the traffic to be continuous, or should the device be asleep for periods of time before waking up to either receive or transmit something?

    There are some unofficial demos and samples showing image transfer and audio streaming that you can find here:

    These are made by Nordic employees, but have not been thoroughly tested or qualified and should be considered provided “as-is”.

    Best regards,
    Marte

Reply Children