Extended adverts bt_le_ext_adv_create error

Hi,

I am trying to enable extended adverts, when the call to bt_le_ext_adv_create is made, it always returns:

Using the following code:

#define BT_UUID_INTERCALL_P_VAL \
	BT_UUID_128_ENCODE(0xf3641400, 0x00b0, 0x4240, 0xba50, 0x05ca45bf8abc)

static struct bt_le_ext_adv *ext_adv;
static const struct bt_le_adv_param connectable_adv_param =
	BT_LE_ADV_PARAM_INIT(BT_LE_ADV_OPT_EXT_ADV | BT_LE_ADV_OPT_CONNECTABLE | BT_LE_ADV_OPT_USE_NAME,
			BT_GAP_ADV_FAST_INT_MIN_2, /* 100 ms */
			BT_GAP_ADV_FAST_INT_MAX_2, /* 150 ms */
			NULL);

static const struct bt_data ext_ad[] = {
	BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
	BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_INTERCALL_P_VAL),
};

static int connectable_adv_create(void)
{
	int err;

	err = bt_set_name(DEVICE_NAME);
	if (err) {
		printk("Failed to set device name (err %d)\n", err);
		return err;
	}

	err = bt_le_ext_adv_create(&connectable_adv_param, &adv_cb, &ext_adv);
	if (err) {
		printk("Failed to create adv (err %d)\n", err);
		return err;
	}

	printk("Created adv: %p\n", ext_adv);

	err = bt_le_ext_adv_set_data(ext_adv, ext_ad, ARRAY_SIZE(ext_ad), NULL, 0);
	if (err) {
		printk("Failed to set advertising data (err %d)\n", err);
		return err;
	}

	return bt_le_ext_adv_start(ext_adv, BT_LE_EXT_ADV_START_DEFAULT);
}

My custom service has the following init:

/* Intercall Peripheral Service Declaration */
BT_GATT_SERVICE_DEFINE(intercall_p_svc,
BT_GATT_PRIMARY_SERVICE(BT_UUID_INTERCALL_P),

	BT_GATT_CHARACTERISTIC(BT_UUID_INTERCALL_P_CALLPOINT,
			       BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE,
			       BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
			       read_callpoint, write_callpoint, &callpoint_data),
	BT_GATT_CCC(intercall_p_callpoint_ccc_cfg_changed,
		    BT_GATT_PERM_READ | BT_GATT_PERM_WRITE),
	
	BT_GATT_CHARACTERISTIC(BT_UUID_INTERCALL_P_NETWORK,
			       BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE,
			       BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
			       read_network, write_network, &network_data),
	BT_GATT_CCC(intercall_p_network_ccc_cfg_changed,
		    BT_GATT_PERM_READ | BT_GATT_PERM_WRITE),
	
	BT_GATT_CHARACTERISTIC(BT_UUID_INTERCALL_P_TEXTUAL,
			       BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE,
			       BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
			       read_textual, write_textual, &textual_data),
);

My prj.conf

CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_NAME="Intercall"
CONFIG_BT_DEVICE_APPEARANCE=512
CONFIG_BT_DEVICE_NAME_DYNAMIC=y
CONFIG_BT_EXT_ADV=y


# CONFIG_BT_DIS=y
# CONFIG_BT_DIS_PNP=y
# CONFIG_BT_DIS_MANUF="Lismore Instruments Ltd"
# CONFIG_BT_DIS_PNP_VID_SRC=1
# CONFIG_BT_DIS_PNP_VID=0x095B
# CONFIG_BT_DIS_PNP_PID=0x0103
# CONFIG_BT_DIS_PNP_VER=0x0100

# Enable the LBS service
CONFIG_BT_LBS=n

CONFIG_DK_LIBRARY=y

CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048

# Config logger
CONFIG_LOG=y
CONFIG_USE_SEGGER_RTT=y
CONFIG_LOG_BACKEND_RTT=y
CONFIG_LOG_BACKEND_UART=n
CONFIG_LOG_PRINTK=y

CONFIG_ASSERT=y
CONFIG_ASSERT_NO_COND_INFO=y
CONFIG_ASSERT_NO_MSG_INFO=y
CONFIG_HW_STACK_PROTECTION=y

CONFIG_BT_LBS_SECURITY_ENABLED=n

If using normal adverts, everything works fine.

Apart from using 128bit UUID, i cant see a difference between this code and examples found in the direction finder or hr samples

Are you able to shed some light on what i need to do?

