更新时间:2022-03-03 06:47:48下载pdf
固件升级是指把新的固件写入芯片中,代替原有的固件的过程。随着市场变化、开发方案升级等原因,涂鸦会定期进行固件更新。同时,涂鸦会根据原厂芯片迭代等情况,对部分旧版本进行停用。另外,设备本身也可以进行功能更新迭代,从而升级固件。
使用查询设备升级信息接口查询到的 TuyaSmartFirmwareUpgradeModel
固件升级模型中,type
属性能查询到固件的类型,typeDesc
属性能查询到固件类型的描述。
接口说明
- (void)getFirmwareUpgradeInfo:(nullable void (^)(NSArray <TuyaSmartFirmwareUpgradeModel *> *upgradeModelList))success failure:(nullable TYFailureError)failure;
参数说明
参数 | 说明 |
---|---|
success | 成功回调,设备的固件升级信息列表 |
failure | 失败回调 |
TuyaSmartFirmwareUpgradeModel
数据模型
字段 | 类型 | 说明 |
---|---|---|
desc | NSString | 升级文案 |
typeDesc | NSString | 设备类型文案 |
upgradeStatus | NSInteger |
|
version | NSString | 新版本使用的固件版本 |
upgradeType | NSInteger |
|
url | NSString | 蓝牙设备的升级固件包下载 URL |
fileSize | NSString | 固件包的大小,单位为字节(byte) |
md5 | NSString | 固件的 MD5 |
upgradingDesc | NSString | 固件升级中的提示文案 |
示例代码
Objc:
- (void)getFirmwareUpgradeInfo {
// self.device = [TuyaSmartDevice deviceWithDeviceId:@"your_device_id"];
[self.device getFirmwareUpgradeInfo:^(NSArray<TuyaSmartFirmwareUpgradeModel *> *upgradeModelList) {
NSLog(@"getFirmwareUpgradeInfo success");
} failure:^(NSError *error) {
NSLog(@"getFirmwareUpgradeInfo failure: %@", error);
}];
}
Swift:
func getFirmwareUpgradeInfo() {
device?.getFirmwareUpgradeInfo({ (upgradeModelList) in
print("getFirmwareUpgradeInfo success")
}, failure: { (error) in
if let e = error {
print("getFirmwareUpgradeInfo failure: \(e)")
}
})
}
接口说明
- (void)upgradeFirmware:(NSInteger)type success:(nullable TYSuccessHandler)success failure:(nullable TYFailureError)failure;
参数说明
参数 | 说明 |
---|---|
type | 需要升级的类型,从设备升级信息接口 getFirmwareUpgradeInfo 查询 |
success | 成功回调 |
failure | 失败回调 |
示例代码
Objc:
- (void)upgradeFirmware {
// self.device = [TuyaSmartDevice deviceWithDeviceId:@"your_device_id"];
// type: 从查询设备升级信息接口 getFirmwareUpgradeInfo 返回的固件类型
// TuyaSmartFirmwareUpgradeModel - type
[self.device upgradeFirmware:type success:^{
NSLog(@"upgradeFirmware success");
} failure:^(NSError *error) {
NSLog(@"upgradeFirmware failure: %@", error);
}];
}
Swift:
func upgradeFirmware() {
// type: 从查询设备升级信息接口 getFirmwareUpgradeInfo 返回的固件类型
// TuyaSmartFirmwareUpgradeModel - type
device?.upgradeFirmware(type, success: {
print("upgradeFirmware success")
}, failure: { (error) in
if let e = error {
print("upgradeFirmware failure: \(e)")
}
})
}
示例代码
Objc:
- (void)deviceFirmwareUpgradeSuccess:(TuyaSmartDevice *)device type:(NSInteger)type {
// 固件升级成功
}
- (void)deviceFirmwareUpgradeFailure:(TuyaSmartDevice *)device type:(NSInteger)type {
// 固件升级失败
}
- (void)device:(TuyaSmartDevice *)device firmwareUpgradeProgress:(NSInteger)type progress:(double)progress {
// 固件升级的进度
}
Swift:
func deviceFirmwareUpgradeSuccess(_ device: TuyaSmartDevice!, type: Int) {
// 固件升级成功
}
func deviceFirmwareUpgradeFailure(_ device: TuyaSmartDevice!, type: Int) {
// 固件升级失败
}
func device(_ device: TuyaSmartDevice!, firmwareUpgradeProgress type: Int, progress: Double) {
// 固件升级的进度
}
该内容对您有帮助吗?
是意见反馈该内容对您有帮助吗?
是意见反馈