fix in clear Neighbours Queue
This commit is contained in:
		@ -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)
 | 
			
		||||
 | 
			
		||||
@ -89,6 +89,7 @@ esp_err_t errMeshOtaPartitionAccessHttps(bool* const cpbNewOTAImage)
 | 
			
		||||
                            if(err == ESP_OK)
 | 
			
		||||
                                {
 | 
			
		||||
                                    *cpbNewOTAImage = true; //image validated
 | 
			
		||||
                                    vMeshOtaUtilAddAllNeighboursToQueue(); //add all existing neighbours to queue (aparent will not be added because this node is the root)
 | 
			
		||||
                                }
 | 
			
		||||
                        }
 | 
			
		||||
                    else
 | 
			
		||||
 | 
			
		||||
@ -328,17 +328,24 @@ void vMeshOtaUtilClearOtaMessageQueue(const mesh_addr_t* const cpcMeshNodeAddr)
 | 
			
		||||
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
 | 
			
		||||
    for (uint32_t u32Index = 0; (u32Index < QUEUE_NODES_SIZE); u32Index++) //loop through all node queue 
 | 
			
		||||
        {
 | 
			
		||||
            if (xQueueReceive(queueNodes, &sNode, 0) == pdTRUE)
 | 
			
		||||
                {
 | 
			
		||||
                    if(!(bMeshNetworkCheckMacEquality(sNode.addr, cpcMeshNodeAddr->addr)))
 | 
			
		||||
                    if((bMeshNetworkCheckMacEquality(sNode.addr, cpcMeshNodeAddr->addr)))
 | 
			
		||||
                        {
 | 
			
		||||
                            //node is NOT cpcMeshNodeAddr --> keep it in queue
 | 
			
		||||
                            vMeshOtaUtilAddNodeToPossibleUpdatableQueue(cpcMeshNodeAddr->addr);
 | 
			
		||||
                            ESP_LOGI(LOG_TAG, "REMOVE_NODE: remove node %x", sNode.addr[5]);
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
                            ESP_LOGI(LOG_TAG, "//node is NOT cpcMeshNodeAddr: %i --> keep it in queue",  sNode.addr[5]);
 | 
			
		||||
                            vMeshOtaUtilAddNodeToPossibleUpdatableQueue(sNode.addr);
 | 
			
		||||
                        }
 | 
			
		||||
                        
 | 
			
		||||
                }else{
 | 
			
		||||
                    ESP_LOGI(LOG_TAG, "REMOVE_NODE: queue leer");
 | 
			
		||||
                }
 | 
			
		||||
        }//end OTA message loop
 | 
			
		||||
        }//end nodes
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@ -361,7 +368,7 @@ void vMeshOtaUtilAddNodeToPossibleUpdatableQueue(const uint8_t* const cpcu8MAC)
 | 
			
		||||
        }
 | 
			
		||||
    else
 | 
			
		||||
        {
 | 
			
		||||
            ESP_LOGD(LOG_TAG, "added node \"%x:%x:%x:%x:%x:%x\" to possible updatable queue", addrNode.addr[0], addrNode.addr[1], addrNode.addr[2], addrNode.addr[3], addrNode.addr[4], addrNode.addr[5]);
 | 
			
		||||
            ESP_LOGI(LOG_TAG, "added node \"%x:%x:%x:%x:%x:%x\" to possible updatable queue", addrNode.addr[0], addrNode.addr[1], addrNode.addr[2], addrNode.addr[3], addrNode.addr[4], addrNode.addr[5]);
 | 
			
		||||
        }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -18,8 +18,8 @@
 | 
			
		||||
#include "HTTPS_Client.h"
 | 
			
		||||
 | 
			
		||||
#define ERASE_NVS //erase non volatile storage if full
 | 
			
		||||
#define QUEUE_NODES_SIZE 10
 | 
			
		||||
#define QUEUE_MESSAGE_OTA_SIZE 10
 | 
			
		||||
#define QUEUE_NODES_SIZE 20
 | 
			
		||||
#define QUEUE_MESSAGE_OTA_SIZE 20
 | 
			
		||||
#define SERVER_CHECK_INTERVAL 30 //in seconds
 | 
			
		||||
#define OTA_HTTPS_SEGMENT_SIZE 2048U
 | 
			
		||||
#define OTA_PROGRESS_LOG_INTERVAL 7U
 | 
			
		||||
 | 
			
		||||
@ -20,7 +20,7 @@
 | 
			
		||||
 | 
			
		||||
#include "Mesh_OTA.h"
 | 
			
		||||
 | 
			
		||||
#define NEW_VERSION
 | 
			
		||||
//#define NEW_VERSION
 | 
			
		||||
 | 
			
		||||
#define GPIO_BOOT_BTN   0 //GPIO0 (Boot BTN)
 | 
			
		||||
#define GPIO_LED_BLUE   2 //GPIO2 (internal blue LED in DevKit V1.0)
 | 
			
		||||
 | 
			
		||||
@ -32,7 +32,7 @@ CONFIG_APP_COMPILE_TIME_DATE=y
 | 
			
		||||
# CONFIG_APP_EXCLUDE_PROJECT_VER_VAR is not set
 | 
			
		||||
# CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR is not set
 | 
			
		||||
CONFIG_APP_PROJECT_VER_FROM_CONFIG=y
 | 
			
		||||
CONFIG_APP_PROJECT_VER="0.0.7"
 | 
			
		||||
CONFIG_APP_PROJECT_VER="0.0.26"
 | 
			
		||||
CONFIG_APP_RETRIEVE_LEN_ELF_SHA=16
 | 
			
		||||
# end of Application manager
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user