Skip to content

Commit 3b6713e

Browse files
committed
TCP: make begin(bool, String uint16_t, bool) private
1 parent e649174 commit 3b6713e

File tree

2 files changed

+62
-60
lines changed

2 files changed

+62
-60
lines changed

src/ArduinoIoTCloudTCP.cpp

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -139,65 +139,6 @@ int ArduinoIoTCloudTCP::begin(ConnectionHandler & connection, bool const enable_
139139
return begin(enable_watchdog, _brokerAddress, _brokerPort, auto_reconnect);
140140
}
141141

142-
int ArduinoIoTCloudTCP::begin(bool const enable_watchdog, String brokerAddress, uint16_t brokerPort, bool auto_reconnect)
143-
{
144-
_enable_watchdog = enable_watchdog;
145-
_brokerAddress = brokerAddress;
146-
_brokerPort = brokerPort;
147-
_auto_reconnect = auto_reconnect;
148-
149-
_state = State::ConfigPhy;
150-
151-
_mqttClient.setClient(_brokerClient);
152-
153-
#ifdef BOARD_HAS_SECRET_KEY
154-
if(_password.length())
155-
{
156-
_mqttClient.setUsernamePassword(getDeviceId(), _password);
157-
}
158-
#endif
159-
160-
_mqttClient.onMessage(ArduinoIoTCloudTCP::onMessage);
161-
_mqttClient.setKeepAliveInterval(30 * 1000);
162-
_mqttClient.setConnectionTimeout(1500);
163-
_mqttClient.setId(getDeviceId().c_str());
164-
165-
_messageTopicOut = getTopic_messageout();
166-
_messageTopicIn = getTopic_messagein();
167-
168-
_thing.begin();
169-
_device.begin();
170-
171-
#if OTA_ENABLED && !defined(OFFLOADED_DOWNLOAD)
172-
_ota.setClient(&_otaClient);
173-
#endif // OTA_ENABLED && !defined(OFFLOADED_DOWNLOAD)
174-
175-
#if OTA_ENABLED && defined(OTA_BASIC_AUTH)
176-
_ota.setAuthentication(getDeviceId().c_str(), _password.c_str());
177-
#endif // OTA_ENABLED && !defined(OFFLOADED_DOWNLOAD) && defined(OTA_BASIC_AUTH)
178-
179-
#ifdef BOARD_HAS_OFFLOADED_ECCX08
180-
if (String(WiFi.firmwareVersion()) < String("1.6.0")) {
181-
DEBUG_ERROR("ArduinoIoTCloudTCP::%s In order to connect to Arduino IoT Cloud, NINA firmware needs to be >= 1.6.0, current %s", __FUNCTION__, WiFi.firmwareVersion());
182-
return 0;
183-
}
184-
#endif /* BOARD_HAS_OFFLOADED_ECCX08 */
185-
186-
#if defined (ARDUINO_UNOWIFIR4)
187-
if (String(WiFi.firmwareVersion()) < String("0.2.0")) {
188-
DEBUG_ERROR("ArduinoIoTCloudTCP::%s In order to connect to Arduino IoT Cloud, WiFi firmware needs to be >= 0.2.0, current %s", __FUNCTION__, WiFi.firmwareVersion());
189-
}
190-
#endif
191-
192-
#if NETWORK_CONFIGURATOR_ENABLED
193-
if(_configurator != nullptr){
194-
_configurator->enableAgent(ConfiguratorAgent::AgentTypes::BLE,false);
195-
_configurator->begin();
196-
}
197-
#endif
198-
return 1;
199-
}
200-
201142
void ArduinoIoTCloudTCP::update()
202143
{
203144
/* Feed the watchdog. If any of the functions called below
@@ -295,6 +236,65 @@ void ArduinoIoTCloudTCP::disconnect() {
295236
* PRIVATE MEMBER FUNCTIONS
296237
******************************************************************************/
297238

239+
int ArduinoIoTCloudTCP::begin(bool const enable_watchdog, String brokerAddress, uint16_t brokerPort, bool auto_reconnect)
240+
{
241+
_enable_watchdog = enable_watchdog;
242+
_brokerAddress = brokerAddress;
243+
_brokerPort = brokerPort;
244+
_auto_reconnect = auto_reconnect;
245+
246+
_state = State::ConfigPhy;
247+
248+
_mqttClient.setClient(_brokerClient);
249+
250+
#ifdef BOARD_HAS_SECRET_KEY
251+
if(_password.length())
252+
{
253+
_mqttClient.setUsernamePassword(getDeviceId(), _password);
254+
}
255+
#endif
256+
257+
_mqttClient.onMessage(ArduinoIoTCloudTCP::onMessage);
258+
_mqttClient.setKeepAliveInterval(30 * 1000);
259+
_mqttClient.setConnectionTimeout(1500);
260+
_mqttClient.setId(getDeviceId().c_str());
261+
262+
_messageTopicOut = getTopic_messageout();
263+
_messageTopicIn = getTopic_messagein();
264+
265+
_thing.begin();
266+
_device.begin();
267+
268+
#if OTA_ENABLED && !defined(OFFLOADED_DOWNLOAD)
269+
_ota.setClient(&_otaClient);
270+
#endif // OTA_ENABLED && !defined(OFFLOADED_DOWNLOAD)
271+
272+
#if OTA_ENABLED && defined(OTA_BASIC_AUTH)
273+
_ota.setAuthentication(getDeviceId().c_str(), _password.c_str());
274+
#endif // OTA_ENABLED && !defined(OFFLOADED_DOWNLOAD) && defined(OTA_BASIC_AUTH)
275+
276+
#ifdef BOARD_HAS_OFFLOADED_ECCX08
277+
if (String(WiFi.firmwareVersion()) < String("1.6.0")) {
278+
DEBUG_ERROR("ArduinoIoTCloudTCP::%s In order to connect to Arduino IoT Cloud, NINA firmware needs to be >= 1.6.0, current %s", __FUNCTION__, WiFi.firmwareVersion());
279+
return 0;
280+
}
281+
#endif /* BOARD_HAS_OFFLOADED_ECCX08 */
282+
283+
#if defined (ARDUINO_UNOWIFIR4)
284+
if (String(WiFi.firmwareVersion()) < String("0.2.0")) {
285+
DEBUG_ERROR("ArduinoIoTCloudTCP::%s In order to connect to Arduino IoT Cloud, WiFi firmware needs to be >= 0.2.0, current %s", __FUNCTION__, WiFi.firmwareVersion());
286+
}
287+
#endif
288+
289+
#if NETWORK_CONFIGURATOR_ENABLED
290+
if(_configurator != nullptr){
291+
_configurator->enableAgent(ConfiguratorAgent::AgentTypes::BLE,false);
292+
_configurator->begin();
293+
}
294+
#endif
295+
return 1;
296+
}
297+
298298
ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_ConfigPhy()
299299
{
300300
#if NETWORK_CONFIGURATOR_ENABLED

src/ArduinoIoTCloudTCP.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ class ArduinoIoTCloudTCP: public ArduinoIoTCloudClass
7575
virtual void disconnect () override;
7676

7777
int begin(ConnectionHandler & connection, bool const enable_watchdog = true, String brokerAddress = DEFAULT_BROKER_ADDRESS, uint16_t brokerPort = DEFAULT_BROKER_PORT_AUTO, bool auto_reconnect = true);
78-
int begin(bool const enable_watchdog = true, String brokerAddress = DEFAULT_BROKER_ADDRESS, uint16_t brokerPort = DEFAULT_BROKER_PORT_AUTO, bool auto_reconnect = true);
7978

8079
#if defined(BOARD_HAS_SECURE_ELEMENT)
8180
int updateCertificate(String authorityKeyIdentifier, String serialNumber, String notBefore, String notAfter, String signature);
@@ -117,6 +116,9 @@ class ArduinoIoTCloudTCP: public ArduinoIoTCloudClass
117116
#endif
118117

119118
private:
119+
120+
int begin(bool const enable_watchdog = true, String brokerAddress = DEFAULT_BROKER_ADDRESS, uint16_t brokerPort = DEFAULT_BROKER_PORT_AUTO, bool auto_reconnect = true);
121+
120122
static const int MQTT_TRANSMIT_BUFFER_SIZE = 256;
121123

122124
enum class State

0 commit comments

Comments
 (0)