i am currently working on 2 app which one emulates as a BLE Peripheral which is advertising using the bluetoothadvertiser and the other is a Client.
The PeripheralBluetoothGattServerCallback - Honor8 Nougat 7.0
The ClientBluetoothGattCallback - Nexus 7 2013 Marshmallow 6.0
I have managed to get them connected successfully using the:
bluetoothgatt = BTdevice.connectGatt(activity,false,callback);
The Nexus 7 connects to the Honor 8 fine,however after about 30 seconds or so the connection times out and i get error: 06-06 11:12:06.305 15683-15694/project.androidads I/BLE: ReportedConnectionChanged:GATT CONN LMP TIMEOUT Connection error:UNKNOWN (0)
Client Log:
06-06 11:11:25.992 15683-15683/project.androidads D/BluetoothGatt: connect() - device: 5A:89:20:7A:C2:C5, auto: false
06-06 11:11:25.993 15683-15683/project.androidads D/BluetoothGatt: registerApp()
06-06 11:11:25.993 15683-15683/project.androidads D/BluetoothGatt: registerApp() - UUID=dab3140d-6d26-48ef-b956-02c38aa3dfe8
06-06 11:11:25.995 15683-15694/project.androidads D/BluetoothGatt: onClientRegistered() - status=0 clientIf=6
06-06 11:11:26.488 15683-15710/project.androidads D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=6 device=5A:89:20:7A:C2:C5
06-06 11:11:26.490 15683-15710/project.androidads I/BLE: ReportedConnectionChanged:SUCCESS Connection error:GATT READ NOT PERMIT
06-06 11:11:26.490 15683-15710/project.androidads D/BluetoothGatt: discoverServices() - device: 5A:89:20:7A:C2:C5
06-06 11:11:26.491 15683-15710/project.androidads I/Tag: CONNECTED
06-06 11:11:26.491 15683-15710/project.androidads D/BluetoothAdapter: STATE_ON
06-06 11:11:26.499 15683-15710/project.androidads D/BluetoothGatt: onSearchComplete() = Device=5A:89:20:7A:C2:C5 Status=0
06-06 11:11:26.506 15683-15710/project.androidads I/BLE: Service:ccaa55ee-7777-aa14-8000-2742f1ba77cc
06-06 11:11:27.661 15683-15710/project.androidads D/BluetoothGatt: setCharacteristicNotification() - uuid: ccaa55ee-7777-aa14-aae1-112855353cc1 enable: true
06-06 11:11:27.661 15683-15710/project.androidads I/BLE: onCharacteristicRead UUID:ccaa55ee-7777-aa14-aae1-112855353cc1
06-06 11:11:27.662 15683-15710/project.androidads I/BLE: onCharacteristicRead:0
06-06 11:12:06.305 15683-15694/project.androidads D/BluetoothGatt: onClientConnectionState() - status=34 clientIf=6 device=5A:89:20:7A:C2:C5
06-06 11:12:06.305 15683-15694/project.androidads I/BLE: ReportedConnectionChanged:GATT CONN LMP TIMEOUT Connection error:UNKNOWN (0)
06-06 11:12:06.305 15683-15694/project.androidads D/BluetoothGatt: cancelOpen() - device: 5A:89:20:7A:C2:C5
06-06 11:12:06.306 15683-15694/project.androidads D/BluetoothGatt: close()
06-06 11:12:06.306 15683-15694/project.androidads D/BluetoothGatt: unregisterApp() - mClientIf=6
06-06 11:12:06.306 15683-15694/project.androidads I/TAG: FAILED:34and:0
Peripheral Log:
06-06 11:11:24.918 22412-22424/project.androidads I/BLE: ReportedConnectionChanged:SUCCESS Connection error:GATT READ NOT PERMIT
06-06 11:11:24.918 22412-22424/project.androidads I/BLE: connected
06-06 11:11:26.179 22412-22425/project.androidads I/BLE: CharacteristicReadRequest Elasped:ccaa55ee-7777-aa14-aae1-112855353cc1
06-06 11:12:24.881 22412-22425/project.androidads I/BLE: ReportedConnectionChanged:SUCCESS Connection error:UNKNOWN (0)
06-06 11:12:24.881 22412-22425/project.androidads I/BLE: disconnected
Been working on this for couple days and i'm not sure what i'm doing wrong,is it the code or there is hardware limitations. Much help would be appreciated.
Related
I'm connecting to BLE device and got two identical onClientConnectionState() calls with identical status. Is this supposed to call multiple times or i doing something wrong? Here the log:
05-06 22:48:31.778 I/BluetoothDevice(17325): createBond() for device D5:...:EA called by pid: 17325 tid: 17360
05-06 22:48:31.813 D/BluetoothGatt(17325): connect() - device: D5:...:EA, auto: false
05-06 22:48:31.814 D/BluetoothGatt(17325): registerApp()
05-06 22:48:31.814 D/BluetoothGatt(17325): registerApp() - UUID=ffbf338d-8200-45f8-83b3-79d71ac40ffd
05-06 22:48:31.816 D/BluetoothGatt(17325): onClientRegistered() - status=0 clientIf=7
05-06 22:48:31.820 D/BluetoothGatt(17325): onClientConnectionState() - status=0 clientIf=7 device=D5:...:EA
Thread started: #7
05-06 22:48:31.835 D/BluetoothGatt(17325): onClientConnectionState() - status=0 clientIf=7 device=D5:...:EA
Thread started: #8
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
We are working on Android BLE & implemented successfully and it’s working fine with all OS version and devices.
We are able to connect successfully using below code:
mBluetoothDevice.connectGatt(this, true, mGattCallback);
connectGatt
But recently Samsung released Android Oreo(8.0.0) for Samsung Galaxy S9, S9+,S8, S8+ etc devices. Now we are not able to connect with BLE in Samsung devices with Android Oreo using above method. We didn’t get any callback in mGattCallback.
When the autoconnect flag true, the log is:
06-16 14:03:39.666 13724-13724/com.ble D/BluetoothGatt: cancelOpen() - device: DA:32:19:58:63:69
06-16 14:03:39.667 13724-13724/com.ble D/BluetoothGatt: close()
06-16 14:03:39.668 13724-13724/com.ble D/BluetoothGatt: unregisterApp() - mClientIf=0
06-16 14:03:39.792 13724-13724/com.ble D/BluetoothGatt: connect() - device: DA:32:19:58:63:69, auto: true
06-16 14:03:39.793 13724-13724/com.ble D/BluetoothGatt: registerApp()
06-16 14:03:39.793 13724-13724/com.ble D/BluetoothGatt: registerApp() - UUID=f672f50e-d321-4785-9af7-0668e5222970
06-16 14:03:39.797 13724-15182/com.ble D/BluetoothGatt: onClientRegistered() - status=0 clientIf=5
But if change the autoconnect flag to false then it’s working.
06-16 14:05:29.486 15681-15681/com.ble D/BluetoothGatt: connect() - device: DA:32:19:58:63:69, auto: false
06-16 14:05:29.487 15681-15681/com.ble D/BluetoothGatt: registerApp()
06-16 14:05:29.487 15681-15681/com.ble D/BluetoothGatt: registerApp() - UUID=a7c4d089-4ba2-422e-b2d1-355d56f6cc8b
06-16 14:05:29.489 15681-16134/com.ble D/BluetoothGatt: onClientRegistered() - status=0 clientIf=5
06-16 14:05:30.198 15681-16134/com.ble D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=5 device=DA:32:19:58:63:69
06-16 14:05:30.202 15681-16134/com.ble D/BluetoothGatt: discoverServices() - device: DA:32:19:58:63:69
06-16 14:05:30.503 15681-16134/com.ble D/BluetoothGatt: onConnectionUpdated() - Device=DA:32:19:58:63:69 interval=6 latency=0 timeout=500 status=0
06-16 14:05:31.033 15681-16134/com.ble D/BluetoothGatt: onSearchComplete() = Device=DA:32:19:58:63:69 Status=0
06-16 14:05:31.055 15681-16134/com.ble D/BluetoothGatt: setCharacteristicNotification() - uuid: 00001734-2927-efef-cdab-eba0fe583711 enable: true
06-16 14:05:31.108 15681-16134/com.ble D/BluetoothGatt: onConnectionUpdated() - Device=DA:32:19:58:63:69 interval=39 latency=0 timeout=500 status=0
When we apply this change it does not connect when the user goes out of range and come again in the range in all devices.
If anyone knows the solutions, please post here.
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 am receiving the above error on Android BLE app while connecting to my pca10040 based board, and I developed this app with nRF Toolbox as a reference.
I am testing this on multiple Android versions and devices, out of which I dont face any problem on motorolla devic, or nexus device (android 7) or on one plus one with android 6.
I am specifically facing this issue on redmi 3s prime with android 6.0.1. On this device My connection handler will wait for some time and then it throws this error.
I have attached the logs with testing different devices:
**Note : 1 = Connected state
2 = Connecting state
Mi Redme 3s Prime (6.0.1 - Marshmallow)
Result: Fail
04-18 11:56:59.462 8852-8852/com.demo.bledoorlock D/BluetoothGatt: connect() - device: D0:35:52:F8:A9:59, auto: false
04-18 11:56:59.462 8852-8852/com.demo.bledoorlock D/BluetoothGatt: registerApp()
04-18 11:56:59.462 8852-8852/com.demo.bledoorlock D/BluetoothGatt: registerApp() - UUID=dd2097ce-ff94-42e4-a454-4c4401aa5482
04-18 11:56:59.466 8852-8892/com.demo.bledoorlock D/BluetoothGatt: onClientRegistered() - status=0 clientIf=5
04-18 11:56:59.467 8852-8852/com.demo.bledoorlock I/System.out: 2
04-18 11:57:00.740 8852-8888/com.demo.bledoorlock V/FA: Inactivity, disconnecting from the service
04-18 11:57:29.490 8852-8992/com.demo.bledoorlock D/BluetoothGatt: onClientConnectionState() - status=133 clientIf=5 device=D0:35:52:F8:A9:59
04-18 11:57:29.491 8852-8852/com.demo.bledoorlock I/System.out: 2
Mi Redme 2 Prime (5.1.1 - Lollipop)
Result: Pass
04-18 11:54:13.871 25251-25251/com.demo.bledoorlock D/BluetoothGatt: connect() - device: D0:35:52:F8:A9:59, auto: false
04-18 11:54:13.871 25251-25251/com.demo.bledoorlock D/BluetoothGatt: registerApp()
04-18 11:54:13.871 25251-25251/com.demo.bledoorlock D/BluetoothGatt: registerApp() - UUID=cb431bbb-bc5e-459b-bdcf-f7ed1929fa01
04-18 11:54:13.871 25251-25580/com.demo.bledoorlock D/BluetoothGatt: onClientRegistered() - status=0 clientIf=5
04-18 11:54:13.871 25251-25251/com.demo.bledoorlock I/System.out: 2
04-18 11:54:14.071 25251-25267/com.demo.bledoorlock D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=5 device=D0:35:52:F8:A9:59
04-18 11:54:14.071 25251-25251/com.demo.bledoorlock I/System.out: 1
04-18 11:54:14.091 25251-25251/com.demo.bledoorlock D/BluetoothGatt: discoverServices() - device: D0:35:52:F8:A9:59
04-18 11:54:14.091 25251-25251/com.demo.bledoorlock I/ViewRootImpl: CPU Rendering VSync enable = true
04-18 11:54:14.091 25251-25580/com.demo.bledoorlock D/BluetoothGatt: onSearchComplete() = Device=D0:35:52:F8:A9:59 Status=0
04-18 11:54:14.101 25251-25580/com.demo.bledoorlock D/BluetoothGatt: setCharacteristicNotification() - uuid: 6e400003-b5a3-f393-e0a9-e50e24dcca9e enable: true
Oneplus One (6.0.1 - Marshmallow)
Result: Pass
04-18 11:58:16.768 28661-28661/com.demo.bledoorlock D/BluetoothGatt: connect() - device: D0:35:52:F8:A9:59, auto: false
04-18 11:58:16.768 28661-28661/com.demo.bledoorlock D/BluetoothGatt: registerApp()
04-18 11:58:16.768 28661-28661/com.demo.bledoorlock D/BluetoothGatt: registerApp() - UUID=a3af82f0-c095-4b06-a1fb-479d7d5f715e
04-18 11:58:16.770 28661-28674/com.demo.bledoorlock D/BluetoothGatt: onClientRegistered() - status=0 clientIf=5
04-18 11:58:16.777 28661-28661/com.demo.bledoorlock I/System.out: 2
04-18 11:58:17.073 28661-28675/com.demo.bledoorlock D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=5 device=D0:35:52:F8:A9:59
04-18 11:58:17.074 28661-28661/com.demo.bledoorlock I/System.out: 1
04-18 11:58:17.086 28661-28661/com.demo.bledoorlock D/BluetoothGatt: discoverServices() - device: D0:35:52:F8:A9:59
04-18 11:58:17.089 28661-28674/com.demo.bledoorlock D/BluetoothGatt: onSearchComplete() = Device=D0:35:52:F8:A9:59 Status=0
04-18 11:58:17.092 28661-28674/com.demo.bledoorlock D/BluetoothGatt: setCharacteristicNotification() - uuid: 6e400003-b5a3-f393-e0a9-e50e24dcca9e enable: true
04-18 11:58:17.159 28661-28697/com.demo.bledoorlock V/RenderScript: 0xaeee3000 Launching thread(s), CPUs 4
04-18 11:58:17.571 28661-28693/com.demo.bledoorlock V/FA: Inactivity, disconnecting from the service
Please suggest how to fix this?