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

Web Bluetooth API shim for noble. #238

Merged
merged 65 commits into from Feb 5, 2017

Conversation

Projects
None yet
@monteslu
Collaborator

monteslu commented Sep 15, 2015

WebBluetooth API is now ready enough to use for several types of BLE apps.

The intent of this is to be able to webpack/browserify noble without the need for a websocket server or other plugins. The bindings should target this spec: https://webbluetoothcg.github.io/web-bluetooth/

A few notes:

  • I've only gotten web bluetooth to connect on ChromeOS behind a flag:
    chrome-flags
  • This code first tries for web bluetooth api, then falls back to the websocket bindings.

cc:// @sandeepmistry @jacobrosenthal @beaufortfrancois

Show outdated Hide outdated lib/webbluetooth/bindings.js
setTimeout(function(){
self.emit('stateChange', 'poweredOn');
}, 50); //maybe just a next tick?

This comment has been minimized.

@sandeepmistry

sandeepmistry Sep 15, 2015

Member

Next tick should be fine. Is there any API to check the state of the Web Bluetooth API (permissions, available, adapter state)?

@sandeepmistry

sandeepmistry Sep 15, 2015

Member

Next tick should be fine. Is there any API to check the state of the Web Bluetooth API (permissions, available, adapter state)?

This comment has been minimized.

@beaufortfrancois

beaufortfrancois Sep 16, 2015

There are none for now but we're talking about it at WebBluetoothCG/web-bluetooth#127

@beaufortfrancois

beaufortfrancois Sep 16, 2015

There are none for now but we're talking about it at WebBluetoothCG/web-bluetooth#127

This comment has been minimized.

@sandeepmistry

sandeepmistry Sep 16, 2015

Member

@beaufortfrancois thanks for the link!

@sandeepmistry

sandeepmistry Sep 16, 2015

Member

@beaufortfrancois thanks for the link!

Show outdated Hide outdated lib/webbluetooth/bindings.js
console.log('peripheral connected', gattServer);
self.emit('connect', deviceUuid);
}, function(err){
console.log('err connecting', err);

This comment has been minimized.

@sandeepmistry

sandeepmistry Sep 15, 2015

Member

You can bubble up the error: self.emit('connect', deviceUuid, error);

@sandeepmistry

sandeepmistry Sep 15, 2015

Member

You can bubble up the error: self.emit('connect', deviceUuid, error);

@sandeepmistry

This comment has been minimized.

Show comment
Hide comment
@sandeepmistry

sandeepmistry Sep 15, 2015

Member

@monteslu great work so far!

Member

sandeepmistry commented Sep 15, 2015

@monteslu great work so far!

@monteslu

This comment has been minimized.

Show comment
Hide comment
@monteslu

monteslu Sep 16, 2015

Collaborator

Created an example app using these bindings in case anyone wants to see how this can be used: https://github.com/monteslu/coolbeans

Collaborator

monteslu commented Sep 16, 2015

Created an example app using these bindings in case anyone wants to see how this can be used: https://github.com/monteslu/coolbeans

@beaufortfrancois

This comment has been minimized.

Show comment
Hide comment
@beaufortfrancois

beaufortfrancois commented Sep 17, 2015

Pretty cool @monteslu!

@deadprogram

This comment has been minimized.

Show comment
Hide comment
@deadprogram

deadprogram Dec 25, 2015

This is very cool work. Do you know about https://github.com/WebBluetoothCG/chrome-app-polyfill was wondering if it might be helpful here.

deadprogram commented Dec 25, 2015

This is very cool work. Do you know about https://github.com/WebBluetoothCG/chrome-app-polyfill was wondering if it might be helpful here.

@monteslu

This comment has been minimized.

Show comment
Hide comment
@monteslu

monteslu Dec 25, 2015

Collaborator

@deadprogram yup, was thinking about using that for now to help finish this port, then hopefully when webbluetooth is finished noble will just work. Hopefully have some time early next week to try that out.

Collaborator

monteslu commented Dec 25, 2015

@deadprogram yup, was thinking about using that for now to help finish this port, then hopefully when webbluetooth is finished noble will just work. Hopefully have some time early next week to try that out.

@beaufortfrancois

This comment has been minimized.

Show comment
Hide comment
@beaufortfrancois

beaufortfrancois Dec 29, 2015

By curiosity, what is needed to finish this port exactly?
See Web Bluetooth implementation status: https://github.com/WebBluetoothCG/web-bluetooth/blob/gh-pages/implementation-status.md#chrome

beaufortfrancois commented Dec 29, 2015

By curiosity, what is needed to finish this port exactly?
See Web Bluetooth implementation status: https://github.com/WebBluetoothCG/web-bluetooth/blob/gh-pages/implementation-status.md#chrome

@monteslu

This comment has been minimized.

Show comment
Hide comment
@monteslu

monteslu Dec 30, 2015

Collaborator

@beaufortfrancois looks like the 2 parts I needed are there now? Was waiting on notification subscriptions and service/characteristic discovery. Will try and give those apis a shot today.

Collaborator

monteslu commented Dec 30, 2015

@beaufortfrancois looks like the 2 parts I needed are there now? Was waiting on notification subscriptions and service/characteristic discovery. Will try and give those apis a shot today.

@beaufortfrancois

This comment has been minimized.

Show comment
Hide comment
@beaufortfrancois

beaufortfrancois Jan 4, 2016

Cool! Please let me know how it goes ;)

beaufortfrancois commented Jan 4, 2016

Cool! Please let me know how it goes ;)

@monteslu

This comment has been minimized.

Show comment
Hide comment
@monteslu

monteslu Jan 6, 2016

Collaborator

Good news!
Notifications working on chrome OS. I've successfully used https://github.com/monteslu/ble-serial to connect to an Arduino 101 running https://github.com/firmata/arduino/tree/ble/examples/StandardFirmataBLE

Now I just need to work out how to use the service/characterstic/descriptor discovery methods on a device.

Collaborator

monteslu commented Jan 6, 2016

Good news!
Notifications working on chrome OS. I've successfully used https://github.com/monteslu/ble-serial to connect to an Arduino 101 running https://github.com/firmata/arduino/tree/ble/examples/StandardFirmataBLE

Now I just need to work out how to use the service/characterstic/descriptor discovery methods on a device.

@monteslu

This comment has been minimized.

Show comment
Hide comment
@monteslu

monteslu Jan 6, 2016

Collaborator

Even more news...

I can get a list of service IDs from a connected device, but discovery ends there for now.

BluetoothGATTService.getCharacteristics() isn't implemented yet.
Also, after that I'll need BluetoothGATTCharacteristic.getDescriptors() to finish this up.

cc:// @beaufortfrancois @jyasskin

Collaborator

monteslu commented Jan 6, 2016

Even more news...

I can get a list of service IDs from a connected device, but discovery ends there for now.

BluetoothGATTService.getCharacteristics() isn't implemented yet.
Also, after that I'll need BluetoothGATTCharacteristic.getDescriptors() to finish this up.

cc:// @beaufortfrancois @jyasskin

@deadprogram

This comment has been minimized.

Show comment
Hide comment
@deadprogram

deadprogram Jan 6, 2016

Isn't https://github.com/WebBluetoothCG/chrome-app-polyfill/blob/master/bluetooth.js#L159 the API call you need?

Also, please feel free to call on me for any help of any kind, testing, etc.

deadprogram commented Jan 6, 2016

Isn't https://github.com/WebBluetoothCG/chrome-app-polyfill/blob/master/bluetooth.js#L159 the API call you need?

Also, please feel free to call on me for any help of any kind, testing, etc.

@monteslu

This comment has been minimized.

Show comment
Hide comment
@monteslu

monteslu Jan 6, 2016

Collaborator

@deadprogram I'm not sure why the chrome app shim is providing that API because it's not part of the spec: https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothgattservice-getcharacteristics

I don't have my chromebook in front of me until tomorrow, but its possible that the getAllCharacteristics() method is available, though I didn't notice the function earlier.

Collaborator

monteslu commented Jan 6, 2016

@deadprogram I'm not sure why the chrome app shim is providing that API because it's not part of the spec: https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothgattservice-getcharacteristics

I don't have my chromebook in front of me until tomorrow, but its possible that the getAllCharacteristics() method is available, though I didn't notice the function earlier.

@beaufortfrancois

This comment has been minimized.

Show comment
Hide comment
@beaufortfrancois

beaufortfrancois Jan 7, 2016

@monteslu You're right. BluetoothGATTService.getCharacteristics() and BluetoothGATTCharacteristic.getDescriptors() are not yet implemented.
And getAllCharacteristics is not implemented either ;)

May I ask why you need them?

beaufortfrancois commented Jan 7, 2016

