I have an app in Android-Kotlin that uses a toggle button. This app connects to other devices using the app so you could have two devices that have a toggle button. When the toggle button is pressed it will change the background color (simple). When one device presses the toggle button the setOnClickListener is triggered causing the background to change and the state of the toggle button to change as well. However, the other device notices that the other toggle button was pressed so it will change its background, but since the setOnClickListener was not actually called it does not change the state of the toggle button so it would remain in the on state while the other was in the off state.
I hav tried to programmatically change the state of the toggle button on the second device (The device that didnt actually have its toggle button pressed), but when i do
toggleButton.setChecked(true) or toggleButton.isChecked = true
my app crashes
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
this.toggleButton = findViewById(R.id.toggleButton)
this.toggleButton.setOnClickListener {
toggleLight(toggleButton.isChecked)
}
}
private fun toggleLight(isOff: Boolean) {
if(isOff) {
this.mLayout.setBackgroundColor(Color.BLACK)
this.toggleButton.isChecked = true
}
else
{
this.mLayout.setBackgroundColor(Color.WHITE)
this.toggleButton.isChecked = false
}
}
2022-07-27 21:56:14.020 5513-5513/? I/ditto.moodligh: Late-enabling -Xcheck:jni
2022-07-27 21:56:14.056 5513-5513/? D/ProcessState: Binder ioctl to enable oneway spam detection failed: Invalid argument
2022-07-27 21:56:14.084 5513-5513/live.ditto.moodlight W/re-initialized>: type=1400 audit(0.0:4432): avc: granted { execute } for path="/data/data/live.ditto.moodlight/code_cache/startup_agents/50cdcce7-agent.so" dev="dm-34" ino=43151 scontext=u:r:untrusted_app:s0:c161,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c161,c256,c512,c768 tclass=file app=live.ditto.moodlight
2022-07-27 21:56:14.089 5513-5513/live.ditto.moodlight V/studio.deploy: Startup agent attached to VM
2022-07-27 21:56:14.089 5513-5513/live.ditto.moodlight V/studio.deploy: No existing instrumentation found. Loading instrumentation from instruments-88564b4d.jar
2022-07-27 21:56:14.091 5513-5513/live.ditto.moodlight W/ditto.moodligh: DexFile /data/data/live.ditto.moodlight/code_cache/.studio/instruments-88564b4d.jar is in boot class path but is not in a known location
2022-07-27 21:56:14.093 5513-5513/live.ditto.moodlight V/studio.deploy: Applying transforms with cached classes
2022-07-27 21:56:14.103 5513-5513/live.ditto.moodlight W/ditto.moodligh: Redefining intrinsic method java.lang.Thread java.lang.Thread.currentThread(). This may cause the unexpected use of the original definition of java.lang.Thread java.lang.Thread.currentThread()in methods that have already been compiled.
2022-07-27 21:56:14.103 5513-5513/live.ditto.moodlight W/ditto.moodligh: Redefining intrinsic method boolean java.lang.Thread.interrupted(). This may cause the unexpected use of the original definition of boolean java.lang.Thread.interrupted()in methods that have already been compiled.
2022-07-27 21:56:14.107 5513-5513/live.ditto.moodlight D/CompatibilityChangeReporter: Compat change id reported: 171979766; UID 10161; state: ENABLED
2022-07-27 21:56:14.131 5513-5513/live.ditto.moodlight W/ditto.moodligh: ClassLoaderContext classpath size mismatch. expected=0, found=1 (PCL[] | PCL[/data/data/live.ditto.moodlight/code_cache/.overlay/base.apk/classes3.dex*4229793514])
2022-07-27 21:56:14.147 5513-5513/live.ditto.moodlight V/GraphicsEnvironment: ANGLE Developer option for 'live.ditto.moodlight' set to: 'default'
2022-07-27 21:56:14.148 5513-5513/live.ditto.moodlight V/GraphicsEnvironment: ANGLE GameManagerService for live.ditto.moodlight: false
2022-07-27 21:56:14.148 5513-5513/live.ditto.moodlight V/GraphicsEnvironment: Neither updatable production driver nor prerelease driver is supported.
2022-07-27 21:56:14.154 5513-5513/live.ditto.moodlight D/NetworkSecurityConfig: No Network Security Config specified, using platform default
2022-07-27 21:56:14.155 5513-5513/live.ditto.moodlight D/NetworkSecurityConfig: No Network Security Config specified, using platform default
2022-07-27 21:56:14.247 5513-5513/live.ditto.moodlight W/ditto.moodligh: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (unsupported, reflection, allowed)
2022-07-27 21:56:14.248 5513-5513/live.ditto.moodlight W/ditto.moodligh: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (unsupported, reflection, allowed)
2022-07-27 21:56:14.365 5513-5545/live.ditto.moodlight D/CompatibilityChangeReporter: Compat change id reported: 191844585; UID 10161; state: ENABLED
2022-07-27 21:56:15.451 5513-5513/live.ditto.moodlight D/BluetoothAdapter: isLeEnabled(): ON
2022-07-27 21:56:15.454 5513-5526/live.ditto.moodlight D/BluetoothLeScanner: onScannerRegistered() - status=0 scannerId=9 mScannerId=0
2022-07-27 21:56:15.458 5513-5513/live.ditto.moodlight D/BluetoothGattServer: registerCallback()
2022-07-27 21:56:15.459 5513-5513/live.ditto.moodlight D/BluetoothGattServer: registerCallback() - UUID=3eb33987-3169-4d97-aba1-d3a8e3d47394
2022-07-27 21:56:15.461 5513-5526/live.ditto.moodlight D/BluetoothGattServer: onServerRegistered() - status=0 serverIf=10
2022-07-27 21:56:15.462 5513-5513/live.ditto.moodlight D/BluetoothGattServer: addService() - service: 331dcaa1-3995-83e8-090a-63787dc81031
2022-07-27 21:56:15.465 5513-5526/live.ditto.moodlight D/BluetoothGattServer: onServiceAdded() - handle=40 uuid=331dcaa1-3995-83e8-090a-63787dc81031 status=0
2022-07-27 21:56:15.473 5513-5572/live.ditto.moodlight D/BluetoothAdapter: listenUsingInsecureL2capChannel: set assigned PSM to 140
2022-07-27 21:56:15.504 5513-5532/live.ditto.moodlight I/AdrenoGLES-0: QUALCOMM build : 781e7d0, I46ff5fc46f
Build Date : 12/01/20
OpenGL ES Shader Compiler Version: EV031.31.04.01
Local Branch : QPR1
Remote Branch :
Remote Branch :
Reconstruct Branch :
2022-07-27 21:56:15.504 5513-5532/live.ditto.moodlight I/AdrenoGLES-0: Build Config : C P 11.0.1 AArch64
2022-07-27 21:56:15.504 5513-5532/live.ditto.moodlight I/AdrenoGLES-0: Driver Path : /vendor/lib64/egl/libGLESv2_adreno.so
2022-07-27 21:56:15.509 5513-5532/live.ditto.moodlight I/AdrenoGLES-0: PFP: 0x016ee190, ME: 0x00000000
2022-07-27 21:56:15.512 5513-5532/live.ditto.moodlight W/AdrenoUtils: <ReadGpuID_from_sysfs:197>: Failed to open /sys/class/kgsl/kgsl-3d0/gpu_model
2022-07-27 21:56:15.512 5513-5532/live.ditto.moodlight W/AdrenoUtils: <ReadGpuID:221>: Failed to read chip ID from gpu_model. Fallback to use the GSL path
2022-07-27 21:56:15.513 5513-5532/live.ditto.moodlight D/hw-ProcessState: Binder ioctl to enable oneway spam detection failed: Invalid argument
2022-07-27 21:56:15.524 5513-5573/live.ditto.moodlight I/Gralloc4: mapper 4.x is not supported
2022-07-27 21:56:15.524 5513-5573/live.ditto.moodlight W/Gralloc3: mapper 3.x is not supported
2022-07-27 21:56:15.526 5513-5573/live.ditto.moodlight W/Gralloc4: allocator 4.x is not supported
2022-07-27 21:56:15.526 5513-5573/live.ditto.moodlight W/Gralloc3: allocator 3.x is not supported
2022-07-27 21:56:15.550 5513-5513/live.ditto.moodlight D/BluetoothAdapter: isLeEnabled(): ON
2022-07-27 21:56:15.551 5513-5513/live.ditto.moodlight D/BluetoothAdapter: isLeEnabled(): ON
2022-07-27 21:56:16.070 5513-5524/live.ditto.moodlight W/System: A resource failed to call close.
2022-07-27 21:56:18.240 5513-5513/live.ditto.moodlight D/BluetoothGatt: connect() - device: 4E:C6:4B:9C:88:45, auto: false
2022-07-27 21:56:18.240 5513-5513/live.ditto.moodlight D/BluetoothGatt: registerApp()
2022-07-27 21:56:18.240 5513-5513/live.ditto.moodlight D/BluetoothGatt: registerApp() - UUID=908f6917-e9d6-4660-8715-29931933209e
2022-07-27 21:56:18.245 5513-5528/live.ditto.moodlight D/BluetoothGatt: onClientRegistered() - status=0 clientIf=11
2022-07-27 21:56:20.208 5513-5526/live.ditto.moodlight D/BluetoothGatt: onClientConnectionState() - status=133 clientIf=11 device=4E:C6:4B:9C:88:45
2022-07-27 21:56:20.209 5513-5528/live.ditto.moodlight D/BluetoothGattServer: onServerConnectionState() - status=0 serverIf=10 device=4E:C6:4B:9C:88:45
2022-07-27 21:56:20.210 5513-5513/live.ditto.moodlight D/BluetoothGatt: close()
2022-07-27 21:56:20.211 5513-5513/live.ditto.moodlight D/BluetoothGatt: unregisterApp() - mClientIf=11
2022-07-27 21:56:22.209 5513-5561/live.ditto.moodlight A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 5561 (Thread-16), pid 5513 (ditto.moodlight)
when the first device presses the toggle button it calls toggleLight. There is another part of the code that also calls toggleLight for the device that did not have its toggleButton pressed.
Any reason why I can't programmatically change the state of the toggleButton?
UPDATE: it seems to crash whenever I try to change the properties of the toggle button. Tried changing toggleButton.text = "off", but this cause a crash as well.
Related
I am using a BLE reactive Flutter library to communicate between STM32WB and my Android phone app (Android 12). Multiple devices (STMs) can be connected to the app at the same time. If one of the devices timeouts, it goes over my disconnection procedure. That works well, but every now and then there is a bug, that some other STM also disconnects without even going over my disconnect functions. What could be the cause of that?
Library github:
https://github.com/PhilipsHue/flutter_reactive_ble#readme
Test case
In this test 3 STM devices were connected to the phone. I purposely timeouted 00:80:E1:26:D2:6D. After that 00:80:E1:26:E6:CC also disconnected itself, but not over my functions. The third device stayed connected and working as it should.
D/BluetoothGatt(27591): onPhyUpdate() - status=0 address=00:80:E1:26:D2:6D txPhy=2 rxPhy=2
// *** I turn off the power to one STM so it timeouts for testing (status 8 - Connection timeout)
D/BluetoothGatt(27591): onClientConnectionState() - status=8 clientIf=9 device=00:80:E1:26:D2:6D
D/BluetoothGatt(27591): setCharacteristicNotification() - uuid: 0000aa02-8e22-4541-9d4c-21edae82ed19 enable: false
D/BluetoothGatt(27591): close()
D/BluetoothGatt(27591): unregisterApp() - mClientIf=9
D/BluetoothGatt(27591): setCharacteristicNotification() - uuid: 0000ac02-8e22-4541-9d4c-21edae82ed19 enable: false
D/BluetoothGatt(27591): setCharacteristicNotification() - uuid: 0000ad02-8e22-4541-9d4c-21edae82ed19 enable: false
D/BluetoothGatt(27591): setCharacteristicNotification() - uuid: 0000ae02-8e22-4541-9d4c-21edae82ed19 enable: false
// *** My disconnection handling functions get called.
[log] Connecting widget: bt disconnected
[log] Battery provider: removed battery 00:80:E1:26:D2:6D
[log] Handling connection lost from: 00:80:E1:26:D2:6D
[log] Disconnecting device: 00:80:E1:26:D2:6D
// *** Procedure to disconnect the timeouted device completed.
D/BluetoothGatt(27591): setCharacteristicNotification() - uuid: 0000ad03-8e22-4541-9d4c-21edae82ed19 enable: false
D/BluetoothGatt(27591): setCharacteristicNotification() - uuid: 0000af02-8e22-4541-9d4c-21edae82ed19 enable: false
D/BluetoothGatt(27591): setCharacteristicNotification() - uuid: 0000ad04-8e22-4541-9d4c-21edae82ed19 enable: false
// *** All 7 streams of disconnected STM get canceled ok
// *** Randomly another device disconnects, but not over my disconnect procedure.
D/BluetoothGatt(27591): cancelOpen() - device: 00:80:E1:26:E6:CC
D/BluetoothGatt(27591): onClientConnectionState() - status=0 clientIf=11 device=00:80:E1:26:E6:CC
D/BluetoothGatt(27591): setCharacteristicNotification() - uuid: 0000aa02-8e22-4541-9d4c-21edae82ed19 enable: false
D/BluetoothGatt(27591): setCharacteristicNotification() - uuid: 0000ac02-8e22-4541-9d4c-21edae82ed19 enable: false
D/BluetoothGatt(27591): setCharacteristicNotification() - uuid: 0000ad02-8e22-4541-9d4c-21edae82ed19 enable: false
D/BluetoothGatt(27591): setCharacteristicNotification() - uuid: 0000ae02-8e22-4541-9d4c-21edae82ed19 enable: false
D/BluetoothGatt(27591): setCharacteristicNotification() - uuid: 0000ad03-8e22-4541-9d4c-21edae82ed19 enable: false
D/BluetoothGatt(27591): setCharacteristicNotification() - uuid: 0000af02-8e22-4541-9d4c-21edae82ed19 enable: false
D/BluetoothGatt(27591): setCharacteristicNotification() - uuid: 0000ad04-8e22-4541-9d4c-21edae82ed19 enable: false
// *** All its 7 streams get canceled.
D/BluetoothGatt(27591): onClientConnectionState() - status=0 clientIf=11 device=00:80:E1:26:E6:CC
// *** My third STM is still connected and working ok tho
Main BLE Reactive function that handles connection changes:
Future<void> handleBluetoothConnectionChanges(String deviceUuid) async {
QueuedDevices device = connectedDevices.where((element) => element.device.id == deviceUuid).first;
device.subscription = Provider.of<BleDeviceConnector>(context, listen: false).state.listen((event) async {
switch(event.connectionState){
case DeviceConnectionState.disconnected:
if(device.connectionState == DeviceConnectionState.disconnected || device.device.id != event.deviceId)
return;
Globals.gLogMessage("Connecting widget: bt disconnected", MessageType.DEBUG);
// Handles all UI changes etc. Nothing directly related to BLE connection.
await Provider.of<BatteriesModel>(context, listen: false).removeBattery(context, deviceUuid);
// Cancels connection and removes device
await handleConnectionLostOrTimeout(device);
break;
}
device.connectionState = event.connectionState;
})..onError((error){
Globals.gLogMessage("EXCEPTION - device connection error!: " + error.toString(), MessageType.ERROR_FATAL);
});
}
handleConnectionLostOrTimeout()
Future<void> handleConnectionLostOrTimeout(QueuedDevices device) async {
try {
Globals.gLogMessage("Handling connection lost from: " + device.device.id, MessageType.DEBUG);
await device.subscription?.cancel();
await Provider.of<BleDeviceConnector>(context, listen: false).disconnect(device.device.id);
connectedDevices.removeWhere((element) => element.device.id == device.device.id);
}
catch(exception) {
Globals.gLogMessage(exception.toString(), MessageType.ERROR_FATAL);
}
}
I am using here map sdk lite version to load map.
We have encountered 1 strange issue.
When we are connecting to WIFI with no internet, It is requesting to oauth2/token multiple times in background which result in hanging of UI.
Can you please suggest us a solution where we can stop this call in such scenario.
Or is it possible to execute it in background.
Below are logs:
2022-07-27 17:29:01.063 5605-5961/com.daimler.android.sixtythree.debug W/OLP: [WARN ] OLP - Request timed out, request_id=4, timeout=10, retry_count=0, url='https://account.api.here.com/oauth2/token'
2022-07-27 17:29:01.065 5605-5961/com.daimler.android.sixtythree.debug E/Authentication: [ERROR] Authentication - Failed to SignInClient: ApiError(ErrorCode: 3, Message: Network request timed out., HTTPStatusCode: -7)
2022-07-27 17:29:01.074 5605-6888/com.daimler.android.sixtythree.debug I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
2022-07-27 17:29:01.074 5605-6888/com.daimler.android.sixtythree.debug I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
2022-07-27 17:29:07.106 5605-6554/com.daimler.android.sixtythree.debug I/Logger63 -> i() -> Line: 83: toUINetworkDetails
2022-07-27 17:29:07.106 5605-6634/com.daimler.android.sixtythree.debug I/Logger63 -> i() -> Line: 83: toUINetworkDetails
2022-07-27 17:29:07.106 5605-6631/com.daimler.android.sixtythree.debug I/Logger63 -> i() -> Line: 83: toUINetworkDetails
2022-07-27 17:29:07.108 5605-6705/com.daimler.android.sixtythree.debug I/Logger63 -> i() -> Line: 83: toUINetworkDetails
2022-07-27 17:29:11.068 5605-5960/com.daimler.android.sixtythree.debug W/OLP: [WARN ] OLP - Request timed out, request_id=5, timeout=10, retry_count=0, url='https://account.api.here.com/oauth2/token'
2022-07-27 17:29:11.070 5605-5960/com.daimler.android.sixtythree.debug E/Authentication: [ERROR] Authentication - Failed to SignInClient: ApiError(ErrorCode: 3, Message: Network request timed out., HTTPStatusCode: -7)
2022-07-27 17:29:11.079 5605-6900/com
I'm working on an application connected to a BLE device, and I'm focused on the firmware update of the device (DFU). For that, I'm using the android lib created by Nordic and I'm trying to make it autonomous, so a user doesn't have to browse his files and pick the zip of the firmware update.
However, the DFU always stops at 30%, the app loses the bluetooth connection and I have to finish the update manually with an external app.
Is there anyone that has already made this kind of thing with DFU and can help me?
Here is a link to the lib's github: https://github.com/NordicSemiconductor/Android-DFU-Library
Here is the code I'm currently using, it's a standard DFU procedure with Nordic lib for Android.
val starter = DfuServiceInitiator(deviceMacAddress!!)
.setDeviceName(deviceName)
.setKeepBond(true)
starter.setUnsafeExperimentalButtonlessServiceInSecureDfuEnabled(true)
starter.setZip(uri)
val controller = starter.start(context!!, DfuService::class.java)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
DfuServiceInitiator.createDfuNotificationChannel(context!!)
}
Edit: Here are some logs that show what happens on runtime
2019-01-08 10:54:35.481 3394-3394/com.thingsaremoving.enovap E/DfuListener: onDeviceConnected
2019-01-08 10:54:35.481 3394-3394/com.thingsaremoving.enovap E/DfuListener: onDfuProcessStarting
2019-01-08 10:54:36.492 3394-3698/com.thingsaremoving.enovap D/BluetoothGatt: setCharacteristicNotification() - uuid: 8ec90003-f315-4f60-9fb8-838830daea50 enable: true
2019-01-08 10:54:41.741 3394-3406/com.thingsaremoving.enovap D/BluetoothGatt: onClientConnectionState() - status=8 clientIf=11 device=FE:E6:FD:B8:13:DE
2019-01-08 10:54:41.741 3394-3592/com.thingsaremoving.enovap D/BluetoothGatt: onClientConnectionState() - status=8 clientIf=12 device=FE:E6:FD:B8:13:DE
2019-01-08 10:54:41.743 3394-3698/com.thingsaremoving.enovap D/BluetoothGatt: close()
2019-01-08 10:54:41.743 3394-3698/com.thingsaremoving.enovap D/BluetoothGatt: unregisterApp() - mClientIf=12
2019-01-08 10:54:41.755 3394-3406/com.thingsaremoving.enovap D/BluetoothGatt: setCharacteristicNotification() - uuid: 23058a49-636d-82ab-d641-badd3648cc9a enable: false
2019-01-08 10:54:41.755 3394-3598/com.thingsaremoving.enovap D/BluetoothManager: getConnectionState()
2019-01-08 10:54:41.755 3394-3598/com.thingsaremoving.enovap D/BluetoothManager: getConnectedDevices
2019-01-08 10:54:41.756 3394-3698/com.thingsaremoving.enovap D/BluetoothAdapter: isLeEnabled(): ON
2019-01-08 10:54:41.757 3394-3406/com.thingsaremoving.enovap E/Companion: Charac change error Disconnected from FE:E6:FD:B8:13:DE with status 8 (GATT_INSUF_AUTHORIZATION)
2019-01-08 10:54:41.757 3394-3406/com.thingsaremoving.enovap E/BleManager: release()
2019-01-08 10:54:41.758 3394-3406/com.thingsaremoving.enovap I/Companion: onConnectionStateChanged : RxBleConnectionState{DISCONNECTED}
2019-01-08 10:54:41.758 3394-3406/com.thingsaremoving.enovap E/BleManager: release()
2019-01-08 10:54:41.759 3394-3406/com.thingsaremoving.enovap E/bleManager: error characteristic change : Disconnected from FE:E6:FD:B8:13:DE with status 8 (GATT_INSUF_AUTHORIZATION)
2019-01-08 10:54:41.761 3394-3598/com.thingsaremoving.enovap D/BluetoothGatt: close()
2019-01-08 10:54:41.761 3394-3598/com.thingsaremoving.enovap D/BluetoothGatt: unregisterApp() - mClientIf=11
2019-01-08 10:54:41.764 3394-3406/com.thingsaremoving.enovap D/BluetoothLeScanner: onScannerRegistered() - status=0 scannerId=12 mScannerId=0
2019-01-08 10:54:41.787 3394-3394/com.thingsaremoving.enovap E/ConnectionState: disconnected
2019-01-08 10:54:41.872 3394-3698/com.thingsaremoving.enovap D/BluetoothAdapter: isLeEnabled(): ON
2019-01-08 10:54:43.905 3394-3698/com.thingsaremoving.enovap D/BluetoothGatt: connect() - device: FE:E6:FD:B8:13:DF, auto: false
2019-01-08 10:54:43.906 3394-3698/com.thingsaremoving.enovap D/BluetoothGatt: registerApp()
2019-01-08 10:54:43.906 3394-3698/com.thingsaremoving.enovap D/BluetoothGatt: registerApp() - UUID=766e5e19-e1f9-48d3-a0a0-9c5eeba2b66a
2019-01-08 10:54:43.910 3394-3592/com.thingsaremoving.enovap D/BluetoothGatt: onClientRegistered() - status=0 clientIf=11
2019-01-08 10:54:44.059 3394-3406/com.thingsaremoving.enovap D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=11 device=FE:E6:FD:B8:13:DF
2019-01-08 10:54:44.060 3394-3406/com.thingsaremoving.enovap D/BluetoothGatt: discoverServices() - device: FE:E6:FD:B8:13:DF
2019-01-08 10:54:44.746 3394-3406/com.thingsaremoving.enovap D/BluetoothGatt: onConnectionUpdated() - Device=FE:E6:FD:B8:13:DF interval=24 latency=0 timeout=400 status=0
2019-01-08 10:54:45.045 3394-3406/com.thingsaremoving.enovap D/BluetoothGatt: onConnectionUpdated() - Device=FE:E6:FD:B8:13:DF interval=6 latency=0 timeout=500 status=0
2019-01-08 10:54:45.135 3394-3406/com.thingsaremoving.enovap D/BluetoothGatt: onSearchComplete() = Device=FE:E6:FD:B8:13:DF Status=0
2019-01-08 10:54:45.224 3394-3406/com.thingsaremoving.enovap D/BluetoothGatt: onConnectionUpdated() - Device=FE:E6:FD:B8:13:DF interval=24 latency=0 timeout=400 status=0
2019-01-08 10:54:45.825 3394-3406/com.thingsaremoving.enovap D/BluetoothGatt: onConnectionUpdated() - Device=FE:E6:FD:B8:13:DF interval=24 latency=0 timeout=400 status=0
2019-01-08 10:54:46.149 3394-3698/com.thingsaremoving.enovap D/BluetoothGatt: configureMTU() - device: FE:E6:FD:B8:13:DF mtu: 517
2019-01-08 10:54:46.244 3394-3406/com.thingsaremoving.enovap D/BluetoothGatt: onConfigureMTU() - Device=FE:E6:FD:B8:13:DF mtu=23 status=0
2019-01-08 10:54:46.246 3394-3698/com.thingsaremoving.enovap D/BluetoothGatt: setCharacteristicNotification() - uuid: 8ec90001-f315-4f60-9fb8-838830daea50 enable: true
2019-01-08 10:54:49.738 3394-3394/com.thingsaremoving.enovap E/timezone: time : 1.0
2019-01-08 10:54:49.738 3394-3394/com.thingsaremoving.enovap I/LocationUpdate: 2.2889202 : 48.8515689
2019-01-08 10:55:09.687 3394-3394/com.thingsaremoving.enovap E/timezone: time : 1.0
2019-01-08 10:55:09.687 3394-3394/com.thingsaremoving.enovap I/LocationUpdate: 2.2889202 : 48.8515689
2019-01-08 10:55:16.871 3394-3406/com.thingsaremoving.enovap E/DfuImpl: Characteristic write error: 133
2019-01-08 10:55:16.871 3394-3406/com.thingsaremoving.enovap D/BluetoothGatt: onClientConnectionState() - status=8 clientIf=11 device=FE:E6:FD:B8:13:DF
2019-01-08 10:55:16.873 3394-3698/com.thingsaremoving.enovap E/DfuBaseService: Unable to write Op Code 3 (error 133)
2019-01-08 10:55:16.874 3394-3698/com.thingsaremoving.enovap W/removing.enova: Accessing hidden method Landroid/bluetooth/BluetoothGatt;->refresh()Z (light greylist, reflection)
2019-01-08 10:55:16.875 3394-3698/com.thingsaremoving.enovap D/BluetoothGatt: refresh() - device: FE:E6:FD:B8:13:DF
2019-01-08 10:55:16.876 3394-3698/com.thingsaremoving.enovap D/BluetoothGatt: close()
2019-01-08 10:55:16.876 3394-3698/com.thingsaremoving.enovap D/BluetoothGatt: unregisterApp() - mClientIf=11
I have a problem when I try to use cheaper Android phones to communicate with our NordicSemi nRF52832 chip.
I can discover the peripheral and then connect, but when I device.discoverServices() the software pauses for about 10 seconds, and then disconnects with the output:
D/BluetoothGatt: connect() - device: CA:E7:8F:03:82:CE, auto: false
D/BluetoothGatt: registerApp() D/BluetoothGatt: registerApp() -
UUID=b05b54e9-bd20-423f-a6db-461775f954f0 D/BluetoothGatt:
onClientRegistered() - status=0 clientIf=7 D/BluetoothGatt:
onClientConnectionState() - status=0 clientIf=7
device=CA:E7:8F:03:82:CE D/BluetoothGatt: discoverServices() - device:
CA:E7:8F:03:82:CE D/BluetoothGatt: onSearchComplete() =
Device=CA:E7:8F:03:82:CE Status=129 D/BluetoothGatt:
onClientConnectionState() - status=22 clientIf=7
device=CA:E7:8F:03:82:CE D/BluetoothGatt: cancelOpen() - device:
CA:E7:8F:03:82:CE D/BluetoothGatt: close() D/BluetoothGatt:
unregisterApp() - mClientIf=7 D/BluetoothGatt: cancelOpen() - device:
CA:E7:8F:03:82:CE D/BluetoothGatt: close() D/BluetoothGatt:
unregisterApp() - mClientIf=0
With onServicesDiscovered status = 129
The phones are in this case: Samsung Galaxy J3 (J320FN) & Huawei P8lite (ALE-L21)
I'm using RxAndroidBle library for communicating with bluetooth device,
however recently i bumped into strange issue.
When reading one of the device characteristics i receive such error:
BleGattCharacteristicException{macAddress=60:CE:32:BA:9E:70,
status=6 (0x06 -> https://android.googlesource.com/platform/external/bluetooth/bluedroid/+/android-5.1.0_r1/stack/include/gatt_api.h),
bleGattOperationType=BleGattOperation{description='CHARACTERISTIC_READ'}}
I see that the description states that something is wrong with the characteristic read but I was able to read it on the same device using some commercial scanners or vanilla bluetooth code from google samples.
I checked the characteristic properties - it has PROPERTY_READ.
I bump into same error when using Polidea sample of RxAndroidBle.
Couldn't find similar case anywhere in the internet, maybe someone bumped into such error.
Additional info might be that the device I'm connecting to is a ble device simulator running on an iPhone.
I'm not providing any snippets as I'm using the same code which is in the core examples.
Full verbose log:
06-12 11:00:20.105 22459-22459/? D/RxBle#Radio: QUEUED RxBleRadioOperationConnect(121589482)
06-12 11:00:20.106 22459-22504/? D/RxBle#Radio: STARTED RxBleRadioOperationConnect(121589482)
06-12 11:00:20.131 22459-22459/? D/BluetoothGatt: connect() - device: 41:0A:AE:0E:C2:50, auto: false
06-12 11:00:20.131 22459-22459/? D/BluetoothGatt: registerApp()
06-12 11:00:20.131 22459-22459/? D/BluetoothGatt: registerApp() - UUID=b6c1ef8f-408b-4afb-8e27-97a6ff2c20fb
06-12 11:00:20.137 22459-22473/? D/BluetoothGatt: onClientRegistered() - status=0 clientIf=6
06-12 11:00:20.330 22459-22473/? D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=6 device=41:0A:AE:0E:C2:50
06-12 11:00:20.333 22459-22473/? D/RxBle#BluetoothGatt: onConnectionStateChange newState=2 status=0
06-12 11:00:20.395 22459-22854/? D/CharacteristicOperationExampleActivity: Hey, connection has been established!
06-12 11:00:20.400 22459-22504/? D/RxBle#Radio: FINISHED RxBleRadioOperationConnect(121589482)
06-12 11:00:25.608 22459-22459/? I/ViewRootImpl: ViewRoot's Touch Event : ACTION_DOWN
06-12 11:00:25.663 22459-22459/? I/ViewRootImpl: ViewRoot's Touch Event : ACTION_UP
06-12 11:00:25.675 22459-22459/? D/RxBle#Radio: QUEUED RxBleRadioOperationServicesDiscover(3295555)
06-12 11:00:25.676 22459-22504/? D/RxBle#Radio: STARTED RxBleRadioOperationServicesDiscover(3295555)
06-12 11:00:25.683 22459-22459/? D/BluetoothGatt: discoverServices() - device: 41:0A:AE:0E:C2:50
06-12 11:00:25.726 22459-22473/? D/BluetoothGatt: onSearchComplete() = Device=41:0A:AE:0E:C2:50 Status=0
06-12 11:00:25.727 22459-22473/? D/RxBle#BluetoothGatt: onServicesDiscovered status=0
06-12 11:00:25.732 22459-22854/? D/RxBle#Radio: QUEUED RxBleRadioOperationCharacteristicRead(177013014)
06-12 11:00:25.733 22459-22504/? D/RxBle#Radio: FINISHED RxBleRadioOperationServicesDiscover(3295555)
06-12 11:00:25.735 22459-22504/? D/RxBle#Radio: STARTED RxBleRadioOperationCharacteristicRead(177013014)
06-12 11:00:25.827 22459-22471/? W/BluetoothGatt: onCharacteristicRead() - Device=41:0A:AE:0E:C2:50 handle=102 Status=6
06-12 11:00:25.830 22459-22471/? D/RxBle#BluetoothGatt: onCharacteristicRead characteristic=1f26b1a4-2b50-11e7-99a8-fcaa142b0bea status=6
06-12 11:00:25.844 22459-22471/? D/RxBle#Radio: QUEUED RxBleRadioOperationDisconnect(84936079)
06-12 11:00:25.849 22459-22471/? D/elo: error: BleGattCharacteristicException{macAddress=41:0A:AE:0E:C2:50, status=6 (0x06 -> https://android.googlesource.com/platform/external/bluetooth/bluedroid/+/android-5.1.0_r1/stack/include/gatt_api.h), bleGattOperationType=BleGattOperation{description='CHARACTERISTIC_READ'}}
06-12 11:00:25.879 22459-22504/? D/RxBle#Radio: FINISHED RxBleRadioOperationCharacteristicRead(177013014)
06-12 11:00:25.880 22459-22504/? D/RxBle#Radio: STARTED RxBleRadioOperationDisconnect(84936079)
06-12 11:00:25.915 22459-22459/? D/elo: error: BleGattCharacteristicException{macAddress=41:0A:AE:0E:C2:50, status=6 (0x06 -> https://android.googlesource.com/platform/external/bluetooth/bluedroid/+/android-5.1.0_r1/stack/include/gatt_api.h), bleGattOperationType=BleGattOperation{description='CHARACTERISTIC_READ'}}
06-12 11:00:25.925 22459-22459/? D/BluetoothManager: getConnectionState()
06-12 11:00:25.925 22459-22459/? D/BluetoothManager: getConnectedDevices
06-12 11:00:25.951 22459-22459/? D/BluetoothGatt: cancelOpen() - device: 41:0A:AE:0E:C2:50
06-12 11:00:25.962 22459-22471/? D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=6 device=41:0A:AE:0E:C2:50
06-12 11:00:25.966 22459-22471/? D/RxBle#BluetoothGatt: onConnectionStateChange newState=0 status=0
06-12 11:00:25.971 22459-22459/? D/BluetoothGatt: close()
06-12 11:00:25.971 22459-22459/? D/BluetoothGatt: unregisterApp() - mClientIf=6
06-12 11:00:25.974 22459-22504/? D/RxBle#Radio: FINISHED RxBleRadioOperationDisconnect(84936079)
Verbose log from the Google Bluetooth Sample app in which I can read that property
06-12 14:43:36.540 10869-10869/com.example.android.bluetoothlegatt I/ViewRootImpl: ViewRoot's Touch Event : ACTION_DOWN
06-12 14:43:36.598 10869-10869/com.example.android.bluetoothlegatt I/ViewRootImpl: ViewRoot's Touch Event : ACTION_UP
06-12 14:43:36.599 10869-10869/com.example.android.bluetoothlegatt D/BluetoothLeService: Trying to use an existing mBluetoothGatt for connection.
06-12 14:43:41.209 10869-10869/com.example.android.bluetoothlegatt D/BluetoothAdapter: stopLeScan()
06-12 14:43:41.215 10869-10869/com.example.android.bluetoothlegatt D/BluetoothAdapter: scan not started yet
06-12 14:43:43.781 10869-10882/com.example.android.bluetoothlegatt D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=6 device=5F:56:F7:E9:8A:38
06-12 14:43:43.789 10869-10882/com.example.android.bluetoothlegatt I/BluetoothLeService: Connected to GATT server.
06-12 14:43:43.789 10869-10882/com.example.android.bluetoothlegatt D/BluetoothGatt: discoverServices() - device: 5F:56:F7:E9:8A:38
06-12 14:43:43.792 10869-10882/com.example.android.bluetoothlegatt I/BluetoothLeService: Attempting to start service discovery:true
06-12 14:43:45.513 10869-10882/com.example.android.bluetoothlegatt D/BluetoothGatt: onSearchComplete() = Device=5F:56:F7:E9:8A:38 Status=0
06-12 14:43:54.958 10869-10869/com.example.android.bluetoothlegatt D/BluetoothGatt: setCharacteristicNotification() - uuid: 1f26b1a4-2b50-11e7-99a8-fcaa142b0bea enable: true
06-12 14:43:55.063 10869-10882/com.example.android.bluetoothlegatt W/BluetoothGatt: onCharacteristicRead() - Device=5F:56:F7:E9:8A:38 handle=110 Status=0
There is a difference indeed, as this app is setting a notification before reading a value. The code in app responsible for that looks like this:
// If a given GATT characteristic is selected, check for supported features. This sample
// demonstrates 'Read' and 'Notify' features. See
// http://d.android.com/reference/android/bluetooth/BluetoothGatt.html for the complete
// list of supported characteristic features.
private final ExpandableListView.OnChildClickListener servicesListClickListner =
new ExpandableListView.OnChildClickListener() {
#Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition,
int childPosition, long id) {
if (mGattCharacteristics != null) {
final BluetoothGattCharacteristic characteristic =
mGattCharacteristics.get(groupPosition).get(childPosition);
final int charaProp = characteristic.getProperties();
if ((charaProp | BluetoothGattCharacteristic.PROPERTY_READ) > 0) {
// If there is an active notification on a characteristic, clear
// it first so it doesn't update the data field on the user interface.
if (mNotifyCharacteristic != null) {
mBluetoothLeService.setCharacteristicNotification(
mNotifyCharacteristic, false);
mNotifyCharacteristic = null;
}
mBluetoothLeService.readCharacteristic(characteristic);
}
if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) {
mNotifyCharacteristic = characteristic;
mBluetoothLeService.setCharacteristicNotification(
characteristic, true);
}
return true;
}
return false;
}
};
As for RxAndroidBle version, I tested it on 1.2.0, 1.2.4 and 1.3.0.
Android versions 7.1, 6.0.1 and 5.1.
Will try to implement this notification before reading characteristic as it's the only difference I can see.