-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
iOS TvCasting app: Implemented commissioner discovery and UDC requests (
#19491) * iOS TvCasting app: Implemented commissioner discovery and UDC requests * Addressing review comments, adding Discover button to Commissioner Discovery UI, using optional Bools to denote the state of the CommissioningView
- Loading branch information
1 parent
6be4b3e
commit 4fa4aa3
Showing
15 changed files
with
669 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
examples/tv-casting-app/darwin/TvCasting/MatterBridge/DiscoveredNodeData.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* | ||
* Copyright (c) 2020-2022 Project CHIP Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
#ifndef DiscoveredNodeData_h | ||
#define DiscoveredNodeData_h | ||
|
||
@interface DiscoveredNodeData : NSObject | ||
|
||
@property NSString * deviceName; | ||
|
||
@property uint16_t vendorId; | ||
|
||
@property uint16_t productId; | ||
|
||
@property uint16_t deviceType; | ||
|
||
@property uint16_t longDiscriminator; | ||
|
||
@property uint8_t commissioningMode; | ||
|
||
@property uint16_t pairingHint; | ||
|
||
@property const uint8_t * rotatingId; | ||
|
||
@property size_t rotatingIdLen; | ||
|
||
@property NSString * instanceName; | ||
|
||
@property uint16_t port; | ||
|
||
@property NSString * hostName; | ||
|
||
@property unsigned int platformInterface; | ||
|
||
@property NSMutableArray * ipAddresses; | ||
|
||
@property size_t numIPs; | ||
|
||
- (DiscoveredNodeData *)initWithDeviceName:(NSString *)deviceName vendorId:(uint16_t)vendorId productId:(uint16_t)productId; | ||
|
||
@end | ||
|
||
#endif /* DiscoveredNodeData_h */ |
73 changes: 73 additions & 0 deletions
73
examples/tv-casting-app/darwin/TvCasting/MatterBridge/DiscoveredNodeData.mm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/** | ||
* | ||
* Copyright (c) 2020-2022 Project CHIP Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
#import "DiscoveredNodeData.h" | ||
#include <lib/dnssd/Resolver.h> | ||
|
||
@implementation DiscoveredNodeData | ||
|
||
- (DiscoveredNodeData *)initWithDeviceName:(NSString *)deviceName vendorId:(uint16_t)vendorId productId:(uint16_t)productId | ||
{ | ||
self = [super init]; | ||
if (self) { | ||
_deviceName = deviceName; | ||
_vendorId = vendorId; | ||
_productId = productId; | ||
} | ||
return self; | ||
} | ||
|
||
- (NSString *)description | ||
{ | ||
return [NSString stringWithFormat:@"%@ with Product ID: %d and Vendor ID: %d", _deviceName, _productId, _vendorId]; | ||
} | ||
|
||
- (BOOL)isEqualToDiscoveredNodeData:(DiscoveredNodeData *)other | ||
{ | ||
return [self.instanceName isEqualToString:other.instanceName]; | ||
} | ||
|
||
- (BOOL)isEqual:(id)other | ||
{ | ||
if (other == nil) { | ||
return NO; | ||
} | ||
|
||
if (self == other) { | ||
return YES; | ||
} | ||
|
||
if (![other isKindOfClass:[DiscoveredNodeData class]]) { | ||
return NO; | ||
} | ||
|
||
return [self isEqualToDiscoveredNodeData:(DiscoveredNodeData *) other]; | ||
} | ||
|
||
- (NSUInteger)hash | ||
{ | ||
const NSUInteger prime = 31; | ||
NSUInteger result = 1; | ||
|
||
result = prime * result + [self.instanceName hash]; | ||
|
||
return result; | ||
} | ||
|
||
@end |
32 changes: 32 additions & 0 deletions
32
examples/tv-casting-app/darwin/TvCasting/MatterBridge/DiscoveredNodeDataConverter.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* | ||
* Copyright (c) 2020-2022 Project CHIP Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
#import "DiscoveredNodeData.h" | ||
#include <lib/dnssd/Resolver.h> | ||
|
||
#ifndef DiscoveredNodeDataConverter_h | ||
#define DiscoveredNodeDataConverter_h | ||
|
||
@interface DiscoveredNodeDataConverter : NSObject | ||
|
||
+ (DiscoveredNodeData *)convertToObjC:(const chip::Dnssd::DiscoveredNodeData *)chipDiscoveredNodedata; | ||
|
||
@end | ||
|
||
#endif /* DiscoveredNodeDataConverter_h */ |
58 changes: 58 additions & 0 deletions
58
examples/tv-casting-app/darwin/TvCasting/MatterBridge/DiscoveredNodeDataConverter.mm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
* | ||
* Copyright (c) 2020-2022 Project CHIP Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#import <Foundation/Foundation.h> | ||
|
||
#import "DiscoveredNodeDataConverter.hpp" | ||
|
||
@implementation DiscoveredNodeDataConverter | ||
|
||
+ (DiscoveredNodeData *)convertToObjC:(const chip::Dnssd::DiscoveredNodeData *)chipDiscoveredNodeData | ||
{ | ||
DiscoveredNodeData * objCDiscoveredNodeData = [DiscoveredNodeData new]; | ||
|
||
// from CommissionNodeData | ||
objCDiscoveredNodeData.deviceType = chipDiscoveredNodeData->commissionData.deviceType; | ||
objCDiscoveredNodeData.vendorId = chipDiscoveredNodeData->commissionData.vendorId; | ||
objCDiscoveredNodeData.productId = chipDiscoveredNodeData->commissionData.productId; | ||
objCDiscoveredNodeData.longDiscriminator = chipDiscoveredNodeData->commissionData.longDiscriminator; | ||
objCDiscoveredNodeData.commissioningMode = chipDiscoveredNodeData->commissionData.commissioningMode; | ||
objCDiscoveredNodeData.pairingHint = chipDiscoveredNodeData->commissionData.pairingHint; | ||
objCDiscoveredNodeData.deviceName = [NSString stringWithCString:chipDiscoveredNodeData->commissionData.deviceName | ||
encoding:NSASCIIStringEncoding]; | ||
objCDiscoveredNodeData.rotatingIdLen = chipDiscoveredNodeData->commissionData.rotatingIdLen; | ||
objCDiscoveredNodeData.rotatingId = chipDiscoveredNodeData->commissionData.rotatingId; | ||
objCDiscoveredNodeData.instanceName = [NSString stringWithCString:chipDiscoveredNodeData->commissionData.instanceName | ||
encoding:NSASCIIStringEncoding]; | ||
|
||
// from CommonResolutionData | ||
objCDiscoveredNodeData.port = chipDiscoveredNodeData->resolutionData.port; | ||
objCDiscoveredNodeData.hostName = [NSString stringWithCString:chipDiscoveredNodeData->resolutionData.hostName | ||
encoding:NSASCIIStringEncoding]; | ||
objCDiscoveredNodeData.platformInterface = chipDiscoveredNodeData->resolutionData.interfaceId.GetPlatformInterface(); | ||
objCDiscoveredNodeData.numIPs = chipDiscoveredNodeData->resolutionData.numIPs; | ||
if (chipDiscoveredNodeData->resolutionData.numIPs > 0) { | ||
objCDiscoveredNodeData.ipAddresses = [NSMutableArray new]; | ||
} | ||
for (int i = 0; i < chipDiscoveredNodeData->resolutionData.numIPs; i++) { | ||
char addrCString[chip::Inet::IPAddress::kMaxStringLength]; | ||
chipDiscoveredNodeData->resolutionData.ipAddress->ToString(addrCString, chip::Inet::IPAddress::kMaxStringLength); | ||
objCDiscoveredNodeData.ipAddresses[i] = [NSString stringWithCString:addrCString encoding:NSASCIIStringEncoding]; | ||
} | ||
return objCDiscoveredNodeData; | ||
} | ||
|
||
@end |
Oops, something went wrong.