Good day to all
Today we will talk about the
Lumia SensorCore SDK , which provides developers with a collection of tools for collecting and processing information of
motion and location sensors . This data is useful primarily in the development of fitness applications and applications where it is necessary to process information about the user's location.
')
The main advantage of this SDK is the ability to work in the background, which optimizes the process of energy consumption.
Introduction
Using
Lumia SensorCore SDK significantly reduces the load on the processor, which increases the battery life of the device. This is achieved by the fact that while the applications are hanging in the background, the SDK automatically captures the data from the sensors.
Information is stored and processed taking into account the user's privacy settings. The user independently makes a decision about connecting / disconnecting the process of collecting information about the movement and location of the user, as well as about the destruction of already collected data. The process of collecting information does not use cloud storage services, and all data is stored locally on the device.
For any SensorCore API to function, both Motion data and Location data must be enabled on the device. Therefore, when developing applications using this SDK, it is necessary to provide scenarios where these settings can be disabled or the device does not support the SensorCore capabilities at the hardware level.
It is important to note that the SensorCore SDK is available only
for devices of the new generation with the Windows Phone 8.1 operating system, such as Nokia Lumia: 630, 635, 930, 730, 830, including the Nokia Lumia 1520.
Main features
Lumia SensorCore SDK contains an API for working with the following sensors:
- Pedometer;
- Activity monitor;
- Location sensor;
- Trekker routes.
Lumia SensorCore SDK for all APIs supports:
Let us consider in more detail the new APIs available for these scenarios.
Step Counter API
A set of tools
for counting steps , provides information about how many steps the user has completed, how long and how: walked or ran.
The difference is determined not only by speed, but also by the intensity of movement, so that the type of movement is identified even if the user ran and walked at the same speed.
Basic methods:
Example of the Step Counter API used in the Health and Fitness Bing application :
Activity Monitor API
The tool captures information about
changes in the user's physical activity , for example, determines when the walk started and when it has already ended.
In order to eliminate inaccurate data, there is a slight delay in determining the change in the type of user activity - in 5-10 seconds.
The API allows to distinguish the following
types of activities :
- Device in standby mode (without user);
- A device with a user, but the user does not move;
- The user is walking;
- The user is running;
- The user is moving, but Active Monitor cannot identify the type of movement, in this case the type of activity is classified as Moving .
Basic methods:
Place Monitor API
Using this API, you can get a list of coordinates of the places in which the user spent some time: making purchases, having dinner or standing in a traffic jam. The main function of this tool is to identify places that the user visits frequently and identify them as
known .
Example of Place Monitor API used in the “ Places” application :
The device must remain in one place for at least 10 minutes in order for the place to be classified as
known and added to the list. One place usually means a circular area with a radius of less than 200 meters. The radius can grow during the time the user moved around this place.
The distance between any two
known places should be more than 500 meters. This means that even if two or more different places are within a radius of 500 meters from each other, the Place Monitor API will try to combine them into one
known place.
All
known places are defined by the Place class, which has the following attributes:
- ID - unique identifier of the place;
- Kind : famous , home, work;
- Position - geographical location of the place;
- Radius - a circular area around the intended location.
Basic methods:
In addition to creating a simple list of
known places, the Place Monitor API independently identifies such places as “Home” and “Work”:
"House" and "Work" are determined by the following criteria:
- How often the device moved and how the user showed the type of activity;
- How actively the device was used;
- Did the phone connect to the charger?
The classification usually takes 2-3 days. It should be noted that “Home” and “Work” are only
logical labels for these two places. For example, the Place Monitor will detect the school as “Work” if the school is visited in accordance with the criteria by which the place “Work” is determined.
If the owner of the device moves to a new address or changes jobs, Place Monitor will detect this within 10 days.
There are
various scenarios for using the proposed in the API classifications of places like "Home" and "Work", for example:
- Creating more meaningful UX in applications. For example, a navigation application might use the values ​​of these Home labels to automatically create a route from home to work;
- You can also use the “House” classification to create a geo-zone around this place, and then use this geofence to calculate how long the device has been at Home or how many times the device has left the House.
- An application can use 'Home' to create a geo-zone around the house and use this geo-zone to trigger some functionality in the device. Or the application may send a message to parents that their child has arrived home.
If the application wants to track the time when the device
enters and leaves the “Home” or “Work” places, the application needs to use
geofing . Using PlaceMonitor, an application can get a list of known Places places and using the described attributes of the
Place class (geo-coordinates and radius) to build a geo-zone around this place.
The API is designed to collect data using minimal amounts of energy and working in the background. Thus, the API uses
towers of cellular operators and Wi-Fi access points to determine the location of the device.
Track Point Monitor API
Track Point Monitor API collects information about the movement of the user. It is similar to the Place Monitor API tool, but instead of specific frequently visited places it
records route points . To determine the location of the device Track Point Monitor API also uses cell towers and Wi-Fi access points.
An example of the Track Monitor API used in the “ Tracks” application :
Points in the track are recorded at 5-minute intervals (API will wait 5 minutes from the last point of the track, and only then write a new one) and only when the
minimum distance between the current and last points of the track is at least
500 meters . For example, if the user stays within 500 meters for a long period of time, the Track Point Monitor will record only one track point for this area.
The Track Point Monitor API provides the following
Place class parameters:
- LengthOfStay - tells how long the device has been in this place.
- Position - the geographical position of the track point.
- Radius - the calculated radius of the circular area around the site. The accuracy of this value depends on various factors, for example, how the device is used and environmental factors such as the presence of cell towers and Wi-Fi access points.
- Timestap - time of fixation of the track point (provided with an accuracy of 5 minutes).
Basic methods:
Features of work with SensorCore SDK
Some functions of the
SensorCore SDK have dependencies on other subsystems of the device. And in some cases, the functionality may not be available if the corresponding hardware is not available in the device. In other cases, functionality is improved when all sorts of ways of obtaining information are available.
Dependencies are illustrated in the following table:
As can be seen from the table, the accelerometer is crucial for the operation of the Step Counter API and Activity Monitor API.
The accuracy of determining locations also depends on
environmental factors , such as the number of cell phone towers and Wi-Fi access points, ie, accuracy is maximum in densely populated areas with a large number of cell towers and Wi-Fi points. The center of a certain place may be
slightly offset from the actual location within 500 meters, since known places are attached to cell towers that were used to determine the location.
In cases where the API is used for navigation applications, accuracy can be improved by using data from
GPS sensors .
Conclusion
In this article about
Lumia SensorCore SDK, we have listed the main features and examples of how the API works in actually functioning applications.
In the
next part , we will develop an application that sends notifications in accordance with the location of the device, taking into account the recommendations of working with the new SDK, we will tell how to generate and use dummy data and API simulators.
useful links
Lumia SensorCore SDK:
Microsoft Virtual Academy (MVA) Training Courses
Windows Development Center
Download free or trial Visual Studio 2013