RDMnet  0.3.0
Implementation of ANSI E1.33 (RDMnet)
View other versions:
device.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 
25 #ifndef RDMNET_DEVICE_H_
26 #define RDMNET_DEVICE_H_
27 
28 #include <stdbool.h>
29 #include "etcpal/uuid.h"
30 #include "rdm/uid.h"
31 #include "rdmnet/client.h"
32 #include "rdmnet/message.h"
33 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
53 typedef int rdmnet_device_t;
55 #define RDMNET_DEVICE_INVALID -1
56 
64  const RdmnetClientConnectedInfo* info,
65  void* context);
66 
75  void* context);
76 
84  const RdmnetClientDisconnectedInfo* info,
85  void* context);
86 
95  const RdmnetRdmCommand* cmd,
96  RdmnetSyncRdmResponse* response,
97  void* context);
98 
107  const LlrpRdmCommand* cmd,
108  RdmnetSyncRdmResponse* response,
109  void* context);
110 
125  const RdmnetDynamicUidAssignmentList* list,
126  void* context);
127 
129 typedef struct RdmnetDeviceCallbacks
130 {
137  void* context;
139 
145 {
147  uint16_t endpoint_id;
156  const RdmUid* static_responders;
160 
174 #define RDMNET_VIRTUAL_ENDPOINT_INIT(endpoint_num) \
175  { \
176  (endpoint_num), NULL, 0, NULL, 0 \
177  }
178 
181 {
183  RdmUid uid;
185  uint16_t control_field;
190  RdmUid binding_uid;
192 
198 {
200  uint16_t endpoint_id;
206 
220 #define RDMNET_PHYSICAL_ENDPOINT_INIT(endpoint_num) \
221  { \
222  (endpoint_num), NULL, 0 \
223  }
224 
226 typedef struct RdmnetDeviceConfig
227 {
228  /************************************************************************************************
229  * Required Values
230  ***********************************************************************************************/
231 
236 
237  /************************************************************************************************
238  * Optional Values
239  ***********************************************************************************************/
240 
245  uint8_t* response_buf;
246 
252 
258  RdmUid uid;
259 
264  const char* search_domain;
265 
270 
275 
285 
297 #define RDMNET_DEVICE_CONFIG_DEFAULT_INIT(manu_id) \
298  { \
299  {{0}}, {NULL, NULL, NULL, NULL, NULL, NULL, NULL}, NULL, RDMNET_SCOPE_CONFIG_DEFAULT_INIT, \
300  {(0x8000 | manu_id), 0}, NULL, NULL, 0, NULL, 0, NULL, 0 \
301  }
302 
303 void rdmnet_device_config_init(RdmnetDeviceConfig* config, uint16_t manufacturer_id);
306  RdmnetDeviceConnectFailedCallback connect_failed,
308  RdmnetDeviceRdmCommandReceivedCallback rdm_command_received,
309  RdmnetDeviceLlrpRdmCommandReceivedCallback llrp_rdm_command_received,
310  RdmnetDeviceDynamicUidStatusCallback dynamic_uid_status_received,
311  void* context);
312 
315 
317  const RdmnetSavedRdmCommand* received_cmd,
318  const uint8_t* response_data,
319  size_t response_data_len);
321  const RdmnetSavedRdmCommand* received_cmd,
322  rdm_nack_reason_t nack_reason);
324  uint16_t subdevice,
325  uint16_t param_id,
326  const uint8_t* data,
327  size_t data_len);
329  const RdmnetSourceAddr* source_addr,
330  uint16_t param_id,
331  const uint8_t* data,
332  size_t data_len);
334  const RdmnetSavedRdmCommand* received_cmd,
335  rpt_status_code_t status_code,
336  const char* status_string);
337 
339  const LlrpSavedRdmCommand* received_cmd,
340  const uint8_t* response_data,
341  uint8_t response_data_len);
343  const LlrpSavedRdmCommand* received_cmd,
344  rdm_nack_reason_t nack_reason);
345 
347  const RdmnetPhysicalEndpointConfig* endpoint_config);
349  const RdmnetPhysicalEndpointConfig* endpoint_configs,
350  size_t num_endpoints);
352  const RdmnetVirtualEndpointConfig* endpoint_config);
354  const RdmnetVirtualEndpointConfig* endpoint_configs,
355  size_t num_endpoints);
356 etcpal_error_t rdmnet_device_remove_endpoint(rdmnet_device_t handle, uint16_t endpoint_id);
358  const uint16_t* endpoint_ids,
359  size_t num_endpoints);
360 
362  uint16_t endpoint_id,
363  const RdmUid* responder_uids,
364  size_t num_responders);
366  uint16_t endpoint_id,
367  const EtcPalUuid* responder_ids,
368  size_t num_responders);
370  uint16_t endpoint_id,
371  const RdmnetPhysicalEndpointResponder* responders,
372  size_t num_responders);
373 
375  uint16_t endpoint_id,
376  const RdmUid* responder_uids,
377  size_t num_responders);
379  uint16_t endpoint_id,
380  const EtcPalUuid* responder_ids,
381  size_t num_responders);
383  uint16_t endpoint_id,
384  const RdmUid* responder_uids,
385  size_t num_responders);
386 
388  const RdmnetScopeConfig* new_scope_config,
389  rdmnet_disconnect_reason_t disconnect_reason);
391  const char* new_search_domain,
392  rdmnet_disconnect_reason_t disconnect_reason);
393 etcpal_error_t rdmnet_device_get_scope(rdmnet_device_t handle, char* scope_str_buf, EtcPalSockAddr* static_broker_addr);
394 
395 #ifdef __cplusplus
396 };
397 #endif
398 
403 #endif /* RDMNET_DEVICE_H_ */
API definitions used by RDMnet clients (controllers and devices)
etcpal_error_t
rdmnet_disconnect_reason_t
Disconnect reason defines for the BrokerDisconnectMsg.
Definition: common.h:85
rpt_status_code_t
RPT status code definitions.
Definition: common.h:53
void(* RdmnetDeviceConnectFailedCallback)(rdmnet_device_t handle, const RdmnetClientConnectFailedInfo *info, void *context)
A connection attempt failed between a device and a broker.
Definition: device.h:73
etcpal_error_t rdmnet_device_remove_endpoint(rdmnet_device_t handle, uint16_t endpoint_id)
Remove an endpoint from a device.
Definition: device.c:656
etcpal_error_t rdmnet_device_add_static_responders(rdmnet_device_t handle, uint16_t endpoint_id, const RdmUid *responder_uids, size_t num_responders)
Add one or more responders with static UIDs to a virtual endpoint.
Definition: device.c:728
etcpal_error_t rdmnet_device_destroy(rdmnet_device_t handle, rdmnet_disconnect_reason_t disconnect_reason)
Destroy a device instance.
Definition: device.c:257
struct RdmnetVirtualEndpointConfig RdmnetVirtualEndpointConfig
Configuration information for a virtual endpoint on a device.
etcpal_error_t rdmnet_device_send_rdm_nack(rdmnet_device_t handle, const RdmnetSavedRdmCommand *received_cmd, rdm_nack_reason_t nack_reason)
Send an RDM NACK response from a device.
Definition: device.c:316
etcpal_error_t rdmnet_device_remove_physical_responders(rdmnet_device_t handle, uint16_t endpoint_id, const RdmUid *responder_uids, size_t num_responders)
Remove one or more responders from a physical endpoint.
Definition: device.c:1073
etcpal_error_t rdmnet_device_add_physical_responders(rdmnet_device_t handle, uint16_t endpoint_id, const RdmnetPhysicalEndpointResponder *responders, size_t num_responders)
Add one or more responders to a physical endpoint.
Definition: device.c:856
struct RdmnetPhysicalEndpointConfig RdmnetPhysicalEndpointConfig
Configuration information for a physical endpoint on a device.
struct RdmnetDeviceConfig RdmnetDeviceConfig
A set of information that defines the startup parameters of an RDMnet Device.
void rdmnet_device_set_callbacks(RdmnetDeviceConfig *config, RdmnetDeviceConnectedCallback connected, RdmnetDeviceConnectFailedCallback connect_failed, RdmnetDeviceDisconnectedCallback disconnected, RdmnetDeviceRdmCommandReceivedCallback rdm_command_received, RdmnetDeviceLlrpRdmCommandReceivedCallback llrp_rdm_command_received, RdmnetDeviceDynamicUidStatusCallback dynamic_uid_status_received, void *context)
Set the main callbacks in an RDMnet device configuration structure.
Definition: device.c:182
etcpal_error_t rdmnet_device_send_rdm_update_from_responder(rdmnet_device_t handle, const RdmnetSourceAddr *source_addr, uint16_t param_id, const uint8_t *data, size_t data_len)
Send an asynchronous RDM GET response to update the value of a parameter on a sub-responder.
Definition: device.c:386
struct RdmnetDeviceCallbacks RdmnetDeviceCallbacks
A set of notification callbacks received about a device.
etcpal_error_t rdmnet_device_change_scope(rdmnet_device_t handle, const RdmnetScopeConfig *new_scope_config, rdmnet_disconnect_reason_t disconnect_reason)
Change the device's scope.
Definition: device.c:1154
etcpal_error_t rdmnet_device_add_physical_endpoint(rdmnet_device_t handle, const RdmnetPhysicalEndpointConfig *endpoint_config)
Add a physical endpoint to a device.
Definition: device.c:512
void(* RdmnetDeviceLlrpRdmCommandReceivedCallback)(rdmnet_device_t handle, const LlrpRdmCommand *cmd, RdmnetSyncRdmResponse *response, void *context)
An RDM command has been received over LLRP, addressed to a device.
Definition: device.h:106
etcpal_error_t rdmnet_device_send_rdm_update(rdmnet_device_t 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: device.c:352
struct RdmnetPhysicalEndpointResponder RdmnetPhysicalEndpointResponder
Identifying information for a physical RDM responder connected to an RDMnet gateway.
etcpal_error_t rdmnet_device_add_physical_endpoints(rdmnet_device_t handle, const RdmnetPhysicalEndpointConfig *endpoint_configs, size_t num_endpoints)
Add multiple physical endpoints to a device.
Definition: device.c:548
etcpal_error_t rdmnet_device_remove_static_responders(rdmnet_device_t handle, uint16_t endpoint_id, const RdmUid *responder_uids, size_t num_responders)
Remove one or more responders with static UIDs from a virtual endpoint.
Definition: device.c:920
etcpal_error_t rdmnet_device_add_virtual_endpoints(rdmnet_device_t handle, const RdmnetVirtualEndpointConfig *endpoint_configs, size_t num_endpoints)
Add multiple virtual endpoints to a device.
Definition: device.c:620
etcpal_error_t rdmnet_device_add_virtual_endpoint(rdmnet_device_t handle, const RdmnetVirtualEndpointConfig *endpoint_config)
Add a virtual endpoint to a device.
Definition: device.c:584
etcpal_error_t rdmnet_device_send_llrp_nack(rdmnet_device_t handle, const LlrpSavedRdmCommand *received_cmd, rdm_nack_reason_t nack_reason)
Send an ACK response to an RDM command received over LLRP.
Definition: device.c:483
etcpal_error_t rdmnet_device_change_search_domain(rdmnet_device_t handle, const char *new_search_domain, rdmnet_disconnect_reason_t disconnect_reason)
Change the device's DNS search domain.
Definition: device.c:1189
void(* RdmnetDeviceConnectedCallback)(rdmnet_device_t handle, const RdmnetClientConnectedInfo *info, void *context)
A device has successfully connected to a broker.
Definition: device.h:63
etcpal_error_t rdmnet_device_send_llrp_ack(rdmnet_device_t handle, const LlrpSavedRdmCommand *received_cmd, const uint8_t *response_data, uint8_t response_data_len)
Send an ACK response to an RDM command received over LLRP.
Definition: device.c:453
etcpal_error_t rdmnet_device_add_dynamic_responders(rdmnet_device_t handle, uint16_t endpoint_id, const EtcPalUuid *responder_ids, size_t num_responders)
Add one or more responders with dynamic UIDs to a virtual endpoint.
Definition: device.c:792
etcpal_error_t rdmnet_device_send_rdm_ack(rdmnet_device_t handle, const RdmnetSavedRdmCommand *received_cmd, const uint8_t *response_data, size_t response_data_len)
Send an RDM ACK response from a device.
Definition: device.c:286
void(* RdmnetDeviceDisconnectedCallback)(rdmnet_device_t handle, const RdmnetClientDisconnectedInfo *info, void *context)
A device which was previously connected to a broker has disconnected.
Definition: device.h:83
void(* RdmnetDeviceRdmCommandReceivedCallback)(rdmnet_device_t handle, const RdmnetRdmCommand *cmd, RdmnetSyncRdmResponse *response, void *context)
An RDM command has been received addressed to a device.
Definition: device.h:94
int rdmnet_device_t
A handle to an RDMnet device.
Definition: device.h:53
void rdmnet_device_config_init(RdmnetDeviceConfig *config, uint16_t manufacturer_id)
Initialize an RDMnet Device Config with default values for the optional config options.
Definition: device.c:156
void(* RdmnetDeviceDynamicUidStatusCallback)(rdmnet_device_t handle, const RdmnetDynamicUidAssignmentList *list, void *context)
The dynamic UID assignment status for a set of virtual responders has been received.
Definition: device.h:124
etcpal_error_t rdmnet_device_get_scope(rdmnet_device_t handle, char *scope_str_buf, EtcPalSockAddr *static_broker_addr)
Retrieve the device's current scope configuration.
Definition: device.c:1222
etcpal_error_t rdmnet_device_create(const RdmnetDeviceConfig *config, rdmnet_device_t *handle)
Create a new instance of RDMnet device functionality.
Definition: device.c:219
etcpal_error_t rdmnet_device_remove_endpoints(rdmnet_device_t handle, const uint16_t *endpoint_ids, size_t num_endpoints)
Remove multiple endpoints from a device.
Definition: device.c:688
etcpal_error_t rdmnet_device_remove_dynamic_responders(rdmnet_device_t handle, uint16_t endpoint_id, const EtcPalUuid *responder_ids, size_t num_responders)
Remove one or more responders with dynamic UIDs from a virtual endpoint.
Definition: device.c:1002
etcpal_error_t rdmnet_device_send_status(rdmnet_device_t handle, const RdmnetSavedRdmCommand *received_cmd, rpt_status_code_t status_code, const char *status_string)
Send an RPT status message from a device.
Definition: device.c:422
Basic types for parsed RDMnet messages.
An RDM command received from a remote LLRP Manager.
Definition: message.h:439
An RDM command received from a remote LLRP Manager.
Definition: message.h:459
Information provided by the library about an unsuccessful RDMnet client connection.
Definition: client.h:164
Information provided by the library about a successful RDMnet client connection.
Definition: client.h:151
Information provided by the library about an RDMnet client connection that disconnected after a succe...
Definition: client.h:196
A set of notification callbacks received about a device.
Definition: device.h:130
RdmnetDeviceDisconnectedCallback disconnected
Required.
Definition: device.h:133
RdmnetDeviceDynamicUidStatusCallback dynamic_uid_status_received
Optional.
Definition: device.h:136
RdmnetDeviceRdmCommandReceivedCallback rdm_command_received
Required.
Definition: device.h:134
RdmnetDeviceLlrpRdmCommandReceivedCallback llrp_rdm_command_received
Required.
Definition: device.h:135
RdmnetDeviceConnectFailedCallback connect_failed
Required.
Definition: device.h:132
void * context
(optional) Pointer to opaque data passed back with each callback.
Definition: device.h:137
RdmnetDeviceConnectedCallback connected
Required.
Definition: device.h:131
A set of information that defines the startup parameters of an RDMnet Device.
Definition: device.h:227
const RdmnetMcastNetintId * llrp_netints
(optional) A set of network interfaces to use for the LLRP target associated with this device.
Definition: device.h:281
const RdmnetPhysicalEndpointConfig * physical_endpoints
An array of initial physical endpoints that the device uses.
Definition: device.h:267
const char * search_domain
(optional) The device's configured search domain for discovery.
Definition: device.h:264
RdmnetScopeConfig scope_config
(optional) The device's configured RDMnet scope.
Definition: device.h:251
const RdmnetVirtualEndpointConfig * virtual_endpoints
An array of initial virtual endpoints that the device uses.
Definition: device.h:272
size_t num_llrp_netints
(optional) The size of the llrp_netints array.
Definition: device.h:283
uint8_t * response_buf
(optional) A data buffer to be used to respond synchronously to RDM commands.
Definition: device.h:245
size_t num_virtual_endpoints
Size of the virtual_endpoints array.
Definition: device.h:274
RdmnetDeviceCallbacks callbacks
A set of callbacks for the device to receive RDMnet notifications.
Definition: device.h:235
size_t num_physical_endpoints
Size of the physical_endpoints array.
Definition: device.h:269
RdmUid uid
(optional) The device's UID.
Definition: device.h:258
EtcPalUuid cid
The device's CID.
Definition: device.h:233
A list of mappings from dynamic UIDs to responder IDs received from an RDMnet broker.
Definition: message.h:245
A set of identifying information for a network interface, for multicast purposes.
Definition: common.h:364
Configuration information for a physical endpoint on a device.
Definition: device.h:198
uint16_t endpoint_id
The endpoint identifier for this endpoint.
Definition: device.h:200
size_t num_responders
Size of the responders array.
Definition: device.h:204
const RdmnetPhysicalEndpointResponder * responders
An array of initial physical RDM responders on this endpoint, identified by static UID.
Definition: device.h:202
Identifying information for a physical RDM responder connected to an RDMnet gateway.
Definition: device.h:181
RdmUid uid
The responder's UID.
Definition: device.h:183
RdmUid binding_uid
The binding UID received in the DISC_MUTE message from this responder.
Definition: device.h:190
uint16_t control_field
The control field received in the DISC_MUTE message from this responder.
Definition: device.h:185
An RDMnet RDM command received by this component.
Definition: message.h:53
An RDM command received by this component and saved for a later response.
Definition: message.h:73
A set of configuration information for a single scope in which an RDMnet client is participating.
Definition: client.h:224
The source address for an unsolicited RDM response generated by a local component.
Definition: client.h:66
This structure should not be manipulated directly - use the macros to access it:
Definition: common.h:214
Configuration information for a virtual endpoint on a device.
Definition: device.h:145
const EtcPalUuid * dynamic_responders
An array of initial virtual RDM responders on this endpoint, identified by RID.
Definition: device.h:152
size_t num_static_responders
Size of the static_responders array.
Definition: device.h:158
size_t num_dynamic_responders
Size of the dynamic_responders array.
Definition: device.h:154
const RdmUid * static_responders
An array of initial virtual RDM responders on this endpoint, identified by static UID.
Definition: device.h:156
uint16_t endpoint_id
The endpoint identifier for this endpoint.
Definition: device.h:147