Location-based services (LBS) uses real-time location or geo-data from devices to monitor and track devices. The geo extension in WSO2 IoT Server provides real-time information about geospatial objects. It processes spatial data from an external source of events and analyzes/manipulates this data to produce meaningful information to end users. You can interact with it to generate a variety of alerts and warnings.
Alert type | Description |
---|---|
Exit fence alert | You can specify a geo area and if the configured device leaves the specified area, an alert is generated. |
Within alert (Enter fence alert) | You can specify a geo area and if the configured device comes into the specified area, an alert is generated. |
Stationery alert | You can specify a geo area, a fluctuation radius, and a time, which generates an alert if the configured device is located in that area during the specified time. The fluctuation radius is used to minimize the fluctuation effect of the device. |
Speed alert | You can specify a maximum speed limit for the movement of the device. If the device exceeds the specified speed, an alert is generated. |
The following sections guide you through installing the geo extension, using geofencing, and setting up alerts.
Setting up geofencing
If you are running WSO2 IoT Server, stop the server before proceeding to the next step.
Navigate to the
<IOTS_HOME>/wso2/analytics/scripts
directory via the terminal and run the following command. This installs the geo extension feature to WSO2 IoT Server.mvn clean install -f siddhi-geo-extention-deployer.xml
Open the
cdm-config.xml
file found in the<IOTS_HOME>/conf
directory and enable theGeoLocationConfiguration
andPublishLocationResponse
configurations.This enables the geo extension feature in WSO2 IoT Server.
<GeoLocationConfiguration> <Enabled>true</Enabled> </GeoLocationConfiguration> <OperationAnalyticsConfiguration> <PublishLocationResponse>true</PublishLocationResponse> <PublishDeviceInfoResponse>false</PublishDeviceInfoResponse> <PublishOperationResponse> <Enabled>false</Enabled> <Operations> <!-- Publish specific operation responses --> <!-- <Operation>BATTERY_LEVEL</Operation> <Operation>CHECK_LOCK_STATUS</Operation> --> <!-- use wildcard '*' to publish all responses --> <Operation>*</Operation> </Operations> </PublishOperationResponse> </OperationAnalyticsConfiguration>
Start the WSO2 IoT Server core and analytics profiles, and sign in to the WSO2 IoT Server Device Management Console.
Deploying in a multi-tenant environment
The geo analytics artifacts are deployed by default in the WSO2 IoT Server super tenant. However, if you are setting up geofencing in a multi-tenant environment, you have to deploy the geo analytics artifacts in each tenant.
Log in to the device management console using the tenant credentials.
Click the button and select Configuration Management > Platform Configurations.
- Click the Deploy Geo Analytics Artifacts button. If required, you can use this button to re-deploy the geo analytics artifacts in the super tenant mode.
Enroll a device. Let's enroll an Android device for this tutorial.
For more information on how to enroll an Android device, see Android.
For more information on how to enroll other sample device types, see Enrolling Devices.
- Access the geofencing map for the device you just enrolled:
- Click the icon, and then click Device Management.
- Click view on the device you just enrolled and select the Location tab.
Setting alerts
Geofencing alerts allow users to set pop-up alerts when a device enters or exits the defined geometry boundaries. You can set up the following alerts using the WSO2 IoT Server geo extensions.
Geofence exit alert
A geofence exit alert notifies the user when the device leaves the specified geofence area. For example, a school administrator may set a geofence exit alert for the school laboratory's tablet devices so that when a device leaves the school premises, the admin is alerted and can disable the device.
Follow the steps given below to define a geo area and set up a geofence exit alert.
- Click on the Add Geofence Exit Alert button.
Define a geo area.
Geofence enter alert
A geofence enter alert notifies the user when the device enters the specified geofence area. For example, an employer may set up a geofence enter alert to a room that contains files with highly classified information in them to notify him or prevent certain employees with restricted access from entering the room.
Follow the steps below to define a geo area and set up a geofence enter alert.
- Click on the Add Geofence Enter Alert button.
Define a geo area.
Stationary alert
Stationary alerts notify the users about the state changes of a device in a predefined geo area. If a device remains stationed within the defined geo area for a specific time period, an alert is generated. For example, you can use this alert to track a lost phone that you may have left in a taxi cab or a public bus. When the device stops moving, you can identify the taxi/bus location and retrieve your phone.
- Click on the Add Stationary Alert button.
Define a geo area.
Speed alert
Speed alerts notify users when a device is traveling above the predefined speed limit. This alert does not require a geofence and is applied globally (wherever the device is located). For example, a system administrator for a taxi service may use this to monitor whether any of the taxi drivers are driving above the allowed speed limit.
- Click on the Set Speed Alert button.
Specify a global speed limit (km/h).
What's next?
- You can customize the alert or set up the geo extension to send SMS/email alerts instead of pop-up alerts on the geo map. For more information on how to do this, see Extending and Customizing Location Based Services.
- Try the Android Sense tutorial to connect an Android device to WSO2 IoT Server and monitor sensor data.