Always advertising, but with only one connection

Hi,

I have two NRF52840, as peripheral and central. The central is scanning and connects automatically to the peripheral.
I'm using Zephyr and NCS 2.5.1

How is it possible that I keep advertising after the connection is establish, but forbit to allow a second connection? Like act as a beacon after a connection is established.

I've tried setting CONFIG_BT_MAX_CONN=2, then the peripheral keeps advertising, but a second central can easily connect.
I've tried stopping advertising manually after the first connection is established and then tried to start advertising as non connectable, but then I get a reset and fault instruction error.

Do you have any hints for me, i appreciate it.

Thanks and Best Regards,
Phobios

Parents
  • Hi,

    Please have a look at the Bluetooth: Multiple advertising sets sample and check if that meets your requirements. 

    Best regards,

    vidar

    I've tried stopping advertising manually after the first connection is established and then tried to start advertising as non connectable, but then I get a reset and fault instruction

    It's difficult to say what lead to this crash without more information.

  • Hi Vidar,

    this is exactly what I was looking for, thanks a lot! You see; i need my peripheral always action as a beacon for rough localisation between many centrals, but also connected to one central in the area.

    What I don't quite understand is the MAC address showing during scanning. In the central, there are two different MACs for the same peripheral; one for the Beacon, one for the connectable advertising set. How can I match them to the same peripheral if i have several in my environment?

  • Excellent! It is also possible to have the advertisers use the same address. You can acheive this by usiing the 'BT_LE_ADV_OPT_USE_IDENTITY' option flag: 

    diff --git a/src/main.c b/src/main.c
    index df4ab3d..b1dcfec 100644
    --- a/src/main.c
    +++ b/src/main.c
    @@ -30,13 +30,13 @@ static K_WORK_DEFINE(advertising_work, advertising_work_handle);
     
     static struct bt_le_ext_adv *ext_adv[CONFIG_BT_EXT_ADV_MAX_ADV_SET];
     static const struct bt_le_adv_param *non_connectable_adv_param =
    -       BT_LE_ADV_PARAM(BT_LE_ADV_OPT_USE_NAME,
    +       BT_LE_ADV_PARAM(BT_LE_ADV_OPT_USE_NAME | BT_LE_ADV_OPT_USE_IDENTITY,
                            0x140, /* 200 ms */
                            0x190, /* 250 ms */
                            NULL);
     
     static const struct bt_le_adv_param *connectable_adv_param =
    -       BT_LE_ADV_PARAM(BT_LE_ADV_OPT_CONNECTABLE | BT_LE_ADV_OPT_USE_NAME,
    +       BT_LE_ADV_PARAM(BT_LE_ADV_OPT_CONNECTABLE | BT_LE_ADV_OPT_USE_NAME | BT_LE_ADV_OPT_USE_IDENTITY,
                            BT_GAP_ADV_FAST_INT_MIN_2, /* 100 ms */
                            BT_GAP_ADV_FAST_INT_MAX_2, /* 150 ms */
                            NULL);
    

Reply Children
No Data
Related