mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Can now print out class of device of incoming device
This commit is contained in:
parent
d20d360695
commit
02f98dd950
1 changed files with 16 additions and 7 deletions
21
BTD.cpp
21
BTD.cpp
|
@ -315,7 +315,7 @@ void BTD::HCI_event_task() {
|
||||||
/* check the event pipe*/
|
/* check the event pipe*/
|
||||||
uint16_t MAX_BUFFER_SIZE = BULK_MAXPKTSIZE; // Request more than 16 bytes anyway, the inTransfer routine will take care of this
|
uint16_t MAX_BUFFER_SIZE = BULK_MAXPKTSIZE; // Request more than 16 bytes anyway, the inTransfer routine will take care of this
|
||||||
uint8_t rcode = pUsb->inTransfer(bAddress, epInfo[ BTD_EVENT_PIPE ].epAddr, &MAX_BUFFER_SIZE, hcibuf); // input on endpoint 1
|
uint8_t rcode = pUsb->inTransfer(bAddress, epInfo[ BTD_EVENT_PIPE ].epAddr, &MAX_BUFFER_SIZE, hcibuf); // input on endpoint 1
|
||||||
if (!rcode || rcode == hrNAK) // Check for errors
|
if (!rcode) // Check for errors
|
||||||
{
|
{
|
||||||
switch (hcibuf[0]) //switch on event type
|
switch (hcibuf[0]) //switch on event type
|
||||||
{
|
{
|
||||||
|
@ -403,6 +403,7 @@ void BTD::HCI_event_task() {
|
||||||
#ifdef EXTRADEBUG
|
#ifdef EXTRADEBUG
|
||||||
else {
|
else {
|
||||||
Notify(PSTR("\r\nConnection Failed"), 0x80);
|
Notify(PSTR("\r\nConnection Failed"), 0x80);
|
||||||
|
hci_state = HCI_CHECK_WII_SERVICE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
@ -416,8 +417,8 @@ void BTD::HCI_event_task() {
|
||||||
|
|
||||||
case EV_REMOTE_NAME_COMPLETE:
|
case EV_REMOTE_NAME_COMPLETE:
|
||||||
if (!hcibuf[2]) { // check if reading is OK
|
if (!hcibuf[2]) { // check if reading is OK
|
||||||
for (uint8_t i = 0; i < 30; i++)
|
for (uint8_t i = 0; i < min(sizeof(remote_name),sizeof(hcibuf)-9); i++)
|
||||||
remote_name[i] = hcibuf[9 + i]; //store first 30 bytes
|
remote_name[i] = hcibuf[9 + i];
|
||||||
hci_event_flag |= HCI_FLAG_REMOTE_NAME_COMPLETE;
|
hci_event_flag |= HCI_FLAG_REMOTE_NAME_COMPLETE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -429,6 +430,14 @@ void BTD::HCI_event_task() {
|
||||||
disc_bdaddr[3] = hcibuf[5];
|
disc_bdaddr[3] = hcibuf[5];
|
||||||
disc_bdaddr[4] = hcibuf[6];
|
disc_bdaddr[4] = hcibuf[6];
|
||||||
disc_bdaddr[5] = hcibuf[7];
|
disc_bdaddr[5] = hcibuf[7];
|
||||||
|
#ifdef EXTRADEBUG
|
||||||
|
Notify(PSTR("\r\nClass of device: "), 0x80);
|
||||||
|
PrintHex<uint8_t > (hcibuf[10], 0x80);
|
||||||
|
Notify(PSTR(" "), 0x80);
|
||||||
|
PrintHex<uint8_t > (hcibuf[9], 0x80);
|
||||||
|
Notify(PSTR(" "), 0x80);
|
||||||
|
PrintHex<uint8_t > (hcibuf[8], 0x80);
|
||||||
|
#endif
|
||||||
hci_event_flag |= HCI_FLAG_INCOMING_REQUEST;
|
hci_event_flag |= HCI_FLAG_INCOMING_REQUEST;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -489,14 +498,14 @@ void BTD::HCI_event_task() {
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
} // switch
|
} // switch
|
||||||
HCI_task();
|
|
||||||
}
|
}
|
||||||
#ifdef EXTRADEBUG
|
#ifdef EXTRADEBUG
|
||||||
else {
|
else if (rcode != hrNAK) {
|
||||||
Notify(PSTR("\r\nHCI event error: "), 0x80);
|
Notify(PSTR("\r\nHCI event error: "), 0x80);
|
||||||
PrintHex<uint8_t > (rcode, 0x80);
|
PrintHex<uint8_t > (rcode, 0x80);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
HCI_task();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Poll Bluetooth and print result */
|
/* Poll Bluetooth and print result */
|
||||||
|
@ -666,6 +675,7 @@ void BTD::HCI_task() {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (strncmp((const char*)remote_name, "Nintendo", 8) == 0) {
|
if (strncmp((const char*)remote_name, "Nintendo", 8) == 0) {
|
||||||
|
incomingWii = true;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Notify(PSTR("\r\nWiimote is connecting"), 0x80);
|
Notify(PSTR("\r\nWiimote is connecting"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
|
@ -684,7 +694,6 @@ void BTD::HCI_task() {
|
||||||
motionPlusInside = false;
|
motionPlusInside = false;
|
||||||
wiiUProController = false;
|
wiiUProController = false;
|
||||||
}
|
}
|
||||||
incomingWii = true;
|
|
||||||
}
|
}
|
||||||
if (pairWithWii && motionPlusInside)
|
if (pairWithWii && motionPlusInside)
|
||||||
hci_state = HCI_CONNECT_WII_STATE;
|
hci_state = HCI_CONNECT_WII_STATE;
|
||||||
|
|
Loading…
Reference in a new issue