[Matter] Bluetooth: settings_load is only called if CONFIG_BT_BONDABLE is set

I'm not sure if this is the right place for this question.

I'm using the Settings subsystem for the BLE name.

When BLE is initialized inside matter, settings_load is only called if CONFIG_BT_BONDABLE is set (modules/lib/matter/src/platform/Zephyr/BLEManagerImpl.cpp). This leads to the error "Can't register service after init and before settings are loaded." when matter tries to register the GATT service.

I can fix this by calling settings_load before initializing matter, but this results in the BLE name being an empty string. The problem here is that BLE settings are only loaded when calling settings_load after bt_enable.

Therefore I have to post a task to matter that calls settings_load_subtree("bt")) and restarts the advertising. Then everything works as expected.

Is this a bug or am I missing something here?

Parents
  • Hi,

    It looks like we have made the assumption that BT_SETTINGS will only be used together with CONFIG_BT_BONDABLE. So I understand this correctly, if you enable CONFIG_BT_BONDABLE it works as well? I have forwarded this question internally. 

    Best regards,

    Vidar

  • Yes, I don't know why CONFIG_BT_BONDABLE is required.

    I enabled CONFIG_BT_SMP and CONFIG_BT_BONDABLE but it failed at bt_id_create (github).

    I had to add CONFIG_BT_ID_MAX=2 as well in our project to trigger the bt_id_reset call afterwards and then it was working.

  • Sorry for the delay. I've been waiting to discuss the issue with the author of the commit, but he's been out of the office all week. I don't foresee any problems with the workaround you described in your first post. I also think you can patch init function in BLEManagerImpl.cpp like below. 

    ...

    #else
    err = InitRandomStaticAddress(false, id);
    VerifyOrReturnError(err == 0 && id == kMatterBleIdentity, MapErrorZephyr(err));
    err = bt_enable(nullptr);
    if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
    settings_load();
    }
    VerifyOrReturnError(err == 0, MapErrorZephyr(err));
    #endif // CONFIG_BT_BONDABLE
    ...
Reply
  • Sorry for the delay. I've been waiting to discuss the issue with the author of the commit, but he's been out of the office all week. I don't foresee any problems with the workaround you described in your first post. I also think you can patch init function in BLEManagerImpl.cpp like below. 

    ...

    #else
    err = InitRandomStaticAddress(false, id);
    VerifyOrReturnError(err == 0 && id == kMatterBleIdentity, MapErrorZephyr(err));
    err = bt_enable(nullptr);
    if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
    settings_load();
    }
    VerifyOrReturnError(err == 0, MapErrorZephyr(err));
    #endif // CONFIG_BT_BONDABLE
    ...
Children
No Data
Related