Skip to content

Commit

Permalink
Merge branch 'master' into TC-SC-4.3-python-test
Browse files Browse the repository at this point in the history
  • Loading branch information
raul-marquez-csa authored Nov 21, 2024
2 parents 719c152 + 093aff8 commit 94adc9c
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 15 deletions.
9 changes: 7 additions & 2 deletions src/darwin/Framework/CHIP/MTRDeviceController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -371,17 +371,22 @@ - (MTRDevice *)_setupDeviceForNodeID:(NSNumber *)nodeID prefetchedClusterData:(N
return [[MTRDevice alloc] initForSubclassesWithNodeID:nodeID controller:self];
}

- (MTRDevice *)deviceForNodeID:(NSNumber *)nodeID
- (MTRDevice *)_deviceForNodeID:(NSNumber *)nodeID createIfNeeded:(BOOL)createIfNeeded
{
std::lock_guard lock(*self.deviceMapLock);
MTRDevice * deviceToReturn = [_nodeIDToDeviceMap objectForKey:nodeID];
if (!deviceToReturn) {
if (!deviceToReturn && createIfNeeded) {
deviceToReturn = [self _setupDeviceForNodeID:nodeID prefetchedClusterData:nil];
}

return deviceToReturn;
}

- (MTRDevice *)deviceForNodeID:(NSNumber *)nodeID
{
return [self _deviceForNodeID:nodeID createIfNeeded:YES];
}

- (void)removeDevice:(MTRDevice *)device
{
std::lock_guard lock(*self.deviceMapLock);
Expand Down
1 change: 1 addition & 0 deletions src/darwin/Framework/CHIP/MTRDeviceController_Internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Device-specific data and SDK access
// DeviceController will act as a central repository for this opaque dictionary that MTRDevice manages
- (MTRDevice *)deviceForNodeID:(NSNumber *)nodeID;
- (MTRDevice *)_deviceForNodeID:(NSNumber *)nodeID createIfNeeded:(BOOL)createIfNeeded;
/**
* _setupDeviceForNodeID is a hook expected to be implemented by subclasses to
* actually allocate a device object of the right type.
Expand Down
2 changes: 1 addition & 1 deletion src/darwin/Framework/CHIP/MTRDeviceController_XPC.mm
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ - (oneway void)controller:(NSUUID *)controller controllerConfigurationUpdated:(N
continue;
}

auto * device = static_cast<MTRDevice_XPC *>([self deviceForNodeID:nodeID]);
auto * device = static_cast<MTRDevice_XPC *>([self _deviceForNodeID:nodeID createIfNeeded:NO]);
[device device:nodeID internalStateUpdated:deviceInternalState];
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/platform/ESP32/ESP32SecureCertDataProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

#include <lib/core/CHIPEncoding.h>
#include <lib/support/CodeUtils.h>
#include <lib/support/Span.h>
#include <lib/support/logging/CHIPLogging.h>
#include <lib/support/span.h>
#include <platform/ESP32/ESP32SecureCertDataProvider.h>

namespace chip {
Expand Down
7 changes: 3 additions & 4 deletions src/platform/Linux/BLEManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,8 @@ uint16_t BLEManagerImpl::_NumConnections()

CHIP_ERROR BLEManagerImpl::ConfigureBle(uint32_t aAdapterId, bool aIsCentral)
{
mAdapterId = aAdapterId;
mIsCentral = aIsCentral;
mpBLEAdvUUID = "0xFFF6";
mAdapterId = aAdapterId;
mIsCentral = aIsCentral;
return CHIP_NO_ERROR;
}

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

Expand Down
1 change: 0 additions & 1 deletion src/platform/Linux/BLEManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ class BLEManagerImpl final : public BLEManager,
BluezEndpoint mEndpoint{ mBluezObjectManager };

BluezAdvertisement mBLEAdvertisement{ mEndpoint };
const char * mpBLEAdvUUID = nullptr;

ChipDeviceScanner mDeviceScanner{ mBluezObjectManager };
BLEScanConfig mBLEScanConfig;
Expand Down
5 changes: 5 additions & 0 deletions src/platform/Linux/bluez/BluezObjectManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ CHIP_ERROR BluezObjectManager::Init()

void BluezObjectManager::Shutdown()
{
// If the D-Bus connection or the object manager are not initialized,
// there is nothing to shutdown. This check prevents unnecessary call
// to the GLibMatterContextInvokeSync function.
VerifyOrReturn(mConnection || mObjectManager);

// Run endpoint cleanup on the CHIPoBluez thread. This is necessary because the
// cleanup function releases the D-Bus manager client object, which handles D-Bus
// signals. Otherwise, we will face race condition when the D-Bus signal is in
Expand Down
9 changes: 4 additions & 5 deletions src/platform/NuttX/BLEManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include <type_traits>
#include <utility>

#include <ble/CHIPBleServiceData.h>
#include <ble/Ble.h>
#include <lib/support/CodeUtils.h>
#include <lib/support/SafeInt.h>
#include <platform/CHIPDeviceLayer.h>
Expand Down Expand Up @@ -197,9 +197,8 @@ uint16_t BLEManagerImpl::_NumConnections()

CHIP_ERROR BLEManagerImpl::ConfigureBle(uint32_t aAdapterId, bool aIsCentral)
{
mAdapterId = aAdapterId;
mIsCentral = aIsCentral;
mpBLEAdvUUID = "0xFFF6";
mAdapterId = aAdapterId;
mIsCentral = aIsCentral;
return CHIP_NO_ERROR;
}

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

Expand Down
1 change: 0 additions & 1 deletion src/platform/NuttX/BLEManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ class BLEManagerImpl final : public BLEManager,
BluezEndpoint mEndpoint;

BluezAdvertisement mBLEAdvertisement;
const char * mpBLEAdvUUID = nullptr;

ChipDeviceScanner mDeviceScanner;
BLEScanConfig mBLEScanConfig;
Expand Down

0 comments on commit 94adc9c

Please sign in to comment.