This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Multiple Advertising Sets in NCS

I am attempting to advertise two sets, one using coded PHY and one using 1M, currently using the master NCS branch (post v1.7.0-rc2 tag). This is on a custom board with an nRF52840.

When attempting to start advertising a 2nd advertising set via a 2nd call to bt_le_ext_adv_start with different args, I'm getting an assert from MPSL from inside its timer0 ISR (unhelpful log: <err> mpsl_init: MPSL ASSERT: 112, 2164 ).

Relevant code:

#define ADV_OPTIONS_COMMON  BT_LE_ADV_OPT_CONNECTABLE \
                          | BT_LE_ADV_OPT_USE_NAME \
                          | BT_LE_ADV_OPT_EXT_ADV \
                          | BT_LE_ADV_OPT_USE_TX_POWER

int ble_adv_init(void) {
    int err;

    struct bt_le_ext_adv *adv_set_coded_PHY = NULL;
    struct bt_le_ext_adv *adv_set_1M_PHY = NULL;

    struct bt_le_adv_param adv_param_coded = {
        .id = BT_ID_DEFAULT,
        .sid = 0,
        .secondary_max_skip = 0,
        .options = ADV_OPTIONS_COMMON | BT_LE_ADV_OPT_CODED,    // Advertise on long-range coded PHY
        .interval_min = 0x20,   // 20 ms (32 * 0.625)
        .interval_max = 0x152,  // 152.5 ms
        .peer = NULL
    };

    struct bt_le_adv_param adv_param_1M = {
        .id = BT_ID_DEFAULT,
        .sid = 1,
        .secondary_max_skip = 0,
        .options = ADV_OPTIONS_COMMON | BT_LE_ADV_OPT_NO_2M,    // Advertise only on legacy 1M PHY
        .interval_min = 0x20,   // 20 ms (32 * 0.625)
        .interval_max = 0x152,  // 152.5 ms
        .peer = NULL
    };

    struct bt_le_ext_adv_cb adv_cb = {.sent = adv_sent};

    err = bt_le_ext_adv_create(&adv_param_coded, &adv_cb, &adv_set_coded_PHY);
    if (err) {
        // TODO
        return err;
    }

    err = bt_le_ext_adv_create(&adv_param_1M, &adv_cb, &adv_set_1M_PHY);
    if (err) {
        // TODO
        return err;
    }

    err = bt_le_ext_adv_set_data(adv_set_coded_PHY, ad, ARRAY_SIZE(ad), sd, ARRAY_SIZE(sd));
    if (err) {
        // TODO
        return err;
    }

    err = bt_le_ext_adv_set_data(adv_set_1M_PHY, ad, ARRAY_SIZE(ad), sd, ARRAY_SIZE(sd));
    if (err) {
        // TODO
        return err;
    }

    struct bt_le_ext_adv_start_param adv_start_param = {
        .timeout = 30000,   // 5 minutes in 10 ms units
        .num_events = 0
    };

    err = bt_le_ext_adv_start(adv_set_coded_PHY, &adv_start_param);
    if (err) {
        // TODO
        return err;
    }

    err = bt_le_ext_adv_start(adv_set_1M_PHY, &adv_start_param);    // Never returns, logs: <err> mpsl_init: MPSL ASSERT: 112, 2164
    if (err) {
        // TODO
        return err;
    }

    return 0;
}

Relevant prj.conf settings:

## General BLE Properties
CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_CTLR_PHY_CODED=y
CONFIG_BT_USER_PHY_UPDATE=y
CONFIG_BT_SMP=y
CONFIG_BT_PRIVACY=y
CONFIG_BT_MAX_CONN=2
CONFIG_BT_MAX_PAIRED=3
CONFIG_BT_SIGNING=y

## BLE Advertising options
CONFIG_BT_EXT_ADV=y
CONFIG_BT_EXT_ADV_MAX_ADV_SET=2

Am I missing something?

Parents Reply Children
No Data
Related