Sleepy end device causing missed report of variable change

Greetings, i'm developing a custom sleepy end device whose role is to detect whether a certain event is occurring, this triggers the update (EDIT: via interrupt handler) of a custom cluster boolean attribute that is then reported to the coordinator, once the event stops being detected, the boolean attribute is then reset by means of a Zephyr timer.

I have noticed that, with the sleepy end device behavior configured, sometimes the device fails to report the change from "false" to "true", but then reports correctly the change back to false when the timer expires.

A check with a packet sniffer further confirmed the fact that the packet is simply not being sent.

How can i solve this issue?
Thanks in advance

EDIT: addendum
After setting up the project to log to RTT and checking more with a DK running the Shell sample as coordinator, i see the following:
-the sending of the report packet seems delayed by around 2-4 seconds (tested by counting the time between a led turning off, signaling the update of the attribute to false and the reception of the report)
-the RTT does not seem to grab all logs in a timely manner, sometimes losing or receiving LOG_INF in a delayed manner, i do not know if this is related

  • So we should schedule a work responsible for changing the attribute (like with the timeout)? Seems feasible assuming the following interrupts check the state of is_shaked (or alternatively, a dummy variable toggled along with the scheduling) before scheduling the work in order to avoid repeated schedulings.

    Though the part regarding "modifying the variable value from multiple threads at the same time" puzzles me, are you saying that having two different works for toggling the variable on and off respectively is not recommended? 


    Edit: the use of the ZB_SCHEDULE_APP_CALLBACK macro worked wonderfully and now we see every single update as it should. We all thank you for your help and for your patience.

Related