更新时间:2024-05-15 08:21:46下载pdf
子设备配网是指智能设备依赖于网关连接到涂鸦,例如 Zigbee 网关、蓝牙网关等。因此,子设备配网的过程必须具体到某个网关,由网关完成设备激活和消息通知。
接口说明
- (void)activeSubDeviceWithGwId:(NSString *)gwId timeout:(NSTimeInterval)timeout
参数说明
参数 | 说明 |
---|---|
gwId | 网关 ID |
timeout | 超时时间 |
示例代码
Objc:
- (void)activeSubDevice {
// 设置 ThingSmartActivator 的 delegate,并实现 delegate 方法
self.subActivator.delegate = self;
[self.subActivator activeSubDeviceWithGwId:@"your_device_id" timeout:100];
}
- (ThingSmartActivator *)subActivator {
if (!_subActivator) {
_subActivator = [[ThingSmartActivator alloc] init];
}
return _subActivator;
}
#pragma mark - ThingSmartActivatorDelegate
- (void)activator:(ThingSmartActivator *)activator didReceiveDevice:(ThingSmartDeviceModel *)deviceModel error:(NSError *)error {
if (!error && deviceModel) {
// 配网成功
}
if (error) {
// 配网失败
}
}
Swift:
func activeSubDevice() {
// 设置 ThingSmartActivator 的 delegate,并实现 delegate 方法
subActivator.delegate = self
subActivator.activeSubDevice(withGwId: "your_device_id", timeout: 100)
}
lazy var subActivator: ThingSmartActivator = {
let activator = ThingSmartActivator()
return activator
}()
#pragma mark - ThingSmartActivatorDelegate
func activator(_ activator: ThingSmartActivator!, didReceiveDevice deviceModel: ThingSmartDeviceModel!, error: Error!) {
if deviceModel != nil && error == nil {
//配网成功
}
if let e = error {
//配网失败
print("\(e)")
}
}
接口说明
- (void)stopActiveSubDeviceWithGwId:(NSString *)gwId
参数说明
参数 | 说明 |
---|---|
gwId | 网关 ID |
示例代码
Objc:
- (void)stopActiveSubDevice {
self.subActivator.delegate = nil;
[self.subActivator stopActiveSubDeviceWithGwId:@"your_device_id"];
}
Swift:
func stopActiveSubDevice() {
subActivator.delegate = nil
subActivator.stopActiveSubDevice(withGwId: "your_device_id")
}
该内容对您有帮助吗?
是意见反馈该内容对您有帮助吗?
是意见反馈