RDMnet  HEAD (unstable)
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/inet.h"
30 #include "etcpal/uuid.h"
31 #include "rdm/uid.h"
32 #include "rdmnet/client.h"
33 #include "rdmnet/message.h"
34 
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 
54 typedef int rdmnet_device_t;
56 #define RDMNET_DEVICE_INVALID -1
57 
65  const RdmnetClientConnectedInfo* info,
66  void* context);
67 
76  void* context);
77 
85  const RdmnetClientDisconnectedInfo* info,
86  void* context);
87 
96  const RdmnetRdmCommand* cmd,
97  RdmnetSyncRdmResponse* response,
98  void* context);
99 
108  const LlrpRdmCommand* cmd,
109  RdmnetSyncRdmResponse* response,
110  void* context);
111 
126  const RdmnetDynamicUidAssignmentList* list,
127  void* context);
128 
130 typedef struct RdmnetDeviceCallbacks
131 {
138  void* context;
140 
146 {
148  uint16_t endpoint_id;
157  const RdmUid* static_responders;
161 
175 #define RDMNET_VIRTUAL_ENDPOINT_INIT(endpoint_num) \
176  { \
177  (endpoint_num), NULL, 0, NULL, 0 \
178  }
179 
182 {
184  RdmUid uid;
186  uint16_t control_field;
191  RdmUid binding_uid;
193 
199 {
201  uint16_t endpoint_id;
207 
221 #define RDMNET_PHYSICAL_ENDPOINT_INIT(endpoint_num) \
222  { \
223  (endpoint_num), NULL, 0 \
224  }
225 
232 typedef struct RdmnetDeviceConfig
233 {
234  /************************************************************************************************
235  * Required Values
236  ***********************************************************************************************/
237 
242 
243  /************************************************************************************************
244  * Optional Values
245  ***********************************************************************************************/
246 
251  uint8_t* response_buf;
252 
258 
264  RdmUid uid;
265 
270  const char* search_domain;
271 
276 
282 
294 #define RDMNET_DEVICE_CONFIG_DEFAULT_INIT(manu_id) \
295  { \
296  {{0}}, {NULL, NULL, NULL, NULL, NULL, NULL, NULL}, NULL, RDMNET_SCOPE_CONFIG_DEFAULT_INIT, \
297  {(0x8000 | manu_id), 0}, NULL, NULL, 0, NULL, 0 \
298  }
299 
300 void rdmnet_device_config_init(RdmnetDeviceConfig* config, uint16_t manufacturer_id);
303  RdmnetDeviceConnectFailedCallback connect_failed,
305  RdmnetDeviceRdmCommandReceivedCallback rdm_command_received,
306  RdmnetDeviceLlrpRdmCommandReceivedCallback llrp_rdm_command_received,
307  RdmnetDeviceDynamicUidStatusCallback dynamic_uid_status_received,
308  void* context);
309 
312 
314  const RdmnetSavedRdmCommand* received_cmd,
315  const uint8_t* response_data,
316  size_t response_data_len);
318  const RdmnetSavedRdmCommand* received_cmd,
319  rdm_nack_reason_t nack_reason);
321  uint16_t subdevice,
322  uint16_t param_id,
323  const uint8_t* data,
324  size_t data_len);
326  const RdmnetSourceAddr* source_addr,
327  uint16_t param_id,
328  const uint8_t* data,
329  size_t data_len);
331  const RdmnetSavedRdmCommand* received_cmd,
332  rpt_status_code_t status_code,
333  const char* status_string);
334 
336  const LlrpSavedRdmCommand* received_cmd,
337  const uint8_t* response_data,
338  uint8_t response_data_len);
340  const LlrpSavedRdmCommand* received_cmd,
341  rdm_nack_reason_t nack_reason);
342 
344  const RdmnetPhysicalEndpointConfig* endpoint_config);
346  const RdmnetPhysicalEndpointConfig* endpoint_configs,
347  size_t num_endpoints);
349  const RdmnetVirtualEndpointConfig* endpoint_config);
351  const RdmnetVirtualEndpointConfig* endpoint_configs,
352  size_t num_endpoints);
353 etcpal_error_t rdmnet_device_remove_endpoint(rdmnet_device_t handle, uint16_t endpoint_id);
355  const uint16_t* endpoint_ids,
356  size_t num_endpoints);
357 
359  uint16_t endpoint_id,
360  const RdmUid* responder_uids,
361  size_t num_responders);
363  uint16_t endpoint_id,
364  const EtcPalUuid* responder_ids,
365  size_t num_responders);
367  uint16_t endpoint_id,
368  const RdmnetPhysicalEndpointResponder* responders,
369  size_t num_responders);
370 
372  uint16_t endpoint_id,
373  const RdmUid* responder_uids,
374  size_t num_responders);
376  uint16_t endpoint_id,
377  const EtcPalUuid* responder_ids,
378  size_t num_responders);
380  uint16_t endpoint_id,
381  const RdmUid* responder_uids,
382  size_t num_responders);
383 
385  const RdmnetScopeConfig* new_scope_config,
386  rdmnet_disconnect_reason_t disconnect_reason);
388  const char* new_search_domain,
389  rdmnet_disconnect_reason_t disconnect_reason);
390 etcpal_error_t rdmnet_device_get_scope(rdmnet_device_t handle, char* scope_str_buf, EtcPalSockAddr* static_broker_addr);
391 
392 #ifdef __cplusplus
393 };
394 #endif
395 
400 #endif /* RDMNET_DEVICE_H_ */
API definitions used by RDMnet clients (controllers and devices)
etcpal_error_t
rdmnet_disconnect_reason_t
Definition: common.h:85
rpt_status_code_t
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:74
etcpal_error_t rdmnet_device_remove_endpoint(rdmnet_device_t handle, uint16_t endpoint_id)
Remove an endpoint from a device.
Definition: device.c:698
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:776
etcpal_error_t rdmnet_device_destroy(rdmnet_device_t handle, rdmnet_disconnect_reason_t disconnect_reason)
Destroy a device instance.
Definition: device.c:266
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:328
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:1072
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:884
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:191
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:404
struct RdmnetDeviceCallbacks RdmnetDeviceCallbacks
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:1146
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:542
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:107
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:367
struct RdmnetPhysicalEndpointResponder RdmnetPhysicalEndpointResponder
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:581
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:934
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:659
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:620
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:510
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:1184
void(* RdmnetDeviceConnectedCallback)(rdmnet_device_t handle, const RdmnetClientConnectedInfo *info, void *context)
A device has successfully connected to a broker.
Definition: device.h:64
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:477
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:830
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:295
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:84
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:95
int rdmnet_device_t
Definition: device.h:54
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:165
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:125
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:1220
etcpal_error_t rdmnet_device_create(const RdmnetDeviceConfig *config, rdmnet_device_t *handle)
Create a new instance of RDMnet device functionality.
Definition: device.c:228
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:733
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:1009
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:443
Basic types for parsed RDMnet messages.
Definition: message.h:440
Definition: message.h:460
Definition: client.h:164
Definition: client.h:151
Definition: client.h:196
Definition: device.h:131
RdmnetDeviceLlrpRdmCommandReceivedCallback llrp_rdm_command_received
Definition: device.h:136
RdmnetDeviceConnectedCallback connected
Definition: device.h:132
RdmnetDeviceDynamicUidStatusCallback dynamic_uid_status_received
Definition: device.h:137
RdmnetDeviceConnectFailedCallback connect_failed
Definition: device.h:133
void * context
Definition: device.h:138
RdmnetDeviceDisconnectedCallback disconnected
Definition: device.h:134
RdmnetDeviceRdmCommandReceivedCallback rdm_command_received
Definition: device.h:135
A set of information that defines the startup parameters of an RDMnet Device.
Definition: device.h:233
size_t num_physical_endpoints
Definition: device.h:275
size_t num_virtual_endpoints
Definition: device.h:280
const RdmnetVirtualEndpointConfig * virtual_endpoints
Definition: device.h:278
EtcPalUuid cid
Definition: device.h:239
RdmnetScopeConfig scope_config
Definition: device.h:257
const RdmnetPhysicalEndpointConfig * physical_endpoints
Definition: device.h:273
const char * search_domain
Definition: device.h:270
uint8_t * response_buf
Definition: device.h:251
RdmnetDeviceCallbacks callbacks
Definition: device.h:241
RdmUid uid
Definition: device.h:264
Definition: message.h:246
Configuration information for a physical endpoint on a device.
Definition: device.h:199
size_t num_responders
Definition: device.h:205
const RdmnetPhysicalEndpointResponder * responders
Definition: device.h:203
uint16_t endpoint_id
Definition: device.h:201
Definition: device.h:182
RdmUid binding_uid
The binding UID received in the DISC_MUTE message from this responder.
Definition: device.h:191
RdmUid uid
Definition: device.h:184
uint16_t control_field
Definition: device.h:186
Definition: message.h:54
Definition: message.h:74
Definition: client.h:224
The source address for an unsolicited RDM response generated by a local component.
Definition: client.h:66
Definition: common.h:217
Configuration information for a virtual endpoint on a device.
Definition: device.h:146
const EtcPalUuid * dynamic_responders
An array of initial virtual RDM responders on this endpoint, identified by RID.
Definition: device.h:153
const RdmUid * static_responders
Definition: device.h:157
size_t num_static_responders
Definition: device.h:159
size_t num_dynamic_responders
Definition: device.h:155
uint16_t endpoint_id
Definition: device.h:148