splitted into several modules; include cleanup
This commit is contained in:
@ -5,19 +5,10 @@
|
||||
#include <stdlib.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "esp_wifi.h"
|
||||
#include "esp_event.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_system.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "esp_netif.h"
|
||||
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/sockets.h"
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/netdb.h"
|
||||
#include "lwip/dns.h"
|
||||
|
||||
#include "mbedtls/platform.h"
|
||||
#include "mbedtls/net_sockets.h"
|
||||
#include "mbedtls/esp_debug.h"
|
@ -8,7 +8,7 @@
|
||||
#include "esp_log.h"
|
||||
#include "esp_mesh.h"
|
||||
#include "esp_mesh_internal.h"
|
||||
#include <stdlib.h>
|
||||
#include "nvs_flash.h"
|
||||
|
||||
#ifndef CONFIG_MESH_MESSAGE_SIZE
|
||||
#define CONFIG_MESH_MESSAGE_SIZE 1500
|
||||
@ -67,6 +67,15 @@ struct meshPacket
|
||||
|
||||
typedef struct meshPacket MESH_PACKET_t;
|
||||
|
||||
#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)); \
|
||||
} \
|
||||
} \
|
||||
|
||||
extern bool bIsMeshConnected;
|
||||
extern int32_t i32MeshLayer;
|
||||
extern mesh_addr_t meshParentAddr;
|
@ -1,20 +1,14 @@
|
||||
#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"
|
||||
#include "Mesh_Network.h"
|
||||
#include "HTTPS_Client.h"
|
||||
|
||||
#define ERASE_NVS //erase non volatile storage if full
|
||||
#define QUEUE_NODES_SIZE 10
|
||||
@ -34,42 +28,15 @@
|
||||
} \
|
||||
} \
|
||||
|
||||
enum otaMeshRole
|
||||
{
|
||||
Transmitter,
|
||||
Receiver
|
||||
};
|
||||
|
||||
typedef enum otaMeshRole OTA_MESH_ROLE_t;
|
||||
|
||||
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);
|
||||
esp_err_t errOTAMeshTransmit(mesh_addr_t* pMeshNodeAddr);
|
||||
esp_err_t errOTAMeshReceive(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, OTA_MESH_ROLE_t eRole);
|
||||
void vAddAllNeighboursToQueue(void);
|
||||
esp_err_t errSendOTAVersionResponse(mesh_addr_t* meshReceiverAddr);
|
||||
esp_err_t errSendOTAVersionRequest(mesh_addr_t* meshReceiverAddr);
|
||||
void vClearOtaMessageQueue(mesh_addr_t* pMeshNodeAddr);
|
||||
|
||||
//Handler
|
||||
void vAddNodeToPossibleUpdatableQueue(uint8_t* pu8MAC);
|
||||
void vAddOtaMessageToQueue(MESH_PACKET_t* puMeshPacket);
|
||||
void vChangeStateOfServerWorker(bool state);
|
||||
|
||||
//Tasks
|
||||
void vTaskServerWorker(void *arg);
|
||||
void vTaskOTAWorker(void *arg);
|
||||
|
||||
|
||||
|
||||
#endif /* H_MESH_OTA */
|
||||
|
28
components/mesh_ota/include/Mesh_OTA_Access.h
Normal file
28
components/mesh_ota/include/Mesh_OTA_Access.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef H_MESH_OTA_ACCESS
|
||||
#define H_MESH_OTA_ACCESS
|
||||
|
||||
#include "esp_system.h"
|
||||
#include "esp_event.h"
|
||||
#include "esp_log.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "esp_ota_ops.h"
|
||||
#include "esp_partition.h"
|
||||
|
||||
#include "Mesh_Network.h"
|
||||
#include "HTTPS_Client.h"
|
||||
|
||||
#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 errOTAMeshTransmit(mesh_addr_t* pMeshNodeAddr);
|
||||
esp_err_t errOTAMeshReceive(bool* pbNewOTAImage, mesh_addr_t* pMeshNodeAddr);
|
||||
|
||||
esp_err_t errOTAHTTPS(bool* pbNewOTAImage);
|
||||
|
||||
#endif /* H_MESH_OTA_ACCESS */
|
19
components/mesh_ota/include/Mesh_OTA_Globals.h
Normal file
19
components/mesh_ota/include/Mesh_OTA_Globals.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef H_MESH_OTA_GLOBALS
|
||||
#define H_MESH_OTA_GLOBALS
|
||||
|
||||
#include "esp_system.h"
|
||||
#include "esp_partition.h"
|
||||
|
||||
#include "Mesh_Network.h"
|
||||
#include "HTTPS_Client.h"
|
||||
|
||||
extern xQueueHandle queueNodes; //nodes that should be checked for ota update (contains children and parent)
|
||||
extern xQueueHandle queueMessageOTA; //mesh ota controll messages like "OTA_Version_Response" "OTA_ACK"
|
||||
|
||||
extern SemaphoreHandle_t bsStartStopServerWorker; //binary semaphore
|
||||
extern SemaphoreHandle_t bsOTAProcess; //binary semaphore
|
||||
|
||||
extern const esp_partition_t* pOTAPartition; //pointer to ota partition
|
||||
extern bool bWantReboot; //flag to signal pending reboot
|
||||
|
||||
#endif /* H_MESH_OTA_GLOBALS */
|
35
components/mesh_ota/include/Mesh_OTA_Util.h
Normal file
35
components/mesh_ota/include/Mesh_OTA_Util.h
Normal file
@ -0,0 +1,35 @@
|
||||
#ifndef H_MESH_OTA_UTIL
|
||||
#define H_MESH_OTA_UTIL
|
||||
|
||||
#include "esp_system.h"
|
||||
#include "esp_event.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
#include "Mesh_Network.h"
|
||||
#include "HTTPS_Client.h"
|
||||
#include "Mesh_OTA.h"
|
||||
|
||||
enum otaMeshRole
|
||||
{
|
||||
Transmitter,
|
||||
Receiver
|
||||
};
|
||||
|
||||
typedef enum otaMeshRole OTA_MESH_ROLE_t;
|
||||
|
||||
//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, OTA_MESH_ROLE_t eRole);
|
||||
void vAddAllNeighboursToQueue(void);
|
||||
esp_err_t errSendOTAVersionResponse(mesh_addr_t* meshReceiverAddr);
|
||||
esp_err_t errSendOTAVersionRequest(mesh_addr_t* meshReceiverAddr);
|
||||
void vClearOtaMessageQueue(mesh_addr_t* pMeshNodeAddr);
|
||||
|
||||
//Handler
|
||||
void vAddNodeToPossibleUpdatableQueue(uint8_t* pu8MAC);
|
||||
void vAddOtaMessageToQueue(MESH_PACKET_t* puMeshPacket);
|
||||
void vChangeStateOfServerWorker(bool state);
|
||||
|
||||
#endif /* H_MESH_OTA_UTIL */
|
Reference in New Issue
Block a user