Ver código fonte

Hopefully Mouse works now either bind or not bind

Was issues not detecting that ISR bind was asked for, also not special casing when we are doing a bind to know which message to send next....
main
Kurt Eckhardt 6 anos atrás
pai
commit
913e3e0f7c
1 arquivos alterados com 31 adições e 12 exclusões
  1. +31
    -12
      bluetooth.cpp

+ 31
- 12
bluetooth.cpp Ver arquivo

#include "USBHost_t36.h" // Read this header first for key info #include "USBHost_t36.h" // Read this header first for key info


#define print USBHost::print_ #define print USBHost::print_
#define println USBHost::println_

#define println USBHost::println_//#define DEBUG_BT
//#define DEBUG_BT //#define DEBUG_BT
//#define DEBUG_BT_VERBOSE
#define DEBUG_BT_VERBOSE


#ifndef DEBUG_BT #ifndef DEBUG_BT
#undef DEBUG_BT_VERBOSE #undef DEBUG_BT_VERBOSE




// Setup some states for the TX pipe where we need to chain messages // Setup some states for the TX pipe where we need to chain messages
enum {STATE_TX_SEND_CONNECT_INT=200, STATE_TX_SEND_CONECT_RSP_SUCCESS, STATE_TX_SEND_CONFIG_REQ};
enum {STATE_TX_SEND_CONNECT_INT=200, STATE_TX_SEND_CONECT_RSP_SUCCESS, STATE_TX_SEND_CONFIG_REQ, STATE_TX_SEND_CONECT_ISR_RSP_SUCCESS, STATE_TX_SEND_CONFIG_ISR_REQ};


// This is a list of all the drivers inherited from the BTHIDInput class. // This is a list of all the drivers inherited from the BTHIDInput class.
// Unlike the list of USBDriver (managed in enumeration.cpp), drivers stay // Unlike the list of USBDriver (managed in enumeration.cpp), drivers stay
device = dev; // yes this is normally done on return from this but should not hurt if we do it here. device = dev; // yes this is normally done on return from this but should not hurt if we do it here.
sendResetHCI(); sendResetHCI();
pending_control_ = PC_RESET; pending_control_ = PC_RESET;
pending_control_tx_ = 0; //


return true; return true;
} }
sendl2cap_ConfigRequest(device_connection_handle_, connection_rxid_, control_scid_); sendl2cap_ConfigRequest(device_connection_handle_, connection_rxid_, control_scid_);
pending_control_tx_ = 0; pending_control_tx_ = 0;
break; break;
case STATE_TX_SEND_CONECT_ISR_RSP_SUCCESS:
delay(1);
// Tell the device we are ready
sendl2cap_ConnectionResponse(device_connection_handle_, connection_rxid_++, interrupt_dcid_, interrupt_scid_, SUCCESSFUL);
pending_control_tx_ = STATE_TX_SEND_CONFIG_ISR_REQ;
break;
case STATE_TX_SEND_CONFIG_ISR_REQ:
delay(1);
sendl2cap_ConfigRequest(device_connection_handle_, connection_rxid_, interrupt_scid_);
pending_control_tx_ = 0;
break;
} }
} }




uint16_t psm = data[4]+((uint16_t)data[5] << 8); uint16_t psm = data[4]+((uint16_t)data[5] << 8);
uint16_t scid = data[6]+((uint16_t)data[7] << 8); uint16_t scid = data[6]+((uint16_t)data[7] << 8);
DBGPrintf(" L2CAP Connection Request: ID: %d, PSM: %x, SCID: %x\n", data[1], psm, scid);
connection_rxid_ = data[1];
DBGPrintf(" L2CAP Connection Request: ID: %d, PSM: %x, SCID: %x\n",connection_rxid_, psm, scid);


// Assuming not pair mode Send response like: // Assuming not pair mode Send response like:
// RXID Len LEN DCID DCID SCID SCID RES 0 0 0 // RXID Len LEN DCID DCID SCID SCID RES 0 0 0
// 0x03 0x02 0x08 0x00 0x70 0x00 0x43 0x00 0x01 0x00 0x00 0x00 // 0x03 0x02 0x08 0x00 0x70 0x00 0x43 0x00 0x01 0x00 0x00 0x00
control_scid_ = scid;
connection_rxid_ = data[1];
sendl2cap_ConnectionResponse(device_connection_handle_, connection_rxid_, control_dcid_, control_scid_, PENDING);
pending_control_tx_ = STATE_TX_SEND_CONECT_RSP_SUCCESS;
if (psm == HID_CTRL_PSM) {
control_scid_ = scid;
sendl2cap_ConnectionResponse(device_connection_handle_, connection_rxid_, control_dcid_, control_scid_, PENDING);
pending_control_tx_ = STATE_TX_SEND_CONECT_RSP_SUCCESS;
} else if (psm == HID_INTR_PSM) {
interrupt_scid_ = scid;
sendl2cap_ConnectionResponse(device_connection_handle_, connection_rxid_, interrupt_dcid_, interrupt_scid_, PENDING);
pending_control_tx_ = STATE_TX_SEND_CONECT_ISR_RSP_SUCCESS;

}
} }


// Process the l2cap_connection_response... // Process the l2cap_connection_response...
if (dcid == interrupt_dcid_) { if (dcid == interrupt_dcid_) {
interrupt_scid_ = scid; interrupt_scid_ = scid;
DBGPrintf(" Interrupt Response\n"); DBGPrintf(" Interrupt Response\n");
connection_rxid_++;
sendl2cap_ConfigRequest(device_connection_handle_, connection_rxid_, scid); sendl2cap_ConfigRequest(device_connection_handle_, connection_rxid_, scid);
} else if (dcid == control_dcid_) { } else if (dcid == control_dcid_) {
control_scid_ = scid; control_scid_ = scid;
// Set HID Boot mode // Set HID Boot mode
setHIDProtocol(HID_BOOT_PROTOCOL); // setHIDProtocol(HID_BOOT_PROTOCOL); //
//setHIDProtocol(HID_RPT_PROTOCOL); //HID_RPT_PROTOCOL //setHIDProtocol(HID_RPT_PROTOCOL); //HID_RPT_PROTOCOL
//if (do_pair_device_) {
// Tell system we will next need to setup connection for the interrupt
if (do_pair_device_)
pending_control_tx_ = STATE_TX_SEND_CONNECT_INT; pending_control_tx_ = STATE_TX_SEND_CONNECT_INT;
//}
else
pending_control_ = 0;
} else if (scid == interrupt_dcid_) { } else if (scid == interrupt_dcid_) {
// Enable SCan to page mode // Enable SCan to page mode
sendHCIWriteScanEnable(2); sendHCIWriteScanEnable(2);

Carregando…
Cancelar
Salvar