This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

nrf51822 ble_app_beacon combine with ble_ app_hrs

Hi everyone :

I'm trying to used ble_app_beacon and I want to combine it into ble_ app_hrs so i add some code as followed:

static void advertising_init(void){
uint32_t      err_code;
ble_advdata_t advdata;
ble_advdata_t scanrsp;
uint8_t       flags        = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
ble_advdata_manuf_data_t manuf_specific_data;
manuf_specific_data.company_identifier = APP_COMPANY_IDENTIFIER;
#if defined(USE_UICR_FOR_MAJ_MIN_VALUES)
uint16_t major_value = ((*(uint32_t *)UICR_ADDRESS) & 0xFFFF0000) >> 16;
uint16_t minor_value = ((*(uint32_t *)UICR_ADDRESS) & 0x0000FFFF);

uint8_t index = MAJ_VAL_OFFSET_IN_BEACON_INFO;

m_beacon_info[index++] = MSB(major_value);
m_beacon_info[index++] = LSB(major_value);

m_beacon_info[index++] = MSB(minor_value);
m_beacon_info[index++] = LSB(minor_value);
#endif
manuf_specific_data.data.p_data = (uint8_t *) m_beacon_info;
manuf_specific_data.data.size   = APP_BEACON_INFO_LENGTH;


ble_uuid_t adv_uuids[] =
{
    {BLE_UUID_HEART_RATE_SERVICE,         BLE_UUID_TYPE_BLE},
    {BLE_UUID_BATTERY_SERVICE,            BLE_UUID_TYPE_BLE},
    {BLE_UUID_DEVICE_INFORMATION_SERVICE, BLE_UUID_TYPE_BLE},
			{LBS_UUID_SERVICE,                    BLE_UUID_TYPE_BLE}
			
};

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

advdata.name_type               = BLE_ADVDATA_FULL_NAME;
advdata.include_appearance      = true;
advdata.flags.size              = sizeof(flags);
advdata.flags.p_data            = &flags;
advdata.p_manuf_specific_data =&manuf_specific_data;
	
	memset(&scanrsp, 0, sizeof(scanrsp));
scanrsp.uuids_complete.uuid_cnt = sizeof(adv_uuids) / sizeof(adv_uuids[0]);
scanrsp.uuids_complete.p_uuids  = adv_uuids;

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_IND;
m_adv_params.p_peer_addr = NULL;                           // Undirected advertisement.
m_adv_params.fp          = BLE_GAP_ADV_FP_ANY;
m_adv_params.interval    = APP_ADV_INTERVAL;
m_adv_params.timeout     = APP_ADV_TIMEOUT_IN_SECONDS;
}

when I running this code it will crash, is it possible combine ble_app_beacon and ble_ app_hrs together?

thanks

Parents
  • What do you mean by crash? Have you checked if ble_advdata_set() returns an error? You can check it by going into debug mode and then set a breakpoint at APP_ERROR_CHECK(). Remember to set the optimization to Level 0 in Options for Target->C/C++

Reply
  • What do you mean by crash? Have you checked if ble_advdata_set() returns an error? You can check it by going into debug mode and then set a breakpoint at APP_ERROR_CHECK(). Remember to set the optimization to Level 0 in Options for Target->C/C++

Children
No Data
Related