Integration with the Geo2Tag platform

Geo2Tag is an open-source location-based service platform. It provides API for geodata (queries and filters) that are needed for deploying location-based and location-context services.

Steps for integrating the Geo2Tag platform to the IoT Hub

Development of the Geo2Tag platform plugin for the IoT

IoT Hub plugins are simple Javascript object with a set of defined functions. Here is an example for an hello world plugin which requires to be be configured:

Hello world plugin example
      
var HelloWorldPluginConfiguration = { 
  needConfiguration: true,
  checkConfiguration: function(data) { 
    var config = JSON.parse(data);
    if (typeof(config.name) !== 'string') { return false; } 
    return true; 
  },
  configure: function(config) {
    if (this.checkConfiguration(config)) {
      var config = JSON.parse(data);
      var name = config.name;
      this.config = { name: name }; 
    }
  },
  isFeatureSupported: function(name) { return typeof(this.config) !== "undefined"; },
  isFeatureAvailable: function(name) { return isFeatureSupported(name); },
  isFeatureReadable: function(name) { return isFeatureSupported(name); },
  isFeatureWritable: function(name) { return false; },
  getNumberOfFeatures: function() { return 1; },
  postFeatureValue: function(name, data) { return false; },
  getFeatureDescription: function(index) {
    if (index == 0) { 
      return JSON.stringify({name: "message", type: "string"});
    } else {return null;}
  },
  getFeatureValue: function (name) {
    if (!isFeatureSupported(name) || name !== "message") { return null; }
    return JSON.stringify('Hello ' + this.config.name);
  }
};
      
The functions that need to be available for an IoT Hub plugin are:

In the case of the Geo2Tag plugin, the configuration includes the JSON Web Signature to enable to Google OAuth 2.0 authentication of the plugin to the Geo2Tag platform and then listing the features available via a GET request on either //channel for the channels, //service for the services

Deploying the Geo2Tag plugin in the IoT Hub

Deploying the plugin on the IoT Hub platform is easy and can be done with POST /plugins

Data
      
{
  "plugin": "Geo2Tag",
  "type": "iothub",
  "file": a base64 string of the Geo2Tag plugin,
  "isService": false
}
      
      

Configuring the Geo2Tag plugin via the Hub enabler

Create an enabler for the plugin via the REST API: POST /enablers

Data
      
{
  "plugin": Geo2TagPluginId,
  "configuration": the configuration of the Geo2Tag plugin for this enabler
}
      
      

Exposing Geo2Tag features as IoT Hub atomic feeds

Once the GeoTag enabler has been created in the IoT Hub, the hub admin can expose the selected features of the plugin via the hub REST API. It requires just a simple POST request to the IoT Hub API POST /enablers/${enabler_id}/feature/${feature_name}/atomic

The function will return the description of the created atomic feed for the feature ${feature_name} of the enabler ${enabler_id}. If it did not exist, the atomic feed will be created

Interacting with Geo2Tag via the IoT Hub API

The Hub users can interact with the Geo2Tag platform via the created atomic feeds if they have the necessary permissions to do so