Skip to content

Commit c805f77

Browse files
authored
AVR: Fix OTA logging (#1074)
1 parent fe42dbd commit c805f77

File tree

3 files changed

+5
-13
lines changed

3 files changed

+5
-13
lines changed

core/MyOTALogging.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@ void OTALog(uint8_t logNode, bool enableAck, const char *fmt, ... )
3636

3737
// create message
3838
va_start (args, fmt );
39-
#ifdef vsnprintf_P
4039
int n = vsnprintf_P(fmtBuffer, sizeof(fmtBuffer), fmt, args);
41-
#else
42-
int n = vsnprintf(fmtBuffer, sizeof(fmtBuffer), fmt, args);
43-
#endif
4440
va_end (args);
4541

4642
// Check number of chars
@@ -92,14 +88,9 @@ void OTALogPrintPrefix()
9288
{
9389
char prefix[37];
9490
// prepend debug message to be handled correctly by controller (C_INTERNAL, I_LOG_MESSAGE)
95-
#ifdef snprintf_P
9691
snprintf_P(prefix, sizeof(prefix),
9792
PSTR("%" PRId8 ";%" PRId8 ";%" PRId8 ";0;%" PRId8 ";%" PRIu32 " "),
9893
OTALogBufferNode, OTALogBufferSensor, C_INTERNAL, I_LOG_MESSAGE, hwMillis());
99-
#else
100-
snprintf(prefix, sizeof(prefix), PSTR("%" PRId8 ";%" PRId8 ";%" PRId8 ";0;%" PRId8 ";%" PRIu32 " "),
101-
OTALogBufferNode, OTALogBufferSensor, C_INTERNAL, I_LOG_MESSAGE, hwMillis());
102-
#endif
10394
MY_SERIALDEVICE.print(prefix);
10495
}
10596

examples/LogOTANode/LogOTANode.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* network topology allowing messages to be routed to nodes.
77
*
88
* Created by Henrik Ekblad <[email protected]>
9-
* Copyright (C) 2013-2015 Sensnology AB
9+
* Copyright (C) 2013-2018 Sensnology AB
1010
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
1111
*
1212
* Documentation: http://www.mysensors.org
@@ -67,8 +67,8 @@ void loop()
6767
c++;
6868

6969
// A debug message
70-
DEBUG_OUTPUT(PSTR("DEBUG\nc=%" PRId16 "\nmillis=" PRId32 "\n"), c, hwMillis());
70+
DEBUG_OUTPUT(PSTR("DEBUG\nc=%" PRId16 "\nmillis=%" PRId32 "\n"), c, hwMillis());
7171

7272
// Send a log message with ACK to a node
73-
OTALog(0, true, PSTR("LOG\nc=%" PRId16 "\nmillis=" PRId32 "\n"), c, hwMillis());
74-
}
73+
OTALog(0, true, PSTR("LOG\nc=%" PRId16 "\nmillis=%" PRId32 "\n"), c, hwMillis());
74+
}

hal/architecture/SAMD/MyHwSAMD.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ extEEPROM eep(MY_EXT_EEPROM_SIZE, 1, MY_EXT_EEPROM_PAGE_SIZE,
4040
#define MIN(a,b) min(a,b)
4141
#define MAX(a,b) max(a,b)
4242
#define snprintf_P(s, f, ...) snprintf((s), (f), __VA_ARGS__)
43+
#define vsnprintf_P(s, n, f, ...) vsnprintf((s), (n), (f), __VA_ARGS__)
4344

4445
// Define these as macros to save valuable space
4546
#define hwDigitalWrite(__pin, __value) digitalWrite(__pin, __value)

0 commit comments

Comments
 (0)