mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
expand interface options beyond BLE
This commit is contained in:
parent
5fb2be0591
commit
841ea515ba
5 changed files with 127 additions and 168 deletions
|
|
@ -50,8 +50,13 @@ class BluetoothRepository @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
/** @return true for a valid Bluetooth address, false otherwise */
|
||||
fun isValid(bleAddress: String): Boolean {
|
||||
return BluetoothAdapter.checkBluetoothAddress(bleAddress)
|
||||
}
|
||||
|
||||
fun getRemoteDevice(address: String): BluetoothDevice? {
|
||||
return bluetoothAdapterLazy.get()?.getRemoteDevice(address)
|
||||
return bluetoothAdapterLazy.get()?.takeIf { isValid(address) }?.getRemoteDevice(address)
|
||||
}
|
||||
|
||||
fun getBluetoothLeScanner(): BluetoothLeScanner? {
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ class RadioInterfaceService @Inject constructor(
|
|||
bluetoothRepository.state.collect { state ->
|
||||
if (state.enabled) {
|
||||
startInterface()
|
||||
} else {
|
||||
} else if (radioIf is BluetoothInterface) {
|
||||
stopInterface()
|
||||
}
|
||||
}
|
||||
|
|
@ -281,7 +281,7 @@ class RadioInterfaceService @Inject constructor(
|
|||
|
||||
debug("Setting bonded device to ${address.anonymize}")
|
||||
|
||||
getPrefs(context).edit(commit = true) {
|
||||
getPrefs(context).edit {
|
||||
if (address == null)
|
||||
this.remove(DEVADDR_KEY)
|
||||
else
|
||||
|
|
|
|||
|
|
@ -59,9 +59,6 @@ class TCPInterface(service: RadioInterfaceService, private val address: String)
|
|||
}
|
||||
|
||||
override fun connect() {
|
||||
//here you must put your computer's IP address.
|
||||
//here you must put your computer's IP address.
|
||||
|
||||
// No need to keep a reference to this thread - it will exit when we close inStream
|
||||
thread(start = true, isDaemon = true, name = "TCP reader") {
|
||||
try {
|
||||
|
|
@ -90,6 +87,7 @@ class TCPInterface(service: RadioInterfaceService, private val address: String)
|
|||
} else
|
||||
readChar(c.toByte())
|
||||
} catch (ex: SocketTimeoutException) {
|
||||
errormsg("SocketTimeoutException in TCP reader: $ex")
|
||||
// Ignore and start another read
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue