Resume advertising is not working

Hi,

I'm trying to connect multiple device on the same peripheral (nrf5340), but my peripheral does not restart advertising once a device is connected.

How to reproduce:

Use https://github.com/nrfconnect/sdk-nrf on branch v2.1-branch (f3b4453b08a7093e23670a7d15d3cccda6afda33).

Apply the following patch:

```diff --git a/samples/bluetooth/peripheral_gatt_dm/prj.conf b/samples/bluetooth/peripheral_gatt_dm/prj.conf
index a2ec483d3..ebbced361 100644
--- a/samples/bluetooth/peripheral_gatt_dm/prj.conf
+++ b/samples/bluetooth/peripheral_gatt_dm/prj.conf
@@ -19,3 +19,4 @@ CONFIG_BT_DEBUG_LOG=y
 CONFIG_BT_GATT_DM_DATA_PRINT=y
 
 CONFIG_DK_LIBRARY=y
+CONFIG_BT_MAX_CONN=10```

Build `bluetooth/peripheral_gatt_dm` sample.

Flash the board (nrf5340dk).

Expected behavior:

Once I connect a device on my board, the board should resume advertising and I should be able to connect a second device.

Actual behavior:

Once I connect a device on my board, the board DOES NOT resume advertising and I can't connect a second device.

Did I miss anything ?

Thanks

  • Hello ThomasW,

    I think there might be a misunderstanding here.

    I can't replicate your patch action, but from the log I assume the only change is adding CONFIG_BT_MAX_CONN=10 to proj.conf, right?
    This change only configures the sample setup to support 10 connections. It doesn't make the device advertise again. 

    Meanwhile, the sample you are working on, Peripheral GATT Device Manager (DM), is a sample designed to connect to one central, and therefore also doesn't have any code to advertise again.

    If you wish to see advertisement starts again, you could check out the Peripheral Bond Management Service (BMS) sample, which is designed to connect two central devices out of the box.

    If you wish to see the behavior in the Peripheral GATT DM sample, you need to write your own behavior. You could refer to the BMS sample for how to do so.

    Out of curiosity, where did you find the instruction to patch the sample like you did?

    Best regards,

    Hieu

    Edit: The information provided above regarding advertisement auto restart is incorrect and therefore I have editted it into strikethrough format.

  • Hi,

    I tried the `bluetooth/peripheral_bms` sample but once I connect to it (using my phone), it does not start advertising again.

    FYI, it's my own instruction:

    If I'm not mistaken, once a device is connected, bt_le_adv_resume will be automatically called by bt_hci_le_enh_conn_complete. But maybe setting CONFIG_BT_MAX_CONN > 1 is not enough. Maybe you can help me with that ?

    I tried the `bluetooth/peripheral` sample on Zephyr (v3.2.0) with the same patch and advertising restarts again after a connection.

    Do you know where the problem comes from ?

    Thanks

  • Hi ThomasW,

    I just run the samples and look at their main.c codes; and it seems that you are right that advertising is automatically resume when a connection is established, and the device is capable for more connections.

    I have updated my previous reply in order to prevent spreading of misinformation. I'm sorry about that. It was wrong of me to assume my knowledge from nRF5 SDK holds true in NCS...

    In any cases, I also observed that advertisement starts again on its own just fine in both the GATT DM and BMS samples.
    I can connect a device to both my computer and my phone, and the only modification is CONFIG_BT_MAX_CONN=2 or 10.

    Thus, I don't have an immediate idea why you were successful with Zephyr but not with NCS...
    I have one idea, but I will need more time to check, so I will get back to you latest on Friday.

    Meanwhile. this is unlikely but perhaps your NCS installation is corrupted?
    How did you install it?
    Your question mentioned you are working on a sdk-nrf branch. Is there a reason you don't work on a tagged release instead?

    Best regards,

    Hieu

  • Hi,

    I tried again the `bluetooth/peripheral_bms` sample on sdk-nrf repository using tag v2.1.0, and I have the same behavior: Advertising does not restart.

    This is exactly the steps I followed:

    - west init -m github.com/.../sdk-nrf --mr v2.1.0

    - west update

    - cd nrf/samples/bluetooth/peripheral_bms

    - west build -d build -b nrf5340dk_nrf5340_cpuapp .

    - nrfjprog -e

    - west flash -d build

    - I use `nRF Connect` on my phone, I run a scan and then I connect to `Nordic_BMS`

    - I use a SECOND phone, I run a scan, and I can't see any devices `Nordic_BMS`

    - If I disconnect from my first phone, I can see the `Nordic_BMS` device advertising on my SECOND phone.

    No reason to use a branch, it's a mistake, So like you suggested I switch on a tag instead.

  • Hi ThomasW,

    Sorry, something comes up and I am a little flooded right now. I will come back with you next week, hopefully Monday, latest Tuesday.

    Meanwhile, would you mind sharing me your final compiled Kconfig?
    That, or could you please share your peripheral_bms folder as it is before building?
    I understand that your setup is supposed to be the SDK untouched. However, as I have trouble reproducing the problem with an equivalent setup, that might help.

    Finally, what advertising parameters were the bt_le_adv_start() called with?

    Best regards,

    Hieu

Related