Skip to content

Commit a8d2a6b

Browse files
authored
Merge pull request #95 from DavidLiu123/main
update FOTA introduction
2 parents 1c096c3 + b8a09bb commit a8d2a6b

File tree

2 files changed

+197
-16
lines changed

2 files changed

+197
-16
lines changed

en-us/api/QuecPythonClasslib.md

Lines changed: 100 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3194,9 +3194,13 @@ Module function: Firmware upgrade.
31943194

31953195
##### Create a fota Object
31963196

3197+
Optional parameters to select whether to automatically restart after downloading the upgrade package
3198+
31973199
> **import fota**
31983200
>
3199-
> **fota_obj = fota()**
3201+
> **fota_obj = fota()**#Automatically restart after downloading
3202+
>
3203+
> **fota_obj = fota(reset_disable=1)**#Not restart after downloading
32003204

32013205
##### One-click Upgrade Interface
32023206

@@ -3209,8 +3213,8 @@ Realize the whole process of firmware download and upgrade with one interface
32093213
| Parameter | Parameter Type | Description |
32103214
| --------- | -------------- | ------------------------------------------------------------ |
32113215
| url1 | str | The url of the first stage upgrade package to be downloaded |
3212-
| url2 | str | The url of the second stage upgrade package to be downloaded. Note: this parameter must be input for the minimum system upgrade because the minimum system is divided into two stages, while this parameter is forbidden to be input for DFOTA and FullFOTA upgrade because there is only one stage for DFOTA and FullFOTA. |
3213-
| callback | function | Callback function which shows downloading progress and status (Optional). Note: This callback is valid on EC600S/EC600N modules with non-minimum system upgrade mode. It is invalid on other modules. |
3216+
| url2 | str | The url of the second stage upgrade package to be downloaded. Note: this parameter must be input for the minimum system upgrade because the minimum system is divided into two stages, while this parameter is forbidden to be input for DFOTA and FullFOTA upgrade because there is only one stage for DFOTA and FullFOTA. Only EC600S/EC600N modules support the minimum system upgrade mode. |
3217+
| callback | function | Callback function which shows downloading progress and status (Optional). Note: This callback is valid on non-minimum system upgrade mode. |
32143218

32153219
- Return Value
32163220

@@ -3223,7 +3227,7 @@ Realize the whole process of firmware download and upgrade with one interface
32233227
- Example
32243228

32253229
```python
3226-
#args[0] indicates the download status. If the download is successful, it returns an integer value: 0 or 1 or 2. If the download fails, it returns an integer value: -1. args[1] represents the download progress. When the download status shows success, it represents the percentage. When the download status shows failure, it represents error code
3230+
#args[0] indicates the download status. If the download is successful, it returns an integer value: 0 or 1 or 2. If the download fails, it returns an integer value: values other than 0,1,2. args[1] represents the download progress. Note:on EC600S/EC600N module,when the download status shows success, it represents the percentage. When the download status shows failure, it represents error code
32273231
def result(args):
32283232
print('download status:',args[0],'download process:',args[1])
32293233

@@ -3255,7 +3259,7 @@ Write upgrade package data stream
32553259

32563260
* Note
32573261

3258-
* The BC25PA platform does not support this method.
3262+
* Currently only EC600S/EC600N/EC800N/EC200U/EC600U platform support this method.
32593263

32603264

32613265
##### Interface to Upgrade Step by Step and Refresh Cached Data to Flash
@@ -3273,9 +3277,9 @@ Refresh cached data to the flash.
32733277
* 0 Successful execution
32743278
* -1 Failed execution
32753279

3276-
* note
3280+
* Note
32773281

3278-
* The BC25PA platform does not support this method.
3282+
* Currently only EC600S/EC600N/EC800N/EC200U/EC600U platform support this method.
32793283

32803284
##### Interface to Upgrade Step by Step and Verify the Data
32813285

@@ -3292,9 +3296,9 @@ Refresh cached data to the flash.
32923296
* 0 Successful execution
32933297
* -1 Failed execution
32943298

3295-
* note
3299+
* Note
32963300

3297-
* The BC25PA platform does not support this method.
3301+
* Currently only EC600S/EC600N/EC800N/EC200U/EC600U platform support this method.
32983302

32993303
* Example
33003304

@@ -3303,13 +3307,84 @@ Refresh cached data to the flash.
33033307
0
33043308
```
33053309

