Browse Source

changed the most params to const

pull/2/head
Hendrik Schutter 1 year ago
parent
commit
77e87ec840
  1. 30
      components/mesh_ota/HTTPS_Client.c
  2. 58
      components/mesh_ota/Mesh_Network.c
  3. 2
      components/mesh_ota/Mesh_Network_Handler.c
  4. 26
      components/mesh_ota/Mesh_OTA.c
  5. 30
      components/mesh_ota/Mesh_OTA_Partition_Access.c
  6. 82
      components/mesh_ota/Mesh_OTA_Util.c
  7. 12
      components/mesh_ota/include/HTTPS_Client.h
  8. 26
      components/mesh_ota/include/Mesh_Network.h
  9. 4
      components/mesh_ota/include/Mesh_OTA.h
  10. 6
      components/mesh_ota/include/Mesh_OTA_Partition_Access.h
  11. 21
      components/mesh_ota/include/Mesh_OTA_Util.h
  12. 2
      main/Blinky_LED.c
  13. 2
      main/Blinky_LED.h

30
components/mesh_ota/HTTPS_Client.c

@ -12,12 +12,12 @@ static const char *REQUEST = "GET " CONFIG_OTA_HTTPS_URL " HTTP/1.1\r\n"
static HTTPS_Client_t sHTTPS_ClientConfig;
https_client_ret_t https_clientInitEmbedTLS();
https_client_ret_t errHTTPSClientConnectToServer();
https_client_ret_t errHTTPSClientValidateServer();
https_client_ret_t errHTTPSClientSendRequest();
https_client_ret_t https_clientInitEmbedTLS(void);
https_client_ret_t errHTTPSClientConnectToServer(void);
https_client_ret_t errHTTPSClientValidateServer(void);
https_client_ret_t errHTTPSClientSendRequest(void);
https_client_ret_t errHTTPSClientInitialize()
https_client_ret_t errHTTPSClientInitialize(void)
{
https_client_ret_t i32RetHTTPClient = HTTPS_CLIENT_OK;
@ -31,27 +31,27 @@ https_client_ret_t errHTTPSClientInitialize()
return i32RetHTTPClient;
}
https_client_ret_t errHTTPSClientRetrieveData(char* pu8Data, uint32_t* pu32DataLenght, uint32_t* pu32BytesRead)
https_client_ret_t errHTTPSClientRetrieveData(char* const cpu8Data, const uint32_t* const cpcu32DataLenght, uint32_t* pu32BytesRead)
{
https_client_ret_t i32RetHTTPClient = HTTPS_CLIENT_OK;
int32_t i32RetRetrieveData = ESP_OK;
bool bRetriveData = true;
bzero(pu8Data, *pu32DataLenght);
*pu32BytesRead = 0U;
bzero(cpu8Data, *cpcu32DataLenght);
(*pu32BytesRead) = 0U;
while (bRetriveData)
{
mbedtls_ssl_conf_read_timeout(&sHTTPS_ClientConfig.conf, HTTPS_READ_TIMEOUT); //set timeout
//Reading HTTP response
i32RetRetrieveData = mbedtls_ssl_read(&sHTTPS_ClientConfig.ssl, (unsigned char *)(pu8Data+(*pu32BytesRead)), ((*pu32DataLenght)-(*pu32BytesRead)));
i32RetRetrieveData = mbedtls_ssl_read(&sHTTPS_ClientConfig.ssl, (unsigned char *)(cpu8Data+(*pu32BytesRead)), ((*cpcu32DataLenght)-(*pu32BytesRead)));
if(i32RetRetrieveData > 0)
{
//Data received
*pu32BytesRead = *pu32BytesRead + i32RetRetrieveData;
if(*pu32DataLenght > 0)
if(*cpcu32DataLenght > 0)
{
//buffer not full yet --> read some more
bRetriveData = true;
@ -86,7 +86,7 @@ https_client_ret_t errHTTPSClientRetrieveData(char* pu8Data, uint32_t* pu32DataL
return i32RetHTTPClient;
}
https_client_ret_t errHTTPSClientReset()
https_client_ret_t errHTTPSClientReset(void)
{
https_client_ret_t i32RetHTTPClient = HTTPS_CLIENT_OK;
@ -103,7 +103,7 @@ https_client_ret_t errHTTPSClientReset()
return i32RetHTTPClient;
}
https_client_ret_t https_clientInitEmbedTLS()
https_client_ret_t https_clientInitEmbedTLS(void)
{
https_client_ret_t i32RetHTTPClient = HTTPS_CLIENT_OK;
@ -197,7 +197,7 @@ https_client_ret_t https_clientInitEmbedTLS()
return i32RetHTTPClient;
}
https_client_ret_t errHTTPSClientConnectToServer()
https_client_ret_t errHTTPSClientConnectToServer(void)
{
https_client_ret_t i32RetHTTPClient = HTTPS_CLIENT_OK;
int32_t i32RetServerConnect = ESP_OK;
@ -230,7 +230,7 @@ https_client_ret_t errHTTPSClientConnectToServer()
return i32RetHTTPClient;
}
https_client_ret_t errHTTPSClientValidateServer()
https_client_ret_t errHTTPSClientValidateServer(void)
{
https_client_ret_t i32RetHTTPClient = HTTPS_CLIENT_OK;
int32_t i32RetValidateServer = ESP_OK;
@ -248,7 +248,7 @@ https_client_ret_t errHTTPSClientValidateServer()
return i32RetHTTPClient;
}
https_client_ret_t errHTTPSClientSendRequest()
https_client_ret_t errHTTPSClientSendRequest(void)
{
https_client_ret_t i32RetHTTPClient = HTTPS_CLIENT_OK;
int32_t i32RetSendRequest = ESP_OK;

58
components/mesh_ota/Mesh_Network.c

@ -10,7 +10,7 @@ uint8_t u8ownMAC[6];
//w: errMeshNetworkInitialize; vMeshNetworkMeshEventHandler
//r: vMeshNetworkMeshEventHandler
esp_netif_t* netif_sta;
esp_netif_t* pNetifSta;
//w: errMeshNetworkInitialize; vMeshNetworkMeshEventHandler
//r: errMeshNetworkInitialize;
@ -25,10 +25,10 @@ int32_t i32MeshLayer;
mesh_addr_t meshParentAddr;
//function pointer for callbacks
void (*pAppRxHandle)(uint8_t*, uint8_t* );
void (*pOTAChildConnectHandle)(uint8_t* );
void (*pOTAMessageHandle)(MESH_PACKET_t* );
void (*pChangeStateOfServerWorkerHandle)(bool );
void (*pAppRxHandle)(const uint8_t* const, const uint8_t* const);
void (*pOTAChildConnectHandle)(const uint8_t* const);
void (*pOTAMessageHandle)(const MESH_PACKET_t* const);
void (*pChangeStateOfServerWorkerHandle)(const bool );
esp_err_t errMeshNetworkInitialize()
{
@ -36,7 +36,7 @@ esp_err_t errMeshNetworkInitialize()
esp_err_t err;
bIsMeshConnected = false;
i32MeshLayer = -1;
netif_sta = NULL;
pNetifSta = NULL;
err = nvs_flash_init(); //init non-volatile storage
@ -54,7 +54,7 @@ esp_err_t errMeshNetworkInitialize()
ERROR_CHECK(esp_event_loop_create_default());
//create network interfaces for mesh (only station instance saved for further manipulation, soft AP instance ignored
ERROR_CHECK(esp_netif_create_default_wifi_mesh_netifs(&netif_sta, NULL));
ERROR_CHECK(esp_netif_create_default_wifi_mesh_netifs(&pNetifSta, NULL));
//wifi initialization
ERROR_CHECK(errMeshNetworkInitializeWiFi());
@ -131,31 +131,31 @@ esp_err_t errMeshNetworkInitializeRouter(mesh_cfg_t* cfg)
return err;
}
esp_err_t errMeshNetworkSetChildConnectedHandle(void (*pChildConnectHandleTmp)(uint8_t * pu8Data))
esp_err_t errMeshNetworkSetChildConnectedHandle(void (*pChildConnectHandleTmp)(const uint8_t* const cpcu8Data))
{
pOTAChildConnectHandle = pChildConnectHandleTmp;
return ESP_OK;
}
esp_err_t errMeshNetworkSetAppReceiveHandle(void (*pAppRxHandleTmp)(uint8_t * pu8Data, uint8_t* pu8Sender))
esp_err_t errMeshNetworkSetAppReceiveHandle(void (*pAppRxHandleTmp)(const uint8_t* const cpcu8Data, const uint8_t* const pu8Sender))
{
pAppRxHandle = pAppRxHandleTmp; //set handle from app as receive handle if an app packet is received
return ESP_OK;
}
esp_err_t errMeshNetworkSetOTAMessageHandleHandle(void (*pOTAMessageHandleTmp)(MESH_PACKET_t* puMeshPacket))
esp_err_t errMeshNetworkSetOTAMessageHandleHandle(void (*pOTAMessageHandleTmp)(const MESH_PACKET_t* const cpcuMeshPacket))
{
pOTAMessageHandle = pOTAMessageHandleTmp;
return ESP_OK;
}
esp_err_t errMeshNetworkSetChangeStateOfServerWorkerHandle(void (*pChangeStateOfServerWorkerHandleTmp)(bool bState))
esp_err_t errMeshNetworkSetChangeStateOfServerWorkerHandle(void (*pChangeStateOfServerWorkerHandleTmp)(const bool cbState))
{
pChangeStateOfServerWorkerHandle = pChangeStateOfServerWorkerHandleTmp;
return ESP_OK;
}
esp_err_t errMeshNetworkSendMeshPacket(mesh_addr_t* pAddrDest, MESH_PACKET_t* pPacket)
esp_err_t errMeshNetworkSendMeshPacket(const mesh_addr_t* const cpcAddrDest, const MESH_PACKET_t* const cpcPacket)
{
esp_err_t err;
mesh_data_t data;
@ -164,9 +164,9 @@ esp_err_t errMeshNetworkSendMeshPacket(mesh_addr_t* pAddrDest, MESH_PACKET_t* pP
data.size = sizeof(tx_buf);
data.proto = MESH_PROTO_BIN;
data.tos = MESH_TOS_P2P;
memcpy(tx_buf, (uint8_t *)pPacket, sizeof(MESH_PACKET_t));
memcpy(tx_buf, (uint8_t *)cpcPacket, sizeof(MESH_PACKET_t));
err = esp_mesh_send(pAddrDest, &data, MESH_DATA_P2P, NULL, 0);
err = esp_mesh_send(cpcAddrDest, &data, MESH_DATA_P2P, NULL, 0);
return err;
}
@ -176,7 +176,7 @@ bool bMeshNetworkIsRootNode()
return esp_mesh_is_root();
}
bool bMeshNetworkIsNodeNeighbour(mesh_addr_t* pNode)
bool bMeshNetworkIsNodeNeighbour(const mesh_addr_t* const cpcNode)
{
esp_err_t err = ESP_OK;
bool bReturn = false;
@ -188,7 +188,7 @@ bool bMeshNetworkIsNodeNeighbour(mesh_addr_t* pNode)
if(err == ESP_OK)
{
if(bMeshNetworkCheckMACEquality(pNode->addr, addrParent.addr) == true)
if(bMeshNetworkCheckMACEquality(cpcNode->addr, addrParent.addr) == true)
{
bReturn = true; //node was found
}
@ -202,7 +202,7 @@ bool bMeshNetworkIsNodeNeighbour(mesh_addr_t* pNode)
for (uint16_t u16Index = 0; ((u16Index < u16ChildrenSize) && (err == ESP_OK) && (bReturn == false)); u16Index++)
{
if(bMeshNetworkCheckMACEquality(pNode->addr, childrenAddr[u16Index].addr) == true)
if(bMeshNetworkCheckMACEquality(cpcNode->addr, childrenAddr[u16Index].addr) == true)
{
bReturn = true; //node was found
}
@ -212,14 +212,14 @@ bool bMeshNetworkIsNodeNeighbour(mesh_addr_t* pNode)
}
//returns true if MAC address is equal
bool bMeshNetworkCheckMACEquality(uint8_t* pu8aMAC, uint8_t* pu8bMAC)
bool bMeshNetworkCheckMACEquality(const uint8_t* const cpcu8aMAC, const uint8_t* const cpcu8bMAC)
{
bool bRet = true;
uint8_t index = 0;
while ((index < 6) && (bRet == true))
{
if(pu8aMAC[index] != pu8bMAC[index])
if(cpcu8aMAC[index] != cpcu8bMAC[index])
{
bRet = false;
}
@ -227,7 +227,7 @@ bool bMeshNetworkCheckMACEquality(uint8_t* pu8aMAC, uint8_t* pu8bMAC)
if(index == 5)
{
//last byte of mac
if(abs((pu8aMAC[index] - pu8bMAC[index])) <= 1)
if(abs((cpcu8aMAC[index] - cpcu8bMAC[index])) <= 1)
{
bRet = true; //last byte differs 1 ore less
}
@ -251,17 +251,16 @@ esp_err_t errMeshNetworkStartReceiveTask()
return err;
}
void vMeshNetworkGetOwnAddr(mesh_addr_t* pMeshOwnAddr)
void vMeshNetworkGetOwnAddr(mesh_addr_t* const cpMeshOwnAddr)
{
memcpy(pMeshOwnAddr->addr, u8ownMAC, 6);
memcpy(cpMeshOwnAddr->addr, u8ownMAC, 6);
}
esp_err_t errMeshNetworkGetChildren(mesh_addr_t* pChildren, uint16_t* pu16ChildrenSize)
esp_err_t errMeshNetworkGetChildren(mesh_addr_t* const cpChildren, uint16_t* const cpu16ChildrenSize)
{
esp_err_t err = ESP_OK;
int route_table_size = 0;
*pu16ChildrenSize = 0;
*cpu16ChildrenSize = 0;
mesh_addr_t route_table[CONFIG_MESH_ROUTE_TABLE_SIZE];
ERROR_CHECK(esp_mesh_get_routing_table((mesh_addr_t *) &route_table, (CONFIG_MESH_ROUTE_TABLE_SIZE * 6), &route_table_size));
@ -273,8 +272,8 @@ esp_err_t errMeshNetworkGetChildren(mesh_addr_t* pChildren, uint16_t* pu16Childr
{
//child node
//ESP_LOGI(LOG_TAG, "adding Node: \"0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x\" ", route_table[index].addr[0], route_table[index].addr[1], route_table[index].addr[2], route_table[index].addr[3], route_table[index].addr[4], route_table[index].addr[5]);
pChildren[*pu16ChildrenSize] = route_table[index];
*pu16ChildrenSize = (*pu16ChildrenSize)+1;
cpChildren[*cpu16ChildrenSize] = route_table[index];
(*cpu16ChildrenSize) = (*cpu16ChildrenSize)+1;
}
}
}
@ -330,8 +329,7 @@ void vMeshNetworkTaskReceiveMeshData(void *arg)
} //end while
}
esp_err_t errMeshNetworkGetParentNode(mesh_addr_t* pMeshParentAddr)
esp_err_t errMeshNetworkGetParentNode(mesh_addr_t* const cpMeshParentAddr)
{
esp_err_t err = ESP_OK;
@ -343,7 +341,7 @@ esp_err_t errMeshNetworkGetParentNode(mesh_addr_t* pMeshParentAddr)
else
{
//node has parent
memcpy(pMeshParentAddr, &meshParentAddr, sizeof(mesh_addr_t));
memcpy(cpMeshParentAddr, &meshParentAddr, sizeof(mesh_addr_t));
}
return err;
}

2
components/mesh_ota/Mesh_Network_Handler.c

@ -90,7 +90,7 @@ last_layer = i32MeshLayer;
bIsMeshConnected = true;
if (esp_mesh_is_root())
{
if(esp_netif_dhcpc_start(netif_sta) == ESP_ERR_ESP_NETIF_DHCP_ALREADY_STARTED) //get a IP from router
if(esp_netif_dhcpc_start(pNetifSta) == ESP_ERR_ESP_NETIF_DHCP_ALREADY_STARTED) //get a IP from router
{
if(pChangeStateOfServerWorkerHandle){pChangeStateOfServerWorkerHandle(true);}// signal reconnect
}

26
components/mesh_ota/Mesh_OTA.c

@ -197,13 +197,13 @@ void vMeshOtaTaskOTAWorker(void *arg)
}
}
esp_err_t errMeshOtaSlaveEndpoint(bool* pbNewOTAImage)
esp_err_t errMeshOtaSlaveEndpoint(bool* const cpbNewOTAImage)
{
esp_err_t err = ESP_OK;
MESH_PACKET_t sOTAMessage;
const esp_partition_t* pBootPartition; //pointer to boot partition (that will booted after reset)
esp_app_desc_t bootPartitionDesc; //Metadate from boot partition
*pbNewOTAImage = false; //set default false
*cpbNewOTAImage = false; //set default false
//read OTAMessages queue
if(uxQueueSpacesAvailable(queueMessageOTA) < QUEUE_MESSAGE_OTA_SIZE)
@ -229,8 +229,8 @@ esp_err_t errMeshOtaSlaveEndpoint(bool* pbNewOTAImage)
{
//remote newer as local
ESP_LOGI(LOG_TAG, "remote image on node is newer --> OTA update required");
// --> this version older --> start OTA_Rx --> set pbNewOTAImage true
ERROR_CHECK(errMeshOtaPartitionAccessMeshReceive(pbNewOTAImage, &sOTAMessage.meshSenderAddr));
// --> this version older --> start OTA_Rx --> set cpbNewOTAImage true
ERROR_CHECK(errMeshOtaPartitionAccessMeshReceive(cpbNewOTAImage, &sOTAMessage.meshSenderAddr));
}
if((bMeshOtaUtilNewerVersion((char*) sOTAMessage.au8Payload, (bootPartitionDesc).version)) && (err == ESP_OK)) //compare remote and local version
@ -246,7 +246,7 @@ esp_err_t errMeshOtaSlaveEndpoint(bool* pbNewOTAImage)
return err;
}
esp_err_t errMeshOtaMasterEndpoint(bool* pbNewOTAImage, mesh_addr_t* pMeshNodeAddr)
esp_err_t errMeshOtaMasterEndpoint(bool* const cpbNewOTAImage, const mesh_addr_t* const cpcMeshNodeAddr)
{
esp_err_t err = ESP_OK;
MESH_PACKET_t sOTAMessage;
@ -255,15 +255,15 @@ esp_err_t errMeshOtaMasterEndpoint(bool* pbNewOTAImage, mesh_addr_t* pMeshNodeAd
bool bNodeIsConnected = false;
bool bNodeIsResponding = false;
*pbNewOTAImage = false; //set default false
*cpbNewOTAImage = false; //set default false
if(bMeshNetworkIsNodeNeighbour(pMeshNodeAddr) == true) //check if node is still connected
if(bMeshNetworkIsNodeNeighbour(cpcMeshNodeAddr) == true) //check if node is still connected
{
bNodeIsConnected = true; //node is one of the neighbours
xSemaphoreTake(bsOTAProcess, portMAX_DELAY); //wait for binary semaphore that allows to start the OTA process
ESP_LOGI(LOG_TAG, "Mesh-Master: send Version_Request to 0x%x", pMeshNodeAddr->addr[5]);
ERROR_CHECK(errMeshOtaUtilSendOTAVersionRequest(pMeshNodeAddr)); //send OTA_VERSION_REQUEST with local version in payload
ESP_LOGI(LOG_TAG, "Mesh-Master: send Version_Request to 0x%x", cpcMeshNodeAddr->addr[5]);
ERROR_CHECK(errMeshOtaUtilSendOTAVersionRequest(cpcMeshNodeAddr)); //send OTA_VERSION_REQUEST with local version in payload
for (uint32_t u32Index = 0; u32Index < QUEUE_MESSAGE_OTA_SIZE; u32Index++) //loop through all OTA messages
{
@ -276,7 +276,7 @@ esp_err_t errMeshOtaMasterEndpoint(bool* pbNewOTAImage, mesh_addr_t* pMeshNodeAd
err = ESP_FAIL;
}
if((err == ESP_OK) && (sOTAMessage.type == OTA_Version_Response) && (bMeshNetworkCheckMACEquality(sOTAMessage.meshSenderAddr.addr, pMeshNodeAddr->addr))) //if OTA_Version_Request
if((err == ESP_OK) && (sOTAMessage.type == OTA_Version_Response) && (bMeshNetworkCheckMACEquality(sOTAMessage.meshSenderAddr.addr, cpcMeshNodeAddr->addr))) //if OTA_Version_Request
{
bNodeIsResponding = true;
pBootPartition = esp_ota_get_boot_partition(); //get boot partition (that will booted after reset), not the running partition
@ -286,8 +286,8 @@ esp_err_t errMeshOtaMasterEndpoint(bool* pbNewOTAImage, mesh_addr_t* pMeshNodeAd
{
//remote newer as local
ESP_LOGI(LOG_TAG, "Mesh: remote image on node is newer --> OTA update required");
// --> this version older --> start OTA_Rx --> set pbNewOTAImage true
ERROR_CHECK(errMeshOtaPartitionAccessMeshReceive(pbNewOTAImage, &sOTAMessage.meshSenderAddr));
// --> this version older --> start OTA_Rx --> set cpbNewOTAImage true
ERROR_CHECK(errMeshOtaPartitionAccessMeshReceive(cpbNewOTAImage, &sOTAMessage.meshSenderAddr));
}
if((bMeshOtaUtilNewerVersion((char*) sOTAMessage.au8Payload, (bootPartitionDesc).version)) && (err == ESP_OK)) //compare remote and local version
@ -318,7 +318,7 @@ esp_err_t errMeshOtaMasterEndpoint(bool* pbNewOTAImage, mesh_addr_t* pMeshNodeAd
{
//add node back to queue if connected and NOT responding
ESP_LOGI(LOG_TAG, "OTA-Master: connected and NOT responding --> add node back to queue ");
vMeshOtaUtilAddNodeToPossibleUpdatableQueue(pMeshNodeAddr->addr);
vMeshOtaUtilAddNodeToPossibleUpdatableQueue(cpcMeshNodeAddr->addr);
}
return err;
}

30
components/mesh_ota/Mesh_OTA_Partition_Access.c

@ -5,7 +5,7 @@
static const char *LOG_TAG = "mesh_ota_partition_access";
esp_err_t errMeshOtaPartitionAccessHttps(bool* pbNewOTAImage)
esp_err_t errMeshOtaPartitionAccessHttps(bool* const cpbNewOTAImage)
{
esp_err_t err = ESP_OK;
char u8OTABuffer[OTA_HTTPS_SEGMENT_SIZE]; //store image segment from server before ota write
@ -64,7 +64,7 @@ esp_err_t errMeshOtaPartitionAccessHttps(bool* pbNewOTAImage)
ERROR_CHECK(esp_ota_set_boot_partition(pOTAPartition)); //set new image as boot
if(err == ESP_OK)
{
*pbNewOTAImage = true; //image validated
*cpbNewOTAImage = true; //image validated
}
}
else
@ -72,7 +72,7 @@ esp_err_t errMeshOtaPartitionAccessHttps(bool* pbNewOTAImage)
//error occurred --> abort ota update process
ESP_LOGE(LOG_TAG, "abort ota process due to error 0x%x -> %s", err, esp_err_to_name(err));
ERROR_CHECK(esp_ota_abort(otaHandle));
*pbNewOTAImage = false; //ota update failed
*cpbNewOTAImage = false; //ota update failed
}
}
else
@ -84,7 +84,7 @@ esp_err_t errMeshOtaPartitionAccessHttps(bool* pbNewOTAImage)
return err;
}
esp_err_t errMeshOtaPartitionAccessMeshTransmit(mesh_addr_t* pMeshNodeAddr)
esp_err_t errMeshOtaPartitionAccessMeshTransmit(const mesh_addr_t* const cpcMeshNodeAddr)
{
esp_err_t err = ESP_OK;
const esp_partition_t* pBootPartition; //pointer to boot partition (that will booted after reset)
@ -119,7 +119,7 @@ esp_err_t errMeshOtaPartitionAccessMeshTransmit(mesh_addr_t* pMeshNodeAddr)
sMeshPacket.type = OTA_Complete;
}
//ESP_LOGI(LOG_TAG, "OTA-TX: send packet");
err = errMeshNetworkSendMeshPacket(pMeshNodeAddr, &sMeshPacket);
err = errMeshNetworkSendMeshPacket(cpcMeshNodeAddr, &sMeshPacket);
}
else
{
@ -127,7 +127,7 @@ esp_err_t errMeshOtaPartitionAccessMeshTransmit(mesh_addr_t* pMeshNodeAddr)
sMeshPacket.type = OTA_Abort;
bAbort = true;
ESP_LOGI(LOG_TAG, "OTA-TX: error while read --> send ABORT");
errMeshNetworkSendMeshPacket(pMeshNodeAddr, &sMeshPacket);
errMeshNetworkSendMeshPacket(cpcMeshNodeAddr, &sMeshPacket);
}
// loop through all OTA messages or until abort is called or error
@ -142,7 +142,7 @@ esp_err_t errMeshOtaPartitionAccessMeshTransmit(mesh_addr_t* pMeshNodeAddr)
err = ESP_FAIL;
}
if((err == ESP_OK) && (bMeshNetworkCheckMACEquality(sMeshPacket.meshSenderAddr.addr, pMeshNodeAddr->addr))) //if OTA_Version_Request
if((err == ESP_OK) && (bMeshNetworkCheckMACEquality(sMeshPacket.meshSenderAddr.addr, cpcMeshNodeAddr->addr))) //if OTA_Version_Request
{
//packet from node received
switch (sMeshPacket.type)
@ -188,11 +188,11 @@ esp_err_t errMeshOtaPartitionAccessMeshTransmit(mesh_addr_t* pMeshNodeAddr)
}
u32SegmentCounter++;
}//end of partition segment loop
vMeshOtaUtilClearOtaMessageQueue(pMeshNodeAddr);
vMeshOtaUtilClearOtaMessageQueue(cpcMeshNodeAddr);
return err;
}
esp_err_t errMeshOtaPartitionAccessMeshReceive(bool* pbNewOTAImage, mesh_addr_t* pMeshNodeAddr)
esp_err_t errMeshOtaPartitionAccessMeshReceive(bool* const cpbNewOTAImage, const mesh_addr_t* const cpcMeshNodeAddr)
{
esp_err_t err = ESP_OK;
MESH_PACKET_t sMeshPacket; //packet for sending and receiving
@ -201,7 +201,7 @@ esp_err_t errMeshOtaPartitionAccessMeshReceive(bool* pbNewOTAImage, mesh_addr_t*
bool bNodeIsResponding = false; //remote node is still active
uint32_t u32OTABytesWritten = 0U; //counter unsed for progress log
static esp_ota_handle_t otaHandle; //OTA process handle
*pbNewOTAImage = false;
*cpbNewOTAImage = false;
uint32_t u32SegmentCounter = 0U;
ERROR_CHECK(esp_ota_begin(pOTAPartition, OTA_SIZE_UNKNOWN, &otaHandle)); //start ota update process
@ -223,7 +223,7 @@ esp_err_t errMeshOtaPartitionAccessMeshReceive(bool* pbNewOTAImage, mesh_addr_t*
err = ESP_FAIL;
}
if((err == ESP_OK) && (bMeshNetworkCheckMACEquality(sMeshPacket.meshSenderAddr.addr, pMeshNodeAddr->addr))) //if OTA_Version_Request
if((err == ESP_OK) && (bMeshNetworkCheckMACEquality(sMeshPacket.meshSenderAddr.addr, cpcMeshNodeAddr->addr))) //if OTA_Version_Request
{
//packet from node received
switch (sMeshPacket.type)
@ -286,7 +286,7 @@ esp_err_t errMeshOtaPartitionAccessMeshReceive(bool* pbNewOTAImage, mesh_addr_t*
//no error while ota write --> send OTA_ACK packet
//ESP_LOGI(LOG_TAG, "OTA-RX: no error while ota write --> send OTA_ACK packet");
sMeshPacket.type = OTA_ACK;
err = errMeshNetworkSendMeshPacket(pMeshNodeAddr, &sMeshPacket);
err = errMeshNetworkSendMeshPacket(cpcMeshNodeAddr, &sMeshPacket);
}
}
else
@ -295,7 +295,7 @@ esp_err_t errMeshOtaPartitionAccessMeshReceive(bool* pbNewOTAImage, mesh_addr_t*
sMeshPacket.type = OTA_Abort;
bAbort = true;
ESP_LOGI(LOG_TAG, "OTA-RX: abort --> send ABORT");
errMeshNetworkSendMeshPacket(pMeshNodeAddr, &sMeshPacket);
errMeshNetworkSendMeshPacket(cpcMeshNodeAddr, &sMeshPacket);
}
}
u32SegmentCounter++;
@ -310,7 +310,7 @@ esp_err_t errMeshOtaPartitionAccessMeshReceive(bool* pbNewOTAImage, mesh_addr_t*
if(err == ESP_OK)
{
//successfully updated OTA partition
*pbNewOTAImage = true;
*cpbNewOTAImage = true;
}
}
else
@ -318,7 +318,7 @@ esp_err_t errMeshOtaPartitionAccessMeshReceive(bool* pbNewOTAImage, mesh_addr_t*
//not all OTA segments received --> abort this OTA process
ERROR_CHECK(esp_ota_abort(otaHandle));
}
vMeshOtaUtilClearOtaMessageQueue(pMeshNodeAddr);
vMeshOtaUtilClearOtaMessageQueue(cpcMeshNodeAddr);
return err;
}

82
components/mesh_ota/Mesh_OTA_Util.c

@ -3,7 +3,7 @@
static const char *LOG_TAG = "mesh_ota";
bool bMeshOtaUtilNewerVersion(const char* pu8Local, const char* pu8Remote)
bool bMeshOtaUtilNewerVersion(const char* cpu8Local, const char* cpu8Remote)
{
/*
* Return true if remote version is newer (higher) than local version
@ -15,8 +15,8 @@ bool bMeshOtaUtilNewerVersion(const char* pu8Local, const char* pu8Remote)
bool bReturn = false; //flag to stop loop
uint8_t u8Index = 0; //numbers counter in version string
strncpy(u8LocalTmp, pu8Local, 12); //copy in tmp
strncpy(u8RemoteTmp, pu8Remote, 12); //copy in tmp
strncpy(u8LocalTmp, cpu8Local, 12); //copy in tmp
strncpy(u8RemoteTmp, cpu8Remote, 12); //copy in tmp
char* pu8TokenLocal = strtok_r(u8LocalTmp, ".", &pu8saveptrLocal); //split tokens
char* pu8TokenRemote = strtok_r(u8RemoteTmp, ".", &pu8saveptrRemote); //split tokens
@ -34,24 +34,24 @@ bool bMeshOtaUtilNewerVersion(const char* pu8Local, const char* pu8Remote)
return bReturn;
}
esp_err_t errMeshOtaUtilExtractVersionNumber(const char* pu8Data, uint32_t* pu32DataLenght, char* pc8RemoteVersionNumber)
esp_err_t errMeshOtaUtilExtractVersionNumber(const char* cpu8Data, uint32_t* const cpcu32DataLenght, char* const pc8RemoteVersionNumber)
{
uint32_t u32StartOffset;
esp_err_t err = ESP_OK;
strcpy(pc8RemoteVersionNumber, "999.999.999"); //init value
err = errMeshOtaUtilFindImageStart(pu8Data, pu32DataLenght, &u32StartOffset); //get image start offset
err = errMeshOtaUtilFindImageStart(cpu8Data, cpcu32DataLenght, &u32StartOffset); //get image start offset
if(err == ESP_OK)
{
//image found
strncpy(pc8RemoteVersionNumber, pu8Data+(u32StartOffset+48), 11); //copy version number
strncpy(pc8RemoteVersionNumber, cpu8Data+(u32StartOffset+48), 11); //copy version number
pc8RemoteVersionNumber[12] = '\0';
}
return err;
}
esp_err_t errMeshOtaUtilFindImageStart(const char* pu8Data, uint32_t* pu32DataLenght, uint32_t* pu32StartOffset)
esp_err_t errMeshOtaUtilFindImageStart(const char* const cpu8Data, const uint32_t* const cpcu32DataLenght, uint32_t* const cpu32StartOffset)
{
/*
Offset value
@ -67,20 +67,20 @@ esp_err_t errMeshOtaUtilFindImageStart(const char* pu8Data, uint32_t* pu32DataLe
uint8_t u8FirstDotIndex = 0;
uint8_t u8SecondDotIndex = 0;
*pu32StartOffset = 0U; //reset offset to zero
*cpu32StartOffset = 0U; //reset offset to zero
while((u32DataIndex < *pu32DataLenght) && (bImageStartOffsetFound == false))
while((u32DataIndex < *cpcu32DataLenght) && (bImageStartOffsetFound == false))
{
//search for magic byte
if(pu8Data[u32DataIndex] == 0xe9)
if(cpu8Data[u32DataIndex] == 0xe9)
{
//magic byte found
while ((u8FirstDotIndex < 3) && (u32FirstDotOffset == 0))
{
//search first dot in version number
if((u32DataIndex+49+u8FirstDotIndex) < *pu32DataLenght)
if((u32DataIndex+49+u8FirstDotIndex) < *cpcu32DataLenght)
{
if((pu8Data[(u32DataIndex+49+u8FirstDotIndex)] == 0x2e))
if((cpu8Data[(u32DataIndex+49+u8FirstDotIndex)] == 0x2e))
{
//first dot found
u32FirstDotOffset = (u32DataIndex+49+u8FirstDotIndex);
@ -92,9 +92,9 @@ esp_err_t errMeshOtaUtilFindImageStart(const char* pu8Data, uint32_t* pu32DataLe
while ((u8SecondDotIndex < 3) && (u32SecondDotOffset == 0) && (u32FirstDotOffset != 0))
{
//search first dot in version number
if((u32FirstDotOffset+(u8SecondDotIndex+2)) < *pu32DataLenght)
if((u32FirstDotOffset+(u8SecondDotIndex+2)) < *cpcu32DataLenght)
{
if((pu8Data[(u32FirstDotOffset+(u8SecondDotIndex+2))] == 0x2e))
if((cpu8Data[(u32FirstDotOffset+(u8SecondDotIndex+2))] == 0x2e))
{
//second dot found
u32SecondDotOffset = (u32FirstDotOffset+(u8SecondDotIndex+2));
@ -106,7 +106,7 @@ esp_err_t errMeshOtaUtilFindImageStart(const char* pu8Data, uint32_t* pu32DataLe
if((u32FirstDotOffset != 0) && (u32SecondDotOffset != 0))
{
//image start found based on magic byte and version number systax
*pu32StartOffset = u32DataIndex; //store image start offset
*cpu32StartOffset = u32DataIndex; //store image start offset
bImageStartOffsetFound = true;
}
else
@ -129,7 +129,7 @@ esp_err_t errMeshOtaUtilFindImageStart(const char* pu8Data, uint32_t* pu32DataLe
return errReturn;
}
esp_err_t errMeshOtaUtilSendOTAVersionRequest(mesh_addr_t* pMeshReceiverAddr)
esp_err_t errMeshOtaUtilSendOTAVersionRequest(const mesh_addr_t* const cpcMeshReceiverAddr)
{
esp_err_t err = ESP_OK;
MESH_PACKET_t packet;
@ -141,11 +141,11 @@ esp_err_t errMeshOtaUtilSendOTAVersionRequest(mesh_addr_t* pMeshReceiverAddr)
pBootPartition = esp_ota_get_boot_partition(); //get boot partition (that will booted after reset), not the running partition
ERROR_CHECK(esp_ota_get_partition_description(pBootPartition, &bootPartitionDesc)); //get metadate of partition
memcpy(&packet.au8Payload, &bootPartitionDesc.version, 12); //copy local version to OTA_Version_Request packet
err = errMeshNetworkSendMeshPacket(pMeshReceiverAddr, &packet);
err = errMeshNetworkSendMeshPacket(cpcMeshReceiverAddr, &packet);
return err;
}
esp_err_t errMeshOtaUtilSendOTAVersionResponse(mesh_addr_t* pMeshReceiverAddr)
esp_err_t errMeshOtaUtilSendOTAVersionResponse(const mesh_addr_t* const cpcMeshReceiverAddr)
{
esp_err_t err = ESP_OK;
MESH_PACKET_t packet;
@ -158,34 +158,34 @@ esp_err_t errMeshOtaUtilSendOTAVersionResponse(mesh_addr_t* pMeshReceiverAddr)
ERROR_CHECK(esp_ota_get_partition_description(pBootPartition, &bootPartitionDesc)); //get metadate of partition
memcpy(&packet.au8Payload, &bootPartitionDesc.version, 12); //copy local version to OTA_Version_Response packet
ESP_LOGI(LOG_TAG, "Send OTA_Version_Response to 0x%x", pMeshReceiverAddr->addr[5]);
ESP_LOGI(LOG_TAG, "Send OTA_Version_Response to 0x%x", cpcMeshReceiverAddr->addr[5]);
err = errMeshNetworkSendMeshPacket(pMeshReceiverAddr, &packet);
err = errMeshNetworkSendMeshPacket(cpcMeshReceiverAddr, &packet);
return err;
}
void vMeshOtaUtilPrintOTAProgress(const uint32_t* const pu32TotalImageSize, const uint32_t* const pu32BytesWritten, OTA_MESH_ROLE_t eRole)
void vMeshOtaUtilPrintOTAProgress(const uint32_t* const cpcu32TotalImageSize, const uint32_t* const cpcu32BytesWritten, const OTA_MESH_ROLE_t ceRole)
{
uint32_t u32Percentage = 0U;
static uint32_t u32LastPercentage = 0U;
if((*pu32BytesWritten) >= (*pu32TotalImageSize))
if((*cpcu32BytesWritten) >= (*cpcu32TotalImageSize))
{
u32Percentage = 100;
}
else
{
u32Percentage = (uint32_t) (((float) (*pu32BytesWritten)/(float) (*pu32TotalImageSize)) * 100.0);
u32Percentage = (uint32_t) (((float) (*cpcu32BytesWritten)/(float) (*cpcu32TotalImageSize)) * 100.0);
}
if((u32Percentage-u32LastPercentage) >= OTA_PROGRESS_LOG_INTERVAL)
{
if(eRole == Transmitter)
if(ceRole == Transmitter)
{
ESP_LOGI(LOG_TAG, "Transmitting OTA update: %i %%", u32Percentage);
}
if(eRole == Receiver)
if(ceRole == Receiver)
{
ESP_LOGI(LOG_TAG, "Receiving OTA update: %i %%", u32Percentage);
}
@ -223,31 +223,31 @@ void vMeshOtaUtilAddAllNeighboursToQueue(void)
}
}
void vMeshOtaUtilClearOtaMessageQueue(mesh_addr_t* pMeshNodeAddr)
void vMeshOtaUtilClearOtaMessageQueue(const mesh_addr_t* const cpcMeshNodeAddr)
{
MESH_PACKET_t sMeshPacket; //packet for sending and receiving
for (uint32_t u32Index = 0; (u32Index < QUEUE_MESSAGE_OTA_SIZE); u32Index++) //loop through all OTA messages
{
if (xQueueReceive(queueMessageOTA, &sMeshPacket, 0) == pdTRUE)
{
if(!(bMeshNetworkCheckMACEquality(sMeshPacket.meshSenderAddr.addr, pMeshNodeAddr->addr)))
if(!(bMeshNetworkCheckMACEquality(sMeshPacket.meshSenderAddr.addr, cpcMeshNodeAddr->addr)))
{
//received OTA message is NOT from pMeshNodeAddr --> keep it in queue
//received OTA message is NOT from cpcMeshNodeAddr --> keep it in queue
vMeshOtaUtilAddOtaMessageToQueue(&sMeshPacket);
}
else
{
ESP_LOGI(LOG_TAG, "Removed type %i from node 0x%x", sMeshPacket.type, pMeshNodeAddr->addr[5]);
ESP_LOGI(LOG_TAG, "Removed type %i from node 0x%x", sMeshPacket.type, cpcMeshNodeAddr->addr[5]);
}
}
}//end OTA message loop
}
void vMeshOtaUtilAddNodeToPossibleUpdatableQueue(uint8_t* pu8MAC)
void vMeshOtaUtilAddNodeToPossibleUpdatableQueue(const uint8_t* const cpcu8MAC)
{
//send payload to node queues
mesh_addr_t addrNode;
memcpy(&addrNode.addr, (uint8_t *)pu8MAC, 6); //copy MAC
memcpy(&addrNode.addr, (uint8_t *)cpcu8MAC, 6); //copy MAC
if (xQueueSend(queueNodes, &addrNode, portMAX_DELAY) != pdPASS)
{
@ -259,26 +259,26 @@ void vMeshOtaUtilAddNodeToPossibleUpdatableQueue(uint8_t* pu8MAC)
}
}
void vMeshOtaUtilAddOtaMessageToQueue(MESH_PACKET_t* puMeshPacket)
void vMeshOtaUtilAddOtaMessageToQueue(const MESH_PACKET_t* const cpcuMeshPacket)
{
//send ota packet to packet queue
if (xQueueSend(queueMessageOTA, puMeshPacket, portMAX_DELAY) != pdPASS)
if (xQueueSend(queueMessageOTA, cpcuMeshPacket, portMAX_DELAY) != pdPASS)
{
ESP_LOGE(LOG_TAG, "Unable to push ota packet into packet queue");
}
else
{
switch (puMeshPacket->type)
switch (cpcuMeshPacket->type)
{
case OTA_Abort:
ESP_LOGI(LOG_TAG, "added ota message to queue: OTA_Abort from 0x%x", puMeshPacket->meshSenderAddr.addr[5]);
ESP_LOGI(LOG_TAG, "added ota message to queue: OTA_Abort from 0x%x", cpcuMeshPacket->meshSenderAddr.addr[5]);
break;
case OTA_Version_Request:
ESP_LOGI(LOG_TAG, "added ota message to queue: OTA_Version_Request from 0x%x", puMeshPacket->meshSenderAddr.addr[5]);
ESP_LOGI(LOG_TAG, "added ota message to queue: OTA_Version_Request from 0x%x", cpcuMeshPacket->meshSenderAddr.addr[5]);
break;
case OTA_Version_Response:
ESP_LOGI(LOG_TAG, "added ota message to queue: OTA_Version Response from 0x%x", puMeshPacket->meshSenderAddr.addr[5]);
ESP_LOGI(LOG_TAG, "added ota message to queue: OTA_Version Response from 0x%x", cpcuMeshPacket->meshSenderAddr.addr[5]);
break;
default:
break;
@ -286,15 +286,15 @@ void vMeshOtaUtilAddOtaMessageToQueue(MESH_PACKET_t* puMeshPacket)
}
}
void vMeshOtaUtilChangeStateOfServerWorker(bool bState) //allow access via function ptn to networl_handler
void vMeshOtaUtilChangeStateOfServerWorker(const bool cbState) //allow access via function ptn to network_handler
{
static bool bLastState = false;
if(bState != bLastState) //change only if necessary
if(cbState != bLastState) //change only if necessary
{
ESP_LOGI(LOG_TAG, "server worker change handler");
if(bState == true)
if(cbState == true)
{
if (xSemaphoreGive(bsStartStopServerWorker) != pdTRUE)
{
@ -308,6 +308,6 @@ void vMeshOtaUtilChangeStateOfServerWorker(bool bState) //allow access via funct
ESP_LOGE(LOG_TAG, "Unable to obtain mutex to deactivate the server worker");
}
}
bLastState = bState;
bLastState = cbState;
}
}

12
components/mesh_ota/include/HTTPS_Client.h

@ -57,12 +57,12 @@ struct HTTPS_Client
typedef int32_t https_client_ret_t;
typedef struct HTTPS_Client HTTPS_Client_t;
https_client_ret_t errHTTPSClientInitialize();
https_client_ret_t errHTTPSClientConnectToServer();
https_client_ret_t errHTTPSClientValidateServer();
https_client_ret_t errHTTPSClientSendRequest();
https_client_ret_t errHTTPSClientRetrieveData(char* pu8Data, uint32_t* pu32DataLenght, uint32_t* pu32BytesRead);
https_client_ret_t errHTTPSClientReset();
https_client_ret_t errHTTPSClientInitialize(void);
https_client_ret_t errHTTPSClientConnectToServer(void);
https_client_ret_t errHTTPSClientValidateServer(void);
https_client_ret_t errHTTPSClientSendRequest(void);
https_client_ret_t errHTTPSClientRetrieveData(char* const cpu8Data, const uint32_t* const cpcu32DataLenght, uint32_t* pu32BytesRead);
https_client_ret_t errHTTPSClientReset(void);
#endif /* H_HTTPS_CLIENT */

26
components/mesh_ota/include/Mesh_Network.h

@ -79,31 +79,31 @@ 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 esp_netif_t* pNetifSta;
extern uint8_t u8ownMAC[6];
extern void (*pOTAChildConnectHandle)(uint8_t* );
extern void (*pChangeStateOfServerWorkerHandle)(bool );
extern void (*pOTAChildConnectHandle)(const uint8_t* const);
extern void (*pChangeStateOfServerWorkerHandle)(const bool );
esp_err_t errMeshNetworkInitialize(void);
esp_err_t errMeshNetworkInitializeWiFi(void);
esp_err_t errMeshNetworkInitializeRouter(mesh_cfg_t* cfg);
esp_err_t errMeshNetworkSetChildConnectedHandle(void (*pChildConnectHandleTmp)(uint8_t * pu8Data));
esp_err_t errMeshNetworkSetAppReceiveHandle(void (*pAppRxHandleTmp)(uint8_t * pu8Data, uint8_t* pu8Sender));
esp_err_t errMeshNetworkSetOTAMessageHandleHandle(void (*pOTAMessageHandleTmp)(MESH_PACKET_t* puMeshPacket));
esp_err_t errMeshNetworkSetChangeStateOfServerWorkerHandle(void (*pChangeStateOfServerWorkerHandleTmp)(bool bState));
esp_err_t errMeshNetworkSetChildConnectedHandle(void (*pChildConnectHandleTmp)(const uint8_t* const cpcu8Data));
esp_err_t errMeshNetworkSetAppReceiveHandle(void (*pAppRxHandleTmp)(const uint8_t* const cpcu8Data, const uint8_t* const cpcu8Sender));
esp_err_t errMeshNetworkSetOTAMessageHandleHandle(void (*pOTAMessageHandleTmp)(const MESH_PACKET_t* const cpcuMeshPacket));
esp_err_t errMeshNetworkSetChangeStateOfServerWorkerHandle(void (*pChangeStateOfServerWorkerHandleTmp)(const bool cbState));
bool bMeshNetworkIsRootNode(void);
bool bMeshNetworkIsNodeNeighbour(mesh_addr_t* pNode);
bool bMeshNetworkCheckMACEquality(uint8_t* pu8aMAC, uint8_t* pu8bMAC);
bool bMeshNetworkIsNodeNeighbour(const mesh_addr_t* const cpcNode);
bool bMeshNetworkCheckMACEquality(const uint8_t* const cpcu8aMAC, const uint8_t* const cpcu8bMAC);
esp_err_t errMeshNetworkStartReceiveTask(void);
esp_err_t errMeshNetworkGetParentNode(mesh_addr_t* pMeshParentAddr);
esp_err_t errMeshNetworkGetChildren(mesh_addr_t* pChildren, uint16_t* pu16ChildrenSize);
esp_err_t errMeshNetworkSendMeshPacket(mesh_addr_t* pAddrDest, MESH_PACKET_t* pPacket);
esp_err_t errMeshNetworkGetParentNode(mesh_addr_t* const cpMeshParentAddr);
esp_err_t errMeshNetworkGetChildren(mesh_addr_t* const cpChildren, uint16_t* const cpu16ChildrenSize);
esp_err_t errMeshNetworkSendMeshPacket(const mesh_addr_t* const cpcAddrDest, const MESH_PACKET_t* const cpcPacket);
void vMeshNetworkTaskReceiveMeshData(void *arg);
void vMeshNetworkGetOwnAddr(mesh_addr_t* pMeshOwnAddr);
void vMeshNetworkGetOwnAddr(mesh_addr_t* const cpMeshOwnAddr);
void vMeshNetworkIpEventHandler(void *arg, esp_event_base_t event_base, int32_t i32EventID, void *vpEventData);
void vMeshNetworkMeshEventHandler(void *arg, esp_event_base_t event_base, int32_t i32EventID, void* vpEventData);

4
components/mesh_ota/include/Mesh_OTA.h

@ -35,7 +35,7 @@ void vMeshOtaTaskServerWorker(void *arg);
void vMeshOtaTaskOTAWorker(void *arg);
//OTA process endpoints
esp_err_t errMeshOtaSlaveEndpoint(bool* pbNewOTAImage);
esp_err_t errMeshOtaMasterEndpoint(bool* pbNewOTAImage, mesh_addr_t* pMeshNodeAddr);
esp_err_t errMeshOtaSlaveEndpoint(bool* const cpbNewOTAImage);
esp_err_t errMeshOtaMasterEndpoint(bool* const cpbNewOTAImage, const mesh_addr_t* const cpcMeshNodeAddr);
#endif /* H_MESH_OTA */

6
components/mesh_ota/include/Mesh_OTA_Partition_Access.h

@ -20,8 +20,8 @@
} \
} \
esp_err_t errMeshOtaPartitionAccessHttps(bool* pbNewOTAImage);
esp_err_t errMeshOtaPartitionAccessMeshTransmit(mesh_addr_t* pMeshNodeAddr);
esp_err_t errMeshOtaPartitionAccessMeshReceive(bool* pbNewOTAImage, mesh_addr_t* pMeshNodeAddr);
esp_err_t errMeshOtaPartitionAccessHttps(bool* const cpbNewOTAImage);
esp_err_t errMeshOtaPartitionAccessMeshTransmit(const mesh_addr_t* const cpcMeshNodeAddr);
esp_err_t errMeshOtaPartitionAccessMeshReceive(bool* const cpbNewOTAImage, const mesh_addr_t* const cpcMeshNodeAddr);
#endif /* H_MESH_OTA_PARTITION_ACCESS */

21
components/mesh_ota/include/Mesh_OTA_Util.h

@ -18,18 +18,19 @@ enum otaMeshRole
typedef enum otaMeshRole OTA_MESH_ROLE_t;
//helper functions
bool bMeshOtaUtilNewerVersion(const char* pu8Local, const char* pu8Remote);
esp_err_t errMeshOtaUtilExtractVersionNumber(const char* pu8Data, uint32_t* pu32DataLenght, char* pc8RemoteVersionNumber);
esp_err_t errMeshOtaUtilFindImageStart(const char* pu8Data, uint32_t* pu32DataLenght, uint32_t* pu32StartOffset);
esp_err_t errMeshOtaUtilSendOTAVersionRequest(mesh_addr_t* pMeshReceiverAddr);
esp_err_t errMeshOtaUtilSendOTAVersionResponse(mesh_addr_t* pMeshReceiverAddr);
void vMeshOtaUtilPrintOTAProgress(const uint32_t* const cpcu32TotalImageSize, const uint32_t* const cpcu32BytesWritten, OTA_MESH_ROLE_t eRole);
bool bMeshOtaUtilNewerVersion(const char* cpu8Local, const char* cpu8Remote);
esp_err_t errMeshOtaUtilExtractVersionNumber(const char* cpu8Data, uint32_t* const cpu32DataLenght, char* const pc8RemoteVersionNumber);
esp_err_t errMeshOtaUtilFindImageStart(const char* const cpu8Data, const uint32_t* const cpu32DataLenght, uint32_t* const cpu32StartOffset);
esp_err_t errMeshOtaUtilSendOTAVersionRequest(const mesh_addr_t* const cpcMeshReceiverAddr);
esp_err_t errMeshOtaUtilSendOTAVersionResponse(const mesh_addr_t* const cpcMeshReceiverAddr);
void vMeshOtaUtilPrintOTAProgress(const uint32_t* const cpcu32TotalImageSize, const uint32_t* const cpcu32BytesWritten, const OTA_MESH_ROLE_t ceRole);
void vMeshOtaUtilAddAllNeighboursToQueue(void);
void vMeshOtaUtilClearOtaMessageQueue(mesh_addr_t* pMeshNodeAddr);
void vMeshOtaUtilClearOtaMessageQueue(const mesh_addr_t* const cpcMeshNodeAddr);
//Handler
void vMeshOtaUtilAddNodeToPossibleUpdatableQueue(uint8_t* pu8MAC);
void vMeshOtaUtilAddOtaMessageToQueue(MESH_PACKET_t* puMeshPacket);
void vMeshOtaUtilChangeStateOfServerWorker(bool bState);
void vMeshOtaUtilAddNodeToPossibleUpdatableQueue(const uint8_t* const cpcu8MAC);
void vMeshOtaUtilAddOtaMessageToQueue(const MESH_PACKET_t* const cpcuMeshPacket);
void vMeshOtaUtilChangeStateOfServerWorker(const bool cbState);
#endif /* H_MESH_OTA_UTIL */

2
main/Blinky_LED.c

@ -62,7 +62,7 @@ void vGPIOInitialize()
gpio_config(&gpioConf);
}
void rxHandle(uint8_t* pu8Data, uint8_t* pu8Sender)
void rxHandle(const uint8_t* const pu8Data, const uint8_t* const pu8Sender)
{
//send payload to app queue
BLINKY_PACKET_t bTmpPacket;

2
main/Blinky_LED.h

@ -31,7 +31,7 @@ typedef struct blinky_packet BLINKY_PACKET_t;
esp_err_t errBlinkyLEDInitialize();
void vGPIOInitialize();
void rxHandle(uint8_t* pu8Data, uint8_t* pu8Sender);
void rxHandle(const uint8_t* const pu8Data, const uint8_t* const pu8Sender);
void vTaskReadUserInput(void *arg);
void vTaskReceiveData(void *arg);

Loading…
Cancel
Save

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