added allow reboot define and clear node from node queue after successfully ota process
This commit is contained in:
parent
77e87ec840
commit
b29887e0ac
|
@ -157,11 +157,11 @@ void vMeshOtaTaskOTAWorker(void *arg)
|
||||||
//nodes queue is empty
|
//nodes queue is empty
|
||||||
ESP_LOGI(LOG_TAG, "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 ...");
|
ESP_LOGE(LOG_TAG, "ESP32 Reboot ...");
|
||||||
//vTaskDelay( (1000) / portTICK_PERIOD_MS);
|
vTaskDelay( (1000) / portTICK_PERIOD_MS);
|
||||||
//esp_restart();
|
esp_restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
ERROR_CHECK(errMeshOtaSlaveEndpoint(&bNewOTAImage));
|
ERROR_CHECK(errMeshOtaSlaveEndpoint(&bNewOTAImage));
|
||||||
|
@ -184,6 +184,11 @@ void vMeshOtaTaskOTAWorker(void *arg)
|
||||||
//OTA process faild --> add back to queue
|
//OTA process faild --> add back to queue
|
||||||
vMeshOtaUtilAddNodeToPossibleUpdatableQueue(meshNodeAddr.addr);
|
vMeshOtaUtilAddNodeToPossibleUpdatableQueue(meshNodeAddr.addr);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vMeshOtaUtilClearNeighboursQueue(&meshNodeAddr); //remove this node from queue
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(bNewOTAImage == true)
|
if(bNewOTAImage == true)
|
||||||
|
@ -191,6 +196,7 @@ void vMeshOtaTaskOTAWorker(void *arg)
|
||||||
//set want reboot
|
//set want reboot
|
||||||
ESP_LOGI(LOG_TAG, "Updated successfully via Mesh, set pending reboot");
|
ESP_LOGI(LOG_TAG, "Updated successfully via Mesh, set pending reboot");
|
||||||
bWantReboot = true;
|
bWantReboot = true;
|
||||||
|
|
||||||
vMeshOtaUtilAddAllNeighboursToQueue(); //add all existing neighbours to queue
|
vMeshOtaUtilAddAllNeighboursToQueue(); //add all existing neighbours to queue
|
||||||
}
|
}
|
||||||
vTaskDelay( (1000) / portTICK_PERIOD_MS);
|
vTaskDelay( (1000) / portTICK_PERIOD_MS);
|
||||||
|
|
|
@ -7,7 +7,7 @@ SemaphoreHandle_t bsStartStopServerWorker; //binary semaphore
|
||||||
SemaphoreHandle_t bsOTAProcess; //binary semaphore
|
SemaphoreHandle_t bsOTAProcess; //binary semaphore
|
||||||
|
|
||||||
//w: errMeshOTAInitialize;
|
//w: errMeshOTAInitialize;
|
||||||
//r: errMeshOTAInitialize; errMeshOtaPartitionAccessHttps; errMeshOtaPartitionAccessMeshReceive;
|
//r: errMeshOTAInitialize; errMeshOtaPartitionAccessHttps; errMeshOtaPartitionAccessMeshReceive;
|
||||||
const esp_partition_t* pOTAPartition; //pointer to ota partition
|
const esp_partition_t* pOTAPartition; //pointer to ota partition
|
||||||
|
|
||||||
//w: errMeshOTAInitialize; vMeshOtaTaskOTAWorker; vMeshOtaTaskServerWorker
|
//w: errMeshOTAInitialize; vMeshOtaTaskOTAWorker; vMeshOtaTaskServerWorker
|
||||||
|
|
|
@ -243,6 +243,27 @@ void vMeshOtaUtilClearOtaMessageQueue(const mesh_addr_t* const cpcMeshNodeAddr)
|
||||||
}//end OTA message loop
|
}//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)
|
void vMeshOtaUtilAddNodeToPossibleUpdatableQueue(const uint8_t* const cpcu8MAC)
|
||||||
{
|
{
|
||||||
//send payload to node queues
|
//send payload to node queues
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#define OTA_PROGRESS_LOG_INTERVAL 7U
|
#define OTA_PROGRESS_LOG_INTERVAL 7U
|
||||||
#define OTA_MESH_SEGMENT_SIZE MESH_NETWORK_PAYLOAD_SIZE
|
#define OTA_MESH_SEGMENT_SIZE MESH_NETWORK_PAYLOAD_SIZE
|
||||||
#define OTA_MESH_TIMEOUT 20000U //in ms
|
#define OTA_MESH_TIMEOUT 20000U //in ms
|
||||||
|
#define OTA_ALLOW_REBOOT 0
|
||||||
|
|
||||||
#define ERROR_CHECK(x) if (err == ESP_OK) \
|
#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 vMeshOtaUtilPrintOTAProgress(const uint32_t* const cpcu32TotalImageSize, const uint32_t* const cpcu32BytesWritten, const OTA_MESH_ROLE_t ceRole);
|
||||||
void vMeshOtaUtilAddAllNeighboursToQueue(void);
|
void vMeshOtaUtilAddAllNeighboursToQueue(void);
|
||||||
void vMeshOtaUtilClearOtaMessageQueue(const mesh_addr_t* const cpcMeshNodeAddr);
|
void vMeshOtaUtilClearOtaMessageQueue(const mesh_addr_t* const cpcMeshNodeAddr);
|
||||||
|
void vMeshOtaUtilClearNeighboursQueue(const mesh_addr_t* const cpcMeshNodeAddr);
|
||||||
|
|
||||||
//Handler
|
//Handler
|
||||||
void vMeshOtaUtilAddNodeToPossibleUpdatableQueue(const uint8_t* const cpcu8MAC);
|
void vMeshOtaUtilAddNodeToPossibleUpdatableQueue(const uint8_t* const cpcu8MAC);
|
||||||
|
|
Loading…
Reference in New Issue