Skip to content

Commit d4b4f24

Browse files
committed
WIP: uniform and reduce length of debug prints
1 parent eddc451 commit d4b4f24

5 files changed

+58
-58
lines changed

src/ArduinoIoTCloudDevice.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void ArduinoCloudDevice::handleMessage(Message *m) {
6565
case DeviceAttachedCmdId:
6666
_attached = true;
6767
_registered = true;
68-
DEBUG_VERBOSE("CloudDevice::%s Device is attached", __FUNCTION__);
68+
DEBUG_VERBOSE("Device::%s Device is attached", __FUNCTION__);
6969
nextState = State::Connected;
7070
break;
7171

@@ -115,7 +115,7 @@ ArduinoCloudDevice::State ArduinoCloudDevice::handleSendCapabilities() {
115115

116116
/* No device configuration received. Wait: 4s -> 8s -> 16s -> 32s -> 32s ...*/
117117
_attachAttempt.retry();
118-
DEBUG_VERBOSE("CloudDevice::%s not attached. %d next configuration request in %d ms",
118+
DEBUG_VERBOSE("Device::%s not attached. %d next configuration request in %d ms",
119119
__FUNCTION__, _attachAttempt.getRetryCount(), _attachAttempt.getWaitTime());
120120
return State::Connected;
121121
}

src/ArduinoIoTCloudLPWAN.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ ArduinoIoTCloudLPWAN::State ArduinoIoTCloudLPWAN::handle_ConnectPhy()
107107

108108
ArduinoIoTCloudLPWAN::State ArduinoIoTCloudLPWAN::handle_SyncTime()
109109
{
110-
DEBUG_VERBOSE("ArduinoIoTCloudLPWAN::%s internal clock configured to posix timestamp %lu", __FUNCTION__, _time_service.getTime());
110+
DEBUG_VERBOSE("LPWAN::%s internal clock configured to posix timestamp %lu", __FUNCTION__, _time_service.getTime());
111111
DEBUG_INFO("Connected to Arduino IoT Cloud");
112112
return State::Connected;
113113
}
@@ -116,7 +116,7 @@ ArduinoIoTCloudLPWAN::State ArduinoIoTCloudLPWAN::handle_Connected()
116116
{
117117
if (!connected())
118118
{
119-
DEBUG_ERROR("ArduinoIoTCloudLPWAN::%s connection to gateway lost", __FUNCTION__);
119+
DEBUG_ERROR("LPWAN::%s connection to gateway lost", __FUNCTION__);
120120
return State::ConnectPhy;
121121
}
122122

src/ArduinoIoTCloudNotecard.cpp

+21-21
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ int ArduinoIoTCloudNotecard::begin(ConnectionHandler &connection_, int interrupt
8989

9090
// Initialize the connection to the Notecard
9191
if (NetworkConnectionState::ERROR == _connection->check()) {
92-
DEBUG_ERROR("ArduinoIoTCloudNotecard::%s encountered fatal connection error!", __FUNCTION__);
92+
DEBUG_ERROR("Notecard::%s encountered fatal connection error!", __FUNCTION__);
9393
return 0; // (false -> failure)
9494
}
9595

@@ -163,11 +163,11 @@ ArduinoIoTCloudNotecard::State ArduinoIoTCloudNotecard::handle_SyncTime()
163163
const uint32_t current_time = ArduinoCloud.getInternalTime();
164164
if (TimeServiceClass::isTimeValid(current_time))
165165
{
166-
DEBUG_VERBOSE("ArduinoIoTCloudNotecard::%s [%d] internal clock configured to posix timestamp %d", __FUNCTION__, millis(), current_time);
166+
DEBUG_VERBOSE("Notecard::%s [%d] internal clock configured to posix timestamp %d", __FUNCTION__, millis(), current_time);
167167
return State::Connected;
168168
}
169169

170-
DEBUG_ERROR("ArduinoIoTCloudNotecard::%s could not get valid time. Retrying now.", __FUNCTION__);
170+
DEBUG_ERROR("Notecard::%s could not get valid time. Retrying now.", __FUNCTION__);
171171
return State::ConnectPhy;
172172
}
173173

@@ -206,7 +206,7 @@ ArduinoIoTCloudNotecard::State ArduinoIoTCloudNotecard::handle_Connected()
206206
ArduinoIoTCloudNotecard::State ArduinoIoTCloudNotecard::handle_Disconnect()
207207
{
208208
if (!connected()) {
209-
DEBUG_ERROR("ArduinoIoTCloudNotecard::%s connection to Notehub lost", __FUNCTION__);
209+
DEBUG_ERROR("Notecard::%s connection to Notehub lost", __FUNCTION__);
210210
}
211211

212212
// Reset the Thing and Device property containers
@@ -285,9 +285,9 @@ void ArduinoIoTCloudNotecard::fetchIncomingBytes(uint8_t *buf, size_t &len)
285285
buf[bytes_received] = _connection->read();
286286
}
287287
if (bytes_received == len && _connection->available()) {
288-
DEBUG_ERROR("ArduinoIoTCloudNotecard::%s buffer overflow on inbound message", __FUNCTION__);
288+
DEBUG_ERROR("Notecard::%s buffer overflow on inbound message", __FUNCTION__);
289289
} else {
290-
DEBUG_DEBUG("ArduinoIoTCloudNotecard::%s received %d bytes from cloud", __FUNCTION__, bytes_received);
290+
DEBUG_DEBUG("Notecard::%s received %d bytes from cloud", __FUNCTION__, bytes_received);
291291
len = bytes_received;
292292
}
293293
}
@@ -306,20 +306,20 @@ void ArduinoIoTCloudNotecard::pollNotecard(void)
306306
void ArduinoIoTCloudNotecard::processCommand(const uint8_t *buf, size_t len)
307307
{
308308
CommandDown command;
309-
DEBUG_VERBOSE("ArduinoIoTCloudNotecard::%s [%d] received %d bytes", __FUNCTION__, millis(), len);
309+
DEBUG_VERBOSE("Notecard::%s [%d] received %d bytes", __FUNCTION__, millis(), len);
310310
CBORMessageDecoder decoder;
311311

312312
if (decoder.decode((Message*)&command, buf, len) != Decoder::Status::Error) {
313-
DEBUG_VERBOSE("ArduinoIoTCloudNotecard::%s [%d] received command id %d", __FUNCTION__, millis(), command.c.id);
313+
DEBUG_VERBOSE("Notecard::%s [%d] received command id %d", __FUNCTION__, millis(), command.c.id);
314314
switch (command.c.id)
315315
{
316316
case CommandId::ThingUpdateCmdId:
317317
{
318-
DEBUG_VERBOSE("ArduinoIoTCloudNotecard::%s [%d] device configuration received", __FUNCTION__, millis());
318+
DEBUG_VERBOSE("Notecard::%s [%d] device configuration received", __FUNCTION__, millis());
319319
String new_thing_id = String(command.thingUpdateCmd.params.thing_id);
320320

321321
if (!new_thing_id.length()) {
322-
DEBUG_DEBUG("ArduinoIoTCloudNotecard::%s received null Thing ID.", __FUNCTION__);
322+
DEBUG_DEBUG("Notecard::%s received null Thing ID.", __FUNCTION__);
323323
_thing_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
324324

325325
// Send message to device state machine to inform we have received a null thing-id
@@ -328,11 +328,11 @@ void ArduinoIoTCloudNotecard::processCommand(const uint8_t *buf, size_t len)
328328
_device.handleMessage(&message);
329329
} else {
330330
if (_device.isAttached() && _thing_id != new_thing_id) {
331-
DEBUG_DEBUG("ArduinoIoTCloudNotecard::%s detaching Thing ID: %s", __FUNCTION__, _thing_id.c_str());
331+
DEBUG_DEBUG("Notecard::%s detaching Thing ID: %s", __FUNCTION__, _thing_id.c_str());
332332
detachThing();
333333
}
334334
if (!_device.isAttached()) {
335-
DEBUG_DEBUG("ArduinoIoTCloudNotecard::%s attaching Thing ID: %s", __FUNCTION__, new_thing_id.c_str());
335+
DEBUG_DEBUG("Notecard::%s attaching Thing ID: %s", __FUNCTION__, new_thing_id.c_str());
336336
attachThing(new_thing_id);
337337
}
338338
}
@@ -342,24 +342,24 @@ void ArduinoIoTCloudNotecard::processCommand(const uint8_t *buf, size_t len)
342342
case CommandId::ThingDetachCmdId:
343343
{
344344
if (!_device.isAttached() || _thing_id != String(command.thingDetachCmd.params.thing_id)) {
345-
DEBUG_VERBOSE("ArduinoIoTCloudNotecard::%s [%d] thing detach rejected", __FUNCTION__, millis());
345+
DEBUG_VERBOSE("Notecard::%s [%d] thing detach rejected", __FUNCTION__, millis());
346346
}
347347

348-
DEBUG_VERBOSE("ArduinoIoTCloudNotecard::%s [%d] thing detach received", __FUNCTION__, millis());
348+
DEBUG_VERBOSE("Notecard::%s [%d] thing detach received", __FUNCTION__, millis());
349349
detachThing();
350350
}
351351
break;
352352

353353
case CommandId::TimezoneCommandDownId:
354354
{
355-
DEBUG_VERBOSE("ArduinoIoTCloudNotecard::%s [%d] timezone update received", __FUNCTION__, millis());
355+
DEBUG_VERBOSE("Notecard::%s [%d] timezone update received", __FUNCTION__, millis());
356356
_thing.handleMessage((Message*)&command);
357357
}
358358
break;
359359

360360
case CommandId::LastValuesUpdateCmdId:
361361
{
362-
DEBUG_VERBOSE("ArduinoIoTCloudNotecard::%s [%d] last values received", __FUNCTION__, millis());
362+
DEBUG_VERBOSE("Notecard::%s [%d] last values received", __FUNCTION__, millis());
363363
CBORDecoder::decode(_thing.getPropertyContainer(),
364364
(uint8_t*)command.lastValuesUpdateCmd.params.last_values,
365365
command.lastValuesUpdateCmd.params.length, true);
@@ -379,7 +379,7 @@ void ArduinoIoTCloudNotecard::processCommand(const uint8_t *buf, size_t len)
379379
#if OTA_ENABLED
380380
case CommandId::OtaUpdateCmdDownId:
381381
{
382-
DEBUG_VERBOSE("ArduinoIoTCloudNotecard::%s [%d] ota update received", __FUNCTION__, millis());
382+
DEBUG_VERBOSE("Notecard::%s [%d] ota update received", __FUNCTION__, millis());
383383
_ota.handleMessage((Message*)&command);
384384
}
385385
#endif
@@ -392,7 +392,7 @@ void ArduinoIoTCloudNotecard::processCommand(const uint8_t *buf, size_t len)
392392

393393
void ArduinoIoTCloudNotecard::processMessage(const uint8_t *buf, size_t len)
394394
{
395-
DEBUG_VERBOSE("ArduinoIoTCloudNotecard::%s [%d] decoding %d bytes from cloud...", __FUNCTION__, millis(), len);
395+
DEBUG_VERBOSE("Notecard::%s [%d] decoding %d bytes from cloud...", __FUNCTION__, millis(), len);
396396
NotecardConnectionHandler *notecard_connection = reinterpret_cast<NotecardConnectionHandler *>(_connection);
397397
switch (notecard_connection->getTopicType()) {
398398
// Commands
@@ -433,15 +433,15 @@ void ArduinoIoTCloudNotecard::sendCommandMsgToCloud(Message * msg_)
433433
if (CBOR_LORA_PAYLOAD_MAX_SIZE < bytes_encoded) {
434434
DEBUG_WARNING("Encoded %d bytes for Command Message. Exceeds maximum payload size of %d bytes, and cannot be sent to cloud.", bytes_encoded, CBOR_LORA_PAYLOAD_MAX_SIZE);
435435
} else if (bytes_encoded > 0) {
436-
DEBUG_DEBUG("ArduinoIoTCloudNotecard::%s encoded %d bytes for Command Message", __FUNCTION__, bytes_encoded);
436+
DEBUG_DEBUG("Notecard::%s encoded %d bytes for Command Message", __FUNCTION__, bytes_encoded);
437437
notecard_connection->setTopicType(NotecardConnectionHandler::TopicType::Command);
438438
if (notecard_connection->write(data, bytes_encoded)) {
439439
DEBUG_ERROR("Failed to send Command Message to cloud");
440440
} else {
441441
notecard_connection->initiateNotehubSync(NotecardConnectionHandler::SyncType::Inbound);
442442
}
443443
} else {
444-
DEBUG_DEBUG("ArduinoIoTCloudNotecard::%s encoded zero (0) bytes for Command Message", __FUNCTION__);
444+
DEBUG_DEBUG("Notecard::%s encoded zero (0) bytes for Command Message", __FUNCTION__);
445445
}
446446
} else {
447447
DEBUG_ERROR("Failed to encode Command Message");
@@ -461,7 +461,7 @@ void ArduinoIoTCloudNotecard::sendThingPropertyContainerToCloud()
461461
} else if (bytes_encoded < 0) {
462462
DEBUG_ERROR("Encoding Thing properties resulted in error: %d.", bytes_encoded);
463463
} else if (bytes_encoded > 0) {
464-
DEBUG_DEBUG("ArduinoIoTCloudNotecard::%s encoded %d bytes of Thing properties", __FUNCTION__, bytes_encoded);
464+
DEBUG_DEBUG("Notecard::%s encoded %d bytes of Thing properties", __FUNCTION__, bytes_encoded);
465465
notecard_connection->setTopicType(NotecardConnectionHandler::TopicType::Thing);
466466
if (notecard_connection->write(data, bytes_encoded)) {
467467
DEBUG_ERROR("Failed to sync Thing properties with cloud");

0 commit comments

Comments
 (0)