mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Added function, so one can connect to any Bluetooth device by setting the Bluetooth address as an argument
This commit is contained in:
parent
c58f93dd83
commit
bcc51279d9
2 changed files with 16 additions and 7 deletions
16
BTD.cpp
16
BTD.cpp
|
@ -969,16 +969,20 @@ void BTD::hci_inquiry_cancel() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void BTD::hci_connect() {
|
void BTD::hci_connect() {
|
||||||
|
hci_connect(disc_bdaddr); // Use last discovered device
|
||||||
|
}
|
||||||
|
|
||||||
|
void BTD::hci_connect(uint8_t *bdaddr) {
|
||||||
hci_event_flag &= ~(HCI_FLAG_CONN_COMPLETE | HCI_FLAG_CONNECT_EVENT);
|
hci_event_flag &= ~(HCI_FLAG_CONN_COMPLETE | HCI_FLAG_CONNECT_EVENT);
|
||||||
hcibuf[0] = 0x05;
|
hcibuf[0] = 0x05;
|
||||||
hcibuf[1] = 0x01 << 2; // HCI OGF = 1
|
hcibuf[1] = 0x01 << 2; // HCI OGF = 1
|
||||||
hcibuf[2] = 0x0D; // parameter Total Length = 13
|
hcibuf[2] = 0x0D; // parameter Total Length = 13
|
||||||
hcibuf[3] = disc_bdaddr[0]; // 6 octet bdaddr
|
hcibuf[3] = bdaddr[0]; // 6 octet bdaddr (LSB)
|
||||||
hcibuf[4] = disc_bdaddr[1];
|
hcibuf[4] = bdaddr[1];
|
||||||
hcibuf[5] = disc_bdaddr[2];
|
hcibuf[5] = bdaddr[2];
|
||||||
hcibuf[6] = disc_bdaddr[3];
|
hcibuf[6] = bdaddr[3];
|
||||||
hcibuf[7] = disc_bdaddr[4];
|
hcibuf[7] = bdaddr[4];
|
||||||
hcibuf[8] = disc_bdaddr[5];
|
hcibuf[8] = bdaddr[5];
|
||||||
hcibuf[9] = 0x18; // DM1 or DH1 may be used
|
hcibuf[9] = 0x18; // DM1 or DH1 may be used
|
||||||
hcibuf[10] = 0xCC; // DM3, DH3, DM5, DH5 may be used
|
hcibuf[10] = 0xCC; // DM3, DH3, DM5, DH5 may be used
|
||||||
hcibuf[11] = 0x01; // Page repetition mode R1
|
hcibuf[11] = 0x01; // Page repetition mode R1
|
||||||
|
|
7
BTD.h
7
BTD.h
|
@ -313,8 +313,13 @@ public:
|
||||||
void hci_inquiry();
|
void hci_inquiry();
|
||||||
/** Cancel a HCI inquiry. */
|
/** Cancel a HCI inquiry. */
|
||||||
void hci_inquiry_cancel();
|
void hci_inquiry_cancel();
|
||||||
/** Connect to a device. */
|
/** Connect to last device communicated with. */
|
||||||
void hci_connect();
|
void hci_connect();
|
||||||
|
/**
|
||||||
|
* Connect to device.
|
||||||
|
* @param bdaddr Bluetooth address of the device.
|
||||||
|
*/
|
||||||
|
void hci_connect(uint8_t *bdaddr);
|
||||||
/** Used to a set the class of the device. */
|
/** Used to a set the class of the device. */
|
||||||
void hci_write_class_of_device();
|
void hci_write_class_of_device();
|
||||||
/**@}*/
|
/**@}*/
|
||||||
|
|
Loading…
Reference in a new issue