Skip to content
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

Simulate BLE scans from the phone UI #1140

Merged
merged 8 commits into from
Mar 29, 2024

Conversation

shankari
Copy link
Contributor

  • Makes it easier to test how BLE works
  • Makes it easier to test the plumbing end to end in the emulator

Without this change, we get an error

```
Warning: Each child in a list should have a unique "key" prop.

Check the render method of `BluetoothCardList`. See https://reactjs.org/link/warning-keys for more information.
BluetoothCard@ionic://localhost/dist/bundle.js:21253:18
BluetoothCardList@ionic://localhost/dist/bundle.js:21666:21
```

With this change, the error does not occur
We currently have two hardcoded beacons in the list. But everybody is going to
have their own beacon for testing. Let's make it possible to add new UUIDs

Changes:
- New field to enter the UUID
- Add button
- When add button is clicked, add new entry with the specified UUID and dummy
  values

Testing done:
Entered two separate UUIDs and clicked "Add"
Two new entries were created in the list
- Creates a new set of fields at the botton of the page for the UUID,
  identifier, major and minor fields
- Adds a new "Add" button
- When the "Add" button is pressed, we add a new UUID entry to the default list
- After the new entry is added, we clear out the old values to prepare for a
  new entry

Testing done:
Added three new entries. They were displayed in the list
e-mission/e-mission-docs#1062 (comment)
@shankari shankari marked this pull request as draft March 29, 2024 00:54
Instead of the statically coded name/identifier
This involved changing the text size so that we could see the UUID
I wonder if we should make the UUID the subtitle and the major:minor the title

Testing done:
e-mission/e-mission-docs#1062 (comment)
We don't know what the result will look like when there are multiple beacons with the same UUID, so we just stringify and display the result.
We cannot test this without having an actual BLE beacon, so I have added a "fake callback button to simulate a callback"

Changes:
- stringify the result in `didDetermineStateForRegion` and pass it in to
  `setRangeStatus`
- Change the BluetoothCard to display the `device.result` as Card.Content
- Add a new button to fake a callback for a device by getting the delegate and
  invoking the `didDetermineStateForRegion` method on it with the device
- Remove the existing result in the device before invoking the callback to
  avoid nested results

Testing done:
e-mission/e-mission-docs#1062 (comment)
@shankari
Copy link
Contributor Author

@JGreenlee I would appreciate a review of this change since it is my first ever RN change. You are clearly more skilled than me in the e-mission UI at this point. However, in order to unblock us on the BLE work (notably to test e-mission/e-mission-docs#1062 (comment)), I plan to merge this tonight and create a new staging release.

I will address your comments in a cleanup PR.

@shankari shankari marked this pull request as ready for review March 29, 2024 03:45
@shankari
Copy link
Contributor Author

The testing results are in e-mission/e-mission-docs#1062
I should have put the screenshots in here but forgot. Sorry!

Copy link

codecov bot commented Mar 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.49%. Comparing base (d0ed16b) to head (7c70840).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1140   +/-   ##
=======================================
  Coverage   77.49%   77.49%           
=======================================
  Files          29       29           
  Lines        1693     1693           
  Branches      370      370           
=======================================
  Hits         1312     1312           
  Misses        381      381           
Flag Coverage Δ
unit 77.49% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

@shankari
Copy link
Contributor Author

Before callbacks Fake callback with monitor and range results (note that major/minor are different for range because of the hardcoded values Trying with invalid UUID; first call succeeds but second call fails Trying with a new random UUID and unset major and minor; range callback has them set to the hardcoded values
simulator_screenshot_C9B5EFD6-325C-4238-8C47-3757FB885660 simulator_screenshot_308FDD34-0A45-415F-9C05-5CCC46EB537B simulator_screenshot_3DCCB48D-1004-402A-9C4C-BF959CDCABF5 simulator_screenshot_0C349050-DB4E-466F-A759-ACA544BF0B9B

Changes:
- in the monitor callback, launch the range call with the UUID that was found
- change the fake callback to call the range callback 500ms after the merge
  callback
- store the two results separately
- display the two results separately using different background colors
@shankari shankari merged commit 76839de into e-mission:master Mar 29, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant