Zephyr BLE example advertise not working.

Hi,

I am working on creating an example for BLE application where I try to start the advertising of BLE device. I have seen other example in the folder bluetooth/peripharal which works fine and device can advertise itself. The following is the code spinet off the application I flashing separately on both the cores of the device.

The code also have defined callbacks for connection and disconnection. Still the device failed to advertise itself.

static void bt_ready(void){

    int err;

	printk("Bluetooth initialized\n");

    char addr_s[BT_ADDR_LE_STR_LEN];
    
    settings_load();
    
    err = bt_le_adv_start(BT_LE_ADV_CONN_NAME, ad, ARRAY_SIZE(ad), sd, ARRAY_SIZE(sd));

    if(err) {
    printk("Advertise did not start..");
    }


}

void main(void)

{
    int ret;

    if(!gpio_is_ready_dt(&bpled)){
        return;
    }
    ret = gpio_pin_configure_dt(&bpled, GPIO_OUTPUT_ACTIVE);

    if(ret<0){
        return;
    }

    if(!gpio_is_ready_dt(&button)){
        return;
    }

    ret = gpio_pin_configure_dt(&button, GPIO_INPUT);

    ret = gpio_pin_interrupt_configure_dt(&button, GPIO_INT_EDGE_TO_ACTIVE);

    gpio_init_callback(&button_callback_data, btn_pressed, BIT(button.pin));
	gpio_add_callback(button.port, &button_callback_data);

    ret = bt_enable(NULL);

    if(ret){
    printk("Bluetooth failed to init");
    }

    if(ret) {
    printk("Bluetooth failed to intialise");
    return;
    }

    bt_ready(); 

}

The following is the code of .conf config settings which also I have copied from the example which works.

CONFIG_GPIO=y


CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048

CONFIG_BT=y
CONFIG_BT_DEBUG_LOG=y
CONFIG_BT_SMP=y
CONFIG_BT_SIGNING=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DIS=y
CONFIG_BT_ATT_PREPARE_COUNT=5
CONFIG_BT_BAS=y
CONFIG_BT_HRS=y
CONFIG_BT_IAS=y
CONFIG_BT_PRIVACY=y
CONFIG_BT_DEVICE_NAME="Zephyr Peripheral Sample Long Name"
CONFIG_BT_DEVICE_APPEARANCE=833
CONFIG_BT_DEVICE_NAME_DYNAMIC=y
CONFIG_BT_DEVICE_NAME_MAX=65

CONFIG_BT_KEYS_OVERWRITE_OLDEST=y
CONFIG_BT_SETTINGS=y
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y
CONFIG_NVS=y
CONFIG_SETTINGS=y

Related