Bug 22274 - Bluetooth LE OnCharacteristicRead and OnCharacteristicChanged callbacks never called
Summary: Bluetooth LE OnCharacteristicRead and OnCharacteristicChanged callbacks never...
Status: RESOLVED NORESPONSE
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 4.14.0
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2014-08-21 18:15 UTC by Jon Douglas [MSFT]
Modified: 2017-06-27 19:28 UTC (History)
6 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NORESPONSE

Description Jon Douglas [MSFT] 2014-08-21 18:15:02 UTC
- Scan the device (StartLeScan)
- Once a device is found, connect to it (device.ConnectGatt)
- Once the connection is established, discover services
(gatt.discoverServices)
- Once the services are discovered, enable notifications on one
characteristic (gatt.SetCharacteristicNotification) and then write some
data on a specific characteristic, to enable BLE communications
(characteristic.setValue, gatt.writeCharacteristic)
- Once the device receive it, it sends back a message. If I don't press
a device button within 5 seconds, it disconnects. If I do, it should
send an other message.

The answers are sent back with a notification, not with a read operation.

Everything works (The OnCharacteristicWrite callback of the
BluetoothGattCallback is called too), but no answer are coming back
(OnCharacteristicRead and OnCharacteristicChanged callbacks are never
called). If I don't press the button, it disconnects, and if I do, it
keeps the connection, so the message was received.

Sample: https://www.dropbox.com/s/i9jvgp1qid89xk3/BleTests%20%281%29.zip

Output Log:

