This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

"Failed enabling advertiser" when running mesh provisioner on nRF5340

I've tried to run a program which allows to run mesh provisioner, among with Direction Finding connectionless locator. 

I was using mesh provisioner example from Zephyr, and previously tested it on nRF52840 - it seemed to be working fine. However when I'm trying to run it on nRF5340, I have an error "Failed enabling advertiser"  when running bt_ready_provisioner.

Code for that function is mostly the same as from example (from separate .c file):

int bt_ready_prov(const struct bt_mesh_prov *prov,
		  const struct bt_mesh_comp *comp)
{
	uint8_t net_key[16], dev_key[16];
	int err;

	err = bt_mesh_init(prov, comp);
        
	if (err) {
		printk("Initializing mesh failed (err %d)\n", err);
		return err;
	}

        err = bt_set_name("nRF 52840");

        if (err) {
		printk("Setting new name failed (err %d)\n", err);
		return err;
	}

	printk("Mesh initialized\n");

	if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
		printk("Loading stored settings\n");
		err = settings_load();
                if (err) {
                      printk("failed err %d\n", err);
                } else {
                      printk("Loaded successfully\n");
                }
	}

	bt_rand(net_key, 16);

	err = bt_mesh_cdb_create(net_key);
	if (err == -EALREADY) {
		printk("Using stored CDB\n");
	} else if (err) {
		printk("Failed to create CDB (err %d)\n", err);
		return err;
	} else {
		printk("Created CDB\n");
		setup_cdb();
	}

	bt_rand(dev_key, 16);

	err = bt_mesh_provision(net_key, BT_MESH_NET_PRIMARY, 0, 0, self_addr,
				dev_key);
	if (err == -EALREADY) {
		printk("Using stored settings\n");
	} else if (err) {
		printk("Provisioning failed (err %d)\n", err);
		return err;
	} else {
		printk("Provisioning completed\n");
	}

	return 0;
}

Main function:

void main(void)
{
	static struct k_work button_work;
	int err = -1;
	printk("Initializing...\n");
        LOG_INF(CONFIG_BOARD);

	if (IS_ENABLED(CONFIG_HWINFO)) {
		err = hwinfo_get_device_id(dev_uuid, sizeof(dev_uuid));
	}
	if (err < 0) {
		dev_uuid[0] = 0xdd;
		dev_uuid[1] = 0xdd;
	}

	err = board_init(&button_work);
	if (err) {
		printk("Board init failed (err: %d)\n", err);
		return;
	}

        printk("Version: 2.3.3.15\n");
        os_mgmt_register_group();
        img_mgmt_register_group();
        smp_bt_register();
        
        /* Initialize the Bluetooth Subsystem and mesh stack as provisioner */
        err = bt_enable(NULL);
        if (err) {
    		printk("Bluetooth init or mesh failed (err %d)\n", err);
    	}
        err = bt_ready_prov(&provisioner, &comp);
        if (err) {
                LOG_ERR("BT Mesh provisioner failed: %d\n", err);
        }

        threads_init();

        LOG_INF("Launched successfully");
}

threads_init():

static void threads_init(void) {
        
        printk("Initialising uuid_print_thread...\n");
        uuid_thread_tid = k_thread_create(&uuid_thread, uuid_stack, K_THREAD_STACK_SIZEOF(uuid_stack), (k_thread_entry_t) uuid_print_thread, 
                                          NULL, NULL, NULL, UUID_THREAD_PRIORITY, 0, K_NO_WAIT);
        
#if defined(CONFIG_BOARD_NRF5340DK_NRF5340_CPUAPP) && defined(CONFIG_BT_DF)
        scan_init();
        printk("Initialising reading direction thread...\n");
        direction_finding_tid = k_thread_create(&direction_thread, direction_finding_stack, K_THREAD_STACK_SIZEOF(direction_finding_stack), 
                                                (k_thread_entry_t) reading_direction, 
                                                NULL, NULL, NULL, DF_RX_PRIORITY, 0, K_NO_WAIT); //regular thread
        k_thread_name_set(prov_wfb_thread, "DF launched");
#endif // defined(CONFIG_BOARD_NRF5340DK_NRF5340_CPUAPP) && defined(CONFIG_BT_DF)
        
        printk("Initialising wfb_thread...\n");
        prov_wfb_thread = k_thread_create(&prov_thread, prov_stack, K_THREAD_STACK_SIZEOF(prov_stack), wait_for_beacon_thread, 
                                          NULL, NULL, NULL, PROV_PRIORITY, 0, K_NO_WAIT); //regular thread
        k_thread_name_set(prov_wfb_thread, "Prov Beacon");
}

