23 #ifndef RDMNET_CPP_CONTROLLER_H_
24 #define RDMNET_CPP_CONTROLLER_H_
29 #include "etcpal/common.h"
35 #include "rdm/cpp/uid.h"
36 #include "rdm/cpp/message.h"
142 ETCPAL_UNUSED_ARG(controller_handle);
143 ETCPAL_UNUSED_ARG(scope_handle);
144 ETCPAL_UNUSED_ARG(list);
170 ETCPAL_UNUSED_ARG(controller_handle);
171 ETCPAL_UNUSED_ARG(cmd);
221 uint32_t new_software_version_id,
222 const char* new_manufacturer_label,
223 const char* new_device_model_description,
224 const char* new_software_version_label,
225 const char* new_device_label);
227 uint32_t new_software_version_id,
246 uint8_t* rdm_response_buf =
nullptr);
257 const char* new_scope_id_str,
261 const Scope& new_scope_config,
266 const DestinationAddr& destination,
269 const uint8_t* data =
nullptr,
270 uint8_t data_len = 0);
272 const DestinationAddr& destination,
274 const uint8_t* data =
nullptr,
275 uint8_t data_len = 0);
277 const DestinationAddr& destination,
279 const uint8_t* data =
nullptr,
280 uint8_t data_len = 0);
287 const SavedRdmCommand& received_cmd,
288 const uint8_t* response_data =
nullptr,
289 size_t response_data_len = 0);
291 const SavedRdmCommand& received_cmd,
292 rdm_nack_reason_t nack_reason);
296 const uint8_t* data =
nullptr,
297 size_t data_len = 0);
300 const uint8_t* response_data =
nullptr,
301 uint8_t response_data_len = 0);
315 RdmData my_rdm_data_;
317 RdmCommandHandler* rdm_cmd_handler_{
nullptr};
318 NotifyHandler* notify_{
nullptr};
333 static_cast<Controller::NotifyHandler*
>(context)->HandleConnectedToBroker(
Controller::Handle(controller_handle),
345 static_cast<Controller::NotifyHandler*
>(context)->HandleBrokerConnectFailed(
Controller::Handle(controller_handle),
357 static_cast<Controller::NotifyHandler*
>(context)->HandleDisconnectedFromBroker(
362 extern "C" inline void ControllerLibCbClientListUpdate(
rdmnet_controller_t controller_handle,
370 static_cast<Controller::NotifyHandler*
>(context)->HandleClientListUpdate(
375 extern "C" inline bool ControllerLibCbRdmResponseReceived(
rdmnet_controller_t controller_handle,
382 return static_cast<Controller::NotifyHandler*
>(context)->HandleRdmResponse(
Controller::Handle(controller_handle),
389 extern "C" inline void ControllerLibCbStatusReceived(
rdmnet_controller_t controller_handle,
394 if (status && context)
396 static_cast<Controller::NotifyHandler*
>(context)->HandleRptStatus(
Controller::Handle(controller_handle),
401 extern "C" inline void ControllerLibCbResponderIdsReceived(
rdmnet_controller_t controller_handle,
408 static_cast<Controller::NotifyHandler*
>(context)->HandleResponderIdsReceived(
Controller::Handle(controller_handle),
413 extern "C" inline void ControllerLibCbRdmCommandReceived(
rdmnet_controller_t controller_handle,
419 if (cmd && response && context)
421 *response =
static_cast<Controller::RdmCommandHandler*
>(context)
427 extern "C" inline void ControllerLibCbLlrpRdmCommandReceived(
rdmnet_controller_t controller_handle,
432 if (cmd && response && context)
434 *response =
static_cast<Controller::RdmCommandHandler*
>(context)
455 : cid(new_cid), uid(rdm::Uid::DynamicUidRequest(manufacturer_id))
462 return (!cid.IsNull() && (uid.IsStatic() || uid.IsDynamicUidRequest()));
467 uint32_t new_software_version_id,
468 const char* new_manufacturer_label,
469 const char* new_device_model_description,
470 const char* new_software_version_label,
471 const char* new_device_label)
472 : model_id(new_model_id), software_version_id(new_software_version_id)
474 if (new_manufacturer_label)
477 if (new_device_model_description)
480 if (new_software_version_label)
483 if (new_device_label)
489 uint32_t new_software_version_id,
494 : model_id(new_model_id)
495 , software_version_id(new_software_version_id)
496 , manufacturer_label(new_manufacturer_label)
497 , device_model_description(new_device_model_description)
498 , software_version_label(new_software_version_label)
499 , device_label(new_device_label)
506 return ((!manufacturer_label.empty()) && (!device_model_description.empty()) && (!software_version_label.empty()) &&
507 (!device_label.empty()));
535 internal::ControllerLibCbConnected,
536 internal::ControllerLibCbConnectFailed,
537 internal::ControllerLibCbDisconnected,
538 internal::ControllerLibCbClientListUpdate,
539 internal::ControllerLibCbRdmResponseReceived,
540 internal::ControllerLibCbStatusReceived,
541 internal::ControllerLibCbResponderIdsReceived,
545 nullptr,
nullptr,
nullptr,
nullptr
588 uint8_t* rdm_response_buf)
594 rdm_cmd_handler_ = &rdm_handler;
600 internal::ControllerLibCbConnected,
601 internal::ControllerLibCbConnectFailed,
602 internal::ControllerLibCbDisconnected,
603 internal::ControllerLibCbClientListUpdate,
604 internal::ControllerLibCbRdmResponseReceived,
605 internal::ControllerLibCbStatusReceived,
606 internal::ControllerLibCbResponderIdsReceived,
610 internal::ControllerLibCbRdmCommandReceived,
611 internal::ControllerLibCbLlrpRdmCommandReceived,
681 return AddScope(
id.c_str(), static_broker_addr);
709 return AddScope(E133_DEFAULT_SCOPE, static_broker_addr);
741 const char* new_scope_id_str,
745 if (!new_scope_id_str)
766 const Scope& new_scope_config,
788 if (!new_search_domain)
815 command_class, param_id, data, data_len, &seq_num);
841 param_id, data, data_len, &seq_num);
867 param_id, data, data_len, &seq_num);
899 if (!uids || (num_uids == 0))
935 const uint8_t* response_data,
936 size_t response_data_len)
954 rdm_nack_reason_t nack_reason)
972 uint16_t raw_nack_reason)
975 static_cast<rdm_nack_reason_t
>(raw_nack_reason));
1008 const uint8_t* response_data,
1009 uint8_t response_data_len)
1041 static_cast<rdm_nack_reason_t
>(raw_nack_reason));
1054 return my_rdm_data_;
1067 return rdm_cmd_handler_;
1076 std::string scope_id(E133_SCOPE_STRING_PADDED_LENGTH, 0);
1082 return Scope(scope_id, static_broker_addr);
1091 ETCPAL_UNUSED_ARG(new_data);
T back_inserter(T... args)
ETCPAL_CONSTEXPR_14 void Clear()
ETCPAL_CONSTEXPR_14 void SetValue(const ValueType &new_value)
constexpr ValueType value() const
constexpr const EtcPalSockAddr & get() const noexcept
constexpr const EtcPalUuid & get() const noexcept
Information about a failed connection to a broker delivered to an RDMnet callback function.
Definition: client.h:228
Information about a successful connection to a broker delivered to an RDMnet callback function.
Definition: client.h:158
Information about a disconnect event from a broker delivered to an RDMnet callback function.
Definition: client.h:346
A base class for a class that receives notification callbacks from a controller.
Definition: controller.h:77
virtual void HandleRptStatus(Handle controller_handle, ScopeHandle scope_handle, const RptStatus &status)=0
An RPT status message has been received in response to a previously-sent RDM command.
virtual void HandleBrokerConnectFailed(Handle controller_handle, ScopeHandle scope_handle, const ClientConnectFailedInfo &info)=0
A connection attempt failed between a controller and a broker.
virtual void HandleConnectedToBroker(Handle controller_handle, ScopeHandle scope_handle, const ClientConnectedInfo &info)=0
A controller has successfully connected to a broker.
virtual void HandleResponderIdsReceived(Handle controller_handle, ScopeHandle scope_handle, const DynamicUidAssignmentList &list)
A set of previously-requested mappings of dynamic UIDs to responder IDs has been received.
Definition: controller.h:138
virtual void HandleDisconnectedFromBroker(Handle controller_handle, ScopeHandle scope_handle, const ClientDisconnectedInfo &info)=0
A controller which was previously connected to a broker has disconnected.
virtual void HandleClientListUpdate(Handle controller_handle, ScopeHandle scope_handle, client_list_action_t list_action, const RptClientList &list)=0
A client list update has been received from a broker.
virtual bool HandleRdmResponse(Handle controller_handle, ScopeHandle scope_handle, const RdmResponse &resp)=0
An RDM response has been received.
A base class for a class that receives RDM commands addressed to a controller.
Definition: controller.h:153
virtual RdmResponseAction HandleLlrpRdmCommand(Handle controller_handle, const llrp::RdmCommand &cmd)
An RDM command has been received over LLRP, addressed to a controller.
Definition: controller.h:168
virtual RdmResponseAction HandleRdmCommand(Handle controller_handle, ScopeHandle scope_handle, const RdmCommand &cmd)=0
An RDM command has been received addressed to a controller.
An instance of RDMnet controller functionality.
Definition: controller.h:67
Controller(Controller &&other)=default
Move a controller instance.
etcpal::Error SendRdmUpdate(ScopeHandle scope_handle, uint16_t param_id, const uint8_t *data=nullptr, size_t data_len=0)
Send an asynchronous RDM GET response to update the value of a local parameter.
Definition: controller.h:989
const RdmData & rdm_data() const
Retrieve the RDM data that this controller was configured with on startup.
Definition: controller.h:1052
etcpal::Error SendLlrpNack(const llrp::SavedRdmCommand &received_cmd, rdm_nack_reason_t nack_reason)
Send a negative acknowledge (NACK) response to an LLRP RDM command received by a controller.
Definition: controller.h:1023
etcpal::Expected< uint32_t > SendRdmCommand(ScopeHandle scope_handle, const DestinationAddr &destination, rdmnet_command_class_t command_class, uint16_t param_id, const uint8_t *data=nullptr, uint8_t data_len=0)
Send an RDM command from a controller on a scope.
Definition: controller.h:806
etcpal::Error Startup(NotifyHandler ¬ify_handler, const Settings &settings, const RdmData &rdm_data)
Allocate resources and start up this controller with the given configuration.
Definition: controller.h:521
etcpal::Expected< ScopeHandle > AddDefaultScope(const etcpal::SockAddr &static_broker_addr=etcpal::SockAddr{})
Shortcut to add the default RDMnet scope to a controller instance.
Definition: controller.h:707
etcpal::Error SendLlrpAck(const llrp::SavedRdmCommand &received_cmd, const uint8_t *response_data=nullptr, uint8_t response_data_len=0)
Send an acknowledge (ACK) response to an LLRP RDM command received by a controller.
Definition: controller.h:1007
Controller::RdmCommandHandler * rdm_command_handler() const
Retrieve the Controller::RdmCommandHandler reference that this controller was configured with.
Definition: controller.h:1065
etcpal::Error SendRdmNack(ScopeHandle scope_handle, const SavedRdmCommand &received_cmd, rdm_nack_reason_t nack_reason)
Send a negative acknowledge (NACK) response to an RDM command received by a controller.
Definition: controller.h:952
etcpal::Error RequestResponderIds(ScopeHandle scope_handle, const rdm::Uid *uids, size_t num_uids)
Request mappings from dynamic UIDs to Responder IDs (RIDs).
Definition: controller.h:897
etcpal::Expected< uint32_t > SendGetCommand(ScopeHandle scope_handle, const DestinationAddr &destination, uint16_t param_id, const uint8_t *data=nullptr, uint8_t data_len=0)
Send an RDM GET command from a controller on a scope.
Definition: controller.h:833
Controller & operator=(Controller &&other)=default
Move a controller instance.
Handle handle() const
Retrieve the handle of a controller instance.
Definition: controller.h:1045
void UpdateRdmData(const RdmData &new_data)
Update the data used to identify this controller to other controllers.
Definition: controller.h:1088
etcpal::Error RequestClientList(ScopeHandle scope_handle)
Request a client list from a broker.
Definition: controller.h:882
void Shutdown(rdmnet_disconnect_reason_t disconnect_reason=kRdmnetDisconnectShutdown)
Shut down this controller and deallocate resources.
Definition: controller.h:636
etcpal::Error ChangeScope(ScopeHandle scope_handle, const char *new_scope_id_str, rdmnet_disconnect_reason_t disconnect_reason, const etcpal::SockAddr &new_static_broker_addr=etcpal::SockAddr{})
Change the configuration of a scope on a controller.
Definition: controller.h:740
etcpal::Expected< Scope > scope(ScopeHandle scope_handle) const
Retrieve the scope configuration associated with a given scope handle.
Definition: controller.h:1074
Controller::NotifyHandler * notify_handler() const
Retrieve the Controller::NotifyHandler reference that this controller was configured with.
Definition: controller.h:1058
etcpal::Error ChangeSearchDomain(const char *new_search_domain, rdmnet_disconnect_reason_t disconnect_reason)
Change the controller's DNS search domain.
Definition: controller.h:785
etcpal::Error RemoveScope(ScopeHandle scope_handle, rdmnet_disconnect_reason_t disconnect_reason)
Remove a previously-added scope from this controller instance.
Definition: controller.h:720
etcpal::OpaqueId< detail::ControllerHandleType, rdmnet_controller_t, RDMNET_CONTROLLER_INVALID > Handle
A handle type used by the RDMnet library to identify controller instances.
Definition: controller.h:70
etcpal::Expected< ScopeHandle > AddScope(const char *id, const etcpal::SockAddr &static_broker_addr=etcpal::SockAddr{})
Add a new scope to this controller instance.
Definition: controller.h:653
etcpal::Error SendRdmAck(ScopeHandle scope_handle, const SavedRdmCommand &received_cmd, const uint8_t *response_data=nullptr, size_t response_data_len=0)
Send an acknowledge (ACK) response to an RDM command received by a controller.
Definition: controller.h:933
etcpal::Expected< uint32_t > SendSetCommand(ScopeHandle scope_handle, const DestinationAddr &destination, uint16_t param_id, const uint8_t *data=nullptr, uint8_t data_len=0)
Send an RDM SET command from a controller on a scope.
Definition: controller.h:859
A destination address for an RDM command in RDMnet's RPT protocol.
Definition: client.h:79
constexpr const RdmnetDestinationAddr & get() const noexcept
Get a const reference to the underlying C type.
Definition: client.h:139
A list of mappings from dynamic UIDs to responder IDs received from an RDMnet broker.
Definition: dynamic_uid.h:99
An RDM command received over RDMnet and delivered to an RDMnet callback function.
Definition: rdm_command.h:43
A class representing a synchronous action to take in response to a received RDM command.
Definition: common.h:146
static RdmResponseAction SendNack(rdm_nack_reason_t nack_reason)
Send an RDM NACK with a reason code.
Definition: common.h:172
An RDM response received over RDMnet and delivered to an RDMnet callback function.
Definition: rdm_response.h:47
A list of RPT client entries.
Definition: rpt_client.h:89
An RPT status message received over RDMnet and delivered to an RDMnet callback function.
Definition: rpt_status.h:42
An RDM command received over RDMnet by a local component and saved for a later response.
Definition: rdm_command.h:87
ETCPAL_CONSTEXPR_14 RdmnetSavedRdmCommand & get() noexcept
Get a mutable reference to the underlying C type.
Definition: rdm_command.h:374
An RDMnet scope configuration.
Definition: client.h:469
const etcpal::SockAddr & static_broker_addr() const noexcept
The static broker address associated with this scope.
Definition: client.h:524
const std::string & id_string() const noexcept
The ID string of this scope.
Definition: client.h:515
Definition: controller.h:58
An RDM command received over LLRP and delivered to an RDMnet callback function.
Definition: llrp_rdm_command.h:46
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
Definitions for the RDMnet Controller API.
C++ wrapper for RDMnet client API definitions.
C++ wrapper for the RDMnet init/deinit functions.
RDMnet C++ message type definitions.
rdmnet_disconnect_reason_t
Definition: common.h:85
rdmnet_command_class_t
An RDM command class, for RDMnet purposes.
Definition: common.h:371
client_list_action_t
Definition: client.h:50
int rdmnet_client_scope_t
Definition: client.h:41
@ kRdmnetDisconnectShutdown
Definition: common.h:87
etcpal_error_t rdmnet_controller_change_scope(rdmnet_controller_t controller_handle, rdmnet_client_scope_t scope_handle, const RdmnetScopeConfig *new_scope_config, rdmnet_disconnect_reason_t disconnect_reason)
Change the configuration of a scope on a controller.
Definition: controller.c:436
etcpal_error_t rdmnet_controller_create(const RdmnetControllerConfig *config, rdmnet_controller_t *handle)
Create a new instance of RDMnet controller functionality.
Definition: controller.c:255
etcpal_error_t rdmnet_controller_send_llrp_ack(rdmnet_controller_t controller_handle, const LlrpSavedRdmCommand *received_cmd, const uint8_t *response_data, uint8_t response_data_len)
Send an LLRP RDM ACK response from a controller.
Definition: controller.c:869
etcpal_error_t rdmnet_controller_send_rdm_ack(rdmnet_controller_t controller_handle, rdmnet_client_scope_t scope_handle, const RdmnetSavedRdmCommand *received_cmd, const uint8_t *response_data, size_t response_data_len)
Send an RDM ACK response from a controller on a scope.
Definition: controller.c:756
etcpal_error_t rdmnet_controller_send_rdm_update(rdmnet_controller_t controller_handle, rdmnet_client_scope_t scope_handle, uint16_t subdevice, uint16_t param_id, const uint8_t *data, size_t data_len)
Send an asynchronous RDM GET response to update the value of a local parameter.
Definition: controller.c:836
etcpal_error_t rdmnet_controller_add_scope(rdmnet_controller_t controller_handle, const RdmnetScopeConfig *scope_config, rdmnet_client_scope_t *scope_handle)
Add a new scope to a controller instance.
Definition: controller.c:330
etcpal_error_t rdmnet_controller_destroy(rdmnet_controller_t controller_handle, rdmnet_disconnect_reason_t reason)
Destroy a controller instance.
Definition: controller.c:293
etcpal_error_t rdmnet_controller_send_set_command(rdmnet_controller_t controller_handle, rdmnet_client_scope_t scope_handle, const RdmnetDestinationAddr *destination, uint16_t param_id, const uint8_t *data, uint8_t data_len, uint32_t *seq_num)
Send an RDM SET command from a controller on a scope.
Definition: controller.c:713
etcpal_error_t rdmnet_controller_request_client_list(rdmnet_controller_t controller_handle, rdmnet_client_scope_t scope_handle)
Request a client list from a broker.
Definition: controller.c:542
#define RDMNET_CONTROLLER_INVALID
Definition: controller.h:56
etcpal_error_t rdmnet_controller_send_get_command(rdmnet_controller_t controller_handle, rdmnet_client_scope_t scope_handle, const RdmnetDestinationAddr *destination, uint16_t param_id, const uint8_t *data, uint8_t data_len, uint32_t *seq_num)
Send an RDM GET command from a controller on a scope.
Definition: controller.c:666
etcpal_error_t rdmnet_controller_request_responder_ids(rdmnet_controller_t controller_handle, rdmnet_client_scope_t scope_handle, const RdmUid *uids, size_t num_uids)
Request a set of responder IDs corresponding with dynamic responder UIDs from a broker.
Definition: controller.c:574
etcpal_error_t rdmnet_controller_change_search_domain(rdmnet_controller_t controller_handle, const char *new_search_domain, rdmnet_disconnect_reason_t disconnect_reason)
Change the controller's DNS search domain.
Definition: controller.c:508
etcpal_error_t rdmnet_controller_get_scope(rdmnet_controller_t controller_handle, rdmnet_client_scope_t scope_handle, char *scope_str_buf, EtcPalSockAddr *static_broker_addr)
Retrieve the scope configuration of a previously-added scope.
Definition: controller.c:474
etcpal_error_t rdmnet_controller_send_rdm_command(rdmnet_controller_t controller_handle, rdmnet_client_scope_t scope_handle, const RdmnetDestinationAddr *destination, rdmnet_command_class_t command_class, uint16_t param_id, const uint8_t *data, uint8_t data_len, uint32_t *seq_num)
Send an RDM command from a controller on a scope.
Definition: controller.c:618
etcpal_error_t rdmnet_controller_send_rdm_nack(rdmnet_controller_t controller_handle, rdmnet_client_scope_t scope_handle, const RdmnetSavedRdmCommand *received_cmd, rdm_nack_reason_t nack_reason)
Send an RDM NACK response from a controller on a scope.
Definition: controller.c:795
etcpal_error_t rdmnet_controller_remove_scope(rdmnet_controller_t controller_handle, rdmnet_client_scope_t scope_handle, rdmnet_disconnect_reason_t reason)
Remove a previously-added scope from a controller instance.
Definition: controller.c:402
etcpal_error_t rdmnet_controller_send_llrp_nack(rdmnet_controller_t controller_handle, const LlrpSavedRdmCommand *received_cmd, rdm_nack_reason_t nack_reason)
Send an LLRP RDM NACK response from a controller.
Definition: controller.c:902
#define RDMNET_CONTROLLER_RDM_DATA_DEFAULT_INIT
A default-value initializer for an RdmnetControllerRdmData struct.
Definition: controller.h:261
int rdmnet_controller_t
Definition: controller.h:54
etcpal::OpaqueId< detail::ScopeHandleType, rdmnet_client_scope_t, RDMNET_CLIENT_SCOPE_INVALID > ScopeHandle
Definition: client.h:456
A namespace which contains all C++ language definitions in the RDMnet library.
Definition: broker.h:45
Definition: message.h:440
A set of information that defines the startup parameters of an RDMnet Controller.
Definition: controller.h:273
Definition: message.h:246
Definition: message.h:399
Definition: message.h:194
A set of initial identifying RDM data to use for a controller.
Definition: controller.h:201
uint32_t software_version_id
A number representing the version of the controller software.
Definition: controller.h:207
uint16_t model_id
A number representing the product model which implements the controller.
Definition: controller.h:204
RdmData()=default
Create an empty, invalid structure by default - must be filled in before passing to Controller::Start...
bool device_label_settable
Whether the library should allow device_label to be changed remotely.
Definition: controller.h:216
std::string manufacturer_label
The manufacturer name of the controller.
Definition: controller.h:212
std::string software_version_label
The software version of the controller as a string.
Definition: controller.h:214
std::string device_label
A user-settable name for this controller instance.
Definition: controller.h:215
std::string device_model_description
The name of the product model which implements the controller.
Definition: controller.h:213
bool IsValid() const
Whether this data is valid (all string members are non-empty).
Definition: controller.h:504
uint16_t product_category
A number representing the product's primary function.
Definition: controller.h:210
A set of configuration settings that a controller needs to initialize.
Definition: controller.h:182
rdm::Uid uid
The controller's RDM UID. For a dynamic UID, use rdm::Uid::DynamicUidRequest().
Definition: controller.h:184
Settings()=default
Create an empty, invalid data structure by default.
std::string search_domain
(optional) The controller's search domain for discovering brokers.
Definition: controller.h:185
etcpal::Uuid cid
The controller's Component Identifier (CID).
Definition: controller.h:183
bool IsValid() const
Determine whether a controller Settings instance contains valid data for RDMnet operation.
Definition: controller.h:460
bool create_llrp_target
(optional) Whether to create an LLRP target associated with this controller.
Definition: controller.h:188