Dilshaad Muthalif
Dilshaad Muthalif

Reputation: 1

Can't pass pairing key in Web BLE API

I have a peripheral device that needs to be paired with a pin to access its characteristics or perform read/write operations. Here is a code snippet of what I have been doing till now.

const server = await device.gatt.connect();
console.log(`Bluetooth: Got server:`, server);

const service = await server.getPrimaryService(currentService.uuid);
let characteristic2 = await this.state.service.getCharacteristic(
  currentService.characteristicsUUID[1]
);
await characteristic2.writeValue(new Int8Array([1]).buffer);

It shows that characteristicAttrib2.writeValue() is not permitted, even though the read and write access is provided by the characteristic of this service because the device has not been paired using pin. I just want to know if there's any API in web-ble using which the browser can request PIN while paring with the device? And only after pairing with that pin it will provide access to the peripheral device.

Upvotes: 0

Views: 276

Answers (1)

Reilly Grant
Reilly Grant

Reputation: 6093

The Chromium team is currently working on adding support for pairing with devices when necessary to access protected characteristics. This currently happens automatically on Android and macOS but not on Windows, Linux and Chrome OS.

Follow along on this issue for updates.

Upvotes: 1

Related Questions