sforkowany z mirror/meshtastic-android
				
			timeout slow bluetooth operations
							rodzic
							
								
									38119a61f6
								
							
						
					
					
						commit
						140c1561c3
					
				|  | @ -0,0 +1,17 @@ | ||||||
|  | <component name="InspectionProjectProfileManager"> | ||||||
|  |   <profile version="1.0"> | ||||||
|  |     <option name="myName" value="Project Default" /> | ||||||
|  |     <inspection_tool class="PreviewAnnotationInFunctionWithParameters" enabled="true" level="ERROR" enabled_by_default="true"> | ||||||
|  |       <option name="previewFile" value="true" /> | ||||||
|  |     </inspection_tool> | ||||||
|  |     <inspection_tool class="PreviewDimensionRespectsLimit" enabled="true" level="WARNING" enabled_by_default="true"> | ||||||
|  |       <option name="previewFile" value="true" /> | ||||||
|  |     </inspection_tool> | ||||||
|  |     <inspection_tool class="PreviewMustBeTopLevelFunction" enabled="true" level="ERROR" enabled_by_default="true"> | ||||||
|  |       <option name="previewFile" value="true" /> | ||||||
|  |     </inspection_tool> | ||||||
|  |     <inspection_tool class="PreviewNeedsComposableAnnotation" enabled="true" level="ERROR" enabled_by_default="true"> | ||||||
|  |       <option name="previewFile" value="true" /> | ||||||
|  |     </inspection_tool> | ||||||
|  |   </profile> | ||||||
|  | </component> | ||||||
|  | @ -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 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 | * 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 VERBOSE | ||||||
| adb shell setprop log.tag.FA-SVC VERBOSE | ``` | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										1
									
								
								TODO.md
								
								
								
								
							
							
						
						
									
										1
									
								
								TODO.md
								
								
								
								
							|  | @ -2,6 +2,7 @@ | ||||||
| 
 | 
 | ||||||
| * use android service from Signal | * use android service from Signal | ||||||
| * DONE handle failures in onCharWrite, instead of logAssert - because they can happen if device goes away | * 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) | * make test implementation of android service (doesn't use bluetooth) | ||||||
| * clean up sw update code in device side | * clean up sw update code in device side | ||||||
| * DONE add broadcasters for use by signal (node changes and packet received) | * DONE add broadcasters for use by signal (node changes and packet received) | ||||||
|  |  | ||||||
|  | @ -26,6 +26,9 @@ class SyncBluetoothDevice(private val context: Context, private val device: Blue | ||||||
|     private var pendingReadC: SyncContinuation<BluetoothGattCharacteristic>? = null |     private var pendingReadC: SyncContinuation<BluetoothGattCharacteristic>? = null | ||||||
|     private var pendingConnect: SyncContinuation<Unit>? = null |     private var pendingConnect: SyncContinuation<Unit>? = null | ||||||
| 
 | 
 | ||||||
|  |     /// Timeout before we declare a bluetooth operation failed | ||||||
|  |     private val timeoutMsec = 30 * 1000L | ||||||
|  | 
 | ||||||
|     var state = BluetoothProfile.STATE_DISCONNECTED |     var state = BluetoothProfile.STATE_DISCONNECTED | ||||||
| 
 | 
 | ||||||
|     private val gattCallback = object : BluetoothGattCallback() { |     private val gattCallback = object : BluetoothGattCallback() { | ||||||
|  | @ -104,31 +107,31 @@ class SyncBluetoothDevice(private val context: Context, private val device: Blue | ||||||
|     lateinit var gatt: BluetoothGatt |     lateinit var gatt: BluetoothGatt | ||||||
| 
 | 
 | ||||||
|     fun connect() = |     fun connect() = | ||||||
|         suspend<Unit> { cont -> |         suspend<Unit>(timeoutMsec) { cont -> | ||||||
|             pendingConnect = cont |             pendingConnect = cont | ||||||
|             gatt = device.connectGatt(context, false, gattCallback)!! |             gatt = device.connectGatt(context, false, gattCallback)!! | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|     fun discoverServices() = |     fun discoverServices() = | ||||||
|         suspend<Unit> { cont -> |         suspend<Unit>(timeoutMsec) { cont -> | ||||||
|             pendingServiceDesc = cont |             pendingServiceDesc = cont | ||||||
|             logAssert(gatt.discoverServices()) |             logAssert(gatt.discoverServices()) | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|     /// Returns the actual MTU size used |     /// Returns the actual MTU size used | ||||||
|     fun requestMtu(len: Int) = suspend<Int> { cont -> |     fun requestMtu(len: Int) = suspend<Int>(timeoutMsec) { cont -> | ||||||
|         pendingMtu = cont |         pendingMtu = cont | ||||||
|         logAssert(gatt.requestMtu(len)) |         logAssert(gatt.requestMtu(len)) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     fun writeCharacteristic(c: BluetoothGattCharacteristic) = |     fun writeCharacteristic(c: BluetoothGattCharacteristic) = | ||||||
|         suspend<Unit> { cont -> |         suspend<Unit>(timeoutMsec) { cont -> | ||||||
|             pendingWriteC = cont |             pendingWriteC = cont | ||||||
|             logAssert(gatt.writeCharacteristic(c)) |             logAssert(gatt.writeCharacteristic(c)) | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|     fun readCharacteristic(c: BluetoothGattCharacteristic) = |     fun readCharacteristic(c: BluetoothGattCharacteristic) = | ||||||
|         suspend<BluetoothGattCharacteristic> { cont -> |         suspend<BluetoothGattCharacteristic>(timeoutMsec) { cont -> | ||||||
|             pendingReadC = cont |             pendingReadC = cont | ||||||
|             logAssert(gatt.readCharacteristic(c)) |             logAssert(gatt.readCharacteristic(c)) | ||||||
|         } |         } | ||||||
|  |  | ||||||
		Ładowanie…
	
		Reference in New Issue
	
	 geeksville
						geeksville