refactor #2
@ -157,11 +157,11 @@ void vMeshOtaTaskOTAWorker(void *arg)
|
||||
//nodes queue is empty
|
||||
ESP_LOGI(LOG_TAG, "nodes queue is empty");
|
||||
|
||||
if(bWantReboot == true)
|
||||
if((bWantReboot == true) && (OTA_ALLOW_REBOOT == 1))
|
||||
{
|
||||
//ESP_LOGI(LOG_TAG, "ESP32 Reboot ...");
|
||||
//vTaskDelay( (1000) / portTICK_PERIOD_MS);
|
||||
//esp_restart();
|
||||
ESP_LOGE(LOG_TAG, "ESP32 Reboot ...");
|
||||
vTaskDelay( (1000) / portTICK_PERIOD_MS);
|
||||
esp_restart();
|
||||
}
|
||||
|
||||
ERROR_CHECK(errMeshOtaSlaveEndpoint(&bNewOTAImage));
|
||||
@ -184,6 +184,11 @@ void vMeshOtaTaskOTAWorker(void *arg)
|
||||
//OTA process faild --> add back to queue
|
||||
vMeshOtaUtilAddNodeToPossibleUpdatableQueue(meshNodeAddr.addr);
|
||||
}
|
||||
else
|
||||
{
|
||||
vMeshOtaUtilClearNeighboursQueue(&meshNodeAddr); //remove this node from queue
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(bNewOTAImage == true)
|
||||
@ -191,6 +196,7 @@ void vMeshOtaTaskOTAWorker(void *arg)
|
||||
//set want reboot
|
||||
ESP_LOGI(LOG_TAG, "Updated successfully via Mesh, set pending reboot");
|
||||
bWantReboot = true;
|
||||
|
||||
vMeshOtaUtilAddAllNeighboursToQueue(); //add all existing neighbours to queue
|
||||
}
|
||||
vTaskDelay( (1000) / portTICK_PERIOD_MS);
|
||||
|
@ -243,6 +243,27 @@ void vMeshOtaUtilClearOtaMessageQueue(const mesh_addr_t* const cpcMeshNodeAddr)
|
||||
}//end OTA message loop
|
||||
}
|
||||
|
||||
void vMeshOtaUtilClearNeighboursQueue(const mesh_addr_t* const cpcMeshNodeAddr)
|
||||
{
|
||||
mesh_addr_t sNode; //packet for sending and receiving
|
||||
for (uint32_t u32Index = 0; (u32Index < QUEUE_MESSAGE_OTA_SIZE); u32Index++) //loop through all OTA messages
|
||||
{
|
||||
if (xQueueReceive(queueNodes, &sNode, 0) == pdTRUE)
|
||||
{
|
||||
if(!(bMeshNetworkCheckMACEquality(sNode.addr, cpcMeshNodeAddr->addr)))
|
||||
{
|
||||
//node is NOT cpcMeshNodeAddr --> keep it in queue
|
||||
vMeshOtaUtilAddNodeToPossibleUpdatableQueue(cpcMeshNodeAddr->addr);
|
||||
}
|
||||
else
|
||||
{
|
||||
ESP_LOGI(LOG_TAG, "Removed node 0x%x", cpcMeshNodeAddr->addr[5]);
|
||||
}
|
||||
}
|
||||
}//end OTA message loop
|
||||
}
|
||||
|
||||
|
||||
void vMeshOtaUtilAddNodeToPossibleUpdatableQueue(const uint8_t* const cpcu8MAC)
|
||||
{
|
||||
//send payload to node queues
|
||||
|
@ -18,6 +18,7 @@
|
||||
#define OTA_PROGRESS_LOG_INTERVAL 7U
|
||||
#define OTA_MESH_SEGMENT_SIZE MESH_NETWORK_PAYLOAD_SIZE
|
||||
#define OTA_MESH_TIMEOUT 20000U //in ms
|
||||
#define OTA_ALLOW_REBOOT 0
|
||||
|
||||
#define ERROR_CHECK(x) if (err == ESP_OK) \
|
||||
{ \
|
||||
|
@ -26,6 +26,7 @@ esp_err_t errMeshOtaUtilSendOTAVersionResponse(const mesh_addr_t* const cpcMeshR
|
||||
void vMeshOtaUtilPrintOTAProgress(const uint32_t* const cpcu32TotalImageSize, const uint32_t* const cpcu32BytesWritten, const OTA_MESH_ROLE_t ceRole);
|
||||
void vMeshOtaUtilAddAllNeighboursToQueue(void);
|
||||
void vMeshOtaUtilClearOtaMessageQueue(const mesh_addr_t* const cpcMeshNodeAddr);
|
||||
void vMeshOtaUtilClearNeighboursQueue(const mesh_addr_t* const cpcMeshNodeAddr);
|
||||
|
||||
//Handler
|
||||
void vMeshOtaUtilAddNodeToPossibleUpdatableQueue(const uint8_t* const cpcu8MAC);
|
||||
|
Loading…
Reference in New Issue
Block a user