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

Can I put measured data in the Scan Response packet?

I'm looking at an application where it would be beneficial to be able to read data from the bluetooth device as it passes. It would be easiest for me to do this by simply reading the scan response data if it was possible to put the measured data in there somehow.

Is this possible? It seems in the examples the scan response packet is set when he advertising is initialised, so can I change it afterwards?

My existing advertising initialisation is this:

static void advertising_init(void)
{
    uint32_t      err_code;
    ble_advdata_t advdata;

    // Build advertising data struct to pass into ble_advertising_init().
    memset(&advdata, 0, sizeof(advdata));

    advdata.name_type               = BLE_ADVDATA_FULL_NAME;
    advdata.flags                   = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;

    ble_adv_modes_config_t options = {0};
    options.ble_adv_fast_enabled  = BLE_ADV_FAST_ENABLED;
    options.ble_adv_fast_interval = APP_ADV_INTERVAL;
    options.ble_adv_fast_timeout  = APP_ADV_TIMEOUT_IN_SECONDS;
    
    // Create a scan response packet and include the list of UUIDs 
	ble_uuid_t m_adv_uuids[] = {BLE_UUID_OUR_SERVICE, BLE_UUID_TYPE_VENDOR_BEGIN};
	
	ble_advdata_t sr_data;
	memset(&sr_data, 0, sizeof(sr_data));
	
	sr_data.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
	sr_data.uuids_complete.p_uuids = m_adv_uuids;

	err_code = ble_advertising_init(&advdata, &sr_data, &options, on_adv_evt, NULL);
    APP_ERROR_CHECK(err_code);
}
Related