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, 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??

Reply Children
No Data
Related