knx
ETS configurable knx-stack
knx_ip_description_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_DEVICE_INFORMATION_DIB + LEN_SERVICE_DIB),
21  _deviceInfo(_data + LEN_KNXIP_HEADER),
22  _supportedServices(_data + LEN_KNXIP_HEADER + LEN_DEVICE_INFORMATION_DIB)
23 {
25 
26  _deviceInfo.length(LEN_DEVICE_INFORMATION_DIB);
27  _deviceInfo.code(DEVICE_INFO);
28 #if MASK_VERSION == 0x57B0
29  _deviceInfo.medium(0x20); //MediumType is IP (for IP-Only Devices)
30 #else
31  _deviceInfo.medium(0x02); //MediumType is TP
32 #endif
33  _deviceInfo.status(deviceObject.progMode());
34  _deviceInfo.individualAddress(parameters.propertyValue<uint16_t>(PID_KNX_INDIVIDUAL_ADDRESS));
36  _deviceInfo.serialNumber(deviceObject.propertyData(PID_SERIAL_NUMBER));
37  _deviceInfo.routingMulticastAddress(parameters.propertyValue<uint32_t>(PID_ROUTING_MULTICAST_ADDRESS));
38  //_deviceInfo.routingMulticastAddress(0);
39 
40  uint8_t mac_address[LEN_MAC_ADDRESS] = {0};
41  Property* prop = parameters.property(PID_MAC_ADDRESS);
42  prop->read(mac_address);
43  _deviceInfo.macAddress(mac_address);
44 
45  uint8_t friendlyName[LEN_FRIENDLY_NAME] = {0};
46  prop = parameters.property(PID_FRIENDLY_NAME);
47  prop->read(1, LEN_FRIENDLY_NAME, friendlyName);
48  _deviceInfo.friendlyName(friendlyName);
49 
50  _supportedServices.length(LEN_SERVICE_DIB);
51  _supportedServices.code(SUPP_SVC_FAMILIES);
52  _supportedServices.serviceVersion(Core, 1);
53  _supportedServices.serviceVersion(DeviceManagement, 1);
54 #ifdef KNX_TUNNELING
55  _supportedServices.serviceVersion(Tunnelling, 1);
56 #endif
57 #if MASK_VERSION == 0x091A
58  _supportedServices.serviceVersion(Routing, 1);
59 #endif
60 }
61 
63 {
64  return _deviceInfo;
65 }
66 
67 
69 {
70  return _supportedServices;
71 }
72 #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
KnxIpDescriptionResponse(IpParameterObject &parameters, DeviceObject &deviceObj)
KnxIpDeviceInformationDIB & deviceInfo()
KnxIpSupportedServiceDIB & supportedServices()
uint16_t serviceTypeIdentifier() const
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
@ DescriptionResponse
Definition: knx_ip_frame.h:19
@ 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_KNX_INDIVIDUAL_ADDRESS
Definition: property.h:116
@ PID_ROUTING_MULTICAST_ADDRESS
Definition: property.h:130