Add support for AirPods (Gen 4 with ANC)

Closes #226
This commit is contained in:
darken
2024-09-23 13:33:12 +02:00
parent 42f2f5bfee
commit 21b6cfc013
4 changed files with 122 additions and 0 deletions
@@ -0,0 +1,46 @@
package eu.darken.capod.pods.core.apple.airpods
import eu.darken.capod.pods.core.PodDevice
import eu.darken.capod.pods.core.apple.BaseAirPodsTest
import eu.darken.capod.pods.core.apple.DualApplePods
import eu.darken.capod.pods.core.apple.HasAppleColor
import io.kotest.matchers.shouldBe
import kotlinx.coroutines.test.runTest
import org.junit.jupiter.api.Test
class AirPodsGen4AncTest : BaseAirPodsTest() {
@Test
fun `AirPods Gen4 with ANC via log from #226`() = runTest {
create<AirPodsGen4Anc>("07 19 01 1B 20 0B 9A 8F 10 00 04 43 DF EC 1D D3 F1 C3 F4 A1 9B 29 26 B9 E7 3A A0") {
rawPrefix shouldBe 0x01.toUByte()
rawDeviceModel shouldBe 0x1B20.toUShort()
rawStatus shouldBe 0x0b.toUByte()
rawPodsBattery shouldBe 0x9A.toUByte()
rawFlags shouldBe 0x8.toUShort()
rawCaseBattery shouldBe 0xF.toUShort()
rawCaseLidState shouldBe 0x10.toUByte()
rawDeviceColor shouldBe 0x00.toUByte()
rawSuffix shouldBe 0x04.toUByte()
batteryLeftPodPercent shouldBe 0.9f
batteryRightPodPercent shouldBe 1.0f
isCaseCharging shouldBe false
isLeftPodCharging shouldBe false
isRightPodCharging shouldBe false
isLeftPodInEar shouldBe true
isRightPodInEar shouldBe true
batteryCasePercent shouldBe null
caseLidState shouldBe DualApplePods.LidState.UNKNOWN
state shouldBe HasStateDetectionAirPods.ConnectionState.IDLE
podStyle.identifier shouldBe HasAppleColor.DeviceColor.WHITE.name
model shouldBe PodDevice.Model.AIRPODS_GEN4_ANC
}
}
}