-
Notifications
You must be signed in to change notification settings - Fork 452
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
New features: included, secondary services + finer handles control #88
Conversation
wino45
commented
Dec 17, 2014
- added include service …
- added secondary service
- added relative and absolute handles (use it with care)
- added example of this features
- added secondary service - added relative and absolute handles (use it with care) - added example of this features
Included example is working but should be cleaned and GATT service example implemented. The GATT service structure from Core specification isin main.js. But this is just array with structure snd should be implemented. |
@wino45 thanks for the pull request! A few things:
It's great that you provided examples. Is it common for a secondary service to include another secondary service? (almost all of the BLE devices I've played with don't use secondary/included services) |
BatteryService.super_.call(this, {
uuid: '180F',
included: ['secondaryID'],
characteristics: [
new BatteryLevelCharacteristic()
],
relativeHandle: '10'
}); But this is just reference to service B. The service B can be primary or secondary. Service B can be referenced (included) in service A, C or D.
|
The relative and absolute handles are needed since devices with non-continuous handles are existing. If one wants to write device discovery software one must handle them. Bleno is IMO the best way to test such cases. Please do not remove it. |
@wino45 here's the message id format for OS X peripheral, for the following code: https://github.com/sandeepmistry/osx-ble-peripheral/blob/master/BLEPeripheral/BPAppDelegate.m#L105
I think it has a similar setup to your Linux patch, where secondary services are referred by id in a primary service. We will not be able to support relative and absolute handles on OS X. Another question, how practical is it to have a secondary service included in more than one primary service? I was thinking of a API like: new PrimaryService({
uuid: '180F',
included: [
new SecondaryService({
uuid: '180E',
characteristics: [
// ....
]
})
],
characteristics: [
new BatteryLevelCharacteristic()
]
}); That way we don't have to reference included services by id. |
Hi Sorry for delayed answer, I will try to answer quickly next time. |
@wino45 I understand your desired to make bleno as flexible as possible, but one of the projects goals is to have an unified API for both Linux and OS X. How about passing the included service in by reference: var secondaryService1 = new SecondaryService({
// ...
});
var secondaryService2 = new SecondaryService({
// ...
});
var primaryService1 = new PrimaryService({
// ...
includeServices: [
secondaryService1,
secondaryService2
],
// ...
});
bleno.on('advertisingStart', function(error) {
console.log('on -> advertisingStart: ' + (error ? 'error ' + error : 'success'));
if (!error) {
bleno.setServices([
primaryService1,
secondaryService1,
secondaryService2
]);
}
}); This is very similar to the OS X CoreBluetooth API, as well a mix of your proposal and my previous. It eliminates the need for secondary service id's. |
@sandeepmistry this IMO looks good. As of unified API for Linux and OS X. It looks like that Linux is much more flexible then OSX. Maybe you can add some kind of properties with flags what is supported and what is not on particular platform ? |
@wino45 I'll add working on OS X side to my todo list, then compare it to your Linux PR, hopefully it gets done in the next few weeks. I'm thinking about not supporting the relative and absolute handles for initial secondary service API, then we can discuss again later on. You can distinguish OS via: var os = require('os');
var platform = os.platform(); |
@wino45 see new branch, I've started with OS X, but seems a little unstable with more than one included service: https://github.com/sandeepmistry/bleno/tree/included-services |
This enhancement will cause issues on OS X, closing for now ... |