Agent Things API
The Agent Things API available on the Neuron®, is an extension of the Agent API which facilitates the interoperation with things in the network. The API does not publish any more resources on the Neuron®. Instead it uses the Agent API to perform the underlying communication with the network.
Javascript Library
The Agent Things API can be accessed via a Javascript API available on the Neuron®. All you need to do to access this library, is to include the Javascript files /Agent.js and /Agent.Things.js in your webpage. You download the files from the Neuron® you wish to access. (You can also review the code via the public GitHub Repository AgentApiJavascript.) If the web page is defined in Markdown, you simply add the following header:
JavaScript: /Agent.js
JavaScript: /Agent.Things.js
Some of the functions have the option of reporting back to the client via asynchronous events. Such can be either polled, via the API, or received immediately, by including the Javascript file /Events.js. The functions that support this, clearly indicate if support for such push notifications are available. If the web page is defined in Markdown, and you wish to receive such asynchronous events, you simply add the following header:
JavaScript: /Events.js
If you are hosting the page on one server, and use the Agent API and Events API from another server, you need to include a meta header on the page, information the /Events.js javascript file where it will register itself to receive client events. To use this neuron, add the following to the HTML header of your page:
<meta name="NEURON" content="tagroot.io"/>
You also need to inform the AgentAPI that you want to use another host, than the server used to host the page. You do this by making a call to AgentAPI.IO.SetHost(Host,Secure) as follows:
AgentAPI.IO.SetHost("tagroot.io",true)
The Agent API, and its extensions, is available to your code via an object called AgentAPI. The following asynchronous methods are available in the Agent Things API.
Things
- Concentrators
AgentAPI.Things.Concentrator.GetCapabilities(JID[,DeviceToken[,ServiceToken[,UserToken]]])AgentAPI.Things.Concentrator.GetAllDataSources(JID,Language[,DeviceToken[,ServiceToken[,UserToken]]])AgentAPI.Things.Concentrator.GetRootDataSources(JID,Language[,DeviceToken[,ServiceToken[,UserToken]]])AgentAPI.Things.Concentrator.GetChildDataSources(JID,Language,SourceId[,DeviceToken[,ServiceToken[,UserToken]]])AgentAPI.Things.Concentrator.ContainsNode(JID,Language,NodeId,SourceId[,Partition[,DeviceToken[,ServiceToken[,UserToken]]]])AgentAPI.Things.Concentrator.GetNode(JID,Language,Parameters,Messages,NodeId,SourceId[,Partition[,DeviceToken[,ServiceToken[,UserToken]]]])AgentAPI.Things.Concentrator.GetRootNodes(JID,Language,SourceId[,DeviceToken[,ServiceToken[,UserToken]]])AgentAPI.Things.Concentrator.GetChildNodes(JID,Language,Parameters,Messages,NodeId,SourceId[,Partition[,DeviceToken[,ServiceToken[,UserToken]]]])
- Sensors
AgentAPI.Things.Sensor.StartReadoutStandaloneDevice(JID,Language,Momentary,Peak,Status,Computed,Identity,History,Fields,From,To,When[,DeviceToken[,ServiceToken[,UserToken[,Id]]]])AgentAPI.Things.Sensor.StartReadoutConcentratorNode(JID,Language,Momentary,Peak,Status,Computed,Identity,History,Fields,From,To,When,NodeId,SourceId[,Partition[,DeviceToken[,ServiceToken[,UserToken[,Id]]]]])AgentAPI.Things.Sensor.ReadStandaloneDevice(JID,Language,Momentary,Peak,Status,Computed,Identity,History,Fields,From,To,When[,DeviceToken[,ServiceToken[,UserToken]]])AgentAPI.Things.Sensor.ReadConcentratorNode(JID,Language,Momentary,Peak,Status,Computed,Identity,History,Fields,From,To,When,NodeId,SourceId[,Partition[,DeviceToken[,ServiceToken[,UserToken]]]])
- Actuators
- Concentrators