Output when running looks like this:

*** Booting Zephyr OS build v2.7.99-ncs1  ***
Initializing...
[00:00:00.016,784] <inf> mesh_main: nrf5340dk_nrf5340_cpuapp
Version: 2.3.3.15
[00:00:00.022,064] <inf> fs_nvs: 2 Sectors of 4096 bytes
[00:00:00.022,094] <inf> fs_nvs: alloc wra: 0, ec0
[00:00:00.022,094] <inf> fs_nvs: data wra: 0, 200
[00:00:00.058,166] <inf> bt_hci_core: HCI: version 5.2 (0x0b) revision 0x2190, manufacturer 0x0059
--- 8 messages dropped ---
[00:00:00.058,197] <inf> bt_hci_core: LMP: version 5.2 (0x0b) subver 0x2190
[00:00:00.060,546] <wrn> bt_hci_core: opcode 0x2036 status 0x01
[00:00:00.060,577] <err> bt_mesh_main: Failed enabling advertiser
Loaded successfully
Using stored CDB
[00:00:00.063,568] <inf> bt_mesh_main: Primary Element: 0x0001
[00:00:00.063,568] <dbg> bt_mesh_main.bt_mesh_provision: net_idx 0x0000 flags 0x00 iv_index 0x0000
Using stored settings
Initialising uuid_print_thread...
Starting Connectionless Locator
success.
Initialising reading direction thread...
Initialising wfb_thread...
[00:00:00.063,812] <inf> mesh_main: Launched successfully
[00:00:00.064,666] <inf> mesh_main: UUID Print thread entered
[00:00:00.064,697] <inf> mesh_main: UUID: be95250522343f3f0000000000000000
[00:00:00.064,758] <inf> direction_rx: Start scanning...
[00:00:00.066,314] <inf> provisioner: Waiting for unprovisioned beacon...
[00:00:00.067,810] <wrn> bt_hci_core: opcode 0x2041 status 0x01
[00:00:00.067,810] <inf> direction_rx: failed (err -5)

[00:00:00.067,840] <inf> direction_rx: Waiting for periodic advertising...

I don't know what's wrong with it, considering it worked well on nRF52840. Is there anything I'm missing?

Parents
  • Hi

    Sorry about the late reply, but I was out of office on Friday, and had some catching up to do.

    No, extended advertising is not part of the Mesh stack. This is by specification. See this case by my colleague Terje for more details.

    I can't find any mention of a config called CONFIG_BT_MESH_EXT_ADV.  I think you need to enable/disable extended advertising (with CONFIG_BT_EXT_ADV) whenever you switch between Mesh and Direction Finding.

    Best regards,

    Simon

Reply
  • Hi

    Sorry about the late reply, but I was out of office on Friday, and had some catching up to do.

    No, extended advertising is not part of the Mesh stack. This is by specification. See this case by my colleague Terje for more details.

    I can't find any mention of a config called CONFIG_BT_MESH_EXT_ADV.  I think you need to enable/disable extended advertising (with CONFIG_BT_EXT_ADV) whenever you switch between Mesh and Direction Finding.

    Best regards,

    Simon

Children
No Data
Related