Unable to advertise after connection

Hi,

We are working on migrating our SES SDK based code to NCS Zephyr.
Our board is nrf52833 based.
We have set up advertising for 1 Minute every time (via KCONFIG flag CONFIG_BT_LIM_ADV_TIMEOUT=60).
In addition (simply as a test) - we check via RTC if 2 minutes have passed since the last advertisement, and attempt to advertise again if so.
As long as the central does not connect - this continues successfully.
However - after the central connects (terminating with LOCAL_HOST_DISCONNECT from the central end, and therefore  REMOTE_DISCONNECT from the zephyr peripheral), subsequent advertisements all fails with:

00> [00:06:15.120,086] <wrn> bt_hci_core: bt_hci_cmd_send_sync: opcode 0x200a status 0x12
00> [00:06:15.120,117] <err> bt_adv: bt_le_adv_start_legacy: Failed to start advertiser
00> Advertising failed to start (err -5)

Our adv (from example code) is:

    int err;

    struct bt_le_adv_param *params = BT_LE_ADV_CONN_NAME;
    params->options = params->options;

    err = bt_le_adv_start(params, ad, ARRAY_SIZE(ad), NULL, 0);
where ad is:
static const struct bt_data ad[] = {
    BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR | BT_LE_AD_LIMITED)),
    BT_DATA_BYTES(BT_DATA_UUID16_ALL,
                  BT_UUID_16_ENCODE(BT_UUID_BAS_VAL),
                  BT_UUID_16_ENCODE(BT_UUID_DIS_VAL)),
    BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_CUSTOM_SERVICE_VAL)};
In addition - to stop the continuous advertising after disconnect, we have opted to stop adv after disconnect (which succeeds), via:
    int err = bt_le_adv_stop();
    if(err)
    {
        printk("Failed to stop adv after disconnect (%d)\n",err);
    }
At first, we had added BLE_ADV_OPT_ONCE to the adv params, but thinking that this was the cause of this current bug, we had removed it.
Is something configured incorrectly?
Thanks!
Roi
Parents
  • Hi,

    What version of NCS are you using?

    00> [00:06:15.120,086] <wrn> bt_hci_core: bt_hci_cmd_send_sync: opcode 0x200a status 0x12

    0x200a is the opcode for enabling BLE advertising, and 0x12 is the error code for INVALID HCI COMMAND PARAMETERS.

    00> Advertising failed to start (err -5)

    err -5 means I/O error. 

    Do you advertise with the same data before the connection as you did before the connection? Sounds strange if it advertises with the same data successfully before the connection, but got failed after the disconnection.

    How do you activate the advertisement after the disconnection? Without stopping adv after disconnect, is it possible to advertise without issues?

    Regards,
    Amanda H.

Reply
  • Hi,

    What version of NCS are you using?

    00> [00:06:15.120,086] <wrn> bt_hci_core: bt_hci_cmd_send_sync: opcode 0x200a status 0x12

    0x200a is the opcode for enabling BLE advertising, and 0x12 is the error code for INVALID HCI COMMAND PARAMETERS.

    00> Advertising failed to start (err -5)

    err -5 means I/O error. 

    Do you advertise with the same data before the connection as you did before the connection? Sounds strange if it advertises with the same data successfully before the connection, but got failed after the disconnection.

    How do you activate the advertisement after the disconnection? Without stopping adv after disconnect, is it possible to advertise without issues?

    Regards,
    Amanda H.

Children
Related