diff --git a/examples/blemesh_bridge/platform/ESP32_custom/nimble/BLEManagerImpl.cpp b/examples/blemesh_bridge/platform/ESP32_custom/nimble/BLEManagerImpl.cpp index 41a7c84da..00279d67b 100644 --- a/examples/blemesh_bridge/platform/ESP32_custom/nimble/BLEManagerImpl.cpp +++ b/examples/blemesh_bridge/platform/ESP32_custom/nimble/BLEManagerImpl.cpp @@ -131,7 +131,7 @@ const struct ble_gatt_svc_def BLEManagerImpl::CHIPoBLEGATTAttrs[] = { { .uuid = (ble_uuid_t *) (&UUID_CHIPoBLEChar_TX), .access_cb = gatt_svr_chr_access, - .flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_NOTIFY | BLE_GATT_CHR_F_INDICATE, + .flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_INDICATE, .val_handle = &sInstance.mTXCharCCCDAttrHandle, }, #if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING @@ -300,17 +300,6 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) case DeviceEventType::kServiceProvisioningChange: case DeviceEventType::kWiFiConnectivityChange: - // If CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED is enabled, and there is a change to the - // device's provisioning state, then automatically disable CHIPoBLE advertising if the device - // is now fully provisioned. -#if CHIP_DEVICE_CONFIG_CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED - if (ConfigurationMgr().IsFullyProvisioned()) - { - mFlags.Clear(Flags::kAdvertisingEnabled); - ChipLogProgress(DeviceLayer, "CHIPoBLE advertising disabled because device is fully provisioned"); - } -#endif // CHIP_DEVICE_CONFIG_CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED - // Force the advertising configuration to be refreshed to reflect new provisioning state. ChipLogProgress(DeviceLayer, "Updating advertising data"); mFlags.Clear(Flags::kAdvertisingConfigured); @@ -380,10 +369,10 @@ bool BLEManagerImpl::SendIndication(BLE_CONNECTION_OBJECT conId, const ChipBleUU ExitNow(); } - err = MapBLEError(ble_gattc_notify_custom(conId, mTXCharCCCDAttrHandle, om)); + err = MapBLEError(ble_gattc_indicate_custom(conId, mTXCharCCCDAttrHandle, om)); if (err != CHIP_NO_ERROR) { - ChipLogError(DeviceLayer, "ble_gattc_notify_custom() failed: %s", ErrorStr(err)); + ChipLogError(DeviceLayer, "ble_gattc_indicate_custom() failed: %s", ErrorStr(err)); ExitNow(); } @@ -485,16 +474,6 @@ void BLEManagerImpl::DriveBLEState(void) if (!mFlags.Has(Flags::kAsyncInitCompleted)) { mFlags.Set(Flags::kAsyncInitCompleted); - - // If CHIP_DEVICE_CONFIG_CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED is enabled, - // disable CHIPoBLE advertising if the device is fully provisioned. -#if CHIP_DEVICE_CONFIG_CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED - if (ConfigurationMgr().IsFullyProvisioned()) - { - mFlags.Clear(Flags::kAdvertisingEnabled); - ChipLogProgress(DeviceLayer, "CHIPoBLE advertising disabled because device is fully provisioned"); - } -#endif // CHIP_DEVICE_CONFIG_CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED } // Initializes the ESP BLE layer if needed. @@ -729,6 +708,8 @@ CHIP_ERROR BLEManagerImpl::InitESPBleLayer(void) vSemaphoreDelete(semaphoreHandle); semaphoreHandle = NULL; + err = bleprph_set_random_addr(); + #if CONFIG_BLE_MESH esp_ble_mesh_register_ble_callback(ble_mesh_ble_cb); app_ble_mesh_init(); @@ -737,7 +718,6 @@ CHIP_ERROR BLEManagerImpl::InitESPBleLayer(void) sInstance.mFlags.Set(Flags::kESPBLELayerInitialized); sInstance.mFlags.Set(Flags::kGATTServiceStarted); - err = bleprph_set_random_addr(); exit: return err; } @@ -860,19 +840,17 @@ void BLEManagerImpl::HandleTXCharCCCDWrite(struct ble_gap_event * gapEvent) { CHIP_ERROR err = CHIP_NO_ERROR; bool indicationsEnabled; - bool notificationsEnabled; ChipLogProgress(DeviceLayer, "Write request/command received for CHIPoBLE TX CCCD characteristic (con %u" - " ) indicate = %d notify = %d", - gapEvent->subscribe.conn_handle, gapEvent->subscribe.cur_indicate, gapEvent->subscribe.cur_notify); + " ) indicate = %d", + gapEvent->subscribe.conn_handle, gapEvent->subscribe.cur_indicate); - // Determine if the client is enabling or disabling indications/notification. - indicationsEnabled = gapEvent->subscribe.cur_indicate; - notificationsEnabled = gapEvent->subscribe.cur_notify; + // Determine if the client is enabling or disabling indications. + indicationsEnabled = gapEvent->subscribe.cur_indicate; - // If the client has requested to enabled indications/notifications - if (indicationsEnabled || notificationsEnabled) + // If the client has requested to enabled indications + if (indicationsEnabled) { // If indications are not already enabled for the connection... if (!IsSubscribed(gapEvent->subscribe.conn_handle)) @@ -895,14 +873,12 @@ void BLEManagerImpl::HandleTXCharCCCDWrite(struct ble_gap_event * gapEvent) // whether the client is enabling or disabling indications. { ChipDeviceEvent event; - event.Type = (indicationsEnabled || notificationsEnabled) ? DeviceEventType::kCHIPoBLESubscribe - : DeviceEventType::kCHIPoBLEUnsubscribe; + event.Type = (indicationsEnabled) ? DeviceEventType::kCHIPoBLESubscribe : DeviceEventType::kCHIPoBLEUnsubscribe; event.CHIPoBLESubscribe.ConId = gapEvent->subscribe.conn_handle; err = PlatformMgr().PostEvent(&event); } - ChipLogProgress(DeviceLayer, "CHIPoBLE %s received", - (indicationsEnabled || notificationsEnabled) ? "subscribe" : "unsubscribe"); + ChipLogProgress(DeviceLayer, "CHIPoBLE %s received", (indicationsEnabled) ? "subscribe" : "unsubscribe"); exit: if (err != CHIP_NO_ERROR)