BLE Peripheral Uart example get disconnected after bonding to windows. No way to reconnect

CONFIG

  • Example reproduced: NRF Peripheral Uart
  • SoC Used: USI AzureSphere Combo Module
  • Windows Version: 11 enterprise (version 10.0.22000)
  • Board type: NRF52DK_nrf52832

Goal:

Setup a windows console that echos the messages received on the COM Port associated to the BLE peripheral

Problem Explainations:

I've configure the BLE Peripheral Uart example with a Azure Uart High Level App (HL App) on an Azure Sphere SoC and everything was working well using the nRF Connect app on an Iphone. The BLE Connection between the SoC and the Iphone was working flawlessly. Messages sent from the Windos UART HL App through the UART bus where seen on the BLE services on the nRF Connect mobile app. Likewise for the other way around (Iphone to HL App).

I tried to reproduce the setup but with a windows laptop. I'm found that on a windows laptop, bonding is needed. Here is the content of prj.conf for info.

 

#
# Copyright (c) 2018 Nordic Semiconductor
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

# Enable the UART driver
CONFIG_UART_ASYNC_API=y
CONFIG_NRFX_UARTE0=y
CONFIG_SERIAL=y

CONFIG_GPIO=y
# Make sure printk is printing to the UART console
CONFIG_CONSOLE=y

CONFIG_HEAP_MEM_POOL_SIZE=2048

CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_NAME="Nordic_UART_Service"
CONFIG_BT_DEVICE_APPEARANCE=63
CONFIG_BT_MAX_CONN=1
CONFIG_BT_MAX_PAIRED=1

# Enable the NUS service
CONFIG_BT_NUS=y

# Enable bonding
CONFIG_BT_SETTINGS=y
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y
CONFIG_NVS=y
CONFIG_SETTINGS=y
# CONFIG_BT_NUS_UART_ASYNC_ADAPTER=y

# Enable DK LED and Buttons library
CONFIG_DK_LIBRARY=y

# This example requires more workqueue stack
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048

# Config logger
CONFIG_LOG=y
CONFIG_USE_SEGGER_RTT=y
CONFIG_LOG_BACKEND_RTT=y
CONFIG_LOG_BACKEND_UART=n

CONFIG_ASSERT=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
CONFIG_BT_BONDING_REQUIRED=y

I also followed the instructions in this link to remove any passkey or interaction requested to secure the connection. auth_passkey_display was set back up to make sure I have a passkey to enter on the windows side. I also changed the appearance number in case windows would load some unwanted drivers with the default 833 appearance number. 

I've also found this link regarding connection intervals but other windows forums were stating that windows adapt itself to the BLE peripheral connection intervals. 

Through the RTT debugger, I can see the passkey interaction but I found no way to understand what is causing this disconnection. 

 

 [00:00:00.027,343] <inf> bt_hci_core: No ID address. App must call settings_load()
00> [00:00:00.027,374] <inf> peripheral_uart: Bluetooth initialized
00> [00:00:01.894,958] <inf> peripheral_uart: Main Started
00> [00:00:05.143,890] <inf> fs_nvs: 6 Sectors of 4096 bytes
00> [00:00:05.143,890] <inf> fs_nvs: alloc wra: 0, fd0
00> [00:00:05.143,920] <inf> fs_nvs: data wra: 0, 1c
00> [00:00:05.144,195] <inf> sdc_hci_driver: SoftDevice Controller build revision: 
00>                                          33 78 2a 18 20 f5 61 61  a6 8b 77 60 62 83 39 2a |3x*. .aa ..w`b.9*
00>                                          7c f1 14 e4                                      ||...             
00> [00:00:05.153,167] <inf> bt_hci_core: No ID address. App must call settings_load()
00> [00:00:05.153,228] <inf> peripheral_uart: Bluetooth initialized
00> [00:00:15.641,174] <inf> peripheral_uart: Connected XX:XX:XX:XX:XX:XX (public)
00> [00:00:16.437,286] <inf> peripheral_uart: Passkey for XX:XX:XX:XX:XX:XX (public): 865928
00> [00:00:29.531,066] <inf> peripheral_uart: Security changed: XX:XX:XX:XX:XX:XX (public) level 4
00> [00:00:29.675,750] <inf> peripheral_uart: Pairing completed: XX:XX:XX:XX:XX:XX (public), bonded: 1
00> [00:00:33.143,096] <inf> peripheral_uart: Disconnected: XX:XX:XX:XX:XX:XX (public) (reason 19)

I've seen on the windows bluetooth setting page that the BLE device itself gets paired but never reconnect. I went through the Windows event viewer and I always found some of these events when I was testing the BLE Connection. Messages in the Event Viewer seemed to changed based on the appearance number.

  • Windows cannot store Bluetooth authentication codes (link keys) on the local adapter. Bluetooth keyboards might not work in the system BIOS during startup.
  • The remote adapter (XX:XX:XX:XX:XX:XX) is no longer a paired device. Its link key has been removed.
  • The remote adapter (XX:XX:XX:XX:XX:XX) successfully paired with the local adapter.

Thanks for any guidance towards this issue!

  • Hi,

    The disconnect reason here is 19 = 0x13 = Remote User Terminated Connection. So the peer (Windows computer) decided to disconnect for some reason.

    I went through the Windows event viewer and I always found some of these events when I was testing the BLE Connection. Messages in the Event Viewer seemed to changed based on the appearance number.

    The log you see here from Windows seems to explain what you are experiencing, but I have never seen anything like it nor am I able to digg into internals of the Windows Bluetooth stack. I suggest you contact Microsoft for assistance about this.

  • Hi Thanks for your answer Einar!

    I found the solution to the problem. All the pairing process goes as expected but somehow once completed, Windows disconnect it. I tried to use another BLE software (Bluetooth LE Explorer) to try to connect once paired and it worked!
    Windows only needed a manual re-connect request even if I thought that once paired, this would be automatic.

Related