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.

  • 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 for the reply!! Thank you for the information about "BLE_GAP_ADV_TYPE_ADV_SCAN_IND" I will give that a try and if it works will accept this!!

    As for the iBeacon stuff, the ble_app_beacon example already has the iBeacon information in the main ad packet I am just a noob and am not sure what to put there or if it's even needed... So any help there would be awesome!

  • ta2, by changing BLE_GAP_ADV_TYPE_ADV_NONCONN_IND to BLE_GAP_ADV_TYPE_ADV_SCAN_IND I can now see my custom data... But it no longer advertises as an iBeacon. When i change it back to "BLE_GAP_ADV_TYPE_ADV_NONCONN_IND" it shows as an iBeacon. Any reason for that??

  • Off the top of my head I would guess one of the following:

    1. The iBeacon spec specifically states that ADV_NONCONN_IND must be used. I think is more of a guideline that an rule, I've seen a number of tools that accept ADV_SCAN_IND. You might want to try BLE_GAP_ADV_TYPE_ADV_IND (Scannable and Connectable) to see if that makes a difference.

    You might be running an iBeacon "finder" that is being explicit with regards to Apple's spec.

    I'm using BLE_GAP_ADV_TYPE_ADV_IND because I have a GATT based configuration service on my iBeacon like device. (It's not an iBeacon we just borrowed the protocol because it was convenient.) I'm having no trouble with iBeacon "finders" seeing my device.

    1. What tool are you using to detect your iBeacon and on what platform? Some of the tools I have seen require you to enter the proximity UUID for your device before it will recognize it. I don't think this is your case since you say it can be found when you are using ADV_NONCONN_IND.

    2. I picked up on the fact that you might be using an iBeacon because the 0x004C is the reserved company ID for Apple. Maybe some thing is getting confused because you have two Manufacturer Specific Data elements with the same company ID. Try setting the company ID to 0xFFFF in the Scan Response Manufacturer Data block or get rid of the block if you are duplicating the one main advertising packet.

  • 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.

Related