28 #ifndef INCLUDE_OLA_RDM_UID_H_
29 #define INCLUDE_OLA_RDM_UID_H_
63 UID(uint16_t esta_id, uint32_t device_id) {
64 m_uid.esta_id = esta_id;
65 m_uid.device_id = device_id;
73 m_uid.esta_id = uid.m_uid.esta_id;
74 m_uid.device_id = uid.m_uid.device_id;
82 explicit UID(
const uint8_t *data) {
83 m_uid.esta_id =
static_cast<uint16_t
>((data[0] << 8) + data[1]);
84 m_uid.device_id =
static_cast<uint32_t
>(data[2] << 24) +
85 static_cast<uint32_t>(data[3] << 16) +
86 static_cast<uint32_t
>(data[4] << 8) +
95 m_uid.esta_id = other.m_uid.esta_id;
96 m_uid.device_id = other.m_uid.device_id;
106 return 0 == cmp(*
this, other);
114 return 0 != cmp(*
this, other);
122 return cmp(*
this, other) > 0;
130 return cmp(*
this, other) < 0;
143 uint32_t
DeviceId()
const {
return m_uid.device_id; }
175 return *
this == uid ||
186 std::ostringstream str;
187 str << std::setfill(
'0') << std::setw(4) << std::hex << m_uid.esta_id
188 <<
":" << std::setw(8) << m_uid.device_id;
207 bool Pack(uint8_t *buffer,
unsigned int length)
const {
210 buffer[0] =
static_cast<uint8_t
>(m_uid.esta_id >> 8);
211 buffer[1] =
static_cast<uint8_t
>(m_uid.esta_id & 0xff);
212 buffer[2] =
static_cast<uint8_t
>(m_uid.device_id >> 24);
213 buffer[3] =
static_cast<uint8_t
>(m_uid.device_id >> 16);
214 buffer[4] =
static_cast<uint8_t
>(m_uid.device_id >> 8);
215 buffer[5] =
static_cast<uint8_t
>(m_uid.device_id & 0xff);
278 struct rdm_uid m_uid;
280 int cmp(
const UID &a,
const UID &b)
const {
281 if (a.m_uid.esta_id == b.m_uid.esta_id)
282 return cmp(a.m_uid.device_id, b.m_uid.device_id);
283 return cmp(a.m_uid.esta_id, b.m_uid.esta_id);
286 int cmp(uint32_t a, uint32_t b)
const {
289 return a < b ? -1 : 1;
294 #endif // INCLUDE_OLA_RDM_UID_H_