rbaron / b-parasite

🌱💧 An open source DIY soil moisture sensor
1.85k stars 143 forks source link

Zigbee schedule steering restart #130

Closed oleo65 closed 1 year ago

oleo65 commented 1 year ago

From the discussion in #126

This PR implements a timer based mechanism to restart networt steering if the previous steering procedure was not successful. This change will improve the reliability with reconnecting to the network e.g. in cases of power losses or being located at the edge of the network.

Zephyr does only try to reconnect to the network a finite amount of times for end devices. It does so with exponential back of for around 15 minutes. This behaviour is hard coded into Zephyr and not easily changeable.

The official docs suggest reinitializing the steering process by either power cycling the device or via provided method user_input_indicate().

The PR is meant for a basis for discussion and further improvements.

I tried to keep the main.c as clean as possible by moving the code to separate files. My C knowledge is somewhat limited and maybe there is a better way of doing this.

I adjusted some LED blinking to reduce blinking in case of network loss to reduce power draw.

The firmware runs on a few parasites in my setup for almost two months now and proves to be quite reliable.

rbaron commented 1 year ago

That's great, thanks once again @oleo65!

I added a few minor cosmetic comments. Let me know what you think - I'm also happy to tackle those changes myself.

Also just double checking that I understand it correctly: with this change, once joined a ZigBee network, we will keep trying to rejoin it forever: initially through ZBOSS built-in retries and then using our watchdog timer.

rbaron commented 1 year ago

Thanks @oleo65, it looks great.

I will flash a few b-parasites with this code and let it roast for a little bit.

rbaron commented 1 year ago

@oleo65 thanks once again!