mirror of
https://github.com/trezor/trezor-suite.git
synced 2026-02-19 16:22:25 +01:00
@trezor/transport-bluetooth
BluetoothIpc and bluetoothIpc proxy
@trezor/suite renderer context
use bluetoothIpc proxy
import { bluetoothIpc } from '@trezor/transport-bluetooth';
await bluetoothIpc.init();
@trezor/suite-desktop-core main context module
implement proxy handler and BluetoothIpc
import { BluetoothIpc } from '@trezor/transport-bluetooth';
createIpcProxyHandler(ipcMain, 'Bluetooth', {
onCreateInstance: () => {
const api = new BluetoothIpc();
return {
onRequest: (method, params) => {
api[method](...params);
},
onAddListener: (eventName, listener) => {
api.on(eventName, listener);
},
onRemoveListener: eventName => {
api.removeAllListeners(eventName);
},
};
},
});
Server build:
yarn workspace @trezor/transport-bluetooth build:server
NAPI build
For MacOS, we use NAPI instead of a standalone process due to issues with pairing.
yarn workspace @trezor/transport-bluetooth build:napi
Server development
Prerequisites: RUST
Vscode:
Vscode rust-analyzer extensions:
- install
rust-analyzerplugin - (NixOS only) install
nix-env-selectorplugin and follow readme to setup
Vscode .vscode/settings:
"rust-analyzer.cargo.sysroot": "discover",
"rust-analyzer.diagnostics.disabled": ["unresolved-proc-macro"],
"rust-analyzer.linkedProjects": ["./packages/transport-bluetooth/Cargo.toml"],
"nixEnvSelector.nixFile": "${workspaceFolder}/packages/transport-bluetooth/shell.nix" // NixOS only
NixOS:
nix-shell ./packages/transport-bluetooth/shell.nix
Run server:
yarn workspace @trezor/transport-bluetooth dev:server
Run dev UI:
Simple html page to communicate with the server using TrezorBluetooth client.
yarn workspace @trezor/transport-bluetooth build:ui
and open ./packages/transport-bluetooth/build/index.html in the browser