diff --git a/packages/transport-native-ble/src/api/nativeBleManager.ts b/packages/transport-native-ble/src/api/nativeBleManager.ts index f5f19aa28376..6d025fb922cb 100644 --- a/packages/transport-native-ble/src/api/nativeBleManager.ts +++ b/packages/transport-native-ble/src/api/nativeBleManager.ts @@ -159,16 +159,16 @@ class NativeBleManager { const alreadyScannedDevice = this.devicesScanList.find( d => d.bleDevice.id === scannedDevice.id, ); - console.log('Advertisment payload base64', scannedDevice.rawScanRecord); - console.log( + debugLog('Advertisment payload base64', scannedDevice.rawScanRecord); + debugLog( 'Advertisment payload as ascii', Buffer.from(scannedDevice.rawScanRecord, 'base64').toString('ascii'), ); - console.log( + debugLog( 'Advertisment payload hex', Buffer.from(scannedDevice.rawScanRecord, 'base64').toString('hex'), ); - console.log( + debugLog( 'Advertisment payload binary', bufferToBinaryString(Buffer.from(scannedDevice.rawScanRecord, 'base64')), ); @@ -176,7 +176,7 @@ class NativeBleManager { if ( alreadyScannedDevice.bleDevice.rawScanRecord !== scannedDevice.rawScanRecord ) { - console.log('!!! Advertisment payload changed !!!'); + debugLog('!!! Advertisment payload changed !!!'); } // Device already in the list, update the last seen timestamp alreadyScannedDevice.lastSeenTimestamp = Date.now(); @@ -568,24 +568,6 @@ class NativeBleManager { console.error('Error writing: ', JSON.stringify(e)); } }; - - public eraseBondsForAllDevices = async () => { - // TEMPORARY until Connect will have message for erasing bonds - const eraseBondsMessage = Buffer.alloc(244); - eraseBondsMessage.fill(0); - eraseBondsMessage.set([63, 35, 35, 31, 70], 0); - - return Promise.all( - this.appConnectedDevices.map(async device => { - await device.bleDevice.writeCharacteristicWithResponseForService( - NUS_SERVICE_UUID, - device.writeUuid, - eraseBondsMessage.toString('base64'), - ); - await this.disconnectDevice(device.bleDevice.id); - }), - ); - }; } export const nativeBleManager = new NativeBleManager(); diff --git a/suite-native/module-authorize-device/src/screens/connect/ConnectingDeviceScreen.tsx b/suite-native/module-authorize-device/src/screens/connect/ConnectingDeviceScreen.tsx index 09f5228d7ded..e6a69ebdb48b 100644 --- a/suite-native/module-authorize-device/src/screens/connect/ConnectingDeviceScreen.tsx +++ b/suite-native/module-authorize-device/src/screens/connect/ConnectingDeviceScreen.tsx @@ -17,7 +17,8 @@ const screenStyle = prepareNativeStyle(() => ({ export const ConnectingDeviceScreen = () => { useOnDeviceReadyNavigation(); - useHandleHardwareBackNavigation(); + // comment this out so we can dismiss the screen by hardware back button because on BT devkit it will freeze there otherwise + // useHandleHardwareBackNavigation(); const { applyStyle } = useNativeStyles(); diff --git a/suite-native/module-dev-utils/src/screens/DevUtilsScreen.tsx b/suite-native/module-dev-utils/src/screens/DevUtilsScreen.tsx index 6ac3e0155c37..2c438092132f 100644 --- a/suite-native/module-dev-utils/src/screens/DevUtilsScreen.tsx +++ b/suite-native/module-dev-utils/src/screens/DevUtilsScreen.tsx @@ -1,4 +1,5 @@ import { Alert } from 'react-native'; +import { useState } from 'react'; import { useNavigation } from '@react-navigation/native'; import * as Sentry from '@sentry/react-native'; @@ -18,6 +19,7 @@ import { import { clearStorage } from '@suite-native/storage'; import { getCommitHash, getSuiteVersion } from '@trezor/env-utils'; import { logs, nativeBleManager } from '@trezor/transport-native-ble'; +import TrezorConnect from '@trezor/connect'; import { BluetoothToggle } from '../components/BluetoothToggle'; import { DevicePassphraseSwitch } from '../components/DevicePassphraseSwitch'; @@ -35,6 +37,27 @@ type NavigationProps = StackToStackCompositeNavigationProps< export const DevUtilsScreen = () => { const navigation = useNavigation(); const copyToClipboard = useCopyToClipboard(); + const [isErasingBonds, setIsErasingBonds] = useState(false); + + const handleEraseBonds = async () => { + setIsErasingBonds(true); + try { + Alert.alert('Please confirm erasing BT bonds on device.'); + const result = await TrezorConnect.eraseBonds({}); + console.log('result', result); + if (!result.success) { + throw new Error(`${result.payload.code} - ${result.payload.error}`); + } + Alert.alert( + 'BT bonds erased - please follow these steps:', + `1. Accept request on Trezor \n2. Restart Trezor device by cutting the power \n2. Click on "Forget device" in system settings \n3. Restart mobile app`, + ); + } catch (error) { + console.error(error); + Alert.alert('Error erasing BT bonds', error.message); + } + setIsErasingBonds(false); + }; return ( }> @@ -66,14 +89,10 @@ export const DevUtilsScreen = () => { )}