File tree 2 files changed +27
-3
lines changed
2 files changed +27
-3
lines changed Original file line number Diff line number Diff line change 22
22
#include < Arduino.h>
23
23
#include " wolfssl.h"
24
24
25
- /* Function to allow wolfcrypt to use Arduino Serial.print for debug messages.
26
- * See wolfssl/wolfcrypt/logging.c */
25
+ /* Function to allow wolfcrypt to use Arduino Serial.print for debug messages.
26
+ * See wolfssl/wolfcrypt/logging.c */
27
+
28
+ #if defined(__AVR__)
29
+ #include < avr/pgmspace.h> /* Required for PROGMEM handling on AVR */
30
+ #endif
27
31
28
32
int wolfSSL_Arduino_Serial_Print (const char * const s)
29
33
{
30
34
/* Reminder: Serial.print is only available in C++ */
31
- Serial.println (F (s));
35
+ int is_progmem = 0 ;
36
+ const char * t;
37
+ t = s;
38
+
39
+ #if defined(__AVR__)
40
+ /* Safely check if `s` is in PROGMEM, 0x8000 is typical for AVR flash */
41
+ if (reinterpret_cast <uint16_t >(t) >= 0x8000 ) {
42
+ while (pgm_read_byte (t)) {
43
+ Serial.write (pgm_read_byte (t++));
44
+ }
45
+ Serial.println ();
46
+ is_progmem = 1 ;
47
+ }
48
+ #endif
49
+
50
+ /* Print normally for non-AVR boards or RAM-stored strings */
51
+ if (!is_progmem) {
52
+ Serial.println (s);
53
+ }
54
+
32
55
return 0 ;
33
56
};
Original file line number Diff line number Diff line change 316
316
317
317
/* board-specific */
318
318
#if defined(__AVR__ )
319
+ #define WOLFSSL_USER_IO
319
320
#define WOLFSSL_NO_SOCK
320
321
#define NO_WRITEV
321
322
#elif defined(__arm__ )
You can’t perform that action at this time.
0 commit comments