Handling of mixed Advertising and Extended Advertising

Hallo,

currently I test several options in regarding the use of advertising. I have a few nRF52840-DK and use Zephyr 2.7-99 and ncs. I have a question regarding combined use of extended advertising and "simple" advertising.

I create an advertising set with bt_le_ext_adv_create(..). Than, I set my transmit data with bt_le_ext_adv_set_data(..), start extended advertising with bt_le_ext_adv_start(..) and stop it after a few transmits with bt_le_ext_adv_stop(..). After a while I do the cycle bt_le_ext_adv_set_data(..) - bt_le_ext_adv_start(..) - bt_le_ext_adv_stop(..) again, and so on. This runs well, no problems. Now I want to use the pause between this cycles to start a simple advertising with bt_le_adv_start(..). Here I saw an error (-12 - not enough memory). I found that I have to delete the advertising set with bt_le_ext_adv_delete(..).

I wonder why I see such a behaviour. It's quite clear that I can't have two different advertising schemes running at the same time. But my extended advertising doesn't run, it is stopped. The advertising set is in my mind just a "collection" of parameters regarding the extended advertising, which is stored in the memory. Furthermore, as far as I understood the functions, I can have a number of advertising sets and pick up one of them when starting extended advertising. So the stack should be able to handle several advertising sets. But why can I not start a simple advertising, when an advertising set exists? The set isn't touched, and the simple advertising doesn't need one.

Kind regards

Axel

  • hi

    i followed all steps that u have told here.but still iam facing enomem error...

    err = bt_le_ext_adv_stop(adv);

    if (err) {
        printk("Failed to stop advertising (err %d)\n", err);
    } else {
        printk("Advertising stopped successfully\n");
    }
    bt_le_ext_adv_delete(adv);
    /*

    struct bt_le_adv_param param = {
        .id = BT_ID_DEFAULT,
        .sid = 0,
        .secondary_max_skip = 0,
        .options = BT_LE_ADV_OPT_EXT_ADV | BT_LE_ADV_OPT_CONNECTABLE,
        .interval_min = params.interval/0.625,  
        .interval_max = params.interval/0.625,
        .peer = NULL,
    };
    */
    struct bt_le_adv_param param =
            BT_LE_ADV_PARAM_INIT(BT_LE_ADV_OPT_EXT_ADV | BT_LE_ADV_OPT_CONNECTABLE,
                         3000,
                         3000,
                         NULL);

        // Update advertising data
        struct bt_data ad[] = {
            BT_DATA(BT_DATA_NAME_COMPLETE, name_buffer, DEVICE_NAME_LEN),
             BT_DATA_BYTES(BT_DATA_FLAGS, BT_LE_AD_NO_BREDR),
            BT_DATA(BT_DATA_MANUFACTURER_DATA, manufacturer_data, sizeof(manufacturer_data)),
            BT_DATA(BT_DATA_MANUFACTURER_DATA, adv_data, sizeof(adv_data)),  


        };


        // Start advertising with updated data
         err = bt_le_ext_adv_create(&param, NULL, &adv);
        if (err) {
            printk("Failed to create advertising set (err %d)\n", err);
            return err;
        }

        err = bt_le_ext_adv_set_data(adv, ad, ARRAY_SIZE(ad), NULL, 0);
        if (err) {
            printk("Failed to set advertising data (err %d)\n", err);
            return 0;
        }
       
    set_tx_power(BT_HCI_VS_LL_HANDLE_TYPE_ADV, 0, 8);
        err = bt_le_ext_adv_start(adv, &start_params);
        if (err) {
            printk("Failed to start extended advertising (err %d)\n", err);
        }
        else
        {
        printk("Advertising successfully started\n");
        }
Related