mirror of
				https://github.com/thelsing/knx.git
				synced 2025-10-26 10:26:25 +01:00 
			
		
		
		
	improve encapsulation of accociation table
This commit is contained in:
		
							parent
							
								
									b4c8671dbb
								
							
						
					
					
						commit
						8e9aef17ab
					
				| @ -22,8 +22,6 @@ void ApplicationLayer::transportLayer(TransportLayer& layer) | ||||
| 
 | ||||
| void ApplicationLayer::dataGroupIndication(HopCountType hopType, Priority priority, uint16_t tsap, APDU& apdu) | ||||
| { | ||||
|     uint16_t entries = _assocTable.entryCount(); | ||||
|      | ||||
|     uint8_t len = apdu.length(); | ||||
|     uint8_t dataArray[len]; | ||||
|     uint8_t* data = dataArray; | ||||
| @ -39,14 +37,12 @@ void ApplicationLayer::dataGroupIndication(HopCountType hopType, Priority priori | ||||
|         len -= 1; | ||||
|     } | ||||
| 
 | ||||
|     for (uint16_t i = 0; i < entries; i++) | ||||
|     uint16_t startIdx = 0; | ||||
|     uint32_t asap = _assocTable.nextAsap(tsap, startIdx); | ||||
|     for (; asap != -1; asap = _assocTable.nextAsap(tsap, startIdx)) | ||||
|     { | ||||
|         uint16_t entry = _assocTable[i]; | ||||
|         if (highByte(entry) == tsap) | ||||
|         switch (apdu.type()) | ||||
|         { | ||||
|             uint16_t asap = lowByte(entry); | ||||
|             switch (apdu.type()) | ||||
|             { | ||||
|             case GroupValueRead: | ||||
|                 _bau.groupValueReadIndication(asap, priority, hopType); | ||||
|                 break; | ||||
| @ -55,7 +51,6 @@ void ApplicationLayer::dataGroupIndication(HopCountType hopType, Priority priori | ||||
|                 break; | ||||
|             case GroupValueWrite: | ||||
|                 _bau.groupValueWriteIndication(asap, priority, hopType, data, len); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -49,6 +49,7 @@ uint8_t* AssociationTableObject::restore(uint8_t* buffer) | ||||
|     return buffer; | ||||
| } | ||||
| 
 | ||||
| // return type is int32 so that we can return uint16 and -1
 | ||||
| int32_t AssociationTableObject::translateAsap(uint16_t asap) | ||||
| { | ||||
|     uint16_t entries = entryCount(); | ||||
| @ -61,6 +62,8 @@ int32_t AssociationTableObject::translateAsap(uint16_t asap) | ||||
|     return -1; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| void AssociationTableObject::beforeStateChange(LoadState& newState) | ||||
| { | ||||
|     if (newState != LS_LOADED) | ||||
| @ -88,4 +91,18 @@ uint8_t AssociationTableObject::propertyCount() | ||||
| PropertyDescription* AssociationTableObject::propertyDescriptions() | ||||
| { | ||||
|     return _propertyDescriptions; | ||||
| } | ||||
| } | ||||
| 
 | ||||
| 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) | ||||
|         { | ||||
|             return lowByte(entry); | ||||
|         } | ||||
|     } | ||||
|     return -1; | ||||
| } | ||||
|  | ||||
| @ -7,12 +7,12 @@ class AssociationTableObject : public TableObject | ||||
|   public: | ||||
|     AssociationTableObject(Platform& platform); | ||||
|     void readProperty(PropertyID id, uint32_t start, uint32_t& count, uint8_t* data); | ||||
|     uint16_t entryCount(); | ||||
|     uint16_t operator[](uint16_t idx); | ||||
| 
 | ||||
|     uint8_t* save(uint8_t* buffer); | ||||
|     uint8_t* restore(uint8_t* buffer); | ||||
| 
 | ||||
|     int32_t translateAsap(uint16_t asap); | ||||
|     int32_t nextAsap(uint16_t tsap, uint16_t startIdx); | ||||
| 
 | ||||
|   protected: | ||||
|     void beforeStateChange(LoadState& newState); | ||||
| @ -20,5 +20,7 @@ class AssociationTableObject : public TableObject | ||||
|     PropertyDescription* propertyDescriptions(); | ||||
| 
 | ||||
|   private: | ||||
|     uint16_t entryCount(); | ||||
|     uint16_t operator[](uint16_t idx); | ||||
|     uint16_t* _tableData = 0; | ||||
| }; | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user