Other Parts Discussed in Thread: Z-STACK, CCSTUDIO, , ENERGYTRACE, LAUNCHXL-CC1352P1
I have imported and modified the zed_sw application as: Z_POWER_TEST added, POWER_TEST_POLL_ACK added, CUI_DISABLE is used, xBOARD_DISPLAY_USE_UART is used, optimization set to 3, radio settings are at 60000 ms at 0 dBm, POWER_SOURCE_BATTERY is used. That achieves 10 uA. That is good enough for now. Automatic network join works nicely.
There is one simple thing I would like to do. The zigbee end device has some button type (open or close) I/O to handle. Power consumption is crucial - looking for the least overhead.
After going through docs and threads, it looks some advice is needed:
1. I saw hal_key.c what supposed to have HalKeyExitSleep() in an old forum entry - not sure if that still exists and/or relevant. If so, then the question is that how to import that and then ensure it executes some code made for the case when zigbee sleep exit was caused by a keypress.
2. Using sensor controller is probably an alternative approach, although it is not clear how to interrupt Z-Stack sleep once triggered.
3. What I really would like to do (without increasing power consumption more than absolutely necessary, and which is cheaper of those):
a) get notified on button state change and send a message to the controller and go back to sleep. Easily done from an added thread, but expensive. Or
b) check button status every time when zigbee wakes up at POLL rate (60000 ms) and test current button status against last known and send message to controller if there was a change (delay is okay). Ideally, without modifying Z-Stack code, just by a callback or such. This feels the most efficient but unsure how to add some extra code to the networking cycle. Is it possible at all? Or
c) Use sensor controller, set variables based on button change, wake-up Z-Stack... and again the same situation: either another thread and semaphore is required (a) or adding some code to be executed in the zigbee thread (b).
The problem is power consumption. As soon as I add just one more thread to get the button callback (like 10 lines of code), 10 uA goes to 500 uA what shrinks battery life to an unusable level.
Summary: how to implement an on-off switch with 1-2 buttons to use as much power as in the reference documentation while sending occasional open / close messages to the controller, like 5-10 per day?