Skip to content
Dimitrios Amaxilatis edited this page Feb 14, 2012 · 1 revision

Examples

In this page we demonstrate some examples of using Überdust via REST calls and WebSocket Calls. In this example set we use wget to make the REST calls but an ordinary web browser will do. NOTE Überdust is currently under development more examples will be added during it's development.

REST

  • For retrieving the latest 10 readings a sensor device named urn:wisebed:ctitestbed:0x14d4 belonging to the group of devices 1 (Testbed) and carrying a light sensor named urn:wisebed:node:capability:light in an HTML page. So the call must be made like this :

wget http://uberdust.cti.gr/rest/testbed/1/node/urn:wisebed:ctitestbed:0x14d4/capability/urn:wisebed:node:capability:light/html/limit/10.

The result will be an ordered by latest reading HTML page looking something like this :

Timestamp Readings(10)
2011-12-19 15:26:58.0 46.0
2011-12-19 15:23:59.0 48.0
2011-12-19 15:20:59.0 48.0
2011-12-19 15:17:59.0 47.0
2011-12-19 15:14:58.0 47.0
2011-12-19 15:11:59.0 47.0
2011-12-19 14:32:59.0 45.0
2011-12-19 14:29:59.0 49.0
2011-12-19 14:26:59.0 52.0
2011-12-19 14:23:58.0 57.0

Notice the /limit/10 suffix that narrows the result set to 10 readings. Removing this prefix would return the whole reading base for the specific device & sensor

  • For easy parsing a user might require the Tab Delimited Text format. Modifying the previous example by setting the format like this :
    wget http://uberdust.cti.gr/rest/testbed/1/node/urn:wisebed:ctitestbed:0x14d4/capability/urn:wisebed:node:capability:light/tabdelimited/limit/10.

1324303739000 47.0
1324301399000 46.0
1324301218000 46.0
1324301039000 48.0
1324300859000 48.0
1324300679000 47.0
1324300498000 47.0
1324300319000 47.0
1324297979000 45.0
1324297799000 49.0

Another useful format available is the JSON format so as to have the result set consumed by a JavaScript enabled application.

  • For inserting a reading for the particular set of grouping, device and testbed we need to provide the timestamp and the reading value that was detected. The final REST call would belike this.

wget uberdust.cti.gr/rest/testbed/1/node/urn:wisebed:ctitestbed:0x14d4/capability/urn:wisebed:node:capability:light/insert/timestamp/1324303739010/reading/12.2/.

This call inserts a reading of double typed value in a specific time (timestamp) in the Überdust platform. A raw text message is returned by the service indicating successful or failed insertion of the reading.

Besides, double values users can provide the system with the string type of reading value. The call must be made like this:

wget uberdust.cti.gr/rest/testbed/1/node/urn:wisebed:ctitestbed:0x14d4/capability/urn:wisebed:node:capability:light/insert/timestamp/1324303739010/stringreading/String Reading !/.

Moreover user can make a call that inserts a reading containing both double and string reading like this :

wget uberdust.cti.gr/rest/testbed/1/node/urn:wisebed:ctitestbed:0x14d4/capability/urn:wisebed:node:capability:light/insert/timestamp/1324303739010/reading/100.0/stringreading/Weird Value Detected !/.

WebSockets

... TODO add code examples ...