Commit graph

246 commits

Author SHA1 Message Date
rbaron
e68c113513 [ble sample] Sets BTHome V2 as the default encoding
This change has been planned for a while, and BTHome v2 + Home Assistant
is currently the most convenient, hassle-free and maintained way to
interface with the BLE sample currently.
2023-07-23 18:39:01 +02:00
rbaron
9ea5c7b4d0 Make init & loop fns static 2023-07-23 18:30:23 +02:00
rbaron
1a5acd02a5 [ble] __ASSERT initialization & sensor reading
After we tracked down a rare, annoying bug for the zigbee sample in #150,
this PR does something similar for the ble sample. If there's an error
either initializing the board of reading the sensors, __ASSERT will
reboot the system, instead of letting it hang forever.
2023-07-23 18:10:28 +02:00
rbaron
9fdd15626a Better error handling for SHTC3 reading 2023-07-15 11:07:35 +02:00
rbaron
c70eb600a3 [zigbee sample] Introduce watchdog for sensor task 2023-07-15 09:45:34 +02:00
rbaron
bc3d834b20 Make it mandatory to select a factory reset method
... in order to avoid unhappy surprises
2023-07-01 08:26:21 +02:00
rbaron
37aff683ad LOG_INF -> LOG_DBG 2023-07-01 08:04:17 +02:00
rbaron
c86f04e406 Nuclear reset option if recurring sensor task cannot be rescheduled
Famous last words: "this should never happen"
2023-07-01 08:04:17 +02:00
rbaron
7f42dd0c00 Add missing prst_led_off after stopping LED flashing timer 2023-07-01 08:04:17 +02:00
rbaron
46feb542cc More fixes to the ZigBee sample
- 🚨 Missing `break` statements in `zboss_signal_handler`
- Makes `zboss_signal_handler` return fast. According to the
  [docs](https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.thread_zigbee.v2.0.0%2Fgroup__zb__comm__signals.html):
  "Signal processing should not do long operations synchronously". I
  removed calls to `prst_flash_led` (essentially a huge sync delay) and `debug_counters_increment`,
  which were blocking. I'll try migrating the debug_counters to
  non-blocking separately
- Main sensor reading task is started for the first time upon
  the `ZB_ZDO_SIGNAL_SKIP_STARTUP` signal. This is what the
  [weather_station sample](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/applications/zigbee_weather_station/README.html) does. It should have no functional difference, but there's [some special handling for alarms started from the ZigBee task](0469247dc4/subsys/zigbee/osif/zb_nrf_platform.c (L426))
