bluetooth: refactor in remote devices handling
- adding persistent link key storage to avoid re-authentications - saving important information about remote devices to make it survive reboots - making all bluetooth status variables uint8 like it is in the command definitions Change-Id: I8956fb356ee734b9fa0ae9704624f6e5fef39e55 Reviewed-on: https://review.haiku-os.org/c/haiku/+/11203 Reviewed-by: waddlesplash <[email protected]> Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
c6c24b3e3a
commit
91994efedd
@@ -145,6 +145,11 @@ const char* BluetoothError(uint8 error);
|
||||
#define HCI_LM_RELIABLE 0x0010
|
||||
#define HCI_LM_SECURE 0x0020
|
||||
|
||||
// Link Types
|
||||
#define HCI_SCO_CONN 0x00
|
||||
#define HCI_ACL_CONN 0x01
|
||||
#define HCI_ESCO_CONN 0x02
|
||||
|
||||
|
||||
#endif // _BTHCI_H_
|
||||
|
||||
|
||||
@@ -280,7 +280,7 @@ struct hci_command_header {
|
||||
#define OCF_LINK_KEY_REPLY 0x000B
|
||||
struct hci_cp_link_key_reply {
|
||||
bdaddr_t bdaddr;
|
||||
uint8 link_key[16];
|
||||
linkkey_t link_key;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define OCF_LINK_KEY_NEG_REPLY 0x000C
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
#include <bluetooth/bluetooth_error.h>
|
||||
#include <bluetooth/BluetoothDevice.h>
|
||||
|
||||
#include <bluetoothserver_p.h>
|
||||
#include <support/String.h>
|
||||
#include <ObjectList.h>
|
||||
|
||||
#define B_BT_WAIT 0x00
|
||||
#define B_BT_SUCCEEDED 0x01
|
||||
@@ -26,6 +28,14 @@ public:
|
||||
static const int WAIT = B_BT_WAIT;
|
||||
static const int SUCCEEDED = B_BT_SUCCEEDED;
|
||||
|
||||
enum ConnectionState {
|
||||
CONNECTED,
|
||||
CONNECTING,
|
||||
DISCONNECTED
|
||||
};
|
||||
|
||||
static BObjectList<RemoteDevice> GetRemoteDevices(LocalDevice* localDevice);
|
||||
|
||||
virtual ~RemoteDevice();
|
||||
|
||||
bool IsTrustedDevice();
|
||||
@@ -34,21 +44,20 @@ public:
|
||||
BString GetCachedFriendlyName();
|
||||
bdaddr_t GetBluetoothAddress();
|
||||
uint8 GetPageRepetitionMode();
|
||||
uint8 GetScanMode();
|
||||
uint8 GetClockOffset();
|
||||
uint16 GetClockOffset();
|
||||
DeviceClass GetDeviceClass();
|
||||
|
||||
bool Equals(RemoteDevice* obj);
|
||||
|
||||
status_t Connect();
|
||||
status_t CancelConnection();
|
||||
status_t Disconnect();
|
||||
status_t Disconnect(bool removeDevice);
|
||||
|
||||
/*static RemoteDevice* GetRemoteDevice(Connection conn); Throwing */
|
||||
/* bool Authorize(Connection conn); Throwing */
|
||||
/*bool Encrypt(Connection conn, bool on); Throwing */
|
||||
/*bool IsAuthorized(Connection conn); Throwing */
|
||||
bool IsAuthenticated(); /* Throwing */
|
||||
RemoteDevice::ConnectionState GetConnectionState();
|
||||
bool IsEncrypted(); /* Throwing */
|
||||
|
||||
BString GetProperty(const char* property); /* Throwing */
|
||||
@@ -62,7 +71,7 @@ public:
|
||||
|
||||
protected:
|
||||
/* called by Discovery[Listener|Agent] */
|
||||
void SetLocalDeviceOwner(LocalDevice* ld);
|
||||
void SetLocalDeviceOwner(LocalDevice* ld);
|
||||
friend class DiscoveryListener;
|
||||
|
||||
private:
|
||||
@@ -70,7 +79,6 @@ private:
|
||||
LocalDevice* fDiscovererLocalDevice;
|
||||
BMessenger* fMessenger;
|
||||
|
||||
uint16 fHandle;
|
||||
uint8 fPageRepetitionMode;
|
||||
uint8 fScanPeriodMode;
|
||||
uint8 fScanMode;
|
||||
|
||||
@@ -74,7 +74,7 @@ status_t
|
||||
SingleParameterCommandRequest(uint8 ofg, uint8 ocf, PARAMETERTYPE parameter,
|
||||
int32* result, hci_id hId, BMessenger* messenger)
|
||||
{
|
||||
int8 bt_status = BT_ERROR;
|
||||
uint8 bt_status = BT_ERROR;
|
||||
|
||||
BluetoothCommand<typed_command(PARAMETERCONTAINER)>
|
||||
simpleCommand(ofg, ocf);
|
||||
@@ -93,7 +93,7 @@ SingleParameterCommandRequest(uint8 ofg, uint8 ocf, PARAMETERTYPE parameter,
|
||||
request.AddInt16("opcodeExpected", PACK_OPCODE(ofg, ocf));
|
||||
|
||||
if (messenger->SendMessage(&request, &reply) == B_OK) {
|
||||
reply.FindInt8("status", &bt_status);
|
||||
reply.FindUInt8("status", &bt_status);
|
||||
if (result != NULL)
|
||||
reply.FindInt32("result", result);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#define BT_MSG_ADD_DEVICE 'btDD'
|
||||
#define BT_MSG_REMOVE_DEVICE 'btrD'
|
||||
#define BT_MSG_GET_PROPERTY 'btgP'
|
||||
#define BT_MSG_GET_REMOTE_DEVICES 'btgD'
|
||||
|
||||
// Discovery
|
||||
#define BT_MSG_INQUIRY_STARTED 'IqSt'
|
||||
@@ -33,5 +34,9 @@
|
||||
#define BT_REQ_CREATE_CONN 'rdCN'
|
||||
#define BT_REQ_CANCEL_CONN 'rdCC'
|
||||
#define BT_REQ_DISCONNECT 'rdDC'
|
||||
#define BT_REQ_REMOVE_DEVICE 'rdRD'
|
||||
|
||||
#define BT_REQ_CONN_STATE 'rdCS'
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user