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

OpenLightingProject / ola / 11783254300

11 Nov 2024 05:23PM UTC coverage: 45.767% (+0.09%) from 45.677%
11783254300

push

github

web-flow
Merge pull request #1978 from DMXControl/add_nodle_r4s

Add DMXControl Projects e.V. Nodle R4S

7798 of 17938 branches covered (43.47%)

0 of 1 new or added line in 1 file covered. (0.0%)

721 existing lines in 11 files now uncovered.

22344 of 48821 relevant lines covered (45.77%)

64.39 hits per line

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

22.55
/common/rdm/RDMAPI.cpp
1
/*
2
 * This library is free software; you can redistribute it and/or
3
 * modify it under the terms of the GNU Lesser General Public
4
 * License as published by the Free Software Foundation; either
5
 * version 2.1 of the License, or (at your option) any later version.
6
 *
7
 * This library 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 GNU
10
 * Lesser General Public License for more details.
11
 *
12
 * You should have received a copy of the GNU Lesser General Public
13
 * License along with this library; if not, write to the Free Software
14
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15
 *
16
 * RDMAPI.cpp
17
 * Provides a generic RDM API that can use different implementations.
18
 * Copyright (C) 2010 Simon Newton
19
 */
20

21
#include <stdint.h>
22
#include <string.h>
23
#include <algorithm>
24
#include <map>
25
#include <string>
26
#include <vector>
27
#include "ola/Callback.h"
28
#include "ola/Logging.h"
29
#include "ola/StringUtils.h"
30
#include "ola/base/Macro.h"
31
#include "ola/network/NetworkUtils.h"
32
#include "ola/rdm/RDMAPI.h"
33
#include "ola/rdm/RDMAPIImplInterface.h"
34
#include "ola/rdm/RDMEnums.h"
35
#include "ola/rdm/UID.h"
36
#include "ola/strings/Format.h"
37

38
namespace ola {
39
namespace rdm {
40

41
using std::map;
42
using std::string;
43
using std::vector;
44
using ola::SingleUseCallback1;
45
using ola::SingleUseCallback2;
46
using ola::SingleUseCallback4;
47
using ola::network::HostToNetwork;
48
using ola::network::NetworkToHost;
49
using ola::strings::IntToString;
50

51

52
/*
53
 * @brief Return the number of queues messages for a UID. Note that this is
54
 * cached on the client side so this number may not be correct.
55
 * @param uid the UID to fetch the outstanding message count for
56
 * @return the number of outstanding messages
57
 */
UNCOV
58
uint8_t RDMAPI::OutstandingMessagesCount(const UID &uid) {
×
59
  map<UID, uint8_t>::const_iterator iter = m_outstanding_messages.find(uid);
×
60

61
  if (iter == m_outstanding_messages.end())
×
62
    return 0;
UNCOV
63
  return iter->second;
×
64
}
65

66

67
/*
68
 * @brief Fetch a count of the proxied devices
69
 * @param universe the universe to perform the call on
70
 * @param uid the UID of the device to address this message to
71
 * @param callback the Callback to invoke when this request completes
72
 * @param error a pointer to a string which is set if an error occurs
73
 * @return false if an error occurred, true otherwise
74
 */
75
bool RDMAPI::GetProxiedDeviceCount(
3✔
76
    unsigned int universe,
77
    const UID &uid,
78
    SingleUseCallback3<void,
79
                       const ResponseStatus&,
80
                       uint16_t,
81
                       bool> *callback,
82
    string *error) {
83
  if (CheckCallback(error, callback))
3✔
UNCOV
84
    return false;
×
85
  if (CheckNotBroadcast(uid, error, callback))
3✔
86
    return false;
87

88
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
1✔
89
    this,
90
    &RDMAPI::_HandleGetProxiedDeviceCount,
91
    callback);
92
  return CheckReturnStatus(
1✔
93
      m_impl->RDMGet(cb,
1✔
94
                     universe,
95
                     uid,
96
                     ROOT_RDM_DEVICE,
97
                     PID_PROXIED_DEVICE_COUNT),
98
      error);
1✔
99
}
100

101

102
/*
103
 * @brief Fetch a list of the proxied devices
104
 * @param universe the universe to perform the call on
105
 * @param uid the UID of the device to address this message to
106
 * @param callback the Callback to invoke when this request completes
107
 * @param error a pointer to a string which is set if an error occurs
108
 * @return false if an error occurred, true otherwise
109
 */
110
bool RDMAPI::GetProxiedDevices(
3✔
111
    unsigned int universe,
112
    const UID &uid,
113
    SingleUseCallback2<void,
114
                       const ResponseStatus&,
115
                       const vector<UID>&> *callback,
116
    string *error) {
117
  if (CheckCallback(error, callback))
3✔
UNCOV
118
    return false;
×
119
  if (CheckNotBroadcast(uid, error, callback))
3✔
120
    return false;
121

122
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
1✔
123
    this,
124
    &RDMAPI::_HandleGetProxiedDevices,
125
    callback);
126
  return CheckReturnStatus(
1✔
127
      m_impl->RDMGet(cb,
1✔
128
                     universe,
129
                     uid,
130
                     ROOT_RDM_DEVICE,
131
                     PID_PROXIED_DEVICES),
132
      error);
1✔
133
}
134

135

136
/*
137
 * @brief Get the communication status report
138
 * @param universe the universe to perform the call on
139
 * @param uid the UID of the device to address this message to
140
 * @param callback the Callback to invoke when this request completes
141
 * @param error a pointer to a string which is set if an error occurs
142
 * @return false if an error occurred, true otherwise
143
 */
144
bool RDMAPI::GetCommStatus(
3✔
145
    unsigned int universe,
146
    const UID &uid,
147
    SingleUseCallback4<void,
148
                       const ResponseStatus&,
149
                       uint16_t,
150
                       uint16_t,
151
                       uint16_t> *callback,
152
    string *error) {
153
  if (CheckCallback(error, callback))
3✔
UNCOV
154
    return false;
×
155
  if (CheckNotBroadcast(uid, error, callback))
3✔
156
    return false;
157

158
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
1✔
159
    this,
160
    &RDMAPI::_HandleGetCommStatus,
161
    callback);
162
  return CheckReturnStatus(
1✔
163
      m_impl->RDMGet(cb,
1✔
164
                     universe,
165
                     uid,
166
                     ROOT_RDM_DEVICE,
167
                     PID_COMMS_STATUS),
168
      error);
1✔
169
}
170

171

172
/*
173
 * @brief Clear the Communication status
174
 * @param universe the universe to perform the call on
175
 * @param uid the UID of the device to address this message to
176
 * @param callback the Callback to invoke when this request completes
177
 * @param error a pointer to a string which is set if an error occurs
178
 * @return false if an error occurred, true otherwise
179
 */
180
bool RDMAPI::ClearCommStatus(
2✔
181
    unsigned int universe,
182
    const UID &uid,
183
    SingleUseCallback1<void, const ResponseStatus&> *callback,
184
    string *error) {
185
  if (CheckCallback(error, callback))
2✔
UNCOV
186
    return false;
×
187
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
2✔
188
    this,
189
    &RDMAPI::_HandleEmptyResponse,
190
    callback);
191
  return CheckReturnStatus(
2✔
192
      m_impl->RDMSet(cb,
2✔
193
                     universe,
194
                     uid,
195
                     ROOT_RDM_DEVICE,
196
                     PID_COMMS_STATUS),
197
      error);
2✔
198
}
199

200

201
/**
202
 * @brief Send a queued message request.
203
 */
UNCOV
204
bool RDMAPI::GetQueuedMessage(
×
205
        unsigned int universe,
206
        const UID &uid,
207
        rdm_status_type status_type,
208
        QueuedMessageHandler *handler,
209
        string *error) {
210
  if (!handler) {
×
211
    if (error)
×
UNCOV
212
      *error = "Callback is null, this is a programming error";
×
UNCOV
213
    return false;
×
214
  }
215

UNCOV
216
  RDMAPIImplInterface::rdm_pid_callback *cb = NewSingleCallback(
×
217
    this,
218
    &RDMAPI::_HandleQueuedMessage,
219
    handler);
220
  uint8_t type = status_type;
×
UNCOV
221
  return CheckReturnStatus(
×
UNCOV
222
      m_impl->RDMGet(cb,
×
223
                     universe,
224
                     uid,
225
                     ROOT_RDM_DEVICE,
226
                     PID_QUEUED_MESSAGE,
227
                     &type,
228
                     sizeof(type)),
229
      error);
230
}
231

232

233
/**
234
 * @brief Send a queued message request. When complete the callback will be run
235
 * and it's up to the caller to decode the message based on the PID.
236
 */
UNCOV
237
bool RDMAPI::GetQueuedMessage(
×
238
        unsigned int universe,
239
        const UID &uid,
240
        rdm_status_type status_type,
241
        SingleUseCallback3<void,
242
                           const ResponseStatus&,
243
                           uint16_t,
244
                           const string&> *callback,
245
        string *error) {
246
  if (CheckCallback(error, callback))
×
247
    return false;
×
248
  uint8_t type = status_type;
×
UNCOV
249
  return CheckReturnStatus(
×
UNCOV
250
      m_impl->RDMGet(callback,
×
251
                     universe,
252
                     uid,
253
                     ROOT_RDM_DEVICE,
254
                     PID_QUEUED_MESSAGE,
255
                     &type,
256
                     sizeof(type)),
257
      error);
258
}
259

260

261
/*
262
 * @brief Get the status information from a device
263
 * @param universe the universe to perform the call on
264
 * @param uid the UID of the device to address this message to
265
 * @param status_type the Status Type requested
266
 * @param callback the Callback to invoke when this request completes
267
 * @param error a pointer to a string which is set if an error occurs
268
 * @return false if an error occurred, true otherwise
269
 */
UNCOV
270
bool RDMAPI::GetStatusMessage(
×
271
    unsigned int universe,
272
    const UID &uid,
273
    rdm_status_type status_type,
274
    SingleUseCallback2<void,
275
                       const ResponseStatus&,
276
                       const vector<StatusMessage>&> *callback,
277
    string *error) {
278
  if (CheckCallback(error, callback))
×
UNCOV
279
    return false;
×
UNCOV
280
  if (CheckNotBroadcast(uid, error, callback))
×
281
    return false;
282

UNCOV
283
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
284
    this,
285
    &RDMAPI::_HandleGetStatusMessage,
286
    callback);
287
  uint8_t type = static_cast<uint8_t>(status_type);
×
UNCOV
288
  return CheckReturnStatus(
×
UNCOV
289
      m_impl->RDMGet(cb,
×
290
                     universe,
291
                     uid,
292
                     ROOT_RDM_DEVICE,
293
                     PID_STATUS_MESSAGES,
294
                     &type,
295
                     sizeof(type)),
296
      error);
297
}
298

299

300
/*
301
 * @brief Fetch the description for a status id
302
 * @param universe the universe to perform the call on
303
 * @param uid the UID of the device to address this message to
304
 * @param callback the callback to invoke when this request completes
305
 * @param error a pointer to a string which is set if an error occurs
306
 * @return true if the request is sent correctly, false otherwise
307
 */
308
bool RDMAPI::GetStatusIdDescription(
3✔
309
    unsigned int universe,
310
    const UID &uid,
311
    uint16_t status_id,
312
    SingleUseCallback2<void, const ResponseStatus&, const string&> *callback,
313
    string *error) {
314
  if (CheckCallback(error, callback))
3✔
UNCOV
315
    return false;
×
316
  if (CheckNotBroadcast(uid, error, callback))
3✔
317
    return false;
318

319
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
1✔
320
    this,
321
    &RDMAPI::_HandleLabelResponse,
322
    callback);
323
  status_id = HostToNetwork(status_id);
1✔
324
  return CheckReturnStatus(
1✔
325
      m_impl->RDMGet(cb,
1✔
326
                     universe,
327
                     uid,
328
                     ROOT_RDM_DEVICE,
329
                     PID_STATUS_ID_DESCRIPTION,
330
                     reinterpret_cast<const uint8_t*>(&status_id),
331
                     sizeof(status_id)),
332
      error);
1✔
333
}
334

335

336
/*
337
 * @brief Clear the status message queue
338
 * @param universe the universe to perform the call on
339
 * @param uid the UID of the device to address this message to
340
 * @param sub_device the sub device to use
341
 * @param callback the callback to invoke when this request completes
342
 * @param error a pointer to a string which is set if an error occurs
343
 * @return true if the request is sent correctly, false otherwise
344
 */
345
bool RDMAPI::ClearStatusId(
2✔
346
    unsigned int universe,
347
    const UID &uid,
348
    uint16_t sub_device,
349
    SingleUseCallback1<void, const ResponseStatus&> *callback,
350
    string *error) {
351
  if (CheckCallback(error, callback))
2✔
UNCOV
352
    return false;
×
353
  if (CheckValidSubDevice(sub_device, true, error, callback))
2✔
354
    return false;
355

356
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
2✔
357
    this,
358
    &RDMAPI::_HandleEmptyResponse,
359
    callback);
360
  return CheckReturnStatus(
2✔
361
      m_impl->RDMSet(cb,
2✔
362
                     universe,
363
                     uid,
364
                     sub_device,
365
                     PID_CLEAR_STATUS_ID),
366
      error);
2✔
367
}
368

369

370
/*
371
 * @brief Get the reporting threshold for a device
372
 * @param universe the universe to perform the call on
373
 * @param uid the UID of the device to address this message to
374
 * @param sub_device the sub device to use
375
 * @param callback the callback to invoke when this request completes
376
 * @param error a pointer to a string which is set if an error occurs
377
 * @return true if the request is sent correctly, false otherwise
378
 */
UNCOV
379
bool RDMAPI::GetSubDeviceReporting(
×
380
    unsigned int universe,
381
    const UID &uid,
382
    uint16_t sub_device,
383
    SingleUseCallback2<void,
384
                       const ResponseStatus&,
385
                       uint8_t> *callback,
386
    string *error) {
387
  if (CheckCallback(error, callback))
×
UNCOV
388
    return false;
×
389
  if (CheckNotBroadcast(uid, error, callback))
×
390
    return false;
UNCOV
391
  if (CheckValidSubDevice(sub_device, false, error, callback))
×
392
    return false;
393

UNCOV
394
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
395
    this,
396
    &RDMAPI::_HandleGetSubDeviceReporting,
397
    callback);
UNCOV
398
  return CheckReturnStatus(
×
UNCOV
399
      m_impl->RDMGet(cb,
×
400
                     universe,
401
                     uid,
402
                     sub_device,
403
                     PID_SUB_DEVICE_STATUS_REPORT_THRESHOLD),
UNCOV
404
      error);
×
405
}
406

407

408
/*
409
 * @brief Set the reporting threshold for a device
410
 * @param universe the universe to perform the call on
411
 * @param uid the UID of the device to address this message to
412
 * @param sub_device the sub device to use
413
 * @param status_type the Status Type to set the threshold as
414
 * @param callback the callback to invoke when this request completes
415
 * @param error a pointer to a string which is set if an error occurs
416
 * @return true if the request is sent correctly, false otherwise
417
 */
UNCOV
418
bool RDMAPI::SetSubDeviceReporting(
×
419
    unsigned int universe,
420
    const UID &uid,
421
    uint16_t sub_device,
422
    rdm_status_type status_type,
423
    SingleUseCallback1<void, const ResponseStatus&> *callback,
424
    string *error) {
425
  if (CheckCallback(error, callback))
×
UNCOV
426
    return false;
×
427
  if (CheckNotBroadcast(uid, error, callback))
×
428
    return false;
UNCOV
429
  if (CheckValidSubDevice(sub_device, true, error, callback))
×
430
    return false;
431

UNCOV
432
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
433
    this,
434
    &RDMAPI::_HandleEmptyResponse,
435
    callback);
436
  uint8_t type = static_cast<uint8_t>(status_type);
×
UNCOV
437
  return CheckReturnStatus(
×
UNCOV
438
      m_impl->RDMSet(cb,
×
439
                     universe,
440
                     uid,
441
                     ROOT_RDM_DEVICE,
442
                     PID_SUB_DEVICE_STATUS_REPORT_THRESHOLD,
443
                     &type,
444
                     sizeof(type)),
445
      error);
446
}
447

448

449
/*
450
 * @brief Fetch the supported parameters list
451
 * @param universe the universe to perform the call on
452
 * @param uid the UID of the device to address this message to
453
 * @param sub_device the sub device to use
454
 * @param callback the callback to invoke when this request completes
455
 * @param error a pointer to a string which is set if an error occurs
456
 * @return true if the request is sent correctly, false otherwise
457
 */
458
bool RDMAPI::GetSupportedParameters(
3✔
459
    unsigned int universe,
460
    const UID &uid,
461
    uint16_t sub_device,
462
    SingleUseCallback2<void,
463
                       const ResponseStatus&,
464
                       const vector<uint16_t>&> *callback,
465
    string *error) {
466
  if (CheckCallback(error, callback))
3✔
UNCOV
467
    return false;
×
468
  if (CheckNotBroadcast(uid, error, callback))
3✔
469
    return false;
470
  if (CheckValidSubDevice(sub_device, false, error, callback))
1✔
471
    return false;
472

473
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
1✔
474
    this,
475
    &RDMAPI::_HandleGetSupportedParameters,
476
    callback);
477
  return m_impl->RDMGet(cb,
1✔
478
                        universe,
479
                        uid,
480
                        sub_device,
481
                        PID_SUPPORTED_PARAMETERS);
1✔
482
}
483

484

485
/*
486
 * @brief Fetch the description of a param ID
487
 * @param universe the universe to perform the call on
488
 * @param uid the UID of the device to address this message to
489
 * @param pid the parameter id to fetch the description for
490
 * @param callback the callback to invoke when this request completes
491
 * @param error a pointer to a string which is set if an error occurs
492
 * @return true if the request is sent correctly, false otherwise
493
 */
494
bool RDMAPI::GetParameterDescription(
4✔
495
    unsigned int universe,
496
    const UID &uid,
497
    uint16_t pid,
498
    SingleUseCallback2<void,
499
                       const ResponseStatus&,
500
                       const ParameterDescriptor&> *callback,
501
    string *error) {
502
  if (CheckCallback(error, callback))
4✔
UNCOV
503
    return false;
×
504
  if (CheckNotBroadcast(uid, error, callback))
4✔
505
    return false;
506

507
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
2✔
508
    this,
509
    &RDMAPI::_HandleGetParameterDescriptor,
510
    callback);
511
  pid = HostToNetwork(pid);
2✔
512
  return CheckReturnStatus(
2✔
513
      m_impl->RDMGet(cb,
2✔
514
                     universe,
515
                     uid,
516
                     ROOT_RDM_DEVICE,
517
                     PID_PARAMETER_DESCRIPTION,
518
                     reinterpret_cast<const uint8_t*>(&pid),
519
                     sizeof(pid)),
520
      error);
2✔
521
}
522

523

524
/*
525
 * @brief Fetch the device information
526
 * @param universe the universe to perform the call on
527
 * @param uid the UID to fetch the outstanding message count for
528
 * @param sub_device the sub device to use
529
 * @param callback the callback to invoke when this request completes
530
 * @param error a pointer to a string which is set if an error occurs
531
 * @return true if the request is sent correctly, false otherwise
532
 */
533
bool RDMAPI::GetDeviceInfo(
3✔
534
    unsigned int universe,
535
    const UID &uid,
536
    uint16_t sub_device,
537
    SingleUseCallback2<void,
538
                       const ResponseStatus&,
539
                       const DeviceDescriptor&> *callback,
540
    string *error) {
541
  if (CheckCallback(error, callback))
3✔
UNCOV
542
    return false;
×
543
  if (CheckNotBroadcast(uid, error, callback))
3✔
544
    return false;
545
  if (CheckValidSubDevice(sub_device, false, error, callback))
1✔
546
    return false;
547

548
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
1✔
549
    this,
550
    &RDMAPI::_HandleGetDeviceDescriptor,
551
    callback);
552
  return CheckReturnStatus(
1✔
553
    m_impl->RDMGet(cb,
1✔
554
                   universe,
555
                   uid,
556
                   sub_device,
557
                   PID_DEVICE_INFO),
558
    error);
1✔
559
}
560

561

562
/*
563
 * @brief Fetch the product detail IDs.
564
 * @param universe the universe to perform the call on
565
 * @param uid the UID to fetch the outstanding message count for
566
 * @param sub_device the sub device to use
567
 * @param callback the callback to invoke when this request completes
568
 * @param error a pointer to a string which is set if an error occurs
569
 * @return true if the request is sent correctly, false otherwise
570
 */
571
bool RDMAPI::GetProductDetailIdList(
3✔
572
    unsigned int universe,
573
    const UID &uid,
574
    uint16_t sub_device,
575
    SingleUseCallback2<void,
576
                       const ResponseStatus&,
577
                       const vector<uint16_t>&> *callback,
578
    string *error) {
579
  if (CheckCallback(error, callback))
3✔
UNCOV
580
    return false;
×
581
  if (CheckNotBroadcast(uid, error, callback))
3✔
582
    return false;
583
  if (CheckValidSubDevice(sub_device, false, error, callback))
1✔
584
    return false;
585

586
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
1✔
587
    this,
588
    &RDMAPI::_HandleGetProductDetailIdList,
589
    callback);
590
  return CheckReturnStatus(
1✔
591
    m_impl->RDMGet(cb,
1✔
592
                   universe,
593
                   uid,
594
                   sub_device,
595
                   PID_PRODUCT_DETAIL_ID_LIST),
596
    error);
1✔
597
}
598

599

600
/*
601
 * @brief Fetch the description for a device model.
602
 * @param universe the universe to perform the call on
603
 * @param uid the UID to fetch the outstanding message count for
604
 * @param sub_device the sub device to use
605
 * @param callback the callback to invoke when this request completes
606
 * @param error a pointer to a string which is set if an error occurs
607
 * @return true if the request is sent correctly, false otherwise
608
 */
