mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
commit
762d23069b
5 changed files with 27 additions and 8 deletions
|
|
@ -17,8 +17,8 @@ android {
|
|||
applicationId "com.geeksville.mesh"
|
||||
minSdkVersion 21 // The oldest emulator image I have tried is 22 (though 21 probably works)
|
||||
targetSdkVersion 29
|
||||
versionCode 10772 // format is Mmmss (where M is 1+the numeric major number
|
||||
versionName "0.7.72"
|
||||
versionCode 10775 // format is Mmmss (where M is 1+the numeric major number
|
||||
versionName "0.7.75"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
buildTypes {
|
||||
|
|
|
|||
|
|
@ -326,6 +326,7 @@ class BluetoothInterface(val service: RadioInterfaceService, val address: String
|
|||
ignoreException {
|
||||
s.closeConnection()
|
||||
}
|
||||
service.onDisconnect(false) // assume we will fail
|
||||
delay(1000) // Give some nasty time for buggy BLE stacks to shutdown (500ms was not enough)
|
||||
reconnectJob = null // Any new reconnect requests after this will be allowed to run
|
||||
warn("Attempting reconnect")
|
||||
|
|
@ -364,7 +365,7 @@ class BluetoothInterface(val service: RadioInterfaceService, val address: String
|
|||
isFirstSend = true
|
||||
|
||||
// Now tell clients they can (finally use the api)
|
||||
service.broadcastConnectionChanged(true, isPermanent = false)
|
||||
service.onConnect()
|
||||
|
||||
// Immediately broadcast any queued packets sitting on the device
|
||||
doReadFromRadio(true)
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ class RadioInterfaceService : Service(), Logging {
|
|||
startInterface() // If bluetooth just got turned on, try to restart our ble link
|
||||
}
|
||||
|
||||
fun broadcastConnectionChanged(isConnected: Boolean, isPermanent: Boolean) {
|
||||
private fun broadcastConnectionChanged(isConnected: Boolean, isPermanent: Boolean) {
|
||||
debug("Broadcasting connection=$isConnected")
|
||||
val intent = Intent(RADIO_CONNECTED_ACTION)
|
||||
intent.putExtra(EXTRA_CONNECTED, isConnected)
|
||||
|
|
@ -163,8 +163,20 @@ class RadioInterfaceService : Service(), Logging {
|
|||
)
|
||||
}
|
||||
|
||||
private var isConnected = false
|
||||
|
||||
fun onConnect() {
|
||||
if (!isConnected) {
|
||||
isConnected = true
|
||||
broadcastConnectionChanged(true, false)
|
||||
}
|
||||
}
|
||||
|
||||
fun onDisconnect(isPermanent: Boolean) {
|
||||
broadcastConnectionChanged(false, isPermanent)
|
||||
if (isConnected) {
|
||||
isConnected = false
|
||||
broadcastConnectionChanged(false, isPermanent)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,12 +6,14 @@ import android.content.Context
|
|||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.os.Build
|
||||
import android.os.DeadObjectException
|
||||
import android.os.Handler
|
||||
import com.geeksville.android.GeeksvilleApplication
|
||||
import com.geeksville.android.Logging
|
||||
import com.geeksville.concurrent.CallbackContinuation
|
||||
import com.geeksville.concurrent.Continuation
|
||||
import com.geeksville.concurrent.SyncContinuation
|
||||
import com.geeksville.util.Exceptions
|
||||
import com.geeksville.util.exceptionReporter
|
||||
import com.geeksville.util.ignoreException
|
||||
import kotlinx.coroutines.*
|
||||
|
|
@ -680,8 +682,12 @@ class SafeBluetooth(private val context: Context, private val device: BluetoothD
|
|||
info("Closing our GATT connection")
|
||||
gatt =
|
||||
null // Clear this first so the onConnectionChange callback can ignore while we are shutting down
|
||||
g.disconnect()
|
||||
g.close()
|
||||
try {
|
||||
g.disconnect()
|
||||
g.close()
|
||||
} catch (ex: DeadObjectException) {
|
||||
Exceptions.report(ex, "Dead object while closing GATT")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ class SerialInterface(private val service: RadioInterfaceService, val address: S
|
|||
io.writeAsync(wakeBytes)
|
||||
|
||||
// Now tell clients they can (finally use the api)
|
||||
service.broadcastConnectionChanged(true, isPermanent = false)
|
||||
service.onConnect()
|
||||
}
|
||||
} else {
|
||||
errormsg("Can't find device")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue