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

Can't connect to peripheral

I'm trying to connect a 52832 board to a peripheral BLE device.

NRF52832
SD: s132 v7.0.1
SDK 16.0.0

As a first step, I'm not setting flters, I just want to connect to any peripheral. There are lots of advertising peripherals nearby, I can scan and connect to them with nRF Connect for example. 

I'm using code taken from example ble_central_and_peripheral/experimental/ble_app_hrs_rscs_relay/

Here is my init function:

static void scan_init(void)
{
    ret_code_t err_code;
    nrf_ble_scan_init_t init_scan;

    memset(&init_scan, 0, sizeof(init_scan));

    init_scan.p_scan_param     = &m_scan_param;
    init_scan.connect_if_match = true;
    init_scan.conn_cfg_tag     = APP_BLE_CONN_CFG_TAG;

    err_code = nrf_ble_scan_init(&m_scan, &init_scan, scan_evt_handler);
    APP_ERROR_CHECK(err_code);
}

Here is my start function :

#define SCAN_DURATION 3000
#define APP_BLE_CONN_CFG_TAG 1

/**< Scan parameters requested for scanning and connection. */
static ble_gap_scan_params_t const m_scan_param =
{
    .active        = 0x01,
    .interval      = NRF_BLE_SCAN_SCAN_INTERVAL,
    .window        = NRF_BLE_SCAN_SCAN_WINDOW,
    .filter_policy  = BLE_GAP_SCAN_FP_ACCEPT_ALL, //BLE_GAP_SCAN_FP_WHITELIST,
    .timeout       = SCAN_DURATION,
    .scan_phys     = BLE_GAP_PHY_1MBPS,
};

void ble_scale_scan_start(void)
{
    ret_code_t err_code;

    err_code = nrf_ble_scan_params_set(&m_scan, &m_scan_param);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_ble_scan_start(&m_scan);
    APP_ERROR_CHECK(err_code);
}

Here are the logs :

00> <debug> ble_scan: Scanning parameters have been changed successfully
00> <debug> ble_scan: Scanning
00> <debug> ble_scan: BLE_GAP_SCAN_TIMEOUT
00> <info> app: Scan timed out.
00> <debug> ble_scan: Scanning parameters have been changed successfully
00> <debug> ble_scan: Scanning
00> <debug> ble_scan: BLE_GAP_SCAN_TIMEOUT
00> <info> app: Scan timed out.
00> <debug> ble_scan: Scanning parameters have been changed successfully
00> <debug> ble_scan: Scanning
00> <debug> ble_scan: BLE_GAP_SCAN_TIMEOUT


What am I missing ?
Thanks !

Parents
  • In your init function here, it seems like you enable all filters, which might cause some issues for you Please try setting this to NRF_BLE_SCAN_NAME_FILTER. Can you also show me how the device name is set in your peripheral device?

    From what I can see, this scan_init should let you connect to a peripheral advertising with the device name Bala.

    Best regards,

    Simon

Reply
  • In your init function here, it seems like you enable all filters, which might cause some issues for you Please try setting this to NRF_BLE_SCAN_NAME_FILTER. Can you also show me how the device name is set in your peripheral device?

    From what I can see, this scan_init should let you connect to a peripheral advertising with the device name Bala.

    Best regards,

    Simon

Children
Related