Published using Google Docs
SmartCampus - Bridge-Middleware API documentation
Updated automatically every 5 minutes

 SmartCampus

1 december 2014 – Version 1.0

Written by: Cyril Cecchinel / I3S-Modalis

 

 

 

Bridge - Middleware API

Technical documentation

 


Queries

Queries respect the HTTP 1.1 standard. A GET request only read and returns resources. A POST request may cause the creation of a new resource and is not idempotent. A PUT request is idempotent and refers directly to a resource that will be created if it doesn’t exists, or updated otherwise. A DELETE request delete a resource.

Parameters specified in this documentations refers to data that can or must be transmitted to the server. Depending on the type of request, the parameters are given in a different way:

Return codes

The API returns standard HTTP codes, and in particular:

200

Request processed successfully. Indicates that recovery, modification or deletion of a resource was successful.

201

Resource created successfully. Indicates that the operation of adding the resource was successful (after a PUT or POST for example).

400

Incorrect parameters. Indicates that the request parameters are incorrect (e.g. required parameter unspecified).

404

Resource not found. Indicates that one wants to access a resource that does not exist (e.g with the wrong ID).


Send a value to the collector

A value is a triplet (measure - sensor name - timestamp) sent to a SmartCampus collector.

POST /value

DESCRIPTION

Send a value to the collector

PARAMETERS

n REQUIRED Sensor name

v REQUIRED Raw measure

t REQUIRED Timestamp of measurement

EXAMPLE

POST {url_middleware}/value HTTP/1.0

{

 "n" : "SENSOR_TEMP_310",

 "v" : "25",

 "t" : "1390411800"

}

Interacting with the Sensor network

SmartCampus bridges allow to expose the sensor network to Internet. They act as “Border routers”.

GET /boards

DESCRIPTION

Retrieve all sensor platforms connected to the Bridge

RESULT

Boards array

EXEMPLE

{"boards" :

[

   {

       "id" : "ARD-310"

   },

   {

       "id" : "PHI-309"

   },

   ...

]}

PUT /config

DESCRIPTION

Push a Sensor Network configuration

PARAMETERS

sensors REQUIRED    A JSON array of Sensor objects

OBJECT SENSOR

id        Sensor ID

board        Sensor board

pin        Pin number on which the sensor is connected

freq        Sensor period (in second)

end-point        Collector URL

NOTE

If a previous configuration was deployed on the sensor network, it will be replaced with the new one.

EXAMPLE

PUT {url_bridge}/config HTTP/1.0

{"config_sensors" :[

 {

   "id" : "TEMP_311",

   "board" : "ARD_CORRIDOR_TEMPLIERS",

   "pin" : "3"

   "freq" : "1000"

   "end-point" : "10.0.2.1"

 },

 {

   "id" : "LIGHTT_311",

   "board" : "ARD_CORRIDOR_TEMPLIERS",

   "pin" : "4"

   "freq" : "500"

   "end-point" : "10.0.2.2"

 },

 ...

]}