shinyorg / shiny

.NET Framework for Backgrounding & Device Hardware Services (iOS, Android, & Catalyst)
https://shinylib.net
MIT License
1.43k stars 227 forks source link

[Bug]: BLE CharacteristicInfo Discovery #1462

Closed RobSchein closed 4 months ago

RobSchein commented 4 months ago

Component/Nuget

BluetoothLE Client (Shiny.BluetoothLE)

What operating system(s) are effected?

Version(s) of Operation Systems

Android 14

Hosting Model

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

aritchie commented 4 months ago

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

RobSchein commented 4 months ago

So sorry, Allan. My bad. Repository now has code.

I’ll re-read the reference you sent.

Thanks in advance,

-Rob

From: Allan Ritchie @.> Sent: Tuesday, April 30, 2024 7:37 AM To: shinyorg/shiny @.> Cc: RobSchein @.>; Author @.> Subject: Re: [shinyorg/shiny] [Bug]: BLE CharacteristicInfo Discovery (Issue #1462)

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

— Reply to this email directly, view it on GitHub https://github.com/shinyorg/shiny/issues/1462#issuecomment-2085356707 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AELOJMWVP7RPL323W6RQW2TY76NA3AVCNFSM6AAAAABG7NURT2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBVGM2TMNZQG4 . You are receiving this because you authored the thread. https://github.com/notifications/beacon/AELOJMQ5L6WDGNXX5YTNRSTY76NA3A5CNFSM6AAAAABG7NURT2WGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTT4JQCKG.gif Message ID: @. @.> >

aritchie commented 4 months ago

Getting 404 on the repo now

RobSchein commented 4 months ago

Hi Allan,

Urg, my bad again. The repo is public now. Pls try again.

Oh, after re-reading the best practices, I want to clarify that the DeviceUuid in the Constants.cs file is the UUID of one of my services on the device (as mentioned in the docs, scanning for My Peripheral should be done using one of the custom Service UUIDs). I believe I am following the other guidelines (at least in the short term until I develop out some more).

Thanks for persisting with my failures 😉

-Rob

From: Allan Ritchie @.> Sent: Tuesday, April 30, 2024 10:24 AM To: shinyorg/shiny @.> Cc: RobSchein @.>; Author @.> Subject: Re: [shinyorg/shiny] [Bug]: BLE CharacteristicInfo Discovery (Issue #1462)

Getting 404 on the repo now

— Reply to this email directly, view it on GitHub https://github.com/shinyorg/shiny/issues/1462#issuecomment-2085862220 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AELOJMUYBILAGL3NXEX7FWDY77ARVAVCNFSM6AAAAABG7NURT2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBVHA3DEMRSGA . You are receiving this because you authored the thread. https://github.com/notifications/beacon/AELOJMSHBICMXD4RGA6ZLMDY77ARVA5CNFSM6AAAAABG7NURT2WGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTT4KO5UY.gif Message ID: @. @.> >

aritchie commented 4 months ago

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 & https://github.com/shinyorg/shiny/commit/0d7831f4aa88411e85db9e0f86ebc2834b12d430

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

RobSchein commented 4 months ago

Hi Allan,

Oh, that’s good news. It’s rare to find someone out there with a great software library, ESPECIALLY who is so dedicated and supportive to spending time to reply and to do so almost immediately. I do appreciate those individual qualities, so much so, that I just sent over a $100 donation.

Short background…

I’ve got a patent in progress for a consumer device (this is not my real job). I’ve got 40 years of C++ development experience, and only started with C# in January (yeah, this year), so I have a ton of tricks to learn. I will never burden you with those questions since I value researching new skills highly.

Again, your ethics and quality align with my developer view, so I wanted to reward you with a little token of appreciation. Hopefully, my little gizmo will be sellable, and I will be able to provide more incremental tokens of my appreciation.

Sincerely,

-Rob

From: Allan Ritchie @.> Sent: Tuesday, April 30, 2024 12:09 PM To: shinyorg/shiny @.> Cc: RobSchein @.>; Author @.> Subject: Re: [shinyorg/shiny] [Bug]: BLE CharacteristicInfo Discovery (Issue #1462)

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 & https://github.com/shinyorg/shiny/commit/0d7831f4aa88411e85db9e0f86ebc2834b12d430 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

— Reply to this email directly, view it on GitHub https://github.com/shinyorg/shiny/issues/1462#issuecomment-2086343829 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AELOJMSIBCRGG4LUEH3YAIDY77MZ5AVCNFSM6AAAAABG7NURT2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBWGM2DGOBSHE . You are receiving this because you authored the thread. https://github.com/notifications/beacon/AELOJMUGJKSVSNV3KGDFELTY77MZ5A5CNFSM6AAAAABG7NURT2WGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTT4LMKJK.gif Message ID: @. @.> >