609
bool RDMAPI::GetDeviceModelDescription(
3✔
610
    unsigned int universe,
611
    const UID &uid,
612
    uint16_t sub_device,
613
    SingleUseCallback2<void,
614
                       const ResponseStatus&,
615
                       const string&> *callback,
616
    string *error) {
617
  if (CheckCallback(error, callback))
3✔
UNCOV
618
    return false;
×
619
  if (CheckNotBroadcast(uid, error, callback))
3✔
620
    return false;
621
  if (CheckValidSubDevice(sub_device, false, error, callback))
1✔
622
    return false;
623

624
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
1✔
625
    this,
626
    &RDMAPI::_HandleLabelResponse,
627
    callback);
628
  return CheckReturnStatus(
1✔
629
    m_impl->RDMGet(cb,
1✔
630
                   universe,
631
                   uid,
632
                   sub_device,
633
                   PID_DEVICE_MODEL_DESCRIPTION),
634
    error);
1✔
635
}
636

637

638
/*
639
 * @brief Fetch the manufacturer label for a device
640
 * @param universe the universe to perform the call on
641
 * @param uid the UID to fetch the outstanding message count for
642
 * @param sub_device the sub device to use
643
 * @param callback the callback to invoke when this request completes
644
 * @param error a pointer to a string which is set if an error occurs
645
 * @return true if the request is sent correctly, false otherwise
646
 */
647
bool RDMAPI::GetManufacturerLabel(
3✔
648
    unsigned int universe,
649
    const UID &uid,
650
    uint16_t sub_device,
651
    SingleUseCallback2<void,
652
                       const ResponseStatus&,
653
                       const string&> *callback,
654
    string *error) {
655
  if (CheckCallback(error, callback))
3✔
UNCOV
656
    return false;
×
657
  if (CheckNotBroadcast(uid, error, callback))
3✔
658
    return false;
659
  if (CheckValidSubDevice(sub_device, false, error, callback))
1✔
660
    return false;
661

662
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
1✔
663
    this,
664
    &RDMAPI::_HandleLabelResponse,
665
    callback);
666
  return CheckReturnStatus(
1✔
667
    m_impl->RDMGet(cb,
1✔
668
                   universe,
669
                   uid,
670
                   sub_device,
671
                   PID_MANUFACTURER_LABEL),
672
    error);
1✔
673
}
674

675

676
/*
677
 * @brief Fetch the device label
678
 * @param universe the universe to perform the call on
679
 * @param uid the UID to fetch the outstanding message count for
680
 * @param sub_device the sub device to use
681
 * @param callback the callback to invoke when this request completes
682
 * @param error a pointer to a string which is set if an error occurs
683
 * @return true if the request is sent correctly, false otherwise
684
 */
685
bool RDMAPI::GetDeviceLabel(
3✔
686
    unsigned int universe,
687
    const UID &uid,
688
    uint16_t sub_device,
689
    SingleUseCallback2<void,
690
                       const ResponseStatus&,
691
                       const string&> *callback,
692
    string *error) {
693
  if (CheckCallback(error, callback))
3✔
UNCOV
694
    return false;
×
695
  if (CheckNotBroadcast(uid, error, callback))
3✔
696
    return false;
697
  if (CheckValidSubDevice(sub_device, false, error, callback))
1✔
698
    return false;
699

700
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
1✔
701
    this,
702
    &RDMAPI::_HandleLabelResponse,
703
    callback);
704
  return CheckReturnStatus(
1✔
705
    m_impl->RDMGet(cb,
1✔
706
                   universe,
707
                   uid,
708
                   sub_device,
709
                   PID_DEVICE_LABEL),
710
    error);
1✔
711
}
712

713

714
/*
715
 * @brief Set the device label
716
 * @param universe the universe to perform the call on
717
 * @param uid the UID to fetch the outstanding message count for
718
 * @param sub_device the sub device to use
719
 * @param callback the callback to invoke when this request completes
720
 * @param error a pointer to a string which is set if an error occurs
721
 * @return true if the request is sent correctly, false otherwise
722
 */
723
bool RDMAPI::SetDeviceLabel(
4✔
724
    unsigned int universe,
725
    const UID &uid,
726
    uint16_t sub_device,
727
    const string &label,
728
    SingleUseCallback1<void, const ResponseStatus&> *callback,
729
    string *error) {
730
  if (CheckCallback(error, callback))
4✔
UNCOV
731
    return false;
×
732
  // It doesn't really make sense to broadcast this but allow it anyway
733
  if (CheckValidSubDevice(sub_device, true, error, callback))
4✔
734
    return false;
735

736
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
3✔
737
    this,
738
    &RDMAPI::_HandleEmptyResponse,
739
    callback);
740
  return CheckReturnStatus(
3✔
741
    m_impl->RDMSet(cb,
3✔
742
                   universe,
743
                   uid,
744
                   sub_device,
745
                   PID_DEVICE_LABEL,
746
                   reinterpret_cast<const uint8_t*>(label.data()),
3✔
747
                   label.size()),
3✔
748
    error);
3✔
749
}
750

751

752
/*
753
 * @brief Check if a device is using the factory defaults
754
 * @param universe the universe to perform the call on
755
 * @param uid the UID to fetch the outstanding message count for
756
 * @param sub_device the sub device to use
757
 * @param callback the callback to invoke when this request completes
758
 * @param error a pointer to a string which is set if an error occurs
759
 * @return true if the request is sent correctly, false otherwise
760
 */
UNCOV
761
bool RDMAPI::GetFactoryDefaults(
×
762
    unsigned int universe,
763
    const UID &uid,
764
    uint16_t sub_device,
765
    SingleUseCallback2<void,
766
                       const ResponseStatus&,
767
                       bool> *callback,
768
    string *error) {
769
  if (CheckCallback(error, callback))
×
UNCOV
770
    return false;
×
771
  if (CheckNotBroadcast(uid, error, callback))
×
772
    return false;
UNCOV
773
  if (CheckValidSubDevice(sub_device, false, error, callback))
×
774
    return false;
775

UNCOV
776
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
777
    this,
778
    &RDMAPI::_HandleBoolResponse,
779
    callback);
UNCOV
780
  return CheckReturnStatus(
×
UNCOV
781
    m_impl->RDMGet(cb,
×
782
                   universe,
783
                   uid,
784
                   sub_device,
785
                   PID_FACTORY_DEFAULTS),
UNCOV
786
    error);
×
787
}
788

789

790
/*
791
 * @brief Reset a device to factory defaults
792
 * @param universe the universe to perform the call on
793
 * @param uid the UID to fetch the outstanding message count for
794
 * @param sub_device the sub device to use
795
 * @param callback the callback to invoke when this request completes
796
 * @param error a pointer to a string which is set if an error occurs
797
 * @return true if the request is sent correctly, false otherwise
798
 */
UNCOV
799
bool RDMAPI::ResetToFactoryDefaults(
×
800
    unsigned int universe,
801
    const UID &uid,
802
    uint16_t sub_device,
803
    SingleUseCallback1<void, const ResponseStatus&> *callback,
804
    string *error) {
805
  if (CheckCallback(error, callback))
×
UNCOV
806
    return false;
×
807
  if (CheckNotBroadcast(uid, error, callback))
×
808
    return false;
UNCOV
809
  if (CheckValidSubDevice(sub_device, true, error, callback))
×
810
    return false;
811

UNCOV
812
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
813
    this,
814
    &RDMAPI::_HandleEmptyResponse,
815
    callback);
UNCOV
816
  return CheckReturnStatus(
×
UNCOV
817
    m_impl->RDMSet(cb,
×
818
                   universe,
819
                   uid,
820
                   sub_device,
821
                   PID_FACTORY_DEFAULTS),
UNCOV
822
    error);
×
823
}
824

825

826
/*
827
 * @brief Get the list of languages this device supports
828
 * @param universe the universe to perform the call on
829
 * @param uid the UID to fetch the outstanding message count for
830
 * @param sub_device the sub device to use
831
 * @param callback the callback to invoke when this request completes
832
 * @param error a pointer to a string which is set if an error occurs
833
 * @return true if the request is sent correctly, false otherwise
834
 */
UNCOV
835
bool RDMAPI::GetLanguageCapabilities(
×
836
    unsigned int universe,
837
    const UID &uid,
838
    uint16_t sub_device,
839
    SingleUseCallback2<void,
840
                       const ResponseStatus&,
841
                       const vector<string>&> *callback,
842
    string *error) {
843
  if (CheckCallback(error, callback))
×
UNCOV
844
    return false;
×
845
  if (CheckNotBroadcast(uid, error, callback))
×
846
    return false;
UNCOV
847
  if (CheckValidSubDevice(sub_device, false, error, callback))
×
848
    return false;
849

UNCOV
850
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
851
    this,
852
    &RDMAPI::_HandleGetLanguageCapabilities,
853
    callback);
UNCOV
854
  return CheckReturnStatus(
×
UNCOV
855
    m_impl->RDMGet(cb,
×
856
                   universe,
857
                   uid,
858
                   sub_device,
859
                   PID_LANGUAGE_CAPABILITIES),
UNCOV
860
    error);
×
861
}
862

863

864
/*
865
 * @brief Get the language for this device
866
 * @param universe the universe to perform the call on
867
 * @param uid the UID to fetch the outstanding message count for
868
 * @param sub_device the sub device to use
869
 * @param callback the callback to invoke when this request completes
870
 * @param error a pointer to a string which is set if an error occurs
871
 * @return true if the request is sent correctly, false otherwise
872
 */
UNCOV
873
bool RDMAPI::GetLanguage(
×
874
    unsigned int universe,
875
    const UID &uid,
876
    uint16_t sub_device,
877
    SingleUseCallback2<void,
878
                       const ResponseStatus&,
879
                       const string&> *callback,
880
    string *error) {
881
  if (CheckCallback(error, callback))
×
UNCOV
882
    return false;
×
883
  if (CheckNotBroadcast(uid, error, callback))
×
884
    return false;
UNCOV
885
  if (CheckValidSubDevice(sub_device, false, error, callback))
×
886
    return false;
887

UNCOV
888
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
889
    this,
890
    &RDMAPI::_HandleGetLanguage,
891
    callback);
UNCOV
892
  return CheckReturnStatus(
×
UNCOV
893
    m_impl->RDMGet(cb,
×
894
                   universe,
895
                   uid,
896
                   sub_device,
897
                   PID_LANGUAGE),
UNCOV
898
    error);
×
899
}
900

901

902
/*
903
 * @brief Set the language for this device
904
 * @param universe the universe to perform the call on
905
 * @param uid the UID to fetch the outstanding message count for
906
 * @param sub_device the sub device to use
907
 * @param language the language code, only the first two characters are used
908
 * @param callback the callback to invoke when this request completes
909
 * @param error a pointer to a string which is set if an error occurs
910
 * @return true if the request is sent correctly, false otherwise
911
 */
UNCOV
912
bool RDMAPI::SetLanguage(
×
913
    unsigned int universe,
914
    const UID &uid,
915
    uint16_t sub_device,
916
    const string &language,
917
    SingleUseCallback1<void, const ResponseStatus&> *callback,
918
    string *error) {
919
  static const unsigned int DATA_SIZE = 2;
×
920
  if (CheckCallback(error, callback))
×
UNCOV
921
    return false;
×
UNCOV
922
  if (CheckValidSubDevice(sub_device, true, error, callback))
×
923
    return false;
924

925
  if (language.size() != DATA_SIZE) {
×
926
    if (error)
×
927
      *error = "Language must be a two letter code";
×
UNCOV
928
    delete callback;
×
UNCOV
929
    return false;
×
930
  }
931

UNCOV
932
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
933
    this,
934
    &RDMAPI::_HandleEmptyResponse,
935
    callback);
UNCOV
936
  return CheckReturnStatus(
×
UNCOV
937
    m_impl->RDMSet(cb,
×
938
                   universe,
939
                   uid,
940
                   sub_device,
941
                   PID_LANGUAGE,
942
                   reinterpret_cast<const uint8_t*>(language.data()),
×
943
                   DATA_SIZE),
UNCOV
944
    error);
×
945
}
946

947

948
/*
949
 * @brief Get the software version label
950
 * @param universe the universe to perform the call on
951
 * @param uid the UID to fetch the outstanding message count for
952
 * @param sub_device the sub device to use
953
 * @param callback the callback to invoke when this request completes
954
 * @param error a pointer to a string which is set if an error occurs
955
 * @return true if the request is sent correctly, false otherwise
956
 */
957
bool RDMAPI::GetSoftwareVersionLabel(
3✔
958
    unsigned int universe,
959
    const UID &uid,
960
    uint16_t sub_device,
961
    SingleUseCallback2<void,
962
                       const ResponseStatus&,
963
                       const string&> *callback,
964
    string *error) {
965
  if (CheckCallback(error, callback))
3✔
UNCOV
966
    return false;
×
967
  if (CheckNotBroadcast(uid, error, callback))
3✔
968
    return false;
969
  if (CheckValidSubDevice(sub_device, false, error, callback))
1✔
970
    return false;
971

972
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
1✔
973
    this,
974
    &RDMAPI::_HandleLabelResponse,
975
    callback);
976
  return CheckReturnStatus(
1✔
977
    m_impl->RDMGet(cb,
1✔
978
                   universe,
979
                   uid,
980
                   sub_device,
981
                   PID_SOFTWARE_VERSION_LABEL),
982
    error);
1✔
983
}
984

985

986
/*
987
 * @brief Get the boot software version.
988
 * @param universe the universe to perform the call on
989
 * @param uid the UID to fetch the outstanding message count for
990
 * @param sub_device the sub device to use
991
 * @param callback the callback to invoke when this request completes
992
 * @param error a pointer to a string which is set if an error occurs
993
 * @return true if the request is sent correctly, false otherwise
994
 */
UNCOV
995
bool RDMAPI::GetBootSoftwareVersion(
×
996
    unsigned int universe,
997
    const UID &uid,
998
    uint16_t sub_device,
999
    SingleUseCallback2<void,
1000
                       const ResponseStatus&,
1001
                       uint32_t> *callback,
1002
    string *error) {
1003
  if (CheckCallback(error, callback))
×
UNCOV
1004
    return false;
×
1005
  if (CheckNotBroadcast(uid, error, callback))
×
1006
    return false;
UNCOV
1007
  if (CheckValidSubDevice(sub_device, false, error, callback))
×
1008
    return false;
1009

UNCOV
1010
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
1011
    this,
1012
    &RDMAPI::_HandleGetBootSoftwareVersion,
1013
    callback);
UNCOV
1014
  return CheckReturnStatus(
×
UNCOV
1015
    m_impl->RDMGet(cb,
×
1016
                   universe,
1017
                   uid,
1018
                   sub_device,
1019
                   PID_BOOT_SOFTWARE_VERSION_ID),
UNCOV
1020
    error);
×
1021
}
1022

1023

1024
/*
1025
 * @brief Get the boot software version label
1026
 * @param universe the universe to perform the call on
1027
 * @param uid the UID to fetch the outstanding message count for
1028
 * @param sub_device the sub device to use
1029
 * @param callback the callback to invoke when this request completes
1030
 * @param error a pointer to a string which is set if an error occurs
1031
 * @return true if the request is sent correctly, false otherwise
1032
 */
1033
bool RDMAPI::GetBootSoftwareVersionLabel(
3✔
1034
    unsigned int universe,
1035
    const UID &uid,
1036
    uint16_t sub_device,
1037
    SingleUseCallback2<void,
1038
                       const ResponseStatus&,
1039
                       const string&> *callback,
1040
    string *error) {
1041
  if (CheckCallback(error, callback))
3✔
UNCOV
1042
    return false;
×
1043
  if (CheckNotBroadcast(uid, error, callback))
3✔
1044
    return false;
1045
  if (CheckValidSubDevice(sub_device, false, error, callback))
1✔
1046
    return false;
1047

1048
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
1✔
1049
    this,
1050
    &RDMAPI::_HandleLabelResponse,
1051
    callback);
1052
  return CheckReturnStatus(
1✔
1053
    m_impl->RDMGet(cb,
1✔
1054
                   universe,
1055
                   uid,
1056
                   sub_device,
1057
                   PID_BOOT_SOFTWARE_VERSION_LABEL),
1058
    error);
1✔
1059
}
1060

1061

1062
/*
1063
 * @brief Get the current DMX personality
1064
 * @param universe the universe to perform the call on
1065
 * @param uid the UID to fetch the outstanding message count for
1066
 * @param sub_device the sub device to use
1067
 * @param callback the callback to invoke when this request completes
1068
 * @param error a pointer to a string which is set if an error occurs
1069
 * @return true if the request is sent correctly, false otherwise
1070
 */
UNCOV
1071
bool RDMAPI::GetDMXPersonality(
×
1072
    unsigned int universe,
1073
    const UID &uid,
1074
    uint16_t sub_device,
1075
    SingleUseCallback3<void,
1076
                       const ResponseStatus&,
1077
                       uint8_t,
1078
                       uint8_t> *callback,
1079
    string *error) {
1080
  if (CheckCallback(error, callback))
×
UNCOV
1081
    return false;
×
1082
  if (CheckNotBroadcast(uid, error, callback))
×
1083
    return false;
UNCOV
1084
  if (CheckValidSubDevice(sub_device, false, error, callback))
×
1085
    return false;
1086

UNCOV
1087
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
1088
    this,
1089
    &RDMAPI::_HandleGetDMXPersonality,
1090
    callback);
UNCOV
1091
  return CheckReturnStatus(
×
UNCOV
1092
    m_impl->RDMGet(cb,
×
1093
                   universe,
1094
                   uid,
1095
                   sub_device,
1096
                   PID_DMX_PERSONALITY),
UNCOV
1097
    error);
×
1098
}
1099

1100

1101
/*
1102
 * @brief Set the DMX personality
1103
 * @param universe the universe to perform the call on
1104
 * @param uid the UID to fetch the outstanding message count for
1105
 * @param sub_device the sub device to use
1106
 * @param personality the value of the personality to choose
1107
 * @param callback the callback to invoke when this request completes
1108
 * @param error a pointer to a string which is set if an error occurs
1109
 * @return true if the request is sent correctly, false otherwise
1110
 */
UNCOV
1111
bool RDMAPI::SetDMXPersonality(
×
1112
    unsigned int universe,
1113
    const UID &uid,
1114
    uint16_t sub_device,
1115
    uint8_t personality,
1116
    SingleUseCallback1<void, const ResponseStatus&> *callback,
1117
    string *error) {
1118
  if (CheckCallback(error, callback))
×
UNCOV
1119
    return false;
×
UNCOV
1120
  if (CheckValidSubDevice(sub_device, true, error, callback))
×
1121
    return false;
1122

UNCOV
1123
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
1124
    this,
1125
    &RDMAPI::_HandleEmptyResponse,
1126
    callback);
UNCOV
1127
  return CheckReturnStatus(
×
UNCOV
1128
    m_impl->RDMSet(cb,
×
1129
                   universe,
1130
                   uid,
1131
                   sub_device,
1132
                   PID_DMX_PERSONALITY,
1133
                   &personality,
1134
                   sizeof(personality)),
UNCOV
1135
    error);
×
1136
}
1137

1138

1139
/*
1140
 * @brief Get the description for a DMX personality
1141
 * @param universe the universe to perform the call on
1142
 * @param uid the UID to fetch the outstanding message count for
1143
 * @param sub_device the sub device to use
1144
 * @param personality the value of the personality to get the description of
1145
 * @param callback the callback to invoke when this request completes
1146
 * @param error a pointer to a string which is set if an error occurs
1147
 * @return true if the request is sent correctly, false otherwise
1148
 */
UNCOV
1149
bool RDMAPI::GetDMXPersonalityDescription(
×
1150
    unsigned int universe,
1151
    const UID &uid,
1152
    uint16_t sub_device,
1153
    uint8_t personality,
1154
    SingleUseCallback4<void,
1155
                       const ResponseStatus&,
1156
                       uint8_t,
1157
                       uint16_t,
1158
                       const string&> *callback,
1159
    string *error) {
1160
  if (CheckCallback(error, callback))
×
UNCOV
1161
    return false;
×
1162
  if (CheckNotBroadcast(uid, error, callback))
×
1163
    return false;
UNCOV
1164
  if (CheckValidSubDevice(sub_device, false, error, callback))
×
1165
    return false;
1166

UNCOV
1167
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
1168
    this,
1169
    &RDMAPI::_HandleGetDMXPersonalityDescription,
1170
    callback);
UNCOV
1171
  return CheckReturnStatus(
×
UNCOV
1172
    m_impl->RDMGet(cb,
×
1173
                   universe,
1174
                   uid,
1175
                   sub_device,
1176
                   PID_DMX_PERSONALITY_DESCRIPTION,
1177
                   &personality,
1178
                   sizeof(personality)),
UNCOV
1179
    error);
×
1180
}
1181

1182

1183
/*
1184
 * @brief Get the DMX start address
1185
 * @param universe the universe to perform the call on
1186
 * @param uid the UID to fetch the outstanding message count for
1187
 * @param sub_device the sub device to use
1188
 * @param callback the callback to invoke when this request completes
1189
 * @param error a pointer to a string which is set if an error occurs
1190
 * @return true if the request is sent correctly, false otherwise
1191
 */
1192
bool RDMAPI::GetDMXAddress(
3✔
1193
    unsigned int universe,
1194
    const UID &uid,
1195
    uint16_t sub_device,
1196
    SingleUseCallback2<void,
1197
                       const ResponseStatus&,
1198
                       uint16_t> *callback,
1199
    string *error) {
1200

1201
  return GenericGetU16(
3✔
1202
    universe,
1203
    uid,
1204
    sub_device,
1205
    callback,
1206
    PID_DMX_START_ADDRESS,
1207
    error);
3✔
1208
}
1209

1210

1211
/*
1212
 * @brief Set the DMX start address
1213
 * @param universe the universe to perform the call on
1214
 * @param uid the UID to fetch the outstanding message count for
1215
 * @param sub_device the sub device to use
1216
 * @param start_address the new start address
1217
 * @param callback the callback to invoke when this request completes
1218
 * @param error a pointer to a string which is set if an error occurs
1219
 * @return true if the request is sent correctly, false otherwise
1220
 */
1221
bool RDMAPI::SetDMXAddress(
4✔
1222
    unsigned int universe,
1223
    const UID &uid,
1224
    uint16_t sub_device,
1225
    uint16_t start_address,
1226
    SingleUseCallback1<void, const ResponseStatus&> *callback,
1227
    string *error) {
1228

1229
  return GenericSetU16(
4✔
1230
    universe,
1231
    uid,
1232
    sub_device,
1233
    start_address,
1234
    callback,
1235
    PID_DMX_START_ADDRESS,
1236
    error);
4✔
1237
}
1238

1239

1240
/*
1241
 * @brief Fetch the DMX slot info
1242
 * @param universe the universe to perform the call on
1243
 * @param uid the UID to fetch the outstanding message count for
1244
 * @param sub_device the sub device to use
1245
 * @param callback the callback to invoke when this request completes
1246
 * @param error a pointer to a string which is set if an error occurs
1247
 * @return true if the request is sent correctly, false otherwise
1248
 */
UNCOV
1249
bool RDMAPI::GetSlotInfo(
×
1250
    unsigned int universe,
1251
    const UID &uid,
1252
    uint16_t sub_device,
1253
    SingleUseCallback2<void,
1254
                       const ResponseStatus&,
1255
                       const vector<SlotDescriptor>&> *callback,
1256
    string *error) {
1257
  if (CheckCallback(error, callback))
×
UNCOV
1258
    return false;
×
1259
  if (CheckNotBroadcast(uid, error, callback))
×
1260
    return false;
UNCOV
1261
  if (CheckValidSubDevice(sub_device, false, error, callback))
×
1262
    return false;
1263

UNCOV
1264
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
1265
    this,
1266
    &RDMAPI::_HandleGetSlotInfo,
1267
    callback);
UNCOV
1268
  return CheckReturnStatus(
×
UNCOV
1269
    m_impl->RDMGet(cb,
×
1270
                   universe,
1271
                   uid,
1272
                   sub_device,
1273
                   PID_SLOT_INFO),
UNCOV
1274
    error);
×
1275
}
1276

1277

1278
/*
1279
 * @brief Fetch a DMX slot description
1280
 * @param universe the universe to perform the call on
1281
 * @param uid the UID to fetch the outstanding message count for
1282
 * @param sub_device the sub device to use
1283
 * @param slot_offset the offset of the slot to get the description of
1284
 * @param callback the callback to invoke when this request completes
1285
 * @param error a pointer to a string which is set if an error occurs
1286
 * @return true if the request is sent correctly, false otherwise
1287
 */
UNCOV
1288
bool RDMAPI::GetSlotDescription(
×
1289
    unsigned int universe,
1290
    const UID &uid,
1291
    uint16_t sub_device,
1292
    uint16_t slot_offset,
1293
    SingleUseCallback3<void,
1294
                       const ResponseStatus&,
1295
                       uint16_t,
1296
                       const string&> *callback,
1297
    string *error) {
1298
  if (CheckCallback(error, callback))
×
UNCOV
1299
    return false;
×
1300
  if (CheckNotBroadcast(uid, error, callback))
×
1301
    return false;
UNCOV
1302
  if (CheckValidSubDevice(sub_device, false, error, callback))
×
1303
    return false;
1304

UNCOV
1305
  slot_offset = HostToNetwork(slot_offset);
×
UNCOV
1306
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
1307
    this,
1308
    &RDMAPI::_HandleGetSlotDescription,
1309
    callback);
UNCOV
1310
  return CheckReturnStatus(
×
UNCOV
1311
    m_impl->RDMGet(cb,
×
1312
                   universe,
1313
                   uid,
1314
                   sub_device,
1315
                   PID_SLOT_DESCRIPTION,
1316
                   reinterpret_cast<const uint8_t*>(&slot_offset),
1317
                   sizeof(slot_offset)),
UNCOV
1318
    error);
×
1319
}
1320

1321

1322
/*
1323
 * @brief Get the default value for a slot
1324
 * @param universe the universe to perform the call on
1325
 * @param uid the UID to fetch the outstanding message count for
1326
 * @param sub_device the sub device to use
1327
 * @param callback the callback to invoke when this request completes
1328
 * @param error a pointer to a string which is set if an error occurs
1329
 * @return true if the request is sent correctly, false otherwise
1330
 */
UNCOV
1331
bool RDMAPI::GetSlotDefaultValues(
×
1332
    unsigned int universe,
1333
    const UID &uid,
1334
    uint16_t sub_device,
1335
    SingleUseCallback2<void,
1336
                       const ResponseStatus&,
1337
                       const vector<SlotDefault>&> *callback,
1338
    string *error) {
1339
  if (CheckCallback(error, callback))
×
UNCOV
1340
    return false;
×
1341
  if (CheckNotBroadcast(uid, error, callback))
×
1342
    return false;
UNCOV
1343
  if (CheckValidSubDevice(sub_device, false, error, callback))
×
1344
    return false;
1345

UNCOV
1346
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
1347
    this,
1348
    &RDMAPI::_HandleGetSlotDefaultValues,
1349
    callback);
UNCOV
1350
  return CheckReturnStatus(
×
UNCOV
1351
    m_impl->RDMGet(cb,
×
1352
                   universe,
1353
                   uid,
1354
                   sub_device,
1355
                   PID_DEFAULT_SLOT_VALUE),
UNCOV
1356
    error);
×
1357
}
1358

1359

1360
/*
1361
 * @brief Get the definition for a sensor
1362
 * @param universe the universe to perform the call on
1363
 * @param uid the UID to fetch the outstanding message count for
1364
 * @param sub_device the sub device to use
1365
 * @param sensor_number the sensor index to get the descriptor for
1366
 * @param callback the callback to invoke when this request completes
1367
 * @param error a pointer to a string which is set if an error occurs
1368
 * @return true if the request is sent correctly, false otherwise
1369
 */
UNCOV
1370
bool RDMAPI::GetSensorDefinition(
×
1371
    unsigned int universe,
1372
    const UID &uid,
1373
    uint16_t sub_device,
1374
    uint8_t sensor_number,
1375
    SingleUseCallback2<void,
1376
                       const ResponseStatus&,
1377
                       const SensorDescriptor&> *callback,
1378
    string *error) {
1379
  if (CheckCallback(error, callback))
×
UNCOV
1380
    return false;
×
1381
  if (CheckNotBroadcast(uid, error, callback))
×
1382
    return false;
UNCOV
1383
  if (CheckValidSubDevice(sub_device, false, error, callback))
×
1384
    return false;
1385

UNCOV
1386
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
1387
    this,
1388
    &RDMAPI::_HandleGetSensorDefinition,
1389
    callback);
UNCOV
1390
  return CheckReturnStatus(
×
UNCOV
1391
    m_impl->RDMGet(cb,
×
1392
                   universe,
1393
                   uid,
1394
                   sub_device,
1395
                   PID_SENSOR_DEFINITION,
1396
                   &sensor_number,
1397
                   sizeof(sensor_number)),
UNCOV
1398
    error);
×
1399
}
1400

1401

1402
/*
1403
 * @brief Get the value of a sensor
1404
 * @param universe the universe to perform the call on
1405
 * @param uid the UID to fetch the outstanding message count for
1406
 * @param sub_device the sub device to use
1407
 * @param sensor_number the sensor index to get the value of
1408
 * @param callback the callback to invoke when this request completes
1409
 * @param error a pointer to a string which is set if an error occurs
1410
 * @return true if the request is sent correctly, false otherwise
1411
 */
UNCOV
1412
bool RDMAPI::GetSensorValue(
×
1413
    unsigned int universe,
1414
    const UID &uid,
1415
    uint16_t sub_device,
1416
    uint8_t sensor_number,
1417
    SingleUseCallback2<void,
1418
                       const ResponseStatus&,
1419
                       const SensorValueDescriptor&> *callback,
1420
    string *error) {
1421
  if (CheckCallback(error, callback))
×
UNCOV
1422
    return false;
×
1423
  if (CheckNotBroadcast(uid, error, callback))
×
1424
    return false;
UNCOV
1425
  if (CheckValidSubDevice(sub_device, false, error, callback))
×
1426
    return false;
1427

UNCOV
1428
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
1429
    this,
1430
    &RDMAPI::_HandleSensorValue,
1431
    callback);
UNCOV
1432
  return CheckReturnStatus(
×
UNCOV
1433
    m_impl->RDMGet(cb,
×
1434
                   universe,
1435
                   uid,
1436
                   sub_device,
1437
                   PID_SENSOR_VALUE,
1438
                   &sensor_number,
1439
                   sizeof(sensor_number)),
UNCOV
1440
    error);
×
1441
}
1442

1443

1444
/*
1445
 * @brief Reset a sensor
1446
 * @param universe the universe to perform the call on
1447
 * @param uid the UID to fetch the outstanding message count for
1448
 * @param sub_device the sub device to use
1449
 * @param sensor_number the sensor index to reset
1450
 * @param callback the callback to invoke when this request completes
1451
 * @param error a pointer to a string which is set if an error occurs
1452
 * @return true if the request is sent correctly, false otherwise
1453
 */
UNCOV
1454
bool RDMAPI::SetSensorValue(
×
1455
    unsigned int universe,
1456
    const UID &uid,
1457
    uint16_t sub_device,
1458
    uint8_t sensor_number,
1459
    SingleUseCallback2<void,
1460
                       const ResponseStatus&,
1461
                       const SensorValueDescriptor&> *callback,
1462
    string *error) {
1463
  if (CheckCallback(error, callback))
×
UNCOV
1464
    return false;
×
UNCOV
1465
  if (CheckValidSubDevice(sub_device, true, error, callback))
×
1466
    return false;
1467

UNCOV
1468
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
1469
    this,
1470
    &RDMAPI::_HandleSensorValue,
1471
    callback);
UNCOV
1472
  return CheckReturnStatus(
×
UNCOV
1473
    m_impl->RDMSet(cb,
×
1474
                   universe,
1475
                   uid,
1476
                   sub_device,
1477
                   PID_SENSOR_VALUE,
1478
                   &sensor_number,
1479
                   sizeof(sensor_number)),
UNCOV
1480
    error);
×
1481
}
1482

1483

1484
/*
1485
 * @brief Put a sensor into record mode
1486
 * @param universe the universe to perform the call on
1487
 * @param uid the UID to fetch the outstanding message count for
1488
 * @param sub_device the sub device to use
1489
 * @param sensor_number the sensor index to record
1490
 * @param callback the callback to invoke when this request completes
1491
 * @param error a pointer to a string which is set if an error occurs
1492
 * @return true if the request is sent correctly, false otherwise
1493
 */
UNCOV
1494
bool RDMAPI::RecordSensors(
×
1495
    unsigned int universe,
1496
    const UID &uid,
1497
    uint16_t sub_device,
1498
    uint8_t sensor_number,
1499
    SingleUseCallback1<void, const ResponseStatus&> *callback,
1500
    string *error) {
1501
  if (CheckCallback(error, callback))
×
UNCOV
1502
    return false;
×
UNCOV
1503
  if (CheckValidSubDevice(sub_device, true, error, callback))
×
1504
    return false;
1505

UNCOV
1506
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
1507
    this,
1508
    &RDMAPI::_HandleEmptyResponse,
1509
    callback);
UNCOV
1510
  return CheckReturnStatus(
×
UNCOV
1511
    m_impl->RDMSet(cb,
×
1512
                   universe,
1513
                   uid,
1514
                   sub_device,
1515
                   PID_RECORD_SENSORS,
1516
                   &sensor_number,
1517
                   sizeof(sensor_number)),
UNCOV
1518
    error);
×
1519
}
1520

1521

1522
/*
1523
 * @brief Get the device hours
1524
 * @param universe the universe to perform the call on
1525
 * @param uid the UID to fetch the outstanding message count for
1526
 * @param sub_device the sub device to use
1527
 * @param callback the callback to invoke when this request completes
1528
 * @param error a pointer to a string which is set if an error occurs
1529
 * @return true if the request is sent correctly, false otherwise
1530
*/
UNCOV
1531
bool RDMAPI::GetDeviceHours(
×
1532
    unsigned int universe,
1533
    const UID &uid,
1534
    uint16_t sub_device,
1535
    SingleUseCallback2<void, const ResponseStatus&, uint32_t> *callback,
1536
    string *error) {
1537
  if (CheckCallback(error, callback))
×
UNCOV
1538
    return false;
×
UNCOV
1539
  return GenericGetU32(
×
1540
      universe,
1541
      uid,
1542
      sub_device,
1543
      callback,
1544
      PID_DEVICE_HOURS,
UNCOV
1545
      error);
×
1546
}
1547

1548

1549
/*
1550
 * @brief Set the device hours
1551
 * @param universe the universe to perform the call on
1552
 * @param uid the UID to fetch the outstanding message count for
1553
 * @param sub_device the sub device to use
1554
 * @param device_hours the number of device hours
1555
 * @param callback the callback to invoke when this request completes
1556
 * @param error a pointer to a string which is set if an error occurs
1557
 * @return true if the request is sent correctly, false otherwise
1558
*/
UNCOV
1559
bool RDMAPI::SetDeviceHours(
×
1560
    unsigned int universe,
1561
    const UID &uid,
1562
    uint16_t sub_device,
1563
    uint32_t device_hours,
1564
    SingleUseCallback1<void, const ResponseStatus&> *callback,
1565
    string *error) {
1566
  if (CheckCallback(error, callback))
×
UNCOV
1567
    return false;
×
UNCOV
1568
  return GenericSetU32(
×
1569
      universe,
1570
      uid,
1571
      sub_device,
1572
      device_hours,
1573
      callback,
1574
      PID_DEVICE_HOURS,
UNCOV
1575
      error);
×
1576
}
1577

1578

1579
/*
1580
* @brief Get the lamp hours
1581
* @param universe the universe to perform the call on
1582
* @param uid the UID to fetch the outstanding message count for
1583
* @param sub_device the sub device to use
1584
* @param callback the callback to invoke when this request completes
1585
* @param error a pointer to a string which is set if an error occurs
1586
* @return true if the request is sent correctly, false otherwise
1587
*/
UNCOV
1588
bool RDMAPI::GetLampHours(
×
1589
    unsigned int universe,
1590
    const UID &uid,
1591
    uint16_t sub_device,
1592
    SingleUseCallback2<void, const ResponseStatus&, uint32_t> *callback,
1593
    string *error) {
1594
  if (CheckCallback(error, callback))
×
UNCOV
1595
    return false;
×
UNCOV
1596
  return GenericGetU32(
×
1597
      universe,
1598
      uid,
1599
      sub_device,
1600
      callback,
1601
      PID_LAMP_HOURS,
UNCOV
1602
      error);
×
1603
}
1604

1605

1606
/*
1607
 * @brief Set the lamp hours
1608
 * @param universe the universe to perform the call on
1609
 * @param uid the UID to fetch the outstanding message count for
1610
 * @param sub_device the sub device to use
1611
 * @param lamp_hours the number of lamp hours
1612
 * @param callback the callback to invoke when this request completes
1613
 * @param error a pointer to a string which is set if an error occurs
1614
 * @return true if the request is sent correctly, false otherwise
1615
*/
UNCOV
1616
bool RDMAPI::SetLampHours(
×
1617
    unsigned int universe,
1618
    const UID &uid,
1619
    uint16_t sub_device,
1620
    uint32_t lamp_hours,
1621
    SingleUseCallback1<void, const ResponseStatus&> *callback,
1622
    string *error) {
1623
  if (CheckCallback(error, callback))
×
UNCOV
1624
    return false;
×
UNCOV
1625
  return GenericSetU32(
×
1626
      universe,
1627
      uid,
1628
      sub_device,
1629
      lamp_hours,
1630
      callback,
1631
      PID_LAMP_STRIKES,
UNCOV
1632
      error);
×
1633
}
1634

1635

1636
/*
1637
* @brief Get the number of lamp strikes
1638
* @param universe the universe to perform the call on
1639
* @param uid the UID to fetch the outstanding message count for
1640
* @param sub_device the sub device to use
1641
* @param callback the callback to invoke when this request completes
1642
* @param error a pointer to a string which is set if an error occurs
1643
* @return true if the request is sent correctly, false otherwise
1644
*/
UNCOV
1645
bool RDMAPI::GetLampStrikes(
×
1646
    unsigned int universe,
1647
    const UID &uid,
1648
    uint16_t sub_device,
1649
    SingleUseCallback2<void, const ResponseStatus&, uint32_t> *callback,
1650
    string *error) {
1651
  if (CheckCallback(error, callback))
×
UNCOV
1652
    return false;
×
UNCOV
1653
  return GenericGetU32(
×
1654
      universe,
1655
      uid,
1656
      sub_device,
1657
      callback,
1658
      PID_LAMP_STRIKES,
UNCOV
1659
      error);
×
1660
}
1661

1662

1663
/*
1664
 * @brief Set the lamp strikes
1665
 * @param universe the universe to perform the call on
1666
 * @param uid the UID to fetch the outstanding message count for
1667
 * @param sub_device the sub device to use
1668
 * @param lamp_strikes the number of lamp strikes
1669
 * @param callback the callback to invoke when this request completes
1670
 * @param error a pointer to a string which is set if an error occurs
1671
 * @return true if the request is sent correctly, false otherwise
1672
*/
UNCOV
1673
bool RDMAPI::SetLampStrikes(
×
1674
    unsigned int universe,
1675
    const UID &uid,
1676
    uint16_t sub_device,
1677
    uint32_t lamp_strikes,
1678
    SingleUseCallback1<void, const ResponseStatus&> *callback,
1679
    string *error) {
1680
  if (CheckCallback(error, callback))
×
UNCOV
1681
    return false;
×
UNCOV
1682
  return GenericSetU32(
×
1683
      universe,
1684
      uid,
1685
      sub_device,
1686
      lamp_strikes,
1687
      callback,
1688
      PID_LAMP_STRIKES,
UNCOV
1689
      error);
×
1690
}
1691

1692

1693
/*
1694
* @brief Get the state of the lamp
1695
* @param universe the universe to perform the call on
1696
* @param uid the UID to fetch the outstanding message count for
1697
* @param sub_device the sub device to use
1698
* @param callback the callback to invoke when this request completes
1699
* @param error a pointer to a string which is set if an error occurs
1700
* @return true if the request is sent correctly, false otherwise
1701
*/
UNCOV
1702
bool RDMAPI::GetLampState(
×
1703
    unsigned int universe,
1704
    const UID &uid,
1705
    uint16_t sub_device,
1706
    SingleUseCallback2<void, const ResponseStatus&, uint8_t> *callback,
1707
    string *error) {
1708
  if (CheckCallback(error, callback))
×
UNCOV
1709
    return false;
×
UNCOV
1710
  return GenericGetU8(
×
1711
      universe,
1712
      uid,
1713
      sub_device,
1714
      callback,
1715
      PID_LAMP_STATE,
UNCOV
1716
      error);
×
1717
}
1718

1719

1720
/*
1721
 * @brief Set the lamp state
1722
 * @param universe the universe to perform the call on
1723
 * @param uid the UID to fetch the outstanding message count for
1724
 * @param sub_device the sub device to use
1725
 * @param lamp_state the new lamp state
1726
 * @param callback the callback to invoke when this request completes
1727
 * @param error a pointer to a string which is set if an error occurs
1728
 * @return true if the request is sent correctly, false otherwise
1729
*/
UNCOV
1730
bool RDMAPI::SetLampState(
×
1731
    unsigned int universe,
1732
    const UID &uid,
1733
    uint16_t sub_device,
1734
    uint8_t lamp_state,
1735
    SingleUseCallback1<void, const ResponseStatus&> *callback,
1736
    string *error) {
1737
  if (CheckCallback(error, callback))
×
UNCOV
1738
    return false;
×
UNCOV
1739
  return GenericSetU8(
×
1740
      universe,
1741
      uid,
1742
      sub_device,
1743
      lamp_state,
1744
      callback,
1745
      PID_LAMP_STATE,
UNCOV
1746
      error);
×
1747
}
1748

1749

1750
/*
1751
* @brief Get the mode of the lamp
1752
* @param universe the universe to perform the call on
1753
* @param uid the UID to fetch the outstanding message count for
1754
* @param sub_device the sub device to use
1755
* @param callback the callback to invoke when this request completes
1756
* @param error a pointer to a string which is set if an error occurs
1757
* @return true if the request is sent correctly, false otherwise
1758
*/
UNCOV
1759
bool RDMAPI::GetLampMode(
×
1760
    unsigned int universe,
1761
    const UID &uid,
1762
    uint16_t sub_device,
1763
    SingleUseCallback2<void, const ResponseStatus&, uint8_t> *callback,
1764
    string *error) {
1765
  if (CheckCallback(error, callback))
×
UNCOV
1766
    return false;
×
UNCOV
1767
  return GenericGetU8(
×
1768
      universe,
1769
      uid,
1770
      sub_device,
1771
      callback,
1772
      PID_LAMP_ON_MODE,
UNCOV
1773
      error);
×
1774
}
1775

1776

1777
/*
1778
 * @brief Set the lamp mode
1779
 * @param universe the universe to perform the call on
1780
 * @param uid the UID to fetch the outstanding message count for
1781
 * @param sub_device the sub device to use
1782
 * @param lamp_mode the new lamp mode
1783
 * @param callback the callback to invoke when this request completes
1784
 * @param error a pointer to a string which is set if an error occurs
1785
 * @return true if the request is sent correctly, false otherwise
1786
*/
UNCOV
1787
bool RDMAPI::SetLampMode(
×
1788
    unsigned int universe,
1789
    const UID &uid,
1790
    uint16_t sub_device,
1791
    uint8_t lamp_mode,
1792
    SingleUseCallback1<void, const ResponseStatus&> *callback,
1793
    string *error) {
1794
  if (CheckCallback(error, callback))
×
UNCOV
1795
    return false;
×
UNCOV
1796
  return GenericSetU8(
×
1797
      universe,
1798
      uid,
1799
      sub_device,
1800
      lamp_mode,
1801
      callback,
1802
      PID_LAMP_ON_MODE,
UNCOV
1803
      error);
×
1804
}
1805