Forwarding debugger port 8818
Detecting existing process
Loaded assembly: Droid.dll
Loaded assembly: Mono.Android.dll [External]
Loaded assembly: System.Core.dll [External]
Loaded assembly: MonoDroidConstructors [External]
[SELinux] Function: selinux_android_load_priority [0], There is no
sepolicy file.
[SELinux]
[SELinux] Function: selinux_android_load_priority , loading version is
VE=SEPF_GT-I9505_4.4.2_0017
[SELinux]
[SELinux]
[SELinux] selinux_android_seapp_context_reload: seapp_contexts file is
loaded from /data/security/spota/seapp_contexts
[libc] WARNING: generic atexit() called from legacy shared library
[Mono] Image addref mscorlib[0x725fe048] -> mscorlib.dll[0x73b6f910]: 1
[Mono] AOT module 'mscorlib.dll.so' not found: dlopen failed: library
"/data/data/Droid.Droid/lib/mscorlib.dll.so" not found
[Mono] Assembly mscorlib[0x725fe048] added to domain RootDomain, ref_count=1
[Mono] Image addref Droid[0x779cd5e8] -> Droid.dll[0x779ccad0]: 1
[Mono] Assembly Droid[0x779cd5e8] added to domain RootDomain, ref_count=1
[Mono] AOT module 'Droid.dll.so' not found: dlopen failed: library
"/data/data/Droid.Droid/lib/Droid.dll.so" not found
[monodroid-gc] GREF GC Threshold: 46800
[Mono] Image addref Mono.Android[0x72b66138] ->
Mono.Android.dll[0x779d1780]: 1
[Mono] Assembly Mono.Android[0x72b66138] added to domain RootDomain,
ref_count=1
[Mono] AOT module 'Mono.Android.dll.so' not found: dlopen failed:
library "/data/data/Droid.Droid/lib/Mono.Android.dll.so" not found
[Mono] Assembly Ref addref Mono.Android[0x72b66138] ->
mscorlib[0x725fe048]: 2
[Mono] Image addref System.Core[0x7bb910f8] ->
System.Core.dll[0x7bb87b20]: 1
[Mono] Assembly System.Core[0x7bb910f8] added to domain RootDomain,
ref_count=1
[Mono] AOT module 'System.Core.dll.so' not found: dlopen failed: library
"/data/data/Droid.Droid/lib/System.Core.dll.so" not found
[Mono] Assembly Ref addref Mono.Android[0x72b66138] ->
System.Core[0x7bb910f8]: 2
[Mono] Assembly Ref addref System.Core[0x7bb910f8] ->
mscorlib[0x725fe048]: 3
[Mono] Assembly Ref addref Droid[0x779cd5e8] -> Mono.Android[0x72b66138]: 2
[Mono] DllImport attempting to load: '__Internal'.
[Mono] DllImport loaded library '(null)'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for '_monodroid_gc_wait_for_bridge_processing'.
[Mono] Probing '_monodroid_gc_wait_for_bridge_processing'.
[Mono] Found as '_monodroid_gc_wait_for_bridge_processing'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for '_monodroid_get_identity_hash_code'.
[Mono] Probing '_monodroid_get_identity_hash_code'.
[Mono] Found as '_monodroid_get_identity_hash_code'.
[Mono] Assembly Ref addref Droid[0x779cd5e8] -> mscorlib[0x725fe048]: 4
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for '_monodroid_gref_log_new'.
[Mono] Probing '_monodroid_gref_log_new'.
[Mono] Found as '_monodroid_gref_log_new'.
[MoreInfoHPW_ViewGroup] Parent view is not a TextView
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for '_monodroid_gref_log_delete'.
[Mono] Probing '_monodroid_gref_log_delete'.
[Mono] Found as '_monodroid_gref_log_delete'.
[Adreno-EGL] <qeglDrvAPI_eglInitialize:381>: EGL 1.4 QUALCOMM build:
(CL3869936)
[Adreno-EGL] OpenGL ES Shader Compiler Version: 17.01.11.SPL
[Adreno-EGL] Build Date: 01/17/14 Fri
[Adreno-EGL] Local Branch:
[Adreno-EGL] Remote Branch:
[Adreno-EGL] Local Patches:
[Adreno-EGL] Reconstruct Branch:
[OpenGLRenderer] Enabling debug mode 0
[Mono] DllImport attempting to load: '/system/lib/liblog.so'.
[Mono] DllImport loaded library '/system/lib/liblog.so'.
[Mono] DllImport searching in: '/system/lib/liblog.so'
('/system/lib/liblog.so').
[Mono] Searching for '__android_log_print'.
[Mono] Probing '__android_log_print'.
[Mono] Found as '__android_log_print'.
BLEScanner: BeginScanningForDevices
[BluetoothAdapter] startLeScan(): null
[BluetoothAdapter] onClientRegistered() - status=0 clientIf=5
[BluetoothAdapter] onScanResult() - Device=F3:EE:F5:D3:F0:29 RSSI=-71
Thread started: #2
[Mono] DllImport attempting to load: '/system/lib/libc.so'.
[Mono] DllImport loaded library '/system/lib/libc.so'.
[Mono] DllImport searching in: '/system/lib/libc.so'
('/system/lib/libc.so').
[Mono] Searching for 'gettid'.
[Mono] Probing 'gettid'.
[Mono] Found as 'gettid'.
BLEScanner: OnLeScan: HAPIfork
BLEDevice: BLEDevice
Thread started: #3
Device F3:EE:F5:D3:F0:29 Added
[BluetoothAdapter] onScanResult() - Device=F3:EE:F5:D3:F0:29 RSSI=-71
Thread started: #4
BLEScanner: OnLeScan: HAPIfork
[BluetoothAdapter] onScanResult() - Device=F3:EE:F5:D3:F0:29 RSSI=-62
BLEScanner: OnLeScan: HAPIfork
[BluetoothAdapter] onScanResult() - Device=F3:EE:F5:D3:F0:29 RSSI=-70
Thread started: #5
BLEScanner: OnLeScan: HAPIfork
[BluetoothAdapter] onScanResult() - Device=F3:EE:F5:D3:F0:29 RSSI=-70
BLEScanner: OnLeScan: HAPIfork
Thread started: <Thread Pool> #6
Thread started: <Thread Pool> #7
[BluetoothAdapter] onScanResult() - Device=F3:EE:F5:D3:F0:29 RSSI=-63
BLEScanner: OnLeScan: HAPIfork
GattCallback: GattCallback
[BluetoothAdapter] onScanResult() - Device=F3:EE:F5:D3:F0:29 RSSI=-68
BLEScanner: OnLeScan: HAPIfork
[BluetoothGatt] connect() - device: F3:EE:F5:D3:F0:29, auto: false
[BluetoothGatt] registerApp()
[BluetoothGatt] registerApp() - UUID=23cd070c-5d14-4170-b080-f3b3fc45100e
[BluetoothGatt] onClientRegistered() - status=0 clientIf=6
[BluetoothGatt] Client registered, waiting for callback
[BluetoothGatt] onClientConnectionState() - status=0 clientIf=6
device=F3:EE:F5:D3:F0:29
GattCallback: OnConnectionStateChange = Connected
[BluetoothGatt] discoverServices() - device: F3:EE:F5:D3:F0:29
[BluetoothGatt] onGetService() - Device=F3:EE:F5:D3:F0:29
UUID=00001800-0000-1000-8000-00805f9b34fb
[BluetoothGatt] onGetService() - Device=F3:EE:F5:D3:F0:29
UUID=00001801-0000-1000-8000-00805f9b34fb
[BluetoothGatt] onGetService() - Device=F3:EE:F5:D3:F0:29
UUID=6e400001-b5a3-f393-e0a9-e50e24dcca9e
[BluetoothGatt] onGetCharacteristic() - Device=F3:EE:F5:D3:F0:29
UUID=00002a00-0000-1000-8000-00805f9b34fb
[BluetoothGatt] onGetCharacteristic() - Device=F3:EE:F5:D3:F0:29
UUID=00002a01-0000-1000-8000-00805f9b34fb
[BluetoothGatt] onGetCharacteristic() - Device=F3:EE:F5:D3:F0:29
UUID=00002a04-0000-1000-8000-00805f9b34fb
[BluetoothGatt] onGetCharacteristic() - Device=F3:EE:F5:D3:F0:29
UUID=00002a05-0000-1000-8000-00805f9b34fb
[BluetoothGatt] onGetCharacteristic() - Device=F3:EE:F5:D3:F0:29
UUID=6e400003-b5a3-f393-e0a9-e50e24dcca9e
[BluetoothGatt] onGetCharacteristic() - Device=F3:EE:F5:D3:F0:29
UUID=6e400002-b5a3-f393-e0a9-e50e24dcca9e
[BluetoothGatt] onGetDescriptor() - Device=F3:EE:F5:D3:F0:29
UUID=00002902-0000-1000-8000-00805f9b34fb
[BluetoothGatt] onGetDescriptor() - Device=F3:EE:F5:D3:F0:29
UUID=00002902-0000-1000-8000-00805f9b34fb
[BluetoothGatt] onSearchComplete() = Device=F3:EE:F5:D3:F0:29 Status=0
GattCallback: OnServicesDiscovered Success
GattCallback: ClearDevice
[BluetoothGatt] setCharacteristicNotification() - uuid:
6e400003-b5a3-f393-e0a9-e50e24dcca9e enable: true
GattCallback: OnServicesDiscovered: SetCharacteristicNotification = True
GattCallback: WriteData: 0x55 0x1E 0x03 0x43 0x4E 0x07 ...
[BluetoothGatt] writeCharacteristic() - uuid:
6e400002-b5a3-f393-e0a9-e50e24dcca9e
GattCallback: WriteData: Written
[BluetoothGatt] onCharacteristicWrite() - Device=F3:EE:F5:D3:F0:29
UUID=6e400002-b5a3-f393-e0a9-e50e24dcca9e Status=0
GattCallback: OnCharacteristicWrite 6e400002-b5a3-f393-e0a9-e50e24dcca9e
status Success
Comment 2 Udham Singh 2016-01-14 08:38:36 UTC
I tried to reproduce this issue but I am not able to reproduce this at my end. I followed all steps as mentioned in bug description. The sample successfully deployed on device but it could not scan any nearby devices.

