From e50f67c18abe1cc90452b3b84c73c20b70bb4c5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Tue, 18 Aug 2015 20:52:18 +0200 Subject: [PATCH] Fix debug mode in example-tls-client Fixes #242 --- yotta/data/example-tls-client/main.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/yotta/data/example-tls-client/main.cpp b/yotta/data/example-tls-client/main.cpp index 926b4837e7..f97187ea61 100644 --- a/yotta/data/example-tls-client/main.cpp +++ b/yotta/data/example-tls-client/main.cpp @@ -256,19 +256,27 @@ protected: * Debug callback for mbed TLS * Just prints on the USB serial port */ - static void my_debug(void *ctx, int level, const char *str) + static void my_debug(void *ctx, int level, const char *file, int line, + const char *str) { + const char *p, *basename; (void) ctx; - (void) level; - printf("%s", str); + /* Extract basename from file */ + for(p = basename = file; *p != '\0'; p++) { + if(*p == '/' || *p == '\\') { + basename = p + 1; + } + } + + printf("%s:%04d: |%d| %s", basename, line, level, str); } /** * Certificate verification callback for mbed TLS * Here we only use it to display information on each cert in the chain */ - static int my_verify(void *data, mbedtls_x509_crt *crt, int depth, int *flags) + static int my_verify(void *data, mbedtls_x509_crt *crt, int depth, uint32_t *flags) { char buf[1024]; (void) data;