RDMnet  0.3.0
Implementation of ANSI E1.33 (RDMnet)
View other versions:
llrp_rdm_command.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2020 ETC Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  ******************************************************************************
16  * This file is a part of RDMnet. For more information, go to:
17  * https://github.com/ETCLabs/RDMnet
18  *****************************************************************************/
19 
22 
23 #ifndef RDMNET_CPP_MESSAGE_TYPES_LLRP_RDM_COMMAND_H_
24 #define RDMNET_CPP_MESSAGE_TYPES_LLRP_RDM_COMMAND_H_
25 
26 #include <cstdint>
27 #include "etcpal/common.h"
28 #include "etcpal/inet.h"
29 #include "etcpal/cpp/uuid.h"
30 #include "rdm/cpp/message.h"
31 #include "rdm/cpp/uid.h"
32 #include "rdmnet/message.h"
33 
34 namespace rdmnet
35 {
36 namespace llrp
37 {
38 class SavedRdmCommand;
39 
46 {
47 public:
49  RdmCommand() = delete;
51  RdmCommand(const RdmCommand& other) = delete;
53  RdmCommand& operator=(const RdmCommand& other) = delete;
54 
55  constexpr RdmCommand(const LlrpRdmCommand& c_cmd) noexcept;
56 
57  constexpr etcpal::Uuid source_cid() const noexcept;
58  constexpr uint32_t seq_num() const noexcept;
59  constexpr RdmnetMcastNetintId netint_id() const noexcept;
60  constexpr etcpal_iptype_t netint_ip_type() const noexcept;
61  constexpr unsigned int netint_index() const noexcept;
62 
63  constexpr rdm::Uid source_uid() const noexcept;
64  constexpr rdm::Uid dest_uid() const noexcept;
65  constexpr uint16_t subdevice() const noexcept;
66  constexpr rdm_command_class_t command_class() const noexcept;
67  constexpr uint16_t param_id() const noexcept;
68 
69  constexpr rdm::CommandHeader rdm_header() const noexcept;
70 
71  constexpr const uint8_t* data() const noexcept;
72  constexpr uint8_t data_len() const noexcept;
73 
74  constexpr bool HasData() const noexcept;
75 
76  constexpr bool IsGet() const noexcept;
77  constexpr bool IsSet() const noexcept;
78 
79  constexpr const LlrpRdmCommand& get() const noexcept;
80 
81  rdm::Command ToRdm() const;
82  SavedRdmCommand Save() const;
83 
84 private:
85  const LlrpRdmCommand& cmd_;
86 };
87 
91 {
92 public:
94  SavedRdmCommand() = default;
95  constexpr SavedRdmCommand(const LlrpSavedRdmCommand& c_cmd) noexcept;
96  SavedRdmCommand& operator=(const LlrpSavedRdmCommand& c_cmd) noexcept;
97  SavedRdmCommand(const RdmCommand& command) noexcept;
98  SavedRdmCommand& operator=(const RdmCommand& command) noexcept;
99 
100  constexpr etcpal::Uuid source_cid() const noexcept;
101  constexpr uint32_t seq_num() const noexcept;
102  constexpr RdmnetMcastNetintId netint_id() const noexcept;
103  constexpr etcpal_iptype_t netint_ip_type() const noexcept;
104  constexpr unsigned int netint_index() const noexcept;
105 
106  constexpr rdm::Uid source_uid() const noexcept;
107  constexpr rdm::Uid dest_uid() const noexcept;
108  constexpr uint16_t subdevice() const noexcept;
109  constexpr rdm_command_class_t command_class() const noexcept;
110  constexpr uint16_t param_id() const noexcept;
111 
112  constexpr rdm::CommandHeader rdm_header() const noexcept;
113 
114  constexpr const uint8_t* data() const noexcept;
115  constexpr uint8_t data_len() const noexcept;
116 
117  bool IsValid() const noexcept;
118  constexpr bool HasData() const noexcept;
119 
120  constexpr bool IsGet() const noexcept;
121  constexpr bool IsSet() const noexcept;
122 
123  ETCPAL_CONSTEXPR_14 LlrpSavedRdmCommand& get() noexcept;
124  constexpr const LlrpSavedRdmCommand& get() const noexcept;
125 
126  rdm::Command ToRdm() const;
127 
128 private:
129  LlrpSavedRdmCommand cmd_{};
130 };
131 
133 // llrp::RdmCommand function definitions
135 
137 constexpr RdmCommand::RdmCommand(const LlrpRdmCommand& c_cmd) noexcept : cmd_(c_cmd)
138 {
139 }
140 
142 constexpr etcpal::Uuid RdmCommand::source_cid() const noexcept
143 {
144  return cmd_.source_cid;
145 }
146 
148 constexpr uint32_t RdmCommand::seq_num() const noexcept
149 {
150  return cmd_.seq_num;
151 }
152 
155 constexpr RdmnetMcastNetintId RdmCommand::netint_id() const noexcept
156 {
157  return cmd_.netint_id;
158 }
159 
161 constexpr etcpal_iptype_t RdmCommand::netint_ip_type() const noexcept
162 {
163  return cmd_.netint_id.ip_type;
164 }
165 
167 constexpr unsigned int RdmCommand::netint_index() const noexcept
168 {
169  return cmd_.netint_id.index;
170 }
171 
173 constexpr rdm::Uid RdmCommand::source_uid() const noexcept
174 {
175  return cmd_.rdm_header.source_uid;
176 }
177 
179 constexpr rdm::Uid RdmCommand::dest_uid() const noexcept
180 {
181  return cmd_.rdm_header.dest_uid;
182 }
183 
185 constexpr uint16_t RdmCommand::subdevice() const noexcept
186 {
187  return cmd_.rdm_header.subdevice;
188 }
189 
191 constexpr rdm_command_class_t RdmCommand::command_class() const noexcept
192 {
193  return cmd_.rdm_header.command_class;
194 }
195 
197 constexpr uint16_t RdmCommand::param_id() const noexcept
198 {
199  return cmd_.rdm_header.param_id;
200 }
201 
203 constexpr rdm::CommandHeader RdmCommand::rdm_header() const noexcept
204 {
205  return cmd_.rdm_header;
206 }
207 
209 constexpr const uint8_t* RdmCommand::data() const noexcept
210 {
211  return cmd_.data;
212 }
213 
215 constexpr uint8_t RdmCommand::data_len() const noexcept
216 {
217  return cmd_.data_len;
218 }
219 
221 constexpr bool RdmCommand::HasData() const noexcept
222 {
223  return (data_len() != 0);
224 }
225 
227 constexpr bool RdmCommand::IsGet() const noexcept
228 {
229  return (cmd_.rdm_header.command_class == kRdmCCGetCommand);
230 }
231 
233 constexpr bool RdmCommand::IsSet() const noexcept
234 {
235  return (cmd_.rdm_header.command_class == kRdmCCSetCommand);
236 }
237 
239 constexpr const LlrpRdmCommand& RdmCommand::get() const noexcept
240 {
241  return cmd_;
242 }
243 
245 inline rdm::Command RdmCommand::ToRdm() const
246 {
247  return rdm::Command(cmd_.rdm_header, cmd_.data, cmd_.data_len);
248 }
249 
253 {
254  return SavedRdmCommand(*this);
255 }
256 
258 // llrp::SavedRdmCommand function definitions
260 
262 constexpr SavedRdmCommand::SavedRdmCommand(const LlrpSavedRdmCommand& c_cmd) noexcept : cmd_(c_cmd)
263 {
264 }
265 
268 {
269  cmd_ = c_cmd;
270  return *this;
271 }
272 
274 inline SavedRdmCommand::SavedRdmCommand(const RdmCommand& command) noexcept
275 {
276  rdmnet_save_llrp_rdm_command(&command.get(), &cmd_);
277 }
278 
280 inline SavedRdmCommand& SavedRdmCommand::operator=(const RdmCommand& command) noexcept
281 {
282  rdmnet_save_llrp_rdm_command(&command.get(), &cmd_);
283  return *this;
284 }
285 
287 constexpr etcpal::Uuid SavedRdmCommand::source_cid() const noexcept
288 {
289  return cmd_.source_cid;
290 }
291 
293 constexpr uint32_t SavedRdmCommand::seq_num() const noexcept
294 {
295  return cmd_.seq_num;
296 }
297 
301 {
302  return cmd_.netint_id;
303 }
304 
307 {
308  return cmd_.netint_id.ip_type;
309 }
310 
312 constexpr unsigned int SavedRdmCommand::netint_index() const noexcept
313 {
314  return cmd_.netint_id.index;
315 }
316 
318 constexpr rdm::Uid SavedRdmCommand::source_uid() const noexcept
319 {
320  return cmd_.rdm_header.source_uid;
321 }
322 
324 constexpr rdm::Uid SavedRdmCommand::dest_uid() const noexcept
325 {
326  return cmd_.rdm_header.dest_uid;
327 }
328 
330 constexpr uint16_t SavedRdmCommand::subdevice() const noexcept
331 {
332  return cmd_.rdm_header.subdevice;
333 }
334 
336 constexpr rdm_command_class_t SavedRdmCommand::command_class() const noexcept
337 {
338  return cmd_.rdm_header.command_class;
339 }
340 
342 constexpr uint16_t SavedRdmCommand::param_id() const noexcept
343 {
344  return cmd_.rdm_header.param_id;
345 }
346 
348 constexpr rdm::CommandHeader SavedRdmCommand::rdm_header() const noexcept
349 {
350  return cmd_.rdm_header;
351 }
352 
354 constexpr const uint8_t* SavedRdmCommand::data() const noexcept
355 {
356  return cmd_.data;
357 }
358 
360 constexpr uint8_t SavedRdmCommand::data_len() const noexcept
361 {
362  return cmd_.data_len;
363 }
364 
367 inline bool SavedRdmCommand::IsValid() const noexcept
368 {
369  return rdm_command_header_is_valid(&cmd_.rdm_header);
370 }
371 
373 constexpr bool SavedRdmCommand::HasData() const noexcept
374 {
375  return (data_len() != 0);
376 }
377 
379 constexpr bool SavedRdmCommand::IsGet() const noexcept
380 {
381  return (cmd_.rdm_header.command_class == kRdmCCGetCommand);
382 }
383 
385 constexpr bool SavedRdmCommand::IsSet() const noexcept
386 {
387  return (cmd_.rdm_header.command_class == kRdmCCSetCommand);
388 }
389 
392 {
393  return cmd_;
394 }
395 
397 constexpr const LlrpSavedRdmCommand& SavedRdmCommand::get() const noexcept
398 {
399  return cmd_;
400 }
401 
403 inline rdm::Command SavedRdmCommand::ToRdm() const
404 {
405  return rdm::Command(cmd_.rdm_header, cmd_.data, cmd_.data_len);
406 }
407 
408 }; // namespace llrp
409 }; // namespace rdmnet
410 
411 #endif // RDMNET_CPP_MESSAGE_TYPES_LLRP_RDM_COMMAND_H_
An RDM command received over LLRP and delivered to an RDMnet callback function.
Definition: llrp_rdm_command.h:46
RdmCommand()=delete
Not default-constructible.
RdmCommand & operator=(const RdmCommand &other)=delete
Not copyable - use Save() to create a copyable version.
constexpr etcpal_iptype_t netint_ip_type() const noexcept
Get the IP protocol type of the network interface on which this command was received.
Definition: llrp_rdm_command.h:161
constexpr etcpal::Uuid source_cid() const noexcept
Get the CID of the LLRP manager that sent this command.
Definition: llrp_rdm_command.h:142
constexpr rdm::Uid dest_uid() const noexcept
Get the UID of the LLRP target to which this command is addressed.
Definition: llrp_rdm_command.h:179
constexpr uint16_t subdevice() const noexcept
Get the RDM subdevice to which this command is addressed (0 means the root device).
Definition: llrp_rdm_command.h:185
constexpr rdm_command_class_t command_class() const noexcept
Get the RDM command class of this command.
Definition: llrp_rdm_command.h:191
constexpr const uint8_t * data() const noexcept
Get a pointer to the RDM parameter data buffer contained within this command.
Definition: llrp_rdm_command.h:209
SavedRdmCommand Save() const
Save the data in this command for later use with API functions from a different context.
Definition: llrp_rdm_command.h:252
constexpr bool IsGet() const noexcept
Whether this command is an RDM GET command.
Definition: llrp_rdm_command.h:227
constexpr const LlrpRdmCommand & get() const noexcept
Get a const reference to the underlying C type.
Definition: llrp_rdm_command.h:239
constexpr rdm::Uid source_uid() const noexcept
Get the UID of the LLRP manager that sent this command.
Definition: llrp_rdm_command.h:173
constexpr unsigned int netint_index() const noexcept
Get the index of the network interface on which this command was received.
Definition: llrp_rdm_command.h:167
constexpr uint16_t param_id() const noexcept
Get the RDM parameter ID (PID) of this command.
Definition: llrp_rdm_command.h:197
constexpr bool IsSet() const noexcept
Whether this command is an RDM SET command.
Definition: llrp_rdm_command.h:233
constexpr rdm::CommandHeader rdm_header() const noexcept
Get the RDM protocol header contained within this command.
Definition: llrp_rdm_command.h:203
constexpr uint32_t seq_num() const noexcept
Get the LLRP sequence number of this command.
Definition: llrp_rdm_command.h:148
constexpr RdmnetMcastNetintId netint_id() const noexcept
Get the network interface ID on which this command was received.
Definition: llrp_rdm_command.h:155
constexpr bool HasData() const noexcept
Whether this command has any associated RDM parameter data.
Definition: llrp_rdm_command.h:221
constexpr uint8_t data_len() const noexcept
Get the length of the RDM parameter data contained within this command.
Definition: llrp_rdm_command.h:215
rdm::Command ToRdm() const
Convert the RDM data in this command to an RDM command type.
Definition: llrp_rdm_command.h:245
RdmCommand(const RdmCommand &other)=delete
Not copyable - use Save() to create a copyable version.
An RDM command received over LLRP by a local component and saved for a later response.
Definition: llrp_rdm_command.h:91
ETCPAL_CONSTEXPR_14 LlrpSavedRdmCommand & get() noexcept
Get a mutable reference to the underlying C type.
Definition: llrp_rdm_command.h:391
SavedRdmCommand & operator=(const LlrpSavedRdmCommand &c_cmd) noexcept
Assign an instance of the C LlrpSavedRdmCommand type to an instance of this class.
Definition: llrp_rdm_command.h:267
constexpr const uint8_t * data() const noexcept
Get a pointer to the RDM parameter data buffer contained within this command.
Definition: llrp_rdm_command.h:354
constexpr rdm::Uid source_uid() const noexcept
Get the UID of the LLRP manager that sent this command.
Definition: llrp_rdm_command.h:318
constexpr rdm::CommandHeader rdm_header() const noexcept
Get the RDM protocol header contained within this command.
Definition: llrp_rdm_command.h:348
constexpr rdm::Uid dest_uid() const noexcept
Get the UID of the LLRP target to which this command is addressed.
Definition: llrp_rdm_command.h:324
constexpr unsigned int netint_index() const noexcept
Get the index of the network interface on which this command was received.
Definition: llrp_rdm_command.h:312
constexpr bool HasData() const noexcept
Whether this command has any associated RDM parameter data.
Definition: llrp_rdm_command.h:373
constexpr rdm_command_class_t command_class() const noexcept
Get the RDM command class of this command.
Definition: llrp_rdm_command.h:336
constexpr uint8_t data_len() const noexcept
Get the length of the RDM parameter data contained within this command.
Definition: llrp_rdm_command.h:360
constexpr etcpal::Uuid source_cid() const noexcept
Get the CID of the LLRP manager that sent this command.
Definition: llrp_rdm_command.h:287
constexpr uint16_t subdevice() const noexcept
Get the RDM subdevice to which this command is addressed (0 means the root device).
Definition: llrp_rdm_command.h:330
constexpr uint16_t param_id() const noexcept
Get the RDM parameter ID (PID) of this command.
Definition: llrp_rdm_command.h:342
constexpr etcpal_iptype_t netint_ip_type() const noexcept
Get the IP protocol type of the network interface on which this command was received.
Definition: llrp_rdm_command.h:306
constexpr bool IsGet() const noexcept
Whether this command is an RDM GET command.
Definition: llrp_rdm_command.h:379
SavedRdmCommand()=default
Create an empty, invalid SavedRdmCommand by default.
constexpr uint32_t seq_num() const noexcept
Get the LLRP sequence number of this command.
Definition: llrp_rdm_command.h:293
constexpr bool IsSet() const noexcept
Whether this command is an RDM SET command.
Definition: llrp_rdm_command.h:385
bool IsValid() const noexcept
Whether the values contained in this command are valid for an RDM command.
Definition: llrp_rdm_command.h:367
constexpr RdmnetMcastNetintId netint_id() const noexcept
Get the network interface ID on which this command was received.
Definition: llrp_rdm_command.h:300
rdm::Command ToRdm() const
Convert the RDM data in this command to an RDM command type.
Definition: llrp_rdm_command.h:403
#define ETCPAL_CONSTEXPR_14_OR_INLINE
etcpal_iptype_t
etcpal_error_t rdmnet_save_llrp_rdm_command(const LlrpRdmCommand *command, LlrpSavedRdmCommand *saved_command)
Save the data in a received LLRP RDM command for later use with API functions from a different contex...
Definition: message.c:443
Basic types for parsed RDMnet messages.
A namespace which contains all C++ language definitions in the RDMnet library.
Definition: broker.h:45
An RDM command received from a remote LLRP Manager.
Definition: message.h:439
uint32_t seq_num
The sequence number received with this command, to be echoed in the corresponding response.
Definition: message.h:443
const uint8_t * data
Pointer to buffer containing any associated RDM parameter data.
Definition: message.h:452
uint8_t data_len
The length of any associated RDM parameter data.
Definition: message.h:454
EtcPalUuid source_cid
The CID of the LLRP Manager from which this command was received.
Definition: message.h:441
RdmCommandHeader rdm_header
The header information from the encapsulated RDM command.
Definition: message.h:450
RdmnetMcastNetintId netint_id
An ID for the network interface on which this command was received.
Definition: message.h:448
An RDM command received from a remote LLRP Manager.
Definition: message.h:459
A set of identifying information for a network interface, for multicast purposes.
Definition: common.h:364
etcpal_iptype_t ip_type
The IP protocol used on the network interface.
Definition: common.h:366
unsigned int index
The index of the network interface.
Definition: common.h:368