Merge pull request #66 from geeksville/dev

Dev
pull/69/head
Kevin Hester 2020-06-25 17:59:21 -07:00 zatwierdzone przez GitHub
commit 3017308aad
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
4 zmienionych plików z 36 dodań i 27 usunięć

Wyświetl plik

@ -1,7 +1,10 @@
# Remaining tasks before declaring 1.0
- disable software update button after update finishes
- first message sent is still doubled for some people
- Android frontend should refetch the android messages from backend service on Resume
- let users set arbitrary params in android
* add a low level settings screen (let user change any of the RadioConfig parameters)
* add play store link with https://developers.google.com/analytics/devguides/collection/android/v4/campaigns#google-play-url-builder and the play icon
Things for the betaish period.

Wyświetl plik

@ -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 10780 // format is Mmmss (where M is 1+the numeric major number
versionName "0.7.80"
versionCode 10781 // format is Mmmss (where M is 1+the numeric major number
versionName "0.7.81"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {

Wyświetl plik

@ -322,7 +322,8 @@ class BluetoothInterface(val service: RadioInterfaceService, val address: String
val s = safe
if (s != null) {
warn("Forcing disconnect and hopefully device will comeback (disabling forced refresh)")
hasForcedRefresh = true
hasForcedRefresh =
true // We've already tossed any old service caches, no need to do it again
ignoreException {
s.closeConnection()
}
@ -384,32 +385,36 @@ class BluetoothInterface(val service: RadioInterfaceService, val address: String
// This callback is invoked after we are connected
connRes.getOrThrow()
info("Connected to radio!")
if (needForceRefresh) { // Our ESP32 code doesn't properly generate "service changed" indications. Therefore we need to force a refresh on initial start
//needForceRefresh = false // In fact, because of tearing down BLE in sleep on the ESP32, our handle # assignments are not stable across sleep - so we much refetch every time
forceServiceRefresh()
}
service.serviceScope.handledLaunch {
info("Connected to radio!")
// we begin by setting our MTU size as high as it can go (if we can)
if (shouldSetMtu)
safe!!.asyncRequestMtu(512) { mtuRes ->
try {
mtuRes.getOrThrow() // FIXME - why sometimes is the result Unit!?!
debug("MTU change attempted")
// throw BLEException("Test MTU set failed")
doDiscoverServicesAndInit()
} catch (ex: BLEException) {
shouldSetMtu = false
scheduleReconnect(
"Giving up on setting MTUs, forcing disconnect $ex"
)
}
if (needForceRefresh) { // Our ESP32 code doesn't properly generate "service changed" indications. Therefore we need to force a refresh on initial start
//needForceRefresh = false // In fact, because of tearing down BLE in sleep on the ESP32, our handle # assignments are not stable across sleep - so we much refetch every time
forceServiceRefresh() // this article says android should not be caching, but it does on some phones: https://punchthrough.com/attribute-caching-in-ble-advantages-and-pitfalls/
delay(200) // From looking at the android C code it seems that we need to give some time for the refresh message to reach that worked _before_ we try to set mtu/get services
}
else
doDiscoverServicesAndInit()
// we begin by setting our MTU size as high as it can go (if we can)
if (shouldSetMtu)
safe!!.asyncRequestMtu(512) { mtuRes ->
try {
mtuRes.getOrThrow() // FIXME - why sometimes is the result Unit!?!
debug("MTU change attempted")
// throw BLEException("Test MTU set failed")
doDiscoverServicesAndInit()
} catch (ex: BLEException) {
shouldSetMtu = false
scheduleReconnect(
"Giving up on setting MTUs, forcing disconnect $ex"
)
}
}
else
doDiscoverServicesAndInit()
}
}

Wyświetl plik

@ -38,6 +38,7 @@ class SafeBluetooth(private val context: Context, private val device: BluetoothD
var timeoutMsec = 15 * 1000L
/// Users can access the GATT directly as needed
@Volatile
var gatt: BluetoothGatt? = null
@Volatile