Hi,
nRF5340 and SDK v3.0.0 I'm using.
Currently my nRF5340 based BLE device can be bonded with smartphone via passkey, after bond is done, the device stops advertising and be invisible.
From smartphone side: in case the smartphone is out of range or the bluetooth on smartphone is disabled
From BLE device side: or in case the bond information on the nRF5340 is removed.
Except rebooting the device, there is no way to make them connect to each other again.
this is the BLE related funcitons:
if (bt_conn_auth_cb_register(&conn_auth_callbacks)) { LOG_ERR("Failed to register authorization callbacks.\n");} if (bt_conn_auth_info_cb_register(&conn_auth_info_callbacks)) { LOG_ERR("Failed to register authorization info callbacks.\n");} bt_conn_cb_register(&connection_callbacks); if (bt_enable(NULL)) { LOG_ERR("Bluetooth init failed. \n");} if (IS_ENABLED(CONFIG_SETTINGS)) { settings_load();} if (bt_services_init(&app_callbacks)) { LOG_ERR("Failed to init LBS. \n");} LOG_INF("Bluetooth initialized\n"); if (bt_le_adv_start(BT_LE_ADV_CONN_FAST_2, ad, ARRAY_SIZE(ad), sd, ARRAY_SIZE(sd))) { LOG_ERR("Advertising failed to start. \n");}
this is BLE related configurations:
# Button and LED library CONFIG_BT_LBS=y CONFIG_BT_LBS_POLL_BUTTON=y CONFIG_DK_LIBRARY=y CONFIG_BT_LBS_SECURITY_ENABLED=y # Bluetooth LE CONFIG_BT=y CONFIG_BT_PERIPHERAL=y CONFIG_BT_DEVICE_NAME="TEST_BLE" CONFIG_BT_SMP=y CONFIG_SETTINGS=y CONFIG_BT_SETTINGS=y #data length and MTU CONFIG_BT_USER_DATA_LEN_UPDATE=y CONFIG_BT_CTLR_DATA_LENGTH_MAX=251 CONFIG_BT_BUF_ACL_RX_SIZE=1024 CONFIG_BT_BUF_ACL_TX_SIZE=251 CONFIG_BT_L2CAP_TX_MTU=247 CONFIG_BT_GATT_CLIENT=y CONFIG_BT_AUTO_PHY_UPDATE=n
**********************************************************************
What I want:
1. just like the earphone, if the connection is lost, they shall be able to reconnect to each other by themselves automatically.
2. if the bond info is removed on the device, it shall advertise and be visible again.
How can I achive these?
Regards
Danny