Fix reversed AirPods Max wear-detection (#116)

* Fix reversed AirPods Max wear-detection
Fixes #115

* Remove unnecessary test
This commit is contained in:
Matthias Urhahn
2023-03-13 13:47:32 +01:00
committed by GitHub
parent 708c7f38ec
commit 3b8ddc9f06
3 changed files with 3 additions and 15 deletions
@@ -34,7 +34,7 @@ data class AirPodsMax(
get() = rawFlags.isBitSet(0)
override val isBeingWorn: Boolean
get() = !rawStatus.isBitSet(5)
get() = rawStatus.isBitSet(5)
class Factory @Inject constructor() : SingleApplePodsFactory(TAG) {
@@ -1,6 +1,5 @@
package eu.darken.capod.pods.core.apple
import eu.darken.capod.pods.core.apple.airpods.AirPodsMax
import io.kotest.matchers.shouldBe
import kotlinx.coroutines.test.runTest
import org.junit.jupiter.api.Test
@@ -21,15 +20,4 @@ class SingleApplePodsTest : BaseAirPodsTest() {
rawSuffix shouldBe 0x40.toUByte()
}
}
@Test
fun `test values based on AirPodMax`() = runTest {
create<AirPodsMax>("07 19 01 0A 20 02 05 80 04 0F 44 A7 60 9B F8 3C FD B1 D8 1C 61 EA 82 60 A3 2C 4E") {
batteryHeadsetPercent shouldBe 0.5f
isHeadsetBeingCharged shouldBe false
isBeingWorn shouldBe true
}
}
}
@@ -81,13 +81,13 @@ class AirPodsMaxTest : BaseAirPodsTest() {
rawStatus shouldBe 0x03.toUByte()
rawStatus.isBitSet(5) shouldBe false
isBeingWorn shouldBe true
isBeingWorn shouldBe false
}
create<AirPodsMax>("07 19 01 0A 20 23 07 80 03 03 65 1F 28 32 D0 D9 71 43 00 9A 40 E7 6B EA 6C 2C FB") {
rawStatus shouldBe 0x23.toUByte()
rawStatus.isBitSet(5) shouldBe true
isBeingWorn shouldBe false
isBeingWorn shouldBe true
}
}
}