I checked the RUI3-LowPower-Example. It wakes using a periodic timer (api.system.timer).
My application is completely event-driven and has no periodic timer.
The MCU should wake only on:
PIR GPIO interrupt
LoRa P2P packet reception
Is api.system.sleep.all() expected to support wake-up from LoRa P2P receive (api.lora.registerPRecvCallback / api.lora.precv(65533)), or is LoRa P2P RX not a supported wake source on the RAK3172?
Then don’t use the periodic timer and instead implement the interrupt function for the PIR to trigger the sending instead.
See RUI3-RAK13011-Alarm, it uses an GPIO connected to a reed relay to trigger sending.
Set the send interval to 0 and it will only send if the interrupt occurs.
Thank you. The PIR GPIO interrupt approach is clear.
I have one more question regarding LoRa P2P.
My application has two wake-up sources:
PIR GPIO interrupt
Incoming LoRa P2P packet
Can api.system.sleep.all() wake the RAK3172 when a LoRa P2P packet is received (api.lora.precv(65533) + api.lora.registerPRecvCallback()), or is GPIO the only supported wake source while sleeping?
If LoRa P2P wake-up is supported, could you point me to an example?
The examples usually do not use sleep() at all they are all event driven. RUI3 will put the device into sleep whenever possible by itself, if setup with correct API calls
// Enable low power mode
api.system.lpmlvl.set(2);
api.system.lpm.set(1);