LWM2M Client - Power Management/callback functions

Good day

I have noticed that when using a callback functions certain limitations exist.  For example, adding functions to the callback function will run into an error or a timeout.  Firstly, I wanted to ask what the limitations when using a callback function(specifically lwm2m ).  Secondly, I am using 

pm_device_action_run(uart_dev, PM_DEVICE_ACTION_SUSPEND);  and 
pm_device_action_run(uart_dev, PM_DEVICE_ACTION_RESUME);
to dynamically turn the UART on and off during the callback function.  I was able to switch the UART on but when I use pm_device_action_run(uart_dev, PM_DEVICE_ACTION_SUSPEND at the end of the function, the UART does not switch off despite the function returning a 0.  What could be the cause of this?  I am aware that these issues are rather specific and any advice would be worthwhile.
Kind regards,
Hassan
  • Hi Hassan,

    I would need additional information.

    Which NCS version do you use? Do you use lwm2m client sample? Have you modified the sample?

    I have noticed that when using a callback functions certain limitations exist.  For example, adding functions to the callback function will run into an error or a timeout.  Firstly, I wanted to ask what the limitations when using a callback function(specifically lwm2m ).

    Could you elaborate on this? What are you trying to achieve? Could you provide an example?

    I was able to switch the UART on but when I use pm_device_action_run(uart_dev, PM_DEVICE_ACTION_SUSPEND at the end of the function, the UART does not switch off despite the function returning a 0.  What could be the cause of this?

    Could you specify more precisely what is currently working and what is not working? Does RESUME work, but SUSPEND not? Could you describe/show where and how you use pm_device_action_run() in your code? What is expected behavior and what actually happens?

    Best regards,
    Dejan

  • Good day Dejan

    I am using the latest toolchain and am modifying the lwm2m client sample. I am using a temperature sensor via a UART to receive information using low power measures and publish onto a lwm2m servers.  As a result, I need to turn on and off the UART when a callback is initiated via the server.  Initially I had a problem whereby the UART wouldn't switch off even after pm_device_action_run(uart_dev, PM_DEVICE_ACTION_SUSPEND was used.  However now, the UART doesnt switch on in time and there callback will result in a timeout server side.  Ive noticed that adding long functions to this callback (or even a delay) will result in a timeout.  Which makes me wonder if this callback has limitations i'm not aware of.  Thank you in advance!

    Kind regards,

    Hassan

  • Hi Hassan,

    There is a configuration option CONFIG_LWM2M_ENGINE_DEFAULT_LIFETIME which specifies how often client sends "I am alive" messages to the server. If the value of this option is set to more than 60 seconds, this may eventually cause timeout. You can have a look at the note in additional configuration.

    Best regards,
    Dejan

  • Thank you for this! will definitely attempt using this.  Another issue I am having as well is  RAI. Using the XRAI commands around my code has been working fine. however, it looks like after the callback function is used, the modem is used again and therefore putting the command at the end of this function doesn't work.  Have you any suggestions for this?

    Kind regards,

    Hassan

  • Hi Hassan,

    Could you show code samples of both working and non-working case when you use XRAI? 

    Best regards,
    Dejan

Related