Need to disable pairing with Windows 10

Greetings,

I've searched the forum, but haven't found a particular answer. I need to configure the project to not pair with Windows 10 PC because it blocks other software that needs to send commands to the device. This is critical. Tried to pair it with Android, but it rejects the pairing. Where can I disable this pairing?

The project is based on a merged hex from:

  1. secure_bootloader_ble_s132_pca10040.hex
  2. s132_nrf52_7.2.0_softdevice.hex
  3. dfu (ble_app_uart_pca10040_s132.hex)
Parents Reply Children
  • Tried to pair it with Android, but it rejects the pairing.

    This may indicate the problem is not really the Windows PC, but that the device is advertising with whitelist, and will then only connect to a previous bonded device. Maybe use the restart advertisement without whitelist api, this will allow connection with new peer device. The HID examples show this.

    But as mentioned, if you don't change the gap address and you already have a central device in the area with a bonded relationship, the central device (even if it's not Windows) will try to connect.

    Kenneth

  • I will check this. BTW, is it possible to add password before pairing a device?

  • The HID keyboard example should support passkey.

    Kenneth

  • Ok, I started with that example. So far, I tweaked the peer_manager_init function. This seems to disable access Windows 10 connecting with the devkit, but connect with the phone, which is what I need. Now I want to integrate that function in my project and add peer_manager.c with its' dependencies. I'm stuck on that part with Segger. How do I add that with the dependencies? I have peer_manager.c in the components folder of the project.

  • Update:

    I have implemented a timeout after 13 seconds, so it disconnects a device if it is connected longer than 13 seconds. The issue is when it is paired with Windows 10, it blocks the timer somehow and it can't disconnect. Any suggestions?

    **@brief Function for handling BLE events.
     *
     * @param[in]   p_ble_evt   Bluetooth stack event.
     * @param[in]   p_context   Unused.
     */
    static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
    {
        uint32_t err_code;
    
        switch (p_ble_evt->header.evt_id)
        {
            case BLE_GAP_EVT_CONNECTED:
                uart_init();
                NRF_LOG_INFO("Connected");
                //err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
                //APP_ERROR_CHECK(err_code);
                m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
                err_code = nrf_ble_qwr_conn_handle_assign(&m_qwr, m_conn_handle);
                APP_ERROR_CHECK(err_code);
                // Start the inactivity timer
                err_code = app_timer_start(m_inactivity_timer_id, APP_TIMER_TICKS(13000), NULL);
                APP_ERROR_CHECK(err_code);
                break;
    
            case BLE_GAP_EVT_DISCONNECTED:
                // Stop the inactivity timer
                err_code = app_timer_stop(m_inactivity_timer_id);
                APP_ERROR_CHECK(err_code);
                // Wait for UART to finish
                while(app_uart_tx_done());
                app_uart_close();
                NRF_LOG_INFO("Disconnected");
                // LED indication will be changed when advertising starts.
                m_conn_handle = BLE_CONN_HANDLE_INVALID;
                break;
    
            case BLE_GAP_EVT_PHY_UPDATE_REQUEST:
            {
                NRF_LOG_DEBUG("PHY update request.");
                ble_gap_phys_t const phys =
                {
                    .rx_phys = BLE_GAP_PHY_AUTO,
                    .tx_phys = BLE_GAP_PHY_AUTO,
                };
                err_code = sd_ble_gap_phy_update(p_ble_evt->evt.gap_evt.conn_handle, &phys);
                APP_ERROR_CHECK(err_code);
            } break;
    
            case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
                // Pairing not supported
                err_code = sd_ble_gap_sec_params_reply(m_conn_handle, BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP, NULL, NULL);
                APP_ERROR_CHECK(err_code);
                break;
    
            case BLE_GATTS_EVT_SYS_ATTR_MISSING:
                // No system attributes have been stored.
                err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, NULL, 0, 0);
                APP_ERROR_CHECK(err_code);
                break;
    
            case BLE_GATTC_EVT_TIMEOUT:
                // Stop the inactivity timer
                err_code = app_timer_stop(m_inactivity_timer_id);
                APP_ERROR_CHECK(err_code);
                // Disconnect on GATT Client timeout event.
                err_code = sd_ble_gap_disconnect(p_ble_evt->evt.gattc_evt.conn_handle,
                                                 BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
                APP_ERROR_CHECK(err_code);
                break;
    
            case BLE_GATTS_EVT_TIMEOUT:
                // Stop the inactivity timer
                err_code = app_timer_stop(m_inactivity_timer_id);
                APP_ERROR_CHECK(err_code);
                // Disconnect on GATT Server timeout event.
                err_code = sd_ble_gap_disconnect(p_ble_evt->evt.gatts_evt.conn_handle,
                                                 BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
                APP_ERROR_CHECK(err_code);
                break;
    
            default:
                // No implementation needed.
                break;
        }
    }

Related