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

  • Discovery ANCS start when DM_EVT_LINK_SECURED which is executed after pairing.

        case DM_EVT_LINK_SECURED:
            err_code = ble_db_discovery_start(&m_ble_db_discovery,
                                              p_evt->event_param.p_gap_param->conn_handle);
            APP_ERROR_CHECK(err_code);
          break;
    

    Then, in original source code of ANCS, the BLE_ANCS_C_EVT_DISCOVER_COMPLETE event always occurs after Pairing request. Can we discover ANCS without link secured ? if not, do you have any solution for this ?

Reply
  • Discovery ANCS start when DM_EVT_LINK_SECURED which is executed after pairing.

        case DM_EVT_LINK_SECURED:
            err_code = ble_db_discovery_start(&m_ble_db_discovery,
                                              p_evt->event_param.p_gap_param->conn_handle);
            APP_ERROR_CHECK(err_code);
          break;
    

    Then, in original source code of ANCS, the BLE_ANCS_C_EVT_DISCOVER_COMPLETE event always occurs after Pairing request. Can we discover ANCS without link secured ? if not, do you have any solution for this ?

Children
No Data
Related