git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26228 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Ruiz Dorantes
2008-07-02 20:01:02 +00:00
parent 9bfe62f9aa
commit c8bc2d8897
9 changed files with 633 additions and 633 deletions
+46 -46
View File
@@ -1,46 +1,46 @@
/* /*
* Copyright 2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com * Copyright 2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
* *
* All rights reserved. Distributed under the terms of the MIT License. * All rights reserved. Distributed under the terms of the MIT License.
* *
*/ */
#ifndef _BLUETOOTH_DEVICE_H #ifndef _BLUETOOTH_DEVICE_H
#define _BLUETOOTH_DEVICE_H #define _BLUETOOTH_DEVICE_H
#include <bluetooth/bluetooth.h> #include <bluetooth/bluetooth.h>
#include <bluetooth/DeviceClass.h> #include <bluetooth/DeviceClass.h>
#include <Messenger.h> #include <Messenger.h>
#include <Message.h> #include <Message.h>
#include <String.h> #include <String.h>
namespace Bluetooth { namespace Bluetooth {
class BluetoothDevice { class BluetoothDevice {
public: public:
virtual BString GetFriendlyName()=0; virtual BString GetFriendlyName()=0;
virtual DeviceClass GetDeviceClass()=0; virtual DeviceClass GetDeviceClass()=0;
virtual BString GetProperty(const char* property)=0; virtual BString GetProperty(const char* property)=0;
virtual void GetProperty(const char* property, uint32* value)=0; virtual void GetProperty(const char* property, uint32* value)=0;
virtual bdaddr_t GetBluetoothAddress()=0; virtual bdaddr_t GetBluetoothAddress()=0;
protected: protected:
bdaddr_t fBdaddr; bdaddr_t fBdaddr;
DeviceClass fDeviceClass; DeviceClass fDeviceClass;
}; };
} }
#ifndef _BT_USE_EXPLICIT_NAMESPACE #ifndef _BT_USE_EXPLICIT_NAMESPACE
using Bluetooth::BluetoothDevice; using Bluetooth::BluetoothDevice;
#endif #endif
#endif #endif
+69 -69
View File
@@ -1,69 +1,69 @@
/* /*
* Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
* *
* All rights reserved. Distributed under the terms of the MIT License. * All rights reserved. Distributed under the terms of the MIT License.
* *
*/ */
#ifndef _DEVICE_CLASS_H #ifndef _DEVICE_CLASS_H
#define _DEVICE_CLASS_H #define _DEVICE_CLASS_H
#include <String.h> #include <String.h>
namespace Bluetooth { namespace Bluetooth {
class DeviceClass { class DeviceClass {
public: public:
DeviceClass(int record) DeviceClass(int record)
{ {
this->record = record; this->record = record;
} }
DeviceClass() DeviceClass()
{ {
this->record = 0; this->record = 0;
} }
int GetServiceClasses() int GetServiceClasses()
{ {
return (record & 0x00FFE000) >> 13; return (record & 0x00FFE000) >> 13;
} }
int GetMajorDeviceClass() int GetMajorDeviceClass()
{ {
return (record & 0x00001F00) >> 8; return (record & 0x00001F00) >> 8;
} }
void GetMajorDeviceClass(BString* str) void GetMajorDeviceClass(BString* str)
{ {
} }
int GetMinorDeviceClass() int GetMinorDeviceClass()
{ {
return (record & 0x000000FF) >> 2; return (record & 0x000000FF) >> 2;
} }
void GetMinorDeviceClass(BString* str) void GetMinorDeviceClass(BString* str)
{ {
} }
private: private:
int record; int record;
}; };
} }
#ifndef _BT_USE_EXPLICIT_NAMESPACE #ifndef _BT_USE_EXPLICIT_NAMESPACE
using Bluetooth::DeviceClass; using Bluetooth::DeviceClass;
#endif #endif
#endif #endif
+74 -74
View File
@@ -1,74 +1,74 @@
/* /*
* Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com * Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
* *
* All rights reserved. Distributed under the terms of the MIT License. * All rights reserved. Distributed under the terms of the MIT License.
* *
*/ */
#ifndef _DISCOVERY_AGENT_H #ifndef _DISCOVERY_AGENT_H
#define _DISCOVERY_AGENT_H #define _DISCOVERY_AGENT_H
#include <bluetooth/bluetooth.h> #include <bluetooth/bluetooth.h>
#include <bluetooth/DiscoveryListener.h> #include <bluetooth/DiscoveryListener.h>
#define BT_CACHED 0x00 #define BT_CACHED 0x00
#define BT_PREKNOWN 0x01 #define BT_PREKNOWN 0x01
#define BT_NOT_DISCOVERABLE 0x01 #define BT_NOT_DISCOVERABLE 0x01
#define BT_GIAC 0x9E8B33 #define BT_GIAC 0x9E8B33
#define BT_LIAC 0x9E8B00 #define BT_LIAC 0x9E8B00
#define BT_MAX_RESPONSES (32) #define BT_MAX_RESPONSES (32)
#define BT_BASE_INQUIRY_TIME (1.28) #define BT_BASE_INQUIRY_TIME (1.28)
#define BT_DEFAULT_INQUIRY_TIME (0x15*BT_BASE_INQUIRY_TIME) /* TODO: REVIEW SPECS! */ #define BT_DEFAULT_INQUIRY_TIME (0x15*BT_BASE_INQUIRY_TIME) /* TODO: REVIEW SPECS! */
namespace Bluetooth { namespace Bluetooth {
class DiscoveryListener; class DiscoveryListener;
class RemoteDevice; class RemoteDevice;
class DiscoveryAgent { class DiscoveryAgent {
public: public:
static const int GIAC = BT_GIAC; static const int GIAC = BT_GIAC;
static const int LIAC = BT_LIAC; static const int LIAC = BT_LIAC;
static const int PREKNOWN = BT_PREKNOWN; static const int PREKNOWN = BT_PREKNOWN;
static const int CACHED = BT_CACHED; static const int CACHED = BT_CACHED;
static const int NOT_DISCOVERABLE = BT_NOT_DISCOVERABLE; static const int NOT_DISCOVERABLE = BT_NOT_DISCOVERABLE;
RemoteDevicesList RetrieveDevices(int option); /* TODO */ RemoteDevicesList RetrieveDevices(int option); /* TODO */
status_t StartInquiry(int accessCode, DiscoveryListener* listener); /* Throwing */ status_t StartInquiry(int accessCode, DiscoveryListener* listener); /* Throwing */
status_t StartInquiry(uint32 accessCode, DiscoveryListener* listener, bigtime_t secs); status_t StartInquiry(uint32 accessCode, DiscoveryListener* listener, bigtime_t secs);
status_t CancelInquiry(DiscoveryListener* listener); status_t CancelInquiry(DiscoveryListener* listener);
/* /*
int searchServices(int[] attrSet, int searchServices(int[] attrSet,
UUID[] uuidSet, UUID[] uuidSet,
RemoteDevice btDev, RemoteDevice btDev,
DiscoveryListener discListener); DiscoveryListener discListener);
bool cancelServiceSearch(int transID); bool cancelServiceSearch(int transID);
BString selectService(UUID uuid, int security, boolean master); BString selectService(UUID uuid, int security, boolean master);
*/ */
private: private:
DiscoveryAgent(LocalDevice* ld); DiscoveryAgent(LocalDevice* ld);
void SetLocalDeviceOwner(LocalDevice* ld); void SetLocalDeviceOwner(LocalDevice* ld);
DiscoveryListener* fLastUsedListener; DiscoveryListener* fLastUsedListener;
LocalDevice* fLocalDevice; LocalDevice* fLocalDevice;
friend class LocalDevice; friend class LocalDevice;
}; };
} }
#ifndef _BT_USE_EXPLICIT_NAMESPACE #ifndef _BT_USE_EXPLICIT_NAMESPACE
using Bluetooth::DiscoveryAgent; using Bluetooth::DiscoveryAgent;
#endif #endif
#endif #endif
+76 -76
View File
@@ -1,76 +1,76 @@
/* /*
* Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
* *
* All rights reserved. Distributed under the terms of the MIT License. * All rights reserved. Distributed under the terms of the MIT License.
* *
*/ */
#ifndef _DISCOVERY_LISTENER_H #ifndef _DISCOVERY_LISTENER_H
#define _DISCOVERY_LISTENER_H #define _DISCOVERY_LISTENER_H
#include <Looper.h> #include <Looper.h>
#include <ObjectList.h> #include <ObjectList.h>
#include <bluetooth/RemoteDevice.h> #include <bluetooth/RemoteDevice.h>
#define BT_INQUIRY_COMPLETED 0x01 // HCI_EVENT_X check specs #define BT_INQUIRY_COMPLETED 0x01 // HCI_EVENT_X check specs
#define BT_INQUIRY_TERMINATED 0x02 // HCI_EVENT_X #define BT_INQUIRY_TERMINATED 0x02 // HCI_EVENT_X
#define BT_INQUIRY_ERROR 0x03 // HCI_EVENT_X #define BT_INQUIRY_ERROR 0x03 // HCI_EVENT_X
namespace Bluetooth { namespace Bluetooth {
typedef BObjectList<RemoteDevice> RemoteDevicesList; typedef BObjectList<RemoteDevice> RemoteDevicesList;
class RemoteDevice; class RemoteDevice;
class DeviceClass; class DeviceClass;
class LocalDevice; class LocalDevice;
class DiscoveryListener : public BLooper { class DiscoveryListener : public BLooper {
public: public:
static const int INQUIRY_COMPLETED = BT_INQUIRY_COMPLETED; static const int INQUIRY_COMPLETED = BT_INQUIRY_COMPLETED;
static const int INQUIRY_TERMINATED = BT_INQUIRY_TERMINATED; static const int INQUIRY_TERMINATED = BT_INQUIRY_TERMINATED;
static const int INQUIRY_ERROR = BT_INQUIRY_ERROR; static const int INQUIRY_ERROR = BT_INQUIRY_ERROR;
static const int SERVICE_SEARCH_COMPLETED = 0x01; static const int SERVICE_SEARCH_COMPLETED = 0x01;
static const int SERVICE_SEARCH_TERMINATED = 0x02; static const int SERVICE_SEARCH_TERMINATED = 0x02;
static const int SERVICE_SEARCH_ERROR = 0x03; static const int SERVICE_SEARCH_ERROR = 0x03;
static const int SERVICE_SEARCH_NO_RECORDS = 0x04; static const int SERVICE_SEARCH_NO_RECORDS = 0x04;
static const int SERVICE_SEARCH_DEVICE_NOT_REACHABLE = 0x06; static const int SERVICE_SEARCH_DEVICE_NOT_REACHABLE = 0x06;
virtual void DeviceDiscovered(RemoteDevice* btDevice, DeviceClass cod); virtual void DeviceDiscovered(RemoteDevice* btDevice, DeviceClass cod);
/* /*
virtual void servicesDiscovered(int transID, ServiceRecord[] servRecord); virtual void servicesDiscovered(int transID, ServiceRecord[] servRecord);
virtual void serviceSearchCompleted(int transID, int respCode); virtual void serviceSearchCompleted(int transID, int respCode);
*/ */
virtual void InquiryCompleted(int discType); virtual void InquiryCompleted(int discType);
/* JSR82 non-defined methods */ /* JSR82 non-defined methods */
virtual void InquiryStarted(status_t status); virtual void InquiryStarted(status_t status);
private: private:
RemoteDevicesList GetRemoteDevicesList(void); RemoteDevicesList GetRemoteDevicesList(void);
void MessageReceived(BMessage* msg); void MessageReceived(BMessage* msg);
LocalDevice* fLocalDevice; LocalDevice* fLocalDevice;
RemoteDevicesList fRemoteDevicesList; RemoteDevicesList fRemoteDevicesList;
friend class DiscoveryAgent; friend class DiscoveryAgent;
protected: protected:
DiscoveryListener(); DiscoveryListener();
void SetLocalDeviceOwner(LocalDevice* ld); void SetLocalDeviceOwner(LocalDevice* ld);
}; };
} }
#ifndef _BT_USE_EXPLICIT_NAMESPACE #ifndef _BT_USE_EXPLICIT_NAMESPACE
using Bluetooth::DiscoveryListener; using Bluetooth::DiscoveryListener;
#endif #endif
#endif #endif
+75 -75
View File
@@ -1,75 +1,75 @@
/* /*
* Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
* *
* All rights reserved. Distributed under the terms of the MIT License. * All rights reserved. Distributed under the terms of the MIT License.
* *
*/ */
#ifndef _LOCAL_DEVICE_H #ifndef _LOCAL_DEVICE_H
#define _LOCAL_DEVICE_H #define _LOCAL_DEVICE_H
#include <bluetooth/bluetooth.h> #include <bluetooth/bluetooth.h>
#include <bluetooth/DeviceClass.h> #include <bluetooth/DeviceClass.h>
#include <bluetooth/BluetoothDevice.h> #include <bluetooth/BluetoothDevice.h>
#include <bluetooth/HCI/btHCI.h> #include <bluetooth/HCI/btHCI.h>
#include <Messenger.h> #include <Messenger.h>
#include <Message.h> #include <Message.h>
#include <String.h> #include <String.h>
namespace Bluetooth { namespace Bluetooth {
class DiscoveryAgent; class DiscoveryAgent;
class LocalDevice : public BluetoothDevice { class LocalDevice : public BluetoothDevice {
public: public:
/* Possible throwing */ /* Possible throwing */
static LocalDevice* GetLocalDevice(); static LocalDevice* GetLocalDevice();
static uint32 GetLocalDeviceCount(); static uint32 GetLocalDeviceCount();
static LocalDevice* GetLocalDevice(hci_id hid); static LocalDevice* GetLocalDevice(hci_id hid);
static LocalDevice* GetLocalDevice(bdaddr_t bdaddr); static LocalDevice* GetLocalDevice(bdaddr_t bdaddr);
DiscoveryAgent* GetDiscoveryAgent(); DiscoveryAgent* GetDiscoveryAgent();
BString GetFriendlyName(); BString GetFriendlyName();
DeviceClass GetDeviceClass(); DeviceClass GetDeviceClass();
/* Possible throwing */ /* Possible throwing */
status_t SetDiscoverable(int mode); status_t SetDiscoverable(int mode);
BString GetProperty(const char* property); BString GetProperty(const char* property);
void GetProperty(const char* property, uint32* value); void GetProperty(const char* property, uint32* value);
int GetDiscoverable(); int GetDiscoverable();
bdaddr_t GetBluetoothAddress(); bdaddr_t GetBluetoothAddress();
/* /*
ServiceRecord getRecord(Connection notifier); ServiceRecord getRecord(Connection notifier);
void updateRecord(ServiceRecord srvRecord); void updateRecord(ServiceRecord srvRecord);
*/ */
private: private:
LocalDevice(hci_id hid); LocalDevice(hci_id hid);
virtual ~LocalDevice(); virtual ~LocalDevice();
hci_id GetID(void) {return hid;} hci_id GetID(void) {return hid;}
static LocalDevice* RequestLocalDeviceID(BMessage* request); static LocalDevice* RequestLocalDeviceID(BMessage* request);
BMessenger* fMessenger; BMessenger* fMessenger;
hci_id hid; hci_id hid;
friend class DiscoveryAgent; friend class DiscoveryAgent;
friend class RemoteDevice; friend class RemoteDevice;
friend class PincodeWindow; friend class PincodeWindow;
}; };
} }
#ifndef _BT_USE_EXPLICIT_NAMESPACE #ifndef _BT_USE_EXPLICIT_NAMESPACE
using Bluetooth::LocalDevice; using Bluetooth::LocalDevice;
#endif #endif
#endif #endif
+81 -81
View File
@@ -1,81 +1,81 @@
/* /*
* Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
* *
* All rights reserved. Distributed under the terms of the MIT License. * All rights reserved. Distributed under the terms of the MIT License.
* *
*/ */
#ifndef _REMOTE_DEVICE_H #ifndef _REMOTE_DEVICE_H
#define _REMOTE_DEVICE_H #define _REMOTE_DEVICE_H
#include <bluetooth/bluetooth.h> #include <bluetooth/bluetooth.h>
#include <bluetooth/BluetoothDevice.h> #include <bluetooth/BluetoothDevice.h>
#include <String.h> #include <String.h>
#define B_BT_WAIT 0x00 #define B_BT_WAIT 0x00
#define B_BT_SUCCEEDED 0x01 #define B_BT_SUCCEEDED 0x01
namespace Bluetooth { namespace Bluetooth {
class Connection; class Connection;
class LocalDevice; class LocalDevice;
class RemoteDevice : public BluetoothDevice { class RemoteDevice : public BluetoothDevice {
public: public:
static const int WAIT = B_BT_WAIT; static const int WAIT = B_BT_WAIT;
static const int SUCCEEDED = B_BT_SUCCEEDED; static const int SUCCEEDED = B_BT_SUCCEEDED;
virtual ~RemoteDevice(); virtual ~RemoteDevice();
bool IsTrustedDevice(); bool IsTrustedDevice();
BString GetFriendlyName(bool alwaysAsk); /* Throwing */ BString GetFriendlyName(bool alwaysAsk); /* Throwing */
BString GetFriendlyName(void); /* Throwing */ BString GetFriendlyName(void); /* Throwing */
bdaddr_t GetBluetoothAddress(); bdaddr_t GetBluetoothAddress();
DeviceClass GetDeviceClass(); DeviceClass GetDeviceClass();
bool Equals(RemoteDevice* obj); bool Equals(RemoteDevice* obj);
/*static RemoteDevice* GetRemoteDevice(Connection conn); Throwing */ /*static RemoteDevice* GetRemoteDevice(Connection conn); Throwing */
bool Authenticate(); /* Throwing */ bool Authenticate(); /* Throwing */
/* bool Authorize(Connection conn); Throwing */ /* bool Authorize(Connection conn); Throwing */
/*bool Encrypt(Connection conn, bool on); Throwing */ /*bool Encrypt(Connection conn, bool on); Throwing */
bool IsAuthenticated(); /* Throwing */ bool IsAuthenticated(); /* Throwing */
/*bool IsAuthorized(Connection conn); Throwing */ /*bool IsAuthorized(Connection conn); Throwing */
bool IsEncrypted(); /* Throwing */ bool IsEncrypted(); /* Throwing */
BString GetProperty(const char* property); /* Throwing */ BString GetProperty(const char* property); /* Throwing */
void GetProperty(const char* property, uint32* value); /* Throwing */ void GetProperty(const char* property, uint32* value); /* Throwing */
LocalDevice* GetLocalDeviceOwner(); LocalDevice* GetLocalDeviceOwner();
protected: protected:
RemoteDevice(BString address); RemoteDevice(BString address);
RemoteDevice(bdaddr_t address); RemoteDevice(bdaddr_t address);
/* Instances of this class only would be instantiated by Discovery[Listener|Agent] */ /* Instances of this class only would be instantiated by Discovery[Listener|Agent] */
friend class DiscoveryListener; friend class DiscoveryListener;
void SetLocalDeviceOwner(LocalDevice* ld); void SetLocalDeviceOwner(LocalDevice* ld);
private: private:
LocalDevice* fDiscovererLocalDevice; LocalDevice* fDiscovererLocalDevice;
BMessenger* fMessenger; BMessenger* fMessenger;
uint8 fPageRepetitionMode; uint8 fPageRepetitionMode;
uint8 fScanPeriodMode; uint8 fScanPeriodMode;
uint8 fScanMode; uint8 fScanMode;
uint16 fClockOffset; uint16 fClockOffset;
}; };
} }
#ifndef _BT_USE_EXPLICIT_NAMESPACE #ifndef _BT_USE_EXPLICIT_NAMESPACE
using Bluetooth::RemoteDevice; using Bluetooth::RemoteDevice;
#endif #endif
#endif #endif
+88 -88
View File
@@ -1,88 +1,88 @@
/* /*
* Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
* *
* All rights reserved. Distributed under the terms of the MIT License. * All rights reserved. Distributed under the terms of the MIT License.
* *
*/ */
#ifndef _BDADDR_UTILS_H #ifndef _BDADDR_UTILS_H
#define _BDADDR_UTILS_H #define _BDADDR_UTILS_H
#include <stdio.h> #include <stdio.h>
#include <bluetooth/bluetooth.h> #include <bluetooth/bluetooth.h>
namespace Bluetooth { namespace Bluetooth {
class bdaddrUtils { class bdaddrUtils {
public: public:
static inline bdaddr_t NullAddress() static inline bdaddr_t NullAddress()
{ {
return ((bdaddr_t) {{0, 0, 0, 0, 0, 0}}); return ((bdaddr_t) {{0, 0, 0, 0, 0, 0}});
} }
static inline bdaddr_t LocalAddress() static inline bdaddr_t LocalAddress()
{ {
return ((bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff}}); return ((bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff}});
} }
static inline bdaddr_t BroadcastAddress() static inline bdaddr_t BroadcastAddress()
{ {
return ((bdaddr_t) {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}); return ((bdaddr_t) {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}});
} }
static bool Compare(bdaddr_t* ba1, bdaddr_t* ba2) static bool Compare(bdaddr_t* ba1, bdaddr_t* ba2)
{ {
return (memcmp(ba1, ba2, sizeof(bdaddr_t)) == 0); return (memcmp(ba1, ba2, sizeof(bdaddr_t)) == 0);
} }
static char* ToString(const bdaddr_t bdaddr) static char* ToString(const bdaddr_t bdaddr)
{ {
// TODO: not safe // TODO: not safe
static char str[18]; static char str[18];
sprintf(str,"%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",bdaddr.b[0], sprintf(str,"%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",bdaddr.b[0],
bdaddr.b[1], bdaddr.b[1],
bdaddr.b[2], bdaddr.b[2],
bdaddr.b[3], bdaddr.b[3],
bdaddr.b[4], bdaddr.b[4],
bdaddr.b[5]); bdaddr.b[5]);
return str; return str;
} }
static bdaddr_t FromString(const char * addr) static bdaddr_t FromString(const char * addr)
{ {
int b0, b1, b2, b3, b4, b5; int b0, b1, b2, b3, b4, b5;
size_t count = sscanf(addr, "%2X:%2X:%2X:%2X:%2X:%2X", size_t count = sscanf(addr, "%2X:%2X:%2X:%2X:%2X:%2X",
&b0, &b0,
&b1, &b1,
&b2, &b2,
&b3, &b3,
&b4, &b4,
&b5); &b5);
if (count == 6) if (count == 6)
return ((bdaddr_t) {{b0, b1, b2, b3, b4, b5}}); return ((bdaddr_t) {{b0, b1, b2, b3, b4, b5}});
return NullAddress(); return NullAddress();
} }
}; };
} }
#ifndef _BT_USE_EXPLICIT_NAMESPACE #ifndef _BT_USE_EXPLICIT_NAMESPACE
using Bluetooth::bdaddrUtils; using Bluetooth::bdaddrUtils;
#endif #endif
#endif #endif
+50 -50
View File
@@ -1,50 +1,50 @@
/* /*
* Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
* *
* All rights reserved. Distributed under the terms of the MIT License. * All rights reserved. Distributed under the terms of the MIT License.
* *
*/ */
#ifndef _BLUETOOTH_H #ifndef _BLUETOOTH_H
#define _BLUETOOTH_H #define _BLUETOOTH_H
#include <ByteOrder.h> #include <ByteOrder.h>
/* Bluetooth version */ /* Bluetooth version */
#define BLUETOOTH_1_1B 0 #define BLUETOOTH_1_1B 0
#define BLUETOOTH_1_1 1 #define BLUETOOTH_1_1 1
#define BLUETOOTH_1_2 2 #define BLUETOOTH_1_2 2
#define BLUETOOTH_2_0 3 #define BLUETOOTH_2_0 3
#define BLUETOOTH_VERSION BLUETOOTH_2_0 #define BLUETOOTH_VERSION BLUETOOTH_2_0
/* Bluetooth common types */ /* Bluetooth common types */
/* BD Address */ /* BD Address */
typedef struct { typedef struct {
uint8 b[6]; uint8 b[6];
} __attribute__((packed)) bdaddr_t; } __attribute__((packed)) bdaddr_t;
#define BDADDR_NULL (&(bdaddr_t) {{0, 0, 0, 0, 0, 0}}) #define BDADDR_NULL (&(bdaddr_t) {{0, 0, 0, 0, 0, 0}})
#define BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff}}) #define BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff}})
#define BDADDR_BROADCAST (&(bdaddr_t) {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}) #define BDADDR_BROADCAST (&(bdaddr_t) {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}})
#define BDADDR_ANY BDADDR_BROADCAST #define BDADDR_ANY BDADDR_BROADCAST
/* 128 integer type needed for SDP */ /* 128 integer type needed for SDP */
struct int128 { struct int128 {
int8 b[16]; int8 b[16];
}; };
typedef struct int128 int128; typedef struct int128 int128;
typedef struct int128 uint128; typedef struct int128 uint128;
/* Protocol definitions - add to as required... */ /* Protocol definitions - add to as required... */
#define BLUETOOTH_PROTO_HCI 134 /* HCI protocol number */ #define BLUETOOTH_PROTO_HCI 134 /* HCI protocol number */
#define BLUETOOTH_PROTO_L2CAP 135 /* L2CAP protocol number */ #define BLUETOOTH_PROTO_L2CAP 135 /* L2CAP protocol number */
#define BLUETOOTH_PROTO_RFCOMM 136 /* RFCOMM protocol number */ #define BLUETOOTH_PROTO_RFCOMM 136 /* RFCOMM protocol number */
#define BLUETOOTH_PROTO_MAX 256 #define BLUETOOTH_PROTO_MAX 256
#endif #endif
+74 -74
View File
@@ -1,74 +1,74 @@
/* /*
* Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
* *
* All rights reserved. Distributed under the terms of the MIT License. * All rights reserved. Distributed under the terms of the MIT License.
* *
*/ */
#ifndef _BLUETOOTH_ERROR_H #ifndef _BLUETOOTH_ERROR_H
#define _BLUETOOTH_ERROR_H #define _BLUETOOTH_ERROR_H
#include <Errors.h> #include <Errors.h>
#define BT_OK B_OK #define BT_OK B_OK
#define BT_ERROR BT_UNSPECIFIED_ERROR #define BT_ERROR BT_UNSPECIFIED_ERROR
/* Official error code for Bluetooth V2.1 + EDR */ /* Official error code for Bluetooth V2.1 + EDR */
#define BT_UNKNOWN_COMMAND 0x01 #define BT_UNKNOWN_COMMAND 0x01
#define BT_NO_CONNECTION 0x02 #define BT_NO_CONNECTION 0x02
#define BT_HARDWARE_FAILURE 0x03 #define BT_HARDWARE_FAILURE 0x03
#define BT_PAGE_TIMEOUT 0x04 #define BT_PAGE_TIMEOUT 0x04
#define BT_AUTHENTICATION_FAILURE 0x05 #define BT_AUTHENTICATION_FAILURE 0x05
#define BT_PIN_OR_KEY_MISSING 0x06 #define BT_PIN_OR_KEY_MISSING 0x06
#define BT_MEMORY_FULL 0x07 #define BT_MEMORY_FULL 0x07
#define BT_CONNECTION_TIMEOUT 0x08 #define BT_CONNECTION_TIMEOUT 0x08
#define BT_MAX_NUMBER_OF_CONNECTIONS 0x09 #define BT_MAX_NUMBER_OF_CONNECTIONS 0x09
#define BT_MAX_NUMBER_OF_SCO_CONNECTIONS 0x0a #define BT_MAX_NUMBER_OF_SCO_CONNECTIONS 0x0a
#define BT_ACL_CONNECTION_EXISTS 0x0b #define BT_ACL_CONNECTION_EXISTS 0x0b
#define BT_COMMAND_DISALLOWED 0x0c #define BT_COMMAND_DISALLOWED 0x0c
#define BT_REJECTED_LIMITED_RESOURCES 0x0d #define BT_REJECTED_LIMITED_RESOURCES 0x0d
#define BT_REJECTED_SECURITY 0x0e #define BT_REJECTED_SECURITY 0x0e
#define BT_REJECTED_PERSONAL 0x0f #define BT_REJECTED_PERSONAL 0x0f
#define BT_HOST_TIMEOUT 0x10 #define BT_HOST_TIMEOUT 0x10
#define BT_UNSUPPORTED_FEATURE 0x11 #define BT_UNSUPPORTED_FEATURE 0x11
#define BT_INVALID_PARAMETERS 0x12 #define BT_INVALID_PARAMETERS 0x12
#define BT_OE_USER_ENDED_CONNECTION 0x13 #define BT_OE_USER_ENDED_CONNECTION 0x13
#define BT_OE_LOW_RESOURCES 0x14 #define BT_OE_LOW_RESOURCES 0x14
#define BT_OE_POWER_OFF 0x15 #define BT_OE_POWER_OFF 0x15
#define BT_CONNECTION_TERMINATED 0x16 #define BT_CONNECTION_TERMINATED 0x16
#define BT_REPEATED_ATTEMPTS 0x17 #define BT_REPEATED_ATTEMPTS 0x17
#define BT_PAIRING_NOT_ALLOWED 0x18 #define BT_PAIRING_NOT_ALLOWED 0x18
#define BT_UNKNOWN_LMP_PDU 0x19 #define BT_UNKNOWN_LMP_PDU 0x19
#define BT_UNSUPPORTED_REMOTE_FEATURE 0x1a #define BT_UNSUPPORTED_REMOTE_FEATURE 0x1a
#define BT_SCO_OFFSET_REJECTED 0x1b #define BT_SCO_OFFSET_REJECTED 0x1b
#define BT_SCO_INTERVAL_REJECTED 0x1c #define BT_SCO_INTERVAL_REJECTED 0x1c
#define BT_AIR_MODE_REJECTED 0x1d #define BT_AIR_MODE_REJECTED 0x1d
#define BT_INVALID_LMP_PARAMETERS 0x1e #define BT_INVALID_LMP_PARAMETERS 0x1e
#define BT_UNSPECIFIED_ERROR 0x1f #define BT_UNSPECIFIED_ERROR 0x1f
#define BT_UNSUPPORTED_LMP_PARAMETER_VALUE 0x20 #define BT_UNSUPPORTED_LMP_PARAMETER_VALUE 0x20
#define BT_ROLE_CHANGE_NOT_ALLOWED 0x21 #define BT_ROLE_CHANGE_NOT_ALLOWED 0x21
#define BT_LMP_RESPONSE_TIMEOUT 0x22 #define BT_LMP_RESPONSE_TIMEOUT 0x22
#define BT_LMP_ERROR_TRANSACTION_COLLISION 0x23 #define BT_LMP_ERROR_TRANSACTION_COLLISION 0x23
#define BT_LMP_PDU_NOT_ALLOWED 0x24 #define BT_LMP_PDU_NOT_ALLOWED 0x24
#define BT_ENCRYPTION_MODE_NOT_ACCEPTED 0x25 #define BT_ENCRYPTION_MODE_NOT_ACCEPTED 0x25
#define BT_UNIT_LINK_KEY_USED 0x26 #define BT_UNIT_LINK_KEY_USED 0x26
#define BT_QOS_NOT_SUPPORTED 0x27 #define BT_QOS_NOT_SUPPORTED 0x27
#define BT_INSTANT_PASSED 0x28 #define BT_INSTANT_PASSED 0x28
#define BT_PAIRING_NOT_SUPPORTED 0x29 #define BT_PAIRING_NOT_SUPPORTED 0x29
#define BT_TRANSACTION_COLLISION 0x2a #define BT_TRANSACTION_COLLISION 0x2a
#define BT_QOS_UNACCEPTABLE_PARAMETER 0x2c #define BT_QOS_UNACCEPTABLE_PARAMETER 0x2c
#define BT_QOS_REJECTED 0x2d #define BT_QOS_REJECTED 0x2d
#define BT_CLASSIFICATION_NOT_SUPPORTED 0x2e #define BT_CLASSIFICATION_NOT_SUPPORTED 0x2e
#define BT_INSUFFICIENT_SECURITY 0x2f #define BT_INSUFFICIENT_SECURITY 0x2f
#define BT_PARAMETER_OUT_OF_RANGE 0x30 #define BT_PARAMETER_OUT_OF_RANGE 0x30
#define BT_ROLE_SWITCH_PENDING 0x32 #define BT_ROLE_SWITCH_PENDING 0x32
#define BT_SLOT_VIOLATION 0x34 #define BT_SLOT_VIOLATION 0x34
#define BT_ROLE_SWITCH_FAILED 0x35 #define BT_ROLE_SWITCH_FAILED 0x35
#define EXTENDED_INQUIRY_RESPONSE_TOO_LARGE 0x36 #define EXTENDED_INQUIRY_RESPONSE_TOO_LARGE 0x36
#define SIMPLE_PAIRING_NOT_SUPPORTED_BY_HOST 0x37 #define SIMPLE_PAIRING_NOT_SUPPORTED_BY_HOST 0x37
#define HOST_BUSY_PAIRING 0x38 #define HOST_BUSY_PAIRING 0x38
#endif #endif