- Read Local features al LocalDevice constructor
- keep record in UL and KL side git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36027 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
0feca7d685
commit
62f5ba006a
@ -9,7 +9,7 @@
|
||||
typedef int32 hci_id;
|
||||
#define HCI_DEVICE_INDEX_OFFSET 0x7c
|
||||
|
||||
typedef enum { H2 = 2, H3, H4, H5 } transport_type;
|
||||
typedef enum { H2 = 2, H3, H4, H5 } transport_type;
|
||||
|
||||
typedef enum { BT_COMMAND = 0,
|
||||
BT_EVENT,
|
||||
@ -44,8 +44,114 @@ const char* BluetoothError(uint8 error);
|
||||
|
||||
/* Device drivers need to take this into account
|
||||
* when receiving ioctls. Only applies to R5 builds
|
||||
* in deprecation process
|
||||
* in deprecation process
|
||||
*/
|
||||
#define BT_IOCTLS_PASS_SIZE
|
||||
|
||||
|
||||
// HCI Packet types
|
||||
#define HCI_2DH1 0x0002
|
||||
#define HCI_3DH1 0x0004
|
||||
#define HCI_DM1 0x0008
|
||||
#define HCI_DH1 0x0010
|
||||
#define HCI_2DH3 0x0100
|
||||
#define HCI_3DH3 0x0200
|
||||
#define HCI_DM3 0x0400
|
||||
#define HCI_DH3 0x0800
|
||||
#define HCI_2DH5 0x1000
|
||||
#define HCI_3DH5 0x2000
|
||||
#define HCI_DM5 0x4000
|
||||
#define HCI_DH5 0x8000
|
||||
|
||||
#define HCI_HV1 0x0020
|
||||
#define HCI_HV2 0x0040
|
||||
#define HCI_HV3 0x0080
|
||||
|
||||
#define HCI_EV3 0x0008
|
||||
#define HCI_EV4 0x0010
|
||||
#define HCI_EV5 0x0020
|
||||
#define HCI_2EV3 0x0040
|
||||
#define HCI_3EV3 0x0080
|
||||
#define HCI_2EV5 0x0100
|
||||
#define HCI_3EV5 0x0200
|
||||
|
||||
#define SCO_PTYPE_MASK (HCI_HV1 | HCI_HV2 | HCI_HV3)
|
||||
#define ACL_PTYPE_MASK (HCI_DM1 | HCI_DH1 | HCI_DM3 | HCI_DH3 | HCI_DM5 | HCI_DH5)
|
||||
|
||||
|
||||
// LMP features
|
||||
#define LMP_3SLOT 0x01
|
||||
#define LMP_5SLOT 0x02
|
||||
#define LMP_ENCRYPT 0x04
|
||||
#define LMP_SOFFSET 0x08
|
||||
#define LMP_TACCURACY 0x10
|
||||
#define LMP_RSWITCH 0x20
|
||||
#define LMP_HOLD 0x40
|
||||
#define LMP_SNIFF 0x80
|
||||
|
||||
#define LMP_PARK 0x01
|
||||
#define LMP_RSSI 0x02
|
||||
#define LMP_QUALITY 0x04
|
||||
#define LMP_SCO 0x08
|
||||
#define LMP_HV2 0x10
|
||||
#define LMP_HV3 0x20
|
||||
#define LMP_ULAW 0x40
|
||||
#define LMP_ALAW 0x80
|
||||
|
||||
#define LMP_CVSD 0x01
|
||||
#define LMP_PSCHEME 0x02
|
||||
#define LMP_PCONTROL 0x04
|
||||
#define LMP_TRSP_SCO 0x08
|
||||
#define LMP_BCAST_ENC 0x80
|
||||
|
||||
#define LMP_EDR_ACL_2M 0x02
|
||||
#define LMP_EDR_ACL_3M 0x04
|
||||
#define LMP_ENH_ISCAN 0x08
|
||||
#define LMP_ILACE_ISCAN 0x10
|
||||
#define LMP_ILACE_PSCAN 0x20
|
||||
#define LMP_RSSI_INQ 0x40
|
||||
#define LMP_ESCO 0x80
|
||||
|
||||
#define LMP_EV4 0x01
|
||||
#define LMP_EV5 0x02
|
||||
#define LMP_AFH_CAP_SLV 0x08
|
||||
#define LMP_AFH_CLS_SLV 0x10
|
||||
#define LMP_EDR_3SLOT 0x80
|
||||
|
||||
#define LMP_EDR_5SLOT 0x01
|
||||
#define LMP_SNIFF_SUBR 0x02
|
||||
#define LMP_PAUSE_ENC 0x04
|
||||
#define LMP_AFH_CAP_MST 0x08
|
||||
#define LMP_AFH_CLS_MST 0x10
|
||||
#define LMP_EDR_ESCO_2M 0x20
|
||||
#define LMP_EDR_ESCO_3M 0x40
|
||||
#define LMP_EDR_3S_ESCO 0x80
|
||||
|
||||
#define LMP_EXT_INQ 0x01
|
||||
#define LMP_SIMPLE_PAIR 0x08
|
||||
#define LMP_ENCAPS_PDU 0x10
|
||||
#define LMP_ERR_DAT_REP 0x20
|
||||
#define LMP_NFLUSH_PKTS 0x40
|
||||
|
||||
#define LMP_LSTO 0x01
|
||||
#define LMP_INQ_TX_PWR 0x02
|
||||
#define LMP_EXT_FEAT 0x80
|
||||
|
||||
// Link policies
|
||||
#define HCI_LP_RSWITCH 0x0001
|
||||
#define HCI_LP_HOLD 0x0002
|
||||
#define HCI_LP_SNIFF 0x0004
|
||||
#define HCI_LP_PARK 0x0008
|
||||
|
||||
// Link mode
|
||||
#define HCI_LM_ACCEPT 0x8000
|
||||
#define HCI_LM_MASTER 0x0001
|
||||
#define HCI_LM_AUTH 0x0002
|
||||
#define HCI_LM_ENCRYPT 0x0004
|
||||
#define HCI_LM_TRUSTED 0x0008
|
||||
#define HCI_LM_RELIABLE 0x0010
|
||||
#define HCI_LM_SECURE 0x0020
|
||||
|
||||
|
||||
#endif // _BTHCI_H_
|
||||
|
||||
|
@ -62,9 +62,9 @@ typedef struct bt_hci_transport_hooks {
|
||||
|
||||
// to be filled by driver
|
||||
status_t (*SendCommand)(hci_id hciId, void* command);
|
||||
status_t (*SendACL)(hci_id hciId, net_buffer* nbuf );
|
||||
status_t (*SendSCO)(hci_id hciId, net_buffer* nbuf );
|
||||
status_t (*SendESCO)(hci_id hciId, net_buffer* nbuf );
|
||||
status_t (*SendACL)(hci_id hciId, net_buffer* nbuf);
|
||||
status_t (*SendSCO)(hci_id hciId, net_buffer* nbuf);
|
||||
status_t (*SendESCO)(hci_id hciId, net_buffer* nbuf);
|
||||
|
||||
status_t (*DeliverStatistics)(hci_id hciId, bt_hci_statistics* statistics);
|
||||
|
||||
@ -90,6 +90,8 @@ struct bluetooth_device : DoublyLinkedListLinkImpl<bluetooth_device> {
|
||||
size_t fExpectedPacketSize[HCI_NUM_PACKET_TYPES];
|
||||
hci_id index;
|
||||
|
||||
uint16 supportedPacketTypes;
|
||||
uint16 linkMode;
|
||||
int fd;
|
||||
|
||||
bt_hci_device_information* info;
|
||||
@ -148,10 +150,11 @@ enum {
|
||||
BT_UP
|
||||
};
|
||||
|
||||
#define PACK_PORTCODE(type,hid,data) ((type & 0xFF) << 24 | (hid & 0xFF) << 16 | (data & 0xFFFF))
|
||||
#define GET_PORTCODE_TYPE(code) ((code & 0xFF000000) >> 24)
|
||||
#define GET_PORTCODE_HID(code) ((code & 0x00FF0000) >> 16)
|
||||
#define GET_PORTCODE_DATA(code) ((code & 0x0000FFFF))
|
||||
// To deprecate ...
|
||||
#define PACK_PORTCODE(type,hid,data) ((type & 0xFF) << 24 | (hid & 0xFF) << 16 | (data & 0xFFFF))
|
||||
#define GET_PORTCODE_TYPE(code) ((code & 0xFF000000) >> 24)
|
||||
#define GET_PORTCODE_HID(code) ((code & 0x00FF0000) >> 16)
|
||||
#define GET_PORTCODE_DATA(code) ((code & 0x0000FFFF))
|
||||
|
||||
/* Port drivers can use to send information (1 for all for
|
||||
at moment refer to ioctl GET_NOTIFICATION_PORT)*/
|
||||
|
@ -35,11 +35,11 @@ public:
|
||||
BString GetFriendlyName();
|
||||
DeviceClass GetDeviceClass();
|
||||
status_t SetDeviceClass(DeviceClass deviceClass);
|
||||
|
||||
|
||||
/* Possible throwing */
|
||||
status_t SetDiscoverable(int mode);
|
||||
|
||||
BString GetProperty(const char* property);
|
||||
BString GetProperty(const char* property);
|
||||
status_t GetProperty(const char* property, uint32* value);
|
||||
|
||||
int GetDiscoverable();
|
||||
@ -53,10 +53,11 @@ private:
|
||||
LocalDevice(hci_id hid);
|
||||
virtual ~LocalDevice();
|
||||
|
||||
status_t ReadLocalVersion();
|
||||
status_t ReadBufferSize();
|
||||
status_t _ReadLocalVersion();
|
||||
status_t _ReadBufferSize();
|
||||
status_t _ReadLocalFeatures();
|
||||
status_t Reset();
|
||||
|
||||
|
||||
static LocalDevice* RequestLocalDeviceID(BMessage* request);
|
||||
|
||||
BMessenger* fMessenger;
|
||||
@ -70,6 +71,7 @@ private:
|
||||
|
||||
}
|
||||
|
||||
|
||||
#ifndef _BT_USE_EXPLICIT_NAMESPACE
|
||||
using Bluetooth::LocalDevice;
|
||||
#endif
|
||||
|
@ -251,7 +251,8 @@ RegisterDriver(bt_hci_transport_hooks* hooks, bluetooth_device** _device)
|
||||
|
||||
device->info = NULL; // not yet used
|
||||
device->hooks = hooks;
|
||||
|
||||
device->supportedPacketTypes = (HCI_DM1 | HCI_DH1 | HCI_HV1);
|
||||
device->linkMode = (HCI_LM_ACCEPT);
|
||||
device->mtu = L2CAP_MTU_MINIMUM; // TODO: ensure specs min value
|
||||
|
||||
MutexLocker _(&sListLock);
|
||||
@ -415,7 +416,6 @@ bluetooth_std_ops(int32 op, ...)
|
||||
if (BluetoothRXPort->Launch() != B_OK) {
|
||||
flowf("RX thread creation failed!\n");
|
||||
// we Cannot do much here ... avoid registering
|
||||
|
||||
} else {
|
||||
flowf("RX thread launched!\n");
|
||||
}
|
||||
|
@ -77,7 +77,6 @@ LocalDevice::GetLocalDevice(const hci_id hid)
|
||||
LocalDevice*
|
||||
LocalDevice::GetLocalDevice(const bdaddr_t bdaddr)
|
||||
{
|
||||
|
||||
BMessage request(BT_MSG_ACQUIRE_LOCAL_DEVICE);
|
||||
request.AddData("bdaddr", B_ANY_TYPE, &bdaddr, sizeof(bdaddr_t));
|
||||
|
||||
@ -110,7 +109,7 @@ LocalDevice::GetLocalDeviceCount()
|
||||
DiscoveryAgent*
|
||||
LocalDevice::GetDiscoveryAgent()
|
||||
{
|
||||
/* TODO: Study a singleton here */
|
||||
// TODO: Study a singleton here
|
||||
return new (std::nothrow)DiscoveryAgent(this);
|
||||
}
|
||||
|
||||
@ -118,7 +117,6 @@ LocalDevice::GetDiscoveryAgent()
|
||||
BString
|
||||
LocalDevice::GetProperty(const char* property)
|
||||
{
|
||||
|
||||
return NULL;
|
||||
|
||||
}
|
||||
@ -334,7 +332,7 @@ LocalDevice::SetDeviceClass(DeviceClass deviceClass)
|
||||
|
||||
|
||||
status_t
|
||||
LocalDevice::ReadLocalVersion()
|
||||
LocalDevice::_ReadLocalVersion()
|
||||
{
|
||||
int8 bt_status = BT_ERROR;
|
||||
|
||||
@ -359,7 +357,7 @@ LocalDevice::ReadLocalVersion()
|
||||
|
||||
|
||||
status_t
|
||||
LocalDevice::ReadBufferSize()
|
||||
LocalDevice::_ReadBufferSize()
|
||||
{
|
||||
int8 bt_status = BT_ERROR;
|
||||
|
||||
@ -383,6 +381,31 @@ LocalDevice::ReadBufferSize()
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
LocalDevice::_ReadLocalFeatures()
|
||||
{
|
||||
int8 bt_status = BT_ERROR;
|
||||
|
||||
BluetoothCommand<> LocalFeatures(OGF_INFORMATIONAL_PARAM,
|
||||
OCF_READ_LOCAL_FEATURES);
|
||||
|
||||
BMessage request(BT_MSG_HANDLE_SIMPLE_REQUEST);
|
||||
BMessage reply;
|
||||
|
||||
request.AddInt32("hci_id", fHid);
|
||||
request.AddData("raw command", B_ANY_TYPE,
|
||||
LocalFeatures.Data(), LocalFeatures.Size());
|
||||
request.AddInt16("eventExpected", HCI_EVENT_CMD_COMPLETE);
|
||||
request.AddInt16("opcodeExpected", PACK_OPCODE(OGF_INFORMATIONAL_PARAM,
|
||||
OCF_READ_LOCAL_FEATURES));
|
||||
|
||||
if (fMessenger->SendMessage(&request, &reply) == B_OK)
|
||||
reply.FindInt8("status", &bt_status);
|
||||
|
||||
return bt_status;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
LocalDevice::Reset()
|
||||
{
|
||||
@ -406,6 +429,7 @@ LocalDevice::Reset()
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
ServiceRecord
|
||||
LocalDevice::getRecord(Connection notifier) {
|
||||
@ -422,7 +446,11 @@ LocalDevice::updateRecord(ServiceRecord srvRecord) {
|
||||
LocalDevice::LocalDevice(hci_id hid) : fHid(hid)
|
||||
{
|
||||
fMessenger = _RetrieveBluetoothMessenger();
|
||||
ReadLocalVersion();
|
||||
|
||||
_ReadBufferSize();
|
||||
_ReadLocalFeatures();
|
||||
_ReadLocalVersion();
|
||||
|
||||
uint32 value;
|
||||
|
||||
// HARDCODE -> move this to addons
|
||||
@ -433,7 +461,7 @@ LocalDevice::LocalDevice(hci_id hid) : fHid(hid)
|
||||
// Reset(); // Perform a reset to Broadcom buggyland
|
||||
|
||||
// Uncomment this out if your Broadcom dongle has a null bdaddr
|
||||
//#define BT_WRITE_BDADDR_FOR_BCM2035
|
||||
// #define BT_WRITE_BDADDR_FOR_BCM2035
|
||||
#ifdef BT_WRITE_BDADDR_FOR_BCM2035
|
||||
#warning Writting broadcom bdaddr @ init.
|
||||
// try write bdaddr to a bcm2035 -> will be moved to an addon
|
||||
@ -462,8 +490,6 @@ LocalDevice::LocalDevice(hci_id hid) : fHid(hid)
|
||||
reply.FindInt8("status", &bt_status);
|
||||
#endif
|
||||
}
|
||||
|
||||
ReadBufferSize();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user