28 #ifndef INCLUDE_OLA_RDM_UID_H_
29 #define INCLUDE_OLA_RDM_UID_H_
33 #include <ola/util/Utils.h>
66 UID(uint16_t esta_id, uint32_t device_id) {
67 m_uid.esta_id = esta_id;
68 m_uid.device_id = device_id;
76 m_uid.esta_id = uid.m_uid.esta_id;
77 m_uid.device_id = uid.m_uid.device_id;
85 explicit UID(
const uint8_t *data) {
86 m_uid.esta_id = ola::utils::JoinUInt8(data[0], data[1]);
87 m_uid.device_id = ola::utils::JoinUInt8(data[2], data[3], data[4],
96 m_uid.esta_id = other.m_uid.esta_id;
97 m_uid.device_id = other.m_uid.device_id;
107 return 0 == cmp(*
this, other);
115 return 0 != cmp(*
this, other);
123 return cmp(*
this, other) > 0;
131 return cmp(*
this, other) < 0;
144 uint32_t
DeviceId()
const {
return m_uid.device_id; }
176 return *
this == uid ||
187 std::ostringstream str;
188 str << std::setfill(
'0') << std::setw(4) << std::hex << m_uid.esta_id
189 <<
":" << std::setw(8) << m_uid.device_id;
208 bool Pack(uint8_t *buffer,
unsigned int length)
const {
211 buffer[0] =
static_cast<uint8_t
>(m_uid.esta_id >> 8);
212 buffer[1] =
static_cast<uint8_t
>(m_uid.esta_id & 0xff);
213 buffer[2] =
static_cast<uint8_t
>(m_uid.device_id >> 24);
214 buffer[3] =
static_cast<uint8_t
>(m_uid.device_id >> 16);
215 buffer[4] =
static_cast<uint8_t
>(m_uid.device_id >> 8);
216 buffer[5] =
static_cast<uint8_t
>(m_uid.device_id & 0xff);
279 struct rdm_uid m_uid;
281 int cmp(
const UID &a,
const UID &b)
const {
282 if (a.m_uid.esta_id == b.m_uid.esta_id)
283 return cmp(a.m_uid.device_id, b.m_uid.device_id);
284 return cmp(a.m_uid.esta_id, b.m_uid.esta_id);
287 int cmp(uint32_t a, uint32_t b)
const {
290 return a < b ? -1 : 1;
295 #endif // INCLUDE_OLA_RDM_UID_H_
UID(const UID &uid)
Copy constructor.
Definition: UID.h:75
bool DirectedToUID(const UID &uid) const
Check if this UID matches against another.
Definition: UID.h:175
bool operator!=(const UID &other) const
Inequality operator.
Definition: UID.h:114
static const uint16_t ALL_MANUFACTURERS
The value for the 'all manufacturers' id.
Definition: UID.h:266
bool operator==(const UID &other) const
Equality operator.
Definition: UID.h:106
static const uint32_t ALL_DEVICES
The value for the 'all devices' id.
Definition: UID.h:271
bool IsBroadcast() const
Check if this UID is a broadcast or vendorcast UID.
Definition: UID.h:150
static UID VendorcastAddress(uint16_t esta_id)
Returns a UID that matches all devices for a particular manufacturer.
Definition: UID.h:234
UID(const uint8_t *data)
Construct a new UID from binary data.
Definition: UID.h:85
friend std::ostream & operator<<(std::ostream &out, const UID &uid)
A helper function to write a UID to an ostream.
Definition: UID.h:198
bool operator<(const UID &other) const
Less than.
Definition: UID.h:130
uint16_t ManufacturerId() const
The manufacturer ID for this UID.
Definition: UID.h:138
bool Pack(uint8_t *buffer, unsigned int length) const
Write the binary representation of the UID to memory.
Definition: UID.h:208
UID & operator=(const UID &other)
Assignment operator.
Definition: UID.h:94
UID(uint16_t esta_id, uint32_t device_id)
Constructs a new UID.
Definition: UID.h:66
static UID * FromString(const std::string &uid)
Return a new UID from a string.
Definition: UID.cpp:32
bool operator>(const UID &other) const
Greater than.
Definition: UID.h:122
Represents a RDM UID.
Definition: UID.h:57
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
uint32_t DeviceId() const
The device ID for this UID.
Definition: UID.h:144
static UID VendorcastAddress(UID uid)
Returns a UID that matches all devices for a particular manufacturer.
Definition: UID.h:244
static UID AllDevices()
Returns a UID that matches all devices (ffff:ffffffff).
Definition: UID.h:224
std::string ToString() const
Convert a UID to a human readable string.
Definition: UID.h:186