hyperion.ng
LedDeviceUdpE131.h
1 #pragma once
2 
3 // hyperion includes
4 #include "ProviderUdp.h"
5 
6 #include <QUuid>
7 
21 #define E131_DEFAULT_PORT 5568
22 
23 /* E1.31 Packet Offsets */
24 #define E131_ROOT_PREAMBLE_SIZE 0
25 #define E131_ROOT_POSTAMBLE_SIZE 2
26 #define E131_ROOT_ID 4
27 #define E131_ROOT_FLENGTH 16
28 #define E131_ROOT_VECTOR 18
29 #define E131_ROOT_CID 22
30 
31 #define E131_FRAME_FLENGTH 38
32 #define E131_FRAME_VECTOR 40
33 #define E131_FRAME_SOURCE 44
34 #define E131_FRAME_PRIORITY 108
35 #define E131_FRAME_RESERVED 109
36 #define E131_FRAME_SEQ 111
37 #define E131_FRAME_OPT 112
38 #define E131_FRAME_UNIVERSE 113
39 
40 #define E131_DMP_FLENGTH 115
41 #define E131_DMP_VECTOR 117
42 #define E131_DMP_TYPE 118
43 #define E131_DMP_ADDR_FIRST 119
44 #define E131_DMP_ADDR_INC 121
45 #define E131_DMP_COUNT 123
46 #define E131_DMP_DATA 125
47 
48 /* E1.31 Packet Structure */
49 typedef union
50 {
51  struct
52  {
53  /* Root Layer */
54  uint16_t preamble_size;
55  uint16_t postamble_size;
56  uint8_t acn_id[12];
57  uint16_t root_flength;
58  uint32_t root_vector;
59  char cid[16];
60 
61  /* Frame Layer */
62  uint16_t frame_flength;
63  uint32_t frame_vector;
64  char source_name[64];
65  uint8_t priority;
66  uint16_t reserved;
67  uint8_t sequence_number;
68  uint8_t options;
69  uint16_t universe;
70 
71  /* DMP Layer */
72  uint16_t dmp_flength;
73  uint8_t dmp_vector;
74  uint8_t type;
75  uint16_t first_address;
76  uint16_t address_increment;
77  uint16_t property_value_count;
78  uint8_t property_values[513];
79  } __attribute__((packed));
80 
81  uint8_t raw[638];
83 
84 /* defined parameters from http://tsp.esta.org/tsp/documents/docs/BSR_E1-31-20xx_CP-2014-1009r2.pdf */
85 #define VECTOR_ROOT_E131_DATA 0x00000004
86 #define VECTOR_ROOT_E131_EXTENDED 0x00000008
87 #define VECTOR_DMP_SET_PROPERTY 0x02
88 #define VECTOR_E131_DATA_PACKET 0x00000002
89 #define VECTOR_E131_EXTENDED_SYNCHRONIZATION 0x00000001
90 #define VECTOR_E131_EXTENDED_DISCOVERY 0x00000002
91 #define VECTOR_UNIVERSE_DISCOVERY_UNIVERSE_LIST 0x00000001
92 #define E131_E131_UNIVERSE_DISCOVERY_INTERVAL 10 // seconds
93 #define E131_NETWORK_DATA_LOSS_TIMEOUT 2500 // milli econds
94 #define E131_DISCOVERY_UNIVERSE 64214
95 #define DMX_MAX 512 // 512 usable slots
96 
101 {
102 public:
108  LedDeviceUdpE131(const QJsonObject &deviceConfig);
109 
115  bool init(const QJsonObject &deviceConfig);
116 
118  static LedDevice* construct(const QJsonObject &deviceConfig);
119 
120 
121 private:
128  virtual int write(const std::vector<ColorRgb> &ledValues);
129 
130  void prepare(const unsigned this_universe, const unsigned this_dmxChannelCount);
131 
132  e131_packet_t e131_packet;
133  uint8_t _e131_seq = 0;
134  uint8_t _e131_universe = 1;
135  uint8_t _acn_id[12] = {0x41, 0x53, 0x43, 0x2d, 0x45, 0x31, 0x2e, 0x31, 0x37, 0x00, 0x00, 0x00 };
136  QString _e131_source_name;
137  QUuid _e131_cid;
138 };
The ProviderUdp implements an abstract base-class for LedDevices using UDP packets.
Definition: ProviderUdp.h:15
Interface (pure virtual base class) for LedDevices.
Definition: LedDevice.h:32
Definition: LedDeviceUdpE131.h:49
static LedDevice * construct(const QJsonObject &deviceConfig)
constructs leddevice
Definition: LedDeviceUdpE131.cpp:33
LedDeviceUdpE131(const QJsonObject &deviceConfig)
Constructs specific LedDevice.
Definition: LedDeviceUdpE131.cpp:7
Implementation of the LedDevice interface for sending led colors via udp/E1.31 packets.
Definition: LedDeviceUdpE131.h:100
bool init(const QJsonObject &deviceConfig)
Sets configuration.
Definition: LedDeviceUdpE131.cpp:13