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

Advertising Sensor data using Service Data

Dear All ,

I am finally able to get my beacon app to compile and work on the nrf51822 using keil with s130 softdevice.

I tried to add service data to the advertising beacon, but the beacon seems to hang...I know this only because the LED stops flashing and i am not getting any advertisements.

this is my code :-

static void advertising_init(void)
{
uint32_t err_code;
ble_advdata_t advdata;
uint8_t flags = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED;

ble_advdata_manuf_data_t manuf_specific_data;
ble_advdata_service_data_t service_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;

service_data.service_uuid=BLE_UUID_HUMAN_INTERFACE_DEVICE_SERVICE;
service_data.data.p_data[0]=0xBA;
service_data.data.size=1;

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

advdata.name_type = BLE_ADVDATA_NO_NAME;
advdata.flags = flags;
advdata.p_manuf_specific_data = &manuf_specific_data;



advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
advdata.uuids_complete.p_uuids = m_adv_uuids;
advdata.p_service_data_array = &service_data;
advdata.service_data_count = 1;

err_code = ble_advdata_set(&advdata, NULL);
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;
}

Any Ideas what i am doing wrong?

thanks

Related