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 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 // Max size for ACL data 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_SET_NAME_STATE 5 49 #define HCI_CHECK_DEVICE_SERVICE 6 51 #define HCI_INQUIRY_STATE 7 // These three states are only used if it should pair and connect to a device 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 64 #define HCI_FLAG_CMD_COMPLETE (1UL << 0) 65 #define HCI_FLAG_CONNECT_COMPLETE (1UL << 1) 66 #define HCI_FLAG_DISCONNECT_COMPLETE (1UL << 2) 67 #define HCI_FLAG_REMOTE_NAME_COMPLETE (1UL << 3) 68 #define HCI_FLAG_INCOMING_REQUEST (1UL << 4) 69 #define HCI_FLAG_READ_BDADDR (1UL << 5) 70 #define HCI_FLAG_READ_VERSION (1UL << 6) 71 #define HCI_FLAG_DEVICE_FOUND (1UL << 7) 72 #define HCI_FLAG_CONNECT_EVENT (1UL << 8) 75 #define hci_check_flag(flag) (hci_event_flag & (flag)) 76 #define hci_set_flag(flag) (hci_event_flag |= (flag)) 77 #define hci_clear_flag(flag) (hci_event_flag &= ~(flag)) 80 #define EV_INQUIRY_COMPLETE 0x01 81 #define EV_INQUIRY_RESULT 0x02 82 #define EV_CONNECT_COMPLETE 0x03 83 #define EV_INCOMING_CONNECT 0x04 84 #define EV_DISCONNECT_COMPLETE 0x05 85 #define EV_AUTHENTICATION_COMPLETE 0x06 86 #define EV_REMOTE_NAME_COMPLETE 0x07 87 #define EV_ENCRYPTION_CHANGE 0x08 88 #define EV_CHANGE_CONNECTION_LINK 0x09 89 #define EV_ROLE_CHANGED 0x12 90 #define EV_NUM_COMPLETE_PKT 0x13 91 #define EV_PIN_CODE_REQUEST 0x16 92 #define EV_LINK_KEY_REQUEST 0x17 93 #define EV_LINK_KEY_NOTIFICATION 0x18 94 #define EV_DATA_BUFFER_OVERFLOW 0x1A 95 #define EV_MAX_SLOTS_CHANGE 0x1B 96 #define EV_READ_REMOTE_VERSION_INFORMATION_COMPLETE 0x0C 97 #define EV_QOS_SETUP_COMPLETE 0x0D 98 #define EV_COMMAND_COMPLETE 0x0E 99 #define EV_COMMAND_STATUS 0x0F 100 #define EV_LOOPBACK_COMMAND 0x19 101 #define EV_PAGE_SCAN_REP_MODE 0x20 108 #define L2CAP_CONTROL_CONNECT_REQUEST 2 109 #define L2CAP_CONTROL_CONFIG_REQUEST 3 110 #define L2CAP_CONTROL_SUCCESS 4 111 #define L2CAP_CONTROL_DISCONNECT 5 114 #define L2CAP_INTERRUPT_SETUP 6 115 #define L2CAP_INTERRUPT_CONNECT_REQUEST 7 116 #define L2CAP_INTERRUPT_CONFIG_REQUEST 8 117 #define L2CAP_INTERRUPT_DISCONNECT 9 120 #define L2CAP_SDP_WAIT 10 121 #define L2CAP_SDP_SUCCESS 11 124 #define L2CAP_RFCOMM_WAIT 12 125 #define L2CAP_RFCOMM_SUCCESS 13 127 #define L2CAP_DISCONNECT_RESPONSE 14 // Used for both SDP and RFCOMM channel 130 #define TURN_ON_LED 17 131 #define PS3_ENABLE_SIXAXIS 18 132 #define WII_CHECK_MOTION_PLUS_STATE 19 133 #define WII_CHECK_EXTENSION_STATE 20 134 #define WII_INIT_MOTION_PLUS_STATE 21 137 #define L2CAP_FLAG_CONNECTION_CONTROL_REQUEST (1UL << 0) 138 #define L2CAP_FLAG_CONFIG_CONTROL_SUCCESS (1UL << 1) 139 #define L2CAP_FLAG_CONTROL_CONNECTED (1UL << 2) 140 #define L2CAP_FLAG_DISCONNECT_CONTROL_RESPONSE (1UL << 3) 143 #define L2CAP_FLAG_CONNECTION_INTERRUPT_REQUEST (1UL << 4) 144 #define L2CAP_FLAG_CONFIG_INTERRUPT_SUCCESS (1UL << 5) 145 #define L2CAP_FLAG_INTERRUPT_CONNECTED (1UL << 6) 146 #define L2CAP_FLAG_DISCONNECT_INTERRUPT_RESPONSE (1UL << 7) 149 #define L2CAP_FLAG_CONNECTION_SDP_REQUEST (1UL << 8) 150 #define L2CAP_FLAG_CONFIG_SDP_SUCCESS (1UL << 9) 151 #define L2CAP_FLAG_DISCONNECT_SDP_REQUEST (1UL << 10) 154 #define L2CAP_FLAG_CONNECTION_RFCOMM_REQUEST (1UL << 11) 155 #define L2CAP_FLAG_CONFIG_RFCOMM_SUCCESS (1UL << 12) 156 #define L2CAP_FLAG_DISCONNECT_RFCOMM_REQUEST (1UL << 13) 158 #define L2CAP_FLAG_DISCONNECT_RESPONSE (1UL << 14) 161 #define l2cap_check_flag(flag) (l2cap_event_flag & (flag)) 162 #define l2cap_set_flag(flag) (l2cap_event_flag |= (flag)) 163 #define l2cap_clear_flag(flag) (l2cap_event_flag &= ~(flag)) 166 #define L2CAP_CMD_COMMAND_REJECT 0x01 167 #define L2CAP_CMD_CONNECTION_REQUEST 0x02 168 #define L2CAP_CMD_CONNECTION_RESPONSE 0x03 169 #define L2CAP_CMD_CONFIG_REQUEST 0x04 170 #define L2CAP_CMD_CONFIG_RESPONSE 0x05 171 #define L2CAP_CMD_DISCONNECT_REQUEST 0x06 172 #define L2CAP_CMD_DISCONNECT_RESPONSE 0x07 173 #define L2CAP_CMD_INFORMATION_REQUEST 0x0A 174 #define L2CAP_CMD_INFORMATION_RESPONSE 0x0B 178 #define SUCCESSFUL 0x00 181 #define SDP_PSM 0x01 // Service Discovery Protocol PSM Value 182 #define RFCOMM_PSM 0x03 // RFCOMM PSM Value 183 #define HID_CTRL_PSM 0x11 // HID_Control PSM Value 184 #define HID_INTR_PSM 0x13 // HID_Interrupt PSM Value 187 #define WI_SUBCLASS_RF 0x01 // RF Controller 188 #define WI_PROTOCOL_BT 0x01 // Bluetooth Programming Interface 190 #define BTD_MAX_ENDPOINTS 4 191 #define BTD_NUM_SERVICES 4 // Max number of Bluetooth services - if you need more than 4 simply increase this number 225 uint8_t
Init(uint8_t parent, uint8_t port,
bool lowspeed);
269 virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) {
303 btService[i] = pService;
380 void L2CAP_Command(uint16_t handle, uint8_t* data, uint8_t nbytes, uint8_t channelLow = 0x01, uint8_t channelHigh = 0x00);
484 waitingForConnection =
false;
539 uint8_t pollInterval;
542 bool pairWiiUsingSync;
543 bool checkRemoteName;
545 uint8_t classOfDevice[3];
549 uint16_t hci_counter;
550 uint16_t hci_num_reset_loops;
551 uint16_t hci_event_flag;
552 uint8_t inquiry_counter;
556 uint8_t l2capoutbuf[14];
559 void HCI_event_task();
561 void ACL_event_task();
564 void setBdaddr(uint8_t* BDADDR);
565 void setMoveBdaddr(uint8_t* BDADDR);
573 pBtd->registerBluetoothService(
this);
579 virtual void ACLData(uint8_t* ACLData) = 0;
581 virtual void Run() = 0;
583 virtual void Reset() = 0;
592 pFuncOnInit = funcOnInit;
601 virtual void onInit() = 0;
605 return (buf[0] == (handle & 0xFF)) && (buf[1] == ((handle >> 8) | 0x20));
609 void (*pFuncOnInit)(void);
static const uint8_t BTD_DATAOUT_PIPE
void l2cap_connection_response(uint16_t handle, uint8_t rxid, uint8_t *dcid, uint8_t *scid, uint8_t result)
void l2cap_connection_request(uint16_t handle, uint8_t rxid, uint8_t *scid, uint16_t psm)
bool sdpConnectionClaimed
int8_t registerBluetoothService(BluetoothService *pService)
void l2cap_disconnection_request(uint16_t handle, uint8_t rxid, uint8_t *dcid, uint8_t *scid)
bool rfcommConnectionClaimed
bool waitingForConnection
static const uint8_t BTD_EVENT_PIPE
void hci_write_scan_disable()
#define BELKIN_F8T065BF_PID
void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep)
virtual bool VIDPIDOK(uint16_t vid, uint16_t pid)
virtual uint8_t GetAddress()
#define BELKIN_F8T065BF_VID
uint8_t readPollInterval()
static const uint8_t BTD_DATAIN_PIPE
void hci_set_local_name(const char *name)
void hci_write_scan_enable()
void l2cap_disconnection_response(uint16_t handle, uint8_t rxid, uint8_t *dcid, uint8_t *scid)
#define USB_CLASS_WIRELESS_CTRL
void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR *ep_ptr)
#define IOGEAR_GBU521_PID
uint8_t ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed)
uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed)
void hci_disconnect(uint16_t handle)
void hci_inquiry_cancel()
void attachOnInit(void(*funcOnInit)(void))
static const uint8_t BTD_CONTROL_PIPE
bool l2capConnectionClaimed
EpInfo epInfo[BTD_MAX_ENDPOINTS]
#define IOGEAR_GBU521_VID
#define BTD_MAX_ENDPOINTS
#define PS3NAVIGATION_PID
void l2cap_information_response(uint16_t handle, uint8_t rxid, uint8_t infoTypeLow, uint8_t infoTypeHigh)
void hci_write_class_of_device()
void hci_pin_code_negative_request_reply()
virtual bool DEVCLASSOK(uint8_t klass)
uint32_t l2cap_event_flag
#define HCI_CHECK_DEVICE_SERVICE
void hci_link_key_request_negative_reply()
void L2CAP_Command(uint16_t handle, uint8_t *data, uint8_t nbytes, uint8_t channelLow=0x01, uint8_t channelHigh=0x00)
void l2cap_config_response(uint16_t handle, uint8_t rxid, uint8_t *scid)
void l2cap_config_request(uint16_t handle, uint8_t rxid, uint8_t *dcid)
void hci_pin_code_request_reply()
void hci_authentication_request()
void hci_read_local_version_information()
void hci_accept_connection()
bool checkHciHandle(uint8_t *buf, uint16_t handle)
void HCI_Command(uint8_t *data, uint16_t nbytes)