1 /* 2 * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com 3 * 4 * All rights reserved. Distributed under the terms of the MIT License. 5 * 6 */ 7 8 #ifndef _BDADDR_UTILS_H 9 #define _BDADDR_UTILS_H 10 11 #include <stdio.h> 12 13 #include <bluetooth/bluetooth.h> 14 15 namespace Bluetooth { 16 17 class bdaddrUtils { 18 19 public: 20 static inline bdaddr_t NullAddress() 21 { 22 23 return ((bdaddr_t) {{0, 0, 0, 0, 0, 0}}); 24 } 25 26 27 static inline bdaddr_t LocalAddress() 28 { 29 30 return ((bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff}}); 31 } 32 33 34 static inline bdaddr_t BroadcastAddress() 35 { 36 37 return ((bdaddr_t) {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}); 38 } 39 40 41 static bool Compare(bdaddr_t* ba1, bdaddr_t* ba2) 42 { 43 return (memcmp(ba1, ba2, sizeof(bdaddr_t)) == 0); 44 } 45 46 47 static char* ToString(const bdaddr_t bdaddr) 48 { 49 // TODO: not safe 50 static char str[18]; 51 52 sprintf(str,"%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",bdaddr.b[0], 53 bdaddr.b[1], 54 bdaddr.b[2], 55 bdaddr.b[3], 56 bdaddr.b[4], 57 bdaddr.b[5]); 58 59 return str; 60 } 61 62 }; 63 64 } 65 66 #ifndef _BT_USE_EXPLICIT_NAMESPACE 67 using Bluetooth::bdaddrUtils; 68 #endif 69 70 71 #endif 72