@monteslu You're right. BluetoothGATTService.getCharacteristics() and BluetoothGATTCharacteristic.getDescriptors() are not yet implemented.
And getAllCharacteristics is not implemented either ;)

May I ask why you need them?

@deadprogram

This comment has been minimized.

Show comment
Hide comment
@deadprogram

deadprogram Jan 7, 2016

@beaufortfrancois I would think that the purpose is to map the Noble functions discoverCharacteristics() & discoverDescriptors() both of which are a part of Noble's expected interfaces.

@monteslu please jump in and correct if I have it wrong here.

deadprogram commented Jan 7, 2016

@beaufortfrancois I would think that the purpose is to map the Noble functions discoverCharacteristics() & discoverDescriptors() both of which are a part of Noble's expected interfaces.

@monteslu please jump in and correct if I have it wrong here.

@monteslu

This comment has been minimized.

Show comment
Hide comment
@monteslu

monteslu Jan 7, 2016

Collaborator

@deadprogram correct. I'm looking to get full compatibility with the noble API. Right now on this PR my hack is to fake the responses for characteristics with some temp data.

Collaborator

monteslu commented Jan 7, 2016

@deadprogram correct. I'm looking to get full compatibility with the noble API. Right now on this PR my hack is to fake the responses for characteristics with some temp data.

@beaufortfrancois

This comment has been minimized.

Show comment
Hide comment
@beaufortfrancois

beaufortfrancois Jan 8, 2016

@deadprogram Thanks!
@monteslu As I'm not an expert of the noble API, would you mind sharing "all" methods that are not working yet in Web Bluetooth so that we can keep track?

beaufortfrancois commented Jan 8, 2016

@deadprogram Thanks!
@monteslu As I'm not an expert of the noble API, would you mind sharing "all" methods that are not working yet in Web Bluetooth so that we can keep track?

@deadprogram

This comment has been minimized.

Show comment
Hide comment
@deadprogram

deadprogram Jan 9, 2016

@beaufortfrancois from a perusal of the code, it would appear that the following Noble API bindings need some additional implementation from Web Bluetooth to work as desired:

Hopefully this list is useful, @monteslu please correct my errors as you see fit.

deadprogram commented Jan 9, 2016

@beaufortfrancois from a perusal of the code, it would appear that the following Noble API bindings need some additional implementation from Web Bluetooth to work as desired:

Hopefully this list is useful, @monteslu please correct my errors as you see fit.

Show outdated Hide outdated lib/webbluetooth/bindings.js
this.emit('stateChange', 'poweredOff');
};
NobleBindings.prototype.startScanning = function(serviceUuids, allowDuplicates) {

This comment has been minimized.

@g-ortuno

g-ortuno Jan 23, 2016

Not sure how it should work on node but in Web Bluetooth you will only get access to the services in your filters and in optionalServices.

@g-ortuno

g-ortuno Jan 23, 2016

Not sure how it should work on node but in Web Bluetooth you will only get access to the services in your filters and in optionalServices.

This comment has been minimized.

@beaufortfrancois

beaufortfrancois Jul 1, 2016

@monteslu Did you figure this one out?
See for instance https://googlechrome.github.io/samples/web-bluetooth/read-characteristic-value-changed.html where battery_service is defined in optionalServices.

@beaufortfrancois

beaufortfrancois Jul 1, 2016

@monteslu Did you figure this one out?
See for instance https://googlechrome.github.io/samples/web-bluetooth/read-characteristic-value-changed.html where battery_service is defined in optionalServices.

Show outdated Hide outdated lib/webbluetooth/bindings.js
console.log('scan finished', device);
if(device){
var address = device.id;

This comment has been minimized.

@g-ortuno

g-ortuno Jan 23, 2016

This is not going to be the address btw. It's just a random string.

@g-ortuno

g-ortuno Jan 23, 2016

This is not going to be the address btw. It's just a random string.

Show outdated Hide outdated lib/webbluetooth/bindings.js
return characteristic.readValue();
})
.then(function(data){
self.emit('write', peripheral.uuid, serviceUuid, characteristicUuid);

This comment has been minimized.

@g-ortuno

g-ortuno Jan 23, 2016

This might be just me not understanding how noble works, but why do you emit a write here and below your error says 'error writing to a characteristic'? This is reading...

@g-ortuno

g-ortuno Jan 23, 2016

This might be just me not understanding how noble works, but why do you emit a write here and below your error says 'error writing to a characteristic'? This is reading...

Show outdated Hide outdated lib/webbluetooth/bindings.js
.then(function(characteristic) {
return characteristic.writeValue(data);
})
.then(function(writeResponse){

This comment has been minimized.

@g-ortuno

g-ortuno Jan 23, 2016

There is no write response from writeValue

@g-ortuno

g-ortuno Jan 23, 2016

There is no write response from writeValue

@g-ortuno

This comment has been minimized.

Show comment
Hide comment
@g-ortuno

g-ortuno Jan 23, 2016

Left a couple of comments.

g-ortuno commented Jan 23, 2016

Left a couple of comments.

@monteslu

This comment has been minimized.

Show comment
Hide comment
@monteslu

monteslu Feb 9, 2016

Collaborator

Thanks @g-ortuno and @deadprogram

@beaufortfrancois The main thing we need to make this really usable is service/characteristic discovery.
The rest of the API would be great, but as it currently stands we're currently stuck faking the UUIDs.

Collaborator

monteslu commented Feb 9, 2016

Thanks @g-ortuno and @deadprogram

@beaufortfrancois The main thing we need to make this really usable is service/characteristic discovery.
The rest of the API would be great, but as it currently stands we're currently stuck faking the UUIDs.

@jyasskin

This comment has been minimized.

Show comment
Hide comment
@jyasskin

jyasskin Feb 9, 2016

Does that mean you're waiting on specifically the no-argument forms of BluetoothRemoteGATTServer.getPrimaryServices() and BluetoothRemoteGATTService.getCharacteristics() to be implemented?

That should be fairly straightforward. If that's all you need for most noble apps to work on Web Bluetooth, we can try to get it done for Chrome 50. (No promises though: our first priority is to ship to the experimental framework.)

jyasskin commented Feb 9, 2016

Does that mean you're waiting on specifically the no-argument forms of BluetoothRemoteGATTServer.getPrimaryServices() and BluetoothRemoteGATTService.getCharacteristics() to be implemented?

That should be fairly straightforward. If that's all you need for most noble apps to work on Web Bluetooth, we can try to get it done for Chrome 50. (No promises though: our first priority is to ship to the experimental framework.)

@monteslu

This comment has been minimized.

Show comment
Hide comment
@monteslu

monteslu Feb 10, 2016

Collaborator

@jyasskin That would be huge!
Those 2 APIs would enable quite a bit of noble-based apps out there today.

I think advertise data reading and broadcasting are pretty important as well in general, but I'd be more than happy if the two APIs you mentioned made it in. And @sandeepmistry can correct me if I'm wrong, but I think after those APIS make it in and this PR is cleaned up, it could maybe be merged in at that point?

Collaborator

monteslu commented Feb 10, 2016

@jyasskin That would be huge!
Those 2 APIs would enable quite a bit of noble-based apps out there today.

I think advertise data reading and broadcasting are pretty important as well in general, but I'd be more than happy if the two APIs you mentioned made it in. And @sandeepmistry can correct me if I'm wrong, but I think after those APIS make it in and this PR is cleaned up, it could maybe be merged in at that point?

@beaufortfrancois

This comment has been minimized.

Show comment
Hide comment
@beaufortfrancois

beaufortfrancois Feb 10, 2016

@jyasskin I agree with @monteslu.
That would be really nice indeed but I think we won't able to do much with Services/Characteristics as developer wouldn't have specified optionalServices.

beaufortfrancois commented Feb 10, 2016

@jyasskin I agree with @monteslu.
That would be really nice indeed but I think we won't able to do much with Services/Characteristics as developer wouldn't have specified optionalServices.

@sandeepmistry

This comment has been minimized.

Show comment
Hide comment
@sandeepmistry

sandeepmistry Feb 11, 2016

Member

@monteslu

... but I think after those APIS make it in and this PR is cleaned up, it could maybe be merged in at that point?

I agree.

@beaufortfrancois @jyasskin

That would be really nice indeed but I think we won't able to do much with Services/Characteristics as developer wouldn't have specified optionalServices.

Is there a way to query the allowed services or get something like Luis has stubbed? https://github.com/monteslu/noble/blob/master/lib/webbluetooth/tempResponses.js

Member

sandeepmistry commented Feb 11, 2016

@monteslu

... but I think after those APIS make it in and this PR is cleaned up, it could maybe be merged in at that point?

I agree.

@beaufortfrancois @jyasskin

That would be really nice indeed but I think we won't able to do much with Services/Characteristics as developer wouldn't have specified optionalServices.

Is there a way to query the allowed services or get something like Luis has stubbed? https://github.com/monteslu/noble/blob/master/lib/webbluetooth/tempResponses.js

@deadprogram

This comment has been minimized.

Show comment
Hide comment
@deadprogram

deadprogram Feb 11, 2016

Perhaps as an interim solution until the full services/characteristics discoverability is in place, a configurable version of the @monteslu hack ala an expected "schema" could serve as a polyfill for this functionality?

deadprogram commented Feb 11, 2016

Perhaps as an interim solution until the full services/characteristics discoverability is in place, a configurable version of the @monteslu hack ala an expected "schema" could serve as a polyfill for this functionality?

@beaufortfrancois

This comment has been minimized.

Show comment
Hide comment
@beaufortfrancois

beaufortfrancois Feb 11, 2016

@sandeepmistry

Is there a way to query the allowed services or get something like Luis has stubbed? https://github.com/monteslu/noble/blob/master/lib/webbluetooth/tempResponses.js

You can use device.uuids to get allowed Service UUIDs when you have access to the BluetoothDevice object.
See https://googlechrome.github.io/samples/web-bluetooth/device-info.html for instance

beaufortfrancois commented Feb 11, 2016

@sandeepmistry

Is there a way to query the allowed services or get something like Luis has stubbed? https://github.com/monteslu/noble/blob/master/lib/webbluetooth/tempResponses.js

You can use device.uuids to get allowed Service UUIDs when you have access to the BluetoothDevice object.
See https://googlechrome.github.io/samples/web-bluetooth/device-info.html for instance

@thegecko

This comment has been minimized.

Show comment
Hide comment
@thegecko

thegecko Feb 12, 2016

I just came across this, nice work.

I have rewritten my BLE / JS abstraction library to follow the web-bluetooth specification:

https://github.com/thegecko/bleat/tree/web-bluetooth

Feel free to borrow any source to further the cause!

https://github.com/thegecko/bleat/blob/web-bluetooth/dist/bleat.core.js
https://github.com/thegecko/bleat/blob/web-bluetooth/dist/bleat.noble.js

thegecko commented Feb 12, 2016

I just came across this, nice work.

I have rewritten my BLE / JS abstraction library to follow the web-bluetooth specification:

https://github.com/thegecko/bleat/tree/web-bluetooth

Feel free to borrow any source to further the cause!

https://github.com/thegecko/bleat/blob/web-bluetooth/dist/bleat.core.js
https://github.com/thegecko/bleat/blob/web-bluetooth/dist/bleat.noble.js

@sandeepmistry

This comment has been minimized.

Show comment
Hide comment
@sandeepmistry

sandeepmistry Feb 13, 2016

Member

@beaufortfrancois thanks for the info and link, this makes sense from a user permission view.

@monteslu is already using device.uuids within discoverServices. So I think the no argument form of BluetoothRemoteGATTService.getCharacteristics() is the only thing needed.

@thegecko thanks for sharing the links!

Member

sandeepmistry commented Feb 13, 2016

@beaufortfrancois thanks for the info and link, this makes sense from a user permission view.

@monteslu is already using device.uuids within discoverServices. So I think the no argument form of BluetoothRemoteGATTService.getCharacteristics() is the only thing needed.

@thegecko thanks for sharing the links!

@g-ortuno

This comment has been minimized.

Show comment
Hide comment
@g-ortuno

g-ortuno Feb 26, 2016

BluetoothRemoteGATTService.getCharacteristics() just landed. Hopefully it will make it into M50.

g-ortuno commented Feb 26, 2016

BluetoothRemoteGATTService.getCharacteristics() just landed. Hopefully it will make it into M50.

@thegecko

This comment has been minimized.

Show comment
Hide comment
@thegecko

thegecko Feb 27, 2016

Cool!

If anyone is interested, the majority (all minus search filters) of the current Web Bluetooth specification has been implemented as an API in the bleat library and is working with noble:

https://github.com/thegecko/bleat

As yet unpublished as I'm working on a few issues and adapter updates.

thegecko commented Feb 27, 2016

Cool!

If anyone is interested, the majority (all minus search filters) of the current Web Bluetooth specification has been implemented as an API in the bleat library and is working with noble:

https://github.com/thegecko/bleat

As yet unpublished as I'm working on a few issues and adapter updates.

@monteslu

This comment has been minimized.

Show comment
Hide comment
@monteslu

monteslu Mar 28, 2016

Collaborator

Good news. We're able to get characteristics from services in Chrome 50. Thanks @jyasskin !

I've updated this PR to use that API. Still not 100% noble-API, but definitely working for many uses cases now. Just needs a little cleanup in the code.

Collaborator

monteslu commented Mar 28, 2016

Good news. We're able to get characteristics from services in Chrome 50. Thanks @jyasskin !

I've updated this PR to use that API. Still not 100% noble-API, but definitely working for many uses cases now. Just needs a little cleanup in the code.

Show outdated Hide outdated lib/webbluetooth/bindings.js
charInfo.properties.push('notify');
}
return charInfo;

This comment has been minimized.

@jyasskin

This comment has been minimized.

Show comment
Hide comment
@jyasskin

jyasskin Mar 29, 2016

Actually thanks @g-ortuno, who implemented it. :)

jyasskin commented Mar 29, 2016

Actually thanks @g-ortuno, who implemented it. :)

@sandeepmistry

This comment has been minimized.

Show comment
Hide comment
@sandeepmistry

sandeepmistry Feb 2, 2017

Member

@monteslu thanks for updating, so in general it sounds like we should leave the TODO's in for now right? Then tackle them once Web Bluetooth fills in stuff?

Member

sandeepmistry commented Feb 2, 2017

@monteslu thanks for updating, so in general it sounds like we should leave the TODO's in for now right? Then tackle them once Web Bluetooth fills in stuff?

@monteslu

This comment has been minimized.

Show comment
Hide comment
@monteslu

monteslu Feb 2, 2017

Collaborator

@sandeepmistry Yup, we should keep the TODO's around until each matching API lands in web bluetooth. Next up is APIs for the descriptors. I'll create another PR for those before they hit chrome stable :)

Collaborator

monteslu commented Feb 2, 2017

@sandeepmistry Yup, we should keep the TODO's around until each matching API lands in web bluetooth. Next up is APIs for the descriptors. I'll create another PR for those before they hit chrome stable :)

return require('./webbluetooth/bindings');
}
return require('./websocket/bindings');

This comment has been minimized.

@sandeepmistry

sandeepmistry Feb 2, 2017

Member

Just a follow up on Gitter, at least for browserify, the web socket bindings will always get included unless there is a rule to exclude them. I think that's why you get a larger bundle size.

@sandeepmistry

sandeepmistry Feb 2, 2017

Member

Just a follow up on Gitter, at least for browserify, the web socket bindings will always get included unless there is a rule to exclude them. I think that's why you get a larger bundle size.

This comment has been minimized.

@monteslu

monteslu Feb 2, 2017

Collaborator

@sandeepmistry Yup, but it's still pretty small overall when I do something like const noble = require('noble/with-bindings')(require('noble/lib/webbluetooth/bindings')); so no worries.

@monteslu

monteslu Feb 2, 2017

Collaborator

@sandeepmistry Yup, but it's still pretty small overall when I do something like const noble = require('noble/with-bindings')(require('noble/lib/webbluetooth/bindings')); so no worries.

@sandeepmistry

