MQTT-SN Gateway Library
Library that allows implementation of MQTT-SN gateway.
|
Interface for Config entity.
The responsibility of the Config object is to to provide a common way to parse the configuration file and provide a convenient interface to retrieve any configuration values, which can later be applied to the Gateway and/or Session objects.
Classes | |
struct | AuthInfo |
Authentication info for single client. More... | |
struct | PredefinedTopicInfo |
Info about single predefined topic. More... | |
Public Types | |
enum | ClientConnectionType { ClientConnectionType_Udp , ClientConnectionType_ValuesLimit } |
Client I/O socket connection type. More... | |
enum | BrokerConnectionType { BrokerConnectionType_Tcp , BrokerConnectionType_ValuesLimit } |
Broker I/O socket connection type. More... | |
using | ConfigMap = std::multimap< std::string, std::string > |
Full configuration map. | |
using | BinaryData = std::vector< std::uint8_t > |
Type of buffer that contains binary data. | |
using | PredefinedTopicsList = std::vector< PredefinedTopicInfo > |
Type of list containing predefined topics. | |
using | AuthInfosList = std::vector< AuthInfo > |
Type of list containing authentication information for multiple clients. | |
using | TopicIdsRange = std::pair< std::uint16_t, std::uint16_t > |
Range of topic IDs. | |
Public Member Functions | |
Config () | |
Constructor. | |
~Config () | |
Destructor. | |
void | read (std::istream &stream) |
Read configuration from input stream. | |
const ConfigMap & | configMap () const |
Get access to the full configuration map. | |
std::uint8_t | gatewayId () const |
Get gateway numeric ID. | |
std::uint16_t | advertisePeriod () const |
Get advertise period. | |
unsigned | retryPeriod () const |
Get retry period. | |
unsigned | retryCount () const |
Get number of retry attempts. | |
const std::string & | defaultClientId () const |
Get default client ID. | |
std::uint16_t | pubOnlyKeepAlive () const |
Get keep alive period for publish only clients. | |
std::size_t | sleepingClientMsgLimit () const |
Get limit for max number of messages to accumulate for sleeping clients. | |
const PredefinedTopicsList & | predefinedTopics () const |
Get access to the list of predefined topics. | |
const AuthInfosList & | authInfos () const |
Get access to list of authentication informations. | |
TopicIdsRange | topicIdAllocRange () const |
Get range of allowed topic IDs for allocation. | |
const std::string & | brokerTcpHostAddress () const |
Get TCP/IP address of the broker. | |
std::uint16_t | brokerTcpHostPort () const |
Get TCP/IP port of the broker. | |
const std::string & | logFile () const |
Get log file. | |
ClientConnectionType | clientConnectionType () const |
Get client side I/O socket connection type. | |
BrokerConnectionType | brokerConnectionType () const |
Get broker side I/O socket connection type. | |
using cc_mqttsn_gateway::Config::ConfigMap = std::multimap<std::string, std::string> |
Full configuration map.
The key is the first word in the configuration line, and the value is rest of the string until the end of the line. NOTE, that the type is multimap, which allows multiple entries with the same key.
using cc_mqttsn_gateway::Config::TopicIdsRange = std::pair<std::uint16_t, std::uint16_t> |
Range of topic IDs.
First element of the pair is minimal ID, and second element of the pair is maximal ID.
std::uint16_t cc_mqttsn_gateway::Config::advertisePeriod | ( | ) | const |
Get advertise period.
Default value is 900 seconds (15 minutes).
BrokerConnectionType cc_mqttsn_gateway::Config::brokerConnectionType | ( | ) | const |
Get broker side I/O socket connection type.
Default value is BrokerConnectionType_Tcp
const std::string & cc_mqttsn_gateway::Config::brokerTcpHostAddress | ( | ) | const |
Get TCP/IP address of the broker.
Default address is 127.0.0.1
std::uint16_t cc_mqttsn_gateway::Config::brokerTcpHostPort | ( | ) | const |
Get TCP/IP port of the broker.
Default value is 1883
ClientConnectionType cc_mqttsn_gateway::Config::clientConnectionType | ( | ) | const |
Get client side I/O socket connection type.
Default value is ClientConnectionType_Udp
const std::string & cc_mqttsn_gateway::Config::defaultClientId | ( | ) | const |
Get default client ID.
Default value is empty string.
std::uint8_t cc_mqttsn_gateway::Config::gatewayId | ( | ) | const |
Get gateway numeric ID.
Default value is 0.
const std::string & cc_mqttsn_gateway::Config::logFile | ( | ) | const |
Get log file.
Expected to be an aboslute file path or one of the special values: "stdout", "stderr". Defaults to "stdout"
std::uint16_t cc_mqttsn_gateway::Config::pubOnlyKeepAlive | ( | ) | const |
Get keep alive period for publish only clients.
Default value is 60 seconds.
void cc_mqttsn_gateway::Config::read | ( | std::istream & | stream | ) |
Read configuration from input stream.
Updates the default values with values read from the stream.
[in] | stream | Input stream. |
unsigned cc_mqttsn_gateway::Config::retryCount | ( | ) | const |
Get number of retry attempts.
Default value is 3.
unsigned cc_mqttsn_gateway::Config::retryPeriod | ( | ) | const |
Get retry period.
Default value is 10 seconds.
std::size_t cc_mqttsn_gateway::Config::sleepingClientMsgLimit | ( | ) | const |
Get limit for max number of messages to accumulate for sleeping clients.
Default value is equivalent to std::numeric_limits<std::size_t>::max() seconds.
TopicIdsRange cc_mqttsn_gateway::Config::topicIdAllocRange | ( | ) | const |
Get range of allowed topic IDs for allocation.
Default range is [1, 0xfffe]