scratchfoundation / scratch-link

Device interoperability layer for Windows and MacOS
BSD 3-Clause "New" or "Revised" License
104 stars 84 forks source link

Add getServices to BLE #115

Closed evhan55 closed 5 years ago

evhan55 commented 5 years ago

Resolves

104: BLE 'getServices' possibly not implemented

Proposed Changes

evhan55 commented 5 years ago

Some services returned seem to be in this list: https://www.bluetooth.com/specifications/gatt/services

and some services returned are custom to the hardware.

evhan55 commented 5 years ago

I have tested this with the microbit on both Mac and Windows:

Mac returns this array of services:

[
"180A",
"F005"
]

Windows returns this array of services:

[
"00001800-0000-1000-8000-00805f9b34fb",
"00001801-0000-1000-8000-00805f9b34fb",
"0000180a-0000-1000-8000-00805f9b34fb",
"0000f005-0000-1000-8000-00805f9b34fb"
]
knandersen commented 5 years ago

Let me know if this is a big stone in your shoe, but would it be possible to also get Advertisement Data now that we're at it? I can see that being useful. For LEGO devices, and hopefully other vendors, that's where we can check hardware and firmware versions, so it would be great to be able to for example let users know they need a firmware update to use a particular extension. If useful we can talk about this at the next extension huddle? @evhan55 @cwillisf

evhan55 commented 5 years ago

@knandersen I am not so well versed in these things, but if it's possible to add and Chris agrees then I don't mind trying to add it. Happy to talk about it at huddle.

cwillisf commented 5 years ago

I think it's best if service UUIDs get "canonicalized" (turned into the full 128-bit UUID string using the canonicalUUID algorithm) before returning them. That would also cause the response to be the same on both platforms.

cwillisf commented 5 years ago

Also, I think adding advertisement data would be great, but I think it should be in a separate PR.

evhan55 commented 5 years ago

@cwillisf I have lost track of this PR's branch from my own branch somehow and can't seem to get them linked again, is it ok with you if I make a new PR with this same code and close this PR?

evhan55 commented 5 years ago

This PR needs to be closed because branch tracking got lost across forks after the LLK/scratch-link repo changed permissions.

Re-opening this PR under the same name here: https://github.com/LLK/scratch-link/pull/123