I use nRFConnect iOS APP to pair nRF52832 device. But it failed to show passkey dialog.
I use nRFConnect iOS APP to pair nRF52832 device. But it failed to show passkey dialog.
I am not sure "it failed to show passkey dialog" means?
There does not seem to be any encryption requested by either side of the device. How do you want to initiate pairing?
Please go through this case where my colleague Vidar tried to explain what is expected on the peripheral side for the pairing to work with Apple devices.
I have added the following configuration in prj.conf.
CONFIG_BT_FIXED_PASSKEY=y
CONFIG_BT_GATT_AUTO_SEC_REQ=y
CONFIG_BT_SMP=y
And I also add the following code in bt.c for static pairing
bt_passkey_set(123456); // in btInit()
bt_conn_set_security(conn, BT_SECURITY_L2); // in connected() callback function
Now nRFConnect iOS APP shows pairing request information. But it doesn't shows dialog for me to enter passkey 123456.
How to add code in pairing_failed() for triggering nRFConnect iOS APP to disconnect.
static void pairing_failed(struct bt_conn *conn, enum bt_security_err reason)
{
char addr[BT_ADDR_LE_STR_LEN];
bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
printk("Pairing failed conn: %s, reason %d", addr, reason);
}
I have added bt_conn_disconnect(conn, BT_HCI_ERR_REMOTE_USER_TERM_CONN) to pairing_failed() callback function. Now nRFConnect iOS APP can disconnect successfully.
static void pairing_failed(struct bt_conn *conn, enum bt_security_err reason)
{
char addr[BT_ADDR_LE_STR_LEN];
bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
bt_conn_disconnect(conn, BT_HCI_ERR_REMOTE_USER_TERM_CONN);
printk("Pairing failed conn: %s, reason %d", addr, reason);
}
Thanks for letting us know about the fix snowuyl.
Thanks for letting us know about the fix snowuyl.