question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Plugin.BLE beta 5, GattCallback error: 133 from ConnectToDeviceAsync(IDevice)

See original GitHub issue

Hi,

I’m using Plugin.BLE beta 5 for my project but I get an exception when I try to connect my phone to a BLE device.

Steps to reproduce

  1. I scan for all of devices I can in a page DevicesListPage.
  2. I choose the device I want to connect to and I passed it through a new Page, ServicesListPage, with that constructor : ServicesListPage(IDevice device). This page has a field, _connectedDevice. I set it in the constructor like this:

_connectedDevice = device

  1. The page ServicesListPage has a button “Connect” to connecting my phone to the device _connectedDevice. When I click on the button the method Connection() is calling:
async void Connection(object sender, EventArgs e)
{
    if (_connectedDevice != null && _connectedDevice.State == Plugin.BLE.Abstractions.DeviceState.Disconnected)
    {
        try
        {
            await App.Adapter.ConnectToDeviceAync(_connectedDevice);
        }
        catch (DeviceConnectionException e){
            System.Diagnostics.Debug.WriteLine("EXCEPTION\nDevice : " + e.DeviceId);
            System.Diagnostics.Debug.WriteLine("Message : " + e.Message + "\nStackTrace : " + e.StackTrace);
        }
    }
}

Expected behavior

Connection should succeed.

Actual behavior

I got a DeviceConnectionException with this message

GattCallback error: 133

Crashlog

EXCEPTION Device : 00000000-0000-0000-0000-d03972ba4265 Message : GattCallback error: 133 StackTrace : at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3415/7db2aac3/source/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /Users/builder/data/lanes/3415/7db2aac3/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/3415/7db2aac3/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/3415/7db2aac3/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 at System.Runtime.CompilerServices.TaskAwaiter1[TResult].GetResult () [0x00000] in /Users/builder/data/lanes/3415/7db2aac3/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:357 at Plugin.BLE.Abstractions.Utils.TaskBuilder+<FromEvent>d__13[TReturn,TEventHandler,TRejectHandler].MoveNext () [0x000c0] in C:\Users\sead\Documents\GitHub\xamarin-bluetooth-le\Source\Plugin.BLE.Abstractions\Utils\TaskBuilder.cs:51 — End of stack trace from previous location where exception was thrown — at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3415/7db2aac3/source/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /Users/builder/data/lanes/3415/7db2aac3/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/3415/7db2aac3/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/3415/7db2aac3/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in /Users/builder/data/lanes/3415/7db2aac3/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:113 at BLETest.ServicesListPage+<ConnectionToDevice>c__async0.MoveNext () [0x0005a] in /Users/nbodinripert/Projects/BLETest/BLETest/Views/Pages/ServicesListPage.xaml.cs:105

Configuration

Version: Xamarin Studio 6.0 Xamarin.Forms : 2.0.1.6495 Plugin.BLE 1.0.0-beta5

Platform: Xamarin Forms (no specific code in iOS or Android sides) but I tested my app only on my Android phone.

Device: LGE Nexus 5X (API 23)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:13

github_iconTop GitHub Comments

9reactions
SamuelLioultcommented, Nov 13, 2018

Hi, I had the same issue. I resolved it specifying the transport type to the ConnectToDeviceAsync method like this:

var parameters = new ConnectParameters(forceBleTransport: true);
await _adapter.ConnectToDeviceAsync(deviceToConnect, parameters, cancellationToken.Token);

Hope it helps.

1reaction
rcbolt3commented, Oct 24, 2017

I’m getting the same exception on my Samsung Galaxy S8+ using both my app and your sample app. However, everything runs smoothly on my Samsung tablet and Note 3. Any ideas?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Plugin.BLE beta 5, GattCallback error: 133 from ...
Hi, I'm using Plugin.BLE beta 5 for my project but I get an exception when I try to connect my phone to a...
Read more >
Developers - Plugin.BLE beta 5, GattCallback error
Plugin.BLE beta 5, GattCallback error: 133 from ConnectToDeviceAsync(IDevice) ... Configuration. Version: Xamarin Studio 6.0. Xamarin.Forms : 2.0.
Read more >
GattCallback error: 133 when writing a character to device?
I am getting a GattCallback error: 133 when writing data to the device.It happens, the app is in the background mode or killed...
Read more >
Xamarin Community Forums - RSSing.com
Does anyone solve this problem i encountered error, GattCallback error : 133, using plugin.ble. here is my code below: device = DevicesList.
Read more >
Plugin.BLE 3.0.0-beta.5
ConnectToDeviceAsync returns a Task that finishes if the device has been connected successful. Otherwise a DeviceConnectionException gets thrown. try { await ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found