Skip to content

feat(blemesh_manager): add generic BLE Mesh provisioner manager (IEC-555)#763

Open
Junius00 wants to merge 1 commit into
espressif:masterfrom
Junius00:feat/blemesh_manager
Open

feat(blemesh_manager): add generic BLE Mesh provisioner manager (IEC-555)#763
Junius00 wants to merge 1 commit into
espressif:masterfrom
Junius00:feat/blemesh_manager

Conversation

@Junius00

Copy link
Copy Markdown
Contributor

State-oriented facade over ESP-BLE-MESH: nodes + states instead of opcodes/AppKeys/models. NimBLE REPL example, Unity test_apps, and idf-extra-components manifest/CI wiring.

Will be used by both esp-matter and RMNG, but is technically separate from either project, so it belongs in a repository like this.

Checklist

  • Component contains License — blemesh_manager/LICENSE (Apache-2.0)
  • Component contains README.md — plus examples/repl_demo/README.md
  • Component contains idf_component.yml file with url field defined
  • Component was added to upload job
  • Component was added to build job — via .build-test-rules.yml (blemesh_manager/examples/repl_demo + blemesh_manager/test_apps, gated SOC_BLE_SUPPORTED + IDF ≥ 5.1); the legacy test_app/CMakeLists.txt path is not used
  • Optional: Component contains unit tests — test_apps/ (Unity, Composition-Data parsers) + pytest_blemesh_manager.py
  • CI passing — pending CI run

Change description

Adds blemesh_manager, a reusable, host-agnostic BLE Mesh provisioner facade for ESP-IDF. The application drives the mesh in terms of nodes and states (set OnOff on 0x0011 to true) instead of opcodes, AppKeys, model IDs, and publication setup.

What it does

  • ESP-BLE-MESH stack bring-up + permanent provisioner role; commissioning-window-gated beacon scanning
  • Serialized per-node Config Client sequence (Composition Data Get → AppKey Add → Model App Bind → Pub Set → Heartbeat Pub Set → Default TTL)
  • Outbound Set/Get translation for OnOff / Level / Lightness / CTL / HSL + Sensor Get; vendor passthrough
  • Inbound Status decode → on_state_changed; Set→Get confirmation escalation; heartbeat reachability; paced initial-state sync; NVS-restore of provisioned nodes on reboot
  • Single internal task + queue; consumer callbacks fire only from that task
  • Host-agnostic — works over NimBLE or Bluedroid (component only calls esp_ble_mesh_*); the example defaults to NimBLE.

* break unicast sends to provisioned nodes. The commissioning window
* is gated separately at the beacon-handling layer (see provisioner). */
err = esp_ble_mesh_provisioner_prov_enable(
ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False positive. esp_ble_mesh_prov_bearer_t is a flag enum; ESP_BLE_MESH_PROV_ADV (0x1) | ESP_BLE_MESH_PROV_GATT (0x2) = 0x3 is the documented bitmask the ESP-BLE-MESH API expects to enable both provisioning bearers (esp_ble_mesh_provisioner_prov_enable and add_unprov_dev take a bearer bitmask; IDF's own examples pass the same OR). The combined value is intentionally not a named enumerator. Well-defined in C, no behavioral issue.

if (err != ESP_OK) {
free(copy);
}
return err;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False positive. Ownership of copy transfers to the manager-task queue on success: blemesh_post()xQueueSend() copies the message struct (carrying the copy pointer), and the manager task frees it in free_msg_payload() for BLEMESH_MSG_VENDOR_SEND. The only path where the queue does not take ownership is blemesh_post() != ESP_OK, which frees copy explicitly (L612). Both paths are covered; the analyzer cannot track the ownership transfer across the FreeRTOS queue.

* here: if the leaf only ever advertises on one of them we still
* pass through; if it advertises on both we don't spam the log
* with "Device in queue not support PB-..." every poll. */
add.bearer = (esp_ble_mesh_prov_bearer_t)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False positive. esp_ble_mesh_prov_bearer_t is a flag enum; ESP_BLE_MESH_PROV_ADV (0x1) | ESP_BLE_MESH_PROV_GATT (0x2) = 0x3 is the documented bitmask the ESP-BLE-MESH API expects to enable both provisioning bearers (esp_ble_mesh_provisioner_prov_enable and add_unprov_dev take a bearer bitmask; IDF's own examples pass the same OR). The combined value is intentionally not a named enumerator. Well-defined in C, no behavioral issue.

Comment thread blemesh_manager/src/blemesh_publication_rx.c Fixed
Comment thread blemesh_manager/src/blemesh_publication_rx.c Fixed
@github-actions github-actions Bot changed the title feat(blemesh_manager): add generic BLE Mesh provisioner manager feat(blemesh_manager): add generic BLE Mesh provisioner manager (IEC-555) Jun 23, 2026
@Junius00 Junius00 force-pushed the feat/blemesh_manager branch 3 times, most recently from 4156753 to 84bd30b Compare June 24, 2026 03:10
State-oriented facade over ESP-BLE-MESH: nodes + states instead of
opcodes/AppKeys/models. NimBLE REPL example, Unity test_apps, and
idf-extra-components manifest/CI wiring.
@Junius00 Junius00 force-pushed the feat/blemesh_manager branch from 84bd30b to f226696 Compare June 24, 2026 03:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants