[Positioning] Add PosUtil::int_to_mac()
This commit is contained in:
parent
a2a289f651
commit
1abe54b7be
|
@ -163,3 +163,21 @@ unsigned long PosUtil::wifi_channel_to_hz(const unsigned long &channel)
|
|||
// Error: wrong channel value
|
||||
throw bad_channel(channel) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* *** Strings *** */
|
||||
|
||||
|
||||
string PosUtil::int_to_mac(const uint32_t source)
|
||||
{
|
||||
uint8_t bytes[6] ;
|
||||
memset(bytes, 0, 6) ;
|
||||
for (int i = 0 ; i < 4 ; ++i)
|
||||
bytes[i+2] = reinterpret_cast<const uint8_t*>(&source)[i] ;
|
||||
char mac_cstr[OWL_ETHER_ADDR_STRLEN] ;
|
||||
owl_mac_bytes_to_string_r(bytes, mac_cstr) ;
|
||||
string mac(mac_cstr) ;
|
||||
to_upper(mac) ;
|
||||
return mac ;
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ public:
|
|||
//@{
|
||||
static void to_upper(std::string &str) ;
|
||||
static void assert_uppercase(const std::string &str) ;
|
||||
static std::string int_to_mac(const uint32_t source) ;
|
||||
//@}
|
||||
} ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue