File tree 2 files changed +26
-1
lines changed
2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 25
25
/* Function to allow wolfcrypt to use Arduino Serial.print for debug messages.
26
26
* See wolfssl/wolfcrypt/logging.c */
27
27
28
+ #if defined(__AVR__)
29
+ #include < avr/pgmspace.h> /* Required for PROGMEM handling on AVR */
30
+ #endif
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
+
37
+ #if defined(__AVR__)
38
+ const char * t;
39
+ t = s;
40
+
41
+ /* Safely check if `s` is in PROGMEM, 0x8000 is typical for AVR flash */
42
+ if (reinterpret_cast <uint16_t >(t) >= 0x8000 ) {
43
+ while (pgm_read_byte (t)) {
44
+ Serial.write (pgm_read_byte (t++));
45
+ }
46
+ Serial.println ();
47
+ is_progmem = 1 ;
48
+ }
49
+ #endif
50
+
51
+ /* Print normally for non-AVR boards or RAM-stored strings */
52
+ if (!is_progmem) {
53
+ Serial.println (s);
54
+ }
55
+
32
56
return 0 ;
33
57
};
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