The IoTResource Builder allows you to define your IoTResources and automatically generate the necessary IoTResource code stubs. Services can then be built using these IoTResources.
Archives: Wikis
IoTResource Builder
Using IoTWorld Gateway
Using IoTResource Catalogue
This tutorial is a quick guide on how to access IoT Resource and their meta data using the IoT Resource Catalogue. It also explains how to invoke actions and retrieve data from IoT Resources using the IoT Resource Catalogue.
Using IoT Resource Builder
This tutorial shows how to use the IoT Resource Builder to create new IoT Resources:
IoT Resource Builder (Windows Version)
Linksmart For Dummies
This tutorial teaches you the basic principles of interacting and using IoT Resources. It teaches you how to find an IoT Resource in the IoT Resource Catalogue and how to read out meta data as well as how to invoke actions.
Download the source code here:
LinkSmartForDummies (Visual Studio Version)
LinkSmartForDummiesSwift (Xcode Version 6.2 – iOS)
Tutorials
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)
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
- Enter a valid endpoint and click use
- Select an action e.g. GetIotResource, GetIotResourcesEndpoints. Depending on this selection some or all of the following controls will be visible
- If the previous selection was GetIoTResource this list will appear where you can select the specific IoTResource to view
- This field shows the URL to the resource catalogue and changes depending on the previous selections
- 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).
- 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.
- 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.
- 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
- 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
- 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
- When you click the “Edit” button to the right of the chart, a pop-up window appears
- 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/
List of actions http://hydra.cnet.se:44441/services/catalogue/actions
List of access resources http://hydra.cnet.se:44441/IoTresources
List of State variables http://hydra.cnet.se:44441/IoTresources/3/services/IoTObservation/statevariables
Select a state variable and get latest 180 measurements http://hydra.cnet.se:44441/IoTresources/3/services/IoTObservation/statevariables/currentconsumption?take=180
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')