3310+
##### Interface to set up APN for FOTA download
3311+
3312+
> fota_obj.apn_set(fota_apn=,ip_type=,fota_user=,fota_password=)
3313+
3314+
Set the APN information used for FOTA download.
3315+
3316+
* Parameter
3317+
3318+
| Parameter | Parameter Type | Description |
3319+
| ------------- | -------------- | ------------------------------------------------------------ |
3320+
| fota_apn | str | APN(You can choose not to pass this parameter) |
3321+
| ip_type | int | IP type0-IPV41-IPV6(You can choose not to pass this parameter) |
3322+
| fota_user | str | user name(You can choose not to pass this parameter) |
3323+
| fota_password | str | password(You can choose not to pass this parameter) |
3324+
3325+
* Return Value
3326+
3327+
* 0 Successful execution
3328+
* -1 Failed execution
3329+
3330+
* Example
3331+
3332+
```python
3333+
>>> fota_obj.apn_set(fota_apn="CMNET",ip_type=0,fota_user="abc",fota_password="123")
3334+
0
3335+
```
3336+
3337+
* Note
3338+
3339+
- Currently only BG95 platform support this method.
3340+
3341+
##### Interface to cancel FOTA downloading
3342+
3343+
> fota_obj.download_cancel()
33063344

3345+
Cancel the FOTA download in progress.
3346+
3347+
- Parameter
3348+
3349+
- None
3350+
3351+
* Return Value
3352+
3353+
* 0 Successful execution
3354+
* -1 Failed execution
3355+
3356+
* Example
3357+
3358+
```python
3359+
import fota
3360+
import _thread
3361+
import utime
3362+
3363+
def th_func():
3364+
utime.sleep(40) #Depending on the size of the package, make sure to cancel before the download is complete
3365+
fota_obj.download_cancel()
3366+
3367+
def result(args):
3368+
print('download status:',args[0],'download process:',args[1])
3369+
3370+
fota_obj = fota()
3371+
_thread.start_new_thread(th_func, ())
3372+
fota_obj.httpDownload(url1="http://www.example.com/fota.bin",callback=result)
3373+
```
3374+
3375+
* Note
3376+
3377+
- Currently only BG95 platform support this method.
3378+
3379+
33073380

33083381
##### Example
33093382

33103383
###### One-click Upgrade Interface
33113384

33123385
```python
3386+
#Automatically restart after downloading
3387+
33133388
import fota
33143389
import utime
33153390
import log
@@ -3340,10 +3415,26 @@ if __name__ == '__main__':
33403415
run()
33413416
```
33423417

3418+
```python
3419+
#Not automatically restart after the download is complete (not supported on the EC600S、EC600N、EC800N platform)
3420+
3421+
# EC200A/EC200U/BG95 platform:
3422+
import fota
3423+
from misc import Power
3424+
fota_obj = fota(reset_disable=1)
3425+
def result(args):
3426+
print('download status:',args[0],'download process:',args[1])
3427+
fota_obj.httpDownload(url1="http://www.example.com/dfota.bin",callback=result) #expected that not restart after execution
3428+
Power.powerRestart() #Manually restart
3429+
```
3430+
33433431

33443432

33453433
###### Interface to Upgrade Step by Step
33463434

3435+
- Note
3436+
- Currently only EC600S/EC600N/EC800N/EC200U/EC600U platform support this feature.
3437+
33473438
```python
33483439
'''
33493440
@Author: Pawn

zh-cn/api/QuecPythonClasslib.md

Lines changed: 97 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3258,9 +3258,13 @@ if __name__ == '__main__':
32583258

32593259
##### 创建fota对象
32603260

3261+
可选择传入参数以选择下载完升级包后是否自动重启
3262+
32613263
> **import fota**
32623264
>
3263-
> **fota_obj = fota()**
3265+
> **fota_obj = fota()** #下载完自动重启
3266+
>
3267+
> **fota_obj = fota(reset_disable=1)** #下载完不自动重启
32643268

32653269
##### 一键升级接口
32663270

@@ -3273,8 +3277,8 @@ if __name__ == '__main__':
32733277
| 参数 | 参数类型 | 参数说明 |
32743278
| -------- | -------- | ------------------------------------------------------------ |
32753279
| url1 | str | 待下载的第一阶段升级包的url |
3276-
| url2 | str | 待下载的第二阶段升级包的url,注:最小系统升级分为2个阶段,必须传入该参数,而差分升级、全包升级只有一个阶段,该参数禁止传入 |
3277-
| callback | function | 回调函数,显示下载进度和状态,可选择传不传入,注:EC600S/EC600N平台且是非最小系统升级方式时有效,其他平台该回调没有反应 |
3280+
| url2 | str | 待下载的第二阶段升级包的url,注:最小系统升级分为2个阶段,必须传入该参数,而差分升级、全包升级只有一个阶段,该参数禁止传入,仅EC600S/EC600N平台支持最小系统升级方式 |
3281+
| callback | function | 回调函数,显示下载进度和状态,可选择传不传入,注:非最小系统升级方式时有效 |
32783282

32793283
- 返回值
32803284

@@ -3283,7 +3287,7 @@ if __name__ == '__main__':
32833287
- 示例
32843288

32853289
```python
3286-
#args[0]表示下载状态,下载成功返回整型值:0或1或2,下载失败返回整型值:-1,args[1]表示下载进度,当下载状态是成功时表示百分比,下载状态是失败时表示错误码
3290+
#args[0]表示下载状态,下载成功返回整型值:0或1或2,下载失败返回整型值:非0、1、2,args[1]表示下载进度(注:EC600S/EC600N平台当下载状态是成功时表示百分比,下载状态是失败时表示错误码)
32873291
def result(args):
32883292
print('download status:',args[0],'download process:',args[1])
32893293

