Skip to content

Commit 8309092

Browse files
committed
more indentation fixes
1 parent e5192d7 commit 8309092

File tree

1 file changed

+87
-87
lines changed

1 file changed

+87
-87
lines changed

src/ArduinoIoTCloudTCP.cpp

Lines changed: 87 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,11 @@ int ArduinoIoTCloudTCP::begin(String brokerAddress, uint16_t brokerPort)
149149
#if OTA_STORAGE_SNU
150150
String const nina_fw_version = WiFi.firmwareVersion();
151151
if (nina_fw_version < "1.4.1") {
152-
_ota_cap = false;
153-
DBG_WARNING(F("ArduinoIoTCloudTCP::%s In order to be ready for cloud OTA, NINA firmware needs to be >= 1.4.1, current %s"), __FUNCTION__, nina_fw_version.c_str());
152+
_ota_cap = false;
153+
DBG_WARNING(F("ArduinoIoTCloudTCP::%s In order to be ready for cloud OTA, NINA firmware needs to be >= 1.4.1, current %s"), __FUNCTION__, nina_fw_version.c_str());
154154
}
155155
else {
156-
_ota_cap = true;
156+
_ota_cap = true;
157157
}
158158
#endif /* OTA_STORAGE_SNU */
159159

@@ -177,7 +177,7 @@ void ArduinoIoTCloudTCP::update()
177177

178178
/* Check for new data from the MQTT client. */
179179
if (_mqttClient.connected())
180-
_mqttClient.poll();
180+
_mqttClient.poll();
181181
}
182182

183183
int ArduinoIoTCloudTCP::connected()
@@ -200,9 +200,9 @@ void ArduinoIoTCloudTCP::printDebugInfo()
200200
ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_ConnectPhy()
201201
{
202202
if (_connection->check() == NetworkConnectionState::CONNECTED)
203-
return State::SyncTime;
203+
return State::SyncTime;
204204
else
205-
return State::ConnectPhy;
205+
return State::ConnectPhy;
206206
}
207207

