|
LoboMQ
|
Go to the source code of this file.
Classes | |
| struct | MessageBase |
| Structure that contains the fields used by every message. More... | |
| struct | SubscribeAnnouncement |
| Structure that contains the fields used by a subscribe message, apart from those inherited from the MessageBase. More... | |
| struct | UnsubscribeAnnouncement |
| Structure that contains the fields used by a unsubscribe message, apart from those inherited from the MessageBase. More... | |
| struct | PublishContent |
| Structure that contains the fields used by a publish message, apart from those inherited from the MessageBase. More... | |
| struct | PayloadContent |
| Structure representing the content of a payload This structure holds properties of the content received inside a publication message. More... | |
Macros | |
| #define | MAXTOPICLENGTH 24 |
| #define | MAXCONTENTSIZE 30 |
Enumerations | |
| enum | MessageType { MSGTYPE_SUBSCRIBE = (uint8_t)0x00 , MSGTYPE_UNSUBSCRIBE , MSGTYPE_PUBLISH } |
| Enumerates every type of message sent between the broker and the clients. More... | |
Functions | |
| LMQErrType | publish (uint8_t *mac, char *topic, void *payload, size_t payloadSize, Elog *_logger=disableLogger()) |
| Publishes a message to the broker. | |
| LMQErrType | subscribe (uint8_t *mac, char *topic, Elog *_logger=disableLogger()) |
| Subscribes to a topic on the broker. | |
| LMQErrType | unsubscribe (uint8_t *mac, char *topic, Elog *_logger=disableLogger()) |
| Unsubscribes from a topic on the broker. | |
| bool | isLMQMessage (const uint8_t *incomingData) |
| Checks if the data received is a MQ message. | |
| PayloadContent | getLMQPayload (const uint8_t *incomingData) |
| Gets the payload content inside a published message This function extracts the payload from the bytes of a received publication message. | |
This file contains the necessary definitions and declarations to publish, subscribe and unsubscribe as a LoboMQ client.
Definition in file PubSub.h.
| enum MessageType |
Enumerates every type of message sent between the broker and the clients.
| PayloadContent getLMQPayload | ( | const uint8_t * | incomingData | ) |
Gets the payload content inside a published message This function extracts the payload from the bytes of a received publication message.
| incomingData | The data received. |
Definition at line 191 of file PubSub.cpp.
| bool isLMQMessage | ( | const uint8_t * | incomingData | ) |
Checks if the data received is a MQ message.
This function checks if the received bytes represent a MQ message from this library.
| incomingData | The data received. |
| `true` | if the data is a MQ message. |
| `false` | otherwise. |
Definition at line 186 of file PubSub.cpp.
| LMQErrType publish | ( | uint8_t * | mac, |
| char * | topic, | ||
| void * | payload, | ||
| size_t | payloadSize, | ||
| Elog * | _logger = disableLogger() ) |
Publishes a message to the broker.
This function takes the payload and builds a message that will be published to the specified topic on the broker.
| mac | The broker MAC address. |
| topic | The topic to publish the message to. It can't contain wildcard characters (+, #) nor non-UTF-8 characters. Invalid example: +/café. Valid example: kitchen/coffee. |
| payload | Pointer to the message payload. |
| payloadSize | Size of the message payload. |
| _logger | Pointer to the logger object. |
| `LMQ_ERR_SUCCESS` | if the message is successfully published. |
| `LMQ_ERR_BAD_ESP_CONFIG` | if ESP-NOW couldn't be initialized. |
| `LMQ_ERR_INVAL_TOPIC` | if the given topic is invalid. |
| `LMQ_ERR_ESP_SEND_FAIL` | if the message couldn't be sent. |
Definition at line 105 of file PubSub.cpp.
| LMQErrType subscribe | ( | uint8_t * | mac, |
| char * | topic, | ||
| Elog * | _logger = disableLogger() ) |
Subscribes to a topic on the broker.
This function sends a message to the broker announcing that the calling board is interested in receiving all the messages compatible with the specified topic.
| mac | The broker MAC address. |
| topic | The topic the board subscribes to. Is compatible with wildcard characters (+, #) when used properly, and can't contain non-UTF-8 characters. Invalid example: résumé/+/#/garden. Valid example: +/+/out/#. |
| _logger | Pointer to the logger object. |
| `LMQ_ERR_SUCCESS` | if the message is successfully published. |
| `LMQ_ERR_BAD_ESP_CONFIG` | if ESP-NOW couldn't be initialized. |
| `LMQ_ERR_INVAL_TOPIC` | if the given topic is invalid. |
| `LMQ_ERR_ESP_SEND_FAIL` | if the message couldn't be sent. |
Definition at line 133 of file PubSub.cpp.
| LMQErrType unsubscribe | ( | uint8_t * | mac, |
| char * | topic, | ||
| Elog * | _logger = disableLogger() ) |
Unsubscribes from a topic on the broker.
This function sends a message to the broker announcing that the calling board is no longer interested in receiving all the messages compatible with the specified topic.
| mac | The broker MAC address. |
| topic | The MQ topic the board unsubscribes from. Is compatible with wildcard characters (+, #) when used properly, and can't contain non-UTF-8 characters. Invalid example: résumé/+/#/garden. Valid example: +/+/out/#. |
| _logger | Pointer to the logger object. |
| `LMQ_ERR_SUCCESS` | if the message is successfully published. |
| `LMQ_ERR_BAD_ESP_CONFIG` | if ESP-NOW couldn't be initialized. |
| `LMQ_ERR_INVAL_TOPIC` | if the given topic is invalid. |
| `LMQ_ERR_ESP_SEND_FAIL` | if the message couldn't be sent. |
Definition at line 159 of file PubSub.cpp.