Skip to content

Commit

Permalink
[Darwin] expose the "getDeviceBeingCommissioned" API to ObjC (#12811)
Browse files Browse the repository at this point in the history
  • Loading branch information
sagar-apple authored and pull[bot] committed Nov 10, 2023
1 parent 2f3f917 commit c8d9450
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/darwin/Framework/CHIP/CHIPDeviceController.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ typedef void (^CHIPDeviceConnectionCallback)(CHIPDevice * _Nullable device, NSEr
- (void)updateDevice:(uint64_t)deviceID fabricId:(uint64_t)fabricId;

- (BOOL)isDevicePaired:(uint64_t)deviceID error:(NSError * __autoreleasing *)error;
- (nullable CHIPDevice *)getDeviceBeingCommissioned:(uint64_t)deviceId error:(NSError * __autoreleasing *)error;
- (BOOL)getConnectedDevice:(uint64_t)deviceID
queue:(dispatch_queue_t)queue
completionHandler:(CHIPDeviceConnectionCallback)completionHandler;
Expand Down
19 changes: 19 additions & 0 deletions src/darwin/Framework/CHIP/CHIPDeviceController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,25 @@ - (BOOL)isDevicePaired:(uint64_t)deviceID error:(NSError * __autoreleasing *)err
return paired;
}

- (CHIPDevice *)getDeviceBeingCommissioned:(uint64_t)deviceId error:(NSError * __autoreleasing *)error
{
CHIP_ERROR errorCode = CHIP_ERROR_INCORRECT_STATE;
if (![self isRunning]) {
[self checkForError:errorCode logMsg:kErrorNotRunning error:error];
return nil;
}

chip::CommissioneeDeviceProxy * deviceProxy;
errorCode = self->_cppCommissioner->GetDeviceBeingCommissioned(deviceId, &deviceProxy);
if (errorCode != CHIP_NO_ERROR) {
if (error) {
*error = [CHIPError errorForCHIPErrorCode:errorCode];
}
return nil;
}
return [[CHIPDevice alloc] initWithDevice:deviceProxy];
}

- (BOOL)getConnectedDevice:(uint64_t)deviceID
queue:(dispatch_queue_t)queue
completionHandler:(CHIPDeviceConnectionCallback)completionHandler
Expand Down

0 comments on commit c8d9450

Please sign in to comment.