Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLE bonding fail when it's no longer used by Matter (CON-1426) #1164

Open
GaryChan-work opened this issue Nov 20, 2024 · 0 comments
Open

BLE bonding fail when it's no longer used by Matter (CON-1426) #1164

GaryChan-work opened this issue Nov 20, 2024 · 0 comments

Comments

@GaryChan-work
Copy link

GaryChan-work commented Nov 20, 2024

Hi,

I had the same issue as listed below and could use @chrelu solution to do the advertising. However, I couldn't perform the bonding with the mobile phone as I did before. I have used the "nRF Connect app" on Android to connect it and perform the bonding, but the connection was dropped, and the bonding was failed. The mobile didn't prompt any message for me to confirm the passkey, and the device also didn't receive BLE_GAP_EVENT_PASSKEY_ACTION as before.


Screenshot from 2024-11-20 10-26-16

Does anyone know how to fix this issue?
Thank you very much!

          I found a solution. Instead of re-initializing BLE, I only reset BLE GATTS and start it again after adding my BLE services (see method gatt_svr_init). I hope I could also help someone else.
void app_event_cb(const ChipDeviceEvent *event, intptr_t arg)
{
    switch (event->Type)
    {
    ...
    case chip::DeviceLayer::DeviceEventType::kCHIPoBLEConnectionClosed:
        ble_start();
        break;
    ...
    }
}
void ble_start(void)
{
    ble_hs_cfg.sync_cb = sync_cb;
    ble_hs_cfg.reset_cb = reset_cb;

    gatt_svr_init();

    sync_cb();
}
void gatt_svr_init()
{
  ble_gatts_reset(); // before I didn't call this method

  ble_svc_gap_init();
  ble_svc_gatt_init();
  ble_gatts_count_cfg(gatt_svr_svcs);
  ble_gatts_add_svcs(gatt_svr_svcs);

  ble_gatts_start(); // before I didn't call this method
}
void sync_cb(void) {
  ble_hs_id_infer_auto(0, &addr_type);
  advertise();
}

Originally posted by @chrelu in #906 (comment)

@GaryChan-work GaryChan-work changed the title BLE bonding fail when it is no longer used by Matter BLE bonding fail when it's no longer used by Matter Nov 20, 2024
@github-actions github-actions bot changed the title BLE bonding fail when it's no longer used by Matter BLE bonding fail when it's no longer used by Matter (CON-1426) Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant