My device supports both Central and Peripheral roles. By default, it works in Peripheral mode.
When the device connects in Peripheral mode, I want the following behavior:
-
A passkey popup window should appear on the mobile app.
-
The mobile should enter the correct passkey.
-
Only after successful pairing and bonding, the mobile should send the passkey to my device through a BLE characteristic.
-
My device stores this passkey and later automatically enters it when connecting to another device in Central mode.
Current Authentication Callback
Issue with This Callback
-
When
auth_passkey_entryis enabled, no popup window is generated on the mobile, and the stack sends a random passkey. -
This happens because
passkey_entryhas higher priority thanpasskey_display. -
If I comment out
passkey_entryandpasskey_confirm, the popup window appears correctly on the mobile. -
However, in that case, the device cannot enter the passkey when it connects to another device in Central mode.
Attempted Solution: Separate Callbacks for Each Role
Because of this, I created separate authentication callbacks and tried switching them based on the role.
Peripheral Mode (Mobile → HH)
DisplayOnly — mobile enters passkey
Central Mode (HH → Underdash 2)
KeyboardOnly — HH enters stored passkey
Current Problem
-
The first registered callback works, but after switching the callback at runtime, the new one does not take effect.
-
I believe this happens because the BLE stack already registered the previous callback, and it cannot be switched dynamically at runtime.
If needed, I can share my full authentication callback implementation so you can analyze it and identify the exact issue.