EngstromJimmy / Blazm.Bluetooth

84 stars 14 forks source link

Bonding before Connection #21

Open noumanqaiser opened 1 year ago

noumanqaiser commented 1 year ago

Hello,

Thanks for this extra ordinary peice of work. I am working with a BLE barcode reader that requires you to bond before you would be able to subscribe and listen to gatt characteristics.

I have put the question here aswell: https://stackoverflow.com/questions/73505491/bluetooth-web-bonding-before-connection

Is there any function that you are exposing to the underlying Bluetooth web api that would allow you to bond to a device before listening to Gatt characteristics?

Looking forward to your input on this.

EngstromJimmy commented 1 year ago

Interesting, I would have thought anything paired with the operating system would work, so I am surprised it doesn't. My library uses Web Bluetooth in the backend with JavaScript interop. I know some devices have a non-standard bonding, which simply calls the right characteristics with the right data. Figuring out what that data is, is the fun part =)

I'll leave this one open, if you ever figure out how to do it with Web Bluetooth, I'll be happy to try and implement it (or do a PR).

frederm2018 commented 1 year ago

Jimmy, this might be a similar question to @noumanqaiser . For BLE devices, normally, we just do a query by Gatt, find any that are beaconing. Then connect, without a prompt, collect data or update data on the device the same way you do now. In windows directly, I can listen to beaconing devices, and then decide, in code, if I want to connect or not. Since this is a web based tool, I'm assuming security wont allow it? If you know of a way to do what I'm looking for that would be helpful. I will keep digging as I'm sure you're busy with things. Take care and thanks for the great video.

EngstromJimmy commented 1 year ago

As far as I know, there is no way. For the same reasons you just mentioned. Apple don't think its secure enough, and haven't implemented it yet. If you figure something out please let me know

frederm2018 commented 1 year ago

looks like in the JavaScript API there is something called "GetDevices" which [Blazer.Bluetooth] tries to wrapper. However, it doesn't seem to work but it is exactly what we'd be looking for. My JavaScripting isn't very strong so I haven't tried playing directly with those libraries. I also figured out that you have to enable specific flags on each browser to allow "Experimental" code to work. Fun stuff. Many browsers don't support it at all. However Edge/Chrome seem to state they do. Just haven't figured it out yet. Once you do find a device, you can then subscribe to its advertisements. Which is kind of backwards. You should subscribe to BLE advertisements in general and then filter based on the device advertising, then connect. Maybe someday.

thanks for taking the time to respond,

On Sun, Jun 18, 2023 at 11:05 PM Jimmy Engstrom @.***> wrote:

As far as I know, there is no way. For the same reasons you just mentioned. Apple don't think its secure enough, and haven't implemented it yet. If you figure something out please let me know

— Reply to this email directly, view it on GitHub https://github.com/EngstromJimmy/Blazm.Bluetooth/issues/21#issuecomment-1596560979, or unsubscribe https://github.com/notifications/unsubscribe-auth/AY7DZQXEYL3M3LAUQJ24OVTXL7T3TANCNFSM6AAAAAAVHVMACI . You are receiving this because you commented.Message ID: @.***>