knx
ETS configurable knx-stack
ip_data_link_layer.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "config.h"
4 #ifdef USE_IP
5 
6 #include <stdint.h>
7 #include "data_link_layer.h"
8 #include "ip_parameter_object.h"
10 #include "service_families.h"
11 
13 {
15 
16  public:
17  IpDataLinkLayer(DeviceObject& devObj, IpParameterObject& ipParam, NetworkLayerEntity& netLayerEntity,
18  Platform& platform, DataLinkLayerCallbacks* dllcb = nullptr);
19 
20  void loop();
21  void enabled(bool value);
22  bool enabled() const;
23  DptMedium mediumType() const override;
24 #ifdef KNX_TUNNELING
25  void dataRequestToTunnel(CemiFrame& frame) override;
26  void dataConfirmationToTunnel(CemiFrame& frame) override;
27  void dataIndicationToTunnel(CemiFrame& frame) override;
28  bool isTunnelAddress(uint16_t addr) override;
29  bool isSentToTunnel(uint16_t address, bool isGrpAddr);
30 #endif
31 
32  private:
33  bool _enabled = false;
34  uint8_t _frameCount[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
35  uint8_t _frameCountBase = 0;
36  uint32_t _frameCountTimeBase = 0;
37  bool sendFrame(CemiFrame& frame);
38 #ifdef KNX_TUNNELING
39  void sendFrameToTunnel(KnxIpTunnelConnection* tunnel, CemiFrame& frame);
40  void loopHandleConnectRequest(uint8_t* buffer, uint16_t length, uint32_t& src_addr, uint16_t& src_port);
41  void loopHandleConnectionStateRequest(uint8_t* buffer, uint16_t length);
42  void loopHandleDisconnectRequest(uint8_t* buffer, uint16_t length);
43  void loopHandleDescriptionRequest(uint8_t* buffer, uint16_t length);
44  void loopHandleDeviceConfigurationRequest(uint8_t* buffer, uint16_t length);
45  void loopHandleTunnelingRequest(uint8_t* buffer, uint16_t length);
46 #endif
47 #if KNX_SERVICE_FAMILY_CORE >= 2
48  void loopHandleSearchRequestExtended(uint8_t* buffer, uint16_t length);
49 #endif
50  bool sendBytes(uint8_t* buffer, uint16_t length);
51  bool isSendLimitReached();
52  IpParameterObject& _ipParameters;
53  DataLinkLayerCallbacks* _dllcb;
54 #ifdef KNX_TUNNELING
55  KnxIpTunnelConnection tunnels[KNX_TUNNELING];
56  uint8_t _lastChannelId = 0;
57 #endif
58 };
59 #endif
DptMedium
Definition: knx_types.h:254