diff --git a/BTD.cpp b/BTD.cpp index a1fa1841..d6ccc5b6 100755 --- a/BTD.cpp +++ b/BTD.cpp @@ -402,14 +402,10 @@ void BTD::HCI_event_task() { break; case EV_COMMAND_STATUS: - if (hcibuf[2]) { // show status on serial if not OK + if (hcibuf[2]) { // Show status on serial if not OK #ifdef DEBUG_USB_HOST Notify(PSTR("\r\nHCI Command Failed: "), 0x80); D_PrintHex (hcibuf[2], 0x80); - Notify(PSTR(" "), 0x80); - D_PrintHex (hcibuf[4], 0x80); - Notify(PSTR(" "), 0x80); - D_PrintHex (hcibuf[5], 0x80); #endif } break; @@ -467,13 +463,13 @@ void BTD::HCI_event_task() { if (!hcibuf[2]) { // check if connected OK 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 - } -#ifdef DEBUG_USB_HOST - else { - Notify(PSTR("\r\nConnection Failed"), 0x80); + } else { hci_state = HCI_CHECK_WII_SERVICE; - } +#ifdef DEBUG_USB_HOST + Notify(PSTR("\r\nConnection Failed: "), 0x80); + D_PrintHex (hcibuf[2], 0x80); #endif + } break; case EV_DISCONNECT_COMPLETE: @@ -1078,7 +1074,7 @@ void BTD::hci_disconnect(uint16_t handle) { // This is called by the different s } void BTD::hci_write_class_of_device() { // See http://bluetooth-pentest.narod.ru/software/bluetooth_class_of_device-service_generator.html - hcibuf[0] = 0x24; // HCI OCF = 3 + hcibuf[0] = 0x24; // HCI OCF = 24 hcibuf[1] = 0x03 << 2; // HCI OGF = 3 hcibuf[2] = 0x03; // parameter length = 3 hcibuf[3] = 0x04; // Robot @@ -1258,9 +1254,9 @@ void BTD::setBdaddr(uint8_t* bdaddr) { buf[1] = 0x00; for (uint8_t i = 0; i < 6; i++) - buf[i + 2] = bdaddr[5 - i]; // Copy into buffer, has to be written reversed + buf[i + 2] = bdaddr[5 - i]; // Copy into buffer, has to be written reversed, so it is MSB first - // bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0xF5), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data) + // bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0xF5), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data pUsb->ctrlReq(bAddress, epInfo[BTD_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, 0xF5, 0x03, 0x00, 8, 8, buf, NULL); } @@ -1276,6 +1272,6 @@ void BTD::setMoveBdaddr(uint8_t* bdaddr) { for (uint8_t i = 0; i < 6; i++) buf[i + 1] = bdaddr[i]; - // bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0x05), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data) + // bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0x05), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data pUsb->ctrlReq(bAddress, epInfo[BTD_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, 0x05, 0x03, 0x00, 11, 11, buf, NULL); } diff --git a/PS3BT.cpp b/PS3BT.cpp index 0638ef5b..7fb6b8b4 100644 --- a/PS3BT.cpp +++ b/PS3BT.cpp @@ -611,7 +611,7 @@ void PS3BT::setLedToggle(LED a) { HID_Command(HIDBuffer, HID_BUFFERSIZE); } -void PS3BT::enable_sixaxis() { //Command used to enable the Dualshock 3 and Navigation controller to send data via USB +void PS3BT::enable_sixaxis() { // Command used to enable the Dualshock 3 and Navigation controller to send data via Bluetooth uint8_t cmd_buf[6]; cmd_buf[0] = 0x53; // HID BT Set_report (0x50) | Report Type (Feature 0x03) cmd_buf[1] = 0xF4; // Report ID @@ -623,7 +623,7 @@ void PS3BT::enable_sixaxis() { //Command used to enable the Dualshock 3 and Navi HID_Command(cmd_buf, 6); } -//Playstation Move Controller commands +// Playstation Move Controller commands void PS3BT::HIDMove_Command(uint8_t* data, uint8_t nbytes) { if (millis() - timerHID <= 250)// Check if is has been less than 200ms since last command diff --git a/Wii.cpp b/Wii.cpp index 57be934e..2e8669db 100755 --- a/Wii.cpp +++ b/Wii.cpp @@ -473,11 +473,11 @@ void WII::ACLData(uint8_t* l2capinbuf) { pitchGyroSpeed = (double)gyroPitchRaw / ((double)gyroPitchZero / pitchGyroScale); /* The onboard gyro has two ranges for slow and fast mode */ - if (!(l2capinbuf[18] & 0x02)) // Check if fast more is used + if (!(l2capinbuf[18] & 0x02)) // Check if fast mode is used yawGyroSpeed *= 4.545; - if (!(l2capinbuf[18] & 0x01)) // Check if fast more is used + if (!(l2capinbuf[18] & 0x01)) // Check if fast mode is used pitchGyroSpeed *= 4.545; - if (!(l2capinbuf[19] & 0x02)) // Check if fast more is used + if (!(l2capinbuf[19] & 0x02)) // Check if fast mode is used rollGyroSpeed *= 4.545; compPitch = (0.93 * (compPitch + (pitchGyroSpeed * (double)(micros() - timer) / 1000000)))+(0.07 * getWiimotePitch()); // Use a complimentary filter to calculate the angle