Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| en:reference:mqtt [2017/10/30 11:28] – kniwwelino | en:reference:mqtt [2018/07/17 17:46] (current) – [void MQTTconnectMATRIX()] kniwwelino | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Messaging / MQTT ====== | ||
| + | |||
| + | ===== API ===== | ||
| + | |||
| + | ==== void MQTTsetGroup(String group) ==== | ||
| + | Sets the MQTT group where all messages are sent and all subscriptions are done. | ||
| + | |||
| + | Can be used to easily separate different applications/ | ||
| + | |||
| + | e.g. specify one group per game or one group per boards playing in the same game. | ||
| + | |||
| + | |||
| + | ==== void MQTTonMessage(void (cb)(String &topic, String & | ||
| + | Sets the callback function that is called one a MQTT message is received for one of the subscribed topics. | ||
| + | |||
| + | needs a callback function with signature: | ||
| + | |||
| + | '' | ||
| + | message - String content of the received message.'' | ||
| + | |||
| + | |||
| + | ==== boolean MQTTpublish(const char topic[], String message) ==== | ||
| + | Publishes/ | ||
| + | |||
| + | if an MQTT group is set, the topic is automatically preceded with this group string. | ||
| + | |||
| + | '' | ||
| + | message - content of the message.'' | ||
| + | |||
| + | |||
| + | ==== boolean MQTTpublish(String topic, String message) ==== | ||
| + | Publishes/ | ||
| + | |||
| + | if an MQTT group is set, the topic is automatically preceded with this group string. | ||
| + | |||
| + | '' | ||
| + | message - content of the message.'' | ||
| + | |||
| + | |||
| + | ==== boolean MQTTsubscribe(const char topic[]) ==== | ||
| + | Subscribes to the specified MQTT topic. Once a message is received for a subscribed topic, the MQTTonMessage callback is called. | ||
| + | |||
| + | If an MQTT group is set, the topic is automatically preceded with this group string. | ||
| + | see https:// | ||
| + | |||
| + | '' | ||
| + | |||
| + | ==== boolean MQTTsubscribe( String s_topic) ==== | ||
| + | Subscribes to the specified MQTT topic. Once a message is received for a subscribed topic, the MQTTonMessage callback is called. | ||
| + | |||
| + | if an MQTT group is set, the topic is automatically preceded with this group string. | ||
| + | see https:// | ||
| + | |||
| + | '' | ||
| + | |||
| + | ==== boolean MQTTunsubscribe(const char topic[]) ==== | ||
| + | Unsubscribes from the specified MQTT topic. | ||
| + | |||
| + | if an MQTT group is set, the topic is automatically preceded with this group string. | ||
| + | |||
| + | '' | ||
| + | |||
| + | ==== void MQTTconnectRGB() ==== | ||
| + | Subscribes the Kniwwelinos RGB LED to specific MQTT topics. If a message is received, the LED color will be changed. | ||
| + | |||
| + | if an MQTT group is set, the topic is automatically preceded with this group string. | ||
| + | |||
| + | The board will listen on // | ||
| + | |||
| + | **Message format: | ||
| + | |||
| + | ''" | ||
| + | |||
| + | |||
| + | |||
| + | ==== void MQTTconnectMATRIX() ==== | ||
| + | Subscribes the Kniwwelinos MATRIX to specific MQTT topics. | ||
| + | |||
| + | if an MQTT group is set, the topic is automatically preceded with this group string. | ||
| + | |||
| + | The board will listen on // | ||
| + | |||
| + | **Message format:** | ||
| + | |||
| + | ''" | ||
| + | " | ||
| + | |||
| + | The board will listen on // | ||
| + | |||
| + | **Message format: | ||
| + | |||
| + | ''" | ||
| + | |||
| + | |||
| + | |||
| + | ===== Wiring ===== | ||
| + | |||
| + | ===== Examples ===== | ||
| + | |||