Skip to content

Commit 81c9a8b

Browse files
authored
Merge pull request #164 from arduino-libraries/debug-macros
Debug macros replace direct calls to Arduino_DebugUtils
2 parents a93b4e2 + 5a57fa0 commit 81c9a8b

File tree

307 files changed

+356
-334
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

307 files changed

+356
-334
lines changed

src/ArduinoIoTCloud_Config.h renamed to src/AIoTC_Config.h

+28-8
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,41 @@
1515
a commercial license, send an email to [email protected].
1616
*/
1717

18-
#ifndef ARDUINO_IOT_CLOUD_CONFIG_H_
19-
#define ARDUINO_IOT_CLOUD_CONFIG_H_
18+
#ifndef ARDUINO_AIOTC_CONFIG_H_
19+
#define ARDUINO_AIOTC_CONFIG_H_
2020

2121
/******************************************************************************
22-
* USER CONFIGURED DEFINES
22+
* USER CONFIGURABLE DEFINES
2323
******************************************************************************/
2424

2525
#ifndef OTA_STORAGE_SFU
2626
#define OTA_STORAGE_SFU (0)
2727
#endif
2828

29+
#ifndef DBG_ERROR
30+
#define DBG_ERROR(fmt, ...) Debug.print(DBG_ERROR, fmt, ## __VA_ARGS__)
31+
#endif
32+
33+
#ifndef DBG_WARNING
34+
#define DBG_WARNING(fmt, ...) Debug.print(DBG_WARNING, fmt, ## __VA_ARGS__)
35+
#endif
36+
37+
#ifndef DBG_INFO
38+
#define DBG_INFO(fmt, ...) Debug.print(DBG_INFO, fmt, ## __VA_ARGS__)
39+
#endif
40+
41+
#ifndef DBG_DEBUG
42+
#define DBG_DEBUG(fmt, ...) Debug.print(DBG_DEBUG, fmt, ## __VA_ARGS__)
43+
#endif
44+
45+
#ifndef DBG_VERBOSE
46+
#define DBG_VERBOSE(fmt, ...) Debug.print(DBG_VERBOSE, fmt, ## __VA_ARGS__)
47+
#endif
48+
49+
/******************************************************************************
50+
* AUTOMATICALLY CONFIGURED DEFINES
51+
******************************************************************************/
52+
2953
#if defined(ARDUINO_SAMD_MKRWIFI1010) || defined(ARDUINO_SAMD_NANO_33_IOT)
3054
#define OTA_STORAGE_SNU (1)
3155
#else
@@ -38,10 +62,6 @@
3862
#define OTA_STORAGE_SSU (0)
3963
#endif
4064

41-
/******************************************************************************
42-
* AUTOMATIC CONFIGURED DEFINES
43-
******************************************************************************/
44-
4565
#if OTA_STORAGE_SFU || OTA_STORAGE_SSU || OTA_STORAGE_SNU
4666
#define OTA_ENABLED (1)
4767
#else
@@ -64,4 +84,4 @@
6484
#define HAS_TCP
6585
#endif
6686

67-
#endif /* ARDUINO_IOT_CLOUD_CONFIG_H_ */
87+
#endif /* ARDUINO_AIOTC_CONFIG_H_ */

