Browse Source

cleanup debug out

develop
Hendrik Schutter 1 year ago
parent
commit
b9e0769843
  1. 28
      components/mesh_ota/Mesh_Network.c
  2. 44
      components/mesh_ota/Mesh_OTA.c
  3. 16
      components/mesh_ota/Mesh_OTA_Partition_Access.c
  4. 24
      components/mesh_ota/Mesh_OTA_Util.c
  5. 1
      main/Blinky_LED.h
  6. 2
      sdkconfig

28
components/mesh_ota/Mesh_Network.c

@ -308,7 +308,7 @@ bool bMeshNetworkIsNodeNeighbour(const mesh_addr_t* const cpcNode)
/**
* @fn bool bMeshNetworkCheckMacEquality(const uint8_t* const cpcu8aMAC, const uint8_t* const cpcu8bMAC)
* @brief returns true if MAC address is equal
* @brief returns true if MAC address is equal, compares only the first 5 bytes, the last is node specific
* @param cpcu8aMAC first MAC
* @param cpcu8bMAC second MAC
* @return boolean
@ -322,35 +322,12 @@ bool bMeshNetworkCheckMacEquality(const uint8_t* const cpcu8aMAC, const uint8_t*
while ((index < 5) && (bRet == true))
{
ESP_LOGI(LOG_TAG, "MACequal: check %x and %x",cpcu8aMAC[index], cpcu8bMAC[index] );
if(cpcu8aMAC[index] != cpcu8bMAC[index])
{
bRet = false;
ESP_LOGI(LOG_TAG, "MACequal: differ %x and %x",cpcu8aMAC[index], cpcu8bMAC[index] );
}
/*
if(index == 5)
{
//last byte of mac
if(abs((cpcu8aMAC[index] - cpcu8bMAC[index])) <= 1)
{
bRet = true; //last byte differs 1 ore less
}
}
*/
index++;
}
if(bRet)
{
ESP_LOGI(LOG_TAG, "MAC same");
}
else
{
ESP_LOGI(LOG_TAG, "MAC NOT same");
}
return bRet;
}
@ -406,8 +383,6 @@ esp_err_t errMeshNetworkGetChildren(mesh_addr_t* const cpChildren, uint16_t* con
mesh_addr_t route_table[CONFIG_MESH_ROUTE_TABLE_SIZE];
ERROR_CHECK(esp_mesh_get_routing_table((mesh_addr_t *) &route_table, (CONFIG_MESH_ROUTE_TABLE_SIZE * 6), &route_table_size));
ESP_LOGI(LOG_TAG, "child: own Node: \"0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x\" ", u8ownMAC[0], u8ownMAC[1], u8ownMAC[2], u8ownMAC[3], u8ownMAC[4], u8ownMAC[5]);
if (err == ESP_OK)
{
for(uint16_t index = 0; index < esp_mesh_get_routing_table_size(); index++)
@ -415,7 +390,6 @@ esp_err_t errMeshNetworkGetChildren(mesh_addr_t* const cpChildren, uint16_t* con
if(! (bMeshNetworkCheckMacEquality(u8ownMAC, route_table[index].addr)) )
{
//child node
ESP_LOGI(LOG_TAG, "CHILDADD Node: \"0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x\" ", route_table[index].addr[0], route_table[index].addr[1], route_table[index].addr[2], route_table[index].addr[3], route_table[index].addr[4], route_table[index].addr[5]);
cpChildren[*cpu16ChildrenSize] = route_table[index];
(*cpu16ChildrenSize) = (*cpu16ChildrenSize)+1;
}

44
components/mesh_ota/Mesh_OTA.c

@ -189,7 +189,7 @@ void vMeshOtaTaskOTAWorker(void *arg)
if((uxQueueSpacesAvailable(queueNodes) - QUEUE_NODES_SIZE) == 0)
{
ESP_LOGI(LOG_TAG, "//nodes queue is empty");
//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))
@ -204,15 +204,13 @@ void vMeshOtaTaskOTAWorker(void *arg)
}
else
{
ESP_LOGI(LOG_TAG, "//queue not empty %i", (uxQueueSpacesAvailable(queueNodes) - QUEUE_NODES_SIZE));
//queue not empty
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)
@ -232,8 +230,6 @@ void vMeshOtaTaskOTAWorker(void *arg)
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);
@ -244,6 +240,7 @@ void vMeshOtaTaskOTAWorker(void *arg)
* @fn esp_err_t errMeshOtaSlaveEndpoint(bool* const cpbNewOTAImage)
* @brief Endpoint for OTA process that is called from remote node
* @param cpbNewOTAImage pointer to boolean to signal if a new image was successfully received
* @param cpcMeshNodeAddr pointer to mesh node that transmitted the update
* @return ESP32 error code
* @author Hendrik Schutter
* @date 21.01.2021
@ -265,7 +262,6 @@ esp_err_t errMeshOtaSlaveEndpoint(bool* const cpbNewOTAImage, mesh_addr_t* const
//queue not empty
if (xQueueReceive(queueMessageOTA, &sOTAMessage, ((100) / portTICK_PERIOD_MS)) != pdTRUE)
{
ESP_LOGE(LOG_TAG, "SLAVE: Unable to receive OTA Messages from Queue");
err = ESP_FAIL;
}
@ -284,7 +280,7 @@ esp_err_t errMeshOtaSlaveEndpoint(bool* const cpbNewOTAImage, mesh_addr_t* const
if((bMeshOtaUtilNewerVersion((bootPartitionDesc).version, (char*) sOTAMessage.au8Payload)) && (err == ESP_OK)) //compare local and remote version
{
//remote newer as local
ESP_LOGI(LOG_TAG, "SLAVE: 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]);
ESP_LOGI(LOG_TAG, "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));
}
@ -292,7 +288,7 @@ esp_err_t errMeshOtaSlaveEndpoint(bool* const cpbNewOTAImage, mesh_addr_t* const
if((bMeshOtaUtilNewerVersion((char*) sOTAMessage.au8Payload, (bootPartitionDesc).version)) && (err == ESP_OK)) //compare remote and local version
{
//local newer as remote
ESP_LOGI(LOG_TAG, "SLAVE: 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]);
ESP_LOGI(LOG_TAG, "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));
}
@ -332,7 +328,6 @@ 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) && (bSameVersion == false)); u32Index++) //loop through all OTA messages
{
@ -341,13 +336,9 @@ esp_err_t errMeshOtaMasterEndpoint(bool* const cpbNewOTAImage, const mesh_addr_t
//queue not empty
if (xQueueReceive(queueMessageOTA, &sOTAMessage, ((3000) / portTICK_PERIOD_MS)) != pdTRUE)
{
ESP_LOGE(LOG_TAG, "MASTER: Unable to receive OTA Messages from queue");
ESP_LOGE(LOG_TAG, "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
{
@ -360,7 +351,7 @@ esp_err_t errMeshOtaMasterEndpoint(bool* const cpbNewOTAImage, const mesh_addr_t
{
//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]);
ESP_LOGI(LOG_TAG, "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;
@ -370,31 +361,15 @@ esp_err_t errMeshOtaMasterEndpoint(bool* const cpbNewOTAImage, const mesh_addr_t
{
//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]);
ESP_LOGI(LOG_TAG, "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);
}
*/
}
else
{
// 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
@ -407,8 +382,5 @@ 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;
}

16
components/mesh_ota/Mesh_OTA_Partition_Access.c

@ -155,10 +155,7 @@ esp_err_t errMeshOtaPartitionAccessMeshTransmit(const mesh_addr_t* const cpcMesh
ESP_LOGI(LOG_TAG, "OTA-TX: last segment--> send Complete");
sMeshPacket.type = OTA_Complete;
}
else
{
ESP_LOGI(LOG_TAG, "OTA-TX: send data");
}
err = errMeshNetworkSendMeshPacket(cpcMeshNodeAddr, &sMeshPacket);
}
else
@ -199,12 +196,6 @@ esp_err_t errMeshOtaPartitionAccessMeshTransmit(const mesh_addr_t* const cpcMesh
break;
}
}
else if (err == ESP_OK)
{
ESP_LOGI(LOG_TAG, "OTA-TX: //received from wrong node --> back to queue");
//vMeshOtaUtilAddOtaMessageToQueue(&sMeshPacket);
//vTaskDelay( (1000) / portTICK_PERIOD_MS);
}
}//end OTA message loop
if(bNodeIsResponding == false)
@ -255,8 +246,6 @@ esp_err_t errMeshOtaPartitionAccessMeshReceive(bool* const cpbNewOTAImage, const
// loop through all OTA messages or until abort is called
for (uint32_t u32Index = 0; ((u32Index < QUEUE_MESSAGE_OTA_SIZE) && (bAbort == false)); u32Index++) //loop through all OTA messages
{
//if(uxQueueSpacesAvailable(queueMessageOTA) < QUEUE_MESSAGE_OTA_SIZE)
// {
//queue not empty
if (xQueueReceive(queueMessageOTA, &sMeshPacket, ((OTA_MESH_TIMEOUT) / portTICK_PERIOD_MS)) != pdTRUE)
{
@ -271,10 +260,8 @@ esp_err_t errMeshOtaPartitionAccessMeshReceive(bool* const cpbNewOTAImage, const
{
case OTA_Complete: //signal end of this OTA process, fall through because same behavior as OTA_Data
bComplete = true;
ESP_LOGE(LOG_TAG, "OTA-RX: receives complete");
//fall through
case OTA_Data: //data segement received
ESP_LOGE(LOG_TAG, "OTA-RX: receives data");
bNodeIsResponding = true;
ERROR_CHECK(esp_ota_write(otaHandle, sMeshPacket.au8Payload, OTA_MESH_SEGMENT_SIZE));
u32OTABytesWritten = ((u32SegmentCounter+1) * OTA_MESH_SEGMENT_SIZE); //calc bytes that are written in this ota process
@ -317,7 +304,6 @@ esp_err_t errMeshOtaPartitionAccessMeshReceive(bool* const cpbNewOTAImage, const
//no error while ota write --> send OTA_ACK packet
sMeshPacket.type = OTA_ACK;
err = errMeshNetworkSendMeshPacket(cpcMeshNodeAddr, &sMeshPacket);
ESP_LOGE(LOG_TAG, "OTA-RX: sent ACK");
}
}
else

24
components/mesh_ota/Mesh_OTA_Util.c

@ -262,8 +262,8 @@ void vMeshOtaUtilPrintOtaProgress(const uint32_t* const cpcu32TotalImageSize, co
/**
* @fn void vMeshOtaUtilAddAllNeighboursToQueue(void)
* @brief add all neigbhours (children and parent) to queue
* @param void
* @brief add all neigbhours (children and parent) to queue, except node used in parameter
* @param const mesh_addr_t* const cpcMeshNodeAddr
* @return void
* @author Hendrik Schutter
* @date 21.01.2021
@ -287,13 +287,11 @@ void vMeshOtaUtilAddAllNeighboursToQueue(const mesh_addr_t* const cpcMeshNodeAdd
}
else
{
ESP_LOGI(LOG_TAG, "AddAllNodes: parent: %x - %x", addrParent.addr[5], cpcMeshNodeAddr->addr[5]);
vMeshOtaUtilAddNodeToPossibleUpdatableQueue(addrParent.addr);
}
}
else
{
ESP_LOGI(LOG_TAG, "AddAllNodes: NULL parent");
vMeshOtaUtilAddNodeToPossibleUpdatableQueue(addrParent.addr);
}
@ -313,13 +311,11 @@ void vMeshOtaUtilAddAllNeighboursToQueue(const mesh_addr_t* const cpcMeshNodeAdd
}
else
{
ESP_LOGI(LOG_TAG, "AddAllNodes: Child: %x", childrenAddr[u16Index].addr[5]);
vMeshOtaUtilAddNodeToPossibleUpdatableQueue(childrenAddr[u16Index].addr);
}
}
else
{
ESP_LOGI(LOG_TAG, "AddAllNodes: NULL Child: %x", childrenAddr[u16Index].addr[5]);
vMeshOtaUtilAddNodeToPossibleUpdatableQueue(childrenAddr[u16Index].addr);
}
}
@ -366,19 +362,15 @@ void vMeshOtaUtilClearNeighboursQueue(const mesh_addr_t* const cpcMeshNodeAddr)
{
if((bMeshNetworkCheckMacEquality(sNode.addr, cpcMeshNodeAddr->addr)))
{
ESP_LOGI(LOG_TAG, "REMOVE_NODE: remove node %x", sNode.addr[5]);
//same node --> don't add again
}
else
{
ESP_LOGI(LOG_TAG, "//node is NOT cpcMeshNodeAddr: %x --> keep it in queue", sNode.addr[5]);
//node is NOT cpcMeshNodeAddr --> keep it in queue
vMeshOtaUtilAddNodeToPossibleUpdatableQueue(sNode.addr);
}
}
else
{
ESP_LOGI(LOG_TAG, "REMOVE_NODE: queue leer");
}
}//end nodes
}
@ -402,7 +394,7 @@ void vMeshOtaUtilAddNodeToPossibleUpdatableQueue(const uint8_t* const cpcu8MAC)
}
else
{
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]);
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]);
}
}
@ -426,14 +418,14 @@ void vMeshOtaUtilAddOtaMessageToQueue(const MESH_PACKET_t* const cpcuMeshPacket)
switch (cpcuMeshPacket->type)
{
case OTA_Abort:
ESP_LOGI(LOG_TAG, "added ota message to queue: OTA_Abort from 0x%x", cpcuMeshPacket->meshSenderAddr.addr[5]);
ESP_LOGD(LOG_TAG, "added ota message to queue: OTA_Abort from 0x%x", cpcuMeshPacket->meshSenderAddr.addr[5]);
break;
case OTA_Version_Request:
ESP_LOGI(LOG_TAG, "added ota message to queue: OTA_Version_Request from 0x%x", cpcuMeshPacket->meshSenderAddr.addr[5]);
ESP_LOGD(LOG_TAG, "added ota message to queue: OTA_Version_Request from 0x%x", cpcuMeshPacket->meshSenderAddr.addr[5]);
break;
case OTA_Version_Response:
ESP_LOGI(LOG_TAG, "added ota message to queue: OTA_Version Response from 0x%x", cpcuMeshPacket->meshSenderAddr.addr[5]);
ESP_LOGD(LOG_TAG, "added ota message to queue: OTA_Version Response from 0x%x", cpcuMeshPacket->meshSenderAddr.addr[5]);
break;
default:
break;

1
main/Blinky_LED.h

@ -26,7 +26,6 @@
#define GPIO_LED_BLUE 2 //GPIO2 (internal blue LED in DevKit V1.0)
#define GPIO_LED_GREEN 13 //GPIO13
#define GPIO_INPUT_PIN_SEL (1ULL<<GPIO_BOOT_BTN)
struct blinky_packet

2
sdkconfig

@ -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.46"
CONFIG_APP_PROJECT_VER="0.1.3"
CONFIG_APP_RETRIEVE_LEN_ELF_SHA=16
# end of Application manager

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