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:
@@ -12,36 +12,49 @@
|
|||||||
|
|
||||||
namespace Bluetooth {
|
namespace Bluetooth {
|
||||||
|
|
||||||
class DeviceClass {
|
class DeviceClass {
|
||||||
|
|
||||||
public:
|
|
||||||
DeviceClass(int record) {
|
|
||||||
this->record = record;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getServiceClasses() {
|
|
||||||
return (record & 0x00FFE000) >> 13;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getMajorDeviceClass() {
|
|
||||||
return (record & 0x00001F00) >> 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
void getMajorDeviceClass(BString* str) {
|
public:
|
||||||
|
|
||||||
}
|
DeviceClass(int record)
|
||||||
|
{
|
||||||
int getMinorDeviceClass() {
|
this->record = record;
|
||||||
return (record & 0x000000FF) >> 2;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void getMinorDeviceClass(BString* str) {
|
|
||||||
|
|
||||||
}
|
int GetServiceClasses()
|
||||||
|
{
|
||||||
private:
|
return (record & 0x00FFE000) >> 13;
|
||||||
int record;
|
}
|
||||||
};
|
|
||||||
|
|
||||||
|
int GetMajorDeviceClass()
|
||||||
|
{
|
||||||
|
return (record & 0x00001F00) >> 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GetMajorDeviceClass(BString* str)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int GetMinorDeviceClass()
|
||||||
|
{
|
||||||
|
return (record & 0x000000FF) >> 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GetMinorDeviceClass(BString* str)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
int record;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -15,34 +15,34 @@
|
|||||||
|
|
||||||
namespace Bluetooth {
|
namespace Bluetooth {
|
||||||
|
|
||||||
class DiscoveryAgent;
|
class DiscoveryAgent;
|
||||||
|
|
||||||
class LocalDevice {
|
class LocalDevice {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/* Possible throwing */
|
/* Possible throwing */
|
||||||
static LocalDevice* getLocalDevice();
|
static LocalDevice* GetLocalDevice();
|
||||||
static LocalDevice* getLocalDevice(uint8 dev);
|
static LocalDevice* GetLocalDevice(uint8 dev);
|
||||||
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 */
|
||||||
bool setDiscoverable(int mode);
|
bool 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();
|
||||||
BString getBluetoothAddress();
|
BString GetBluetoothAddress();
|
||||||
/*
|
/*
|
||||||
ServiceRecord getRecord(Connection notifier);
|
ServiceRecord getRecord(Connection notifier);
|
||||||
void updateRecord(ServiceRecord srvRecord);
|
void updateRecord(ServiceRecord srvRecord);
|
||||||
*/
|
*/
|
||||||
private:
|
private:
|
||||||
LocalDevice();
|
LocalDevice();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -9,33 +9,44 @@
|
|||||||
#ifndef _BDADDR_UTILS_H
|
#ifndef _BDADDR_UTILS_H
|
||||||
#define _BDADDR_UTILS_H
|
#define _BDADDR_UTILS_H
|
||||||
|
|
||||||
|
#include <bluetooth/bluetooth.h>
|
||||||
|
|
||||||
namespace Bluetooth {
|
namespace Bluetooth {
|
||||||
|
|
||||||
class bdaddrUtils {
|
class bdaddrUtils {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static inline bdaddr_t nullAddress() {
|
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}});
|
return str;
|
||||||
}
|
}
|
||||||
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) {
|
|
||||||
static char str[12];
|
|
||||||
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user