From 001662ae04b1e220cfc87453b03a050938040d6f Mon Sep 17 00:00:00 2001 From: Oliver Ruiz Dorantes Date: Sat, 2 Aug 2008 21:15:02 +0000 Subject: [PATCH] A bit more styling on main headers git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26743 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/bluetooth/BluetoothDevice.h | 5 +- headers/os/bluetooth/DeviceClass.h | 65 +++++++------ headers/os/bluetooth/DiscoveryAgent.h | 53 +++++------ headers/os/bluetooth/DiscoveryListener.h | 57 ++++++------ headers/os/bluetooth/HCI/btHCI.h | 5 +- headers/os/bluetooth/HCI/btHCI_acl.h | 5 +- headers/os/bluetooth/HCI/btHCI_command.h | 5 +- headers/os/bluetooth/HCI/btHCI_event.h | 9 +- headers/os/bluetooth/HCI/btHCI_module.h | 5 +- headers/os/bluetooth/HCI/btHCI_transport.h | 5 +- headers/os/bluetooth/L2CAP/btL2CAP.h | 4 +- headers/os/bluetooth/LinkKeyUtils.h | 79 +++++++--------- headers/os/bluetooth/LocalDevice.h | 63 ++++++------- headers/os/bluetooth/RemoteDevice.h | 71 +++++++------- headers/os/bluetooth/bdaddrUtils.h | 103 ++++++++++----------- headers/os/bluetooth/bluetooth.h | 5 +- headers/os/bluetooth/bluetooth_error.h | 101 ++++++++++---------- headers/os/bluetooth/bluetooth_util.h | 5 +- 18 files changed, 293 insertions(+), 352 deletions(-) diff --git a/headers/os/bluetooth/BluetoothDevice.h b/headers/os/bluetooth/BluetoothDevice.h index c73dea3a15..a710963e2c 100644 --- a/headers/os/bluetooth/BluetoothDevice.h +++ b/headers/os/bluetooth/BluetoothDevice.h @@ -1,10 +1,7 @@ /* * 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 @@ -42,4 +39,4 @@ class BluetoothDevice { using Bluetooth::BluetoothDevice; #endif -#endif +#endif // _BLUETOOTH_DEVICE_H diff --git a/headers/os/bluetooth/DeviceClass.h b/headers/os/bluetooth/DeviceClass.h index c135f64635..f68c2fe596 100644 --- a/headers/os/bluetooth/DeviceClass.h +++ b/headers/os/bluetooth/DeviceClass.h @@ -1,10 +1,7 @@ /* * 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 @@ -14,50 +11,50 @@ namespace Bluetooth { class DeviceClass { - public: +public: - DeviceClass(int record) - { - this->record = record; - } + DeviceClass(int record) + { + this->record = record; + } - DeviceClass() - { - this->record = 0; - } + DeviceClass() + { + this->record = 0; + } - int GetServiceClasses() - { - return (record & 0x00FFE000) >> 13; - } + int GetServiceClasses() + { + return (record & 0x00FFE000) >> 13; + } - int GetMajorDeviceClass() - { - return (record & 0x00001F00) >> 8; - } + int GetMajorDeviceClass() + { + return (record & 0x00001F00) >> 8; + } - void GetMajorDeviceClass(BString* str) - { + void GetMajorDeviceClass(BString* str) + { - } + } - int GetMinorDeviceClass() - { - return (record & 0x000000FF) >> 2; - } + int GetMinorDeviceClass() + { + return (record & 0x000000FF) >> 2; + } - void GetMinorDeviceClass(BString* str) - { + void GetMinorDeviceClass(BString* str) + { - } - - private: - int record; + } + +private: + int record; }; } @@ -66,4 +63,4 @@ class DeviceClass { using Bluetooth::DeviceClass; #endif -#endif +#endif // _DEVICE_CLASS_H diff --git a/headers/os/bluetooth/DiscoveryAgent.h b/headers/os/bluetooth/DiscoveryAgent.h index 9f1e3b3a9d..428a61f48a 100644 --- a/headers/os/bluetooth/DiscoveryAgent.h +++ b/headers/os/bluetooth/DiscoveryAgent.h @@ -1,10 +1,7 @@ /* * 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 @@ -30,38 +27,38 @@ class RemoteDevice; class DiscoveryAgent { - public: +public: - static const int GIAC = BT_GIAC; - static const int LIAC = BT_LIAC; + 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; + 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); + 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); + /* + int searchServices(int[] attrSet, UUID[] uuidSet, RemoteDevice btDev, + DiscoveryListener discListener); - bool cancelServiceSearch(int transID); - BString selectService(UUID uuid, int security, boolean master); - */ + bool cancelServiceSearch(int transID); + BString selectService(UUID uuid, int security, boolean master); + */ - private: - DiscoveryAgent(LocalDevice* ld); - ~DiscoveryAgent(); - void SetLocalDeviceOwner(LocalDevice* ld); +private: + DiscoveryAgent(LocalDevice* ld); + ~DiscoveryAgent(); + void SetLocalDeviceOwner(LocalDevice* ld); - DiscoveryListener* fLastUsedListener; - LocalDevice* fLocalDevice; - BMessenger* fMessenger; + DiscoveryListener* fLastUsedListener; + LocalDevice* fLocalDevice; + BMessenger* fMessenger; - friend class LocalDevice; + friend class LocalDevice; }; } @@ -70,4 +67,4 @@ class DiscoveryAgent { using Bluetooth::DiscoveryAgent; #endif -#endif +#endif // _DISCOVERY_AGENT_H diff --git a/headers/os/bluetooth/DiscoveryListener.h b/headers/os/bluetooth/DiscoveryListener.h index e71198f13c..55cb6070bc 100644 --- a/headers/os/bluetooth/DiscoveryListener.h +++ b/headers/os/bluetooth/DiscoveryListener.h @@ -1,10 +1,7 @@ /* * 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 @@ -29,42 +26,42 @@ class LocalDevice; class DiscoveryListener : public BLooper { - public: +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 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; + 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); + 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); + /* JSR82 non-defined methods */ + virtual void InquiryStarted(status_t status); - private: +private: - RemoteDevicesList GetRemoteDevicesList(void); + RemoteDevicesList GetRemoteDevicesList(void); - void MessageReceived(BMessage* msg); + void MessageReceived(BMessage* msg); - LocalDevice* fLocalDevice; - RemoteDevicesList fRemoteDevicesList; + LocalDevice* fLocalDevice; + RemoteDevicesList fRemoteDevicesList; - friend class DiscoveryAgent; + friend class DiscoveryAgent; - protected: - DiscoveryListener(); - void SetLocalDeviceOwner(LocalDevice* ld); +protected: + DiscoveryListener(); + void SetLocalDeviceOwner(LocalDevice* ld); }; } @@ -73,4 +70,4 @@ class DiscoveryListener : public BLooper { using Bluetooth::DiscoveryListener; #endif -#endif +#endif // _DISCOVERY_LISTENER_H diff --git a/headers/os/bluetooth/HCI/btHCI.h b/headers/os/bluetooth/HCI/btHCI.h index 0ec0f49718..413c8f97c0 100644 --- a/headers/os/bluetooth/HCI/btHCI.h +++ b/headers/os/bluetooth/HCI/btHCI.h @@ -1,10 +1,7 @@ /* * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com - * * All rights reserved. Distributed under the terms of the MIT License. - * */ - #ifndef _BTHCI_H_ #define _BTHCI_H_ @@ -38,4 +35,4 @@ typedef enum { BT_COMMAND = 0, #define HCI_FEATURES_SIZE 8 /* LMP features */ #define HCI_DEVICE_NAME_SIZE 248 /* unit name size */ -#endif +#endif // _BTHCI_H_ diff --git a/headers/os/bluetooth/HCI/btHCI_acl.h b/headers/os/bluetooth/HCI/btHCI_acl.h index e39d569afb..d62deb823f 100644 --- a/headers/os/bluetooth/HCI/btHCI_acl.h +++ b/headers/os/bluetooth/HCI/btHCI_acl.h @@ -1,10 +1,7 @@ /* * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com - * * All rights reserved. Distributed under the terms of the MIT License. - * */ - #ifndef _BTHCI_ACL_H_ #define _BTHCI_ACL_H_ @@ -36,4 +33,4 @@ struct hci_acl_header { #define HCI_ACL_BROADCAST_PICONET 0x2 /* both directions */ /* 11 - reserved for future use */ -#endif +#endif // _BTHCI_ACL_H_ diff --git a/headers/os/bluetooth/HCI/btHCI_command.h b/headers/os/bluetooth/HCI/btHCI_command.h index c32e8e9a3a..8cb99363d4 100644 --- a/headers/os/bluetooth/HCI/btHCI_command.h +++ b/headers/os/bluetooth/HCI/btHCI_command.h @@ -1,10 +1,7 @@ /* * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com - * * All rights reserved. Distributed under the terms of the MIT License. - * */ - #ifndef _BTHCI_COMMAND_H_ #define _BTHCI_COMMAND_H_ @@ -337,4 +334,4 @@ struct hci_command_header { /* Vendor specific commands */ #define OGF_VENDOR_CMD 0x3F -#endif +#endif // _BTHCI_COMMAND_H_ diff --git a/headers/os/bluetooth/HCI/btHCI_event.h b/headers/os/bluetooth/HCI/btHCI_event.h index 92bb21b102..d639de3be8 100644 --- a/headers/os/bluetooth/HCI/btHCI_event.h +++ b/headers/os/bluetooth/HCI/btHCI_event.h @@ -1,11 +1,8 @@ /* * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com * Copyright 2008 Mika Lindqvist, monni1995_at_gmail.com - * * All rights reserved. Distributed under the terms of the MIT License. - * */ - #ifndef _BTHCI_EVENT_H_ #define _BTHCI_EVENT_H_ @@ -318,15 +315,13 @@ struct hci_ev_sychronous_connection_changed { #define HCI_EVENT_REMOTE_HOST_SUPPORTED_FEATURES_NOTIFICATION 0x3D - - /* HAIKU Internal Events, not produced by the transport devices but * by some entity of the Haiku Bluetooth Stack. * The MSB 0xE is chosen for this purpose */ -#define HCI_HAIKU_EVENT_SERVER_QUITTING 0xE0 +#define HCI_HAIKU_EVENT_SERVER_QUITTING 0xE0 #define HCI_HAIKU_EVENT_DEVICE_REMOVED 0xE1 -#endif +#endif // _BTHCI_EVENT_H_ diff --git a/headers/os/bluetooth/HCI/btHCI_module.h b/headers/os/bluetooth/HCI/btHCI_module.h index 3ed39a4939..af548ae3a2 100644 --- a/headers/os/bluetooth/HCI/btHCI_module.h +++ b/headers/os/bluetooth/HCI/btHCI_module.h @@ -1,10 +1,7 @@ /* * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com - * * All rights reserved. Distributed under the terms of the MIT License. - * */ - #ifndef _BTHCI_MODULE_H_ #define _BTHCI_MODULE_H_ @@ -35,4 +32,4 @@ typedef struct bt_hci_module_info { } bt_hci_module_info ; -#endif +#endif // _BTHCI_MODULE_H_ diff --git a/headers/os/bluetooth/HCI/btHCI_transport.h b/headers/os/bluetooth/HCI/btHCI_transport.h index 99277376c0..fe005698f0 100644 --- a/headers/os/bluetooth/HCI/btHCI_transport.h +++ b/headers/os/bluetooth/HCI/btHCI_transport.h @@ -1,10 +1,7 @@ /* * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com - * * All rights reserved. Distributed under the terms of the MIT License. - * */ - #ifndef _BTHCI_TRANSPORT_H_ #define _BTHCI_TRANSPORT_H_ @@ -99,4 +96,4 @@ enum { at moment refer to ioctl GET_NOTIFICATION_PORT)*/ #define BT_USERLAND_PORT_NAME "BT kernel-user Land" -#endif +#endif // _BTHCI_TRANSPORT_H_ diff --git a/headers/os/bluetooth/L2CAP/btL2CAP.h b/headers/os/bluetooth/L2CAP/btL2CAP.h index b0fef2ddfc..32b75d7b72 100644 --- a/headers/os/bluetooth/L2CAP/btL2CAP.h +++ b/headers/os/bluetooth/L2CAP/btL2CAP.h @@ -1,8 +1,6 @@ /* * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com - * * All rights reserved. Distributed under the terms of the MIT License. - * */ #ifndef _BTL2CAP_H_ @@ -18,4 +16,4 @@ struct sockaddr_l2cap { }; -#endif \ No newline at end of file +#endif // _BTL2CAP_H_ \ No newline at end of file diff --git a/headers/os/bluetooth/LinkKeyUtils.h b/headers/os/bluetooth/LinkKeyUtils.h index e3b6dd6e71..ff3d82ff11 100644 --- a/headers/os/bluetooth/LinkKeyUtils.h +++ b/headers/os/bluetooth/LinkKeyUtils.h @@ -1,10 +1,7 @@ /* * Copyright 2008 Mika Lindqvist, monni1995_at_gmail.com - * * All rights reserved. Distributed under the terms of the MIT License. - * */ - #ifndef _LINKKEY_UTILS_H #define _LINKKEY_UTILS_H @@ -17,51 +14,47 @@ namespace Bluetooth { class LinkKeyUtils { public: - static bool Compare(linkkey_t* lk1, linkkey_t* lk2) - { - return (memcmp(lk1, lk2, sizeof(linkkey_t)) == 0); - } + static bool Compare(linkkey_t* lk1, linkkey_t* lk2) + { + return memcmp(lk1, lk2, sizeof(linkkey_t)) == 0; + } - static linkkey_t NullKey() - { - return (linkkey_t) {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; - } - - static char* ToString(const linkkey_t lk) - { - - // TODO: not safe - static char str[50]; + static linkkey_t NullKey() + { + return (linkkey_t){{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; + } + + static char* ToString(const linkkey_t lk) + { + // TODO: not safe + static char str[50]; - sprintf(str, "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:" - "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", - lk.l[0], lk.l[1], lk.l[2], lk.l[3], - lk.l[4], lk.l[5], lk.l[6], lk.l[7], - lk.l[8], lk.l[9], lk.l[10], lk.l[11], - lk.l[12], lk.l[13], lk.l[14], lk.l[15]); - - return str; - } + sprintf(str, "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:" + "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", + lk.l[0], lk.l[1], lk.l[2], lk.l[3], lk.l[4], lk.l[5], + lk.l[6], lk.l[7], lk.l[8], lk.l[9], lk.l[10], lk.l[11], + lk.l[12], lk.l[13], lk.l[14], lk.l[15]); - static linkkey_t FromString(const char *lkstr) - { - if (lkstr != NULL) - { - int l0, l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12, l13, l14, l15; - size_t count = sscanf(lkstr, "%2X:%2X:%2X:%2X:%2X:%2X:%2X:%2X:" - "%2X:%2X:%2X:%2X:%2X:%2X:%2X:%2X", - &l0, &l1, &l2, &l3, &l4, &l5, &l6, &l7, - &l8, &l9, &l10, &l11, &l12, &l13, &l14, &l15); + return str; + } - if (count == 16) - { - return (linkkey_t) {{l0, l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12, l13, l14, l15}}; - } + static linkkey_t FromString(const char *lkstr) + { + if (lkstr != NULL) { + int l0, l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12, l13, l14, l15; + size_t count = sscanf(lkstr, "%2X:%2X:%2X:%2X:%2X:%2X:%2X:%2X:" + "%2X:%2X:%2X:%2X:%2X:%2X:%2X:%2X", &l0, &l1, &l2, &l3, + &l4, &l5, &l6, &l7, &l8, &l9, &l10, &l11, &l12, &l13, + &l14, &l15); + + if (count == 16) { + return (linkkey_t){{l0, l1, l2, l3, l4, l5, l6, l7, l8, + l9, l10, l11, l12, l13, l14, l15}}; } + } - return NullKey(); - - } + return NullKey(); + } }; } @@ -70,4 +63,4 @@ public: using Bluetooth::LinkKeyUtils; #endif -#endif \ No newline at end of file +#endif // _LINKKEY_UTILS_H diff --git a/headers/os/bluetooth/LocalDevice.h b/headers/os/bluetooth/LocalDevice.h index d50fb6b9db..b2c5dd3a9b 100644 --- a/headers/os/bluetooth/LocalDevice.h +++ b/headers/os/bluetooth/LocalDevice.h @@ -1,10 +1,7 @@ /* * 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 @@ -26,44 +23,44 @@ class DiscoveryAgent; class LocalDevice : public BluetoothDevice { - public: - /* Possible throwing */ - static LocalDevice* GetLocalDevice(); - static uint32 GetLocalDeviceCount(); +public: + /* Possible throwing */ + static LocalDevice* GetLocalDevice(); + static uint32 GetLocalDeviceCount(); - static LocalDevice* GetLocalDevice(hci_id hid); - static LocalDevice* GetLocalDevice(bdaddr_t bdaddr); + 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); + 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); + 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); - */ + int GetDiscoverable(); + bdaddr_t GetBluetoothAddress(); + /* + ServiceRecord getRecord(Connection notifier); + void updateRecord(ServiceRecord srvRecord); + */ - private: - LocalDevice(hci_id hid); - virtual ~LocalDevice(); +private: + LocalDevice(hci_id hid); + virtual ~LocalDevice(); - hci_id GetID(void) {return hid;} - static LocalDevice* RequestLocalDeviceID(BMessage* request); + hci_id GetID(void) {return hid;} + static LocalDevice* RequestLocalDeviceID(BMessage* request); - BMessenger* fMessenger; + BMessenger* fMessenger; - hci_id hid; + hci_id hid; - friend class DiscoveryAgent; - friend class RemoteDevice; - friend class PincodeWindow; + friend class DiscoveryAgent; + friend class RemoteDevice; + friend class PincodeWindow; }; } @@ -72,4 +69,4 @@ class LocalDevice : public BluetoothDevice { using Bluetooth::LocalDevice; #endif -#endif +#endif // _LOCAL_DEVICE_H diff --git a/headers/os/bluetooth/RemoteDevice.h b/headers/os/bluetooth/RemoteDevice.h index 0c50617b17..a75a59861c 100644 --- a/headers/os/bluetooth/RemoteDevice.h +++ b/headers/os/bluetooth/RemoteDevice.h @@ -1,10 +1,7 @@ /* * 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 @@ -24,50 +21,50 @@ class LocalDevice; class RemoteDevice : public BluetoothDevice { - public: - static const int WAIT = B_BT_WAIT; - static const int SUCCEEDED = B_BT_SUCCEEDED; +public: + static const int WAIT = B_BT_WAIT; + static const int SUCCEEDED = B_BT_SUCCEEDED; - virtual ~RemoteDevice(); + virtual ~RemoteDevice(); - bool IsTrustedDevice(); - BString GetFriendlyName(bool alwaysAsk); /* Throwing */ - BString GetFriendlyName(void); /* Throwing */ - bdaddr_t GetBluetoothAddress(); - DeviceClass GetDeviceClass(); + bool IsTrustedDevice(); + BString GetFriendlyName(bool alwaysAsk); /* Throwing */ + BString GetFriendlyName(void); /* Throwing */ + bdaddr_t GetBluetoothAddress(); + DeviceClass GetDeviceClass(); - bool Equals(RemoteDevice* obj); + 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 */ + /*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 */ + BString GetProperty(const char* property); /* Throwing */ + void GetProperty(const char* property, uint32* value); /* Throwing */ - LocalDevice* GetLocalDeviceOwner(); + LocalDevice* GetLocalDeviceOwner(); - RemoteDevice(BString address); - RemoteDevice(bdaddr_t address); + RemoteDevice(BString address); + RemoteDevice(bdaddr_t address); - protected: - /* called by Discovery[Listener|Agent] */ - void SetLocalDeviceOwner(LocalDevice* ld); - friend class DiscoveryListener; +protected: + /* called by Discovery[Listener|Agent] */ + void SetLocalDeviceOwner(LocalDevice* ld); + friend class DiscoveryListener; - private: +private: - LocalDevice* fDiscovererLocalDevice; - BMessenger* fMessenger; + LocalDevice* fDiscovererLocalDevice; + BMessenger* fMessenger; - uint8 fPageRepetitionMode; - uint8 fScanPeriodMode; - uint8 fScanMode; - uint16 fClockOffset; + uint8 fPageRepetitionMode; + uint8 fScanPeriodMode; + uint8 fScanMode; + uint16 fClockOffset; }; @@ -77,4 +74,4 @@ class RemoteDevice : public BluetoothDevice { using Bluetooth::RemoteDevice; #endif -#endif +#endif // _REMOTE_DEVICE_H diff --git a/headers/os/bluetooth/bdaddrUtils.h b/headers/os/bluetooth/bdaddrUtils.h index ea0e60dce4..ea5a63297e 100644 --- a/headers/os/bluetooth/bdaddrUtils.h +++ b/headers/os/bluetooth/bdaddrUtils.h @@ -1,11 +1,8 @@ /* * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com * Copyright 2008 Mika Lindqvist, monni1995_at_gmail.com - * * All rights reserved. Distributed under the terms of the MIT License. - * */ - #ifndef _BDADDR_UTILS_H #define _BDADDR_UTILS_H @@ -17,57 +14,57 @@ namespace Bluetooth { class bdaddrUtils { - public: - static inline bdaddr_t NullAddress() - { - return ((bdaddr_t) {{0, 0, 0, 0, 0, 0}}); +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; + + if (addr != NULL) { + 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}}); } - - 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; - - if (addr != NULL) { - 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(); - } + return NullAddress(); + } }; @@ -78,4 +75,4 @@ using Bluetooth::bdaddrUtils; #endif -#endif +#endif // _BDADDR_UTILS_H diff --git a/headers/os/bluetooth/bluetooth.h b/headers/os/bluetooth/bluetooth.h index 74842fd2ef..493af88ada 100644 --- a/headers/os/bluetooth/bluetooth.h +++ b/headers/os/bluetooth/bluetooth.h @@ -1,11 +1,8 @@ /* * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com * Copyright 2008 Mika Lindqvist, monni1995_at_gmail.com - * * All rights reserved. Distributed under the terms of the MIT License. - * */ - #ifndef _BLUETOOTH_H #define _BLUETOOTH_H @@ -55,4 +52,4 @@ typedef struct int128 uint128; #define BLUETOOTH_PROTO_MAX 256 -#endif +#endif // _BLUETOOTH_H diff --git a/headers/os/bluetooth/bluetooth_error.h b/headers/os/bluetooth/bluetooth_error.h index 9acddff60e..998612535c 100644 --- a/headers/os/bluetooth/bluetooth_error.h +++ b/headers/os/bluetooth/bluetooth_error.h @@ -1,74 +1,71 @@ /* * 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 +#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_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_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_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_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_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 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 EXTENDED_INQUIRY_RESPONSE_TOO_LARGE 0x36 #define SIMPLE_PAIRING_NOT_SUPPORTED_BY_HOST 0x37 -#define HOST_BUSY_PAIRING 0x38 +#define HOST_BUSY_PAIRING 0x38 -#endif +#endif // _BLUETOOTH_ERROR_H diff --git a/headers/os/bluetooth/bluetooth_util.h b/headers/os/bluetooth/bluetooth_util.h index 8d5743320d..4eba4d688d 100644 --- a/headers/os/bluetooth/bluetooth_util.h +++ b/headers/os/bluetooth/bluetooth_util.h @@ -1,10 +1,7 @@ /* * 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 @@ -55,4 +52,4 @@ static inline char* btstrerror(int error_code) } -#endif +#endif // _BLUETOOTH_UTIL_H