Skip to content

Commit

Permalink
Fix pairing command
Browse files Browse the repository at this point in the history
It happened to be the same in our case, but it should always be 3.
  • Loading branch information
RReverser authored Nov 19, 2024
1 parent b0c5237 commit 707c05d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ const UUID_SERVICE = '00050000-0000-1000-0000-d8492fffa821',
UUID_PAIR = '00050002-0000-1000-0000-d8492fffa821',
UUID_SHOOT = '00050003-0000-1000-0000-d8492fffa821';

function encodeRemoteName(name) {
function encodePairCommand(name) {
let result = new Uint8Array(name.length + 1);
result[0] = name.length;
result[0] = 3;
for (let i = 0; i < name.length; i++) {
result[i + 1] = name.charCodeAt(i);
}
return result;
}

const remoteName = encodeRemoteName('Web');
const pairCmd = encodePairCommand('Web');

function timeout(sec) {
return new Promise(resolve => setTimeout(resolve, sec * 1000));
Expand Down Expand Up @@ -67,7 +67,7 @@ connectBtn.onclick = async () => {
);
let service = await device.gatt.getPrimaryService(UUID_SERVICE);
let pairCharacteristic = await service.getCharacteristic(UUID_PAIR);
await pairCharacteristic.writeValue(remoteName);
await pairCharacteristic.writeValue(pairCmd);
shootCharacteristic = await service.getCharacteristic(UUID_SHOOT);
onConnectionChange();
} catch (e) {
Expand Down

0 comments on commit 707c05d

Please sign in to comment.