From 570d2cf9aea3c3b93b0774fbbc5a8eff346d3250 Mon Sep 17 00:00:00 2001 From: Felix Hou Date: Wed, 15 Jan 2025 17:10:36 +0800 Subject: [PATCH] =?UTF-8?q?=20():=20<=E5=9B=BA=E4=BB=B6fota?= =?UTF-8?q?=E7=A4=BA=E4=BE=8B=E4=BB=A3=E7=A0=81=E5=A2=9E=E5=8A=A0=E7=BD=91?= =?UTF-8?q?=E7=BB=9C=E6=A3=80=E6=B5=8B=E5=8A=9F=E8=83=BD>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 固件版本: N/A 是否需要文案翻译: 否 --- docs/API_reference/en/syslib/fota.md | 34 ++++++++++++++++--------- docs/API_reference/zh/syslib/fota.md | 38 ++++++++++++++++++---------- 2 files changed, 46 insertions(+), 26 deletions(-) diff --git a/docs/API_reference/en/syslib/fota.md b/docs/API_reference/en/syslib/fota.md index 6c94f2c7..0a78f322 100644 --- a/docs/API_reference/en/syslib/fota.md +++ b/docs/API_reference/en/syslib/fota.md @@ -10,26 +10,36 @@ import fota import utime import log +import checkNet # Sets the log output level log.basicConfig(level=log.INFO) fota_log = log.getLogger("Fota") +PROJECT_NAME = "QuecPython_fota_example" +PROJECT_VERSION = "1.0.0" + +checknet = checkNet.CheckNetwork(PROJECT_NAME, PROJECT_VERSION) + def result(args): print('download status:',args[0],'download process:',args[1]) - + def run(): - fota_obj = fota() # Creates a FOTA object - fota_log.info("httpDownload...") - # Methods of DFOTA upgrades - res = fota_obj.httpDownload(url1="http://www.example.com/fota.bin",callback=result) - # Methods of mini FOTA - #res = fota_obj.httpDownload(url1="http://www.example.com/fota1.bin",url2="http://www.example.com/fota2.bin") - if res != 0: - fota_log.error("httpDownload error") - return - fota_log.info("wait httpDownload update...") - utime.sleep(2) + stagecode, subcode = checknet.wait_network_connected(30) + if stagecode == 3 and subcode == 1: + fota_obj = fota() # Creates a FOTA object + fota_log.info("httpDownload...") + # Methods of DFOTA upgrades + res = fota_obj.httpDownload(url1="http://www.example.com/fota.bin",callback=result) + # Methods of mini FOTA + #res = fota_obj.httpDownload(url1="http://www.example.com/fota1.bin",url2="http://www.example.com/fota2.bin") + if res != 0: + fota_log.error("httpDownload error") + return + fota_log.info("wait httpDownload update...") + utime.sleep(2) + else: + socket_log.info('Network connection failed! stagecode = {}, subcode = {}'.format(stagecode, subcode)) if __name__ == '__main__': fota_log.info("run start...") diff --git a/docs/API_reference/zh/syslib/fota.md b/docs/API_reference/zh/syslib/fota.md index f462f1b3..dd165b6b 100644 --- a/docs/API_reference/zh/syslib/fota.md +++ b/docs/API_reference/zh/syslib/fota.md @@ -10,28 +10,38 @@ import fota import utime import log +import checkNet # 设置日志输出级别 log.basicConfig(level=log.INFO) fota_log = log.getLogger("Fota") +PROJECT_NAME = "QuecPython_fota_example" +PROJECT_VERSION = "1.0.0" + +checknet = checkNet.CheckNetwork(PROJECT_NAME, PROJECT_VERSION) + def result(args): print('download status:',args[0],'download process:',args[1]) - + def run(): - fota_obj = fota() # 创建Fota对象 - fota_log.info("httpDownload...") - #差分升级方式 - res = fota_obj.httpDownload(url1="http://www.example.com/fota.bin",callback=result) - #mini fota方式 - #res = fota_obj.httpDownload(url1="http://www.example.com/fota1.bin",url2="http://www.example.com/fota2.bin") - #差分升级FTP方式 - #res = fota_obj.httpDownload(url1="ftp://user:password@ip:port/fota.bin",callback=result) #其中user,password,ip,port需要填写具体使用的FTP服务器信息 - if res != 0: - fota_log.error("httpDownload error") - return - fota_log.info("wait httpDownload update...") - utime.sleep(2) + stagecode, subcode = checknet.wait_network_connected(30) + if stagecode == 3 and subcode == 1: + fota_obj = fota() # 创建Fota对象 + fota_log.info("httpDownload...") + #差分升级方式 + res = fota_obj.httpDownload(url1="http://www.example.com/fota.bin",callback=result) + #mini fota方式 + #res = fota_obj.httpDownload(url1="http://www.example.com/fota1.bin",url2="http://www.example.com/fota2.bin") + #差分升级FTP方式 + #res = fota_obj.httpDownload(url1="ftp://user:password@ip:port/fota.bin",callback=result) #其中user,password,ip,port需要填写具体使用的FTP服务器信息 + if res != 0: + fota_log.error("httpDownload error") + return + fota_log.info("wait httpDownload update...") + utime.sleep(2) + else: + socket_log.info('Network connection failed! stagecode = {}, subcode = {}'.format(stagecode, subcode)) if __name__ == '__main__': fota_log.info("run start...") -- Gitee