I have a custom hardware running on nrf52840 and using ncs 2.6.1. I have implemented a custom authentication flow with customer characteristic along with the BLE bonding. I have a custom app for iOS and Android both. I tested my device pairing and bonding with my iOS app and its is working as expected.
But when I test the same firmware with Android App I am facing issue with pairing. After the connection the device is not able to complete the BLE pairing somehow. To identify the actual issue I debug the operation and from the logs I found that the MTU size is not getting updated when I connect the device with the Android. And that is why my customer service that performs the authentication is not executed.
Regarding to the mobile app that I am using, both the apps are built on the same platform and well tested. And I have another application which is running on legacy Nordic SDK RTOS which is working fine with both the App android and iOS on the same hardware. And my existing application is the Zephyr revision of this legacy application.
So I suspect there is something that is missing after adding the Zephyr as the Application and Hardware both performing well but the same code with Zephyr is creating issue. Below are the application details.
prj.conf
CONFIG_BT=y CONFIG_BT_SMP=y CONFIG_BT_SMP_APP_PAIRING_ACCEPT=y CONFIG_BT_PERIPHERAL=y CONFIG_BT_DEVICE_NAME="LP" CONFIG_BT_DEVICE_NAME_DYNAMIC=y CONFIG_BT_DEVICE_NAME_MAX=7 CONFIG_BLE_NAME_AS_PER_MAC=y CONFIG_BT_GATT_CLIENT=y CONFIG_BT_GATT_DYNAMIC_DB=y CONFIG_BT_L2CAP_TX_MTU=247 CONFIG_BT_BUF_ACL_RX_SIZE=251 CONFIG_BT_BUF_ACL_TX_SIZE=251 CONFIG_BT_CTLR_DATA_LENGTH_MAX=251 CONFIG_BT_BONDING_FEATURE=y CONFIG_BT_SETTINGS=y CONFIG_FLASH_PAGE_LAYOUT=y CONFIG_SETTINGS=y CONFIG_SETTINGS_NVS=y CONFIG_BT_MAX_PAIRED=5 CONFIG_BT_KEYS_OVERWRITE_OLDEST=y CONFIG_BT_USER_PHY_UPDATE=y CONFIG_BT_USER_DATA_LEN_UPDATE=y CONFIG_BT_AUTO_PHY_UPDATE=n CONFIG_BT_ATT_PREPARE_COUNT=2 CONFIG_BT_BUF_ACL_TX_COUNT=10
iOS App pairing logs (Running on iPad iPadOS version 18.3.2)
00> I: Updated MTU: TX: 23 RX: 23 bytes 00> I: Current address: 6D:A0:99:63:55:47 (random) 00> I: Connected 6D:A0:99:63:55:47 (random) 00> I: Initialize iv :: 00> I: LE PHY updated: TX PHY LE 2M, RX PHY LE 2M 00> I: LE data len updated: TX (len: 251 time: 2120) RX (len: 251 time: 2120) 00> W: Ignoring data for unknown channel ID 0x003a 00> I: Updated MTU: TX: 527 RX: 247 bytes 00> I: Security changed: 6D:A0:99:63:55:47 (random) level 2 00> I: Pairing completed: 20:15:82:15:8F:2A (public), bonded: 1
Android App pairing logs (Running on Android tablet version 14)
00> I: Updated MTU: TX: 23 RX: 23 bytes 00> I: Current address: 24:F0:D3:EF:99:EE (public) 00> I: Connected 24:F0:D3:EF:99:EE (public) 00> I: Initialize iv :: 00> I: LE data len updated: TX (len: 251 time: 2120) RX (len: 27 time: 328) 00> I: Connection parameters updated: 00> interval=7.50 ms, latency=0, timeout=5000 ms 00> I: Connection parameters updated: 00> interval=45.00 ms, latency=0, timeout=5000 ms 00> I: Security failed: 24:F0:D3:EF:99:EE (public) level 1 err 4 00> I: Pairing failed conn: 24:F0:D3:EF:99:EE (public), reason 4 00> I: Disconnected from 24:F0:D3:EF:99:EE (public) (reason 19)
I am using BLE bonding with security