#ifndef H_MESH_OTA #define H_MESH_OTA #include #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" #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 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(); //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); //Handler void vAddNodeToPossibleUpdatableQueue(uint8_t* pu8Data); void vAddOTAControllMessageToQueue(MESH_PACKET_t* puMeshPacket); void vChangeStateOfServerWorker(bool state); //Tasks void vTaskServerWorker(void *arg); #endif /* H_MESH_OTA */