LoboMQ
Loading...
Searching...
No Matches
BrokerTopic.h
Go to the documentation of this file.
1
9#ifndef BROKERTOPIC_H
10
11#define BROKERTOPIC_H
12
13#include <Arduino.h>
14#include <esp_now.h>
15#include <string>
16#include <vector>
17#include <array>
18
19#include "PubSub.h"
20
22 private:
23 char topic[MAXTOPICLENGTH];
24 std::vector<std::array<uint8_t, 6>> subscribers;
25 char filename[MAXTOPICLENGTH*2]; //double the topic size, if it has to store special chars
26 QueueHandle_t messagesQueue;
27 bool hasWildcards;
28 Elog *logger;
29
30 public:
32 BrokerTopic(Elog *_logger, const char topic[]);
33
34 const char* getTopic() const;
35 int getSubscribersAmount() const;
36 const std::vector<std::array<uint8_t, 6>>& getSubscribers() const;
37 const char* getFilename() const;
38 void setFilename(const char* filename);
39 bool subscribe(const uint8_t *mac) const;
40 bool subscribe(const std::array<uint8_t, 6> &mac) const;
41 bool unsubscribe(const uint8_t *mac);
42 bool isSubscribed(const uint8_t *mac) const;
43 std::string getSubscribersString() const;
44 bool sendToQueue(const PublishContent *pubContent) const;
45 void dispatchMessages() const;
46 void publish(PublishContent pubContent, std::vector<std::array<uint8_t, 6>>& alreadySentMacs) const;
47 bool isPublishable(const char *publishTopic) const;
48
49 std::string toString() const;
50};
51
52#endif
LMQErrType subscribe(uint8_t *mac, char *topic, Elog *_logger)
Subscribes to a topic on the broker.
Definition PubSub.cpp:133
Structure that contains the fields used by a publish message, apart from those inherited from the Mes...
Definition PubSub.h:65