-
-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
839 additions
and
18 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
[ | ||
{ | ||
"value": null, | ||
"isIndicatable": false, | ||
"isNotifiable": false, | ||
"isWritableWithoutResponse": true, | ||
"isWritableWithResponse": true, | ||
"serviceUUID": "6e400001-b5a3-f393-e0a9-e50e24dcca9e", | ||
"deviceID": "6D:CB:AD:D4:70:CA", | ||
"isReadable": false, | ||
"serviceID": 9, | ||
"isNotifying": false, | ||
"uuid": "6e400002-b5a3-f393-e0a9-e50e24dcca9e", | ||
"id": 10, | ||
"_manager": { | ||
"_eventEmitter": { | ||
"_nativeModule": { | ||
"StateChangeEvent": "StateChangeEvent", | ||
"RestoreStateEvent": "RestoreStateEvent", | ||
"ScanEvent": "ScanEvent", | ||
"DisconnectionEvent": "DisconnectionEvent", | ||
"ReadEvent": "ReadEvent" | ||
} | ||
}, | ||
"_uniqueId": 7, | ||
"_activePromises": {}, | ||
"_activeSubscriptions": { "4": {} }, | ||
"_errorCodesToMessagesMapping": { | ||
"0": "Unknown error occurred. This is probably a bug! Check reason property.", | ||
"1": "BleManager was destroyed", | ||
"2": "Operation was cancelled", | ||
"3": "Operation timed out", | ||
"4": "Operation was rejected", | ||
"5": "Invalid UUIDs or IDs were passed: {internalMessage}", | ||
"100": "BluetoothLE is unsupported on this device", | ||
"101": "Device is not authorized to use BluetoothLE", | ||
"102": "BluetoothLE is powered off", | ||
"103": "BluetoothLE is in unknown state", | ||
"104": "BluetoothLE is resetting", | ||
"105": "Bluetooth state change failed", | ||
"200": "Device {deviceID} connection failed", | ||
"201": "Device {deviceID} was disconnected", | ||
"202": "RSSI read failed for device {deviceID}", | ||
"203": "Device {deviceID} is already connected", | ||
"204": "Device {deviceID} not found", | ||
"205": "Device {deviceID} is not connected", | ||
"206": "Device {deviceID} could not change MTU size", | ||
"300": "Services discovery failed for device {deviceID}", | ||
"301": "Included services discovery failed for device {deviceID} and service: {serviceUUID}", | ||
"302": "Service {serviceUUID} for device {deviceID} not found", | ||
"303": "Services not discovered for device {deviceID}", | ||
"400": "Characteristic discovery failed for device {deviceID} and service {serviceUUID}", | ||
"401": "Characteristic {characteristicUUID} write failed for device {deviceID} and service {serviceUUID}", | ||
"402": "Characteristic {characteristicUUID} read failed for device {deviceID} and service {serviceUUID}", | ||
"403": "Characteristic {characteristicUUID} notify change failed for device {deviceID} and service {serviceUUID}", | ||
"404": "Characteristic {characteristicUUID} not found", | ||
"405": "Characteristics not discovered for device {deviceID} and service {serviceUUID}", | ||
"406": "Cannot write to characteristic {characteristicUUID} with invalid data format: {internalMessage}", | ||
"500": "Descriptor {descriptorUUID} discovery failed for device {deviceID}, service {serviceUUID} and characteristic {characteristicUUID}", | ||
"501": "Descriptor {descriptorUUID} write failed for device {deviceID}, service {serviceUUID} and characteristic {characteristicUUID}", | ||
"502": "Descriptor {descriptorUUID} read failed for device {deviceID}, service {serviceUUID} and characteristic {characteristicUUID}", | ||
"503": "Descriptor {descriptorUUID} not found", | ||
"504": "Descriptors not discovered for device {deviceID}, service {serviceUUID} and characteristic {characteristicUUID}", | ||
"505": "Cannot write to descriptor {descriptorUUID} with invalid data format: {internalMessage}", | ||
"506": "Cannot write to descriptor {descriptorUUID}. It's not allowed by iOS and therefore forbidden on Android as well.", | ||
"600": "Cannot start scanning operation", | ||
"601": "Location services are disabled" | ||
}, | ||
"_scanEventSubscription": {} | ||
} | ||
}, | ||
{ | ||
"value": null, | ||
"isIndicatable": false, | ||
"isNotifiable": true, | ||
"isWritableWithoutResponse": false, | ||
"isWritableWithResponse": false, | ||
"serviceUUID": "6e400001-b5a3-f393-e0a9-e50e24dcca9e", | ||
"deviceID": "6D:CB:AD:D4:70:CA", | ||
"isReadable": false, | ||
"serviceID": 9, | ||
"isNotifying": false, | ||
"uuid": "6e400003-b5a3-f393-e0a9-e50e24dcca9e", | ||
"id": 11, | ||
"_manager": { | ||
"_eventEmitter": { | ||
"_nativeModule": { | ||
"StateChangeEvent": "StateChangeEvent", | ||
"RestoreStateEvent": "RestoreStateEvent", | ||
"ScanEvent": "ScanEvent", | ||
"DisconnectionEvent": "DisconnectionEvent", | ||
"ReadEvent": "ReadEvent" | ||
} | ||
}, | ||
"_uniqueId": 7, | ||
"_activePromises": {}, | ||
"_activeSubscriptions": { "4": {} }, | ||
"_errorCodesToMessagesMapping": { | ||
"0": "Unknown error occurred. This is probably a bug! Check reason property.", | ||
"1": "BleManager was destroyed", | ||
"2": "Operation was cancelled", | ||
"3": "Operation timed out", | ||
"4": "Operation was rejected", | ||
"5": "Invalid UUIDs or IDs were passed: {internalMessage}", | ||
"100": "BluetoothLE is unsupported on this device", | ||
"101": "Device is not authorized to use BluetoothLE", | ||
"102": "BluetoothLE is powered off", | ||
"103": "BluetoothLE is in unknown state", | ||
"104": "BluetoothLE is resetting", | ||
"105": "Bluetooth state change failed", | ||
"200": "Device {deviceID} connection failed", | ||
"201": "Device {deviceID} was disconnected", | ||
"202": "RSSI read failed for device {deviceID}", | ||
"203": "Device {deviceID} is already connected", | ||
"204": "Device {deviceID} not found", | ||
"205": "Device {deviceID} is not connected", | ||
"206": "Device {deviceID} could not change MTU size", | ||
"300": "Services discovery failed for device {deviceID}", | ||
"301": "Included services discovery failed for device {deviceID} and service: {serviceUUID}", | ||
"302": "Service {serviceUUID} for device {deviceID} not found", | ||
"303": "Services not discovered for device {deviceID}", | ||
"400": "Characteristic discovery failed for device {deviceID} and service {serviceUUID}", | ||
"401": "Characteristic {characteristicUUID} write failed for device {deviceID} and service {serviceUUID}", | ||
"402": "Characteristic {characteristicUUID} read failed for device {deviceID} and service {serviceUUID}", | ||
"403": "Characteristic {characteristicUUID} notify change failed for device {deviceID} and service {serviceUUID}", | ||
"404": "Characteristic {characteristicUUID} not found", | ||
"405": "Characteristics not discovered for device {deviceID} and service {serviceUUID}", | ||
"406": "Cannot write to characteristic {characteristicUUID} with invalid data format: {internalMessage}", | ||
"500": "Descriptor {descriptorUUID} discovery failed for device {deviceID}, service {serviceUUID} and characteristic {characteristicUUID}", | ||
"501": "Descriptor {descriptorUUID} write failed for device {deviceID}, service {serviceUUID} and characteristic {characteristicUUID}", | ||
"502": "Descriptor {descriptorUUID} read failed for device {deviceID}, service {serviceUUID} and characteristic {characteristicUUID}", | ||
"503": "Descriptor {descriptorUUID} not found", | ||
"504": "Descriptors not discovered for device {deviceID}, service {serviceUUID} and characteristic {characteristicUUID}", | ||
"505": "Cannot write to descriptor {descriptorUUID} with invalid data format: {internalMessage}", | ||
"506": "Cannot write to descriptor {descriptorUUID}. It's not allowed by iOS and therefore forbidden on Android as well.", | ||
"600": "Cannot start scanning operation", | ||
"601": "Location services are disabled" | ||
}, | ||
"_scanEventSubscription": {} | ||
} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
export { NativeUsbTransport } from './nativeUsb'; | ||
export { NativeBluetoothTransport } from './nativeBluetooth'; | ||
export { nativeBleManager } from './api/bluetoothApi'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { | ||
Transport as AbstractTransport, | ||
AbstractApiTransport, | ||
SessionsClient, | ||
SessionsBackground, | ||
} from '@trezor/transport'; | ||
|
||
import { BluetoothApi } from './api/bluetoothApi'; | ||
|
||
export class NativeBluetoothTransport extends AbstractApiTransport { | ||
// TODO: Not sure how to solve this type correctly. | ||
public name = 'NativeUsbTransport' as any; | ||
|
||
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 BluetoothApi({ | ||
logger, | ||
}), | ||
|
||
sessionsClient, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.