-
|
I'm trying to create my own alternative to Pybricks Code (also a web app, in TypeScript and with Vue.js instead of React, but I think that this is not important), and my UART terminal does not work. I use Xterm.js and write both to UART TX characteristic and to Pybricks Service (with header like Pybricks Code's) when user types into terminal. Here is a simplified example of my code: const device = await navigator.bluetooth.requestDevice({
filters: [{ services: [pybricksServiceUUID] }],
optionalServices: [nordicUartServiceUUID]
});
console.log('Connecting to device...');
const gatt = await device.gatt!.connect();
const nordicUartService = await gatt.getPrimaryService(nordicUartServiceUUID);
const nordicUartRxCharacteristic = await nordicUartService.getCharacteristic('6e400002-b5a3-f393-e0a9-e50e24dcca9e');
const nordicUartTxCharacteristic = await nordicUartService.getCharacteristic('6e400003-b5a3-f393-e0a9-e50e24dcca9e');
nordicUartTxCharacteristic.addEventListener('characteristicvaluechanged', () => {
// here it's simplified. but in my app I also write to my Xterm.js instance here.
console.log('Got UART data', nordicUartTxCharacteristic.value!.buffer);
});
// HACK: see https://github.com/pybricks/pybricks-code/blob/4c364e7fd57c6b06a5cc390d07876d6df4aa7a32/src/ble/sagas.ts#L438-L444
await nordicUartTxCharacteristic.stopNotifications();
await nordicUartTxCharacteristic.startNotifications();
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
We no longer use the nordic uart service in the firmware. So unless you want to support really old firmware versions, you don't need that part. However, |
Beta Was this translation helpful? Give feedback.
We no longer use the nordic uart service in the firmware. So unless you want to support really old firmware versions, you don't need that part.
However,
6e40000X-b5a3-f393-e0a9-e50e24dcca9eis the Pybricks characteristics, not the nordic uart ones, so it looks like your code is trying to mix the two.