This comment has been minimized.

Show comment
Hide comment
@sandeepmistry

sandeepmistry Feb 2, 2017

Member

@jacobrosenthal any objections to (squashing and) merging this?

Member

sandeepmistry commented Feb 2, 2017

@jacobrosenthal any objections to (squashing and) merging this?

@jacobrosenthal

This comment has been minimized.

Show comment
Hide comment
@jacobrosenthal

jacobrosenthal Feb 2, 2017

Member
Member

jacobrosenthal commented Feb 2, 2017

@tybro0103

This comment has been minimized.

Show comment
Hide comment
@tybro0103

tybro0103 Feb 2, 2017

I believe ws will need moved from devDependencies to dependencies, no?

tybro0103 commented Feb 2, 2017

I believe ws will need moved from devDependencies to dependencies, no?

@monteslu

This comment has been minimized.

Show comment
Hide comment
@monteslu

monteslu Feb 2, 2017

Collaborator

@tybro0103 I think you're right, but it shouldn't affect this PR so I think we should probably put that on a different issue. There's a few other unrelated tasks I'll likely open as well.

Collaborator

monteslu commented Feb 2, 2017

@tybro0103 I think you're right, but it shouldn't affect this PR so I think we should probably put that on a different issue. There's a few other unrelated tasks I'll likely open as well.

