diff --git a/headers/os/bluetooth/DeviceClass.h b/headers/os/bluetooth/DeviceClass.h index ebe4329416..719175b743 100644 --- a/headers/os/bluetooth/DeviceClass.h +++ b/headers/os/bluetooth/DeviceClass.h @@ -12,36 +12,49 @@ namespace Bluetooth { - class DeviceClass { - - public: - DeviceClass(int record) { - this->record = record; - } - - int getServiceClasses() { - return (record & 0x00FFE000) >> 13; - } - - int getMajorDeviceClass() { - return (record & 0x00001F00) >> 8; - } +class DeviceClass { - void getMajorDeviceClass(BString* str) { + public: - } - - int getMinorDeviceClass() { - return (record & 0x000000FF) >> 2; - } + DeviceClass(int record) + { + this->record = record; + } - void getMinorDeviceClass(BString* str) { - } - - private: - int record; - }; + 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; +}; + } #endif diff --git a/headers/os/bluetooth/DiscoveryAgent.h b/headers/os/bluetooth/DiscoveryAgent.h new file mode 100644 index 0000000000..4fe837d161 --- /dev/null +++ b/headers/os/bluetooth/DiscoveryAgent.h @@ -0,0 +1,57 @@ +/* + * Copyright 2007 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 + +#define B_BT_CACHED 0x00 +#define B_BT_PREKNOWN 0x01 +#define B_BT_NOT_DISCOVERABLE 0x01 + +#define B_BT_GIAC 0x9E8B33 +#define B_BT_LIAC 0x9E8B00 + +namespace Bluetooth { + +class DiscoveryListener; +class RemoteDevice; + +class DiscoveryAgent { + + public: + + static const int GIAC = B_BT_GIAC; + static const int LIAC = B_BT_LIAC; + + static const int PREKNOWN = B_BT_PREKNOWN; + static const int CACHED = B_BT_CACHED; + static const int NOT_DISCOVERABLE = B_BT_NOT_DISCOVERABLE; + + RemoteDevice** RetrieveDevices(int option); /* TODO */ + bool StartInquiry(int accessCode, DiscoveryListener listener); /* Throwing */ + bool 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(); + +}; + +} + +#endif diff --git a/headers/os/bluetooth/LocalDevice.h b/headers/os/bluetooth/LocalDevice.h index cb4fc9b0df..1236483e45 100644 --- a/headers/os/bluetooth/LocalDevice.h +++ b/headers/os/bluetooth/LocalDevice.h @@ -15,34 +15,34 @@ namespace Bluetooth { - class DiscoveryAgent; +class DiscoveryAgent; - class LocalDevice { - - public: - /* Possible throwing */ - static LocalDevice* getLocalDevice(); - static LocalDevice* getLocalDevice(uint8 dev); - static LocalDevice* getLocalDevice(bdaddr_t bdaddr); - - DiscoveryAgent* getDiscoveryAgent(); - BString getFriendlyName(); - DeviceClass getDeviceClass(); - /* Possible throwing */ - bool setDiscoverable(int mode); - - BString getProperty(const char* property); - void getProperty(const char* property, uint32* value); - - int getDiscoverable(); - BString getBluetoothAddress(); -/* - ServiceRecord getRecord(Connection notifier); - void updateRecord(ServiceRecord srvRecord); -*/ - private: - LocalDevice(); - }; +class LocalDevice { + + public: + /* Possible throwing */ + static LocalDevice* GetLocalDevice(); + static LocalDevice* GetLocalDevice(uint8 dev); + static LocalDevice* GetLocalDevice(bdaddr_t bdaddr); + + DiscoveryAgent* GetDiscoveryAgent(); + BString GetFriendlyName(); + DeviceClass GetDeviceClass(); + /* Possible throwing */ + bool SetDiscoverable(int mode); + + BString GetProperty(const char* property); + void GetProperty(const char* property, uint32* value); + + int GetDiscoverable(); + BString GetBluetoothAddress(); + /* + ServiceRecord getRecord(Connection notifier); + void updateRecord(ServiceRecord srvRecord); + */ + private: + LocalDevice(); +}; } diff --git a/headers/os/bluetooth/RemoteDevice.h b/headers/os/bluetooth/RemoteDevice.h new file mode 100644 index 0000000000..65073d5a37 --- /dev/null +++ b/headers/os/bluetooth/RemoteDevice.h @@ -0,0 +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 _REMOTE_DEVICE_H +#define _REMOTE_DEVICE_H + +#include + +#include + +#define B_BT_WAIT 0x00 +#define B_BT_SUCCEEDED 0x01 + + +namespace Bluetooth { + +class Connection; + +class RemoteDevice { + + public: + + static const int WAIT = B_BT_WAIT; + static const int SUCCEEDED = B_BT_SUCCEEDED; + + bool IsTrustedDevice(); + BString GetFriendlyName(bool alwaysAsk); /* Throwing */ + BString GetBluetoothAddress(); + 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 */ + + protected: + RemoteDevice(BString address); + +}; + +} + +#endif diff --git a/headers/os/bluetooth/bdaddrUtils.h b/headers/os/bluetooth/bdaddrUtils.h index 4913c2c03e..dd893e9da7 100644 --- a/headers/os/bluetooth/bdaddrUtils.h +++ b/headers/os/bluetooth/bdaddrUtils.h @@ -9,33 +9,44 @@ #ifndef _BDADDR_UTILS_H #define _BDADDR_UTILS_H +#include namespace Bluetooth { - class bdaddrUtils { - - public: - static inline bdaddr_t nullAddress() { +class bdaddrUtils { + + public: + static inline bdaddr_t MullAddress() + { + + 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 const char* ToString(bdaddr_t bdaddr) + { + // TODO: + static char str[12]; - return ((bdaddr_t) {{0, 0, 0, 0, 0, 0}}); - } - static inline bdaddr_t localAddress() { + return str; + } - return ((bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff}}); - } - - static inline bdaddr_t broadcastAddress() { - - return ((bdaddr_t) {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}); - } - - static const char* ToString(bdaddr_t bdaddr) { - static char str[12]; - - return str; - } - - }; +}; + } #endif