21 #ifndef LIBS_ACN_DMPPDU_H_ 22 #define LIBS_ACN_DMPPDU_H_ 28 #include "libs/acn/DMPAddress.h" 29 #include "libs/acn/DMPHeader.h" 30 #include "libs/acn/PDU.h" 42 PDU(vector, ONE_BYTE),
43 m_header(dmp_header) {
47 unsigned int HeaderSize()
const {
return DMPHeader::DMP_HEADER_SIZE; }
48 bool PackHeader(uint8_t *data,
unsigned int *length)
const;
61 template <
typename Address>
65 const std::vector<Address> &addresses):
67 m_addresses(addresses) {}
69 unsigned int DataSize()
const {
70 return static_cast<unsigned int>(m_addresses.size() * m_header.Bytes() *
71 (m_header.Type() == NON_RANGE ? 1 : 3));
74 bool PackData(uint8_t *data,
unsigned int *length)
const {
75 typename std::vector<Address>::const_iterator iter;
76 unsigned int offset = 0;
77 for (iter = m_addresses.begin(); iter != m_addresses.end(); ++iter) {
78 unsigned int remaining = *length - offset;
79 if (!iter->Pack(data + offset, &remaining))
88 typename std::vector<Address>::const_iterator iter;
89 for (iter = m_addresses.begin(); iter != m_addresses.end(); ++iter)
94 std::vector<Address> m_addresses;
105 template <
typename type>
106 const DMPPDU *NewDMPGetProperty(
113 TypeToDMPSize<type>());
122 template <
typename type>
123 const DMPPDU *_CreateDMPGetProperty(
bool is_virtual,
125 unsigned int start) {
127 std::vector<DMPAddress<type> > addresses;
128 addresses.push_back(address);
129 return NewDMPGetProperty<type>(is_virtual, is_relative, addresses);
140 const DMPPDU *NewDMPGetProperty(
bool is_virtual,
153 template <
typename type>
154 const DMPPDU *NewRangeDMPGetProperty(
161 TypeToDMPSize<type>());
166 template <
typename type>
167 const DMPPDU *_CreateRangeDMPGetProperty(
bool is_virtual,
170 unsigned int increment,
171 unsigned int number) {
172 std::vector<RangeDMPAddress<type> > addresses;
174 addresses.push_back(address);
175 return NewRangeDMPGetProperty<type>(is_virtual, is_relative, addresses);
188 const DMPPDU *NewRangeDMPGetProperty(
192 unsigned int increment,
193 unsigned int number);
202 template <
typename type>
205 typedef std::vector<DMPAddressData<type> > AddressDataChunks;
211 unsigned int DataSize()
const {
212 typename AddressDataChunks::const_iterator iter;
213 unsigned int length = 0;
214 for (iter = m_chunks.begin(); iter != m_chunks.end(); ++iter)
215 length += iter->Size();
219 bool PackData(uint8_t *data,
unsigned int *length)
const {
220 typename AddressDataChunks::const_iterator iter;
221 unsigned int offset = 0;
222 for (iter = m_chunks.begin(); iter != m_chunks.end(); ++iter) {
223 unsigned int remaining = *length - offset;
224 if (!iter->Pack(data + offset, &remaining))
233 typename AddressDataChunks::const_iterator iter;
234 for (iter = m_chunks.begin(); iter != m_chunks.end(); ++iter)
239 AddressDataChunks m_chunks;
246 template <
typename type>
247 const DMPPDU *NewDMPSetProperty(
255 TypeToDMPSize<type>());
267 template <
typename type>
268 const DMPPDU *NewRangeDMPSetProperty(
272 bool multiple_elements =
true,
273 bool equal_size_elements =
true) {
275 dmp_address_type address_type;
276 if (multiple_elements) {
277 if (equal_size_elements)
278 address_type = RANGE_EQUAL;
280 address_type = RANGE_MIXED;
282 address_type = RANGE_SINGLE;
288 TypeToDMPSize<type>());
293 #endif // LIBS_ACN_DMPPDU_H_
Definition: OutputStream.h:54
Definition: DMPAddress.h:240
Definition: DMPAddress.h:168
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
Definition: ACNVectors.h:56
Definition: DMPAddress.h:118
Definition: ACNVectors.h:57