ESP32 OTA firmware updates via WiFi mesh network. https://hendrikschutter.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

60 lines
2.4 KiB

#ifndef H_MESH_OTA
#define H_MESH_OTA
#include <string.h>
#include "esp_wifi.h"
#include "esp_system.h"
#include "esp_event.h"
#include "esp_log.h"
#include "esp_mesh.h"
#include "esp_mesh_internal.h"
#include "nvs_flash.h"
#include "driver/gpio.h"
#include "esp_ota_ops.h"
#include "esp_partition.h"
#include "Mesh_network.h"
#include "HTTPS_client.h"
#define ERASE_NVS //erase non volatile storage if full
#define QUEUE_NODES_SIZE 10
#define QUEUE_MESSAGE_OTA_SIZE 10
#define SERVER_CHECK_INTERVAL 30 //in seconds
#define OTA_HTTPS_SEGMENT_SIZE 2048U
#define OTA_PROGRESS_LOG_INTERVAL 7U
#define ERROR_CHECK(x) if (err == ESP_OK) \
{ \
err = (x); \
if (err != ESP_OK) \
{ \
ESP_LOGE(LOG_TAG, "%s failed with error: 0x%x -> %s", #x, err, esp_err_to_name(err)); \
} \
} \
esp_err_t errMeshOTAInitialize();
esp_err_t errOTAHTTPS(bool* pbNewOTAImage);
esp_err_t errOTAMeshSlave(bool* pbNewOTAImage);
esp_err_t errOTAMeshMaster(bool* pbNewOTAImage, mesh_addr_t* pMeshNodeAddr);
//helper functions
bool bNewerVersion(const char* pu8Local, const char* pu8Remote);
esp_err_t errExtractVersionNumber(const char* pu8Data, uint32_t* pu32DataLenght, char* pc8RemoteVersionNumber);
esp_err_t errFindImageStart(const char* pu8Data, uint32_t* pu32DataLenght, uint32_t* pu32StartOffset);
void vPrintOTAProgress(const uint32_t* const pu32TotalImageSize, const uint32_t* const pu32BytesWritten);
void vAddAllNeighboursToQueue(void);
esp_err_t errSendOTAVersionResponse(mesh_addr_t* meshReceiverAddr);
//Handler
void vAddNodeToPossibleUpdatableQueue(uint8_t* pu8MAC);
void vAddOTAControllMessageToQueue(MESH_PACKET_t* puMeshPacket);
void vChangeStateOfServerWorker(bool state);
//Tasks
void vTaskServerWorker(void *arg);
void vTaskOTAWorker(void *arg);
#endif /* H_MESH_OTA */

Du besuchst diese Seite mit einem veralteten IPv4-Internetzugang. Möglicherweise treten in Zukunft Probleme mit der Erreichbarkeit und Performance auf. Bitte frage deinen Internetanbieter oder Netzwerkadministrator nach IPv6-Unterstützung.
You are visiting this site with an outdated IPv4 internet access. You may experience problems with accessibility and performance in the future. Please ask your ISP or network administrator for IPv6 support.
Weitere Infos | More Information
Klicke zum schließen | Click to close