Browse Source

fixing timeout and non-relevant OTA messages

pull/2/head
Hendrik Schutter 1 year ago
parent
commit
14028679e1
  1. 43
      components/mesh_ota/Mesh_OTA.c
  2. 1
      components/mesh_ota/Mesh_network.c
  3. 5
      components/mesh_ota/include/Mesh_OTA.h

43
components/mesh_ota/Mesh_OTA.c

@ -67,7 +67,7 @@ esp_err_t errMeshOTAInitialize()
}
ERROR_CHECK(errMeshNetworkSetChildConnectedHandle(vAddNodeToPossibleUpdatableQueue));
ERROR_CHECK(errMeshNetworkSetOTAMessageHandleHandle(vAddOTAControllMessageToQueue));
ERROR_CHECK(errMeshNetworkSetOTAMessageHandleHandle(vAddOtaMessageToQueue));
ERROR_CHECK(errMeshNetworkSetChangeStateOfServerWorkerHandle(vChangeStateOfServerWorker));
if(err == ESP_OK)
@ -121,7 +121,7 @@ void vAddNodeToPossibleUpdatableQueue(uint8_t* pu8MAC)
}
}
void vAddOTAControllMessageToQueue(MESH_PACKET_t* puMeshPacket)
void vAddOtaMessageToQueue(MESH_PACKET_t* puMeshPacket)
{
//send ota packet to packet queue
if (xQueueSend(queueMessageOTA, puMeshPacket, portMAX_DELAY) != pdPASS)
@ -455,7 +455,7 @@ esp_err_t errOTAMeshMaster(bool* pbNewOTAImage, mesh_addr_t* pMeshNodeAddr)
else if (err == ESP_OK)
{
//received from wrong node or type --> back to queue
vAddOTAControllMessageToQueue(&sOTAMessage);
vAddOtaMessageToQueue(&sOTAMessage);
}
}
else
@ -674,10 +674,33 @@ esp_err_t errSendOTAVersionResponse(mesh_addr_t* pMeshReceiverAddr)
pBootPartition = esp_ota_get_boot_partition(); //get boot partition (that will booted after reset), not the running partition
ERROR_CHECK(esp_ota_get_partition_description(pBootPartition, &bootPartitionDesc)); //get metadate of partition
memcpy(&packet.au8Payload, &bootPartitionDesc.version, 12); //copy local version to OTA_Version_Response packet
ESP_LOGI(LOG_TAG, "Send OTA_Version_Response to 0x%x", pMeshReceiverAddr->addr[5]);
err = errSendMeshPacket(pMeshReceiverAddr, &packet);
return err;
}
void vClearOtaMessageQueue(mesh_addr_t* pMeshNodeAddr)
{
MESH_PACKET_t sMeshPacket; //packet for sending and receiving
for (uint32_t u32Index = 0; (u32Index < QUEUE_MESSAGE_OTA_SIZE); u32Index++) //loop through all OTA messages
{
if (xQueueReceive(queueMessageOTA, &sMeshPacket, 0) == pdTRUE)
{
if(!(bCheckMACEquality(sMeshPacket.meshSenderAddr.addr, pMeshNodeAddr->addr)))
{
//received OTA message is NOT from pMeshNodeAddr --> keep it in queue
vAddOtaMessageToQueue(&sMeshPacket);
}
else
{
ESP_LOGI(LOG_TAG, "Removed type %i from node 0x%x", sMeshPacket.type, pMeshNodeAddr->addr[5]);
}
}
}//end OTA message loop
}
esp_err_t errSendOTAVersionRequest(mesh_addr_t* pMeshReceiverAddr)
{
esp_err_t err = ESP_OK;
@ -746,7 +769,7 @@ esp_err_t errOTAMeshTransmit(mesh_addr_t* pMeshNodeAddr)
// if(uxQueueSpacesAvailable(queueMessageOTA) < QUEUE_MESSAGE_OTA_SIZE)
// {
//queue not empty
if (xQueueReceive(queueMessageOTA, &sMeshPacket, ((3000) / portTICK_PERIOD_MS)) != pdTRUE)
if (xQueueReceive(queueMessageOTA, &sMeshPacket, ((OTA_MESH_TIMEOUT) / portTICK_PERIOD_MS)) != pdTRUE)
{
ESP_LOGE(LOG_TAG, "Unable to receive OTA Messages from queue");
err = ESP_FAIL;
@ -768,14 +791,14 @@ esp_err_t errOTAMeshTransmit(mesh_addr_t* pMeshNodeAddr)
break;
default:
//receives wrong OTA message type from node --> back to queue
//vAddOTAControllMessageToQueue(&sMeshPacket);
//vAddOtaMessageToQueue(&sMeshPacket);
break;
}
}
else if (err == ESP_OK)
{
//received from wrong node --> back to queue
vAddOTAControllMessageToQueue(&sMeshPacket);
vAddOtaMessageToQueue(&sMeshPacket);
}
/*
}
@ -798,6 +821,7 @@ esp_err_t errOTAMeshTransmit(mesh_addr_t* pMeshNodeAddr)
}
u32SegmentCounter++;
}//end of partition segment loop
vClearOtaMessageQueue(pMeshNodeAddr);
return err;
}
@ -826,7 +850,7 @@ esp_err_t errOTAMeshReceive(bool* pbNewOTAImage, mesh_addr_t* pMeshNodeAddr)
//if(uxQueueSpacesAvailable(queueMessageOTA) < QUEUE_MESSAGE_OTA_SIZE)
// {
//queue not empty
if (xQueueReceive(queueMessageOTA, &sMeshPacket, ((3000) / portTICK_PERIOD_MS)) != pdTRUE)
if (xQueueReceive(queueMessageOTA, &sMeshPacket, ((OTA_MESH_TIMEOUT) / portTICK_PERIOD_MS)) != pdTRUE)
{
ESP_LOGE(LOG_TAG, "Unable to receive OTA Messages from queue");
err = ESP_FAIL;
@ -856,14 +880,14 @@ esp_err_t errOTAMeshReceive(bool* pbNewOTAImage, mesh_addr_t* pMeshNodeAddr)
break;
default:
//receives wrong OTA message type from node --> back to queue
//vAddOTAControllMessageToQueue(&sMeshPacket);
//vAddOtaMessageToQueue(&sMeshPacket);
break;
}
}
else if (err == ESP_OK)
{
//received from wrong node --> back to queue
vAddOTAControllMessageToQueue(&sMeshPacket);
vAddOtaMessageToQueue(&sMeshPacket);
}
/* }
@ -927,5 +951,6 @@ esp_err_t errOTAMeshReceive(bool* pbNewOTAImage, mesh_addr_t* pMeshNodeAddr)
//not all OTA segments received --> abort this OTA process
ERROR_CHECK(esp_ota_abort(otaHandle));
}
vClearOtaMessageQueue(pMeshNodeAddr);
return err;
}

1
components/mesh_ota/Mesh_network.c

@ -136,7 +136,6 @@ bool bCheckMACEquality(uint8_t* pu8aMAC, uint8_t* pu8bMAC)
bRet = true; //last byte differs 1 ore less
}
}
index++;
}
return bRet;

5
components/mesh_ota/include/Mesh_OTA.h

@ -23,7 +23,7 @@
#define OTA_HTTPS_SEGMENT_SIZE 2048U
#define OTA_PROGRESS_LOG_INTERVAL 7U
#define OTA_MESH_SEGMENT_SIZE MESH_NETWORK_PAYLOAD_SIZE
#define OTA_MESH_TIMEOUT 400U //in ms
#define OTA_MESH_TIMEOUT 20000U //in ms
#define ERROR_CHECK(x) if (err == ESP_OK) \
{ \
@ -59,10 +59,11 @@ void vPrintOTAProgress(const uint32_t* const pu32TotalImageSize, const uint32_t*
void vAddAllNeighboursToQueue(void);
esp_err_t errSendOTAVersionResponse(mesh_addr_t* meshReceiverAddr);
esp_err_t errSendOTAVersionRequest(mesh_addr_t* meshReceiverAddr);
void vClearOtaMessageQueue(mesh_addr_t* pMeshNodeAddr);
//Handler
void vAddNodeToPossibleUpdatableQueue(uint8_t* pu8MAC);
void vAddOTAControllMessageToQueue(MESH_PACKET_t* puMeshPacket);
void vAddOtaMessageToQueue(MESH_PACKET_t* puMeshPacket);
void vChangeStateOfServerWorker(bool state);
//Tasks

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