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

nRF51822 connect to Android without pairing

Hello,

I am working on a wearable device at the moment. To support iOS and Android at the same time, I have implemented ANCS and nRF UART on the circuit.

When working with just the nRF UART on the DevKit, it never prompted me to pair (on the phone). But after implementing ANCS and UART together, it starts prompting to pair, and the connection has been poorer since then. Whether I click 'pair' or 'cancel', it fails to connect properly. It works well with the iOS devices.

Is there a way to have ANCS and nRF UART but not ask for pair on Android side?

Parents
  • Hey.

    If you have merged the ancs example code into your project, this is probably what is causing the pairing request:

    case DM_EVT_CONNECTION:
            m_peer_handle = (*p_handle);
            err_code      = app_timer_start(m_sec_req_timer_id, SECURITY_REQUEST_DELAY, NULL);
            APP_ERROR_CHECK(err_code);
            break;
    

    and

    static void sec_req_timeout_handler(void * p_context)
    {
    uint32_t             err_code;
    dm_security_status_t status;
    
    if (m_conn_handle != BLE_CONN_HANDLE_INVALID)
    {
        err_code = dm_security_status_req(&m_peer_handle, &status);
        APP_ERROR_CHECK(err_code);
    
        // If the link is still not secured by the peer, initiate security procedure.
        if (status == NOT_ENCRYPTED)
        {
            err_code = dm_security_setup_req(&m_peer_handle);
            APP_ERROR_CHECK(err_code);
        }
    }
    

    }

    dm_security_setup_req() requests pairing.

    The timer starts on connection. You should change it to start after discovering the ancs service, i.e on the BLE_ANCS_C_EVT_DISCOVER_COMPLETE event inside on_ancs_c_evt

  • Thanks you for kind answer.

    But, to simplify user interaction, I would NOT like to pair with Android devices. But, to discover whether ANCS exists or not, secure connection (via Pairing) seems necessary. Is there away to know whether the connected device at DM_EVT_CONNECTION is running Android or iOS? So I only request for secure setup after timeout when it is an iOS device. (i.e. if I put app_timer_start() inside BLE_ANCS_C_EVT_DISCOVER_COMPLETE event, it is never called.

Reply
  • Thanks you for kind answer.

    But, to simplify user interaction, I would NOT like to pair with Android devices. But, to discover whether ANCS exists or not, secure connection (via Pairing) seems necessary. Is there away to know whether the connected device at DM_EVT_CONNECTION is running Android or iOS? So I only request for secure setup after timeout when it is an iOS device. (i.e. if I put app_timer_start() inside BLE_ANCS_C_EVT_DISCOVER_COMPLETE event, it is never called.

Children
No Data
Related