Add examples/esp32/uart-bridge

This commit is contained in:
Sergey Lyubka committed 2022-06-19 18:27:37 +01:00
1 parent 2d5c26d44f
commit 46bf79455c
20 files changed
+434 -8

No files matched your search

+6 -6
View File
@@ -3683,12 +3683,12 @@ Usage example: redirecting logs to syslog.
```c
static void mylog(uint8_t ch) {
static char buf[128];
static struct mg_iobuf log = { .buf = buf, .size = sizeof(buf), .len = 0};
log.buf[log.len++] = ch;
if (ch == '\n' || log.len >= log.size) {
syslog(LOG_INFO, "%.*s", (int) log.len, log.buf);
log.len = 0;
static char buf[256];
static size_t len;
buf[len++] = ch;
if (ch == '\n' || len >= sizeof(buf)) {
syslog(LOG_INFO, "%.*s", (int) len, buf); // Send logs
len = 0;
}
}
...