Browse Source

fix in MAC equality check fn

develop
Hendrik Schutter 1 year ago
parent
commit
a930f709ff
  1. 5
      components/mesh_ota/Mesh_Network.c
  2. 68
      components/mesh_ota/test/test_mesh_ota.c

5
components/mesh_ota/Mesh_Network.c

@ -320,13 +320,13 @@ bool bMeshNetworkCheckMacEquality(const uint8_t* const cpcu8aMAC, const uint8_t*
bool bRet = true;
uint8_t index = 0;
while ((index < 6) && (bRet == true))
while ((index < 10) && (bRet == true))
{
if(cpcu8aMAC[index] != cpcu8bMAC[index])
{
bRet = false;
}
/*
if(index == 5)
{
//last byte of mac
@ -335,6 +335,7 @@ bool bMeshNetworkCheckMacEquality(const uint8_t* const cpcu8aMAC, const uint8_t*
bRet = true; //last byte differs 1 ore less
}
}
*/
index++;
}
return bRet;

68
components/mesh_ota/test/test_mesh_ota.c

@ -3,6 +3,7 @@
#include "Mesh_OTA_Util.h"
#include "test_image_hex.h"
#include "Mesh_Network.h"
// ### ### ### distinguish newer image version ### ### ###
@ -206,11 +207,78 @@ TEST_CASE("extract version 999.99.999", "[extract image version number]")
}
TEST_CASE("same MACs", "[check MAC equality]")
{
unsigned char cMAC_A[] = "012345678901";
unsigned char cMAC_B[] = "012345678901";
TEST_ASSERT_TRUE( bMeshNetworkCheckMacEquality(cMAC_A,cMAC_B) );
}
TEST_CASE("different MACs", "[check MAC equality]")
{
unsigned char cMAC_A[] = "012345678901";
unsigned char cMAC_B[] = "087464874718";
TEST_ASSERT_FALSE( bMeshNetworkCheckMacEquality(cMAC_A,cMAC_B) );
}
TEST_CASE("same MACs last A_byte+1", "[check MAC equality]")
{
unsigned char cMAC_A[] = "012345678902";
unsigned char cMAC_B[] = "012345678901";
TEST_ASSERT_TRUE( bMeshNetworkCheckMacEquality(cMAC_A,cMAC_B) );
}
TEST_CASE("same MACs last B_byte+1", "[check MAC equality]")
{
unsigned char cMAC_A[] = "012345678901";
unsigned char cMAC_B[] = "012345678902";
TEST_ASSERT_TRUE( bMeshNetworkCheckMacEquality(cMAC_A,cMAC_B) );
}
TEST_CASE("same MACs last B_byte+2", "[check MAC equality]")
{
unsigned char cMAC_A[] = "012345678901";
unsigned char cMAC_B[] = "012345678903";
TEST_ASSERT_TRUE( bMeshNetworkCheckMacEquality(cMAC_A,cMAC_B) );
}
TEST_CASE("different MACs last B_byte+2", "[check MAC equality]")
{
unsigned char cMAC_A[] = "012344678901";
unsigned char cMAC_B[] = "012345678903";
TEST_ASSERT_FALSE( bMeshNetworkCheckMacEquality(cMAC_A,cMAC_B) );
}
TEST_CASE("same Node0", "[check MAC equality]")
{
unsigned char cMAC_A[] = "ac67b27162b0";
unsigned char cMAC_B[] = "ac67b27162b0";
TEST_ASSERT_TRUE( bMeshNetworkCheckMacEquality(cMAC_A,cMAC_B) );
}
TEST_CASE("same Node0 first MAC+1", "[check MAC equality]")
{
unsigned char cMAC_A[] = "ac67b27162b1";
unsigned char cMAC_B[] = "ac67b27162b0";
TEST_ASSERT_TRUE( bMeshNetworkCheckMacEquality(cMAC_A,cMAC_B) );
}
TEST_CASE("same Node0 second MAC+1", "[check MAC equality]")
{
unsigned char cMAC_A[] = "ac67b27162b0";
unsigned char cMAC_B[] = "ac67b27162b1";
TEST_ASSERT_TRUE( bMeshNetworkCheckMacEquality(cMAC_A,cMAC_B) );
}

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