mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Store the timestamp of the last Bluetooth DATA input report received on the interrupt channel
This can be used detect if the connection to a Bluetooth device is lost fx if the battery runs out or it gets out of range
This commit is contained in:
parent
8758b2fc25
commit
b4bbfecd09
2 changed files with 13 additions and 0 deletions
|
@ -337,6 +337,8 @@ void BTHID::ACLData(uint8_t* l2capinbuf) {
|
|||
}
|
||||
#endif
|
||||
if(l2capinbuf[8] == 0xA1) { // HID BT DATA (0xA0) | Report Type (Input 0x01)
|
||||
lastBtDataInputIntMillis = (uint32_t)millis(); // Store the timestamp of the report
|
||||
|
||||
uint16_t length = ((uint16_t)l2capinbuf[5] << 8 | l2capinbuf[4]);
|
||||
ParseBTHIDData((uint8_t)(length - 1), &l2capinbuf[9]); // First byte will be the report ID
|
||||
|
||||
|
|
11
BTHID.h
11
BTHID.h
|
@ -93,6 +93,15 @@ public:
|
|||
pBtd->pairWithHID();
|
||||
};
|
||||
|
||||
/**
|
||||
* Used to get the millis() of the last Bluetooth DATA input report received on the interrupt channel.
|
||||
* This can be used detect if the connection to a Bluetooth device is lost fx if the battery runs out or if it gets out of range.
|
||||
* @return Timestamp in milliseconds of the last Bluetooth DATA input report received on the interrupt channel.
|
||||
*/
|
||||
uint32_t getLastMessageTime() {
|
||||
return lastBtDataInputIntMillis;
|
||||
};
|
||||
|
||||
protected:
|
||||
/** @name BluetoothService implementation */
|
||||
/**
|
||||
|
@ -173,5 +182,7 @@ private:
|
|||
uint8_t interrupt_dcid[2]; // L2CAP device CID for HID_Interrupt - Always 0x0071
|
||||
uint8_t sdp_dcid[2];
|
||||
uint8_t l2cap_state;
|
||||
|
||||
uint32_t lastBtDataInputIntMillis; // Variable used to store the millis value of the last Bluetooth DATA input report received on the interrupt channel
|
||||
};
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue