25 #define PS3_VID 0x054C
26 #define PS3_PID 0x0268
27 #define PS3NAVIGATION_PID 0x042F
28 #define PS3MOVE_PID 0x03D5
31 #define IOGEAR_GBU521_VID 0x0A5C
32 #define IOGEAR_GBU521_PID 0x21E8
33 #define BELKIN_F8T065BF_VID 0x050D
34 #define BELKIN_F8T065BF_PID 0x065A
37 #define BULK_MAXPKTSIZE 64
40 #define bmREQ_HCI_OUT USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_DEVICE
43 #define HCI_INIT_STATE 0
44 #define HCI_RESET_STATE 1
45 #define HCI_CLASS_STATE 2
46 #define HCI_BDADDR_STATE 3
47 #define HCI_LOCAL_VERSION_STATE 4
48 #define HCI_WRITE_NAME_STATE 5
49 #define HCI_CHECK_DEVICE_SERVICE 6
51 #define HCI_INQUIRY_STATE 7
52 #define HCI_CONNECT_DEVICE_STATE 8
53 #define HCI_CONNECTED_DEVICE_STATE 9
55 #define HCI_SCANNING_STATE 10
56 #define HCI_CONNECT_IN_STATE 11
57 #define HCI_REMOTE_NAME_STATE 12
58 #define HCI_CONNECTED_STATE 13
59 #define HCI_DISABLE_SCAN_STATE 14
60 #define HCI_DONE_STATE 15
61 #define HCI_DISCONNECT_STATE 16
62 #define HCI_LOCAL_EXTENDED_FEATURES_STATE 17
63 #define HCI_WRITE_SIMPLE_PAIRING_STATE 18
64 #define HCI_SET_EVENT_MASK_STATE 19
67 #define HCI_FLAG_CMD_COMPLETE (1UL << 0)
68 #define HCI_FLAG_CONNECT_COMPLETE (1UL << 1)
69 #define HCI_FLAG_DISCONNECT_COMPLETE (1UL << 2)
70 #define HCI_FLAG_REMOTE_NAME_COMPLETE (1UL << 3)
71 #define HCI_FLAG_INCOMING_REQUEST (1UL << 4)
72 #define HCI_FLAG_READ_BDADDR (1UL << 5)
73 #define HCI_FLAG_READ_VERSION (1UL << 6)
74 #define HCI_FLAG_DEVICE_FOUND (1UL << 7)
75 #define HCI_FLAG_CONNECT_EVENT (1UL << 8)
76 #define HCI_FLAG_LOCAL_EXTENDED_FEATURES (1UL << 9)
79 #define hci_check_flag(flag) (hci_event_flag & (flag))
80 #define hci_set_flag(flag) (hci_event_flag |= (flag))
81 #define hci_clear_flag(flag) (hci_event_flag &= ~(flag))
84 #define EV_INQUIRY_COMPLETE 0x01
85 #define EV_INQUIRY_RESULT 0x02
86 #define EV_CONNECT_COMPLETE 0x03
87 #define EV_INCOMING_CONNECT 0x04
88 #define EV_DISCONNECT_COMPLETE 0x05
89 #define EV_AUTHENTICATION_COMPLETE 0x06
90 #define EV_REMOTE_NAME_COMPLETE 0x07
91 #define EV_ENCRYPTION_CHANGE 0x08
92 #define EV_CHANGE_CONNECTION_LINK 0x09
93 #define EV_READ_REMOTE_VERSION_INFORMATION_COMPLETE 0x0C
94 #define EV_QOS_SETUP_COMPLETE 0x0D
95 #define EV_COMMAND_COMPLETE 0x0E
96 #define EV_COMMAND_STATUS 0x0F
97 #define EV_ROLE_CHANGED 0x12
98 #define EV_NUM_COMPLETE_PKT 0x13
99 #define EV_PIN_CODE_REQUEST 0x16
100 #define EV_LINK_KEY_REQUEST 0x17
101 #define EV_LINK_KEY_NOTIFICATION 0x18
102 #define EV_DATA_BUFFER_OVERFLOW 0x1A
103 #define EV_MAX_SLOTS_CHANGE 0x1B
104 #define EV_LOOPBACK_COMMAND 0x19
105 #define EV_PAGE_SCAN_REP_MODE 0x20
106 #define EV_READ_REMOTE_EXTENDED_FEATURES_COMPLETE 0x23
107 #define EV_EXTENDED_INQUIRY_RESULT 0x2F
108 #define EV_IO_CAPABILITY_REQUEST 0x31
109 #define EV_IO_CAPABILITY_RESPONSE 0x32
110 #define EV_USER_CONFIRMATION_REQUEST 0x33
111 #define EV_SIMPLE_PAIRING_COMPLETE 0x36
118 #define L2CAP_CONTROL_CONNECT_REQUEST 2
119 #define L2CAP_CONTROL_CONFIG_REQUEST 3
120 #define L2CAP_CONTROL_SUCCESS 4
121 #define L2CAP_CONTROL_DISCONNECT 5
124 #define L2CAP_INTERRUPT_SETUP 6
125 #define L2CAP_INTERRUPT_CONNECT_REQUEST 7
126 #define L2CAP_INTERRUPT_CONFIG_REQUEST 8
127 #define L2CAP_INTERRUPT_DISCONNECT 9
130 #define L2CAP_SDP_WAIT 10
131 #define L2CAP_SDP_SUCCESS 11
134 #define L2CAP_RFCOMM_WAIT 12
135 #define L2CAP_RFCOMM_SUCCESS 13
137 #define L2CAP_DISCONNECT_RESPONSE 14
140 #define TURN_ON_LED 17
141 #define PS3_ENABLE_SIXAXIS 18
142 #define WII_CHECK_MOTION_PLUS_STATE 19
143 #define WII_CHECK_EXTENSION_STATE 20
144 #define WII_INIT_MOTION_PLUS_STATE 21
147 #define L2CAP_FLAG_CONNECTION_CONTROL_REQUEST (1UL << 0)
148 #define L2CAP_FLAG_CONFIG_CONTROL_SUCCESS (1UL << 1)
149 #define L2CAP_FLAG_CONTROL_CONNECTED (1UL << 2)
150 #define L2CAP_FLAG_DISCONNECT_CONTROL_RESPONSE (1UL << 3)
153 #define L2CAP_FLAG_CONNECTION_INTERRUPT_REQUEST (1UL << 4)
154 #define L2CAP_FLAG_CONFIG_INTERRUPT_SUCCESS (1UL << 5)
155 #define L2CAP_FLAG_INTERRUPT_CONNECTED (1UL << 6)
156 #define L2CAP_FLAG_DISCONNECT_INTERRUPT_RESPONSE (1UL << 7)
159 #define L2CAP_FLAG_CONNECTION_SDP_REQUEST (1UL << 8)
160 #define L2CAP_FLAG_CONFIG_SDP_SUCCESS (1UL << 9)
161 #define L2CAP_FLAG_DISCONNECT_SDP_REQUEST (1UL << 10)
164 #define L2CAP_FLAG_CONNECTION_RFCOMM_REQUEST (1UL << 11)
165 #define L2CAP_FLAG_CONFIG_RFCOMM_SUCCESS (1UL << 12)
166 #define L2CAP_FLAG_DISCONNECT_RFCOMM_REQUEST (1UL << 13)
168 #define L2CAP_FLAG_DISCONNECT_RESPONSE (1UL << 14)
171 #define l2cap_check_flag(flag) (l2cap_event_flag & (flag))
172 #define l2cap_set_flag(flag) (l2cap_event_flag |= (flag))
173 #define l2cap_clear_flag(flag) (l2cap_event_flag &= ~(flag))
176 #define L2CAP_CMD_COMMAND_REJECT 0x01
177 #define L2CAP_CMD_CONNECTION_REQUEST 0x02
178 #define L2CAP_CMD_CONNECTION_RESPONSE 0x03
179 #define L2CAP_CMD_CONFIG_REQUEST 0x04
180 #define L2CAP_CMD_CONFIG_RESPONSE 0x05
181 #define L2CAP_CMD_DISCONNECT_REQUEST 0x06
182 #define L2CAP_CMD_DISCONNECT_RESPONSE 0x07
183 #define L2CAP_CMD_INFORMATION_REQUEST 0x0A
184 #define L2CAP_CMD_INFORMATION_RESPONSE 0x0B
188 #define SUCCESSFUL 0x00
192 #define RFCOMM_PSM 0x03
193 #define HID_CTRL_PSM 0x11
194 #define HID_INTR_PSM 0x13
197 #define SDP_SERVICE_SEARCH_REQUEST 0x02
198 #define SDP_SERVICE_SEARCH_RESPONSE 0x03
199 #define SDP_SERVICE_ATTRIBUTE_REQUEST 0x04
200 #define SDP_SERVICE_ATTRIBUTE_RESPONSE 0x05
201 #define SDP_SERVICE_SEARCH_ATTRIBUTE_REQUEST 0x06
202 #define SDP_SERVICE_SEARCH_ATTRIBUTE_RESPONSE 0x07
203 #define PNP_INFORMATION_UUID 0x1200
204 #define SERIALPORT_UUID 0x1101
205 #define L2CAP_UUID 0x0100
208 #define WI_SUBCLASS_RF 0x01
209 #define WI_PROTOCOL_BT 0x01
211 #define BTD_MAX_ENDPOINTS 4
212 #define BTD_NUM_SERVICES 4
246 uint8_t
Init(uint8_t parent, uint8_t port,
bool lowspeed);
290 virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) {
324 btService[i] = pService;
411 void L2CAP_Command(uint16_t handle, uint8_t* data, uint8_t nbytes, uint8_t channelLow = 0x01, uint8_t channelHigh = 0x00);
573 uint8_t pollInterval;
574 bool simple_pairing_supported;
577 bool pairWiiUsingSync;
578 bool checkRemoteName;
579 bool incomingPSController;
580 uint8_t classOfDevice[3];
584 uint16_t hci_counter;
585 uint16_t hci_num_reset_loops;
586 uint16_t hci_event_flag;
587 uint8_t inquiry_counter;
591 uint8_t l2capoutbuf[14];
594 void HCI_event_task();
596 void ACL_event_task();
599 void setBdaddr(uint8_t* BDADDR);
600 void setMoveBdaddr(uint8_t* BDADDR);
640 return (buf[0] == (handle & 0xFF)) && (buf[1] == ((handle >> 8) | 0x20));
#define HCI_CHECK_DEVICE_SERVICE
#define PS3NAVIGATION_PID
#define BELKIN_F8T065BF_VID
#define IOGEAR_GBU521_VID
#define BELKIN_F8T065BF_PID
#define IOGEAR_GBU521_PID
#define BTD_MAX_ENDPOINTS
#define USB_CLASS_WIRELESS_CTRL
void hci_user_confirmation_request_reply()
static const uint8_t BTD_DATAOUT_PIPE
bool l2capConnectionClaimed
void hci_disconnect(uint16_t handle)
void hci_accept_connection()
void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep)
static const uint8_t BTD_EVENT_PIPE
void hci_read_local_extended_features(uint8_t page_number)
void l2cap_disconnection_response(uint16_t handle, uint8_t rxid, uint8_t *dcid, uint8_t *scid)
uint8_t readPollInterval()
void hci_io_capability_request_reply()
void hci_write_simple_pairing_mode(bool enable)
void hci_inquiry_cancel()
static const uint8_t BTD_DATAIN_PIPE
uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed)
static const uint8_t BTD_CONTROL_PIPE
uint8_t ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed)
void l2cap_connection_request(uint16_t handle, uint8_t rxid, uint8_t *scid, uint16_t psm)
void hci_pin_code_request_reply()
void hci_pin_code_negative_request_reply()
void l2cap_config_response(uint16_t handle, uint8_t rxid, uint8_t *scid)
void l2cap_connection_response(uint16_t handle, uint8_t rxid, uint8_t *dcid, uint8_t *scid, uint8_t result)
void hci_write_scan_enable()
EpInfo epInfo[BTD_MAX_ENDPOINTS]
void l2cap_information_response(uint16_t handle, uint8_t rxid, uint8_t infoTypeLow, uint8_t infoTypeHigh)
bool waitingForConnection
void hci_write_class_of_device()
bool rfcommConnectionClaimed
void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR *ep_ptr)
void L2CAP_Command(uint16_t handle, uint8_t *data, uint8_t nbytes, uint8_t channelLow=0x01, uint8_t channelHigh=0x00)
void l2cap_config_request(uint16_t handle, uint8_t rxid, uint8_t *dcid)
void hci_write_local_name(const char *name)
void l2cap_disconnection_request(uint16_t handle, uint8_t rxid, uint8_t *dcid, uint8_t *scid)
int8_t registerBluetoothService(BluetoothService *pService)
void hci_set_event_mask()
void hci_authentication_request()
virtual bool VIDPIDOK(uint16_t vid, uint16_t pid)
void hci_read_local_version_information()
virtual uint8_t GetAddress()
void HCI_Command(uint8_t *data, uint16_t nbytes)
virtual bool DEVCLASSOK(uint8_t klass)
void hci_link_key_request_negative_reply()
bool sdpConnectionClaimed
void hci_write_scan_disable()
bool checkHciHandle(uint8_t *buf, uint16_t handle)
void(* pFuncOnInit)(void)
void attachOnInit(void(*funcOnInit)(void))
uint32_t l2cap_event_flag
virtual void disconnect()=0
virtual void ACLData(uint8_t *ACLData)=0