diff --git a/www/js/bluetooth/BluetoothScanPage.tsx b/www/js/bluetooth/BluetoothScanPage.tsx index 8f0b62dbf..0344f8c91 100644 --- a/www/js/bluetooth/BluetoothScanPage.tsx +++ b/www/js/bluetooth/BluetoothScanPage.tsx @@ -1,10 +1,11 @@ import React, { useState } from 'react'; import { useTranslation } from 'react-i18next'; -import { StyleSheet, Modal, ScrollView, SafeAreaView, View } from 'react-native'; -import { gatherBluetoothData, startBLEScanning } from './bluetoothScanner'; -import { logWarn, displayError, displayErrorMsg } from '../plugin/logger'; +import { StyleSheet, Modal, ScrollView, SafeAreaView, View, Text } from 'react-native'; +import { gatherBluetoothClassicData } from './bluetoothScanner'; +import { logWarn, displayError, displayErrorMsg, logDebug } from '../plugin/logger'; import BluetoothCard from './BluetoothCard'; import { Appbar, useTheme, Button } from 'react-native-paper'; +import { BluetoothClassicDevice } from '../types/BluetoothDevices'; /** * The implementation of this scanner page follows the design of @@ -16,7 +17,7 @@ import { Appbar, useTheme, Button } from 'react-native-paper'; const BluetoothScanPage = ({ ...props }: any) => { const { t } = useTranslation(); - const [logs, setLogs] = useState([]); + const [logs, setLogs] = useState([]); const [testLogs, setTestLogs] = useState([]); const [isScanning, setIsScanning] = useState(false); const [isClassic, setIsClassic] = useState(false); @@ -43,7 +44,7 @@ const BluetoothScanPage = ({ ...props }: any) => { try { setIsScanning(true); - const newLogs = await gatherBluetoothData(t); + const newLogs = await gatherBluetoothClassicData(t); setLogs(newLogs); } catch (error) { logWarn(error); @@ -65,23 +66,19 @@ const BluetoothScanPage = ({ ...props }: any) => { setTestLogs((prevLogs) => [...prevLogs, message]); }; - logToDom('HELLO'); - logToDom('HELLO2'); - let delegate = new window['cordova'].plugins.locationManager.Delegate(); - logToDom(delegate); delegate.didDetermineStateForRegion = function (pluginResult) { logToDom('[BLE] didDetermineStateForRegion'); - logToDom(JSON.stringify(pluginResult)); + logToDom(JSON.stringify(pluginResult, null, 2)); window['cordova'].plugins.locationManager.appendToDeviceLog( - '[DOM] didDetermineStateForRegion: ' + JSON.stringify(pluginResult), + '[DOM] didDetermineStateForRegion: ' + JSON.stringify(pluginResult, null, 2), ); }; delegate.didStartMonitoringForRegion = function (pluginResult) { - logToDom('[BLE] didStartMonitoringForRegion'); - logToDom(JSON.stringify(pluginResult)); + logDebug('[BLE] didStartMonitoringForRegion'); + logDebug(JSON.stringify(pluginResult)); }; delegate.didRangeBeaconsInRegion = function (pluginResult) { @@ -90,7 +87,7 @@ const BluetoothScanPage = ({ ...props }: any) => { }; var uuid = '426C7565-4368-6172-6D42-6561636F6E73'; - var identifier = 'Louis-Beacon'; + var identifier = 'BlueCharm_98105'; var minor = 4949; var major = 3838; @@ -177,8 +174,8 @@ const BluetoothScanPage = ({ ...props }: any) => { - {testLogs.map((l) => ( -
{l}
+ {testLogs.map((log, index) => ( + {log} ))}
diff --git a/www/js/bluetooth/bluetoothScanner.ts b/www/js/bluetooth/bluetoothScanner.ts index d3a6cebc0..819801cbd 100644 --- a/www/js/bluetooth/bluetoothScanner.ts +++ b/www/js/bluetooth/bluetoothScanner.ts @@ -22,7 +22,7 @@ const KatieTestBeacon: BLEBeaconDevice = { * @param t is the i18next translation function * @returns an array of strings containing device data, formatted ['ID: id Name: name'] */ -export function gatherBluetoothData(t): Promise { +export function gatherBluetoothClassicData(t): Promise { return new Promise((resolve, reject) => { logDebug('Running bluetooth discovery test!');