-
Notifications
You must be signed in to change notification settings - Fork 19
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
🍏 🛜 iOS BLE Integration #220
Conversation
- Added `kScanningForBLEState` state - Added transitions `[CFCTransitionScanBLE, CFCTransitionBLEFound, CFCTransitionBLENotFound]` - `kScanningForBLEState` is between `kWaitingForTripStartState` and `kOngoingTripState`
Just reached the first design hurdle... As discussed here, Because (i) iOS 17.0 was released relatively recently, (ii) We currently support iOS 13.0+ (iii) We cannot reliably expect users to update their phones for OpenPATH, I'm very hesitant to use this moving forward. As I see it, we've got a few choices:
My current plan is to begin tests with the older CLBeaconRegion, per my concerns above. @shankari , let me know if you'd like me to proceed another way! I'll be using |
Looking to separate the Bluetooth functionality into a separate function, similar to |
This article from 2017 seems to suggest the following about
If this is true, this:
I haven't been able to find any articles / threads corroborating this, will investigate further... |
Probably barking up the wrong tree here, don't think we can do this. If I understand the documentation correctly, we can only have one delegate at a time: and, in the case of Considering the bluetooth scanning is technically an action performed in the TDSM, I'll try adding the scanner to the preexisting delegate instead. |
Currently working out how we're going to check if BLE Scanning has "timed out" (i.e., if we exit a geofence and there is no beacon available, what should we do?)
EDIT: maybe I misunderstand |
Correct. Just to clarify, each instance of location manager can only have one delegate. And since we are going to reuse the location manager between both the location and the bluetooth regions, we must use the same delegate. I was going to clarify this tonight; I'm glad you figured it out yourself 😄 |
More of a general design question, for my own understanding -- what is the purpose of including the notifications within + (void) startTracking:(NSString*) transition withLocationMgr:(CLLocationManager*)locMgr {
[self startTrackingLocation:locMgr];
[[NSNotificationCenter defaultCenter] postNotificationName:CFCTransitionNotificationName // <- The line in question...
object:CFCTransitionTripStarted];
} But, when called in - (void) handleWaitingForTripStart:(NSString*) transition withUserInfo:(NSDictionary*) userInfo {
// More code...
else if ([transition isEqualToString:CFCTransitionVisitEnded]) {
if ([ConfigManager instance].ios_use_visit_notifications_for_detection) {
// We first start tracking and then delete the geofence to make sure that we are always tracking something
[TripDiaryActions startTracking:transition withLocationMgr:self.locMgr];
[TripDiaryActions deleteGeofence:self.locMgr];
[[NSNotificationCenter defaultCenter] postNotificationName:CFCTransitionNotificationName // <- Same notification
object:CFCTransitionTripStarted];
}
// ....
} I have to assume this was done intentionally -- why not just have the notification fire off once? What is the reason to having it occur twice? I'll follow this design pattern for the BLE integration, but I'm curious as to justification for doing so! |
Well, there may be some issues with using "edu.berkeley.eecs.emission" as our identifier. When working with the BK011, the Beacon Name / Identifier has a limit of 17 ASCII characters... For testing sake, I'll shorten this to "nrel.emission". We may be able to set a larger identifier with the iBKS 105, but this is unlikely. |
TODO: - Run tests to confirm these changes perform correctly - Add second phase of beacon ranging after intial region monitoring
Testing SetupSpent ~3 hours running errands today with the following OpenPATH configurations:
Tests PerformedHere are the two tests I performed:
Results:iBeacon Broadcasting:
No Beacon Present:
EDIT: It seems that the Fleet version of the app does not start tracking, even when an iBeacon is present. My initial hope was caused by a false positive, where two phones (Staging & Fleet) were logged into the same opcode. Having addressed this issue, it appears that the tracking is not starting. Unfortunate, but data is data. Calling it a night for now will check the logs and reevaluate tomorrow morning. |
Ran a second round of tests, with the following config:
For these tests, I took two trips as described above. Will report back on the results! |
Second Round of TestsThe data has been processed through the pipeline, with some unexpected results. I'll describe them in the table below. In the interest of not disclosing my address, I won't be including screenshots on the public repo -- feel free to shoot me a message if you'd like more details! As with past tests, the setup of the "With Beacon" tests and "Without Beacon" tests is as follows:
Test Results
AnalysisAs we can see, the behavior we're recording isn't exactly what we'd expect. From these two (limited) tests, it seems we can draw two conclusions:
My plan is to spend some time sifting through the logs to determine exactly what happened during these tests! |
Note: Looking into the logs, it seems I was wrong about the "20-second timeout period" when running CLLocationMonitor's
|
Region Monitoring ObservationsWell, it may not be the culprit, but I do think I've found an issue with my code... Current CodeRight now, we're checking the region entrance in // After scanning is set up (as above), this will be called when a given beacon is in range
- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region {
// We only monitor the entrance of BLE Regions...
if([region.identifier compare:OpenPATHBeaconIdentifier] != NSOrderedSame) {
[[NSNotificationCenter defaultCenter] postNotificationName:CFCTransitionNotificationName
object:CFCTransitionBLEFound];
return;
} Compare this to how the logs display the region: Beacon Detected
No Beacon Detected
ObservationRegardless of whether or not the region was within range, it appears that the Next StepsIf I am unable to find an obvious culprit for the tracking issues, I think my next plan is to add some logs to the |
Standardizing OpenPATH UUIDJust wanted to add a quick note about what UUID's we'll be using! As Jack discussed in this thread, we'll be using the iBeacon signature as follows:
Since we need a unique UUID, Shankari and I decided to generate one with Python as follows: >>> import uuid
>>> uuid.uuid3(uuid.NAMESPACE_DNS, 'gov.nrel.cims.openpath')
UUID('bf3df3b1-6e46-35fa-86e5-927c95dd096c')
>>> Going forward, I will be configuring my test beacons to use the following:
|
Adds 2 fields to the dynamic config (as described in e-mission/e-mission-docs#1062) For vehicle identities, I have only added 1 so far: my own car with the Accent beacon I have in my possession. I will configure this beacon with the UUID described here e-mission/e-mission-data-collection#220 (comment); and with the major and minor values I put in the config ("dfc0:fff0") Will add others' vehicles once I have that information. Also sets "tracking" . "bluetooth_only" to true, to signify that we will not track trips unless one of these vehicles is recognized.
@the-bay-kay I think this looks fine at a high level. Some potential cleanups:
Please update this with how it worked when you implemented it! |
So far, not so good -- It appears none of my trips got tracked yesterday... Going to 2xcheck that (i) EDIT: |
Well, that was an embarrassing bug 🤦♀️ Turns out, having two checks for the same region would cause some issues.... } else if ([transition isEqualToString:CFCTransitionEnterBLERegion]) { // <- The Problem!!
// FLEET: If we detected a BLE Region before
// Now, we'll have to check for the GeoFENCE Exit
[[NSNotificationCenter defaultCenter] postNotificationName:CFCTransitionNotificationName
object:CFCTransitionEnterBLERegion];
} else if ([transition isEqualToString:CFCTransitionVisitEnded]) {
if ([ConfigManager instance].ios_use_visit_notifications_for_detection) {
// We first start tracking and then delete the geofence to make sure that we are always tracking something
[TripDiaryActions startTracking:transition withLocationMgr:self.locMgr];
[TripDiaryActions deleteGeofence:self.locMgr];
[[NSNotificationCenter defaultCenter] postNotificationName:CFCTransitionNotificationName
object:CFCTransitionTripStarted];
}
} else if ([transition isEqualToString:CFCTransitionTripStarted]) {
[self setState:kOngoingTripState withChecks:TRUE];
} else if ([transition isEqualToString:CFCTransitionEnterBLERegion]) {
[self setState:kCheckingGeofenceState withChecks:TRUE];
} At least it's a quick fix. Recompiling, then I'll go on a few walks (Car's low on gas, don't wanna waste fuel driving circles!) and report my findings. |
Back from a walk with the beacon, waiting for the data to process. In the mean time, to address your questions @shankari :
EDIT I misread that -- I believe you're correct, the two initializations can happen in parallel!
That step is missing from the diagram, but already in the code! I'll update my diagram accordingly -- once this is fully working, I'll draw up a new rendition of the FSM.
Correct! I believe this will occur as it already does -- I shouldn't be touching any of the outgoing edges from |
More issues with the current version, my walk did not record. Looking at the logs, it appears I successfully entered the region and transitioned to 1414,1712863583.01609,2024-04-11T12:26:23.016090-07:00,"Received geofence exit in state STATE_CHECKING_GEOFENCE, ignoring"
1415,1712863583.01946,2024-04-11T12:26:23.019460-07:00,Current state of region STATIONARY_GEOFENCE_LOCATION is 2 (outside) When at the /*
* handleCheckGeofenceStatus is an function for the Fleet Deployment, that checks
* for a Geofence exit after a BLE Beacon has been detected.
*/
- (void) handleCheckGeofenceStatus:(NSString*) transition withUserInfo:(NSDictionary*) userInfo {
if ([transition isEqualToString:CFCTransitionExitedGeofence]) {
[TripDiaryActions deleteGeofence:self.locMgr];
[[NSNotificationCenter defaultCenter] postNotificationName:CFCTransitionNotificationName
object:CFCTransitionTripStarted];
} else if ([transition isEqualToString:CFCTransitionExitBLERegion]) {
// Left BLE Region without geofence exit, don't start tracking
[[NSNotificationCenter defaultCenter] postNotificationName:CFCTransitionNotificationName
object:CFCTransitionFailedToExitGeofence];
} else if ([transition isEqualToString:CFCTransitionFailedToExitGeofence]) {
[self setState:kWaitingForTripStartState withChecks:TRUE];
} else if ([transition isEqualToString:CFCTransitionTripStarted]) {
[self setState:kOngoingTripState withChecks:TRUE];
} else if ([transition isEqualToString:CFCTransitionEnterBLERegion]) {
// If we just entered this state, NOOP to stay here
[[NSNotificationCenter defaultCenter] postNotificationName:CFCTransitionNotificationName
object:CFCTransitionNOP];
} else {
NSLog(@"Got unexpected transition %@ in state %@, ignoring",
transition,
[TripDiaryStateMachine getStateName:self.currState]);
}
}
EDITTurns out the answer was pretty obvious. When the geofence exit is checked, we also check the current state, before sending out the notification (link). Will add the |
@the-bay-kay I think you should draw out the FSM carefully (maybe in a powerpoint) and make sure that you have thought through it carefully. If the FSM is right, the implementation will be right. |
FSM ChangesShankari and I met this morning to discuss the structure of the FSM. Considering Alpha testing begins in 3 days, and we noticed that the BLE Region status was the deciding factor along all of the steps in the FSM, we opted to remove the Geofence for the time being. After alpha testing is complete, we'll most likely re-incorporate the geofence. Below is my updated FSM, utilizing only the the BLE Region Status / Ranging Status. Following that are some additional notes on my design: Some notes on this design:
1390,1712863393.14896,2024-04-11T12:23:13.148960-07:00,[BLE] didDetermineStateForRegion
1391,1712863393.15425,2024-04-11T12:23:13.154250-07:00,"{
""region"": {
""typeName"": ""BeaconRegion"",
""uuid"": ""BF3DF3B1-6E46-35FA-86E5-927C95DD096C"",
""identifier"": ""nrel.emission""
},
""eventType"": ""didDetermineStateForRegion"",
""state"": ""CLRegionStateInside""
}"
1392,1712863393.16959,2024-04-11T12:23:13.169590-07:00,[BLE] didRangeBeaconsInRegion
1393,1712863393.17201,2024-04-11T12:23:13.172010-07:00,"{
""region"": {
""typeName"": ""BeaconRegion"",
""uuid"": ""BF3DF3B1-6E46-35FA-86E5-927C95DD096C"",
""identifier"": ""edu.berkeley.eecs.emission""
},
""eventType"": ""didRangeBeaconsInRegion"",
""beacons"": []
}"
1394,1712863394.24039,2024-04-11T12:23:14.240390-07:00,[BLE] didRangeBeaconsInRegion
1395,1712863394.24869,2024-04-11T12:23:14.248690-07:00,"{
""region"": {
""typeName"": ""BeaconRegion"",
""uuid"": ""BF3DF3B1-6E46-35FA-86E5-927C95DD096C"",
""identifier"": ""edu.berkeley.eecs.emission""
},
""eventType"": ""didRangeBeaconsInRegion"",
""beacons"": [
{
""minor"": 1972,
""rssi"": -67,
""major"": 57280,
""proximity"": ""ProximityImmediate"",
""accuracy"": 0.22,
""uuid"": ""BF3DF3B1-6E46-35FA-86E5-927C95DD096C""
}
]
}"
While these two feel incredibly similar, I do believe the |
@the-bay-kay for this initial implementation, I think this is way too complicated. You should use only beacon ranging as the trigger out of ongoing_trip as well. If we get a Can you clarify why you need |
@shankari I'm somewhat confused -- In this version, I am using the beacon ranging as the trigger out of I added the |
- This current iteration should only track when a BLE Beacon is within range - TODO: - Address varios TODO comments within code - Case on the Dynamic Config, such that only FLEET deployments use BLE - Store BLE sensor data
iOS Updates, Future WorkI was able to install the latest version of the BLE build -- there are still several issues to work out, but we are now successfully only tracking within the presence of a BLE Beacon [Image 1] Because:
I believe the best course of action is to implement the following remaining features, before debugging the FSM Changes further:
Once these two pieces have been integrated, I plan to:
Proof of trip tracking: |
@the-bay-kay I have pulled these changes and simplified it. Concretely, you have a bunch of code which had commented out the non-fleet version. We cannot push a version to production with those changes (it will break everybody else), and we cannot really have the GSA folks all use staging builds. The non-fleet version needs to stay production quality - only the fleet version can be alpha quality. I don't have a beacon, so let us please allocate some time today for testing. |
@shankari Understood -- I forgot to add it to my initial post, but adding the config check was on my list of changes to make this evening. Almost done incorporating the BLE permission check in the popup -- I'll link to the PR once I've confirmed it's working. Once that is done, I'll pivot to the config check. I'll allocate some time to drive around this evening for tests as well, once the pop-up is done. Let me know if there are any other components I'm missing. |
@the-bay-kay let me clarify - I am done with the config checks. I am adding code to save the entries, and after testing, I am going to push that to staging for people with actual BLE beacons to test. Will then pull the last UI changes and hopefully send it off to production tonight/early tomorrow. |
Ah, I misunderstood -- When those changes are ready, LMK which branch to pull from, so my permissions changes are up to date with that. After I am done with this, what would you like me to prioritize as to not double up on work -- debugging and re-testing the beacon tracking? |
…d non-fleet cases The previous code had the non-fleet versions commented out. However, when we push this to production, we need to support both fleet and non-fleet versions. Making sure we keep the original functionality for the fleet case. Also, consistent with e-mission/e-mission-docs#1062 (comment) and e-mission/e-mission-docs#1062 (comment) used the standard transitions from the data model instead NOTE: that the `isFleet` is currently hardcoded, we need to read it properly from the dynamic config Testing done: 2024-04-14 14:47:18.722084-0700 emission[53427:11554764] In TripDiaryStateMachine, received transition T_EXITED_GEOFENCE in state STATE_WAITING_FOR_TRIP_START 2024-04-14 14:47:18.728881-0700 emission[53427:11554764] Got transition T_EXITED_GEOFENCE in state STATE_WAITING_FOR_TRIP_START with fleet mode, checking for beacons before starting location tracking 2024-04-14 14:50:45.818623-0700 emission[53427:11554764] In TripDiaryStateMachine, received transition T_BLE_BEACON_FOUND in state STATE_WAITING_FOR_TRIP_START 2024-04-14 14:50:45.823268-0700 emission[53427:11554764] Got transition T_BLE_BEACON_FOUND in state STATE_WAITING_FOR_TRIP_START with fleet mode, starting location tracking 2024-04-14 14:51:53.498788-0700 emission[53427:11554764] DEBUG: In TripDiaryStateMachine, received transition T_BLE_BEACON_LOST in state STATE_ONGOING_TRIP START 2024-04-14 14:51:53.685614 POST /usercache/put START 2024-04-14 14:51:53.723916 POST /usercache/get END 2024-04-14 14:51:53.779754 POST /usercache/get 4c152d72-a66d-4472-93f4-62b07c9e110f 0.055525779724121094 END 2024-04-14 14:51:54.061900 POST /usercache/put 4c152d72-a66d-4472-93f4-62b07c9e110f 0.3760108947753906 ``` 2024-04-14 14:57:32.309087-0700 emission[53427:11554764] DEBUG: In TripDiaryStateMachine, received transition T_BLE_BEACON_FOUND in state STATE_WAITING_FOR_TRIP_START 2024-04-14 14:57:32.313790-0700 emission[53427:11554764] Got transition T_BLE_BEACON_FOUND in state STATE_WAITING_FOR_TRIP_START with fleet mode, starting location tracking 2024-04-14 14:57:32.314013-0700 emission[53427:11554764] started fine location tracking with accuracy = -1 and distanceFilter = 1 2024-04-14 14:57:32.316945-0700 emission[53427:11554764] In TripDiaryStateMachine, received transition T_TRIP_STARTED in state STATE_WAITING_FOR_TRIP_START 2024-04-14 14:57:32.323449-0700 emission[53427:11554764] DEBUG: Moved from STATE_WAITING_FOR_TRIP_START to STATE_ONGOING_TRIP ``` ``` 2024-04-14 15:21:38.026872-0700 emission[53427:11554764] Got transition T_BLE_BEACON_FOUND in state STATE_WAITING_FOR_TRIP_START with fleet mode, starting location tracking 2024-04-14 15:28:31.763608-0700 emission[53427:11554764] Got transition T_TRIP_END_DETECTED in state STATE_ONGOING_TRIP with fleet mode, still seeing beacon but no location updates, ignoring 2024-04-14 15:29:27.951348-0700 emission[53427:11554764] DEBUG: In TripDiaryStateMachine, received transition T_BLE_BEACON_LOST in state STATE_ONGOING_TRIP 2024-04-14 15:29:27.977814-0700 emission[53427:11554764] In TripDiaryStateMachine, received transition T_END_TRIP_TRACKING in state STATE_ONGOING_TRIP 2024-04-14 15:29:27.986602-0700 emission[53427:11554764] In TripDiaryStateMachine, received transition T_TRIP_ENDED in state STATE_ONGOING_TRIP 2024-04-14 15:29:28.033050-0700 emission[53427:11554764] DEBUG: Moved from STATE_ONGOING_TRIP to STATE_WAITING_FOR_TRIP_START ``` ``` 2024-04-14 15:40:45.930239-0700 emission[65361:11644200] In TripDiaryStateMachine, received transition T_EXITED_GEOFENCE in state STATE_WAITING_FOR_TRIP_START 2024-04-14 15:40:45.938188-0700 emission[65361:11644200] In TripDiaryStateMachine, received transition T_TRIP_STARTED in state STATE_WAITING_FOR_TRIP_START 2024-04-14 15:40:45.968094-0700 emission[65361:11644200] In TripDiaryStateMachine, received transition T_TRIP_STARTED in state STATE_ONGOING_TRIP 2024-04-14 15:40:45.978604-0700 emission[65361:11644200] In TripDiaryStateMachine, received transition T_TRIP_RESTARTED in state STATE_ONGOING_TRIP 2024-04-14 15:40:45.987830-0700 emission[65361:11644200] In TripDiaryStateMachine, received transition T_TRIP_RESTARTED in state STATE_ONGOING_TRIP 2024-04-14 15:41:12.876066-0700 emission[65361:11644200] In TripDiaryStateMachine, received transition T_BLE_BEACON_FOUND in state STATE_ONGOING_TRIP 2024-04-14 15:41:22.486777-0700 emission[65361:11644200] In TripDiaryStateMachine, received transition T_BLE_BEACON_FOUND in state STATE_ONGOING_TRIP 2024-04-14 15:41:24.861993-0700 emission[65361:11644200] In TripDiaryStateMachine, received transition T_BLE_BEACON_FOUND in state STATE_ONGOING_TRIP 2024-04-14 15:41:27.220213-0700 emission[65361:11644200] In TripDiaryStateMachine, received transition T_BLE_BEACON_FOUND in state STATE_ONGOING_TRIP 2024-04-14 15:41:31.110132-0700 emission[65361:11644200] In TripDiaryStateMachine, received transition T_BLE_BEACON_LOST in state STATE_ONGOING_TRIP 2024-04-14 15:41:37.788507-0700 emission[65361:11644200] In TripDiaryStateMachine, received transition T_BLE_BEACON_LOST in state STATE_ONGOING_TRIP 2024-04-14 15:41:37.796704-0700 emission[65361:11644200] In TripDiaryStateMachine, received transition T_BLE_BEACON_LOST in state STATE_ONGOING_TRIP 2024-04-14 15:41:53.319772-0700 emission[65361:11644200] In TripDiaryStateMachine, received transition T_TRIP_END_DETECTED in state STATE_ONGOING_TRIP 2024-04-14 15:41:53.871614-0700 emission[65361:11644200] In TripDiaryStateMachine, received transition (null) in state STATE_ONGOING_TRIP 2024-04-14 15:41:55.577755-0700 emission[65361:11644200] In TripDiaryStateMachine, received transition T_END_TRIP_TRACKING in state STATE_ONGOING_TRIP 2024-04-14 15:41:55.583780-0700 emission[65361:11644200] In TripDiaryStateMachine, received transition T_TRIP_ENDED in state STATE_ONGOING_TRIP 2024-04-14 15:41:56.022684-0700 emission[65361:11644200] In TripDiaryStateMachine, received transition T_DATA_PUSHED in state STATE_WAITING_FOR_TRIP_START ```
yes, testing. I don't have a beacon, and we are going to push this to production with very little time on staging. I would really like thorough testing of both the fleet and non-fleet versions. You could start with android for now, where my changes are done; I can test with simulating transitions, but I can't easily invoke the BluetoothService in the way that the actual beacon/library combination does. EDIT: Note that you don't actually have to go on a trip for the first round of testing. You should be able to start and stop trips from the developer zone. You can start a trip from there and then move the beacon near and far and see what happens in the device logs (adb logcat or xcode logs) |
@the-bay-kay as you can see, I am able to push changes to your branch directly. Once I am done, I will merge this to |
In e-mission@a46fad8 we hardcoded the fleet / non-fleet flag to make it easier to test This commit reads the flag correctly from the dynamic config. Before making this change, I was concerned that we may be calling the `init` function before the user has put in their opcode and we have donwloaded the dynamic config. however, it looks, through testing, that fortunately, we have done the right thing. we wait to initialize the FSM until the user has entered the opcode Testing done: e-mission#220 (comment) - Uninstalled and reinstalled - TripDiaryStateMachine was not initialized - Put in opcode - TripDiaryStateMachine was initialized with this stacktrace ``` ``` On restart (after install), the backtrace is ``` ```
@the-bay-kay I don't have a beacon, so I can't test this. What is the type of object that we receive in EDIT: It looks like it is in fact CLBeaconRegion (by looking at the code in the delegate). Not sure that has been tested, though... |
Correct -- we are using CLBeaconRegion, despite the fact it is deprecated, because the contemporary CLBeaconIdentityCondition is only available for iOS 17.0+ (docs). (I wrote more about this at the beginning of the PR here) I'm somewhat confused though -- when you ask "has it been tested", what do you mean? This API is the same as the one used in |
I meant, have we added a breakpoint here and confirmed that the value passed in is a |
@the-bay-kay I am almost done with my changes, but have not been able to test the native callbacks (e.g. the code in |
Consistent with e-mission/e-mission-docs#1062 (comment) store the BLE scan results so that we can use them while matching the mapping While storing the changes, I realized that the region enter and exit calls returned a CLBeaconRegion object and the range scans returned a CLRegion object. e-mission#220 (comment) This needed us to change the wrapper class as well: - Add a new initFromCLBeaconRegion that only copies non-range values and sets default values for the range values (proximity, accuracy and rssi) - Change the existing initFromCLBeacon to not need an event type, since it is only called for the scans, and the event type is always `RANGE_UPDATE` in that case. Testing done: - Compiled - Launched the app - Note that we cannot test this code without a physical beacon, but it is very straightforward and compiles. The only reason why it may fail is if values are not filled out in unexpected ways.
Merging this to clear the decks to start building for staging |
@@ -49,6 +50,35 @@ + (void) stopTracking:(NSString*) transition withLocationMgr:(CLLocationManager* | |||
object:CFCTransitionTripEnded]; | |||
} | |||
|
|||
+ (void)startBLEMonitoring:(NSString*) transition withLocationMgr:(CLLocationManager*)locMgr { | |||
// Note: We don't need to run `RequestAlwaysAuthorization`, already set in SensorControlForegroundDelegate.m. | |||
if ([CLLocationManager isMonitoringAvailableForClass:[CLBeaconRegion class]]) { // May be unecessary |
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.
future fix: should see what happens if the phone bluetooth is turned off. We may need to add a check for that, and remind the user to turn it on, at least in the fleet case
// TODO: unify the checks here and in the exit region. Why are we checking for isKindOFClass here but not in the exit code? | ||
if ([region isKindOfClass:[CLBeaconRegion class]]) { |
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.
Future fix: note TODO here
|
||
[[NSNotificationCenter defaultCenter] postNotificationName:CFCTransitionNotificationName | ||
object:CFCTransitionBeaconFound]; | ||
|
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.
don't you need to check for the UUID as well here?
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.
I believe we do not -- as I understand CLBeacon, the (CLBeaconIdentityConstraint *)
within the function signature will be the constraint set when we begin ranging for beacons. That is, when we call startRangingBeaconSatisfyingConstraint on line 341, we will only receive notifications for beacons that match that constraint.
Purpose
The purpose of this PR is to incorporate BLE Scanning into the OpenPATH Finite-State Machine, such that trips are only tracked when a registered BLE Beacon is present at the beginning of the trip.
Timeline
Further Reading
For information on this PR, please consult the following: