• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

OpenLightingProject / ola / 8768757758

21 Apr 2024 12:25AM UTC coverage: 45.687% (+0.02%) from 45.668%
8768757758

push

github

web-flow
Merge pull request #1959 from peternewman/e1.33-cherry-pick

E1.33 cherry pick number 6

7783 of 17912 branches covered (43.45%)

27 of 35 new or added lines in 3 files covered. (77.14%)

4 existing lines in 1 file now uncovered.

22238 of 48675 relevant lines covered (45.69%)

59.98 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/libs/acn/MessageBuilder.cpp
1
/*
2
 * This program is free software; you can redistribute it and/or modify
3
 * it under the terms of the GNU General Public License as published by
4
 * the Free Software Foundation; either version 2 of the License, or
5
 * (at your option) any later version.
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 * GNU Library General Public License for more details.
11
 *
12
 * You should have received a copy of the GNU General Public License
13
 * along with this program; if not, write to the Free Software
14
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15
 *
16
 * MessageBuilder.cpp
17
 * Copyright (C) 2013 Simon Newton
18
 *
19
 * A class to simplify some of the E1.33 packet building operations.
20
 */
21

22
#include <string>
23
#include "ola/acn/ACNVectors.h"
24
#include "ola/acn/CID.h"
25
#include "ola/e133/MessageBuilder.h"
26
#include "ola/io/IOStack.h"
27
#include "ola/rdm/RDMCommandSerializer.h"
28
#include "ola/rdm/UID.h"
29

30
#include "libs/acn/BrokerPDU.h"
31
#include "libs/acn/E133PDU.h"
32
#include "libs/acn/RDMPDU.h"
33
#include "libs/acn/RootPDU.h"
34
#include "libs/acn/RPTPDU.h"
35
#include "libs/acn/RPTRequestPDU.h"
36
#include "libs/acn/E133StatusPDU.h"
37
#include "libs/acn/PreamblePacker.h"
38

