diff --git a/src/knx/association_table_object.cpp b/src/knx/association_table_object.cpp index 926cd9d..ce428ae 100644 --- a/src/knx/association_table_object.cpp +++ b/src/knx/association_table_object.cpp @@ -29,7 +29,7 @@ uint16_t AssociationTableObject::entryCount() return ntohs(_tableData[0]); } -uint16_t AssociationTableObject::operator[](uint16_t idx) +uint16_t AssociationTableObject::getTSAP(uint16_t idx) { if (idx < 0 || idx >= entryCount()) return 0; @@ -37,6 +37,14 @@ uint16_t AssociationTableObject::operator[](uint16_t idx) return ntohs(_tableData[2 * idx + 1]); } +uint16_t AssociationTableObject::getASAP(uint16_t idx) +{ + if (idx < 0 || idx >= entryCount()) + return 0; + + return ntohs(_tableData[2 * idx + 2]); +} + uint8_t* AssociationTableObject::save(uint8_t* buffer) { return TableObject::save(buffer); @@ -53,10 +61,10 @@ uint8_t* AssociationTableObject::restore(uint8_t* buffer) int32_t AssociationTableObject::translateAsap(uint16_t asap) { uint16_t entries = entryCount(); - for (uint16_t i = 0; i < entries * 2; i+=2) + for (uint16_t i = 0; i < entries; i++) { - if (operator[](i + 1) == asap) - return operator[](i); + if (getASAP(i) == asap) + return getTSAP(i); } return -1; } @@ -97,11 +105,11 @@ int32_t AssociationTableObject::nextAsap(uint16_t tsap, uint16_t& startIdx) uint16_t entries = entryCount(); for (uint16_t i = startIdx; i < entries; i++) { - startIdx = i; + startIdx = i+1; - if (operator[](i) == tsap) + if (getTSAP(i) == tsap) { - return operator[](i+1); + return getASAP(i); } } return -1; diff --git a/src/knx/association_table_object.h b/src/knx/association_table_object.h index 7b943ce..b56587c 100644 --- a/src/knx/association_table_object.h +++ b/src/knx/association_table_object.h @@ -21,6 +21,7 @@ class AssociationTableObject : public TableObject private: uint16_t entryCount(); - uint16_t operator[](uint16_t idx); + uint16_t getTSAP(uint16_t idx); + uint16_t getASAP(uint16_t idx); uint16_t* _tableData = 0; -}; \ No newline at end of file +}; diff --git a/src/knx/tpuart_data_link_layer.cpp b/src/knx/tpuart_data_link_layer.cpp index 13b688d..12b45fe 100644 --- a/src/knx/tpuart_data_link_layer.cpp +++ b/src/knx/tpuart_data_link_layer.cpp @@ -235,7 +235,7 @@ void TpUartDataLinkLayer::loop() //Destination Address + payload available _xorSum ^= rxByte; //check if echo - if (!((buffer[0] ^ _sendBuffer[0]) & ~0x20) && !memcmp(buffer + 2, _sendBuffer + 1, 5)) + if (!((buffer[0] ^ _sendBuffer[0]) & ~0x20) && !memcmp(buffer + _convert + 1, _sendBuffer + 1, 5)) { //ignore repeated bit of control byte _isEcho = true; }