mirror of
https://github.com/d4rken-org/capod.git
synced 2026-09-16 11:16:12 -04:00
Boost signal quality rating by up to 25% depending on how long they have been tracked.
This commit is contained in:
@@ -6,6 +6,9 @@ import com.squareup.moshi.Json
|
|||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
||||||
import eu.darken.capod.common.R
|
import eu.darken.capod.common.R
|
||||||
import eu.darken.capod.common.bluetooth.BleScanResult
|
import eu.darken.capod.common.bluetooth.BleScanResult
|
||||||
|
import eu.darken.capod.common.debug.logging.Logging.Priority.VERBOSE
|
||||||
|
import eu.darken.capod.common.debug.logging.log
|
||||||
|
import java.time.Duration
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
@@ -40,9 +43,10 @@ interface PodDevice {
|
|||||||
* The range of the RSSI is device specific (ROMs).
|
* The range of the RSSI is device specific (ROMs).
|
||||||
*/
|
*/
|
||||||
val sqRssi = ((100 - abs(rssi)) / 100f)
|
val sqRssi = ((100 - abs(rssi)) / 100f)
|
||||||
//log("#####", Logging.Priority.VERBOSE) { "Signal Quality ($address): rssi=$sqRssi, reliability=$reliability" }
|
val sqReliability = max(BASE_CONFIDENCE, reliability)
|
||||||
val sqConfidence = max(BASE_CONFIDENCE, reliability)
|
val sqAge = (Duration.between(seenFirstAt, Instant.now()).toMinutes().coerceAtMost(60) / 60f) * 0.25f
|
||||||
return (sqRssi + sqConfidence) / 2f
|
log(VERBOSE) { "Signal Quality ($address): rssi=$sqRssi, reliability=$reliability, age=$sqAge" }
|
||||||
|
return (sqRssi + sqReliability + sqAge) / 2f
|
||||||
}
|
}
|
||||||
|
|
||||||
val rawData: Map<Int, ByteArray>
|
val rawData: Map<Int, ByteArray>
|
||||||
|
|||||||
Reference in New Issue
Block a user