1806

1807
/*
1808
* @brief Get the number of device power cycles
1809
* @param universe the universe to perform the call on
1810
* @param uid the UID to fetch the outstanding message count for
1811
* @param sub_device the sub device to use
1812
* @param callback the callback to invoke when this request completes
1813
* @param error a pointer to a string which is set if an error occurs
1814
* @return true if the request is sent correctly, false otherwise
1815
*/
UNCOV
1816
bool RDMAPI::GetDevicePowerCycles(
×
1817
    unsigned int universe,
1818
    const UID &uid,
1819
    uint16_t sub_device,
1820
    SingleUseCallback2<void, const ResponseStatus&, uint32_t> *callback,
1821
    string *error) {
1822
  if (CheckCallback(error, callback))
×
UNCOV
1823
    return false;
×
UNCOV
1824
  return GenericGetU32(
×
1825
      universe,
1826
      uid,
1827
      sub_device,
1828
      callback,
1829
      PID_DEVICE_POWER_CYCLES,
UNCOV
1830
      error);
×
1831
}
1832

1833

1834
/*
1835
 * @brief Set the number of power cycles
1836
 * @param universe the universe to perform the call on
1837
 * @param uid the UID to fetch the outstanding message count for
1838
 * @param sub_device the sub device to use
1839
 * @param power_cycles the number of power cycles
1840
 * @param callback the callback to invoke when this request completes
1841
 * @param error a pointer to a string which is set if an error occurs
1842
 * @return true if the request is sent correctly, false otherwise
1843
*/
UNCOV
1844
bool RDMAPI::SetDevicePowerCycles(
×
1845
    unsigned int universe,
1846
    const UID &uid,
1847
    uint16_t sub_device,
1848
    uint32_t power_cycles,
1849
    SingleUseCallback1<void, const ResponseStatus&> *callback,
1850
    string *error) {
1851
  if (CheckCallback(error, callback))
×
UNCOV
1852
    return false;
×
UNCOV
1853
  return GenericSetU32(
×
1854
      universe,
1855
      uid,
1856
      sub_device,
1857
      power_cycles,
1858
      callback,
1859
      PID_DEVICE_POWER_CYCLES,
UNCOV
1860
      error);
×
1861
}
1862

1863

1864
/*
1865
* @brief Get the display invert setting
1866
* @param universe the universe to perform the call on
1867
* @param uid the UID to fetch the outstanding message count for
1868
* @param sub_device the sub device to use
1869
* @param callback the callback to invoke when this request completes
1870
* @param error a pointer to a string which is set if an error occurs
1871
* @return true if the request is sent correctly, false otherwise
1872
*/
UNCOV
1873
bool RDMAPI::GetDisplayInvert(
×
1874
    unsigned int universe,
1875
    const UID &uid,
1876
    uint16_t sub_device,
1877
    SingleUseCallback2<void, const ResponseStatus&, uint8_t> *callback,
1878
    string *error) {
1879
  if (CheckCallback(error, callback))
×
UNCOV
1880
    return false;
×
UNCOV
1881
  return GenericGetU8(
×
1882
      universe,
1883
      uid,
1884
      sub_device,
1885
      callback,
1886
      PID_DISPLAY_INVERT,
UNCOV
1887
      error);
×
1888
}
1889

1890

1891
/*
1892
 * @brief Set the display invert setting
1893
 * @param universe the universe to perform the call on
1894
 * @param uid the UID to fetch the outstanding message count for
1895
 * @param sub_device the sub device to use
1896
 * @param display_invert the new invert setting
1897
 * @param callback the callback to invoke when this request completes
1898
 * @param error a pointer to a string which is set if an error occurs
1899
 * @return true if the request is sent correctly, false otherwise
1900
*/
UNCOV
1901
bool RDMAPI::SetDisplayInvert(
×
1902
    unsigned int universe,
1903
    const UID &uid,
1904
    uint16_t sub_device,
1905
    uint8_t display_invert,
1906
    SingleUseCallback1<void, const ResponseStatus&> *callback,
1907
    string *error) {
1908
  if (CheckCallback(error, callback))
×
UNCOV
1909
    return false;
×
UNCOV
1910
  return GenericSetU8(
×
1911
      universe,
1912
      uid,
1913
      sub_device,
1914
      display_invert,
1915
      callback,
1916
      PID_DISPLAY_INVERT,
UNCOV
1917
      error);
×
1918
}
1919

1920

1921
/*
1922
* @brief Get the display level
1923
* @param universe the universe to perform the call on
1924
* @param uid the UID to fetch the outstanding message count for
1925
* @param sub_device the sub device to use
1926
* @param callback the callback to invoke when this request completes
1927
* @param error a pointer to a string which is set if an error occurs
1928
* @return true if the request is sent correctly, false otherwise
1929
*/
UNCOV
1930
bool RDMAPI::GetDisplayLevel(
×
1931
    unsigned int universe,
1932
    const UID &uid,
1933
    uint16_t sub_device,
1934
    SingleUseCallback2<void, const ResponseStatus&, uint8_t> *callback,
1935
    string *error) {
1936
  if (CheckCallback(error, callback))
×
UNCOV
1937
    return false;
×
UNCOV
1938
  return GenericGetU8(
×
1939
      universe,
1940
      uid,
1941
      sub_device,
1942
      callback,
1943
      PID_DISPLAY_LEVEL,
UNCOV
1944
      error);
×
1945
}
1946

1947

1948
/*
1949
 * @brief Set the display level
1950
 * @param universe the universe to perform the call on
1951
 * @param uid the UID to fetch the outstanding message count for
1952
 * @param sub_device the sub device to use
1953
 * @param display_level the new setting
1954
 * @param callback the callback to invoke when this request completes
1955
 * @param error a pointer to a string which is set if an error occurs
1956
 * @return true if the request is sent correctly, false otherwise
1957
*/
UNCOV
1958
bool RDMAPI::SetDisplayLevel(
×
1959
    unsigned int universe,
1960
    const UID &uid,
1961
    uint16_t sub_device,
1962
    uint8_t display_level,
1963
    SingleUseCallback1<void, const ResponseStatus&> *callback,
1964
    string *error) {
1965
  if (CheckCallback(error, callback))
×
UNCOV
1966
    return false;
×
UNCOV
1967
  return GenericSetU8(
×
1968
      universe,
1969
      uid,
1970
      sub_device,
1971
      display_level,
1972
      callback,
1973
      PID_DISPLAY_LEVEL,
UNCOV
1974
      error);
×
1975
}
1976

1977

1978
/*
1979
* @brief Get the pan invert parameter
1980
* @param universe the universe to perform the call on
1981
* @param uid the UID to fetch the outstanding message count for
1982
* @param sub_device the sub device to use
1983
* @param callback the callback to invoke when this request completes
1984
* @param error a pointer to a string which is set if an error occurs
1985
* @return true if the request is sent correctly, false otherwise
1986
*/
UNCOV
1987
bool RDMAPI::GetPanInvert(
×
1988
    unsigned int universe,
1989
    const UID &uid,
1990
    uint16_t sub_device,
1991
    SingleUseCallback2<void, const ResponseStatus&, uint8_t> *callback,
1992
    string *error) {
1993
  if (CheckCallback(error, callback))
×
UNCOV
1994
    return false;
×
UNCOV
1995
  return GenericGetU8(
×
1996
      universe,
1997
      uid,
1998
      sub_device,
1999
      callback,
2000
      PID_PAN_INVERT,
UNCOV
2001
      error);
×
2002
}
2003

2004

2005
/*
2006
 * @brief Invert the pan parameter
2007
 * @param universe the universe to perform the call on
2008
 * @param uid the UID to fetch the outstanding message count for
2009
 * @param sub_device the sub device to use
2010
 * @param invert set to true to invert
2011
 * @param callback the callback to invoke when this request completes
2012
 * @param error a pointer to a string which is set if an error occurs
2013
 * @return true if the request is sent correctly, false otherwise
2014
*/
UNCOV
2015
bool RDMAPI::SetPanInvert(
×
2016
    unsigned int universe,
2017
    const UID &uid,
2018
    uint16_t sub_device,
2019
    uint8_t invert,
2020
    SingleUseCallback1<void, const ResponseStatus&> *callback,
2021
    string *error) {
2022
  if (CheckCallback(error, callback))
×
UNCOV
2023
    return false;
×
UNCOV
2024
  return GenericSetU8(
×
2025
      universe,
2026
      uid,
2027
      sub_device,
2028
      invert,
2029
      callback,
2030
      PID_PAN_INVERT,
UNCOV
2031
      error);
×
2032
}
2033

2034

2035
/*
2036
* @brief Get the tilt invert parameter
2037
* @param universe the universe to perform the call on
2038
* @param uid the UID to fetch the outstanding message count for
2039
* @param sub_device the sub device to use
2040
* @param callback the callback to invoke when this request completes
2041
* @param error a pointer to a string which is set if an error occurs
2042
* @return true if the request is sent correctly, false otherwise
2043
*/
UNCOV
2044
bool RDMAPI::GetTiltInvert(
×
2045
    unsigned int universe,
2046
    const UID &uid,
2047
    uint16_t sub_device,
2048
    SingleUseCallback2<void, const ResponseStatus&, uint8_t> *callback,
2049
    string *error) {
2050
  if (CheckCallback(error, callback))
×
UNCOV
2051
    return false;
×
UNCOV
2052
  return GenericGetU8(
×
2053
      universe,
2054
      uid,
2055
      sub_device,
2056
      callback,
2057
      PID_TILT_INVERT,
UNCOV
2058
      error);
×
2059
}
2060

2061

2062
/*
2063
 * @brief Invert the tilt parameter
2064
 * @param universe the universe to perform the call on
2065
 * @param uid the UID to fetch the outstanding message count for
2066
 * @param sub_device the sub device to use
2067
 * @param invert set to true to invert
2068
 * @param callback the callback to invoke when this request completes
2069
 * @param error a pointer to a string which is set if an error occurs
2070
 * @return true if the request is sent correctly, false otherwise
2071
*/
UNCOV
2072
bool RDMAPI::SetTiltInvert(
×
2073
    unsigned int universe,
2074
    const UID &uid,
2075
    uint16_t sub_device,
2076
    uint8_t invert,
2077
    SingleUseCallback1<void, const ResponseStatus&> *callback,
2078
    string *error) {
2079
  if (CheckCallback(error, callback))
×
UNCOV
2080
    return false;
×
UNCOV
2081
  return GenericSetU8(
×
2082
      universe,
2083
      uid,
2084
      sub_device,
2085
      invert,
2086
      callback,
2087
      PID_TILT_INVERT,
UNCOV
2088
      error);
×
2089
}
2090

2091

2092
/*
2093
* @brief Get the pan/tilt swap parameter
2094
* @param universe the universe to perform the call on
2095
* @param uid the UID to fetch the outstanding message count for
2096
* @param sub_device the sub device to use
2097
* @param callback the callback to invoke when this request completes
2098
* @param error a pointer to a string which is set if an error occurs
2099
* @return true if the request is sent correctly, false otherwise
2100
*/
UNCOV
2101
bool RDMAPI::GetPanTiltSwap(
×
2102
    unsigned int universe,
2103
    const UID &uid,
2104
    uint16_t sub_device,
2105
    SingleUseCallback2<void, const ResponseStatus&, uint8_t> *callback,
2106
    string *error) {
2107
  if (CheckCallback(error, callback))
×
UNCOV
2108
    return false;
×
UNCOV
2109
  return GenericGetU8(
×
2110
      universe,
2111
      uid,
2112
      sub_device,
2113
      callback,
2114
      PID_PAN_TILT_SWAP,
UNCOV
2115
      error);
×
2116
}
2117

2118

2119
/*
2120
 * @brief Swap the pan and tilt actions
2121
 * @param universe the universe to perform the call on
2122
 * @param uid the UID to fetch the outstanding message count for
2123
 * @param sub_device the sub device to use
2124
 * @param swap, true to swap, false otherwise
2125
 * @param callback the callback to invoke when this request completes
2126
 * @param error a pointer to a string which is set if an error occurs
2127
 * @return true if the request is sent correctly, false otherwise
2128
*/
UNCOV
2129
bool RDMAPI::SetPanTiltSwap(
×
2130
    unsigned int universe,
2131
    const UID &uid,
2132
    uint16_t sub_device,
2133
    uint8_t swap,
2134
    SingleUseCallback1<void, const ResponseStatus&> *callback,
2135
    string *error) {
2136
  if (CheckCallback(error, callback))
×
UNCOV
2137
    return false;
×
UNCOV
2138
  return GenericSetU8(
×
2139
      universe,
2140
      uid,
2141
      sub_device,
2142
      swap,
2143
      callback,
2144
      PID_PAN_TILT_SWAP,
UNCOV
2145
      error);
×
2146
}
2147

2148

2149
/*
2150
 * @brief Get the clock value
2151
 * @param universe the universe to perform the call on
2152
 * @param uid the UID to fetch the outstanding message count for
2153
 * @param sub_device the sub device to use
2154
 * @param callback the callback to invoke when this request completes
2155
 * @param error a pointer to a string which is set if an error occurs
2156
 * @return true if the request is sent correctly, false otherwise
2157
*/
UNCOV
2158
bool RDMAPI::GetClock(
×
2159
    unsigned int universe,
2160
    const UID &uid,
2161
    uint16_t sub_device,
2162
    SingleUseCallback2<void,
2163
                       const ResponseStatus&,
2164
                       const ClockValue&> *callback,
2165
    string *error) {
2166
  if (CheckCallback(error, callback))
×
UNCOV
2167
    return false;
×
UNCOV
2168
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
2169
    this,
2170
    &RDMAPI::_HandleClock,
2171
    callback);
UNCOV
2172
  return CheckReturnStatus(
×
UNCOV
2173
      m_impl->RDMGet(cb,
×
2174
                     universe,
2175
                     uid,
2176
                     sub_device,
2177
                     PID_REAL_TIME_CLOCK),
UNCOV
2178
      error);
×
2179
}
2180

2181

2182
/*
2183
 * @brief Set the clock value
2184
 * @param universe the universe to perform the call on
2185
 * @param uid the UID to fetch the outstanding message count for
2186
 * @param sub_device the sub device to use
2187
 * @param clock, the new clock settings
2188
 * @param callback the callback to invoke when this request completes
2189
 * @param error a pointer to a string which is set if an error occurs
2190
 * @return true if the request is sent correctly, false otherwise
2191
*/
UNCOV
2192
bool RDMAPI::SetClock(
×
2193
    unsigned int universe,
2194
    const UID &uid,
2195
    uint16_t sub_device,
2196
    const ClockValue &clock,
2197
    SingleUseCallback1<void, const ResponseStatus&> *callback,
2198
    string *error) {
2199
  if (CheckCallback(error, callback))
×
2200
    return false;
×
2201
  ClockValue clock_data;
×
UNCOV
2202
  memcpy(&clock_data, &clock, sizeof(clock_data));
×
2203
  clock_data.year = HostToNetwork(clock_data.year);
×
2204

UNCOV
2205
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
2206
    this,
2207
    &RDMAPI::_HandleEmptyResponse,
2208
    callback);
UNCOV
2209
  return CheckReturnStatus(
×
UNCOV
2210
      m_impl->RDMSet(cb,
×
2211
                     universe,
2212
                     uid,
2213
                     sub_device,
2214
                     PID_REAL_TIME_CLOCK,
2215
                     reinterpret_cast<const uint8_t*>(&clock_data),
2216
                     sizeof(struct clock_value_s)),
2217
      error);
2218
}
2219

2220

2221
/*
2222
 * @brief Check the identify state for a device
2223
 * @param universe the universe to perform the call on
2224
 * @param uid the UID to fetch the outstanding message count for
2225
 * @param sub_device the sub device to use
2226
 * @param callback the callback to invoke when this request completes
2227
 * @param error a pointer to a string which is set if an error occurs
2228
 * @return true if the request is sent correctly, false otherwise
2229
 */
UNCOV
2230
bool RDMAPI::GetIdentifyDevice(
×
2231
    unsigned int universe,
2232
    const UID &uid,
2233
    uint16_t sub_device,
2234
    SingleUseCallback2<void, const ResponseStatus&, bool> *callback,
2235
    string *error) {
2236
  if (CheckCallback(error, callback))
×
UNCOV
2237
    return false;
×
2238
  if (CheckNotBroadcast(uid, error, callback))
×
2239
    return false;
UNCOV
2240
  if (CheckValidSubDevice(sub_device, false, error, callback))
×
2241
    return false;
2242

UNCOV
2243
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
2244
    this,
2245
    &RDMAPI::_HandleBoolResponse,
2246
    callback);
UNCOV
2247
  return CheckReturnStatus(
×
UNCOV
2248
    m_impl->RDMGet(cb,
×
2249
                   universe,
2250
                   uid,
2251
                   sub_device,
2252
                   PID_IDENTIFY_DEVICE),
UNCOV
2253
    error);
×
2254
}
2255

2256

2257
/*
2258
 * @brief Change the identify state for a device
2259
 * @param universe the universe to perform the call on
2260
 * @param uid the UID to fetch the outstanding message count for
2261
 * @param sub_device the sub device to use
2262
 * @param mode the identify mode to set
2263
 * @param callback the callback to invoke when this request completes
2264
 * @param error a pointer to a string which is set if an error occurs
2265
 * @return true if the request is sent correctly, false otherwise
2266
*/
UNCOV
2267
bool RDMAPI::IdentifyDevice(
×
2268
    unsigned int universe,
2269
    const UID &uid,
2270
    uint16_t sub_device,
2271
    bool mode,
2272
    SingleUseCallback1<void, const ResponseStatus&> *callback,
2273
    string *error) {
2274
  if (CheckCallback(error, callback))
×
UNCOV
2275
    return false;
×
UNCOV
2276
  if (CheckValidSubDevice(sub_device, true, error, callback))
×
2277
    return false;
2278

UNCOV
2279
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
2280
    this,
2281
    &RDMAPI::_HandleEmptyResponse,
2282
    callback);
2283
  uint8_t option = mode;
×
UNCOV
2284
  return CheckReturnStatus(
×
UNCOV
2285
    m_impl->RDMSet(cb,
×
2286
                   universe,
2287
                   uid,
2288
                   sub_device,
2289
                   PID_IDENTIFY_DEVICE,
2290
                   &option,
2291
                   sizeof(option)),
2292
    error);
2293
}
2294

2295

2296
/*
2297
 * @brief Reset a device
2298
 * @param universe the universe to perform the call on
2299
 * @param uid the UID to fetch the outstanding message count for
2300
 * @param sub_device the sub device to use
2301
 * @param warm_reset true for a warm reset, false for a cold reset
2302
 * @param callback the callback to invoke when this request completes
2303
 * @param error a pointer to a string which is set if an error occurs
2304
 * @return true if the request is sent correctly, false otherwise
2305
*/
UNCOV
2306
bool RDMAPI::ResetDevice(
×
2307
    unsigned int universe,
2308
    const UID &uid,
2309
    uint16_t sub_device,
2310
    bool warm_reset,
2311
    SingleUseCallback1<void, const ResponseStatus&> *callback,
2312
    string *error) {
2313
  if (CheckCallback(error, callback))
×
UNCOV
2314
    return false;
×
UNCOV
2315
  if (CheckValidSubDevice(sub_device, true, error, callback))
×
2316
    return false;
2317

UNCOV
2318
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
2319
    this,
2320
    &RDMAPI::_HandleEmptyResponse,
2321
    callback);
2322
  uint8_t option = warm_reset ? RESET_WARM : RESET_COLD;
×
UNCOV
2323
  return CheckReturnStatus(
×
UNCOV
2324
    m_impl->RDMSet(cb,
×
2325
                   universe,
2326
                   uid,
2327
                   sub_device,
2328
                   PID_RESET_DEVICE,
2329
                   &option,
2330
                   sizeof(option)),
2331
    error);
2332
}
2333

2334

2335
/*
2336
 * @brief Get the power state for a device
2337
 * @param universe the universe to perform the call on
2338
 * @param uid the UID to fetch the outstanding message count for
2339
 * @param sub_device the sub device to use
2340
 * @param callback the callback to invoke when this request completes
2341
 * @param error a pointer to a string which is set if an error occurs
2342
 * @return true if the request is sent correctly, false otherwise
2343
*/
UNCOV
2344
bool RDMAPI::GetPowerState(
×
2345
    unsigned int universe,
2346
    const UID &uid,
2347
    uint16_t sub_device,
2348
    SingleUseCallback2<void, const ResponseStatus&, uint8_t> *callback,
2349
    string *error) {
2350
  if (CheckCallback(error, callback))
×
UNCOV
2351
    return false;
×
2352
  if (CheckNotBroadcast(uid, error, callback))
×
2353
    return false;
UNCOV
2354
  if (CheckValidSubDevice(sub_device, false, error, callback))
×
2355
    return false;
2356

UNCOV
2357
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
2358
    this,
2359
    &RDMAPI::_HandleU8Response,
2360
    callback);
UNCOV
2361
  return CheckReturnStatus(
×
UNCOV
2362
    m_impl->RDMGet(cb,
×
2363
                   universe,
2364
                   uid,
2365
                   sub_device,
2366
                   PID_POWER_STATE),
UNCOV
2367
    error);
×
2368
}
2369

2370

2371
/*
2372
 * @brief Set the power state for a device.
2373
 * @param universe the universe to perform the call on
2374
 * @param uid the UID to fetch the outstanding message count for
2375
 * @param sub_device the sub device to use
2376
 * @param power_state the new power state
2377
 * @param callback the callback to invoke when this request completes
2378
 * @param error a pointer to a string which is set if an error occurs
2379
 * @return true if the request is sent correctly, false otherwise
2380
*/
UNCOV
2381
bool RDMAPI::SetPowerState(
×
2382
    unsigned int universe,
2383
    const UID &uid,
2384
    uint16_t sub_device,
2385
    rdm_power_state power_state,
2386
    SingleUseCallback1<void, const ResponseStatus&> *callback,
2387
    string *error) {
2388
  if (CheckCallback(error, callback))
×
UNCOV
2389
    return false;
×
UNCOV
2390
  if (CheckValidSubDevice(sub_device, true, error, callback))
×
2391
    return false;
2392

UNCOV
2393
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
2394
    this,
2395
    &RDMAPI::_HandleEmptyResponse,
2396
    callback);
