fix in clear Neighbours Queue

This commit is contained in:
2021-01-26 21:59:25 +01:00
parent a62d3265ca
commit e73a05fc42
6 changed files with 27 additions and 14 deletions

View File

@ -161,7 +161,6 @@ void vMeshOtaTaskServerWorker(void *arg)
//set want reboot
ESP_LOGI(LOG_TAG, "Updated successfully via HTTPS, set pending reboot");
bWantReboot = true;
vMeshOtaUtilAddAllNeighboursToQueue(); //add all existing neighbours to queue (aparent will not be added because this node is the root)
}
vTaskDelay( (SERVER_CHECK_INTERVAL*1000) / portTICK_PERIOD_MS); //sleep till next server checks
}
@ -181,6 +180,7 @@ void vMeshOtaTaskOTAWorker(void *arg)
esp_err_t err = ESP_OK;
bool bNewOTAImage; //true if a new ota image was downloaded and validated
mesh_addr_t meshNodeAddr; //node that should be checked for ota update
BaseType_t xReturned;
while(true)
{
@ -189,25 +189,30 @@ void vMeshOtaTaskOTAWorker(void *arg)
if((uxQueueSpacesAvailable(queueNodes) - QUEUE_NODES_SIZE) == 0)
{
//nodes queue is empty
if((bWantReboot == true) && (OTA_ALLOW_REBOOT == 1))
ESP_LOGI(LOG_TAG, "//nodes queue is empty");
xReturned = xSemaphoreTake(bsOTAProcess, portMAX_DELAY); //wait for binary semaphore that allows to start the OTA process
if((xReturned == pdTRUE) && (bWantReboot == true) && (OTA_ALLOW_REBOOT == 1))
{
ESP_LOGE(LOG_TAG, "ESP32 Reboot ...");
vTaskDelay( (1000) / portTICK_PERIOD_MS);
esp_restart();
}
xSemaphoreGive(bsOTAProcess); //free binary semaphore, this allows other tasks to start the OTA process
ERROR_CHECK(errMeshOtaSlaveEndpoint(&bNewOTAImage));
}
else
{
//queue not empty
ESP_LOGI(LOG_TAG, "//queue not empty %i", (uxQueueSpacesAvailable(queueNodes) - QUEUE_NODES_SIZE));
if (xQueueReceive(queueNodes, &meshNodeAddr, ((100) / portTICK_PERIOD_MS)) != pdTRUE)
{
ESP_LOGE(LOG_TAG, "Unable to receive OTA Messages from Queue");
err = ESP_FAIL;
}
ESP_LOGI(LOG_TAG, "//handle node %x", meshNodeAddr.addr[5]);
ERROR_CHECK(errMeshOtaMasterEndpoint(&bNewOTAImage, &meshNodeAddr));
if (err != ESP_OK)