更新时间:2024-05-15 08:20:46下载pdf
接口说明
/// Returns the devices that support Pegasus.
/// @param homeID The home ID.
/// @return A list of devices that support Pegasus.
+ (NSArray <ThingSmartDeviceModel *> *)pegasusDeviceListWithHomeID:(long long)homeID;
参数说明
参数 | 说明 |
---|---|
homeId | 家庭 ID |
示例代码
Objc:
NSArray <ThingSmartDeviceModel *> *deviceList = [ThingSmartPegasusActivator pegasusDeviceListWithHomeID:homeId];
Swift:
let deviceList = ThingSmartPegasusActivator.pegasusDeviceList(withHomeID: homeId)
接口说明
/// Start Pegasus Activator discover pending device.
/// @param devIDs Device ID list
/// @param serverTimeout Configured devices, search timeout for devices to be configured.
/// @param clientTimeout Pending devices, pending devices is searched for and not added to the family timeout.
/// @param success Called when the task finishes successfully.
/// @param failure Called when the task is interrupted by an error.
- (void)startDiscoverWithDevIDs:(NSArray<NSString *> *)devIDs
serverTimeout:(NSTimeInterval)serverTimeout
clientTimeout:(NSTimeInterval)clientTimeout
success:(ThingSuccessHandler)success
failure:(ThingFailureError)failure;
参数说明
参数 | 说明 |
---|---|
devIDs | 家庭中支持闪电配网的设备 |
serverTimeout | 已配网设备搜索时长,单位秒 |
clientTimeout | 待配网设备锁定时长,单位秒 |
success | 成功回调 |
failure | 失败回调 |
示例代码
Objc:
[self.pegasusActivator startDiscoverWithDevIDs:dArr serverTimeout:120 clientTimeout:120 success:^{
} failure:^(NSError *error) {
NSLog("无待配网设备返回");
}];
Swift:
let pegasusActivator = ThingSmartPegasusActivator.init()
pegasusActivator.startDiscover(withDevIDs:devids , serverTimeout: 120, clientTimeout: 120) {
} failure: { error in
}
接口说明
@protocol ThingSmartPegasusActivatorDelegate <NSObject>
/// Devices found by Pegasus.
/// @param activator Activator instance.
/// @param serverDeviceModel Device in the home that support pegasus.
/// @param deviceModel The device is found, but there is no device ID at this time.
/// @param error Error message.
- (void)pegasusActivator:(ThingSmartPegasusActivator *)activator serverDevice:(ThingSmartDeviceModel *)serverDeviceModel didFoundDevice:(ThingSmartDeviceModel *)deviceModel error:(NSError * __nullable)error;
@end
参数说明
参数 | 说明 |
---|---|
activator | 配网使用 ThingSmartPegasusActivator 示例对象 |
serverDeviceModel | 支持闪电的设备 |
deviceModel | 搜索发现的待配网设备 |
error | 错误消息 |
示例代码
Objc:
- (void)pegasusActivator:(ThingSmartPegasusActivator *)activator serverDevice:(ThingSmartDeviceModel *)serverDeviceModel didFoundDevice:(ThingSmartDeviceModel *)deviceModel error:(NSError * __nullable)error {
NSLog(@"⚡️⚡️⚡️ pegasus did found, server:%@ client:%@ error:%@",serverDeviceModel.devId, deviceModel.uuid, error);
}
Swift:
func pegasusActivator(_ activator: ThingSmartPegasusActivator, serverDevice serverDeviceModel: ThingSmartDeviceModel, didFoundDevice deviceModel: ThingSmartDeviceModel, error: Error?) {
}
接口说明
/// Stops pairing devices by Pegasus after devices are paired.
///
/// The value of 'devIDs' is generated in the call of ThingSmartPegasusActivator::pegasusDeviceListWithHomeID:.
///
/// @param devIDs A list of devices that support Pegasus.
/// @param success Called when the task is finished.
/// @param failure Called when the task is interrupted by an error.
- (void)stopDiscoverWithDevIDs:(NSArray<NSString *> *)devIDs
success:(ThingSuccessHandler)success
failure:(ThingFailureError)failure;
参数说明
参数 | 说明 |
---|---|
devIDs | 家庭中支持闪电配网的设备 ID |
success | 成功回调 |
failure | 失败回调 |
示例代码
Objc:
[self.pegasusActivator stopDiscoverWithDevIDs:dArr success:^{
} failure:^(NSError *error) {
}];
Swift:
let pegasusActivator = ThingSmartPegasusActivator.init()
pegasusActivator.stopDiscover(withDevIDs: devIDS) {
} failure: { error in
}
接口说明
/// Pairs specified devices by using Pegasus.
///
/// The value of 'token' can be generated in the call of ThingSmartActivator::getTokenWithHomeId:success:failure:.
///
/// @param devIDs A list of devices that support Pegasus.
/// @param UUIDs A list of UUIDs of devices to be paired.
/// @param token The pairing token.
/// @param timeout The timeout value. Unit: seconds. Default value: 100.
/// @param success Called when the task is finished.
/// @param failure Called when the task is interrupted by an error.
- (void)startActivatorWithDevIDs:(NSArray<NSString *> *)devIDs
UUIDs:(NSArray<NSString *> *)UUIDs
token:(NSString *)token
timeout:(NSTimeInterval)timeout
success:(ThingSuccessHandler)success
failure:(ThingFailureError)failure;
参数说明
参数 | 说明 |
---|---|
devID | 家庭中支持闪电配网的设备 ID |
UUIDs | 待配网设备 ID |
token | 配网 token |
timeout | 超时时间 |
success | 完成回调 |
failure | 失败回调 |
示例代码
Objc:
[self.pegasusActivator startActivatorWithDevIDs:dArr UUIDs:mArr.copy token:result timeout:120 success:^{
} failure:^(NSError *error) {
TYLogError(error.localizedDescription);
}];
Swift:
let pegasusActivator = ThingSmartPegasusActivator.init()
pegasusActivator.start(withDevIDs: devIDS, uuids: uuids, token: token, timeout: 120) {
} failure: { error in
}
接口说明
@protocol ThingSmartPegasusActivatorDelegate <NSObject>
/// Returns the devices that are found by Pegasus.
/// @param activator The activator instance.
/// @param deviceModel The device that is found by Pegasus.
/// @param error An error occurs while processing the request.
- (void)pegasusActivator:(ThingSmartPegasusActivator *)activator didReceiveDevice:(ThingSmartDeviceModel *)deviceModel error:(NSError * __nullable)error;
@end
参数说明
参数 | 说明 |
---|---|
activator | 配网使用 ThingSmartPegasusActivator 示例对象 |
deviceModel | 配网成功设备 |
error | 错误消息 |
示例代码
Objc:
- (void)pegasusActivator:(ThingSmartPegasusActivator *)activator didReceiveDevice:(ThingSmartDeviceModel *)deviceModel error:(NSError * __nullable)error {
NSLog(@"⚡️⚡️⚡️ pegasus did receive, client-uuid:%@ devID:%@ error:%@",deviceModel.uuid,deviceModel.devId,error);
}
Swift:
func pegasusActivator(_ activator: ThingSmartPegasusActivator, didReceiveDevice deviceModel: ThingSmartDeviceModel, error: Error?) {
}
接口说明
/// Cancels the Pegasus-based pairing of devices.
/// @param devIDs A list of devices that support Pegasus.
/// @param UUIDs A list of UUIDs of devices to be paired.
/// @param success Called when the task is finished.
/// @param failure Called when the task is interrupted by an error.
- (void)cancelActivatorWithDevIDs:(NSArray<NSString *> *)devIDs
UUIDs:(NSArray<NSString *> *)UUIDs
success:(ThingSuccessHandler)success
failure:(ThingFailureError)failure;
参数说明
参数 | 说明 |
---|---|
devIDs | 家庭中支持闪电配网的设备 ID |
UUIDs | 待配网设备 ID |
success | 完成回调 |
failure | 失败回调 |
示例代码
Objc:
[self.pegasusActivator cancelActivatorWithDevIDs:dArr UUIDs:mArr.copy success:^{
} failure:^(NSError *error) {
}];
Swift:
let pegasusActivator = ThingSmartPegasusActivator.init()
pegasusActivator.cancel(withDevIDs: devIDS, uuids: uuids) {
} failure: { error in
}
该内容对您有帮助吗?
是意见反馈该内容对您有帮助吗?
是意见反馈