@tybro0103

This comment has been minimized.

Show comment
Hide comment
@tybro0103

tybro0103 Feb 3, 2017

So is there currently a way to discover services? I'm working with a device not in the official registry.

peripheral.discoverServices() does nothing except return the base service.

tybro0103 commented Feb 3, 2017

So is there currently a way to discover services? I'm working with a device not in the official registry.

peripheral.discoverServices() does nothing except return the base service.

@monteslu

This comment has been minimized.

Show comment
Hide comment
@monteslu

monteslu Feb 3, 2017

Collaborator

@tybro0103 you'll need to know the service id beforehand with webbluetooth. But if you have that you can specify it as a filter same as in noble on node with noble.startScanning([serviceUUIDs]...

Collaborator

monteslu commented Feb 3, 2017

@tybro0103 you'll need to know the service id beforehand with webbluetooth. But if you have that you can specify it as a filter same as in noble on node with noble.startScanning([serviceUUIDs]...

@tybro0103

This comment has been minimized.

Show comment
Hide comment
@tybro0103

tybro0103 Feb 3, 2017

@monteslu Ahhh, I figured I had to specify it somewhere, but couldn't figure out where.

tybro0103 commented Feb 3, 2017

@monteslu Ahhh, I figured I had to specify it somewhere, but couldn't figure out where.

@sandeepmistry sandeepmistry merged commit ef986f9 into noble:master Feb 5, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@sandeepmistry

This comment has been minimized.

Show comment
Hide comment
@sandeepmistry
Member

sandeepmistry commented Feb 5, 2017

@monteslu 🎉

@nybblr

This comment has been minimized.

Show comment
Hide comment
@nybblr

nybblr Feb 15, 2017

Super exciting, and just in time now that Bluetooth is enabled by default in Chrome 56: https://www.chromestatus.com/feature/5264933985976320

Time to fly my Parrot drone from the browser 🎊

nybblr commented Feb 15, 2017

Super exciting, and just in time now that Bluetooth is enabled by default in Chrome 56: https://www.chromestatus.com/feature/5264933985976320

Time to fly my Parrot drone from the browser 🎊

@zkiiito

This comment has been minimized.

Show comment
Hide comment
@zkiiito

zkiiito Feb 15, 2017

Contributor

I'm trying to test this in chrome 56 with this url: https://noble.surge.sh/
but on ubuntu & windows, it says
error: Error: This browser does not support WebBluetooth.

Contributor

zkiiito commented Feb 15, 2017

I'm trying to test this in chrome 56 with this url: https://noble.surge.sh/
but on ubuntu & windows, it says
error: Error: This browser does not support WebBluetooth.

@beaufortfrancois

This comment has been minimized.

Show comment
Hide comment
@beaufortfrancois

beaufortfrancois Feb 15, 2017

@zkiiito Windows is not supported yet*. See https://plus.google.com/+FrancoisBeaufort/posts/9XVHcKC4im7

For Ubuntu, it is not enabled by default yet. See https://developers.google.com/web/updates/2015/07/interact-with-ble-devices-on-the-web#before_we_start

On Linux, you still have to go to chrome://flags/#enable-experimental-web-platform-features, enable the highlighted flag, and restart Chrome for now.

beaufortfrancois commented Feb 15, 2017

@zkiiito Windows is not supported yet*. See https://plus.google.com/+FrancoisBeaufort/posts/9XVHcKC4im7

For Ubuntu, it is not enabled by default yet. See https://developers.google.com/web/updates/2015/07/interact-with-ble-devices-on-the-web#before_we_start

On Linux, you still have to go to chrome://flags/#enable-experimental-web-platform-features, enable the highlighted flag, and restart Chrome for now.

@zkiiito

This comment has been minimized.

Show comment
Hide comment
@zkiiito

zkiiito Feb 15, 2017

Contributor

thanks, i did not dig this deep, just heard that it "should" work :)
keep up the good work!

Contributor

zkiiito commented Feb 15, 2017

thanks, i did not dig this deep, just heard that it "should" work :)
keep up the good work!

Loghorn added a commit to Loghorn/noble that referenced this pull request Apr 15, 2017

