manekinekko / angular-web-bluetooth

The missing Web Bluetooth module for Angular
https://manekinekko.github.io/angular-web-bluetooth/
MIT License
195 stars 56 forks source link

How do we directly connect to the device without selecting device from popup list? #20

Closed narada85 closed 6 years ago

beaufortfrancois commented 7 years ago

You can't for now as the Permissions API has not been integrated to the Web Bluetooth API. See https://github.com/WebBluetoothCG/web-bluetooth/blob/master/implementation-status.md#gatt-communication-api and https://webbluetoothcg.github.io/web-bluetooth/#permission-api-integration

narada85 commented 7 years ago

@beaufortfrancois device UUID and name wont help?

narada85 commented 7 years ago

Since electron doesn't have popup available to show device list, somehow i need to connect to device and read the data, Do you have any thoughts on this matter? Tx!

beaufortfrancois commented 7 years ago

I believe* you should be able to see the popup according to https://github.com/aalhaimi/electron-web-bluetooth

narada85 commented 7 years ago

@beaufortfrancois i'm doing angular2 web app and going to convert it to electron. So this proposed plugin doesn't support, since angular2 supports only typescript.

this ' https://github.com/aalhaimi/electron-web-bluetooth' plugin doesn't show popup, but it takes around 1 min to send the response.

manekinekko commented 7 years ago

@beaufortfrancois i'm doing angular2 web app and going to convert it to electron. So this proposed plugin doesn't support, since angular2 supports only typescript.

@narada85 what do you mean by that? typescript is just javascript. What are you trying to accomplish?

narada85 commented 7 years ago

@manekinekko i need to convert this ' https://github.com/aalhaimi/electron-web-bluetooth' code to ng2, but how do i do that without typings?

manekinekko commented 7 years ago

The electron app is just a shell app. You don't have to convert it to typescript. You can for instance, use this project starter and launch it with the electron app by calling the URL like in this line: https://github.com/aalhaimi/electron-web-bluetooth/blob/master/main.js#L21

narada85 commented 7 years ago

@manekinekko It worked, tx!, it didn't show up device popup list. but shows battery level after 1min.

manekinekko commented 7 years ago

@beaufortfrancois do you know what could cause that delay? Does it depends on the device specs?

beaufortfrancois commented 7 years ago

@narada85 Did you read battery level or did you wait for a BLE GATT notification? Can I see the code? https://github.com/aalhaimi/electron-web-bluetooth does not seem to show "battery level" but "heart rate"

narada85 commented 7 years ago

@beaufortfrancois, i did read the battery level.

beaufortfrancois commented 7 years ago

Can you share code and logs with timestamps? 1 minute is a long time ;)

beaufortfrancois commented 7 years ago

Can you reproduce with https://googlechrome.github.io/samples/web-bluetooth/battery-level.html?

narada85 commented 7 years ago

Here is the output: https://drive.google.com/file/d/0B-qW8Onx1jDfNkUta2l2U0t3SXc/view?usp=sharing

narada85 commented 7 years ago

@beaufortfrancois

  1. what are the functions that i can use to check device status(like 'connected' 'disconnected')
  2. what are the functions that i can use to check bluetooth status('turn-on and turn-off'). Tx!
beaufortfrancois commented 7 years ago
  1. In vanilla JS, you can use myBluetoothDevice.gatt.connected. See https://googlechrome.github.io/samples/web-bluetooth/device-info.html and https://googlechrome.github.io/samples/web-bluetooth/device-disconnect.html
  2. You can't for now sadly. In the future, we might have something like https://webbluetoothcg.github.io/web-bluetooth/#availability

Can you share timestamps when device is actually connected?

narada85 commented 7 years ago

@beaufortfrancois pls mention line numbers on following file that you want to put logs. Then i will send you a output.

https://github.com/manekinekko/angular-web-bluetooth-starter/blob/master/src/app/battery-level.service.ts

beaufortfrancois commented 7 years ago

https://github.com/manekinekko/angular-web-bluetooth-starter/blob/master/src/app/battery-level.service.ts#L37 https://github.com/manekinekko/angular-web-bluetooth-starter/blob/master/src/app/battery-level.service.ts#L46 https://github.com/manekinekko/angular-web-bluetooth-starter/blob/master/src/app/battery-level.service.ts#L49 https://github.com/manekinekko/angular-web-bluetooth-starter/blob/master/src/app/battery-level.service.ts#L52

sai-kyaw commented 6 years ago

FYI. Delay on electron is due to their bluetooth_chooser implementation. Basically, they scan the devices and only choose the device once the scan timeout reach. Electron BT Chooser

manekinekko commented 6 years ago

I'm closing this issue. Please reopen if needed.