MQTT-SN Gateway Library
Library that allows implementation of MQTT-SN gateway.
Loading...
Searching...
No Matches
Config.h
Go to the documentation of this file.
1//
2// Copyright 2016 - 2024 (C). Alex Robenko. All rights reserved.
3//
4// This Source Code Form is subject to the terms of the Mozilla Public
5// License, v. 2.0. If a copy of the MPL was not distributed with this
6// file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
10
11#pragma once
12
13#include <memory>
14#include <cstdint>
15#include <map>
16#include <iosfwd>
17#include <vector>
18#include <cstdint>
19#include <string>
20#include <list>
21#include <utility>
22
23namespace cc_mqttsn_gateway
24{
25
26class ConfigImpl;
27
33class Config
34{
35public:
36
42 using ConfigMap = std::multimap<std::string, std::string>;
43
45 using BinaryData = std::vector<std::uint8_t>;
46
49 {
50 std::string clientId;
51 std::string topic;
52 std::uint16_t topicId = 0;
53 };
54
56 using PredefinedTopicsList = std::vector<PredefinedTopicInfo>;
57
59 struct AuthInfo
60 {
61 std::string clientId;
62 std::string username;
63 std::string password;
64 };
65
67 using AuthInfosList = std::vector<AuthInfo>;
68
72 using TopicIdsRange = std::pair<std::uint16_t, std::uint16_t>;
73
80
87
90
93
97 void read(std::istream& stream);
98
100 const ConfigMap& configMap() const;
101
105 std::uint8_t gatewayId() const;
106
110 std::uint16_t advertisePeriod() const;
111
115 unsigned retryPeriod() const;
116
120 unsigned retryCount() const;
121
125 const std::string& defaultClientId() const;
126
130 std::uint16_t pubOnlyKeepAlive() const;
131
136 std::size_t sleepingClientMsgLimit() const;
137
140
142 const AuthInfosList& authInfos() const;
143
147
150 const std::string& brokerTcpHostAddress() const;
151
154 std::uint16_t brokerTcpHostPort() const;
155
159 const std::string& logFile() const;
160
164
168
169private:
170 std::unique_ptr<ConfigImpl> m_pImpl;
171};
172
173} // namespace cc_mqttsn_gateway
174
175
Interface for Config entity.
Definition Config.h:34
std::uint16_t advertisePeriod() const
Get advertise period.
const std::string & defaultClientId() const
Get default client ID.
const AuthInfosList & authInfos() const
Get access to list of authentication informations.
ClientConnectionType clientConnectionType() const
Get client side I/O socket connection type.
std::vector< PredefinedTopicInfo > PredefinedTopicsList
Type of list containing predefined topics.
Definition Config.h:56
std::size_t sleepingClientMsgLimit() const
Get limit for max number of messages to accumulate for sleeping clients.
std::vector< std::uint8_t > BinaryData
Type of buffer that contains binary data.
Definition Config.h:45
TopicIdsRange topicIdAllocRange() const
Get range of allowed topic IDs for allocation.
std::multimap< std::string, std::string > ConfigMap
Full configuration map.
Definition Config.h:42
std::uint16_t brokerTcpHostPort() const
Get TCP/IP port of the broker.
unsigned retryCount() const
Get number of retry attempts.
std::uint16_t pubOnlyKeepAlive() const
Get keep alive period for publish only clients.
std::vector< AuthInfo > AuthInfosList
Type of list containing authentication information for multiple clients.
Definition Config.h:67
std::pair< std::uint16_t, std::uint16_t > TopicIdsRange
Range of topic IDs.
Definition Config.h:72
const std::string & brokerTcpHostAddress() const
Get TCP/IP address of the broker.
void read(std::istream &stream)
Read configuration from input stream.
BrokerConnectionType
Broker I/O socket connection type.
Definition Config.h:83
@ BrokerConnectionType_Tcp
TCP/IP.
Definition Config.h:84
@ BrokerConnectionType_ValuesLimit
Limit to available values, must be last.
Definition Config.h:85
std::uint8_t gatewayId() const
Get gateway numeric ID.
const PredefinedTopicsList & predefinedTopics() const
Get access to the list of predefined topics.
unsigned retryPeriod() const
Get retry period.
const std::string & logFile() const
Get log file.
ClientConnectionType
Client I/O socket connection type.
Definition Config.h:76
@ ClientConnectionType_Udp
UDP/IP.
Definition Config.h:77
@ ClientConnectionType_ValuesLimit
Limit to available values, must be last.
Definition Config.h:78
BrokerConnectionType brokerConnectionType() const
Get broker side I/O socket connection type.
const ConfigMap & configMap() const
Get access to the full configuration map.
Main namespace for all classes / functions of the gateway library.
Authentication info for single client.
Definition Config.h:60
std::string password
Password string (from the configuration)
Definition Config.h:63
std::string clientId
Client ID.
Definition Config.h:61
std::string username
Username.
Definition Config.h:62
Info about single predefined topic.
Definition Config.h:49
std::string topic
Topic string.
Definition Config.h:51
std::uint16_t topicId
Numeric topic ID.
Definition Config.h:52
std::string clientId
Client ID.
Definition Config.h:50