void BTD::hci_write_scan_disable() { hcibuf[0] = 0x1A; // HCI OCF = 1A hcibuf[1] = 0x03 << 2; // HCI OGF = 3 hcibuf[2] = 0x01; // parameter length = 1 hcibuf[3] = 0x00; // Inquiry Scan disabled. Page Scan disabled. HCI_Command(hcibuf, 4); }
void BTD::hci_inquiry_cancel() { hcibuf[0] = 0x02; hcibuf[1] = 0x01 << 2; // HCI OGF = 1 hcibuf[2] = 0x0; // Parameter Total Length = 0 HCI_Command(hcibuf, 3); }
void BTD::hci_reset() { hci_event_flag = 0; // Clear all the flags hcibuf[0] = 0x03; // HCI OCF = 3 hcibuf[1] = 0x03 << 2; // HCI OGF = 3 hcibuf[2] = 0x00; HCI_Command(hcibuf, 3); }
void BTD::hci_pin_code_request_reply() { hcibuf[0] = 0x0D; // HCI OCF = 0D hcibuf[1] = 0x01 << 2; // HCI OGF = 1 hcibuf[2] = 0x17; // parameter length 23 hcibuf[3] = disc_bdaddr[0]; // 6 octet bdaddr hcibuf[4] = disc_bdaddr[1]; hcibuf[5] = disc_bdaddr[2]; hcibuf[6] = disc_bdaddr[3]; hcibuf[7] = disc_bdaddr[4]; hcibuf[8] = disc_bdaddr[5]; if(pairWithWii) { hcibuf[9] = 6; // Pin length is the length of the Bluetooth address if(wiiUProController) { #ifdef DEBUG_USB_HOST Notify(PSTR("\r\nParing with Wii U Pro Controller"), 0x80); #endif for(uint8_t i = 0; i < 6; i++) hcibuf[10 + i] = my_bdaddr[i]; // The pin is the Bluetooth dongles Bluetooth address backwards } else { for(uint8_t i = 0; i < 6; i++) hcibuf[10 + i] = disc_bdaddr[i]; // The pin is the Wiimote's Bluetooth address backwards } for(uint8_t i = 16; i < 26; i++) hcibuf[i] = 0x00; // The rest should be 0 } else { hcibuf[9] = strlen(btdPin); // Length of pin uint8_t i; for(i = 0; i < strlen(btdPin); i++) // The maximum size of the pin is 16 hcibuf[i + 10] = btdPin[i]; for(; i < 16; i++) hcibuf[i + 10] = 0x00; // The rest should be 0 } HCI_Command(hcibuf, 26); }
void BTD::hci_read_local_version_information() { hci_clear_flag(HCI_FLAG_READ_VERSION); hcibuf[0] = 0x01; // HCI OCF = 1 hcibuf[1] = 0x04 << 2; // HCI OGF = 4 hcibuf[2] = 0x00; HCI_Command(hcibuf, 3); }
void BTD::hci_read_bdaddr() { hci_clear_flag(HCI_FLAG_READ_BDADDR); hcibuf[0] = 0x09; // HCI OCF = 9 hcibuf[1] = 0x04 << 2; // HCI OGF = 4 hcibuf[2] = 0x00; HCI_Command(hcibuf, 3); }
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[1] = 0x03 << 2; // HCI OGF = 3 hcibuf[2] = 0x03; // parameter length = 3 hcibuf[3] = 0x04; // Robot hcibuf[4] = 0x08; // Toy hcibuf[5] = 0x00; HCI_Command(hcibuf, 6); }
void BTD::hci_authentication_request() { hcibuf[0] = 0x11; // HCI OCF = 11 hcibuf[1] = 0x01 << 2; // HCI OGF = 1 hcibuf[2] = 0x02; // parameter length = 2 hcibuf[3] = (uint8_t)(hci_handle & 0xFF);//connection handle - low byte hcibuf[4] = (uint8_t)((hci_handle >> 8) & 0x0F);//connection handle - high byte HCI_Command(hcibuf, 5); }
void BTD::hci_set_local_name(const char* name) { hcibuf[0] = 0x13; // HCI OCF = 13 hcibuf[1] = 0x03 << 2; // HCI OGF = 3 hcibuf[2] = strlen(name)+1; // parameter length = the length of the string + end byte uint8_t i; for(i = 0; i < strlen(name); i++) hcibuf[i+3] = name[i]; hcibuf[i+3] = 0x00; // End of string HCI_Command(hcibuf, 4+strlen(name)); }
void BTD::hci_write_scan_enable() { hci_event_flag &= ~HCI_FLAG_INCOMING_REQUEST; hcibuf[0] = 0x1A; // HCI OCF = 1A hcibuf[1] = 0x03 << 2; // HCI OGF = 3 hcibuf[2] = 0x01; // parameter length = 1 if(btdName != NULL) hcibuf[3] = 0x03; // Inquiry Scan enabled. Page Scan enabled. else hcibuf[3] = 0x02; // Inquiry Scan disabled. Page Scan enabled. HCI_Command(hcibuf, 4); }
void BTD::hci_disconnect(uint16_t handle) { // This is called by the different services hci_event_flag &= ~HCI_FLAG_DISCONN_COMPLETE; hcibuf[0] = 0x06; // HCI OCF = 6 hcibuf[1] = 0x01 << 2; // HCI OGF = 1 hcibuf[2] = 0x03; // parameter length = 3 hcibuf[3] = (uint8_t)(handle & 0xFF);//connection handle - low byte hcibuf[4] = (uint8_t)((handle >> 8) & 0x0F);//connection handle - high byte hcibuf[5] = 0x13; // reason HCI_Command(hcibuf, 6); }
void BTD::hci_inquiry() { hci_event_flag &= ~HCI_FLAG_WII_FOUND; hcibuf[0] = 0x01; hcibuf[1] = 0x01 << 2; // HCI OGF = 1 hcibuf[2] = 0x05; // Parameter Total Length = 5 hcibuf[3] = 0x33; // LAP: Genera/Unlimited Inquiry Access Code (GIAC = 0x9E8B33) - see https://www.bluetooth.org/Technical/AssignedNumbers/baseband.htm hcibuf[4] = 0x8B; hcibuf[5] = 0x9E; hcibuf[6] = 0x30; // Inquiry time = 61.44 sec (maximum) hcibuf[7] = 0x0A; // 10 number of responses HCI_Command(hcibuf, 8); }
void BTD::hci_link_key_request_negative_reply() { hcibuf[0] = 0x0C; // HCI OCF = 0C hcibuf[1] = 0x01 << 2; // HCI OGF = 1 hcibuf[2] = 0x06; // parameter length 6 hcibuf[3] = disc_bdaddr[0]; // 6 octet bdaddr hcibuf[4] = disc_bdaddr[1]; hcibuf[5] = disc_bdaddr[2]; hcibuf[6] = disc_bdaddr[3]; hcibuf[7] = disc_bdaddr[4]; hcibuf[8] = disc_bdaddr[5]; HCI_Command(hcibuf, 9); }
void BTD::hci_accept_connection() { hci_event_flag &= ~HCI_FLAG_CONN_COMPLETE; hcibuf[0] = 0x09; // HCI OCF = 9 hcibuf[1] = 0x01 << 2; // HCI OGF = 1 hcibuf[2] = 0x07; // parameter length 7 hcibuf[3] = disc_bdaddr[0]; // 6 octet bdaddr hcibuf[4] = disc_bdaddr[1]; hcibuf[5] = disc_bdaddr[2]; hcibuf[6] = disc_bdaddr[3]; hcibuf[7] = disc_bdaddr[4]; hcibuf[8] = disc_bdaddr[5]; hcibuf[9] = 0x00; //switch role to master HCI_Command(hcibuf, 10); }
void BTD::hci_remote_name() { hci_event_flag &= ~HCI_FLAG_REMOTE_NAME_COMPLETE; hcibuf[0] = 0x19; // HCI OCF = 19 hcibuf[1] = 0x01 << 2; // HCI OGF = 1 hcibuf[2] = 0x0A; // parameter length = 10 hcibuf[3] = disc_bdaddr[0]; // 6 octet bdaddr hcibuf[4] = disc_bdaddr[1]; hcibuf[5] = disc_bdaddr[2]; hcibuf[6] = disc_bdaddr[3]; hcibuf[7] = disc_bdaddr[4]; hcibuf[8] = disc_bdaddr[5]; hcibuf[9] = 0x01; //Page Scan Repetition Mode hcibuf[10] = 0x00; //Reserved hcibuf[11] = 0x00; //Clock offset - low byte hcibuf[12] = 0x00; //Clock offset - high byte HCI_Command(hcibuf, 13); }
void BTD::hci_pin_code_request_reply(const char* key) { hcibuf[0] = 0x0D; // HCI OCF = 0D hcibuf[1] = 0x01 << 2; // HCI OGF = 1 hcibuf[2] = 0x17; // parameter length 23 hcibuf[3] = disc_bdaddr[0]; // 6 octet bdaddr hcibuf[4] = disc_bdaddr[1]; hcibuf[5] = disc_bdaddr[2]; hcibuf[6] = disc_bdaddr[3]; hcibuf[7] = disc_bdaddr[4]; hcibuf[8] = disc_bdaddr[5]; hcibuf[9] = strlen(key); // Length of key uint8_t i; for(i = 0; i < strlen(key); i++) // The maximum size of the key is 16 hcibuf[i+10] = key[i]; for(;i < 16; i++) hcibuf[i+10] = 0x00; // The rest should be 0 HCI_Command(hcibuf, 26); }
void BTD::hci_connect() { hci_event_flag &= ~(HCI_FLAG_CONN_COMPLETE | HCI_FLAG_CONNECT_EVENT); hcibuf[0] = 0x05; hcibuf[1] = 0x01 << 2; // HCI OGF = 1 hcibuf[2] = 0x0D; // parameter Total Length = 13 hcibuf[3] = disc_bdaddr[0]; // 6 octet bdaddr hcibuf[4] = disc_bdaddr[1]; hcibuf[5] = disc_bdaddr[2]; hcibuf[6] = disc_bdaddr[3]; hcibuf[7] = disc_bdaddr[4]; hcibuf[8] = disc_bdaddr[5]; hcibuf[9] = 0x18; // DM1 or DH1 may be used hcibuf[10] = 0xCC; // DM3, DH3, DM5, DH5 may be used hcibuf[11] = 0x01; // Page repetition mode R1 hcibuf[12] = 0x00; // Reserved hcibuf[13] = 0x00; // Clock offset hcibuf[14] = 0x00; // Invalid clock offset hcibuf[15] = 0x00; // Do not allow role switch HCI_Command(hcibuf, 16); }
void BTD::hci_read_local_version_information() { hcibuf[0] = 0x01; // HCI OCF = 1 hcibuf[1] = 0x04 << 2; // HCI OGF = 4 hcibuf[2] = 0x00; HCI_Command(hcibuf, 3); }
void BTD::hci_read_bdaddr() { hcibuf[0] = 0x09; // HCI OCF = 9 hcibuf[1] = 0x04 << 2; // HCI OGF = 4 hcibuf[2] = 0x00; HCI_Command(hcibuf, 3); }