[BUG] sleepyTransaction counter in ZigBeeTransactionManager stucked
It has happened that no transaction for any of the sleeping devices was processed, because the transaction sleepyTransaction counter was no longer decrements.
After investigation, I noticed that a transaction placed in a sleepy queue (in method sendNextTRansaction), once processed: In the transactionComplete method, when the queue is retrieved using getTransactionQueue, it is no longer marked as sleepy because it becomes the default queue...?... Therefore, the counter is not decremented.
Another comment, I was surprised to see that there was only a global counter for all sleeping devices, and not a per-device counter. Wouldn’t it be relevant to have a counter per queue?
Handling sleepy devices is a pain. Some routers may not have many buffers available, so having too many outstanding messages sent to SEDs can cause them to get lost, so you'd need to be careful about releasing too many messages to SEDs. This is probably why it was implemented as a global counter... That said - this was written a long time ago so I'm happy to be convinced that there's a better way to manage this if you have some tests that show it working better.