Fix coding style and add more classes

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22667 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Ruiz Dorantes
2007-10-22 17:51:59 +00:00
parent 2eaecb7b33
commit 7044da5546
5 changed files with 206 additions and 75 deletions
+39 -26
View File
@@ -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
+57
View File
@@ -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 <bluetooth/bluetooth.h>
#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
+27 -27
View File
@@ -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();
};
}
+50
View File
@@ -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 <bluetooth/bluetooth.h>
#include <String.h>
#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
+33 -22
View File
@@ -9,33 +9,44 @@
#ifndef _BDADDR_UTILS_H
#define _BDADDR_UTILS_H
#include <bluetooth/bluetooth.h>
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