2397
  uint8_t option = static_cast<uint8_t>(power_state);
×
UNCOV
2398
  return CheckReturnStatus(
×
UNCOV
2399
    m_impl->RDMSet(cb,
×
2400
                   universe,
2401
                   uid,
2402
                   sub_device,
2403
                   PID_POWER_STATE,
2404
                   &option,
2405
                   sizeof(option)),
2406
    error);
2407
}
2408

2409

2410
/*
2411
 * @brief Set the reset device for a device.
2412
 * @param universe the universe to perform the call on
2413
 * @param uid the UID to fetch the outstanding message count for
2414
 * @param sub_device the sub device to use
2415
 * @param reset_device the new reset device
2416
 * @param callback the callback to invoke when this request completes
2417
 * @param error a pointer to a string which is set if an error occurs
2418
 * @return true if the request is sent correctly, false otherwise
2419
*/
UNCOV
2420
bool RDMAPI::SetResetDevice(
×
2421
    unsigned int universe,
2422
    const UID &uid,
2423
    uint16_t sub_device,
2424
    rdm_reset_device_mode reset_device,
2425
    SingleUseCallback1<void, const ResponseStatus&> *callback,
2426
    string *error) {
2427
  if (CheckCallback(error, callback))
×
UNCOV
2428
    return false;
×
UNCOV
2429
  if (CheckValidSubDevice(sub_device, true, error, callback))
×
2430
    return false;
2431

UNCOV
2432
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
2433
    this,
2434
    &RDMAPI::_HandleEmptyResponse,
2435
    callback);
2436
  uint8_t option = static_cast<uint8_t>(reset_device);
×
UNCOV
2437
  return CheckReturnStatus(
×
UNCOV
2438
    m_impl->RDMSet(cb,
×
2439
                   universe,
2440
                   uid,
2441
                   sub_device,
2442
                   PID_RESET_DEVICE,
2443
                   &option,
2444
                   sizeof(option)),
2445
    error);
2446
}
2447

2448

2449
/*
2450
 * @brief Fetch the DNS hostname
2451
 * @param universe the universe to perform the call on
2452
 * @param uid the UID to fetch the DNS hostname for
2453
 * @param sub_device the sub device to use
2454
 * @param callback the callback to invoke when this request completes
2455
 * @param error a pointer to a string which is set if an error occurs
2456
 * @return true if the request is sent correctly, false otherwise
2457
 */
UNCOV
2458
bool RDMAPI::GetDnsHostname(
×
2459
    unsigned int universe,
2460
    const UID &uid,
2461
    uint16_t sub_device,
2462
    SingleUseCallback2<void,
2463
                       const ResponseStatus&,
2464
                       const string&> *callback,
2465
    string *error) {
UNCOV
2466
  if (CheckCallback(error, callback)) {
×
2467
    return false;
×
2468
  }
UNCOV
2469
  if (CheckNotBroadcast(uid, error, callback)) {
×
2470
    return false;
2471
  }
UNCOV
2472
  if (CheckValidSubDevice(sub_device, false, error, callback)) {
×
2473
    return false;
2474
  }
2475

UNCOV
2476
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
2477
    this,
2478
    &RDMAPI::_HandleCustomLengthLabelResponse,
2479
    callback,
2480
    MAX_RDM_HOSTNAME_LENGTH);
UNCOV
2481
  return CheckReturnStatus(
×
UNCOV
2482
    m_impl->RDMGet(cb,
×
2483
                   universe,
2484
                   uid,
2485
                   sub_device,
2486
                   PID_DNS_HOSTNAME),
UNCOV
2487
    error);
×
2488
}
2489

2490

2491
/*
2492
 * @brief Set the DNS hostname
2493
 * @param universe the universe to perform the call on
2494
 * @param uid the UID to set the DNS hostname for
2495
 * @param sub_device the sub device to use
2496
 * @param callback the callback to invoke when this request completes
2497
 * @param error a pointer to a string which is set if an error occurs
2498
 * @return true if the request is sent correctly, false otherwise
2499
 */
UNCOV
2500
bool RDMAPI::SetDnsHostname(
×
2501
    unsigned int universe,
2502
    const UID &uid,
2503
    uint16_t sub_device,
2504
    const string &label,
2505
    SingleUseCallback1<void, const ResponseStatus&> *callback,
2506
    string *error) {
UNCOV
2507
  if (CheckCallback(error, callback)) {
×
UNCOV
2508
    return false;
×
2509
  }
2510
  // It doesn't really make sense to broadcast this but allow it anyway
UNCOV
2511
  if (CheckValidSubDevice(sub_device, true, error, callback)) {
×
2512
    return false;
2513
  }
2514

UNCOV
2515
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
2516
    this,
2517
    &RDMAPI::_HandleEmptyResponse,
2518
    callback);
UNCOV
2519
  return CheckReturnStatus(
×
UNCOV
2520
    m_impl->RDMSet(cb,
×
2521
                   universe,
2522
                   uid,
2523
                   sub_device,
2524
                   PID_DNS_HOSTNAME,
2525
                   reinterpret_cast<const uint8_t*>(label.data()),
×
UNCOV
2526
                   label.size()),
×
UNCOV
2527
    error);
×
2528
}
2529

2530

2531
/*
2532
 * @brief Fetch the DNS domain name
2533
 * @param universe the universe to perform the call on
2534
 * @param uid the UID to fetch the DNS domain name for
2535
 * @param sub_device the sub device to use
2536
 * @param callback the callback to invoke when this request completes
2537
 * @param error a pointer to a string which is set if an error occurs
2538
 * @return true if the request is sent correctly, false otherwise
2539
 */
UNCOV
2540
bool RDMAPI::GetDnsDomainName(
×
2541
    unsigned int universe,
2542
    const UID &uid,
2543
    uint16_t sub_device,
2544
    SingleUseCallback2<void,
2545
                       const ResponseStatus&,
2546
                       const string&> *callback,
2547
    string *error) {
UNCOV
2548
  if (CheckCallback(error, callback)) {
×
2549
    return false;
×
2550
  }
UNCOV
2551
  if (CheckNotBroadcast(uid, error, callback)) {
×
2552
    return false;
2553
  }
UNCOV
2554
  if (CheckValidSubDevice(sub_device, false, error, callback)) {
×
2555
    return false;
2556
  }
2557

UNCOV
2558
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
2559
    this,
2560
    &RDMAPI::_HandleCustomLengthLabelResponse,
2561
    callback,
2562
    MAX_RDM_DOMAIN_NAME_LENGTH);
UNCOV
2563
  return CheckReturnStatus(
×
UNCOV
2564
    m_impl->RDMGet(cb,
×
2565
                   universe,
2566
                   uid,
2567
                   sub_device,
2568
                   PID_DNS_DOMAIN_NAME),
UNCOV
2569
    error);
×
2570
}
2571

2572

2573
/*
2574
 * @brief Set the DNS domain name
2575
 * @param universe the universe to perform the call on
2576
 * @param uid the UID to set the DNS domain name for
2577
 * @param sub_device the sub device to use
2578
 * @param callback the callback to invoke when this request completes
2579
 * @param error a pointer to a string which is set if an error occurs
2580
 * @return true if the request is sent correctly, false otherwise
2581
 */
UNCOV
2582
bool RDMAPI::SetDnsDomainName(
×
2583
    unsigned int universe,
2584
    const UID &uid,
2585
    uint16_t sub_device,
2586
    const string &label,
2587
    SingleUseCallback1<void, const ResponseStatus&> *callback,
2588
    string *error) {
UNCOV
2589
  if (CheckCallback(error, callback)) {
×
UNCOV
2590
    return false;
×
2591
  }
2592

UNCOV
2593
  if (CheckValidSubDevice(sub_device, true, error, callback)) {
×
2594
    return false;
2595
  }
2596

UNCOV
2597
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
2598
    this,
2599
    &RDMAPI::_HandleEmptyResponse,
2600
    callback);
UNCOV
2601
  return CheckReturnStatus(
×
UNCOV
2602
    m_impl->RDMSet(cb,
×
2603
                   universe,
2604
                   uid,
2605
                   sub_device,
2606
                   PID_DNS_DOMAIN_NAME,
2607
                   reinterpret_cast<const uint8_t*>(label.data()),
×
UNCOV
2608
                   label.size()),
×
UNCOV
2609
    error);
×
2610
}
2611

2612
/*
2613
 * @brief Fetch the dimmer curve
2614
 * @param universe the universe to perform the call on
2615
 * @param uid the UID to fetch the dimmer curve information for
2616
 * @param sub_device the sub device to use
2617
 * @param callback the callback to invoke when this request completes
2618
 * @param error a pointer to a string which is set if an error occurs
2619
 * @return true if the request is sent correctly, false otherwise
2620
 */
UNCOV
2621
bool RDMAPI::GetCurve(
×
2622
    unsigned int universe,
2623
    const UID &uid,
2624
    uint16_t sub_device,
2625
    SingleUseCallback3<void,
2626
                       const ResponseStatus&,
2627
                       uint8_t,
2628
                       uint8_t> *callback,
2629
    string *error) {
UNCOV
2630
  if (CheckCallback(error, callback)) {
×
2631
    return false;
×
2632
  }
UNCOV
2633
  if (CheckNotBroadcast(uid, error, callback)) {
×
2634
    return false;
2635
  }
UNCOV
2636
  if (CheckValidSubDevice(sub_device, false, error, callback)) {
×
2637
    return false;
2638
  }
2639

UNCOV
2640
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
2641
    this,
2642
    &RDMAPI::_HandleGetCurve,
2643
    callback);
UNCOV
2644
  return CheckReturnStatus(
×
UNCOV
2645
    m_impl->RDMGet(cb,
×
2646
                   universe,
2647
                   uid,
2648
                   sub_device,
2649
                   PID_CURVE),
UNCOV
2650
    error);
×
2651
}
2652

2653
/*
2654
 * @brief Set the dimmer curve
2655
 * @param universe the universe to perform the call on
2656
 * @param uid the UID to set the dimmer curve for
2657
 * @param sub_device the sub device to use
2658
 * @param curve the index of the curve to set
2659
 * @param callback the callback to invoke when this request completes
2660
 * @param error a pointer to a string which is set if an error occurs
2661
 * @return true if the request is sent correctly, false otherwise
2662
 */
UNCOV
2663
bool RDMAPI::SetCurve(
×
2664
    unsigned int universe,
2665
    const UID &uid,
2666
    uint16_t sub_device,
2667
    uint8_t curve,
2668
    SingleUseCallback1<void, const ResponseStatus&> *callback,
2669
    string *error) {
UNCOV
2670
  if (CheckCallback(error, callback)) {
×
UNCOV
2671
    return false;
×
2672
  }
2673

UNCOV
2674
  if (CheckValidSubDevice(sub_device, true, error, callback)) {
×
2675
    return false;
2676
  }
2677

UNCOV
2678
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
2679
    this,
2680
    &RDMAPI::_HandleEmptyResponse,
2681
    callback);
UNCOV
2682
  return CheckReturnStatus(
×
UNCOV
2683
    m_impl->RDMSet(cb,
×
2684
                   universe,
2685
                   uid,
2686
                   sub_device,
2687
                   PID_CURVE,
2688
                   &curve,
2689
                   sizeof(curve)),
UNCOV
2690
    error);
×
2691
}
2692

2693
/*
2694
 * @brief Fetch the dimmer curve description (name)
2695
 * @param universe the universe to perform the call on
2696
 * @param uid the UID to fetch the dimmer curve description for
2697
 * @param sub_device the sub device to use
2698
 * @param curve the id of the curve to fetch the description for
2699
 * @param callback the callback to invoke when this request completes
2700
 * @param error a pointer to a string which is set if an error occurs
2701
 * @return true if the request is sent correctly, false otherwise
2702
 */
UNCOV
2703
bool RDMAPI::GetCurveDescription(
×
2704
    unsigned int universe,
2705
    const UID &uid,
2706
    uint16_t sub_device,
2707
    uint8_t curve,
2708
    SingleUseCallback3<void,
2709
                       const ResponseStatus&,
2710
                       uint8_t,
2711
                       const string&> *callback,
2712
    string *error) {
UNCOV
2713
  if (CheckCallback(error, callback)) {
×
2714
    return false;
×
2715
  }
UNCOV
2716
  if (CheckNotBroadcast(uid, error, callback)) {
×
2717
    return false;
2718
  }
UNCOV
2719
  if (CheckValidSubDevice(sub_device, false, error, callback)) {
×
2720
    return false;
2721
  }
2722

UNCOV
2723
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
2724
    this,
2725
    &RDMAPI::_HandleGetCurveDescription,
2726
    callback);
UNCOV
2727
  return CheckReturnStatus(
×
UNCOV
2728
    m_impl->RDMGet(cb,
×
2729
                   universe,
2730
                   uid,
2731
                   sub_device,
2732
                   PID_CURVE_DESCRIPTION,
2733
                   &curve,
2734
                   sizeof(curve)),
UNCOV
2735
    error);
×
2736
}
2737

2738
/*
2739
 * @brief Fetch the dimmer info
2740
 * @param universe the universe to perform the call on
2741
 * @param uid the UID to fetch the dimmer info for
2742
 * @param sub_device the sub device to use
2743
 * @param callback the callback to invoke when this request completes
2744
 * @param error a pointer to a string which is set if an error occurs
2745
 * @return true if the request is sent correctly, false otherwise
2746
 */
UNCOV
2747
bool RDMAPI::GetDimmerInfo(
×
2748
    unsigned int universe,
2749
    const UID &uid,
2750
    uint16_t sub_device,
2751
    SingleUseCallback2<void,
2752
                       const ResponseStatus&,
2753
                       const DimmerInfoDescriptor&> *callback,
2754
    string *error) {
UNCOV
2755
  if (CheckCallback(error, callback)) {
×
UNCOV
2756
    return false;
×
2757
  }
2758

UNCOV
2759
  if (CheckNotBroadcast(uid, error, callback)) {
×
2760
    return false;
2761
  }
2762

UNCOV
2763
  if (CheckValidSubDevice(sub_device, false, error, callback)) {
×
2764
    return false;
2765
  }
2766

UNCOV
2767
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
2768
    this,
2769
    &RDMAPI::_HandleGetDimmerInfo,
2770
    callback);
UNCOV
2771
  return CheckReturnStatus(
×
UNCOV
2772
    m_impl->RDMGet(cb,
×
2773
                   universe,
2774
                   uid,
2775
                   sub_device,
2776
                   PID_DIMMER_INFO),
UNCOV
2777
    error);
×
2778
}
2779

2780
/*
2781
 * @brief Fetch the dimmer minimum levels
2782
 * @param universe the universe to perform the call on
2783
 * @param uid the UID to fetch the dimmer info for
2784
 * @param sub_device the sub device to use
2785
 * @param callback the callback to invoke when this request completes
2786
 * @param error a pointer to a string which is set if an error occurs
2787
 * @return true if the request is sent correctly, false otherwise
2788
 */
UNCOV
2789
bool RDMAPI::GetDimmerMinimumLevels(
×
2790
    unsigned int universe,
2791
    const UID &uid,
2792
    uint16_t sub_device,
2793
    SingleUseCallback2<void,
2794
                       const ResponseStatus&,
2795
                       const DimmerMinimumDescriptor&> *callback,
2796
    string *error) {
UNCOV
2797
  if (CheckCallback(error, callback)) {
×
UNCOV
2798
    return false;
×
2799
  }
2800

UNCOV
2801
  if (CheckNotBroadcast(uid, error, callback)) {
×
2802
    return false;
2803
  }
2804

UNCOV
2805
  if (CheckValidSubDevice(sub_device, false, error, callback)) {
×
2806
    return false;
2807
  }
2808

UNCOV
2809
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
2810
    this,
2811
    &RDMAPI::_HandleGetDimmerMinimumLevels,
2812
    callback);
UNCOV
2813
  return CheckReturnStatus(
×
UNCOV
2814
    m_impl->RDMGet(cb,
×
2815
                   universe,
2816
                   uid,
2817
                   sub_device,
2818
                   PID_MINIMUM_LEVEL),
UNCOV
2819
    error);
×
2820
}
2821

2822
/*
2823
 * @brief Set the dimmer minimum levels
2824
 * @param universe the universe to perform the call on
2825
 * @param uid the UID to set the dimmer curve for
2826
 * @param sub_device the sub device to use
2827
 * @param min_increasing the value for dimmer minimum while increasing
2828
 * @param min_decreasing the value for dimmer minimum while decreasing
2829
 * @param on_below_min the value set to either true or false to indicate whether
2830
 *        or not the dimmer stays on when minimum is exceeded
2831
 * @param callback the callback to invoke when this request completes
2832
 * @param error a pointer to a string which is set if an error occurs
2833
 * @return true if the request is sent correctly, false otherwise
2834
 */
UNCOV
2835
bool RDMAPI::SetDimmerMinimumLevels(
×
2836
    unsigned int universe,
2837
    const UID &uid,
2838
    uint16_t sub_device,
2839
    uint16_t min_increasing,
2840
    uint16_t min_decreasing,
2841
    bool on_below_min,
2842
    SingleUseCallback1<void, const ResponseStatus&> *callback,
2843
    string *error) {
UNCOV
2844
  if (CheckCallback(error, callback)) {
×
UNCOV
2845
    return false;
×
2846
  }
2847

UNCOV
2848
  if (CheckValidSubDevice(sub_device, true, error, callback)) {
×
2849
    return false;
2850
  }
2851

UNCOV
2852
  PACK(
×
2853
  struct minimum_levels {
2854
    uint16_t min_increasing;
2855
    uint16_t min_decreasing;
2856
    uint8_t on_below_min;
2857
  });
UNCOV
2858
  STATIC_ASSERT(sizeof(minimum_levels) == 5);
×
2859
  struct minimum_levels raw_levels;
×
2860

2861
  raw_levels.min_increasing = HostToNetwork(min_increasing);
×
UNCOV
2862
  raw_levels.min_decreasing = HostToNetwork(min_decreasing);
×
2863
  raw_levels.on_below_min = on_below_min;
×
2864

UNCOV
2865
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
2866
    this,
2867
    &RDMAPI::_HandleEmptyResponse,
2868
    callback);
UNCOV
2869
  return CheckReturnStatus(
×
UNCOV
2870
    m_impl->RDMSet(cb,
×
2871
                   universe,
2872
                   uid,
2873
                   sub_device,
2874
                   PID_MINIMUM_LEVEL,
2875
                   reinterpret_cast<const uint8_t*>(&raw_levels),
2876
                   sizeof(raw_levels)),
2877
    error);
2878
}
2879

2880
/*
2881
 * @brief Fetch the dimmer maximum level
2882
 * @param universe the universe to perform the call on
2883
 * @param uid the UID to fetch the dimmer info for
2884
 * @param sub_device the sub device to use
2885
 * @param callback the callback to invoke when this request completes
2886
 * @param error a pointer to a string which is set if an error occurs
2887
 * @return true if the request is sent correctly, false otherwise
2888
 */
UNCOV
2889
bool RDMAPI::GetDimmerMaximumLevel(
×
2890
    unsigned int universe,
2891
    const UID &uid,
2892
    uint16_t sub_device,
2893
    SingleUseCallback2<void, const ResponseStatus&, uint16_t> *callback,
2894
    string *error) {
2895

UNCOV
2896
  return GenericGetU16(
×
2897
      universe,
2898
      uid,
2899
      sub_device,
2900
      callback,
2901
      PID_MAXIMUM_LEVEL,
UNCOV
2902
      error);
×
2903
}
2904

2905
/*
2906
 * @brief Set the dimmer maximum level
2907
 * @param universe the universe to perform the call on
2908
 * @param uid the UID to fetch the outstanding message count for
2909
 * @param sub_device the sub device to use
2910
 * @param maximum_level the new maximum level
2911
 * @param callback the callback to invoke when this request completes
2912
 * @param error a pointer to a string which is set if an error occurs
2913
 * @return true if the request is sent correctly, false otherwise
2914
 */
UNCOV
2915
bool RDMAPI::SetDimmerMaximumLevel(
×
2916
    unsigned int universe,
2917
    const UID &uid,
2918
    uint16_t sub_device,
2919
    uint16_t maximum_level,
2920
    SingleUseCallback1<void, const ResponseStatus&> *callback,
2921
    string *error) {
2922

UNCOV
2923
  return GenericSetU16(
×
2924
      universe,
2925
      uid,
2926
      sub_device,
2927
      maximum_level,
2928
      callback,
2929
      PID_MAXIMUM_LEVEL,
UNCOV
2930
      error);
×
2931
}
2932

2933
/*
2934
 * @brief Check if a device is in self test mode.
2935
 * @param universe the universe to perform the call on
2936
 * @param uid the UID to fetch the outstanding message count for
2937
 * @param sub_device the sub device to use
2938
 * @param callback the callback to invoke when this request completes
2939
 * @param error a pointer to a string which is set if an error occurs
2940
 * @return true if the request is sent correctly, false otherwise
2941
*/
UNCOV
2942
bool RDMAPI::SelfTestEnabled(
×
2943
    unsigned int universe,
2944
    const UID &uid,
2945
    uint16_t sub_device,
2946
    SingleUseCallback2<void, const ResponseStatus&, bool> *callback,
2947
    string *error) {
2948
  if (CheckCallback(error, callback))
×
UNCOV
2949
    return false;
×
2950
  if (CheckNotBroadcast(uid, error, callback))
×
2951
    return false;
UNCOV
2952
  if (CheckValidSubDevice(sub_device, false, error, callback))
×
2953
    return false;
2954

UNCOV
2955
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
2956
    this,
2957
    &RDMAPI::_HandleBoolResponse,
2958
    callback);
UNCOV
2959
  return CheckReturnStatus(
×
UNCOV
2960
    m_impl->RDMGet(cb,
×
2961
                   universe,
2962
                   uid,
2963
                   sub_device,
2964
                   PID_PERFORM_SELFTEST),
UNCOV
2965
    error);
