• 大小: 9.59MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-08-22
  • 语言: 其他
  • 标签:

资源简介

EPS8266在线升级例程,OTA例程。

资源截图

代码片段和文件信息

/*
 * ESPRESSIF MIT License
 *
 * Copyright (c) 2016 
 *
 * Permission is hereby granted for use on ESPRESSIF SYSTEMS ESP8266 only in which case
 * it is free of charge to any person obtaining a copy of this software and associated
 * documentation files (the “Software“) to deal in the Software without restriction including
 * without limitation the rights to use copy modify merge publish distribute sublicense
 * and/or sell copies of the Software and to permit persons to whom the Software is furnished
 * to do so subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or
 * substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED “AS IS“ WITHOUT WARRANTY OF ANY KIND EXPRESS OR
 * IMPLIED INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY FITNESS
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM DAMAGES OR OTHER LIABILITY WHETHER
 * IN AN ACTION OF CONTRACT TORT OR OTHERWISE ARISING FROM OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 */

#include “ets_sys.h“
#include “osapi.h“
#include “ip_addr.h“
#include “espconn.h“
#include “mem.h“
#include “user_interface.h“
#include “smartconfig.h“
#include “airkiss.h“
#include “c_types.h“
#include “upgrade.h“

#define fileBinPath  “xuhong/8266NewBin/“

LOCAL esp_udp ssdp_udp;
LOCAL struct espconn pssdpudpconn;
LOCAL os_timer_t ssdp_time_serv;


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);
}

/**
 * server_ip: 服务器地址
 * port:服务器端口
 * path:文件
 */
void ICACHE_FLASH_ATTR ota_start_Upgrade(const char *server_ip uint16_t portconst char *path) {
const char* file;
//获取系统的目前加载的是哪个bin文件
uint8_t userBin = system_upgrade_userbin_check();

switch (userBin) {

//如果检查当前的是处于user1的加载文件,那么拉取的就是user2.bin
case UPGRADE_FW_BIN1:
file = “user2.4096.new.6.bin“;
break;

//如果检查当前的是处于user2的加载文件,那么拉取的就是user1.bin
case UPGRADE_FW_BIN2:
file = “user1.4096.new.6.bin“;
break;

//如果检查都不是,可能此刻不是OTA的bin固件
default:
os_printf(“Fail read system_upgrade_userbin_check! \n\n“);
return;
}

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;
//设置OTA回调函数
update->check_cb = ota_finished_callback;
//设置定时回调时间
update->check_times = 10000;
//从 4M *1024 =4096申请内存
update->url = (uint8 *)os_zalloc(4096);

//打印下請求地址
os_printf(“Http Server Address:%d.%d.%d.

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-04-26 12:06  19_Esp8266_OTA_NONOS\
     文件        3719  2018-04-26 12:06  19_Esp8266_OTA_NONOS\.cproject
     文件         798  2018-04-26 12:06  19_Esp8266_OTA_NONOS\.project
     目录           0  2018-04-26 12:06  19_Esp8266_OTA_NONOS\.settings\
     目录           0  2018-04-27 11:38  19_Esp8266_OTA_NONOS\app\
     目录           0  2018-04-26 12:06  19_Esp8266_OTA_NONOS\app\.output\
     目录           0  2018-04-27 11:38  19_Esp8266_OTA_NONOS\app\.output\eagle\
     目录           0  2018-04-27 11:38  19_Esp8266_OTA_NONOS\app\.output\eagle\debug\
     目录           0  2018-04-27 11:38  19_Esp8266_OTA_NONOS\app\.output\eagle\debug\bin\
     目录           0  2018-04-27 11:38  19_Esp8266_OTA_NONOS\app\.output\eagle\debug\image\
     文件      337118  2018-04-27 11:38  19_Esp8266_OTA_NONOS\app\.output\eagle\debug\image\eagle.app.v6.out
     文件        3080  2018-02-06 04:45  19_Esp8266_OTA_NONOS\app\gen_misc.bat
     文件        3788  2018-02-06 04:45  19_Esp8266_OTA_NONOS\app\gen_misc.sh
     目录           0  2018-04-26 12:04  19_Esp8266_OTA_NONOS\app\include\
     文件        1296  2018-02-06 04:45  19_Esp8266_OTA_NONOS\app\include\user_config.h
     文件        2814  2018-02-06 04:45  19_Esp8266_OTA_NONOS\app\Makefile
     目录           0  2018-04-26 14:41  19_Esp8266_OTA_NONOS\app\user\
     目录           0  2018-04-26 12:06  19_Esp8266_OTA_NONOS\app\user\.output\
     目录           0  2018-04-27 11:38  19_Esp8266_OTA_NONOS\app\user\.output\eagle\
     目录           0  2018-04-27 11:38  19_Esp8266_OTA_NONOS\app\user\.output\eagle\debug\
     目录           0  2018-04-27 11:38  19_Esp8266_OTA_NONOS\app\user\.output\eagle\debug\lib\
     文件       22956  2018-04-27 11:38  19_Esp8266_OTA_NONOS\app\user\.output\eagle\debug\lib\libuser.a
     目录           0  2018-04-27 11:38  19_Esp8266_OTA_NONOS\app\user\.output\eagle\debug\obj\
     文件        1317  2018-04-27 11:38  19_Esp8266_OTA_NONOS\app\user\.output\eagle\debug\obj\user_main.d
     文件       22692  2018-04-27 11:38  19_Esp8266_OTA_NONOS\app\user\.output\eagle\debug\obj\user_main.o
     文件        1477  2018-02-06 04:45  19_Esp8266_OTA_NONOS\app\user\Makefile
     文件        7560  2018-04-27 11:37  19_Esp8266_OTA_NONOS\app\user\user_main.c
     目录           0  2018-04-26 14:49  19_Esp8266_OTA_NONOS\bin\
     目录           0  2018-02-06 04:45  19_Esp8266_OTA_NONOS\bin\at\
     目录           0  2018-02-06 04:45  19_Esp8266_OTA_NONOS\bin\at\1024+1024\
     文件      407796  2018-02-06 04:45  19_Esp8266_OTA_NONOS\bin\at\1024+1024\user1.2048.new.5.bin
............此处省略112个文件信息

评论

共有 条评论

相关资源