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