Hello,
I'm implementing a device based on the NRF52840 Dongle and the hids keyboard example. The basic functionality work, so that I can send pressed keys to a connected device. The problem is that after the restart/power loss, the devices must be paired again.
I added SETTINGS related variables to the prj.conf:
CONFIG_SETTINGS=y CONFIG_SETTINGS_RUNTIME=y # NVS variables when enabled prevent boot. Even serial port is not visible in the system # CONFIG_NVS=y # CONFIG_SETTINGS_NVS=y # Setting these two does not change the behavior. # CONFIG_FCB=y # CONFIG_SETTINGS_FCB=y # This variable gets "y" in the build unless NVS or FCB is enabled # CONFIG_SETTINGS_NONE=n CONFIG_BT_SETTINGS=y CONFIG_BT_GATT_CACHING=n CONFIG_FLASH=y CONFIG_FLASH_PAGE_LAYOUT=y CONFIG_FLASH_MAP=y
main.c:
int main(void) { if (IS_ENABLED(CONFIG_SETTINGS)) { err = settings_load(); if (!err) { printk("settings_load done\n"); } else { printk("settings_load failed, err=%d\n", err); } } err = bt_enable(NULL); if (err) { printk("Bluetooth init failed (err %d)\n", err); return 0; } printk("Bluetooth initialized\n"); if (IS_ENABLED(CONFIG_SETTINGS)) { // see bt_enable() description err = settings_load_subtree("bt"); if (!err) { printk("settings_load BT done\n"); } else { printk("settings_load BT failed, err=%d\n", err); } } ...
After the successful connection I see several error messages in the console:
Connected 64:6E:E0:48:6A:A1 (public) E: Failed to save keys (err -2) Pairing completed: 64:6E:E0:48:6A:A1 (public), bonded: 1 HID service notified E: Failed to store CCCs (err -2) Security changed: 64:6E:E0:48:6A:A1 (public) level 2 E: failed to store SC (err -2) Output report read E: Failed to store CCCs (err -2) E: Failed to store CCCs (err -2)
I tried already different CONFIG combinations, nothing worked. What I'm doing wrong?
Thank you for your answers.