Skip to content

Commit 956cd77

Browse files
committed
Correcting debug macros to allow code to compile.
1 parent 573ce66 commit 956cd77

File tree

1 file changed

+42
-22
lines changed

1 file changed

+42
-22
lines changed

src/ArduinoIoTCloudTCP.cpp

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,35 @@ int ArduinoIoTCloudTCP::begin(String brokerAddress, uint16_t brokerPort)
118118
#endif /* OTA_ENABLED */
119119

120120
#ifdef BOARD_HAS_OFFLOADED_ECCX08
121-
if (!ECCX08.begin()) { DBG_ERROR(F("Cryptography processor failure. Make sure you have a compatible board.")); return 0; }
122-
if (!CryptoUtil::readDeviceId(ECCX08, getDeviceId(), ECCX08Slot::DeviceId)) { DBG_ERROR(F("Cryptography processor read failure.")); return 0; }
121+
if (!ECCX08.begin())
122+
{
123+
DEBUG_ERROR("Cryptography processor failure. Make sure you have a compatible board.");
124+
return 0;
125+
}
126+
if (!CryptoUtil::readDeviceId(ECCX08, getDeviceId(), ECCX08Slot::DeviceId))
127+
{
128+
DEBUG_ERROR("Cryptography processor read failure.");
129+
return 0;
130+
}
123131
ECCX08.end();
124132
#endif
125133

