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

Adding more scan response data

Hello, I am using the example "ble_app_beacon", I have compiled and tested (all works well).

I am wanting to add more data to the scan response by passing more data to "ble_advdata_set"... Below is my "advertising_init" function:

uint32_t        err_code;
	ble_advdata_t   advdata;
	ble_advdata_t scanrsp;

	ble_advdata_manuf_data_t scanrsp_manuf_data;
	uint8_array_t            scanrsp_manuf_data_array;
	uint8_t                  scanrsp_manuf_data_data[2];

uint8_t         flags = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED;

ble_advdata_manuf_data_t manuf_specific_data;

	

manuf_specific_data.company_identifier = APP_COMPANY_IDENTIFIER;
[...]


	

manuf_specific_data.data.p_data        = (uint8_t *) m_beacon_info;
manuf_specific_data.data.size          = APP_BEACON_INFO_LENGTH;

// Build and set advertising data.
memset(&advdata, 0, sizeof(advdata));

advdata.name_type               = BLE_ADVDATA_NO_NAME;
advdata.flags.size              = sizeof(flags);
advdata.flags.p_data            = &flags;
advdata.p_manuf_specific_data   = &manuf_specific_data;
	
	// Setting custom service data
	// Build and set scan response data
	memset(&scanrsp, 0, sizeof(scanrsp));
	scanrsp_manuf_data_data[0] = 0xCC;
	scanrsp_manuf_data_data[1] = 0xDD;
	
	scanrsp_manuf_data_array.p_data = scanrsp_manuf_data_data;
	scanrsp_manuf_data_array.size = sizeof(scanrsp_manuf_data_data);
	
	scanrsp_manuf_data.company_identifier = 0x004C;
	scanrsp_manuf_data.data = scanrsp_manuf_data_array;
	
	scanrsp.p_manuf_specific_data = &scanrsp_manuf_data;
	
err_code = ble_advdata_set(&advdata, &scanrsp);
APP_ERROR_CHECK(err_code);

// Initialize advertising parameters (used when starting advertising).
memset(&m_adv_params, 0, sizeof(m_adv_params));

m_adv_params.type        = BLE_GAP_ADV_TYPE_ADV_NONCONN_IND;
m_adv_params.p_peer_addr = NULL;                             // Undirected advertisement.
m_adv_params.fp          = BLE_GAP_ADV_FP_ANY;
m_adv_params.interval    = NON_CONNECTABLE_ADV_INTERVAL;
m_adv_params.timeout     = APP_CFG_NON_CONN_ADV_TIMEOUT;

When I compile and load this to the test beacon I am not seeing my additional data... I have been looking through the devzone and that is what brought me to the above solution (https://devzone.nordicsemi.com/question/12846/adding-service_data-to-advertising-custom-service/?answer=12850#post-id-12850)

I am just not able to see the data... What am I missing? Please let me know if you need additional information.

Parents
  • There are four different advertising packet types that are used to declare what connectability you support. The advertising data is the same, they just differentiate between what you will accept.

    ADV_NONCONN_IND packets (BLE_GAP_ADV_TYPE_ADV_NONCONN_IND) declare that you do not accept connections and that you do not accept Scan Requests.

    ADV_SCAN_IND packets (BLE_GAP_ADV_TYPE_ADV_SCAN_IND) declare that you do not accept connections but that you do accept Scan Requests.

    Also, seeing the 0x004C in your scanrsp_manuf_data.company_identifier are you trying to advertise as an iBeacon? The iBeacon spec requires that data to be in the main advertising packet, not in a Scan Response.

    Cheers!

    --- ta2

  • ta2, thanks again for the quick response! Ok I am using Master Control Panel on a Samsung tablet. I am also using another 3rd party app called "Bluetooth LE Scanner" on Android

    • When using BLE_GAP_ADV_TYPE_ADV_SCAN_IND or BLE_GAP_ADV_TYPE_ADV_IND the 3rd party app does not show it as an iBeacon... But when using the Master control Panel I see the Company set to Apple along with my custom data... Using BLE_GAP_ADV_TYPE_ADV_IND I get the same result as using BLE_GAP_ADV_TYPE_ADV_SCAN_IND.. (Not showing as iBeacon in the 3rd party app) I think you have identified my problem. It looks to be the "Bluetooth LE Scanner" app that is following the iBeacon spec to the letter and showing only a beacon as an iBeacon when its 100% to the spec.

    -- Also thanks for the company id information i did change mine to "0xFFFF" and it is showing in the scan but did not effect the iBeacon outcome.

Reply
  • ta2, thanks again for the quick response! Ok I am using Master Control Panel on a Samsung tablet. I am also using another 3rd party app called "Bluetooth LE Scanner" on Android

    • When using BLE_GAP_ADV_TYPE_ADV_SCAN_IND or BLE_GAP_ADV_TYPE_ADV_IND the 3rd party app does not show it as an iBeacon... But when using the Master control Panel I see the Company set to Apple along with my custom data... Using BLE_GAP_ADV_TYPE_ADV_IND I get the same result as using BLE_GAP_ADV_TYPE_ADV_SCAN_IND.. (Not showing as iBeacon in the 3rd party app) I think you have identified my problem. It looks to be the "Bluetooth LE Scanner" app that is following the iBeacon spec to the letter and showing only a beacon as an iBeacon when its 100% to the spec.

    -- Also thanks for the company id information i did change mine to "0xFFFF" and it is showing in the scan but did not effect the iBeacon outcome.

Children
No Data
Related