fix: simplify device name matching logic
This commit is contained in:
@@ -12,8 +12,8 @@ android {
|
||||
applicationId = "org.noxylva.lbjconsole"
|
||||
minSdk = 29
|
||||
targetSdk = 35
|
||||
versionCode = 6
|
||||
versionName = "0.0.6"
|
||||
versionCode = 7
|
||||
versionName = "0.0.7"
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
@@ -66,24 +66,7 @@ class BLEClient(private val context: Context) : BluetoothGattCallback() {
|
||||
deviceName != null && deviceName.equals(targetDeviceName, ignoreCase = true)
|
||||
}
|
||||
else -> {
|
||||
deviceName != null && (
|
||||
deviceName.contains("LBJ", ignoreCase = true) ||
|
||||
deviceName.contains("Receiver", ignoreCase = true) ||
|
||||
deviceName.contains("Train", ignoreCase = true) ||
|
||||
deviceName.contains("Console", ignoreCase = true) ||
|
||||
deviceName.contains("ESP", ignoreCase = true) ||
|
||||
deviceName.contains("Arduino", ignoreCase = true) ||
|
||||
deviceName.contains("BLE", ignoreCase = true) ||
|
||||
deviceName.contains("UART", ignoreCase = true) ||
|
||||
deviceName.contains("Serial", ignoreCase = true)
|
||||
) && !(
|
||||
deviceName.contains("Midea", ignoreCase = true) ||
|
||||
deviceName.contains("TV", ignoreCase = true) ||
|
||||
deviceName.contains("Phone", ignoreCase = true) ||
|
||||
deviceName.contains("Watch", ignoreCase = true) ||
|
||||
deviceName.contains("Headset", ignoreCase = true) ||
|
||||
deviceName.contains("Speaker", ignoreCase = true)
|
||||
)
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -639,10 +639,10 @@ class MainActivity : ComponentActivity() {
|
||||
|
||||
bleClient.setAutoReconnect(true)
|
||||
|
||||
val targetDeviceName = if (settingsDeviceName.isNotBlank() && settingsDeviceName != "LBJReceiver") {
|
||||
val targetDeviceName = if (settingsDeviceName.isNotBlank()) {
|
||||
settingsDeviceName
|
||||
} else {
|
||||
"LBJReceiver"
|
||||
null
|
||||
}
|
||||
|
||||
Log.d(TAG, "Auto scanning for target device: $targetDeviceName")
|
||||
@@ -680,7 +680,7 @@ class MainActivity : ComponentActivity() {
|
||||
isScanning = true
|
||||
foundDevices = emptyList()
|
||||
|
||||
val targetDeviceName = if (settingsDeviceName.isNotBlank() && settingsDeviceName != "LBJReceiver") {
|
||||
val targetDeviceName = if (settingsDeviceName.isNotBlank()) {
|
||||
settingsDeviceName
|
||||
} else {
|
||||
null
|
||||
|
||||
Reference in New Issue
Block a user