Could you please provide me the device information, environment info to reproduce this issue.

Application output : https://gist.github.com/Udham1/4458e5d453d7b0ff261f
IDE Log : https://gist.github.com/Udham1/41635d14e6be8c21de08

Environment Info :

=== Xamarin Studio ===

Version 5.10.2 (build 51)
Installation UUID: f1eb2965-85a8-49a2-840b-84538e10ec34
Runtime:
	Microsoft .NET 4.0.30319.42000
	GTK+ 2.24.23 (MS-Windows theme)
	GTK# 2.12.30

=== Xamarin.Profiler ===

Not Installed

=== Xamarin.Android ===

Version: 6.0.1.5 (Enterprise Edition)
Android SDK: E:\sdk\android-sdk
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
		5.1    (API level 22)
		6.0    (API level 23)

SDK Tools Version: 25.0.1 rc2

SDK Platform Tools Version: 23.1

SDK Build Tools Version: 23.0.2


Java SDK: C:\Program Files (x86)\Java\jdk1.7.0_71
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) Client VM (build 24.71-b01, mixed mode)

=== Xamarin Android Player ===

Version: 0.6.5
Location: C:\Program Files\Xamarin Android Player\DeviceManager.exe

=== Build Information ===

Release ID: 510020051
Git revision: 36453d5e06a1ad2cc8d261ad32e29abe0ed57c1f
Build date: 2016-01-12 14:16:50-05
Xamarin addins: ab25321e8918350655a7d46c86cfbaac3222fd3c
Build lane: monodevelop-windows-cycle6-c6sr1

=== Operating System ===

Windows 10.0.10240.0 (64-bit)
Comment 3 Chris Hardy [MSFT] 2017-06-27 19:28:43 UTC
Because we have not received a reply to our request for more information we are closing this issue. If you are still encountering this issue, please reopen the ticket with the requested information. Thanks!