28 #ifndef INCLUDE_OLA_RDM_UID_H_
29 #define INCLUDE_OLA_RDM_UID_H_
64 UID(uint16_t esta_id, uint32_t device_id) {
65 m_uid.esta_id = esta_id;
66 m_uid.device_id = device_id;
74 m_uid.esta_id = uid.m_uid.esta_id;
75 m_uid.device_id = uid.m_uid.device_id;
83 explicit UID(
const uint8_t *data) {
84 m_uid.esta_id =
static_cast<uint16_t
>((data[0] << 8) + data[1]);
85 m_uid.device_id =
static_cast<uint32_t
>(data[2] << 24) +
86 static_cast<uint32_t>(data[3] << 16) +
87 static_cast<uint32_t
>(data[4] << 8) +
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::stringstream 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_