I am currently developing a firmware application on the nRF5340 where I need the device to function in dual role:
- As a Bluetooth Mesh Node, communicating with other mesh nodes.
- As a BLE GATT Server (Peripheral), allowing a mobile app to connect and exchange data over a custom GATT service.
Issue:
After provisioning the device into a Mesh network using the nRF Mesh app, I attempt to start GATT advertising using bt_le_adv_start()
to expose the custom GATT service. However, this consistently fails with error -12 (ENOMEM).
To resolve this, I tried the following:
1. Disabling Mesh Provisioning and GATT Proxy after provisioning using:
bt_mesh_prov_disable(BT_MESH_PROV_ADV | BT_MESH_PROV_GATT);
bt_mesh_proxy_gatt_disable();
However, this still results in the same -12 (ENOMEM)
error.
2. Enabling Extended Advertising:
Even with extended advertising enabled, bt_le_adv_start()
still fails with -12
, indicating an internal limitation or conflict with Mesh Proxy usage.
3. Resetting Mesh and Disabling BLE Stack after provisioning using:
bt_mesh_reset();
bt_disable();
This allows GATT advertising to work, and the mobile app can connect and exchange data. However, the device no longer participates in the Mesh network it stops sending and receiving mesh messages.
Intended Behavior:
- The device is provisioned via the nRF Mesh app and joins the Mesh network.
- After provisioning, the device should:
- Continue operating as an active Mesh node, publishing and subscribing to messages.
- Start GATT advertising to expose a custom service that allows a mobile app to connect.
- Enable simultaneous communication with both mesh nodes and the connected mobile app.
please recommend me :
- How can I safely disable the Mesh GATT Proxy post-provisioning to free advertising resources?
- What is the recommended way to run BLE Mesh and a custom GATT server in parallel on the nRF5340?
- What is the intended flow in NCS for transitioning from Mesh provisioning (via PB-GATT) to custom GATT advertising for application use cases?