Hi!
Recently I have been working with Nordic products, starting with NRF52DK. I want to pair/bond cycling equipment (BLE and ANT+) with NRF52DK. After no success with ANT+ SDK examples I decided to deep into BLE first (ble_app_hrs_c_pca10040_s332). I have some problems during that:
1. I can't sustain connection with hear rate belt. Everytime I try to connect with it I get following result:
<info> app: Device: Heart rate belt <info> app: name: 2809_83C5AB <info> app: Connected. <info> app: GATT ATT MTU on connection 0x0 changed to 23. <info> app: Data length for connection 0x0 updated to 27. <info> peer_manager_handler: Connection security failed: role: Central, conn_han dle: 0x0, procedure: Pairing, error: 133 <info> app: BLE_GAP_EVT_AUTH_STATUS: status=0x85 bond=0x0 lv4: 0 kdist_own:0x0 k dist_peer:0x0 <info> app: Disconnected, reason 0x13. <info> app: Starting scan.
As far I know this error relates to BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP, but I have no idea how to solve it. I have tried few options for Peer Manager but with no success. I changed #define TARGET_UUID that describes cadence and speed sensor and I did manage to connect without any problems.
2. I am reading event NRF_BLE_SCAN_EVT_FILTER_MATCH from scan module, and I perform additional check if this is really a HeartRateService. In future I want to make a list of device types in range so I need to read what UUID has coused scan event trigger. As you can see below I am reading 16bit UUID from advertising data, next check if this is HeartRateService and also read device name. Can it be done somehow faster? Since scan event has been triggered and I am filtering by UUID, UUID that has triggered the event has to be stored somewhere. Is there an option to read what UUID/DeviceName etc. coused event NRF_BLE_SCAN_EVT_FILTER_MATCH in scan module? By that I wouldn't need to scan advertising buffer for specific data.
/*Check for UUID*/ length = ble_advdata_search(p_adv_report->data.p_data, p_adv_report->data.len, &offset, BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_MORE_AVAILABLE); if (length == 0) { length = ble_advdata_search(p_adv_report->data.p_data, p_adv_report->data.len, &offset, BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_COMPLETE); } if (length != 0) { memcpy(device, &p_adv_report->data.p_data[offset], 2); /*If this is Hear Rate Service*/ if(device[0] == 0x0D && device[1] == 0x18) { NRF_LOG_INFO("Device: Heart rate belt"); /*Print device name*/ offset = 0; length = ble_advdata_search(p_adv_report->data.p_data, p_adv_report->data.len, &offset, BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME); if (length == 0) { // Look for the short local name if it was not found as complete. length = ble_advdata_search(p_adv_report->data.p_data, p_adv_report->data.len, &offset, BLE_GAP_AD_TYPE_SHORT_LOCAL_NAME); } if (length != 0) { memcpy(name, &p_adv_report->data.p_data[offset], length); NRF_LOG_INFO("name: %s", nrf_log_push(name)); } /*Perform connection*/ sd_ble_gap_connect(p_addr, p_scan_params, p_conn_params, con_cfg_tag); } }
3. If I need to scan for BLE and ANT devices that are nerby can it be done in one operation or I need to first scan for BLE and then for ANT.