Open Lighting Architecture 0.10.9
Loading...
Searching...
No Matches
E133Receiver.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 * E133Receiver.h
17 * Handles E1.33 UDP packets and executes RDM and Status message callbacks.
18 * Copyright (C) 2013 Simon Newton
19 */
20
21#ifndef INCLUDE_OLA_E133_E133RECEIVER_H_
22#define INCLUDE_OLA_E133_E133RECEIVER_H_
23
24#include <ola/Callback.h>
25#include <ola/base/Macro.h>
27#include <ola/network/Socket.h>
28#include <ola/rdm/RDMCommand.h>
29
30#include <memory>
31#include <string>
32
33using std::string;
34using std::auto_ptr;
36
37namespace ola {
38// We don't want to suck in all the ACN headers, so we forward declare these
39// and allocate the members on the heap.
40namespace acn {
41class E133Header;
42class E133Inflator;
43class E133StatusInflator;
44class IncomingUDPTransport;
45class RDMInflator;
46class RootInflator;
47class TransportHeader;
48} // namespace acn
49
50namespace e133 {
51
53 public:
54 E133Message(const IPV4Address &ip,
55 uint16_t endpoint,
56 uint32_t sequence_number)
57 : ip(ip),
58 endpoint(endpoint),
59 sequence_number(sequence_number) {
60 }
61 virtual ~E133Message() {}
62
63 IPV4Address ip;
64 uint16_t endpoint;
65 uint32_t sequence_number;
66};
67
68
73 public:
75 uint16_t endpoint,
76 uint32_t sequence_number,
77 uint16_t status_code,
78 string status_message)
79 : E133Message(ip, endpoint, sequence_number),
80 status_code(status_code),
81 status_message(status_message) {
82 }
83
84 uint16_t status_code;
85 string status_message;
86};
87
88
94 public:
96 uint16_t endpoint,
97 uint32_t sequence_number,
98 ola::rdm::RDMStatusCode status_code,
99 const ola::rdm::RDMResponse *response)
100 : E133Message(ip, endpoint, sequence_number),
101 status_code(status_code),
102 response(response) {
103 }
104
105 ola::rdm::RDMStatusCode status_code;
106 const ola::rdm::RDMResponse *response;
107};
108
109
114 public:
117
118 explicit E133Receiver(ola::network::UDPSocket *socket,
119 StatusCallback *status_callback,
120 RDMCallback *rdm_callback);
122
123 private:
124 ola::network::UDPSocket *m_udp_socket;
125 StatusCallback *m_status_callback;
126 RDMCallback *m_rdm_callback;
127
128 auto_ptr<ola::acn::RootInflator> m_root_inflator;
129 auto_ptr<ola::acn::E133Inflator> m_e133_inflator;
130 auto_ptr<ola::acn::RDMInflator> m_rdm_inflator;
131 auto_ptr<ola::acn::E133StatusInflator> m_e133_status_inflator;
132 auto_ptr<ola::acn::IncomingUDPTransport> m_incoming_udp_transport;
133
134 void HandleStatusMessage(
135 const ola::acn::TransportHeader *transport_header,
136 const ola::acn::E133Header *e133_header,
137 uint16_t status_code,
138 const string &description);
139
140 void HandlePacket(
141 const ola::acn::TransportHeader *transport_header,
142 const ola::acn::E133Header *e133_header,
143 const std::string &raw_response);
144
145 E133Receiver(const E133Receiver &) = delete;
146 const E133Receiver &operator=(const E133Receiver &) = delete;
147};
148} // namespace e133
149} // namespace ola
150#endif // INCLUDE_OLA_E133_E133RECEIVER_H_
Represents an IPv4 Address.
Helper macros.
Classes that represent RDM commands.
A 1 argument callback which can be called multiple times.
Definition Callback.h:992
Definition E133Header.h:35
Definition TransportHeader.h:35
Definition E133Receiver.h:52
Definition E133Receiver.h:93
Definition E133Receiver.h:113
Definition E133Receiver.h:72
Represents a IPv4 Address.
Definition IPV4Address.h:55
Definition Socket.h:239
An RDM Command that represents responses (GET, SET or DISCOVER).
Definition RDMCommand.h:457
RDMStatusCode
RDM Status Codes.
Definition RDMResponseCodes.h:45
The namespace containing all OLA symbols.
Definition Credentials.cpp:44