|
14 | 14 | * See the License for the specific language governing permissions and
|
15 | 15 | * limitations under the License.
|
16 | 16 | */
|
17 |
| -#import <os/lock.h> |
18 |
| - |
19 |
| -#import "MTRDeviceController.h" |
| 17 | +#import "MTRDeviceController_Internal.h" |
20 | 18 |
|
21 | 19 | #import "MTRBaseDevice_Internal.h"
|
22 | 20 | #import "MTRCommissioningParameters.h"
|
|
54 | 52 | #include <setup_payload/ManualSetupPayloadGenerator.h>
|
55 | 53 | #include <system/SystemClock.h>
|
56 | 54 |
|
| 55 | +#import <os/lock.h> |
| 56 | + |
57 | 57 | static NSString * const kErrorCommissionerInit = @"Init failure while initializing a commissioner";
|
58 | 58 | static NSString * const kErrorIPKInit = @"Init failure while initializing IPK";
|
59 | 59 | static NSString * const kErrorSigningKeypairInit = @"Init failure while creating signing keypair bridge";
|
@@ -678,17 +678,6 @@ - (BOOL)checkIsRunning:(NSError * __autoreleasing *)error
|
678 | 678 | return NO;
|
679 | 679 | }
|
680 | 680 |
|
681 |
| -- (BOOL)_deviceBeingCommissionedOverBLE:(uint64_t)deviceID |
682 |
| -{ |
683 |
| - VerifyOrReturnValue([self checkIsRunning], NO); |
684 |
| - |
685 |
| - chip::CommissioneeDeviceProxy * deviceProxy; |
686 |
| - auto errorCode = self->_cppCommissioner->GetDeviceBeingCommissioned(deviceID, &deviceProxy); |
687 |
| - VerifyOrReturnValue(errorCode == CHIP_NO_ERROR, NO); |
688 |
| - |
689 |
| - return deviceProxy->GetDeviceTransportType() == chip::Transport::Type::kBle; |
690 |
| -} |
691 |
| - |
692 | 681 | - (void)getSessionForNode:(chip::NodeId)nodeID completion:(MTRInternalDeviceConnectionCallback)completion
|
693 | 682 | {
|
694 | 683 | [self
|
@@ -728,6 +717,28 @@ - (void)getSessionForCommissioneeDevice:(chip::NodeId)deviceID completion:(MTRIn
|
728 | 717 | }];
|
729 | 718 | }
|
730 | 719 |
|
| 720 | +- (MTRTransportType)sessionTransportTypeForDevice:(MTRBaseDevice *)device |
| 721 | +{ |
| 722 | + VerifyOrReturnValue([self checkIsRunning], MTRTransportTypeUndefined); |
| 723 | + |
| 724 | + __block MTRTransportType result = MTRTransportTypeUndefined; |
| 725 | + dispatch_sync(_chipWorkQueue, ^{ |
| 726 | + VerifyOrReturn([self checkIsRunning]); |
| 727 | + |
| 728 | + if (device.isPASEDevice) { |
| 729 | + chip::CommissioneeDeviceProxy * deviceProxy; |
| 730 | + VerifyOrReturn(CHIP_NO_ERROR == self->_cppCommissioner->GetDeviceBeingCommissioned(device.nodeID, &deviceProxy)); |
| 731 | + result = MTRMakeTransportType(deviceProxy->GetDeviceTransportType()); |
| 732 | + } else { |
| 733 | + auto scopedNodeID = self->_cppCommissioner->GetPeerScopedId(device.nodeID); |
| 734 | + auto sessionHandle = self->_cppCommissioner->SessionMgr()->FindSecureSessionForNode(scopedNodeID); |
| 735 | + VerifyOrReturn(sessionHandle.HasValue()); |
| 736 | + result = MTRMakeTransportType(sessionHandle.Value()->AsSecureSession()->GetPeerAddress().GetTransportType()); |
| 737 | + } |
| 738 | + }); |
| 739 | + return result; |
| 740 | +} |
| 741 | + |
731 | 742 | - (void)asyncGetCommissionerOnMatterQueue:(void (^)(chip::Controller::DeviceCommissioner *))block
|
732 | 743 | errorHandler:(nullable MTRDeviceErrorHandler)errorHandler
|
733 | 744 | {
|
@@ -795,10 +806,6 @@ - (BOOL)syncRunOnWorkQueueWithBoolReturnValue:(SyncWorkQueueBlockWithBoolReturnV
|
795 | 806 | return success;
|
796 | 807 | }
|
797 | 808 |
|
798 |
| -@end |
799 |
| - |
800 |
| -@implementation MTRDeviceController (InternalMethods) |
801 |
| - |
802 | 809 | - (chip::FabricIndex)fabricIndex
|
803 | 810 | {
|
804 | 811 | if (!_cppCommissioner) {
|
@@ -848,6 +855,7 @@ - (void)invalidateCASESessionForNode:(chip::NodeId)nodeID;
|
848 | 855 |
|
849 | 856 | [self syncRunOnWorkQueue:block error:nil];
|
850 | 857 | }
|
| 858 | + |
851 | 859 | @end
|
852 | 860 |
|
853 | 861 | /**
|
|
0 commit comments