Velorexe / Unity-Android-Bluetooth-Low-Energy

A Unity Android plugin to support basic Bluetooth Low Energy interactions.
The Unlicense
101 stars 21 forks source link

Handling Connection errors #17

Closed SofianeBek closed 1 year ago

SofianeBek commented 1 year ago

Hi, I hope that you are doing well.

I am fairly new to unity and I am working on a project which establishes a BLE connection between a device and an android based application and I am using this repo to achieve this goal. So far, it was very helpful.

I am just having a hard time to catch errors in case of connection failure between a device and an android based application and I have noticed that with this library, I am not able to catch any errors related to connection to a device. In fact , if I try to connect to a device and turn off the device during the connection phase, the lib is unable to catch it. Therefore, it is very difficult to treat cases of error connections.

Unless I missed something , is there a way to treat the previously explained cases with your code ?

Sorry if the question is not clear enough !

Velorexe commented 1 year ago

Hi @SofianeBek

I'm glad that you've found my plugin helpful up till now. From what I've gathered from your question, you're trying to get catch exceptions that occur with a specific command?

Currently the only way to catch any exceptions is if they're raised by the BleAdapter, which is the adapter between Unity and the Android library. In there there's a .NET event and a UnityEvent to which you can subscribe to. They both return a BleObject that should contain some general information about what caused the error (device UUID, characteristics or services, etc.).

If you're looking for exceptions on certain commands, that's something that hasn't been implemented as of yet. I'm always open for suggestions if you do see this as something you'd like to see in the plugin.