112 - Discover devices based on BLE Advertisement Data
Proposed Changes
This pull request allows Scratch Link's BLE Session to accept a filter based on BLE Advertisement Manufacturer Data. This is an optional filter to distinguish different devices that share the same BLE Service and Characteristic UUID.
The dataPrefix and mask will be bitwise AND'ed, and any device discovered by Scratch Link will have it's manufacturer data prefix AND'ed with the supplied mask. The two AND'ed results will be compared, and if they match, Scratch Link will include the device in discovered devices.
dataPrefix and mask must be the same length, and max 32 bytes.
Reason for Changes
LEGO products featuring BLE and the LEGO Wireless Protocol 3 and later (https://lego.github.io/lego-ble-wireless-protocol-docs/) will only feature a single BLE service and characteristic with the same UUID shared across multiple products. This means that individual "product" extensions will not be able to scan for individual devices based on UUID alone, but will need to distinguish devices based on the manufacturer data provided in the device's advertisement data.
Resolves
112 - Discover devices based on BLE Advertisement Data
Proposed Changes
This pull request allows Scratch Link's BLE Session to accept a filter based on BLE Advertisement Manufacturer Data. This is an optional filter to distinguish different devices that share the same BLE Service and Characteristic UUID.
It assumes the manufacturer data is structured as proposed (although at the time of writing not established) by the Web Bluetooth standard: https://webbluetoothcg.github.io/web-bluetooth/#example-filter-by-manufacturer-service-data
An example of the filter provided by the client (in this case Scratch VM using a LEGO Boost extension):
The
dataPrefix
andmask
will be bitwise AND'ed, and any device discovered by Scratch Link will have it's manufacturer data prefix AND'ed with the supplied mask. The two AND'ed results will be compared, and if they match, Scratch Link will include the device in discovered devices.dataPrefix
andmask
must be the same length, and max 32 bytes.Reason for Changes
LEGO products featuring BLE and the LEGO Wireless Protocol 3 and later (https://lego.github.io/lego-ble-wireless-protocol-docs/) will only feature a single BLE service and characteristic with the same UUID shared across multiple products. This means that individual "product" extensions will not be able to scan for individual devices based on UUID alone, but will need to distinguish devices based on the manufacturer data provided in the device's advertisement data.