*Incorrect endianess handling from bdaddr at parsing from string.
*Remove bluetooth_util deprecated header *Issue conn_req for socket connect() call git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37132 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -7,9 +7,9 @@
|
||||
#define _BDADDR_UTILS_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <bluetooth/bluetooth.h>
|
||||
#include <bluetooth/bluetooth_util.h>
|
||||
|
||||
namespace Bluetooth {
|
||||
|
||||
@@ -34,12 +34,17 @@ public:
|
||||
}
|
||||
|
||||
|
||||
static bool Compare(bdaddr_t *ba1, bdaddr_t *ba2)
|
||||
static bool Compare(const bdaddr_t* ba1, const bdaddr_t* ba2)
|
||||
{
|
||||
return (bacmp(ba1, ba2) == 0);
|
||||
return (memcmp(ba1, ba2, sizeof(bdaddr_t)) == 0);
|
||||
}
|
||||
|
||||
|
||||
static void Copy(bdaddr_t* dst, const bdaddr_t* src)
|
||||
{
|
||||
memcpy(dst, src, sizeof(bdaddr_t));
|
||||
}
|
||||
|
||||
static char* ToString(const bdaddr_t bdaddr)
|
||||
{
|
||||
// TODO: not safe
|
||||
@@ -58,7 +63,7 @@ public:
|
||||
|
||||
if (addr != NULL) {
|
||||
size_t count = sscanf(addr, "%2X:%2X:%2X:%2X:%2X:%2X",
|
||||
&b0, &b1, &b2, &b3, &b4, &b5);
|
||||
&b5, &b4, &b3, &b2, &b1, &b0);
|
||||
|
||||
if (count == 6)
|
||||
return ((bdaddr_t) {{b0, b1, b2, b3, b4, b5}});
|
||||
@@ -71,6 +76,7 @@ public:
|
||||
|
||||
}
|
||||
|
||||
|
||||
#ifndef _BT_USE_EXPLICIT_NAMESPACE
|
||||
using Bluetooth::bdaddrUtils;
|
||||
#endif
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* 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>
|
||||
#include <string.h>
|
||||
|
||||
/* 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));
|
||||
}
|
||||
|
||||
|
||||
static inline void baswap(bdaddr_t* dst, bdaddr_t* src)
|
||||
{
|
||||
register uint8* d = (uint8*)dst;
|
||||
register uint8* s = (uint8*)src;
|
||||
register int i;
|
||||
|
||||
for(i = 0; i < 6; i++)
|
||||
d[i] = s[5 - i];
|
||||
}
|
||||
|
||||
|
||||
/* TODO: Bluetooth Errors */
|
||||
static inline char* btstrerror(int error_code)
|
||||
{
|
||||
return "Unknown Bluetooth error";
|
||||
}
|
||||
|
||||
|
||||
#endif // _BLUETOOTH_UTIL_H
|
||||
Reference in New Issue
Block a user