xamarin / Monkey.BluetoothLE

BluetoothLE abstraction for use with Xamarin projects, including Xamarin.Forms.
Apache License 2.0
348 stars 223 forks source link

Android Device reconnect exception #42

Open KeyvanPouyan opened 9 years ago

KeyvanPouyan commented 9 years ago

For each instance of the IDevice on Android side there is an event subscription. This is done using a Lambda. It is preferred to hook this up to an actual delegate for the purpose of event unsubscription. In the constructor of the Device the DeviceConnected event is being subscribed to. In case of disconnect, this event is not cleared. So the next time the same device is discovered and connected to, previous event gets the first notification. The GATT instance in the initial IDevice is null so it throws an exception.

smoy commented 9 years ago

I submitted a pull request to fix that here: https://github.com/xamarin/Monkey.Robotics/pull/41

KeyvanPouyan commented 9 years ago

Thanks Steven. Just one more issue I forgot to mention on the issue I created. Upon triggering the connection made event, the returned device is added to the list of connect devices. However it is never removed from the list once disconnected. I don't use that list since my app will only talk to one designated BLE device at a time. It would be nice to fix in case someone is planning on a multi-connection session.

smoy commented 9 years ago

I submitted a pull request to address ConnectedDevices property: https://github.com/xamarin/Monkey.Robotics/pull/43