mirror of
				https://github.com/thelsing/knx.git
				synced 2025-10-26 10:26:25 +01:00 
			
		
		
		
	change association table to format 1 (see 3_5_1 p 157)
This commit is contained in:
		
							parent
							
								
									8e9aef17ab
								
							
						
					
					
						commit
						de8f4631b6
					
				@ -38,7 +38,7 @@ void ApplicationLayer::dataGroupIndication(HopCountType hopType, Priority priori
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    uint16_t startIdx = 0;
 | 
					    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))
 | 
					    for (; asap != -1; asap = _assocTable.nextAsap(tsap, startIdx))
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        switch (apdu.type())
 | 
					        switch (apdu.type())
 | 
				
			||||||
 | 
				
			|||||||
@ -34,7 +34,7 @@ uint16_t AssociationTableObject::operator[](uint16_t idx)
 | 
				
			|||||||
    if (idx < 0 || idx >= entryCount())
 | 
					    if (idx < 0 || idx >= entryCount())
 | 
				
			||||||
        return 0;
 | 
					        return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return ntohs(_tableData[idx + 1]);
 | 
					    return ntohs(_tableData[2 * idx + 1]);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
uint8_t* AssociationTableObject::save(uint8_t* buffer)
 | 
					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)
 | 
					int32_t AssociationTableObject::translateAsap(uint16_t asap)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    uint16_t entries = entryCount();
 | 
					    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 (operator[](i + 1) == asap)
 | 
				
			||||||
        if (lowByte(entry) == asap)
 | 
					            return operator[](i);
 | 
				
			||||||
            return highByte(entry);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return -1;
 | 
					    return -1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -75,7 +74,7 @@ void AssociationTableObject::beforeStateChange(LoadState& newState)
 | 
				
			|||||||
static PropertyDescription _propertyDescriptions[] =
 | 
					static PropertyDescription _propertyDescriptions[] =
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    { PID_OBJECT_TYPE, false, PDT_UNSIGNED_INT, 1, ReadLv3 | WriteLv0 },
 | 
					    { 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_LOAD_STATE_CONTROL, true, PDT_CONTROL, 1, ReadLv3 | WriteLv3 },
 | 
				
			||||||
    { PID_TABLE_REFERENCE, false, PDT_UNSIGNED_LONG, 1, ReadLv3 | WriteLv0 },
 | 
					    { PID_TABLE_REFERENCE, false, PDT_UNSIGNED_LONG, 1, ReadLv3 | WriteLv0 },
 | 
				
			||||||
    { PID_ERROR_CODE, false, PDT_ENUM8, 1, ReadLv3 | WriteLv0 },
 | 
					    { PID_ERROR_CODE, false, PDT_ENUM8, 1, ReadLv3 | WriteLv0 },
 | 
				
			||||||
@ -93,15 +92,16 @@ PropertyDescription* AssociationTableObject::propertyDescriptions()
 | 
				
			|||||||
    return _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();
 | 
					    uint16_t entries = entryCount();
 | 
				
			||||||
    for (uint16_t i = startIdx; i < entries; i++)
 | 
					    for (uint16_t i = startIdx; i < entries; i++)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        uint16_t entry = operator[](i);
 | 
					        startIdx = i;
 | 
				
			||||||
        if (highByte(entry) == tsap)
 | 
					
 | 
				
			||||||
 | 
					        if (operator[](i) == tsap)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            return lowByte(entry);
 | 
					            return operator[](i+1);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return -1;
 | 
					    return -1;
 | 
				
			||||||
 | 
				
			|||||||
@ -12,7 +12,7 @@ class AssociationTableObject : public TableObject
 | 
				
			|||||||
    uint8_t* restore(uint8_t* buffer);
 | 
					    uint8_t* restore(uint8_t* buffer);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int32_t translateAsap(uint16_t asap);
 | 
					    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:
 | 
					  protected:
 | 
				
			||||||
    void beforeStateChange(LoadState& newState);
 | 
					    void beforeStateChange(LoadState& newState);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user