208208
ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SyncTime()
@@ -215,7 +215,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SyncTime()
215215
ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_ConnectMqttBroker()
216216
{
217217
if (_mqttClient.connect(_brokerAddress.c_str(), _brokerPort))
218-
return State::SubscribeMqttTopics;
218+
return State::SubscribeMqttTopics;
219219

220220
DBG_ERROR(F("ArduinoIoTCloudTCP::%s could not connect to %s:%d"), __FUNCTION__, _brokerAddress.c_str(), _brokerPort);
221221
return State::ConnectPhy;
@@ -225,26 +225,26 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SubscribeMqttTopics()
225225
{
226226
if (!_mqttClient.subscribe(_dataTopicIn))
227227
{
228-
DBG_ERROR(F("ArduinoIoTCloudTCP::%s could not subscribe to %s"), __FUNCTION__, _dataTopicIn.c_str());
229-
return State::SubscribeMqttTopics;
228+
DBG_ERROR(F("ArduinoIoTCloudTCP::%s could not subscribe to %s"), __FUNCTION__, _dataTopicIn.c_str());
229+
return State::SubscribeMqttTopics;
230230
}
231231

232232
if (_shadowTopicIn != "")
233233
{
234-
if (!_mqttClient.subscribe(_shadowTopicIn))
235-
{
236-
DBG_ERROR(F("ArduinoIoTCloudTCP::%s could not subscribe to %s"), __FUNCTION__, _shadowTopicIn.c_str());
237-
return State::SubscribeMqttTopics;
238-
}
234+
if (!_mqttClient.subscribe(_shadowTopicIn))
235+
{
236+
DBG_ERROR(F("ArduinoIoTCloudTCP::%s could not subscribe to %s"), __FUNCTION__, _shadowTopicIn.c_str());
237+
return State::SubscribeMqttTopics;
238+
}
239239
}
240240

241241
DBG_INFO(F("Connected to Arduino IoT Cloud"));
242242
execCloudEventCallback(ArduinoIoTCloudEvent::CONNECT);
243243

244244
if (_shadowTopicIn != "")
245-
return State::RequestLastValues;
245+
return State::RequestLastValues;
246246
else
247-
return State::Connected;
247+
return State::Connected;
248248
}
249249

250250
ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_RequestLastValues()
@@ -253,9 +253,9 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_RequestLastValues()
253253
unsigned long const now = millis();
254254
if ((now - _lastSyncRequestTickTime) > TIMEOUT_FOR_LASTVALUES_SYNC)
255255
{
256-
DBG_VERBOSE(F("ArduinoIoTCloudTCP::%s [%d] last values requested"), __FUNCTION__, now);
257-
requestLastValue();
258-
_lastSyncRequestTickTime = now;
256+
DBG_VERBOSE(F("ArduinoIoTCloudTCP::%s [%d] last values requested"), __FUNCTION__, now);
257+
requestLastValue();
258+
_lastSyncRequestTickTime = now;
259259
}
260260

261261
return State::RequestLastValues;
@@ -265,62 +265,62 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_Connected()
265265
{
266266
if (!_mqttClient.connected())
267267
{
268-
DBG_ERROR(F("ArduinoIoTCloudTCP::%s MQTT client connection lost"), __FUNCTION__);
268+
DBG_ERROR(F("ArduinoIoTCloudTCP::%s MQTT client connection lost"), __FUNCTION__);
269269

270-
/* Forcefully disconnect MQTT client and trigger a reconnection. */
271-
_mqttClient.stop();
270+
/* Forcefully disconnect MQTT client and trigger a reconnection. */
271+
_mqttClient.stop();
272272

273-
/* The last message was definitely lost, trigger a retransmit. */
274-
_mqtt_data_request_retransmit = true;
273+
/* The last message was definitely lost, trigger a retransmit. */
274+
_mqtt_data_request_retransmit = true;
275275

276-
/* We are not connected anymore, trigger the callback for a disconnected event. */
277-
execCloudEventCallback(ArduinoIoTCloudEvent::DISCONNECT);
276+
/* We are not connected anymore, trigger the callback for a disconnected event. */
277+
execCloudEventCallback(ArduinoIoTCloudEvent::DISCONNECT);
278278

279-
return State::ConnectPhy;
279+
return State::ConnectPhy;
280280
}
281281
/* We are connected so let's to our stuff here. */
282282
else
283283
{
284-
/* Check if a primitive property wrapper is locally changed.
285-
* This function requires an existing time service which in
286-
* turn requires an established connection. Not having that
287-
* leads to a wrong time set in the time service which inhibits
288-
* the connection from being established due to a wrong data
289-
* in the reconstructed certificate.
290-
*/
291-
updateTimestampOnLocallyChangedProperties(_property_container);
292-
293-
/* Retransmit data in case there was a lost transaction due
294-
* to phy layer or MQTT connectivity loss.
295-
*/
296-
if(_mqtt_data_request_retransmit && (_mqtt_data_len > 0)) {
297-
write(_dataTopicOut, _mqtt_data_buf, _mqtt_data_len);
298-
_mqtt_data_request_retransmit = false;
299-
}
284+
/* Check if a primitive property wrapper is locally changed.
285+
* This function requires an existing time service which in
286+
* turn requires an established connection. Not having that
287+
* leads to a wrong time set in the time service which inhibits
288+
* the connection from being established due to a wrong data
289+
* in the reconstructed certificate.
290+
*/
291+
updateTimestampOnLocallyChangedProperties(_property_container);
292+
293+
/* Retransmit data in case there was a lost transaction due
294+
* to phy layer or MQTT connectivity loss.
295+
*/
296+
if(_mqtt_data_request_retransmit && (_mqtt_data_len > 0)) {
297+
write(_dataTopicOut, _mqtt_data_buf, _mqtt_data_len);
298+
_mqtt_data_request_retransmit = false;
299+
}
300300

301-
/* Check if any properties need encoding and send them to
302-
* the cloud if necessary.
303-
*/
304-
sendPropertiesToCloud();
301+
/* Check if any properties need encoding and send them to
302+
* the cloud if necessary.
303+
*/
304+
sendPropertiesToCloud();
305305

306306
#if OTA_ENABLED
307-
/* Request a OTA download if the hidden property
308-
* OTA request has been set.
309-
*/
310-
if (_ota_req)
311-
{
312-
/* Clear the error flag. */
313-
_ota_error = static_cast<int>(OTAError::None);
314-
/* Transmit the cleared error flag to the cloud. */
315-
sendPropertiesToCloud();
316-
/* Clear the request flag. */
317-
_ota_req = false;
318-
/* Call member function to handle OTA request. */
319-
onOTARequest();
320-
}
307+
/* Request a OTA download if the hidden property
308+
* OTA request has been set.
309+
*/
310+
if (_ota_req)
311+
{
312+
/* Clear the error flag. */
313+
_ota_error = static_cast<int>(OTAError::None);
314+
/* Transmit the cleared error flag to the cloud. */
315+
sendPropertiesToCloud();
316+
/* Clear the request flag. */
317+
_ota_req = false;
318+
/* Call member function to handle OTA request. */
319+
onOTARequest();
320+
}
321321
#endif /* OTA_ENABLED */
322322

323-
return State::Connected;
323+
return State::Connected;
324324
}
325325
}
326326

@@ -336,20 +336,20 @@ void ArduinoIoTCloudTCP::handleMessage(int length)
336336
byte bytes[length];
337337

338338
for (int i = 0; i < length; i++) {
339-
bytes[i] = _mqttClient.read();
339+
bytes[i] = _mqttClient.read();
340340
}
341341

342342
if (_dataTopicIn == topic) {
343-
CBORDecoder::decode(_property_container, (uint8_t*)bytes, length);
343+
CBORDecoder::decode(_property_container, (uint8_t*)bytes, length);
344344
}
345345

346346
if ((_shadowTopicIn == topic) && (_state == State::RequestLastValues))
347347
{
348-
DBG_VERBOSE(F("ArduinoIoTCloudTCP::%s [%d] last values received"), __FUNCTION__, millis());
349-
CBORDecoder::decode(_property_container, (uint8_t*)bytes, length, true);
350-
sendPropertiesToCloud();
351-
execCloudEventCallback(ArduinoIoTCloudEvent::SYNC);
352-
_state = State::Connected;
348+
DBG_VERBOSE(F("ArduinoIoTCloudTCP::%s [%d] last values received"), __FUNCTION__, millis());
349+
CBORDecoder::decode(_property_container, (uint8_t*)bytes, length, true);
350+
sendPropertiesToCloud();
351+
execCloudEventCallback(ArduinoIoTCloudEvent::SYNC);
352+
_state = State::Connected;
353353
}
354354
}
355355

