2007-10-21 21:56:01 +04:00
|
|
|
/*
|
2007-11-30 22:51:44 +03:00
|
|
|
* Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
|
|
|
|
*
|
|
|
|
* All rights reserved. Distributed under the terms of the MIT License.
|
2007-10-21 21:56:01 +04:00
|
|
|
*
|
|
|
|
*/
|
2007-11-30 22:51:44 +03:00
|
|
|
|
2007-10-21 21:56:01 +04:00
|
|
|
#ifndef _BDADDR_UTILS_H
|
|
|
|
#define _BDADDR_UTILS_H
|
|
|
|
|
2008-02-25 23:14:15 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2007-10-22 21:51:59 +04:00
|
|
|
#include <bluetooth/bluetooth.h>
|
2007-10-21 21:56:01 +04:00
|
|
|
|
|
|
|
namespace Bluetooth {
|
|
|
|
|
2007-10-22 21:51:59 +04:00
|
|
|
class bdaddrUtils {
|
|
|
|
|
|
|
|
public:
|
2007-11-30 22:51:44 +03:00
|
|
|
static inline bdaddr_t NullAddress()
|
2007-10-22 21:51:59 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
return ((bdaddr_t) {{0, 0, 0, 0, 0, 0}});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline bdaddr_t LocalAddress()
|
|
|
|
{
|
|
|
|
|
|
|
|
return ((bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff}});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline bdaddr_t BroadcastAddress()
|
|
|
|
{
|
|
|
|
|
|
|
|
return ((bdaddr_t) {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-25 23:14:15 +03:00
|
|
|
static char* ToString(const bdaddr_t bdaddr)
|
2007-10-22 21:51:59 +04:00
|
|
|
{
|
2008-02-25 23:14:15 +03:00
|
|
|
// TODO: not safe
|
|
|
|
static char str[18];
|
2007-10-21 21:56:01 +04:00
|
|
|
|
2008-02-25 23:14:15 +03:00
|
|
|
sprintf(str,"%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",bdaddr.b[0],
|
|
|
|
bdaddr.b[1],
|
|
|
|
bdaddr.b[2],
|
|
|
|
bdaddr.b[3],
|
|
|
|
bdaddr.b[4],
|
|
|
|
bdaddr.b[5]);
|
|
|
|
|
2007-10-22 21:51:59 +04:00
|
|
|
return str;
|
|
|
|
}
|
2007-10-21 21:56:01 +04:00
|
|
|
|
2007-10-22 21:51:59 +04:00
|
|
|
};
|
|
|
|
|
2007-10-21 21:56:01 +04:00
|
|
|
}
|
|
|
|
|
2008-02-25 23:14:15 +03:00
|
|
|
#ifndef _BT_USE_EXPLICIT_NAMESPACE
|
|
|
|
using Bluetooth::bdaddrUtils;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2007-10-21 21:56:01 +04:00
|
|
|
#endif
|