powered-up icon indicating copy to clipboard operation
powered-up copied to clipboard

WebAssembly Port

Open tthiery opened this issue 5 years ago • 2 comments

Enable the usage of the SharpBrick.PoweredUp library in Blazor on WebAssembly. For that a bridge between Blazor and WebBluetooth is required. After the bridge, an adapter to the SharpBrick.PoweredUp.Bluetooth interface is required.

tthiery avatar Jul 04 '20 22:07 tthiery

The WebBluetooth stack is not fast enough to setup a GATT characteristics handler. A member of the WebBluetooth WG was friendly enough and filed an issue as a request of my StackOverflow question.

Simultaneously reported to the LEGO Protocol repository in hope to get a command to explicit query the information which are send automatically in the beginning of the protocol setup (hub attached io).

tthiery avatar Sep 26 '20 19:09 tthiery

Minimum reproducable issue in the browser

function writeToLog(x) {
    console.log(x.target.value.buffer);
}
async function connectToLwpDevice() {
    const serviceUuid = "00001623-1212-EFDE-1623-785FEABCD123".toLowerCase();
    const characteristicUuid = "00001624-1212-EFDE-1623-785FEABCD123".toLowerCase();
    const device = await navigator.bluetooth.requestDevice({ filters: [{ services: [serviceUuid] }] });
    const connectedDevice = await device.gatt.connect();
    const service = await connectedDevice.getPrimaryService(serviceUuid);
    const characteristic = await service.getCharacteristic(characteristicUuid);
    characteristic.addEventListener('characteristicvaluechanged', writeToLog);
    await characteristic.startNotifications();
}

tthiery avatar Sep 26 '20 19:09 tthiery