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.