feat(mesh): add BLE advertisement bearer scaffold#10292
Draft
Komzpa wants to merge 2 commits into
Draft
Conversation
9332707 to
40f3a56
Compare
68e8b9c to
41f5317
Compare
2 tasks
94b8b2d to
8530eaf
Compare
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.
Summary
Adds an experimental firmware-side BLE advertisement mesh bearer:
BLE_ADVERTISEMENT_BROADCASTnetwork protocol flag andTRANSPORT_BLE_ADVERTISEMENTpacket transport marker in generated protobuf headersBleAdvertisementMeshCodecthat fragments encryptedMeshPacketprotobufs into legacy BLE advertisement manufacturer-data frames and reassembles them with CRC-16 validationMeshPacketsize, so a full encrypted packet can be sent across all repeated fragment rounds without dropping framesOSThread-backed frame queue so router send paths enqueue ADV fragments instead of blocking on each fragment burstBLE_MESH_ADVERTISEMENT_COMPANY_IDMotivation
The goal is to make BLE advertisements behave like a LoRa-like broadcast bearer for encrypted Meshtastic packets, rather than like the existing phone GATT API. This keeps the current phone
FromRadio/ToRadioBLE service untouched while giving supported BLE stacks a small transport contract to plug into.Notes
This is still a draft and experimental. It does not enable BLE advertisement relaying through default saved config; the new bearer only starts when
BLE_ADVERTISEMENT_BROADCASTis present inconfig.network.enabled_protocols.The matching canonical schema enum/source PR is meshtastic/protobufs#917; keep this firmware PR draft until that schema lands or generated bindings are refreshed from the accepted schema.
The current real platform path is ESP32 devices using NimBLE2 extended-advertising support, currently represented by the ESP32-C6 target in this tree. Older ESP32/NimBLE1 builds and nRF52 builds do not enable the bearer by default, so they should keep their current phone BLE behavior.
The manufacturer id defaults to an experimental placeholder (
0x05e1) and can be overridden by builds. Review should decide whether Meshtastic wants an assigned Bluetooth SIG company id, service-data encoding, or a project-specific compile-time id.Validation
git diff --check- passeddocker run --rm -v "$PWD:/src:ro" -v /home/kom/proj/lora/.platformio-cache-pr10292:/home/meshtastic/.platformio meshtastic-native-test bash -lc 'rm -rf /tmp/fw-test && cp -a /src /tmp/fw-test && cd /tmp/fw-test && sed -i '''s/-DBUILD_EPOCH=$UNIX_TIME/#-DBUILD_EPOCH=$UNIX_TIME/''' platformio.ini && platformio test -e coverage -v -f test_ble_advertisement_mesh'- passed, 4/4 testsdocker run --rm -v "$PWD:/src:ro" -v /home/kom/proj/lora/.platformio-cache-pr10292:/home/meshtastic/.platformio meshtastic-native-test bash -lc 'rm -rf /tmp/fw-build && cp -a /src /tmp/fw-build && cd /tmp/fw-build && platformio run -e m5stack-unitc6l && platformio run -e rak4631'- passed;m5stack-unitc6landrak4631both reportedSUCCESSNimBLEExtAdvertising,NimBLEExtAdvertisement,NimBLEScan, andNimBLEAdvertisedDevice94:B8:6D:25:56:F1, smallcat adapter:44:03:2C:ED:51:F6MTfragment header, CRC, rotating fragment order, and repeated rounds successfully sent text in both directions over BLE advertisements: nucat -> smallcat (ping from nucat via ble-adv-mesh) and smallcat -> nucat (ack-smallcat)CAP_NET_RAWonly to a small HCI monitor-channel helper allowed non-root raw advertisement receive without restarting bluetoothd, claiming the adapter, or touching normal BlueZ GATT/advertising state; the monitor path saw live repeated LE Advertising Reports directly and assembled text without the BlueZ D-Bus cache workaround: smallcat -> nucat (monitor path from smallcat,helper path from smallcat) and nucat -> smallcat (monitor slow nucat)Not Yet Validated