diff --git a/www/js/bluetooth/BluetoothCard.tsx b/www/js/bluetooth/BluetoothCard.tsx
index 75d27095b..825b47f6f 100644
--- a/www/js/bluetooth/BluetoothCard.tsx
+++ b/www/js/bluetooth/BluetoothCard.tsx
@@ -1,5 +1,5 @@
import React from 'react';
-import { Card, List, useTheme } from 'react-native-paper';
+import { Card, List, Text, Button, useTheme } from 'react-native-paper';
import { StyleSheet } from 'react-native';
type Props = any;
@@ -23,6 +23,19 @@ const BluetoothCard = ({ device, isClassic, isScanningBLE }: Props) => {
bgColor = device.in_range ? `rgba(200,250,200,1)` : `rgba(250,200,200,1)`;
}
+ async function fakeCallback() {
+ // If we don't do this, the results start accumulating in the device object
+ // first call, we put a result into the device
+ // second call, the device already has a result, so we put another one in...
+ const deviceWithoutResult = {...device};
+ deviceWithoutResult.result = undefined;
+ window['cordova'].plugins.locationManager.getDelegate().didDetermineStateForRegion({
+ region: deviceWithoutResult,
+ eventType: "didDetermineStateForRegion",
+ state: "CLRegionStateInside"
+ });
+ }
+
return (
{
subtitle={`Configured major ${device.major} and minor ${device.minor}`} // e.g.,
left={() => }
/>
+
+ {device.result}
+
+
);
};
diff --git a/www/js/bluetooth/BluetoothScanPage.tsx b/www/js/bluetooth/BluetoothScanPage.tsx
index f9287d211..69a982cdf 100644
--- a/www/js/bluetooth/BluetoothScanPage.tsx
+++ b/www/js/bluetooth/BluetoothScanPage.tsx
@@ -85,11 +85,12 @@ const BluetoothScanPage = ({ ...props }: any) => {
}
}
- function setRangeStatus(uuid: string, status: boolean) {
+ function setRangeStatus(uuid: string, result: string, status: boolean) {
setSampleBLEDevices((prevDevices) => ({
...prevDevices,
[uuid]: {
...prevDevices[uuid],
+ result: result,
in_range: status,
},
}));
@@ -104,16 +105,17 @@ const BluetoothScanPage = ({ ...props }: any) => {
delegate.didDetermineStateForRegion = function (pluginResult: BLEPluginCallback) {
// `stateInside`is returned when the user enters the beacon region
// `StateOutside` is either (i) left region, or (ii) started scanner (outside region)
+ const pluginResultStr = JSON.stringify(pluginResult, null, 2);
if (pluginResult.state == 'CLRegionStateInside') {
// need toUpperCase(), b/c callback returns with only lowercase values...
- setRangeStatus(pluginResult.region.uuid.toUpperCase(), true);
+ setRangeStatus(pluginResult.region.uuid.toUpperCase(), pluginResultStr, true);
} else if (pluginResult.state == 'CLRegionStateOutside') {
- setRangeStatus(pluginResult.region.uuid.toUpperCase(), false);
+ setRangeStatus(pluginResult.region.uuid.toUpperCase(), pluginResultStr, false);
}
logDebug('[BLE] didDetermineStateForRegion');
- logDebug(JSON.stringify(pluginResult, null, 2));
+ logDebug(pluginResultStr);
window['cordova'].plugins.locationManager.appendToDeviceLog(
- '[DOM] didDetermineStateForRegion: ' + JSON.stringify(pluginResult, null, 2),
+ '[DOM] didDetermineStateForRegion: ' + pluginResultStr,
);
};
@@ -287,7 +289,7 @@ const BluetoothScanPage = ({ ...props }: any) => {
setNewUUID(t)}
+ onChangeText={(t) => setNewUUID(t.toUpperCase())}
/>