Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
ConfiguredTcpConnection.hxx
Go to the documentation of this file.
1
35#ifndef _OPENLCB_CONFIGUREDTCPCONNCTION_HXX_
36#define _OPENLCB_CONFIGUREDTCPCONNCTION_HXX_
37
39
40namespace openlcb
41{
42
48{
49public:
51 static constexpr const char *SEARCH_MODE_NAME = "Search Mode";
53 static constexpr const char *SEARCH_MODE_DESCR =
54 "Defines the order of how to locate the server to connect to. 'auto' "
55 "uses the mDNS protocol to find the IP address automatically. 'manual' "
56 "uses the IP address entered in this settings.";
59 static constexpr const char *SEARCH_MODE_MAP =
60 "<relation><property>0</property><value>Auto, Manual</value></relation>"
61 "<relation><property>1</property><value>Manual, Auto</value></relation>"
62 "<relation><property>2</property><value>Auto Only</value></relation>"
63 "<relation><property>3</property><value>Manual Only</value></relation>";
64
66 static constexpr const char *MANUAL_ADDRESS_NAME = "Manual Address";
68 static constexpr const char *MANUAL_ADDRESS_DESCR =
69 "Set IP address here if auto-detection does not work.";
70
72 static constexpr const char *IP_ADDRESS_NAME = "IP Address";
75 static constexpr const char *IP_ADDRESS_DESCR =
76 "Enter the server IP address. Example: 192.168.0.55";
77
80 static constexpr int DEFAULT_PORT = 12021;
82 static constexpr const char *PORT_NAME = "Port Number";
84 static constexpr const char *PORT_DESCR =
85 "TCP port number of the server. Most of the time this does not need to "
86 "be changed.";
87
89 static constexpr const char *AUTO_ADDRESS_NAME = "Auto Address";
91 static constexpr const char *AUTO_ADDRESS_DESCR =
92 "Advanced settings for the server IP address auto-detection (mDNS).";
93
95 static constexpr const char *SERVICE_NAME = "mDNS Service";
98 static constexpr const char *SERVICE_DESCR =
99 "mDNS or Bonjour service name, such as _openlcb-can._tcp";
100
102 static constexpr const char *HOST_NAME = "Only Hostname";
104 static constexpr const char *HOST_DESCR =
105 "Use when multiple servers provide the same service on the network. If "
106 "set, selects this specific host name; the connection will fail if "
107 "none of the servers have this hostname (use correct capitalization!). "
108 "Example: My JMRI Railroad";
109
111 static constexpr const char *RECONNECT_NAME = "Reconnect";
113 static constexpr const char *RECONNECT_DESCR =
114 "If enabled, tries the last known good IP address before searching for "
115 "the server.";
118 static constexpr const char *RECONNECT_MAP =
119 "<relation><property>0</property><value>Disabled</value></relation>"
120 "<relation><property>1</property><value>Enabled</value></relation>";
122 static constexpr int RECONNECT_DEFAULT = 1;
123};
124
125template <class LocalParams> CDI_GROUP(TcpManualAddress);
127 Name(LocalParams::IP_ADDRESS_NAME),
128 Description(LocalParams::IP_ADDRESS_DESCR));
129CDI_GROUP_ENTRY(port, Uint16ConfigEntry, Name(LocalParams::PORT_NAME),
130 Description(LocalParams::PORT_DESCR), Min(1), Max(65535),
131 Default(LocalParams::DEFAULT_PORT));
133
134template <class LocalParams> CDI_GROUP(TcpAutoAddress);
136 Name(LocalParams::SERVICE_NAME), Description(LocalParams::SERVICE_DESCR));
137CDI_GROUP_ENTRY(host_name, StringConfigEntry<48>, Name(LocalParams::HOST_NAME),
138 Description(LocalParams::HOST_DESCR));
140
141template <class LocalParams> CDI_GROUP(TcpClientConfig);
142// This is of type SocketClientParams::SearchMode.
144 Name(LocalParams::SEARCH_MODE_NAME),
145 Description(LocalParams::SEARCH_MODE_DESCR), Min(0), Max(3), Default(0),
146 MapValues(LocalParams::SEARCH_MODE_MAP));
147CDI_GROUP_ENTRY(manual_address, TcpManualAddress<LocalParams>,
148 Name(LocalParams::MANUAL_ADDRESS_NAME),
149 Description(LocalParams::MANUAL_ADDRESS_DESCR));
150CDI_GROUP_ENTRY(auto_address, TcpAutoAddress<LocalParams>,
151 Name(LocalParams::AUTO_ADDRESS_NAME),
152 Description(LocalParams::AUTO_ADDRESS_DESCR));
153CDI_GROUP_ENTRY(reconnect, Uint8ConfigEntry, Name(LocalParams::RECONNECT_NAME),
154 Description(LocalParams::RECONNECT_DESCR), Min(0), Max(1),
155 Default(LocalParams::RECONNECT_DEFAULT),
156 MapValues(LocalParams::RECONNECT_MAP));
159CDI_GROUP_ENTRY(last_address, TcpManualAddress<LocalParams>, Hidden(true));
161
162} // namespace openlcb
163
164#endif // _OPENLCB_CONFIGUREDTCPCONNCTION_HXX_
#define CDI_GROUP(GroupName, ARGS...)
Starts a CDI group.
#define CDI_GROUP_ENTRY(NAME, TYPE, ARGS...)
Adds an entry to a CDI group.
Implementation class for numeric configuration entries, templated by the integer type.
Implementation class for string configuration entries.
This structure shows what parameters are configurable in the TcpClientConfig CDI group definition.
static constexpr const char * AUTO_ADDRESS_NAME
Visible name of the auto address group.
static constexpr const char * RECONNECT_DESCR
Visible description of the reconnect enable field.
static constexpr const char * SERVICE_NAME
Visible name of the service name field in the auto address group.
static constexpr const char * SEARCH_MODE_MAP
<map> of possible keys and descriptive values to show to the user for the search_mode field.
static constexpr const char * HOST_NAME
Visible name of the host name field in the auto address group.
static constexpr const char * SEARCH_MODE_DESCR
Visible description of the search_mode field.
static constexpr const char * IP_ADDRESS_DESCR
Visible description of the ip address field inside the manual address group.
static constexpr const char * MANUAL_ADDRESS_NAME
Visible name of the manual address group.
static constexpr const char * RECONNECT_NAME
Visible name of the reconnect enable field.
static constexpr const char * SEARCH_MODE_NAME
Visible name of the search_mode field.
static constexpr const char * MANUAL_ADDRESS_DESCR
Visible description of the manual address group.
static constexpr const char * PORT_DESCR
Visible description of the port number field.
static constexpr const char * PORT_NAME
Visible name of the port number field.
static constexpr const char * RECONNECT_MAP
<map> of possible keys and descriptive values to show to the user for the reconnect field.
static constexpr const char * IP_ADDRESS_NAME
Visible name of the ip address field inside the manual address group.
static constexpr const char * SERVICE_DESCR
Visible description of the service name field in the auto address group.
static constexpr const char * AUTO_ADDRESS_DESCR
Visible description of the auto address group.
static constexpr int RECONNECT_DEFAULT
Default value for the Reconnect parameter.
static constexpr const char * HOST_DESCR
Visible description of the host name field in the auto address group.
static constexpr int DEFAULT_PORT
Default value for the port number field.
CDI_GROUP_END()
Signals termination of the group.