From 04df66f736203b083401b6975ebf2a796313e25b Mon Sep 17 00:00:00 2001 From: Katie Rischpater <98350084+the-bay-kay@users.noreply.github.com> Date: Fri, 9 Feb 2024 10:56:12 -0800 Subject: [PATCH 01/33] Added button for Bluetooth Scan Page See Issue [#1046](https://github.com/e-mission/e-mission-docs/issues/1046#issuecomment-1924743636) for more details. This commit adds the Dev-Zone settings option, which will eventually link to the Bluetooth Scanner page. TODO: - Add i18next translation for control.bluetooth --- www/js/control/ProfileSettings.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/www/js/control/ProfileSettings.tsx b/www/js/control/ProfileSettings.tsx index 56c19efe9..7b2151a6a 100644 --- a/www/js/control/ProfileSettings.tsx +++ b/www/js/control/ProfileSettings.tsx @@ -460,8 +460,11 @@ const ProfileSettings = () => { textKey="control.email-log" iconName="email" action={() => sendEmail('loggerDB')}> - + {alert(`Not Implemented!`)}}> Date: Fri, 9 Feb 2024 15:17:50 -0800 Subject: [PATCH 02/33] Added barebones BluetoothScanPage The button added in settings now will open a Modal "Page" that will (eventually) contain the bluetooth devices within scanning distance! --- www/js/bluetooth/BluetoothScanPage.tsx | 62 ++++++++++++++++++++++ www/js/control/BluetoothScanSettingRow.tsx | 27 ++++++++++ www/js/control/ProfileSettings.tsx | 6 +-- 3 files changed, 91 insertions(+), 4 deletions(-) create mode 100644 www/js/bluetooth/BluetoothScanPage.tsx create mode 100644 www/js/control/BluetoothScanSettingRow.tsx diff --git a/www/js/bluetooth/BluetoothScanPage.tsx b/www/js/bluetooth/BluetoothScanPage.tsx new file mode 100644 index 000000000..80f5c7a1c --- /dev/null +++ b/www/js/bluetooth/BluetoothScanPage.tsx @@ -0,0 +1,62 @@ +import React, { useContext } from 'react'; +import { useTranslation } from 'react-i18next'; +import { AppContext } from '../App'; +import { StyleSheet, Text, Modal, ScrollView, SafeAreaView, Pressable } from 'react-native'; + +/** + * The implementation of this scanner page follows the design of + * `www/js/survey/enketo/EnketoModal.tsx`! + * + * Future work may include refractoring these files to be implementations of a + * single base "pop-up page" component + */ +const BluetoothScanPage = ({...props}: any) => { + const { t } = useTranslation(); + const context = useContext(AppContext); // May not be necessary + + const BlueScanContent = ( +
+
+ { // TODO: Fix background color of button + + } +
+ + {'Add Scanner Components here!'} + +
+ ); + + return ( + <> + + + + +
{BlueScanContent}
+
+
+
+
+ + ); +}; + +const s = StyleSheet.create({ + dismissBtn: { + height: 38, + fontSize: 11, + color: '#222', + marginRight: 'auto', + display: 'flex', + alignItems: 'center', + padding: 0, + }, +}); + +export default BluetoothScanPage; diff --git a/www/js/control/BluetoothScanSettingRow.tsx b/www/js/control/BluetoothScanSettingRow.tsx new file mode 100644 index 000000000..1f7757559 --- /dev/null +++ b/www/js/control/BluetoothScanSettingRow.tsx @@ -0,0 +1,27 @@ +import React, { useState } from 'react'; +import SettingRow from './SettingRow'; +import BluetoothScanPage from '../bluetooth/BluetoothScanPage'; + +const BluetoothScanSettingRow = ({}) => { + const [bluePageVisible, setBluePageVisible] = useState(false); + + function openPopover() { + // TODO: Add logic to check for conifig here, or in settings + setBluePageVisible(true) + }; + + return ( + <> + + setBluePageVisible(false)} + /> + + ); +}; + +export default BluetoothScanSettingRow; \ No newline at end of file diff --git a/www/js/control/ProfileSettings.tsx b/www/js/control/ProfileSettings.tsx index 7b2151a6a..32c5bcddd 100644 --- a/www/js/control/ProfileSettings.tsx +++ b/www/js/control/ProfileSettings.tsx @@ -6,6 +6,7 @@ import ExpansionSection from './ExpandMenu'; import SettingRow from './SettingRow'; import ControlDataTable from './ControlDataTable'; import DemographicsSettingRow from './DemographicsSettingRow'; +import BluetoothScanSettingRow from './BluetoothScanSettingRow'; import PopOpCode from './PopOpCode'; import ReminderTime from './ReminderTime'; import useAppConfig from '../useAppConfig'; @@ -461,10 +462,7 @@ const ProfileSettings = () => { iconName="email" action={() => sendEmail('loggerDB')}>
- {alert(`Not Implemented!`)}}> + Date: Fri, 9 Feb 2024 15:35:52 -0800 Subject: [PATCH 03/33] Ran Prettier It seems I accidentally turned off my local VSCode Prettier... Fixing that now --- www/js/bluetooth/BluetoothScanPage.tsx | 53 +++++++++++----------- www/js/control/BluetoothScanSettingRow.tsx | 23 ++++------ www/js/control/ProfileSettings.tsx | 2 +- 3 files changed, 37 insertions(+), 41 deletions(-) diff --git a/www/js/bluetooth/BluetoothScanPage.tsx b/www/js/bluetooth/BluetoothScanPage.tsx index 80f5c7a1c..ae6a36a8a 100644 --- a/www/js/bluetooth/BluetoothScanPage.tsx +++ b/www/js/bluetooth/BluetoothScanPage.tsx @@ -4,45 +4,44 @@ import { AppContext } from '../App'; import { StyleSheet, Text, Modal, ScrollView, SafeAreaView, Pressable } from 'react-native'; /** - * The implementation of this scanner page follows the design of - * `www/js/survey/enketo/EnketoModal.tsx`! - * - * Future work may include refractoring these files to be implementations of a + * The implementation of this scanner page follows the design of + * `www/js/survey/enketo/EnketoModal.tsx`! + * + * Future work may include refractoring these files to be implementations of a * single base "pop-up page" component */ -const BluetoothScanPage = ({...props}: any) => { +const BluetoothScanPage = ({ ...props }: any) => { const { t } = useTranslation(); const context = useContext(AppContext); // May not be necessary const BlueScanContent = (
-
- { // TODO: Fix background color of button - - } -
- - {'Add Scanner Components here!'} - +
+ { + // TODO: Fix background color of button + + } +
+ {'Add Scanner Components here!'}
); return ( <> - - - - -
{BlueScanContent}
-
-
-
-
+ + + + +
{BlueScanContent}
+
+
+
+
); }; diff --git a/www/js/control/BluetoothScanSettingRow.tsx b/www/js/control/BluetoothScanSettingRow.tsx index 1f7757559..59beff0c9 100644 --- a/www/js/control/BluetoothScanSettingRow.tsx +++ b/www/js/control/BluetoothScanSettingRow.tsx @@ -5,23 +5,20 @@ import BluetoothScanPage from '../bluetooth/BluetoothScanPage'; const BluetoothScanSettingRow = ({}) => { const [bluePageVisible, setBluePageVisible] = useState(false); - function openPopover() { - // TODO: Add logic to check for conifig here, or in settings - setBluePageVisible(true) - }; + function openPopover() { + // TODO: Add logic to check for conifig here, or in settings + setBluePageVisible(true); + } return ( <> - - setBluePageVisible(false)} - /> + + setBluePageVisible(false)} /> ); }; -export default BluetoothScanSettingRow; \ No newline at end of file +export default BluetoothScanSettingRow; diff --git a/www/js/control/ProfileSettings.tsx b/www/js/control/ProfileSettings.tsx index 32c5bcddd..5d857dd99 100644 --- a/www/js/control/ProfileSettings.tsx +++ b/www/js/control/ProfileSettings.tsx @@ -462,7 +462,7 @@ const ProfileSettings = () => { iconName="email" action={() => sendEmail('loggerDB')}>
- + Date: Sat, 10 Feb 2024 13:33:15 -0500 Subject: [PATCH 04/33] Added in the new bluetooth plugin so that it will automatically download on build. --- package.cordovabuild.json | 4 +++- setup/setup_shared_native.sh | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/package.cordovabuild.json b/package.cordovabuild.json index 0fc1e31b2..9c0c1acb4 100644 --- a/package.cordovabuild.json +++ b/package.cordovabuild.json @@ -96,7 +96,8 @@ "cordova-plugin-androidx-adapter": {}, "phonegap-plugin-barcodescanner": { "ANDROID_SUPPORT_V4_VERSION": "27.+" - } + }, + "cordova-plugin-bluetooth-serial": {} } }, "dependencies": { @@ -132,6 +133,7 @@ "cordova-plugin-ionic-webview": "5.0.0", "cordova-plugin-local-notification-12": "github:e-mission/cordova-plugin-local-notification-12#v0.1.4-fix-android-action", "cordova-plugin-x-socialsharing": "6.0.4", + "cordova-plugin-bluetooth-serial": "0.4.7", "core-js": "^2.5.7", "enketo-core": "^6.1.7", "enketo-transformer": "^4.0.0", diff --git a/setup/setup_shared_native.sh b/setup/setup_shared_native.sh index 00c72a375..f7cba2aaf 100644 --- a/setup/setup_shared_native.sh +++ b/setup/setup_shared_native.sh @@ -23,7 +23,7 @@ sed -i -e "s|/usr/bin/env node|/usr/bin/env node --unhandled-rejections=strict|" npx cordova prepare -EXPECTED_COUNT=23 +EXPECTED_COUNT=24 INSTALLED_COUNT=`npx cordova plugin list | wc -l` echo "Found $INSTALLED_COUNT plugins, expected $EXPECTED_COUNT" if [ $INSTALLED_COUNT -lt $EXPECTED_COUNT ]; From 2cf78822827a977294cb6b0b32916897cdeae69e Mon Sep 17 00:00:00 2001 From: louisg1337 Date: Sat, 10 Feb 2024 17:25:56 -0500 Subject: [PATCH 05/33] Roughly implemented the bluetooth scanner into the bluetooth page. Created bluetoothScanner.ts which houses the plugin scan request. I then added in functionality to the BluetoothScanPage to output the data that we get from the scan function. --- www/js/bluetooth/BluetoothScanPage.tsx | 33 +++++++++++++++++++++++++- www/js/bluetooth/blueoothScanner.ts | 23 ++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 www/js/bluetooth/blueoothScanner.ts diff --git a/www/js/bluetooth/BluetoothScanPage.tsx b/www/js/bluetooth/BluetoothScanPage.tsx index ae6a36a8a..e885392fb 100644 --- a/www/js/bluetooth/BluetoothScanPage.tsx +++ b/www/js/bluetooth/BluetoothScanPage.tsx @@ -1,7 +1,8 @@ -import React, { useContext } from 'react'; +import React, { useContext, useState, useEffect } from 'react'; import { useTranslation } from 'react-i18next'; import { AppContext } from '../App'; import { StyleSheet, Text, Modal, ScrollView, SafeAreaView, Pressable } from 'react-native'; +import { gatherData } from './blueoothScanner'; /** * The implementation of this scanner page follows the design of @@ -13,6 +14,23 @@ import { StyleSheet, Text, Modal, ScrollView, SafeAreaView, Pressable } from 're const BluetoothScanPage = ({ ...props }: any) => { const { t } = useTranslation(); const context = useContext(AppContext); // May not be necessary + const [logs, setLogs] = useState([]); + + useEffect(() => { + + }, []); + + // Function to run Bluetooth test and update logs + const runBluetoothTest = async () => { + try { + setLogs(["Loading..."]); + const newLogs = await gatherData(); + setLogs(newLogs); + } catch (error) { + console.error(error); + // Handle error + } + }; const BlueScanContent = (
@@ -28,6 +46,16 @@ const BluetoothScanPage = ({ ...props }: any) => { } {'Add Scanner Components here!'} + + +

Console Output:

+ {logs.map((log, index) => ( +

{log}

+ ))}
); @@ -56,6 +84,9 @@ const s = StyleSheet.create({ alignItems: 'center', padding: 0, }, + btn: { + display: 'flex' + } }); export default BluetoothScanPage; diff --git a/www/js/bluetooth/blueoothScanner.ts b/www/js/bluetooth/blueoothScanner.ts new file mode 100644 index 000000000..594860442 --- /dev/null +++ b/www/js/bluetooth/blueoothScanner.ts @@ -0,0 +1,23 @@ +function gatherData(): Promise { + return new Promise((resolve, reject) => { + let logs: string[] = []; + + window['bluetoothSerial'].discoverUnpaired( + (devices) => { + logs.push("Successfully scanned, results..."); + devices.forEach(function (device) { + logs.push("ID: " + device.id + " Name: " + device.name); + }); + resolve(logs); + }, + (failure) => { + logs.push("Failed!"); + logs.push("ERROR: " + failure); + console.debug("ERROR: " + failure); + reject(new Error(failure)); + } + ); + }); +} + + export { gatherData }; \ No newline at end of file From 7fe3958aeadc9781d8d89dc641c434d11731cb98 Mon Sep 17 00:00:00 2001 From: Katie Rischpater <98350084+the-bay-kay@users.noreply.github.com> Date: Mon, 12 Feb 2024 12:16:58 -0800 Subject: [PATCH 06/33] Updated Scanner UI - Formatted buttons - Added `BluetoothCard.tsx` - Centered buttons & Device Info - Fixed "Dismiss" Button, updated to arrow --- www/js/bluetooth/BluetoothCard.tsx | 33 +++++++++++ www/js/bluetooth/BluetoothScanPage.tsx | 82 +++++++++++++------------- www/js/bluetooth/blueoothScanner.ts | 46 ++++++++------- 3 files changed, 97 insertions(+), 64 deletions(-) create mode 100644 www/js/bluetooth/BluetoothCard.tsx diff --git a/www/js/bluetooth/BluetoothCard.tsx b/www/js/bluetooth/BluetoothCard.tsx new file mode 100644 index 000000000..76c14e892 --- /dev/null +++ b/www/js/bluetooth/BluetoothCard.tsx @@ -0,0 +1,33 @@ +import React from 'react'; +import { useTranslation } from 'react-i18next'; +import { Card, List } from 'react-native-paper'; +import { StyleSheet } from 'react-native'; + +type Props = any; +const BluetoothCard = ({ deviceName, deviceData }: Props) => { + const { t } = useTranslation(); + return ( + + } + /> + + ); +}; + +export const cardStyles = StyleSheet.create({ + card: { + position: 'relative', + alignSelf: 'center', + marginVertical: 10, + }, + cardContent: { + flex: 1, + width: '100%', + }, +}); + +export default BluetoothCard; diff --git a/www/js/bluetooth/BluetoothScanPage.tsx b/www/js/bluetooth/BluetoothScanPage.tsx index e885392fb..b3d479caf 100644 --- a/www/js/bluetooth/BluetoothScanPage.tsx +++ b/www/js/bluetooth/BluetoothScanPage.tsx @@ -1,8 +1,11 @@ import React, { useContext, useState, useEffect } from 'react'; import { useTranslation } from 'react-i18next'; import { AppContext } from '../App'; -import { StyleSheet, Text, Modal, ScrollView, SafeAreaView, Pressable } from 'react-native'; -import { gatherData } from './blueoothScanner'; +import { StyleSheet, Modal, ScrollView, SafeAreaView, View } from 'react-native'; +import gatherBluetoothData from './blueoothScanner'; +import { logDebug } from '../plugin/logger'; +import BluetoothCard from './BluetoothCard'; +import { Appbar, useTheme, Button } from 'react-native-paper'; /** * The implementation of this scanner page follows the design of @@ -13,48 +16,48 @@ import { gatherData } from './blueoothScanner'; */ const BluetoothScanPage = ({ ...props }: any) => { const { t } = useTranslation(); - const context = useContext(AppContext); // May not be necessary const [logs, setLogs] = useState([]); - - useEffect(() => { - - }, []); + const { colors } = useTheme(); // Function to run Bluetooth test and update logs const runBluetoothTest = async () => { try { - setLogs(["Loading..."]); - const newLogs = await gatherData(); + const newLogs = await gatherBluetoothData(); setLogs(newLogs); } catch (error) { - console.error(error); + logDebug(error); // Handle error } }; const BlueScanContent = (
-
- { - // TODO: Fix background color of button - - } -
- {'Add Scanner Components here!'} - - -

Console Output:

+ + { + props.onDismiss?.(); + }} + /> + + + + + + + {logs.map((log, index) => ( -

{log}

+ ))}
); @@ -64,9 +67,7 @@ const BluetoothScanPage = ({ ...props }: any) => { - -
{BlueScanContent}
-
+
{BlueScanContent}
@@ -75,18 +76,15 @@ const BluetoothScanPage = ({ ...props }: any) => { }; const s = StyleSheet.create({ - dismissBtn: { + btnContainer: { + padding: 16, + justifyContent: 'center', + }, + btn: { height: 38, fontSize: 11, - color: '#222', - marginRight: 'auto', - display: 'flex', - alignItems: 'center', - padding: 0, + margin: 4, }, - btn: { - display: 'flex' - } }); export default BluetoothScanPage; diff --git a/www/js/bluetooth/blueoothScanner.ts b/www/js/bluetooth/blueoothScanner.ts index 594860442..c311a6476 100644 --- a/www/js/bluetooth/blueoothScanner.ts +++ b/www/js/bluetooth/blueoothScanner.ts @@ -1,23 +1,25 @@ -function gatherData(): Promise { - return new Promise((resolve, reject) => { - let logs: string[] = []; - - window['bluetoothSerial'].discoverUnpaired( - (devices) => { - logs.push("Successfully scanned, results..."); - devices.forEach(function (device) { - logs.push("ID: " + device.id + " Name: " + device.name); - }); - resolve(logs); - }, - (failure) => { - logs.push("Failed!"); - logs.push("ERROR: " + failure); - console.debug("ERROR: " + failure); - reject(new Error(failure)); - } - ); - }); +import { logDebug } from '../plugin/logger'; + +export function gatherBluetoothData(): Promise { + return new Promise((resolve, reject) => { + let logs: string[] = []; + + window['bluetoothSerial'].discoverUnpaired( + (devices: Array) => { + logs.push('Successfully scanned, results...'); + devices.forEach(function (device) { + logs.push('ID: ' + device.id + ' Name: ' + device.name); + }); + resolve(logs); + }, + (err: string) => { + logs.push('Failed!'); + logs.push('ERROR: ' + err); + logDebug('ERROR: ' + err); + reject(new Error(err)); + }, + ); + }); } - - export { gatherData }; \ No newline at end of file + +export default gatherBluetoothData; From 07e4e17729b6eba9c6c32b66f40aeef7c648fdfb Mon Sep 17 00:00:00 2001 From: Katie Rischpater <98350084+the-bay-kay@users.noreply.github.com> Date: Mon, 12 Feb 2024 16:41:53 -0800 Subject: [PATCH 07/33] Added translation support to Bluetooth Scanner Added english translations for scanner components --- www/i18n/en.json | 13 ++++++++++++- www/js/bluetooth/BluetoothCard.tsx | 2 -- www/js/bluetooth/BluetoothScanPage.tsx | 15 +++++++-------- www/js/bluetooth/blueoothScanner.ts | 16 +++++++++++----- 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/www/i18n/en.json b/www/i18n/en.json index 9a1fadec7..4aec6165d 100644 --- a/www/i18n/en.json +++ b/www/i18n/en.json @@ -29,6 +29,7 @@ "user-data": "User data", "erase-data": "Erase data", "dev-zone": "Developer zone", + "bluetooth-scan": "Scan for Bluetooth", "refresh": "Refresh", "end-trip-sync": "End trip + sync", "check-consent": "Check consent", @@ -230,6 +231,15 @@ "list-datepicker-close": "Close", "list-datepicker-set": "Set", + "bluetooth": { + "scan-debug-title": "Bluetooth Scanner", + "scan-for-bluetooth": "Scan for Devices", + "device-info": { + "id": "ID", + "name": "Name" + } + }, + "service": { "reading-server": "Reading from server...", "reading-unprocessed-data": "Reading unprocessed data..." @@ -409,7 +419,8 @@ "while-repopulating-entry": "While repopulating timeline entry: ", "while-loading-metrics": "While loading metrics: ", "while-log-messages": "While getting messages from the log ", - "while-max-index": "While getting max index " + "while-max-index": "While getting max index ", + "while-scanning-bluetooth": "While scanning for Bluetooth Devices: " }, "consent-text": { "title": "NREL OPENPATH PRIVACY POLICY/TERMS OF USE", diff --git a/www/js/bluetooth/BluetoothCard.tsx b/www/js/bluetooth/BluetoothCard.tsx index 76c14e892..cda146f76 100644 --- a/www/js/bluetooth/BluetoothCard.tsx +++ b/www/js/bluetooth/BluetoothCard.tsx @@ -1,11 +1,9 @@ import React from 'react'; -import { useTranslation } from 'react-i18next'; import { Card, List } from 'react-native-paper'; import { StyleSheet } from 'react-native'; type Props = any; const BluetoothCard = ({ deviceName, deviceData }: Props) => { - const { t } = useTranslation(); return ( { const newLogs = await gatherBluetoothData(); setLogs(newLogs); } catch (error) { - logDebug(error); - // Handle error + logWarn(error); + // TODO: Handle error further } }; @@ -41,7 +40,7 @@ const BluetoothScanPage = ({ ...props }: any) => { props.onDismiss?.(); }} /> - + diff --git a/www/js/bluetooth/blueoothScanner.ts b/www/js/bluetooth/blueoothScanner.ts index c311a6476..efad6aea7 100644 --- a/www/js/bluetooth/blueoothScanner.ts +++ b/www/js/bluetooth/blueoothScanner.ts @@ -1,21 +1,27 @@ -import { logDebug } from '../plugin/logger'; +import { logWarn } from '../plugin/logger'; +import { useTranslation } from 'react-i18next'; export function gatherBluetoothData(): Promise { + const { t } = useTranslation(); + return new Promise((resolve, reject) => { let logs: string[] = []; window['bluetoothSerial'].discoverUnpaired( (devices: Array) => { - logs.push('Successfully scanned, results...'); devices.forEach(function (device) { - logs.push('ID: ' + device.id + ' Name: ' + device.name); + logs.push( + `${t('bluetooth.device-info.id')}: ${device.id} ${t('bluetooth.device-info.name')}: ${ + device.name + }`, + ); }); resolve(logs); }, (err: string) => { - logs.push('Failed!'); + logs.push(t('errors.while-scanning-bluetooth')); logs.push('ERROR: ' + err); - logDebug('ERROR: ' + err); + logWarn('ERROR: ' + err); reject(new Error(err)); }, ); From 86957d92e2ac19678667f72cd46aa303d339c90a Mon Sep 17 00:00:00 2001 From: Katie Rischpater <98350084+the-bay-kay@users.noreply.github.com> Date: Tue, 13 Feb 2024 12:08:55 -0800 Subject: [PATCH 08/33] Changed "Scan once" button to "Toggle Scanning" --- www/i18n/en.json | 1 + www/js/bluetooth/BluetoothScanPage.tsx | 26 +++++++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/www/i18n/en.json b/www/i18n/en.json index 4aec6165d..ac4c87469 100644 --- a/www/i18n/en.json +++ b/www/i18n/en.json @@ -234,6 +234,7 @@ "bluetooth": { "scan-debug-title": "Bluetooth Scanner", "scan-for-bluetooth": "Scan for Devices", + "is-scanning": "Scanning...", "device-info": { "id": "ID", "name": "Name" diff --git a/www/js/bluetooth/BluetoothScanPage.tsx b/www/js/bluetooth/BluetoothScanPage.tsx index b570ae44b..40826adf9 100644 --- a/www/js/bluetooth/BluetoothScanPage.tsx +++ b/www/js/bluetooth/BluetoothScanPage.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { StyleSheet, Modal, ScrollView, SafeAreaView, View } from 'react-native'; import gatherBluetoothData from './blueoothScanner'; @@ -16,6 +16,7 @@ import { Appbar, useTheme, Button } from 'react-native-paper'; const BluetoothScanPage = ({ ...props }: any) => { const { t } = useTranslation(); const [logs, setLogs] = useState([]); + const [isScanning, setIsScanning] = useState(false); const { colors } = useTheme(); // Function to run Bluetooth test and update logs @@ -29,6 +30,20 @@ const BluetoothScanPage = ({ ...props }: any) => { } }; + useEffect(() => { + let intervalId; + if (isScanning) { + intervalId = setInterval(runBluetoothTest, 5000); + } else { + clearInterval(intervalId); + } + return () => clearInterval(intervalId); + }, [isScanning]); + + const handleToggle = () => { + setIsScanning(!isScanning); + }; + const BlueScanContent = (
{ style={s.btn}> {t('consent.permissions')} - From 6023c7f39d108991486afd8c58fe2b242a27c5b5 Mon Sep 17 00:00:00 2001 From: louisg1337 Date: Tue, 13 Feb 2024 15:38:35 -0500 Subject: [PATCH 09/33] Refactored the permissions for the bluetooth scanner so that there is now proper error handling. --- www/js/bluetooth/BluetoothScanPage.tsx | 7 ------- www/js/control/BluetoothScanSettingRow.tsx | 12 ++++++++++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/www/js/bluetooth/BluetoothScanPage.tsx b/www/js/bluetooth/BluetoothScanPage.tsx index b570ae44b..a5dc1188d 100644 --- a/www/js/bluetooth/BluetoothScanPage.tsx +++ b/www/js/bluetooth/BluetoothScanPage.tsx @@ -43,13 +43,6 @@ const BluetoothScanPage = ({ ...props }: any) => { - diff --git a/www/js/control/BluetoothScanSettingRow.tsx b/www/js/control/BluetoothScanSettingRow.tsx index 59beff0c9..efbae279a 100644 --- a/www/js/control/BluetoothScanSettingRow.tsx +++ b/www/js/control/BluetoothScanSettingRow.tsx @@ -1,13 +1,21 @@ import React, { useState } from 'react'; import SettingRow from './SettingRow'; import BluetoothScanPage from '../bluetooth/BluetoothScanPage'; +import { displayError } from '../plugin/logger'; const BluetoothScanSettingRow = ({}) => { const [bluePageVisible, setBluePageVisible] = useState(false); - function openPopover() { + async function openPopover() { // TODO: Add logic to check for conifig here, or in settings - setBluePageVisible(true); + + // Check and prompt for bluetooth scan permission + try { + let response = await window['cordova'].plugins.BEMDataCollection.bluetoothScanPermissions(); + if (response == "OK") setBluePageVisible(true) + } catch (e) { + displayError(e, "Insufficient Permissions"); + } } return ( From 4a5d8537efe5e5cbbc5ec605d300694483fcf328 Mon Sep 17 00:00:00 2001 From: louisg1337 Date: Tue, 13 Feb 2024 15:46:09 -0500 Subject: [PATCH 10/33] Got rid of unused permissions button now --- www/js/bluetooth/BluetoothScanPage.tsx | 7 ------- 1 file changed, 7 deletions(-) diff --git a/www/js/bluetooth/BluetoothScanPage.tsx b/www/js/bluetooth/BluetoothScanPage.tsx index 40826adf9..777aaa95d 100644 --- a/www/js/bluetooth/BluetoothScanPage.tsx +++ b/www/js/bluetooth/BluetoothScanPage.tsx @@ -58,13 +58,6 @@ const BluetoothScanPage = ({ ...props }: any) => { - -
-
- -
- - - - - - diff --git a/www/i18n/intro/consent-fr.html b/www/i18n/intro/consent-fr.html deleted file mode 100644 index 74c8ab056..000000000 --- a/www/i18n/intro/consent-fr.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/www/i18n/intro/consent-lo.html b/www/i18n/intro/consent-lo.html deleted file mode 100644 index 47721fbd4..000000000 --- a/www/i18n/intro/consent-lo.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - diff --git a/www/i18n/intro/consent-text-es.html b/www/i18n/intro/consent-text-es.html deleted file mode 100644 index fd970fb11..000000000 --- a/www/i18n/intro/consent-text-es.html +++ /dev/null @@ -1,139 +0,0 @@ - -