Skip to content

Commit 94adc9c

Browse files
Merge branch 'master' into TC-SC-4.3-python-test
2 parents 719c152 + 093aff8 commit 94adc9c

9 files changed

+22
-15
lines changed

src/darwin/Framework/CHIP/MTRDeviceController.mm

+7-2
Original file line numberDiff line numberDiff line change
@@ -371,17 +371,22 @@ - (MTRDevice *)_setupDeviceForNodeID:(NSNumber *)nodeID prefetchedClusterData:(N
371371
return [[MTRDevice alloc] initForSubclassesWithNodeID:nodeID controller:self];
372372
}
373373

374-
- (MTRDevice *)deviceForNodeID:(NSNumber *)nodeID
374+
- (MTRDevice *)_deviceForNodeID:(NSNumber *)nodeID createIfNeeded:(BOOL)createIfNeeded
375375
{
376376
std::lock_guard lock(*self.deviceMapLock);
377377
MTRDevice * deviceToReturn = [_nodeIDToDeviceMap objectForKey:nodeID];
378-
if (!deviceToReturn) {
378+
if (!deviceToReturn && createIfNeeded) {
379379
deviceToReturn = [self _setupDeviceForNodeID:nodeID prefetchedClusterData:nil];
380380
}
381381

382382
return deviceToReturn;
383383
}
384384

385+
- (MTRDevice *)deviceForNodeID:(NSNumber *)nodeID
386+
{
387+
return [self _deviceForNodeID:nodeID createIfNeeded:YES];
388+
}
389+
385390
- (void)removeDevice:(MTRDevice *)device
386391
{
387392
std::lock_guard lock(*self.deviceMapLock);

src/darwin/Framework/CHIP/MTRDeviceController_Internal.h

+1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ NS_ASSUME_NONNULL_BEGIN
107107
#pragma mark - Device-specific data and SDK access
108108
// DeviceController will act as a central repository for this opaque dictionary that MTRDevice manages
109109
- (MTRDevice *)deviceForNodeID:(NSNumber *)nodeID;
110+
- (MTRDevice *)_deviceForNodeID:(NSNumber *)nodeID createIfNeeded:(BOOL)createIfNeeded;
110111
/**
111112
* _setupDeviceForNodeID is a hook expected to be implemented by subclasses to
112113
* actually allocate a device object of the right type.

src/darwin/Framework/CHIP/MTRDeviceController_XPC.mm

+1-1
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ - (oneway void)controller:(NSUUID *)controller controllerConfigurationUpdated:(N
487487
continue;
488488
}
489489

490-
auto * device = static_cast<MTRDevice_XPC *>([self deviceForNodeID:nodeID]);
490+
auto * device = static_cast<MTRDevice_XPC *>([self _deviceForNodeID:nodeID createIfNeeded:NO]);
491491
[device device:nodeID internalStateUpdated:deviceInternalState];
492492
}
493493
}

src/platform/ESP32/ESP32SecureCertDataProvider.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121

2222
#include <lib/core/CHIPEncoding.h>
2323
#include <lib/support/CodeUtils.h>
24+
#include <lib/support/Span.h>
2425
#include <lib/support/logging/CHIPLogging.h>
25-
#include <lib/support/span.h>
2626
#include <platform/ESP32/ESP32SecureCertDataProvider.h>
2727

2828
namespace chip {

src/platform/Linux/BLEManagerImpl.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,8 @@ uint16_t BLEManagerImpl::_NumConnections()
186186

187187
CHIP_ERROR BLEManagerImpl::ConfigureBle(uint32_t aAdapterId, bool aIsCentral)
188188
{
189-
mAdapterId = aAdapterId;
190-
mIsCentral = aIsCentral;
191-
mpBLEAdvUUID = "0xFFF6";
189+
mAdapterId = aAdapterId;
190+
mIsCentral = aIsCentral;
192191
return CHIP_NO_ERROR;
193192
}
194193

@@ -578,7 +577,7 @@ void BLEManagerImpl::DriveBLEState()
578577
// Configure advertising data if it hasn't been done yet.
579578
if (!mFlags.Has(Flags::kAdvertisingConfigured))
580579
{
581-
SuccessOrExit(err = mBLEAdvertisement.Init(mAdapter.get(), mpBLEAdvUUID, mDeviceName));
580+
SuccessOrExit(err = mBLEAdvertisement.Init(mAdapter.get(), Ble::CHIP_BLE_SERVICE_SHORT_UUID_STR, mDeviceName));
582581
mFlags.Set(Flags::kAdvertisingConfigured);
583582
}
584583

src/platform/Linux/BLEManagerImpl.h

-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ class BLEManagerImpl final : public BLEManager,
199199
BluezEndpoint mEndpoint{ mBluezObjectManager };
200200

201201
BluezAdvertisement mBLEAdvertisement{ mEndpoint };
202-
const char * mpBLEAdvUUID = nullptr;
203202

204203
ChipDeviceScanner mDeviceScanner{ mBluezObjectManager };
205204
BLEScanConfig mBLEScanConfig;

src/platform/Linux/bluez/BluezObjectManager.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ CHIP_ERROR BluezObjectManager::Init()
6262

6363
void BluezObjectManager::Shutdown()
6464
{
65+
// If the D-Bus connection or the object manager are not initialized,
66+
// there is nothing to shutdown. This check prevents unnecessary call
67+
// to the GLibMatterContextInvokeSync function.
68+
VerifyOrReturn(mConnection || mObjectManager);
69+
6570
// Run endpoint cleanup on the CHIPoBluez thread. This is necessary because the
6671
// cleanup function releases the D-Bus manager client object, which handles D-Bus
6772
// signals. Otherwise, we will face race condition when the D-Bus signal is in

src/platform/NuttX/BLEManagerImpl.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#include <type_traits>
3636
#include <utility>
3737

38-
#include <ble/CHIPBleServiceData.h>
38+
#include <ble/Ble.h>
3939
#include <lib/support/CodeUtils.h>
4040
#include <lib/support/SafeInt.h>
4141
#include <platform/CHIPDeviceLayer.h>
@@ -197,9 +197,8 @@ uint16_t BLEManagerImpl::_NumConnections()
197197

198198
CHIP_ERROR BLEManagerImpl::ConfigureBle(uint32_t aAdapterId, bool aIsCentral)
199199
{
200-
mAdapterId = aAdapterId;
201-
mIsCentral = aIsCentral;
202-
mpBLEAdvUUID = "0xFFF6";
200+
mAdapterId = aAdapterId;
201+
mIsCentral = aIsCentral;
203202
return CHIP_NO_ERROR;
204203
}
205204

@@ -587,7 +586,7 @@ void BLEManagerImpl::DriveBLEState()
587586
// Configure advertising data if it hasn't been done yet.
588587
if (!mFlags.Has(Flags::kAdvertisingConfigured))
589588
{
590-
SuccessOrExit(err = mBLEAdvertisement.Init(mEndpoint, mpBLEAdvUUID, mDeviceName));
589+
SuccessOrExit(err = mBLEAdvertisement.Init(mEndpoint, Ble::CHIP_BLE_SERVICE_SHORT_UUID_STR, mDeviceName));
591590
mFlags.Set(Flags::kAdvertisingConfigured);
592591
}
593592

src/platform/NuttX/BLEManagerImpl.h

-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ class BLEManagerImpl final : public BLEManager,
189189
BluezEndpoint mEndpoint;
190190

191191
BluezAdvertisement mBLEAdvertisement;
192-
const char * mpBLEAdvUUID = nullptr;
193192

194193
ChipDeviceScanner mDeviceScanner;
195194
BLEScanConfig mBLEScanConfig;

0 commit comments

Comments
 (0)