====== 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/users/groups e.g. specify one group per game or one group per boards playing in the same game. ==== void MQTTonMessage(void (cb)(String &topic, String &message)) ==== 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: ''topic - String topic on which the message was received\\ message - String content of the received message.'' ==== boolean MQTTpublish(const char topic[], String message) ==== Publishes/sents a message to the specified MQTT topic. if an MQTT group is set, the topic is automatically preceded with this group string. ''topic - topic to which the message will be sent\\ message - content of the message.'' ==== boolean MQTTpublish(String topic, String message) ==== Publishes/sents a message to the specified MQTT topic. if an MQTT group is set, the topic is automatically preceded with this group string. ''topic - topic to which the message will be sent\\ 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://www.hivemq.com/blog/mqtt-essentials-part-5-mqtt-topics-best-practices for more information on topic subscriptions. ''topic - topic to subscribe to'' ==== 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://www.hivemq.com/blog/mqtt-essentials-part-5-mqtt-topics-best-practices for more information on topic subscriptions. ''topic - topic to subscribe to'' ==== 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. ''topic - topic to unsubscribe from'' ==== 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 //group/RGB/COLOR// for messages. **Message format:** ''"FF00FF", first 2 digits specify the RED, second the GREEN, third the BLUE component.'' ==== 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 //group/MATRIX/ICON// for icons. If a message is received, the ICON will be displayed. **Message format:** ''"B1111100000111110000011111" 25 pixels binary one after the other, prefix B or\\ "0x7008E828A0" one byte for each 5px row, prefix 0x'' The board will listen on //group/MATRIX/TEXT// for icons. If a message is received, the Text will be displayed. **Message format:** ''"Hello World!"'' ===== Wiring ===== ===== Examples =====