Switching off listenMode

Started by DRCO, September 22, 2016, 07:18:34 PM

DRCO

Hi Forum,
I've been working for sometime on a water pressure project based on the ultra low power listen mode example covered pretty extensively here:https://lowpowerlab.com/forum/low-power-techniques/ultra-low-power-listening-mode-for-battery-nodes/. I have this process running in a function (outside the main loop) whereby it polls (by incrementing the TARGETID) all the nodes on a network that are sampling sensors.
This is great but to conserve batteries on the nodes, I'd like to initiate the function with a received ping from one of the sensors that can detect water flow.
My premise was to use a cut down version of the struct receive example in the main loop – with the sensor running a cut down version of the struct send example. Once a radio receive is done – that has a certain integer payload (9999) it fires up the function and polls all the other sleeping nodes.
Works great – ONCE!
Clearly there is something in setup() that allows an initial receive in the standard struct send/receive mode – but once this line *** radio.listenModeSendBurst(TARGETID, payload, sizeof(payload)) *** is called in the function – the main loop just rolls over forever regardless of the number of pings I send from the struct send node.
I've tried adding listenModeEnd(); to the loop and in the function but it seems to have no effect.
I have a very amateur sort of workaround whereby I call setup() at the end of the loop, which works – but also terminates some other millis() based functions that I need for other parts of the program.
So, can anyone advise how I can terminate the LowPower listenMode so that radio.receiveDone() will work in the main loop?
I'm pretty new to programming and radio – so greatly appreciate any help. If I need to do homework, please just point me in the right direction.
Greatly appreciate any help...
Chris

ChemE

I do know that setup calls init() as part of its baked in code.  One of the first things that init() does is sei().  Perhaps all you need to do is set interrupts.

DRCO

Hi ChemE, thanks for your suggestion. I seem to have the process going well and reliably using the call to setup(); but in the interest of better understanding what's going on and learning in general, Ill take your advice and do some homework. If I come up with anything I think is useful, I'll post it and ping you.