Geofencing Validation

Simulate a connected car with IoTIFY and validate the functionality of a simple geofencing server.

Geofencing is a technique to trigger specific action when an object enters or leave a particular area of interest. It is used extensively to push location based action such as targeted advertising. In this example, we will use it to restrict the movement of a simulated vehicle leaving a city.

The objective of the test would be to ensure that a car is stopped by ignition override remotely if it moves beyond a certain radial distance from its starting point. We have provided you with an IOTIFY device template to simulate a vehicle moving on the streets of Paris. We have also provided a sample server side application based on Node.js and Vue.js which you could use to monitor the car position and manually initiate ignition override as the car moves beyond the geofencing circle. Following are the details of this scenario -

The IoTIFY device template will simulate a vehicle traveling from Paris to Lille in France.

The device will send an HTTP post message to our server application with the current GPS location, odometer and ignition state.

The server application will respond to POST message with ignition status sent as a response. If the vehicle is within the expected geographical radius, the ignition value will be set to true, else it is supposed to be false.

The Vue.js based web application will allow user to manually disable the ignition value of the car by a switch in the UI. The application will also plot the path vehicle has traveled and also the radial distance moved from its first reported location.

An assert condition in the device model could be enabled, to mark the test as failed, if the vehicle has moved beyond 1000 meter radial distance from its starting position. This is to make sure that the functionality of server application is correct as expected.

Step 1: Launch the server Application

The code of the sample server side application is available on github. You are free to try it on your own infrastructure, however for this demo, we will use a online IDE workspace at

Click on the link below to automatically load the git repository into a new online workspace

Once the application has been loaded and running, you should see a web application page on the right hand side as follows. Note that by default the application will show Not Connected, as it awaits the first message being posted by the device simulator.

Copy the codebox server URL of this application. The server hostname will be used in the HTTP server settings in next step.

Step 2: Prepare the IOTIFY client simulator

Signup with IOTIFY Network Simulator and go to the template menu. Click on the button Import Template on the right hand side to import the template from Github.

The code for IoTIFY template used in this simulation is available at

Once the template is imported, a new template with name geofencing will be created in your workspace. Make sure to update HTTP protocol section with the server hostname in Step 1. E.g.

In the case above, our server application was running in codebox workspace named ( so we copied as the hostname in our template. The path of the HTTP should be /endpoint

Once the template has been updated, save it and run the simulation with the following settings

Number of Clients: 1

Repeat Messages: 50

Gap between each message: 10 seconds

As soon as the template runs, you will see that the server side application will show the initial location of the vehicle within the city of Paris. A circle will be drawn around it, which will show the geofence radius, beyond which vehicle is not allowed to travel.

You could adjust the geofencing radius in the settings. The vehicle will slowly move beyond this radius at some time, and as soon as that happens, click on ignition switch to turn the ignition off. This should result in a message sent to the vehicle to disable its ignition upon next POST, and the vehicle will no longer update its position after being stopped.

Clicking on the vehicle Icon will display the last received data from it.

If the ignition stopping doesn't occur in time, vehicle will move beyond the geofencing radius and simulation iterations will be marked as failed.

Optional Exercises

Last updated