feat: auto-detect device preset from BLE name
VBT260400xy → FLAT, VBT260402xy → NEW_CASE2, VBT260403xy → NEW_CASE1 2025MEDIP → LEGACY_5CH Auto-called on BLE connect. Logged to debug. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -374,6 +374,9 @@ class BleManager private constructor(private val context: Context) {
|
||||
if (idx >= 0) discoveredDevices[idx] = discoveredDevices[idx].copy(isConnected = true, isConnecting = false)
|
||||
isConnected.value = true
|
||||
connectedDeviceName.value = try { gatt.device.name ?: "Unknown" } catch (_: Exception) { "Unknown" }
|
||||
// Auto-detect device preset from name
|
||||
com.example.medilightv2android.managers.PiezoHW.autoDetectPreset(connectedDeviceName.value)
|
||||
logd { "Device preset: ${com.example.medilightv2android.managers.PiezoHW.presetName} (from '${connectedDeviceName.value}')" }
|
||||
|
||||
// Save last connected device address
|
||||
try {
|
||||
|
||||
@@ -37,8 +37,24 @@ object PiezoHW {
|
||||
NEW_CASE2
|
||||
}
|
||||
|
||||
/** ★ 여기만 바꾸면 전체 적용 ★ */
|
||||
val activePreset: DevicePreset = DevicePreset.FLAT
|
||||
/** 현재 활성 preset — 기기 연결 시 자동 감지, 수동 변경도 가능 */
|
||||
var activePreset: DevicePreset = DevicePreset.FLAT
|
||||
|
||||
/**
|
||||
* BLE 기기 이름으로 preset 자동 감지.
|
||||
* VBT26040x0y: x=0 → FLAT, x=2 → NEW_CASE2, x=3 → NEW_CASE1
|
||||
*/
|
||||
fun autoDetectPreset(deviceName: String) {
|
||||
if (deviceName.startsWith("VBT2604") && deviceName.length >= 9) {
|
||||
when (deviceName[7]) {
|
||||
'0' -> activePreset = DevicePreset.FLAT
|
||||
'2' -> activePreset = DevicePreset.NEW_CASE2
|
||||
'3' -> activePreset = DevicePreset.NEW_CASE1
|
||||
}
|
||||
} else if (deviceName.startsWith("2025MEDIP")) {
|
||||
activePreset = DevicePreset.LEGACY_5CH
|
||||
}
|
||||
}
|
||||
|
||||
// BV용 수직 채널 (CH0~CH3)
|
||||
val sensorZMm: DoubleArray
|
||||
|
||||
Reference in New Issue
Block a user