Location considerations for a personal safety application

Hi,

I’m developing an application for personal safety and looking for some general advice on using location services with regards to battery life. We are targeting Galaxy Watch Active 2 using Tizen 4 and .NET. (Side question: would a native app would be smarter choice for battery life?)

We have geofence areas and want to create an alarm when the watch leaves or enters an area. We have other wearables that send their location periocally and we do the detection on the server side. But using boundaries (CircleBoundary, PolygonBoundary and the ZoneChanged event) seem the way to go. Detecting on the device means fewer network calls but will the location services use more energy?

We also want to send periodic heartbeats, say with 15-30 minute intervals. Should I create an alarm that requests a location or should I set an interval on the same locator that uses the boundaries?

Where can I learn about the different location types? Gps and Wps are fairly obvious but how does Hybrid work and what is Passive?

Hi,
Battery consumption is always a major issue in location service. So it would be better to choose your service carefully. I would like to recommend some calculation of the battery consumption according to the following chart (this chart is for GPS power consumption).

Operation Power consumption Description
Full acquisition 32~40 mA For the first fix, after 2 or 3 days have passed.
Tracking 13~16 mA For the first fix, while continuously tracking the location where the satellite signals are very strong.
Low power tracking 3~5 mA GPS chipset supported in a low power mode.

Find this chart in the following page. You will also find some best practices regarding location service and power consumption here. You will also find the following chart which is indicating the relation and comparison between the accuracy and power consumption among location service methods (GPS, WPS, HYBRID).

Method Location source Description
LOCATIONS_METHOD_HYBRID GPS, Wi-Fi AP, cell information This method allows the device to use all location sources. It provides the best effort with the highest power consumption.
LOCATIONS_METHOD_GPS GPS This method is used by navigation applications requiring high accuracy. The power consumption is lower than in the hybrid method but higher than in the WPS method.
LOCATIONS_METHOD_WPS Wi-Fi AP, cell information This method receives location information from an external positioning server that computes the approximate location based on the Wi-Fi AP or mobile network cell tower. It provides the lowest power consumption and the weakest location accuracy.

Details information regarding the location service will be found in the following page. Moreover, there are several sample applications for helping developers. Please check the following link. Find the source code on the GitHub.

Please let me know if this helps you :smiley:

1 Like

Very helpful links, thank you! The key takeaway here is to always check the native documentation even though writing the app with C#.

I have a working implementation already and the battery life is about 48 hours with the location services running. I’ll try to improve this further by changing from Hybrid to Gps. I’m using boundaries and the Locator.ZoneChanged event and it works great!

We also want to send periodic heartbeats, say with 15-30 minute intervals. Should I create an alarm that requests a location or should I set an interval on the same locator that uses the boundaries?

The maximum interval for Locator.LocationChanged is 120 seconds! So I will use an alarm instead and read the location from the locator instance when the alarm fires.

1 Like

Hi,
It’s really great to hear that you find that helpful :smiley:. You can check the push notification documentation. This might helpful for sending notifications to the devices.

@coderbob, I’m brand new to the Tizen environment and am working on something that seems very aligned with what you are describing here. I also thought the ZoneChanged approach would be the way to go.

I’ve got a very down and dirty background service up and running and upon init I’m creating a zone at the current location. And the code is written so that if the user leaves the zone it will update the boundary to the current location again.

For some reason I’m not ever getting any updated conditions. Like I said, I’m new to it so I figure I’m overlooking something simple. Would you have some sample code illustrating your approach?

We are working on an application to help keep track of individuals with disabilities.

Thanks for your consideration.

Hi @tom,
Why are you creating a zone / boundary at the current position and then updating the boundary? And what does updating a boundary mean? Wouldn’t it make more sense to have a set of zones for the individual carrying the device? So you set the zones once and then receive leave/enter events? If the person is not within any safe zone then you periodically collect positions and upload to your backend.

Anyway. if you do want to change the boundaries if I recall correctly I think you have to stop the locator, unsubscribe, add the new boundaries and then Start() the locator again.

Are you building with Web, native (C) or Xamarin? Anyway, here is how I’m doing it with C#. Anytime the boundaries change (configuration change in the backend) I create a new Locator. Notice how I’m subscribing to both LocationChanged and a ZoneChanged events.

public void StartLocator(List<LocationBoundary> boundaries, int intervalInSeconds)
{
    if (intervalInSeconds < 15)
    {
        _log.Write("Invalid interval, setting to 15 seconds");
        intervalInSeconds = 15;
    }
    if (intervalInSeconds > 120)
    {
        _log.Write("Invalid interval, setting to 120 seconds");
        intervalInSeconds = 120;
    }
    if (_locator != null)
    {
        _locator.Stop();
        _locator.Dispose();
    }

    _locator = new Locator(LocationType.Hybrid);
    _locator.EnableMock = false;
    _locator.Interval = intervalInSeconds;
    _locator.LocationChanged += OnLocationChanged;
    _locator.ZoneChanged += ZoneChanged;
    foreach (var boundary in boundaries)
    {
        _log.Write("adding boundary");
        _locator.AddBoundary(boundary);
    }
    _locator.Start();
    _log.Write("_locator started");
}

@coderbob, thanks for the update. I realized after re-reading your post that our attempted use cases aren’t the same. I didn’t realize you were using boundaries as geofences, but see that now.

I’m attempting to be sly with my detection per se. I generally don’t want to constantly poll location. I was hoping that setting a boundary for the users current location would be sufficient to simply wait until they leave the location to report a change. Then as they move just continually move the boundary with them so I get regular exit events. The intended hope was that generally while the user is stationary the system isn’t actively accessing the location, but when they are on the move there are more regular updates (setting smart boundary radius depending on velocity). Then periodically polling location for a sanity check.

We do have a geofence concept in our cloud rules engine, but just need to generally get timely location updated events pushed through our API. Hopefully without being terribly ham handed and crushing battery life.

We are also doing this in C#, so I find your example to be understandable.

@tom, I see. The boundaries are geofences, no matter how you’re using them :slight_smile:

BTW, I’m using version 4 of the API as we are targeting Samsung Galaxy Active 2.

The docs are not entirely clear but it seems you could be using distance based location.
https://samsung.github.io/TizenFX/API4/api/Tizen.Location.Locator.html#Tizen_Location_Locator_DistanceBasedLocationChanged

_locator.Distance = 50; // meters
_locator.StayInterval = 120; //seconds
_locator. DistanceBasedLocationChanged += MyHandler;

Anyway, I would do the simplest possible thing that works before trying to optimize for battery. Internally it needs to monitor the location to see if a boundary is crossed which means the GPS circuits are consuming energy whether you are receiving callbacks or not. The CPU cycles saved by fewer callbacks are probably neglible. Starting simple gives you a performance baseline to measure against.

Thanks @coderbob, I didn’t see the distance based stuff which seems more aligned with our goals. Though the 120 second min interval seems like it may still be too often for a service that is running all of the time.

I’ll give this a go and see how it goes.