Hi,
I'm evaluating the Raytac MDBT50Q devkit, using nRF52840-DK to program it. I'm testing the system with SDK project nRF5_SDK_15.3.0_59ac345\examples\ble_central\ble_app_uart_c
Scanning and connecting to advertising devices is working, but when I tested modifying the application so, that the UUID-address in sd_ble_gap_connect() parameter differs from the one scanned, the system seems to be hanging.
The code for making a connection is following:
static void on_adv_report(ble_gap_evt_adv_report_t const * p_adv_report)
{
****
// If the address is correct, stop scanning and initiate a connection with the peripheral device.
nrf_ble_scan_stop();
static ble_gap_addr_t addr; // Have a local address structure that can be modified
// Copy the contents from the SCAN info
addr.addr_id_peer = p_adv_report->peer_addr.addr_id_peer;
addr.addr_type = p_adv_report->peer_addr.addr_type;
for (i=0;i<BLE_GAP_ADDR_LEN;++i)
{
addr.addr[i] = p_adv_report->peer_addr.addr[i];
}
addr.addr[0] = 0x07; // Modify the address, which originally is 0F0AC761FED6
err_code = sd_ble_gap_connect(&addr, //&p_adv_report->peer_addr,
&m_scan.scan_params,
&m_scan.conn_params,
APP_BLE_CONN_CFG_TAG);
APP_ERROR_CHECK(err_code);
if (NRF_SUCCESS == err_code) printf("Connecting\r\n");
}
The sd_ble_gap_connect() call returns success, since "Connecting" is printed out. Timers are working but no connection/scan related events occurs afterwards.
Reason for making this kind of test is the fact that the module is connected to the host via UART and it can't be guaranteed that an address used for connection is always correct.
Questions:
* can the sd_ble_gap_connect() call be made at any point in the code, or must is always be made from inside the on_adv_report() event handler?
* what is the status of the connection manager in this situation? How can we detect the flaw and fix it - maybe the nrf_ble_scan_start() must be called?
* must the address given to sd_ble_gap_connect() always be just scanned?
Best regards, Jukka Lamminmäki