src/ArduinoIoTCloud.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,11 @@ void ArduinoIoTCloudClass::printConnectionStatus(ArduinoIoTConnectionStatus stat
199199
{
200200
switch (status)
201201
{
202-
case ArduinoIoTConnectionStatus::IDLE: Debug.print(DBG_INFO, "Arduino IoT Cloud Connection status: IDLE"); break;
203-
case ArduinoIoTConnectionStatus::ERROR: Debug.print(DBG_ERROR, "Arduino IoT Cloud Connection status: ERROR"); break;
204-
case ArduinoIoTConnectionStatus::CONNECTING: Debug.print(DBG_INFO, "Arduino IoT Cloud Connection status: CONNECTING"); break;
205-
case ArduinoIoTConnectionStatus::RECONNECTING: Debug.print(DBG_INFO, "Arduino IoT Cloud Connection status: RECONNECTING"); break;
206-
case ArduinoIoTConnectionStatus::CONNECTED: Debug.print(DBG_INFO, "Arduino IoT Cloud Connection status: CONNECTED"); break;
207-
case ArduinoIoTConnectionStatus::DISCONNECTED: Debug.print(DBG_ERROR, "Arduino IoT Cloud Connection status: DISCONNECTED"); break;
202+
case ArduinoIoTConnectionStatus::IDLE: DBG_INFO ("Arduino IoT Cloud Connection status: IDLE"); break;
203+
case ArduinoIoTConnectionStatus::ERROR: DBG_ERROR("Arduino IoT Cloud Connection status: ERROR"); break;
204+
case ArduinoIoTConnectionStatus::CONNECTING: DBG_INFO ("Arduino IoT Cloud Connection status: CONNECTING"); break;
205+
case ArduinoIoTConnectionStatus::RECONNECTING: DBG_INFO ("Arduino IoT Cloud Connection status: RECONNECTING"); break;
206+
case ArduinoIoTConnectionStatus::CONNECTED: DBG_INFO ("Arduino IoT Cloud Connection status: CONNECTED"); break;
207+
case ArduinoIoTConnectionStatus::DISCONNECTED: DBG_ERROR("Arduino IoT Cloud Connection status: DISCONNECTED"); break;
208208
}
209209
}

src/ArduinoIoTCloud.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* INCLUDE
2323
******************************************************************************/
2424

25-
#include <ArduinoIoTCloud_Config.h>
25+
#include <AIoTC_Config.h>
2626

2727
#include <Arduino_ConnectionHandler.h>
2828
#include <Arduino_DebugUtils.h>

src/ArduinoIoTCloudLPWAN.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* INCLUDE
2020
******************************************************************************/
2121

22-
#include <ArduinoIoTCloud_Config.h>
22+
#include <AIoTC_Config.h>
2323

2424
#ifdef HAS_LORA
2525

@@ -101,8 +101,8 @@ void ArduinoIoTCloudLPWAN::update()
101101

102102
void ArduinoIoTCloudLPWAN::printDebugInfo()
103103
{
104-
Debug.print(DBG_INFO, "***** Arduino IoT Cloud LPWAN - configuration info *****");
105-
Debug.print(DBG_INFO, "Thing ID: %s", getThingId().c_str());
104+
DBG_INFO("***** Arduino IoT Cloud LPWAN - configuration info *****");
105+
DBG_INFO("Thing ID: %s", getThingId().c_str());
106106
}
107107

108108
/******************************************************************************

src/ArduinoIoTCloudTCP.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* INCLUDE
2020
******************************************************************************/
2121

22-
#include <ArduinoIoTCloud_Config.h>
22+
#include <AIoTC_Config.h>
2323

2424
#ifdef HAS_TCP
2525
#include <ArduinoIoTCloudTCP.h>
@@ -119,9 +119,9 @@ int ArduinoIoTCloudTCP::begin(String brokerAddress, uint16_t brokerPort)
119119
_brokerPort = brokerPort;
120120

121121
#ifdef BOARD_HAS_ECCX08
122-
if (!ECCX08.begin()) { Debug.print(DBG_ERROR, "Cryptography processor failure. Make sure you have a compatible board."); return 0; }
123-
if (!CryptoUtil::readDeviceId(ECCX08, getDeviceId(), ECCX08Slot::DeviceId)) { Debug.print(DBG_ERROR, "Cryptography processor read failure."); return 0; }
124-
if (!CryptoUtil::reconstructCertificate(_eccx08_cert, getDeviceId(), ECCX08Slot::Key, ECCX08Slot::CompressedCertificate, ECCX08Slot::SerialNumberAndAuthorityKeyIdentifier)) { Debug.print(DBG_ERROR, "Cryptography certificate reconstruction failure."); return 0; }
122+
if (!ECCX08.begin()) { DBG_ERROR("Cryptography processor failure. Make sure you have a compatible board."); return 0; }
123+
if (!CryptoUtil::readDeviceId(ECCX08, getDeviceId(), ECCX08Slot::DeviceId)) { DBG_ERROR("Cryptography processor read failure."); return 0; }
124+
if (!CryptoUtil::reconstructCertificate(_eccx08_cert, getDeviceId(), ECCX08Slot::Key, ECCX08Slot::CompressedCertificate, ECCX08Slot::SerialNumberAndAuthorityKeyIdentifier)) { DBG_ERROR("Cryptography certificate reconstruction failure."); return 0; }
125125
_sslClient.setClient(_connection->getClient());
126126
_sslClient.setEccSlot(static_cast<int>(ECCX08Slot::Key), _eccx08_cert.bytes(), _eccx08_cert.length());
127127
#elif defined(BOARD_ESP)
@@ -219,10 +219,10 @@ int ArduinoIoTCloudTCP::connected()
219219

220220
void ArduinoIoTCloudTCP::printDebugInfo()
221221
{
222-
Debug.print(DBG_INFO, "***** Arduino IoT Cloud - configuration info *****");
223-
Debug.print(DBG_INFO, "Device ID: %s", getDeviceId().c_str());
224-
Debug.print(DBG_INFO, "Thing ID: %s", getThingId().c_str());
225-
Debug.print(DBG_INFO, "MQTT Broker: %s:%d", _brokerAddress.c_str(), _brokerPort);
222+
DBG_INFO("***** Arduino IoT Cloud - configuration info *****");
223+
DBG_INFO("Device ID: %s", getDeviceId().c_str());
224+
DBG_INFO("Thing ID: %s", getThingId().c_str());
225+
DBG_INFO("MQTT Broker: %s:%d", _brokerAddress.c_str(), _brokerPort);
226226
}
227227

228228
#if OTA_ENABLED
@@ -342,7 +342,7 @@ ArduinoIoTConnectionStatus ArduinoIoTCloudTCP::checkCloudConnection()
342342
case ArduinoIoTConnectionStatus::DISCONNECTED: next_iot_status = ArduinoIoTConnectionStatus::RECONNECTING; break;
343343
case ArduinoIoTConnectionStatus::CONNECTING:
344344
{
345-
Debug.print(DBG_INFO, "Arduino IoT Cloud connecting ...");
345+
DBG_INFO("Arduino IoT Cloud connecting ...");
346346
int const ret = connect();
347347
if (ret == CONNECT_SUCCESS)
348348
{
@@ -352,14 +352,14 @@ ArduinoIoTConnectionStatus ArduinoIoTCloudTCP::checkCloudConnection()
352352
}
353353
else if (ret == CONNECT_FAILURE_SUBSCRIBE)
354354
{
355-
Debug.print(DBG_ERROR, "ERROR - Please verify your THING ID");
355+
DBG_ERROR("ERROR - Please verify your THING ID");
356356
}
357357
}
358358
break;
359359

360360
case ArduinoIoTConnectionStatus::RECONNECTING:
361361
{
362-
Debug.print(DBG_INFO, "Arduino IoT Cloud reconnecting ...");
362+
DBG_INFO("Arduino IoT Cloud reconnecting ...");
363363
if (reconnect() == CONNECT_SUCCESS)
364364
{
365365
next_iot_status = ArduinoIoTConnectionStatus::CONNECTED;

src/ArduinoIoTCloudTCP.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* INCLUDE
2323
******************************************************************************/
2424

25-
#include <ArduinoIoTCloud_Config.h>
25+
#include <AIoTC_Config.h>
2626

2727
#include <ArduinoIoTCloud.h>
2828

src/CloudSerial.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* INCLUDE
2020
******************************************************************************/
2121

22-
#include <ArduinoIoTCloud_Config.h>
22+
#include <AIoTC_Config.h>
2323

2424
#ifndef HAS_LORA
2525

src/tls/BearSSLClient.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* SOFTWARE.
2323
*/
2424

25-
#include <ArduinoIoTCloud_Config.h>
25+
#include <AIoTC_Config.h>
2626
#ifdef BOARD_HAS_ECCX08
2727

2828
#include <ArduinoECCX08.h>

src/tls/BearSSLClient.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#ifndef _BEAR_SSL_CLIENT_H_
2626
#define _BEAR_SSL_CLIENT_H_
2727

28-
#include <ArduinoIoTCloud_Config.h>
28+
#include <AIoTC_Config.h>
2929
#ifdef BOARD_HAS_ECCX08
3030

3131
#ifndef BEAR_SSL_CLIENT_OBUF_SIZE

src/tls/BearSSLTrustAnchors.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* INCLUDE
2424
******************************************************************************/
2525

26-
#include <ArduinoIoTCloud_Config.h>
26+
#include <AIoTC_Config.h>
2727
#ifdef BOARD_HAS_ECCX08
2828

2929
#include "bearssl/bearssl_ssl.h"

src/tls/bearssl/aes_big_cbcdec.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* SOFTWARE.
2323
*/
2424

25-
#include <ArduinoIoTCloud_Config.h>
25+
#include <AIoTC_Config.h>
2626
#ifdef BOARD_HAS_ECCX08
2727

2828
#include "inner.h"

src/tls/bearssl/aes_big_cbcenc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* SOFTWARE.
2323
*/
2424

25-
#include <ArduinoIoTCloud_Config.h>
25+
#include <AIoTC_Config.h>
2626
#ifdef BOARD_HAS_ECCX08
2727

2828
#include "inner.h"

src/tls/bearssl/aes_big_ctr.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* SOFTWARE.
2323
*/
2424

25-
#include <ArduinoIoTCloud_Config.h>
25+
#include <AIoTC_Config.h>
2626
#ifdef BOARD_HAS_ECCX08
2727

2828
#include "inner.h"

src/tls/bearssl/aes_big_ctrcbc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* SOFTWARE.
2323
*/
2424

25-
#include <ArduinoIoTCloud_Config.h>
25+
#include <AIoTC_Config.h>
2626
#ifdef BOARD_HAS_ECCX08
2727

2828
#include "inner.h"

src/tls/bearssl/aes_big_dec.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* SOFTWARE.
2323
*/
2424

25-
#include <ArduinoIoTCloud_Config.h>
25+
#include <AIoTC_Config.h>
2626
#ifdef BOARD_HAS_ECCX08
2727

2828
#include "inner.h"

src/tls/bearssl/aes_big_enc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* SOFTWARE.
2323
*/
2424

25-
#include <ArduinoIoTCloud_Config.h>
25+
#include <AIoTC_Config.h>
2626
#ifdef BOARD_HAS_ECCX08
2727

2828
#include "inner.h"

src/tls/bearssl/aes_common.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* SOFTWARE.
2323
*/
2424

25-
#include <ArduinoIoTCloud_Config.h>
25+
#include <AIoTC_Config.h>
2626
#ifdef BOARD_HAS_ECCX08
2727

2828
#include "inner.h"

src/tls/bearssl/aes_ct.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* SOFTWARE.
2323
*/
2424

25-
#include <ArduinoIoTCloud_Config.h>
25+
#include <AIoTC_Config.h>
2626
#ifdef BOARD_HAS_ECCX08
2727

2828
#include "inner.h"

src/tls/bearssl/aes_ct64.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* SOFTWARE.
2323
*/
2424

25-
#include <ArduinoIoTCloud_Config.h>
25+
#include <AIoTC_Config.h>
2626
#ifdef BOARD_HAS_ECCX08
2727

2828
#include "inner.h"

src/tls/bearssl/aes_ct64_cbcdec.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* SOFTWARE.
2323
*/
2424

25-
#include <ArduinoIoTCloud_Config.h>
25+
#include <AIoTC_Config.h>
2626
#ifdef BOARD_HAS_ECCX08
2727

2828
#include "inner.h"

src/tls/bearssl/aes_ct64_cbcenc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* SOFTWARE.
2323
*/
2424

25-
#include <ArduinoIoTCloud_Config.h>
25+
#include <AIoTC_Config.h>
2626
#ifdef BOARD_HAS_ECCX08
2727

2828
#include "inner.h"

src/tls/bearssl/aes_ct64_ctr.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* SOFTWARE.
2323
*/
2424

25-
#include <ArduinoIoTCloud_Config.h>
25+
#include <AIoTC_Config.h>
2626
#ifdef BOARD_HAS_ECCX08
2727

2828
#include "inner.h"

src/tls/bearssl/aes_ct64_ctrcbc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* SOFTWARE.
2323
*/
2424

25-
#include <ArduinoIoTCloud_Config.h>
25+
#include <AIoTC_Config.h>
2626
#ifdef BOARD_HAS_ECCX08
2727

2828
#include "inner.h"

src/tls/bearssl/aes_ct64_dec.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* SOFTWARE.
2323
*/
2424

25-
#include <ArduinoIoTCloud_Config.h>
25+
#include <AIoTC_Config.h>
2626
#ifdef BOARD_HAS_ECCX08
2727

2828
#include "inner.h"

src/tls/bearssl/aes_ct64_enc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* SOFTWARE.
2323
*/
2424

25-
#include <ArduinoIoTCloud_Config.h>
25+
#include <AIoTC_Config.h>
2626
#ifdef BOARD_HAS_ECCX08
2727

2828
#include "inner.h"

src/tls/bearssl/aes_ct_cbcdec.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* SOFTWARE.
2323
*/
2424

25-
#include <ArduinoIoTCloud_Config.h>
25+
#include <AIoTC_Config.h>
2626
#ifdef BOARD_HAS_ECCX08
2727

2828
#include "inner.h"

src/tls/bearssl/aes_ct_cbcenc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* SOFTWARE.
2323
*/
2424

25-
#include <ArduinoIoTCloud_Config.h>
25+
#include <AIoTC_Config.h>
2626
#ifdef BOARD_HAS_ECCX08
2727

2828
#include "inner.h"

src/tls/bearssl/aes_ct_ctr.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* SOFTWARE.
2323
*/
2424

25-
#include <ArduinoIoTCloud_Config.h>
25+
#include <AIoTC_Config.h>
2626
#ifdef BOARD_HAS_ECCX08
2727

2828
#include "inner.h"

src/tls/bearssl/aes_ct_ctrcbc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* SOFTWARE.
2323
*/
2424

25-
#include <ArduinoIoTCloud_Config.h>
25+
#include <AIoTC_Config.h>
2626
#ifdef BOARD_HAS_ECCX08
2727

2828
#include "inner.h"

src/tls/bearssl/aes_ct_dec.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* SOFTWARE.
2323
*/
2424

25-
#include <ArduinoIoTCloud_Config.h>
25+
#include <AIoTC_Config.h>
2626
#ifdef BOARD_HAS_ECCX08
2727

2828
#include "inner.h"

0 commit comments

Comments
 (0)