Skip to content

Commit 5efbfa7

Browse files
authored
Merge pull request #45 from tim-gromeyer/ear-detection-status-in.case
[Linux] Add "in case" as ear detection status
2 parents 321a3bd + 6cb29e2 commit 5efbfa7

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

linux/main.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,12 @@ public slots:
568568
notifyAndroidDevice();
569569
}
570570

571+
QString getEarStatus(char value)
572+
{
573+
return (value == 0x00) ? "In Ear" : (value == 0x01) ? "Out of Ear"
574+
: "In case";
575+
}
576+
571577
void parseData(const QByteArray &data) {
572578
LOG_DEBUG("Received: " << data.toHex());
573579
if (data.size() == 11 && data.startsWith(QByteArray::fromHex("0400040009000D"))) {
@@ -579,11 +585,10 @@ public slots:
579585
LOG_ERROR("Invalid noise control mode value received: " << mode);
580586
}
581587
} else if (data.size() == 8 && data.startsWith(QByteArray::fromHex("040004000600"))) {
582-
bool primaryInEar = data[6] == 0x00;
583-
bool secondaryInEar = data[7] == 0x00;
588+
char primary = data[6];
589+
char secondary = data[7];
584590
QString earDetectionStatus = QString("Primary: %1, Secondary: %2")
585-
.arg(primaryInEar ? "In Ear" : "Out of Ear")
586-
.arg(secondaryInEar ? "In Ear" : "Out of Ear");
591+
.arg(getEarStatus(primary), getEarStatus(secondary));
587592
LOG_INFO("Ear detection status: " << earDetectionStatus);
588593
emit earDetectionStatusChanged(earDetectionStatus);
589594
} else if (data.size() == 22 && data.startsWith(QByteArray::fromHex("040004000400"))) {

0 commit comments

Comments
 (0)