Skip to content

Commit

Permalink
Fill in a "beacons" array for the range callback
Browse files Browse the repository at this point in the history
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
e-mission/e-mission-docs#1062 (comment)
  • Loading branch information
shankari committed Apr 11, 2024
1 parent 26c388d commit ba3ef43
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
22 changes: 15 additions & 7 deletions www/js/bluetooth/BluetoothCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
});
Expand All @@ -65,7 +73,7 @@ const BluetoothCard = ({ device, isClassic, isScanningBLE }: Props) => {
<Text style={{ backgroundColor: colors.secondaryContainer }} variant="bodyMedium">
{device.rangeResult}
</Text>
<Card.Actions>
<Card.Actions >
<Button mode="elevated" onPress={() => fakeMonitorCallback('CLRegionStateInside')}>
Enter
</Button>
Expand Down
3 changes: 2 additions & 1 deletion www/js/bluetooth/BluetoothScanPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ const BluetoothScanPage = ({ ...props }: any) => {
...prevDevices,
[uuid]: {
...prevDevices[uuid],
monitorResult: result,
monitorResult: status? result : undefined,
rangeResult: undefined,
in_range: status,
},
}));
Expand Down

0 comments on commit ba3ef43

Please sign in to comment.