mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Removed all direct calls to serial.print
This commit is contained in:
parent
78cb524bcf
commit
48b3ed93f5
9 changed files with 90 additions and 72 deletions
12
BTD.cpp
12
BTD.cpp
|
@ -373,7 +373,7 @@ void BTD::HCI_event_task() {
|
||||||
if (hcibuf[2]) { // Check that there is more than zero responses
|
if (hcibuf[2]) { // Check that there is more than zero responses
|
||||||
#ifdef EXTRADEBUG
|
#ifdef EXTRADEBUG
|
||||||
Notify(PSTR("\r\nNumber of responses: "), 0x80);
|
Notify(PSTR("\r\nNumber of responses: "), 0x80);
|
||||||
Serial.print(hcibuf[2]);
|
Notify(hcibuf[2], 0x80);
|
||||||
#endif
|
#endif
|
||||||
for (uint8_t i = 0; i < hcibuf[2]; i++) {
|
for (uint8_t i = 0; i < hcibuf[2]; i++) {
|
||||||
if ((hcibuf[4 + 8 * hcibuf[2] + 3 * i] == 0x04 && hcibuf[5 + 8 * hcibuf[2] + 3 * i] == 0x25 && hcibuf[6 + 8 * hcibuf[2] + 3 * i] == 0x00) || (hcibuf[4 + 8 * hcibuf[2] + 3 * i] == 0x08 && hcibuf[5 + 8 * hcibuf[2] + 3 * i] == 0x05 && hcibuf[6 + 8 * hcibuf[2] + 3 * i] == 0x00)) { // See http://bluetooth-pentest.narod.ru/software/bluetooth_class_of_device-service_generator.html and http://wiibrew.org/wiki/Wiimote#SDP_information
|
if ((hcibuf[4 + 8 * hcibuf[2] + 3 * i] == 0x04 && hcibuf[5 + 8 * hcibuf[2] + 3 * i] == 0x25 && hcibuf[6 + 8 * hcibuf[2] + 3 * i] == 0x00) || (hcibuf[4 + 8 * hcibuf[2] + 3 * i] == 0x08 && hcibuf[5 + 8 * hcibuf[2] + 3 * i] == 0x05 && hcibuf[6 + 8 * hcibuf[2] + 3 * i] == 0x00)) { // See http://bluetooth-pentest.narod.ru/software/bluetooth_class_of_device-service_generator.html and http://wiibrew.org/wiki/Wiimote#SDP_information
|
||||||
|
@ -460,7 +460,7 @@ void BTD::HCI_event_task() {
|
||||||
} else if (btdPin != NULL) {
|
} else if (btdPin != NULL) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Notify(PSTR("\r\nBluetooth pin is set too: "), 0x80);
|
Notify(PSTR("\r\nBluetooth pin is set too: "), 0x80);
|
||||||
Serial.print(btdPin);
|
NotifyStr(btdPin, 0x80);
|
||||||
#endif
|
#endif
|
||||||
hci_pin_code_request_reply();
|
hci_pin_code_request_reply();
|
||||||
} else {
|
} else {
|
||||||
|
@ -590,7 +590,7 @@ void BTD::HCI_task() {
|
||||||
if (hci_cmd_complete) {
|
if (hci_cmd_complete) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Notify(PSTR("\r\nThe name is set to: "), 0x80);
|
Notify(PSTR("\r\nThe name is set to: "), 0x80);
|
||||||
Serial.print(btdName);
|
NotifyStr(btdName, 0x80);
|
||||||
#endif
|
#endif
|
||||||
hci_state = HCI_CHECK_WII_SERVICE;
|
hci_state = HCI_CHECK_WII_SERVICE;
|
||||||
}
|
}
|
||||||
|
@ -681,7 +681,7 @@ void BTD::HCI_task() {
|
||||||
for (uint8_t i = 0; i < 30; i++) {
|
for (uint8_t i = 0; i < 30; i++) {
|
||||||
if (remote_name[i] == NULL)
|
if (remote_name[i] == NULL)
|
||||||
break;
|
break;
|
||||||
Serial.write(remote_name[i]);
|
Notifyc(remote_name[i], 0x80);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (strncmp((const char*)remote_name, "Nintendo", 8) == 0) {
|
if (strncmp((const char*)remote_name, "Nintendo", 8) == 0) {
|
||||||
|
@ -1073,9 +1073,9 @@ void BTD::L2CAP_Command(uint16_t handle, uint8_t* data, uint8_t nbytes, uint8_t
|
||||||
Notify(PSTR("\r\nError sending L2CAP message: 0x"), 0x80);
|
Notify(PSTR("\r\nError sending L2CAP message: 0x"), 0x80);
|
||||||
PrintHex<uint8_t > (rcode, 0x80);
|
PrintHex<uint8_t > (rcode, 0x80);
|
||||||
Notify(PSTR(" - Channel ID: "), 0x80);
|
Notify(PSTR(" - Channel ID: "), 0x80);
|
||||||
Serial.print(channelHigh);
|
PrintHex<uint8_t > (channelHigh, 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
Serial.print(channelLow);
|
PrintHex<uint8_t > (channelLow, 0x80);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
30
PS3BT.cpp
30
PS3BT.cpp
|
@ -258,7 +258,7 @@ void PS3BT::ACLData(uint8_t* ACLData) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (pBtd->hci_version < 3) { // Check the HCI Version of the Bluetooth dongle
|
if (pBtd->hci_version < 3) { // Check the HCI Version of the Bluetooth dongle
|
||||||
Notify(PSTR("\r\nYour dongle may not support reading the analog buttons, sensors and status\r\nYour HCI Version is: "), 0x80);
|
Notify(PSTR("\r\nYour dongle may not support reading the analog buttons, sensors and status\r\nYour HCI Version is: "), 0x80);
|
||||||
Serial.print(pBtd->hci_version);
|
Notify(pBtd->hci_version, 0x80);
|
||||||
Notify(PSTR("\r\nBut should be at least 3\r\nThis means that it doesn't support Bluetooth Version 2.0+EDR"), 0x80);
|
Notify(PSTR("\r\nBut should be at least 3\r\nThis means that it doesn't support Bluetooth Version 2.0+EDR"), 0x80);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -273,15 +273,15 @@ void PS3BT::ACLData(uint8_t* ACLData) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Notify(PSTR("\r\nL2CAP Command Rejected - Reason: "), 0x80);
|
Notify(PSTR("\r\nL2CAP Command Rejected - Reason: "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[13], 0x80);
|
PrintHex<uint8_t > (l2capinbuf[13], 0x80);
|
||||||
Serial.print(" ");
|
Notify(PSTR(" "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[12], 0x80);
|
PrintHex<uint8_t > (l2capinbuf[12], 0x80);
|
||||||
Serial.print(" Data: ");
|
Notify(PSTR(" Data: "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[17], 0x80);
|
PrintHex<uint8_t > (l2capinbuf[17], 0x80);
|
||||||
Serial.print(" ");
|
Notify(PSTR(" "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[16], 0x80);
|
PrintHex<uint8_t > (l2capinbuf[16], 0x80);
|
||||||
Serial.print(" ");
|
Notify(PSTR(" "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[15], 0x80);
|
PrintHex<uint8_t > (l2capinbuf[15], 0x80);
|
||||||
Serial.print(" ");
|
Notify(PSTR(" "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[14], 0x80);
|
PrintHex<uint8_t > (l2capinbuf[14], 0x80);
|
||||||
#endif
|
#endif
|
||||||
} else if (l2capinbuf[8] == L2CAP_CMD_CONNECTION_REQUEST) {
|
} else if (l2capinbuf[8] == L2CAP_CMD_CONNECTION_REQUEST) {
|
||||||
|
@ -311,20 +311,20 @@ void PS3BT::ACLData(uint8_t* ACLData) {
|
||||||
} else if (l2capinbuf[8] == L2CAP_CMD_CONFIG_RESPONSE) {
|
} else if (l2capinbuf[8] == L2CAP_CMD_CONFIG_RESPONSE) {
|
||||||
if ((l2capinbuf[16] | (l2capinbuf[17] << 8)) == 0x0000) { // Success
|
if ((l2capinbuf[16] | (l2capinbuf[17] << 8)) == 0x0000) { // Success
|
||||||
if (l2capinbuf[12] == control_dcid[0] && l2capinbuf[13] == control_dcid[1]) {
|
if (l2capinbuf[12] == control_dcid[0] && l2capinbuf[13] == control_dcid[1]) {
|
||||||
//Serial.print("\r\nHID Control Configuration Complete");
|
//Notify(PSTR("\r\nHID Control Configuration Complete"), 0x80);
|
||||||
l2cap_event_flag |= L2CAP_FLAG_CONFIG_CONTROL_SUCCESS;
|
l2cap_event_flag |= L2CAP_FLAG_CONFIG_CONTROL_SUCCESS;
|
||||||
} else if (l2capinbuf[12] == interrupt_dcid[0] && l2capinbuf[13] == interrupt_dcid[1]) {
|
} else if (l2capinbuf[12] == interrupt_dcid[0] && l2capinbuf[13] == interrupt_dcid[1]) {
|
||||||
//Serial.print("\r\nHID Interrupt Configuration Complete");
|
//Notify(PSTR("\r\nHID Interrupt Configuration Complete"), 0x80);
|
||||||
l2cap_event_flag |= L2CAP_FLAG_CONFIG_INTERRUPT_SUCCESS;
|
l2cap_event_flag |= L2CAP_FLAG_CONFIG_INTERRUPT_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (l2capinbuf[8] == L2CAP_CMD_CONFIG_REQUEST) {
|
} else if (l2capinbuf[8] == L2CAP_CMD_CONFIG_REQUEST) {
|
||||||
if (l2capinbuf[12] == control_dcid[0] && l2capinbuf[13] == control_dcid[1]) {
|
if (l2capinbuf[12] == control_dcid[0] && l2capinbuf[13] == control_dcid[1]) {
|
||||||
//Serial.print("\r\nHID Control Configuration Request");
|
//Notify(PSTR("\r\nHID Control Configuration Request"), 0x80);
|
||||||
identifier = l2capinbuf[9];
|
identifier = l2capinbuf[9];
|
||||||
l2cap_event_flag |= L2CAP_FLAG_CONFIG_CONTROL_REQUEST;
|
l2cap_event_flag |= L2CAP_FLAG_CONFIG_CONTROL_REQUEST;
|
||||||
} else if (l2capinbuf[12] == interrupt_dcid[0] && l2capinbuf[13] == interrupt_dcid[1]) {
|
} else if (l2capinbuf[12] == interrupt_dcid[0] && l2capinbuf[13] == interrupt_dcid[1]) {
|
||||||
//Serial.print("\r\nHID Interrupt Configuration Request");
|
//Notify(PSTR("\r\nHID Interrupt Configuration Request"), 0x80);
|
||||||
identifier = l2capinbuf[9];
|
identifier = l2capinbuf[9];
|
||||||
l2cap_event_flag |= L2CAP_FLAG_CONFIG_INTERRUPT_REQUEST;
|
l2cap_event_flag |= L2CAP_FLAG_CONFIG_INTERRUPT_REQUEST;
|
||||||
}
|
}
|
||||||
|
@ -346,11 +346,11 @@ void PS3BT::ACLData(uint8_t* ACLData) {
|
||||||
}
|
}
|
||||||
} else if (l2capinbuf[8] == L2CAP_CMD_DISCONNECT_RESPONSE) {
|
} else if (l2capinbuf[8] == L2CAP_CMD_DISCONNECT_RESPONSE) {
|
||||||
if (l2capinbuf[12] == control_scid[0] && l2capinbuf[13] == control_scid[1]) {
|
if (l2capinbuf[12] == control_scid[0] && l2capinbuf[13] == control_scid[1]) {
|
||||||
//Serial.print("\r\nDisconnect Response: Control Channel");
|
//Notify(PSTR("\r\nDisconnect Response: Control Channel"), 0x80);
|
||||||
identifier = l2capinbuf[9];
|
identifier = l2capinbuf[9];
|
||||||
l2cap_event_flag |= L2CAP_FLAG_DISCONNECT_CONTROL_RESPONSE;
|
l2cap_event_flag |= L2CAP_FLAG_DISCONNECT_CONTROL_RESPONSE;
|
||||||
} else if (l2capinbuf[12] == interrupt_scid[0] && l2capinbuf[13] == interrupt_scid[1]) {
|
} else if (l2capinbuf[12] == interrupt_scid[0] && l2capinbuf[13] == interrupt_scid[1]) {
|
||||||
//Serial.print("\r\nDisconnect Response: Interrupt Channel");
|
//Notify(PSTR("\r\nDisconnect Response: Interrupt Channel"), 0x80);
|
||||||
identifier = l2capinbuf[9];
|
identifier = l2capinbuf[9];
|
||||||
l2cap_event_flag |= L2CAP_FLAG_DISCONNECT_INTERRUPT_RESPONSE;
|
l2cap_event_flag |= L2CAP_FLAG_DISCONNECT_INTERRUPT_RESPONSE;
|
||||||
}
|
}
|
||||||
|
@ -362,7 +362,7 @@ void PS3BT::ACLData(uint8_t* ACLData) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else if (l2capinbuf[6] == interrupt_dcid[0] && l2capinbuf[7] == interrupt_dcid[1]) { // l2cap_interrupt
|
} else if (l2capinbuf[6] == interrupt_dcid[0] && l2capinbuf[7] == interrupt_dcid[1]) { // l2cap_interrupt
|
||||||
//Serial.print("\r\nL2CAP Interrupt");
|
//Notify(PSTR("\r\nL2CAP Interrupt"), 0x80);
|
||||||
if (PS3Connected || PS3MoveConnected || PS3NavigationConnected) {
|
if (PS3Connected || PS3MoveConnected || PS3NavigationConnected) {
|
||||||
/* Read Report */
|
/* Read Report */
|
||||||
if (l2capinbuf[8] == 0xA1) { // HID_THDR_DATA_INPUT
|
if (l2capinbuf[8] == 0xA1) { // HID_THDR_DATA_INPUT
|
||||||
|
@ -382,9 +382,9 @@ void PS3BT::ACLData(uint8_t* ACLData) {
|
||||||
#ifdef PRINTREPORT // Uncomment "#define PRINTREPORT" to print the report send by the PS3 Controllers
|
#ifdef PRINTREPORT // Uncomment "#define PRINTREPORT" to print the report send by the PS3 Controllers
|
||||||
for (uint8_t i = 10; i < 58; i++) {
|
for (uint8_t i = 10; i < 58; i++) {
|
||||||
PrintHex<uint8_t > (l2capinbuf[i], 0x80);
|
PrintHex<uint8_t > (l2capinbuf[i], 0x80);
|
||||||
Serial.print(" ");
|
Notify(PSTR(" "), 0x80);
|
||||||
}
|
}
|
||||||
Serial.println();
|
Notify(PSTR("\r\n"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,7 +209,7 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
Notify(PSTR("\r\nBluetooth Address was set to: "), 0x80);
|
Notify(PSTR("\r\nBluetooth Address was set to: "), 0x80);
|
||||||
for (int8_t i = 5; i > 0; i--) {
|
for (int8_t i = 5; i > 0; i--) {
|
||||||
PrintHex<uint8_t > (my_bdaddr[i], 0x80);
|
PrintHex<uint8_t > (my_bdaddr[i], 0x80);
|
||||||
Serial.print(":");
|
Notify(PSTR(":"), 0x80);
|
||||||
}
|
}
|
||||||
PrintHex<uint8_t > (my_bdaddr[0], 0x80);
|
PrintHex<uint8_t > (my_bdaddr[0], 0x80);
|
||||||
#endif
|
#endif
|
||||||
|
@ -299,9 +299,9 @@ void PS3USB::printReport() { //Uncomment "#define PRINTREPORT" to print the repo
|
||||||
return;
|
return;
|
||||||
for (uint8_t i = 0; i < PS3_REPORT_BUFFER_SIZE; i++) {
|
for (uint8_t i = 0; i < PS3_REPORT_BUFFER_SIZE; i++) {
|
||||||
PrintHex<uint8_t > (readBuf[i], 0x80);
|
PrintHex<uint8_t > (readBuf[i], 0x80);
|
||||||
Serial.print(" ");
|
Notify(PSTR(" "), 0x80);
|
||||||
}
|
}
|
||||||
Serial.println();
|
Notify(PSTR("\r\n"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
36
SPP.cpp
36
SPP.cpp
|
@ -139,20 +139,20 @@ void SPP::ACLData(uint8_t* l2capinbuf) {
|
||||||
} else if (l2capinbuf[8] == L2CAP_CMD_CONFIG_RESPONSE) {
|
} else if (l2capinbuf[8] == L2CAP_CMD_CONFIG_RESPONSE) {
|
||||||
if ((l2capinbuf[16] | (l2capinbuf[17] << 8)) == 0x0000) { // Success
|
if ((l2capinbuf[16] | (l2capinbuf[17] << 8)) == 0x0000) { // Success
|
||||||
if (l2capinbuf[12] == sdp_dcid[0] && l2capinbuf[13] == sdp_dcid[1]) {
|
if (l2capinbuf[12] == sdp_dcid[0] && l2capinbuf[13] == sdp_dcid[1]) {
|
||||||
//Serial.print("\r\nSDP Configuration Complete");
|
//Notify(PSTR("\r\nSDP Configuration Complete"), 0x80);
|
||||||
l2cap_event_flag |= L2CAP_FLAG_CONFIG_SDP_SUCCESS;
|
l2cap_event_flag |= L2CAP_FLAG_CONFIG_SDP_SUCCESS;
|
||||||
} else if (l2capinbuf[12] == rfcomm_dcid[0] && l2capinbuf[13] == rfcomm_dcid[1]) {
|
} else if (l2capinbuf[12] == rfcomm_dcid[0] && l2capinbuf[13] == rfcomm_dcid[1]) {
|
||||||
//Serial.print("\r\nRFCOMM Configuration Complete");
|
//Notify(PSTR("\r\nRFCOMM Configuration Complete"), 0x80);
|
||||||
l2cap_event_flag |= L2CAP_FLAG_CONFIG_RFCOMM_SUCCESS;
|
l2cap_event_flag |= L2CAP_FLAG_CONFIG_RFCOMM_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (l2capinbuf[8] == L2CAP_CMD_CONFIG_REQUEST) {
|
} else if (l2capinbuf[8] == L2CAP_CMD_CONFIG_REQUEST) {
|
||||||
if (l2capinbuf[12] == sdp_dcid[0] && l2capinbuf[13] == sdp_dcid[1]) {
|
if (l2capinbuf[12] == sdp_dcid[0] && l2capinbuf[13] == sdp_dcid[1]) {
|
||||||
//Serial.print("\r\nSDP Configuration Request");
|
//Notify(PSTR("\r\nSDP Configuration Request"), 0x80);
|
||||||
identifier = l2capinbuf[9];
|
identifier = l2capinbuf[9];
|
||||||
l2cap_event_flag |= L2CAP_FLAG_CONFIG_SDP_REQUEST;
|
l2cap_event_flag |= L2CAP_FLAG_CONFIG_SDP_REQUEST;
|
||||||
} else if (l2capinbuf[12] == rfcomm_dcid[0] && l2capinbuf[13] == rfcomm_dcid[1]) {
|
} else if (l2capinbuf[12] == rfcomm_dcid[0] && l2capinbuf[13] == rfcomm_dcid[1]) {
|
||||||
//Serial.print("\r\nRFCOMM Configuration Request");
|
//Notify(PSTR("\r\nRFCOMM Configuration Request"), 0x80);
|
||||||
identifier = l2capinbuf[9];
|
identifier = l2capinbuf[9];
|
||||||
l2cap_event_flag |= L2CAP_FLAG_CONFIG_RFCOMM_REQUEST;
|
l2cap_event_flag |= L2CAP_FLAG_CONFIG_RFCOMM_REQUEST;
|
||||||
}
|
}
|
||||||
|
@ -168,11 +168,11 @@ void SPP::ACLData(uint8_t* l2capinbuf) {
|
||||||
}
|
}
|
||||||
} else if (l2capinbuf[8] == L2CAP_CMD_DISCONNECT_RESPONSE) {
|
} else if (l2capinbuf[8] == L2CAP_CMD_DISCONNECT_RESPONSE) {
|
||||||
if (l2capinbuf[12] == sdp_scid[0] && l2capinbuf[13] == sdp_scid[1]) {
|
if (l2capinbuf[12] == sdp_scid[0] && l2capinbuf[13] == sdp_scid[1]) {
|
||||||
//Serial.print("\r\nDisconnect Response: SDP Channel");
|
//Notify(PSTR("\r\nDisconnect Response: SDP Channel"), 0x80);
|
||||||
identifier = l2capinbuf[9];
|
identifier = l2capinbuf[9];
|
||||||
l2cap_event_flag |= L2CAP_FLAG_DISCONNECT_RESPONSE;
|
l2cap_event_flag |= L2CAP_FLAG_DISCONNECT_RESPONSE;
|
||||||
} else if (l2capinbuf[12] == rfcomm_scid[0] && l2capinbuf[13] == rfcomm_scid[1]) {
|
} else if (l2capinbuf[12] == rfcomm_scid[0] && l2capinbuf[13] == rfcomm_scid[1]) {
|
||||||
//Serial.print("\r\nDisconnect Response: RFCOMM Channel");
|
//Notify(PSTR("\r\nDisconnect Response: RFCOMM Channel"), 0x80);
|
||||||
identifier = l2capinbuf[9];
|
identifier = l2capinbuf[9];
|
||||||
l2cap_event_flag |= L2CAP_FLAG_DISCONNECT_RESPONSE;
|
l2cap_event_flag |= L2CAP_FLAG_DISCONNECT_RESPONSE;
|
||||||
}
|
}
|
||||||
|
@ -240,20 +240,20 @@ void SPP::ACLData(uint8_t* l2capinbuf) {
|
||||||
|
|
||||||
#ifdef EXTRADEBUG
|
#ifdef EXTRADEBUG
|
||||||
Notify(PSTR("\r\nRFCOMM Channel: "), 0x80);
|
Notify(PSTR("\r\nRFCOMM Channel: "), 0x80);
|
||||||
Serial.print(rfcommChannel >> 3, HEX);
|
PrintHex<uint8_t > (rfcommChannel >> 3, 0x80);
|
||||||
Notify(PSTR(" Direction: "), 0x80);
|
Notify(PSTR(" Direction: "), 0x80);
|
||||||
Serial.print(rfcommDirection >> 2, HEX);
|
PrintHex<uint8_t > (rfcommDirection >> 2, 0x80);
|
||||||
Notify(PSTR(" CommandResponse: "), 0x80);
|
Notify(PSTR(" CommandResponse: "), 0x80);
|
||||||
Serial.print(rfcommCommandResponse >> 1, HEX);
|
PrintHex<uint8_t > (rfcommCommandResponse >> 1, 0x80);
|
||||||
Notify(PSTR(" ChannelType: "), 0x80);
|
Notify(PSTR(" ChannelType: "), 0x80);
|
||||||
Serial.print(rfcommChannelType, HEX);
|
PrintHex<uint8_t > (rfcommChannelType, 0x80);
|
||||||
Notify(PSTR(" PF_BIT: "), 0x80);
|
Notify(PSTR(" PF_BIT: "), 0x80);
|
||||||
Serial.print(rfcommPfBit, HEX);
|
PrintHex<uint8_t > (rfcommPfBit, 0x80);
|
||||||
#endif
|
#endif
|
||||||
if (rfcommChannelType == RFCOMM_DISC) {
|
if (rfcommChannelType == RFCOMM_DISC) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Notify(PSTR("\r\nReceived Disconnect RFCOMM Command on channel: "), 0x80);
|
Notify(PSTR("\r\nReceived Disconnect RFCOMM Command on channel: "), 0x80);
|
||||||
Serial.print(rfcommChannel >> 3, HEX);
|
PrintHex<uint8_t > (rfcommChannel >> 3, 0x80);
|
||||||
#endif
|
#endif
|
||||||
connected = false;
|
connected = false;
|
||||||
sendRfcomm(rfcommChannel, rfcommDirection, rfcommCommandResponse, RFCOMM_UA, rfcommPfBit, rfcommbuf, 0x00); // UA Command
|
sendRfcomm(rfcommChannel, rfcommDirection, rfcommCommandResponse, RFCOMM_UA, rfcommPfBit, rfcommbuf, 0x00); // UA Command
|
||||||
|
@ -270,15 +270,15 @@ void SPP::ACLData(uint8_t* l2capinbuf) {
|
||||||
}
|
}
|
||||||
#ifdef EXTRADEBUG
|
#ifdef EXTRADEBUG
|
||||||
Notify(PSTR("\r\nRFCOMM Data Available: "), 0x80);
|
Notify(PSTR("\r\nRFCOMM Data Available: "), 0x80);
|
||||||
Serial.print(rfcommAvailable);
|
Notify(rfcommAvailable, 0x80);
|
||||||
if (offset) {
|
if (offset) {
|
||||||
Notify(PSTR(" - Credit: 0x"), 0x80);
|
Notify(PSTR(" - Credit: 0x"), 0x80);
|
||||||
Serial.print(l2capinbuf[11], HEX);
|
PrintHex<uint8_t > (l2capinbuf[11], 0x80);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef PRINTREPORT // Uncomment "#define PRINTREPORT" to print the report send to the Arduino via Bluetooth
|
#ifdef PRINTREPORT // Uncomment "#define PRINTREPORT" to print the report send to the Arduino via Bluetooth
|
||||||
for (uint8_t i = 0; i < length; i++)
|
for (uint8_t i = 0; i < length; i++)
|
||||||
Serial.write(l2capinbuf[i + 11 + offset]);
|
Notifyc(l2capinbuf[i + 11 + offset], 0x80);
|
||||||
#endif
|
#endif
|
||||||
} else if (rfcommChannelType == RFCOMM_UIH && l2capinbuf[11] == BT_RFCOMM_RPN_CMD) { // UIH Remote Port Negotiation Command
|
} else if (rfcommChannelType == RFCOMM_UIH && l2capinbuf[11] == BT_RFCOMM_RPN_CMD) { // UIH Remote Port Negotiation Command
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -688,7 +688,7 @@ void SPP::sendRfcomm(uint8_t channel, uint8_t direction, uint8_t CR, uint8_t cha
|
||||||
#ifdef EXTRADEBUG
|
#ifdef EXTRADEBUG
|
||||||
Notify(PSTR(" - RFCOMM Data: "), 0x80);
|
Notify(PSTR(" - RFCOMM Data: "), 0x80);
|
||||||
for (i = 0; i < length + 4; i++) {
|
for (i = 0; i < length + 4; i++) {
|
||||||
Serial.print(l2capoutbuf[i], HEX);
|
PrintHex<uint8_t > (l2capoutbuf[i], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -704,7 +704,7 @@ void SPP::sendRfcommCredit(uint8_t channel, uint8_t direction, uint8_t CR, uint8
|
||||||
#ifdef EXTRADEBUG
|
#ifdef EXTRADEBUG
|
||||||
Notify(PSTR(" - RFCOMM Credit Data: "), 0x80);
|
Notify(PSTR(" - RFCOMM Credit Data: "), 0x80);
|
||||||
for (uint8_t i = 0; i < 5; i++) {
|
for (uint8_t i = 0; i < 5; i++) {
|
||||||
Serial.print(l2capoutbuf[i], HEX);
|
PrintHex<uint8_t > (l2capoutbuf[i], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -929,7 +929,7 @@ uint8_t SPP::read() {
|
||||||
sendRfcommCredit(rfcommChannelConnection, rfcommDirection, 0, RFCOMM_UIH, 0x10, sizeof (rfcommDataBuffer)); // Send more credit
|
sendRfcommCredit(rfcommChannelConnection, rfcommDirection, 0, RFCOMM_UIH, 0x10, sizeof (rfcommDataBuffer)); // Send more credit
|
||||||
#ifdef EXTRADEBUG
|
#ifdef EXTRADEBUG
|
||||||
Notify(PSTR("\r\nSent "), 0x80);
|
Notify(PSTR("\r\nSent "), 0x80);
|
||||||
Serial.print(sizeof (rfcommDataBuffer));
|
Notify((uint8_t)sizeof (rfcommDataBuffer), 0x80);
|
||||||
Notify(PSTR(" more credit"), 0x80);
|
Notify(PSTR(" more credit"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
40
Wii.cpp
40
Wii.cpp
|
@ -161,13 +161,13 @@ void WII::ACLData(uint8_t* l2capinbuf) {
|
||||||
} else if (l2capinbuf[8] == L2CAP_CMD_CONNECTION_RESPONSE) {
|
} else if (l2capinbuf[8] == L2CAP_CMD_CONNECTION_RESPONSE) {
|
||||||
if (((l2capinbuf[16] | (l2capinbuf[17] << 8)) == 0x0000) && ((l2capinbuf[18] | (l2capinbuf[19] << 8)) == SUCCESSFUL)) { // Success
|
if (((l2capinbuf[16] | (l2capinbuf[17] << 8)) == 0x0000) && ((l2capinbuf[18] | (l2capinbuf[19] << 8)) == SUCCESSFUL)) { // Success
|
||||||
if (l2capinbuf[14] == control_dcid[0] && l2capinbuf[15] == control_dcid[1]) { // Success
|
if (l2capinbuf[14] == control_dcid[0] && l2capinbuf[15] == control_dcid[1]) { // Success
|
||||||
//Serial.print("\r\nHID Control Connection Complete");
|
//Notify(PSTR("\r\nHID Control Connection Complete"), 0x80);
|
||||||
identifier = l2capinbuf[9];
|
identifier = l2capinbuf[9];
|
||||||
control_scid[0] = l2capinbuf[12];
|
control_scid[0] = l2capinbuf[12];
|
||||||
control_scid[1] = l2capinbuf[13];
|
control_scid[1] = l2capinbuf[13];
|
||||||
l2cap_event_flag |= L2CAP_FLAG_CONTROL_CONNECTED;
|
l2cap_event_flag |= L2CAP_FLAG_CONTROL_CONNECTED;
|
||||||
} else if (l2capinbuf[14] == interrupt_dcid[0] && l2capinbuf[15] == interrupt_dcid[1]) {
|
} else if (l2capinbuf[14] == interrupt_dcid[0] && l2capinbuf[15] == interrupt_dcid[1]) {
|
||||||
//Serial.print("\r\nHID Interrupt Connection Complete");
|
//Notify(PSTR("\r\nHID Interrupt Connection Complete"), 0x80);
|
||||||
identifier = l2capinbuf[9];
|
identifier = l2capinbuf[9];
|
||||||
interrupt_scid[0] = l2capinbuf[12];
|
interrupt_scid[0] = l2capinbuf[12];
|
||||||
interrupt_scid[1] = l2capinbuf[13];
|
interrupt_scid[1] = l2capinbuf[13];
|
||||||
|
@ -201,21 +201,21 @@ void WII::ACLData(uint8_t* l2capinbuf) {
|
||||||
} else if (l2capinbuf[8] == L2CAP_CMD_CONFIG_RESPONSE) {
|
} else if (l2capinbuf[8] == L2CAP_CMD_CONFIG_RESPONSE) {
|
||||||
if ((l2capinbuf[16] | (l2capinbuf[17] << 8)) == 0x0000) { // Success
|
if ((l2capinbuf[16] | (l2capinbuf[17] << 8)) == 0x0000) { // Success
|
||||||
if (l2capinbuf[12] == control_dcid[0] && l2capinbuf[13] == control_dcid[1]) {
|
if (l2capinbuf[12] == control_dcid[0] && l2capinbuf[13] == control_dcid[1]) {
|
||||||
//Serial.print("\r\nHID Control Configuration Complete");
|
//Notify(PSTR("\r\nHID Control Configuration Complete"), 0x80);
|
||||||
identifier = l2capinbuf[9];
|
identifier = l2capinbuf[9];
|
||||||
l2cap_event_flag |= L2CAP_FLAG_CONFIG_CONTROL_SUCCESS;
|
l2cap_event_flag |= L2CAP_FLAG_CONFIG_CONTROL_SUCCESS;
|
||||||
} else if (l2capinbuf[12] == interrupt_dcid[0] && l2capinbuf[13] == interrupt_dcid[1]) {
|
} else if (l2capinbuf[12] == interrupt_dcid[0] && l2capinbuf[13] == interrupt_dcid[1]) {
|
||||||
//Serial.print("\r\nHID Interrupt Configuration Complete");
|
//Notify(PSTR("\r\nHID Interrupt Configuration Complete"), 0x80);
|
||||||
identifier = l2capinbuf[9];
|
identifier = l2capinbuf[9];
|
||||||
l2cap_event_flag |= L2CAP_FLAG_CONFIG_INTERRUPT_SUCCESS;
|
l2cap_event_flag |= L2CAP_FLAG_CONFIG_INTERRUPT_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (l2capinbuf[8] == L2CAP_CMD_CONFIG_REQUEST) {
|
} else if (l2capinbuf[8] == L2CAP_CMD_CONFIG_REQUEST) {
|
||||||
if (l2capinbuf[12] == control_dcid[0] && l2capinbuf[13] == control_dcid[1]) {
|
if (l2capinbuf[12] == control_dcid[0] && l2capinbuf[13] == control_dcid[1]) {
|
||||||
//Serial.print("\r\nHID Control Configuration Request");
|
//Notify(PSTR("\r\nHID Control Configuration Request"), 0x80);
|
||||||
pBtd->l2cap_config_response(hci_handle, l2capinbuf[9], control_scid);
|
pBtd->l2cap_config_response(hci_handle, l2capinbuf[9], control_scid);
|
||||||
} else if (l2capinbuf[12] == interrupt_dcid[0] && l2capinbuf[13] == interrupt_dcid[1]) {
|
} else if (l2capinbuf[12] == interrupt_dcid[0] && l2capinbuf[13] == interrupt_dcid[1]) {
|
||||||
//Serial.print("\r\nHID Interrupt Configuration Request");
|
//Notify(PSTR("\r\nHID Interrupt Configuration Request"), 0x80);
|
||||||
pBtd->l2cap_config_response(hci_handle, l2capinbuf[9], interrupt_scid);
|
pBtd->l2cap_config_response(hci_handle, l2capinbuf[9], interrupt_scid);
|
||||||
}
|
}
|
||||||
} else if (l2capinbuf[8] == L2CAP_CMD_DISCONNECT_REQUEST) {
|
} else if (l2capinbuf[8] == L2CAP_CMD_DISCONNECT_REQUEST) {
|
||||||
|
@ -236,11 +236,11 @@ void WII::ACLData(uint8_t* l2capinbuf) {
|
||||||
}
|
}
|
||||||
} else if (l2capinbuf[8] == L2CAP_CMD_DISCONNECT_RESPONSE) {
|
} else if (l2capinbuf[8] == L2CAP_CMD_DISCONNECT_RESPONSE) {
|
||||||
if (l2capinbuf[12] == control_scid[0] && l2capinbuf[13] == control_scid[1]) {
|
if (l2capinbuf[12] == control_scid[0] && l2capinbuf[13] == control_scid[1]) {
|
||||||
//Serial.print("\r\nDisconnect Response: Control Channel");
|
//Notify(PSTR("\r\nDisconnect Response: Control Channel"), 0x80);
|
||||||
identifier = l2capinbuf[9];
|
identifier = l2capinbuf[9];
|
||||||
l2cap_event_flag |= L2CAP_FLAG_DISCONNECT_CONTROL_RESPONSE;
|
l2cap_event_flag |= L2CAP_FLAG_DISCONNECT_CONTROL_RESPONSE;
|
||||||
} else if (l2capinbuf[12] == interrupt_scid[0] && l2capinbuf[13] == interrupt_scid[1]) {
|
} else if (l2capinbuf[12] == interrupt_scid[0] && l2capinbuf[13] == interrupt_scid[1]) {
|
||||||
//Serial.print("\r\nDisconnect Response: Interrupt Channel");
|
//Notify(PSTR("\r\nDisconnect Response: Interrupt Channel"), 0x80);
|
||||||
identifier = l2capinbuf[9];
|
identifier = l2capinbuf[9];
|
||||||
l2cap_event_flag |= L2CAP_FLAG_DISCONNECT_INTERRUPT_RESPONSE;
|
l2cap_event_flag |= L2CAP_FLAG_DISCONNECT_INTERRUPT_RESPONSE;
|
||||||
}
|
}
|
||||||
|
@ -253,7 +253,7 @@ void WII::ACLData(uint8_t* l2capinbuf) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else if (l2capinbuf[6] == interrupt_dcid[0] && l2capinbuf[7] == interrupt_dcid[1]) { // l2cap_interrupt
|
} else if (l2capinbuf[6] == interrupt_dcid[0] && l2capinbuf[7] == interrupt_dcid[1]) { // l2cap_interrupt
|
||||||
//Serial.print("\r\nL2CAP Interrupt");
|
//Notify(PSTR("\r\nL2CAP Interrupt"), 0x80);
|
||||||
if (wiimoteConnected) {
|
if (wiimoteConnected) {
|
||||||
if (l2capinbuf[8] == 0xA1) { // HID_THDR_DATA_INPUT
|
if (l2capinbuf[8] == 0xA1) { // HID_THDR_DATA_INPUT
|
||||||
if ((l2capinbuf[9] >= 0x20 && l2capinbuf[9] <= 0x22) || (l2capinbuf[9] >= 0x30 && l2capinbuf[9] <= 0x37) || l2capinbuf[9] == 0x3e || l2capinbuf[9] == 0x3f) { // These reports include the buttons
|
if ((l2capinbuf[9] >= 0x20 && l2capinbuf[9] <= 0x22) || (l2capinbuf[9] >= 0x30 && l2capinbuf[9] <= 0x37) || l2capinbuf[9] == 0x3e || l2capinbuf[9] == 0x3f) { // These reports include the buttons
|
||||||
|
@ -481,18 +481,18 @@ void WII::ACLData(uint8_t* l2capinbuf) {
|
||||||
timer = micros();
|
timer = micros();
|
||||||
/*
|
/*
|
||||||
// Uncomment these lines to tune the gyro scale variabels
|
// Uncomment these lines to tune the gyro scale variabels
|
||||||
Serial.print("\r\ngyroYaw: ");
|
Notify(PSTR("\r\ngyroYaw: "), 0x80);
|
||||||
Serial.print(gyroYaw);
|
Notify(gyroYaw, 0x80);
|
||||||
Serial.print("\tgyroRoll: ");
|
Notify(PSTR("\tgyroRoll: "), 0x80);
|
||||||
Serial.print(gyroRoll);
|
Notify(gyroRoll, 0x80);
|
||||||
Serial.print("\tgyroPitch: ");
|
Notify(PSTR("\tgyroPitch: "), 0x80);
|
||||||
Serial.print(gyroPitch);
|
Notify(gyroPitch, 0x80);
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
Serial.print("\twiimoteRoll: ");
|
Notify(PSTR("\twiimoteRoll: "), 0x80);
|
||||||
Serial.print(wiimoteRoll);
|
Notify(wiimoteRoll, 0x80);
|
||||||
Serial.print("\twiimotePitch: ");
|
Notify(PSTR("\twiimotePitch: "), 0x80);
|
||||||
Serial.print(wiimotePitch);
|
Notify(wiimotePitch, 0x80);
|
||||||
*/
|
*/
|
||||||
} else {
|
} else {
|
||||||
if ((micros() - timer) > 1000000) { // Loop for 1 sec before resetting the values
|
if ((micros() - timer) > 1000000) { // Loop for 1 sec before resetting the values
|
||||||
|
@ -567,7 +567,7 @@ void WII::ACLData(uint8_t* l2capinbuf) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
default:
|
default:
|
||||||
Notify(PSTR("\r\nUnknown Report type: "), 0x80);
|
Notify(PSTR("\r\nUnknown Report type: "), 0x80);
|
||||||
Serial.print(l2capinbuf[9], HEX);
|
PrintHex<uint8_t > (l2capinbuf[9], 0x80);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
10
XBOXRECV.cpp
10
XBOXRECV.cpp
|
@ -278,7 +278,7 @@ uint8_t XBOXRECV::Poll() {
|
||||||
if (bufferSize > 0) { // The number of received bytes
|
if (bufferSize > 0) { // The number of received bytes
|
||||||
#ifdef EXTRADEBUG
|
#ifdef EXTRADEBUG
|
||||||
Notify(PSTR("Bytes Received: "), 0x80);
|
Notify(PSTR("Bytes Received: "), 0x80);
|
||||||
Serial.print(bufferSize);
|
PrintHex<uint16_t > (bufferSize, 0x80);
|
||||||
Notify(PSTR("\r\n"), 0x80);
|
Notify(PSTR("\r\n"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
readReport(i);
|
readReport(i);
|
||||||
|
@ -298,7 +298,7 @@ void XBOXRECV::readReport(uint8_t controller) {
|
||||||
Xbox360Connected[controller] = readBuf[1];
|
Xbox360Connected[controller] = readBuf[1];
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Notify(PSTR("Controller "), 0x80);
|
Notify(PSTR("Controller "), 0x80);
|
||||||
Serial.print(controller);
|
Notify(controller, 0x80);
|
||||||
#endif
|
#endif
|
||||||
if (Xbox360Connected[controller]) {
|
if (Xbox360Connected[controller]) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -371,13 +371,13 @@ void XBOXRECV::printReport(uint8_t controller, uint8_t nBytes) { //Uncomment "#d
|
||||||
if (readBuf == NULL)
|
if (readBuf == NULL)
|
||||||
return;
|
return;
|
||||||
Notify(PSTR("Controller "), 0x80);
|
Notify(PSTR("Controller "), 0x80);
|
||||||
Serial.print(controller);
|
Notify(controller, 0x80);
|
||||||
Notify(PSTR(": "), 0x80);
|
Notify(PSTR(": "), 0x80);
|
||||||
for (uint8_t i = 0; i < nBytes; i++) {
|
for (uint8_t i = 0; i < nBytes; i++) {
|
||||||
PrintHex<uint8_t > (readBuf[i], 0x80);
|
PrintHex<uint8_t > (readBuf[i], 0x80);
|
||||||
Serial.print(" ");
|
Notify(PSTR(" "), 0x80);
|
||||||
}
|
}
|
||||||
Serial.println();
|
Notify(PSTR("\r\n"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -260,9 +260,9 @@ void XBOXUSB::printReport() { //Uncomment "#define PRINTREPORT" to print the rep
|
||||||
return;
|
return;
|
||||||
for (uint8_t i = 0; i < XBOX_REPORT_BUFFER_SIZE; i++) {
|
for (uint8_t i = 0; i < XBOX_REPORT_BUFFER_SIZE; i++) {
|
||||||
PrintHex<uint8_t > (readBuf[i], 0x80);
|
PrintHex<uint8_t > (readBuf[i], 0x80);
|
||||||
Serial.print(" ");
|
Notify(PSTR(" "), 0x80);
|
||||||
}
|
}
|
||||||
Serial.println();
|
Notify(PSTR("\r\n"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
16
message.cpp
16
message.cpp
|
@ -48,6 +48,22 @@ void NotifyStr(char const * msg, int lvl) {
|
||||||
while (c = *msg++) Notifyc(c, lvl);
|
while (c = *msg++) Notifyc(c, lvl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Notify(uint8_t b, int lvl) {
|
||||||
|
if (UsbDEBUGlvl < lvl) return;
|
||||||
|
#if defined(ARDUINO) && ARDUINO >=100
|
||||||
|
Serial.print(b);
|
||||||
|
#else
|
||||||
|
Serial.print(b, DEC);
|
||||||
|
#endif
|
||||||
|
Serial.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Notify(double d, int lvl) {
|
||||||
|
if (UsbDEBUGlvl < lvl) return;
|
||||||
|
Serial.print(d);
|
||||||
|
Serial.flush();
|
||||||
|
}
|
||||||
|
|
||||||
void NotifyFailGetDevDescr(void) {
|
void NotifyFailGetDevDescr(void) {
|
||||||
Notify(PSTR("\r\ngetDevDescr"), 0x80);
|
Notify(PSTR("\r\ngetDevDescr"), 0x80);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,8 @@ extern int UsbDEBUGlvl;
|
||||||
|
|
||||||
#include "printhex.h"
|
#include "printhex.h"
|
||||||
|
|
||||||
|
void Notify(uint8_t b, int lvl);
|
||||||
|
void Notify(double d, int lvl);
|
||||||
void Notify(char const * msg, int lvl);
|
void Notify(char const * msg, int lvl);
|
||||||
void NotifyStr(char const * msg, int lvl);
|
void NotifyStr(char const * msg, int lvl);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
Loading…
Reference in a new issue