2023-07-01 08:04:17 +02:00
rbaron
62a99cc716 Reintroduced accidentally deleted comment 2023-07-01 08:04:17 +02:00
rbaron
90f99bd5b0 Fixes (minor?) issues with the ZigBee sample
1. zigbee_configure_sleepy_behavior must be called before zigbee_enable - [source
docs](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/libraries/zigbee/zigbee_app_utils.html#c.zigbee_configure_sleepy_behavior)

2. zb_zdo_pim_set_long_poll_interval must be called after the network is joined - [source docs](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/zboss/3.5.2.0/group__zdo__poll__control.html#ga3aae8929b30e71c872f937771b89c768).
On top of that, the argument for the call was incorrect - it expects ms directly.

3. Removed the unecessary CONFIG_PM, seems like there's no impact in power consumption. Could it cause some weirdness?

4. Implemented CONFIG_PRST_ZB_FACTORY_RESET_DISABLED=y to fully disable factory resetting. May aid debugging.

5. Implemented multi/single channel support. Helps with battery life when scanning networks
2023-07-01 08:04:15 +02:00
rbaron
5882312a77 [zb] Debugging changes:
- Disables double reset
- Fully reset with zb_reset() on reset watchdog instead of
  user_input_indicate()
- Debug counters before/after sensors read
2023-07-01 08:03:42 +02:00
rbaron
f9f122b818 Formatting 2023-06-27 21:34:49 +02:00
rbaron
d5891f4a6f [ZigBee sample] Implements factory reset via SW1 button (hardware v2.0.0+) 2023-06-27 21:28:56 +02:00
rbaron
56c5fa7ba0
Merge pull request #133 from rbaron/zb_debug_counters
[ZigBee Sample] Introduce debug counters
2023-06-27 19:08:53 +02:00
rbaron
afa53f0e94 Introduce CONFIG_BOARD_REVISION_CODE
Beside having a `CONFIG_BOARD_REVISION` Kconfig string that represents
our semantic versioning for board revisions, the ZigBee sample requires
an integer representation of it. Instead of conditioning the integer
version on the string version only for that sample and having to touch
the ZigBee sample whenever we add a revision, I decided to have a
board-wide config, so that both string and int versions live close to
each other.

Fixes #138.
2023-06-15 07:45:55 +02:00
rbaron
930239e385 Cleanup + double_reset counter 2023-06-07 08:26:05 +02:00
rbaron
015ce94bbd Cleanup 2023-06-07 08:10:23 +02:00
rbaron
987c4f52c0 Removes async debug counters API - not needed 2023-06-07 08:08:34 +02:00
rbaron
509350457f [ZigBee sample] Introduce debug counters
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.
2023-06-07 08:08:34 +02:00
Ole Odendahl
3aa33cdd89
Fixed api of restart watchdog. 2023-06-02 11:39:52 +02:00
Ole Odendahl
ce748c4759
Added restart watchdog timeout to Kconfig. 2023-06-02 11:31:58 +02:00
Ole Odendahl
5cede82dc5
Changing api of restart handler to only expose needed functions.
This encapsulates the low level timer logic from the caller.
2023-06-02 11:16:49 +02:00
Ole Odendahl
9285a6bc41
Added comment to describe nordic funny function name. 2023-06-02 11:15:46 +02:00
Ole Odendahl
6f10dc9e19
Fixed clang format. 2023-06-02 11:07:47 +02:00
Ole Odendahl
c52d5f7a48
Added steering restart handler to signal handler steering branch.
Made the device flash less frequently to save power on unexpected connection drops.
2023-06-02 11:07:47 +02:00
Ole Odendahl
727138415e
Added restart handler module. 2023-06-02 11:07:46 +02:00
Ole Odendahl
69c0ed3694
Separated two signals for better debugging and possibly different handling. 2023-06-02 11:07:46 +02:00
Ole Odendahl
ba786eb298
Moving steering successful flashing to success if branch. 2023-06-02 11:00:17 +02:00
Matthew Dawson
54b1c48638
Implement workaround for errata KRKNWK-12017
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.
2023-05-10 10:45:30 -04:00
rbaron
7ac6d98b3b [ble] Make advertising non-connectable
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.
2023-04-16 12:28:23 +02:00
rbaron
9ff5180cd7
Merge pull request #117 from rbaron/hardware-v2
Version 2.0.0
2023-03-30 19:30:06 +02:00
rbaron
cb40173b6b Remove debug info 2023-03-29 21:46:41 +02:00
rbaron
ebc26fcccd Cleanups 2023-03-29 21:42:41 +02:00
rbaron
e82c1b6bc1 Implements button handling
- DTS bindings
- Debouncing logic
- New `input` for testing and interrupt power profiling
2023-03-29 21:28:24 +02:00
Ole Odendahl
20d6c893bf
Added callback for handling identify button action as declared in identify cluster. 2023-03-27 12:20:03 +02:00
rbaron
02b3970ffc Shorten job names 2023-03-19 16:45:55 +01:00
rbaron
5cc40a41f6 Set calibration coefficients for 2.0.0 2023-03-19 15:06:39 +01:00
rbaron
b34bc60a0a Actually use the devicetree calibration coeffs 2023-03-19 15:06:39 +01:00
rbaron
2f7a25e266 Add devicetree calibration coeffs to nrf52833 board 2023-03-19 15:06:39 +01:00
rbaron
e24530b7c3 Fix devicetree-coeffs bug 2023-03-19 15:06:39 +01:00
rbaron
1983f31af9 Store calibration polynomial in devicetree
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.
2023-03-19 15:06:39 +01:00
rbaron
dbf288138e Add 2.0.0 board revision & CONFIG_BOARD_REVISION Kconfig 2023-03-19 15:06:39 +01:00
rbaron
5e315ba9cd [ble] Update connection interval docs & power profile
Closes #98
2023-02-12 16:13:55 +01:00
rbaron
7be5fe1669 [ble] Bumps default advertising interval to [30, 40] ms
This makes the BLE sample use the same parameters as the legacy
firmware, and immproves the range.
2023-02-12 16:02:51 +01:00
rbaron
d292190d31
Merge pull request #103 from MJDSys/fix_battery_information 2023-02-02 08:14:47 +01:00
Matthew Dawson
d3bcc13749
Fix battery quantity/size reporting
The API for reporting information requires a pointer to the data value,
and cannot deal with a constant directly.  The current quantity/size
returned by the device are random values from memory.

Instead move these values into the prst_batt_attrs_t struct and
set their values in prst_zb_attrs_init.
2023-02-02 00:43:13 -05:00
rbaron
28db7224a6 Make advertisement intervals configurable
We were previously relying on the default values (100ms, 150ms). This
PR makes it easier to test and configure parameters for different
tradeoffs between range / power consumption (#98).
2023-01-28 11:44:17 +01:00
rbaron
41ba531fba
Merge pull request #101 from MJDSys/zigbee_2.2_sdk 2023-01-23 11:12:55 +01:00