nRF5340 Dual Role Issue: BLE Mesh Node + GATT Server (BLE Peripheral) Not Working in Parallel

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:

  1. The device is provisioned via the nRF Mesh app and joins the Mesh network.
  2. 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?
Parents
  • Hello Pallavi,

    Could you please share the compiled Kconfig file located at the following path?
    <build directory>/<application name>/zephyr/.config

    Hieu

  • Hello Hieu,

    I have previously tried merging the Light Switch (BLE Mesh) example with my custom GATT service (based on the Nordic LBS example). The node does not start GATT advertising after provisioning, and Mesh functionality also stop working after resetting mesh

    Uploading .config directly is not supported, I’ve attached a .zip file below  that includes the .config file .

    /cfs-file/__key/communityserver-discussions-components-files/4/7180.light_5F00_switch.zip      

    I found this ticket titled "Same Node as BLE Mesh and BLE Server (Dual Role)", which related to what I’m working on. I’ve tried the suggestions mentioned there, but get the same result advertising is not working. I have  tried to use it by creating new project(light Switch example) for nrf5340dk and then replace files with suggested project to build it. 

    Please find Below zip file for your reference.

    /cfs-file/__key/communityserver-discussions-components-files/4/5277.light_5F00_switch_5F00_coex.zip

  • Hi Pallavi,

    I see that you have the Proxy feature enabled in both project.

    In the first attachment, on the application core, CONFIG_BT_MAX_CONN is only 1, and on the network core, CONFIG_BT_CTLR_SDC_PERIPHERAL_COUNT is also only 1.

    In the second attachment, CONFIG_BT_MAX_CONN is higher on the application core, but CONFIG_BT_CTLR_SDC_PERIPHERAL_COUNT is still only 1 on the network core.

    In both cases, your device can only support one peripheral connection at a time. Additionally, it also means that the device can only have one connectable advertising set running at a time.

    In this situation, the Mesh Proxy advertising would take that one spot, making it not possible to start new connectable advertising. 

    Please try to set a higher value to CONFIG_BT_MAX_CONN on both cores, and CONFIG_BT_CTLR_SDC_PERIPHERAL_COUNT on the network core.

Reply
  • Hi Pallavi,

    I see that you have the Proxy feature enabled in both project.

    In the first attachment, on the application core, CONFIG_BT_MAX_CONN is only 1, and on the network core, CONFIG_BT_CTLR_SDC_PERIPHERAL_COUNT is also only 1.

    In the second attachment, CONFIG_BT_MAX_CONN is higher on the application core, but CONFIG_BT_CTLR_SDC_PERIPHERAL_COUNT is still only 1 on the network core.

    In both cases, your device can only support one peripheral connection at a time. Additionally, it also means that the device can only have one connectable advertising set running at a time.

    In this situation, the Mesh Proxy advertising would take that one spot, making it not possible to start new connectable advertising. 

    Please try to set a higher value to CONFIG_BT_MAX_CONN on both cores, and CONFIG_BT_CTLR_SDC_PERIPHERAL_COUNT on the network core.

Children
No Data
Related