2008-02-02 00:17:02 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
|
|
|
|
* All rights reserved. Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef _BLUETOOTH_UTIL_H
|
|
|
|
#define _BLUETOOTH_UTIL_H
|
|
|
|
|
|
|
|
#include <bluetooth/bluetooth.h>
|
2008-08-15 23:08:48 +04:00
|
|
|
#include <string.h>
|
2008-02-02 00:17:02 +03:00
|
|
|
|
|
|
|
/* BD Address management */
|
|
|
|
static inline int bacmp(bdaddr_t* ba1, bdaddr_t* ba2)
|
|
|
|
{
|
|
|
|
return memcmp(ba1, ba2, sizeof(bdaddr_t));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline void bacpy(bdaddr_t* dst, bdaddr_t* src)
|
|
|
|
{
|
|
|
|
memcpy(dst, src, sizeof(bdaddr_t));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-16 23:32:19 +03:00
|
|
|
static inline void baswap(bdaddr_t* dst, bdaddr_t* src)
|
2008-02-02 00:17:02 +03:00
|
|
|
{
|
2009-04-22 01:36:37 +04:00
|
|
|
register uint8* d = (uint8*)dst;
|
|
|
|
register uint8* s = (uint8*)src;
|
|
|
|
register int i;
|
2008-02-02 00:17:02 +03:00
|
|
|
|
2009-04-22 01:36:37 +04:00
|
|
|
for(i = 0; i < 6; i++)
|
|
|
|
d[i] = s[5 - i];
|
2008-02-02 00:17:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* TODO: Bluetooth Errors */
|
|
|
|
static inline char* btstrerror(int error_code)
|
|
|
|
{
|
|
|
|
return "Unknown Bluetooth error";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-03 01:15:02 +04:00
|
|
|
#endif // _BLUETOOTH_UTIL_H
|