Open Lighting Architecture  Latest Git
RDMHTTPModule.h
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program 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
10  * GNU Library General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15  *
16  * RDMHTTPModule.h
17  * This module acts as the HTTP -> olad gateway for RDM commands.
18  * Copyright (C) 2010 Simon Newton
19  */
20 
21 #ifndef OLAD_RDMHTTPMODULE_H_
22 #define OLAD_RDMHTTPMODULE_H_
23 
24 #include <map>
25 #include <queue>
26 #include <string>
27 #include <utility>
28 #include <vector>
29 #include "ola/base/Macro.h"
30 #include "ola/client/ClientRDMAPIShim.h"
31 #include "ola/client/OlaClient.h"
32 #include "ola/http/HTTPServer.h"
33 #include "ola/rdm/PidStore.h"
34 #include "ola/rdm/RDMAPI.h"
35 #include "ola/rdm/UID.h"
36 #include "ola/thread/Mutex.h"
37 #include "ola/web/JsonSections.h"
38 
39 namespace ola {
40 
41 
42 /*
43  * The module that deals with RDM requests.
44  */
46  public:
48  ola::client::OlaClient *client);
49  ~RDMHTTPModule();
50 
51  void SetPidStore(const ola::rdm::RootPidStore *pid_store);
52 
53  int RunRDMDiscovery(const ola::http::HTTPRequest *request,
54  ola::http::HTTPResponse *response);
55 
56  int JsonUIDs(const ola::http::HTTPRequest *request,
57  ola::http::HTTPResponse *response);
58 
59  // these are used by the RDM Patcher
60  int JsonUIDInfo(const ola::http::HTTPRequest *request,
61  ola::http::HTTPResponse *response);
63  ola::http::HTTPResponse *response);
65  ola::http::HTTPResponse *response);
66 
67  // these are used by the RDM Attributes Panel
68  int JsonSupportedPIDs(const ola::http::HTTPRequest *request,
69  ola::http::HTTPResponse *response);
71  ola::http::HTTPResponse *response);
72  int JsonSectionInfo(const ola::http::HTTPRequest *request,
73  ola::http::HTTPResponse *response);
75  ola::http::HTTPResponse *response);
76 
77  void PruneUniverseList(const std::vector<client::OlaUniverse> &universes);
78 
79  private:
80  typedef struct {
81  std::string manufacturer;
82  std::string device;
83  bool active;
84  } resolved_uid;
85 
86  typedef enum {
87  RESOLVE_MANUFACTURER,
88  RESOLVE_DEVICE,
89  } uid_resolve_action;
90 
91  typedef struct {
92  std::map<ola::rdm::UID, resolved_uid> resolved_uids;
93  std::queue<std::pair<ola::rdm::UID, uid_resolve_action> > pending_uids;
94  bool uid_resolution_running;
95  bool active;
96  } uid_resolution_state;
97 
98  ola::http::HTTPServer *m_server;
99  ola::client::OlaClient *m_client;
101  ola::rdm::RDMAPI m_rdm_api;
102  std::map<unsigned int, uid_resolution_state*> m_universe_uids;
103 
104  ola::thread::Mutex m_pid_store_mu;
105  const ola::rdm::RootPidStore *m_pid_store; // GUARDED_BY(m_pid_store_mu);
106 
107  typedef struct {
108  std::string id;
109  std::string name;
110  std::string hint;
111  } section_info;
112 
113  struct lt_section_info {
114  bool operator()(const section_info &left, const section_info &right) {
115  return left.name < right.name;
116  }
117  };
118 
119  typedef struct {
120  unsigned int universe_id;
121  const ola::rdm::UID uid;
122  std::string hint;
123  std::string device_model;
124  std::string software_version;
125  } device_info;
126 
127  typedef struct {
128  unsigned int universe_id;
129  const ola::rdm::UID *uid;
130  bool include_descriptions;
131  bool return_as_section;
132  unsigned int active;
133  unsigned int next;
134  unsigned int total;
135  std::vector<std::pair<uint32_t, std::string> > personalities;
136  } personality_info;
137 
138  typedef struct {
139  unsigned int universe_id;
140  const ola::rdm::UID *uid;
141  bool include_descriptions;
142  unsigned int active;
143  unsigned int next;
144  unsigned int total;
145  std::vector<std::string> curve_descriptions;
146  } curve_info;
147 
148  // UID resolution methods
149  void HandleUIDList(ola::http::HTTPResponse *response,
150  unsigned int universe_id,
151  const client::Result &result,
152  const ola::rdm::UIDSet &uids);
153 
154  void ResolveNextUID(unsigned int universe_id);
155 
156  void UpdateUIDManufacturerLabel(unsigned int universe,
157  ola::rdm::UID uid,
158  const ola::rdm::ResponseStatus &status,
159  const std::string &device_label);
160 
161  void UpdateUIDDeviceLabel(unsigned int universe,
162  ola::rdm::UID uid,
163  const ola::rdm::ResponseStatus &status,
164  const std::string &device_label);
165 
166  uid_resolution_state *GetUniverseUids(unsigned int universe);
167  uid_resolution_state *GetUniverseUidsOrCreate(unsigned int universe);
168 
169  // uid info handler
170  void UIDInfoHandler(ola::http::HTTPResponse *response,
171  const ola::rdm::ResponseStatus &status,
172  const ola::rdm::DeviceDescriptor &device);
173 
174  // uid identify handler
175  void UIDIdentifyDeviceHandler(ola::http::HTTPResponse *response,
176  const ola::rdm::ResponseStatus &status,
177  bool value);
178 
179  // personality handler
180  void SendPersonalityResponse(ola::http::HTTPResponse *response,
181  personality_info *info);
182 
183 
184  // supported params / sections
185  void SupportedParamsHandler(ola::http::HTTPResponse *response,
186  const ola::rdm::ResponseStatus &status,
187  const std::vector<uint16_t> &pids);
188  void SupportedSectionsHandler(ola::http::HTTPResponse *response,
189  unsigned int universe,
190  ola::rdm::UID uid,
191  const ola::rdm::ResponseStatus &status,
192  const std::vector<uint16_t> &pids);
193  void SupportedSectionsDeviceInfoHandler(
194  ola::http::HTTPResponse *response,
195  const std::vector<uint16_t> pids,
196  const ola::rdm::ResponseStatus &status,
197  const ola::rdm::DeviceDescriptor &device);
198 
199  // section methods
200  std::string GetCommStatus(ola::http::HTTPResponse *response,
201  unsigned int universe_id,
202  const ola::rdm::UID &uid);
203 
204  void CommStatusHandler(ola::http::HTTPResponse *response,
205  const ola::rdm::ResponseStatus &status,
206  uint16_t short_messages,
207  uint16_t length_mismatch,
208  uint16_t checksum_fail);
209 
210  std::string ClearCommsCounters(ola::http::HTTPResponse *response,
211  unsigned int universe_id,
212  const ola::rdm::UID &uid);
213 
214  std::string GetProxiedDevices(ola::http::HTTPResponse *response,
215  unsigned int universe_id,
216  const ola::rdm::UID &uid);
217 
218 
219  void ProxiedDevicesHandler(ola::http::HTTPResponse *response,
220  unsigned int universe_id,
221  const ola::rdm::ResponseStatus &status,
222  const std::vector<ola::rdm::UID> &uids);
223 
224  std::string GetDeviceInfo(const ola::http::HTTPRequest *request,
225  ola::http::HTTPResponse *response,
226  unsigned int universe_id,
227  const ola::rdm::UID &uid);
228 
229  void GetSoftwareVersionHandler(ola::http::HTTPResponse *response,
230  device_info dev_info,
231  const ola::rdm::ResponseStatus &status,
232  const std::string &software_version);
233 
234  void GetDeviceModelHandler(ola::http::HTTPResponse *response,
235  device_info dev_info,
236  const ola::rdm::ResponseStatus &status,
237  const std::string &device_model);
238 
239  void GetDeviceInfoHandler(ola::http::HTTPResponse *response,
240  device_info dev_info,
241  const ola::rdm::ResponseStatus &status,
242  const ola::rdm::DeviceDescriptor &device);
243 
244  std::string GetProductIds(const ola::http::HTTPRequest *request,
245  ola::http::HTTPResponse *response,
246  unsigned int universe_id,
247  const ola::rdm::UID &uid);
248 
249  void GetProductIdsHandler(ola::http::HTTPResponse *response,
250  const ola::rdm::ResponseStatus &status,
251  const std::vector<uint16_t> &ids);
252 
253  std::string GetManufacturerLabel(const ola::http::HTTPRequest *request,
254  ola::http::HTTPResponse *response,
255  unsigned int universe_id,
256  const ola::rdm::UID &uid);
257 
258  void GetManufacturerLabelHandler(ola::http::HTTPResponse *response,
259  unsigned int universe_id,
260  const ola::rdm::UID uid,
261  const ola::rdm::ResponseStatus &status,
262  const std::string &label);
263 
264  std::string GetDeviceLabel(const ola::http::HTTPRequest *request,
265  ola::http::HTTPResponse *response,
266  unsigned int universe_id,
267  const ola::rdm::UID &uid);
268 
269  void GetDeviceLabelHandler(ola::http::HTTPResponse *response,
270  unsigned int universe_id,
271  const ola::rdm::UID uid,
272  const ola::rdm::ResponseStatus &status,
273  const std::string &label);
274 
275  std::string SetDeviceLabel(const ola::http::HTTPRequest *request,
276  ola::http::HTTPResponse *response,
277  unsigned int universe_id,
278  const ola::rdm::UID &uid);
279 
280  std::string GetFactoryDefaults(ola::http::HTTPResponse *response,
281  unsigned int universe_id,
282  const ola::rdm::UID &uid);
283 
284  void FactoryDefaultsHandler(ola::http::HTTPResponse *response,
285  const ola::rdm::ResponseStatus &status,
286  bool defaults);
287 
288  std::string SetFactoryDefault(ola::http::HTTPResponse *response,
289  unsigned int universe_id,
290  const ola::rdm::UID &uid);
291 
292  std::string GetLanguage(ola::http::HTTPResponse *response,
293  unsigned int universe_id,
294  const ola::rdm::UID &uid);
295 
296  void GetSupportedLanguagesHandler(
297  ola::http::HTTPResponse *response,
298  unsigned int universe_id,
299  const ola::rdm::UID uid,
300  const ola::rdm::ResponseStatus &status,
301  const std::vector<std::string> &languages);
302 
303  void GetLanguageHandler(ola::http::HTTPResponse *response,
304  std::vector<std::string> languages,
305  const ola::rdm::ResponseStatus &status,
306  const std::string &language);
307 
308  std::string SetLanguage(const ola::http::HTTPRequest *request,
309  ola::http::HTTPResponse *response,
310  unsigned int universe_id,
311  const ola::rdm::UID &uid);
312 
313  std::string GetBootSoftware(ola::http::HTTPResponse *response,
314  unsigned int universe_id,
315  const ola::rdm::UID &uid);
316 
317  void GetBootSoftwareLabelHandler(ola::http::HTTPResponse *response,
318  unsigned int universe_id,
319  const ola::rdm::UID uid,
320  const ola::rdm::ResponseStatus &status,
321  const std::string &label);
322 
323  void GetBootSoftwareVersionHandler(
324  ola::http::HTTPResponse *response,
325  std::string label,
326  const ola::rdm::ResponseStatus &status,
327  uint32_t version);
328 
329  std::string GetPersonalities(const ola::http::HTTPRequest *request,
330  ola::http::HTTPResponse *response,
331  unsigned int universe_id,
332  const ola::rdm::UID &uid,
333  bool return_as_section,
334  bool include_description = false);
335 
336  void GetPersonalityHandler(
337  ola::http::HTTPResponse *response,
338  personality_info *info,
339  const ola::rdm::ResponseStatus &status,
340  uint8_t current,
341  uint8_t total);
342 
343  void GetNextPersonalityDescription(ola::http::HTTPResponse *response,
344  personality_info *info);
345 
346  void GetPersonalityLabelHandler(
347  ola::http::HTTPResponse *response,
348  personality_info *info,
349  const ola::rdm::ResponseStatus &status,
350  uint8_t personality,
351  uint16_t slot_count,
352  const std::string &label);
353 
354  void SendSectionPersonalityResponse(ola::http::HTTPResponse *response,
355  personality_info *info);
356 
357  std::string SetPersonality(const ola::http::HTTPRequest *request,
358  ola::http::HTTPResponse *response,
359  unsigned int universe_id,
360  const ola::rdm::UID &uid);
361 
362  std::string GetStartAddress(const ola::http::HTTPRequest *request,
363  ola::http::HTTPResponse *response,
364  unsigned int universe_id,
365  const ola::rdm::UID &uid);
366 
367  void GetStartAddressHandler(ola::http::HTTPResponse *response,
368  const ola::rdm::ResponseStatus &status,
369  uint16_t address);
370 
371  std::string SetStartAddress(const ola::http::HTTPRequest *request,
372  ola::http::HTTPResponse *response,
373  unsigned int universe_id,
374  const ola::rdm::UID &uid);
375 
376  std::string GetSensor(const ola::http::HTTPRequest *request,
377  ola::http::HTTPResponse *response,
378  unsigned int universe_id,
379  const ola::rdm::UID &uid);
380 
381  void SensorDefinitionHandler(ola::http::HTTPResponse *response,
382  unsigned int universe_id,
383  const ola::rdm::UID uid,
384  uint8_t sensor_id,
385  const ola::rdm::ResponseStatus &status,
386  const ola::rdm::SensorDescriptor &definition);
387 
388  void SensorValueHandler(ola::http::HTTPResponse *response,
389  ola::rdm::SensorDescriptor *definition,
390  const ola::rdm::ResponseStatus &status,
391  const ola::rdm::SensorValueDescriptor &value);
392 
393  std::string RecordSensor(const ola::http::HTTPRequest *request,
394  ola::http::HTTPResponse *response,
395  unsigned int universe_id,
396  const ola::rdm::UID &uid);
397 
398  std::string GetDeviceHours(const ola::http::HTTPRequest *request,
399  ola::http::HTTPResponse *response,
400  unsigned int universe_id,
401  const ola::rdm::UID &uid);
402 
403  std::string SetDeviceHours(const ola::http::HTTPRequest *request,
404  ola::http::HTTPResponse *response,
405  unsigned int universe_id,
406  const ola::rdm::UID &uid);
407 
408  std::string GetLampHours(const ola::http::HTTPRequest *request,
409  ola::http::HTTPResponse *response,
410  unsigned int universe_id,
411  const ola::rdm::UID &uid);
412 
413  std::string SetLampHours(const ola::http::HTTPRequest *request,
414  ola::http::HTTPResponse *response,
415  unsigned int universe_id,
416  const ola::rdm::UID &uid);
417 
418  std::string GetLampStrikes(const ola::http::HTTPRequest *request,
419  ola::http::HTTPResponse *response,
420  unsigned int universe_id,
421  const ola::rdm::UID &uid);
422 
423  std::string SetLampStrikes(const ola::http::HTTPRequest *request,
424  ola::http::HTTPResponse *response,
425  unsigned int universe_id,
426  const ola::rdm::UID &uid);
427 
428  std::string GetLampState(const ola::http::HTTPRequest *request,
429  ola::http::HTTPResponse *response,
430  unsigned int universe_id,
431  const ola::rdm::UID &uid);
432 
433  void LampStateHandler(ola::http::HTTPResponse *response,
434  const ola::rdm::ResponseStatus &status,
435  uint8_t state);
436 
437  std::string SetLampState(const ola::http::HTTPRequest *request,
438  ola::http::HTTPResponse *response,
439  unsigned int universe_id,
440  const ola::rdm::UID &uid);
441 
442  std::string GetLampMode(const ola::http::HTTPRequest *request,
443  ola::http::HTTPResponse *response,
444  unsigned int universe_id,
445  const ola::rdm::UID &uid);
446 
447  void LampModeHandler(ola::http::HTTPResponse *response,
448  const ola::rdm::ResponseStatus &status,
449  uint8_t mode);
450 
451  std::string SetLampMode(const ola::http::HTTPRequest *request,
452  ola::http::HTTPResponse *response,
453  unsigned int universe_id,
454  const ola::rdm::UID &uid);
455 
456  std::string GetPowerCycles(const ola::http::HTTPRequest *request,
457  ola::http::HTTPResponse *response,
458  unsigned int universe_id,
459  const ola::rdm::UID &uid);
460 
461  std::string SetPowerCycles(const ola::http::HTTPRequest *request,
462  ola::http::HTTPResponse *response,
463  unsigned int universe_id,
464  const ola::rdm::UID &uid);
465 
466  std::string GetDisplayInvert(ola::http::HTTPResponse *response,
467  unsigned int universe_id,
468  const ola::rdm::UID &uid);
469 
470  void DisplayInvertHandler(ola::http::HTTPResponse *response,
471  const ola::rdm::ResponseStatus &status,
472  uint8_t value);
473 
474  std::string SetDisplayInvert(const ola::http::HTTPRequest *request,
475  ola::http::HTTPResponse *response,
476  unsigned int universe_id,
477  const ola::rdm::UID &uid);
478 
479  std::string GetDisplayLevel(ola::http::HTTPResponse *response,
480  unsigned int universe_id,
481  const ola::rdm::UID &uid);
482 
483  void DisplayLevelHandler(ola::http::HTTPResponse *response,
484  const ola::rdm::ResponseStatus &status,
485  uint8_t value);
486 
487  std::string SetDisplayLevel(const ola::http::HTTPRequest *request,
488  ola::http::HTTPResponse *response,
489  unsigned int universe_id,
490  const ola::rdm::UID &uid);
491 
492  std::string GetPanInvert(ola::http::HTTPResponse *response,
493  unsigned int universe_id,
494  const ola::rdm::UID &uid);
495 
496  std::string SetPanInvert(const ola::http::HTTPRequest *request,
497  ola::http::HTTPResponse *response,
498  unsigned int universe_id,
499  const ola::rdm::UID &uid);
500 
501  std::string GetTiltInvert(ola::http::HTTPResponse *response,
502  unsigned int universe_id,
503  const ola::rdm::UID &uid);
504 
505  std::string SetTiltInvert(const ola::http::HTTPRequest *request,
506  ola::http::HTTPResponse *response,
507  unsigned int universe_id,
508  const ola::rdm::UID &uid);
509 
510  std::string GetPanTiltSwap(ola::http::HTTPResponse *response,
511  unsigned int universe_id,
512  const ola::rdm::UID &uid);
513 
514  std::string SetPanTiltSwap(const ola::http::HTTPRequest *request,
515  ola::http::HTTPResponse *response,
516  unsigned int universe_id,
517  const ola::rdm::UID &uid);
518 
519  std::string GetClock(ola::http::HTTPResponse *response,
520  unsigned int universe_id,
521  const ola::rdm::UID &uid);
522 
523  void ClockHandler(ola::http::HTTPResponse *response,
524  const ola::rdm::ResponseStatus &status,
525  const ola::rdm::ClockValue &clock);
526 
527  std::string SyncClock(ola::http::HTTPResponse *response,
528  unsigned int universe_id,
529  const ola::rdm::UID &uid);
530 
531  std::string GetIdentifyDevice(ola::http::HTTPResponse *response,
532  unsigned int universe_id,
533  const ola::rdm::UID &uid);
534 
535  std::string SetIdentifyDevice(const ola::http::HTTPRequest *request,
536  ola::http::HTTPResponse *response,
537  unsigned int universe_id,
538  const ola::rdm::UID &uid);
539 
540  std::string GetPowerState(ola::http::HTTPResponse *response,
541  unsigned int universe_id,
542  const ola::rdm::UID &uid);
543 
544  void PowerStateHandler(ola::http::HTTPResponse *response,
545  const ola::rdm::ResponseStatus &status,
546  uint8_t value);
547 
548  std::string SetPowerState(const ola::http::HTTPRequest *request,
549  ola::http::HTTPResponse *response,
550  unsigned int universe_id,
551  const ola::rdm::UID &uid);
552 
553  std::string GetResetDevice(ola::http::HTTPResponse *response);
554 
555  std::string SetResetDevice(const ola::http::HTTPRequest *request,
556  ola::http::HTTPResponse *response,
557  unsigned int universe_id,
558  const ola::rdm::UID &uid);
559 
560  std::string GetDnsHostname(ola::http::HTTPResponse *response,
561  unsigned int universe_id,
562  const ola::rdm::UID &uid);
563 
564  void GetDnsHostnameHandler(ola::http::HTTPResponse *response,
565  const ola::rdm::ResponseStatus &status,
566  const std::string &label);
567 
568  std::string SetDnsHostname(const ola::http::HTTPRequest *request,
569  ola::http::HTTPResponse *response,
570  unsigned int universe_id,
571  const ola::rdm::UID &uid);
572 
573  std::string GetDnsDomainName(ola::http::HTTPResponse *response,
574  unsigned int universe_id,
575  const ola::rdm::UID &uid);
576 
577  void GetDnsDomainNameHandler(ola::http::HTTPResponse *response,
578  const ola::rdm::ResponseStatus &status,
579  const std::string &label);
580 
581  std::string SetDnsDomainName(const ola::http::HTTPRequest *request,
582  ola::http::HTTPResponse *response,
583  unsigned int universe_id,
584  const ola::rdm::UID &uid);
585 
586  std::string GetCurve(const ola::http::HTTPRequest *request,
587  ola::http::HTTPResponse *response,
588  unsigned int universe_id,
589  const ola::rdm::UID &uid,
590  bool include_descriptions);
591 
592  void GetCurveHandler(ola::http::HTTPResponse *response,
593  curve_info *info,
594  const ola::rdm::ResponseStatus &status,
595  uint8_t current_curve,
596  uint8_t curve_count);
597 
598  void GetNextCurveDescription(ola::http::HTTPResponse *response,
599  curve_info *info);
600 
601  void GetCurveDescriptionHandler(ola::http::HTTPResponse *response,
602  curve_info *info,
603  const ola::rdm::ResponseStatus &status,
604  uint8_t curve,
605  const std::string &resp_description);
606 
607  void SendCurveResponse(ola::http::HTTPResponse *response,
608  curve_info *info);
609 
610  std::string SetCurve(const ola::http::HTTPRequest *request,
611  ola::http::HTTPResponse *response,
612  unsigned int universe_id,
613  const ola::rdm::UID &uid);
614 
615  std::string GetDimmerInfo(ola::http::HTTPResponse *response,
616  unsigned int universe_id,
617  const ola::rdm::UID &uid);
618 
619  void GetDimmerInfoHandler(ola::http::HTTPResponse *response,
620  const ola::rdm::ResponseStatus &status,
621  const ola::rdm::DimmerInfoDescriptor &dimmer);
622 
623  std::string GetDimmerMinimumLevels(ola::http::HTTPResponse *response,
624  unsigned int universe_id,
625  const ola::rdm::UID &uid);
626 
627  void GetDimmerMinimumLevelsHandler(
628  ola::http::HTTPResponse *response,
629  const ola::rdm::ResponseStatus &status,
630  const ola::rdm::DimmerMinimumDescriptor &dimmer);
631 
632  std::string SetDimmerMinimumLevels(const ola::http::HTTPRequest *request,
633  ola::http::HTTPResponse *response,
634  unsigned int universe_id,
635  const ola::rdm::UID &uid);
636 
637  std::string GetDimmerMaximumLevel(ola::http::HTTPResponse *response,
638  unsigned int universe_id,
639  const ola::rdm::UID &uid);
640 
641  void GetDimmerMaximumLevelHandler(ola::http::HTTPResponse *response,
642  const ola::rdm::ResponseStatus &status,
643  uint16_t maximum_level);
644 
645  std::string SetDimmerMaximumLevel(const ola::http::HTTPRequest *request,
646  ola::http::HTTPResponse *response,
647  unsigned int universe_id,
648  const ola::rdm::UID &uid);
649 
650  // util methods
651  bool CheckForInvalidId(const ola::http::HTTPRequest *request,
652  unsigned int *universe_id);
653 
654  bool CheckForInvalidUid(const ola::http::HTTPRequest *request,
655  ola::rdm::UID **uid);
656 
657  uint16_t SubDeviceOrRoot(const ola::http::HTTPRequest *request);
658 
659  void SetHandler(ola::http::HTTPResponse *response,
660  const ola::rdm::ResponseStatus &status);
661 
662  void GenericUIntHandler(ola::http::HTTPResponse *response,
663  std::string description,
664  const ola::rdm::ResponseStatus &status,
665  uint32_t value);
666 
667  void GenericUInt8BoolHandler(ola::http::HTTPResponse *response,
668  std::string description,
669  const ola::rdm::ResponseStatus &status,
670  uint8_t value);
671  void GenericBoolHandler(ola::http::HTTPResponse *response,
672  std::string description,
673  const ola::rdm::ResponseStatus &status,
674  bool value);
675 
676  bool CheckForRDMError(ola::http::HTTPResponse *response,
677  const ola::rdm::ResponseStatus &status);
678  int RespondWithError(ola::http::HTTPResponse *response,
679  const std::string &error);
680  void RespondWithSection(ola::http::HTTPResponse *response,
681  const ola::web::JsonSection &section);
682 
683  bool CheckForRDMSuccess(const ola::rdm::ResponseStatus &status);
684  bool CheckForRDMSuccessWithError(const ola::rdm::ResponseStatus &status,
685  std::string *error);
686 
687  void HandleBoolResponse(ola::http::HTTPResponse *response,
688  const std::string &error);
689 
690  void AddSection(std::vector<section_info> *sections,
691  const std::string &section_id,
692  const std::string &section_name,
693  const std::string &hint = "");
694 
695  static const uint32_t INVALID_PERSONALITY = 0xffff;
696  static const char BACKEND_DISCONNECTED_ERROR[];
697 
698  static const char HINT_KEY[];
699  static const char ID_KEY[];
700  static const char SECTION_KEY[];
701  static const char UID_KEY[];
702 
703  static const char ADDRESS_FIELD[];
704  static const char DIMMER_MINIMUM_INCREASING_FIELD[];
705  static const char DIMMER_MINIMUM_DECREASING_FIELD[];
706  static const char DISPLAY_INVERT_FIELD[];
707  static const char GENERIC_BOOL_FIELD[];
708  static const char GENERIC_STRING_FIELD[];
709  static const char GENERIC_UINT_FIELD[];
710  static const char IDENTIFY_DEVICE_FIELD[];
711  static const char LABEL_FIELD[];
712  static const char LANGUAGE_FIELD[];
713  static const char RECORD_SENSOR_FIELD[];
714  static const char SUB_DEVICE_FIELD[];
715 
716  static const char BOOT_SOFTWARE_SECTION[];
717  static const char CLOCK_SECTION[];
718  static const char COMMS_STATUS_SECTION[];
719  static const char CURVE_SECTION[];
720  static const char DEVICE_HOURS_SECTION[];
721  static const char DEVICE_INFO_SECTION[];
722  static const char DEVICE_LABEL_SECTION[];
723  static const char DIMMER_INFO_SECTION[];
724  static const char DIMMER_MAXIMUM_SECTION[];
725  static const char DIMMER_MINIMUM_SECTION[];
726  static const char DISPLAY_INVERT_SECTION[];
727  static const char DISPLAY_LEVEL_SECTION[];
728  static const char DMX_ADDRESS_SECTION[];
729  static const char DNS_DOMAIN_NAME_SECTION[];
730  static const char DNS_HOSTNAME_SECTION[];
731  static const char FACTORY_DEFAULTS_SECTION[];
732  static const char IDENTIFY_DEVICE_SECTION[];
733  static const char LAMP_HOURS_SECTION[];
734  static const char LAMP_MODE_SECTION[];
735  static const char LAMP_STATE_SECTION[];
736  static const char LAMP_STRIKES_SECTION[];
737  static const char LANGUAGE_SECTION[];
738  static const char MANUFACTURER_LABEL_SECTION[];
739  static const char PAN_INVERT_SECTION[];
740  static const char PAN_TILT_SWAP_SECTION[];
741  static const char PERSONALITY_SECTION[];
742  static const char POWER_CYCLES_SECTION[];
743  static const char POWER_STATE_SECTION[];
744  static const char PRODUCT_DETAIL_SECTION[];
745  static const char PROXIED_DEVICES_SECTION[];
746  static const char RESET_DEVICE_SECTION[];
747  static const char SENSOR_SECTION[];
748  static const char TILT_INVERT_SECTION[];
749 
750  static const char BOOT_SOFTWARE_SECTION_NAME[];
751  static const char CLOCK_SECTION_NAME[];
752  static const char COMMS_STATUS_SECTION_NAME[];
753  static const char CURVE_SECTION_NAME[];
754  static const char DEVICE_HOURS_SECTION_NAME[];
755  static const char DEVICE_INFO_SECTION_NAME[];
756  static const char DEVICE_LABEL_SECTION_NAME[];
757  static const char DIMMER_INFO_SECTION_NAME[];
758  static const char DIMMER_MAXIMUM_SECTION_NAME[];
759  static const char DIMMER_MINIMUM_SECTION_NAME[];
760  static const char DISPLAY_INVERT_SECTION_NAME[];
761  static const char DISPLAY_LEVEL_SECTION_NAME[];
762  static const char DMX_ADDRESS_SECTION_NAME[];
763  static const char DNS_DOMAIN_NAME_SECTION_NAME[];
764  static const char DNS_HOSTNAME_SECTION_NAME[];
765  static const char FACTORY_DEFAULTS_SECTION_NAME[];
766  static const char IDENTIFY_DEVICE_SECTION_NAME[];
767  static const char LAMP_HOURS_SECTION_NAME[];
768  static const char LAMP_MODE_SECTION_NAME[];
769  static const char LAMP_STATE_SECTION_NAME[];
770  static const char LAMP_STRIKES_SECTION_NAME[];
771  static const char LANGUAGE_SECTION_NAME[];
772  static const char MANUFACTURER_LABEL_SECTION_NAME[];
773  static const char PAN_INVERT_SECTION_NAME[];
774  static const char PAN_TILT_SWAP_SECTION_NAME[];
775  static const char PERSONALITY_SECTION_NAME[];
776  static const char POWER_CYCLES_SECTION_NAME[];
777  static const char POWER_STATE_SECTION_NAME[];
778  static const char PRODUCT_DETAIL_SECTION_NAME[];
779  static const char PROXIED_DEVICES_SECTION_NAME[];
780  static const char RESET_DEVICE_SECTION_NAME[];
781  static const char TILT_INVERT_SECTION_NAME[];
782 
784 };
785 } // namespace ola
786 #endif // OLAD_RDMHTTPMODULE_H_
The base HTTP Server.
Definition: HTTPServer.h:156
void PruneUniverseList(const std::vector< client::OlaUniverse > &universes)
Definition: RDMHTTPModule.cpp:689
Represents a set of RDM UIDs.
Definition: UIDSet.h:48
int JsonSectionInfo(const ola::http::HTTPRequest *request, ola::http::HTTPResponse *response)
Get the information required to render a section in the RDM controller panel.
Definition: RDMHTTPModule.cpp:492
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Creates dummy copy constructor and assignment operator declarations.
Definition: Macro.h:44
Definition: RDMAPI.h:317
int JsonUIDPersonalities(const ola::http::HTTPRequest *request, ola::http::HTTPResponse *response)
Returns the personalities on the device.
Definition: RDMHTTPModule.cpp:375
Definition: HTTPServer.h:65
int JsonSaveSectionInfo(const ola::http::HTTPRequest *request, ola::http::HTTPResponse *response)
Definition: RDMHTTPModule.cpp:596
void SetPidStore(const ola::rdm::RootPidStore *pid_store)
Can be called while the server is running. Ownership is not transferred.
Definition: RDMHTTPModule.cpp:228
Holds information about RDM PIDs.
Provide a generic RDM API that can use different implementations.
A RDM unique identifier (UID).
int JsonUIDs(const ola::http::HTTPRequest *request, ola::http::HTTPResponse *response)
Return the list of uids for this universe as json.
Definition: RDMHTTPModule.cpp:270
The callback based C++ client for OLA.
Definition: OlaClient.h:45
Definition: ClientRDMAPIShim.h:39
Definition: HTTPServer.h:109
Indicates the result of a OLA API call.
Definition: Result.h:52
int JsonUIDIdentifyDevice(const ola::http::HTTPRequest *request, ola::http::HTTPResponse *response)
Returns the identify state for the device.
Definition: RDMHTTPModule.cpp:336
Represents the state of a response and/or any error codes.
Definition: RDMAPIImplInterface.h:51
Definition: JsonSections.h:203
Definition: RDMAPI.h:132
Definition: RDMAPI.h:191
Definition: RDMAPI.h:178
Helper macros.
int RunRDMDiscovery(const ola::http::HTTPRequest *request, ola::http::HTTPResponse *response)
Run RDM discovery for a universe.
Definition: RDMHTTPModule.cpp:240
Represents a RDM UID.
Definition: UID.h:57
int JsonUIDInfo(const ola::http::HTTPRequest *request, ola::http::HTTPResponse *response)
Return the device info for this uid.
Definition: RDMHTTPModule.cpp:297
int JsonSupportedSections(const ola::http::HTTPRequest *request, ola::http::HTTPResponse *response)
Return a list of sections to display in the RDM control panel.
Definition: RDMHTTPModule.cpp:452
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
The root of the RDM parameter descriptor store.
Definition: PidStore.h:68
int JsonSupportedPIDs(const ola::http::HTTPRequest *request, ola::http::HTTPResponse *response)
Return a list of PIDs supported by this device.
Definition: RDMHTTPModule.cpp:410
Definition: RDMHTTPModule.h:45
Definition: Mutex.h:41