mqtt

flespi MQTT channel protocol by Gurtam is used to receive messages directly from MQTT broker.

Expected MQTT message payload should be a valid JSON object and should contain at least an ident attribute for unique device identification. Other JSON object attributes like "timestamp", "position.latitude", "position.longitude" are optional. Check other protocols for suggested attribute names and values.

It is possible to use flespi MQTT broker as a central hub between IoT devices, smart sensors or custom platforms publishers and channel subscriber. In order to use it you need:

  • Come up with a unique topic where you will publish messages, e.g. messages/[device].
  • Create a flespi token with either no ACL or with MQTT ACL only and possibility to publish to messages/+. Use this token to connect publishers to flespi MQTT broker.
  • Create another flespi token with either no ACL or with MQTT ACL only and possibility to subscribe to messages/+. Use this token to connect subscribers to flespi MQTT broker
  • You can test both tokens directly from the flespi MQTT broker page: one page with the first token will publish messages and another page should subscribe to # and receive them.
  • Then create a channel with MQTT protocol and configure it to connect to flespi MQTT broker: URI=mqtt.flespi.io:1883, username=2nd-token, topic=messages/+.
  • Enable/start the channel and check in the Toolbox that you have no errors.
  • Now you can publish messages from the first web-page or directly from your smart sensors, and the messages will appear in the channel and operate according to standard flespi telematics message pipeline - stored in the device, re-published, streamed, etc.

It is possible to use just one token with no ACL for simplicity for both publishers and subscribers. Please look into the tokens ACL article for more information.

You may also use MQTT protocol to subscribe to messages from another flespi channel, just subscribe it to the correct topic, e.g. flespi/message/gw/#, see flespi MQTT-API for more information.

Below is the list of parameters that can appear in the messages received by the channel via mqtt protocol. In most parameters, the name consists of tags split by dots: tag1.tag2.tag3.tag4... Each tag defines a certain area of an application, e.g. any parameter that contains mileage data has the 'mileage' tag in the name and any parameter related to fuel control contains the 'fuel' tag. By default JSON fields of the message received by a channel via this protocol can only contain the below-specified parameters. Any additional parameter will be prefixed by the "custom" tag, e.g. "custom.unspecified-name".

Name Type Unit Description
channel_id number ID of channel that received message
custom Any custom parameter
ident string Device unique identificator and optional password
timestamp number seconds Message timestamp
No results found.