File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -271,6 +271,25 @@ void hal_sleep () {
271
271
// -----------------------------------------------------------------------------
272
272
273
273
#if defined(LMIC_PRINTF_TO)
274
+ #if defined(ESP8266) || defined(ESP31B) || defined(ESP32)
275
+ // ESPXX specific PRINTF, only tested with ESP32 Haltec LoRA Wifi so far
276
+ static ssize_t uart_putchar (void *, const char *buf, size_t len) {
277
+ return LMIC_PRINTF_TO.write ((const uint8_t *)buf, len);
278
+ }
279
+
280
+ static cookie_io_functions_t functions =
281
+ {
282
+ .read = NULL ,
283
+ .write = uart_putchar,
284
+ .seek = NULL ,
285
+ .close = NULL
286
+ };
287
+
288
+ void hal_printf_init () {
289
+ stdout = fopencookie (NULL , " w" , functions);
290
+ }
291
+ #else // !defined(ESP8266) || defined(ESP31B) || defined(ESP32)
292
+ // all else, like AVR
274
293
static int uart_putchar (char c, FILE *)
275
294
{
276
295
LMIC_PRINTF_TO.write (c) ;
@@ -288,6 +307,8 @@ void hal_printf_init() {
288
307
// The uart is the standard output device STDOUT.
289
308
stdout = &uartout ;
290
309
}
310
+
311
+ #endif // !defined(ESP8266) || defined(ESP31B) || defined(ESP32)
291
312
#endif // defined(LMIC_PRINTF_TO)
292
313
293
314
void hal_init (void ) {
You can’t perform that action at this time.
0 commit comments