knx
ETS configurable knx-stack
knx_ip_search_response.cpp
Go to the documentation of this file.
2 #ifdef USE_IP
3 
4 #define LEN_SERVICE_FAMILIES 2
5 #if MASK_VERSION == 0x091A
6  #ifdef KNX_TUNNELING
7  #define LEN_SERVICE_DIB (2 + 4 * LEN_SERVICE_FAMILIES)
8  #else
9  #define LEN_SERVICE_DIB (2 + 3 * LEN_SERVICE_FAMILIES)
10  #endif
11 #else
12  #ifdef KNX_TUNNELING
13  #define LEN_SERVICE_DIB (2 + 3 * LEN_SERVICE_FAMILIES)
14  #else
15  #define LEN_SERVICE_DIB (2 + 2 * LEN_SERVICE_FAMILIES)
16  #endif
17 #endif
18 
20  : KnxIpFrame(LEN_KNXIP_HEADER + LEN_IPHPAI + LEN_DEVICE_INFORMATION_DIB + LEN_SERVICE_DIB),
21  _controlEndpoint(_data + LEN_KNXIP_HEADER), _deviceInfo(_data + LEN_KNXIP_HEADER + LEN_IPHPAI),
22  _supportedServices(_data + LEN_KNXIP_HEADER + LEN_IPHPAI + LEN_DEVICE_INFORMATION_DIB)
23 {
25 
26  _controlEndpoint.length(LEN_IPHPAI);
27  _controlEndpoint.code(IPV4_UDP);
28  _controlEndpoint.ipAddress(parameters.propertyValue<uint32_t>(PID_CURRENT_IP_ADDRESS));
29  _controlEndpoint.ipPortNumber(KNXIP_MULTICAST_PORT);
30 
31  _deviceInfo.length(LEN_DEVICE_INFORMATION_DIB);
32  _deviceInfo.code(DEVICE_INFO);
33 #if MASK_VERSION == 0x57B0
34  _deviceInfo.medium(0x20); //MediumType is IP (for IP-Only Devices)
35 #else
36  _deviceInfo.medium(0x02); //MediumType is TP
37 #endif
38  _deviceInfo.status(deviceObject.progMode());
39  _deviceInfo.individualAddress(parameters.propertyValue<uint16_t>(PID_KNX_INDIVIDUAL_ADDRESS));
41  _deviceInfo.serialNumber(deviceObject.propertyData(PID_SERIAL_NUMBER));
42  _deviceInfo.routingMulticastAddress(parameters.propertyValue<uint32_t>(PID_ROUTING_MULTICAST_ADDRESS));
43  //_deviceInfo.routingMulticastAddress(0);
44 
45  uint8_t mac_address[LEN_MAC_ADDRESS] = {0};
46  Property* prop = parameters.property(PID_MAC_ADDRESS);
47  prop->read(mac_address);
48  _deviceInfo.macAddress(mac_address);
49 
50  uint8_t friendlyName[LEN_FRIENDLY_NAME] = {0};
51  prop = parameters.property(PID_FRIENDLY_NAME);
52  prop->read(1, LEN_FRIENDLY_NAME, friendlyName);
53  _deviceInfo.friendlyName(friendlyName);
54 
55  _supportedServices.length(LEN_SERVICE_DIB);
56  _supportedServices.code(SUPP_SVC_FAMILIES);
57  _supportedServices.serviceVersion(Core, KNX_SERVICE_FAMILY_CORE);
58  _supportedServices.serviceVersion(DeviceManagement, KNX_SERVICE_FAMILY_DEVICE_MANAGEMENT);
59 #ifdef KNX_TUNNELING
60  _supportedServices.serviceVersion(Tunnelling, KNX_SERVICE_FAMILY_TUNNELING);
61 #endif
62 #if MASK_VERSION == 0x091A
63  _supportedServices.serviceVersion(Routing, KNX_SERVICE_FAMILY_ROUTING);
64 #endif
65 }
66 
67 
69 {
70  return _controlEndpoint;
71 }
72 
73 
75 {
76  return _deviceInfo;
77 }
78 
79 
81 {
82  return _supportedServices;
83 }
84 #endif
const uint8_t * propertyData(PropertyID id)
T propertyValue(PropertyID id)
Property * property(PropertyID id)
Gets property with PropertyID id if it exists and nullptr otherwise.
DescriptionTypeCode code() const
Definition: knx_ip_dib.cpp:19
uint8_t length() const
Definition: knx_ip_dib.cpp:9
uint16_t serviceTypeIdentifier() const
KnxIpSearchResponse(IpParameterObject &parameters, DeviceObject &deviceObj)
KnxIpSupportedServiceDIB & supportedServices()
KnxIpDeviceInformationDIB & deviceInfo()
IpHostProtocolAddressInformation & controlEndpoint()
uint8_t serviceVersion(ServiceFamily family)
virtual uint8_t read(uint16_t start, uint8_t count, uint8_t *data) const =0
@ SUPP_SVC_FAMILIES
Definition: knx_ip_dib.h:11
@ DEVICE_INFO
Definition: knx_ip_dib.h:10
@ SearchResponse
Definition: knx_ip_frame.h:17
@ PID_MAC_ADDRESS
Definition: property.h:128
@ PID_FRIENDLY_NAME
Definition: property.h:140
@ PID_PROJECT_INSTALLATION_ID
KNXnet/IP Parameter Object.
Definition: property.h:115
@ PID_SERIAL_NUMBER
Definition: property.h:78
@ PID_CURRENT_IP_ADDRESS
Definition: property.h:121
@ PID_KNX_INDIVIDUAL_ADDRESS
Definition: property.h:116
@ PID_ROUTING_MULTICAST_ADDRESS
Definition: property.h:130