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 - 2026 (C). Alex Robenko. All rights reserved.
3//
4// SPDX-License-Identifier: MPL-2.0
5//
6// This Source Code Form is subject to the terms of the Mozilla Public
7// License, v. 2.0. If a copy of the MPL was not distributed with this
8// file, You can obtain one at http://mozilla.org/MPL/2.0/.
9
12
13#pragma once
14
15#include <memory>
16#include <cstdint>
17#include <map>
18#include <iosfwd>
19#include <vector>
20#include <cstdint>
21#include <string>
22#include <list>
23#include <utility>
24
25namespace cc_mqttsn_gateway
26{
27
28class ConfigImpl;
29
35class Config
36{
37public:
38
44 using ConfigMap = std::multimap<std::string, std::string>;
45
47 using BinaryData = std::vector<std::uint8_t>;
48
51 {
52 std::string clientId;
53 std::string topic;
54 std::uint16_t topicId = 0;
55 };
56
58 using PredefinedTopicsList = std::vector<PredefinedTopicInfo>;
59
61 struct AuthInfo
62 {
63 std::string clientId;
64 std::string username;
65 std::string password;
66 };
67
69 using AuthInfosList = std::vector<AuthInfo>;
70
74 using TopicIdsRange = std::pair<std::uint16_t, std::uint16_t>;
75
82
89
92
95
99 void read(std::istream& stream);
100
102 const ConfigMap& configMap() const;
103
107 std::uint8_t gatewayId() const;
108
112 std::uint16_t advertisePeriod() const;
113
117 unsigned retryPeriod() const;
118
122 unsigned retryCount() const;
123
127 const std::string& defaultClientId() const;
128
132 std::uint16_t pubOnlyKeepAlive() const;
133
138 std::size_t sleepingClientMsgLimit() const;
139
142
144 const AuthInfosList& authInfos() const;
145
149
152 const std::string& brokerTcpHostAddress() const;
153
156 std::uint16_t brokerTcpHostPort() const;
157
161 const std::string& logFile() const;
162
166
170
171private:
172 std::unique_ptr<ConfigImpl> m_pImpl;
173};
174
175} // namespace cc_mqttsn_gateway
176
Interface for Config entity.
Definition Config.h:36
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:58
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:47
TopicIdsRange topicIdAllocRange() const
Get range of allowed topic IDs for allocation.
std::multimap< std::string, std::string > ConfigMap
Full configuration map.
Definition Config.h:44
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:69
std::pair< std::uint16_t, std::uint16_t > TopicIdsRange
Range of topic IDs.
Definition Config.h:74
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:85
@ BrokerConnectionType_Tcp
TCP/IP.
Definition Config.h:86
@ BrokerConnectionType_ValuesLimit
Limit to available values, must be last.
Definition Config.h:87
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:78
@ ClientConnectionType_Udp
UDP/IP.
Definition Config.h:79
@ ClientConnectionType_ValuesLimit
Limit to available values, must be last.
Definition Config.h:80
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:62
std::string password
Password string (from the configuration)
Definition Config.h:65
std::string clientId
Client ID.
Definition Config.h:63
std::string username
Username.
Definition Config.h:64
Info about single predefined topic.
Definition Config.h:51
std::string topic
Topic string.
Definition Config.h:53
std::uint16_t topicId
Numeric topic ID.
Definition Config.h:54
std::string clientId
Client ID.
Definition Config.h:52