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

Changing Advertisement data while advertising not working

I am working on SDKv14 with S132 softdevice and was trying to modify the Heart Rate Example to vary the Manufacturer Specific Data after each advertisement. After searching quite a bit, I found out that it can be done with the help of the radio_notification_event_handler functionality present in the SDK - https://devzone.nordicsemi.com/f/nordic-q-a/17041/changing-advertisement-data-in-every-packet

Here is my code:- (Setting the configuration of the Radio Notification)

uint32_t radio_notification_init(uint32_t irq_priority, uint8_t notification_type, uint8_t notification_distance)
{
uint32_t err_code;

err_code = sd_nvic_ClearPendingIRQ(SWI1_IRQn);
if (err_code != NRF_SUCCESS)
{
return err_code;
}

err_code = sd_nvic_SetPriority(SWI1_IRQn, irq_priority);
if (err_code != NRF_SUCCESS)
{
return err_code;
}

err_code = sd_nvic_EnableIRQ(SWI1_IRQn);
if (err_code != NRF_SUCCESS)
{
return err_code;
}

// Configure the event
return sd_radio_notification_cfg_set(notification_type, notification_distance);
}

with the Software Interrupt Handler something like this:-

void SWI1_IRQHandler(bool radio_evt)
{
uint32_t err_code;
ble_advertising_init_t init2;

if (radio_evt)
{
memset(&init2, 0, sizeof(init2));
ble_advdata_manuf_data_t manuf_data;
uint8_t* data;

/... Random data assigned to data array..../
manuf_data.company_identifier = 0xFFFF; // Unregistered company
manuf_data.data.p_data = data;
manuf_data.data.size = sizeof(data);
i++;

init2.advdata.name_type = BLE_ADVDATA_SHORT_NAME;
init2.advdata.short_name_len = 6;
init2.advdata.include_appearance = false;
init2.advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
init2.advdata.p_manuf_specific_data = &manuf_data;

err_code = ble_advdata_set(&(init2.advdata), NULL);
APP_ERROR_CHECK(err_code);

}
}

By doing this, the advertising has stopped completely. To confirm, if the radio notification module is working or not, I toggled LED lights after we enter the if statement above, exactly similar to this - https://devzone.nordicsemi.com/tutorials/b/software-development-kit/posts/radio-notification

Can anyone tell me what is it which I am doing wrong here? I am not seeing any advertising if I build and run this.

Parents Reply Children
No Data
Related