@@ -359,16 +359,16 @@ void ArduinoIoTCloudTCP::sendPropertiesToCloud()
359359
uint8_t data[MQTT_TRANSMIT_BUFFER_SIZE];
360360

361361
if (CBOREncoder::encode(_property_container, data, sizeof(data), bytes_encoded, false) == CborNoError)
362-
if (bytes_encoded > 0)
363-
{
364-
/* If properties have been encoded store them in the back-up buffer
365-
* in order to allow retransmission in case of failure.
366-
*/
367-
_mqtt_data_len = bytes_encoded;
368-
memcpy(_mqtt_data_buf, data, _mqtt_data_len);
369-
/* Transmit the properties to the MQTT broker */
370-
write(_dataTopicOut, _mqtt_data_buf, _mqtt_data_len);
371-
}
362+
if (bytes_encoded > 0)
363+
{
364+
/* If properties have been encoded store them in the back-up buffer
365+
* in order to allow retransmission in case of failure.
366+
*/
367+
_mqtt_data_len = bytes_encoded;
368+
memcpy(_mqtt_data_buf, data, _mqtt_data_len);
369+
/* Transmit the properties to the MQTT broker */
370+
write(_dataTopicOut, _mqtt_data_buf, _mqtt_data_len);
371+
}
372372
}
373373

374374
void ArduinoIoTCloudTCP::requestLastValue()
@@ -383,12 +383,12 @@ void ArduinoIoTCloudTCP::requestLastValue()
383383
int ArduinoIoTCloudTCP::write(String const topic, byte const data[], int const length)
384384
{
385385
if (_mqttClient.beginMessage(topic, length, false, 0)) {
386-
if (_mqttClient.write(data, length)) {
387-
if (_mqttClient.endMessage()) {
388-
return 1;
386+
if (_mqttClient.write(data, length)) {
387+
if (_mqttClient.endMessage()) {
388+
return 1;
389+
}
389390
}
390391
}
391-
}
392392
return 0;
393393
}
394394

@@ -411,9 +411,9 @@ void ArduinoIoTCloudTCP::onOTARequest()
411411
uint8_t nina_ota_err_code = 0;
412412
if (!WiFiStorage.downloadOTA(_ota_url.c_str(), &nina_ota_err_code))
413413
{
414-
DBG_ERROR(F("ArduinoIoTCloudTCP::%s error download to nina: %d"), __FUNCTION__, nina_ota_err_code);
415-
_ota_error = static_cast<int>(OTAError::DownloadFailed);
416-
return;
414+
DBG_ERROR(F("ArduinoIoTCloudTCP::%s error download to nina: %d"), __FUNCTION__, nina_ota_err_code);
415+
_ota_error = static_cast<int>(OTAError::DownloadFailed);
416+
return;
417417
}
418418

419419
/* The download was a success. */
@@ -422,7 +422,7 @@ void ArduinoIoTCloudTCP::onOTARequest()
422422

423423
/* Perform the reset to reboot to SxU. */
424424
if (ota_download_success)
425-
NVIC_SystemReset();
425+
NVIC_SystemReset();
426426
}
427427
#endif
428428

0 commit comments

Comments
 (0)