Updated some comments

This commit is contained in:
Kristian Lauszus 2013-12-11 10:06:40 +01:00
parent 809e80a1b0
commit dec1a31bc7

47
BTD.cpp
View file

@ -388,11 +388,11 @@ void BTD::HCI_event_task() {
{ {
case EV_COMMAND_COMPLETE: case EV_COMMAND_COMPLETE:
if (!hcibuf[5]) { // Check if command succeeded if (!hcibuf[5]) { // Check if command succeeded
hci_event_flag |= HCI_FLAG_CMD_COMPLETE; // set command complete flag hci_event_flag |= HCI_FLAG_CMD_COMPLETE; // Set command complete flag
if ((hcibuf[3] == 0x01) && (hcibuf[4] == 0x10)) { // parameters from read local version information if ((hcibuf[3] == 0x01) && (hcibuf[4] == 0x10)) { // Parameters from read local version information
hci_version = hcibuf[6]; // Used to check if it supports 2.0+EDR - see http://www.bluetooth.org/Technical/AssignedNumbers/hci.htm hci_version = hcibuf[6]; // Used to check if it supports 2.0+EDR - see http://www.bluetooth.org/Technical/AssignedNumbers/hci.htm
hci_event_flag |= HCI_FLAG_READ_VERSION; hci_event_flag |= HCI_FLAG_READ_VERSION;
} else if ((hcibuf[3] == 0x09) && (hcibuf[4] == 0x10)) { // parameters from read local bluetooth address } else if ((hcibuf[3] == 0x09) && (hcibuf[4] == 0x10)) { // Parameters from read local bluetooth address
for (uint8_t i = 0; i < 6; i++) for (uint8_t i = 0; i < 6; i++)
my_bdaddr[i] = hcibuf[6 + i]; my_bdaddr[i] = hcibuf[6 + i];
hci_event_flag |= HCI_FLAG_READ_BDADDR; hci_event_flag |= HCI_FLAG_READ_BDADDR;
@ -440,7 +440,7 @@ void BTD::HCI_event_task() {
for (uint8_t j = 0; j < 3; j++) for (uint8_t j = 0; j < 3; j++)
classOfDevice[j] = hcibuf[j + 4 + offset]; classOfDevice[j] = hcibuf[j + 4 + offset];
if (pairWithWii && classOfDevice[2] == 0x00 && (classOfDevice[1] & 0x05) && (classOfDevice[0] & 0x0C)) { // See http://bluetooth-pentest.narod.ru/software/bluetooth_class_of_device-service_generator.html and http://wiibrew.org/wiki/Wiimote#SDP_information if (pairWithWii && classOfDevice[2] == 0x00 && (classOfDevice[1] & 0x05) && (classOfDevice[0] & 0x0C)) { // See http://wiibrew.org/wiki/Wiimote#SDP_information
if (classOfDevice[0] & 0x08) // Check if it's the new Wiimote with motion plus inside that was detected if (classOfDevice[0] & 0x08) // Check if it's the new Wiimote with motion plus inside that was detected
motionPlusInside = true; motionPlusInside = true;
else else
@ -451,7 +451,7 @@ void BTD::HCI_event_task() {
hci_event_flag |= HCI_FLAG_DEVICE_FOUND; hci_event_flag |= HCI_FLAG_DEVICE_FOUND;
break; break;
} else if (pairWithHIDDevice && (classOfDevice[1] & 0x05) && (classOfDevice[0] & 0xC0)) { // Check if it is a mouse or keyboard } else if (pairWithHIDDevice && (classOfDevice[1] & 0x05) && (classOfDevice[0] & 0xC0)) { // Check if it is a mouse or keyboard - see: http://bluetooth-pentest.narod.ru/software/bluetooth_class_of_device-service_generator.html
#ifdef DEBUG_USB_HOST #ifdef DEBUG_USB_HOST
if (classOfDevice[0] & 0x80) if (classOfDevice[0] & 0x80)
Notify(PSTR("\r\nMouse found"), 0x80); Notify(PSTR("\r\nMouse found"), 0x80);
@ -480,12 +480,12 @@ void BTD::HCI_event_task() {
case EV_CONNECT_COMPLETE: case EV_CONNECT_COMPLETE:
hci_event_flag |= HCI_FLAG_CONNECT_EVENT; hci_event_flag |= HCI_FLAG_CONNECT_EVENT;
if (!hcibuf[2]) { // check if connected OK if (!hcibuf[2]) { // Check if connected OK
#ifdef EXTRADEBUG #ifdef EXTRADEBUG
Notify(PSTR("\r\nConnection established"), 0x80); Notify(PSTR("\r\nConnection established"), 0x80);
#endif #endif
hci_handle = hcibuf[3] | ((hcibuf[4] & 0x0F) << 8); // store the handle for the ACL connection hci_handle = hcibuf[3] | ((hcibuf[4] & 0x0F) << 8); // Store the handle for the ACL connection
hci_event_flag |= HCI_FLAG_CONN_COMPLETE; // set connection complete flag hci_event_flag |= HCI_FLAG_CONN_COMPLETE; // Set connection complete flag
} else { } else {
hci_state = HCI_CHECK_DEVICE_SERVICE; hci_state = HCI_CHECK_DEVICE_SERVICE;
#ifdef DEBUG_USB_HOST #ifdef DEBUG_USB_HOST
@ -496,9 +496,9 @@ void BTD::HCI_event_task() {
break; break;
case EV_DISCONNECT_COMPLETE: case EV_DISCONNECT_COMPLETE:
if (!hcibuf[2]) { // check if disconnected OK if (!hcibuf[2]) { // Check if disconnected OK
hci_event_flag |= HCI_FLAG_DISCONN_COMPLETE; // set disconnect command complete flag hci_event_flag |= HCI_FLAG_DISCONN_COMPLETE; // Set disconnect command complete flag
hci_event_flag &= ~HCI_FLAG_CONN_COMPLETE; // clear connection complete flag hci_event_flag &= ~HCI_FLAG_CONN_COMPLETE; // Clear connection complete flag
} }
break; break;
@ -567,12 +567,12 @@ void BTD::HCI_event_task() {
#ifdef DEBUG_USB_HOST #ifdef DEBUG_USB_HOST
Notify(PSTR("\r\nPairing successful with Wiimote"), 0x80); Notify(PSTR("\r\nPairing successful with Wiimote"), 0x80);
#endif #endif
connectToWii = true; // Only send the ACL data to the Wii service connectToWii = true; // Used to indicate to the Wii service, that it should connect to this device
} else if (pairWithHIDDevice && !connectToHIDDevice) { } else if (pairWithHIDDevice && !connectToHIDDevice) {
#ifdef DEBUG_USB_HOST #ifdef DEBUG_USB_HOST
Notify(PSTR("\r\nPairing successful with HID device"), 0x80); Notify(PSTR("\r\nPairing successful with HID device"), 0x80);
#endif #endif
connectToHIDDevice = true; // Only send the ACL data to the Wii service connectToHIDDevice = true; // Used to indicate to the BTHID service, that it should connect to this device
} }
break; break;
/* We will just ignore the following events */ /* We will just ignore the following events */
@ -596,7 +596,7 @@ void BTD::HCI_event_task() {
} }
break; break;
#endif #endif
} // switch } // Switch
} }
#ifdef EXTRADEBUG #ifdef EXTRADEBUG
else { else {
@ -686,7 +686,7 @@ void BTD::HCI_task() {
break; break;
case HCI_CHECK_DEVICE_SERVICE: case HCI_CHECK_DEVICE_SERVICE:
if (pairWithHIDDevice || pairWithWii) { // Check if it should try to connect to a wiimote if (pairWithHIDDevice || pairWithWii) { // Check if it should try to connect to a Wiimote
#ifdef DEBUG_USB_HOST #ifdef DEBUG_USB_HOST
if (pairWithWii) if (pairWithWii)
Notify(PSTR("\r\nStarting inquiry\r\nPress 1 & 2 on the Wiimote\r\nOr press sync if you are using a Wii U Pro Controller"), 0x80); Notify(PSTR("\r\nStarting inquiry\r\nPress 1 & 2 on the Wiimote\r\nOr press sync if you are using a Wii U Pro Controller"), 0x80);
@ -750,7 +750,7 @@ void BTD::HCI_task() {
else else
Notify(PSTR("\r\nConnected to HID device"), 0x80); Notify(PSTR("\r\nConnected to HID device"), 0x80);
#endif #endif
hci_authentication_request(); // This will start the pairing with the wiimote hci_authentication_request(); // This will start the pairing with the Wiimote
hci_state = HCI_SCANNING_STATE; hci_state = HCI_SCANNING_STATE;
} else { } else {
#ifdef DEBUG_USB_HOST #ifdef DEBUG_USB_HOST
@ -860,18 +860,11 @@ void BTD::HCI_task() {
hci_event_flag = 0; // Clear all flags hci_event_flag = 0; // Clear all flags
// Reset all buffers // Reset all buffers
for (uint8_t i = 0; i < BULK_MAXPKTSIZE; i++) memset(hcibuf, 0, BULK_MAXPKTSIZE);
hcibuf[i] = 0; memset(l2capinbuf, 0, BULK_MAXPKTSIZE);
for (uint8_t i = 0; i < BULK_MAXPKTSIZE; i++)
l2capinbuf[i] = 0;
connectToWii = false; connectToWii = incomingWii = pairWithWii = false;
incomingWii = false; connectToHIDDevice = incomingHIDDevice = pairWithHIDDevice = false;
pairWithWii = false;
connectToHIDDevice = false;
incomingHIDDevice = false;
pairWithHIDDevice = false;
hci_state = HCI_SCANNING_STATE; hci_state = HCI_SCANNING_STATE;
} }