Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Must be handling a user gesture to show a permission request #24

Open
Bengkel opened this issue Jul 4, 2023 · 5 comments
Open

Must be handling a user gesture to show a permission request #24

Bengkel opened this issue Jul 4, 2023 · 5 comments

Comments

@Bengkel
Copy link

Bengkel commented Jul 4, 2023

I added the NuGet package to my Blazor WASM App and get following error message:

_message 'Failed to execute 'requestDevice' on 'Bluetooth': Must be handling a user gesture to show a permission request.\n Error: Failed to execute 'requestDevice' on 'Bluetooth': Must be handling a user gesture to show a permission request.\n at Module.requestDevice (https://localhost:44398/_content/Blazm.Bluetooth/Blazm.Bluetooth.js:7:44)\n at https://localhost:44398/_framework/blazor.webassembly.js:1:3332\n at new Promise (<anonymous>)\n at Object.beginInvokeJSFromDotNet (https://localhost:4439…(https://localhost:44398/_framework/blazor.webassembly.js:1:59849)\n at _mono_wasm_invoke_js_blazor (https://localhost:44398/_framework/dotnet.6.0.18.gsaaqh5ry8.js:1:195300)\n at https://localhost:44398/_framework/dotnet.wasm:wasm-function[219]:0x1a4c1\n at https://localhost:44398/_framework/dotnet.wasm:wasm-function[167]:0xce8f\n at https://localhost:44398/_framework/dotnet.wasm:wasm-function[166]:0xbd73\n at https://localhost:44398/_framework/dotnet.wasm:wasm-function[2815]:0xabf2c' string

@EngstromJimmy
Copy link
Owner

You need to place the call in a button. It's a security thing in the web browser API.

@Bengkel
Copy link
Author

Bengkel commented Jul 5, 2023

I did, this only works once.

  1. The first time it shows me the pairing pop-up in my browser. I can select my device and pair the device.
  2. When I start the project with Visual Studio the second time, "no compatbile devices found" is shown and it throws this error message.
  3. When I can pair the SetupNotifyAsync throws an other error:

'User cancelled the requestDevice() chooser.\nundefined'

or

'GATT Server is disconnected. Cannot retrieve services. (Re)connect first withdevice.gatt.connect.\nundefined'

Checked all Ids with edge://bluetooth-internals/#devices, and they are correct.

When I "forget" the device I am able to pair again.

@Bengkel
Copy link
Author

Bengkel commented Jul 5, 2023

This is the error message in the output window

Setting up
BluetoothDevice {NotificationHandler: N, id: 'XbdpjsWpppJGnQgMi0aGnw==', name: 'Bluno', gatt: BluetoothRemoteGATTServer, ongattserverdisconnected: null}
> Bluetooth Device disconnected
[12:11:42] Connecting to Bluetooth Device... ```

@Bengkel
Copy link
Author

Bengkel commented Jul 7, 2023

I fixed some problems by updating the firmware of my device. Most of the functionality works now. Only exception left is that I get when attaching the notification handler: 'GATT Error: Not supported.\nundefined'

Could this be related to the device?

@EngstromJimmy
Copy link
Owner

It could be. I have noticed this kind of problem before, but I don't think (I'm really guessing here) it is related to the Blazor implementation. It might be the browser implementation, or it might be the device.
I am going to record a couple of videos on this, so I will test the library a bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants