mirror of
https://github.com/d4rken-org/capod.git
synced 2026-09-14 18:26:11 -04:00
Better logging of unknown devices.
This commit is contained in:
@@ -57,26 +57,27 @@ class AppleFactory @Inject constructor(
|
||||
|
||||
log(TAG, INFO) { "Decoding $scanResult" }
|
||||
|
||||
var factory = podFactories.firstOrNull { it.isResponsible(pm) }
|
||||
val factory = podFactories.firstOrNull { it.isResponsible(pm) }
|
||||
|
||||
if (factory == null) {
|
||||
if (scanResult.address != "6E:9E:D1:49:D2:6D") {
|
||||
Bugs.report(
|
||||
tag = TAG,
|
||||
message = "Unknown proximity message type",
|
||||
exception = IllegalArgumentException("Unknown ProximityMessage: $pm")
|
||||
)
|
||||
}
|
||||
factory = unknownAppleFactory
|
||||
}
|
||||
|
||||
return factory.create(
|
||||
val device = (factory ?: unknownAppleFactory).create(
|
||||
scanResult = scanResult,
|
||||
proximityMessage = pm,
|
||||
)
|
||||
|
||||
if (factory == null && !SILENCED_PMS.contains(device.rawDeviceModel) && scanResult.address != "6E:9E:D1:49:D2:6D") {
|
||||
SILENCED_PMS.add(device.rawDeviceModel)
|
||||
Bugs.report(
|
||||
tag = TAG,
|
||||
message = "Unknown proximity message type",
|
||||
exception = IllegalArgumentException("Unknown ProximityMessage: $pm")
|
||||
)
|
||||
}
|
||||
|
||||
return@withLock device
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val SILENCED_PMS = mutableSetOf<UShort>()
|
||||
private val TAG = logTag("Pod", "Apple", "Factory")
|
||||
}
|
||||
}
|
||||
@@ -32,15 +32,10 @@ object ProximityPairing {
|
||||
deviceColor = data[7]
|
||||
)
|
||||
|
||||
override fun toString(): String =
|
||||
"ProximityPairing.Message(type=$type, length=$length, data=${
|
||||
data.joinToString(separator = " ") {
|
||||
String.format(
|
||||
"%02X",
|
||||
it
|
||||
)
|
||||
}
|
||||
}"
|
||||
override fun toString(): String {
|
||||
val dataHex = data.joinToString(separator = " ") { String.format("%02X", it.toByte()) }
|
||||
return "ProximityPairing.Message(type=$type, length=$length, data=$dataHex)"
|
||||
}
|
||||
}
|
||||
|
||||
@Reusable
|
||||
|
||||
Reference in New Issue
Block a user