From 8bc0457fda083414a05872f1d36478e130041da3 Mon Sep 17 00:00:00 2001 From: "K. Shankari" Date: Thu, 28 Mar 2024 17:35:36 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Allow=20users=20to=20add=20new?= =?UTF-8?q?=20beacons=20to=20be=20scanned=20through=20the=20UI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Creates a new set of fields at the botton of the page for the UUID, identifier, major and minor fields - Adds a new "Add" button - When the "Add" button is pressed, we add a new UUID entry to the default list - After the new entry is added, we clear out the old values to prepare for a new entry Testing done: Added three new entries. They were displayed in the list https://github.com/e-mission/e-mission-docs/issues/1062#issuecomment-2026395782 --- www/js/bluetooth/BluetoothScanPage.tsx | 45 +++++++++++++++++++------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/www/js/bluetooth/BluetoothScanPage.tsx b/www/js/bluetooth/BluetoothScanPage.tsx index d3d34233f..bdb352946 100644 --- a/www/js/bluetooth/BluetoothScanPage.tsx +++ b/www/js/bluetooth/BluetoothScanPage.tsx @@ -40,7 +40,10 @@ const BluetoothScanPage = ({ ...props }: any) => { const [isScanningClassic, setIsScanningClassic] = useState(false); const [isScanningBLE, setIsScanningBLE] = useState(false); const [isClassic, setIsClassic] = useState(false); - const [newUUID, setNewUUID] = useState(null); + const [newUUID, setNewUUID] = useState(null); + const [newIdentifier, setNewIdentifier] = useState(null); + const [newMajor, setNewMajor] = useState(0); + const [newMinor, setNewMinor] = useState(0); const { colors } = useTheme(); // Flattens the `sampleBeacons` into an array of BLEBeaconDevices @@ -171,16 +174,20 @@ const BluetoothScanPage = ({ ...props }: any) => { }; // Add a beacon with the new UUID to the list of BLE devices to scan - function addNewUUID(newUUID: string) { + function addNewUUID(newUUID: string, newIdentifier: string, newMajor: number, newMinor: number) { console.log("Before adding UUID "+newUUID+" entries = "+sampleBLEDevices); const devicesWithAddition = {...sampleBLEDevices}; devicesWithAddition[newUUID] = { - identifier: 'Test-Beacon', - minor: 4949, - major: 3838, + identifier: newIdentifier, + minor: newMajor, + major: newMinor, in_range: false, } setSampleBLEDevices(devicesWithAddition); + setNewUUID(null); + setNewIdentifier(null); + setNewMajor(null); + setNewMinor(null); } const BluetoothCardList = ({ devices }) => { @@ -277,12 +284,28 @@ const BluetoothScanPage = ({ ...props }: any) => { - setNewUUID(t)} - /> -