Archives: Wikis

Example links for the Catalogue

Here are some examples of how to use the catalogue to search for IoT Resources and perform actions on them. These can be tested against the demo catalogue at CNet, linksmart.cnet.se:44441. You can watch and see the effect of your commands at the demo setup at webcam.cnet.se.

Catalogue Meta Data

http://linksmart.cnet.se:44441/services (list all services of the catalogue)

http://linksmart.cnet.se:44441/iotresources (list all IoT Resources with their endpoints)

http://linksmart.cnet.se:44441/* (list all IoT Resources with complete meta data)

Searching the Catalogue

 http://linksmart.cnet.se:44441//upnp:friendlyName[contains(.,’Hue’)] (list all Philips Hue Resources )

http://linksmart.cnet.se:44441//upnp:device[upnp:friendlyName[contains(.,’Hue’)]][IoTObservation:Status[.=’off’]]  (list all Philips Hue Resources that are currently switched off)

Get IoT Resource meta data through the Catalogue

http://linksmart.cnet.se:44441/iotresources/AirQualityDevice/services (list all services provided by IoT Resource AirQualityDevice)

http://linksmart.cnet.se:44441/iotresources/AirQualityDevice/services/sensor/actions (list all actions provided in the “sensor” service)

 http://linksmart.cnet.se:44441/iotresources/AirQualityDevice/services/IoTObservation (list all statevariables that are logged)

Actuation on IoT Resources using resource id

http://linksmart.cnet.se:44441/iotresources/DiscoBall/services/IoTObservation/statevariables/currentconsumption?take=180 (list the energyconsumption of the DiscoBall for the last 3 hours)

http://linksmart.cnet.se:44441/iotresources/DiscoBall/services/switch/actions/TurnOn (start the DiscoBall)

http://linksmart.cnet.se:44441/iotresources/DiscoBall/services/switch/actions/TurnOff (stop the DiscoBall)

Actuation on IoT Resources using search expressions

 http://linksmart.cnet.se:44441//upnp:device[upnp:manufacturer=’CNet’][IoT:currentconsumption>200]/services/switch/actions/TurnOff (turn off all  switches from manufacturer CNet that is consuming more than 200W)

IoT World Gateway GUI

GUIDE

This is a guide to the IoT World Gateway GUI which is a visualizing tool for your IoTWorld.

First view

GUI1_3

  1. Enter a valid endpoint and click use
  2. Select an action e.g. GetIotResource, GetIotResourcesEndpoints. Depending on this selection some or all of the following controls will be visible
  3. If the previous selection was GetIoTResource this list will appear where you can select the specific IoTResource to view
  4. This field shows the URL to the resource catalogue and changes depending on the previous selections
  5. The “Go” button visualizes the selected action in the “Output” window to the left bottom, and in the case of the GetIotResource action the IoTResource services will be shown to the top right (see next image).
  6. The “Output” window shows the xml results from the Resource Catalogue, by clicking the “View xml” link to the upper right corner of the window a new browser tab will be opened with the same results. You could also copy the URL from the previous action field (4) and get the same result.
  7. The “IoT Data Streams” window consists of two customizable charts showing two of the IoTResources. Which IoT Resource to show can be edited by clicking on the “Edit” button to the upper right of each chart.
  8. You can also edit the header of the page by clicking on the “Edit” button to the upper tight of the blue header

Select an IoT Resource

GUI2_3

  1. Once you have selected an Iot Resource and klicked “Go” the “Output” window will be updated and another window called “Services” will appear to the right
  2. The “Services” window show all services provided by the IoT Resource as buttons. Clicking one of the service buttons will generate a chart showing the last 180 measurements

Edit IoT Data Stream Charts

GUI3_3

  1. When you click the “Edit” button to the right of the chart, a pop-up window appears
  2. Two selections are required in the pop-up window, the first is the IoTResource and the second is the service. Once the selection has been made you click the “Save” button to save the changes. The changes will be saved in the web browsers local storage

Access and parse the resource catalogue

First a short overview of the resource catalogue

Main page or root of the resource catalogue ex. http://hydra.cnet.se:44441/
RC_root

List of actions http://hydra.cnet.se:44441/services/catalogue/actions
RC_listActions

List of access resources http://hydra.cnet.se:44441/IoTresources
RC_resources

List of State variables http://hydra.cnet.se:44441/IoTresources/3/services/IoTObservation/statevariables
RC_services

Select a state variable and get latest 180 measurements http://hydra.cnet.se:44441/IoTresources/3/services/IoTObservation/statevariables/currentconsumption?take=180
RC_measurements

Read xml with Javascript


function readXml(url) {
var xhr = createCORSRequest('GET', url);
if (!xhr) {
console.log('CORS not supported');
return;
}

// Response handlers.
xhr.onload = function () {
var xml = xhr.responseText;
if (typeof firstAction !== ‘undefined’) {
console.log(xml);
}
};

xhr.onerror = function () {
console.log(‘Woops, there was an error making the request.’);
};

xhr.send();
}

function createCORSRequest(method, url) {
var xhr = new XMLHttpRequest();
if (“withCredentials” in xhr) {
// XHR for Chrome/Firefox/Opera/Safari.
xhr.open(method, url, true);
} else if (typeof XDomainRequest != “undefined”) {
// XDomainRequest for IE.
xhr = new XDomainRequest();
xhr.open(method, url);
} else {
// CORS not supported.
xhr = null;
}
return xhr;
}

 

Ex.
readXml('http://hydra.cnet.se:44441/services/catalogue/actions')