Skip to content

Commit f015cdb

Browse files
authored
Merge pull request #13 from TerraTroniq/main
Add receivedBatteryAt, reset received*At values when not connected
2 parents b5c049f + a315664 commit f015cdb

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/XboxSeriesXControllerESP32_asukiaaa.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ class Core {
203203

204204
void onLoop() {
205205
if (!isConnected()) {
206+
receivedNotificationAt = 0;
207+
receivedBatteryAt = 0;
206208
if (advDevice != nullptr) {
207209
auto connectionResult = connectToServer(advDevice);
208210
if (!connectionResult || !isConnected()) {
@@ -256,10 +258,12 @@ class Core {
256258
}
257259
unsigned long getReceiveNotificationAt() { return receivedNotificationAt; }
258260
uint8_t getCountFailedConnection() { return countFailedConnection; }
261+
unsigned long getReceiveBatteryAt() { return receivedBatteryAt; }
259262

260263
private:
261264
ConnectionState connectionState = ConnectionState::Scanning;
262265
unsigned long receivedNotificationAt = 0;
266+
unsigned long receivedBatteryAt = 0;
263267
uint32_t msScanTime = 4000; /** 0 = scan forever */
264268
uint8_t countFailedConnection = 0;
265269
uint8_t retryCountInOneConnection = 3;
@@ -513,6 +517,7 @@ class Core {
513517
} else {
514518
if (sUuid.equals(uuidServiceBattery)) {
515519
battery = pData[0];
520+
receivedBatteryAt = millis();
516521
#ifdef XBOX_SERIES_X_CONTROLLER_DEBUG_SERIAL
517522
XBOX_SERIES_X_CONTROLLER_DEBUG_SERIAL.println("battery notification");
518523
#endif

0 commit comments

Comments
 (0)