diff --git a/drivers/bluetooth/hci/h5.c b/drivers/bluetooth/hci/h5.c index 93dce5583a3..a6d242496ac 100644 --- a/drivers/bluetooth/hci/h5.c +++ b/drivers/bluetooth/hci/h5.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -246,29 +247,29 @@ static void hexdump(const char *str, const uint8_t *packet, size_t length) int n = 0; if (!length) { - printf("%s zero-length signal packet\n", str); + printk("%s zero-length signal packet\n", str); return; } while (length--) { if (n % 16 == 0) { - printf("%s %08X ", str, n); + printk("%s %08X ", str, n); } - printf("%02X ", *packet++); + printk("%02X ", *packet++); n++; if (n % 8 == 0) { if (n % 16 == 0) { - printf("\n"); + printk("\n"); } else { - printf(" "); + printk(" "); } } } if (n % 16) { - printf("\n"); + printk("\n"); } } #else diff --git a/include/bluetooth/bluetooth.h b/include/bluetooth/bluetooth.h index fd2862b37c4..5c2f1d5d06f 100644 --- a/include/bluetooth/bluetooth.h +++ b/include/bluetooth/bluetooth.h @@ -27,9 +27,8 @@ */ #include -#include #include - +#include #include #include #include @@ -402,7 +401,7 @@ int bt_br_oob_get_local(struct bt_br_oob *oob); */ static inline int bt_addr_to_str(const bt_addr_t *addr, char *str, size_t len) { - return snprintf(str, len, "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", + return snprintk(str, len, "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", addr->val[5], addr->val[4], addr->val[3], addr->val[2], addr->val[1], addr->val[0]); } @@ -430,11 +429,11 @@ static inline int bt_addr_le_to_str(const bt_addr_le_t *addr, char *str, strcpy(type, "random"); break; default: - sprintf(type, "0x%02x", addr->type); + snprintk(type, sizeof(type), "0x%02x", addr->type); break; } - return snprintf(str, len, "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X (%s)", + return snprintk(str, len, "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X (%s)", addr->a.val[5], addr->a.val[4], addr->a.val[3], addr->a.val[2], addr->a.val[1], addr->a.val[0], type); } diff --git a/subsys/bluetooth/host/Kconfig b/subsys/bluetooth/host/Kconfig index e1cffcd42a7..25eb8457961 100644 --- a/subsys/bluetooth/host/Kconfig +++ b/subsys/bluetooth/host/Kconfig @@ -115,6 +115,7 @@ if BLUETOOTH_HCI_HOST config BLUETOOTH_INTERNAL_STORAGE bool "Use an internal persistent storage handler" depends on FILE_SYSTEM + depends on PRINTK help When selected the application doesn't need to register its own persistent storage handlers through the bt_storage API, rather @@ -464,6 +465,7 @@ config BLUETOOTH_RFCOMM_L2CAP_MTU config BLUETOOTH_HFP_HF bool "Bluetooth Handsfree profile HF Role support [EXPERIMENTAL]" + depends on PRINTK select BLUETOOTH_RFCOMM help This option enables Bluetooth HF support diff --git a/subsys/bluetooth/host/hfp_hf.c b/subsys/bluetooth/host/hfp_hf.c index 1a6177795e9..062c6ca4641 100644 --- a/subsys/bluetooth/host/hfp_hf.c +++ b/subsys/bluetooth/host/hfp_hf.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -67,7 +68,7 @@ int hfp_hf_send_cmd(struct bt_hfp_hf *hf, at_resp_cb_t resp, } va_start(vargs, format); - ret = vsnprintf(buf->data, (net_buf_tailroom(buf) - 1), format, vargs); + ret = vsnprintk(buf->data, (net_buf_tailroom(buf) - 1), format, vargs); if (ret < 0) { BT_ERR("Unable to format variable arguments"); return ret; diff --git a/subsys/bluetooth/host/storage.c b/subsys/bluetooth/host/storage.c index e1d63c7a314..e694b159d60 100644 --- a/subsys/bluetooth/host/storage.c +++ b/subsys/bluetooth/host/storage.c @@ -15,8 +15,8 @@ */ #include -#include #include +#include #include #include @@ -56,7 +56,7 @@ static int storage_open(const bt_addr_le_t *addr, uint16_t key, #if MAX_FILE_NAME >= STORAGE_FILE_NAME_LEN int len; - len = snprintf(path, sizeof(path), + len = snprintk(path, sizeof(path), STORAGE_ROOT "/%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X%u", addr->a.val[5], addr->a.val[4], addr->a.val[3], addr->a.val[2], addr->a.val[1], addr->a.val[0], @@ -76,12 +76,12 @@ static int storage_open(const bt_addr_le_t *addr, uint16_t key, } } - snprintf(path + len, sizeof(path) - len, "/%04x", key); + snprintk(path + len, sizeof(path) - len, "/%04x", key); #else return -ENAMETOOLONG; #endif } else { - snprintf(path, sizeof(path), STORAGE_ROOT "/%04x", key); + snprintk(path, sizeof(path), STORAGE_ROOT "/%04x", key); } return fs_open(file, path); @@ -149,7 +149,7 @@ static int unlink_recursive(char path[STORAGE_PATH_MAX]) break; } - snprintf(path + path_len, STORAGE_PATH_MAX - path_len, "/%s", + snprintk(path + path_len, STORAGE_PATH_MAX - path_len, "/%s", entry.name); if (entry.type == FS_DIR_ENTRY_DIR) { @@ -180,7 +180,7 @@ static int storage_clear(const bt_addr_le_t *addr) if (addr) { #if MAX_FILE_NAME >= STORAGE_FILE_NAME_LEN - snprintf(path, STORAGE_PATH_MAX, + snprintk(path, STORAGE_PATH_MAX, STORAGE_ROOT "/%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X%u", addr->a.val[5], addr->a.val[4], addr->a.val[3], addr->a.val[2], addr->a.val[1], addr->a.val[0], diff --git a/tests/bluetooth/shell/src/main.c b/tests/bluetooth/shell/src/main.c index 4f352759a15..ea2deee098e 100644 --- a/tests/bluetooth/shell/src/main.c +++ b/tests/bluetooth/shell/src/main.c @@ -1316,7 +1316,7 @@ static void auth_passkey_display(struct bt_conn *conn, unsigned int passkey) bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); - snprintf(passkey_str, 7, "%06u", passkey); + snprintk(passkey_str, 7, "%06u", passkey); printk("Passkey for %s: %s\n", addr, passkey_str); } @@ -1328,7 +1328,7 @@ static void auth_passkey_confirm(struct bt_conn *conn, unsigned int passkey) bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); - snprintf(passkey_str, 7, "%06u", passkey); + snprintk(passkey_str, 7, "%06u", passkey); printk("Confirm passkey for %s: %s\n", addr, passkey_str); }