mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
feat: create BLEDeviceListEntry class
This commit is contained in:
parent
d4c125b962
commit
effc450af8
2 changed files with 9 additions and 6 deletions
|
|
@ -114,6 +114,13 @@ class BTScanModel @Inject constructor(
|
|||
val isTCP: Boolean get() = prefix == 't'
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
class BLEDeviceListEntry(device: BluetoothDevice) : DeviceListEntry(
|
||||
device.name,
|
||||
"x${device.address}",
|
||||
device.bondState == BluetoothDevice.BOND_BONDED
|
||||
)
|
||||
|
||||
class USBDeviceListEntry(usbManager: UsbManager, val usb: UsbSerialDriver) : DeviceListEntry(
|
||||
usb.device.deviceName,
|
||||
SerialInterface.toInterfaceName(usb.device.deviceName),
|
||||
|
|
@ -332,7 +339,7 @@ class BTScanModel @Inject constructor(
|
|||
bluetoothRepository.getBondedDevices()
|
||||
?.filter { it.name != null && it.name.matches(Regex(BLE_NAME_PATTERN)) }
|
||||
?.forEach {
|
||||
addDevice(DeviceListEntry(it.name, "x${it.address}", true))
|
||||
addDevice(BLEDeviceListEntry(it))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -252,11 +252,7 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
|
|||
?.let { device ->
|
||||
scanModel.onSelected(
|
||||
myActivity,
|
||||
BTScanModel.DeviceListEntry(
|
||||
device.name,
|
||||
"x${device.address}",
|
||||
device.bondState == BluetoothDevice.BOND_BONDED
|
||||
)
|
||||
BTScanModel.BLEDeviceListEntry(device)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue