Hi,
I have successfully created a BT Peripheral which uses a static/fixed passkey upon connection with my phone (nrf connect mobile) or using the nrf52840 dongle. When I connect with the peripheral, I am prompted for the passkey on my phone or desktop and succedes to connect after writing the same "123456" passkey every time.
What I am struggling with, however, is how to connect to the peripheral with a Zephyr/NCS Central using the fixed passkey. Could you please aid me in getting this to work?
My Peripherals auth connection callback struct looks like:
static struct bt_conn_auth_cb auth_cb = { .cancel = auth_cancel, .passkey_display = auth_passkey_display, .pairing_confirm = NULL, .pairing_complete = pairing_complete, .pairing_failed = pairing_failed, };
and my Centrals auth connection callback struct looks like:
static struct bt_conn_auth_cb conn_auth_callbacks = { .cancel = auth_cancel, .pairing_confirm = NULL, .passkey_confirm = passkey_confirm, .pairing_complete = pairing_complete, .pairing_failed = pairing_failed};
I though perhaps the Central would accept the Peripherals fixed passkey through:
static void passkey_confirm(struct bt_conn *conn, unsigned int passkey) { char addr[BT_ADDR_LE_STR_LEN]; bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); int err; unsigned int fixed_passkey = 123456; if (passkey == fixed_passkey) { err = bt_conn_auth_passkey_confirm(conn); if (err) { printk("failed to confirm passkey, err: %d\n", err); } } }
But that doesn't work. Any suggestions?
Thanks a lot in advance!
Best regards,
Jonas