126134
#ifdef BOARD_HAS_ECCX08
127-
if (!ECCX08.begin()) { DBG_ERROR(F("Cryptography processor failure. Make sure you have a compatible board.")); return 0; }
128-
if (!CryptoUtil::readDeviceId(ECCX08, getDeviceId(), ECCX08Slot::DeviceId)) { DBG_ERROR(F("Cryptography processor read failure.")); return 0; }
129-
if (!CryptoUtil::reconstructCertificate(_eccx08_cert, getDeviceId(), ECCX08Slot::Key, ECCX08Slot::CompressedCertificate, ECCX08Slot::SerialNumberAndAuthorityKeyIdentifier)) { DBG_ERROR(F("Cryptography certificate reconstruction failure.")); return 0; }
135+
if (!ECCX08.begin())
136+
{
137+
DEBUG_ERROR(F("Cryptography processor failure. Make sure you have a compatible board."));
138+
return 0;
139+
}
140+
if (!CryptoUtil::readDeviceId(ECCX08, getDeviceId(), ECCX08Slot::DeviceId))
141+
{
142+
DEBUG_ERROR(F("Cryptography processor read failure."));
143+
return 0;
144+
}
145+
if (!CryptoUtil::reconstructCertificate(_eccx08_cert, getDeviceId(), ECCX08Slot::Key, ECCX08Slot::CompressedCertificate, ECCX08Slot::SerialNumberAndAuthorityKeyIdentifier))
146+
{
147+
DEBUG_ERROR(F("Cryptography certificate reconstruction failure."));
148+
return 0;
149+
}
130150
_sslClient.setClient(_connection->getClient());
131151
_sslClient.setEccSlot(static_cast<int>(ECCX08Slot::Key), _eccx08_cert.bytes(), _eccx08_cert.length());
132152
#elif defined(BOARD_ESP)
@@ -161,7 +181,7 @@ int ArduinoIoTCloudTCP::begin(String brokerAddress, uint16_t brokerPort)
161181
String const nina_fw_version = WiFi.firmwareVersion();
162182
if (nina_fw_version < "1.4.1") {
163183
_ota_cap = false;
164-
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());
184+
DEBUG_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());
165185
}
166186
else {
167187
_ota_cap = true;
@@ -198,10 +218,10 @@ int ArduinoIoTCloudTCP::connected()
198218

199219
void ArduinoIoTCloudTCP::printDebugInfo()
200220
{
201-
DBG_INFO(F("***** Arduino IoT Cloud - configuration info *****"));
202-
DBG_INFO(F("Device ID: %s"), getDeviceId().c_str());
203-
DBG_INFO(F("Thing ID: %s"), getThingId().c_str());
204-
DBG_INFO(F("MQTT Broker: %s:%d"), _brokerAddress.c_str(), _brokerPort);
221+
DEBUG_INFO(F("***** Arduino IoT Cloud - configuration info *****"));
222+
DEBUG_INFO(F("Device ID: %s"), getDeviceId().c_str());
223+
DEBUG_INFO(F("Thing ID: %s"), getThingId().c_str());
224+
DEBUG_INFO(F("MQTT Broker: %s:%d"), _brokerAddress.c_str(), _brokerPort);
205225
}
206226

207227
/******************************************************************************
@@ -219,7 +239,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_ConnectPhy()
219239
ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SyncTime()
220240
{
221241
unsigned long const internal_posix_time = _time_service.getTime();
222-
DBG_VERBOSE(F("ArduinoIoTCloudTCP::%s internal clock configured to posix timestamp %d"), __FUNCTION__, internal_posix_time);
242+
DEBUG_VERBOSE(F("ArduinoIoTCloudTCP::%s internal clock configured to posix timestamp %d"), __FUNCTION__, internal_posix_time);
223243
return State::ConnectMqttBroker;
224244
}
225245

@@ -228,30 +248,30 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_ConnectMqttBroker()
228248
if (_mqttClient.connect(_brokerAddress.c_str(), _brokerPort))
229249
return State::SubscribeMqttTopics;
230250

231-
DBG_ERROR(F("ArduinoIoTCloudTCP::%s could not connect to %s:%d"), __FUNCTION__, _brokerAddress.c_str(), _brokerPort);
251+
DEBUG_ERROR(F("ArduinoIoTCloudTCP::%s could not connect to %s:%d"), __FUNCTION__, _brokerAddress.c_str(), _brokerPort);
232252
return State::ConnectPhy;
233253
}
234254

235255
ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SubscribeMqttTopics()
236256
{
237257
if (!_mqttClient.subscribe(_dataTopicIn))
238258
{
239-
DBG_ERROR(F("ArduinoIoTCloudTCP::%s could not subscribe to %s"), __FUNCTION__, _dataTopicIn.c_str());
240-
DBG_ERROR(F("Check your thing configuration, and press the reset button on your board."));
259+
DEBUG_ERROR(F("ArduinoIoTCloudTCP::%s could not subscribe to %s"), __FUNCTION__, _dataTopicIn.c_str());
260+
DEBUG_ERROR(F("Check your thing configuration, and press the reset button on your board."));
241261
return State::SubscribeMqttTopics;
242262
}
243263

244264
if (_shadowTopicIn != "")
245265
{
246266
if (!_mqttClient.subscribe(_shadowTopicIn))
247267
{
248-
DBG_ERROR(F("ArduinoIoTCloudTCP::%s could not subscribe to %s"), __FUNCTION__, _shadowTopicIn.c_str());
249-
DBG_ERROR(F("Check your thing configuration, and press the reset button on your board."));
268+
DEBUG_ERROR(F("ArduinoIoTCloudTCP::%s could not subscribe to %s"), __FUNCTION__, _shadowTopicIn.c_str());
269+
DEBUG_ERROR(F("Check your thing configuration, and press the reset button on your board."));
250270
return State::SubscribeMqttTopics;
251271
}
252272
}
253273

254-
DBG_INFO(F("Connected to Arduino IoT Cloud"));
274+
DEBUG_INFO(F("Connected to Arduino IoT Cloud"));
255275
execCloudEventCallback(ArduinoIoTCloudEvent::CONNECT);
256276

257277
if (_shadowTopicIn != "")
@@ -266,7 +286,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_RequestLastValues()
266286
unsigned long const now = millis();
267287
if ((now - _lastSyncRequestTickTime) > TIMEOUT_FOR_LASTVALUES_SYNC)
268288
{
269-
DBG_VERBOSE(F("ArduinoIoTCloudTCP::%s [%d] last values requested"), __FUNCTION__, now);
289+
DEBUG_VERBOSE(F("ArduinoIoTCloudTCP::%s [%d] last values requested"), __FUNCTION__, now);
270290
requestLastValue();
271291
_lastSyncRequestTickTime = now;
272292
}
@@ -278,7 +298,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_Connected()
278298
{
279299
if (!_mqttClient.connected())
280300
{
281-
DBG_ERROR(F("ArduinoIoTCloudTCP::%s MQTT client connection lost"), __FUNCTION__);
301+
DEBUG_ERROR(F("ArduinoIoTCloudTCP::%s MQTT client connection lost"), __FUNCTION__);
282302

283303
/* Forcefully disconnect MQTT client and trigger a reconnection. */
284304
_mqttClient.stop();
@@ -358,7 +378,7 @@ void ArduinoIoTCloudTCP::handleMessage(int length)
358378

359379
if ((_shadowTopicIn == topic) && (_state == State::RequestLastValues))
360380
{
361-
DBG_VERBOSE(F("ArduinoIoTCloudTCP::%s [%d] last values received"), __FUNCTION__, millis());
381+
DEBUG_VERBOSE(F("ArduinoIoTCloudTCP::%s [%d] last values received"), __FUNCTION__, millis());
362382
CBORDecoder::decode(_property_container, (uint8_t*)bytes, length, true);
363383
sendPropertiesToCloud();
364384
execCloudEventCallback(ArduinoIoTCloudEvent::SYNC);
@@ -408,7 +428,7 @@ int ArduinoIoTCloudTCP::write(String const topic, byte const data[], int const l
408428
#if OTA_ENABLED
409429
void ArduinoIoTCloudTCP::onOTARequest()
410430
{
411-
DBG_VERBOSE(F("ArduinoIoTCloudTCP::%s _ota_url = %s"), __FUNCTION__, _ota_url.c_str());
431+
DEBUG_VERBOSE(F("ArduinoIoTCloudTCP::%s _ota_url = %s"), __FUNCTION__, _ota_url.c_str());
412432

413433
/* Status flag to prevent the reset from being executed
414434
* when HTTPS download is not supported.
@@ -424,7 +444,7 @@ void ArduinoIoTCloudTCP::onOTARequest()
424444
uint8_t nina_ota_err_code = 0;
425445
if (!WiFiStorage.downloadOTA(_ota_url.c_str(), &nina_ota_err_code))
426446
{
427-
DBG_ERROR(F("ArduinoIoTCloudTCP::%s error download to nina: %d"), __FUNCTION__, nina_ota_err_code);
447+
DEBUG_ERROR(F("ArduinoIoTCloudTCP::%s error download to nina: %d"), __FUNCTION__, nina_ota_err_code);
428448
_ota_error = static_cast<int>(OTAError::DownloadFailed);
429449
return;
430450
}

0 commit comments

Comments
 (0)