資源簡介
本人測試分別使用遠程服務器和本地服務器都可以實現OTA無線升級,升級后的程序穩定運行

代碼片段和文件信息
/******************************************************************************
?*?Copyright?2015-2018?Espressif?Systems?(Wuxi)
?*
?*?Description:?entry?file?of?user?application
?*
?*?Modification?history:
?*?????2015/3/06?v1.0?create?this?file.
*******************************************************************************/
#include?“c_types.h“
#include?“user_interface.h“
#include?“espconn.h“
#include?“mem.h“
#include?“osapi.h“
#include?“upgrade.h“
#include?“hsuser.h“
#ifdef?OTA_UPGRADE_SUPPORT?
void?ICACHE_FLASH_ATTR?ota_finished_callback(void?*arg)
{
struct?upgrade_server_info?*update?=?arg;
if?(update->upgrade_flag?==?true)
{
os_printf(“[OTA]success;?rebooting!\n“);
system_upgrade_reboot();
}
else
{
os_printf(“[OTA]failed!\n“);
}
os_free(update->pespconn);
os_free(update->url);
os_free(update);
}
void?ICACHE_FLASH_ATTR?ota_start_Upgrade(uint8_t?serverVersion?const?char?*server_ip?uint16_t?port?const?char?*path)
{
const?char*?file;
uint8_t?userBin?=?system_upgrade_userbin_check();
switch?(userBin)
{
case?UPGRADE_FW_BIN1:?file?=?“user2.4096.new.4.bin“;?break;?//??user2.bin
case?UPGRADE_FW_BIN2:?file?=?“user1.4096.new.4.bin“;?break;?//?user1.bin
default:
os_printf(“[OTA]Invalid?userbin?number!\n“);
return;
}
uint16_t?version=1;
if?(serverVersion?<=?version)
{
os_printf(“[OTA]No?update.?Server?version:%d?local?version?%d\n“?serverVersion?version);
return;
}
os_printf(“[OTA]Upgrade?available?version:?%d\n“?serverVersion);
struct?upgrade_server_info*?update?=?(struct?upgrade_server_info?*)os_zalloc(sizeof(struct?upgrade_server_info));
update->pespconn?=?(struct?espconn?*)os_zalloc(sizeof(struct?espconn));
os_memcpy(update->ip?server_ip?4);
update->port?=?port;
os_printf(“[OTA]Server?“IPSTR“:%d.?Path:?[%s]file:?[%s]\n“?IP2STR(update->ip)?update->port?path?file);
update->check_cb?=?ota_finished_callback;
update->check_times?=?10000;
update->url?=?(uint8?*)os_zalloc(512);
os_sprintf((char*)update->url
“GET?/%s%s?HTTP/1.1\r\n“
“Host:?“IPSTR“:%d\r\n“
“Connection:?keep-alive\r\n“
“\r\n“
path?file?IP2STR(update->ip)?update->port);
if?(system_upgrade_start(update)?==?false)
{
os_printf(“[OTA]Could?not?start?upgrade\n“);
os_free(update->pespconn);
os_free(update->url);
os_free(update);
}
else
{
os_printf(“[OTA]Upgrading...\n“);
}
}
#endif
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????4374970??2017-10-12?14:36??wifi空中升級\2a-esp8266-sdk_getting_started_guide_cn.pdf
?????文件????1586971??2017-10-12?14:36??wifi空中升級\99c-esp8266_fota_upgrade_cn.pdf
?????文件??????86171??2017-10-11?15:14??wifi空中升級\EasyWebSvr1.9.zip
?????文件???????2444??2017-10-12?13:58??wifi空中升級\ota_upgrade.c
?????文件???????1218??2017-10-12?15:34??wifi空中升級\wifi無線升級說明.txt
?????文件?????143464??2017-10-12?15:12??wifi空中升級\服務器使用教程.docx
?????目錄??????????0??2017-10-12?15:12??wifi空中升級
-----------?---------??----------?-----??----
??????????????6195238????????????????????7
- 上一篇:ARCHIBUS案例
- 下一篇:基于nrf51822的TSM12觸控例程
評論
共有 條評論