LoboMQ
Loading...
Searching...
No Matches
Broker.h File Reference
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <vector>
#include "commons/Includes.h"
#include "PubSub.h"
#include "MACAddrList.h"

Go to the source code of this file.

Classes

struct  SubscribeTaskParams
 
struct  UnsubscribeTaskParams
 
struct  PublishTaskParams
 

Macros

#define BRO_DEFAULT_WHITELIST   nullptr
 
#define BRO_DEFAULT_LOGGER   initializeSerialLogger(BROKER)
 
#define BRO_DEFAULT_PERSISTENCE   false
 
#define BRO_DEFAULT_CS_SD_PIN   -1
 

Functions

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.
 

Detailed Description

Author
Rubén Gómez Villegas

This file contains the necessary definitions and declarations to deploy a LoboMQ broker.

Definition in file Broker.h.

Macro Definition Documentation

◆ BRO_DEFAULT_CS_SD_PIN

#define BRO_DEFAULT_CS_SD_PIN   -1

Definition at line 39 of file Broker.h.

◆ BRO_DEFAULT_LOGGER

#define BRO_DEFAULT_LOGGER   initializeSerialLogger(BROKER)

Definition at line 37 of file Broker.h.

◆ BRO_DEFAULT_PERSISTENCE

#define BRO_DEFAULT_PERSISTENCE   false

Definition at line 38 of file Broker.h.

◆ BRO_DEFAULT_WHITELIST

#define BRO_DEFAULT_WHITELIST   nullptr

Definition at line 36 of file Broker.h.

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.