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.
 
 

102 lines
3.0 KiB

#ifndef H_MESH_NETWORK
#define H_MESH_NETWORK
#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"
#ifndef CONFIG_MESH_MESSAGE_SIZE
#define CONFIG_MESH_MESSAGE_SIZE 1500
#endif
#ifndef CONFIG_MESH_TOPOLOGY
#define CONFIG_MESH_TOPOLOGY MESH_TOPO_TREE
#endif
#ifndef CONFIG_MESH_MAX_LAYER
#define CONFIG_MESH_MAX_LAYER 6
#endif
#ifndef CONFIG_MESH_ID
#define CONFIG_MESH_ID "00, 00, 00, 00, 00, 00"
#endif
#ifndef CONFIG_MESH_AP_AUTHMODE
#define CONFIG_MESH_AP_AUTHMODE WIFI_AUTH_WPA2_PSK
#endif
#ifndef CONFIG_MESH_AP_CONNECTIONS
#define CONFIG_MESH_AP_CONNECTIONS 6
#endif
#ifndef CONFIG_MESH_AP_PASSWD
#define CONFIG_MESH_AP_PASSWD "MAP_PASSWD"
#endif
#ifndef CONFIG_MESH_CHANNEL
#define CONFIG_MESH_CHANNEL 0
#endif
#ifndef CONFIG_MESH_ROUTER_SSID
#define CONFIG_MESH_ROUTER_SSID "ROUTER_SSID"
#endif
#ifndef CONFIG_MESH_ROUTER_PASSWD
#define CONFIG_MESH_ROUTER_PASSWD "ROUTER_PASSWD"
#endif
#ifndef CONFIG_MESH_ROUTE_TABLE_SIZE
#define CONFIG_MESH_ROUTE_TABLE_SIZE 50
#endif
struct meshPacket
{
enum otaMeshPacketType
{
APP_Data, //data for application
OTA_Version_Request, //send own version in payload
OTA_Version_Response, //send own version in payload
OTA_Data, //send image segment
OTA_ACK, //ack image segment
OTA_Complete //signal end of image
} type;
uint8_t au8Payload[1024];
mesh_addr_t meshSenderAddr;
};
typedef struct meshPacket MESH_PACKET_t;
extern bool bIsMeshConnected;
extern int32_t i32MeshLayer;
extern mesh_addr_t meshParentAddr;
extern esp_netif_t* netif_sta;
extern uint8_t u8ownMAC[6];
extern void (*pOTAChildConnectHandle)(uint8_t* );
extern void (*pChangeStateOfServerWorkerHandle)(bool );
esp_err_t errMeshNetworkInitialize();
esp_err_t errMeshNetworkInitializeWiFi();
esp_err_t errMeshNetworkInitializeRouter(mesh_cfg_t* cfg);
esp_err_t errMeshNetworkSetAppReceiveHandle(void (*pAppRxHandleTmp)(uint8_t * pu8Data, uint8_t* pu8Sender));
esp_err_t errMeshNetworkSetChildConnectedHandle(void (*pChildConnectHandleTmp)(uint8_t * pu8Data));
esp_err_t errMeshNetworkSetOTAMessageHandleHandle(void (*pOTAMessageHandleTmp)(MESH_PACKET_t* puMeshPacket));
esp_err_t errMeshNetworkSetChangeStateOfServerWorkerHandle(void (*pChangeStateOfServerWorkerHandleTmp)(bool bState));
bool bCheckMACEquality(uint8_t* pu8aMAC, uint8_t* pu8bMAC);
void vGetOwnAddr(mesh_addr_t* pMeshOwnAddr);
esp_err_t errGetParentNode(mesh_addr_t* pMeshParentAddr);
esp_err_t errGetChildren(mesh_addr_t* pChildren, uint16_t* pu16ChildrenSize);
bool bIsRootNode();
esp_err_t errStartReceiveTask();
void vTaskReceiveMeshData(void *arg);
void vMeshEventHandler(void *arg, esp_event_base_t event_base, int32_t i32EventID, void* vpEventData);
void vIPEventHandler(void *arg, esp_event_base_t event_base, int32_t i32EventID, void *event_data);
esp_err_t errSendMeshPacket(mesh_addr_t* pAddrDest, MESH_PACKET_t* pPacket);
#endif /* H_MESH_NETWORK */

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