Skip to content

Commit 50e3e11

Browse files
Simplify UUID handling, CBUUID does most of it already
1 parent 915f426 commit 50e3e11

File tree

9 files changed

+130
-221
lines changed

9 files changed

+130
-221
lines changed

src/controller/python/chip/ble/darwin/Scanning.mm

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include <ble/Ble.h>
22
#include <lib/support/CHIPMem.h>
33
#include <lib/support/logging/CHIPLogging.h>
4-
#include <platform/Darwin/MTRUUIDHelper.h>
4+
#include <platform/Darwin/BleUtils.h>
55

66
#import <CoreBluetooth/CoreBluetooth.h>
77

@@ -45,7 +45,7 @@ - (id)initWithContext:(PyObject *)context
4545
{
4646
self = [super init];
4747
if (self) {
48-
self.shortServiceUUID = [MTRUUIDHelper GetShortestServiceUUID:&chip::Ble::CHIP_BLE_SVC_ID];
48+
self.shortServiceUUID = chip::DeviceLayer::Internal::CBUUIDFromBleUUID(chip::Ble::CHIP_BLE_SVC_ID);
4949

5050
_workQueue = dispatch_queue_create("com.chip.python.ble.work_queue", DISPATCH_QUEUE_SERIAL);
5151
_timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, _workQueue);
@@ -78,7 +78,7 @@ - (void)centralManager:(CBCentralManager *)central
7878

7979
NSDictionary * servicesData = [advertisementData objectForKey:CBAdvertisementDataServiceDataKey];
8080
for (CBUUID * serviceUUID in servicesData) {
81-
if (![serviceUUID.data isEqualToData:_shortServiceUUID.data]) {
81+
if (![serviceUUID isEqualTo:_shortServiceUUID]) {
8282
continue;
8383
}
8484
NSData * serviceData = [servicesData objectForKey:serviceUUID];

src/darwin/Framework/Matter.xcodeproj/project.pbxproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,8 @@
656656
3DA1A3532ABAB3B4004F0BB9 /* MTRAsyncWorkQueue.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRAsyncWorkQueue.mm; sourceTree = "<group>"; };
657657
3DA1A3572ABABF69004F0BB9 /* MTRAsyncWorkQueueTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MTRAsyncWorkQueueTests.m; sourceTree = "<group>"; };
658658
3DB9DAE42D67EE5A00704FAB /* MTRBleTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MTRBleTests.m; sourceTree = "<group>"; };
659+
3DB9DAE92D754C7200704FAB /* BleUtils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BleUtils.h; sourceTree = "<group>"; };
660+
3DB9DAEA2D754C7200704FAB /* BleUtils.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = BleUtils.mm; sourceTree = "<group>"; };
659661
3DECCB6D29347D2C00585AEC /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/System/Library/Frameworks/Security.framework; sourceTree = DEVELOPER_DIR; };
660662
3DECCB6F2934AC1C00585AEC /* MTRLogging.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MTRLogging.h; sourceTree = "<group>"; };
661663
3DECCB712934AFE200585AEC /* MTRLogging.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRLogging.mm; sourceTree = "<group>"; };
@@ -698,8 +700,6 @@
698700
3DF5218B2D5E90BE008F8E52 /* Logging.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = Logging.mm; sourceTree = "<group>"; };
699701
3DF5218C2D5E90BE008F8E52 /* MdnsError.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MdnsError.h; sourceTree = "<group>"; };
700702
3DF5218D2D5E90BE008F8E52 /* MdnsError.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MdnsError.cpp; sourceTree = "<group>"; };
701-
3DF5218E2D5E90BE008F8E52 /* MTRUUIDHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MTRUUIDHelper.h; sourceTree = "<group>"; };
702-
3DF5218F2D5E90BE008F8E52 /* MTRUUIDHelperImpl.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRUUIDHelperImpl.mm; sourceTree = "<group>"; };
703703
3DF521902D5E90BE008F8E52 /* NetworkCommissioningDriver.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NetworkCommissioningDriver.h; sourceTree = "<group>"; };
704704
3DF521912D5E90BE008F8E52 /* PlatformManagerImpl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PlatformManagerImpl.h; sourceTree = "<group>"; };
705705
3DF521922D5E90BE008F8E52 /* PlatformManagerImpl.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformManagerImpl.cpp; sourceTree = "<group>"; };
@@ -1415,6 +1415,8 @@
14151415
3DF5216F2D5E90BE008F8E52 /* BlePlatformDelegateImpl.h */,
14161416
3DF521702D5E90BE008F8E52 /* BlePlatformDelegateImpl.mm */,
14171417
3DF521712D5E90BE008F8E52 /* BleScannerDelegate.h */,
1418+
3DB9DAE92D754C7200704FAB /* BleUtils.h */,
1419+
3DB9DAEA2D754C7200704FAB /* BleUtils.mm */,
14181420
3DF521732D5E90BE008F8E52 /* CHIPDevicePlatformConfig.h */,
14191421
3DF521742D5E90BE008F8E52 /* CHIPDevicePlatformEvent.h */,
14201422
3DF521752D5E90BE008F8E52 /* CHIPPlatformConfig.h */,
@@ -1442,8 +1444,6 @@
14421444
3DF5218B2D5E90BE008F8E52 /* Logging.mm */,
14431445
3DF5218C2D5E90BE008F8E52 /* MdnsError.h */,
14441446
3DF5218D2D5E90BE008F8E52 /* MdnsError.cpp */,
1445-
3DF5218E2D5E90BE008F8E52 /* MTRUUIDHelper.h */,
1446-
3DF5218F2D5E90BE008F8E52 /* MTRUUIDHelperImpl.mm */,
14471447
3DF521902D5E90BE008F8E52 /* NetworkCommissioningDriver.h */,
14481448
3DF521912D5E90BE008F8E52 /* PlatformManagerImpl.h */,
14491449
3DF521922D5E90BE008F8E52 /* PlatformManagerImpl.cpp */,

src/platform/Darwin/BUILD.gn

+1-2
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ static_library("Darwin") {
131131
"BlePlatformDelegateImpl.h",
132132
"BlePlatformDelegateImpl.mm",
133133
"BleUtils.h",
134-
"MTRUUIDHelper.h",
135-
"MTRUUIDHelperImpl.mm",
134+
"BleUtils.mm",
136135
]
137136
}
138137
}

src/platform/Darwin/BleConnectionDelegateImpl.mm

+15-74
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
#include <setup_payload/SetupPayload.h>
3636
#include <tracing/metric_event.h>
3737

38-
#import "MTRUUIDHelper.h"
38+
#import <CoreBluetooth/CoreBluetooth.h>
39+
3940
#import "PlatformMetricKeys.h"
4041

4142
using namespace chip::Ble;
@@ -60,7 +61,6 @@ @interface BleConnection : NSObject <CBCentralManagerDelegate, CBPeripheralDeleg
6061
@property (strong, nonatomic) dispatch_queue_t workQueue; // the CHIP work queue
6162
@property (strong, nonatomic) CBCentralManager * centralManager;
6263
@property (strong, nonatomic) CBPeripheral * peripheral;
63-
@property (strong, nonatomic) CBUUID * shortServiceUUID;
6464
@property (nonatomic, readonly, nullable) dispatch_source_t timer;
6565
@property (nonatomic, readonly) BleConnectionMode currentMode;
6666
@property (strong, nonatomic) NSMutableDictionary<CBPeripheral *, NSDictionary *> * cachedPeripherals;
@@ -212,13 +212,15 @@ @interface BleConnection ()
212212
@property (nonatomic, readonly) int32_t totalDevicesRemoved;
213213
@end
214214

215-
@implementation BleConnection
215+
@implementation BleConnection {
216+
CBUUID * _chipServiceUUID;
217+
}
216218

217219
- (instancetype)init
218220
{
219221
self = [super init];
220222
if (self) {
221-
self.shortServiceUUID = [MTRUUIDHelper GetShortestServiceUUID:&chip::Ble::CHIP_BLE_SVC_ID];
223+
_chipServiceUUID = CBUUIDFromBleUUID(chip::Ble::CHIP_BLE_SVC_ID);
222224
_workQueue = chip::DeviceLayer::PlatformMgrImpl().GetWorkQueue();
223225
_centralManager = [CBCentralManager alloc];
224226
_found = false;
@@ -338,15 +340,7 @@ - (void)centralManager:(CBCentralManager *)central
338340
advertisementData:(NSDictionary *)advertisementData
339341
RSSI:(NSNumber *)RSSI
340342
{
341-
NSDictionary * servicesData = [advertisementData objectForKey:CBAdvertisementDataServiceDataKey];
342-
NSData * serviceData;
343-
for (CBUUID * serviceUUID in servicesData) {
344-
if ([serviceUUID.data isEqualToData:_shortServiceUUID.data]) {
345-
serviceData = [servicesData objectForKey:serviceUUID];
346-
break;
347-
}
348-
}
349-
343+
NSData * serviceData = advertisementData[CBAdvertisementDataServiceDataKey][_chipServiceUUID];
350344
if (!serviceData) {
351345
return;
352346
}
@@ -431,7 +425,7 @@ - (void)peripheral:(CBPeripheral *)peripheral didDiscoverServices:(NSError *)err
431425
MATTER_LOG_METRIC_END(kMetricBLEDiscoveredServices, CHIP_ERROR(chip::ChipError::Range::kOS, static_cast<uint32_t>(error.code)));
432426

433427
for (CBService * service in peripheral.services) {
434-
if ([service.UUID.data isEqualToData:_shortServiceUUID.data] && !self.found) {
428+
if ([service.UUID isEqual:_chipServiceUUID] && !self.found) {
435429
MATTER_LOG_METRIC_BEGIN(kMetricBLEDiscoveredCharacteristics);
436430
[peripheral discoverCharacteristics:nil forService:service];
437431
self.found = true;
@@ -464,9 +458,8 @@ - (void)peripheral:(CBPeripheral *)peripheral
464458
error:(NSError *)error
465459
{
466460
if (nil == error) {
467-
chip::Ble::ChipBleUUID svcId;
468-
chip::Ble::ChipBleUUID charId;
469-
[BleConnection fillServiceWithCharacteristicUuids:characteristic svcId:&svcId charId:&charId];
461+
ChipBleUUID svcId = BleUUIDFromCBUUD(characteristic.service.UUID);
462+
ChipBleUUID charId = BleUUIDFromCBUUD(characteristic.UUID);
470463
_mBleLayer->HandleWriteConfirmation(BleConnObjectFromCBPeripheral(peripheral), &svcId, &charId);
471464
} else {
472465
ChipLogError(
@@ -483,10 +476,8 @@ - (void)peripheral:(CBPeripheral *)peripheral
483476
bool isNotifying = characteristic.isNotifying;
484477

485478
if (nil == error) {
486-
chip::Ble::ChipBleUUID svcId;
487-
chip::Ble::ChipBleUUID charId;
488-
[BleConnection fillServiceWithCharacteristicUuids:characteristic svcId:&svcId charId:&charId];
489-
479+
ChipBleUUID svcId = BleUUIDFromCBUUD(characteristic.service.UUID);
480+
ChipBleUUID charId = BleUUIDFromCBUUD(characteristic.UUID);
490481
if (isNotifying) {
491482
_mBleLayer->HandleSubscribeComplete(BleConnObjectFromCBPeripheral(peripheral), &svcId, &charId);
492483
} else {
@@ -513,9 +504,8 @@ - (void)peripheral:(CBPeripheral *)peripheral
513504
error:(NSError *)error
514505
{
515506
if (nil == error) {
516-
chip::Ble::ChipBleUUID svcId;
517-
chip::Ble::ChipBleUUID charId;
518-
[BleConnection fillServiceWithCharacteristicUuids:characteristic svcId:&svcId charId:&charId];
507+
ChipBleUUID svcId = BleUUIDFromCBUUD(characteristic.service.UUID);
508+
ChipBleUUID charId = BleUUIDFromCBUUD(characteristic.UUID);
519509
auto * value = characteristic.value; // read immediately before dispatching
520510

521511
// build a inet buffer from the rxEv and send to blelayer.
@@ -603,7 +593,7 @@ - (void)startScanning
603593
[self _resetCounters];
604594

605595
auto scanOptions = @{ CBCentralManagerScanOptionAllowDuplicatesKey : @YES };
606-
[_centralManager scanForPeripheralsWithServices:@[ _shortServiceUUID ] options:scanOptions];
596+
[_centralManager scanForPeripheralsWithServices:@[ _chipServiceUUID ] options:scanOptions];
607597
}
608598

609599
- (void)stopScanning
@@ -782,55 +772,6 @@ - (void)removePeripheralsFromCache
782772
}
783773
}
784774

785-
/**
786-
* private static method to copy service and characteristic UUIDs from CBCharacteristic to a pair of ChipBleUUID objects.
787-
* this is used in calls into Chip layer to decouple it from CoreBluetooth
788-
*
789-
* @param[in] characteristic the source characteristic
790-
* @param[in] svcId the destination service UUID
791-
* @param[in] charId the destination characteristic UUID
792-
*
793-
*/
794-
+ (void)fillServiceWithCharacteristicUuids:(CBCharacteristic *)characteristic
795-
svcId:(chip::Ble::ChipBleUUID *)svcId
796-
charId:(chip::Ble::ChipBleUUID *)charId
797-
{
798-
static const size_t FullUUIDLength = 16;
799-
if ((FullUUIDLength != sizeof(charId->bytes)) || (FullUUIDLength != sizeof(svcId->bytes))
800-
|| (FullUUIDLength != characteristic.UUID.data.length)) {
801-
// we're dead. we expect the data length to be the same (16-byte) across the board
802-
ChipLogError(Ble, "UUID of characteristic is incompatible");
803-
return;
804-
}
805-
806-
memcpy(charId->bytes, characteristic.UUID.data.bytes, sizeof(charId->bytes));
807-
memset(svcId->bytes, 0, sizeof(svcId->bytes));
808-
809-
// Expand service UUID back to 16-byte long as that's what the BLE Layer expects
810-
// this is a buffer pre-filled with BLE service UUID Base
811-
// byte 0 to 3 are reserved for shorter versions of BLE service UUIDs
812-
// For 4-byte service UUIDs, all bytes from 0 to 3 are used
813-
// For 2-byte service UUIDs, byte 0 and 1 shall be 0
814-
uint8_t serviceFullUUID[FullUUIDLength]
815-
= { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB };
816-
817-
switch (characteristic.service.UUID.data.length) {
818-
case 2:
819-
// copy the 2-byte service UUID onto the right offset
820-
memcpy(serviceFullUUID + 2, characteristic.service.UUID.data.bytes, 2);
821-
break;
822-
case 4:
823-
// flow through
824-
case 16:
825-
memcpy(serviceFullUUID, characteristic.service.UUID.data.bytes, characteristic.service.UUID.data.length);
826-
break;
827-
default:
828-
// we're dead. we expect the data length to be the same (16-byte) across the board
829-
ChipLogError(Ble, "Service UUIDs are incompatible");
830-
}
831-
memcpy(svcId->bytes, serviceFullUUID, sizeof(svcId->bytes));
832-
}
833-
834775
- (void)setBleLayer:(chip::Ble::BleLayer *)bleLayer
835776
{
836777
_mBleLayer = bleLayer;

src/platform/Darwin/BlePlatformDelegateImpl.mm

+33-68
Original file line numberDiff line numberDiff line change
@@ -30,68 +30,53 @@
3030
#include <platform/Darwin/BlePlatformDelegateImpl.h>
3131
#include <platform/Darwin/BleUtils.h>
3232

33-
#import "MTRUUIDHelper.h"
33+
#import <CoreBluetooth/CoreBluetooth.h>
3434

3535
using namespace chip::Ble;
3636
using chip::System::PacketBufferHandle;
3737

3838
namespace chip {
3939
namespace DeviceLayer {
4040
namespace Internal {
41-
CHIP_ERROR BlePlatformDelegateImpl::SubscribeCharacteristic(
42-
BLE_CONNECTION_OBJECT connObj, const ChipBleUUID * svcId, const ChipBleUUID * charId)
43-
{
44-
CHIP_ERROR err = BLE_ERROR_GATT_SUBSCRIBE_FAILED;
45-
46-
if (nullptr == svcId || nullptr == charId) {
47-
return err;
48-
}
49-
50-
CBUUID * serviceId = [MTRUUIDHelper GetShortestServiceUUID:svcId];
51-
CBUUID * characteristicId = [CBUUID UUIDWithData:[NSData dataWithBytes:charId->bytes length:sizeof(charId->bytes)]];
52-
CBPeripheral * peripheral = CBPeripheralFromBleConnObject(connObj);
5341

54-
for (CBService * service in peripheral.services) {
55-
if ([service.UUID.data isEqualToData:serviceId.data]) {
56-
for (CBCharacteristic * characteristic in service.characteristics) {
57-
if ([characteristic.UUID.data isEqualToData:characteristicId.data]) {
58-
err = CHIP_NO_ERROR;
59-
[peripheral setNotifyValue:true forCharacteristic:characteristic];
60-
break;
42+
namespace {
43+
CBCharacteristic * FindCharacteristic(CBPeripheral * peripheral, const ChipBleUUID * svcId, const ChipBleUUID * charId)
44+
{
45+
VerifyOrReturnValue(svcId != nullptr && charId != nullptr, nil);
46+
CBUUID * cbSvcId = CBUUIDFromBleUUID(*svcId);
47+
for (CBService * service in peripheral.services) {
48+
if ([service.UUID isEqual:cbSvcId]) {
49+
CBUUID * cbCharId = CBUUIDFromBleUUID(*charId);
50+
for (CBCharacteristic * characteristic in service.characteristics) {
51+
if ([characteristic.UUID isEqual:cbCharId]) {
52+
return characteristic;
53+
}
6154
}
55+
break;
6256
}
6357
}
58+
return nil;
6459
}
60+
}
6561

66-
return err;
62+
CHIP_ERROR BlePlatformDelegateImpl::SubscribeCharacteristic(
63+
BLE_CONNECTION_OBJECT connObj, const ChipBleUUID * svcId, const ChipBleUUID * charId)
64+
{
65+
CBPeripheral * peripheral = CBPeripheralFromBleConnObject(connObj);
66+
CBCharacteristic * characteristic = FindCharacteristic(peripheral, svcId, charId);
67+
VerifyOrReturnError(characteristic != nil, BLE_ERROR_GATT_SUBSCRIBE_FAILED);
68+
[peripheral setNotifyValue:YES forCharacteristic:characteristic];
69+
return CHIP_NO_ERROR;
6770
}
6871

6972
CHIP_ERROR BlePlatformDelegateImpl::UnsubscribeCharacteristic(
7073
BLE_CONNECTION_OBJECT connObj, const ChipBleUUID * svcId, const ChipBleUUID * charId)
7174
{
72-
CHIP_ERROR err = BLE_ERROR_GATT_UNSUBSCRIBE_FAILED;
73-
if (nullptr == svcId || nullptr == charId) {
74-
return err;
75-
}
76-
77-
CBUUID * serviceId = [MTRUUIDHelper GetShortestServiceUUID:svcId];
78-
CBUUID * characteristicId = characteristicId = [CBUUID UUIDWithData:[NSData dataWithBytes:charId->bytes
79-
length:sizeof(charId->bytes)]];
8075
CBPeripheral * peripheral = CBPeripheralFromBleConnObject(connObj);
81-
82-
for (CBService * service in peripheral.services) {
83-
if ([service.UUID.data isEqualToData:serviceId.data]) {
84-
for (CBCharacteristic * characteristic in service.characteristics) {
85-
if ([characteristic.UUID.data isEqualToData:characteristicId.data]) {
86-
err = CHIP_NO_ERROR;
87-
[peripheral setNotifyValue:false forCharacteristic:characteristic];
88-
break;
89-
}
90-
}
91-
}
92-
}
93-
94-
return err;
76+
CBCharacteristic * characteristic = FindCharacteristic(peripheral, svcId, charId);
77+
VerifyOrReturnError(characteristic != nil, BLE_ERROR_GATT_UNSUBSCRIBE_FAILED);
78+
[peripheral setNotifyValue:NO forCharacteristic:characteristic];
79+
return CHIP_NO_ERROR;
9580
}
9681

9782
CHIP_ERROR BlePlatformDelegateImpl::CloseConnection(BLE_CONNECTION_OBJECT connObj)
@@ -126,32 +111,12 @@
126111
CHIP_ERROR BlePlatformDelegateImpl::SendWriteRequest(
127112
BLE_CONNECTION_OBJECT connObj, const ChipBleUUID * svcId, const ChipBleUUID * charId, PacketBufferHandle pBuf)
128113
{
129-
CHIP_ERROR err = BLE_ERROR_GATT_WRITE_FAILED;
130-
if (nullptr == svcId || nullptr == charId || pBuf.IsNull()) {
131-
return err;
132-
}
133-
134-
CBUUID * serviceId = [MTRUUIDHelper GetShortestServiceUUID:svcId];
135-
CBUUID * characteristicId = [CBUUID UUIDWithData:[NSData dataWithBytes:charId->bytes length:sizeof(charId->bytes)]];
136-
NSData * data = [NSData dataWithBytes:pBuf->Start() length:pBuf->DataLength()];
137114
CBPeripheral * peripheral = CBPeripheralFromBleConnObject(connObj);
138-
139-
for (CBService * service in peripheral.services) {
140-
if ([service.UUID.data isEqualToData:serviceId.data]) {
141-
for (CBCharacteristic * characteristic in service.characteristics) {
142-
if ([characteristic.UUID.data isEqualToData:characteristicId.data]) {
143-
err = CHIP_NO_ERROR;
144-
[peripheral writeValue:data forCharacteristic:characteristic type:CBCharacteristicWriteWithResponse];
145-
break;
146-
}
147-
}
148-
}
149-
}
150-
151-
// Going out of scope releases delegate's reference to pBuf. pBuf will be freed when both platform delegate and Chip
152-
// stack free their references to it. We release pBuf's reference here since its payload bytes were copied into a new
153-
// NSData object
154-
return err;
115+
CBCharacteristic * characteristic = FindCharacteristic(peripheral, svcId, charId);
116+
VerifyOrReturnError(characteristic != nil && !pBuf.IsNull(), BLE_ERROR_GATT_WRITE_FAILED);
117+
NSData * data = [NSData dataWithBytes:pBuf->Start() length:pBuf->DataLength()]; // copies data, pBuf can be freed
118+
[peripheral writeValue:data forCharacteristic:characteristic type:CBCharacteristicWriteWithResponse];
119+
return CHIP_NO_ERROR;
155120
}
156121

157122
} // namespace Internal

src/platform/Darwin/BleUtils.h

+9
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@
1414
* limitations under the License.
1515
*/
1616

17+
#pragma once
18+
1719
#include <ble/Ble.h>
1820

1921
@class CBPeripheral;
22+
@class CBUUID;
2023

2124
namespace chip {
2225
namespace DeviceLayer {
@@ -32,6 +35,12 @@ namespace DeviceLayer {
3235
return (__bridge void *) peripheral;
3336
}
3437

38+
// Creates a CBUUID from a ChipBleUUID
39+
CBUUID * CBUUIDFromBleUUID(Ble::ChipBleUUID const & uuid);
40+
41+
// Creates a ChipBleUUID from a CBUUID, expanding 16 or 32 bit UUIDs if necessary.
42+
Ble::ChipBleUUID BleUUIDFromCBUUD(CBUUID * uuid);
43+
3544
}
3645
}
3746
}

0 commit comments

Comments
 (0)