加入收藏
举报
当前仅显示指定条件回帖 [ 展开查看全部 ]
02-14 20:02
#
文件名称:
OTA.md
所在目录:
Openharmony v1.0 / docs / api / api-SmartVision-Devices
文件大小:
11.45 KB
下载地址:
fenwii/OpenHarmony
   
免责声明:本网站仅提供指向 GitHub 上的文件的链接,所有文件的版权归原作者所有,本网站不对文件内容的合法性、准确性或安全性承担任何责任。
文本预览:
# OTA
## **Overview**
Provides system upgrades.
**Since:**
1.0
**Version:**
1.0
## **Summary**
## Files








File Name


Description


hota_updater.h


Defines the functions for system upgrades.



## Functions





























Function Name


Description


HotaSetPackageType (unsigned int flag)


int 


Sets the switch for using the default upgrade package format.


HotaGetUpdateIndex (unsigned int *index)


int 


Obtains the index of the A/B partition to be upgraded.


HotaInit (ErrorCallBackFunc errorCallback, StatusCallBackFunc statusCallback)


int 


Initializes the OTA module.


HotaWrite (unsigned char *buffer, unsigned int offset, unsigned int buffSize)


int 


Writes specified data into flash memory.


HotaRead (unsigned int offset, unsigned int bufLen, unsigned char *buf)


int 


Reads the data that has been written into flash memory.


HotaCancel (void)


int 


Cancels an upgrade.


HotaSetBootSettings (void)


int 


Sets the system state to be upgrading after data has been written into flash memory by HotaWrite.


HotaRestart (void)


int 


Restarts the system after an upgrade.



## **Details**
## **Function Documentation**
## HotaCancel\(\)
```
int HotaCancel (void )
```
**Description:**
Cancels an upgrade.
If an upgrade fails or is interrupted, you can use this function to cancel it.
**Returns:**
Returns **0** if the operation is successful; returns **-1** otherwise.
## HotaGetUpdateIndex\(\)
```
int HotaGetUpdateIndex (unsigned int * index)
```
**Description:**
Obtains the index of the A/B partition to be upgraded.
In the A/B upgrade scenario, you can use this function to determine whether partition A or B will be upgraded.
**Parameters:**








Name


Description


index Indicates the index of a partition. The value 1 means partition A, and 2 means partition B.

**Returns:**
Returns **0** if the operation is successful; returns **-1** otherwise.
## HotaInit\(\)
```
int HotaInit (ErrorCallBackFunc errorCallback, StatusCallBackFunc statusCallback )
```
**Description:**
Initializes the OTA module.
**Parameters:**











Name


Description


errorCallback Indicates the callback invoked when an error occurs during the upgrade. This parameter can be null.
statusCallback Indicates the callback invoked when the upgrade status changes. This parameter can be null.

**Returns:**
Returns **0** if the operation is successful; returns **-1** otherwise.
## HotaRead\(\)
```
int HotaRead (unsigned int offset, unsigned int bufLen, unsigned char * buf )
```
**Description:**
Reads the data that has been written into flash memory.
This function is required for verifying data correctness when the default upgrade package format is not used. It is not required when the default upgrade package format is used.
**Parameters:**














Name


Description


offset Indicates the offset from where to start reading data.
bufLen Indicates the length of the data to be read.
buf Indicates the buffer to store the data that has been read.

**Returns:**
Returns **0** if the operation is successful; returns **-1** otherwise.
## HotaRestart\(\)
```
int HotaRestart (void )
```
**Description:**
Restarts the system after an upgrade.
You need to call this function after you have called the [HotaSetBootSettings](OTA.md#ga017c1bd1166fd95dede1a28a87adb0fa) function.
**Returns:**
Returns **0** if the operation is successful; returns **-1** otherwise.
## HotaSetBootSettings\(\)
```
int HotaSetBootSettings (void )
```
**Description:**
Sets the system state to be upgrading after data has been written into flash memory by [HotaWrite](OTA.md#ga3b2d7152e8898e5f1d95fcabaa181e40).
After this operation is successful, you need to call the [HotaRestart](OTA.md#gad539df71d6fa124457e06badc0c05c46) function to complete the upgrade.
**Returns:**
Returns **0** if the operation is successful; returns **-1** otherwise.
## HotaSetPackageType\(\)
```
int HotaSetPackageType (unsigned int flag)
```
**Description:**
Sets the switch for using the default upgrade package format.
You can call this function to choose the default upgrade package format when developing the system upgrade capability. If the default upgrade package format is used, the system ensures the security and integrity of the upgrade package. If it is not used, you need to ensure the security and integrity of the upgrade package you have chosen. To be specific, you need to call the [HotaRead](OTA.md#ga0972316900eaa074273a3c286c42d409) function to read the data that has been written into flash memory, and then verify the data.
**Parameters:**








Name


Description


flag Specifies whether to use the default system upgrade package format. The value 1 (default value) means to use it, and 0 means not to use it.

**Returns:**
Returns **0** if the operation is successful; returns **-1** otherwise.
## HotaWrite\(\)
```
int HotaWrite (unsigned char * buffer, unsigned int offset, unsigned int buffSize )
```
**Description:**
Writes specified data into flash memory.
**Parameters:**














Name


Description


buffer Indicates the data to be written into flash memory.
offset Indicates the offset from where to start writing data.
buffSize Indicates the size of the data to be written.

**Returns:**
Returns **0** if the operation is successful; returns **-1** otherwise.
点赞 回复
回帖
支持markdown部分语法 ?