Skip to content

Commit

Permalink
Move fabricIndex property to MTRDeviceController_Concrete. (project-c…
Browse files Browse the repository at this point in the history
…hip#36324)

This doesn't really make sense for non-concrete controllers.

Also removes some unnecessary declarations and includes from
MTRDeviceController_Internal.
  • Loading branch information
bzbarsky-apple authored Oct 31, 2024
1 parent 6a31fc2 commit bc83fc2
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 29 deletions.
6 changes: 0 additions & 6 deletions src/darwin/Framework/CHIP/MTRDeviceController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ - (instancetype)initWithDelegate:(id<MTRDeviceControllerDelegate>)delegate queue
@implementation MTRDeviceController {
os_unfair_lock _underlyingDeviceMapLock;

std::atomic<chip::FabricIndex> _storedFabricIndex;
std::atomic<std::optional<uint64_t>> _storedCompressedFabricID;

// For now, we just ensure that access to _suspended is atomic, but don't
Expand Down Expand Up @@ -503,11 +502,6 @@ - (void)asyncDispatchToMatterQueue:(dispatch_block_t)block errorHandler:(nullabl
errorHandler([MTRError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE]);
}

- (chip::FabricIndex)fabricIndex
{
return _storedFabricIndex;
}

- (nullable NSNumber *)compressedFabricID
{
auto storedValue = _storedCompressedFabricID.load();
Expand Down
5 changes: 5 additions & 0 deletions src/darwin/Framework/CHIP/MTRDeviceController_Concrete.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,11 @@ NS_ASSUME_NONNULL_BEGIN
queue:(dispatch_queue_t)queue
completion:(void (^)(NSURL * _Nullable url, NSError * _Nullable error))completion;

/**
* Will return chip::kUndefinedFabricIndex if we do not have a fabric index.
*/
@property (readonly) chip::FabricIndex fabricIndex;

@end

NS_ASSUME_NONNULL_END
19 changes: 0 additions & 19 deletions src/darwin/Framework/CHIP/MTRDeviceController_Internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
#import "MTRDeviceConnectionBridge.h" // For MTRInternalDeviceConnectionCallback
#import "MTRDeviceController.h"

#include <lib/core/CHIPError.h>
#include <lib/core/DataModelTypes.h>

#import <os/lock.h>

#import "MTRBaseDevice.h"
Expand All @@ -37,11 +34,8 @@
#import "MTRDeviceControllerDelegate.h"
#import "MTRDeviceStorageBehaviorConfiguration.h"

#import <Matter/MTRP256KeypairBridge.h>

#import <Matter/MTRDefines.h>
#import <Matter/MTRDeviceControllerStorageDelegate.h>
#import <Matter/MTRDiagnosticLogsType.h>
#import <Matter/MTROTAProviderDelegate.h>

@class MTRDeviceControllerParameters;
Expand All @@ -52,14 +46,6 @@
@protocol MTRDeviceControllerDelegate;
@class MTRDevice_Concrete;

namespace chip {
class FabricTable;

namespace Controller {
class DeviceCommissioner;
}
} // namespace chip

NS_ASSUME_NONNULL_BEGIN

@interface MTRDeviceController ()
Expand All @@ -74,11 +60,6 @@ NS_ASSUME_NONNULL_BEGIN

#pragma mark - MTRDeviceControllerFactory methods

/**
* Will return chip::kUndefinedFabricIndex if we do not have a fabric index.
*/
@property (readonly) chip::FabricIndex fabricIndex;

/**
* Will return the compressed fabric id of the fabric if the controller is
* running, else nil.
Expand Down
1 change: 1 addition & 0 deletions src/darwin/Framework/CHIP/MTRDeviceController_XPC.mm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#import "MTRDeviceController_Internal.h"
#import "MTRDevice_XPC.h"
#import "MTRDevice_XPC_Internal.h"
#import "MTRError_Internal.h"
#import "MTRLogging_Internal.h"
#import "MTRXPCClientProtocol.h"
#import "MTRXPCServerProtocol.h"
Expand Down
4 changes: 3 additions & 1 deletion src/darwin/Framework/CHIP/MTROTAProviderDelegateBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#import <Matter/MTROTAProviderDelegate.h>

#import "MTRDeviceController_Concrete.h"

#include <app/clusters/ota-provider/ota-provider-delegate.h>

NS_ASSUME_NONNULL_BEGIN
Expand All @@ -35,7 +37,7 @@ class MTROTAProviderDelegateBridge : public chip::app::Clusters::OTAProviderDele

// ControllerShuttingDown must be called on the Matter work queue, since it
// touches Matter objects.
void ControllerShuttingDown(MTRDeviceController * controller);
void ControllerShuttingDown(MTRDeviceController_Concrete * controller);

void HandleQueryImage(
chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
Expand Down
4 changes: 2 additions & 2 deletions src/darwin/Framework/CHIP/MTROTAProviderDelegateBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ CHIP_ERROR Shutdown()
return CHIP_NO_ERROR;
}

void ControllerShuttingDown(MTRDeviceController * controller)
void ControllerShuttingDown(MTRDeviceController_Concrete * controller)
{
assertChipStackLockedByCurrentThread();

Expand Down Expand Up @@ -506,7 +506,7 @@ CHIP_ERROR ConfigureState(chip::FabricIndex fabricIndex, chip::NodeId nodeId)

void MTROTAProviderDelegateBridge::Shutdown() { gOtaSender->Shutdown(); }

void MTROTAProviderDelegateBridge::ControllerShuttingDown(MTRDeviceController * controller)
void MTROTAProviderDelegateBridge::ControllerShuttingDown(MTRDeviceController_Concrete * controller)
{
gOtaSender->ControllerShuttingDown(controller);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#import "MTRConversion.h"
#import "MTRDeviceControllerFactory_Internal.h"
#import "MTRDeviceController_Concrete.h"
#import "MTRDeviceController_Internal.h"
#import "MTRLogging_Internal.h"
#import "NSDataSpanConversion.h"
Expand Down Expand Up @@ -58,7 +59,7 @@
auto * resumptionIDData = AsData(resumptionId);

auto * controllerList = [mFactory getRunningControllers];
for (MTRDeviceController * controller in controllerList) {
for (MTRDeviceController_Concrete * controller in controllerList) {
FabricIndex fabricIndex = controller.fabricIndex;
if (!IsValidFabricIndex(fabricIndex)) {
// This controller is not sufficiently "running"; it does not have a
Expand Down

0 comments on commit bc83fc2

Please sign in to comment.