ICharacteristic.WriteAsync(byte[]) Error on Android 5.0.1
See original GitHub issueCaused by: android.runtime.JavaProxyThrowable: Plugin.BLE.Abstractions.Exceptions.CharacteristicReadException: Gatt write characteristic FAILED.
at Plugin.BLE.Android.Characteristic.InternalWrite (System.Byte[] data) [0x00054] in <5d0080769b114fa0ac55d0d5e8f42614>:0
at Plugin.BLE.Android.Characteristic+<>c__DisplayClass19_0.<WriteNativeAsync>b__0 () [0x00000] in <5d0080769b114fa0ac55d0d5e8f42614>:0
at Plugin.BLE.Abstractions.Utils.TaskBuilder+<FromEvent>d__13[TReturn,TEventHandler,TRejectHandler].MoveNext () [0x000b3] in <17233c4b6076471cb4183230850d0bba>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <a709efbb17bf4aa7b8d27ea8973c7f4c>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <a709efbb17bf4aa7b8d27ea8973c7f4c>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <a709efbb17bf4aa7b8d27ea8973c7f4c>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <a709efbb17bf4aa7b8d27ea8973c7f4c>:0 at System.Runtime.CompilerServices.TaskAwaiter
1[TResult].GetResult () [0x00000] in <a709efbb17bf4aa7b8d27ea8973c7f4c>:0
at Plugin.BLE.Android.Characteristic+<WriteNativeAsync>d__19.MoveNext () [0x000dc] in <5d0080769b114fa0ac55d0d5e8f42614>:0
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <a709efbb17bf4aa7b8d27ea8973c7f4c>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <a709efbb17bf4aa7b8d27ea8973c7f4c>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <a709efbb17bf4aa7b8d27ea8973c7f4c>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <a709efbb17bf4aa7b8d27ea8973c7f4c>:0
at System.Runtime.CompilerServices.TaskAwaiter1[TResult].GetResult () [0x00000] in <a709efbb17bf4aa7b8d27ea8973c7f4c>:0 at Plugin.BLE.Abstractions.CharacteristicBase+<WriteAsync>d__27.MoveNext () [0x000b1] in <17233c4b6076471cb4183230850d0bba>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <a709efbb17bf4aa7b8d27ea8973c7f4c>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <a709efbb17bf4aa7b8d27ea8973c7f4c>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <a709efbb17bf4aa7b8d27ea8973c7f4c>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <a709efbb17bf4aa7b8d27ea8973c7f4c>:0 at System.Runtime.CompilerServices.TaskAwaiter
1[TResult].GetResult () [0x00000] in <a709efbb17bf4aa7b8d27ea8973c7f4c>:0
at WeatherMonitor.PageTab+<SendToDevice>d__18.MoveNext () [0x00072] in <939c423dfe1e41988295c028824d3434>:0
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <a709efbb17bf4aa7b8d27ea8973c7f4c>:0
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>m__0 (System.Object state) [0x00000] in <a709efbb17bf4aa7b8d27ea8973c7f4c>:0
at Android.App.SyncContext+<Post>c__AnonStorey0.<>m__0 () [0x00000] in <b56096d9aca04f2d9c2570e7f66fd957>:0
at Java.Lang.Thread+RunnableImplementor.Run () [0x0000b] in <b56096d9aca04f2d9c2570e7f66fd957>:0
at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in <b56096d9aca04f2d9c2570e7f66fd957>:0
at (wrapper dynamic-method) System.Object:1b37c8f1-1a72-4a48-8432-f868d2c67885 (intptr,intptr)
at mono.java.lang.RunnableImplementor.n_run(Native Method)
at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5572)
… 4 more
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:966)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
Issue Analytics
- State:
- Created 7 years ago
- Comments:8
Top GitHub Comments
FYI: you forgot to await
characteristic.WriteAsync(array);
Xamarin.Forms.Device.BeginInvokeOnMainThread should be enough to workaround this issue. If WriteAsync still fails it means that the main thread is not the problem… Usually when, you call Read/Write as a result of the user interacting with the UI it’s already on the main thread…
Ye we should do it. Default enabled, and configurable?