25 #define PS3_VID 0x054C // Sony Corporation
26 #define PS3_PID 0x0268 // PS3 Controller DualShock 3
27 #define PS3NAVIGATION_PID 0x042F // Navigation controller
28 #define PS3MOVE_PID 0x03D5 // Motion controller
30 #define IOGEAR_GBU521_VID 0x0A5C // The IOGEAR GBU521 dongle does not presents itself correctly, so we have to check for it manually
31 #define IOGEAR_GBU521_PID 0x21E8
34 #define BULK_MAXPKTSIZE 64 // max size for ACL data
37 #define bmREQ_HCI_OUT USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_DEVICE
39 #define bmREQ_HID_OUT USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE
40 #define HID_REQUEST_SET_REPORT 0x09
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_SET_NAME_STATE 5
49 #define HCI_CHECK_WII_SERVICE 6
51 #define HCI_INQUIRY_STATE 7 // These three states are only used if it should pair and connect to a Wii controller
52 #define HCI_CONNECT_WII_STATE 8
53 #define HCI_CONNECTED_WII_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
64 #define HCI_FLAG_CMD_COMPLETE 0x01
65 #define HCI_FLAG_CONN_COMPLETE 0x02
66 #define HCI_FLAG_DISCONN_COMPLETE 0x04
67 #define HCI_FLAG_REMOTE_NAME_COMPLETE 0x08
68 #define HCI_FLAG_INCOMING_REQUEST 0x10
69 #define HCI_FLAG_READ_BDADDR 0x20
70 #define HCI_FLAG_READ_VERSION 0x40
71 #define HCI_FLAG_WII_FOUND 0x80
72 #define HCI_FLAG_CONNECT_EVENT 0x100
75 #define hci_cmd_complete (hci_event_flag & HCI_FLAG_CMD_COMPLETE)
76 #define hci_connect_complete (hci_event_flag & HCI_FLAG_CONN_COMPLETE)
77 #define hci_disconnect_complete (hci_event_flag & HCI_FLAG_DISCONN_COMPLETE)
78 #define hci_remote_name_complete (hci_event_flag & HCI_FLAG_REMOTE_NAME_COMPLETE)
79 #define hci_incoming_connect_request (hci_event_flag & HCI_FLAG_INCOMING_REQUEST)
80 #define hci_read_bdaddr_complete (hci_event_flag & HCI_FLAG_READ_BDADDR)
81 #define hci_read_version_complete (hci_event_flag & HCI_FLAG_READ_VERSION)
82 #define hci_wii_found (hci_event_flag & HCI_FLAG_WII_FOUND)
83 #define hci_connect_event (hci_event_flag & HCI_FLAG_CONNECT_EVENT)
86 #define EV_INQUIRY_COMPLETE 0x01
87 #define EV_INQUIRY_RESULT 0x02
88 #define EV_CONNECT_COMPLETE 0x03
89 #define EV_INCOMING_CONNECT 0x04
90 #define EV_DISCONNECT_COMPLETE 0x05
91 #define EV_AUTHENTICATION_COMPLETE 0x06
92 #define EV_REMOTE_NAME_COMPLETE 0x07
93 #define EV_ENCRYPTION_CHANGE 0x08
94 #define EV_CHANGE_CONNECTION_LINK 0x09
95 #define EV_ROLE_CHANGED 0x12
96 #define EV_NUM_COMPLETE_PKT 0x13
97 #define EV_PIN_CODE_REQUEST 0x16
98 #define EV_LINK_KEY_REQUEST 0x17
99 #define EV_LINK_KEY_NOTIFICATION 0x18
100 #define EV_DATA_BUFFER_OVERFLOW 0x1A
101 #define EV_MAX_SLOTS_CHANGE 0x1B
102 #define EV_READ_REMOTE_VERSION_INFORMATION_COMPLETE 0x0C
103 #define EV_QOS_SETUP_COMPLETE 0x0D
104 #define EV_COMMAND_COMPLETE 0x0E
105 #define EV_COMMAND_STATUS 0x0F
106 #define EV_LOOPBACK_COMMAND 0x19
107 #define EV_PAGE_SCAN_REP_MODE 0x20
110 #define L2CAP_CMD_COMMAND_REJECT 0x01
111 #define L2CAP_CMD_CONNECTION_REQUEST 0x02
112 #define L2CAP_CMD_CONNECTION_RESPONSE 0x03
113 #define L2CAP_CMD_CONFIG_REQUEST 0x04
114 #define L2CAP_CMD_CONFIG_RESPONSE 0x05
115 #define L2CAP_CMD_DISCONNECT_REQUEST 0x06
116 #define L2CAP_CMD_DISCONNECT_RESPONSE 0x07
117 #define L2CAP_CMD_INFORMATION_REQUEST 0x0A
118 #define L2CAP_CMD_INFORMATION_RESPONSE 0x0B
122 #define SUCCESSFUL 0x00
125 #define SDP_PSM 0x01 // Service Discovery Protocol PSM Value
126 #define RFCOMM_PSM 0x03 // RFCOMM PSM Value
127 #define HID_CTRL_PSM 0x11 // HID_Control PSM Value
128 #define HID_INTR_PSM 0x13 // HID_Interrupt PSM Value
131 #define WI_SUBCLASS_RF 0x01 // RF Controller
132 #define WI_PROTOCOL_BT 0x01 // Bluetooth Programming Interface
134 #define BTD_MAX_ENDPOINTS 4
135 #define BTD_NUMSERVICES 4 // Max number of Bluetooth services - if you need more than four simply increase this number
148 virtual void Reset();
173 virtual uint8_t
Init(uint8_t parent, uint8_t port,
bool lowspeed);
183 virtual uint8_t
Poll();
214 virtual boolean VIDPIDOK(uint16_t vid, uint16_t pid) {
246 btService[i] = pService;
318 void L2CAP_Command(uint16_t handle, uint8_t* data, uint8_t nbytes, uint8_t channelLow = 0x01, uint8_t channelHigh = 0x00);
462 uint8_t pollInterval;
466 uint16_t hci_counter;
467 uint8_t hci_num_reset_loops;
468 uint16_t hci_event_flag;
469 uint8_t inquiry_counter;
473 uint8_t l2capoutbuf[14];
476 void HCI_event_task();
478 void ACL_event_task();
481 void setBdaddr(uint8_t* BDADDR);
482 void setMoveBdaddr(uint8_t* BDADDR);