diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 00000000..8a10375b --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,17 @@ + + + + \ No newline at end of file diff --git a/README.md b/README.md index c5e52b22..b211c014 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,10 @@ Once this project is public, I'll happily let collaborators have access to the c * To see analytics: https://console.firebase.google.com/u/0/project/meshutil/analytics/app/android:com.geeksville.mesh/overview * To see crash logs: https://console.firebase.google.com/u/0/project/meshutil/crashlytics/app/android:com.geeksville.mesh/issues?state=open&time=last-seven-days&type=crash -for verbose logging +for verbose logging: +```aidl adb shell setprop log.tag.FA VERBOSE -adb shell setprop log.tag.FA-SVC VERBOSE +``` + diff --git a/TODO.md b/TODO.md index 324e3312..8ad40ed2 100644 --- a/TODO.md +++ b/TODO.md @@ -2,6 +2,7 @@ * use android service from Signal * DONE handle failures in onCharWrite, instead of logAssert - because they can happen if device goes away +* explictly broadcast towards signal https://developer.android.com/guide/components/broadcasts * make test implementation of android service (doesn't use bluetooth) * clean up sw update code in device side * DONE add broadcasters for use by signal (node changes and packet received) diff --git a/app/src/main/java/com/geeksville/mesh/SyncBluetoothDevice.kt b/app/src/main/java/com/geeksville/mesh/SyncBluetoothDevice.kt index d5dbeca5..f5504b01 100644 --- a/app/src/main/java/com/geeksville/mesh/SyncBluetoothDevice.kt +++ b/app/src/main/java/com/geeksville/mesh/SyncBluetoothDevice.kt @@ -26,6 +26,9 @@ class SyncBluetoothDevice(private val context: Context, private val device: Blue private var pendingReadC: SyncContinuation? = null private var pendingConnect: SyncContinuation? = null + /// Timeout before we declare a bluetooth operation failed + private val timeoutMsec = 30 * 1000L + var state = BluetoothProfile.STATE_DISCONNECTED private val gattCallback = object : BluetoothGattCallback() { @@ -104,31 +107,31 @@ class SyncBluetoothDevice(private val context: Context, private val device: Blue lateinit var gatt: BluetoothGatt fun connect() = - suspend { cont -> + suspend(timeoutMsec) { cont -> pendingConnect = cont gatt = device.connectGatt(context, false, gattCallback)!! } fun discoverServices() = - suspend { cont -> + suspend(timeoutMsec) { cont -> pendingServiceDesc = cont logAssert(gatt.discoverServices()) } /// Returns the actual MTU size used - fun requestMtu(len: Int) = suspend { cont -> + fun requestMtu(len: Int) = suspend(timeoutMsec) { cont -> pendingMtu = cont logAssert(gatt.requestMtu(len)) } fun writeCharacteristic(c: BluetoothGattCharacteristic) = - suspend { cont -> + suspend(timeoutMsec) { cont -> pendingWriteC = cont logAssert(gatt.writeCharacteristic(c)) } fun readCharacteristic(c: BluetoothGattCharacteristic) = - suspend { cont -> + suspend(timeoutMsec) { cont -> pendingReadC = cont logAssert(gatt.readCharacteristic(c)) }