From 9e40e6e3fd0e16a2ec1f1a3014b504115c85f1f9 Mon Sep 17 00:00:00 2001 From: Tim Gromeyer Date: Sat, 15 Mar 2025 11:21:11 +0100 Subject: [PATCH] Show more info --- linux/ble/blemanager.cpp | 8 ++++---- linux/ble/blescanner.cpp | 12 ++++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/linux/ble/blemanager.cpp b/linux/ble/blemanager.cpp index 25d6b92..9331f12 100644 --- a/linux/ble/blemanager.cpp +++ b/linux/ble/blemanager.cpp @@ -78,13 +78,13 @@ void BleManager::onDeviceDiscovered(const QBluetoothDeviceInfo &info) int rightNibble = areValuesFlipped ? podsBatteryByte & 0x0F : (podsBatteryByte >> 4) & 0x0F; deviceInfo.leftPodBattery = (leftNibble == 15) ? -1 : leftNibble * 10; deviceInfo.rightPodBattery = (rightNibble == 15) ? -1 : rightNibble * 10; - int caseNibble = (flagsAndCaseBattery >> 4) & 0x0F; + int caseNibble = (flagsAndCaseBattery >> 4) & 0x0F; // Extracts upper nibble deviceInfo.caseBattery = (caseNibble == 15) ? -1 : caseNibble * 10; // Parse charging statuses from flags (lower 4 bits of data[7]) - quint8 flags = flagsAndCaseBattery & 0x0F; - deviceInfo.leftCharging = areValuesFlipped ? (flags & 0x02) != 0 : (flags & 0x01) != 0; // Bit 1 or 0 - deviceInfo.rightCharging = areValuesFlipped ? (flags & 0x01) != 0 : (flags & 0x02) != 0; // Bit 0 or 1 + quint8 flags = flagsAndCaseBattery & 0x0F; // Extracts lower nibble + deviceInfo.leftCharging = areValuesFlipped ? (flags & 0x01) != 0 : (flags & 0x02) != 0; // + deviceInfo.rightCharging = areValuesFlipped ? (flags & 0x02) != 0 : (flags & 0x01) != 0; // deviceInfo.caseCharging = (flags & 0x04) != 0; // Keeping original bit 1 for consistency // Additional status flags from status byte (data[5]) diff --git a/linux/ble/blescanner.cpp b/linux/ble/blescanner.cpp index 5139ea9..5928ae3 100644 --- a/linux/ble/blescanner.cpp +++ b/linux/ble/blescanner.cpp @@ -285,21 +285,25 @@ void BleScanner::onDeviceSelected() .arg(statusBinary)); // Lid State enum handling + QString lidStateStr; + switch (device.lidState) { case DeviceInfo::LidState::OPEN: - lidStateLabel->setText("Open"); + lidStateStr.append("Open"); break; case DeviceInfo::LidState::CLOSED: - lidStateLabel->setText("Closed"); + lidStateStr.append("Closed"); break; case DeviceInfo::LidState::NOT_IN_CASE: - lidStateLabel->setText("Not in Case"); + lidStateStr.append("Not in Case"); break; case DeviceInfo::LidState::UNKNOWN: - lidStateLabel->setText("Unknown"); + lidStateStr.append("Unknown"); break; } + lidStateStr.append(" (0x" + QString::number(device.lidOpenCounter, 16).toUpper() + " = " + QString::number(device.lidOpenCounter) + ")"); + lidStateLabel->setText(lidStateStr); QString colorName = getColorName(device.deviceColor); colorLabel->setText(colorName + " (" + QString::number(device.deviceColor) + ")");