Merge branch 'fix_ble_mesh_example_v1_5' into 'release/v1.5'

examples/common: fix ble not start in blemesh_bridge exmaple (v1.5)

See merge request app-frameworks/esp-matter!1485
This commit is contained in:
Shu Chen
2026-03-31 10:59:32 +00:00
2 changed files with 12 additions and 8 deletions
@@ -71,6 +71,7 @@ buildconfig_header("custom_buildconfig") {
"CHIP_USE_TRANSITIONAL_DEVICE_INSTANCE_INFO_PROVIDER=true", "CHIP_USE_TRANSITIONAL_DEVICE_INSTANCE_INFO_PROVIDER=true",
"CHIP_DEVICE_LAYER_TARGET_ESP32=1", "CHIP_DEVICE_LAYER_TARGET_ESP32=1",
"CHIP_DEVICE_LAYER_TARGET=ESP32_custom", "CHIP_DEVICE_LAYER_TARGET=ESP32_custom",
"CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE=${chip_enable_chipoble}",
"BLE_PLATFORM_CONFIG_INCLUDE=<platform/ESP32_custom/BlePlatformConfig.h>", "BLE_PLATFORM_CONFIG_INCLUDE=<platform/ESP32_custom/BlePlatformConfig.h>",
"CHIP_DEVICE_PLATFORM_CONFIG_INCLUDE=<platform/ESP32_custom/CHIPDevicePlatformConfig.h>", "CHIP_DEVICE_PLATFORM_CONFIG_INCLUDE=<platform/ESP32_custom/CHIPDevicePlatformConfig.h>",
"CHIP_PLATFORM_CONFIG_INCLUDE=<platform/ESP32_custom/CHIPPlatformConfig.h>", "CHIP_PLATFORM_CONFIG_INCLUDE=<platform/ESP32_custom/CHIPPlatformConfig.h>",
@@ -140,6 +140,8 @@ const ble_uuid128_t UUID_CHIPoBLEChar_C3 = {
}; };
#endif // CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING #endif // CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING
const struct ble_gatt_svc_def kNullSvc = { 0 };
SemaphoreHandle_t semaphoreHandle = NULL; SemaphoreHandle_t semaphoreHandle = NULL;
// LE Random Device Address // LE Random Device Address
@@ -152,7 +154,7 @@ uint8_t own_addr_type = BLE_OWN_ADDR_RANDOM;
ChipDeviceScanner & mDeviceScanner = Internal::ChipDeviceScanner::GetInstance(); ChipDeviceScanner & mDeviceScanner = Internal::ChipDeviceScanner::GetInstance();
#endif #endif
BLEManagerImpl BLEManagerImpl::sInstance; BLEManagerImpl BLEManagerImpl::sInstance;
const struct ble_gatt_svc_def BLEManagerImpl::CHIPoBLEGATTAttrs[] = { const struct ble_gatt_svc_def BLEManagerImpl::CHIPoBLEGATTSvc =
{ .type = BLE_GATT_SVC_TYPE_PRIMARY, { .type = BLE_GATT_SVC_TYPE_PRIMARY,
.uuid = (ble_uuid_t *) (&ShortUUID_CHIPoBLEService), .uuid = (ble_uuid_t *) (&ShortUUID_CHIPoBLEService),
.characteristics = .characteristics =
@@ -180,11 +182,7 @@ const struct ble_gatt_svc_def BLEManagerImpl::CHIPoBLEGATTAttrs[] = {
{ {
0, /* No more characteristics in this service */ 0, /* No more characteristics in this service */
}, },
} }, }
{
0, /* No more services. */
},
}; };
#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER #ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER
@@ -1006,14 +1004,19 @@ CHIP_ERROR BLEManagerImpl::InitESPBleLayer(void)
ble_svc_gap_init(); ble_svc_gap_init();
ble_svc_gatt_init(); ble_svc_gatt_init();
err = MapBLEError(ble_gatts_count_cfg(CHIPoBLEGATTAttrs)); if (mGattSvcs.size() == 0)
{
mGattSvcs.push_back(CHIPoBLEGATTSvc);
mGattSvcs.push_back(kNullSvc);
}
err = MapBLEError(ble_gatts_count_cfg(&mGattSvcs[0]));
if (err != CHIP_NO_ERROR) if (err != CHIP_NO_ERROR)
{ {
ChipLogError(DeviceLayer, "ble_gatts_count_cfg failed: %s", ErrorStr(err)); ChipLogError(DeviceLayer, "ble_gatts_count_cfg failed: %s", ErrorStr(err));
ExitNow(); ExitNow();
} }
err = MapBLEError(ble_gatts_add_svcs(CHIPoBLEGATTAttrs)); err = MapBLEError(ble_gatts_add_svcs(&mGattSvcs[0]));
if (err != CHIP_NO_ERROR) if (err != CHIP_NO_ERROR)
{ {
ChipLogError(DeviceLayer, "ble_gatts_add_svcs failed: %s", ErrorStr(err)); ChipLogError(DeviceLayer, "ble_gatts_add_svcs failed: %s", ErrorStr(err));