LogoLogo
HomeSign UpGithub
  • Home
  • Release Notes
  • Getting Started
    • Create your first Test
    • Create Run Settings
    • Analyze the results
      • Job Summary
      • Logs
      • State
      • Payload
    • Look deeper with Metrics
  • Concepts
    • Workspaces
      • Role Based Access Control (RBAC)
      • Invitation Management
      • GitHub Integration
      • Deletion of Workspaces
      • System Status
    • Understanding Tests
      • Stages Management
        • Init Stage
        • Running Stage(s)
        • Finished State
      • Generating Messages
        • Scripting Environment
        • State Object
      • Response Handler
      • Preview Tests
      • Exporting/Importing Tests
        • Import OpenAPI JSON/YAML
      • Locking/Unlocking a test
    • Stateful Simulation
      • Mapping the IoT device lifecycle
    • Protocol Settings
      • MQTT
      • HTTP
      • Using other protocols
    • Run Settings
      • Network Simulation
      • Execution Strategies
      • Client Distribution
    • Scenarios
    • Glob Storage
    • Metrics
    • Mailbox
    • Licensing and Limits
    • Deployment Models
  • Additional Helpers
    • External Libraries
    • Inbuilt Libraries
    • IoTIFY Helper Functions
      • Job Functions
      • Messaging Functions
      • Glob Functions
      • Metrics Functions
      • Mailbox Functions
      • Data Generation Functions
  • platform integrations
    • AWS IoT Connector
  • Guides
    • Smart City
    • Smart Home
    • Load Testing Kafka
  • IoT Testing
    • Overview
      • Feed offline sensor data from Google Sheets to your IoT platform
    • Functional Testing
      • Basic functional test
      • Geofencing Validation
    • Performance Testing
      • MQTT end to end latency Measurement
    • Security Testing
    • Load Testing
    • Test Automation & CI/CD integration
  • API
    • Simulation API
    • Glob APIs
    • Metrics API
  • Glossary
  • Create Account
  • TEMP
    • Getting Started
      • Beginner
      • Developer
      • Tester
    • Walkthrough
    • Protocol Settings
      • CoAP
      • Raw (TCP/UDP/TLS/DTLS)
      • LWM2M
      • NONE
    • Under the hood
    • Google Sheets API
    • Azure IoT
    • Losant IoT
      • Losant Connector
      • Parking Space Management
      • Waste Management
      • Connected Truck
      • Delivery Van
    • Google Cloud IoT Core
    • IBM Cloud
      • Simple Messaging
      • IBM Bluemix: Monitoring Energy Consumption
    • Dweet.io
    • JMeter and why it fails at IoT
Powered by GitBook
On this page
  • Step 1: Launch the server Application
  • Step 2: Prepare the IOTIFY client simulator
  • Optional Exercises

Was this helpful?

  1. IoT Testing
  2. Functional Testing

Geofencing Validation

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

PreviousBasic functional testNextPerformance Testing

Last updated 4 years ago

Was this helpful?

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 . You are free to try it on your own infrastructure, however for this demo, we will use a online IDE workspace at codesandbox.io

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 (https://x2kru.sse.codesandbox.io/) so we copied x2kru.sse.codesandbox.io 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

https://raw.githubusercontent.com/iotify/nsim-examples/master/functional-testing/geofencing.json
github
https://codesandbox.io/embed/github/iotify/geofencing-server-demo/tree/master/?autoresize=1&fontsize=14&hidenavigation=1&theme=dark&view=preview
The HTTP Host should be updated to reflect your actual workspace
A connected dashboard for geofencing application