-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
☰♭ Adding a Bluetooth Scanner to dev options #1128
Conversation
See Issue [e-mission#1046](e-mission/e-mission-docs#1046 (comment)) 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
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1128 +/- ##
=======================================
Coverage 77.49% 77.49%
=======================================
Files 29 29
Lines 1693 1693
Branches 370 370
=======================================
Hits 1312 1312
Misses 381 381
Flags with carried forward coverage won't be shown. Click here to find out more. |
The button added in settings now will open a Modal "Page" that will (eventually) contain the bluetooth devices within scanning distance!
UI Progress UpdateJust added the bare-bones settings page! I chose to format this page similarly to the Screen.Recording.2024-02-09.at.3.21.30.PM.movTODO
|
It seems I accidentally turned off my local VSCode Prettier... Fixing that now
…eated 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.
Scanner UpdateWe now have a roughly working bluetooth scanner! Big thanks to @the-bay-kay for getting all the react side of stuff setup for us! If you look at the picture it picks up my JBL headphones which I think are bluetooth classic, so it seems like a success. To use the scanner, navigate to the bluetooth page, click on permissions, click Allow, then click scan and wait for the results. Quick run down of what I've done so far:
Notes Since I had to mess around with
After those steps I think we should be all set! I think we have to do it this way until we can get a new release pushed out to Todos
|
First things first, great work getting the scanning working!
Correct! Bluetooth Classic is used for the vast majority of audio data transfer . JBL doesn't disclose what protocol they use, but I'd put good money on it being classic -- which means we should be in business!
I'll get started on these! Just brianstorming some other things left to-do, I think we need to:
With time permitting, we could:
I'm going to start working down the list, focusing on the UX / UI for now -- I'll keep this thread updated as I go! |
- Formatted buttons - Added `BluetoothCard.tsx` - Centered buttons & Device Info - Fixed "Dismiss" Button, updated to arrow
Added english translations for scanner components
Added i18next support and English translations! Below is a video of the current UI, with some dummy examples. As usual, I'll update the to-do list. Some asides:
Screen.Recording.2024-02-12.at.4.52.49.PM.mov |
Working on making the bluetooth scan a "toggle", and ran into a fascinating bug. When attempting to use the Screen.Recording.2024-02-13.at.11.34.23.AM.mov |
…our bluetooth scanner
- Updated plugin to a fork of the original: ideally, this fork should support Bluetooth Classic for both iOS & Android
PR UpdatesLouis and I have been discussing & testing this PR, and wanted to share some notes / updates!
Permissions BugsBelow are a few subtle bugs I've noticed, as I've been working on this. Just dumping these here for now, so they don't get lost as we fix the bigger things!
Going ForwardAs of this moment, our next steps are:
|
- Cards were not splitting logs correctly, fixed to split via index - We should be fine with this rudimentary string parsing technique; from my testing, IDs have not gone past the length given.
Merge to keep branch up to date with master
Still working on the WSOD issue - when looking for more information on the In App Browser (
|
- Updated calls to Bluetooth Plugin, to ensure paired devices are included in the scan list
Some more notes / updates on the WSOD issue:
I just performed a fresh install (Deleted XCode, cleared the simulators, cache, etc.), with no change. At first, I was certain this would fix the issue; since others can build on their devices, I figured it was an issue with my XCode install.. I'll be doing some more research to find a solution! |
Test UpdatesJust wanted to write a few words about these last two commits! I initially had some concerns that our API call ( Unfortunately, it seems that the "visibility" of a signal still applies to pair devices; after running some tests with my car stereo, a "non-visible" device still doesn't appear during a scan, even when it's paired. Still glad to have crossed this off the list of tests! |
Finally managed to re-build! Turns out, this build issue and issue 1053 were closely related. The issue was with my MacOS version, and the plugin 'use strict';
const os = require('os');
const nameMap = new Map([
[23, ['Sonoma', '14.3.1']], // <- Version added
[22, ['Ventura', '13']],
[21, ['Monterey', '12']],
// More versions below
]); // more code below I also manually checked (and edited) I'll go ahead and add these notes to the issue mentioned above, and close it; now that this issue is in the rear view mirror, I'll go ahead and start fixing / testing the iOS build! |
Along with these changes, there has been some work done to incorporate bluetooth permissions into e-mission-datacollection, and here is the respective pull request for that. |
Louis and I chatted earlier this morning, and we agreed the last change necessary for this PR is that we may need to handle iOS's Bluetooth permission acceptance / rejection better. As written, we don't have much of a structure in place for this: if someone rejects the Bluetooth permission, we're unsure if that state is recoverable. I went to test on my hardware, and ran into the same WSOD as before... I'll run some more tests, and then update this PR as necessary! |
Louis and I have both given this a final once-over, and the PR is ready for review! That being said, this does rely on the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of high level changes:
- avoid race conditions
- use the device settings correctly
Once you address those and bump up the version number, I can merge this
- Moved permissions check to BLE Screen, fixed error with permission appearing upon install - Updated OS checks, fixed config export
@the-bay-kay please remember to move the PR back into ready for review after you are done addressing review comments |
- Changed to avoid race conditions in logs
- Display status is indicated through the icon: "bluetooth-off"
- Merge needed to fix Android build issue
Attached below is the functioning, current version of the Bluetooth Classic scanner! Interestingly, I've noticed that Currently re-reading the docs to see if another function would suffice (notabely, .isConnected() is not what we want, it only confirms that something is connected). |
- Changed logs to only pass devices, now parsed in BluetoothCard - Updated promise handling in blueoothScanner - Reverted iOS permissions check
As written, this is ready for merge -- it's functional, if not performing exactly how we'd like. At a glance, I haven't found anything within the function that easily displays connected devices. I'll spend a few more minutes reading through the docs, but then will pivot to try and finish the BLE Scanner. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I only see one minor comment/fix below, which you can handle in the next PR
}); | ||
|
||
Promise.all([unpairedDevicesPromise, pairedDevicesPromise]) | ||
.then((logs: Array<any>) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, future fix: can't this be:
.then((logs: Array<any>) => { | |
.then((logs: Array<BluetoothClassicDevice>) => { |
Purpose
In our upcoming project with GSA GPG, we're hoping to utilize either (a) Classic Bluetooth , or (b) Bluetooth Low-Energy (BLE) Beacons to track vehicle data. Because Classic Bluetooth is found in most modern vehicles, we are hoping to utilize it in our vehicle tracking.
To test the validity of this, we're implementing a rudimentary scanner within the
Developer Zone
of the OpenPATH app. This will be used by the team to record data on the behavior of Classic Bluetooth devices found within personal cars. Then, with this data, we will be able to make a more informed decision on how to proceed with our project!Implementation
Myself and @louisg1337 have come up with a brief set of"Project Requirements" for this project:
<Text/>
), that displays a given Bluetooth Device's informationOur current "bottleneck" is the lack of a comprehensive Cordova Bluetooth plugin. The ability to work with Core Bluetooth was added to iOS was added somewhat (within the past 5 years, according to this article on Apple's site). We've found a few options for Android Scanners, detailed in the issue below. If we are unable to find a "one-size fits all" plugin, we're planning to utilize two separate ones, depending on OS; we've already found some decent options for Android.
For more information on this project please see Issue #1046 .