Browse Source

added allow reboot define and clear node from node queue after successfully ota process

pull/2/head
Hendrik Schutter 1 year ago
parent
commit
b29887e0ac
  1. 14
      components/mesh_ota/Mesh_OTA.c
  2. 2
      components/mesh_ota/Mesh_OTA_Globals.c
  3. 21
      components/mesh_ota/Mesh_OTA_Util.c
  4. 1
      components/mesh_ota/include/Mesh_OTA.h
  5. 1
      components/mesh_ota/include/Mesh_OTA_Util.h

14
components/mesh_ota/Mesh_OTA.c

@ -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);

2
components/mesh_ota/Mesh_OTA_Globals.c

@ -7,7 +7,7 @@ SemaphoreHandle_t bsStartStopServerWorker; //binary semaphore
SemaphoreHandle_t bsOTAProcess; //binary semaphore
//w: errMeshOTAInitialize;
//r: errMeshOTAInitialize; errMeshOtaPartitionAccessHttps; errMeshOtaPartitionAccessMeshReceive;
//r: errMeshOTAInitialize; errMeshOtaPartitionAccessHttps; errMeshOtaPartitionAccessMeshReceive;
const esp_partition_t* pOTAPartition; //pointer to ota partition
//w: errMeshOTAInitialize; vMeshOtaTaskOTAWorker; vMeshOtaTaskServerWorker

21
components/mesh_ota/Mesh_OTA_Util.c

@ -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

1
components/mesh_ota/include/Mesh_OTA.h

@ -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) \
{ \

1
components/mesh_ota/include/Mesh_OTA_Util.h

@ -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…
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