knx
ETS configurable knx-stack
rf_data_link_layer.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "config.h"
4 #ifdef USE_RF
5 
6 #include <stdint.h>
7 #include "data_link_layer.h"
8 
9 #define MAX_KNX_TELEGRAM_SIZE 263
10 
11 class RfMediumObject;
12 
14 {
15 #if defined(DeviceFamily_CC13X0)
16  friend class RfPhysicalLayerCC1310;
17 #else
18  friend class RfPhysicalLayerCC1101;
19 #endif
22 
23  public:
24  RfDataLinkLayer(DeviceObject& devObj, RfMediumObject& rfMediumObj, NetworkLayerEntity& netLayerEntity,
25  Platform& platform);
26 
27  void loop();
28  void enabled(bool value);
29  bool enabled() const;
30  DptMedium mediumType() const override;
31 
32  private:
33  bool _enabled = false;
34  uint8_t _loopState = 0;
35 
36  uint8_t _buffer[512];
37 
38  uint8_t _frameNumber = 0;
39 
40  struct _tx_queue_frame_t
41  {
42  uint8_t* data;
43  uint16_t length;
44  _tx_queue_frame_t* next;
45  };
46 
47  struct _tx_queue_t
48  {
49  _tx_queue_frame_t* front = NULL;
50  _tx_queue_frame_t* back = NULL;
51  } _tx_queue;
52 
53  RfMediumObject& _rfMediumObj;
54 #if defined(DeviceFamily_CC13X0)
55  RfPhysicalLayerCC1310 _rfPhy;
56 #else
57  RfPhysicalLayerCC1101 _rfPhy;
58 #endif
59  void fillRfFrame(CemiFrame& frame, uint8_t* data);
60  void addFrameTxQueue(CemiFrame& frame);
61  bool isTxQueueEmpty();
62  void loadNextTxFrame(uint8_t** sendBuffer, uint16_t* sendBufferLength);
63  bool sendFrame(CemiFrame& frame);
64  void frameBytesReceived(uint8_t* buffer, uint16_t length);
65 };
66 
67 #endif
DptMedium
Definition: knx_types.h:254