Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Darwin: Namespace common class names #33459

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/controller/python/chip/ble/darwin/Scanning.mm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <ble/Ble.h>
#include <lib/support/CHIPMem.h>
#include <lib/support/logging/CHIPLogging.h>
#include <platform/Darwin/UUIDHelper.h>
#include <platform/Darwin/MTRUUIDHelper.h>

#import <CoreBluetooth/CoreBluetooth.h>

Expand Down Expand Up @@ -45,7 +45,7 @@ - (id)initWithContext:(PyObject *)context
{
self = [super init];
if (self) {
self.shortServiceUUID = [UUIDHelper GetShortestServiceUUID:&chip::Ble::CHIP_BLE_SVC_ID];
self.shortServiceUUID = [MTRUUIDHelper GetShortestServiceUUID:&chip::Ble::CHIP_BLE_SVC_ID];

_workQueue = dispatch_queue_create("com.chip.python.ble.work_queue", DISPATCH_QUEUE_SERIAL);
_timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, _workQueue);
Expand Down
72 changes: 36 additions & 36 deletions src/darwin/Framework/CHIP/MTRDiagnosticLogsDownloader.mm
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

NS_ASSUME_NONNULL_BEGIN

@interface Download : NSObject
@interface MTRDownload : NSObject
@property (nonatomic) NSString * fileDesignator;
@property (nonatomic) NSNumber * fabricIndex;
@property (nonatomic) NSNumber * nodeID;
Expand All @@ -55,7 +55,7 @@ - (instancetype)initWithType:(MTRDiagnosticLogType)type
nodeID:(NSNumber *)nodeID
queue:(dispatch_queue_t)queue
completion:(void (^)(NSURL * _Nullable url, NSError * _Nullable error))completion
done:(void (^)(Download * finishedDownload))done;
done:(void (^)(MTRDownload * finishedDownload))done;

- (void)writeToFile:(NSData *)data error:(out NSError **)error;

Expand All @@ -69,24 +69,24 @@ - (void)success;
- (void)failure:(NSError * _Nullable)error;
@end

@interface Downloads : NSObject
@property (nonatomic, strong) NSMutableArray<Download *> * downloads;
@interface MTRDownloads : NSObject
@property (nonatomic, strong) NSMutableArray<MTRDownload *> * downloads;

- (Download * _Nullable)get:(NSString *)fileDesignator
fabricIndex:(NSNumber *)fabricIndex
nodeID:(NSNumber *)nodeID;
- (MTRDownload * _Nullable)get:(NSString *)fileDesignator
fabricIndex:(NSNumber *)fabricIndex
nodeID:(NSNumber *)nodeID;

- (Download * _Nullable)add:(MTRDiagnosticLogType)type
fabricIndex:(NSNumber *)fabricIndex
nodeID:(NSNumber *)nodeID
queue:(dispatch_queue_t)queue
completion:(void (^)(NSURL * _Nullable url, NSError * _Nullable error))completion
done:(void (^)(Download * finishedDownload))done;
- (MTRDownload * _Nullable)add:(MTRDiagnosticLogType)type
fabricIndex:(NSNumber *)fabricIndex
nodeID:(NSNumber *)nodeID
queue:(dispatch_queue_t)queue
completion:(void (^)(NSURL * _Nullable url, NSError * _Nullable error))completion
done:(void (^)(MTRDownload * finishedDownload))done;
@end

@interface MTRDiagnosticLogsDownloader ()
@property (readonly) DiagnosticLogsDownloaderBridge * bridge;
@property (nonatomic, strong) Downloads * downloads;
@property (nonatomic, strong) MTRDownloads * downloads;

/**
* Notify the delegate when a BDX Session starts for some logs.
Expand Down Expand Up @@ -134,21 +134,21 @@ - (void)handleBDXTransferSessionEndForFileDesignator:(NSString *)fileDesignator
CHIP_ERROR OnTransferEnd(chip::bdx::BDXTransferProxy * transfer, CHIP_ERROR error) override;
CHIP_ERROR OnTransferData(chip::bdx::BDXTransferProxy * transfer, const chip::ByteSpan & data) override;

CHIP_ERROR StartBDXTransferTimeout(Download * download, uint16_t timeoutInSeconds);
void CancelBDXTransferTimeout(Download * download);
CHIP_ERROR StartBDXTransferTimeout(MTRDownload * download, uint16_t timeoutInSeconds);
void CancelBDXTransferTimeout(MTRDownload * download);

private:
static void OnTransferTimeout(chip::System::Layer * layer, void * context);
MTRDiagnosticLogsDownloader * __weak mDelegate;
};

@implementation Download
@implementation MTRDownload
- (instancetype)initWithType:(MTRDiagnosticLogType)type
fabricIndex:(NSNumber *)fabricIndex
nodeID:(NSNumber *)nodeID
queue:(dispatch_queue_t)queue
completion:(void (^)(NSURL * _Nullable url, NSError * _Nullable error))completion
done:(void (^)(Download * finishedDownload))done;
done:(void (^)(MTRDownload * finishedDownload))done;
{
self = [super init];
if (self) {
Expand All @@ -158,7 +158,7 @@ - (instancetype)initWithType:(MTRDiagnosticLogType)type
__weak typeof(self) weakSelf = self;
auto bdxTransferDone = ^(NSError * bdxError) {
dispatch_async(queue, ^{
Download * strongSelf = weakSelf;
MTRDownload * strongSelf = weakSelf;
if (strongSelf) {
// If a fileHandle exists, it means that the BDX session has been initiated and a file has
// been created to host the data of the session. So even if there is an error there may be some
Expand Down Expand Up @@ -303,7 +303,7 @@ - (NSString *)_toTypeString:(MTRDiagnosticLogType)type

@end

@implementation Downloads
@implementation MTRDownloads
- (instancetype)init
{
if (self = [super init]) {
Expand All @@ -315,15 +315,15 @@ - (instancetype)init
- (void)dealloc
{
auto error = [MTRError errorForCHIPErrorCode:CHIP_ERROR_INTERNAL];
for (Download * download in _downloads) {
for (MTRDownload * download in _downloads) {
[download failure:error];
}
_downloads = nil;
}

- (Download * _Nullable)get:(NSString *)fileDesignator fabricIndex:(NSNumber *)fabricIndex nodeID:(NSNumber *)nodeID
- (MTRDownload * _Nullable)get:(NSString *)fileDesignator fabricIndex:(NSNumber *)fabricIndex nodeID:(NSNumber *)nodeID
{
for (Download * download in _downloads) {
for (MTRDownload * download in _downloads) {
if ([download matches:fileDesignator fabricIndex:fabricIndex nodeID:nodeID]) {
return download;
}
Expand All @@ -332,23 +332,23 @@ - (Download * _Nullable)get:(NSString *)fileDesignator fabricIndex:(NSNumber *)f
return nil;
}

- (Download * _Nullable)add:(MTRDiagnosticLogType)type
fabricIndex:(NSNumber *)fabricIndex
nodeID:(NSNumber *)nodeID
queue:(dispatch_queue_t)queue
completion:(void (^)(NSURL * _Nullable url, NSError * _Nullable error))completion
done:(void (^)(Download * finishedDownload))done
- (MTRDownload * _Nullable)add:(MTRDiagnosticLogType)type
fabricIndex:(NSNumber *)fabricIndex
nodeID:(NSNumber *)nodeID
queue:(dispatch_queue_t)queue
completion:(void (^)(NSURL * _Nullable url, NSError * _Nullable error))completion
done:(void (^)(MTRDownload * finishedDownload))done
{
assertChipStackLockedByCurrentThread();

auto download = [[Download alloc] initWithType:type fabricIndex:fabricIndex nodeID:nodeID queue:queue completion:completion done:done];
auto download = [[MTRDownload alloc] initWithType:type fabricIndex:fabricIndex nodeID:nodeID queue:queue completion:completion done:done];
VerifyOrReturnValue(nil != download, nil);

[_downloads addObject:download];
return download;
}

- (void)remove:(Download *)download
- (void)remove:(MTRDownload *)download
{
assertChipStackLockedByCurrentThread();

Expand All @@ -362,7 +362,7 @@ - (instancetype)init
assertChipStackLockedByCurrentThread();

if (self = [super init]) {
_downloads = [[Downloads alloc] init];
_downloads = [[MTRDownloads alloc] init];
_bridge = new DiagnosticLogsDownloaderBridge(self);
if (_bridge == nullptr) {
MTR_LOG_ERROR("Error: %@", kErrorInitDiagnosticLogsDownloader);
Expand Down Expand Up @@ -406,7 +406,7 @@ - (void)downloadLogFromNodeWithID:(NSNumber *)nodeID
}

// This block is always called when a download is finished.
auto done = ^(Download * finishedDownload) {
auto done = ^(MTRDownload * finishedDownload) {
[controller asyncDispatchToMatterQueue:^() {
[self->_downloads remove:finishedDownload];

Expand Down Expand Up @@ -593,13 +593,13 @@ - (void)handleBDXTransferSessionEndForFileDesignator:(NSString *)fileDesignator
return CHIP_NO_ERROR;
}

CHIP_ERROR DiagnosticLogsDownloaderBridge::StartBDXTransferTimeout(Download * download, uint16_t timeoutInSeconds)
CHIP_ERROR DiagnosticLogsDownloaderBridge::StartBDXTransferTimeout(MTRDownload * download, uint16_t timeoutInSeconds)
{
assertChipStackLockedByCurrentThread();
return chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds16(timeoutInSeconds), OnTransferTimeout, (__bridge void *) download);
}

void DiagnosticLogsDownloaderBridge::CancelBDXTransferTimeout(Download * download)
void DiagnosticLogsDownloaderBridge::CancelBDXTransferTimeout(MTRDownload * download)
{
assertChipStackLockedByCurrentThread();
chip::DeviceLayer::SystemLayer().CancelTimer(OnTransferTimeout, (__bridge void *) download);
Expand All @@ -609,7 +609,7 @@ - (void)handleBDXTransferSessionEndForFileDesignator:(NSString *)fileDesignator
{
assertChipStackLockedByCurrentThread();

auto * download = (__bridge Download *) context;
auto * download = (__bridge MTRDownload *) context;
VerifyOrReturn(nil != download);

// If there is no abortHandler, it means that the BDX transfer has not started.
Expand Down
4 changes: 2 additions & 2 deletions src/platform/Darwin/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ static_library("Darwin") {
"BleConnectionDelegateImpl.mm",
"BlePlatformDelegate.h",
"BlePlatformDelegateImpl.mm",
"UUIDHelper.h",
"UUIDHelperImpl.mm",
"MTRUUIDHelper.h",
"MTRUUIDHelperImpl.mm",
]
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/platform/Darwin/BleConnectionDelegateImpl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
#include <setup_payload/SetupPayload.h>
#include <tracing/metric_event.h>

#import "MTRUUIDHelper.h"
#import "PlatformMetricKeys.h"
#import "UUIDHelper.h"

using namespace chip::Ble;
using namespace chip::DeviceLayer;
Expand Down Expand Up @@ -245,7 +245,7 @@ - (id)initWithQueue:(dispatch_queue_t)queue
{
self = [super init];
if (self) {
self.shortServiceUUID = [UUIDHelper GetShortestServiceUUID:&chip::Ble::CHIP_BLE_SVC_ID];
self.shortServiceUUID = [MTRUUIDHelper GetShortestServiceUUID:&chip::Ble::CHIP_BLE_SVC_ID];
_chipWorkQueue = chip::DeviceLayer::PlatformMgrImpl().GetWorkQueue();
_workQueue = queue;
_centralManager = [CBCentralManager alloc];
Expand Down
8 changes: 4 additions & 4 deletions src/platform/Darwin/BlePlatformDelegateImpl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <lib/support/logging/CHIPLogging.h>
#include <platform/Darwin/BlePlatformDelegate.h>

#import "UUIDHelper.h"
#import "MTRUUIDHelper.h"

using namespace ::chip;
using namespace ::chip::Ble;
Expand All @@ -47,7 +47,7 @@
return found;
}

CBUUID * serviceId = [UUIDHelper GetShortestServiceUUID:svcId];
CBUUID * serviceId = [MTRUUIDHelper GetShortestServiceUUID:svcId];
CBUUID * characteristicId = [CBUUID UUIDWithData:[NSData dataWithBytes:charId->bytes length:sizeof(charId->bytes)]];
CBPeripheral * peripheral = (__bridge CBPeripheral *) connObj;

Expand All @@ -74,7 +74,7 @@
return found;
}

CBUUID * serviceId = [UUIDHelper GetShortestServiceUUID:svcId];
CBUUID * serviceId = [MTRUUIDHelper GetShortestServiceUUID:svcId];
CBUUID * characteristicId = characteristicId = [CBUUID UUIDWithData:[NSData dataWithBytes:charId->bytes
length:sizeof(charId->bytes)]];
CBPeripheral * peripheral = (__bridge CBPeripheral *) connObj;
Expand Down Expand Up @@ -131,7 +131,7 @@
return found;
}

CBUUID * serviceId = [UUIDHelper GetShortestServiceUUID:svcId];
CBUUID * serviceId = [MTRUUIDHelper GetShortestServiceUUID:svcId];
CBUUID * characteristicId = [CBUUID UUIDWithData:[NSData dataWithBytes:charId->bytes length:sizeof(charId->bytes)]];
NSData * data = [NSData dataWithBytes:pBuf->Start() length:pBuf->DataLength()];
CBPeripheral * peripheral = (__bridge CBPeripheral *) connObj;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@

#import <CoreBluetooth/CoreBluetooth.h>

@interface UUIDHelper : NSObject
@interface MTRUUIDHelper : NSObject
+ (CBUUID *)GetShortestServiceUUID:(const chip::Ble::ChipBleUUID *)svcId;
@end
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
#error This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
#endif

#import "UUIDHelper.h"
#import "MTRUUIDHelper.h"

@implementation UUIDHelper
@implementation MTRUUIDHelper

+ (CBUUID *)GetShortestServiceUUID:(const chip::Ble::ChipBleUUID *)svcId
{
Expand Down
Loading