change association table to format 1 (see 3_5_1 p 157)

This commit is contained in:
Thomas Kunze 2019-07-26 23:00:08 +02:00
parent 8e9aef17ab
commit de8f4631b6
3 changed files with 12 additions and 12 deletions

View File

@ -38,7 +38,7 @@ void ApplicationLayer::dataGroupIndication(HopCountType hopType, Priority priori
}
uint16_t startIdx = 0;
uint32_t asap = _assocTable.nextAsap(tsap, startIdx);
int32_t asap = _assocTable.nextAsap(tsap, startIdx);
for (; asap != -1; asap = _assocTable.nextAsap(tsap, startIdx))
{
switch (apdu.type())

View File

@ -34,7 +34,7 @@ uint16_t AssociationTableObject::operator[](uint16_t idx)
if (idx < 0 || idx >= entryCount())
return 0;
return ntohs(_tableData[idx + 1]);
return ntohs(_tableData[2 * idx + 1]);
}
uint8_t* AssociationTableObject::save(uint8_t* buffer)
@ -53,11 +53,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; i++)
for (uint16_t i = 0; i < entries * 2; i+=2)
{
uint16_t entry = operator[](i);
if (lowByte(entry) == asap)
return highByte(entry);
if (operator[](i + 1) == asap)
return operator[](i);
}
return -1;
}
@ -75,7 +74,7 @@ void AssociationTableObject::beforeStateChange(LoadState& newState)
static PropertyDescription _propertyDescriptions[] =
{
{ PID_OBJECT_TYPE, false, PDT_UNSIGNED_INT, 1, ReadLv3 | WriteLv0 },
{ PID_TABLE, false, PDT_GENERIC_02, 254, ReadLv3 | WriteLv0 },
{ PID_TABLE, false, PDT_GENERIC_04, 65535, ReadLv3 | WriteLv0 },
{ PID_LOAD_STATE_CONTROL, true, PDT_CONTROL, 1, ReadLv3 | WriteLv3 },
{ PID_TABLE_REFERENCE, false, PDT_UNSIGNED_LONG, 1, ReadLv3 | WriteLv0 },
{ PID_ERROR_CODE, false, PDT_ENUM8, 1, ReadLv3 | WriteLv0 },
@ -93,15 +92,16 @@ PropertyDescription* AssociationTableObject::propertyDescriptions()
return _propertyDescriptions;
}
int32_t AssociationTableObject::nextAsap(uint16_t tsap, uint16_t startIdx)
int32_t AssociationTableObject::nextAsap(uint16_t tsap, uint16_t& startIdx)
{
uint16_t entries = entryCount();
for (uint16_t i = startIdx; i < entries; i++)
{
uint16_t entry = operator[](i);
if (highByte(entry) == tsap)
startIdx = i;
if (operator[](i) == tsap)
{
return lowByte(entry);
return operator[](i+1);
}
}
return -1;

View File

@ -12,7 +12,7 @@ class AssociationTableObject : public TableObject
uint8_t* restore(uint8_t* buffer);
int32_t translateAsap(uint16_t asap);
int32_t nextAsap(uint16_t tsap, uint16_t startIdx);
int32_t nextAsap(uint16_t tsap, uint16_t& startIdx);
protected:
void beforeStateChange(LoadState& newState);