Thanks

  • I hava some additional debug data



    [00:00:33.437,377] <dbg> bt_hci_core.bt_hci_cmd_create: opcode 0x2036 param_len 25
    [00:00:33.460,571] <dbg> bt_hci_core.bt_hci_cmd_create: buf 0x200060cc
    [00:00:33.482,788] <dbg> bt_id.bt_id_set_adv_random_addr: F3:27:69:6D:48:9E
    [00:00:35.749,877] <dbg> bt_hci_core.bt_hci_cmd_send_sync: buf 0x200060cc opcode 0x2036 len 28
    [00:00:35.774,169] <dbg> bt_hci_core.process_events: count 2
    [00:00:35.795,379] <dbg> bt_hci_core.process_events: ev->state 4
    [00:00:35.816,955] <dbg> bt_hci_core.send_cmd: calling net_buf_get
    [00:00:35.838,653] <dbg> bt_hci_core.send_cmd: calling sem_take_wait
    [00:00:35.860,565] <dbg> bt_hci_core.send_cmd: Sending command 0x2036 (buf 0x200060cc) to driver
    [00:00:35.884,979] <dbg> bt_hci_core.bt_send: buf 0x200060cc len 28 type 0
    [00:00:35.907,440] <dbg> bt_hci_driver.bt_rpmsg_send: buf 0x200060cc type 0 len 28
    [00:00:35.930,633] <dbg> bt_hci_driver.Final HCI buffer:
                                           01 36 20 19 00 01 00 a0  00 00 f0 00 00 07 01 00 |.6 ..... ........
                                           00 00 00 00 00 00 00 7f  01 00 02 00 00          |........ .....
    [00:00:35.971,221] <dbg> bt_hci_core.process_events: ev->state 0
    [00:00:35.992,797] <dbg> bt_hci_driver_nrf53.endpoint_cb: Received message of 7 bytes.
    [00:00:36.016,296] <dbg> bt_hci_driver_nrf53.Data:
                                                 04 0f 04 01 01 36 20                             |.....6
    [00:00:36.046,875] <dbg> bt_hci_driver.RPMsg data:
                                           04 0f 04 01 01 36 20                             |.....6
    [00:00:36.076,934] <dbg> bt_hci_driver.bt_rpmsg_evt_recv: len 4
    [00:00:36.098,388] <dbg> bt_hci_driver.bt_rpmsg_rx: Calling bt_recv(0x200060cc)
    [00:00:36.121,276] <dbg> bt_hci_core.bt_recv: buf 0x200060cc len 6
    [00:00:36.143,035] <dbg> bt_hci_core.hci_cmd_status: opcode 0x2036
    [00:00:36.164,764] <dbg> bt_hci_core.hci_cmd_done: opcode 0x2036 status 0x01 buf 0x200060cc
    [00:00:36.188,781] <dbg> bt_hci_driver.RX buf payload:
    [00:00:36.209,472] <dbg> bt_conn.bt_conn_prepare_events:
    [00:00:36.230,407] <dbg> bt_hci_core.hci_tx_thread: Calling k_poll with 2 events
    [00:00:36.253,417] <wrn> bt_hci_core: opcode 0x2036 status 0x01
    Failed to create adv (err -5)
    Ext advertising failed to start (err -5)
  • Hi Billy

    Have you set the configs in a child_image folder as well? You can refer to the peripheral_hr_coded sample project to see how it is done there.

    Best regards,

    Simon

  • Hi Simon,

    Yes, sorry i should have included this.

    My project is derived from the peripheral_lbs sample, so when i look in the explorer i have a

    child_image\hci_rpmsg\boards\thingy53_nrf5340_cpunet.conf

    file, i have copied the three lines from the periperhal_hr_coded file

    peripheral_hr_coded\child_image\hci_rpmsg.conf

    so now my child_image conf file looks like this:

    CONFIG_RPMSG_SERVICE=y
    CONFIG_RPMSG_SERVICE_MODE_REMOTE=y

    CONFIG_HEAP_MEM_POOL_SIZE=8192

    CONFIG_MAIN_STACK_SIZE=512
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512
    CONFIG_BT=y
    CONFIG_BT_HCI_RAW=y
    CONFIG_BT_MAX_CONN=10
    CONFIG_BT_CTLR_ASSERT_HANDLER=y
    CONFIG_BT_HCI_RAW_RESERVE=1
    CONFIG_BT_BUF_CMD_TX_COUNT=10

    # Increase maximum data length of PDU supported in the Controller
    CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
    CONFIG_BT_BUF_ACL_TX_SIZE=251
    CONFIG_BT_BUF_ACL_RX_SIZE=502

    CONFIG_BT_EXT_ADV=y
    CONFIG_BT_CTLR_ADV_EXT=y
    # CONFIG_BT_CTLR_PHY_CODED=y

    But it did not help

    Im assuming this is the correct file?

  • Hi

    So if you remove the CONFIG_BT_CTLR_ADV_EXT and CONFIG_BT_EXT_ADV from the child image config file, the application works as intended (this should be the correct file)? It seems like you're building for the Thingy:53, is that correct? Have you followed the Thingy:53 application guide?

    Best regards,

    Simon

  • Hi

    Adding or removing the two entries seems to make no difference.

    I am not building for the Thingy:53, All i did was use the 'New application from sample' option, and when adding the build selected the nRF5340dk_nRF5340_cpuapp option - and this is what was created

    I did not select the Thingy:53 - this was given to me automatically by nRFConnect - i assumed it uses the same option

Related