Advertise a per-node name so several HiveInsides can be told apart - #70
Merged
Merged
Conversation
Every node advertised the bare local name "HiveInside". In a yard running more than one, a scanner listed several identical entries and the only thing separating them was the raw BLE address — which is not on the enclosure, not in HiveHub's dashboard, and not something a beekeeper has memorized. beacon_init() now appends a hyphen and the last two bytes of the node's identity address, so what goes on the air is "HiveInside-8A3F". The suffix is derived from the address rather than provisioned, so it needs no setup step and survives a factory erase. bt_set_name() keeps the GAP Device Name characteristic in step with the scan response, so a node does not call itself one thing while advertising another. The name buffer starts out holding the bare prefix, so a node whose identity address cannot be read, or whose suffix would not fit, still advertises a usable name instead of an empty or half-written one. Two build asserts hold the sizing: the scan response is still measured at the name's full length against the 31-byte legacy limit, and CONFIG_BT_DEVICE_NAME_MAX must cover the name bt_set_name() is handed. Firmware 0.4.7 -> 0.5.0 (the advertised scan response changes).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Every node advertised the bare local name
HiveInside. In a yard running more than one, a scanner listed several identical entries and the only thing separating them was the raw BLE address — not on the enclosure, not in HiveHub's dashboard, and not something a beekeeper has memorized.What changed
beacon_init()appends a hyphen and the last two bytes of the node's identity address, so what goes on the air isHiveInside-8A3F. The suffix is derived from the address rather than provisioned, so it needs no setup step and survives a factory erase.bt_set_name()keeps the GAP Device Name characteristic in step with the scan response, so a node does not call itself one thing while advertising another. That needsCONFIG_BT_DEVICE_NAME_DYNAMIC=y;CONFIG_BT_DEVICE_NAME_MAXis pinned to 15 rather than left at the default 28, which would reserve RAM for a name this firmware cannot produce.snprintkreports what it would have written, so the truncation guard checks against the room it was given, not just a negative return.CONFIG_BT_DEVICE_NAME_MAXmust cover the namebt_set_name()is handed.Firmware 0.4.7 → 0.5.0 — the advertised scan response changes.
Files
firmware-nrf54lm20a/src/beacon.cbuild_adv_name(), both scan-response paths, build assertsfirmware-nrf54lm20a/src/hive_config.hHIVEINSIDE_DEVICE_NAME_MAX; version bumpfirmware-nrf54lm20a/prj.confCONFIG_BT_DEVICE_NAME_DYNAMIC,CONFIG_BT_DEVICE_NAME_MAXREADME.mdTesting
Not built. This environment has no west/Zephyr toolchain, so the firmware is unbuilt here — CI is the first real compile. The change is source-level only (no build-system or manifest changes), and the sizing constraints that would normally bite are covered by the two
BUILD_ASSERTs rather than left to a link error.Companion
MacNite/HiveHub#171 surfaces this name in the dashboard's firmware panel. That side degrades gracefully on its own: a node still on 0.4.x shows its BLE address and a note saying 0.5.0 gives it a distinguishable name.
🤖 Generated with Claude Code
https://claude.ai/code/session_01T9ZUAmc45AB5Mf7ETM82Uv