LoboMQ
Loading...
Searching...
No Matches
Broker.cpp File Reference

Go to the source code of this file.

Macros

#define SUBSCRIBETASKS   1
 
#define UNSUBSCRIBETASKS   1
 
#define PUBLISHTASKS   1
 

Functions

void SubscribeTask (void *parameter)
 
void UnsubscribeTask (void *parameter)
 
void PublishTask (void *parameter)
 
void OnDataRecv (const uint8_t *mac, const uint8_t *incomingData, int len)
 
LMQErrType initBroker (MACAddrList *whitelist, Elog *_logger, bool persistence, int csSdPin)
 Initializes the broker.
 

Variables

std::vector< BrokerTopictopicsVector
 
QueueHandle_t subMsgQueue
 
QueueHandle_t unsubMsgQueue
 
QueueHandle_t pubMsgQueue
 
Elog * logger
 
bool gPersistence
 
int gCsSdPin
 
SemaphoreHandle_t mutex
 
MACAddrListgWhitelist
 

Detailed Description

Author
Rubén Gómez Villegas

This file contains the necessary logic to deploy a LoboMQ broker.

Definition in file Broker.cpp.

Macro Definition Documentation

◆ PUBLISHTASKS

#define PUBLISHTASKS   1

Definition at line 14 of file Broker.cpp.

◆ SUBSCRIBETASKS

#define SUBSCRIBETASKS   1

Definition at line 12 of file Broker.cpp.

◆ UNSUBSCRIBETASKS

#define UNSUBSCRIBETASKS   1

Definition at line 13 of file Broker.cpp.

Function Documentation

◆ initBroker()

LMQErrType initBroker ( MACAddrList * whitelist = BRO_DEFAULT_WHITELIST,
Elog * _logger = BRO_DEFAULT_LOGGER,
bool persistence = BRO_DEFAULT_PERSISTENCE,
int csSdPin = BRO_DEFAULT_CS_SD_PIN )

Initializes the broker.

This function sets up the proper tasks and queues to handle received message and gives a node the role of broker. This broker redirects published messages to the subscribers. If persistence is enabled, topics will be restored on boot and stored in the SD card.

Parameters
whitelistList with the allowed MAC addresses. If is BRO_DEFAULT_WHITELIST, all MAC addresses are allowed.
_loggerPointer to the logger object.
persistenceIf is true, the broker will save the topics in a SD card.
csSdPinThe Chip Select pin of the SD card module.
Return values
`LMQ_ERR_SUCCESS`if the broker is successfully deployed.
`LMQ_ERR_BAD_ESP_CONFIG`if ESP-NOW couldn't be initialized.
`LMQ_ERR_XQUEUECREATE_FAIL`if the message queues for the tasks couldn't be created.
`LMQ_ERR_XTASKCREATE_FAIL`if the tasks to process the messages couldn't be created.

Definition at line 240 of file Broker.cpp.

◆ OnDataRecv()

void OnDataRecv ( const uint8_t * mac,
const uint8_t * incomingData,
int len )

Definition at line 152 of file Broker.cpp.

◆ PublishTask()

void PublishTask ( void * parameter)

Definition at line 119 of file Broker.cpp.

◆ SubscribeTask()

void SubscribeTask ( void * parameter)

Definition at line 30 of file Broker.cpp.

◆ UnsubscribeTask()

void UnsubscribeTask ( void * parameter)

Definition at line 76 of file Broker.cpp.

Variable Documentation

◆ gCsSdPin

int gCsSdPin

Definition at line 25 of file Broker.cpp.

◆ gPersistence

bool gPersistence

Definition at line 24 of file Broker.cpp.

◆ gWhitelist

MACAddrList* gWhitelist

Definition at line 28 of file Broker.cpp.

◆ logger

Elog* logger

Definition at line 23 of file Broker.cpp.

◆ mutex

SemaphoreHandle_t mutex

Definition at line 26 of file Broker.cpp.

◆ pubMsgQueue

QueueHandle_t pubMsgQueue

Definition at line 21 of file Broker.cpp.

◆ subMsgQueue

QueueHandle_t subMsgQueue

Definition at line 19 of file Broker.cpp.

◆ topicsVector

std::vector<BrokerTopic> topicsVector

Definition at line 16 of file Broker.cpp.

◆ unsubMsgQueue

QueueHandle_t unsubMsgQueue

Definition at line 20 of file Broker.cpp.