From ba3ef4365c655080825950ee820c4f59869cdf2b Mon Sep 17 00:00:00 2001 From: "K. Shankari" Date: Thu, 11 Apr 2024 09:42:56 -0700 Subject: [PATCH] Fill in a "beacons" array for the range callback The array has randomly generated accuracy and RSSI values Further, when we exit the region, all the results are undefined This is part of the change to test the data model defined in https://github.com/e-mission/e-mission-docs/issues/1062#issuecomment-2027849093 --- www/js/bluetooth/BluetoothCard.tsx | 22 +++++++++++++++------- www/js/bluetooth/BluetoothScanPage.tsx | 3 ++- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/www/js/bluetooth/BluetoothCard.tsx b/www/js/bluetooth/BluetoothCard.tsx index 561bf9045..d3361badc 100644 --- a/www/js/bluetooth/BluetoothCard.tsx +++ b/www/js/bluetooth/BluetoothCard.tsx @@ -38,13 +38,21 @@ const BluetoothCard = ({ device, isClassic, isScanningBLE }: Props) => { } async function fakeRangeCallback() { - const deviceWithMajorMinor = { ...device }; - deviceWithMajorMinor.major = device.major | 1234; - deviceWithMajorMinor.minor = device.minor | 4567; - deviceWithMajorMinor.monitorResult = undefined; - deviceWithMajorMinor.rangeResult = undefined; + const deviceWithBeacons = { ...device }; + deviceWithBeacons.monitorResult = undefined; + deviceWithBeacons.rangeResult = undefined; + deviceWithBeacons.beacons = [ + {uuid: device.uuid, + major: device.major | 4567, + minor: device.minor | 1945, + proximity: "ProximityNear", + accuracy: Math.random() * 1.33, + rssi: Math.random() * -62} + ] + deviceWithBeacons.minor = device.minor | 4567; + deviceWithBeacons.minor = device.minor | 4567; window['cordova'].plugins.locationManager.getDelegate().didRangeBeaconsInRegion({ - region: deviceWithMajorMinor, + region: deviceWithBeacons, eventType: 'didRangeBeaconsInRegion', state: 'CLRegionStateInside', }); @@ -65,7 +73,7 @@ const BluetoothCard = ({ device, isClassic, isScanningBLE }: Props) => { {device.rangeResult} - + diff --git a/www/js/bluetooth/BluetoothScanPage.tsx b/www/js/bluetooth/BluetoothScanPage.tsx index 6e2387ad3..435a7c4de 100644 --- a/www/js/bluetooth/BluetoothScanPage.tsx +++ b/www/js/bluetooth/BluetoothScanPage.tsx @@ -90,7 +90,8 @@ const BluetoothScanPage = ({ ...props }: any) => { ...prevDevices, [uuid]: { ...prevDevices[uuid], - monitorResult: result, + monitorResult: status? result : undefined, + rangeResult: undefined, in_range: status, }, }));