haiku/headers/os/bluetooth/bdaddrUtils.h
Oliver Ruiz Dorantes 01e363a708 - Reflect the APi change in the RemoteDevice
- Implement function to compare Bluetooth Addresses


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24992 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-04-16 22:17:55 +00:00

72 lines
1.3 KiB
C++

/*
* Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
*
* All rights reserved. Distributed under the terms of the MIT License.
*
*/
#ifndef _BDADDR_UTILS_H
#define _BDADDR_UTILS_H
#include <stdio.h>
#include <bluetooth/bluetooth.h>
namespace Bluetooth {
class bdaddrUtils {
public:
static inline bdaddr_t NullAddress()
{
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}});
}
static bool Compare(bdaddr_t* ba1, bdaddr_t* ba2)
{
return (memcmp(ba1, ba2, sizeof(bdaddr_t)) == 0);
}
static char* ToString(const bdaddr_t bdaddr)
{
// TODO: not safe
static char str[18];
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]);
return str;
}
};
}
#ifndef _BT_USE_EXPLICIT_NAMESPACE
using Bluetooth::bdaddrUtils;
#endif
#endif