【已解决】ESP_MESH_LITE OTA升级问题

aiya122
Posts: 15
Joined: Sun Jun 19, 2022 8:37 am

【已解决】ESP_MESH_LITE OTA升级问题

Postby aiya122 » Tue Jun 20, 2023 4:36 am

请问一下我成功使用了esp mesh lite连接外网 ,但是不知道如何使用他的OTA升级功能 ,目前所有设备能够单独连接外网 使用原来的OTA升级方式(IDF例程中),单设备更新没有问题 ,多设备同时 会导致mesh 连接丢失, lite库中并没有OTA相关的例程,请问哪里有相关资料可以参考呢

Code: Select all





/**
****************************************************************************************
* @FilePath: wifimesh32_lite.c
* @Author: jack
* @Date: 2023-06-16 16:21:58
* @LastEditors:
* @LastEditTime: 2023-06-16 16:21:58
* @Copyright: 2023 xxxTech CO.,LTD. All Rights Reserved.
* @Descripttion:
****************************************************************************************
*/
#include <inttypes.h>

#include "wifimesh32_lite.h"
extern esp_ip4_addr_t mqtt_send_ip;

static void ip_event_sta_got_ip_handler(void *arg, esp_event_base_t event_base,
                                        int32_t event_id, void *event_data)
{

    ip_event_got_ip_t *event = (ip_event_got_ip_t *)event_data;
    ESP_LOGI("mesh_lite_ay", "<mesh获取到>IP:" IPSTR, IP2STR(&event->ip_info.ip));
    mqtt_send_ip.addr = event->ip_info.ip.addr;
    // #if !CONFIG_MESH_USE_GLOBAL_DNS_IP
    //     esp_netif_t *netif = event->esp_netif;
    //     esp_netif_dns_info_t dns;
    //     ESP_ERROR_CHECK(esp_netif_get_dns_info(netif, ESP_NETIF_DNS_MAIN, &dns));
    //     mesh_netif_start_root_ap(esp_mesh_is_root(), dns.ip.u_addr.ip4.addr);
    // #endif
    mainuser();
    vTaskDelay(1000);
    // mqtt_app_start();
    DEVICEINFO.devicestatus = ping_mqtt_yes;
    // mainuser();

    // esp_mesh_comm_mqtt_task_start();
    //  example_start_file_server("/rdy");
}

static esp_err_t wifi_init(void)
{
    // Station
    wifi_config_t wifi_config;
    strcpy((char *)wifi_config.sta.ssid, DEVICEINFO.wifi_infometion.ssid);
    strcpy((char *)wifi_config.sta.password, DEVICEINFO.wifi_infometion.password);

    esp_bridge_wifi_set(WIFI_MODE_STA, (char *)wifi_config.sta.ssid, (char *)wifi_config.sta.password, NULL);

    // // Softap
    memset(&wifi_config, 0x0, sizeof(wifi_config_t));
    // size_t softap_ssid_len = sizeof(wifi_config.ap.ssid);
    // if (esp_mesh_lite_get_softap_ssid_from_nvs((char *)wifi_config.ap.ssid, &softap_ssid_len) != ESP_OK)
    // {
    snprintf((char *)wifi_config.ap.ssid, sizeof(wifi_config.ap.ssid), "%s", CONFIG_BRIDGE_SOFTAP_SSID);
    // }
    // size_t softap_psw_len = sizeof(wifi_config.ap.password);
    // if (esp_mesh_lite_get_softap_psw_from_nvs((char *)wifi_config.ap.password, &softap_psw_len) != ESP_OK)
    // {
    strlcpy((char *)wifi_config.ap.password, CONFIG_BRIDGE_SOFTAP_PASSWORD, sizeof(wifi_config.ap.password));
    // }
    esp_bridge_wifi_set(WIFI_MODE_AP, (char *)wifi_config.ap.ssid, (char *)wifi_config.ap.password, NULL);

    return ESP_OK;
}

void print_task_memory(void)
{
    char *task_list_buffer;
    UBaseType_t task_count = uxTaskGetNumberOfTasks();
    task_list_buffer = malloc(task_count * sizeof(TaskStatus_t));
    vTaskList(task_list_buffer);
    printf("Task Name\t\tStack High Water Mark\n");
    printf("----------------------------------------\n");
    TaskStatus_t *task_status_array = (TaskStatus_t *)task_list_buffer;
    for (int i = 0; i < task_count; i++)
    {
        printf("%s\t\t%d words\n", task_status_array[i].pcTaskName, task_status_array[i].usStackHighWaterMark);
    }
    free(task_list_buffer);
}

void tt(void)
{

    char *test;
    test = malloc(1000);
}
void wifi_lite(void *p)
{

    esp_bridge_create_all_netif();
    wifi_init();
    esp_mesh_lite_config_t mesh_lite_config = ESP_MESH_LITE_DEFAULT_INIT();
    strcpy(mesh_lite_config.device_category, "mjk");
    esp_mesh_lite_init(&mesh_lite_config);
    ESP_ERROR_CHECK(esp_event_handler_instance_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &ip_event_sta_got_ip_handler, NULL, NULL));
    int m = 0;
    while (1)
    {
        //    printf("wifi_lite\r\n");
        //     print_task_memory();
        m = m + 2;
        vTaskDelay(100);
    }
}

void wifimesh_lite(void)
{
    xTaskCreatePinnedToCore(wifi_lite, "wifi_lite", 10240, NULL, 5, NULL, 0);
}









代码如上 OTA 使用的是IDF例程中的HTTP方式 为了节约内存使用的是 双OTA分区无factory方式

ESP_TianSW
Posts: 52
Joined: Wed Sep 23, 2020 12:19 pm

Re: ESP_MESH_LITE OTA升级问题

Postby ESP_TianSW » Wed Jul 19, 2023 2:32 am

可以参考这部分文档

aiya122
Posts: 15
Joined: Sun Jun 19, 2022 8:37 am

Re: ESP_MESH_LITE OTA升级问题

Postby aiya122 » Wed Jul 19, 2023 4:03 am

谢谢大佬,困扰了这么久

Who is online

Users browsing this forum: No registered users and 10 guests