Web Bluetooth API shim for noble. (#238)
* can connect from web, no services discovery

* cleanup

* cleanup

* reorganize stub data

* next tick and emit errors

* working notifications

* list service IDs

* working characteristics discover

* cleanup read

* replace console.log with debug

* add semicolon

* cleanup

* use dataview buffer, emit errors

* emit a bindings error if web bluettooth not available

* duplicate all uuids to optionalServices

* return full list of seri

* search by name or prefix

* remove console.log

* fix param juggling

* can connect from web, no services discovery

* cleanup

* cleanup

* reorganize stub data

* working notifications

* list service IDs

* working characteristics discover

* no write response

* revert to not using test abstraction

* Fix startScanning callback calling

According to README, when startScanning is passed a callback as a third argument, that callback is a usual Node-style "error first" callback.
But in fact, when scanning is started successfully, callback is called with `filterDuplicates` value as its first argument.
Here is an example situation where it causes problem:
```
// don't allow duplicates (as by default) but pass a callback
noble.startScanning([], false, function(error) {
  if(error) {
    console.log('Failed to start scanning:', error);
  }
});
```
What happens when you run this code:
`Failed to start scanning: true`

This PR is intended to fix this.

* allow for unsubscribing

* linting fixes

* Update central.js

Remove inaccurate comment

* can connect from web, no services discovery

* can connect from web, no services discovery

* cleanup

* cleanup

* cleanup

* cleanup

* reorganize stub data

* reorganize stub data

* next tick and emit errors

* working notifications

* working notifications

* list service IDs

* list service IDs

* working characteristics discover

* working characteristics discover

* cleanup read

* replace console.log with debug

* add semicolon

* cleanup

* use dataview buffer, emit errors

* emit a bindings error if web bluettooth not available

* duplicate all uuids to optionalServices

* return full list of seri

* search by name or prefix

* remove console.log

* fix param juggling

* no write response

* revert to not using test abstraction

* allow for unsubscribing

* linting fixes

* fix linting

Loghorn added a commit to Loghorn/noble that referenced this pull request Apr 15, 2017

Web Bluetooth API shim for noble. (#238)
* can connect from web, no services discovery

* cleanup

* cleanup

* reorganize stub data

* next tick and emit errors

* working notifications

* list service IDs

* working characteristics discover

* cleanup read

* replace console.log with debug

* add semicolon

* cleanup

* use dataview buffer, emit errors

* emit a bindings error if web bluettooth not available

* duplicate all uuids to optionalServices

* return full list of seri

* search by name or prefix

* remove console.log

* fix param juggling

* can connect from web, no services discovery

* cleanup

* cleanup

* reorganize stub data

* working notifications

* list service IDs

* working characteristics discover

* no write response

* revert to not using test abstraction

* Fix startScanning callback calling

According to README, when startScanning is passed a callback as a third argument, that callback is a usual Node-style "error first" callback.
But in fact, when scanning is started successfully, callback is called with `filterDuplicates` value as its first argument.
Here is an example situation where it causes problem:
```
// don't allow duplicates (as by default) but pass a callback
noble.startScanning([], false, function(error) {
  if(error) {
    console.log('Failed to start scanning:', error);
  }
});
```
What happens when you run this code:
`Failed to start scanning: true`

This PR is intended to fix this.

* allow for unsubscribing

* linting fixes

* Update central.js

Remove inaccurate comment

* can connect from web, no services discovery

* can connect from web, no services discovery

* cleanup

* cleanup

* cleanup

* cleanup

* reorganize stub data

* reorganize stub data

* next tick and emit errors

* working notifications

* working notifications

* list service IDs

* list service IDs

* working characteristics discover

* working characteristics discover

* cleanup read

* replace console.log with debug

* add semicolon

* cleanup

* use dataview buffer, emit errors

* emit a bindings error if web bluettooth not available

* duplicate all uuids to optionalServices

* return full list of seri

* search by name or prefix

* remove console.log

* fix param juggling

* no write response

* revert to not using test abstraction

* allow for unsubscribing

* linting fixes

* fix linting
@urish

This comment has been minimized.

Show comment
Hide comment
@urish

urish Jun 17, 2017

Contributor

Regarding Windows 10: You can now use web-bluetoooth-polyfill to get Web Bluetooth working in Chrome on Windows 10 Creators Update

Contributor

urish commented Jun 17, 2017

Regarding Windows 10: You can now use web-bluetoooth-polyfill to get Web Bluetooth working in Chrome on Windows 10 Creators Update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment