mirror of
				https://github.com/thelsing/knx.git
				synced 2025-10-26 10:26:25 +01:00 
			
		
		
		
	Refactor broadcast/systembroadcast (#62)
* Add missing source files * Fix comment * Refactor Broadcast/SystemBroadcast * Add empty confirm methods * Remove unclean solution to suppress warning about unsed var * Restore old structure * Fix issues * Add more missing source files * Make sure that services from SystemBroadcast are also available from Broadcast on closed media * Make sure that sent broadcast/systembroadcast frames are always marked as broadcast frames on closed media
This commit is contained in:
		
							parent
							
								
									fa269a259d
								
							
						
					
					
						commit
						cadc6c6124
					
				| @ -28,8 +28,11 @@ add_executable(knx-linux | ||||
| 	../../src/knx/cemi_frame.cpp | ||||
| 	../../src/knx/cemi_frame.h | ||||
| 	../../src/knx/cemi_server.cpp  | ||||
| 	../../src/knx/cemi_server_object.cpp  | ||||
| 	../../src/knx/data_link_layer.cpp  | ||||
|         ../../src/knx/cemi_server.h | ||||
|         ../../src/knx/cemi_server_object.cpp | ||||
|         ../../src/knx/cemi_server_object.h | ||||
|         ../../src/knx/config.h | ||||
|         ../../src/knx/data_link_layer.cpp | ||||
| 	../../src/knx/data_link_layer.h | ||||
| 	../../src/knx/data_property.cpp  | ||||
| 	../../src/knx/data_property.h | ||||
| @ -50,14 +53,23 @@ add_executable(knx-linux | ||||
| 	../../src/knx/ip_parameter_object.cpp  | ||||
| 	../../src/knx/ip_parameter_object.h | ||||
| 	../../src/knx/knx_ip_device_information_dib.cpp | ||||
| 	../../src/knx/knx_ip_dib.cpp | ||||
| 	../../src/knx/knx_ip_frame.cpp | ||||
| 	../../src/knx/knx_ip_routing_indication.cpp | ||||
| 	../../src/knx/knx_ip_search_request.cpp | ||||
| 	../../src/knx/knx_ip_search_response.cpp | ||||
| 	../../src/knx/knx_ip_supported_service_dib.cpp | ||||
| 	../../src/knx/ip_host_protocol_address_information.cpp | ||||
| 	../../src/knx/knx_value.cpp | ||||
|         ../../src/knx/knx_ip_device_information_dib.h | ||||
|         ../../src/knx/knx_ip_dib.cpp | ||||
|         ../../src/knx/knx_ip_dib.h | ||||
|         ../../src/knx/knx_ip_frame.cpp | ||||
|         ../../src/knx/knx_ip_frame.h | ||||
|         ../../src/knx/knx_ip_routing_indication.cpp | ||||
|         ../../src/knx/knx_ip_routing_indication.h | ||||
|         ../../src/knx/knx_ip_search_request.cpp | ||||
|         ../../src/knx/knx_ip_search_request.h | ||||
|         ../../src/knx/knx_ip_search_response.cpp | ||||
|         ../../src/knx/knx_ip_search_response.h | ||||
|         ../../src/knx/knx_ip_supported_service_dib.cpp | ||||
|         ../../src/knx/knx_ip_supported_service_dib.h | ||||
|         ../../src/knx/ip_host_protocol_address_information.cpp | ||||
|         ../../src/knx/ip_host_protocol_address_information.h | ||||
|         ../../src/knx/knx_types.h | ||||
|         ../../src/knx/knx_value.cpp | ||||
| 	../../src/knx/knx_value.h | ||||
| 	../../src/knx/memory.cpp  | ||||
| 	../../src/knx/memory.h | ||||
| @ -65,7 +77,7 @@ add_executable(knx-linux | ||||
| 	../../src/knx/network_layer.h | ||||
| 	../../src/knx/npdu.cpp  | ||||
| 	../../src/knx/npdu.h | ||||
|     ../../src/knx/platform.cpp | ||||
|         ../../src/knx/platform.cpp | ||||
| 	../../src/knx/platform.h | ||||
| 	../../src/knx/property.cpp | ||||
| 	../../src/knx/property.h  | ||||
| @ -75,6 +87,7 @@ add_executable(knx-linux | ||||
| 	../../src/knx/rf_medium_object.h | ||||
| 	../../src/knx/rf_physical_layer.cpp | ||||
| 	../../src/knx/rf_physical_layer.h | ||||
|         ../../src/knx/save_restore.h | ||||
| 	../../src/knx/table_object.cpp | ||||
| 	../../src/knx/table_object.h | ||||
| 	../../src/knx/tpdu.cpp  | ||||
| @ -84,7 +97,8 @@ add_executable(knx-linux | ||||
| 	../../src/knx/transport_layer.cpp  | ||||
| 	../../src/knx/transport_layer.h | ||||
| 	../../src/knx/usb_tunnel_interface.cpp | ||||
| 	../../src/knx_facade.cpp  | ||||
|         ../../src/knx/usb_tunnel_interface.h | ||||
|         ../../src/knx_facade.cpp | ||||
| 	../../src/knx_facade.h | ||||
| 	../../src/linux_platform.cpp  | ||||
| 	../../src/linux_platform.h | ||||
|  | ||||
| @ -118,8 +118,15 @@ void ApplicationLayer::dataBroadcastIndication(HopCountType hopType, Priority pr | ||||
|             break; | ||||
|         } | ||||
|         default: | ||||
| #if (MEDIUM_TYPE == 5)||(MEDIUM_TYPE == 0) | ||||
|             // Make sure we also check if it is a service normally available only on SystemBroadcast on open media
 | ||||
|             dataSystemBroadcastIndication(hopType, priority, source, apdu); | ||||
| #else | ||||
|             print("Broadcast-indication: unhandled APDU-Type: "); | ||||
|             println(apdu.type()); | ||||
| 
 | ||||
| #endif | ||||
|             break; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| @ -159,8 +166,15 @@ void ApplicationLayer::dataBroadcastConfirm(AckType ack, HopCountType hopType, P | ||||
|             break; | ||||
|         } | ||||
|         default: | ||||
| #if (MEDIUM_TYPE == 5)||(MEDIUM_TYPE == 0) | ||||
|             // Make sure we also check if it is a service normally available only on SystemBroadcast on open media
 | ||||
|             dataSystemBroadcastConfirm(hopType, priority, apdu, status); | ||||
| #else | ||||
|             print("Broadcast-confirm: unhandled APDU-Type: "); | ||||
|             println(apdu.type()); | ||||
| 
 | ||||
| #endif | ||||
|             break; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| @ -198,13 +212,58 @@ void ApplicationLayer::dataSystemBroadcastIndication(HopCountType hopType, Prior | ||||
|             break; | ||||
|         } | ||||
|         default: | ||||
| #if (MEDIUM_TYPE == 5)||(MEDIUM_TYPE == 0) | ||||
|             print("Broadcast-indication: unhandled APDU-Type: "); | ||||
| #else | ||||
|             print("SystemBroadcast-indication: unhandled APDU-Type: "); | ||||
| #endif | ||||
|             println(apdu.type()); | ||||
|             break; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void ApplicationLayer::dataSystemBroadcastConfirm(HopCountType hopType, Priority priority, APDU& apdu, bool status) | ||||
| { | ||||
| 
 | ||||
|     const uint8_t* data = apdu.data(); | ||||
|     switch (apdu.type()) | ||||
|     { | ||||
|         // TODO: testInfo could be of any length
 | ||||
|         case SystemNetworkParameterRead: | ||||
|         { | ||||
|             uint16_t objectType; | ||||
|             uint16_t propertyId; | ||||
|             uint8_t testInfo[2]; | ||||
|             popWord(objectType, data + 1); | ||||
|             popWord(propertyId, data + 3); | ||||
|             popByte(testInfo[0], data + 4); | ||||
|             popByte(testInfo[1], data + 5); | ||||
|             propertyId = (propertyId >> 4) & 0x0FFF;; | ||||
|             testInfo[0] &= 0x0F; | ||||
|             _bau.systemNetworkParameterReadLocalConfirm(priority, hopType, objectType, propertyId, testInfo, sizeof(testInfo), status); | ||||
|             break; | ||||
|         } | ||||
|         case DomainAddressSerialNumberWrite: | ||||
|         { | ||||
|             const uint8_t* knxSerialNumber = &data[1]; | ||||
|             const uint8_t* domainAddress = &data[7]; | ||||
|             _bau.domainAddressSerialNumberWriteLocalConfirm(priority, hopType, domainAddress, knxSerialNumber, status); | ||||
|             break; | ||||
|         } | ||||
|         case DomainAddressSerialNumberRead: | ||||
|         { | ||||
|             const uint8_t* knxSerialNumber = &data[1]; | ||||
|             _bau.domainAddressSerialNumberReadLocalConfirm(priority, hopType, knxSerialNumber, status); | ||||
|             break; | ||||
|         } | ||||
|         default: | ||||
| #if (MEDIUM_TYPE == 5)||(MEDIUM_TYPE == 0) | ||||
|             print("Broadcast-confirm: unhandled APDU-Type: "); | ||||
| #else | ||||
|             print("SystemBroadcast-confirm: unhandled APDU-Type: "); | ||||
| #endif | ||||
|             println(apdu.type()); | ||||
|             break; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void ApplicationLayer::dataIndividualIndication(HopCountType hopType, Priority priority, uint16_t tsap, APDU& apdu) | ||||
|  | ||||
| @ -264,6 +264,20 @@ void BusAccessUnit::domainAddressSerialNumberReadIndication(Priority priority, H | ||||
| { | ||||
| } | ||||
| 
 | ||||
| void BusAccessUnit::systemNetworkParameterReadLocalConfirm(Priority priority, HopCountType hopType, uint16_t objectType, | ||||
|                                                          uint16_t propertyId, uint8_t* testInfo, uint16_t testInfoLength, bool status) | ||||
| { | ||||
| } | ||||
| 
 | ||||
| void BusAccessUnit::domainAddressSerialNumberWriteLocalConfirm(Priority priority, HopCountType hopType, const uint8_t* rfDoA, | ||||
|                                                              const uint8_t* knxSerialNumber, bool status) | ||||
| { | ||||
| } | ||||
| 
 | ||||
| void BusAccessUnit::domainAddressSerialNumberReadLocalConfirm(Priority priority, HopCountType hopType, const uint8_t* knxSerialNumber, bool status) | ||||
| { | ||||
| } | ||||
| 
 | ||||
| void BusAccessUnit::propertyValueRead(ObjectType objectType, uint8_t objectInstance, uint8_t propertyId, | ||||
|                                       uint8_t& numberOfElements, uint16_t startIndex, | ||||
|                                       uint8_t** data, uint32_t& length) | ||||
|  | ||||
| @ -123,6 +123,14 @@ class BusAccessUnit | ||||
| 
 | ||||
|     virtual void domainAddressSerialNumberReadIndication(Priority priority, HopCountType hopType, const uint8_t* knxSerialNumber); | ||||
| 
 | ||||
|     virtual void systemNetworkParameterReadLocalConfirm(Priority priority, HopCountType hopType, uint16_t objectType, | ||||
|                                                         uint16_t propertyId, uint8_t* testInfo, uint16_t testInfoLength, bool status); | ||||
| 
 | ||||
|     virtual void domainAddressSerialNumberWriteLocalConfirm(Priority priority, HopCountType hopType, const uint8_t* rfDoA, | ||||
|                                                             const uint8_t* knxSerialNumber, bool status); | ||||
| 
 | ||||
|     virtual void domainAddressSerialNumberReadLocalConfirm(Priority priority, HopCountType hopType, const uint8_t* knxSerialNumber, bool status); | ||||
| 
 | ||||
|     virtual void propertyValueRead(ObjectType objectType, uint8_t objectInstance, uint8_t propertyId, | ||||
|                                    uint8_t& numberOfElements, uint16_t startIndex, | ||||
|                                    uint8_t** data, uint32_t& length); | ||||
|  | ||||
| @ -150,4 +150,14 @@ void Bau27B0::individualAddressSerialNumberReadIndication(Priority priority, Hop | ||||
|         _appLayer.IndividualAddressSerialNumberReadResponse(priority, hopType, _rfMediumObj.rfDomainAddress(), knxSerialNumber); | ||||
| } | ||||
| 
 | ||||
| #endif // #if MEDIUM_TYPE == 2
 | ||||
| void Bau27B0::domainAddressSerialNumberWriteLocalConfirm(Priority priority, HopCountType hopType, const uint8_t* rfDoA, | ||||
|                                                          const uint8_t* knxSerialNumber, bool status) | ||||
| { | ||||
| } | ||||
| 
 | ||||
| void Bau27B0::domainAddressSerialNumberReadLocalConfirm(Priority priority, HopCountType hopType, const uint8_t* knxSerialNumber, bool status) | ||||
| { | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| #endif // #ifdef USE_RF
 | ||||
|  | ||||
| @ -34,5 +34,8 @@ class Bau27B0 : public BauSystemB | ||||
|     void individualAddressSerialNumberWriteIndication(Priority priority, HopCountType hopType, uint16_t newIndividualAddress, | ||||
|                                                       uint8_t* knxSerialNumber) override; | ||||
|     void individualAddressSerialNumberReadIndication(Priority priority, HopCountType hopType, uint8_t* knxSerialNumber) override; | ||||
|     void domainAddressSerialNumberWriteLocalConfirm(Priority priority, HopCountType hopType, const uint8_t* rfDoA, | ||||
|                                                     const uint8_t* knxSerialNumber, bool status) override; | ||||
|     void domainAddressSerialNumberReadLocalConfirm(Priority priority, HopCountType hopType, const uint8_t* knxSerialNumber, bool status) override; | ||||
| }; | ||||
| #endif | ||||
| #endif | ||||
|  | ||||
| @ -419,6 +419,11 @@ void BauSystemB::systemNetworkParameterReadIndication(Priority priority, HopCoun | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void BauSystemB::systemNetworkParameterReadLocalConfirm(Priority priority, HopCountType hopType, uint16_t objectType, | ||||
|                                                          uint16_t propertyId, uint8_t* testInfo, uint16_t testInfoLength, bool status) | ||||
| { | ||||
| } | ||||
| 
 | ||||
| void BauSystemB::propertyValueRead(ObjectType objectType, uint8_t objectInstance, uint8_t propertyId, | ||||
|                                    uint8_t &numberOfElements, uint16_t startIndex, | ||||
|                                    uint8_t **data, uint32_t &length) | ||||
|  | ||||
| @ -72,6 +72,8 @@ class BauSystemB : protected BusAccessUnit | ||||
|                                    uint8_t* data, uint8_t dataLength) override; | ||||
|     void systemNetworkParameterReadIndication(Priority priority, HopCountType hopType, uint16_t objectType, | ||||
|                                               uint16_t propertyId, uint8_t* testInfo, uint16_t testinfoLength) override; | ||||
|     void systemNetworkParameterReadLocalConfirm(Priority priority, HopCountType hopType, uint16_t objectType, | ||||
|                                                 uint16_t propertyId, uint8_t* testInfo, uint16_t testInfoLength, bool status) override; | ||||
|     void connectConfirm(uint16_t tsap) override; | ||||
| 
 | ||||
|     virtual InterfaceObject* getInterfaceObject(uint8_t idx) = 0; | ||||
|  | ||||
| @ -140,7 +140,12 @@ bool DataLinkLayer::sendTelegram(NPDU & npdu, AckType ack, uint16_t destinationA | ||||
|     frame.addressType(addrType); | ||||
|     frame.priority(priority); | ||||
|     frame.repetition(RepititionAllowed); | ||||
| #if (MEDIUM_TYPE == 5)||(MEDIUM_TYPE == 0) | ||||
|     // Make sure to always send as normal Broadcast on closed media (TP and IP)
 | ||||
|     frame.systemBroadcast(Broadcast); | ||||
| #else | ||||
|     frame.systemBroadcast(systemBroadcast); | ||||
| #endif | ||||
| 
 | ||||
|     if (npdu.octetCount() <= 15) | ||||
|         frame.frameType(StandardFrame); | ||||
|  | ||||
| @ -45,7 +45,6 @@ void NetworkLayer::dataIndication(AckType ack, AddressType addrType, uint16_t de | ||||
|     } | ||||
|     // destination == 0
 | ||||
|     _transportLayer.dataBroadcastIndication(hopType, priority, source, npdu.tpdu()); | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| void NetworkLayer::dataConfirm(AckType ack, AddressType addressType, uint16_t destination, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status) | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user