13 November, 2017

Streams: now pushing as well as pulling

New independent streams in the flespi registry module are capable of forwarding data from channels, devices, or both, and enable the flespi platform to work in push and pull modes.

Think of flespi as a warehouse where your devices deliver data. flespi stores it and sends it out to the addressee(s) in response to a REST API call. This is a PULL mode because data sits in the warehouse until requested (pulled).

An alternative is a PUSH mode. And this one caused us sleepless nights since it is another opportunity to help our customers which we haven't tapped. Until very recently. Advantages of PUSHing are plenty and obvious:

  • one-time setup: tune your app to receive data, enable flespi in PUSH mode, and do nothing else;
  • no REST API: no extra links between flespi and your application. The shorter the chain, the simpler the deployment. And flespi strives for maximum simplicity while ensuring the top performance!
  • no auxiliary modules to tune and host;
  • minimal storage fee: your data sends to you instantly, so you don't need space of flespi servers.

Now we are all set to present you the new streams interface. Here are some quick facts about flespi streams:

  • stream is an instance responsible for delivering messages from flespi to another platform;
  • stream is an independent instance — it does not belong to any channel or device;
  • stream can serve many channels and devices simultaneously;
  • stream is unidirectional — it delivers messages from channels and devices to other platforms;
  • to start sending messages from flespi devices or channels to a third-party platform through a stream, subscribe it to these devices or channels and set the outbound protocol suitable for the target software.

Below is the illustration of what streams are up to:

how new flespi streams work

Next, we consider three main implementations of flespi streams: MQTT, Wialon Retranslator, and HTTP.

MQTT

MQTT is one of the most widely used protocols for IoT. Currently, flespi streams support three MQTT-based implementations: Amazon Web Services, Thingsboard, and general MQTT. Here are some tips for each of them:

AWS:

  • designed to subscribe for flespi devices. “mqtt_topic” parameter in stream configuration is used to deliver new messages from flespi registry devices
  • you can find some advice on AWS IoT configuration here
  • a single certificate supports multiple AWS things
  • “thing_name” parameter in stream configuration applies to update thing’s shadow.

Thingsboard:

  • default URI for demo platform is demo.thingsboard.io:1883
  • no need to manually create devices on the thingsboard platform: just select “is gateway” checkbox in one new device configuration and set up a stream to this device with “access token.” Thingsboard will automatically create a new device if the message with unknown “ident” arrives.

General MQTT:

  • may work with your specific MQTT broker implementation. We have tested it with an open-source Mosquitto.
  • we have implemented our own MQTT broker: efficient, distributed and scalable over multiple servers, and featuring a wide range of settings. Give it a try and let us know what you think.

Wialon Retranslator

HTTP

  • performs POST request with JSON list of messages as a HTTP “data” parameter
  • optional custom HTTP headers are possible
  • URI must include the protocol: HTTP or HTTPS

Upon completion of the stream config, you see a green check mark in the top right corner of a stream card. Now it’s time to subscribe to some flespi instances. Do so by selecting the desired streams in a channel or device card.

subscribe stream to channels or flespi devices

To prolong your excitement we’ll finish with a cliffhanger :) The current stream implementation is just kind of wrapper for our internal MQTT message bus that processes all messages from all channels and devices. We are planning to give you direct access to it soon. You can hardly imagine what possibilities it can provide to a developer!

Get updates on Telegram!

Jan Bartnitsky
Software Engineer


Get the latest updates and monthly newsletters from flespi in your inbox

7 February, 2018 | flespi features | Anton Kulichenko

Connecting a tracker to Wialon via flespi and why you may want it

What are the benefits of putting flespi between your trackers and Wialon and how to do it? Step-by-step guide with Queclink GV300.

11 January, 2018 | flespi integrations | Anton Kulichenko

How flespi adds protocols and easy device setup to Traccar

Integration of flespi allows Traccar users to connect more tracker types, see more message parameters, and configure devices from different manufacturers in a single interface.