51 lines
1.8 KiB
C
51 lines
1.8 KiB
C
#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"
|
|
|
|
#define ERASE_NVS //erase non volatile storage if full
|
|
|
|
struct ota_mesh_packet
|
|
{
|
|
enum ota_mesh_packet_type
|
|
{
|
|
APP_Version_Request,
|
|
APP_Version_Response,
|
|
OTA_Data,
|
|
OTA_ACK,
|
|
OTA_Complete
|
|
} type;
|
|
|
|
uint8_t au8Payload[1024];
|
|
};
|
|
|
|
#define ERROR_CHECK(x) if (err == ESP_OK) \
|
|
{ \
|
|
err = (x); \
|
|
if (err != ESP_OK) \
|
|
{ \
|
|
ESP_LOGE(LOG_TAG, "%s failed with error: %d -> %s", #x, err, esp_err_to_name(err)); \
|
|
} \
|
|
} \
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
#endif /* H_MESH_OTA */
|