In the effort to increse reliability of the Zigbee sample, #126 and #130
introduced handling for possibly rare, hard-to-debug events that may be
occurring. While these changes seem to help in practive, we don't know
exactly how often, if ever, they are triggered.
This PR introduces debug_counters in hope to add some visilibty in these
hard-to-debug, rare conditions.
Calling `prst_debug_counters_increment("some_counter")` will increment a
value stored in flash. These values are then dumped via logging when the
device boots. Moving forward we can also consider exposing these values
via a ZigBee cluster.
Nordic has published an errata for the nRF Connect SDK for versions
>1.8.0 where a Zigbee End Device can end up getting stuck if the
parent device does not acknowledge the "Device Announcement packet".
They have a suggested workaround to implement in the SDK, which has
been adapted for the custom signal handler used here.
This is an effort to solve issues where my parasites would occasionally
drop off my network and require a reboot. After 24Hrs, I've not yet
had a device disappear but it has taken >weeks before a device would
fail. Unforunately it's hard to debug the board as the chips are in a
low power state when this occurs.
I've been debugging a Shelly [bluetooth
proxy](https://www.home-assistant.io/integrations/shelly/#bluetooth-support)
feature, which didn't like b-parasite's advertising. It swallowed it before proxying it to HA.
I compared to both ATC and the legacy b-parasite advertising
(pre-nrf-connect) and found it to be related to the
non-connectable/non-scannable settings. Until this PR, we were
mistankenly settings the advertising to scannable, although with no
scannable data. The Zephyr code that sets this parameter based on the
scannable data is [here](c0fcd35531/subsys/bluetooth/host/adv.c (L860)).
My bet is that some scanners like ESPHome are okay with this, but Shelly
is not. Either way, I believe this PR makes the advertisements more
compliant.
Previous, SW1 was too close to RST, making it difficult to press one
without pressing another. After changing its position, it was more
convenient to route SW1 to pin 10 on U1 - That's P0.30/AIN6 both on
nRF52840 (C) and nRF52833 (E) modules.
I previously used a basic 2N3906 and then changed its footprint to
SOT-23. This led to the wrong pin assignment.
This commit fixes it by using the correct symbol and footprint for it.
Note that the PCB layout still needs fixing.
This will enable us to transparently use different calibration for
different board revisions. The 2.0.0 revision changes the sensing
circuitry and will need its own coeffs.
In this commit, both models are run in parallel for debugging.