Last Updated on : 2022-03-03 06:47:48
Firmware update is the process to flash new firmware to a chip and update the earlier firmware. Tuya supports regular firmware updates to meet your development and market requirements. Tuya also deactivates certain earlier firmware versions in line with chip iterations of the manufacturers. In the case of device feature updates, firmware updates are also required.
Returns the device update information. The firmware update model TuyaSmartFirmwareUpgradeModel
provides the type
property to indicate the firmware type and the typeDesc
property to describe the firmware type.
API description
- (void)getFirmwareUpgradeInfo:(nullable void (^)(NSArray <TuyaSmartFirmwareUpgradeModel *> *upgradeModelList))success failure:(nullable TYFailureError)failure;
Parameters
Parameter | Description |
---|---|
success | The success callback. A list of firmware update information is returned. |
failure | The failure callback. |
Data model of TuyaSmartFirmwareUpgradeModel
Field | Type | Description |
---|---|---|
desc | NSString | The description of the update. |
typeDesc | NSString | The description of the device type. |
upgradeStatus | NSInteger |
|
version | NSString | The target firmware version. |
upgradeType | NSInteger |
|
url | NSString | The URL at which the firmware update package of the Bluetooth device can be downloaded. |
fileSize | NSString | The size of the firmware update package. Unit: bytes. |
md5 | NSString | The MD5 (Message-Digest algorithm 5) hash value of the firmware. |
upgradingDesc | NSString | The description of the firmware update. |
Example
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)")
}
})
}
API description
- (void)upgradeFirmware:(NSInteger)type success:(nullable TYSuccessHandler)success failure:(nullable TYFailureError)failure;
Parameters
Parameter | Description |
---|---|
type | The type of update. You can call getFirmwareUpgradeInfo to get the value. |
success | The success callback. |
failure | The failure callback. |
Example
ObjC:
- (void)upgradeFirmware {
// self.device = [TuyaSmartDevice deviceWithDeviceId:@"your_device_id"];
// `type`: the type of update. You can call `getFirmwareUpgradeInfo` to get the value.
// TuyaSmartFirmwareUpgradeModel - type
[self.device upgradeFirmware:type success:^{
NSLog(@"upgradeFirmware success");
} failure:^(NSError *error) {
NSLog(@"upgradeFirmware failure: %@", error);
}];
}
Swift:
func upgradeFirmware() {
// `type`: the type of update. You can call `getFirmwareUpgradeInfo` to get the value.
// TuyaSmartFirmwareUpgradeModel - type
device?.upgradeFirmware(type, success: {
print("upgradeFirmware success")
}, failure: { (error) in
if let e = error {
print("upgradeFirmware failure: \(e)")
}
})
}
Example
ObjC:
- (void)deviceFirmwareUpgradeSuccess:(TuyaSmartDevice *)device type:(NSInteger)type {
// The firmware is updated.
}
- (void)deviceFirmwareUpgradeFailure:(TuyaSmartDevice *)device type:(NSInteger)type {
// Failed to update the firmware.
}
- (void)device:(TuyaSmartDevice *)device firmwareUpgradeProgress:(NSInteger)type progress:(double)progress {
// The progress of the firmware update.
}
Swift:
func deviceFirmwareUpgradeSuccess(_ device: TuyaSmartDevice!, type: Int) {
// The firmware is updated.
}
func deviceFirmwareUpgradeFailure(_ device: TuyaSmartDevice!, type: Int) {
// Failed to update the firmware.
}
func device(_ device: TuyaSmartDevice!, firmwareUpgradeProgress type: Int, progress: Double) {
// The progress of the firmware update.
}
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback