You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by gi...@git.apache.org on 2017/06/29 22:54:11 UTC

[GitHub] mkiiskila commented on a change in pull request #362: nimble: add monitor protocol/interface + improve logs

mkiiskila 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_r124931053
 
 

 ##########
 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:
   My 2 cents: I would not like to see custom printf formatter. I still want to use this with other libc implementations besides baselibc. For some of those, it would probably be difficult to add custom printf formatting (thinking native MacOS/Windows here).
 
----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services