HiHere's a patch that replaces the spaces indenting in the bluetooth headers with tabs and cleans up the indenting a bit. No functional changes. I hope I'm not stepping on someones toes..
/Fredrik Ekdahl
Index: headers/os/bluetooth/LocalDevice.h =================================================================== --- headers/os/bluetooth/LocalDevice.h (revision 25973) +++ headers/os/bluetooth/LocalDevice.h (arbetskopia) @@ -25,45 +25,45 @@ class DiscoveryAgent; class LocalDevice : public BluetoothDevice { - - public: - /* Possible throwing */ - static LocalDevice* GetLocalDevice(); - static uint32 GetLocalDeviceCount(); - - static LocalDevice* GetLocalDevice(hci_id hid); - static LocalDevice* GetLocalDevice(bdaddr_t bdaddr); - - DiscoveryAgent* GetDiscoveryAgent(); - BString GetFriendlyName(); - DeviceClass GetDeviceClass(); - /* Possible throwing */ - status_t SetDiscoverable(int mode); - - BString GetProperty(const char* property); - void GetProperty(const char* property, uint32* value); - - int GetDiscoverable(); - bdaddr_t GetBluetoothAddress(); - /* - ServiceRecord getRecord(Connection notifier); - void updateRecord(ServiceRecord srvRecord); - */ - private: - LocalDevice(hci_id hid); - - static LocalDevice* RequestLocalDeviceID(BMessage* request); - - static BMessenger* sfMessenger; - BMessenger* fMessenger; - hci_id hid; - hci_id GetID(void) {return hid;} + public: + /* Possible throwing */ + static LocalDevice* GetLocalDevice(); + static uint32 GetLocalDeviceCount(); + static LocalDevice* GetLocalDevice(hci_id hid); + static LocalDevice* GetLocalDevice(bdaddr_t bdaddr); + + DiscoveryAgent* GetDiscoveryAgent(); + BString GetFriendlyName(); + DeviceClass GetDeviceClass(); + /* Possible throwing */ + status_t SetDiscoverable(int mode); + + BString GetProperty(const char* property); + void GetProperty(const char* property, uint32* value); + + int GetDiscoverable(); + bdaddr_t GetBluetoothAddress(); + /* + ServiceRecord getRecord(Connection notifier); + void updateRecord(ServiceRecord srvRecord); + */ + private: + LocalDevice(hci_id hid); + + static LocalDevice* RequestLocalDeviceID(BMessage* request); + + static BMessenger* sfMessenger; + BMessenger* fMessenger; + + hci_id hid; + hci_id GetID(void) {return hid;} + friend class DiscoveryAgent; friend class RemoteDevice; }; - + } #ifndef _BT_USE_EXPLICIT_NAMESPACE Index: headers/os/bluetooth/RemoteDevice.h =================================================================== --- headers/os/bluetooth/RemoteDevice.h (revision 25973) +++ headers/os/bluetooth/RemoteDevice.h (arbetskopia) @@ -23,50 +23,45 @@ class LocalDevice; class RemoteDevice : public BluetoothDevice { + public: + static const int WAIT = B_BT_WAIT; + static const int SUCCEEDED = B_BT_SUCCEEDED; - public: - - static const int WAIT = B_BT_WAIT; - static const int SUCCEEDED = B_BT_SUCCEEDED; - - bool IsTrustedDevice(); - BString GetFriendlyName(bool alwaysAsk); /* Throwing */ - BString GetFriendlyName(void); /* Throwing */ - bdaddr_t GetBluetoothAddress(); - DeviceClass GetDeviceClass(); - - 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 */ - - BString GetProperty(const char* property); /* Throwing */ - void GetProperty(const char* property, uint32* value); /* Throwing */ + bool IsTrustedDevice(); + BString GetFriendlyName(bool alwaysAsk); /* Throwing */ + BString GetFriendlyName(void); /* Throwing */ + bdaddr_t GetBluetoothAddress(); + DeviceClass GetDeviceClass(); - - protected: - RemoteDevice(BString address); - RemoteDevice(bdaddr_t address); - - /* Instances of this class only will be done by Discovery[Listener|Agent] TODO */ - friend class DiscoveryListener; - - private: - void SetLocalDeviceOwner(LocalDevice* ld); - - - LocalDevice* fDiscovererLocalDevice; - - uint8 fPageRepetitionMode; - uint8 fScanPeriodMode; - uint8 fScanMode; - uint16 fClockOffset; - + 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 */ + + BString GetProperty(const char* property); /* Throwing */ + void GetProperty(const char* property, uint32* value); /* Throwing */ + + protected: + RemoteDevice(BString address); + RemoteDevice(bdaddr_t address); + + /* Instances of this class only will be done by Discovery[Listener|Agent] TODO */ + friend class DiscoveryListener; + + private: + void SetLocalDeviceOwner(LocalDevice* ld); + + LocalDevice* fDiscovererLocalDevice; + + uint8 fPageRepetitionMode; + uint8 fScanPeriodMode; + uint8 fScanMode; + uint16 fClockOffset; }; } Index: headers/os/bluetooth/DiscoveryListener.h =================================================================== --- headers/os/bluetooth/DiscoveryListener.h (revision 25973) +++ headers/os/bluetooth/DiscoveryListener.h (arbetskopia) @@ -14,9 +14,9 @@ #include <bluetooth/RemoteDevice.h> -#define BT_INQUIRY_COMPLETED 0x01 // HCI_EVENT_X check specs -#define BT_INQUIRY_TERMINATED 0x02 // HCI_EVENT_X -#define BT_INQUIRY_ERROR 0x03 // HCI_EVENT_X +#define BT_INQUIRY_COMPLETED 0x01 // HCI_EVENT_X check specs +#define BT_INQUIRY_TERMINATED 0x02 // HCI_EVENT_X +#define BT_INQUIRY_ERROR 0x03 // HCI_EVENT_X namespace Bluetooth { @@ -28,43 +28,40 @@ class LocalDevice; class DiscoveryListener : public BLooper { + public: + static const int INQUIRY_COMPLETED = BT_INQUIRY_COMPLETED; + static const int INQUIRY_TERMINATED = BT_INQUIRY_TERMINATED; + static const int INQUIRY_ERROR = BT_INQUIRY_ERROR; - public: + static const int SERVICE_SEARCH_COMPLETED = 0x01; + static const int SERVICE_SEARCH_TERMINATED = 0x02; + static const int SERVICE_SEARCH_ERROR = 0x03; + static const int SERVICE_SEARCH_NO_RECORDS = 0x04; + static const int SERVICE_SEARCH_DEVICE_NOT_REACHABLE = 0x06; + + virtual void DeviceDiscovered(RemoteDevice* btDevice, DeviceClass cod); + /* + virtual void servicesDiscovered(int transID, ServiceRecord[] servRecord); + virtual void serviceSearchCompleted(int transID, int respCode); + */ + virtual void InquiryCompleted(int discType); - static const int INQUIRY_COMPLETED = BT_INQUIRY_COMPLETED; - static const int INQUIRY_TERMINATED = BT_INQUIRY_TERMINATED; - static const int INQUIRY_ERROR = BT_INQUIRY_ERROR; - - static const int SERVICE_SEARCH_COMPLETED = 0x01; - static const int SERVICE_SEARCH_TERMINATED = 0x02; - static const int SERVICE_SEARCH_ERROR = 0x03; - static const int SERVICE_SEARCH_NO_RECORDS = 0x04; - static const int SERVICE_SEARCH_DEVICE_NOT_REACHABLE = 0x06; - - virtual void DeviceDiscovered(RemoteDevice* btDevice, DeviceClass cod); - /* - virtual void servicesDiscovered(int transID, ServiceRecord[] servRecord); - virtual void serviceSearchCompleted(int transID, int respCode); - */ - virtual void InquiryCompleted(int discType); - /* JSR82 non-defined methods */ virtual void InquiryStarted(status_t status); - - private: + private: RemoteDevicesList GetRemoteDevicesList(void); - - void MessageReceived(BMessage* msg); + void MessageReceived(BMessage* msg); + LocalDevice* fLocalDevice; RemoteDevicesList fRemoteDevicesList; - + friend class DiscoveryAgent; protected: - DiscoveryListener(); - void SetLocalDeviceOwner(LocalDevice* ld); + DiscoveryListener(); + void SetLocalDeviceOwner(LocalDevice* ld); }; } Index: headers/os/bluetooth/HCI/btHCI.h =================================================================== --- headers/os/bluetooth/HCI/btHCI.h (revision 25973) +++ headers/os/bluetooth/HCI/btHCI.h (arbetskopia) @@ -14,28 +14,22 @@ typedef enum { H2 = 2, H3, H4, H5 } transport_type; // TODO: something more authomatic here? -#define HCI_NUM_PACKET_TYPES 5 -typedef enum { BT_COMMAND = 0, - BT_EVENT, - BT_ACL, - BT_SCO, - BT_ESCO - } bt_packet_t; +#define HCI_NUM_PACKET_TYPES 5 +typedef enum { BT_COMMAND = 0, BT_EVENT, BT_ACL, BT_SCO, BT_ESCO } bt_packet_t; - /* packets sizes */ -#define HCI_MAX_ACL_SIZE 1024 -#define HCI_MAX_SCO_SIZE 255 -#define HCI_MAX_EVENT_SIZE 260 -#define HCI_MAX_FRAME_SIZE (HCI_MAX_ACL_SIZE + 4) +#define HCI_MAX_ACL_SIZE 1024 +#define HCI_MAX_SCO_SIZE 255 +#define HCI_MAX_EVENT_SIZE 260 +#define HCI_MAX_FRAME_SIZE (HCI_MAX_ACL_SIZE + 4) /* fields sizes */ -#define HCI_LAP_SIZE 3 /* LAP */ -#define HCI_LINK_KEY_SIZE 16 /* link key */ -#define HCI_PIN_SIZE 16 /* PIN */ -#define HCI_EVENT_MASK_SIZE 8 /* event mask */ -#define HCI_CLASS_SIZE 3 /* class */ -#define HCI_FEATURES_SIZE 8 /* LMP features */ -#define HCI_DEVICE_NAME_SIZE 248 /* unit name size */ +#define HCI_LAP_SIZE 3 /* LAP */ +#define HCI_LINK_KEY_SIZE 16 /* link key */ +#define HCI_PIN_SIZE 16 /* PIN */ +#define HCI_EVENT_MASK_SIZE 8 /* event mask */ +#define HCI_CLASS_SIZE 3 /* class */ +#define HCI_FEATURES_SIZE 8 /* LMP features */ +#define HCI_DEVICE_NAME_SIZE 248 /* unit name size */ #endif Index: headers/os/bluetooth/HCI/btHCI_event.h =================================================================== --- headers/os/bluetooth/HCI/btHCI_event.h (revision 25973) +++ headers/os/bluetooth/HCI/btHCI_event.h (arbetskopia) @@ -11,232 +11,232 @@ #include <bluetooth/bluetooth.h> #include <bluetooth/HCI/btHCI.h> -#define HCI_EVENT_HDR_SIZE 2 +#define HCI_EVENT_HDR_SIZE 2 struct hci_event_header { - uint8 ecode; - uint8 elen; + uint8 ecode; + uint8 elen; } __attribute__ ((packed)); /* ---- HCI Events ---- */ -#define HCI_EVENT_INQUIRY_COMPLETE 0x01 +#define HCI_EVENT_INQUIRY_COMPLETE 0x01 -#define HCI_EVENT_INQUIRY_RESULT 0x02 +#define HCI_EVENT_INQUIRY_RESULT 0x02 struct inquiry_info { - bdaddr_t bdaddr; - uint8 pscan_rep_mode; - uint8 pscan_period_mode; - uint8 pscan_mode; - uint8 dev_class[3]; - uint16 clock_offset; + bdaddr_t bdaddr; + uint8 pscan_rep_mode; + uint8 pscan_period_mode; + uint8 pscan_mode; + uint8 dev_class[3]; + uint16 clock_offset; } __attribute__ ((packed)); -#define HCI_EVENT_CONN_COMPLETE 0x03 +#define HCI_EVENT_CONN_COMPLETE 0x03 struct hci_ev_conn_complete { - uint8 status; - uint16 handle; - bdaddr_t bdaddr; - uint8 link_type; - uint8 encrypt_mode; + uint8 status; + uint16 handle; + bdaddr_t bdaddr; + uint8 link_type; + uint8 encrypt_mode; } __attribute__ ((packed)); -#define HCI_EVENT_CONN_REQUEST 0x04 +#define HCI_EVENT_CONN_REQUEST 0x04 struct hci_ev_conn_request { - bdaddr_t bdaddr; - uint8 dev_class[3]; - uint8 link_type; + bdaddr_t bdaddr; + uint8 dev_class[3]; + uint8 link_type; } __attribute__ ((packed)); -#define HCI_EVENT_DISCONNECTION_COMPLETE 0x05 +#define HCI_EVENT_DISCONNECTION_COMPLETE 0x05 struct hci_disconnection_complete_reply { - uint8 status; - uint16 handle; - uint8 reason; + uint8 status; + uint16 handle; + uint8 reason; } __attribute__ ((packed)); #define HCI_EVENT_AUTH_COMPLETE 0x06 struct hci_ev_auth_complete { - uint8 status; - uint16 handle; + uint8 status; + uint16 handle; } __attribute__ ((packed)); -#define HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE 0x07 +#define HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE 0x07 struct hci_remote_name_request_complete_reply { - uint8 status; - bdaddr_t bdaddr; - char remote_name[248]; + uint8 status; + bdaddr_t bdaddr; + char remote_name[248]; } __attribute__ ((packed)); -#define HCI_EVENT_ENCRYPT_CHANGE 0x08 +#define HCI_EVENT_ENCRYPT_CHANGE 0x08 struct hci_ev_encrypt_change { - uint8 status; - uint16 handle; - uint8 encrypt; + uint8 status; + uint16 handle; + uint8 encrypt; } __attribute__ ((packed)); -#define HCI_EVENT_CHANGE_CONN_LINK_KEY_COMPLETE 0x09 +#define HCI_EVENT_CHANGE_CONN_LINK_KEY_COMPLETE 0x09 struct hci_ev_change_conn_link_key_complete { - uint8 status; - uint16 handle; + uint8 status; + uint16 handle; } __attribute__ ((packed)); -#define HCI_EVENT_MASTER_LINK_KEY_COMPL 0x0a +#define HCI_EVENT_MASTER_LINK_KEY_COMPL 0x0a struct hci_ev_master_link_key_complete { - uint8 status; /* 0x00 - success */ - uint16 handle; /* Connection handle */ - uint8 key_flag; /* Key flag */ + uint8 status; /* 0x00 - success */ + uint16 handle; /* Connection handle */ + uint8 key_flag; /* Key flag */ } __attribute__ ((packed)); -#define HCI_EVENT_RMT_FEATURES 0x0B +#define HCI_EVENT_RMT_FEATURES 0x0B struct hci_ev_rmt_features { - uint8 status; - uint16 handle; - uint8 features[8]; + uint8 status; + uint16 handle; + uint8 features[8]; } __attribute__ ((packed)); -#define HCI_EVENT_RMT_VERSION 0x0C +#define HCI_EVENT_RMT_VERSION 0x0C struct hci_ev_rmt_version { - uint8 status; - uint16 handle; - uint8 lmp_ver; - uint16 manufacturer; - uint16 lmp_subver; + uint8 status; + uint16 handle; + uint8 lmp_ver; + uint16 manufacturer; + uint16 lmp_subver; } __attribute__ ((packed)); -#define HCI_EVENT_QOS_SETUP_COMPLETE 0x0D +#define HCI_EVENT_QOS_SETUP_COMPLETE 0x0D struct hci_qos { - uint8 service_type; - uint32 token_rate; - uint32 peak_bandwidth; - uint32 latency; - uint32 delay_variation; + uint8 service_type; + uint32 token_rate; + uint32 peak_bandwidth; + uint32 latency; + uint32 delay_variation; } __attribute__ ((packed)); struct hci_ev_qos_setup_complete { - uint8 status; - uint16 handle; - struct hci_qos qos; + uint8 status; + uint16 handle; + struct hci_qos qos; } __attribute__ ((packed)); -#define HCI_EVENT_CMD_COMPLETE 0x0E +#define HCI_EVENT_CMD_COMPLETE 0x0E struct hci_ev_cmd_complete { - uint8 ncmd; - uint16 opcode; + uint8 ncmd; + uint16 opcode; } __attribute__ ((packed)); -#define HCI_EVENT_CMD_STATUS 0x0F +#define HCI_EVENT_CMD_STATUS 0x0F struct hci_ev_cmd_status { - uint8 status; - uint8 ncmd; - uint16 opcode; + uint8 status; + uint8 ncmd; + uint16 opcode; } __attribute__ ((packed)); -#define HCI_EVENT_HARDWARE_ERROR 0x10 +#define HCI_EVENT_HARDWARE_ERROR 0x10 struct hci_ev_hardware_error { - uint8 hardware_code; /* hardware error code */ + uint8 hardware_code; /* hardware error code */ } __attribute__ ((packed)) ; -#define HCI_EVENT_FLUSH_OCCUR 0x11 +#define HCI_EVENT_FLUSH_OCCUR 0x11 struct hci_ev_flush_occur { - uint16 handle; /* connection handle */ + uint16 handle; /* connection handle */ } __attribute__ ((packed)) ; -#define HCI_EVENT_ROLE_CHANGE 0x12 +#define HCI_EVENT_ROLE_CHANGE 0x12 struct hci_ev_role_change { - uint8 status; - bdaddr_t bdaddr; - uint8 role; + uint8 status; + bdaddr_t bdaddr; + uint8 role; } __attribute__ ((packed)); -#define HCI_EVENT_NUM_COMP_PKTS 0x13 - struct handle_and_number { - uint16 handle; - uint16 num_completed; - } __attribute__ ((packed)); - - struct hci_ev_num_comp_pkts { - uint8 num_hndl; - // struct handle_and_number; hardcoded... - } __attribute__ ((packed)); +#define HCI_EVENT_NUM_COMP_PKTS 0x13 +struct handle_and_number { + uint16 handle; + uint16 num_completed; +} __attribute__ ((packed)); -#define HCI_EVENT_MODE_CHANGE 0x14 +struct hci_ev_num_comp_pkts { + uint8 num_hndl; + // struct handle_and_number; hardcoded... +} __attribute__ ((packed)); + +#define HCI_EVENT_MODE_CHANGE 0x14 struct hci_ev_mode_change { - uint8 status; - uint16 handle; - uint8 mode; - uint16 interval; + uint8 status; + uint16 handle; + uint8 mode; + uint16 interval; } __attribute__ ((packed)); -#define HCI_EVENT_RETURN_LINK_KEYS 0x15 +#define HCI_EVENT_RETURN_LINK_KEYS 0x15 struct link_key_info { bdaddr_t bdaddr; uint8 link_key[HCI_LINK_KEY_SIZE]; } __attribute__ ((packed)) ; struct hci_ev_return_link_keys { - uint8 num_keys; /* # of keys */ + uint8 num_keys; /* # of keys */ struct link_key_info link_keys; /* As much as num_keys param */ } __attribute__ ((packed)) ; -#define HCI_EVENT_PIN_CODE_REQ 0x16 +#define HCI_EVENT_PIN_CODE_REQ 0x16 struct hci_ev_pin_code_req { bdaddr_t bdaddr; } __attribute__ ((packed)); -#define HCI_EVENT_LINK_KEY_REQ 0x17 +#define HCI_EVENT_LINK_KEY_REQ 0x17 struct hci_ev_link_key_req { bdaddr_t bdaddr; } __attribute__ ((packed)); -#define HCI_EVENT_LINK_KEY_NOTIFY 0x18 +#define HCI_EVENT_LINK_KEY_NOTIFY 0x18 struct hci_ev_link_key_notify { bdaddr_t bdaddr; uint8 link_key[16]; uint8 key_type; } __attribute__ ((packed)); -#define HCI_EVENT_LOOPBACK_COMMAND 0x19 +#define HCI_EVENT_LOOPBACK_COMMAND 0x19 struct hci_ev_loopback_command { uint8 command[0]; /* depends of command */ } __attribute__ ((packed)) ; -#define HCI_EVENT_DATA_BUFFER_OVERFLOW 0x1a +#define HCI_EVENT_DATA_BUFFER_OVERFLOW 0x1a struct hci_ev_data_buffer_overflow { uint8 link_type; /* Link type */ } __attribute__ ((packed)) ; -#define HCI_EVENT_MAX_SLOT_CHANGE 0x1b +#define HCI_EVENT_MAX_SLOT_CHANGE 0x1b struct hci_ev_max_slot_change { - uint16 handle; /* connection handle */ + uint16 handle; /* connection handle */ uint8 lmp_max_slots; /* Max. # of slots allowed */ } __attribute__ ((packed)) ; -#define HCI_EVENT_READ_CLOCK_OFFSET_COMPL 0x1c +#define HCI_EVENT_READ_CLOCK_OFFSET_COMPL 0x1c struct hci_ev_read_clock_offset_compl { - uint8 status; /* 0x00 - success */ - uint16 handle; /* Connection handle */ + uint8 status; /* 0x00 - success */ + uint16 handle; /* Connection handle */ uint16 clock_offset; /* Clock offset */ } __attribute__ ((packed)) ; -#define HCI_EVENT_CON_PKT_TYPE_CHANGED 0x1d +#define HCI_EVENT_CON_PKT_TYPE_CHANGED 0x1d struct hci_ev_con_pkt_type_changed { - uint8 status; /* 0x00 - success */ + uint8 status; /* 0x00 - success */ uint16 handle; /* connection handle */ uint16 pkt_type; /* packet type */ } __attribute__ ((packed)); -#define HCI_EVENT_QOS_VIOLATION 0x1e +#define HCI_EVENT_QOS_VIOLATION 0x1e struct hci_ev_qos_violation { uint16 handle; /* connection handle */ } __attribute__ ((packed)) ; -#define HCI_EVENT_PAGE_SCAN_REP_MODE_CHANGE 0x20 +#define HCI_EVENT_PAGE_SCAN_REP_MODE_CHANGE 0x20 struct hci_ev_page_scan_rep_mode_change { - bdaddr_t bdaddr; /* destination address */ - uint8 page_scan_rep_mode; /* page scan repetition mode */ + bdaddr_t bdaddr; /* destination address */ + uint8 page_scan_rep_mode; /* page scan repetition mode */ } __attribute__ ((packed)); /* Events Beyond Bluetooth 1.1 */ -#define HCI_EVENT_FLOW_SPECIFICATION 0x21 +#define HCI_EVENT_FLOW_SPECIFICATION 0x21 struct hci_ev_flow_specification { uint8 status; uint16 handle; @@ -249,46 +249,46 @@ uint32 access_latency; } __attribute__ ((packed)); -#define HCI_EVENT_INQUIRY_RESULT_WITH_RSSI 0x22 +#define HCI_EVENT_INQUIRY_RESULT_WITH_RSSI 0x22 struct hci_ev_inquiry_info_with_rssi { bdaddr_t bdaddr; - uint8 pscan_rep_mode; - uint8 pscan_period_mode; - uint8 dev_class[3]; - uint16 clock_offset; - int8 rssi; + uint8 pscan_rep_mode; + uint8 pscan_period_mode; + uint8 dev_class[3]; + uint16 clock_offset; + int8 rssi; } __attribute__ ((packed)); -#define HCI_EVENT_REMOTE_EXTENDED_FEATURES 0x23 -struct hci_ev_remote_extended_features { - uint8 status; - uint16 handle; - uint8 page_number; - uint8 maximun_page_number; - uint64 extended_lmp_features; +#define HCI_EVENT_REMOTE_EXTENDED_FEATURES 0x23 +struct hci_ev_remote_extended_features { + uint8 status; + uint16 handle; + uint8 page_number; + uint8 maximun_page_number; + uint64 extended_lmp_features; } __attribute__ ((packed)); #define HCI_EVENT_SYNCHRONOUS_CONNECTION_COMPLETED 0x2C -struct hci_ev_sychronous_connection_completed { - uint8 status; - uint16 handle; - bdaddr_t bdaddr; - uint8 link_type; - uint8 transmission_interval; - uint8 retransmission_window; - uint16 rx_packet_length; - uint16 tx_packet_length; - uint8 air_mode; +struct hci_ev_sychronous_connection_completed { + uint8 status; + uint16 handle; + bdaddr_t bdaddr; + uint8 link_type; + uint8 transmission_interval; + uint8 retransmission_window; + uint16 rx_packet_length; + uint16 tx_packet_length; + uint8 air_mode; } __attribute__ ((packed)); #define HCI_EVENT_SYNCHRONOUS_CONNECTION_CHANGED 0x2D -struct hci_ev_sychronous_connection_changed { - uint8 status; - uint16 handle; - uint8 transmission_interval; - uint8 retransmission_window; - uint16 rx_packet_length; - uint16 tx_packet_length; +struct hci_ev_sychronous_connection_changed { + uint8 status; + uint16 handle; + uint8 transmission_interval; + uint8 retransmission_window; + uint16 rx_packet_length; + uint16 tx_packet_length; } __attribute__ ((packed)); // TODO: Define remaining Bluetooth 2.1 events structures Index: headers/os/bluetooth/HCI/btHCI_module.h =================================================================== --- headers/os/bluetooth/HCI/btHCI_module.h (revision 25973) +++ headers/os/bluetooth/HCI/btHCI_module.h (arbetskopia) @@ -19,21 +19,20 @@ /* TODO: Possible definition of a bus manager of whatever is gonna be on the top */ typedef struct bt_hci_module_info { - - /* registration */ - status_t (*RegisterDriver)(bt_hci_transport* desc, hci_id *id /*out*/, - bt_hci_device* cookie /*out*/ ); - status_t (*UnregisterDriver)(hci_id id); - - /* Transferences to be called from drivers */ + /* registration */ + status_t (*RegisterDriver)(bt_hci_transport* desc, hci_id *id /*out*/, + bt_hci_device* cookie /*out*/ ); + status_t (*UnregisterDriver)(hci_id id); - status_t (*PostACL)(hci_id id, net_buffer* nbuf); - status_t (*PostSCO)(hci_id id, net_buffer* nbuf); - - /* Management */ - bt_hci_device* (*GetHciDevice)(hci_id id); + /* Transferences to be called from drivers */ + status_t (*PostACL)(hci_id id, net_buffer* nbuf); + status_t (*PostSCO)(hci_id id, net_buffer* nbuf); + + /* Management */ + bt_hci_device* (*GetHciDevice)(hci_id id); + } bt_hci_module_info ; -#endif \ No newline at end of file +#endif Index: headers/os/bluetooth/HCI/btHCI_transport.h =================================================================== --- headers/os/bluetooth/HCI/btHCI_transport.h (revision 25973) +++ headers/os/bluetooth/HCI/btHCI_transport.h (arbetskopia) @@ -14,58 +14,58 @@ #include <Drivers.h> typedef enum { ANCILLYANT = 1, - RUNNING, - LEAVING, - SENDING, - PROCESSING - } bt_transport_status_t; + RUNNING, + LEAVING, + SENDING, + PROCESSING + } bt_transport_status_t; typedef uint8 bt_stat_t; typedef struct bt_hci_statistics { - + bt_stat_t acceptedTX; bt_stat_t rejectedTX; bt_stat_t successfulTX; - bt_stat_t errorTX; + bt_stat_t errorTX; bt_stat_t acceptedRX; bt_stat_t rejectedRX; bt_stat_t successfulRX; - bt_stat_t errorRX; + bt_stat_t errorRX; bt_stat_t commandTX; bt_stat_t eventRX; bt_stat_t aclTX; - bt_stat_t aclRX; + bt_stat_t aclRX; bt_stat_t scoTX; - bt_stat_t scoRX; + bt_stat_t scoRX; bt_stat_t escoTX; bt_stat_t escoRX; - + bt_stat_t bytesRX; bt_stat_t bytesTX; - + } bt_hci_statistics; - + /* TODO: Possible Hooks which drivers will have to provide */ typedef struct bt_hci_transport { - status_t (*SendCommand)(hci_id hci_dev, net_buffer* snbuf); - status_t (*SendPacket)(hci_id hci_dev, net_buffer* nbuf ); - status_t (*SendSCO)(hci_id hci_dev, net_buffer* nbuf ); - status_t (*DeliverStatistics)(bt_hci_statistics* statistics); - - transport_type kind; - char name[B_OS_NAME_LENGTH]; - + status_t (*SendCommand)(hci_id hci_dev, net_buffer* snbuf); + status_t (*SendPacket)(hci_id hci_dev, net_buffer* nbuf ); + status_t (*SendSCO)(hci_id hci_dev, net_buffer* nbuf ); + status_t (*DeliverStatistics)(bt_hci_statistics* statistics); + + transport_type kind; + char name[B_OS_NAME_LENGTH]; + } bt_hci_transport; typedef struct bt_hci_device { - - transport_type kind; - char realName[B_OS_NAME_LENGTH]; - + + transport_type kind; + char realName[B_OS_NAME_LENGTH]; + } bt_hci_device; @@ -83,16 +83,16 @@ #define BT_IOCTLS_OFFSET 3000 enum { - ISSUE_BT_COMMAND = B_DEVICE_OP_CODES_END + BT_IOCTLS_OFFSET , + ISSUE_BT_COMMAND = B_DEVICE_OP_CODES_END + BT_IOCTLS_OFFSET, GET_STATICS, GET_NOTIFICATION_PORT, - GET_HCI_ID + GET_HCI_ID }; -#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)) +#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)*/ Index: headers/os/bluetooth/HCI/btHCI_command.h =================================================================== --- headers/os/bluetooth/HCI/btHCI_command.h (revision 25973) +++ headers/os/bluetooth/HCI/btHCI_command.h (arbetskopia) @@ -14,8 +14,8 @@ #define HCI_COMMAND_HDR_SIZE 3 struct hci_command_header { - uint16 opcode; /* OCF & OGF */ - uint8 clen; + uint16 opcode; /* OCF & OGF */ + uint8 clen; } __attribute__ ((packed)); @@ -28,313 +28,313 @@ /* - Informational Parameters Command definition - */ #define OGF_INFORMATIONAL_PARAM 0x04 - #define OCF_READ_LOCAL_VERSION 0x0001 - struct hci_rp_read_loc_version { - uint8 status; - uint8 hci_ver; - uint16 hci_rev; - uint8 lmp_ver; - uint16 manufacturer; - uint16 lmp_subver; - } __attribute__ ((packed)); - - #define OCF_READ_LOCAL_FEATURES 0x0003 - struct hci_rp_read_loc_features { - uint8 status; - uint8 features[8]; - } __attribute__ ((packed)); - - #define OCF_READ_BUFFER_SIZE 0x0005 - struct hci_rp_read_buffer_size { - uint8 status; - uint16 acl_mtu; - uint8 sco_mtu; - uint16 acl_max_pkt; - uint16 sco_max_pkt; - } __attribute__ ((packed)); - - #define OCF_READ_BD_ADDR 0x0009 - struct hci_rp_read_bd_addr { - uint8 status; - bdaddr_t bdaddr; - } __attribute__ ((packed)); - -/* - Host Controller and Baseband Command definition - */ -#define OGF_CONTROL_BASEBAND 0x03 + #define OCF_READ_LOCAL_VERSION 0x0001 + struct hci_rp_read_loc_version { + uint8 status; + uint8 hci_ver; + uint16 hci_rev; + uint8 lmp_ver; + uint16 manufacturer; + uint16 lmp_subver; + } __attribute__ ((packed)); - #define OCF_RESET 0x0003 + #define OCF_READ_LOCAL_FEATURES 0x0003 + struct hci_rp_read_loc_features { + uint8 status; + uint8 features[8]; + } __attribute__ ((packed)); + + #define OCF_READ_BUFFER_SIZE 0x0005 + struct hci_rp_read_buffer_size { + uint8 status; + uint16 acl_mtu; + uint8 sco_mtu; + uint16 acl_max_pkt; + uint16 sco_max_pkt; + } __attribute__ ((packed)); + + #define OCF_READ_BD_ADDR 0x0009 + struct hci_rp_read_bd_addr { + uint8 status; + bdaddr_t bdaddr; + } __attribute__ ((packed)); + +/* - Host Controller and Baseband Command definition - */ +#define OGF_CONTROL_BASEBAND 0x03 + + #define OCF_RESET 0x0003 /*struct hci_reset { - void no_fields; - } __attribute__ ((packed));*/ - - #define OCF_SET_EVENT_FLT 0x0005 - struct hci_cp_set_event_flt { - uint8 flt_type; - uint8 cond_type; - uint8 condition[0]; - } __attribute__ ((packed)); - - #define OCF_READ_STORED_LINK_KEY 0x000D - struct hci_read_stored_link_key { - bdaddr_t bdaddr; - uint8 all_keys_flag; - } __attribute__ ((packed)); - struct hci_read_stored_link_key_reply { - uint8 status; - uint16 max_num_keys; - uint16 num_keys_read; - } __attribute__ ((packed)); - - #define OCF_WRITE_STORED_LINK_KEY 0x0011 - struct hci_write_stored_link_key { - uint8 num_keys_to_write; - // these are repeated "num_keys_write" times - bdaddr_t bdaddr; - uint8 key[HCI_LINK_KEY_SIZE]; - } __attribute__ ((packed)); - struct hci_write_stored_link_key_reply { - uint8 status; - uint8 num_keys_written; - } __attribute__ ((packed)); - - - #define OCF_WRITE_LOCAL_NAME 0x0013 - #define OCF_READ_LOCAL_NAME 0x0014 - struct hci_rp_read_local_name { - uint8 status; - char local_name[HCI_DEVICE_NAME_SIZE]; - } __attribute__ ((packed)); - - #define OCF_WRITE_CA_TIMEOUT 0x0016 - #define OCF_WRITE_PG_TIMEOUT 0x0018 - - #define OCF_WRITE_SCAN_ENABLE 0x001A - #define HCI_SCAN_DISABLED 0x00 - #define HCI_SCAN_INQUIRY 0x01 - #define HCI_SCAN_PAGE 0x02 - #define HCI_SCAN_INQUIRY_PAGE 0x03 - struct hci_write_scan_enable { - uint8 scan; - } __attribute__ ((packed)); - - #define OCF_READ_AUTH_ENABLE 0x001F - #define OCF_WRITE_AUTH_ENABLE 0x0020 - #define HCI_AUTH_DISABLED 0x00 - #define HCI_AUTH_ENABLED 0x01 - struct hci_write_authentication_enable { - uint8 authentication; - } __attribute__ ((packed)); - - #define OCF_READ_ENCRYPT_MODE 0x0021 - #define OCF_WRITE_ENCRYPT_MODE 0x0022 - #define HCI_ENCRYPT_DISABLED 0x00 - #define HCI_ENCRYPT_P2P 0x01 - #define HCI_ENCRYPT_BOTH 0x02 - struct hci_write_encryption_mode_enable { - uint8 encryption; - } __attribute__ ((packed)); - - /* Filter types */ - #define HCI_FLT_CLEAR_ALL 0x00 - #define HCI_FLT_INQ_RESULT 0x01 - #define HCI_FLT_CONN_SETUP 0x02 - - /* CONN_SETUP Condition types */ - #define HCI_CONN_SETUP_ALLOW_ALL 0x00 - #define HCI_CONN_SETUP_ALLOW_CLASS 0x01 - #define HCI_CONN_SETUP_ALLOW_BDADDR 0x02 - - /* CONN_SETUP Conditions */ - #define HCI_CONN_SETUP_AUTO_OFF 0x01 - #define HCI_CONN_SETUP_AUTO_ON 0x02 - - #define OCF_READ_CLASS_OF_DEV 0x0023 - - struct hci_read_dev_class_reply { - uint8 status; - uint8 dev_class[3]; - } __attribute__ ((packed)); - - #define OCF_WRITE_CLASS_OF_DEV 0x0024 - struct hci_write_dev_class { - uint8 dev_class[3]; - } __attribute__ ((packed)); - - #define OCF_READ_VOICE_SETTING 0x0025 - struct hci_rp_read_voice_setting { - uint8 status; - uint16 voice_setting; - } __attribute__ ((packed)); - - #define OCF_WRITE_VOICE_SETTING 0x0026 - struct hci_cp_write_voice_setting { - uint16 voice_setting; - } __attribute__ ((packed)); - - #define OCF_HOST_BUFFER_SIZE 0x0033 - struct hci_cp_host_buffer_size { - uint16 acl_mtu; - uint8 sco_mtu; - uint16 acl_max_pkt; - uint16 sco_max_pkt; - } __attribute__ ((packed)); - - /* Link Control Command definition */ - #define OGF_LINK_CONTROL 0x01 + void no_fields; + } __attribute__ ((packed));*/ + + #define OCF_SET_EVENT_FLT 0x0005 + struct hci_cp_set_event_flt { + uint8 flt_type; + uint8 cond_type; + uint8 condition[0]; + } __attribute__ ((packed)); + + #define OCF_READ_STORED_LINK_KEY 0x000D + struct hci_read_stored_link_key { + bdaddr_t bdaddr; + uint8 all_keys_flag; + } __attribute__ ((packed)); + struct hci_read_stored_link_key_reply { + uint8 status; + uint16 max_num_keys; + uint16 num_keys_read; + } __attribute__ ((packed)); + + #define OCF_WRITE_STORED_LINK_KEY 0x0011 + struct hci_write_stored_link_key { + uint8 num_keys_to_write; + // these are repeated "num_keys_write" times + bdaddr_t bdaddr; + uint8 key[HCI_LINK_KEY_SIZE]; + } __attribute__ ((packed)); + struct hci_write_stored_link_key_reply { + uint8 status; + uint8 num_keys_written; + } __attribute__ ((packed)); + + + #define OCF_WRITE_LOCAL_NAME 0x0013 + #define OCF_READ_LOCAL_NAME 0x0014 + struct hci_rp_read_local_name { + uint8 status; + char local_name[HCI_DEVICE_NAME_SIZE]; + } __attribute__ ((packed)); + + #define OCF_WRITE_CA_TIMEOUT 0x0016 + #define OCF_WRITE_PG_TIMEOUT 0x0018 + + #define OCF_WRITE_SCAN_ENABLE 0x001A + #define HCI_SCAN_DISABLED 0x00 + #define HCI_SCAN_INQUIRY 0x01 + #define HCI_SCAN_PAGE 0x02 + #define HCI_SCAN_INQUIRY_PAGE 0x03 + struct hci_write_scan_enable { + uint8 scan; + } __attribute__ ((packed)); + + #define OCF_READ_AUTH_ENABLE 0x001F + #define OCF_WRITE_AUTH_ENABLE 0x0020 + #define HCI_AUTH_DISABLED 0x00 + #define HCI_AUTH_ENABLED 0x01 + struct hci_write_authentication_enable { + uint8 authentication; + } __attribute__ ((packed)); + + #define OCF_READ_ENCRYPT_MODE 0x0021 + #define OCF_WRITE_ENCRYPT_MODE 0x0022 + #define HCI_ENCRYPT_DISABLED 0x00 + #define HCI_ENCRYPT_P2P 0x01 + #define HCI_ENCRYPT_BOTH 0x02 + struct hci_write_encryption_mode_enable { + uint8 encryption; + } __attribute__ ((packed)); + + /* Filter types */ + #define HCI_FLT_CLEAR_ALL 0x00 + #define HCI_FLT_INQ_RESULT 0x01 + #define HCI_FLT_CONN_SETUP 0x02 + + /* CONN_SETUP Condition types */ + #define HCI_CONN_SETUP_ALLOW_ALL 0x00 + #define HCI_CONN_SETUP_ALLOW_CLASS 0x01 + #define HCI_CONN_SETUP_ALLOW_BDADDR 0x02 + + /* CONN_SETUP Conditions */ + #define HCI_CONN_SETUP_AUTO_OFF 0x01 + #define HCI_CONN_SETUP_AUTO_ON 0x02 + + #define OCF_READ_CLASS_OF_DEV 0x0023 + + struct hci_read_dev_class_reply { + uint8 status; + uint8 dev_class[3]; + } __attribute__ ((packed)); + + #define OCF_WRITE_CLASS_OF_DEV 0x0024 + struct hci_write_dev_class { + uint8 dev_class[3]; + } __attribute__ ((packed)); + + #define OCF_READ_VOICE_SETTING 0x0025 + struct hci_rp_read_voice_setting { + uint8 status; + uint16 voice_setting; + } __attribute__ ((packed)); + + #define OCF_WRITE_VOICE_SETTING 0x0026 + struct hci_cp_write_voice_setting { + uint16 voice_setting; + } __attribute__ ((packed)); + + #define OCF_HOST_BUFFER_SIZE 0x0033 + struct hci_cp_host_buffer_size { + uint16 acl_mtu; + uint8 sco_mtu; + uint16 acl_max_pkt; + uint16 sco_max_pkt; + } __attribute__ ((packed)); + + /* Link Control Command definition */ + #define OGF_LINK_CONTROL 0x01 - #define OCF_INQUIRY 0x0001 - struct hci_cp_inquiry { - uint8 lap[3]; - uint8 length; - uint8 num_rsp; - } __attribute__ ((packed)); - - #define OCF_INQUIRY_CANCEL 0x0002 + #define OCF_INQUIRY 0x0001 + struct hci_cp_inquiry { + uint8 lap[3]; + uint8 length; + uint8 num_rsp; + } __attribute__ ((packed)); + + #define OCF_INQUIRY_CANCEL 0x0002 - #define OCF_CREATE_CONN 0x0005 - struct hci_cp_create_conn { - bdaddr_t bdaddr; - uint16 pkt_type; - uint8 pscan_rep_mode; - uint8 pscan_mode; - uint16 clock_offset; - uint8 role_switch; - } __attribute__ ((packed)); - - #define OCF_DISCONNECT 0x0006 - struct hci_disconnect { - uint16 handle; - uint8 reason; - } __attribute__ ((packed)); - - #define OCF_ADD_SCO 0x0007 - struct hci_cp_add_sco { - uint16 handle; - uint16 pkt_type; - } __attribute__ ((packed)); + #define OCF_CREATE_CONN 0x0005 + struct hci_cp_create_conn { + bdaddr_t bdaddr; + uint16 pkt_type; + uint8 pscan_rep_mode; + uint8 pscan_mode; + uint16 clock_offset; + uint8 role_switch; + } __attribute__ ((packed)); + + #define OCF_DISCONNECT 0x0006 + struct hci_disconnect { + uint16 handle; + uint8 reason; + } __attribute__ ((packed)); + + #define OCF_ADD_SCO 0x0007 + struct hci_cp_add_sco { + uint16 handle; + uint16 pkt_type; + } __attribute__ ((packed)); - #define OCF_ACCEPT_CONN_REQ 0x0009 - struct hci_cp_accept_conn_req { - bdaddr_t bdaddr; - uint8 role; - } __attribute__ ((packed)); - - #define OCF_REJECT_CONN_REQ 0x000a - struct hci_cp_reject_conn_req { - bdaddr_t bdaddr; - uint8 reason; - } __attribute__ ((packed)); - - #define OCF_LINK_KEY_REPLY 0x000B - struct hci_cp_link_key_reply { - bdaddr_t bdaddr; - uint8 link_key[16]; - } __attribute__ ((packed)); - - #define OCF_LINK_KEY_NEG_REPLY 0x000C - struct hci_cp_link_key_neg_reply { - bdaddr_t bdaddr; - } __attribute__ ((packed)); - - #define OCF_PIN_CODE_REPLY 0x000D - struct hci_cp_pin_code_reply { - bdaddr_t bdaddr; - uint8 pin_len; - uint8 pin_code[HCI_PIN_SIZE]; - } __attribute__ ((packed)); - - #define OCF_PIN_CODE_NEG_REPLY 0x000E - struct hci_cp_pin_code_neg_reply { - bdaddr_t bdaddr; - } __attribute__ ((packed)); - - #define OCF_CHANGE_CONN_PTYPE 0x000F - struct hci_cp_change_conn_ptype { - uint16 handle; - uint16 pkt_type; - } __attribute__ ((packed)); - - #define OCF_AUTH_REQUESTED 0x0011 - struct hci_cp_auth_requested { - uint16 handle; - } __attribute__ ((packed)); - - #define OCF_SET_CONN_ENCRYPT 0x0013 - struct hci_cp_set_conn_encrypt { - uint16 handle; - uint8 encrypt; - } __attribute__ ((packed)); - - #define OCF_CHANGE_CONN_LINK_KEY 0x0015 - struct hci_cp_change_conn_link_key { - uint16 handle; - } __attribute__ ((packed)); - - #define OCF_REMOTE_NAME_REQUEST 0x0019 - struct hci_remote_name_request { - bdaddr_t bdaddr; - uint8 pscan_rep_mode; - uint8 reserved; - uint16 clock_offset; - } __attribute__ ((packed)); - - #define OCF_READ_REMOTE_FEATURES 0x001B - struct hci_cp_read_rmt_features { - uint16 handle; - } __attribute__ ((packed)); - - #define OCF_READ_REMOTE_VERSION 0x001D - struct hci_cp_read_rmt_version { - uint16 handle; - } __attribute__ ((packed)); - - + #define OCF_ACCEPT_CONN_REQ 0x0009 + struct hci_cp_accept_conn_req { + bdaddr_t bdaddr; + uint8 role; + } __attribute__ ((packed)); + + #define OCF_REJECT_CONN_REQ 0x000a + struct hci_cp_reject_conn_req { + bdaddr_t bdaddr; + uint8 reason; + } __attribute__ ((packed)); + + #define OCF_LINK_KEY_REPLY 0x000B + struct hci_cp_link_key_reply { + bdaddr_t bdaddr; + uint8 link_key[16]; + } __attribute__ ((packed)); + + #define OCF_LINK_KEY_NEG_REPLY 0x000C + struct hci_cp_link_key_neg_reply { + bdaddr_t bdaddr; + } __attribute__ ((packed)); + + #define OCF_PIN_CODE_REPLY 0x000D + struct hci_cp_pin_code_reply { + bdaddr_t bdaddr; + uint8 pin_len; + uint8 pin_code[HCI_PIN_SIZE]; + } __attribute__ ((packed)); + + #define OCF_PIN_CODE_NEG_REPLY 0x000E + struct hci_cp_pin_code_neg_reply { + bdaddr_t bdaddr; + } __attribute__ ((packed)); + + #define OCF_CHANGE_CONN_PTYPE 0x000F + struct hci_cp_change_conn_ptype { + uint16 handle; + uint16 pkt_type; + } __attribute__ ((packed)); + + #define OCF_AUTH_REQUESTED 0x0011 + struct hci_cp_auth_requested { + uint16 handle; + } __attribute__ ((packed)); + + #define OCF_SET_CONN_ENCRYPT 0x0013 + struct hci_cp_set_conn_encrypt { + uint16 handle; + uint8 encrypt; + } __attribute__ ((packed)); + + #define OCF_CHANGE_CONN_LINK_KEY 0x0015 + struct hci_cp_change_conn_link_key { + uint16 handle; + } __attribute__ ((packed)); + + #define OCF_REMOTE_NAME_REQUEST 0x0019 + struct hci_remote_name_request { + bdaddr_t bdaddr; + uint8 pscan_rep_mode; + uint8 reserved; + uint16 clock_offset; + } __attribute__ ((packed)); + + #define OCF_READ_REMOTE_FEATURES 0x001B + struct hci_cp_read_rmt_features { + uint16 handle; + } __attribute__ ((packed)); + + #define OCF_READ_REMOTE_VERSION 0x001D + struct hci_cp_read_rmt_version { + uint16 handle; + } __attribute__ ((packed)); + + /* Link Policy Command definition */ -#define OGF_LINK_POLICY 0x02 +#define OGF_LINK_POLICY 0x02 - #define OCF_ROLE_DISCOVERY 0x0009 - struct hci_cp_role_discovery { - uint16 handle; - } __attribute__ ((packed)); - struct hci_rp_role_discovery { - uint8 status; - uint16 handle; - uint8 role; - } __attribute__ ((packed)); - - #define OCF_READ_LINK_POLICY 0x000C - struct hci_cp_read_link_policy { - uint16 handle; - } __attribute__ ((packed)); - struct hci_rp_read_link_policy { - uint8 status; - uint16 handle; - uint16 policy; - } __attribute__ ((packed)); - - #define OCF_SWITCH_ROLE 0x000B - struct hci_cp_switch_role { - bdaddr_t bdaddr; - uint8 role; - } __attribute__ ((packed)); - - #define OCF_WRITE_LINK_POLICY 0x000D - struct hci_cp_write_link_policy { - uint16 handle; - uint16 policy; - } __attribute__ ((packed)); - struct hci_rp_write_link_policy { - uint8 status; - uint16 handle; - } __attribute__ ((packed)); - + #define OCF_ROLE_DISCOVERY 0x0009 + struct hci_cp_role_discovery { + uint16 handle; + } __attribute__ ((packed)); + struct hci_rp_role_discovery { + uint8 status; + uint16 handle; + uint8 role; + } __attribute__ ((packed)); + + #define OCF_READ_LINK_POLICY 0x000C + struct hci_cp_read_link_policy { + uint16 handle; + } __attribute__ ((packed)); + struct hci_rp_read_link_policy { + uint8 status; + uint16 handle; + uint16 policy; + } __attribute__ ((packed)); + + #define OCF_SWITCH_ROLE 0x000B + struct hci_cp_switch_role { + bdaddr_t bdaddr; + uint8 role; + } __attribute__ ((packed)); + + #define OCF_WRITE_LINK_POLICY 0x000D + struct hci_cp_write_link_policy { + uint16 handle; + uint16 policy; + } __attribute__ ((packed)); + struct hci_rp_write_link_policy { + uint8 status; + uint16 handle; + } __attribute__ ((packed)); + /* Status params */ -#define OGF_STATUS_PARAM 0x05 - +#define OGF_STATUS_PARAM 0x05 + /* Testing commands */ -#define OGF_TESTING_CMD 0x3E +#define OGF_TESTING_CMD 0x3E /* Vendor specific commands */ -#define OGF_VENDOR_CMD 0x3F +#define OGF_VENDOR_CMD 0x3F #endif Index: headers/os/bluetooth/HCI/btHCI_acl.h =================================================================== --- headers/os/bluetooth/HCI/btHCI_acl.h (revision 25973) +++ headers/os/bluetooth/HCI/btHCI_acl.h (arbetskopia) @@ -11,7 +11,7 @@ #include <bluetooth/bluetooth.h> #include <bluetooth/HCI/btHCI.h> -#define HCI_ACL_HDR_SIZE 4 +#define HCI_ACL_HDR_SIZE 4 struct hci_acl_header { uint16 handle; /* Handle & Flags(PB, BC) */ @@ -19,7 +19,7 @@ } __attribute__ ((packed)) ; /* ACL handle and flags pack/unpack */ -#define pack_acl_handle_flags(h, pb, bc) (((h) & 0x0fff) | (((pb) & 3) << 12) | (((bc) & 3) << 14)) +#define pack_acl_handle_flags(h, pb, bc) (((h) & 0x0fff) | (((pb) & 3) << 12) | (((bc) & 3) << 14)) #define get_acl_handle(h) ((h) & 0x0fff) #define get_acl_pb_flag(h) (((h) & 0x3000) >> 12) #define get_acl_bc_flag(h) (((h) & 0xc000) >> 14) @@ -32,8 +32,8 @@ /* BC flag values */ #define HCI_ACL_POINT2POINT 0x0 /* only Host controller to Host */ -#define HCI_ACL_BROADCAST_ACTIVE 0x1 /* both directions */ -#define HCI_ACL_BROADCAST_PICONET 0x2 /* both directions */ - /* 11 - reserved for future use */ - +#define HCI_ACL_BROADCAST_ACTIVE 0x1 /* both directions */ +#define HCI_ACL_BROADCAST_PICONET 0x2 /* both directions */ + /* 11 - reserved for future use */ + #endif Index: headers/os/bluetooth/bluetooth_error.h =================================================================== --- headers/os/bluetooth/bluetooth_error.h (revision 25973) +++ headers/os/bluetooth/bluetooth_error.h (arbetskopia) @@ -11,64 +11,64 @@ #include <Errors.h> -#define BT_OK B_OK -#define BT_ERROR BT_UNSPECIFIED_ERROR +#define BT_OK B_OK +#define BT_ERROR BT_UNSPECIFIED_ERROR /* Official error code for Bluetooth V2.1 + EDR */ -#define BT_UNKNOWN_COMMAND 0x01 -#define BT_NO_CONNECTION 0x02 -#define BT_HARDWARE_FAILURE 0x03 -#define BT_PAGE_TIMEOUT 0x04 -#define BT_AUTHENTICATION_FAILURE 0x05 -#define BT_PIN_OR_KEY_MISSING 0x06 -#define BT_MEMORY_FULL 0x07 -#define BT_CONNECTION_TIMEOUT 0x08 +#define BT_UNKNOWN_COMMAND 0x01 +#define BT_NO_CONNECTION 0x02 +#define BT_HARDWARE_FAILURE 0x03 +#define BT_PAGE_TIMEOUT 0x04 +#define BT_AUTHENTICATION_FAILURE 0x05 +#define BT_PIN_OR_KEY_MISSING 0x06 +#define BT_MEMORY_FULL 0x07 +#define BT_CONNECTION_TIMEOUT 0x08 #define BT_MAX_NUMBER_OF_CONNECTIONS 0x09 #define BT_MAX_NUMBER_OF_SCO_CONNECTIONS 0x0a -#define BT_ACL_CONNECTION_EXISTS 0x0b -#define BT_COMMAND_DISALLOWED 0x0c +#define BT_ACL_CONNECTION_EXISTS 0x0b +#define BT_COMMAND_DISALLOWED 0x0c #define BT_REJECTED_LIMITED_RESOURCES 0x0d -#define BT_REJECTED_SECURITY 0x0e -#define BT_REJECTED_PERSONAL 0x0f -#define BT_HOST_TIMEOUT 0x10 -#define BT_UNSUPPORTED_FEATURE 0x11 -#define BT_INVALID_PARAMETERS 0x12 -#define BT_OE_USER_ENDED_CONNECTION 0x13 -#define BT_OE_LOW_RESOURCES 0x14 -#define BT_OE_POWER_OFF 0x15 -#define BT_CONNECTION_TERMINATED 0x16 -#define BT_REPEATED_ATTEMPTS 0x17 -#define BT_PAIRING_NOT_ALLOWED 0x18 -#define BT_UNKNOWN_LMP_PDU 0x19 +#define BT_REJECTED_SECURITY 0x0e +#define BT_REJECTED_PERSONAL 0x0f +#define BT_HOST_TIMEOUT 0x10 +#define BT_UNSUPPORTED_FEATURE 0x11 +#define BT_INVALID_PARAMETERS 0x12 +#define BT_OE_USER_ENDED_CONNECTION 0x13 +#define BT_OE_LOW_RESOURCES 0x14 +#define BT_OE_POWER_OFF 0x15 +#define BT_CONNECTION_TERMINATED 0x16 +#define BT_REPEATED_ATTEMPTS 0x17 +#define BT_PAIRING_NOT_ALLOWED 0x18 +#define BT_UNKNOWN_LMP_PDU 0x19 #define BT_UNSUPPORTED_REMOTE_FEATURE 0x1a -#define BT_SCO_OFFSET_REJECTED 0x1b -#define BT_SCO_INTERVAL_REJECTED 0x1c -#define BT_AIR_MODE_REJECTED 0x1d -#define BT_INVALID_LMP_PARAMETERS 0x1e -#define BT_UNSPECIFIED_ERROR 0x1f +#define BT_SCO_OFFSET_REJECTED 0x1b +#define BT_SCO_INTERVAL_REJECTED 0x1c +#define BT_AIR_MODE_REJECTED 0x1d +#define BT_INVALID_LMP_PARAMETERS 0x1e +#define BT_UNSPECIFIED_ERROR 0x1f #define BT_UNSUPPORTED_LMP_PARAMETER_VALUE 0x20 -#define BT_ROLE_CHANGE_NOT_ALLOWED 0x21 -#define BT_LMP_RESPONSE_TIMEOUT 0x22 +#define BT_ROLE_CHANGE_NOT_ALLOWED 0x21 +#define BT_LMP_RESPONSE_TIMEOUT 0x22 #define BT_LMP_ERROR_TRANSACTION_COLLISION 0x23 -#define BT_LMP_PDU_NOT_ALLOWED 0x24 -#define BT_ENCRYPTION_MODE_NOT_ACCEPTED 0x25 -#define BT_UNIT_LINK_KEY_USED 0x26 -#define BT_QOS_NOT_SUPPORTED 0x27 -#define BT_INSTANT_PASSED 0x28 -#define BT_PAIRING_NOT_SUPPORTED 0x29 -#define BT_TRANSACTION_COLLISION 0x2a -#define BT_QOS_UNACCEPTABLE_PARAMETER 0x2c -#define BT_QOS_REJECTED 0x2d -#define BT_CLASSIFICATION_NOT_SUPPORTED 0x2e -#define BT_INSUFFICIENT_SECURITY 0x2f -#define BT_PARAMETER_OUT_OF_RANGE 0x30 -#define BT_ROLE_SWITCH_PENDING 0x32 -#define BT_SLOT_VIOLATION 0x34 -#define BT_ROLE_SWITCH_FAILED 0x35 +#define BT_LMP_PDU_NOT_ALLOWED 0x24 +#define BT_ENCRYPTION_MODE_NOT_ACCEPTED 0x25 +#define BT_UNIT_LINK_KEY_USED 0x26 +#define BT_QOS_NOT_SUPPORTED 0x27 +#define BT_INSTANT_PASSED 0x28 +#define BT_PAIRING_NOT_SUPPORTED 0x29 +#define BT_TRANSACTION_COLLISION 0x2a +#define BT_QOS_UNACCEPTABLE_PARAMETER 0x2c +#define BT_QOS_REJECTED 0x2d +#define BT_CLASSIFICATION_NOT_SUPPORTED 0x2e +#define BT_INSUFFICIENT_SECURITY 0x2f +#define BT_PARAMETER_OUT_OF_RANGE 0x30 +#define BT_ROLE_SWITCH_PENDING 0x32 +#define BT_SLOT_VIOLATION 0x34 +#define BT_ROLE_SWITCH_FAILED 0x35 -#define EXTENDED_INQUIRY_RESPONSE_TOO_LARGE 0x36 +#define EXTENDED_INQUIRY_RESPONSE_TOO_LARGE 0x36 #define SIMPLE_PAIRING_NOT_SUPPORTED_BY_HOST 0x37 -#define HOST_BUSY_PAIRING 0x38 +#define HOST_BUSY_PAIRING 0x38 #endif Index: headers/os/bluetooth/bdaddrUtils.h =================================================================== --- headers/os/bluetooth/bdaddrUtils.h (revision 25973) +++ headers/os/bluetooth/bdaddrUtils.h (arbetskopia) @@ -4,7 +4,7 @@ * All rights reserved. Distributed under the terms of the MIT License. * */ - + #ifndef _BDADDR_UTILS_H #define _BDADDR_UTILS_H @@ -15,50 +15,43 @@ namespace Bluetooth { class bdaddrUtils { - - public: + + public: static inline bdaddr_t NullAddress() { - 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 bool Compare(bdaddr_t* ba1, bdaddr_t* ba2) { return (memcmp(ba1, ba2, sizeof(bdaddr_t)) == 0); } - - + + static char* ToString(const bdaddr_t bdaddr) { // TODO: not safe static char str[18]; - + sprintf(str,"%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",bdaddr.b[0], - bdaddr.b[1], - bdaddr.b[2], - bdaddr.b[3], - bdaddr.b[4], - bdaddr.b[5]); - + bdaddr.b[1], bdaddr.b[2], bdaddr.b[3], bdaddr.b[4], + bdaddr.b[5]); return str; } - + }; } Index: headers/os/bluetooth/DeviceClass.h =================================================================== --- headers/os/bluetooth/DeviceClass.h (revision 25973) +++ headers/os/bluetooth/DeviceClass.h (arbetskopia) @@ -14,50 +14,50 @@ class DeviceClass { - public: + public: - DeviceClass(int record) - { - this->record = record; - } + DeviceClass(int record) + { + this->record = record; + } - DeviceClass() - { - this->record = 0; - } + DeviceClass() + { + this->record = 0; + } - int GetServiceClasses() - { - return (record & 0x00FFE000) >> 13; - } + int GetServiceClasses() + { + return (record & 0x00FFE000) >> 13; + } - int GetMajorDeviceClass() - { - return (record & 0x00001F00) >> 8; - } + int GetMajorDeviceClass() + { + return (record & 0x00001F00) >> 8; + } - void GetMajorDeviceClass(BString* str) - { + void GetMajorDeviceClass(BString* str) + { - } + } - int GetMinorDeviceClass() - { + int GetMinorDeviceClass() + { return (record & 0x000000FF) >> 2; - } + } - void GetMinorDeviceClass(BString* str) - { + void GetMinorDeviceClass(BString* str) + { - } - - private: - int record; + } + + private: + int record; }; } Index: headers/os/bluetooth/bluetooth.h =================================================================== --- headers/os/bluetooth/bluetooth.h (revision 25973) +++ headers/os/bluetooth/bluetooth.h (arbetskopia) @@ -11,12 +11,12 @@ #include <ByteOrder.h> /* Bluetooth version */ -#define BLUETOOTH_1_1B 0 -#define BLUETOOTH_1_1 1 -#define BLUETOOTH_1_2 2 -#define BLUETOOTH_2_0 3 +#define BLUETOOTH_1_1B 0 +#define BLUETOOTH_1_1 1 +#define BLUETOOTH_1_2 2 +#define BLUETOOTH_2_0 3 -#define BLUETOOTH_VERSION BLUETOOTH_2_0 +#define BLUETOOTH_VERSION BLUETOOTH_2_0 /* Bluetooth common types */ @@ -27,10 +27,10 @@ } __attribute__((packed)) bdaddr_t; -#define BDADDR_NULL (&(bdaddr_t) {{0, 0, 0, 0, 0, 0}}) -#define BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff}}) -#define BDADDR_BROADCAST (&(bdaddr_t) {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}) -#define BDADDR_ANY BDADDR_BROADCAST +#define BDADDR_NULL (&(bdaddr_t) {{0, 0, 0, 0, 0, 0}}) +#define BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff}}) +#define BDADDR_BROADCAST (&(bdaddr_t) {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}) +#define BDADDR_ANY BDADDR_BROADCAST /* 128 integer type needed for SDP */ struct int128 { @@ -44,7 +44,7 @@ #define BLUETOOTH_PROTO_L2CAP 135 /* L2CAP protocol number */ #define BLUETOOTH_PROTO_RFCOMM 136 /* RFCOMM protocol number */ -#define BLUETOOTH_PROTO_MAX 256 +#define BLUETOOTH_PROTO_MAX 256 #endif Index: headers/os/bluetooth/BluetoothDevice.h =================================================================== --- headers/os/bluetooth/BluetoothDevice.h (revision 25973) +++ headers/os/bluetooth/BluetoothDevice.h (arbetskopia) @@ -11,7 +11,6 @@ #include <bluetooth/bluetooth.h> #include <bluetooth/DeviceClass.h> - #include <Messenger.h> #include <Message.h> @@ -21,22 +20,22 @@ namespace Bluetooth { class BluetoothDevice { - - public: + public: + virtual BString GetFriendlyName()=0; - virtual DeviceClass GetDeviceClass()=0; - - virtual BString GetProperty(const char* property)=0; - virtual void GetProperty(const char* property, uint32* value)=0; + virtual DeviceClass GetDeviceClass()=0; - virtual bdaddr_t GetBluetoothAddress()=0; - + virtual BString GetProperty(const char* property)=0; + virtual void GetProperty(const char* property, uint32* value)=0; + + virtual bdaddr_t GetBluetoothAddress()=0; + protected: - bdaddr_t fBdaddr; - DeviceClass fDeviceClass; + bdaddr_t fBdaddr; + DeviceClass fDeviceClass; }; - + } #ifndef _BT_USE_EXPLICIT_NAMESPACE Index: headers/os/bluetooth/DiscoveryAgent.h =================================================================== --- headers/os/bluetooth/DiscoveryAgent.h (revision 25973) +++ headers/os/bluetooth/DiscoveryAgent.h (arbetskopia) @@ -19,9 +19,9 @@ #define BT_GIAC 0x9E8B33 #define BT_LIAC 0x9E8B00 -#define BT_MAX_RESPONSES (32) -#define BT_BASE_INQUIRY_TIME (1.28) -#define BT_DEFAULT_INQUIRY_TIME (0x15*BT_BASE_INQUIRY_TIME) /* TODO: REVIEW SPECS! */ +#define BT_MAX_RESPONSES (32) +#define BT_BASE_INQUIRY_TIME (1.28) +#define BT_DEFAULT_INQUIRY_TIME (0x15*BT_BASE_INQUIRY_TIME) /* TODO: REVIEW SPECS! */ namespace Bluetooth { @@ -29,40 +29,37 @@ class RemoteDevice; class DiscoveryAgent { + public: + static const int GIAC = BT_GIAC; + static const int LIAC = BT_LIAC; - public: - - static const int GIAC = BT_GIAC; - static const int LIAC = BT_LIAC; - - static const int PREKNOWN = BT_PREKNOWN; - static const int CACHED = BT_CACHED; - static const int NOT_DISCOVERABLE = BT_NOT_DISCOVERABLE; - - RemoteDevicesList RetrieveDevices(int option); /* TODO */ - status_t StartInquiry(int accessCode, DiscoveryListener* listener); /* Throwing */ - status_t StartInquiry(uint32 accessCode, DiscoveryListener* listener, bigtime_t secs); - status_t 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(LocalDevice* ld); - void SetLocalDeviceOwner(LocalDevice* ld); + static const int PREKNOWN = BT_PREKNOWN; + static const int CACHED = BT_CACHED; + static const int NOT_DISCOVERABLE = BT_NOT_DISCOVERABLE; - DiscoveryListener* fLastUsedListener; - LocalDevice* fLocalDevice; - - friend class LocalDevice; + RemoteDevicesList RetrieveDevices(int option); /* TODO */ + status_t StartInquiry(int accessCode, DiscoveryListener* listener); /* Throwing */ + status_t StartInquiry(uint32 accessCode, DiscoveryListener* listener, bigtime_t secs); + status_t 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(LocalDevice* ld); + void SetLocalDeviceOwner(LocalDevice* ld); + + DiscoveryListener* fLastUsedListener; + LocalDevice* fLocalDevice; + + friend class LocalDevice; }; }