×
2966
}
2967

2968

2969
/*
2970
 * @brief Perform a self test on a device.
2971
 * @param universe the universe to perform the call on
2972
 * @param uid the UID to fetch the outstanding message count for
2973
 * @param sub_device the sub device to use
2974
 * @param self_test_number the number of the self test to perform.
2975
 * @param callback the callback to invoke when this request completes
2976
 * @param error a pointer to a string which is set if an error occurs
2977
 * @return true if the request is sent correctly, false otherwise
2978
*/
UNCOV
2979
bool RDMAPI::PerformSelfTest(
×
2980
    unsigned int universe,
2981
    const UID &uid,
2982
    uint16_t sub_device,
2983
    uint8_t self_test_number,
2984
    SingleUseCallback1<void, const ResponseStatus&> *callback,
2985
    string *error) {
2986
  if (CheckCallback(error, callback))
×
UNCOV
2987
    return false;
×
UNCOV
2988
  if (CheckValidSubDevice(sub_device, true, error, callback))
×
2989
    return false;
2990

UNCOV
2991
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
2992
    this,
2993
    &RDMAPI::_HandleEmptyResponse,
2994
    callback);
UNCOV
2995
  return CheckReturnStatus(
×
UNCOV
2996
    m_impl->RDMSet(cb,
×
2997
                   universe,
2998
                   uid,
2999
                   sub_device,
3000
                   PID_PERFORM_SELFTEST,
3001
                   &self_test_number,
3002
                   sizeof(self_test_number)),
UNCOV
3003
    error);
×
3004
}
3005

3006

3007
/*
3008
 * @brief Fetch the description of a self test.
3009
 * @param universe the universe to perform the call on
3010
 * @param uid the UID to fetch the outstanding message count for
3011
 * @param sub_device the sub device to use
3012
 * @param self_test_number the number of the self test to fetch the description
3013
 *   of.
3014
 * @param callback the callback to invoke when this request completes
3015
 * @param error a pointer to a string which is set if an error occurs
3016
 * @return true if the request is sent correctly, false otherwise
3017
*/
UNCOV
3018
bool RDMAPI::SelfTestDescription(
×
3019
    unsigned int universe,
3020
    const UID &uid,
3021
    uint16_t sub_device,
3022
    uint8_t self_test_number,
3023
    SingleUseCallback3<void, const ResponseStatus&, uint8_t,
3024
                       const string&> *callback,
3025
    string *error) {
3026
  if (CheckCallback(error, callback))
×
UNCOV
3027
    return false;
×
3028
  if (CheckNotBroadcast(uid, error, callback))
×
3029
    return false;
UNCOV
3030
  if (CheckValidSubDevice(sub_device, false, error, callback))
×
3031
    return false;
3032

UNCOV
3033
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
3034
    this,
3035
    &RDMAPI::_HandleSelfTestDescription,
3036
    callback);
UNCOV
3037
  return CheckReturnStatus(
×
UNCOV
3038
    m_impl->RDMGet(cb,
×
3039
                   universe,
3040
                   uid,
3041
                   sub_device,
3042
                   PID_SELF_TEST_DESCRIPTION,
3043
                   &self_test_number,
3044
                   sizeof(self_test_number)),
UNCOV
3045
    error);
×
3046
}
3047

3048

3049
/*
3050
 * @brief Capture the current state into a preset.
3051
 * @param universe the universe to perform the call on
3052
 * @param uid the UID to fetch the outstanding message count for
3053
 * @param sub_device the sub device to use
3054
 * @param scene the number of the preset scene to store
3055
 * @param fade_up_time the time in 10s of a second to fade up this scene.
3056
 * @param fade_down_time the time in 10s of a second to fade down the previous
3057
 *   scene.
3058
 * @param wait_time the time in 10s of a second to hold this scene when the
3059
 *   playback mode is PRESET_PLAYBACK_ALL
3060
 * @param callback the callback to invoke when this request completes
3061
 * @param error a pointer to a string which is set if an error occurs
3062
 * @return true if the request is sent correctly, false otherwise
3063
*/
UNCOV
3064
bool RDMAPI::CapturePreset(
×
3065
    unsigned int universe,
3066
    const UID &uid,
3067
    uint16_t sub_device,
3068
    uint16_t scene,
3069
    uint16_t fade_up_time,
3070
    uint16_t fade_down_time,
3071
    uint16_t wait_time,
3072
    SingleUseCallback1<void, const ResponseStatus&> *callback,
3073
    string *error) {
3074
  if (CheckCallback(error, callback))
×
UNCOV
3075
    return false;
×
UNCOV
3076
  if (CheckValidSubDevice(sub_device, true, error, callback))
×
3077
    return false;
3078

UNCOV
3079
  PACK(
×
3080
  struct preset_config {
3081
    uint16_t scene;
3082
    uint16_t fade_up_time;
3083
    uint16_t fade_down_time;
3084
    uint16_t wait_time;
3085
  });
UNCOV
3086
  STATIC_ASSERT(sizeof(preset_config) == 8);
×
3087
  struct preset_config raw_config;
×
3088

3089
  raw_config.scene = HostToNetwork(scene);
×
3090
  raw_config.fade_up_time = HostToNetwork(fade_up_time);
×
UNCOV
3091
  raw_config.fade_down_time = HostToNetwork(fade_down_time);
×
3092
  raw_config.wait_time = HostToNetwork(wait_time);
×
3093

UNCOV
3094
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
3095
    this,
3096
    &RDMAPI::_HandleEmptyResponse,
3097
    callback);
UNCOV
3098
  return CheckReturnStatus(
×
UNCOV
3099
    m_impl->RDMSet(cb,
×
3100
                   universe,
3101
                   uid,
3102
                   sub_device,
3103
                   PID_CAPTURE_PRESET,
3104
                   reinterpret_cast<const uint8_t*>(&raw_config),
3105
                   sizeof(raw_config)),
3106
    error);
3107
}
3108

3109

3110
/*
3111
 * @brief Fetch the current playback mode.
3112
 * @param universe the universe to perform the call on
3113
 * @param uid the UID to fetch the outstanding message count for
3114
 * @param sub_device the sub device to use
3115
 * @param callback the callback to invoke when this request completes
3116
 * @param error a pointer to a string which is set if an error occurs
3117
 * @return true if the request is sent correctly, false otherwise
3118
*/
UNCOV
3119
bool RDMAPI::PresetPlaybackMode(
×
3120
    unsigned int universe,
3121
    const UID &uid,
3122
    uint16_t sub_device,
3123
    SingleUseCallback3<void,
3124
                       const ResponseStatus&,
3125
                       uint16_t,
3126
                       uint8_t> *callback,
3127
    string *error) {
3128
  if (CheckCallback(error, callback))
×
UNCOV
3129
    return false;
×
3130
  if (CheckNotBroadcast(uid, error, callback))
×
3131
    return false;
UNCOV
3132
  if (CheckValidSubDevice(sub_device, false, error, callback))
×
3133
    return false;
3134

UNCOV
3135
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
3136
    this,
3137
    &RDMAPI::_HandlePlaybackMode,
3138
    callback);
UNCOV
3139
  return CheckReturnStatus(
×
UNCOV
3140
    m_impl->RDMGet(cb,
×
3141
                   universe,
3142
                   uid,
3143
                   sub_device,
3144
                   PID_PRESET_PLAYBACK,
3145
                   NULL,
3146
                   0),
UNCOV
3147
    error);
×
3148
}
3149

3150

3151
/*
3152
 * @brief Set the current playback mode.
3153
 * @param universe the universe to perform the call on
3154
 * @param uid the UID to fetch the outstanding message count for
3155
 * @param sub_device the sub device to use
3156
 * @param playback_mode the playback scene to use, PRESET_PLAYBACK_OFF or
3157
 *   PRESET_PLAYBACK_ALL.
3158
 * @param level the level to use for the scene.
3159
 * @param callback the callback to invoke when this request completes
3160
 * @param error a pointer to a string which is set if an error occurs
3161
 * @return true if the request is sent correctly, false otherwise
3162
*/
UNCOV
3163
bool RDMAPI::SetPresetPlaybackMode(
×
3164
    unsigned int universe,
3165
    const UID &uid,
3166
    uint16_t sub_device,
3167
    uint16_t playback_mode,
3168
    uint8_t level,
3169
    SingleUseCallback1<void, const ResponseStatus&> *callback,
3170
    string *error) {
3171

3172
  if (CheckCallback(error, callback))
×
UNCOV
3173
    return false;
×
UNCOV
3174
  if (CheckValidSubDevice(sub_device, true, error, callback))
×
3175
    return false;
3176

UNCOV
3177
  PACK(
×
3178
  struct preset_config {
3179
    uint16_t mode;
3180
    uint8_t level;
3181
  });
UNCOV
3182
  STATIC_ASSERT(sizeof(preset_config) == 3);
×
3183
  struct preset_config raw_config;
×
3184

UNCOV
3185
  raw_config.mode = HostToNetwork(playback_mode);
×
3186
  raw_config.level = level;
×
3187

UNCOV
3188
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
3189
    this,
3190
    &RDMAPI::_HandleEmptyResponse,
3191
    callback);
UNCOV
3192
  return CheckReturnStatus(
×
UNCOV
3193
    m_impl->RDMSet(cb,
×
3194
                   universe,
3195
                   uid,
3196
                   sub_device,
3197
                   PID_PRESET_PLAYBACK,
3198
                   reinterpret_cast<const uint8_t*>(&raw_config),
3199
                   sizeof(raw_config)),
3200
    error);
3201
}
3202

3203

3204
// Handlers follow. These are invoked by the RDMAPIImpl when responses arrive
3205
// ----------------------------------------------------------------------------
3206

3207
/*
3208
 * @brief Handle a response that contains a custom length ASCII string
3209
 */
3210
void RDMAPI::_HandleCustomLengthLabelResponse(
6✔
3211
    SingleUseCallback2<void,
3212
                       const ResponseStatus&,
3213
                       const string&> *callback,
3214
    uint8_t max_length,
3215
    const ResponseStatus &status,
3216
    const string &data) {
3217
  ResponseStatus response_status = status;
6✔
3218
  if (status.WasAcked() && data.size() > max_length) {
12✔
3219
    std::ostringstream str;
×
3220
    str << "PDL needs to be <= " << static_cast<int>(max_length) << ", was "
×
3221
        << data.size();
×
UNCOV
3222
    response_status.error = str.str();
×
UNCOV
3223
  }
×
3224

3225
  string label = data;
6✔
3226
  ShortenString(&label);
6✔
3227
  callback->Run(response_status, label);
6✔
3228
}
6✔
3229

3230

3231
/*
3232
 * @brief Handle a response that contains a 32 byte ASCII string
3233
 */
3234
void RDMAPI::_HandleLabelResponse(
6✔
3235
    SingleUseCallback2<void,
3236
                       const ResponseStatus&,
3237
                       const string&> *callback,
3238
    const ResponseStatus &status,
3239
    const string &data) {
3240
  _HandleCustomLengthLabelResponse(callback,
6✔
3241
                                   MAX_RDM_STRING_LENGTH,
3242
                                   status,
3243
                                   data);
3244
}
6✔
3245

3246

3247
/*
3248
 * @brief Handle a response that contains a bool
3249
 */
UNCOV
3250
void RDMAPI::_HandleBoolResponse(
×
3251
    SingleUseCallback2<void,
3252
                       const ResponseStatus&,
3253
                       bool> *callback,
3254
    const ResponseStatus &status,
3255
    const string &data) {
3256
  static const unsigned int DATA_SIZE = 1;
×
UNCOV
3257
  ResponseStatus response_status = status;
×
3258
  bool option = false;
×
3259

3260
  if (response_status.WasAcked()) {
×
UNCOV
3261
    if (data.size() == DATA_SIZE) {
×
3262
      option = data.data()[0];
×
3263
    } else {
UNCOV
3264
      SetIncorrectPDL(&response_status, data.size(), DATA_SIZE);
×
3265
    }
3266
  }
UNCOV
3267
  callback->Run(response_status, option);
×
UNCOV
3268
}
×
3269

3270

3271
/*
3272
 * @brief Handle a response that contains a uint8_t
3273
 */
UNCOV
3274
void RDMAPI::_HandleU8Response(
×
3275
    SingleUseCallback2<void,
3276
                       const ResponseStatus&,
3277
                       uint8_t> *callback,
3278
    const ResponseStatus &status,
3279
    const string &data) {
UNCOV
3280
  ResponseStatus response_status = status;
×
3281
  uint8_t value = 0;
×
3282

3283
  if (response_status.WasAcked()) {
×
UNCOV
3284
    if (data.size() == sizeof(value)) {
×
3285
      value = data.data()[0];
×
3286
    } else {
UNCOV
3287
      SetIncorrectPDL(&response_status, data.size(), sizeof(value));
×
3288
    }
3289
  }
UNCOV
3290
  callback->Run(response_status, value);
×
UNCOV
3291
}
×
3292

3293
/*
3294
 * @brief Handle a response that contains a uint16_t
3295
 */
3296
void RDMAPI::_HandleU16Response(
1✔
3297
    SingleUseCallback2<void,
3298
                       const ResponseStatus&,
3299
                       uint16_t> *callback,
3300
    const ResponseStatus &status,
3301
    const string &data) {
3302
  ResponseStatus response_status = status;
1✔
3303
  uint16_t value = 0;
1✔
3304

3305
  if (response_status.WasAcked()) {
1✔
3306
    if (data.size() == sizeof(value)) {
1✔
3307
      const uint16_t *ptr = reinterpret_cast<const uint16_t*>(data.data());
1✔
3308
      value = NetworkToHost(*ptr);
1✔
3309
    } else {
UNCOV
3310
      SetIncorrectPDL(&response_status, data.size(), sizeof(value));
×
3311
    }
3312
  }
3313
  callback->Run(response_status, value);
1✔
3314
}
1✔
3315

3316

3317
/*
3318
 * @brief Handle a response that contains a uint32_t
3319
 */
UNCOV
3320
void RDMAPI::_HandleU32Response(
×
3321
    SingleUseCallback2<void,
3322
                       const ResponseStatus&,
3323
                       uint32_t> *callback,
3324
    const ResponseStatus &status,
3325
    const string &data) {
UNCOV
3326
  ResponseStatus response_status = status;
×
3327
  uint32_t value = 0;
×
3328

3329
  if (response_status.WasAcked()) {
×
3330
    if (data.size() == sizeof(value)) {
×
UNCOV
3331
      const uint32_t *ptr = reinterpret_cast<const uint32_t*>(data.data());
×
3332
      value = NetworkToHost(*ptr);
×
3333
    } else {
UNCOV
3334
      SetIncorrectPDL(&response_status, data.size(), sizeof(value));
×
3335
    }
3336
  }
UNCOV
3337
  callback->Run(response_status, value);
×
UNCOV
3338
}
×
3339

3340

3341
/*
3342
 * @brief Handle a response that doesn't contain any data
3343
 */
3344
void RDMAPI::_HandleEmptyResponse(
10✔
3345
    SingleUseCallback1<void, const ResponseStatus&> *callback,
3346
    const ResponseStatus &status,
3347
    const string &data) {
3348
  ResponseStatus response_status = status;
10✔
3349
  if (response_status.WasAcked() && !data.empty())
14✔
UNCOV
3350
    SetIncorrectPDL(&response_status, data.size(), 0);
×
3351
  callback->Run(response_status);
10✔
3352
}
10✔
3353

3354

3355
/*
3356
 * @brief Handle a PROXIED_DEVICE_COUNT get response
3357
 */
3358
void RDMAPI::_HandleGetProxiedDeviceCount(
1✔
3359
    SingleUseCallback3<void,
3360
                       const ResponseStatus&,
3361
                       uint16_t,
3362
                       bool> *callback,
3363
    const ResponseStatus &status,
3364
    const string &data) {
3365
  static const unsigned int DATA_SIZE = 3;
1✔
3366
  ResponseStatus response_status = status;
1✔
3367

3368
  uint16_t device_count = 0;
1✔
3369
  bool list_change = false;
1✔
3370

3371
  if (response_status.WasAcked()) {
1✔
3372
    if (data.size() >= DATA_SIZE) {
1✔
3373
      struct {
1✔
3374
        uint16_t device_count;
3375
        uint8_t list_change;
3376
      } unpacked_data;
3377
      memcpy(&unpacked_data, data.data(), DATA_SIZE);
1✔
3378
      device_count = NetworkToHost(unpacked_data.device_count);
1✔
3379
      list_change = unpacked_data.list_change;
1✔
3380
    } else {
UNCOV
3381
      SetIncorrectPDL(&response_status, data.size(), DATA_SIZE);
×
3382
    }
3383
  }
3384
  callback->Run(response_status, device_count, list_change);
1✔
3385
}
1✔
3386

3387

3388
/*
3389
 * @brief Handle a PROXIED_DEVICES get response
3390
 */
3391
void RDMAPI::_HandleGetProxiedDevices(
1✔
3392
    SingleUseCallback2<void,
3393
                       const ResponseStatus&,
3394
                       const vector<UID>&> *callback,
3395
    const ResponseStatus &status,
3396
    const string &data) {
3397
  ResponseStatus response_status = status;
1✔
3398
  vector<UID> uids;
1✔
3399

3400
  unsigned int data_size = data.size();
1✔
3401
  if (response_status.WasAcked()) {
1✔
3402
    if (data_size % UID::UID_SIZE == 0) {
1✔
3403
      const uint8_t *start = reinterpret_cast<const uint8_t*>(data.data());
1✔
3404
      for (const uint8_t *ptr = start; ptr < start + data_size;
3✔
3405
           ptr += UID::UID_SIZE) {
2✔
3406
        UID uid(ptr);
2✔
3407
        uids.push_back(uid);
2✔
3408
      }
3409
    } else {
3410
      response_status.error = ("PDL size not a multiple of " +
×
UNCOV
3411
          IntToString(static_cast<int>(UID::UID_SIZE)) + " : " +
×
UNCOV
3412
          IntToString(static_cast<int>(data_size)));
×
3413
    }
3414
  }
3415
  callback->Run(response_status, uids);
1✔
3416
}
1✔
3417

3418

3419
/*
3420
 * @brief Handle a get COMMS_STATUS response
3421
 */
3422
void RDMAPI::_HandleGetCommStatus(
1✔
3423
    SingleUseCallback4<void,
3424
                       const ResponseStatus&,
3425
                       uint16_t,
3426
                       uint16_t,
3427
                       uint16_t> *callback,
3428
    const ResponseStatus &status,
3429
    const string &data) {
3430
  static const unsigned int DATA_SIZE = 6;
1✔
3431
  ResponseStatus response_status = status;
1✔
3432

3433
  uint16_t short_message = 0, length_mismatch = 0, checksum_fail = 0;
1✔
3434

3435
  if (response_status.WasAcked()) {
1✔
3436
    if (data.size() >= DATA_SIZE) {
1✔
3437
      struct {
1✔
3438
        uint16_t short_message;
3439
        uint16_t length_mismatch;
3440
        uint16_t checksum_fail;
3441
      } unpacked_data;
3442
      memcpy(&unpacked_data, data.data(), DATA_SIZE);
1✔
3443
      short_message = NetworkToHost(unpacked_data.short_message);
1✔
3444
      length_mismatch = NetworkToHost(unpacked_data.length_mismatch);
1✔
3445
      checksum_fail = NetworkToHost(unpacked_data.checksum_fail);
1✔
3446
    } else {
UNCOV
3447
      SetIncorrectPDL(&response_status, data.size(), DATA_SIZE);
×
3448
    }
3449
  }
3450
  callback->Run(response_status, short_message, length_mismatch,
1✔
3451
                checksum_fail);
3452
}
1✔
3453

3454

3455
/*
3456
 * @brief Handle a QUEUED_MESSAGE response
3457
 */
UNCOV
3458
void RDMAPI::_HandleQueuedMessage(
×
3459
    QueuedMessageHandler *handler,
3460
    const ResponseStatus &status,
3461
    uint16_t pid,
3462
    const string &data) {
3463

3464
  // now we need to switch on pid, and dispatch to the handler
3465
  // we should also pass the uid here
UNCOV
3466
  handler->DefaultHandler(status, pid, data);
×
UNCOV
3467
}
×
3468

3469

3470
/*
3471
 * @brief Handle a STATUS_MESSAGES response
3472
 */
UNCOV
3473
void RDMAPI::_HandleGetStatusMessage(
×
3474
    SingleUseCallback2<void,
3475
                       const ResponseStatus&,
3476
                       const vector<StatusMessage>&> *callback,
3477
    const ResponseStatus &status,
3478
    const string &data) {
3479

3480
  // Seriously WTF, learn how to align data structures
UNCOV
3481
  struct status_message {
×
3482
    uint8_t sub_device_hi;
3483
    uint8_t sub_device_lo;
3484
    uint8_t status_type;
3485
    uint8_t message_id_hi;
3486
    uint8_t message_id_lo;
3487
    uint8_t value_1_hi;
3488
    uint8_t value_1_lo;
3489
    uint8_t value_2_hi;
3490
    uint8_t value_2_lo;
3491
  } message;
3492

3493
  ResponseStatus response_status = status;
×
UNCOV
3494
  vector<StatusMessage> messages;
×
3495
  unsigned int data_size = data.size();
×
3496

3497
  if (response_status.WasAcked()) {
×
3498
    if (data_size % sizeof(message) == 0) {
×
3499
      const uint8_t *start = reinterpret_cast<const uint8_t*>(data.data());
×
3500
      for (const uint8_t *ptr = start; ptr < start + data_size;
×
3501
           ptr += sizeof(message)) {
×
3502
        memcpy(&message, ptr, sizeof(message));
×
3503
        StatusMessage msg_object;
×
3504
        msg_object.sub_device = (message.sub_device_hi << 8) +
×
3505
            message.sub_device_lo;
×
3506
        msg_object.status_message_id = (message.message_id_hi << 8) +
×
3507
            message.message_id_lo;
×
3508
        msg_object.value1 = (message.value_1_hi << 8) + message.value_1_lo;
×
3509
        msg_object.value2 = (message.value_2_hi << 8) + message.value_2_lo;
×
UNCOV
3510
        msg_object.status_type = message.status_type;
×
UNCOV
3511
        messages.push_back(msg_object);
×
3512
      }
3513
    } else {
3514
      response_status.error = ("PDL size not a multiple of " +
×
UNCOV
3515
          IntToString(static_cast<int>(sizeof(message))) + " : " +
×
UNCOV
3516
          IntToString(static_cast<int>(data_size)));
×
3517
    }
3518
  }
UNCOV
3519
  callback->Run(response_status, messages);
×
UNCOV
3520
}
×
3521

