andrzej-kaczmarek commented on a change in pull request #362: nimble: add
monitor protocol/interface + improve logs
URL:
https://github.com/apache/incubator-mynewt-core/pull/362#discussion_r124893182
##########
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:
I don't like this either and default sizes of these buffers are way too big
- I just set them like this at the very beginning... so this has to be changed
for sure.
An additional idea here: what if we add % formatter to printf implementation
which would output bt_addr_t structure and hexdumps? This would require
virtually zero extra memory and should not be hard to implement I guess.
----------------------------------------------------------------
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