update bluetooth flow since we can't get pin until after pairing initiated from android side
This commit is contained in:
@@ -1750,11 +1750,12 @@
|
|||||||
console.log("start bluetooth pairing");
|
console.log("start bluetooth pairing");
|
||||||
const pin = await rnode.startBluetoothPairing();
|
const pin = await rnode.startBluetoothPairing();
|
||||||
console.log("start bluetooth pairing: done");
|
console.log("start bluetooth pairing: done");
|
||||||
alert(`Bluetooth Pairing Pin: ${pin}`);
|
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
alert(error);
|
alert(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
alert("RNode should now be in Bluetooth Pairing mode. A pin will be shown on the screen when you pair with it from Android bluetooth settings.");
|
||||||
|
|
||||||
// done
|
// done
|
||||||
await rnode.close();
|
await rnode.close();
|
||||||
|
|
||||||
|
|||||||
44
js/rnode.js
44
js/rnode.js
@@ -544,28 +544,30 @@ class RNode {
|
|||||||
0x02, // enable pairing
|
0x02, // enable pairing
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// attempt to get bluetooth pairing pin
|
// todo: listen for packets, pin will be available once user has initiated pairing from Android device
|
||||||
try {
|
|
||||||
|
|
||||||
// read response from device
|
// // attempt to get bluetooth pairing pin
|
||||||
const [ command, ...pinBytes ] = await this.readFromSerialPort(5000);
|
// try {
|
||||||
if(command !== this.CMD_BT_PIN){
|
//
|
||||||
throw `unexpected command response: ${command}`;
|
// // read response from device
|
||||||
}
|
// const [ command, ...pinBytes ] = await this.readFromSerialPort(5000);
|
||||||
|
// if(command !== this.CMD_BT_PIN){
|
||||||
// convert 4 bytes to 32bit integer
|
// throw `unexpected command response: ${command}`;
|
||||||
const pin = pinBytes[0] << 24 | pinBytes[1] << 16 | pinBytes[2] << 8 | pinBytes[3];
|
// }
|
||||||
|
//
|
||||||
// todo: remove logs
|
// // convert 4 bytes to 32bit integer
|
||||||
console.log(pinBytes);
|
// const pin = pinBytes[0] << 24 | pinBytes[1] << 16 | pinBytes[2] << 8 | pinBytes[3];
|
||||||
console.log(pin);
|
//
|
||||||
|
// // todo: remove logs
|
||||||
// todo: convert to string
|
// console.log(pinBytes);
|
||||||
return pin;
|
// console.log(pin);
|
||||||
|
//
|
||||||
} catch(error) {
|
// // todo: convert to string
|
||||||
throw `failed to get bluetooth pin: ${error}`;
|
// return pin;
|
||||||
}
|
//
|
||||||
|
// } catch(error) {
|
||||||
|
// throw `failed to get bluetooth pin: ${error}`;
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user