3522

3523
/*
3524
 * @brief Handle a get SUB_DEVICE_STATUS_REPORT_THRESHOLD message
3525
 */
UNCOV
3526
void RDMAPI::_HandleGetSubDeviceReporting(
×
3527
    SingleUseCallback2<void,
3528
                       const ResponseStatus&,
3529
                       uint8_t> *callback,
3530
    const ResponseStatus &status,
3531
    const string &data) {
UNCOV
3532
  ResponseStatus response_status = status;
×
3533
  uint8_t status_type = 0;
×
3534

3535
  if (response_status.WasAcked()) {
×
UNCOV
3536
    if (data.size() == sizeof(status_type)) {
×
3537
      status_type = data.data()[0];
×
3538
    } else {
UNCOV
3539
      SetIncorrectPDL(&response_status, data.size(), sizeof(status_type));
×
3540
    }
3541
  }
UNCOV
3542
  callback->Run(response_status, status_type);
×
UNCOV
3543
}
×
3544

3545

3546
/*
3547
 * @brief Handle a SUPPORTED_PARAMETERS Get command
3548
 */
3549
void RDMAPI::_HandleGetSupportedParameters(
1✔
3550
    SingleUseCallback2<void,
3551
                       const ResponseStatus&,
3552
                       const vector<uint16_t>&> *callback,
3553
    const ResponseStatus &status,
3554
    const string &data) {
3555
  ResponseStatus response_status = status;
1✔
3556
  vector<uint16_t> pids;
1✔
3557

3558
  unsigned int data_size = data.size();
1✔
3559
  if (response_status.WasAcked()) {
1✔
3560
    if (data_size % 2 == 0) {
1✔
3561
      const uint16_t *start = reinterpret_cast<const uint16_t*>(data.data());
1✔
3562
      const uint16_t *end = start + (data_size / sizeof(*start));
1✔
3563
      for (const uint16_t *ptr = start; ptr < end; ptr++) {
4✔
3564
        pids.push_back(NetworkToHost(*ptr));
3✔
3565
      }
3566
    } else {
UNCOV
3567
      response_status.error = ("PDL size not a multiple of 2 : " +
×
UNCOV
3568
          IntToString(static_cast<int>(data_size)));
×
3569
    }
3570
    sort(pids.begin(), pids.end());
1✔
3571
  }
3572
  callback->Run(response_status, pids);
1✔
3573
}
1✔
3574

3575

3576
/*
3577
 * @brief Handle a PARAMETER_DESCRIPTION message
3578
 */
3579
void RDMAPI::_HandleGetParameterDescriptor(
2✔
3580
    SingleUseCallback2<void,
3581
                       const ResponseStatus&,
3582
                       const ParameterDescriptor&> *callback,
3583
    const ResponseStatus &status,
3584
    const string &data) {
3585
  ResponseStatus response_status = status;
2✔
3586
  ParameterDescriptor description;
2✔
3587

3588
  if (response_status.WasAcked()) {
2✔
3589
    PACK(
2✔
3590
    struct param_description {
3591
      uint16_t pid;
3592
      uint8_t pdl_size;
3593
      uint8_t data_type;
3594
      uint8_t command_class;
3595
      uint8_t type;
3596
      uint8_t unit;
3597
      uint8_t prefix;
3598
      uint32_t min_value;
3599
      uint32_t max_value;
3600
      uint32_t default_value;
3601
      // +1 for a null since it's not clear in the spec if this is null
3602
      // terminated
3603
      char description[MAX_RDM_STRING_LENGTH + 1];
3604
    });
3605
    STATIC_ASSERT(sizeof(param_description) == 53);
2✔
3606
    struct param_description raw_description;
2✔
3607

3608
    unsigned int max = sizeof(raw_description) - 1;
2✔
3609
    unsigned int min = max - MAX_RDM_STRING_LENGTH;
2✔
3610
    unsigned int data_size = data.size();
2✔
3611
    if (data_size >= min && data_size <= max) {
2✔
3612
      memcpy(&raw_description, data.data(),
1✔
3613
             std::min(static_cast<unsigned int>(data.size()), max));
1✔
3614
      raw_description.description[MAX_RDM_STRING_LENGTH] = 0;
1✔
3615

3616
      description.pid = NetworkToHost(raw_description.pid);
1✔
3617
      description.pdl_size = raw_description.pdl_size;
1✔
3618
      description.data_type = raw_description.data_type;
1✔
3619
      description.command_class = raw_description.command_class;
1✔
3620
      description.unit = raw_description.unit;
1✔
3621
      description.prefix = raw_description.prefix;
1✔
3622
      description.min_value = NetworkToHost(raw_description.min_value);
1✔
3623
      description.default_value = NetworkToHost(raw_description.default_value);
1✔
3624
      description.max_value = NetworkToHost(raw_description.max_value);
1✔
3625
      unsigned int label_size = data_size - (
1✔
3626
          sizeof(raw_description) - MAX_RDM_STRING_LENGTH - 1);
3627
      description.description = string(raw_description.description,
1✔
3628
                                       label_size);
1✔
3629
      ShortenString(&description.description);
1✔
3630
    } else {
3631
      std::ostringstream str;
1✔
3632
      str << data_size << " needs to be between " << min << " and " << max;
1✔
3633
      response_status.error = str.str();
1✔
3634
    }
1✔
3635
  }
3636
  callback->Run(response_status, description);
2✔
3637
}
3✔
3638

3639

3640
/*
3641
 * @brief Handle a DEVICE_INFO Get command
3642
 */
3643
void RDMAPI::_HandleGetDeviceDescriptor(
1✔
3644
    SingleUseCallback2<void,
3645
                       const ResponseStatus&,
3646
                       const DeviceDescriptor&> *callback,
3647
    const ResponseStatus &status,
3648
    const string &data) {
3649
  ResponseStatus response_status = status;
1✔
3650
  DeviceDescriptor device_info;
1✔
3651

3652
  if (response_status.WasAcked()) {
1✔
3653
    unsigned int data_size = data.size();
1✔
3654
    if (data_size == sizeof(device_info)) {
1✔
3655
      memcpy(&device_info, data.data(), sizeof(device_info));
1✔
3656
      device_info.device_model = NetworkToHost(device_info.device_model);
1✔
3657
      device_info.product_category =
2✔
3658
        NetworkToHost(device_info.product_category);
1✔
3659
      device_info.software_version =
2✔
3660
        NetworkToHost(device_info.software_version);
1✔
3661
      device_info.dmx_footprint =
2✔
3662
        NetworkToHost(device_info.dmx_footprint);
1✔
3663
      device_info.dmx_start_address =
2✔
3664
        NetworkToHost(device_info.dmx_start_address);
1✔
3665
      device_info.sub_device_count =
1✔
3666
        NetworkToHost(device_info.sub_device_count);
1✔
3667
    } else {
UNCOV
3668
      SetIncorrectPDL(&response_status, data.size(), sizeof(device_info));
×
3669
    }
3670
  }
3671
  callback->Run(response_status, device_info);
1✔
3672
}
1✔
3673

3674

3675
/*
3676
 * @brief Handle a PRODUCT_DETAIL_ID_LIST response
3677
 */
3678
void RDMAPI::_HandleGetProductDetailIdList(
1✔
3679
    SingleUseCallback2<void,
3680
                       const ResponseStatus&,
3681
                       const vector<uint16_t>&> *callback,
3682
    const ResponseStatus &status,
3683
    const string &data) {
3684
  static const unsigned int MAX_DETAIL_IDS = 6;
1✔
3685
  ResponseStatus response_status = status;
1✔
3686
  vector<uint16_t> product_detail_ids;
1✔
3687

3688
  if (response_status.WasAcked()) {
1✔
3689
    unsigned int data_size = data.size();
1✔
3690
    if (data_size > MAX_DETAIL_IDS * sizeof(uint16_t)) {
1✔
3691
      std::ostringstream str;
×
3692
      str << "PDL needs to be <= " << (MAX_DETAIL_IDS * sizeof(uint16_t)) <<
×
UNCOV
3693
        ", was " << data_size;
×
3694
      response_status.error = str.str();
×
3695
    } else if (data_size % 2) {
1✔
3696
      std::ostringstream str;
×
3697
      str << "PDL needs to be a multiple of 2, was " << data_size;
×
UNCOV
3698
      response_status.error = str.str();
×
UNCOV
3699
    } else {
×
3700
      const uint16_t *start = reinterpret_cast<const uint16_t*>(data.data());
1✔
3701
      const uint16_t *end = start + (data_size / sizeof(*start));
1✔
3702
      for (const uint16_t *ptr = start; ptr < end; ptr++) {
4✔
3703
        product_detail_ids.push_back(NetworkToHost(*ptr));
3✔
3704
      }
3705
    }
3706
  }
3707
  callback->Run(response_status, product_detail_ids);
1✔
3708
}
1✔
3709

3710

3711
/*
3712
 * @brief Handle a LANGUAGE_CAPABILITIES response
3713
 */
UNCOV
3714
void RDMAPI::_HandleGetLanguageCapabilities(
×
3715
    SingleUseCallback2<void,
3716
                       const ResponseStatus&,
3717
                       const vector<string>&> *callback,
3718
    const ResponseStatus &status,
3719
    const string &data) {
UNCOV
3720
  ResponseStatus response_status = status;
×
3721
  vector<string> languages;
×
3722

3723
  if (response_status.WasAcked()) {
×
3724
    unsigned int data_size = data.size();
×
3725
    if (data_size % 2) {
×
3726
      std::ostringstream str;
×
3727
      str << "PDL needs to be a multiple of 2, was " << data_size;
×
3728
      response_status.error = str.str();
×
3729
    } else {
×
3730
      const char *ptr = data.data();
×
3731
      const char *end = data.data() + data.size();
×
3732
      while (ptr < end) {
×
UNCOV
3733
        languages.push_back(string(ptr, 2));
×
UNCOV
3734
        ptr+=2;
×
3735
      }
3736
    }
3737
  }
UNCOV
3738
  callback->Run(response_status, languages);
×
UNCOV
3739
}
×
3740

3741

3742
/*
3743
 * @brief Handle a LANGUAGE response
3744
 */
UNCOV
3745
void RDMAPI::_HandleGetLanguage(
×
3746
    SingleUseCallback2<void,
3747
                       const ResponseStatus&,
3748
                       const string&> *callback,
3749
    const ResponseStatus &status,
3750
    const string &data) {
3751
  ResponseStatus response_status = status;
×
3752
  static const unsigned int DATA_SIZE = 2;
×
UNCOV
3753
  if (response_status.WasAcked() && data.size() != DATA_SIZE) {
×
3754
    SetIncorrectPDL(&response_status, data.size(), DATA_SIZE);
×
3755
  }
UNCOV
3756
  callback->Run(response_status, data);
×
UNCOV
3757
}
×
3758

3759

3760
/*
3761
 * @brief Handle a BOOT_SOFTWARE_VERSION_ID response
3762
 */
UNCOV
3763
void RDMAPI::_HandleGetBootSoftwareVersion(
×
3764
    SingleUseCallback2<void,
3765
                       const ResponseStatus&,
3766
                       uint32_t> *callback,
3767
    const ResponseStatus &status,
3768
    const string &data) {
3769
  ResponseStatus response_status = status;
×
3770
  static const unsigned int DATA_SIZE = 4;
×
3771
  uint32_t boot_version = 0;
×
3772
  if (response_status.WasAcked()) {
×
UNCOV
3773
    if (data.size() != DATA_SIZE) {
×
3774
      SetIncorrectPDL(&response_status, data.size(), DATA_SIZE);
×
3775
    } else {
UNCOV
3776
      boot_version = *(reinterpret_cast<const uint32_t*>(data.data()));
×
UNCOV
3777
      boot_version = NetworkToHost(boot_version);
×
3778
    }
3779
  }
UNCOV
3780
  callback->Run(response_status, boot_version);
×
UNCOV
3781
}
×
3782

3783

3784
/*
3785
 * @brief Handle a get DMX_PERSONALITY response
3786
 */
UNCOV
3787
void RDMAPI::_HandleGetDMXPersonality(
×
3788
    SingleUseCallback3<void,
3789
                       const ResponseStatus&,
3790
                       uint8_t,
3791
                       uint8_t> *callback,
3792
    const ResponseStatus &status,
3793
    const string &data) {
3794
  ResponseStatus response_status = status;
×
3795
  static const unsigned int DATA_SIZE = 2;
×
3796
  uint8_t current_personality = 0;
×
3797
  uint8_t personality_count = 0;
×
3798
  if (response_status.WasAcked()) {
×
UNCOV
3799
    if (data.size() != DATA_SIZE) {
×
3800
      SetIncorrectPDL(&response_status, data.size(), DATA_SIZE);
×
3801
    } else {
UNCOV
3802
      current_personality = data[0];
×
UNCOV
3803
      personality_count = data[1];
×
3804
    }
3805
  }
UNCOV
3806
  callback->Run(response_status, current_personality, personality_count);
×
UNCOV
3807
}
×
3808

3809

3810
/*
3811
 * @brief Handle a get DMX_PERSONALITY_DESCRIPTION response
3812
 */
UNCOV
3813
void RDMAPI::_HandleGetDMXPersonalityDescription(
×
3814
    SingleUseCallback4<void,
3815
                       const ResponseStatus&,
3816
                       uint8_t,
3817
                       uint16_t,
3818
                       const string&> *callback,
3819
    const ResponseStatus &status,
3820
    const string &data) {
3821
  ResponseStatus response_status = status;
×
3822

3823
  uint8_t personality = 0;
×
UNCOV
3824
  uint16_t dmx_slots = 0;
×
3825
  string description;
×
3826

UNCOV
3827
  if (response_status.WasAcked()) {
×
UNCOV
3828
    PACK(
×
3829
    struct personality_description {
3830
      uint8_t personality;
3831
      uint16_t dmx_slots;
3832
      // +1 for a null since it's not clear in the spec if this is null
3833
      // terminated
3834
      char description[MAX_RDM_STRING_LENGTH + 1];
3835
    });
UNCOV
3836
    STATIC_ASSERT(sizeof(personality_description) == 36);
×
3837
    struct personality_description raw_description;
×
3838

3839
    unsigned int max = sizeof(personality_description) - 1;
×
3840
    unsigned int min = max - MAX_RDM_STRING_LENGTH;
×
3841
    unsigned int data_size = data.size();
×
3842
    if (data_size >= min && data_size <= max) {
×
3843
      memcpy(&raw_description, data.data(),
×
3844
             std::min(static_cast<unsigned int>(data.size()), max));
×
3845
      personality = raw_description.personality;
×
3846
      dmx_slots = NetworkToHost(raw_description.dmx_slots);
×
UNCOV
3847
      description = string(raw_description.description, data_size - min);
×
3848
      ShortenString(&description);
×
3849
    } else {
3850
      std::ostringstream str;
×
3851
      str << data_size << " needs to be between " << min << " and " << max;
×
UNCOV
3852
      response_status.error = str.str();
×
3853
    }
×
3854
  }
UNCOV
3855
  callback->Run(response_status, personality, dmx_slots, description);
×
UNCOV
3856
}
×
3857

3858

3859
/*
3860
 * @brief Handle a get SLOT_INFO response
3861
 */
UNCOV
3862
void RDMAPI::_HandleGetSlotInfo(
×
3863
    SingleUseCallback2<void,
3864
                       const ResponseStatus&,
3865
                       const vector<SlotDescriptor>&> *callback,
3866
    const ResponseStatus &status,
3867
    const string &data) {
3868
  ResponseStatus response_status = status;
×
3869
  vector<SlotDescriptor> slots;
×
UNCOV
3870
  SlotDescriptor slot_info;
×
3871
  unsigned int slot_info_size = sizeof(slot_info);
×
3872

3873
  unsigned int data_size = data.size();
×
3874
  if (response_status.WasAcked()) {
×
3875
    if (data_size % slot_info_size) {
×
3876
      response_status.error = ("PDL size not a multiple of " +
×
UNCOV
3877
          IntToString(slot_info_size) + ", was " +
×
3878
          IntToString(static_cast<int>(data_size)));
×
3879
    } else {
3880
      const uint8_t *ptr = reinterpret_cast<const uint8_t*>(data.data());
×
3881
      const uint8_t *end = ptr + data.size();
×
3882
      while (ptr < end) {
×
3883
        memcpy(&slot_info, ptr, slot_info_size);
×
3884
        slot_info.slot_offset = NetworkToHost(slot_info.slot_offset);
×
UNCOV
3885
        slot_info.slot_label = NetworkToHost(slot_info.slot_label);
×
UNCOV
3886
        slots.push_back(slot_info);
×
3887
      }
3888
    }
3889
  }
UNCOV
3890
  callback->Run(response_status, slots);
×
UNCOV
3891
}
×
3892

3893

3894
/*
3895
 * @brief Handle a get SLOT_DESCRIPTION response
3896
 */
UNCOV
3897
void RDMAPI::_HandleGetSlotDescription(
×
3898
    SingleUseCallback3<void,
3899
                       const ResponseStatus&,
3900
                       uint16_t,
3901
                       const string&> *callback,
3902
    const ResponseStatus &status,
3903
    const string &data) {
3904
  ResponseStatus response_status = status;
×
3905

UNCOV
3906
  uint16_t slot_index = 0;
×
3907
  string description;
×
3908

UNCOV
3909
  if (response_status.WasAcked()) {
×
UNCOV
3910
    PACK(
×
3911
    struct slot_description {
3912
      uint16_t slot_index;
3913
      // +1 for a null since it's not clear in the spec if this is null
3914
      // terminated
3915
      char description[MAX_RDM_STRING_LENGTH + 1];
3916
    });
UNCOV
3917
    STATIC_ASSERT(sizeof(slot_description) == 35);
×
3918
    struct slot_description raw_description;
×
3919

3920
    unsigned int max = sizeof(raw_description) - 1;
×
3921
    unsigned int min = max - MAX_RDM_STRING_LENGTH;
×
3922
    unsigned int data_size = data.size();
×
3923
    if (data_size >= min && data_size <= max) {
×
3924
      raw_description.description[MAX_RDM_STRING_LENGTH] = 0;
×
3925
      memcpy(&raw_description, data.data(), data.size());
×
3926
      slot_index = NetworkToHost(raw_description.slot_index);
×
3927
      description = string(raw_description.description,
×
UNCOV
3928
                           data.size() - min);
×
3929
      ShortenString(&description);
×
3930
    } else {
3931
      std::ostringstream str;
×
3932
      str << data_size << " needs to be between " << min << " and " << max;
×
UNCOV
3933
      response_status.error = str.str();
×
3934
    }
×
3935
  }
UNCOV
3936
  callback->Run(response_status, slot_index, description);
×
UNCOV
3937
}
×
3938

3939

3940
/*
3941
 * @brief Handle a get DEFAULT_SLOT_VALUE response
3942
 */
UNCOV
3943
void RDMAPI::_HandleGetSlotDefaultValues(
×
3944
    SingleUseCallback2<void,
3945
                       const ResponseStatus&,
3946
                       const vector<SlotDefault>&> *callback,
3947
    const ResponseStatus &status,
3948
    const string &data) {
3949
  ResponseStatus response_status = status;
×
3950
  vector<SlotDefault> slots;
×
UNCOV
3951
  SlotDefault slot_default;
×
3952
  unsigned int slot_default_size = sizeof(slot_default);
×
3953

3954
  unsigned int data_size = data.size();
×
3955
  if (response_status.WasAcked()) {
×
3956
    if (data_size % slot_default_size) {
×
3957
      response_status.error = ("PDL size not a multiple of " +
×
UNCOV
3958
          IntToString(slot_default_size) + ", was " +
×
3959
          IntToString(static_cast<int>(data_size)));
×
3960
    } else {
3961
      const uint8_t *ptr = reinterpret_cast<const uint8_t*>(data.data());
×
3962
      const uint8_t *end = ptr + data.size();
×
3963
      while (ptr < end) {
×
3964
        memcpy(&slot_default, ptr, slot_default_size);
×
UNCOV
3965
        slot_default.slot_offset = NetworkToHost(slot_default.slot_offset);
×
UNCOV
3966
        slots.push_back(slot_default);
×
3967
      }
3968
    }
3969
  }
UNCOV
3970
  callback->Run(response_status, slots);
×
UNCOV
3971
}
×
3972

3973

3974
/*
3975
 * @brief Handle a SENSOR_DEFINITION response
3976
 */
UNCOV
3977
void RDMAPI::_HandleGetSensorDefinition(
×
3978
    SingleUseCallback2<void,
3979
                       const ResponseStatus&,
3980
                       const SensorDescriptor&> *callback,
3981
    const ResponseStatus &status,
3982
    const string &data) {
UNCOV
3983
  ResponseStatus response_status = status;
×
3984
  SensorDescriptor sensor;
×
3985

UNCOV
3986
  if (response_status.WasAcked()) {
×
UNCOV
3987
    PACK(
×
3988
    struct sensor_definition_s {
3989
      uint8_t sensor_number;
3990
      uint8_t type;
3991
      uint8_t unit;
3992
      uint8_t prefix;
3993
      int16_t range_min;
3994
      int16_t range_max;
3995
      int16_t normal_min;
3996
      int16_t normal_max;
3997
      uint8_t recorded_value_support;
3998
      char description[MAX_RDM_STRING_LENGTH + 1];
3999
    });
UNCOV
4000
    STATIC_ASSERT(sizeof(sensor_definition_s) == 46);
×
4001
    struct sensor_definition_s raw_description;
×
4002

4003
    unsigned int max = sizeof(raw_description) - 1;
×
4004
    unsigned int min = max - MAX_RDM_STRING_LENGTH;
×
4005
    unsigned int data_size = data.size();
×
4006
    if (data_size >= min && data_size <= max) {
×
UNCOV
4007
      memcpy(&raw_description, data.data(),
×
4008
             std::min(static_cast<unsigned int>(data.size()), max));
×
4009

4010
      sensor.sensor_number = raw_description.sensor_number;
×
4011
      sensor.type = raw_description.type;
×
4012
      sensor.unit = raw_description.unit;
×
4013
      sensor.prefix = raw_description.prefix;
×
4014
      sensor.range_min = NetworkToHost(raw_description.range_min);
×
4015
      sensor.range_max = NetworkToHost(raw_description.range_max);
×
4016
      sensor.normal_min = NetworkToHost(raw_description.normal_min);
×
4017
      sensor.normal_max = NetworkToHost(raw_description.normal_max);
×
4018
      sensor.recorded_value_support = raw_description.recorded_value_support;
×
4019
      sensor.description = string(raw_description.description,
×
UNCOV
4020
                                  data_size - min);
×
4021
      ShortenString(&sensor.description);
×
4022
    } else {
4023
      std::ostringstream str;
×
4024
      str << data_size << " needs to be between " << min << " and " << max;
×
UNCOV
4025
      response_status.error = str.str();
×
4026
    }
×
4027
  }
UNCOV
4028
  callback->Run(response_status, sensor);
×
UNCOV
4029
}
×
4030

4031

4032
/*
4033
 * @brief Handle a SENSOR_VALUE response
4034
 */
UNCOV
4035
void RDMAPI::_HandleSensorValue(
×
4036
    SingleUseCallback2<void,
4037
                       const ResponseStatus&,
4038
                       const SensorValueDescriptor&> *callback,
4039
    const ResponseStatus &status,
4040
    const string &data) {
UNCOV
4041
  ResponseStatus response_status = status;
×
4042
  SensorValueDescriptor sensor;
×
4043

4044
  if (response_status.WasAcked()) {
×
4045
    unsigned int data_size = data.size();
×
4046
    if (data_size == sizeof(sensor)) {
×
4047
      memcpy(&sensor, data.data(), sizeof(sensor));
×
4048
      sensor.present_value = NetworkToHost(sensor.present_value);
×
4049
      sensor.lowest = NetworkToHost(sensor.lowest);
×
UNCOV
4050
      sensor.highest = NetworkToHost(sensor.highest);
×
4051
      sensor.recorded = NetworkToHost(sensor.recorded);
×
4052
    } else {
UNCOV
4053
      SetIncorrectPDL(&response_status, data.size(), sizeof(sensor));
×
4054
    }
4055
  }
UNCOV
4056
  callback->Run(response_status, sensor);
×
UNCOV
4057
}
×
4058

4059

4060
/*
4061
 * @brief Handle a REAL_TIME_CLOCK response
4062
 */
UNCOV
4063
void RDMAPI::_HandleClock(
×
4064
    SingleUseCallback2<void,
4065
                       const ResponseStatus&,
4066
                       const ClockValue&> *callback,
4067
    const ResponseStatus &status,
4068
    const string &data) {
UNCOV
4069
  ResponseStatus response_status = status;
×
4070
  ClockValue clock;
×
4071

4072
  if (response_status.WasAcked()) {
×
4073
    unsigned int data_size = data.size();
×
4074
    if (data_size == sizeof(clock)) {
×
UNCOV
4075
      memcpy(&clock, data.data(), sizeof(clock));
×
4076
      clock.year = NetworkToHost(clock.year);
×
4077
    } else {
UNCOV
4078
      SetIncorrectPDL(&response_status, data.size(), sizeof(clock));
×
4079
    }
4080
  }
UNCOV
4081
  callback->Run(response_status, clock);
×
UNCOV
4082
}
×
4083

4084

4085
/**
4086
 * @brief Handle a PID_SELF_TEST_DESCRIPTION response.
4087
 */
UNCOV
4088
void RDMAPI::_HandleSelfTestDescription(
×
4089
    SingleUseCallback3<void,
4090
                       const ResponseStatus&,
4091
                       uint8_t,
4092
                       const string&> *callback,
4093
    const ResponseStatus &status,
4094
    const string &data) {
4095
  ResponseStatus response_status = status;
×
4096

UNCOV
4097
  uint8_t self_test_number = 0;
×
4098
  string description;
×
4099

UNCOV
4100
  if (response_status.WasAcked()) {
×
UNCOV
4101
    PACK(
×
4102
    struct self_test_description {
4103
      uint8_t self_test_number;
4104
      // +1 for a null since it's not clear in the spec if this is null
4105
      // terminated
4106
      char description[MAX_RDM_STRING_LENGTH + 1];
4107
    });
UNCOV
4108
    STATIC_ASSERT(sizeof(self_test_description) == 34);
×
4109
    struct self_test_description raw_description;
×
4110

4111
    unsigned int max = sizeof(raw_description) - 1;
×
4112
    unsigned int min = max - MAX_RDM_STRING_LENGTH;
×
4113
    unsigned int data_size = data.size();
×
4114
    if (data_size >= min && data_size <= max) {
×
4115
      raw_description.description[MAX_RDM_STRING_LENGTH] = 0;
×
4116
      memcpy(&raw_description, data.data(), data.size());
×
4117
      self_test_number = raw_description.self_test_number;
×
4118
      description = string(raw_description.description,
×
UNCOV
4119
                           data.size() - min);
×
4120
      ShortenString(&description);
×
4121
    } else {
4122
      std::ostringstream str;
×
4123
      str << data_size << " needs to be between " << min << " and " << max;
×
UNCOV
4124
      response_status.error = str.str();
×
4125
    }
×
4126
  }
UNCOV
4127
  callback->Run(response_status, self_test_number, description);
×
UNCOV
4128
}
×
4129

4130

4131
/**
4132
 * @brief Handle a PID_PRESET_PLAYBACK response
4133
 */
UNCOV
4134
void RDMAPI::_HandlePlaybackMode(
×
4135
    SingleUseCallback3<void,
4136
                       const ResponseStatus&,
4137
                       uint16_t,
4138
                       uint8_t> *callback,
4139
    const ResponseStatus &status,
4140
    const string &data) {
4141
  ResponseStatus response_status = status;
×
4142

UNCOV
4143
  uint16_t mode = 0;
×
4144
  uint8_t level = 0;
×
4145

UNCOV
4146
  if (response_status.WasAcked()) {
×
UNCOV
4147
    PACK(
×
4148
    struct preset_mode {
4149
      uint16_t mode;
4150
      uint8_t level;
4151
    });
UNCOV
4152
    STATIC_ASSERT(sizeof(preset_mode) == 3);
×
4153
    struct preset_mode raw_config;
×
4154

4155
    if (data.size() >= sizeof(raw_config)) {
×
4156
      memcpy(&raw_config, data.data(), data.size());
×
UNCOV
4157
      mode = NetworkToHost(raw_config.mode);
×
4158
      level = raw_config.level;
×
4159
    } else {
4160
      std::ostringstream str;
×
4161
      str << data.size() << " needs to be more than " << sizeof(raw_config);
×
UNCOV
4162
      response_status.error = str.str();
×
4163
    }
×
4164
  }
UNCOV
4165
  callback->Run(response_status, mode, level);
×
UNCOV
4166
}
×
4167

4168
/*
4169
 * @brief Handle a get CURVE response
4170
 */
UNCOV
4171
void RDMAPI::_HandleGetCurve(
×
4172
    SingleUseCallback3<void,
4173
                       const ResponseStatus&,
4174
                       uint8_t,
4175
                       uint8_t> *callback,
4176
    const ResponseStatus &status,
4177
    const string &data) {
4178
  ResponseStatus response_status = status;
×
4179
  static const unsigned int DATA_SIZE = 2;
×
4180
  uint8_t active_curve = 0;
×
4181
  uint8_t curve_count = 0;
×
4182
  if (response_status.WasAcked()) {
×
UNCOV
4183
    if (data.size() != DATA_SIZE) {
×
4184
      SetIncorrectPDL(&response_status, data.size(), DATA_SIZE);
×
4185
    } else {
UNCOV
4186
      active_curve = data[0];
×
UNCOV
4187
      curve_count = data[1];
×
4188
    }
4189
  }
UNCOV
4190
  callback->Run(response_status, active_curve, curve_count);
×
UNCOV
4191
}
×
4192

4193
/*
4194
 * @brief Handle a get CURVE_DESCRIPTION response
4195
 */
UNCOV
4196
void RDMAPI::_HandleGetCurveDescription(
×
4197
    SingleUseCallback3<void,
4198
                       const ResponseStatus&,
4199
                       uint8_t,
4200
                       const string&> *callback,
4201
    const ResponseStatus &status,
4202
    const string &data) {
4203
  ResponseStatus response_status = status;
×
4204

UNCOV
4205
  uint8_t requested_curve = 0;
×
4206
  string description;
×
4207

UNCOV
4208
  if (response_status.WasAcked()) {
×
UNCOV
4209
    PACK(
×
4210
    struct curve_description {
4211
      uint8_t curve;
4212
      // +1 for a null since it's not clear in the spec if this is null
4213
      // terminated
4214
      char description[MAX_RDM_STRING_LENGTH + 1];
4215
    });
UNCOV
4216
    STATIC_ASSERT(sizeof(curve_description) == 34);
×
4217
    struct curve_description raw_description;
×
4218

4219
    unsigned int max = sizeof(curve_description) - 1;
×
4220
    unsigned int min = max - MAX_RDM_STRING_LENGTH;
×
4221
    unsigned int data_size = data.size();
×
4222
    if (data_size >= min && data_size <= max) {
×
4223
      memcpy(&raw_description, data.data(),
×
4224
             std::min(static_cast<unsigned int>(data.size()), max));
×
4225
      requested_curve = raw_description.curve;
×
UNCOV
4226
      description = string(raw_description.description, data_size - min);
×
4227
      ShortenString(&description);
×
4228
    } else {
4229
      std::ostringstream str;
×
4230
      str << data_size << " needs to be between " << min << " and " << max;
×
UNCOV
4231
      response_status.error = str.str();
×
4232
    }
×
4233
  }
UNCOV
4234
  callback->Run(response_status, requested_curve, description);
×
UNCOV
4235
}
×
4236

4237
/*
4238
 * @brief Handle a get DIMMER_INFO response
4239
 */
UNCOV
4240
void RDMAPI::_HandleGetDimmerInfo(
×
4241
    SingleUseCallback2<void,
4242
                       const ResponseStatus&,
4243
                       const DimmerInfoDescriptor&> *callback,
4244
    const ResponseStatus &status,
4245
    const string &data) {
UNCOV
4246
  ResponseStatus response_status = status;
×
4247
  DimmerInfoDescriptor dimmer_info;
×
4248

UNCOV
4249
  if (response_status.WasAcked()) {
×
UNCOV
4250
    PACK(
×
4251
    struct dimmer_info_s {
4252
      uint16_t min_level_lower_limit;
4253
      uint16_t min_level_upper_limit;
4254
      uint16_t max_level_lower_limit;
4255
      uint16_t max_level_upper_limit;
4256
      uint8_t curves_supported;
4257
      uint8_t resolution;
4258
      uint8_t split_levels_supported;
4259
    });
UNCOV
4260
    STATIC_ASSERT(sizeof(dimmer_info_s) == 11);
×
4261
    struct dimmer_info_s raw_description;
×
4262

4263
    unsigned int data_size = data.size();
×
UNCOV
4264
    if (data_size == sizeof(dimmer_info_s)) {
×
4265
      memcpy(&raw_description, data.data(), data_size);
×
4266

4267
      dimmer_info.min_level_lower_limit =
×
4268
          NetworkToHost(raw_description.min_level_lower_limit);
×
4269
      dimmer_info.min_level_upper_limit =
×
4270
          NetworkToHost(raw_description.min_level_upper_limit);
×
4271
      dimmer_info.max_level_lower_limit =
×
4272
          NetworkToHost(raw_description.max_level_lower_limit);
×
4273
      dimmer_info.max_level_upper_limit =
×
4274
          NetworkToHost(raw_description.max_level_upper_limit);
×
4275
      dimmer_info.curves_supported = raw_description.curves_supported;
×
4276
      dimmer_info.resolution = raw_description.resolution;
×
UNCOV
4277
      dimmer_info.split_levels_supported =
×
4278
          raw_description.split_levels_supported;
×
4279
    } else {
4280
      std::ostringstream str;
×
4281
      str << data_size << " needs to be " << sizeof(dimmer_info_s);
×
UNCOV
4282
      response_status.error = str.str();
×
4283
    }
×
4284
  }
UNCOV
4285
  callback->Run(response_status, dimmer_info);
×
UNCOV
4286
}
×
4287

4288
/*
4289
 * @brief Handle a get MINIMUM_LEVEL response
4290
 */
UNCOV
4291
void RDMAPI::_HandleGetDimmerMinimumLevels(
×
4292
    SingleUseCallback2<void,
4293
                       const ResponseStatus&,
4294
                       const DimmerMinimumDescriptor&> *callback,
4295
    const ResponseStatus &status,
4296
    const string &data) {
UNCOV
4297
  ResponseStatus response_status = status;
×
4298
  DimmerMinimumDescriptor dimmer_mins;
×
4299

UNCOV
4300
  if (response_status.WasAcked()) {
×
UNCOV
4301
    PACK(
×
4302
    struct dimmer_min_s {
4303
      uint16_t min_level_increasing;
4304
      uint16_t min_level_decreasing;
4305
      uint8_t on_below_min;
4306
    });
UNCOV
4307
    STATIC_ASSERT(sizeof(dimmer_min_s) == 5);
×
4308
    struct dimmer_min_s raw_description;
×
4309

4310
    unsigned int data_size = data.size();
×
UNCOV
4311
    if (data_size == sizeof(dimmer_min_s)) {
×
4312
      memcpy(&raw_description, data.data(), data_size);
×
4313

4314
      dimmer_mins.min_level_increasing =
×
4315
          NetworkToHost(raw_description.min_level_increasing);
×
4316
      dimmer_mins.min_level_decreasing =
×
UNCOV
4317
          NetworkToHost(raw_description.min_level_decreasing);
×
4318
      dimmer_mins.on_below_min = raw_description.on_below_min;
×
4319
    } else {
4320
      std::ostringstream str;
×
4321
      str << data_size << " needs to be " << sizeof(dimmer_min_s);
×
UNCOV
4322
      response_status.error = str.str();
×
4323
    }
×
4324
  }
UNCOV
4325
  callback->Run(response_status, dimmer_mins);
×
UNCOV
4326
}
×
4327

4328

4329
//-----------------------------------------------------------------------------
4330
// Private methods follow
4331

4332
// @brief get a 8 bit value
UNCOV
4333
bool RDMAPI::GenericGetU8(
×
4334
    unsigned int universe,
4335
    const UID &uid,
4336
    uint8_t sub_device,
4337
    SingleUseCallback2<void, const ResponseStatus&, uint8_t> *callback,
4338
    uint16_t pid,
4339
    string *error) {
4340
  if (CheckNotBroadcast(uid, error, callback))
×
4341
    return false;
4342
  if (CheckValidSubDevice(sub_device, false, error, callback))
×
4343
    return false;
UNCOV
4344
  if (CheckCallback(error, callback))
×
4345
    return false;
×
4346

UNCOV
4347
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
4348
    this,
4349
    &RDMAPI::_HandleU8Response,
4350
    callback);
UNCOV
4351
  return CheckReturnStatus(
×
UNCOV
4352
    m_impl->RDMGet(cb,
×
4353
                   universe,
4354
                   uid,
4355
                   sub_device,
4356
                   pid),
UNCOV
4357
    error);
×
4358
}
4359

4360

4361
// @brief set an 8 bit value
UNCOV
4362
bool RDMAPI::GenericSetU8(
×
4363
    unsigned int universe,
4364
    const UID &uid,
4365
    uint16_t sub_device,
4366
    uint8_t value,
4367
    SingleUseCallback1<void, const ResponseStatus&> *callback,
4368
    uint16_t pid,
4369
    string *error) {
4370
  if (CheckValidSubDevice(sub_device, true, error, callback))
×
4371
    return false;
UNCOV
4372
  if (CheckCallback(error, callback))
×
4373
    return false;
×
4374

UNCOV
4375
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
4376
    this,
4377
    &RDMAPI::_HandleEmptyResponse,
4378
    callback);
UNCOV
4379
  return CheckReturnStatus(
×
UNCOV
4380
    m_impl->RDMSet(cb,
×
4381
                   universe,
4382
                   uid,
4383
                   sub_device,
4384
                   pid,
4385
                   &value,
4386
                   sizeof(value)),
UNCOV
4387
    error);
×
4388
}
4389

4390

4391
// @brief get a 16 bit value
4392
bool RDMAPI::GenericGetU16(
3✔
4393
    unsigned int universe,
4394
    const UID &uid,
4395
    uint16_t sub_device,
4396
    SingleUseCallback2<void, const ResponseStatus&, uint16_t> *callback,
4397
    uint16_t pid,
4398
    string *error) {
4399
  if (CheckNotBroadcast(uid, error, callback))
3✔
4400
    return false;
4401
  if (CheckValidSubDevice(sub_device, false, error, callback))
1✔
4402
    return false;
4403
  if (CheckCallback(error, callback))
1✔
UNCOV
4404
    return false;
×
4405

4406
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
1✔
4407
    this,
4408
    &RDMAPI::_HandleU16Response,
4409
    callback);
4410
  return CheckReturnStatus(
1✔
4411
    m_impl->RDMGet(cb,
1✔
4412
                   universe,
4413
                   uid,
4414
                   sub_device,
4415
                   pid),
4416
    error);
1✔
4417
}
4418

4419

4420
// @brief set a 16 bit value
4421
bool RDMAPI::GenericSetU16(
4✔
4422
    unsigned int universe,
4423
    const UID &uid,
4424
    uint16_t sub_device,
4425
    uint16_t value,
4426
    SingleUseCallback1<void, const ResponseStatus&> *callback,
4427
    uint16_t pid,
4428
    string *error) {
4429
  if (CheckValidSubDevice(sub_device, true, error, callback))
4✔
4430
    return false;
4431
  if (CheckCallback(error, callback))
3✔
UNCOV
4432
    return false;
×
4433

4434
  value = HostToNetwork(value);
3✔
4435
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
3✔
4436
    this,
4437
    &RDMAPI::_HandleEmptyResponse,
4438
    callback);
4439
  return CheckReturnStatus(
3✔
4440
    m_impl->RDMSet(cb,
3✔
4441
                   universe,
4442
                   uid,
4443
                   sub_device,
4444
                   pid,
4445
                   reinterpret_cast<const uint8_t*>(&value),
4446
                   sizeof(value)),
4447
    error);
3✔
4448
}
4449

4450

4451
// @brief get a 32 bit value
UNCOV
4452
bool RDMAPI::GenericGetU32(
×
4453
    unsigned int universe,
4454
    const UID &uid,
4455
    uint16_t sub_device,
4456
    SingleUseCallback2<void, const ResponseStatus&, uint32_t> *callback,
4457
    uint16_t pid,
4458
    string *error) {
4459
  if (CheckNotBroadcast(uid, error, callback))
×
4460
    return false;
4461
  if (CheckValidSubDevice(sub_device, false, error, callback))
×
4462
    return false;
UNCOV
4463
  if (CheckCallback(error, callback))
×
4464
    return false;
×
4465

UNCOV
4466
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
4467
    this,
4468
    &RDMAPI::_HandleU32Response,
4469
    callback);
UNCOV
4470
  return CheckReturnStatus(
×
UNCOV
4471
    m_impl->RDMGet(cb,
×
4472
                   universe,
4473
                   uid,
4474
                   sub_device,
4475
                   pid),
UNCOV
4476
    error);
×
4477
}
4478

4479

4480
// @brief set a 32 bit value
UNCOV
4481
bool RDMAPI::GenericSetU32(
×
4482
    unsigned int universe,
4483
    const UID &uid,
4484
    uint16_t sub_device,
4485
    uint32_t value,
4486
    SingleUseCallback1<void, const ResponseStatus&> *callback,
4487
    uint16_t pid,
4488
    string *error) {
4489
  if (CheckValidSubDevice(sub_device, true, error, callback))
×
4490
    return false;
UNCOV
4491
  if (CheckCallback(error, callback))
×
4492
    return false;
×
4493

UNCOV
4494
  value = HostToNetwork(value);
×
UNCOV
4495
  RDMAPIImplInterface::rdm_callback *cb = NewSingleCallback(
×
4496
    this,
4497
    &RDMAPI::_HandleEmptyResponse,
4498
    callback);
UNCOV
4499
  return CheckReturnStatus(
×
UNCOV
4500
    m_impl->RDMSet(cb,
×
4501
                   universe,
4502
                   uid,
4503
                   sub_device,
4504
                   pid,
4505
                   reinterpret_cast<const uint8_t*>(&value),
4506
                   sizeof(value)),
UNCOV
4507
    error);
×
4508
}
4509

4510

4511
// @brief Checks the status of a rdm command and sets error appropriately
4512
bool RDMAPI::CheckReturnStatus(bool status, string *error) {
24✔
4513
  if (!status && error)
24✔
UNCOV
4514
    *error = "Unable to send RDM command";
×
4515
  return status;
24✔
4516
}
4517

4518
// Mark a ResponseStatus as malformed due to a length mismatch
UNCOV
4519
void RDMAPI::SetIncorrectPDL(ResponseStatus *status,
×
4520
                             unsigned int actual,
4521
                             unsigned int expected) {
4522
  status->error = ("PDL mismatch, " +
×
4523
    IntToString(actual) + " != " +
×
UNCOV
4524
    IntToString(expected) + " (expected)");
×
UNCOV
4525
}
×
4526
}  // namespace rdm
4527
}  // 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

© 2025 Coveralls, Inc