Skip to content

Communicate via BT Browser API #41

@deltasystems-pl

Description

@deltasystems-pl

After sending a cmd to RPi i got this warning in network manager and no response

W | NetworkManagerBluetoothServer: Got invalid json object "{c:0}\n"

My JS code:

button.addEventListener('pointerup', function(event) {
                navigator.bluetooth.requestDevice({
                  acceptAllDevices: true,
                  optionalServices: [
                      'ef6d6610-b8af-49e0-9eca-ab343513641c',
                      '00001801-0000-1000-8000-00805f9b34fb',
                      'e081fec0-f757-4449-b9c9-bfa83133f7fc',
                      '00001800-0000-1000-8000-00805f9b34fb',
                      '0000180a-0000-1000-8000-00805f9b34fb'
                  ]
                })
                .then(device => device.gatt.connect())
                .then(server => {
                  // Getting Battery Service…
                  return server.getPrimaryService('e081fec0-f757-4449-b9c9-bfa83133f7fc');
                })
                .then(service => {
                  // Getting Battery Level Characteristic…
                  return service.getCharacteristic('e081fec1-f757-4449-b9c9-bfa83133f7fc');
                })
                .then(characteristic => {
                   let encoder = new TextEncoder('utf-8');
                  return characteristic.writeValue(encoder.encode({'c': 0}+'\n'));
                })
                .then(value => {
                    console.log( new TextDecoder("utf-8").decode(value));
                })
                .catch(error => { console.error(error); });
            });

Do I something wrong? Have someone try to use Browser BT API to set WLAN on RPi?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions