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]: BLE CharacteristicInfo Discovery

RobSchein opened this issue · comments

Component/Nuget

BluetoothLE Client (Shiny.BluetoothLE)

What operating system(s) are effected?

  • iOS (13+ supported)
  • Mac Catalyst
  • Android (8+ supported)

Version(s) of Operation Systems

Android 14

Hosting Model

  • MAUI
  • Native/Classic Xamarin
  • Manual

Steps To Reproduce

I believe I whittled down my application to a minimal working framework that simply lists a device, lists its services, and lists characteristics. You will see classes that represent collections of devices, a device, collections of services, a single service, a collection of characteristics, and a single characteristic. All the scanning work is done in the collections classes and is handled in a few lines of code each.

  1. Edit the Constants.cs file and change DeviceUuid to the Uuid of a service on the device being used to test. Here you will also see the Uuids of the services and characteristics I have programmed into my peripheral.
  2. Build and execute project on android phone
  3. There is a Scan button, a Connect button, then three picker controls to select a device, a service on that device, then list the characteristics associated with the selected service.
  4. Once running, click Scan button to start Peripheral scanner (ScanConfig(OneOfMyServicesUuid) (I have only 1 device and it is found.
  5. Click Connect (connects to device and populates "Select a device" picker control
  6. Click on "Select a device" from the picker control - this action scans for and populates the "Select a service" picker control
  7. Click on "Select a service" from the picker control - This action scans for characteristics using the selected ServiceInfo.Uuid obtained from this step.
  8. Click on "Select a Characteristic" from the picker control. This action displays the characteristics, HOWEVER, all the characteristics on my Peripheral are displayed, not just the ones for the selected service.

Expected Behavior

After successfully scanning for a Perpheral, and then scanning for its services, I call

var CharacteristicListReadOnly = await Peripheral.GetCharacteristicsAsync(ServiceInfo.Uuid);
I presume that by calling this function with a ServiceInfo.Uuid, CharacteristicListReadOnly would return the list of characteristics that are assoicated with the supplied service.

Actual Behavior

CharacteristicListReadOnly returns the list of ALL characteristics that are implemented on the Peripheral. I have to manually filter only the characteristics that I have knowledge that belong to that ServiceInfo.Uuid.

Exception or Log output

None.

Code Sample

https://github.com/RobSchein/ShinyTest.git

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!

Edit the Constants.cs file and change DeviceUuid to the Uuid of a service on the device being used to test. Here you will also see the Uuids of the services and characteristics I have programmed into my peripheral.

You need to read the docs about the device UUID - https://shinylib.net/client/ble/best-practices/

https://github.com/RobSchein/ShinyTest.git
There is no source code here

Getting 404 on the repo now

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)

		<PackageReference Include="Shiny.BluetoothLE" Version="3.2.4" />
		<PackageReference Include="Shiny.Hosting.Maui" Version="3.2.4" />
		<PackageReference Include="Shiny.Logging.Sqlite" Version="3.3.0" />

Version 3.3.3 is the latest.

https://shinylib.net/release-notes/client/v30/ - read 3.3.1 & 0d7831f

Please follow the guidelines in the template in the future!!!!

As an FYI, abstracting and abstraction is something I don't review and you will run into problems in the future doing stuff like this going forward