Skip to content

Commit

Permalink
fix(bt): fix connect after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Nodonisko committed Jan 15, 2025
1 parent b088f4b commit 14ac1a5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 21 deletions.
14 changes: 10 additions & 4 deletions packages/transport-native-ble/src/api/bleApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
DEVICE_TYPE,
} from '@trezor/transport/src/api/abstract';
import * as ERRORS from '@trezor/transport/src/errors';
import { AsyncResultWithTypedError } from '@trezor/transport/src/types';
import { AsyncResultWithTypedError, DescriptorApiLevel } from '@trezor/transport/src/types';

import { log } from '../logs';
import { nativeBleManager } from './nativeBleManager';
Expand Down Expand Up @@ -72,9 +72,15 @@ export class BleApi extends AbstractApi {

private async devicesToDescriptors() {
const devices = await nativeBleManager.getAllConnectedDevices();

// TODO: implement proper device type
return devices.map(d => ({ path: d.id, type: DEVICE_TYPE.TypeT2 }));
const descriptors: DescriptorApiLevel[] = devices.map(
d =>
({
path: d.id,
type: DEVICE_TYPE.TypeT2,
}) as DescriptorApiLevel,
);

return descriptors;
}
public async read(
path: string,
Expand Down
18 changes: 1 addition & 17 deletions packages/transport-native-ble/src/nativeTransportBLE.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
Transport as AbstractTransport,
AbstractApiTransport,
SessionsClient,
SessionsBackground,
} from '@trezor/transport';
import { Transport as AbstractTransport, AbstractApiTransport } from '@trezor/transport';

import { BleApi } from './api/bleApi';

Expand All @@ -12,24 +7,13 @@ export class NativeTransportBLE extends AbstractApiTransport {

constructor(params?: ConstructorParameters<typeof AbstractTransport>[0]) {
const { messages, logger } = params || {};
const sessionsBackground = new SessionsBackground();

const sessionsClient = new SessionsClient({
requestFn: args => sessionsBackground.handleMessage(args),
registerBackgroundCallbacks: () => {},
});

sessionsBackground.on('descriptors', descriptors => {
sessionsClient.emit('descriptors', descriptors);
});

super({
messages,
api: new BleApi({
logger,
}),
logger,
sessionsClient,
});
}
}

0 comments on commit 14ac1a5

Please sign in to comment.