Show more info

This commit is contained in:
Tim Gromeyer
2025-03-15 11:21:11 +01:00
parent 5b5a62f156
commit 9e40e6e3fd
2 changed files with 12 additions and 8 deletions

View File

@@ -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])

View File

@@ -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) + ")");