Skip to content

Commit

Permalink
Adjust supported AirPods Max features. (#86)
Browse files Browse the repository at this point in the history
Remove state detection (was UNKNOWN when it should have been MUSIC).
Add PodStyle detection.
  • Loading branch information
d4rken authored Jan 30, 2023
1 parent 87a92fd commit 4198579
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import eu.darken.capod.common.isBitSet
import eu.darken.capod.pods.core.HasEarDetection
import eu.darken.capod.pods.core.PodDevice
import eu.darken.capod.pods.core.apple.ApplePods
import eu.darken.capod.pods.core.apple.HasAppleColor
import eu.darken.capod.pods.core.apple.SingleApplePods
import eu.darken.capod.pods.core.apple.SingleApplePodsFactory
import eu.darken.capod.pods.core.apple.protocol.ProximityPairing
Expand All @@ -21,7 +22,7 @@ data class AirPodsMax(
override val proximityMessage: ProximityPairing.Message,
override val confidence: Float = PodDevice.BASE_CONFIDENCE,
private val rssiAverage: Int? = null,
) : SingleApplePods, HasEarDetection, HasStateDetectionAirPods {
) : SingleApplePods, HasEarDetection, HasAppleColor {

override val model: PodDevice.Model = PodDevice.Model.AIRPODS_MAX

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ 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.HasAppleColor
import io.kotest.matchers.shouldBe
import kotlinx.coroutines.test.runTest
import org.junit.jupiter.api.Test
Expand Down Expand Up @@ -53,4 +54,27 @@ class AirPodsMaxTest : BaseAirPodsTest() {
isHeadphonesBeingWorn shouldBe true
}
}

@Test
fun `some dude at the gym`() = runTest {
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") {
rawPrefix shouldBe 0x01.toUByte()
rawDeviceModel shouldBe 0x0A20.toUShort()
rawStatus shouldBe 0x23.toUByte()
rawPodsBattery shouldBe 0x07.toUByte()
rawFlags shouldBe 0x8.toUShort()
rawCaseBattery shouldBe 0x0.toUShort()
rawCaseLidState shouldBe 0x03.toUByte()
rawDeviceColor shouldBe 0x03.toUByte()
rawSuffix shouldBe 0x65.toUByte()

batteryHeadsetPercent shouldBe 0.7f

isHeadsetBeingCharged shouldBe false

isHeadphonesBeingWorn shouldBe true

podStyle shouldBe HasAppleColor.DeviceColor.BLUE
}
}
}

0 comments on commit 4198579

Please sign in to comment.