@@ -3314,7 +3318,7 @@ fota_obj.httpDownload(url1="http://www.example.com/fota1.bin",url2="http://www.e
33143318

33153319
* 注意
33163320

3317-
BC25PA平台不支持此方法
3321+
目前支持平台:EC600S/EC600N/EC800N/EC600U/EC200U
33183322

33193323

33203324
##### 分步升级接口,刷新缓存数据到flash
@@ -3333,7 +3337,7 @@ fota_obj.httpDownload(url1="http://www.example.com/fota1.bin",url2="http://www.e
33333337

33343338
* 注意
33353339

3336-
BC25PA平台不支持此方法
3340+
目前支持平台:EC600S/EC600N/EC800N/EC600U/EC200U
33373341

33383342

33393343
##### 分步升级接口,数据校验
@@ -3352,7 +3356,7 @@ fota_obj.httpDownload(url1="http://www.example.com/fota1.bin",url2="http://www.e
33523356

33533357
* 注意
33543358

3355-
BC25PA平台不支持此方法
3359+
目前支持平台:EC600S/EC600N/EC800N/EC600U/EC200U
33563360

33573361
* 示例
33583362

@@ -3361,13 +3365,82 @@ fota_obj.httpDownload(url1="http://www.example.com/fota1.bin",url2="http://www.e
33613365
0
33623366
```
33633367

3368+
##### 设置FOTA下载APN
3369+
3370+
> fota_obj.apn_set(fota_apn=,ip_type=,fota_user=,fota_password=)
3371+
3372+
设置FOTA下载使用的APN信息。
3373+
3374+
* 参数
3375+
3376+
| 参数 | 参数类型 | 参数说明 |
3377+
| ------------- | -------- | ---------------------------------------------- |
3378+
| fota_apn | str | APN(可选择传不传入该参数) |
3379+
| ip_type | int | IP类型:0-IPV41-IPV6(可选择传不传入该参数) |
3380+
| fota_user | str | 用户名(可选择传不传入该参数) |
3381+
| fota_password | str | 密码(可选择传不传入该参数) |
3382+
3383+
* 返回值
3384+
3385+
写入成功返回整型值0,写入失败返回值整型值-1
3386+
3387+
* 示例
3388+
3389+
```python
3390+
>>> fota_obj.apn_set(fota_apn="CMNET",ip_type=0,fota_user="abc",fota_password="123")
3391+
0
3392+
```
3393+
3394+
* 注意
3395+
3396+
目前支持平台:BG95
3397+
3398+
##### 取消FOTA下载
3399+
3400+
> fota_obj.download_cancel()
3401+
3402+
取消正在进行的FOTA下载。
3403+
3404+
- 参数
3405+
3406+
3407+
3408+
* 返回值
3409+
3410+
取消成功返回整型值0,取消失败返回整型值-1
3411+
3412+
* 示例
3413+
3414+
```python
3415+
import fota
3416+
import _thread
3417+
import utime
3418+
3419+
def th_func():
3420+
utime.sleep(40) #时间根据下载包的大小来定,确保在下载完之前取消
3421+
fota_obj.download_cancel()
3422+
3423+
def result(args):
3424+
print('download status:',args[0],'download process:',args[1])
3425+
3426+
fota_obj = fota()
3427+
_thread.start_new_thread(th_func, ())
3428+
fota_obj.httpDownload(url1="http://www.example.com/fota.bin",callback=result)
3429+
```
3430+
3431+
* 注意
3432+
3433+
目前支持平台:BG95
3434+
33643435

33653436

33663437
##### 使用示例
33673438

33683439
###### 一键升级接口
33693440

33703441
```python
3442+
#下载完自动重启
3443+
33713444
import fota
33723445
import utime
33733446
import log
@@ -3398,10 +3471,27 @@ if __name__ == '__main__':
33983471
run()
33993472
```
34003473

3474+
```python
3475+
# 下载完不自动重启(EC600S/EC600N/EC800N/平台不支持)
3476+
3477+
# EC200A/EC200U平台/BG95平台:
3478+
import fota
3479+
from misc import Power
3480+
fota_obj = fota(reset_disable=1)
3481+
def result(args):
3482+
print('download status:',args[0],'download process:',args[1])
3483+
fota_obj.httpDownload(url1="http://www.example.com/dfota.bin",callback=result) #期望下载完不重启
3484+
Power.powerRestart() #手动重启进行升级
3485+
```
3486+
34013487

34023488

34033489
###### 分步升级接口
34043490

3491+
- 注意
3492+
3493+
目前支持平台:EC600S/EC600N/EC800N/EC600U/EC200U
3494+
34053495
```python
34063496
'''
34073497
@Author: Pawn

0 commit comments

Comments
 (0)