EN: Correctly average rssi on database entry update

Fixes #1230
This commit is contained in:
Marvin W 2020-10-17 15:09:17 +02:00
parent d3d04459d6
commit 139f7eaf17
No known key found for this signature in database
GPG Key ID: 072E9235DB996F2A
1 changed files with 1 additions and 1 deletions

View File

@ -129,7 +129,7 @@ class ExposureDatabase private constructor(private val context: Context) : SQLit
}
fun noteAdvertisement(rpi: ByteArray, aem: ByteArray, rssi: Int, timestamp: Long = Date().time) = writableDatabase.run {
val update = compileStatement("UPDATE $TABLE_ADVERTISEMENTS SET rssi = ((rssi * duration) + (? * (? - timestamp - duration)) / (? - timestamp)), duration = (? - timestamp) WHERE rpi = ? AND timestamp > ? AND timestamp < ?").run {
val update = compileStatement("UPDATE $TABLE_ADVERTISEMENTS SET rssi = ((rssi * duration) + (? * (? - timestamp - duration))) / (? - timestamp), duration = (? - timestamp) WHERE rpi = ? AND timestamp > ? AND timestamp < ?").run {
bindLong(1, rssi.toLong())
bindLong(2, timestamp)
bindLong(3, timestamp)