loginov-rocks / Web-Bluetooth-Terminal

Progressive Web Application for serial communication with your own Bluetooth Low Energy (Smart) devices
https://loginov-rocks.github.io/Web-Bluetooth-Terminal/
MIT License
234 stars 79 forks source link

Feature request: Nordic UART/BBC micro:bit support #11

Closed jaustin closed 5 years ago

jaustin commented 5 years ago

Hello, the BBC micro:bit (microbit.org) uses the Nordic UART service https://lancaster-university.github.io/microbit-docs/ble/uart-service/ - it would be awesome if this app supported micro:bit. This would also allow trivial support for other Arm MBED boards https://os.mbed.com/teams/Bluetooth-Low-Energy/wiki/UART-access-over-BLE

There's a program for testing with the micro:bit here https://makecode.microbit.org/_8gyHC3Aq8Yxu

loginov-rocks commented 5 years ago

Hello @jaustin !

What service & characteristic UUIDs does microbit use? Could it be configured to the custom UUIDs?

jaustin commented 5 years ago

Hey - the micro:bit is getting the UUIDs from UARTServiceRXCharacteristicShortUUID - but we're not the only ones using these - many Nordic boards do too - we're using Nordic's definition https://developer.nordicsemi.com/nRF5_SDK/nRF51_SDK_v8.x.x/doc/8.0.0/s110/html/a00072.html

This is specified as part of the micro:bit Bluetooth Profile spec here: https://lancaster-university.github.io/microbit-docs/resources/bluetooth/bluetooth_profile.html - this links to https://developer.nordicsemi.com/nRF5_SDK/nRF51_SDK_v8.x.x/doc/8.0.0/s110/html/a00072.html as background

It's possible for someone writing their own micro:bit programme to specify custom UUIDs, but as there are a bunch of tools already using the ones documented above it doesn't make sense for us to change the profile now, if that's what you mean by "Could it be configured to use the custom UUIDs"

loginov-rocks commented 5 years ago

What you need to determine is a service & characteristic UUIDs used by the board to specify them in the instance of BluetoothTerminal class: https://github.com/1oginov/bluetooth-terminal#setserviceuuiduuid By default it uses 0xFFE0 as service UUID and 0xFFE1 as charateristic UUID. Actually you can pass an argument of different type (hex, string) as it's done here: https://developers.google.com/web/updates/2015/07/interact-with-ble-devices-on-the-web#request_bluetooth_devices

So your first step is to get your device shown in the Bluetooth device picker in Chrome. To achieve that you need to find appropriate service UUID and pass it as the first argument to the constructor here: https://github.com/1oginov/Web-Bluetooth-Terminal/blob/master/js/main.js#L32 If Chrome will find your device, then you can move further.

loginov-rocks commented 5 years ago

You can also try different samples from Google https://googlechrome.github.io/samples/web-bluetooth/ to find what missing.