andrzej-kaczmarek commented on a change in pull request #362: nimble: add 
monitor protocol/interface + improve logs
URL: https://github.com/apache/mynewt-core/pull/362#discussion_r125025055
 
 

 ##########
 File path: net/nimble/host/src/ble_hs_log.c
 ##########
 @@ -45,3 +51,97 @@ ble_hs_log_flat_buf(const void *data, int len)
         BLE_HS_LOG(DEBUG, "0x%02x ", u8ptr[i]);
     }
 }
+
+const char *
+ble_addr_str(const ble_addr_t *addr)
+{
+    static char bufs[2][27];
+    static uint8_t cur;
+    char type[7];
+    char *str;
+
+    str = bufs[cur++];
+    cur %= sizeof(bufs) / sizeof(bufs[0]);
+
+    if (!addr) {
+        return "(none)";
+    }
+
+    switch (addr->type) {
+    case BLE_ADDR_PUBLIC:
+        strcpy(type, "public");
+        break;
+    case BLE_ADDR_RANDOM:
+        strcpy(type, "random");
+        break;
+    default:
+        snprintf(type, sizeof(type), "0x%02x", addr->type);
+        break;
+    }
+
+    sprintf(str, "%02X:%02X:%02X:%02X:%02X:%02X (%s)",
+            addr->val[5], addr->val[4], addr->val[3],
+            addr->val[2], addr->val[1], addr->val[0], type);
+
+    return str;
+}
+
+static char *
+get_buf(void)
+{
+    static char hexbufs[HEXBUF_COUNT][HEXBUF_LENGTH + 1];
 
 Review comment:
   We could extract tinyprintf to separate package and let nimble (or anyone) 
use this for outputting logs - create package libc/tinyprintf and make it 
required by libc/baselibc and net/nimble/host. This means we can have our 
mynewt_printf with whatever printf specifiers may come in handy later and you 
can use whatever libc you want at the same time.
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to