Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/user_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,13 @@
#elif defined(WOLFSSL_SERVER_EXAMPLE)
#define NO_WOLFSSL_CLIENT
#elif defined(WOLFSSL_TEMPLATE_EXAMPLE)
#define NO_TLS
#define WOLFCRYPT_ONLY
#define NO_WOLFSSL_SERVER
#define NO_WOLFSSL_CLIENT
#elif defined(WOLFSSL_AES_CTR_EXAMPLE)
#define NO_TLS
#define WOLFCRYPT_ONLY
#define NO_WOLFSSL_SERVER
#define NO_WOLFSSL_CLIENT
#define WOLFSSL_AES
Expand Down
26 changes: 25 additions & 1 deletion src/wolfssl-arduino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,33 @@
/* Function to allow wolfcrypt to use Arduino Serial.print for debug messages.
* See wolfssl/wolfcrypt/logging.c */

#if defined(__AVR__)
#include <avr/pgmspace.h> /* Required for PROGMEM handling on AVR */
#endif

int wolfSSL_Arduino_Serial_Print(const char* const s)
{
/* Reminder: Serial.print is only available in C++ */
Serial.println(F(s));
int is_progmem = 0;

#if defined(__AVR__)
const char* t;
t = s;

/* Safely check if `s` is in PROGMEM, 0x8000 is typical for AVR flash */
if (reinterpret_cast<uint16_t>(t) >= 0x8000) {
while (pgm_read_byte(t)) {
Serial.write(pgm_read_byte(t++));
}
Serial.println();
is_progmem = 1;
}
#endif

/* Print normally for non-AVR boards or RAM-stored strings */
if (!is_progmem) {
Serial.println(s);
}

return 0;
};
1 change: 1 addition & 0 deletions src/wolfssl/wolfcrypt/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@

/* board-specific */
#if defined(__AVR__)
#define WOLFSSL_USER_IO
#define WOLFSSL_NO_SOCK
#define NO_WRITEV
#elif defined(__arm__)
Expand Down