fixed uninitialized node addr that causes bug in upstream ota
This commit is contained in:
@ -200,7 +200,7 @@ void vMeshOtaTaskOTAWorker(void *arg)
|
||||
}
|
||||
|
||||
xSemaphoreGive(bsOTAProcess); //free binary semaphore, this allows other tasks to start the OTA process
|
||||
ERROR_CHECK(errMeshOtaSlaveEndpoint(&bNewOTAImage));
|
||||
ERROR_CHECK(errMeshOtaSlaveEndpoint(&bNewOTAImage, &meshNodeAddr));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -231,6 +231,9 @@ void vMeshOtaTaskOTAWorker(void *arg)
|
||||
//set want reboot
|
||||
ESP_LOGI(LOG_TAG, "Updated successfully via Mesh, set pending reboot");
|
||||
bWantReboot = true;
|
||||
|
||||
ESP_LOGI(LOG_TAG, "Succ updated from MAC: \"%x:%x:%x:%x:%x:%x\" ", meshNodeAddr.addr[0], meshNodeAddr.addr[1], meshNodeAddr.addr[2], meshNodeAddr.addr[3], meshNodeAddr.addr[4], meshNodeAddr.addr[5]);
|
||||
|
||||
vMeshOtaUtilAddAllNeighboursToQueue(&meshNodeAddr); //add all existing neighbours to queue
|
||||
}
|
||||
vTaskDelay( (1000) / portTICK_PERIOD_MS);
|
||||
@ -248,7 +251,7 @@ void vMeshOtaTaskOTAWorker(void *arg)
|
||||
* Answers the OTA_Version_Request with OTA_Version_Response
|
||||
* calls errMeshOtaPartitionAccessMeshReceive OR errMeshOtaPartitionAccessMeshTransmit based on version number
|
||||
*/
|
||||
esp_err_t errMeshOtaSlaveEndpoint(bool* const cpbNewOTAImage)
|
||||
esp_err_t errMeshOtaSlaveEndpoint(bool* const cpbNewOTAImage, mesh_addr_t* const cpcMeshNodeAddr)
|
||||
{
|
||||
esp_err_t err = ESP_OK;
|
||||
MESH_PACKET_t sOTAMessage;
|
||||
@ -270,6 +273,8 @@ esp_err_t errMeshOtaSlaveEndpoint(bool* const cpbNewOTAImage)
|
||||
{
|
||||
xSemaphoreTake(bsOTAProcess, portMAX_DELAY); //wait for binary semaphore that allows to start the OTA process
|
||||
|
||||
memcpy(cpcMeshNodeAddr, &sOTAMessage.meshSenderAddr, sizeof(mesh_addr_t));
|
||||
|
||||
cpBootPartition = esp_ota_get_boot_partition(); //get boot partition (that will booted after reset), not the running partition
|
||||
ERROR_CHECK(esp_ota_get_partition_description(cpBootPartition, &bootPartitionDesc)); //get metadata of partition
|
||||
|
||||
@ -317,6 +322,7 @@ esp_err_t errMeshOtaMasterEndpoint(bool* const cpbNewOTAImage, const mesh_addr_t
|
||||
esp_app_desc_t bootPartitionDesc; //Metadata from boot partition
|
||||
bool bNodeIsConnected = false;
|
||||
bool bNodeIsResponding = false;
|
||||
bool bSameVersion = false;
|
||||
|
||||
*cpbNewOTAImage = false; //set default false
|
||||
|
||||
@ -326,50 +332,69 @@ esp_err_t errMeshOtaMasterEndpoint(bool* const cpbNewOTAImage, const mesh_addr_t
|
||||
xSemaphoreTake(bsOTAProcess, portMAX_DELAY); //wait for binary semaphore that allows to start the OTA process
|
||||
|
||||
ERROR_CHECK(errMeshOtaUtilSendOtaVersionRequest(cpcMeshNodeAddr)); //send OTA_VERSION_REQUEST with local version in payload
|
||||
ESP_LOGI(LOG_TAG, "MASTER: sent Request to %x", cpcMeshNodeAddr->addr[5]);
|
||||
|
||||
for (uint32_t u32Index = 0; u32Index < QUEUE_MESSAGE_OTA_SIZE; u32Index++) //loop through all OTA messages
|
||||
for (uint32_t u32Index = 0; ((u32Index < QUEUE_MESSAGE_OTA_SIZE) && (bSameVersion == false)); u32Index++) //loop through all OTA messages
|
||||
{
|
||||
if(uxQueueSpacesAvailable(queueMessageOTA) < QUEUE_MESSAGE_OTA_SIZE)
|
||||
//if(uxQueueSpacesAvailable(queueMessageOTA) < QUEUE_MESSAGE_OTA_SIZE)
|
||||
// {
|
||||
//queue not empty
|
||||
if (xQueueReceive(queueMessageOTA, &sOTAMessage, ((3000) / portTICK_PERIOD_MS)) != pdTRUE)
|
||||
{
|
||||
//queue not empty
|
||||
if (xQueueReceive(queueMessageOTA, &sOTAMessage, ((3000) / portTICK_PERIOD_MS)) != pdTRUE)
|
||||
ESP_LOGE(LOG_TAG, "MASTER: Unable to receive OTA Messages from queue");
|
||||
err = ESP_FAIL;
|
||||
}
|
||||
else
|
||||
{
|
||||
ESP_LOGI(LOG_TAG, "MASTER: rec message: %i", sOTAMessage.type);
|
||||
}
|
||||
|
||||
if((err == ESP_OK) && (sOTAMessage.type == OTA_Version_Response) && (bMeshNetworkCheckMacEquality(sOTAMessage.meshSenderAddr.addr, cpcMeshNodeAddr->addr))) //if OTA_Version_Request
|
||||
{
|
||||
bSameVersion = true;
|
||||
bNodeIsResponding = true;
|
||||
cpBootPartition = esp_ota_get_boot_partition(); //get boot partition (that will booted after reset), not the running partition
|
||||
ERROR_CHECK(esp_ota_get_partition_description(cpBootPartition, &bootPartitionDesc)); //get metadata of partition
|
||||
|
||||
if((bMeshOtaUtilNewerVersion((bootPartitionDesc).version, (char*) sOTAMessage.au8Payload)) && (err == ESP_OK)) //compare local and remote version
|
||||
{
|
||||
ESP_LOGE(LOG_TAG, "MASTER: Unable to receive OTA Messages from queue");
|
||||
err = ESP_FAIL;
|
||||
//remote newer as local
|
||||
bSameVersion = false;
|
||||
ESP_LOGI(LOG_TAG, "MASTER: remote image on node is newer --> OTA update required from node \"%x:%x:%x:%x:%x:%x\"", sOTAMessage.meshSenderAddr.addr[0], sOTAMessage.meshSenderAddr.addr[1], sOTAMessage.meshSenderAddr.addr[2], sOTAMessage.meshSenderAddr.addr[3], sOTAMessage.meshSenderAddr.addr[4], sOTAMessage.meshSenderAddr.addr[5]);
|
||||
// --> this version older --> start OTA_Rx --> set cpbNewOTAImage true
|
||||
ERROR_CHECK(errMeshOtaPartitionAccessMeshReceive(cpbNewOTAImage, &sOTAMessage.meshSenderAddr));
|
||||
u32Index = QUEUE_MESSAGE_OTA_SIZE;
|
||||
}
|
||||
|
||||
if((err == ESP_OK) && (sOTAMessage.type == OTA_Version_Response) && (bMeshNetworkCheckMacEquality(sOTAMessage.meshSenderAddr.addr, cpcMeshNodeAddr->addr))) //if OTA_Version_Request
|
||||
if((bMeshOtaUtilNewerVersion((char*) sOTAMessage.au8Payload, (bootPartitionDesc).version)) && (err == ESP_OK)) //compare remote and local version
|
||||
{
|
||||
bNodeIsResponding = true;
|
||||
cpBootPartition = esp_ota_get_boot_partition(); //get boot partition (that will booted after reset), not the running partition
|
||||
ERROR_CHECK(esp_ota_get_partition_description(cpBootPartition, &bootPartitionDesc)); //get metadata of partition
|
||||
|
||||
if((bMeshOtaUtilNewerVersion((bootPartitionDesc).version, (char*) sOTAMessage.au8Payload)) && (err == ESP_OK)) //compare local and remote version
|
||||
{
|
||||
//remote newer as local
|
||||
ESP_LOGI(LOG_TAG, "MASTER: remote image on node is newer --> OTA update required from node \"%x:%x:%x:%x:%x:%x\"", sOTAMessage.meshSenderAddr.addr[0], sOTAMessage.meshSenderAddr.addr[1], sOTAMessage.meshSenderAddr.addr[2], sOTAMessage.meshSenderAddr.addr[3], sOTAMessage.meshSenderAddr.addr[4], sOTAMessage.meshSenderAddr.addr[5]);
|
||||
// --> this version older --> start OTA_Rx --> set cpbNewOTAImage true
|
||||
ERROR_CHECK(errMeshOtaPartitionAccessMeshReceive(cpbNewOTAImage, &sOTAMessage.meshSenderAddr));
|
||||
}
|
||||
|
||||
if((bMeshOtaUtilNewerVersion((char*) sOTAMessage.au8Payload, (bootPartitionDesc).version)) && (err == ESP_OK)) //compare remote and local version
|
||||
{
|
||||
//local newer as remote
|
||||
ESP_LOGI(LOG_TAG, "MASTER: remote image on node is older --> OTA send required to node \"%x:%x:%x:%x:%x:%x\"", sOTAMessage.meshSenderAddr.addr[0], sOTAMessage.meshSenderAddr.addr[1], sOTAMessage.meshSenderAddr.addr[2], sOTAMessage.meshSenderAddr.addr[3], sOTAMessage.meshSenderAddr.addr[4], sOTAMessage.meshSenderAddr.addr[5]);
|
||||
// --> this version newer --> start OTA_Tx
|
||||
ERROR_CHECK(errMeshOtaPartitionAccessMeshTransmit(&sOTAMessage.meshSenderAddr));
|
||||
}
|
||||
//local newer as remote
|
||||
bSameVersion = false;
|
||||
ESP_LOGI(LOG_TAG, "MASTER: remote image on node is older --> OTA send required to node \"%x:%x:%x:%x:%x:%x\"", sOTAMessage.meshSenderAddr.addr[0], sOTAMessage.meshSenderAddr.addr[1], sOTAMessage.meshSenderAddr.addr[2], sOTAMessage.meshSenderAddr.addr[3], sOTAMessage.meshSenderAddr.addr[4], sOTAMessage.meshSenderAddr.addr[5]);
|
||||
// --> this version newer --> start OTA_Tx
|
||||
ERROR_CHECK(errMeshOtaPartitionAccessMeshTransmit(&sOTAMessage.meshSenderAddr));
|
||||
u32Index = QUEUE_MESSAGE_OTA_SIZE;
|
||||
}
|
||||
|
||||
|
||||
if(bSameVersion == true)
|
||||
{
|
||||
ESP_LOGI(LOG_TAG, "MASTER: same version --> NO OTA update");
|
||||
}
|
||||
|
||||
|
||||
/* }
|
||||
else if (err == ESP_OK)
|
||||
{
|
||||
//received from wrong node or type --> back to queue
|
||||
vMeshOtaUtilAddOtaMessageToQueue(&sOTAMessage);
|
||||
}
|
||||
{
|
||||
//received from wrong node or type --> back to queue
|
||||
vMeshOtaUtilAddOtaMessageToQueue(&sOTAMessage);
|
||||
}
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
// OTA Message queue is empty --> wait some time
|
||||
ESP_LOGD(LOG_TAG, "OTA-Master: OTA Message queue is empty --> wait some time");
|
||||
ESP_LOGI(LOG_TAG, "OTA-Master: OTA Message queue is empty --> wait some time");
|
||||
vTaskDelay( (1000/QUEUE_MESSAGE_OTA_SIZE) / portTICK_PERIOD_MS);
|
||||
}
|
||||
}//end loop
|
||||
@ -382,5 +407,8 @@ esp_err_t errMeshOtaMasterEndpoint(bool* const cpbNewOTAImage, const mesh_addr_t
|
||||
ESP_LOGI(LOG_TAG, "OTA-Master: connected and NOT responding --> add node back to queue ");
|
||||
vMeshOtaUtilAddNodeToPossibleUpdatableQueue(cpcMeshNodeAddr->addr);
|
||||
}
|
||||
|
||||
|
||||
ESP_LOGI(LOG_TAG, "OTA-Master: return with %i ", err);
|
||||
return err;
|
||||
}
|
||||
|
Reference in New Issue
Block a user