1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-10-28 14:25:17 +01:00

Improve detection logic for QN and Renpho scales

The device discovery for QN and Renpho scales has been refined.
The QN scale detection now explicitly checks for specific QN service UUIDs (0xFFE0 or 0xFFF0) in addition to the device name starting with "QN-Scale".
The Renpho scale detection now ensures the device has standard weight service UUIDs (0x181D or 0x181B) and its name contains "renpho-scale", while also excluding devices that appear to be QN scales (i.e., devices with QN-specific UUIDs).
This commit is contained in:
oliexdev
2025-09-03 16:41:08 +02:00
parent fb2b560496
commit b2cf36ebfa
2 changed files with 21 additions and 21 deletions

View File

@@ -17,6 +17,7 @@
*/
package com.health.openscale.core.bluetooth.modern
import android.R.attr.name
import com.health.openscale.R
import com.health.openscale.core.bluetooth.data.ScaleMeasurement
import com.health.openscale.core.bluetooth.data.ScaleUser
@@ -73,24 +74,24 @@ class QNHandler : ScaleDeviceHandler() {
// ---- Capability discovery --------------------------------------------------
override fun supportFor(device: ScannedDeviceInfo): DeviceSupport? {
val uuids = device.serviceUuids
val uuids = device.serviceUuids.toSet()
val supports = device.name.startsWith("QN-Scale") && uuids.any { it == SVC_T1 || it == SVC_T2 }
if (!supports) return null
val hasQN = uuids.contains(uuid16(0xFFE0)) || uuids.contains(uuid16(0xFFF0))
// Remember a hint about which flavor we likely have
likelyUseType1 = uuids.contains(SVC_T1) && !uuids.contains(SVC_T2)
if (!hasQN) return null
if (!device.name.startsWith("QN-Scale")) return null
val capabilities = buildSet {
add(DeviceCapability.TIME_SYNC)
add(DeviceCapability.LIVE_WEIGHT_STREAM)
add(DeviceCapability.BODY_COMPOSITION) // derived via impedance
}
likelyUseType1 = uuids.contains(uuid16(0xFFE0)) && !uuids.contains(uuid16(0xFFF0))
val caps = setOf(
DeviceCapability.TIME_SYNC,
DeviceCapability.LIVE_WEIGHT_STREAM,
DeviceCapability.BODY_COMPOSITION
)
return DeviceSupport(
displayName = "QN Scale",
capabilities = capabilities,
implemented = capabilities,
capabilities = caps,
implemented = caps,
linkMode = LinkMode.CONNECT_GATT
)
}

View File

@@ -96,13 +96,14 @@ class RenphoHandler : ScaleDeviceHandler() {
* We keep this moderately strict to avoid grabbing unrelated scales.
*/
override fun supportFor(device: ScannedDeviceInfo): DeviceSupport? {
val name = device.name.lowercase(Locale.ROOT)
val nameLc = device.name.lowercase()
val svc = device.serviceUuids.toSet()
val looksRenpho =
name.contains("Renpho-Scale".lowercase()) ||
(svc.contains(SERV_WEIGHT_SCALE) && svc.contains(SERV_BODY_COMP))
val hasStdWeight = svc.contains(uuid16(0x181D)) || svc.contains(uuid16(0x181B))
val hasQN = svc.contains(uuid16(0xFFE0)) || svc.contains(uuid16(0xFFF0))
val looksRenphoByName = nameLc.contains("renpho-scale")
val looksRenpho = (hasStdWeight && looksRenphoByName) && !hasQN
if (!looksRenpho) return null
val caps = setOf(
@@ -110,12 +111,10 @@ class RenphoHandler : ScaleDeviceHandler() {
DeviceCapability.USER_SYNC,
DeviceCapability.BODY_COMPOSITION
)
val impl = setOf(
DeviceCapability.TIME_SYNC,
DeviceCapability.USER_SYNC,
DeviceCapability.USER_SYNC
)
return DeviceSupport(
displayName = "RENPHO ES-WBE28",
capabilities = caps,