Introduction

servIoTicy allows for the interaction with the platform through protocols that are not HTTP/REST. Support for MQTT, STOMP-over-TCP and STOMP-over-WS is provided. This page describes how to leverage this protocols for easy interaction with the platform.

They can be used in three different forms:

 

Information for communicating with the platform using MQTT/WS/TCP:

Topics:

Important: Notice that the topics used in MQTT and STOM follow a different format. More information found here (MQTT) and here (STOMP)

Subscribing to data streams:

We would POST the following JSON document to the URL:

http://api.servioticy.com/SOid/streams/streamID/subscriptions

Note that the filed “destination” is here the API_TOKEN of the subscriber.
Example topic:
M2JhMmRkMDEtZTAwZi00ODM5LThmYTktOGU4NjNjYmJmMjc5N2UzNzYwNWItNTc2ZS00MGVlLTgyNTMtNTgzMmJhZjA0ZmIy/1396461657731411aa73c28444ecf9a8c803e62312fd1/streams/location/updates

Client-Server interaction:

REST API is mapped on top of a topic using the following structure (note the use of an optional “messageId” field to match queries and responses):

An example of how to to list all the SOs belonging to a user:

An example of how to push data to the platform:

Code samples

A sample python code for pushing data to the platform (based on Paho):

The actual Node.js multi-protocol bridge between the broker and the platform:

Note that it uses STOMP+TCP, and therefore uses a topic notation that is: “/topic/field1.field2.field3….”