Flutter Passive Sensing
- Download and install Flutter for your development platform flutter
- Follow instructions on how to enable your device for development. On Android, you need to go to Settings -> About -> Software Information -> Build Information. Click "Build Information" 7 times to enable developer options. From developer options, you need to enable development mode and USB Debugging.
- Connect your device via a cable, accept USB transfer from your phone
- From your computer you can do
flutter devices
To see your device
- Build the project
flutter pub get
- Run the project
flutter run
This may take a moment and will launch the app.
I decided to use the most naive approach in the interest of meeting the time requirement.
We need to make sure we ask the user to consent to bluetooth scanning and saving to local storage.
The bluetooth scanning is simple. We just run a scan every 10 seconds and give it 5 seconds to complete. From those results, we count the number of devices, average the signal strength, and save to a hive database. Concurrently we also update the nearby devices list.
The time series chart is intended to support user gestures. So the user can scroll to the left and right. If the user scrolls all the way to the right side, the live stream will show.
This first version was developed for an Android target device on a Linux desktop, so that has received the most testing. I also included changes to the IOS info.plist file to support permission checks on IOS. However, I do not have an IOS device and did not find a quick way to use an IOS emulator on Linux, although that does surprise me. In the interest of time, I focused on Android although I did check that Hive is cross platform, so I don't expect any issues there.
I did not focus on any optimizations for this project. However, I can think of a few simple ideas:
- Scan less frequently
- Use bluetooth low energy
- Use background scans
- Filter out specific device types
There are a lot of other improvements I'd make to this with more time:
- Move the device list to a different page so we have more space
- Reconsider the way data is saved to hive. If we instead saved the timestamp, device info, and signal strength, we could then introduce more interesting filtering for devices or signal strengths
- I'd introduce a button to clear scan data and consider adding a ttl on the hive data so the app doesn't bloat
- Ideally we'd isolate the scrolling and chart logic (rescaling) from the chart data
- It would be good to tweak the line too. The line that is used out of the box is a bit sensitive to changes. I would probably start by investigating how smoothing out past data with a X-period of time rolling lookback window would work.
- Introduce testing