39
namespace ola {
40
namespace e133 {
41

42
using ola::acn::CID;
43
using ola::io::IOStack;
44
using ola::acn::BrokerPDU;
45
using ola::acn::E133PDU;
46
using ola::acn::PreamblePacker;
47
using ola::acn::RootPDU;
48
using ola::acn::RPTPDU;
49

50

51
MessageBuilder::MessageBuilder(const CID &cid, const string &source_name)
×
52
    : m_cid(cid),
×
53
      m_source_name(source_name),
×
54
      // The Max sized RDM packet is 256 bytes, E1.33 adds 118 bytes of
55
      // headers.
56
      m_memory_pool(400) {
×
57
}
×
58

59

60
/**
61
 * Append a RDM PDU Header onto this packet
62
 */
63
void MessageBuilder::PrependRDMHeader(IOStack *packet) {
×
64
  ola::acn::RDMPDU::PrependPDU(packet);
×
65
}
×
66

67

68
/**
69
 * Build a TCP E1.33 RDM Command PDU response.
70
 */
71
void MessageBuilder::BuildTCPRDMCommandPDU(IOStack *packet,
×
72
                                           ola::rdm::RDMRequest *request,
73
                                           uint16_t source_endpoint_id,
74
                                           uint16_t destination_endpoint_id,
75
                                           uint32_t sequence_number) {
76
  // TODO(Peter): Potentially need some future way to handle controller
77
  // messages here
NEW
78
  ola::rdm::UID rpt_destination_uid = request->DestinationUID();
×
NEW
79
  if (rpt_destination_uid.IsBroadcast()) {
×
NEW
80
    if (rpt_destination_uid.IsVendorcast()) {
×
NEW
81
      rpt_destination_uid = ola::rdm::UID::RPTVendorcastAddressDevices(
×
NEW
82
          rpt_destination_uid);
×
83
    } else {
NEW
84
      rpt_destination_uid = ola::rdm::UID::RPTAllDevices();
×
85
    }
NEW
86
    if (destination_endpoint_id != NULL_ENDPOINT) {
×
87
      // TODO(Peter): Should we handle the reserved endpoints now?
NEW
88
      destination_endpoint_id = BROADCAST_ENDPOINT;
×
89
    }
90
  }
91
  ola::rdm::RDMCommandSerializer::Write(*request, packet);
×
92
  ola::acn::RDMPDU::PrependPDU(packet);
×
93
  ola::acn::RPTRequestPDU::PrependPDU(packet);
×
94
  RPTPDU::PrependPDU(packet, ola::acn::VECTOR_RPT_REQUEST,
×
95
                     request->SourceUID(), source_endpoint_id,
96
                     rpt_destination_uid, destination_endpoint_id,
97
                     sequence_number);
98
  RootPDU::PrependPDU(packet, ola::acn::VECTOR_ROOT_RPT, m_cid, true);
×
99
  PreamblePacker::AddTCPPreamble(packet);
×
100
}
×
101

102

103
/**
104
 * Build a NULL TCP packet. These packets can be used for heartbeats.
105
 */
106
void MessageBuilder::BuildNullTCPPacket(IOStack *packet) {
×
107
  RootPDU::PrependPDU(packet, ola::acn::VECTOR_ROOT_NULL, m_cid);
×
108
  PreamblePacker::AddTCPPreamble(packet);
×
109
}
×
110

111

112
/**
113
 * Build a Broker Fetch Client List TCP packet.
114
 */
115
void MessageBuilder::BuildBrokerFetchClientListTCPPacket(IOStack *packet) {
×
116
  BrokerPDU::PrependPDU(packet, ola::acn::VECTOR_BROKER_FETCH_CLIENT_LIST);
×
117
  RootPDU::PrependPDU(packet, ola::acn::VECTOR_ROOT_BROKER, m_cid, true);
×
118
  PreamblePacker::AddTCPPreamble(packet);
×
119
}
×
120

121

122
/**
123
 * Build a Broker NULL TCP packet. These packets can be used for broker heartbeats.
124
 */
125
void MessageBuilder::BuildBrokerNullTCPPacket(IOStack *packet) {
×
126
  BrokerPDU::PrependPDU(packet, ola::acn::VECTOR_BROKER_NULL);
×
127
  RootPDU::PrependPDU(packet, ola::acn::VECTOR_ROOT_BROKER, m_cid, true);
×
128
  PreamblePacker::AddTCPPreamble(packet);
×
129
}
×
130

131

132
/**
133
 * Build a TCP E1.33 Status PDU response. This should really only be used with
134
 * SC_E133_ACK.
135
 */
136
void MessageBuilder::BuildTCPE133StatusPDU(ola::io::IOStack *packet,
×
137
                                           uint32_t sequence_number,
138
                                           uint16_t endpoint_id,
139
                                           E133StatusCode status_code,
140
                                           const string &description) {
141
  ola::acn::E133StatusPDU::PrependPDU(
×
142
      packet, status_code, description);
143
  BuildTCPRootE133(
×
144
      packet, ola::acn::VECTOR_FRAMING_STATUS,
145
      sequence_number, endpoint_id);
146
}
×
147

148

149
/**
150
 * Build an E1.33 Status PDU response
151
 */
152
void MessageBuilder::BuildUDPE133StatusPDU(ola::io::IOStack *packet,
×
153
                                           uint32_t sequence_number,
154
                                           uint16_t endpoint_id,
155
                                           E133StatusCode status_code,
156
                                           const string &description) {
157
  ola::acn::E133StatusPDU::PrependPDU(
×
158
      packet, status_code, description);
159
  BuildUDPRootE133(
×
160
      packet, ola::acn::VECTOR_FRAMING_STATUS,
161
      sequence_number, endpoint_id);
162
}
×
163

164

165
/**
166
 * Append an E133PDU, a RootPDU and the TCP preamble to a packet.
167
 */
168
void MessageBuilder::BuildTCPRootE133(IOStack *packet,
×
169
                                      uint32_t vector,
170
                                      uint32_t sequence_number,
171
                                      uint16_t endpoint_id) {
172
  E133PDU::PrependPDU(packet, vector, m_source_name, sequence_number,
×
173
                      endpoint_id);
174
  RootPDU::PrependPDU(packet, ola::acn::VECTOR_ROOT_RPT, m_cid);
×
175
  PreamblePacker::AddTCPPreamble(packet);
×
176
}
×
177

178

179
/**
180
 * Append an E133PDU, a RootPDU and the UDP preamble to a packet.
181
 */
182
void MessageBuilder::BuildUDPRootE133(IOStack *packet,
×
183
                                      uint32_t vector,
184
                                      uint32_t sequence_number,
185
                                      uint16_t endpoint_id) {
186
  E133PDU::PrependPDU(packet, vector, m_source_name, sequence_number,
×
187
                      endpoint_id);
188
  RootPDU::PrependPDU(packet, ola::acn::VECTOR_ROOT_RPT, m_cid);
×
189
  PreamblePacker::AddUDPPreamble(packet);
×
190
}
×
191
}  // namespace e133
192
}  // namespace ola
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc