shinyorg / shiny

.NET Framework for Backgrounding & Device Hardware Services (iOS, Android, & Catalyst)

Home Page:https://shinylib.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]: Android does not throw a Disconnected into the BleDelegate

HausBJB opened this issue · comments

Component/Nuget

BluetoothLE Client (Shiny.BluetoothLE)

What operating system(s) are effected?

  • iOS (13+ supported)
  • Mac Catalyst
  • Android (8+ supported)
  • Windows (.NET 7 Target - only Core is currently supported, BLE is coming)

Version(s) of Operation Systems

Android 10.0
Shiny.BluetoothLE 3.2.4

Hosting Model

  • MAUI
  • Native/Classic Xamarin
  • Manual

Steps To Reproduce

  1. Create maui project
  2. add to the MauiProgram.cs
    builder.Services.AddBluetoothLE();
  3. connect with bluethoot device
  4. Disconnect with Bluethoot device

Expected Behavior

When connecting the Bluethoot device, the OnPeripheralStateChanged method is called in the BleDelegate
When the Bluethoot device is disconnected, the OnPeripheralStateChanged method is called in the BleDelegate

perhaps this is due to the fact that in line 130 in the file https://github.com/shinyorg/shiny/blob/dev/src/Shiny.BluetoothLE/Platforms/Android/BleManager.cs

BluetoothDevice.ActionAclDisconnected Field is missing

Actual Behavior

When connecting the Bluetooth device, the OnPeripheralStateChanged method is called in the BleDelegate

When disconnecting the Bluethoot device, the OnPeripheralStateChanged method is not called in the BleDelegate

Exception or Log output

None

Code Sample

public class MyBleDelegate : BleDelegate
{
readonly SampleSqliteConnection conn;
public MyBleDelegate(SampleSqliteConnection conn)
=> this.conn = conn;

public override Task OnAdapterStateChanged(AccessState state)
    => this.conn.Log(
        "BLE",
        "Adapter Status",
        $"New Status: {state}"
    );

public override Task OnPeripheralStateChanged(IPeripheral peripheral)
    => this.conn.Log(
        "BLE",
        "Peripheral Connected",
        peripheral.Name
    );

}

Code of Conduct

  • I have supplied a reproducible sample that is NOT FROM THE SHINY SAMPLES!
  • I am a Sponsor OR I am using the LATEST stable/beta version from nuget (v3.0 stable - ALPHAS are not taking issues - Sponsors can still send v2 issues)
  • I am Sponsor OR My GitHub account is 30+ days old
  • I understand that if I am checking these boxes and I am not actually following what they are saying, I will be removed from this repository!

What else I can say, which unfortunately I have only now observed, is that it is important that the Bluetooth device disconnects itself and not from the code, if you pay attention to this, the OnPeripheralStateChanged method will not be called on a disconnect on an Android device, but it will on an iOS device