From e458f5aae63bbdd0a8310da450a8ad8eac700758 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Battrel?= Date: Wed, 2 Nov 2022 14:31:13 +0100 Subject: [PATCH] Bluetooth: Use Zephyr standard log system instead of `bluetooth/common/log` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `bluetooth/common/log.h` and `bluetooth/common/log.c` files have been removed. Files that were using them have been updated to use `zephyr/logging/log.h` instead. Those replacement have been done consequently: - `/BT_DBG/LOG_DBG/` - `/BT_ERR/LOG_ERR/` - `/BT_WARN/LOG_WRN/` - `/BT_INFO/LOG_INF/` - `/BT_HEXDUMP_DBG/LOG_HEXDUMP_DBG/` - `/BT_DBG_OBJ_ID/LOG_DBG_OBJ_ID/` Also, some files were relying on the `common/log.h` include to include `zephyr/bluetooth/hci.h`, in those cases the include of `hci.h` has been added. For files that were including `common/log.h` but not using any logs, the include has been removed and not replaced. Signed-off-by: Théo Battrel --- doc/releases/release-notes-3.3.rst | 5 + drivers/bluetooth/hci/h4.c | 74 +- drivers/bluetooth/hci/h5.c | 91 ++- drivers/bluetooth/hci/hci_b91.c | 46 +- drivers/bluetooth/hci/hci_esp32.c | 61 +- drivers/bluetooth/hci/ipm_stm32wb.c | 65 +- drivers/bluetooth/hci/rpmsg.c | 61 +- drivers/bluetooth/hci/spi.c | 41 +- drivers/bluetooth/hci/userchan.c | 35 +- include/zephyr/bluetooth/audio/tbs.h | 4 +- include/zephyr/bluetooth/services/ots.h | 2 +- samples/bluetooth/hci_rpmsg/src/main.c | 9 +- samples/bluetooth/mesh/microbit_gatt.conf | 18 +- samples/bluetooth/mesh/nrf51_qfaa.conf | 16 +- samples/bluetooth/mesh/prj.conf | 4 +- samples/bluetooth/mesh/prj_bbc_microbit.conf | 16 +- samples/bluetooth/mesh_provisioner/prj.conf | 22 +- samples/boards/nrf/mesh/onoff-app/prj.conf | 32 +- .../onoff_level_lighting_vnd_app/prj.conf | 30 +- samples/boards/reel_board/mesh_badge/prj.conf | 6 +- subsys/bluetooth/audio/Kconfig.aics | 14 +- subsys/bluetooth/audio/Kconfig.baps | 50 +- subsys/bluetooth/audio/Kconfig.cap | 6 + subsys/bluetooth/audio/Kconfig.csip | 18 + subsys/bluetooth/audio/Kconfig.has | 12 + subsys/bluetooth/audio/Kconfig.mcs | 12 + subsys/bluetooth/audio/Kconfig.mctl | 6 + subsys/bluetooth/audio/Kconfig.micp | 12 + subsys/bluetooth/audio/Kconfig.mpl | 6 + subsys/bluetooth/audio/Kconfig.pacs | 6 + subsys/bluetooth/audio/Kconfig.tbs | 12 + subsys/bluetooth/audio/Kconfig.vcs | 12 + subsys/bluetooth/audio/Kconfig.vocs | 13 +- subsys/bluetooth/audio/aics.c | 131 ++-- subsys/bluetooth/audio/aics_client.c | 211 +++--- subsys/bluetooth/audio/ascs.c | 298 ++++---- .../bluetooth/audio/bap_broadcast_assistant.c | 77 +- subsys/bluetooth/audio/bap_scan_delegator.c | 187 +++-- subsys/bluetooth/audio/broadcast_sink.c | 176 +++-- subsys/bluetooth/audio/broadcast_source.c | 140 ++-- subsys/bluetooth/audio/cap_acceptor.c | 10 +- subsys/bluetooth/audio/cap_initiator.c | 32 +- subsys/bluetooth/audio/codec.c | 18 +- subsys/bluetooth/audio/csip_crypto.c | 45 +- subsys/bluetooth/audio/csip_set_coordinator.c | 227 +++--- subsys/bluetooth/audio/csip_set_member.c | 62 +- subsys/bluetooth/audio/has.c | 66 +- subsys/bluetooth/audio/has_client.c | 114 +-- subsys/bluetooth/audio/mcc.c | 706 +++++++++--------- subsys/bluetooth/audio/mcs.c | 173 +++-- subsys/bluetooth/audio/media_proxy.c | 402 +++++----- subsys/bluetooth/audio/media_proxy_internal.h | 6 +- subsys/bluetooth/audio/micp_mic_ctlr.c | 74 +- subsys/bluetooth/audio/micp_mic_dev.c | 22 +- subsys/bluetooth/audio/mpl.c | 327 ++++---- subsys/bluetooth/audio/pacs.c | 61 +- subsys/bluetooth/audio/stream.c | 213 +++--- subsys/bluetooth/audio/tbs.c | 222 +++--- subsys/bluetooth/audio/tbs_client.c | 298 ++++---- subsys/bluetooth/audio/unicast_client.c | 413 +++++----- subsys/bluetooth/audio/unicast_server.c | 14 +- subsys/bluetooth/audio/vcs.c | 128 ++-- subsys/bluetooth/audio/vcs_client.c | 124 ++- subsys/bluetooth/audio/vocs.c | 66 +- subsys/bluetooth/audio/vocs_client.c | 169 ++--- subsys/bluetooth/common/CMakeLists.txt | 1 - subsys/bluetooth/common/Kconfig | 12 + .../common/Kconfig.template.log_config_bt | 17 + subsys/bluetooth/common/log.c | 8 - subsys/bluetooth/common/log.h | 46 -- subsys/bluetooth/common/rpa.c | 15 +- subsys/bluetooth/controller/crypto/crypto.c | 19 +- subsys/bluetooth/controller/hci/hci.c | 128 ++-- subsys/bluetooth/controller/hci/hci_driver.c | 56 +- subsys/bluetooth/controller/ll_sw/isoal.c | 13 +- subsys/bluetooth/controller/ll_sw/ll_feat.c | 5 +- .../bluetooth/controller/ll_sw/ll_settings.c | 18 +- subsys/bluetooth/controller/ll_sw/lll_chan.c | 3 - .../bluetooth/controller/ll_sw/lll_common.c | 3 - .../controller/ll_sw/nordic/hal/nrf5/cntr.c | 3 - .../controller/ll_sw/nordic/hal/nrf5/ecb.c | 3 - .../controller/ll_sw/nordic/hal/nrf5/mayfly.c | 3 - .../controller/ll_sw/nordic/hal/nrf5/ticker.c | 3 - .../controller/ll_sw/nordic/lll/lll.c | 3 - .../controller/ll_sw/nordic/lll/lll_adv.c | 3 - .../controller/ll_sw/nordic/lll/lll_adv_aux.c | 3 - .../controller/ll_sw/nordic/lll/lll_adv_iso.c | 4 +- .../ll_sw/nordic/lll/lll_adv_sync.c | 3 - .../controller/ll_sw/nordic/lll/lll_central.c | 3 - .../ll_sw/nordic/lll/lll_central_iso.c | 2 - .../controller/ll_sw/nordic/lll/lll_clock.c | 3 - .../controller/ll_sw/nordic/lll/lll_conn.c | 5 +- .../ll_sw/nordic/lll/lll_conn_iso.c | 2 - .../controller/ll_sw/nordic/lll/lll_df.c | 3 - .../ll_sw/nordic/lll/lll_peripheral.c | 3 - .../ll_sw/nordic/lll/lll_peripheral_iso.c | 2 - .../controller/ll_sw/nordic/lll/lll_scan.c | 3 - .../ll_sw/nordic/lll/lll_scan_aux.c | 3 - .../controller/ll_sw/nordic/lll/lll_sync.c | 5 +- .../ll_sw/nordic/lll/lll_sync_iso.c | 4 +- .../controller/ll_sw/nordic/lll/lll_test.c | 5 +- .../controller/ll_sw/openisa/hal/RV32M1/ecb.c | 8 +- .../ll_sw/openisa/hal/RV32M1/radio/radio.c | 37 +- .../controller/ll_sw/openisa/lll/lll.c | 3 - .../controller/ll_sw/openisa/lll/lll_clock.c | 2 - .../controller/ll_sw/openisa/lll/lll_conn.c | 3 +- subsys/bluetooth/controller/ll_sw/ull.c | 3 - subsys/bluetooth/controller/ll_sw/ull_adv.c | 3 - .../bluetooth/controller/ll_sw/ull_adv_aux.c | 3 - .../bluetooth/controller/ll_sw/ull_adv_iso.c | 5 +- .../bluetooth/controller/ll_sw/ull_adv_sync.c | 3 - .../bluetooth/controller/ll_sw/ull_central.c | 3 - .../controller/ll_sw/ull_central_iso.c | 5 +- subsys/bluetooth/controller/ll_sw/ull_conn.c | 15 +- .../bluetooth/controller/ll_sw/ull_conn_iso.c | 5 +- subsys/bluetooth/controller/ll_sw/ull_df.c | 3 - .../bluetooth/controller/ll_sw/ull_filter.c | 11 +- subsys/bluetooth/controller/ll_sw/ull_iso.c | 11 +- subsys/bluetooth/controller/ll_sw/ull_llcp.c | 3 - .../bluetooth/controller/ll_sw/ull_llcp_cc.c | 3 - .../controller/ll_sw/ull_llcp_chmu.c | 3 - .../controller/ll_sw/ull_llcp_common.c | 3 - .../controller/ll_sw/ull_llcp_conn_upd.c | 3 - .../bluetooth/controller/ll_sw/ull_llcp_enc.c | 3 - .../controller/ll_sw/ull_llcp_local.c | 3 - .../bluetooth/controller/ll_sw/ull_llcp_pdu.c | 3 - .../bluetooth/controller/ll_sw/ull_llcp_phy.c | 3 - .../controller/ll_sw/ull_llcp_remote.c | 3 - .../controller/ll_sw/ull_peripheral.c | 3 - .../controller/ll_sw/ull_peripheral_iso.c | 17 +- subsys/bluetooth/controller/ll_sw/ull_scan.c | 3 - .../bluetooth/controller/ll_sw/ull_scan_aux.c | 5 +- subsys/bluetooth/controller/ll_sw/ull_sched.c | 5 +- subsys/bluetooth/controller/ll_sw/ull_sync.c | 3 - .../bluetooth/controller/ll_sw/ull_sync_iso.c | 5 +- subsys/bluetooth/controller/ticker/ticker.c | 3 - subsys/bluetooth/crypto/CMakeLists.txt | 7 + subsys/bluetooth/crypto/Kconfig | 6 + subsys/bluetooth/crypto/bt_crypto.c | 9 +- subsys/bluetooth/host/CMakeLists.txt | 4 +- subsys/bluetooth/host/Kconfig | 85 ++- subsys/bluetooth/host/Kconfig.gatt | 12 + subsys/bluetooth/host/Kconfig.l2cap | 6 + subsys/bluetooth/host/a2dp.c | 25 +- subsys/bluetooth/host/adv.c | 41 +- subsys/bluetooth/host/aes_ccm.c | 15 +- subsys/bluetooth/host/att.c | 256 ++++--- subsys/bluetooth/host/avdtp.c | 53 +- subsys/bluetooth/host/br.c | 74 +- subsys/bluetooth/host/buf.c | 4 +- subsys/bluetooth/host/conn.c | 118 ++- subsys/bluetooth/host/crypto.c | 23 +- subsys/bluetooth/host/direction.c | 82 +- subsys/bluetooth/host/ecc.c | 20 +- subsys/bluetooth/host/gatt.c | 343 ++++----- subsys/bluetooth/host/hci_core.c | 320 ++++---- subsys/bluetooth/host/hci_ecc.c | 17 +- subsys/bluetooth/host/hci_raw.c | 34 +- subsys/bluetooth/host/hfp_hf.c | 104 +-- subsys/bluetooth/host/id.c | 105 +-- subsys/bluetooth/host/iso.c | 370 +++++---- subsys/bluetooth/host/iso_internal.h | 4 +- subsys/bluetooth/host/keys.c | 85 +-- subsys/bluetooth/host/keys_br.c | 37 +- subsys/bluetooth/host/l2cap.c | 246 +++--- subsys/bluetooth/host/l2cap_br.c | 132 ++-- subsys/bluetooth/host/l2cap_internal.h | 4 +- subsys/bluetooth/host/rfcomm.c | 129 ++-- subsys/bluetooth/host/scan.c | 65 +- subsys/bluetooth/host/sdp.c | 239 +++--- subsys/bluetooth/host/settings.c | 56 +- subsys/bluetooth/host/smp.c | 406 +++++----- subsys/bluetooth/host/smp_null.c | 12 +- subsys/bluetooth/host/ssp.c | 88 +-- subsys/bluetooth/mesh/Kconfig | 118 ++- subsys/bluetooth/mesh/access.c | 140 ++-- subsys/bluetooth/mesh/adv.c | 35 +- subsys/bluetooth/mesh/adv_ext.c | 33 +- subsys/bluetooth/mesh/adv_legacy.c | 26 +- subsys/bluetooth/mesh/app_keys.c | 55 +- subsys/bluetooth/mesh/beacon.c | 68 +- subsys/bluetooth/mesh/cdb.c | 125 ++-- subsys/bluetooth/mesh/cfg.c | 20 +- subsys/bluetooth/mesh/cfg_cli.c | 153 ++-- subsys/bluetooth/mesh/cfg_srv.c | 365 +++++---- subsys/bluetooth/mesh/crypto.c | 73 +- subsys/bluetooth/mesh/friend.c | 218 +++--- subsys/bluetooth/mesh/gatt_cli.c | 43 +- subsys/bluetooth/mesh/health_cli.c | 38 +- subsys/bluetooth/mesh/health_srv.c | 68 +- subsys/bluetooth/mesh/heartbeat.c | 45 +- subsys/bluetooth/mesh/lpn.c | 130 ++-- subsys/bluetooth/mesh/main.c | 23 +- subsys/bluetooth/mesh/msg.c | 12 +- subsys/bluetooth/mesh/net.c | 165 ++-- subsys/bluetooth/mesh/pb_adv.c | 122 ++- subsys/bluetooth/mesh/pb_gatt.c | 33 +- subsys/bluetooth/mesh/pb_gatt_cli.c | 12 +- subsys/bluetooth/mesh/pb_gatt_srv.c | 39 +- subsys/bluetooth/mesh/prov.c | 30 +- subsys/bluetooth/mesh/prov_device.c | 124 +-- subsys/bluetooth/mesh/provisioner.c | 158 ++-- subsys/bluetooth/mesh/proxy_cli.c | 16 +- subsys/bluetooth/mesh/proxy_msg.c | 29 +- subsys/bluetooth/mesh/proxy_srv.c | 102 +-- subsys/bluetooth/mesh/rpl.c | 37 +- subsys/bluetooth/mesh/settings.c | 18 +- subsys/bluetooth/mesh/subnet.c | 67 +- subsys/bluetooth/mesh/test.c | 3 - subsys/bluetooth/mesh/transport.c | 233 +++--- subsys/bluetooth/services/dis.c | 30 +- subsys/bluetooth/services/ias/Kconfig.ias | 6 + subsys/bluetooth/services/ias/ias_client.c | 15 +- subsys/bluetooth/services/ots/Kconfig | 7 + subsys/bluetooth/services/ots/ots_client.c | 403 +++++----- subsys/bluetooth/shell/mcc.c | 16 +- subsys/bluetooth/shell/media_controller.c | 8 +- subsys/bluetooth/shell/mpl.c | 22 +- subsys/bluetooth/shell/tbs.c | 2 +- .../bsim_bt/bsim_test_audio/prj.conf | 60 +- .../bsim_bt/bsim_test_l2cap/prj.conf | 2 +- .../bluetooth/bsim_bt/bsim_test_mesh/prj.conf | 2 +- .../bsim_bt/bsim_test_mesh/prj_gatt.conf | 2 +- .../bsim_bt/bsim_test_mesh/prj_low_lat.conf | 2 +- .../bsim_bt/bsim_test_mesh/prj_pst.conf | 4 +- .../edtt_ble_test_app/hci_test_app/src/main.c | 2 +- .../controller/mock_ctrl/src/lll_clock.c | 3 - .../controller/mock_ctrl/src/ull_conn_iso.c | 3 - tests/bluetooth/hci_prop_evt/prj.conf | 4 +- tests/bluetooth/host_long_adv_recv/prj.conf | 4 +- tests/bluetooth/init/prj_17.conf | 16 +- tests/bluetooth/init/prj_20.conf | 20 +- tests/bluetooth/init/prj_21.conf | 16 +- tests/bluetooth/init/prj_ctlr_dbg.conf | 16 +- tests/bluetooth/init/prj_h5_dbg.conf | 2 +- tests/bluetooth/mesh/dbg.conf | 24 +- tests/bluetooth/mesh/ext_adv.conf | 24 +- tests/bluetooth/mesh/friend.conf | 24 +- tests/bluetooth/mesh/gatt.conf | 24 +- tests/bluetooth/mesh/lpn.conf | 24 +- tests/bluetooth/mesh/microbit.conf | 16 +- tests/bluetooth/mesh/microbit_gatt.conf | 18 +- tests/bluetooth/mesh/multi_ext_adv.conf | 14 +- tests/bluetooth/mesh/nrf51-16k.conf | 16 +- tests/bluetooth/mesh/pb_gatt.conf | 24 +- tests/bluetooth/mesh/prj.conf | 24 +- tests/bluetooth/mesh/proxy.conf | 24 +- tests/bluetooth/mesh_shell/prj.conf | 2 +- tests/bluetooth/shell/audio.conf | 48 +- tests/bluetooth/shell/log.conf | 66 ++ tests/bluetooth/shell/mesh.conf | 2 +- tests/bluetooth/shell/testcase.yaml | 5 + .../tester/boards/qemu_cortex_m3.conf | 12 +- 253 files changed, 7131 insertions(+), 7180 deletions(-) create mode 100644 subsys/bluetooth/common/Kconfig.template.log_config_bt delete mode 100644 subsys/bluetooth/common/log.c delete mode 100644 subsys/bluetooth/common/log.h create mode 100644 tests/bluetooth/shell/log.conf diff --git a/doc/releases/release-notes-3.3.rst b/doc/releases/release-notes-3.3.rst index 75755511708..4df81c9c759 100644 --- a/doc/releases/release-notes-3.3.rst +++ b/doc/releases/release-notes-3.3.rst @@ -40,6 +40,11 @@ Changes in this release * Starting from this release ``zephyr-`` prefixed tags won't be created anymore. The project will continue using ``v`` tags, for example ``v3.3.0``. +* Bluetooth: Deprecate the Bluetooth logging subsystem in favor of the Zephyr + standard logging system. To enable debugging for a particular module in the + Bluetooth subsystem, enable `CONFIG_BT_(module name)_LOG_LEVEL_DBG` instead of + `CONFIG_BT_DEBUG_(module name)`. + Removed APIs in this release ============================ diff --git a/drivers/bluetooth/hci/h4.c b/drivers/bluetooth/hci/h4.c index 1f428e678ed..3c79935b51b 100644 --- a/drivers/bluetooth/hci/h4.c +++ b/drivers/bluetooth/hci/h4.c @@ -22,9 +22,10 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_driver -#include "common/log.h" +#define LOG_LEVEL CONFIG_BT_HCI_DRIVER_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_driver); + #include "common/bt_str.h" #include "../util.h" @@ -76,7 +77,7 @@ static inline void h4_get_type(void) { /* Get packet type */ if (uart_fifo_read(h4_dev, &rx.type, 1) != 1) { - BT_WARN("Unable to read H:4 packet type"); + LOG_WRN("Unable to read H:4 packet type"); rx.type = H4_NONE; return; } @@ -98,7 +99,7 @@ static inline void h4_get_type(void) } __fallthrough; default: - BT_ERR("Unknown H:4 type 0x%02x", rx.type); + LOG_ERR("Unknown H:4 type 0x%02x", rx.type); rx.type = H4_NONE; } } @@ -110,7 +111,7 @@ static void h4_read_hdr(void) ret = uart_fifo_read(h4_dev, rx.hdr + bytes_read, rx.remaining); if (unlikely(ret < 0)) { - BT_ERR("Unable to read from UART (ret %d)", ret); + LOG_ERR("Unable to read from UART (ret %d)", ret); } else { rx.remaining -= ret; } @@ -124,7 +125,7 @@ static inline void get_acl_hdr(void) struct bt_hci_acl_hdr *hdr = &rx.acl; rx.remaining = sys_le16_to_cpu(hdr->len); - BT_DBG("Got ACL header. Payload %u bytes", rx.remaining); + LOG_DBG("Got ACL header. Payload %u bytes", rx.remaining); rx.have_hdr = true; } } @@ -137,7 +138,7 @@ static inline void get_iso_hdr(void) struct bt_hci_iso_hdr *hdr = &rx.iso; rx.remaining = bt_iso_hdr_len(sys_le16_to_cpu(hdr->len)); - BT_DBG("Got ISO header. Payload %u bytes", rx.remaining); + LOG_DBG("Got ISO header. Payload %u bytes", rx.remaining); rx.have_hdr = true; } } @@ -166,12 +167,12 @@ static inline void get_evt_hdr(void) if (!rx.remaining) { if (rx.evt.evt == BT_HCI_EVT_LE_META_EVENT && (rx.hdr[sizeof(*hdr)] == BT_HCI_EVT_LE_ADVERTISING_REPORT)) { - BT_DBG("Marking adv report as discardable"); + LOG_DBG("Marking adv report as discardable"); rx.discardable = true; } rx.remaining = hdr->len - (rx.hdr_len - sizeof(*hdr)); - BT_DBG("Got event header. Payload %u bytes", hdr->len); + LOG_DBG("Got event header. Payload %u bytes", hdr->len); rx.have_hdr = true; } } @@ -193,7 +194,7 @@ static void reset_rx(void) static struct net_buf *get_rx(k_timeout_t timeout) { - BT_DBG("type 0x%02x, evt 0x%02x", rx.type, rx.evt.evt); + LOG_DBG("type 0x%02x, evt 0x%02x", rx.type, rx.evt.evt); switch (rx.type) { case H4_EVT: @@ -217,10 +218,10 @@ static void rx_thread(void *p1, void *p2, void *p3) ARG_UNUSED(p2); ARG_UNUSED(p3); - BT_DBG("started"); + LOG_DBG("started"); while (1) { - BT_DBG("rx.buf %p", rx.buf); + LOG_DBG("rx.buf %p", rx.buf); /* We can only do the allocation if we know the initial * header, since Command Complete/Status events must use the @@ -228,9 +229,9 @@ static void rx_thread(void *p1, void *p2, void *p3) */ if (rx.have_hdr && !rx.buf) { rx.buf = get_rx(K_FOREVER); - BT_DBG("Got rx.buf %p", rx.buf); + LOG_DBG("Got rx.buf %p", rx.buf); if (rx.remaining > net_buf_tailroom(rx.buf)) { - BT_ERR("Not enough space in buffer"); + LOG_ERR("Not enough space in buffer"); rx.discard = rx.remaining; reset_rx(); } else { @@ -245,7 +246,7 @@ static void rx_thread(void *p1, void *p2, void *p3) do { uart_irq_rx_enable(h4_dev); - BT_DBG("Calling bt_recv(%p)", buf); + LOG_DBG("Calling bt_recv(%p)", buf); bt_recv(buf); /* Give other threads a chance to run if the ISR @@ -267,7 +268,7 @@ static size_t h4_discard(const struct device *uart, size_t len) err = uart_fifo_read(uart, buf, MIN(len, sizeof(buf))); if (unlikely(err < 0)) { - BT_ERR("Unable to read from UART (err %d)", err); + LOG_ERR("Unable to read from UART (err %d)", err); return 0; } @@ -286,23 +287,22 @@ static inline void read_payload(void) rx.buf = get_rx(K_NO_WAIT); if (!rx.buf) { if (rx.discardable) { - BT_WARN("Discarding event 0x%02x", rx.evt.evt); + LOG_WRN("Discarding event 0x%02x", rx.evt.evt); rx.discard = rx.remaining; reset_rx(); return; } - BT_WARN("Failed to allocate, deferring to rx_thread"); + LOG_WRN("Failed to allocate, deferring to rx_thread"); uart_irq_rx_disable(h4_dev); return; } - BT_DBG("Allocated rx.buf %p", rx.buf); + LOG_DBG("Allocated rx.buf %p", rx.buf); buf_tailroom = net_buf_tailroom(rx.buf); if (buf_tailroom < rx.remaining) { - BT_ERR("Not enough space in buffer %u/%zu", - rx.remaining, buf_tailroom); + LOG_ERR("Not enough space in buffer %u/%zu", rx.remaining, buf_tailroom); rx.discard = rx.remaining; reset_rx(); return; @@ -313,16 +313,15 @@ static inline void read_payload(void) read = uart_fifo_read(h4_dev, net_buf_tail(rx.buf), rx.remaining); if (unlikely(read < 0)) { - BT_ERR("Failed to read UART (err %d)", read); + LOG_ERR("Failed to read UART (err %d)", read); return; } net_buf_add(rx.buf, read); rx.remaining -= read; - BT_DBG("got %d bytes, remaining %u", read, rx.remaining); - BT_DBG("Payload (len %u): %s", rx.buf->len, - bt_hex(rx.buf->data, rx.buf->len)); + LOG_DBG("got %d bytes, remaining %u", read, rx.remaining); + LOG_DBG("Payload (len %u): %s", rx.buf->len, bt_hex(rx.buf->data, rx.buf->len)); if (rx.remaining) { return; @@ -343,12 +342,12 @@ static inline void read_payload(void) if (IS_ENABLED(CONFIG_BT_RECV_BLOCKING) && (evt_flags & BT_HCI_EVT_FLAG_RECV_PRIO)) { - BT_DBG("Calling bt_recv_prio(%p)", buf); + LOG_DBG("Calling bt_recv_prio(%p)", buf); bt_recv_prio(buf); } if (evt_flags & BT_HCI_EVT_FLAG_RECV) { - BT_DBG("Putting buf %p to rx fifo", buf); + LOG_DBG("Putting buf %p to rx fifo", buf); net_buf_put(&rx.fifo, buf); } } @@ -378,7 +377,7 @@ static inline void read_header(void) if (rx.have_hdr && rx.buf) { if (rx.remaining > net_buf_tailroom(rx.buf)) { - BT_ERR("Not enough space in buffer"); + LOG_ERR("Not enough space in buffer"); rx.discard = rx.remaining; reset_rx(); } else { @@ -394,7 +393,7 @@ static inline void process_tx(void) if (!tx.buf) { tx.buf = net_buf_get(&tx.fifo, K_NO_WAIT); if (!tx.buf) { - BT_ERR("TX interrupt but no pending buffer!"); + LOG_ERR("TX interrupt but no pending buffer!"); uart_irq_tx_disable(h4_dev); return; } @@ -415,13 +414,13 @@ static inline void process_tx(void) } __fallthrough; default: - BT_ERR("Unknown buffer type"); + LOG_ERR("Unknown buffer type"); goto done; } bytes = uart_fifo_fill(h4_dev, &tx.type, 1); if (bytes != 1) { - BT_WARN("Unable to send H:4 type"); + LOG_WRN("Unable to send H:4 type"); tx.type = H4_NONE; return; } @@ -429,7 +428,7 @@ static inline void process_tx(void) bytes = uart_fifo_fill(h4_dev, tx.buf->data, tx.buf->len); if (unlikely(bytes < 0)) { - BT_ERR("Unable to write to UART (err %d)", bytes); + LOG_ERR("Unable to write to UART (err %d)", bytes); } else { net_buf_pull(tx.buf, bytes); } @@ -449,9 +448,8 @@ done: static inline void process_rx(void) { - BT_DBG("remaining %u discard %u have_hdr %u rx.buf %p len %u", - rx.remaining, rx.discard, rx.have_hdr, rx.buf, - rx.buf ? rx.buf->len : 0); + LOG_DBG("remaining %u discard %u have_hdr %u rx.buf %p len %u", rx.remaining, rx.discard, + rx.have_hdr, rx.buf, rx.buf ? rx.buf->len : 0); if (rx.discard) { rx.discard -= h4_discard(h4_dev, rx.discard); @@ -483,7 +481,7 @@ static void bt_uart_isr(const struct device *unused, void *user_data) static int h4_send(struct net_buf *buf) { - BT_DBG("buf %p type %u len %u", buf, bt_buf_get_type(buf), buf->len); + LOG_DBG("buf %p type %u len %u", buf, bt_buf_get_type(buf), buf->len); net_buf_put(&tx.fifo, buf); uart_irq_tx_enable(h4_dev); @@ -508,7 +506,7 @@ static int h4_open(void) int ret; k_tid_t tid; - BT_DBG(""); + LOG_DBG(""); uart_irq_rx_disable(h4_dev); uart_irq_tx_disable(h4_dev); diff --git a/drivers/bluetooth/hci/h5.c b/drivers/bluetooth/hci/h5.c index 6430c29709a..38edac51a67 100644 --- a/drivers/bluetooth/hci/h5.c +++ b/drivers/bluetooth/hci/h5.c @@ -23,12 +23,12 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_driver -#include "common/log.h" - #include "../util.h" +#define LOG_LEVEL CONFIG_BT_HCI_DRIVER_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_driver); + static K_KERNEL_STACK_DEFINE(tx_stack, 256); static K_KERNEL_STACK_DEFINE(rx_stack, 256); @@ -159,7 +159,7 @@ static int h5_unslip_byte(uint8_t *byte) *byte = SLIP_ESC; break; default: - BT_ERR("Invalid escape byte %x\n", *byte); + LOG_ERR("Invalid escape byte %x\n", *byte); return -EIO; } @@ -175,8 +175,8 @@ static void process_unack(void) return; } - BT_DBG("rx_ack %u tx_ack %u tx_seq %u unack_queue_len %u", - h5.rx_ack, h5.tx_ack, h5.tx_seq, unack_queue_len); + LOG_DBG("rx_ack %u tx_ack %u tx_seq %u unack_queue_len %u", h5.rx_ack, h5.tx_ack, h5.tx_seq, + unack_queue_len); while (unack_queue_len > 0) { if (next_seq == h5.rx_ack) { @@ -192,22 +192,22 @@ static void process_unack(void) } if (next_seq != h5.rx_ack) { - BT_ERR("Wrong sequence: rx_ack %u tx_seq %u next_seq %u", - h5.rx_ack, h5.tx_seq, next_seq); + LOG_ERR("Wrong sequence: rx_ack %u tx_seq %u next_seq %u", h5.rx_ack, h5.tx_seq, + next_seq); } - BT_DBG("Need to remove %u packet from the queue", number_removed); + LOG_DBG("Need to remove %u packet from the queue", number_removed); while (number_removed) { struct net_buf *buf = net_buf_get(&h5.unack_queue, K_NO_WAIT); if (!buf) { - BT_ERR("Unack queue is empty"); + LOG_ERR("Unack queue is empty"); break; } /* TODO: print or do something with packet */ - BT_DBG("Remove buf from the unack_queue"); + LOG_DBG("Remove buf from the unack_queue"); net_buf_unref(buf); unack_queue_len--; @@ -218,18 +218,15 @@ static void process_unack(void) static void h5_print_header(const uint8_t *hdr, const char *str) { if (H5_HDR_RELIABLE(hdr)) { - BT_DBG("%s REL: seq %u ack %u crc %u type %u len %u", - str, H5_HDR_SEQ(hdr), H5_HDR_ACK(hdr), - H5_HDR_CRC(hdr), H5_HDR_PKT_TYPE(hdr), - H5_HDR_LEN(hdr)); + LOG_DBG("%s REL: seq %u ack %u crc %u type %u len %u", str, H5_HDR_SEQ(hdr), + H5_HDR_ACK(hdr), H5_HDR_CRC(hdr), H5_HDR_PKT_TYPE(hdr), H5_HDR_LEN(hdr)); } else { - BT_DBG("%s UNREL: ack %u crc %u type %u len %u", - str, H5_HDR_ACK(hdr), H5_HDR_CRC(hdr), - H5_HDR_PKT_TYPE(hdr), H5_HDR_LEN(hdr)); + LOG_DBG("%s UNREL: ack %u crc %u type %u len %u", str, H5_HDR_ACK(hdr), + H5_HDR_CRC(hdr), H5_HDR_PKT_TYPE(hdr), H5_HDR_LEN(hdr)); } } -#if defined(CONFIG_BT_DEBUG_HCI_DRIVER) +#if defined(CONFIG_BT_HCI_DRIVER_LOG_LEVEL_DBG) static void hexdump(const char *str, const uint8_t *packet, size_t length) { int n = 0; @@ -327,7 +324,7 @@ static void retx_timeout(struct k_work *work) { ARG_UNUSED(work); - BT_DBG("unack_queue_len %u", unack_queue_len); + LOG_DBG("unack_queue_len %u", unack_queue_len); if (unack_queue_len) { struct k_fifo tmp_queue; @@ -360,7 +357,7 @@ static void ack_timeout(struct k_work *work) { ARG_UNUSED(work); - BT_DBG(""); + LOG_DBG(""); h5_send(NULL, HCI_3WIRE_ACK_PKT, 0); } @@ -369,7 +366,7 @@ static void h5_process_complete_packet(uint8_t *hdr) { struct net_buf *buf; - BT_DBG(""); + LOG_DBG(""); /* rx_ack should be in every packet */ h5.rx_ack = H5_HDR_ACK(hdr); @@ -425,9 +422,9 @@ static void bt_uart_isr(const struct device *unused, void *user_data) if (!uart_irq_rx_ready(h5_dev)) { if (uart_irq_tx_ready(h5_dev)) { - BT_DBG("transmit ready"); + LOG_DBG("transmit ready"); } else { - BT_DBG("spurious interrupt"); + LOG_DBG("spurious interrupt"); } /* Only the UART RX path is interrupt-enabled */ break; @@ -479,7 +476,7 @@ static void bt_uart_isr(const struct device *unused, void *user_data) h5.rx_buf = bt_buf_get_rx(BT_BUF_ACL_IN, K_NO_WAIT); if (!h5.rx_buf) { - BT_WARN("No available data buffers"); + LOG_WRN("No available data buffers"); h5_reset_rx(); continue; } @@ -490,7 +487,7 @@ static void bt_uart_isr(const struct device *unused, void *user_data) h5.rx_buf = bt_buf_get_rx(BT_BUF_ISO_IN, K_NO_WAIT); if (!h5.rx_buf) { - BT_WARN("No available data buffers"); + LOG_WRN("No available data buffers"); h5_reset_rx(); continue; } @@ -501,7 +498,7 @@ static void bt_uart_isr(const struct device *unused, void *user_data) case HCI_3WIRE_ACK_PKT: h5.rx_buf = net_buf_alloc(&h5_pool, K_NO_WAIT); if (!h5.rx_buf) { - BT_WARN("No available signal buffers"); + LOG_WRN("No available signal buffers"); h5_reset_rx(); continue; } @@ -509,8 +506,7 @@ static void bt_uart_isr(const struct device *unused, void *user_data) h5.rx_state = PAYLOAD; break; default: - BT_ERR("Wrong packet type %u", - H5_HDR_PKT_TYPE(hdr)); + LOG_ERR("Wrong packet type %u", H5_HDR_PKT_TYPE(hdr)); h5.rx_state = END; break; } @@ -530,7 +526,7 @@ static void bt_uart_isr(const struct device *unused, void *user_data) if (!h5.rx_buf) { h5.rx_buf = get_evt_buf(byte); if (!h5.rx_buf) { - BT_WARN("No available event buffers"); + LOG_WRN("No available event buffers"); h5_reset_rx(); continue; } @@ -538,8 +534,8 @@ static void bt_uart_isr(const struct device *unused, void *user_data) buf_tailroom = net_buf_tailroom(h5.rx_buf); if (buf_tailroom < sizeof(byte)) { - BT_ERR("Not enough space in buffer %zu/%zu", - sizeof(byte), buf_tailroom); + LOG_ERR("Not enough space in buffer %zu/%zu", sizeof(byte), + buf_tailroom); h5_reset_rx(); break; } @@ -552,13 +548,12 @@ static void bt_uart_isr(const struct device *unused, void *user_data) break; case END: if (byte != SLIP_DELIMITER) { - BT_ERR("Missing ending SLIP_DELIMITER"); + LOG_ERR("Missing ending SLIP_DELIMITER"); h5_reset_rx(); break; } - BT_DBG("Received full packet: type %u", - H5_HDR_PKT_TYPE(hdr)); + LOG_DBG("Received full packet: type %u", H5_HDR_PKT_TYPE(hdr)); /* Check when full packet is received, it can be done * when parsing packet header but we need to receive @@ -566,8 +561,8 @@ static void bt_uart_isr(const struct device *unused, void *user_data) */ if (H5_HDR_RELIABLE(hdr) && H5_HDR_SEQ(hdr) != h5.tx_ack) { - BT_ERR("Seq expected %u got %u. Drop packet", - h5.tx_ack, H5_HDR_SEQ(hdr)); + LOG_ERR("Seq expected %u got %u. Drop packet", h5.tx_ack, + H5_HDR_SEQ(hdr)); h5_reset_rx(); break; } @@ -588,7 +583,7 @@ static int h5_queue(struct net_buf *buf) { uint8_t type; - BT_DBG("buf %p type %u len %u", buf, bt_buf_get_type(buf), buf->len); + LOG_DBG("buf %p type %u len %u", buf, bt_buf_get_type(buf), buf->len); switch (bt_buf_get_type(buf)) { case BT_BUF_CMD: @@ -601,7 +596,7 @@ static int h5_queue(struct net_buf *buf) type = HCI_ISODATA_PKT; break; default: - BT_ERR("Unknown packet type %u", bt_buf_get_type(buf)); + LOG_ERR("Unknown packet type %u", bt_buf_get_type(buf)); return -1; } @@ -614,7 +609,7 @@ static int h5_queue(struct net_buf *buf) static void tx_thread(void) { - BT_DBG(""); + LOG_DBG(""); /* FIXME: make periodic sending */ h5_send(sync_req, HCI_3WIRE_LINK_PKT, sizeof(sync_req)); @@ -623,7 +618,7 @@ static void tx_thread(void) struct net_buf *buf; uint8_t type; - BT_DBG("link_state %u", h5.link_state); + LOG_DBG("link_state %u", h5.link_state); switch (h5.link_state) { case UNINIT: @@ -660,7 +655,7 @@ static void h5_set_txwin(uint8_t *conf) static void rx_thread(void) { - BT_DBG(""); + LOG_DBG(""); while (true) { struct net_buf *buf; @@ -700,11 +695,9 @@ static void rx_thread(void) h5.tx_win = (buf->data[2] & 0x07); } - BT_DBG("Finished H5 configuration, tx_win %u", - h5.tx_win); + LOG_DBG("Finished H5 configuration, tx_win %u", h5.tx_win); } else { - BT_ERR("Not handled yet %x %x", - buf->data[0], buf->data[1]); + LOG_ERR("Not handled yet %x %x", buf->data[0], buf->data[1]); } net_buf_unref(buf); @@ -718,7 +711,7 @@ static void rx_thread(void) static void h5_init(void) { - BT_DBG(""); + LOG_DBG(""); h5.link_state = UNINIT; h5.rx_state = START; @@ -751,7 +744,7 @@ static void h5_init(void) static int h5_open(void) { - BT_DBG(""); + LOG_DBG(""); uart_irq_rx_disable(h5_dev); uart_irq_tx_disable(h5_dev); diff --git a/drivers/bluetooth/hci/hci_b91.c b/drivers/bluetooth/hci/hci_b91.c index 156eacd8606..93061e20d80 100644 --- a/drivers/bluetooth/hci/hci_b91.c +++ b/drivers/bluetooth/hci/hci_b91.c @@ -4,15 +4,17 @@ * SPDX-License-Identifier: Apache-2.0 */ -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_hci_driver_b91 -#include "common/log.h" +#include #include #include #include +#define LOG_LEVEL CONFIG_BT_HCI_DRIVER_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_hci_driver_b91); + #define HCI_CMD 0x01 #define HCI_ACL 0x02 #define HCI_EVT 0x04 @@ -54,7 +56,7 @@ static struct net_buf *bt_b91_evt_recv(uint8_t *data, size_t len) size_t buf_tailroom; if (len < sizeof(hdr)) { - BT_ERR("Not enough data for event header"); + LOG_ERR("Not enough data for event header"); return NULL; } @@ -65,17 +67,17 @@ static struct net_buf *bt_b91_evt_recv(uint8_t *data, size_t len) len -= sizeof(hdr); if (len != hdr.len) { - BT_ERR("Event payload length is not correct"); + LOG_ERR("Event payload length is not correct"); return NULL; } - BT_DBG("len %u", hdr.len); + LOG_DBG("len %u", hdr.len); buf = bt_buf_get_evt(hdr.evt, discardable, K_NO_WAIT); if (!buf) { if (discardable) { - BT_DBG("Discardable buffer pool full, ignoring event"); + LOG_DBG("Discardable buffer pool full, ignoring event"); } else { - BT_ERR("No available event buffers!"); + LOG_ERR("No available event buffers!"); } return buf; } @@ -84,8 +86,7 @@ static struct net_buf *bt_b91_evt_recv(uint8_t *data, size_t len) buf_tailroom = net_buf_tailroom(buf); if (buf_tailroom < len) { - BT_ERR("Not enough space in buffer %zu/%zu", - len, buf_tailroom); + LOG_ERR("Not enough space in buffer %zu/%zu", len, buf_tailroom); net_buf_unref(buf); return NULL; } @@ -102,7 +103,7 @@ static struct net_buf *bt_b91_acl_recv(uint8_t *data, size_t len) size_t buf_tailroom; if (len < sizeof(hdr)) { - BT_ERR("Not enough data for ACL header"); + LOG_ERR("Not enough data for ACL header"); return NULL; } @@ -112,12 +113,12 @@ static struct net_buf *bt_b91_acl_recv(uint8_t *data, size_t len) data += sizeof(hdr); len -= sizeof(hdr); } else { - BT_ERR("No available ACL buffers!"); + LOG_ERR("No available ACL buffers!"); return NULL; } if (len != sys_le16_to_cpu(hdr.len)) { - BT_ERR("ACL payload length is not correct"); + LOG_ERR("ACL payload length is not correct"); net_buf_unref(buf); return NULL; } @@ -125,13 +126,12 @@ static struct net_buf *bt_b91_acl_recv(uint8_t *data, size_t len) net_buf_add_mem(buf, &hdr, sizeof(hdr)); buf_tailroom = net_buf_tailroom(buf); if (buf_tailroom < len) { - BT_ERR("Not enough space in buffer %zu/%zu", - len, buf_tailroom); + LOG_ERR("Not enough space in buffer %zu/%zu", len, buf_tailroom); net_buf_unref(buf); return NULL; } - BT_DBG("len %u", len); + LOG_DBG("len %u", len); net_buf_add_mem(buf, data, len); return buf; @@ -158,11 +158,11 @@ static void hci_b91_host_rcv_pkt(uint8_t *data, uint16_t len) default: buf = NULL; - BT_ERR("Unknown HCI type %u", pkt_indicator); + LOG_ERR("Unknown HCI type %u", pkt_indicator); } if (buf) { - BT_DBG("Calling bt_recv(%p)", buf); + LOG_DBG("Calling bt_recv(%p)", buf); bt_recv(buf); } } @@ -182,7 +182,7 @@ static int bt_b91_send(struct net_buf *buf) int err = 0; uint8_t type; - BT_DBG("buf %p type %u len %u", buf, bt_buf_get_type(buf), buf->len); + LOG_DBG("buf %p type %u len %u", buf, bt_buf_get_type(buf), buf->len); switch (bt_buf_get_type(buf)) { case BT_BUF_ACL_OUT: @@ -194,7 +194,7 @@ static int bt_b91_send(struct net_buf *buf) break; default: - BT_ERR("Unknown type %u", bt_buf_get_type(buf)); + LOG_ERR("Unknown type %u", bt_buf_get_type(buf)); goto done; } @@ -203,7 +203,7 @@ static int bt_b91_send(struct net_buf *buf) if (k_sem_take(&hci_send_sem, HCI_BT_B91_TIMEOUT) == 0) { b91_bt_host_send_packet(type, buf->data, buf->len); } else { - BT_ERR("Send packet timeout error"); + LOG_ERR("Send packet timeout error"); err = -ETIMEDOUT; } @@ -220,13 +220,13 @@ static int hci_b91_open(void) status = b91_bt_controller_init(); if (status) { - BT_ERR("Bluetooth controller init failed %d", status); + LOG_ERR("Bluetooth controller init failed %d", status); return status; } b91_bt_host_callback_register(&vhci_host_cb); - BT_DBG("B91 BT started"); + LOG_DBG("B91 BT started"); return 0; } diff --git a/drivers/bluetooth/hci/hci_esp32.c b/drivers/bluetooth/hci/hci_esp32.c index 93adac26016..cf7045bcd9b 100644 --- a/drivers/bluetooth/hci/hci_esp32.c +++ b/drivers/bluetooth/hci/hci_esp32.c @@ -4,9 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_hci_driver_esp32 -#include "common/log.h" +#include #include #include @@ -15,6 +13,10 @@ #include +#define LOG_LEVEL CONFIG_BT_HCI_DRIVER_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_hci_driver_esp32); + #define HCI_CMD 0x01 #define HCI_ACL 0x02 #define HCI_SCO 0x03 @@ -58,7 +60,7 @@ static struct net_buf *bt_esp_evt_recv(uint8_t *data, size_t remaining) size_t buf_tailroom; if (remaining < sizeof(hdr)) { - BT_ERR("Not enough data for event header"); + LOG_ERR("Not enough data for event header"); return NULL; } @@ -69,17 +71,17 @@ static struct net_buf *bt_esp_evt_recv(uint8_t *data, size_t remaining) remaining -= sizeof(hdr); if (remaining != hdr.len) { - BT_ERR("Event payload length is not correct"); + LOG_ERR("Event payload length is not correct"); return NULL; } - BT_DBG("len %u", hdr.len); + LOG_DBG("len %u", hdr.len); buf = bt_buf_get_evt(hdr.evt, discardable, K_NO_WAIT); if (!buf) { if (discardable) { - BT_DBG("Discardable buffer pool full, ignoring event"); + LOG_DBG("Discardable buffer pool full, ignoring event"); } else { - BT_ERR("No available event buffers!"); + LOG_ERR("No available event buffers!"); } return buf; } @@ -88,8 +90,7 @@ static struct net_buf *bt_esp_evt_recv(uint8_t *data, size_t remaining) buf_tailroom = net_buf_tailroom(buf); if (buf_tailroom < remaining) { - BT_ERR("Not enough space in buffer %zu/%zu", - remaining, buf_tailroom); + LOG_ERR("Not enough space in buffer %zu/%zu", remaining, buf_tailroom); net_buf_unref(buf); return NULL; } @@ -106,7 +107,7 @@ static struct net_buf *bt_esp_acl_recv(uint8_t *data, size_t remaining) size_t buf_tailroom; if (remaining < sizeof(hdr)) { - BT_ERR("Not enough data for ACL header"); + LOG_ERR("Not enough data for ACL header"); return NULL; } @@ -118,25 +119,24 @@ static struct net_buf *bt_esp_acl_recv(uint8_t *data, size_t remaining) net_buf_add_mem(buf, &hdr, sizeof(hdr)); } else { - BT_ERR("No available ACL buffers!"); + LOG_ERR("No available ACL buffers!"); return NULL; } if (remaining != sys_le16_to_cpu(hdr.len)) { - BT_ERR("ACL payload length is not correct"); + LOG_ERR("ACL payload length is not correct"); net_buf_unref(buf); return NULL; } buf_tailroom = net_buf_tailroom(buf); if (buf_tailroom < remaining) { - BT_ERR("Not enough space in buffer %zu/%zu", - remaining, buf_tailroom); + LOG_ERR("Not enough space in buffer %zu/%zu", remaining, buf_tailroom); net_buf_unref(buf); return NULL; } - BT_DBG("len %u", remaining); + LOG_DBG("len %u", remaining); net_buf_add_mem(buf, data, remaining); return buf; @@ -149,7 +149,7 @@ static struct net_buf *bt_esp_iso_recv(uint8_t *data, size_t remaining) size_t buf_tailroom; if (remaining < sizeof(hdr)) { - BT_ERR("Not enough data for ISO header"); + LOG_ERR("Not enough data for ISO header"); return NULL; } @@ -161,25 +161,24 @@ static struct net_buf *bt_esp_iso_recv(uint8_t *data, size_t remaining) net_buf_add_mem(buf, &hdr, sizeof(hdr)); } else { - BT_ERR("No available ISO buffers!"); + LOG_ERR("No available ISO buffers!"); return NULL; } if (remaining != bt_iso_hdr_len(sys_le16_to_cpu(hdr.len))) { - BT_ERR("ISO payload length is not correct"); + LOG_ERR("ISO payload length is not correct"); net_buf_unref(buf); return NULL; } buf_tailroom = net_buf_tailroom(buf); if (buf_tailroom < remaining) { - BT_ERR("Not enough space in buffer %zu/%zu", - remaining, buf_tailroom); + LOG_ERR("Not enough space in buffer %zu/%zu", remaining, buf_tailroom); net_buf_unref(buf); return NULL; } - BT_DBG("len %zu", remaining); + LOG_DBG("len %zu", remaining); net_buf_add_mem(buf, data, remaining); return buf; @@ -210,12 +209,12 @@ static int hci_esp_host_rcv_pkt(uint8_t *data, uint16_t len) break; default: - BT_ERR("Unknown HCI type %u", pkt_indicator); + LOG_ERR("Unknown HCI type %u", pkt_indicator); return -1; } if (buf) { - BT_DBG("Calling bt_recv(%p)", buf); + LOG_DBG("Calling bt_recv(%p)", buf); bt_recv(buf); } @@ -238,7 +237,7 @@ static int bt_esp32_send(struct net_buf *buf) int err = 0; uint8_t pkt_indicator; - BT_DBG("buf %p type %u len %u", buf, bt_buf_get_type(buf), buf->len); + LOG_DBG("buf %p type %u len %u", buf, bt_buf_get_type(buf), buf->len); switch (bt_buf_get_type(buf)) { case BT_BUF_ACL_OUT: @@ -251,7 +250,7 @@ static int bt_esp32_send(struct net_buf *buf) pkt_indicator = HCI_ISO; break; default: - BT_ERR("Unknown type %u", bt_buf_get_type(buf)); + LOG_ERR("Unknown type %u", bt_buf_get_type(buf)); goto done; } net_buf_push_u8(buf, pkt_indicator); @@ -259,13 +258,13 @@ static int bt_esp32_send(struct net_buf *buf) LOG_HEXDUMP_DBG(buf->data, buf->len, "Final HCI buffer:"); if (!esp_vhci_host_check_send_available()) { - BT_WARN("Controller not ready to receive packets"); + LOG_WRN("Controller not ready to receive packets"); } if (k_sem_take(&hci_send_sem, HCI_BT_ESP32_TIMEOUT) == 0) { esp_vhci_host_send_packet(buf->data, buf->len); } else { - BT_ERR("Send packet timeout error"); + LOG_ERR("Send packet timeout error"); err = -ETIMEDOUT; } @@ -289,13 +288,13 @@ static int bt_esp32_ble_init(void) ret = esp_bt_controller_init(&bt_cfg); if (ret) { - BT_ERR("Bluetooth controller init failed %d", ret); + LOG_ERR("Bluetooth controller init failed %d", ret); return ret; } ret = esp_bt_controller_enable(mode); if (ret) { - BT_ERR("Bluetooth controller enable failed: %d", ret); + LOG_ERR("Bluetooth controller enable failed: %d", ret); return ret; } @@ -313,7 +312,7 @@ static int bt_esp32_open(void) return err; } - BT_DBG("ESP32 BT started"); + LOG_DBG("ESP32 BT started"); return 0; } diff --git a/drivers/bluetooth/hci/ipm_stm32wb.c b/drivers/bluetooth/hci/ipm_stm32wb.c index 95b08de9a63..beaae71fc8b 100644 --- a/drivers/bluetooth/hci/ipm_stm32wb.c +++ b/drivers/bluetooth/hci/ipm_stm32wb.c @@ -37,11 +37,12 @@ PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static uint8_t static void syscmd_status_not(SHCI_TL_CmdStatus_t status); static void sysevt_received(void *pdata); -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME hci_ipm -#include "common/log.h" #include "common/bt_str.h" +#define LOG_LEVEL CONFIG_BT_HCI_DRIVER_LOG_LEVEL +#include +LOG_MODULE_REGISTER(hci_ipm); + #define HCI_CMD 0x01 #define HCI_ACL 0x02 #define HCI_SCO 0x03 @@ -118,7 +119,7 @@ static void sysevt_received(void *pdata) static void syscmd_status_not(SHCI_TL_CmdStatus_t status) { - BT_DBG("status:%d", status); + LOG_DBG("status:%d", status); } /* @@ -144,7 +145,7 @@ static void tryfix_event(TL_Evt_t *tev) (void *)((uint8_t *)mev + (sizeof(*mev))); if (!bt_addr_cmp(&evt->peer_addr.a, BT_ADDR_NONE)) { - BT_WARN("Invalid peer addr %s", bt_addr_le_str(&evt->peer_addr)); + LOG_WRN("Invalid peer addr %s", bt_addr_le_str(&evt->peer_addr)); bt_addr_copy(&evt->peer_addr.a, &evt->peer_rpa); evt->peer_addr.type = BT_ADDR_LE_RANDOM; } @@ -174,13 +175,13 @@ static void bt_ipm_rx_thread(void) switch (hcievt->evtserial.type) { case HCI_EVT: - BT_DBG("EVT: hcievt->evtserial.evt.evtcode: 0x%02x", - hcievt->evtserial.evt.evtcode); + LOG_DBG("EVT: hcievt->evtserial.evt.evtcode: 0x%02x", + hcievt->evtserial.evt.evtcode); switch (hcievt->evtserial.evt.evtcode) { case BT_HCI_EVT_VENDOR: /* Vendor events are currently unsupported */ - BT_ERR("Unknown evtcode type 0x%02x", - hcievt->evtserial.evt.evtcode); + LOG_ERR("Unknown evtcode type 0x%02x", + hcievt->evtserial.evt.evtcode); TL_MM_EvtDone(hcievt); goto end_loop; default: @@ -195,7 +196,7 @@ static void bt_ipm_rx_thread(void) hcievt->evtserial.evt.evtcode, discardable, timeout); if (!buf) { - BT_DBG("Discard adv report due to insufficient buf"); + LOG_DBG("Discard adv report due to insufficient buf"); goto end_loop; } } @@ -205,8 +206,8 @@ static void bt_ipm_rx_thread(void) buf_tailroom = net_buf_tailroom(buf); buf_add_len = hcievt->evtserial.evt.plen + 2; if (buf_tailroom < buf_add_len) { - BT_ERR("Not enough space in buffer %zu/%zu", - buf_add_len, buf_tailroom); + LOG_ERR("Not enough space in buffer %zu/%zu", buf_add_len, + buf_tailroom); net_buf_unref(buf); goto end_loop; } @@ -219,15 +220,14 @@ static void bt_ipm_rx_thread(void) buf = bt_buf_get_rx(BT_BUF_ACL_IN, K_FOREVER); acl_hdr.handle = acl->handle; acl_hdr.len = acl->length; - BT_DBG("ACL: handle %x, len %x", - acl_hdr.handle, acl_hdr.len); + LOG_DBG("ACL: handle %x, len %x", acl_hdr.handle, acl_hdr.len); net_buf_add_mem(buf, &acl_hdr, sizeof(acl_hdr)); buf_tailroom = net_buf_tailroom(buf); buf_add_len = acl_hdr.len; if (buf_tailroom < buf_add_len) { - BT_ERR("Not enough space in buffer %zu/%zu", - buf_add_len, buf_tailroom); + LOG_ERR("Not enough space in buffer %zu/%zu", buf_add_len, + buf_tailroom); net_buf_unref(buf); goto end_loop; } @@ -236,8 +236,7 @@ static void bt_ipm_rx_thread(void) buf_add_len); break; default: - BT_ERR("Unknown BT buf type %d", - hcievt->evtserial.type); + LOG_ERR("Unknown BT buf type %d", hcievt->evtserial.type); TL_MM_EvtDone(hcievt); goto end_loop; } @@ -317,12 +316,12 @@ void transport_init(void) TL_BLE_InitConf_t tl_ble_config; SHCI_TL_HciInitConf_t shci_init_config; - BT_DBG("BleCmdBuffer: %p", (void *)&BleCmdBuffer); - BT_DBG("HciAclDataBuffer: %p", (void *)&HciAclDataBuffer); - BT_DBG("SystemCmdBuffer: %p", (void *)&SystemCmdBuffer); - BT_DBG("EvtPool: %p", (void *)&EvtPool); - BT_DBG("SystemSpareEvtBuffer: %p", (void *)&SystemSpareEvtBuffer); - BT_DBG("BleSpareEvtBuffer: %p", (void *)&BleSpareEvtBuffer); + LOG_DBG("BleCmdBuffer: %p", (void *)&BleCmdBuffer); + LOG_DBG("HciAclDataBuffer: %p", (void *)&HciAclDataBuffer); + LOG_DBG("SystemCmdBuffer: %p", (void *)&SystemCmdBuffer); + LOG_DBG("EvtPool: %p", (void *)&EvtPool); + LOG_DBG("SystemSpareEvtBuffer: %p", (void *)&SystemSpareEvtBuffer); + LOG_DBG("BleSpareEvtBuffer: %p", (void *)&BleSpareEvtBuffer); /**< Reference table initialization */ TL_Init(); @@ -357,8 +356,7 @@ static int bt_ipm_send(struct net_buf *buf) switch (bt_buf_get_type(buf)) { case BT_BUF_ACL_OUT: - BT_DBG("ACL: buf %p type %u len %u", buf, bt_buf_get_type(buf), - buf->len); + LOG_DBG("ACL: buf %p type %u len %u", buf, bt_buf_get_type(buf), buf->len); k_sem_take(&acl_data_ack, K_FOREVER); net_buf_push_u8(buf, HCI_ACL); memcpy((void *) @@ -367,8 +365,7 @@ static int bt_ipm_send(struct net_buf *buf) TL_BLE_SendAclData(NULL, 0); break; case BT_BUF_CMD: - BT_DBG("CMD: buf %p type %u len %u", buf, bt_buf_get_type(buf), - buf->len); + LOG_DBG("CMD: buf %p type %u len %u", buf, bt_buf_get_type(buf), buf->len); ble_cmd_buff->cmdserial.type = HCI_CMD; ble_cmd_buff->cmdserial.cmd.plen = buf->len; memcpy((void *)&ble_cmd_buff->cmdserial.cmd, buf->data, @@ -377,7 +374,7 @@ static int bt_ipm_send(struct net_buf *buf) break; default: k_sem_give(&ipm_busy); - BT_ERR("Unsupported type"); + LOG_ERR("Unsupported type"); return -EINVAL; } @@ -506,7 +503,7 @@ static int bt_ipm_ble_init(void) err = bt_ipm_set_addr(); if (err) { - BT_ERR("Can't set BLE UID addr"); + LOG_ERR("Can't set BLE UID addr"); } /* Send ACI_WRITE_SET_TX_POWER_LEVEL */ buf = bt_hci_cmd_create(ACI_WRITE_SET_TX_POWER_LEVEL, 3); @@ -541,7 +538,7 @@ static int c2_reset(void) if (k_sem_take(&c2_started, STM32WB_C2_LOCK_TIMEOUT)) { return -ETIMEDOUT; } - BT_DBG("C2 unlocked"); + LOG_DBG("C2 unlocked"); stm32wb_start_ble(); @@ -580,7 +577,7 @@ static int bt_ipm_open(void) } #endif /* CONFIG_BT_HCI_HOST */ - BT_DBG("IPM Channel Open Completed"); + LOG_DBG("IPM Channel Open Completed"); return 0; } @@ -593,7 +590,7 @@ static int bt_ipm_close(void) err = bt_hci_cmd_send_sync(ACI_HAL_STACK_RESET, NULL, &rsp); if (err) { - BT_ERR("IPM Channel Close Issue"); + LOG_ERR("IPM Channel Close Issue"); return err; } net_buf_unref(rsp); @@ -606,7 +603,7 @@ static int bt_ipm_close(void) k_thread_abort(&ipm_rx_thread_data); - BT_DBG("IPM Channel Close Completed"); + LOG_DBG("IPM Channel Close Completed"); return err; } diff --git a/drivers/bluetooth/hci/rpmsg.c b/drivers/bluetooth/hci/rpmsg.c index 4c3bcde6c3a..3898e570821 100644 --- a/drivers/bluetooth/hci/rpmsg.c +++ b/drivers/bluetooth/hci/rpmsg.c @@ -14,9 +14,9 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_hci_driver -#include "common/log.h" +#define LOG_LEVEL CONFIG_BT_HCI_DRIVER_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_hci_driver); #define RPMSG_CMD 0x01 #define RPMSG_ACL 0x02 @@ -73,7 +73,7 @@ static struct net_buf *bt_rpmsg_evt_recv(const uint8_t *data, size_t remaining) size_t buf_tailroom; if (remaining < sizeof(hdr)) { - BT_ERR("Not enough data for event header"); + LOG_ERR("Not enough data for event header"); return NULL; } @@ -84,19 +84,19 @@ static struct net_buf *bt_rpmsg_evt_recv(const uint8_t *data, size_t remaining) remaining -= sizeof(hdr); if (remaining != hdr.len) { - BT_ERR("Event payload length is not correct"); + LOG_ERR("Event payload length is not correct"); return NULL; } - BT_DBG("len %u", hdr.len); + LOG_DBG("len %u", hdr.len); do { buf = bt_buf_get_evt(hdr.evt, discardable, discardable ? K_NO_WAIT : K_SECONDS(10)); if (!buf) { if (discardable) { - BT_DBG("Discardable buffer pool full, ignoring event"); + LOG_DBG("Discardable buffer pool full, ignoring event"); return buf; } - BT_WARN("Couldn't allocate a buffer after waiting 10 seconds."); + LOG_WRN("Couldn't allocate a buffer after waiting 10 seconds."); } } while (!buf); @@ -104,8 +104,7 @@ static struct net_buf *bt_rpmsg_evt_recv(const uint8_t *data, size_t remaining) buf_tailroom = net_buf_tailroom(buf); if (buf_tailroom < remaining) { - BT_ERR("Not enough space in buffer %zu/%zu", - remaining, buf_tailroom); + LOG_ERR("Not enough space in buffer %zu/%zu", remaining, buf_tailroom); net_buf_unref(buf); return NULL; } @@ -122,7 +121,7 @@ static struct net_buf *bt_rpmsg_acl_recv(const uint8_t *data, size_t remaining) size_t buf_tailroom; if (remaining < sizeof(hdr)) { - BT_ERR("Not enough data for ACL header"); + LOG_ERR("Not enough data for ACL header"); return NULL; } @@ -134,25 +133,24 @@ static struct net_buf *bt_rpmsg_acl_recv(const uint8_t *data, size_t remaining) net_buf_add_mem(buf, &hdr, sizeof(hdr)); } else { - BT_ERR("No available ACL buffers!"); + LOG_ERR("No available ACL buffers!"); return NULL; } if (remaining != sys_le16_to_cpu(hdr.len)) { - BT_ERR("ACL payload length is not correct"); + LOG_ERR("ACL payload length is not correct"); net_buf_unref(buf); return NULL; } buf_tailroom = net_buf_tailroom(buf); if (buf_tailroom < remaining) { - BT_ERR("Not enough space in buffer %zu/%zu", - remaining, buf_tailroom); + LOG_ERR("Not enough space in buffer %zu/%zu", remaining, buf_tailroom); net_buf_unref(buf); return NULL; } - BT_DBG("len %u", remaining); + LOG_DBG("len %u", remaining); net_buf_add_mem(buf, data, remaining); return buf; @@ -165,7 +163,7 @@ static struct net_buf *bt_rpmsg_iso_recv(const uint8_t *data, size_t remaining) size_t buf_tailroom; if (remaining < sizeof(hdr)) { - BT_ERR("Not enough data for ISO header"); + LOG_ERR("Not enough data for ISO header"); return NULL; } @@ -177,25 +175,24 @@ static struct net_buf *bt_rpmsg_iso_recv(const uint8_t *data, size_t remaining) net_buf_add_mem(buf, &hdr, sizeof(hdr)); } else { - BT_ERR("No available ISO buffers!"); + LOG_ERR("No available ISO buffers!"); return NULL; } if (remaining != bt_iso_hdr_len(sys_le16_to_cpu(hdr.len))) { - BT_ERR("ISO payload length is not correct"); + LOG_ERR("ISO payload length is not correct"); net_buf_unref(buf); return NULL; } buf_tailroom = net_buf_tailroom(buf); if (buf_tailroom < remaining) { - BT_ERR("Not enough space in buffer %zu/%zu", - remaining, buf_tailroom); + LOG_ERR("Not enough space in buffer %zu/%zu", remaining, buf_tailroom); net_buf_unref(buf); return NULL; } - BT_DBG("len %zu", remaining); + LOG_DBG("len %zu", remaining); net_buf_add_mem(buf, data, remaining); return buf; @@ -226,12 +223,12 @@ static void bt_rpmsg_rx(const uint8_t *data, size_t len) break; default: - BT_ERR("Unknown HCI type %u", pkt_indicator); + LOG_ERR("Unknown HCI type %u", pkt_indicator); return; } if (buf) { - BT_DBG("Calling bt_recv(%p)", buf); + LOG_DBG("Calling bt_recv(%p)", buf); bt_recv(buf); @@ -244,7 +241,7 @@ static int bt_rpmsg_send(struct net_buf *buf) int err; uint8_t pkt_indicator; - BT_DBG("buf %p type %u len %u", buf, bt_buf_get_type(buf), buf->len); + LOG_DBG("buf %p type %u len %u", buf, bt_buf_get_type(buf), buf->len); switch (bt_buf_get_type(buf)) { case BT_BUF_ACL_OUT: @@ -257,7 +254,7 @@ static int bt_rpmsg_send(struct net_buf *buf) pkt_indicator = RPMSG_ISO; break; default: - BT_ERR("Unknown type %u", bt_buf_get_type(buf)); + LOG_ERR("Unknown type %u", bt_buf_get_type(buf)); goto done; } net_buf_push_u8(buf, pkt_indicator); @@ -265,7 +262,7 @@ static int bt_rpmsg_send(struct net_buf *buf) LOG_HEXDUMP_DBG(buf->data, buf->len, "Final HCI buffer:"); err = ipc_service_send(&hci_ept, buf->data, buf->len); if (err < 0) { - BT_ERR("Failed to send (err %d)", err); + LOG_ERR("Failed to send (err %d)", err); } done: @@ -297,23 +294,23 @@ static int bt_rpmsg_open(void) const struct device *hci_ipc_instance = DEVICE_DT_GET(DT_CHOSEN(zephyr_bt_hci_rpmsg_ipc)); - BT_DBG(""); + LOG_DBG(""); err = ipc_service_open_instance(hci_ipc_instance); if (err && (err != -EALREADY)) { - BT_ERR("IPC service instance initialization failed: %d\n", err); + LOG_ERR("IPC service instance initialization failed: %d\n", err); return err; } err = ipc_service_register_endpoint(hci_ipc_instance, &hci_ept, &hci_ept_cfg); if (err) { - BT_ERR("Registering endpoint failed with %d", err); + LOG_ERR("Registering endpoint failed with %d", err); return err; } err = k_sem_take(&ipc_bound_sem, IPC_BOUND_TIMEOUT_IN_MS); if (err) { - BT_ERR("Endpoint binding failed with %d", err); + LOG_ERR("Endpoint binding failed with %d", err); return err; } @@ -338,7 +335,7 @@ static int bt_rpmsg_init(const struct device *unused) err = bt_hci_driver_register(&drv); if (err < 0) { - BT_ERR("Failed to register BT HIC driver (err %d)", err); + LOG_ERR("Failed to register BT HIC driver (err %d)", err); } return err; diff --git a/drivers/bluetooth/hci/spi.c b/drivers/bluetooth/hci/spi.c index a8cd2269c16..9aa21dd3c08 100644 --- a/drivers/bluetooth/hci/spi.c +++ b/drivers/bluetooth/hci/spi.c @@ -17,9 +17,9 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_driver -#include "common/log.h" +#define LOG_LEVEL CONFIG_BT_HCI_DRIVER_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_driver); #define HCI_CMD 0x01 #define HCI_ACL 0x02 @@ -71,7 +71,7 @@ static K_SEM_DEFINE(sem_busy, 1, 1); static K_KERNEL_STACK_DEFINE(spi_rx_stack, 512); static struct k_thread spi_rx_thread_data; -#if defined(CONFIG_BT_DEBUG_HCI_DRIVER) +#if defined(CONFIG_BT_HCI_DRIVER_LOG_LEVEL_DBG) #include static inline void spi_dump_message(const uint8_t *pre, uint8_t *buf, uint8_t size) @@ -163,7 +163,7 @@ static void bt_spi_isr(const struct device *unused1, struct gpio_callback *unused2, uint32_t unused3) { - BT_DBG(""); + LOG_DBG(""); k_sem_give(&sem_request); } @@ -218,7 +218,7 @@ static bool irq_pin_high(void) pin_state = gpio_pin_get_dt(&irq_gpio); - BT_DBG("IRQ Pin: %d", pin_state); + LOG_DBG("IRQ Pin: %d", pin_state); return pin_state > 0; } @@ -293,7 +293,7 @@ static void bt_spi_rx_thread(void) gpio_pin_interrupt_configure_dt(&irq_gpio, GPIO_INT_DISABLE); k_sem_take(&sem_busy, K_FOREVER); - BT_DBG(""); + LOG_DBG(""); do { init_irq_high_loop(); @@ -321,7 +321,7 @@ static void bt_spi_rx_thread(void) if (ret || size == 0) { if (ret) { - BT_ERR("Error %d", ret); + LOG_ERR("Error %d", ret); } continue; } @@ -348,14 +348,15 @@ static void bt_spi_rx_thread(void) buf = bt_buf_get_evt(rxmsg[EVT_HEADER_EVENT], discardable, timeout); if (!buf) { - BT_DBG("Discard adv report due to insufficient buf"); + LOG_DBG("Discard adv report due to insufficient " + "buf"); continue; } } len = sizeof(struct bt_hci_evt_hdr) + rxmsg[EVT_HEADER_SIZE]; if (len > net_buf_tailroom(buf)) { - BT_ERR("Event too long: %d", len); + LOG_ERR("Event too long: %d", len); net_buf_unref(buf); continue; } @@ -366,14 +367,14 @@ static void bt_spi_rx_thread(void) memcpy(&acl_hdr, &rxmsg[1], sizeof(acl_hdr)); len = sizeof(acl_hdr) + sys_le16_to_cpu(acl_hdr.len); if (len > net_buf_tailroom(buf)) { - BT_ERR("ACL too long: %d", len); + LOG_ERR("ACL too long: %d", len); net_buf_unref(buf); continue; } net_buf_add_mem(buf, &rxmsg[1], len); break; default: - BT_ERR("Unknown BT buf type %d", rxmsg[0]); + LOG_ERR("Unknown BT buf type %d", rxmsg[0]); continue; } @@ -391,11 +392,11 @@ static int bt_spi_send(struct net_buf *buf) int pending; int ret; - BT_DBG(""); + LOG_DBG(""); /* Buffer needs an additional byte for type */ if (buf->len >= SPI_MAX_MSG_LEN) { - BT_ERR("Message too long"); + LOG_ERR("Message too long"); return -EINVAL; } @@ -418,7 +419,7 @@ static int bt_spi_send(struct net_buf *buf) net_buf_push_u8(buf, HCI_CMD); break; default: - BT_ERR("Unsupported type"); + LOG_ERR("Unsupported type"); k_sem_give(&sem_busy); return -EINVAL; } @@ -449,7 +450,7 @@ static int bt_spi_send(struct net_buf *buf) k_sem_give(&sem_busy); if (ret) { - BT_ERR("Error %d", ret); + LOG_ERR("Error %d", ret); goto out; } @@ -521,7 +522,7 @@ static int bt_spi_init(const struct device *unused) ARG_UNUSED(unused); if (!spi_is_ready(&bus)) { - BT_ERR("SPI device not ready"); + LOG_ERR("SPI device not ready"); return -ENODEV; } @@ -530,19 +531,19 @@ static int bt_spi_init(const struct device *unused) } if (!device_is_ready(irq_gpio.port)) { - BT_ERR("IRQ GPIO device not ready"); + LOG_ERR("IRQ GPIO device not ready"); return -ENODEV; } if (!device_is_ready(rst_gpio.port)) { - BT_ERR("Reset GPIO device not ready"); + LOG_ERR("Reset GPIO device not ready"); return -ENODEV; } bt_hci_driver_register(&drv); - BT_DBG("BT SPI initialized"); + LOG_DBG("BT SPI initialized"); return 0; } diff --git a/drivers/bluetooth/hci/userchan.c b/drivers/bluetooth/hci/userchan.c index fc9076053ca..2e6e0c1726c 100644 --- a/drivers/bluetooth/hci/userchan.c +++ b/drivers/bluetooth/hci/userchan.c @@ -28,9 +28,9 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_driver -#include "common/log.h" +#define LOG_LEVEL CONFIG_BT_HCI_DRIVER_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_driver); #define BTPROTO_HCI 1 struct sockaddr_hci { @@ -78,7 +78,7 @@ static struct net_buf *get_rx(const uint8_t *buf) } __fallthrough; default: - BT_ERR("Unknown packet type: %u", buf[0]); + LOG_ERR("Unknown packet type: %u", buf[0]); } return NULL; @@ -97,7 +97,7 @@ static void rx_thread(void *p1, void *p2, void *p3) ARG_UNUSED(p2); ARG_UNUSED(p3); - BT_DBG("started"); + LOG_DBG("started"); while (1) { static uint8_t frame[512]; @@ -111,7 +111,7 @@ static void rx_thread(void *p1, void *p2, void *p3) continue; } - BT_DBG("calling read()"); + LOG_DBG("calling read()"); len = read(uc_fd, frame, sizeof(frame)); if (len < 0) { @@ -120,7 +120,7 @@ static void rx_thread(void *p1, void *p2, void *p3) continue; } - BT_ERR("Reading socket failed, errno %d", errno); + LOG_ERR("Reading socket failed, errno %d", errno); close(uc_fd); uc_fd = -1; return; @@ -128,22 +128,21 @@ static void rx_thread(void *p1, void *p2, void *p3) buf = get_rx(frame); if (!buf) { - BT_DBG("Discard adv report due to insufficient buf"); + LOG_DBG("Discard adv report due to insufficient buf"); continue; } buf_tailroom = net_buf_tailroom(buf); buf_add_len = len - 1; if (buf_tailroom < buf_add_len) { - BT_ERR("Not enough space in buffer %zu/%zu", - buf_add_len, buf_tailroom); + LOG_ERR("Not enough space in buffer %zu/%zu", buf_add_len, buf_tailroom); net_buf_unref(buf); continue; } net_buf_add_mem(buf, &frame[1], buf_add_len); - BT_DBG("Calling bt_recv(%p)", buf); + LOG_DBG("Calling bt_recv(%p)", buf); bt_recv(buf); @@ -153,10 +152,10 @@ static void rx_thread(void *p1, void *p2, void *p3) static int uc_send(struct net_buf *buf) { - BT_DBG("buf %p type %u len %u", buf, bt_buf_get_type(buf), buf->len); + LOG_DBG("buf %p type %u len %u", buf, bt_buf_get_type(buf), buf->len); if (uc_fd < 0) { - BT_ERR("User channel not open"); + LOG_ERR("User channel not open"); return -EIO; } @@ -174,7 +173,7 @@ static int uc_send(struct net_buf *buf) } __fallthrough; default: - BT_ERR("Unknown buffer type"); + LOG_ERR("Unknown buffer type"); return -EINVAL; } @@ -215,18 +214,18 @@ static int user_chan_open(uint16_t index) static int uc_open(void) { if (bt_dev_index < 0) { - BT_ERR("No Bluetooth device specified"); + LOG_ERR("No Bluetooth device specified"); return -ENODEV; } - BT_DBG("hci%d", bt_dev_index); + LOG_DBG("hci%d", bt_dev_index); uc_fd = user_chan_open(bt_dev_index); if (uc_fd < 0) { return uc_fd; } - BT_DBG("User Channel opened as fd %d", uc_fd); + LOG_DBG("User Channel opened as fd %d", uc_fd); k_thread_create(&rx_thread_data, rx_thread_stack, K_KERNEL_STACK_SIZEOF(rx_thread_stack), @@ -234,7 +233,7 @@ static int uc_open(void) K_PRIO_COOP(CONFIG_BT_DRIVER_RX_HIGH_PRIO), 0, K_NO_WAIT); - BT_DBG("returning"); + LOG_DBG("returning"); return 0; } diff --git a/include/zephyr/bluetooth/audio/tbs.h b/include/zephyr/bluetooth/audio/tbs.h index 06b6c87e43c..cfe1374e115 100644 --- a/include/zephyr/bluetooth/audio/tbs.h +++ b/include/zephyr/bluetooth/audio/tbs.h @@ -326,10 +326,10 @@ int bt_tbs_set_uri_scheme_list(uint8_t bearer_index, const char **uri_list, */ void bt_tbs_register_cb(struct bt_tbs_cb *cbs); -#if defined(CONFIG_BT_DEBUG_TBS) +#if defined(CONFIG_BT_TBS_LOG_LEVEL_DBG) /** @brief Prints all calls of all services to the debug log */ void bt_tbs_dbg_print_calls(void); -#endif /* defined(CONFIG_BT_DEBUG_TBS) */ +#endif /* defined(CONFIG_BT_TBS_LOG_LEVEL_DBG) */ struct bt_tbs_client_call_state { uint8_t index; diff --git a/include/zephyr/bluetooth/services/ots.h b/include/zephyr/bluetooth/services/ots.h index 8fd6218584e..cfcb306e074 100644 --- a/include/zephyr/bluetooth/services/ots.h +++ b/include/zephyr/bluetooth/services/ots.h @@ -1074,7 +1074,7 @@ static inline int bt_ots_obj_id_to_str(uint64_t obj_id, char *str, size_t len) id[5], id[4], id[3], id[2], id[1], id[0]); } -/** @brief Displays one or more object metadata as text with BT_INFO. +/** @brief Displays one or more object metadata as text with LOG_INF. * * @param metadata Pointer to the first (or only) metadata in an array. * @param count Number of metadata objects to display information of. diff --git a/samples/bluetooth/hci_rpmsg/src/main.c b/samples/bluetooth/hci_rpmsg/src/main.c index 4da4822de38..7a5e28022ab 100644 --- a/samples/bluetooth/hci_rpmsg/src/main.c +++ b/samples/bluetooth/hci_rpmsg/src/main.c @@ -28,9 +28,9 @@ #include #endif /* CONFIG_BT_HCI_VS_FATAL_ERROR */ -#define BT_DBG_ENABLED 0 -#define LOG_MODULE_NAME hci_rpmsg -#include "common/log.h" +#include + +LOG_MODULE_REGISTER(hci_rpmsg, CONFIG_BT_LOG_LEVEL); static struct ipc_ept hci_ept; @@ -211,8 +211,7 @@ static void hci_rpmsg_send(struct net_buf *buf, bool is_fatal_err) uint8_t retries = 0; int ret; - LOG_DBG("buf %p type %u len %u", buf, bt_buf_get_type(buf), - buf->len); + LOG_DBG("buf %p type %u len %u", buf, bt_buf_get_type(buf), buf->len); LOG_HEXDUMP_DBG(buf->data, buf->len, "Controller buffer:"); diff --git a/samples/bluetooth/mesh/microbit_gatt.conf b/samples/bluetooth/mesh/microbit_gatt.conf index 0b345b36fc3..714dfb4969c 100644 --- a/samples/bluetooth/mesh/microbit_gatt.conf +++ b/samples/bluetooth/mesh/microbit_gatt.conf @@ -51,12 +51,12 @@ CONFIG_BT_MESH_LABEL_COUNT=0 #CONFIG_BT_DEBUG_MONITOR_UART=y #CONFIG_BT_DEBUG_LOG=y -#CONFIG_BT_MESH_DEBUG=y -#CONFIG_BT_MESH_DEBUG_NET=y -#CONFIG_BT_MESH_DEBUG_PROXY=y -#CONFIG_BT_MESH_DEBUG_TRANS=y -#CONFIG_BT_MESH_DEBUG_PROV=y -#CONFIG_BT_MESH_DEBUG_BEACON=y -#CONFIG_BT_MESH_DEBUG_CRYPTO=y -#CONFIG_BT_MESH_DEBUG_ADV=y -#CONFIG_BT_MESH_DEBUG_ACCESS=y +#CONFIG_BT_MESH_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_NET_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_PROXY_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_TRANS_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_BEACON_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_CRYPTO_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_ADV_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_ACCESS_LOG_LEVEL_DBG=y diff --git a/samples/bluetooth/mesh/nrf51_qfaa.conf b/samples/bluetooth/mesh/nrf51_qfaa.conf index b1decb8001f..acf3f6db4e6 100644 --- a/samples/bluetooth/mesh/nrf51_qfaa.conf +++ b/samples/bluetooth/mesh/nrf51_qfaa.conf @@ -39,11 +39,11 @@ CONFIG_BT_MESH_LABEL_COUNT=0 #CONFIG_BT_MESH_SELF_TEST=y #CONFIG_BT_MESH_IV_UPDATE_TEST=y -#CONFIG_BT_MESH_DEBUG=y -#CONFIG_BT_MESH_DEBUG_NET=y -#CONFIG_BT_MESH_DEBUG_TRANS=y -#CONFIG_BT_MESH_DEBUG_PROV=y -#CONFIG_BT_MESH_DEBUG_BEACON=y -#CONFIG_BT_MESH_DEBUG_CRYPTO=y -#CONFIG_BT_MESH_DEBUG_ADV=y -#CONFIG_BT_MESH_DEBUG_ACCESS=y +#CONFIG_BT_MESH_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_NET_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_TRANS_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_BEACON_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_CRYPTO_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_ADV_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_ACCESS_LOG_LEVEL_DBG=y diff --git a/samples/bluetooth/mesh/prj.conf b/samples/bluetooth/mesh/prj.conf index 2d3db993ab6..83a38ef3c89 100644 --- a/samples/bluetooth/mesh/prj.conf +++ b/samples/bluetooth/mesh/prj.conf @@ -41,5 +41,5 @@ CONFIG_BT_MESH_LABEL_COUNT=3 CONFIG_BT_DEBUG_LOG=y -CONFIG_BT_MESH_DEBUG=y -CONFIG_BT_MESH_DEBUG_MODEL=y +CONFIG_BT_MESH_LOG_LEVEL_DBG=y +CONFIG_BT_MESH_MODEL_LOG_LEVEL_DBG=y diff --git a/samples/bluetooth/mesh/prj_bbc_microbit.conf b/samples/bluetooth/mesh/prj_bbc_microbit.conf index 8b4af38759f..1ba4f2b4c02 100644 --- a/samples/bluetooth/mesh/prj_bbc_microbit.conf +++ b/samples/bluetooth/mesh/prj_bbc_microbit.conf @@ -54,11 +54,11 @@ CONFIG_BT_MESH_LABEL_COUNT=0 #CONFIG_BT_DEBUG_LOG=y -#CONFIG_BT_MESH_DEBUG=y -#CONFIG_BT_MESH_DEBUG_NET=y -#CONFIG_BT_MESH_DEBUG_TRANS=y -#CONFIG_BT_MESH_DEBUG_PROV=y -#CONFIG_BT_MESH_DEBUG_BEACON=y -#CONFIG_BT_MESH_DEBUG_CRYPTO=y -#CONFIG_BT_MESH_DEBUG_ADV=y -#CONFIG_BT_MESH_DEBUG_ACCESS=y +#CONFIG_BT_MESH_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_NET_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_TRANS_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_BEACON_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_CRYPTO_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_ADV_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_ACCESS_LOG_LEVEL_DBG=y diff --git a/samples/bluetooth/mesh_provisioner/prj.conf b/samples/bluetooth/mesh_provisioner/prj.conf index 8c8e88d224a..8e58221fe17 100644 --- a/samples/bluetooth/mesh_provisioner/prj.conf +++ b/samples/bluetooth/mesh_provisioner/prj.conf @@ -39,16 +39,16 @@ CONFIG_NVS=y CONFIG_SETTINGS=y CONFIG_BT_MESH_RPL_STORE_TIMEOUT=600 -#CONFIG_BT_MESH_DEBUG=y -#CONFIG_BT_MESH_DEBUG_SETTINGS=y -#CONFIG_BT_MESH_DEBUG_NET=y -#CONFIG_BT_MESH_DEBUG_MODEL=y -#CONFIG_BT_MESH_DEBUG_TRANS=y -#CONFIG_BT_MESH_DEBUG_ACCESS=y +#CONFIG_BT_MESH_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_SETTINGS_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_NET_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_MODEL_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_TRANS_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_ACCESS_LOG_LEVEL_DBG=y #CONFIG_BT_MESH_LOW_POWER=y -#CONFIG_BT_MESH_DEBUG_PROV=y -#CONFIG_BT_MESH_DEBUG_LOW_POWER=y -#CONFIG_BT_MESH_DEBUG_BEACON=y -#CONFIG_BT_MESH_DEBUG_CRYPTO=y -#CONFIG_BT_MESH_DEBUG_ADV=y +#CONFIG_BT_MESH_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_LOW_POWER_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_BEACON_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_CRYPTO_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_ADV_LOG_LEVEL_DBG=y diff --git a/samples/boards/nrf/mesh/onoff-app/prj.conf b/samples/boards/nrf/mesh/onoff-app/prj.conf index 4fce259d392..4f7a4649995 100644 --- a/samples/boards/nrf/mesh/onoff-app/prj.conf +++ b/samples/boards/nrf/mesh/onoff-app/prj.conf @@ -66,18 +66,18 @@ CONFIG_UART_CONSOLE=y CONFIG_BT_DEBUG_LOG=y -CONFIG_BT_MESH_DEBUG=y -#CONFIG_BT_MESH_DEBUG_PROV=y -#CONFIG_BT_MESH_DEBUG_PROXY=y -#CONFIG_BT_MESH_DEBUG_BEACON=y -#CONFIG_BT_MESH_DEBUG_NET=y -#CONFIG_BT_MESH_DEBUG_TRANS=y -#CONFIG_BT_MESH_DEBUG_LOW_POWER=y -#CONFIG_BT_MESH_DEBUG_FRIEND=y -#CONFIG_BT_MESH_DEBUG_MODEL=y -#CONFIG_BT_MESH_DEBUG_ACCESS=y -#CONFIG_BT_MESH_DEBUG_CRYPTO=y -#CONFIG_BT_MESH_DEBUG_ADV=y +CONFIG_BT_MESH_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_PROXY_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_BEACON_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_NET_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_TRANS_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_LOW_POWER_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_FRIEND_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_MODEL_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_ACCESS_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_CRYPTO_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_ADV_LOG_LEVEL_DBG=y #CONFIG_BT_MESH_SELF_TEST=y #CONFIG_BT_HCI_VS_EXT=n @@ -86,10 +86,10 @@ CONFIG_BT_MESH_DEBUG=y CONFIG_BT_RX_STACK_SIZE=4096 -#CONFIG_BT_DEBUG_HCI_DRIVER=y -#CONFIG_BT_DEBUG_HCI_CORE=y -#CONFIG_BT_DEBUG_GATT=y -#CONFIG_BT_DEBUG_CONN=y +#CONFIG_BT_HCI_DRIVER_LOG_LEVEL_DBG=y +#CONFIG_BT_HCI_CORE_LOG_LEVEL_DBG=y +#CONFIG_BT_GATT_LOG_LEVEL_DBG=y +#CONFIG_BT_CONN_LOG_LEVEL_DBG=y CONFIG_BT_MAX_CONN=1 CONFIG_BT_CTLR_RX_BUFFERS=6 diff --git a/samples/boards/nrf/mesh/onoff_level_lighting_vnd_app/prj.conf b/samples/boards/nrf/mesh/onoff_level_lighting_vnd_app/prj.conf index f94fc0a528b..832a600af84 100644 --- a/samples/boards/nrf/mesh/onoff_level_lighting_vnd_app/prj.conf +++ b/samples/boards/nrf/mesh/onoff_level_lighting_vnd_app/prj.conf @@ -61,24 +61,24 @@ CONFIG_BT_MESH_LABEL_COUNT=3 #CONFIG_BT_DEBUG_MONITOR_UART=y #CONFIG_BT_DEBUG_LOG=y -##CONFIG_BT_MESH_DEBUG=y -#CONFIG_BT_MESH_DEBUG_PROV=y -#CONFIG_BT_MESH_DEBUG_PROXY=y -#CONFIG_BT_MESH_DEBUG_BEACON=y -#CONFIG_BT_MESH_DEBUG_NET=y -#CONFIG_BT_MESH_DEBUG_TRANS=y -#CONFIG_BT_MESH_DEBUG_SETTINGS=y -#CONFIG_BT_MESH_DEBUG_LOW_POWER=y -#CONFIG_BT_MESH_DEBUG_FRIEND=y -#CONFIG_BT_MESH_DEBUG_MODEL=y -#CONFIG_BT_MESH_DEBUG_ACCESS=y -#CONFIG_BT_MESH_DEBUG_CRYPTO=y -#CONFIG_BT_MESH_DEBUG_ADV=y +##CONFIG_BT_MESH_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_PROXY_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_BEACON_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_NET_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_TRANS_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_SETTINGS_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_LOW_POWER_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_FRIEND_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_MODEL_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_ACCESS_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_CRYPTO_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_ADV_LOG_LEVEL_DBG=y #CONFIG_BT_MESH_SELF_TEST=y CONFIG_GPIO=y CONFIG_BT_CTLR_ADVANCED_FEATURES=y CONFIG_BT_HCI_TX_STACK_SIZE=1024 -#CONFIG_BT_DEBUG_HCI_CORE=y -#CONFIG_BT_DEBUG_HCI_DRIVER=y +#CONFIG_BT_HCI_CORE_LOG_LEVEL_DBG=y +#CONFIG_BT_HCI_DRIVER_LOG_LEVEL_DBG=y diff --git a/samples/boards/reel_board/mesh_badge/prj.conf b/samples/boards/reel_board/mesh_badge/prj.conf index 64307610314..5d470fa0f0d 100644 --- a/samples/boards/reel_board/mesh_badge/prj.conf +++ b/samples/boards/reel_board/mesh_badge/prj.conf @@ -13,9 +13,9 @@ CONFIG_BT_DEVICE_NAME="reel board" CONFIG_BT_DEVICE_NAME_MAX=32 CONFIG_BT_DEBUG_LOG=y -CONFIG_BT_MESH_DEBUG=y -#CONFIG_BT_DEBUG_HCI_CORE=y -#CONFIG_BT_MESH_DEBUG_ADV=y +CONFIG_BT_MESH_LOG_LEVEL_DBG=y +#CONFIG_BT_HCI_CORE_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_ADV_LOG_LEVEL_DBG=y CONFIG_BT_OBSERVER=y CONFIG_BT_BROADCASTER=y diff --git a/subsys/bluetooth/audio/Kconfig.aics b/subsys/bluetooth/audio/Kconfig.aics index f0e897968e8..5dcddd504ff 100644 --- a/subsys/bluetooth/audio/Kconfig.aics +++ b/subsys/bluetooth/audio/Kconfig.aics @@ -31,14 +31,21 @@ config BT_AICS_MAX_INPUT_DESCRIPTION_SIZE range 0 512 help This option sets the maximum input description size in octets. + ############# DEBUG ############# config BT_DEBUG_AICS bool "Audio Input Control Service debug" + select DEPRECATED help Use this option to enable Audio Input Control Service debug logs for the Bluetooth Audio functionality. +module = BT_AICS +legacy-debug-sym = BT_DEBUG_AICS +module-str = "Audio Input Control Service" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + endif # BT_AICS ##################### Audio Input Control Service Client ##################### @@ -58,15 +65,20 @@ config BT_AICS_CLIENT help This hidden option enables support for Audio Input Control Service. - if BT_AICS_CLIENT ############# DEBUG ############# config BT_DEBUG_AICS_CLIENT bool "Audio Input Control Service client debug" + select DEPRECATED help Use this option to enable Audio Input Control Service client debug logs for the Bluetooth Audio functionality. +module = BT_AICS_CLIENT +legacy-debug-sym = BT_DEBUG_AICS_CLIENT +module-str = "Audio Input Control Service client" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + endif # BT_AICS_CLIENT diff --git a/subsys/bluetooth/audio/Kconfig.baps b/subsys/bluetooth/audio/Kconfig.baps index 3721ea9d0e8..643ae5188c5 100644 --- a/subsys/bluetooth/audio/Kconfig.baps +++ b/subsys/bluetooth/audio/Kconfig.baps @@ -262,14 +262,20 @@ endif # BT_BAP_BROADCAST_ASSISTANT config BT_AUDIO_DEBUG_STREAM bool "Bluetooth Audio Stream debug" + select DEPRECATED depends on BT_AUDIO_STREAM help Use this option to enable Bluetooth Audio Stream debug logs for the Bluetooth Audio functionality. +module = BT_AUDIO_STREAM +legacy-debug-sym = BT_AUDIO_DEBUG_STREAM +module-str = "Bluetooth Audio Stream" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_AUDIO_DEBUG_STREAM_DATA bool "Bluetooth Audio Stream data debug" - depends on BT_AUDIO_DEBUG_STREAM + depends on BT_AUDIO_STREAM_LOG_LEVEL_DBG help Use this option to enable Bluetooth Audio Stream data debug logs for the Bluetooth Audio functionality. This will enable debug logs for all @@ -277,53 +283,95 @@ config BT_AUDIO_DEBUG_STREAM_DATA config BT_DEBUG_ASCS bool "Audio Stream Control Service debug" + select DEPRECATED depends on BT_ASCS help Use this option to enable Audio Stream Control Service debug logs for the Bluetooth Audio functionality. +module = BT_ASCS +legacy-debug-sym = BT_DEBUG_ASCS +module-str = "Audio Stream Control Service" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_AUDIO_DEBUG_UNICAST_SERVER bool "Bluetooth Audio Unicast Server debug" + select DEPRECATED depends on BT_AUDIO_UNICAST_SERVER help Use this option to enable Bluetooth Audio Unicast Server debug logs for the Bluetooth Audio functionality. +module = BT_AUDIO_UNICAST_SERVER +legacy-debug-sym = BT_AUDIO_DEBUG_UNICAST_SERVER +module-str = "Bluetooth Audio Unicast Server" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_AUDIO_DEBUG_UNICAST_CLIENT bool "Basic Audio Profile debug" + select DEPRECATED depends on BT_AUDIO_UNICAST_CLIENT help Use this option to enable Basic Audio Profile debug logs for the Bluetooth Audio functionality. +module = BT_AUDIO_UNICAST_CLIENT +legacy-debug-sym = BT_AUDIO_DEBUG_UNICAST_CLIENT +module-str = "Basic Audio Profile" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_AUDIO_DEBUG_BROADCAST_SOURCE bool "Bluetooth Audio Broadcast Source debug" + select DEPRECATED depends on BT_AUDIO_BROADCAST_SOURCE help Use this option to enable Bluetooth Audio Broadcast Source debug logs for the Bluetooth Audio functionality. +module = BT_AUDIO_BROADCAST_SOURCE +legacy-debug-sym = BT_AUDIO_DEBUG_BROADCAST_SOURCE +module-str = "Bluetooth Audio Broadcast Source" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_AUDIO_DEBUG_BROADCAST_SINK bool "Bluetooth Audio Broadcast Sink debug" + select DEPRECATED depends on BT_AUDIO_BROADCAST_SINK help Use this option to enable Bluetooth Audio Broadcast Sink debug logs for the Bluetooth Audio functionality. +module = BT_AUDIO_BROADCAST_SINK +legacy-debug-sym = BT_AUDIO_DEBUG_BROADCAST_SINK +module-str = "Bluetooth Audio Broadcast Sink" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_DEBUG_BAP_SCAN_DELEGATOR bool "Broadcast Audio Scan Service debug" + select DEPRECATED depends on BT_BAP_SCAN_DELEGATOR help Use this option to enable Broadcast Audio Scan Service debug logs for the Bluetooth Audio functionality. +module = BT_BAP_SCAN_DELEGATOR +legacy-debug-sym = BT_DEBUG_BAP_SCAN_DELEGATOR +module-str = "Broadcast Audio Scan Service" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_DEBUG_BAP_BROADCAST_ASSISTANT bool "Broadcast Audio Scan Service client debug" + select DEPRECATED depends on BT_BAP_BROADCAST_ASSISTANT help Use this option to enable Broadcast Audio Scan Service client debug logs for the Bluetooth Audio functionality. +module = BT_BAP_BROADCAST_ASSISTANT +legacy-debug-sym = BT_DEBUG_BAP_BROADCAST_ASSISTANT +module-str = "Broadcast Audio Scan Service client debug" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_AUDIO_STREAM # Virtual/hidden option bool diff --git a/subsys/bluetooth/audio/Kconfig.cap b/subsys/bluetooth/audio/Kconfig.cap index 316ac1a5cd1..7532391bd7d 100644 --- a/subsys/bluetooth/audio/Kconfig.cap +++ b/subsys/bluetooth/audio/Kconfig.cap @@ -28,11 +28,17 @@ config BT_CAP_ACCEPTOR_SET_MEMBER config BT_DEBUG_CAP_ACCEPTOR bool "Common Audio Profile debug" + select DEPRECATED depends on BT_CAP_ACCEPTOR help Use this option to enable CAP debug logs for the Bluetooth Audio functionality. +module = BT_CAP_ACCEPTOR +legacy-debug-sym = BT_DEBUG_CAP_ACCEPTOR +module-str = "Common Audio Profile" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_CAP_INITIATOR bool "Common Audio Profile Initiator Role Support [EXPERIMENTAL]" depends on (BT_AUDIO_UNICAST_CLIENT && BT_CSIP_SET_COORDINATOR) || BT_AUDIO_BROADCAST_SOURCE diff --git a/subsys/bluetooth/audio/Kconfig.csip b/subsys/bluetooth/audio/Kconfig.csip index a8a1b17ed25..c9004b211eb 100644 --- a/subsys/bluetooth/audio/Kconfig.csip +++ b/subsys/bluetooth/audio/Kconfig.csip @@ -51,10 +51,16 @@ config BT_CSIP_SET_MEMBER_MAX_INSTANCE_COUNT config BT_DEBUG_CSIP_SET_MEMBER bool "Coordinated Set Identification Service debug" + select DEPRECATED help Use this option to enable Coordinated Set Identification Service debug logs for the Bluetooth Audio functionality. +module = BT_CSIP_SET_MEMBER +legacy-debug-sym = BT_DEBUG_CSIP_SET_MEMBER +module-str = "Coordinated Set Identification Service" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + endif # BT_CSIP_SET_MEMBER #################### Coordinated Set Identification Client #################### @@ -99,15 +105,27 @@ config BT_CSIP_SET_COORDINATOR_ENC_SIRK_SUPPORT config BT_DEBUG_CSIP_SET_COORDINATOR bool "Coordinated Set Identification Profile Set Coordinator debug" + select DEPRECATED help Use this option to enable Coordinated Set Identification Profile Set Coordinator debug logs for the Bluetooth Audio functionality. +module = BT_CSIP_SET_COORDINATOR +legacy-debug-sym = BT_DEBUG_CSIP_SET_COORDINATOR +module-str = "Coordinated Set Identification Profile Set Coordinator" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + endif # BT_CSIP_SET_COORDINATOR config BT_DEBUG_CSIP_SET_MEMBER_CRYPTO bool "Coordinated Set Identification Profile crypto functions debug" + select DEPRECATED depends on BT_CSIP_SET_COORDINATOR || BT_CSIP_SET_MEMBER help Use this option to enable Coordinated Set Identification Profile crypto functions debug logs for the Bluetooth Audio functionality. + +module = BT_CSIP_SET_MEMBER_CRYPTO +legacy-debug-sym = BT_DEBUG_CSIP_SET_MEMBER_CRYPTO +module-str = "Coordinated Set Identification Profile crypto functions" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" diff --git a/subsys/bluetooth/audio/Kconfig.has b/subsys/bluetooth/audio/Kconfig.has index 695bb78057d..5d2bff60da0 100644 --- a/subsys/bluetooth/audio/Kconfig.has +++ b/subsys/bluetooth/audio/Kconfig.has @@ -97,9 +97,15 @@ endif # BT_HAS_PRESET_SUPPORT config BT_DEBUG_HAS bool "Hearing Access Service debug" + select DEPRECATED help This option enables enables Hearing Access Service debug logs. +module = BT_HAS +legacy-debug-sym = BT_DEBUG_HAS +module-str = "Hearing Access Service" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + endif # BT_HAS config BT_HAS_CLIENT @@ -114,6 +120,12 @@ config BT_HAS_CLIENT config BT_DEBUG_HAS_CLIENT bool "Hearing Access Service Client debug" + select DEPRECATED depends on BT_HAS_CLIENT help This option enables enables Hearing Access Service Client debug logs. + +module = BT_HAS_CLIENT +legacy-debug-sym = BT_DEBUG_HAS_CLIENT +module-str = "Hearing Access Service Client" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" diff --git a/subsys/bluetooth/audio/Kconfig.mcs b/subsys/bluetooth/audio/Kconfig.mcs index ac918dc3b03..78c81db9038 100644 --- a/subsys/bluetooth/audio/Kconfig.mcs +++ b/subsys/bluetooth/audio/Kconfig.mcs @@ -21,10 +21,16 @@ if BT_MCS config BT_DEBUG_MCS bool "Media Control Service debug" + select DEPRECATED help Use this option to enable Media Control Service debug logs for the Bluetooth Audio functionality. +module = BT_MCS +legacy-debug-sym = BT_DEBUG_MCS +module-str = "Media Control Service" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + endif # BT_MCS #### Media Control Client ################################ @@ -134,8 +140,14 @@ config BT_MCC_SHELL config BT_DEBUG_MCC bool "Media Control Client debug" + select DEPRECATED help Use this option to enable Media Control Client debug logs for the Bluetooth Audio functionality. +module = BT_MCC +legacy-debug-sym = BT_DEBUG_MCC +module-str = "Media Control Client" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + endif # BT_MCC diff --git a/subsys/bluetooth/audio/Kconfig.mctl b/subsys/bluetooth/audio/Kconfig.mctl index ff2ab3c134f..ed4a56f26b7 100644 --- a/subsys/bluetooth/audio/Kconfig.mctl +++ b/subsys/bluetooth/audio/Kconfig.mctl @@ -59,7 +59,13 @@ config MCTL_REMOTE_PLAYER_CONTROL_OBJECTS config MCTL_DEBUG bool "Media control debug" + select DEPRECATED help Use this option to enable Media control debug logs +module = MCTL +legacy-debug-sym = MCTL_DEBUG +module-str = "Media control" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + endif # MCTL diff --git a/subsys/bluetooth/audio/Kconfig.micp b/subsys/bluetooth/audio/Kconfig.micp index 58ef8f035ec..bebfbd10fc6 100644 --- a/subsys/bluetooth/audio/Kconfig.micp +++ b/subsys/bluetooth/audio/Kconfig.micp @@ -37,10 +37,16 @@ config BT_MICP_MIC_DEV_AICS config BT_DEBUG_MICP_MIC_DEV bool "Microphone Input Control Profile Microphone Device debug" + select DEPRECATED help Use this option to enable Microphone Input Control Profile Microphone Device debug logs for the Bluetooth Audio functionality. +module = BT_MICP_MIC_DEV +legacy-debug-sym = BT_DEBUG_MICP_MIC_DEV +module-str = "Microphone Input Control Profile Microphone Device" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + endif # BT_MICP_MIC_DEV ########### Microphone Input Control Profile Microphone Controller ########### @@ -75,8 +81,14 @@ config BT_MICP_MIC_CTLR_AICS config BT_DEBUG_MICP_MIC_CTLR bool "Microphone Input Control Profile Microphone Controller debug" + select DEPRECATED help Use this option to enable Microphone Input Control Profile Microphone Controller debug logs for the Bluetooth Audio functionality. +module = BT_MICP_MIC_CTLR +legacy-debug-sym = BT_DEBUG_MICP_MIC_CTLR +module-str = "Microphone Input Control Profile Microphone Controller" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + endif # BT_MICP_MIC_CTLR diff --git a/subsys/bluetooth/audio/Kconfig.mpl b/subsys/bluetooth/audio/Kconfig.mpl index 5e5e3179d92..43d09c11bb1 100644 --- a/subsys/bluetooth/audio/Kconfig.mpl +++ b/subsys/bluetooth/audio/Kconfig.mpl @@ -109,7 +109,13 @@ endif # BT_MPL_OBJECTS config BT_DEBUG_MPL bool "Media player debug" + select DEPRECATED help Enables debug logs for the media player +module = BT_MPL +legacy-debug-sym = BT_DEBUG_MPL +module-str = "Media player" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + endif # BT_MPL diff --git a/subsys/bluetooth/audio/Kconfig.pacs b/subsys/bluetooth/audio/Kconfig.pacs index db822ce9585..af95e2122bc 100644 --- a/subsys/bluetooth/audio/Kconfig.pacs +++ b/subsys/bluetooth/audio/Kconfig.pacs @@ -90,9 +90,15 @@ config BT_PACS config BT_DEBUG_PACS bool "Published Audio Capabilities Service debug" + select DEPRECATED depends on BT_PACS help Use this option to enable Published Audio Capabilities Service debug logs for the Bluetooth Audio functionality. +module = BT_PACS +legacy-debug-sym = BT_DEBUG_PACS +module-str = "Published Audio Capabilities Service" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + endmenu diff --git a/subsys/bluetooth/audio/Kconfig.tbs b/subsys/bluetooth/audio/Kconfig.tbs index 048f016dd43..cc9c093d0be 100644 --- a/subsys/bluetooth/audio/Kconfig.tbs +++ b/subsys/bluetooth/audio/Kconfig.tbs @@ -131,10 +131,16 @@ config BT_TBS_AUTHORIZATION config BT_DEBUG_TBS bool "Telephone Bearer Service debug" + select DEPRECATED help Use this option to enable Telephone Bearer Service debug logs for the Bluetooth Audio functionality. +module = BT_TBS +legacy-debug-sym = BT_DEBUG_TBS +module-str = "Telephone Bearer Service" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + endif # BT_TBS @@ -320,10 +326,16 @@ config BT_TBS_CLIENT_CALL_FRIENDLY_NAME config BT_DEBUG_TBS_CLIENT bool "Telephone Bearer Service client debug" + select DEPRECATED help Use this option to enable Telephone Bearer Service client debug logs for the Bluetooth Audio functionality. +module = BT_TBS_CLIENT +legacy-debug-sym = BT_DEBUG_TBS_CLIENT +module-str = "Telephone Bearer Service client" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + endif # BT_TBS_CLIENT if BT_TBS || BT_TBS_CLIENT diff --git a/subsys/bluetooth/audio/Kconfig.vcs b/subsys/bluetooth/audio/Kconfig.vcs index 09f4bcac7c3..bb1ae6e89fe 100644 --- a/subsys/bluetooth/audio/Kconfig.vcs +++ b/subsys/bluetooth/audio/Kconfig.vcs @@ -49,10 +49,16 @@ config BT_VCS_AICS config BT_DEBUG_VCS bool "Volume Control Service debug" + select DEPRECATED help Use this option to enable Volume Control Service debug logs for the Bluetooth Audio functionality. +module = BT_VCS +legacy-debug-sym = BT_DEBUG_VCS +module-str = "Volume Control Service" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + endif # BT_VCS ##################### Volume Control Profile Client ##################### @@ -101,8 +107,14 @@ config BT_VCS_CLIENT_AICS config BT_DEBUG_VCS_CLIENT bool "Volume Control Profile debug" + select DEPRECATED help Use this option to enable Volume Control Profile debug logs for the Bluetooth Audio functionality. +module = BT_VCS_CLIENT +legacy-debug-sym = BT_DEBUG_VCS_CLIENT +module-str = "Volume Control Profile" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + endif # BT_VCS_CLIENT diff --git a/subsys/bluetooth/audio/Kconfig.vocs b/subsys/bluetooth/audio/Kconfig.vocs index 5f29aa8a019..55d4075fb8b 100644 --- a/subsys/bluetooth/audio/Kconfig.vocs +++ b/subsys/bluetooth/audio/Kconfig.vocs @@ -35,10 +35,16 @@ config BT_VOCS_MAX_OUTPUT_DESCRIPTION_SIZE config BT_DEBUG_VOCS bool "Volume Offset Control Service debug" + select DEPRECATED help Use this option to enable Volume Offset Control Service debug logs for the Bluetooth Audio functionality. +module = BT_VOCS +legacy-debug-sym = BT_DEBUG_VOCS +module-str = "Volume Offset Control Service" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + endif # BT_VOCS ##################### Volume Offset Control Service Client ##################### @@ -58,15 +64,20 @@ config BT_VOCS_CLIENT help This hidden option enables support for Volume Offset Control Service. - if BT_VOCS_CLIENT ############# DEBUG ############# config BT_DEBUG_VOCS_CLIENT bool "Volume Offset Control Service client debug" + select DEPRECATED help Use this option to enable Volume Offset Control Service client debug logs for the Bluetooth Audio functionality. +module = BT_VOCS_CLIENT +legacy-debug-sym = BT_DEBUG_VOCS_CLIENT +module-str = "Volume Offset Control Service client" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + endif # BT_VOCS_CLIENT diff --git a/subsys/bluetooth/audio/aics.c b/subsys/bluetooth/audio/aics.c index 68560e100ff..bdbc9a9542f 100644 --- a/subsys/bluetooth/audio/aics.c +++ b/subsys/bluetooth/audio/aics.c @@ -20,9 +20,9 @@ #include "aics_internal.h" #include "audio_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_AICS) -#define LOG_MODULE_NAME bt_aics -#include "common/log.h" +#define LOG_LEVEL CONFIG_BT_AICS_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_aics); #define VALID_AICS_OPCODE(opcode) \ ((opcode) >= BT_AICS_OPCODE_SET_GAIN && (opcode) <= BT_AICS_OPCODE_SET_AUTO) @@ -105,7 +105,7 @@ BT_GATT_SERVICE_INSTANCE_DEFINE(aics_service_list, aics_insts, static void aics_state_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("value 0x%04x", value); + LOG_DBG("value 0x%04x", value); } static ssize_t read_aics_state(struct bt_conn *conn, @@ -114,9 +114,8 @@ static ssize_t read_aics_state(struct bt_conn *conn, { struct bt_aics *inst = BT_AUDIO_CHRC_USER_DATA(attr); - BT_DBG("gain %d, mute %u, gain_mode %u, counter %u", - inst->srv.state.gain, inst->srv.state.mute, - inst->srv.state.gain_mode, inst->srv.state.change_counter); + LOG_DBG("gain %d, mute %u, gain_mode %u, counter %u", inst->srv.state.gain, + inst->srv.state.mute, inst->srv.state.gain_mode, inst->srv.state.change_counter); return bt_gatt_attr_read(conn, attr, buf, len, offset, &inst->srv.state, sizeof(inst->srv.state)); @@ -128,9 +127,8 @@ static ssize_t read_aics_gain_settings(struct bt_conn *conn, { struct bt_aics *inst = BT_AUDIO_CHRC_USER_DATA(attr); - BT_DBG("units %u, min %d, max %d", - inst->srv.gain_settings.units, inst->srv.gain_settings.minimum, - inst->srv.gain_settings.maximum); + LOG_DBG("units %u, min %d, max %d", inst->srv.gain_settings.units, + inst->srv.gain_settings.minimum, inst->srv.gain_settings.maximum); return bt_gatt_attr_read(conn, attr, buf, len, offset, &inst->srv.gain_settings, @@ -142,7 +140,7 @@ static ssize_t read_type(struct bt_conn *conn, const struct bt_gatt_attr *attr, { struct bt_aics *inst = BT_AUDIO_CHRC_USER_DATA(attr); - BT_DBG("%u", inst->srv.type); + LOG_DBG("%u", inst->srv.type); return bt_gatt_attr_read(conn, attr, buf, len, offset, &inst->srv.type, sizeof(inst->srv.type)); @@ -151,7 +149,7 @@ static ssize_t read_type(struct bt_conn *conn, const struct bt_gatt_attr *attr, static void aics_input_status_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("value 0x%04x", value); + LOG_DBG("value 0x%04x", value); } static ssize_t read_input_status(struct bt_conn *conn, @@ -160,7 +158,7 @@ static ssize_t read_input_status(struct bt_conn *conn, { struct bt_aics *inst = BT_AUDIO_CHRC_USER_DATA(attr); - BT_DBG("%u", inst->srv.status); + LOG_DBG("%u", inst->srv.status); return bt_gatt_attr_read(conn, attr, buf, len, offset, &inst->srv.status, sizeof(inst->srv.status)); @@ -187,7 +185,7 @@ static ssize_t write_aics_control(struct bt_conn *conn, /* Check opcode before length */ if (!VALID_AICS_OPCODE(cp->cp.opcode)) { - BT_DBG("Invalid opcode %u", cp->cp.opcode); + LOG_DBG("Invalid opcode %u", cp->cp.opcode); return BT_GATT_ERR(BT_AICS_ERR_OP_NOT_SUPPORTED); } @@ -197,14 +195,14 @@ static ssize_t write_aics_control(struct bt_conn *conn, return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } - BT_DBG("Opcode %u, counter %u", cp->cp.opcode, cp->cp.counter); + LOG_DBG("Opcode %u, counter %u", cp->cp.opcode, cp->cp.counter); if (cp->cp.counter != inst->srv.state.change_counter) { return BT_GATT_ERR(BT_AICS_ERR_INVALID_COUNTER); } switch (cp->cp.opcode) { case BT_AICS_OPCODE_SET_GAIN: - BT_DBG("Set gain %d", cp->gain_setting); + LOG_DBG("Set gain %d", cp->gain_setting); if (cp->gain_setting < inst->srv.gain_settings.minimum || cp->gain_setting > inst->srv.gain_settings.maximum) { return BT_GATT_ERR(BT_AICS_ERR_OUT_OF_RANGE); @@ -216,7 +214,7 @@ static ssize_t write_aics_control(struct bt_conn *conn, } break; case BT_AICS_OPCODE_UNMUTE: - BT_DBG("Unmute"); + LOG_DBG("Unmute"); if (inst->srv.state.mute == BT_AICS_STATE_MUTE_DISABLED) { return BT_GATT_ERR(BT_AICS_ERR_MUTE_DISABLED); } @@ -226,7 +224,7 @@ static ssize_t write_aics_control(struct bt_conn *conn, } break; case BT_AICS_OPCODE_MUTE: - BT_DBG("Mute"); + LOG_DBG("Mute"); if (inst->srv.state.mute == BT_AICS_STATE_MUTE_DISABLED) { return BT_GATT_ERR(BT_AICS_ERR_MUTE_DISABLED); } @@ -236,7 +234,7 @@ static ssize_t write_aics_control(struct bt_conn *conn, } break; case BT_AICS_OPCODE_SET_MANUAL: - BT_DBG("Set manual mode"); + LOG_DBG("Set manual mode"); if (BT_AICS_INPUT_MODE_IMMUTABLE(inst->srv.state.gain_mode)) { return BT_GATT_ERR(BT_AICS_ERR_GAIN_MODE_NOT_ALLOWED); } @@ -246,7 +244,7 @@ static ssize_t write_aics_control(struct bt_conn *conn, } break; case BT_AICS_OPCODE_SET_AUTO: - BT_DBG("Set automatic mode"); + LOG_DBG("Set automatic mode"); if (BT_AICS_INPUT_MODE_IMMUTABLE(inst->srv.state.gain_mode)) { return BT_GATT_ERR(BT_AICS_ERR_GAIN_MODE_NOT_ALLOWED); } @@ -262,9 +260,9 @@ static ssize_t write_aics_control(struct bt_conn *conn, if (notify) { inst->srv.state.change_counter++; - BT_DBG("New state: gain %d, mute %u, gain_mode %u, counter %u", - inst->srv.state.gain, inst->srv.state.mute, - inst->srv.state.gain_mode, inst->srv.state.change_counter); + LOG_DBG("New state: gain %d, mute %u, gain_mode %u, counter %u", + inst->srv.state.gain, inst->srv.state.mute, inst->srv.state.gain_mode, + inst->srv.state.change_counter); bt_gatt_notify_uuid(NULL, BT_UUID_AICS_STATE, inst->srv.service_p->attrs, &inst->srv.state, @@ -275,7 +273,7 @@ static ssize_t write_aics_control(struct bt_conn *conn, inst->srv.state.mute, inst->srv.state.gain_mode); } else { - BT_DBG("Callback not registered for instance %p", inst); + LOG_DBG("Callback not registered for instance %p", inst); } } @@ -286,7 +284,7 @@ static ssize_t write_aics_control(struct bt_conn *conn, static void aics_description_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("value 0x%04x", value); + LOG_DBG("value 0x%04x", value); } #endif /* CONFIG_BT_AICS */ @@ -298,8 +296,8 @@ static ssize_t write_description(struct bt_conn *conn, struct bt_aics *inst = BT_AUDIO_CHRC_USER_DATA(attr); if (len >= sizeof(inst->srv.description)) { - BT_DBG("Output desc was clipped from length %u to %zu", - len, sizeof(inst->srv.description) - 1); + LOG_DBG("Output desc was clipped from length %u to %zu", len, + sizeof(inst->srv.description) - 1); /* We just clip the string value if it's too long */ len = (uint16_t)sizeof(inst->srv.description) - 1; } @@ -316,11 +314,11 @@ static ssize_t write_description(struct bt_conn *conn, inst->srv.cb->description(inst, 0, inst->srv.description); } else { - BT_DBG("Callback not registered for instance %p", inst); + LOG_DBG("Callback not registered for instance %p", inst); } } - BT_DBG("%s", inst->srv.description); + LOG_DBG("%s", inst->srv.description); return len; } @@ -355,7 +353,7 @@ static ssize_t read_description(struct bt_conn *conn, { struct bt_aics *inst = BT_AUDIO_CHRC_USER_DATA(attr); - BT_DBG("%s", inst->srv.description); + LOG_DBG("%s", inst->srv.description); return bt_gatt_attr_read(conn, attr, buf, len, offset, &inst->srv.description, strlen(inst->srv.description)); @@ -365,7 +363,7 @@ static ssize_t read_description(struct bt_conn *conn, void *bt_aics_svc_decl_get(struct bt_aics *aics) { CHECKIF(!aics) { - BT_DBG("NULL instance"); + LOG_DBG("NULL instance"); return NULL; } @@ -385,12 +383,12 @@ int bt_aics_register(struct bt_aics *aics, struct bt_aics_register_param *param) static bool instance_prepared; CHECKIF(!aics) { - BT_DBG("NULL aics pointer"); + LOG_DBG("NULL aics pointer"); return -ENOTCONN; } CHECKIF(!param) { - BT_DBG("NULL param"); + LOG_DBG("NULL param"); return -EINVAL; } @@ -404,33 +402,33 @@ int bt_aics_register(struct bt_aics *aics, struct bt_aics_register_param *param) } CHECKIF(param->mute > BT_AICS_STATE_MUTE_DISABLED) { - BT_DBG("Invalid AICS mute value: %u", param->mute); + LOG_DBG("Invalid AICS mute value: %u", param->mute); return -EINVAL; } CHECKIF(param->gain_mode > BT_AICS_MODE_AUTO) { - BT_DBG("Invalid AICS mode value: %u", param->gain_mode); + LOG_DBG("Invalid AICS mode value: %u", param->gain_mode); return -EINVAL; } CHECKIF(param->type > BT_AICS_INPUT_TYPE_STREAMING) { - BT_DBG("Invalid AICS input type value: %u", param->type); + LOG_DBG("Invalid AICS input type value: %u", param->type); return -EINVAL; } CHECKIF(param->units == 0) { - BT_DBG("AICS units value shall not be 0"); + LOG_DBG("AICS units value shall not be 0"); return -EINVAL; } CHECKIF(!(param->min_gain <= param->max_gain)) { - BT_DBG("AICS min gain (%d) shall be lower than or equal to max gain (%d)", - param->min_gain, param->max_gain); + LOG_DBG("AICS min gain (%d) shall be lower than or equal to max gain (%d)", + param->min_gain, param->max_gain); return -EINVAL; } CHECKIF(param->gain < param->min_gain || param->gain > param->max_gain) { - BT_DBG("AICS gain (%d) shall be not lower than min gain (%d) " + LOG_DBG("AICS gain (%d) shall be not lower than min gain (%d) " "or higher than max gain (%d)", param->gain, param->min_gain, param->max_gain); return -EINVAL; @@ -451,10 +449,9 @@ int bt_aics_register(struct bt_aics *aics, struct bt_aics_register_param *param) sizeof(aics->srv.description) - 1); /* strncpy may not always null-terminate */ aics->srv.description[sizeof(aics->srv.description) - 1] = '\0'; - if (IS_ENABLED(CONFIG_BT_DEBUG_AICS) && + if (IS_ENABLED(CONFIG_BT_AICS_LOG_LEVEL_DBG) && strcmp(aics->srv.description, param->description)) { - BT_DBG("Input desc clipped to %s", - aics->srv.description); + LOG_DBG("Input desc clipped to %s", aics->srv.description); } } @@ -486,7 +483,7 @@ int bt_aics_register(struct bt_aics *aics, struct bt_aics_register_param *param) err = bt_gatt_service_register(aics->srv.service_p); if (err) { - BT_DBG("Could not register AICS service"); + LOG_DBG("Could not register AICS service"); return err; } @@ -508,13 +505,13 @@ struct bt_aics *bt_aics_free_instance_get(void) int bt_aics_deactivate(struct bt_aics *inst) { CHECKIF(!inst) { - BT_DBG("NULL instance"); + LOG_DBG("NULL instance"); return -EINVAL; } if (inst->srv.status == BT_AICS_STATUS_ACTIVE) { inst->srv.status = BT_AICS_STATUS_INACTIVE; - BT_DBG("Instance %p: Status was set to inactive", inst); + LOG_DBG("Instance %p: Status was set to inactive", inst); bt_gatt_notify_uuid(NULL, BT_UUID_AICS_INPUT_STATUS, inst->srv.service_p->attrs, @@ -524,7 +521,7 @@ int bt_aics_deactivate(struct bt_aics *inst) if (inst->srv.cb && inst->srv.cb->status) { inst->srv.cb->status(inst, 0, inst->srv.status); } else { - BT_DBG("Callback not registered for instance %p", inst); + LOG_DBG("Callback not registered for instance %p", inst); } } @@ -534,13 +531,13 @@ int bt_aics_deactivate(struct bt_aics *inst) int bt_aics_activate(struct bt_aics *inst) { CHECKIF(!inst) { - BT_DBG("NULL instance"); + LOG_DBG("NULL instance"); return -EINVAL; } if (inst->srv.status == BT_AICS_STATUS_INACTIVE) { inst->srv.status = BT_AICS_STATUS_ACTIVE; - BT_DBG("Instance %p: Status was set to active", inst); + LOG_DBG("Instance %p: Status was set to active", inst); bt_gatt_notify_uuid(NULL, BT_UUID_AICS_INPUT_STATUS, inst->srv.service_p->attrs, @@ -550,7 +547,7 @@ int bt_aics_activate(struct bt_aics *inst) if (inst->srv.cb && inst->srv.cb->status) { inst->srv.cb->status(inst, 0, inst->srv.status); } else { - BT_DBG("Callback not registered for instance %p", inst); + LOG_DBG("Callback not registered for instance %p", inst); } } @@ -562,7 +559,7 @@ int bt_aics_activate(struct bt_aics *inst) int bt_aics_state_get(struct bt_aics *inst) { CHECKIF(!inst) { - BT_DBG("NULL instance"); + LOG_DBG("NULL instance"); return -EINVAL; } @@ -574,7 +571,7 @@ int bt_aics_state_get(struct bt_aics *inst) inst->srv.state.mute, inst->srv.state.gain_mode); } else { - BT_DBG("Callback not registered for instance %p", inst); + LOG_DBG("Callback not registered for instance %p", inst); } return 0; } @@ -585,7 +582,7 @@ int bt_aics_state_get(struct bt_aics *inst) int bt_aics_gain_setting_get(struct bt_aics *inst) { CHECKIF(!inst) { - BT_DBG("NULL instance"); + LOG_DBG("NULL instance"); return -EINVAL; } @@ -598,7 +595,7 @@ int bt_aics_gain_setting_get(struct bt_aics *inst) inst->srv.gain_settings.minimum, inst->srv.gain_settings.maximum); } else { - BT_DBG("Callback not registered for instance %p", inst); + LOG_DBG("Callback not registered for instance %p", inst); } return 0; } @@ -609,7 +606,7 @@ int bt_aics_gain_setting_get(struct bt_aics *inst) int bt_aics_type_get(struct bt_aics *inst) { CHECKIF(!inst) { - BT_DBG("NULL instance"); + LOG_DBG("NULL instance"); return -EINVAL; } @@ -619,7 +616,7 @@ int bt_aics_type_get(struct bt_aics *inst) if (inst->srv.cb && inst->srv.cb->type) { inst->srv.cb->type(inst, 0, inst->srv.type); } else { - BT_DBG("Callback not registered for instance %p", inst); + LOG_DBG("Callback not registered for instance %p", inst); } return 0; } @@ -630,7 +627,7 @@ int bt_aics_type_get(struct bt_aics *inst) int bt_aics_status_get(struct bt_aics *inst) { CHECKIF(!inst) { - BT_DBG("NULL instance"); + LOG_DBG("NULL instance"); return -EINVAL; } @@ -640,7 +637,7 @@ int bt_aics_status_get(struct bt_aics *inst) if (inst->srv.cb && inst->srv.cb->status) { inst->srv.cb->status(inst, 0, inst->srv.status); } else { - BT_DBG("Callback not registered for instance %p", inst); + LOG_DBG("Callback not registered for instance %p", inst); } return 0; } @@ -651,7 +648,7 @@ int bt_aics_status_get(struct bt_aics *inst) int bt_aics_unmute(struct bt_aics *inst) { CHECKIF(!inst) { - BT_DBG("NULL instance"); + LOG_DBG("NULL instance"); return -EINVAL; } @@ -672,7 +669,7 @@ int bt_aics_unmute(struct bt_aics *inst) int bt_aics_mute(struct bt_aics *inst) { CHECKIF(!inst) { - BT_DBG("NULL instance"); + LOG_DBG("NULL instance"); return -EINVAL; } @@ -693,7 +690,7 @@ int bt_aics_mute(struct bt_aics *inst) int bt_aics_manual_gain_set(struct bt_aics *inst) { CHECKIF(!inst) { - BT_DBG("NULL instance"); + LOG_DBG("NULL instance"); return -EINVAL; } @@ -714,7 +711,7 @@ int bt_aics_manual_gain_set(struct bt_aics *inst) int bt_aics_automatic_gain_set(struct bt_aics *inst) { CHECKIF(!inst) { - BT_DBG("NULL instance"); + LOG_DBG("NULL instance"); return -EINVAL; } @@ -735,7 +732,7 @@ int bt_aics_automatic_gain_set(struct bt_aics *inst) int bt_aics_gain_set(struct bt_aics *inst, int8_t gain) { CHECKIF(!inst) { - BT_DBG("NULL instance"); + LOG_DBG("NULL instance"); return -EINVAL; } @@ -757,7 +754,7 @@ int bt_aics_gain_set(struct bt_aics *inst, int8_t gain) int bt_aics_description_get(struct bt_aics *inst) { CHECKIF(!inst) { - BT_DBG("NULL instance"); + LOG_DBG("NULL instance"); return -EINVAL; } @@ -768,7 +765,7 @@ int bt_aics_description_get(struct bt_aics *inst) inst->srv.cb->description(inst, 0, inst->srv.description); } else { - BT_DBG("Callback not registered for instance %p", inst); + LOG_DBG("Callback not registered for instance %p", inst); } return 0; } @@ -779,12 +776,12 @@ int bt_aics_description_get(struct bt_aics *inst) int bt_aics_description_set(struct bt_aics *inst, const char *description) { CHECKIF(!inst) { - BT_DBG("NULL instance"); + LOG_DBG("NULL instance"); return -EINVAL; } CHECKIF(!description) { - BT_DBG("NULL description"); + LOG_DBG("NULL description"); return -EINVAL; } diff --git a/subsys/bluetooth/audio/aics_client.c b/subsys/bluetooth/audio/aics_client.c index 39e41a8d675..3f160ed0d13 100644 --- a/subsys/bluetooth/audio/aics_client.c +++ b/subsys/bluetooth/audio/aics_client.c @@ -23,9 +23,9 @@ #include "aics_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_AICS_CLIENT) -#define LOG_MODULE_NAME bt_aics_client -#include "common/log.h" +#include + +LOG_MODULE_REGISTER(bt_aics_client, CONFIG_BT_AICS_CLIENT_LOG_LEVEL); static struct bt_aics aics_insts[CONFIG_BT_MAX_CONN * CONFIG_BT_AICS_CLIENT_MAX_INSTANCE_COUNT]; @@ -42,7 +42,7 @@ static struct bt_aics *lookup_aics_by_handle(struct bt_conn *conn, uint16_t hand } } - BT_DBG("Could not find AICS instance with handle 0x%04x", handle); + LOG_DBG("Could not find AICS instance with handle 0x%04x", handle); return NULL; } @@ -62,7 +62,7 @@ uint8_t aics_client_notify_handler(struct bt_conn *conn, struct bt_gatt_subscrib inst = lookup_aics_by_handle(conn, handle); if (!inst) { - BT_DBG("Instance not found"); + LOG_DBG("Instance not found"); return BT_GATT_ITER_STOP; } @@ -73,9 +73,8 @@ uint8_t aics_client_notify_handler(struct bt_conn *conn, struct bt_gatt_subscrib if (handle == inst->cli.state_handle) { if (length == sizeof(*state)) { state = (struct bt_aics_state *)data; - BT_DBG("Inst %p: Gain %d, mute %u, gain_mode %u, counter %u", - inst, state->gain, state->mute, state->gain_mode, - state->change_counter); + LOG_DBG("Inst %p: Gain %d, mute %u, gain_mode %u, counter %u", inst, + state->gain, state->mute, state->gain_mode, state->change_counter); inst->cli.change_counter = state->change_counter; @@ -88,7 +87,7 @@ uint8_t aics_client_notify_handler(struct bt_conn *conn, struct bt_gatt_subscrib } else if (handle == inst->cli.status_handle) { if (length == sizeof(*status)) { status = (uint8_t *)data; - BT_DBG("Inst %p: Status %u", inst, *status); + LOG_DBG("Inst %p: Status %u", inst, *status); if (inst->cli.cb && inst->cli.cb->status) { inst->cli.cb->status(inst, 0, *status); } @@ -98,14 +97,14 @@ uint8_t aics_client_notify_handler(struct bt_conn *conn, struct bt_gatt_subscrib /* Truncate if too large */ if (length > sizeof(desc) - 1) { - BT_DBG("Description truncated from %u to %zu octets", - length, sizeof(desc) - 1); + LOG_DBG("Description truncated from %u to %zu octets", length, + sizeof(desc) - 1); } length = MIN(sizeof(desc) - 1, length); memcpy(desc, data, length); desc[length] = '\0'; - BT_DBG("Inst %p: Input description: %s", inst, desc); + LOG_DBG("Inst %p: Input description: %s", inst, desc); if (inst->cli.cb && inst->cli.cb->description) { inst->cli.cb->description(inst, 0, desc); } @@ -125,15 +124,15 @@ static uint8_t aics_client_read_state_cb(struct bt_conn *conn, uint8_t err, memset(params, 0, sizeof(*params)); if (!inst) { - BT_DBG("Instance not found"); + LOG_DBG("Instance not found"); return BT_GATT_ITER_STOP; } - BT_DBG("Inst %p: err: 0x%02X", inst, err); + LOG_DBG("Inst %p: err: 0x%02X", inst, err); inst->cli.busy = false; if (cb_err) { - BT_DBG("State read failed: %d", err); + LOG_DBG("State read failed: %d", err); if (inst->cli.cb && inst->cli.cb->state) { inst->cli.cb->state(inst, cb_err, 0, 0, 0); } @@ -142,18 +141,16 @@ static uint8_t aics_client_read_state_cb(struct bt_conn *conn, uint8_t err, if (data) { if (length == sizeof(*state)) { - BT_DBG("Gain %d, mute %u, gain_mode %u, counter %u", - state->gain, state->mute, state->gain_mode, - state->change_counter); + LOG_DBG("Gain %d, mute %u, gain_mode %u, counter %u", state->gain, + state->mute, state->gain_mode, state->change_counter); inst->cli.change_counter = state->change_counter; } else { - BT_DBG("Invalid length %u (expected %zu)", - length, sizeof(*state)); + LOG_DBG("Invalid length %u (expected %zu)", length, sizeof(*state)); cb_err = BT_ATT_ERR_INVALID_ATTRIBUTE_LEN; } } else { - BT_DBG("Invalid state"); + LOG_DBG("Invalid state"); cb_err = BT_ATT_ERR_UNLIKELY; } @@ -176,15 +173,15 @@ static uint8_t aics_client_read_gain_settings_cb(struct bt_conn *conn, uint8_t e memset(params, 0, sizeof(*params)); if (!inst) { - BT_DBG("Instance not found"); + LOG_DBG("Instance not found"); return BT_GATT_ITER_STOP; } - BT_DBG("Inst %p: err: 0x%02X", inst, err); + LOG_DBG("Inst %p: err: 0x%02X", inst, err); inst->cli.busy = false; if (cb_err) { - BT_DBG("Gain settings read failed: %d", err); + LOG_DBG("Gain settings read failed: %d", err); if (inst->cli.cb && inst->cli.cb->gain_setting) { inst->cli.cb->gain_setting(inst, cb_err, 0, 0, 0); } @@ -193,14 +190,14 @@ static uint8_t aics_client_read_gain_settings_cb(struct bt_conn *conn, uint8_t e if (data) { if (length == sizeof(*gain_settings)) { - BT_DBG("Units %u, Max %d, Min %d", gain_settings->units, - gain_settings->maximum, gain_settings->minimum); + LOG_DBG("Units %u, Max %d, Min %d", gain_settings->units, + gain_settings->maximum, gain_settings->minimum); } else { - BT_DBG("Invalid length %u (expected %zu)", length, sizeof(*gain_settings)); + LOG_DBG("Invalid length %u (expected %zu)", length, sizeof(*gain_settings)); cb_err = BT_ATT_ERR_INVALID_ATTRIBUTE_LEN; } } else { - BT_DBG("Invalid gain settings"); + LOG_DBG("Invalid gain settings"); cb_err = BT_ATT_ERR_UNLIKELY; } @@ -224,15 +221,15 @@ static uint8_t aics_client_read_type_cb(struct bt_conn *conn, uint8_t err, memset(params, 0, sizeof(*params)); if (!inst) { - BT_DBG("Instance not found"); + LOG_DBG("Instance not found"); return BT_GATT_ITER_STOP; } - BT_DBG("Inst %p: err: 0x%02X", inst, err); + LOG_DBG("Inst %p: err: 0x%02X", inst, err); inst->cli.busy = false; if (cb_err) { - BT_DBG("Type read failed: %d", err); + LOG_DBG("Type read failed: %d", err); if (inst->cli.cb && inst->cli.cb->type) { inst->cli.cb->type(inst, cb_err, 0); } @@ -241,13 +238,13 @@ static uint8_t aics_client_read_type_cb(struct bt_conn *conn, uint8_t err, if (data) { if (length == sizeof(*type)) { - BT_DBG("Type %u", *type); + LOG_DBG("Type %u", *type); } else { - BT_DBG("Invalid length %u (expected %zu)", length, sizeof(*type)); + LOG_DBG("Invalid length %u (expected %zu)", length, sizeof(*type)); cb_err = BT_ATT_ERR_INVALID_ATTRIBUTE_LEN; } } else { - BT_DBG("Invalid type"); + LOG_DBG("Invalid type"); cb_err = BT_ATT_ERR_UNLIKELY; } @@ -269,15 +266,15 @@ static uint8_t aics_client_read_status_cb(struct bt_conn *conn, uint8_t err, memset(params, 0, sizeof(*params)); if (!inst) { - BT_DBG("Instance not found"); + LOG_DBG("Instance not found"); return BT_GATT_ITER_STOP; } - BT_DBG("Inst %p: err: 0x%02X", inst, err); + LOG_DBG("Inst %p: err: 0x%02X", inst, err); inst->cli.busy = false; if (cb_err) { - BT_DBG("Status read failed: %d", err); + LOG_DBG("Status read failed: %d", err); if (inst->cli.cb && inst->cli.cb->status) { inst->cli.cb->status(inst, cb_err, 0); } @@ -286,13 +283,13 @@ static uint8_t aics_client_read_status_cb(struct bt_conn *conn, uint8_t err, if (data) { if (length == sizeof(*status)) { - BT_DBG("Status %u", *status); + LOG_DBG("Status %u", *status); } else { - BT_DBG("Invalid length %u (expected %zu)", length, sizeof(*status)); + LOG_DBG("Invalid length %u (expected %zu)", length, sizeof(*status)); cb_err = BT_ATT_ERR_INVALID_ATTRIBUTE_LEN; } } else { - BT_DBG("Invalid status"); + LOG_DBG("Invalid status"); cb_err = BT_ATT_ERR_UNLIKELY; } @@ -336,7 +333,7 @@ static void aics_cp_notify_app(struct bt_aics *inst, uint8_t err) } break; default: - BT_DBG("Unknown opcode 0x%02x", inst->cli.cp_val.cp.opcode); + LOG_DBG("Unknown opcode 0x%02x", inst->cli.cp_val.cp.opcode); break; } } @@ -352,19 +349,18 @@ static uint8_t internal_read_state_cb(struct bt_conn *conn, uint8_t err, memset(params, 0, sizeof(*params)); if (!inst) { - BT_ERR("Instance not found"); + LOG_ERR("Instance not found"); return BT_GATT_ITER_STOP; } if (err) { - BT_WARN("State read failed: %d", err); + LOG_WRN("State read failed: %d", err); } else if (data) { if (length == sizeof(*state)) { int write_err; - BT_DBG("Gain %d, mute %u, gain_mode %u, counter %u", - state->gain, state->mute, - state->gain_mode, state->change_counter); + LOG_DBG("Gain %d, mute %u, gain_mode %u, counter %u", state->gain, + state->mute, state->gain_mode, state->change_counter); inst->cli.change_counter = state->change_counter; /* clear busy flag to reuse function */ @@ -382,7 +378,7 @@ static uint8_t internal_read_state_cb(struct bt_conn *conn, uint8_t err, cb_err = BT_ATT_ERR_UNLIKELY; } } else { - BT_DBG("Invalid length %u (expected %zu)", length, sizeof(*state)); + LOG_DBG("Invalid length %u (expected %zu)", length, sizeof(*state)); cb_err = BT_ATT_ERR_UNLIKELY; } } @@ -405,11 +401,11 @@ static void aics_client_write_aics_cp_cb(struct bt_conn *conn, uint8_t err, memset(params, 0, sizeof(*params)); if (!inst) { - BT_DBG("Instance not found"); + LOG_DBG("Instance not found"); return; } - BT_DBG("Inst %p: err: %d", inst, cb_err); + LOG_DBG("Inst %p: err: %d", inst, cb_err); /* If the change counter is out of data when a write was attempted from * the application, we automatically initiate a read to get the newest @@ -428,7 +424,7 @@ static void aics_client_write_aics_cp_cb(struct bt_conn *conn, uint8_t err, cb_err = bt_gatt_read(conn, &inst->cli.read_params); if (cb_err) { - BT_WARN("Could not read state: %d", cb_err); + LOG_WRN("Could not read state: %d", cb_err); } else { inst->cli.cp_retried = true; /* Wait for read callback */ @@ -447,22 +443,22 @@ static int aics_client_common_control(uint8_t opcode, struct bt_aics *inst) int err; CHECKIF(!inst) { - BT_DBG("NULL instance"); + LOG_DBG("NULL instance"); return -EINVAL; } CHECKIF(!inst->client_instance) { - BT_DBG("Not a client instance instance"); + LOG_DBG("Not a client instance instance"); return -EINVAL; } CHECKIF(inst->cli.conn == NULL) { - BT_DBG("NULL conn"); + LOG_DBG("NULL conn"); return -EINVAL; } if (!inst->cli.control_handle) { - BT_DBG("Handle not set for opcode %u", opcode); + LOG_DBG("Handle not set for opcode %u", opcode); return -EINVAL; } else if (inst->cli.busy) { return -EBUSY; @@ -497,14 +493,14 @@ static uint8_t aics_client_read_desc_cb(struct bt_conn *conn, uint8_t err, memset(params, 0, sizeof(*params)); if (!inst) { - BT_DBG("Instance not found"); + LOG_DBG("Instance not found"); return BT_GATT_ITER_STOP; } inst->cli.busy = false; if (cb_err) { - BT_DBG("Description read failed: %d", err); + LOG_DBG("Description read failed: %d", err); if (inst->cli.cb && inst->cli.cb->description) { inst->cli.cb->description(inst, cb_err, NULL); } @@ -516,8 +512,8 @@ static uint8_t aics_client_read_desc_cb(struct bt_conn *conn, uint8_t err, /* Truncate if too large */ if (length > sizeof(desc) - 1) { - BT_DBG("Description truncated from %u to %zu octets", - length, sizeof(desc) - 1); + LOG_DBG("Description truncated from %u to %zu octets", length, + sizeof(desc) - 1); } length = MIN(sizeof(desc) - 1, length); @@ -527,7 +523,7 @@ static uint8_t aics_client_read_desc_cb(struct bt_conn *conn, uint8_t err, } desc[length] = '\0'; - BT_DBG("Input description: %s", desc); + LOG_DBG("Input description: %s", desc); if (inst->cli.cb && inst->cli.cb->description) { inst->cli.cb->description(inst, cb_err, desc); @@ -555,7 +551,7 @@ static uint8_t aics_discover_func(struct bt_conn *conn, const struct bt_gatt_att struct bt_aics *inst = CONTAINER_OF(client_inst, struct bt_aics, cli); if (!attr) { - BT_DBG("Discovery complete for AICS %p", inst); + LOG_DBG("Discovery complete for AICS %p", inst); memset(params, 0, sizeof(*params)); @@ -570,7 +566,7 @@ static uint8_t aics_discover_func(struct bt_conn *conn, const struct bt_gatt_att return BT_GATT_ITER_STOP; } - BT_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); + LOG_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); if (params->type == BT_GATT_DISCOVER_CHARACTERISTIC) { struct bt_gatt_subscribe_params *sub_params = NULL; @@ -583,24 +579,24 @@ static uint8_t aics_discover_func(struct bt_conn *conn, const struct bt_gatt_att inst->cli.end_handle = chrc->value_handle; if (!bt_uuid_cmp(chrc->uuid, BT_UUID_AICS_STATE)) { - BT_DBG("Audio Input state"); + LOG_DBG("Audio Input state"); inst->cli.state_handle = chrc->value_handle; sub_params = &inst->cli.state_sub_params; } else if (!bt_uuid_cmp(chrc->uuid, BT_UUID_AICS_GAIN_SETTINGS)) { - BT_DBG("Gain settings"); + LOG_DBG("Gain settings"); inst->cli.gain_handle = chrc->value_handle; } else if (!bt_uuid_cmp(chrc->uuid, BT_UUID_AICS_INPUT_TYPE)) { - BT_DBG("Input type"); + LOG_DBG("Input type"); inst->cli.type_handle = chrc->value_handle; } else if (!bt_uuid_cmp(chrc->uuid, BT_UUID_AICS_INPUT_STATUS)) { - BT_DBG("Input status"); + LOG_DBG("Input status"); inst->cli.status_handle = chrc->value_handle; sub_params = &inst->cli.status_sub_params; } else if (!bt_uuid_cmp(chrc->uuid, BT_UUID_AICS_CONTROL)) { - BT_DBG("Control point"); + LOG_DBG("Control point"); inst->cli.control_handle = chrc->value_handle; } else if (!bt_uuid_cmp(chrc->uuid, BT_UUID_AICS_DESCRIPTION)) { - BT_DBG("Description"); + LOG_DBG("Description"); inst->cli.desc_handle = chrc->value_handle; if (chrc->properties & BT_GATT_CHRC_NOTIFY) { sub_params = &inst->cli.desc_sub_params; @@ -678,24 +674,25 @@ int bt_aics_discover(struct bt_conn *conn, struct bt_aics *inst, int err = 0; CHECKIF(!inst || !conn || !param) { - BT_DBG("%s cannot be NULL", - inst == NULL ? "inst" : conn == NULL ? "conn" : "param"); + LOG_DBG("%s cannot be NULL", inst == NULL ? "inst" + : conn == NULL ? "conn" + : "param"); return -EINVAL; } CHECKIF(param->end_handle <= param->start_handle) { - BT_DBG("start_handle (%u) shall be less than end_handle (%u)", - param->start_handle, param->end_handle); + LOG_DBG("start_handle (%u) shall be less than end_handle (%u)", param->start_handle, + param->end_handle); return -EINVAL; } CHECKIF(!inst->cli.active) { - BT_DBG("Inactive instance"); + LOG_DBG("Inactive instance"); return -EINVAL; } if (inst->cli.busy) { - BT_DBG("Instance is busy"); + LOG_DBG("Instance is busy"); return -EBUSY; } @@ -711,7 +708,7 @@ int bt_aics_discover(struct bt_conn *conn, struct bt_aics *inst, err = bt_gatt_discover(conn, &inst->cli.discover_params); if (err) { - BT_DBG("Discover failed (err %d)", err); + LOG_DBG("Discover failed (err %d)", err); } else { inst->cli.busy = true; } @@ -735,17 +732,17 @@ struct bt_aics *bt_aics_client_free_instance_get(void) int bt_aics_client_conn_get(const struct bt_aics *aics, struct bt_conn **conn) { CHECKIF(aics == NULL) { - BT_DBG("NULL aics pointer"); + LOG_DBG("NULL aics pointer"); return -EINVAL; } if (!aics->client_instance) { - BT_DBG("aics pointer shall be client instance"); + LOG_DBG("aics pointer shall be client instance"); return -EINVAL; } if (aics->cli.conn == NULL) { - BT_DBG("aics pointer not associated with a connection. " + LOG_DBG("aics pointer not associated with a connection. " "Do discovery first"); return -ENOTCONN; } @@ -759,22 +756,22 @@ int bt_aics_client_state_get(struct bt_aics *inst) int err; CHECKIF(!inst) { - BT_DBG("NULL instance"); + LOG_DBG("NULL instance"); return -EINVAL; } CHECKIF(!inst->client_instance) { - BT_DBG("Not a client instance instance"); + LOG_DBG("Not a client instance instance"); return -EINVAL; } CHECKIF(inst->cli.conn == NULL) { - BT_DBG("NULL conn"); + LOG_DBG("NULL conn"); return -EINVAL; } if (!inst->cli.state_handle) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } else if (inst->cli.busy) { return -EBUSY; @@ -797,22 +794,22 @@ int bt_aics_client_gain_setting_get(struct bt_aics *inst) int err; CHECKIF(!inst) { - BT_DBG("NULL instance"); + LOG_DBG("NULL instance"); return -EINVAL; } CHECKIF(!inst->client_instance) { - BT_DBG("Not a client instance instance"); + LOG_DBG("Not a client instance instance"); return -EINVAL; } CHECKIF(inst->cli.conn == NULL) { - BT_DBG("NULL conn"); + LOG_DBG("NULL conn"); return -EINVAL; } if (!inst->cli.gain_handle) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } else if (inst->cli.busy) { return -EBUSY; @@ -835,22 +832,22 @@ int bt_aics_client_type_get(struct bt_aics *inst) int err; CHECKIF(!inst) { - BT_DBG("NULL instance"); + LOG_DBG("NULL instance"); return -EINVAL; } CHECKIF(!inst->client_instance) { - BT_DBG("Not a client instance instance"); + LOG_DBG("Not a client instance instance"); return -EINVAL; } CHECKIF(inst->cli.conn == NULL) { - BT_DBG("NULL conn"); + LOG_DBG("NULL conn"); return -EINVAL; } if (!inst->cli.type_handle) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } else if (inst->cli.busy) { return -EBUSY; @@ -873,22 +870,22 @@ int bt_aics_client_status_get(struct bt_aics *inst) int err; CHECKIF(!inst) { - BT_DBG("NULL instance"); + LOG_DBG("NULL instance"); return -EINVAL; } CHECKIF(!inst->client_instance) { - BT_DBG("Not a client instance instance"); + LOG_DBG("Not a client instance instance"); return -EINVAL; } CHECKIF(inst->cli.conn == NULL) { - BT_DBG("NULL conn"); + LOG_DBG("NULL conn"); return -EINVAL; } if (!inst->cli.status_handle) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } else if (inst->cli.busy) { return -EBUSY; @@ -931,22 +928,22 @@ int bt_aics_client_gain_set(struct bt_aics *inst, int8_t gain) int err; CHECKIF(!inst) { - BT_DBG("NULL instance"); + LOG_DBG("NULL instance"); return -EINVAL; } CHECKIF(!inst->client_instance) { - BT_DBG("Not a client instance instance"); + LOG_DBG("Not a client instance instance"); return -EINVAL; } CHECKIF(inst->cli.conn == NULL) { - BT_DBG("NULL conn"); + LOG_DBG("NULL conn"); return -EINVAL; } if (!inst->cli.control_handle) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } else if (inst->cli.busy) { return -EBUSY; @@ -974,22 +971,22 @@ int bt_aics_client_description_get(struct bt_aics *inst) int err; CHECKIF(!inst) { - BT_DBG("NULL instance"); + LOG_DBG("NULL instance"); return -EINVAL; } CHECKIF(!inst->client_instance) { - BT_DBG("Not a client instance instance"); + LOG_DBG("Not a client instance instance"); return -EINVAL; } CHECKIF(inst->cli.conn == NULL) { - BT_DBG("NULL conn"); + LOG_DBG("NULL conn"); return -EINVAL; } if (!inst->cli.desc_handle) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } else if (inst->cli.busy) { return -EBUSY; @@ -1011,27 +1008,27 @@ int bt_aics_client_description_set(struct bt_aics *inst, const char *description) { CHECKIF(!inst) { - BT_DBG("NULL instance"); + LOG_DBG("NULL instance"); return -EINVAL; } CHECKIF(!inst->client_instance) { - BT_DBG("Not a client instance instance"); + LOG_DBG("Not a client instance instance"); return -EINVAL; } CHECKIF(inst->cli.conn == NULL) { - BT_DBG("NULL conn"); + LOG_DBG("NULL conn"); return -EINVAL; } if (!inst->cli.desc_handle) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } else if (inst->cli.busy) { return -EBUSY; } else if (!inst->cli.desc_writable) { - BT_DBG("Description is not writable on peer service instance"); + LOG_DBG("Description is not writable on peer service instance"); return -EPERM; } @@ -1043,7 +1040,7 @@ int bt_aics_client_description_set(struct bt_aics *inst, void bt_aics_client_cb_register(struct bt_aics *inst, struct bt_aics_cb *cb) { CHECKIF(!inst) { - BT_DBG("inst cannot be NULL"); + LOG_DBG("inst cannot be NULL"); return; } diff --git a/subsys/bluetooth/audio/ascs.c b/subsys/bluetooth/audio/ascs.c index f90ab474488..d0b75b3f782 100644 --- a/subsys/bluetooth/audio/ascs.c +++ b/subsys/bluetooth/audio/ascs.c @@ -22,9 +22,10 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_ASCS) -#define LOG_MODULE_NAME bt_ascs -#include "common/log.h" +#include + +LOG_MODULE_REGISTER(bt_ascs, CONFIG_BT_ASCS_LOG_LEVEL); + #include "common/bt_str.h" #include "common/assert.h" @@ -83,9 +84,8 @@ void ascs_ep_set_state(struct bt_audio_ep *ep, uint8_t state) ep->status.state = state; state_changed = old_state != state; - BT_DBG("ep %p id 0x%02x %s -> %s", ep, ep->status.id, - bt_audio_ep_state_str(old_state), - bt_audio_ep_state_str(state)); + LOG_DBG("ep %p id 0x%02x %s -> %s", ep, ep->status.id, bt_audio_ep_state_str(old_state), + bt_audio_ep_state_str(state)); /* Notify clients*/ ase_status_changed(ep, old_state, state); @@ -256,7 +256,7 @@ void ascs_ep_set_state(struct bt_audio_ep *ep, uint8_t state) break; /* no-op*/ default: - BT_ERR("Invalid state: %u", state); + LOG_ERR("Invalid state: %u", state); break; } } @@ -271,8 +271,7 @@ static void ascs_codec_data_add(struct net_buf_simple *buf, const char *prefix, for (i = 0; i < num; i++) { struct bt_data *d = &data[i].data; - BT_DBG("#%u: %s type 0x%02x len %u", i, prefix, d->type, - d->data_len); + LOG_DBG("#%u: %s type 0x%02x len %u", i, prefix, d->type, d->data_len); LOG_HEXDUMP_DBG(d->data, d->data_len, prefix); cc = net_buf_simple_add(buf, sizeof(*cc)); @@ -302,7 +301,7 @@ static void ascs_ep_get_status_config(struct bt_audio_ep *ep, cfg->codec.cid = sys_cpu_to_le16(ep->codec.cid); cfg->codec.vid = sys_cpu_to_le16(ep->codec.vid); - BT_DBG("dir 0x%02x unframed_supported 0x%02x phy 0x%02x rtn %u " + LOG_DBG("dir 0x%02x unframed_supported 0x%02x phy 0x%02x rtn %u " "latency %u pd_min %u pd_max %u codec 0x%02x", ep->dir, pref->unframed_supported, pref->phy, pref->rtn, pref->latency, pref->pd_min, pref->pd_max, @@ -329,7 +328,7 @@ static void ascs_ep_get_status_qos(struct bt_audio_ep *ep, qos->latency = sys_cpu_to_le16(ep->stream->qos->latency); sys_put_le24(ep->stream->qos->pd, qos->pd); - BT_DBG("dir 0x%02x codec 0x%02x interval %u framing 0x%02x phy 0x%02x " + LOG_DBG("dir 0x%02x codec 0x%02x interval %u framing 0x%02x phy 0x%02x " "rtn %u latency %u pd %u", ep->dir, ep->stream->codec->id, ep->stream->qos->interval, ep->stream->qos->framing, @@ -350,8 +349,7 @@ static void ascs_ep_get_status_enable(struct bt_audio_ep *ep, ascs_codec_data_add(buf, "meta", ep->codec.meta_count, ep->codec.meta); enable->metadata_len = buf->len - enable->metadata_len; - BT_DBG("dir 0x%02x cig 0x%02x cis 0x%02x", - ep->dir, ep->cig_id, ep->cis_id); + LOG_DBG("dir 0x%02x cig 0x%02x cis 0x%02x", ep->dir, ep->cig_id, ep->cis_id); } static int ascs_ep_get_status(struct bt_audio_ep *ep, @@ -363,7 +361,7 @@ static int ascs_ep_get_status(struct bt_audio_ep *ep, return -EINVAL; } - BT_DBG("ep %p id 0x%02x state %s", ep, ep->status.id, + LOG_DBG("ep %p id 0x%02x state %s", ep, ep->status.id, bt_audio_ep_state_str(ep->status.state)); /* Reset if buffer before using */ @@ -391,7 +389,7 @@ static int ascs_ep_get_status(struct bt_audio_ep *ep, ascs_ep_get_status_enable(ep, buf); break; default: - BT_ERR("Invalid Endpoint state"); + LOG_ERR("Invalid Endpoint state"); break; } @@ -409,33 +407,32 @@ static void ascs_iso_recv(struct bt_iso_chan *chan, ep = iso->rx.ep; if (ep == NULL) { - BT_ERR("iso %p not bound with ep", chan); + LOG_ERR("iso %p not bound with ep", chan); return; } if (ep->status.state != BT_AUDIO_EP_STATE_STREAMING) { - BT_DBG("ep %p is not in the streaming state: %s", + LOG_DBG("ep %p is not in the streaming state: %s", ep, bt_audio_ep_state_str(ep->status.state)); return; } stream = ep->stream; if (stream == NULL) { - BT_ERR("No stream for ep %p", ep); + LOG_ERR("No stream for ep %p", ep); return; } ops = stream->ops; if (IS_ENABLED(CONFIG_BT_AUDIO_DEBUG_STREAM_DATA)) { - BT_DBG("stream %p ep %p len %zu", - stream, ep, net_buf_frags_len(buf)); + LOG_DBG("stream %p ep %p len %zu", stream, stream->ep, net_buf_frags_len(buf)); } if (ops != NULL && ops->recv != NULL) { ops->recv(stream, info, buf); } else { - BT_WARN("No callback for recv set"); + LOG_WRN("No callback for recv set"); } } @@ -448,20 +445,20 @@ static void ascs_iso_sent(struct bt_iso_chan *chan) ep = iso->tx.ep; if (ep == NULL) { - BT_ERR("iso %p not bound with ep", chan); + LOG_ERR("iso %p not bound with ep", chan); return; } stream = ep->stream; if (stream == NULL) { - BT_ERR("No stream for ep %p", ep); + LOG_ERR("No stream for ep %p", ep); return; } ops = stream->ops; if (IS_ENABLED(CONFIG_BT_AUDIO_DEBUG_STREAM_DATA)) { - BT_DBG("stream %p ep %p", stream, ep); + LOG_DBG("stream %p ep %p", stream, stream->ep); } if (ops != NULL && ops->sent != NULL) { @@ -490,7 +487,7 @@ static void ascs_ep_iso_connected(struct bt_audio_ep *ep) int err; if (ep->status.state != BT_AUDIO_EP_STATE_ENABLING) { - BT_DBG("ep %p not in enabling state: %s", + LOG_DBG("ep %p not in enabling state: %s", ep, bt_audio_ep_state_str(ep->status.state)); return; } @@ -501,13 +498,13 @@ static void ascs_ep_iso_connected(struct bt_audio_ep *ep) stream = ep->stream; if (stream == NULL) { - BT_ERR("No stream for ep %p", ep); + LOG_ERR("No stream for ep %p", ep); return; } err = ase_stream_start(stream); if (err) { - BT_ERR("Could not start stream %d", err); + LOG_ERR("Could not start stream %d", err); } } @@ -516,7 +513,7 @@ static void ascs_iso_connected(struct bt_iso_chan *chan) struct bt_audio_iso *iso = CONTAINER_OF(chan, struct bt_audio_iso, chan); if (iso->rx.ep == NULL && iso->tx.ep == NULL) { - BT_ERR("iso %p not bound with ep", chan); + LOG_ERR("iso %p not bound with ep", chan); return; } @@ -536,18 +533,18 @@ static void ascs_ep_iso_disconnected(struct bt_audio_ep *ep, uint8_t reason) stream = ep->stream; if (stream == NULL) { - BT_ERR("No stream for ep %p", ep); + LOG_ERR("No stream for ep %p", ep); return; } ops = stream->ops; - BT_DBG("stream %p ep %p reason 0x%02x", stream, ep, reason); + LOG_DBG("stream %p ep %p reason 0x%02x", stream, stream->ep, reason); if (ops != NULL && ops->stopped != NULL) { ops->stopped(stream); } else { - BT_WARN("No callback for stopped set"); + LOG_WRN("No callback for stopped set"); } if (ep->status.state == BT_AUDIO_EP_STATE_RELEASING) { @@ -569,7 +566,7 @@ static void ascs_ep_iso_disconnected(struct bt_audio_ep *ep, uint8_t reason) err = bt_audio_stream_iso_listen(stream); if (err != 0) { - BT_ERR("Could not make stream listen: %d", err); + LOG_ERR("Could not make stream listen: %d", err); } } } @@ -579,7 +576,7 @@ static void ascs_iso_disconnected(struct bt_iso_chan *chan, uint8_t reason) struct bt_audio_iso *iso = CONTAINER_OF(chan, struct bt_audio_iso, chan); if (iso->rx.ep == NULL && iso->tx.ep == NULL) { - BT_ERR("iso %p not bound with ep", chan); + LOG_ERR("iso %p not bound with ep", chan); return; } @@ -602,7 +599,7 @@ static struct bt_iso_chan_ops ascs_iso_ops = { static void ascs_ase_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("attr %p value 0x%04x", attr, value); + LOG_DBG("attr %p value 0x%04x", attr, value); } NET_BUF_SIMPLE_DEFINE_STATIC(rsp_buf, CONFIG_BT_L2CAP_TX_MTU); @@ -623,9 +620,9 @@ static void ascs_cp_rsp_add(uint8_t id, uint8_t op, uint8_t code, struct bt_ascs_cp_rsp *rsp = (void *)rsp_buf.__buf; struct bt_ascs_cp_ase_rsp *ase_rsp; - BT_DBG("id 0x%02x op %s (0x%02x) code %s (0x%02x) reason %s (0x%02x)", - id, bt_ascs_op_str(op), op, bt_ascs_rsp_str(code), code, - bt_ascs_reason_str(reason), reason); + LOG_DBG("id 0x%02x op %s (0x%02x) code %s (0x%02x) reason %s (0x%02x)", id, + bt_ascs_op_str(op), op, bt_ascs_rsp_str(code), code, bt_ascs_reason_str(reason), + reason); /* Allocate response if buffer is empty */ if (!rsp_buf.len) { @@ -658,7 +655,7 @@ static void ascs_cp_rsp_add(uint8_t id, uint8_t op, uint8_t code, static void ascs_cp_rsp_add_errno(uint8_t id, uint8_t op, int err, uint8_t reason) { - BT_DBG("id %u op %u err %d reason %u", id, op, err, reason); + LOG_DBG("id %u op %u err %d reason %u", id, op, err, reason); switch (err) { case -ENOBUFS: @@ -730,8 +727,7 @@ static void ase_release(struct bt_ascs_ase *ase) { int err; - BT_DBG("ase %p state %s", - ase, bt_audio_ep_state_str(ase->ep.status.state)); + LOG_DBG("ase %p state %s", ase, bt_audio_ep_state_str(ase->ep.status.state)); if (ase->ep.status.state == BT_AUDIO_EP_STATE_RELEASING) { /* already releasing */ @@ -761,7 +757,7 @@ static void ase_disable(struct bt_ascs_ase *ase) struct bt_audio_ep *ep; int err; - BT_DBG("ase %p", ase); + LOG_DBG("ase %p", ase); ep = &ase->ep; @@ -772,7 +768,7 @@ static void ase_disable(struct bt_ascs_ase *ase) case BT_AUDIO_EP_STATE_STREAMING: break; default: - BT_WARN("Invalid operation in state: %s", bt_audio_ep_state_str(ep->status.state)); + LOG_WRN("Invalid operation in state: %s", bt_audio_ep_state_str(ep->status.state)); ascs_cp_rsp_add_errno(ASE_ID(ase), BT_ASCS_DISABLE_OP, -EBADMSG, BT_ASCS_REASON_NONE); return; @@ -787,7 +783,7 @@ static void ase_disable(struct bt_ascs_ase *ase) } if (err) { - BT_ERR("Disable failed: %d", err); + LOG_ERR("Disable failed: %d", err); ascs_cp_rsp_add_errno(ASE_ID(ase), BT_ASCS_DISABLE_OP, err, BT_ASCS_REASON_NONE); return; @@ -889,7 +885,7 @@ static struct bt_audio_iso *audio_iso_get_or_new(struct bt_ascs *ascs, static void ase_stream_add(struct bt_ascs *ascs, struct bt_ascs_ase *ase, struct bt_audio_stream *stream) { - BT_DBG("ase %p stream %p", ase, stream); + LOG_DBG("ase %p stream %p", ase, stream); ase->ep.stream = stream; stream->conn = ascs->conn; stream->ep = &ase->ep; @@ -916,7 +912,7 @@ static void ase_process(struct k_work *work) const uint8_t ep_state = ep->status.state; struct bt_conn *conn = ase->ascs->conn; - BT_DBG("ase %p, ep %p, ep.stream %p", ase, ep, stream); + LOG_DBG("ase %p, ep %p, ep.stream %p", ase, ep, stream); if (conn != NULL && conn->state == BT_CONN_CONNECTED) { ascs_ep_get_status(ep, &ase_buf); @@ -945,8 +941,7 @@ static void ase_process(struct k_work *work) const int err = bt_audio_stream_disconnect(stream); if (err != 0) { - BT_ERR("Failed to disconnect stream %p: %d", - stream, err); + LOG_ERR("Failed to disconnect stream %p: %d", stream, err); } } } else if (ep_state == BT_AUDIO_EP_STATE_ENABLING) { @@ -977,7 +972,7 @@ static uint8_t ase_attr_cb(const struct bt_gatt_attr *attr, uint16_t handle, void ascs_ep_init(struct bt_audio_ep *ep, uint8_t id) { - BT_DBG("ep %p id 0x%02x", ep, id); + LOG_DBG("ep %p id 0x%02x", ep, id); (void)memset(ep, 0, sizeof(*ep)); ep->status.id = id; @@ -1064,12 +1059,11 @@ static ssize_t ascs_ase_read(struct bt_conn *conn, struct bt_ascs *ascs = ascs_get(conn); struct bt_ascs_ase *ase; - BT_DBG("conn %p attr %p buf %p len %u offset %u", conn, attr, buf, len, - offset); + LOG_DBG("conn %p attr %p buf %p len %u offset %u", conn, attr, buf, len, offset); ase = ase_get(ascs, POINTER_TO_UINT(BT_AUDIO_CHRC_USER_DATA(attr))); if (!ase) { - BT_ERR("Unable to get ASE"); + LOG_ERR("Unable to get ASE"); return BT_GATT_ERR(BT_ATT_ERR_UNLIKELY); } @@ -1081,7 +1075,7 @@ static ssize_t ascs_ase_read(struct bt_conn *conn, static void ascs_cp_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("attr %p value 0x%04x", attr, value); + LOG_DBG("attr %p value 0x%04x", attr, value); } static bool ascs_codec_config_store(struct bt_data *data, void *user_data) @@ -1090,20 +1084,19 @@ static bool ascs_codec_config_store(struct bt_data *data, void *user_data) struct bt_codec_data *cdata; if (codec->data_count >= ARRAY_SIZE(codec->data)) { - BT_ERR("No slot available for Codec Config"); + LOG_ERR("No slot available for Codec Config"); return false; } cdata = &codec->data[codec->data_count]; if (data->data_len > sizeof(cdata->value)) { - BT_ERR("Not enough space for Codec Config: %u > %zu", - data->data_len, sizeof(cdata->value)); + LOG_ERR("Not enough space for Codec Config: %u > %zu", data->data_len, + sizeof(cdata->value)); return false; } - BT_DBG("#%u type 0x%02x len %u", codec->data_count, data->type, - data->data_len); + LOG_DBG("#%u type 0x%02x len %u", codec->data_count, data->type, data->data_len); cdata->data.type = data->type; cdata->data.data_len = data->data_len; @@ -1150,13 +1143,13 @@ static int ascs_ep_set_codec(struct bt_audio_ep *ep, uint8_t id, uint16_t cid, return -EINVAL; } - BT_DBG("ep %p dir %u codec id 0x%02x cid 0x%04x vid 0x%04x len %u", - ep, ep->dir, id, cid, vid, len); + LOG_DBG("ep %p dir %u codec id 0x%02x cid 0x%04x vid 0x%04x len %u", ep, ep->dir, id, cid, + vid, len); bt_pacs_cap_foreach(ep->dir, codec_lookup_id, &lookup_data); if (lookup_data.codec == NULL) { - BT_DBG("Codec with id %u for dir %u is not supported by our capabilities", + LOG_DBG("Codec with id %u for dir %u is not supported by our capabilities", id, ep->dir); return -ENOENT; @@ -1184,7 +1177,7 @@ static int ascs_ep_set_codec(struct bt_audio_ep *ep, uint8_t id, uint16_t cid, /* Check if all entries could be parsed */ if (ad.len) { - BT_ERR("Unable to parse Codec Config: len %u", ad.len); + LOG_ERR("Unable to parse Codec Config: len %u", ad.len); (void)memset(codec, 0, sizeof(*codec)); return -EINVAL; @@ -1201,14 +1194,14 @@ static int ase_config(struct bt_ascs *ascs, struct bt_ascs_ase *ase, struct bt_codec codec; int err; - BT_DBG("ase %p latency 0x%02x phy 0x%02x codec 0x%02x " + LOG_DBG("ase %p latency 0x%02x phy 0x%02x codec 0x%02x " "cid 0x%04x vid 0x%04x codec config len 0x%02x", ase, cfg->latency, cfg->phy, cfg->codec.id, cfg->codec.cid, cfg->codec.vid, cfg->cc_len); if (cfg->latency < BT_ASCS_CONFIG_LATENCY_LOW || cfg->latency > BT_ASCS_CONFIG_LATENCY_HIGH) { - BT_WARN("Invalid latency: 0x%02x", cfg->latency); + LOG_WRN("Invalid latency: 0x%02x", cfg->latency); ascs_cp_rsp_add(ASE_ID(ase), BT_ASCS_CONFIG_OP, BT_ASCS_RSP_CONF_INVALID, BT_ASCS_REASON_LATENCY); @@ -1217,7 +1210,7 @@ static int ase_config(struct bt_ascs *ascs, struct bt_ascs_ase *ase, if (cfg->phy < BT_ASCS_CONFIG_PHY_LE_1M || cfg->phy > BT_ASCS_CONFIG_PHY_LE_CODED) { - BT_WARN("Invalid PHY: 0x%02x", cfg->phy); + LOG_WRN("Invalid PHY: 0x%02x", cfg->phy); ascs_cp_rsp_add(ASE_ID(ase), BT_ASCS_CONFIG_OP, BT_ASCS_RSP_CONF_INVALID, BT_ASCS_REASON_PHY); return 0; @@ -1232,7 +1225,7 @@ static int ase_config(struct bt_ascs *ascs, struct bt_ascs_ase *ase, case BT_AUDIO_EP_STATE_QOS_CONFIGURED: break; default: - BT_WARN("Invalid operation in state: %s", + LOG_WRN("Invalid operation in state: %s", bt_audio_ep_state_str(ase->ep.status.state)); ascs_cp_rsp_add(ASE_ID(ase), BT_ASCS_CONFIG_OP, BT_ASCS_RSP_INVALID_ASE_STATE, 0x00); @@ -1269,7 +1262,7 @@ static int ase_config(struct bt_ascs *ascs, struct bt_ascs_ase *ase, if (err != 0) { uint8_t reason = BT_ASCS_REASON_CODEC_DATA; - BT_ERR("Reconfig failed: %d", err); + LOG_ERR("Reconfig failed: %d", err); (void)memcpy(&ase->ep.codec, &codec, sizeof(codec)); ascs_cp_rsp_add_errno(ASE_ID(ase), @@ -1292,8 +1285,7 @@ static int ase_config(struct bt_ascs *ascs, struct bt_ascs_ase *ase, } if (err != 0 || stream == NULL) { - BT_ERR("Config failed, err: %d, stream %p", - err, stream); + LOG_ERR("Config failed, err: %d, stream %p", err, stream); (void)memcpy(&ase->ep.codec, &codec, sizeof(codec)); ascs_cp_rsp_add(ASE_ID(ase), BT_ASCS_CONFIG_OP, @@ -1326,19 +1318,19 @@ static ssize_t ascs_config(struct bt_ascs *ascs, struct net_buf_simple *buf) int i; if (buf->len < sizeof(*req)) { - BT_WARN("Malformed ASE Config"); + LOG_WRN("Malformed ASE Config"); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } req = net_buf_simple_pull_mem(buf, sizeof(*req)); - BT_DBG("num_ases %u", req->num_ases); + LOG_DBG("num_ases %u", req->num_ases); if (req->num_ases < 1) { - BT_WARN("Number_of_ASEs parameter value is less than 1"); + LOG_WRN("Number_of_ASEs parameter value is less than 1"); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } else if (buf->len < req->num_ases * sizeof(*cfg)) { - BT_WARN("Malformed ASE Config: len %u < %zu", buf->len, + LOG_WRN("Malformed ASE Config: len %u < %zu", buf->len, req->num_ases * sizeof(*cfg)); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } @@ -1348,18 +1340,18 @@ static ssize_t ascs_config(struct bt_ascs *ascs, struct net_buf_simple *buf) int err; if (buf->len < sizeof(*cfg)) { - BT_WARN("Malformed ASE Config: len %u < %zu", buf->len, sizeof(*cfg)); + LOG_WRN("Malformed ASE Config: len %u < %zu", buf->len, sizeof(*cfg)); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } cfg = net_buf_simple_pull_mem(buf, sizeof(*cfg)); if (buf->len < cfg->cc_len) { - BT_WARN("Malformed ASE Codec Config len %u != %u", buf->len, cfg->cc_len); + LOG_WRN("Malformed ASE Codec Config len %u != %u", buf->len, cfg->cc_len); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } - BT_DBG("ase 0x%02x cc_len %u", cfg->ase, cfg->cc_len); + LOG_DBG("ase 0x%02x cc_len %u", cfg->ase, cfg->cc_len); if (cfg->ase) { ase = ase_get(ascs, cfg->ase); @@ -1370,13 +1362,13 @@ static ssize_t ascs_config(struct bt_ascs *ascs, struct net_buf_simple *buf) if (!ase) { ascs_cp_rsp_add(cfg->ase, BT_ASCS_CONFIG_OP, BT_ASCS_RSP_INVALID_ASE, 0x00); - BT_WARN("Unknown ase 0x%02x", cfg->ase); + LOG_WRN("Unknown ase 0x%02x", cfg->ase); continue; } err = ase_config(ascs, ase, cfg, buf); if (err != 0) { - BT_WARN("Malformed ASE Config"); + LOG_WRN("Malformed ASE Config"); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } } @@ -1392,10 +1384,10 @@ static int ase_stream_qos(struct bt_audio_stream *stream, { struct bt_audio_ep *ep; - BT_DBG("stream %p ep %p qos %p", stream, stream->ep, qos); + LOG_DBG("stream %p ep %p qos %p", stream, stream->ep, qos); if (stream == NULL || stream->ep == NULL || qos == NULL) { - BT_DBG("Invalid input stream, ep or qos pointers"); + LOG_DBG("Invalid input stream, ep or qos pointers"); return -EINVAL; } @@ -1408,7 +1400,7 @@ static int ase_stream_qos(struct bt_audio_stream *stream, case BT_AUDIO_EP_STATE_QOS_CONFIGURED: break; default: - BT_WARN("Invalid operation in state: %s", bt_audio_ep_state_str(ep->status.state)); + LOG_WRN("Invalid operation in state: %s", bt_audio_ep_state_str(ep->status.state)); return -EBADMSG; } @@ -1425,7 +1417,7 @@ static int ase_stream_qos(struct bt_audio_stream *stream, err = unicast_server_cb->qos(stream, qos); if (err != 0) { - BT_DBG("Application returned error: %d", err); + LOG_DBG("Application returned error: %d", err); return err; } } @@ -1440,12 +1432,12 @@ static int ase_stream_qos(struct bt_audio_stream *stream, iso = audio_iso_get_or_new(ascs, cig_id, cis_id); if (iso == NULL) { - BT_ERR("Could not allocate audio_iso"); + LOG_ERR("Could not allocate audio_iso"); return -ENOMEM; } if (bt_audio_iso_get_ep(iso, ep->dir) != NULL) { - BT_ERR("iso %p already in use in dir %u", + LOG_ERR("iso %p already in use in dir %u", &iso->chan, ep->dir); bt_audio_iso_unref(iso); return -EALREADY; @@ -1481,7 +1473,7 @@ static void ase_qos(struct bt_ascs_ase *ase, const struct bt_ascs_qos *qos) cqos->latency = sys_le16_to_cpu(qos->latency); cqos->pd = sys_get_le24(qos->pd); - BT_DBG("ase %p cig 0x%02x cis 0x%02x interval %u framing 0x%02x " + LOG_DBG("ase %p cig 0x%02x cis 0x%02x interval %u framing 0x%02x " "phy 0x%02x sdu %u rtn %u latency %u pd %u", ase, qos->cig, qos->cis, cqos->interval, cqos->framing, cqos->phy, cqos->sdu, cqos->rtn, cqos->latency, cqos->pd); @@ -1490,7 +1482,7 @@ static void ase_qos(struct bt_ascs_ase *ase, const struct bt_ascs_qos *qos) if (err) { uint8_t reason = BT_ASCS_REASON_NONE; - BT_ERR("QoS failed: err %d", err); + LOG_ERR("QoS failed: err %d", err); if (err == -ENOTSUP) { if (cqos->interval == 0) { @@ -1551,13 +1543,13 @@ static ssize_t ascs_qos(struct bt_ascs *ascs, struct net_buf_simple *buf) req = net_buf_simple_pull_mem(buf, sizeof(*req)); - BT_DBG("num_ases %u", req->num_ases); + LOG_DBG("num_ases %u", req->num_ases); if (req->num_ases < 1) { - BT_WARN("Number_of_ASEs parameter value is less than 1"); + LOG_WRN("Number_of_ASEs parameter value is less than 1"); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } else if (buf->len < req->num_ases * sizeof(*qos)) { - BT_WARN("Malformed ASE QoS: len %u < %zu", buf->len, req->num_ases * sizeof(*qos)); + LOG_WRN("Malformed ASE QoS: len %u < %zu", buf->len, req->num_ases * sizeof(*qos)); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } @@ -1566,13 +1558,13 @@ static ssize_t ascs_qos(struct bt_ascs *ascs, struct net_buf_simple *buf) qos = net_buf_simple_pull_mem(buf, sizeof(*qos)); - BT_DBG("ase 0x%02x", qos->ase); + LOG_DBG("ase 0x%02x", qos->ase); ase = ase_find(ascs, qos->ase); if (!ase) { ascs_cp_rsp_add(qos->ase, BT_ASCS_QOS_OP, BT_ASCS_RSP_INVALID_ASE, 0x00); - BT_WARN("Unknown ase 0x%02x", qos->ase); + LOG_WRN("Unknown ase 0x%02x", qos->ase); continue; } @@ -1595,9 +1587,7 @@ static bool ascs_codec_store_metadata(struct bt_data *data, void *user_data) meta->data.data = meta->value; (void)memcpy(meta->value, data->data, data->data_len); - BT_DBG("#%zu: data: %s", - codec->meta_count, - bt_hex(meta->value, data->data_len)); + LOG_DBG("#%zu: data: %s", codec->meta_count, bt_hex(meta->value, data->data_len)); codec->meta_count++; @@ -1620,19 +1610,19 @@ static bool ascs_parse_metadata(struct bt_data *data, void *user_data) result->count++; - BT_DBG("#%u type 0x%02x len %u", result->count, data_type, data_len); + LOG_DBG("#%u type 0x%02x len %u", result->count, data_type, data_len); if (result->count > CONFIG_BT_CODEC_MAX_METADATA_COUNT) { - BT_ERR("Not enough buffers for Codec Config Metadata: %zu > %zu", - result->count, CONFIG_BT_CODEC_MAX_METADATA_LEN); + LOG_ERR("Not enough buffers for Codec Config Metadata: %zu > %zu", result->count, + CONFIG_BT_CODEC_MAX_METADATA_LEN); result->err = -ENOMEM; return false; } if (data_len > CONFIG_BT_CODEC_MAX_METADATA_LEN) { - BT_ERR("Not enough space for Codec Config Metadata: %u > %zu", - data->data_len, CONFIG_BT_CODEC_MAX_METADATA_LEN); + LOG_ERR("Not enough space for Codec Config Metadata: %u > %zu", data->data_len, + CONFIG_BT_CODEC_MAX_METADATA_LEN); result->err = -ENOMEM; return false; @@ -1646,7 +1636,7 @@ static bool ascs_parse_metadata(struct bt_data *data, void *user_data) const uint16_t context = sys_get_le16(data_value); if (!bt_pacs_context_available(ep->dir, context)) { - BT_WARN("Context 0x%04x is unavailable", context); + LOG_WRN("Context 0x%04x is unavailable", context); result->err = -EACCES; @@ -1661,7 +1651,7 @@ static bool ascs_parse_metadata(struct bt_data *data, void *user_data) if (!bt_cap_acceptor_ccid_exist(ep->stream->conn, ccid)) { - BT_WARN("CCID %u is unknown", ccid); + LOG_WRN("CCID %u is unknown", ccid); /* TBD: * Should we reject the Metadata? @@ -1698,7 +1688,7 @@ static int ascs_verify_metadata(const struct net_buf_simple *buf, /* Check if all entries could be parsed */ if (meta_ltv.len != 0) { - BT_ERR("Unable to parse Metadata: len %u", meta_ltv.len); + LOG_ERR("Unable to parse Metadata: len %u", meta_ltv.len); if (meta_ltv.len > 2) { /* Value of the Metadata Type field in error */ @@ -1721,7 +1711,7 @@ static int ascs_ep_set_metadata(struct bt_audio_ep *ep, struct net_buf_simple *b return -EINVAL; } - BT_DBG("ep %p len %u codec %p", ep, len, codec); + LOG_DBG("ep %p len %u codec %p", ep, len, codec); if (len == 0) { (void)memset(codec->meta, 0, sizeof(codec->meta)); @@ -1761,7 +1751,7 @@ static int ase_metadata(struct bt_ascs_ase *ase, uint8_t op, uint8_t state; int err; - BT_DBG("ase %p meta->len %u", ase, meta->len); + LOG_DBG("ase %p meta->len %u", ase, meta->len); ep = &ase->ep; state = ep->status.state; @@ -1773,7 +1763,7 @@ static int ase_metadata(struct bt_ascs_ase *ase, uint8_t op, case BT_AUDIO_EP_STATE_STREAMING: break; default: - BT_WARN("Invalid operation in state: %s", bt_audio_ep_state_str(state)); + LOG_WRN("Invalid operation in state: %s", bt_audio_ep_state_str(state)); err = -EBADMSG; ascs_cp_rsp_add_errno(ASE_ID(ase), op, err, buf->len ? *buf->data : 0x00); @@ -1810,7 +1800,7 @@ static int ase_metadata(struct bt_ascs_ase *ase, uint8_t op, (void)memcpy(ep->codec.meta, metadata_backup, sizeof(metadata_backup)); - BT_ERR("Metadata failed: %d", err); + LOG_ERR("Metadata failed: %d", err); ascs_cp_rsp_add_errno(ASE_ID(ase), op, err, buf->len ? *buf->data : 0x00); return err; @@ -1831,14 +1821,14 @@ static int ase_enable(struct bt_ascs_ase *ase, struct bt_ascs_metadata *meta, struct bt_audio_ep *ep; int err; - BT_DBG("ase %p buf->len %u", ase, buf->len); + LOG_DBG("ase %p buf->len %u", ase, buf->len); ep = &ase->ep; /* Valid for an ASE only if ASE_State field = 0x02 (QoS Configured) */ if (ep->status.state != BT_AUDIO_EP_STATE_QOS_CONFIGURED) { err = -EBADMSG; - BT_WARN("Invalid operation in state: %s", bt_audio_ep_state_str(ep->status.state)); + LOG_WRN("Invalid operation in state: %s", bt_audio_ep_state_str(ep->status.state)); ascs_cp_rsp_add_errno(ASE_ID(ase), BT_ASCS_ENABLE_OP, err, BT_ASCS_REASON_NONE); return err; @@ -1865,7 +1855,7 @@ static int ase_enable(struct bt_ascs_ase *ase, struct bt_ascs_metadata *meta, } if (err) { - BT_ERR("Enable rejected: %d", err); + LOG_ERR("Enable rejected: %d", err); ascs_cp_rsp_add_errno(ASE_ID(ase), BT_ASCS_ENABLE_OP, err, BT_ASCS_REASON_NONE); return -EFAULT; @@ -1890,13 +1880,13 @@ static ssize_t ascs_enable(struct bt_ascs *ascs, struct net_buf_simple *buf) req = net_buf_simple_pull_mem(buf, sizeof(*req)); - BT_DBG("num_ases %u", req->num_ases); + LOG_DBG("num_ases %u", req->num_ases); if (req->num_ases < 1) { - BT_WARN("Number_of_ASEs parameter value is less than 1"); + LOG_WRN("Number_of_ASEs parameter value is less than 1"); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } else if (buf->len < req->num_ases * sizeof(*meta)) { - BT_WARN("Malformed ASE Metadata: len %u < %zu", buf->len, + LOG_WRN("Malformed ASE Metadata: len %u < %zu", buf->len, req->num_ases * sizeof(*meta)); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } @@ -1906,10 +1896,10 @@ static ssize_t ascs_enable(struct bt_ascs *ascs, struct net_buf_simple *buf) meta = net_buf_simple_pull_mem(buf, sizeof(*meta)); - BT_DBG("ase 0x%02x meta->len %u", meta->ase, meta->len); + LOG_DBG("ase 0x%02x meta->len %u", meta->ase, meta->len); if (buf->len < meta->len) { - BT_WARN("Malformed ASE Enable Metadata len %u != %u", buf->len, meta->len); + LOG_WRN("Malformed ASE Enable Metadata len %u != %u", buf->len, meta->len); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } @@ -1917,7 +1907,7 @@ static ssize_t ascs_enable(struct bt_ascs *ascs, struct net_buf_simple *buf) if (!ase) { ascs_cp_rsp_add(meta->ase, BT_ASCS_ENABLE_OP, BT_ASCS_RSP_INVALID_ASE, 0x00); - BT_WARN("Unknown ase 0x%02x", meta->ase); + LOG_WRN("Unknown ase 0x%02x", meta->ase); continue; } @@ -1931,13 +1921,13 @@ static void ase_start(struct bt_ascs_ase *ase) { struct bt_audio_ep *ep; - BT_DBG("ase %p", ase); + LOG_DBG("ase %p", ase); ep = &ase->ep; /* Valid for an ASE only if ASE_State field = 0x02 (QoS Configured) */ if (ep->status.state != BT_AUDIO_EP_STATE_ENABLING) { - BT_WARN("Invalid operation in state: %s", bt_audio_ep_state_str(ep->status.state)); + LOG_WRN("Invalid operation in state: %s", bt_audio_ep_state_str(ep->status.state)); ascs_cp_rsp_add_errno(ASE_ID(ase), BT_ASCS_START_OP, -EBADMSG, BT_ASCS_REASON_NONE); return; @@ -1950,7 +1940,7 @@ static void ase_start(struct bt_ascs_ase *ase) * Response_Code value for that ASE to 0x05 (Invalid ASE direction). */ if (ep->dir == BT_AUDIO_DIR_SINK) { - BT_WARN("Start failed: invalid operation for Sink"); + LOG_WRN("Start failed: invalid operation for Sink"); ascs_cp_rsp_add(ASE_ID(ase), BT_ASCS_START_OP, BT_ASCS_RSP_INVALID_DIR, BT_ASCS_REASON_NONE); return; @@ -1963,7 +1953,7 @@ static void ase_start(struct bt_ascs_ase *ase) err = ase_stream_start(ep->stream); if (err) { - BT_ERR("Start failed: %d", err); + LOG_ERR("Start failed: %d", err); ascs_cp_rsp_add(ASE_ID(ase), BT_ASCS_START_OP, err, BT_ASCS_REASON_NONE); return; @@ -1984,13 +1974,13 @@ static ssize_t ascs_start(struct bt_ascs *ascs, struct net_buf_simple *buf) req = net_buf_simple_pull_mem(buf, sizeof(*req)); - BT_DBG("num_ases %u", req->num_ases); + LOG_DBG("num_ases %u", req->num_ases); if (req->num_ases < 1) { - BT_WARN("Number_of_ASEs parameter value is less than 1"); + LOG_WRN("Number_of_ASEs parameter value is less than 1"); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } else if (buf->len < req->num_ases) { - BT_WARN("Malformed ASE Start: len %u < %u", buf->len, req->num_ases); + LOG_WRN("Malformed ASE Start: len %u < %u", buf->len, req->num_ases); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } @@ -2000,13 +1990,13 @@ static ssize_t ascs_start(struct bt_ascs *ascs, struct net_buf_simple *buf) id = net_buf_simple_pull_u8(buf); - BT_DBG("ase 0x%02x", id); + LOG_DBG("ase 0x%02x", id); ase = ase_find(ascs, id); if (!ase) { ascs_cp_rsp_add(id, BT_ASCS_START_OP, BT_ASCS_RSP_INVALID_ASE, 0x00); - BT_WARN("Unknown ase 0x%02x", id); + LOG_WRN("Unknown ase 0x%02x", id); continue; } @@ -2027,13 +2017,13 @@ static ssize_t ascs_disable(struct bt_ascs *ascs, struct net_buf_simple *buf) req = net_buf_simple_pull_mem(buf, sizeof(*req)); - BT_DBG("num_ases %u", req->num_ases); + LOG_DBG("num_ases %u", req->num_ases); if (req->num_ases < 1) { - BT_WARN("Number_of_ASEs parameter value is less than 1"); + LOG_WRN("Number_of_ASEs parameter value is less than 1"); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } else if (buf->len < req->num_ases) { - BT_WARN("Malformed ASE Disable: len %u < %u", buf->len, req->num_ases); + LOG_WRN("Malformed ASE Disable: len %u < %u", buf->len, req->num_ases); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } @@ -2043,13 +2033,13 @@ static ssize_t ascs_disable(struct bt_ascs *ascs, struct net_buf_simple *buf) id = net_buf_simple_pull_u8(buf); - BT_DBG("ase 0x%02x", id); + LOG_DBG("ase 0x%02x", id); ase = ase_find(ascs, id); if (!ase) { ascs_cp_rsp_add(id, BT_ASCS_DISABLE_OP, BT_ASCS_RSP_INVALID_ASE, 0x00); - BT_WARN("Unknown ase 0x%02x", id); + LOG_WRN("Unknown ase 0x%02x", id); continue; } @@ -2065,7 +2055,7 @@ static void ase_stop(struct bt_ascs_ase *ase) struct bt_audio_ep *ep; int err; - BT_DBG("ase %p", ase); + LOG_DBG("ase %p", ase); ep = &ase->ep; @@ -2076,14 +2066,14 @@ static void ase_stop(struct bt_ascs_ase *ase) * Response_Code value for that ASE to 0x05 (Invalid ASE direction). */ if (ase->ep.dir == BT_AUDIO_DIR_SINK) { - BT_WARN("Stop failed: invalid operation for Sink"); + LOG_WRN("Stop failed: invalid operation for Sink"); ascs_cp_rsp_add(ASE_ID(ase), BT_ASCS_STOP_OP, BT_ASCS_RSP_INVALID_DIR, BT_ASCS_REASON_NONE); return; } if (ep->status.state != BT_AUDIO_EP_STATE_DISABLING) { - BT_WARN("Invalid operation in state: %s", bt_audio_ep_state_str(ep->status.state)); + LOG_WRN("Invalid operation in state: %s", bt_audio_ep_state_str(ep->status.state)); ascs_cp_rsp_add_errno(ASE_ID(ase), BT_ASCS_STOP_OP, -EBADMSG, BT_ASCS_REASON_NONE); return; @@ -2097,7 +2087,7 @@ static void ase_stop(struct bt_ascs_ase *ase) } if (err) { - BT_ERR("Stop failed: %d", err); + LOG_ERR("Stop failed: %d", err); ascs_cp_rsp_add_errno(ASE_ID(ase), BT_ASCS_STOP_OP, err, BT_ASCS_REASON_NONE); return; @@ -2110,14 +2100,14 @@ static void ase_stop(struct bt_ascs_ase *ase) */ err = bt_audio_stream_disconnect(stream); if (err != -ENOTCONN && err != 0) { - BT_ERR("Could not disconnect the CIS: %d", err); + LOG_ERR("Could not disconnect the CIS: %d", err); return; } ascs_ep_set_state(ep, BT_AUDIO_EP_STATE_QOS_CONFIGURED); err = bt_audio_stream_iso_listen(stream); if (err != 0) { - BT_ERR("Could not make stream listen: %d", err); + LOG_ERR("Could not make stream listen: %d", err); return; } @@ -2135,13 +2125,13 @@ static ssize_t ascs_stop(struct bt_ascs *ascs, struct net_buf_simple *buf) req = net_buf_simple_pull_mem(buf, sizeof(*req)); - BT_DBG("num_ases %u", req->num_ases); + LOG_DBG("num_ases %u", req->num_ases); if (req->num_ases < 1) { - BT_WARN("Number_of_ASEs parameter value is less than 1"); + LOG_WRN("Number_of_ASEs parameter value is less than 1"); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } else if (buf->len < req->num_ases) { - BT_WARN("Malformed ASE Start: len %u < %u", buf->len, req->num_ases); + LOG_WRN("Malformed ASE Start: len %u < %u", buf->len, req->num_ases); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } @@ -2151,13 +2141,13 @@ static ssize_t ascs_stop(struct bt_ascs *ascs, struct net_buf_simple *buf) id = net_buf_simple_pull_u8(buf); - BT_DBG("ase 0x%02x", id); + LOG_DBG("ase 0x%02x", id); ase = ase_find(ascs, id); if (!ase) { ascs_cp_rsp_add(id, BT_ASCS_STOP_OP, BT_ASCS_RSP_INVALID_ASE, 0x00); - BT_WARN("Unknown ase 0x%02x", id); + LOG_WRN("Unknown ase 0x%02x", id); continue; } @@ -2179,13 +2169,13 @@ static ssize_t ascs_metadata(struct bt_ascs *ascs, struct net_buf_simple *buf) req = net_buf_simple_pull_mem(buf, sizeof(*req)); - BT_DBG("num_ases %u", req->num_ases); + LOG_DBG("num_ases %u", req->num_ases); if (req->num_ases < 1) { - BT_WARN("Number_of_ASEs parameter value is less than 1"); + LOG_WRN("Number_of_ASEs parameter value is less than 1"); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } else if (buf->len < req->num_ases * sizeof(*meta)) { - BT_WARN("Malformed ASE Metadata: len %u < %zu", buf->len, + LOG_WRN("Malformed ASE Metadata: len %u < %zu", buf->len, req->num_ases * sizeof(*meta)); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } @@ -2196,17 +2186,17 @@ static ssize_t ascs_metadata(struct bt_ascs *ascs, struct net_buf_simple *buf) meta = net_buf_simple_pull_mem(buf, sizeof(*meta)); if (buf->len < meta->len) { - BT_WARN("Malformed ASE Metadata: len %u < %u", buf->len, meta->len); + LOG_WRN("Malformed ASE Metadata: len %u < %u", buf->len, meta->len); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } - BT_DBG("ase 0x%02x meta->len %u", meta->ase, meta->len); + LOG_DBG("ase 0x%02x meta->len %u", meta->ase, meta->len); ase = ase_find(ascs, meta->ase); if (!ase) { ascs_cp_rsp_add(meta->ase, BT_ASCS_METADATA_OP, BT_ASCS_RSP_INVALID_ASE, 0x00); - BT_WARN("Unknown ase 0x%02x", meta->ase); + LOG_WRN("Unknown ase 0x%02x", meta->ase); continue; } @@ -2227,13 +2217,13 @@ static ssize_t ascs_release(struct bt_ascs *ascs, struct net_buf_simple *buf) req = net_buf_simple_pull_mem(buf, sizeof(*req)); - BT_DBG("num_ases %u", req->num_ases); + LOG_DBG("num_ases %u", req->num_ases); if (req->num_ases < 1) { - BT_WARN("Number_of_ASEs parameter value is less than 1"); + LOG_WRN("Number_of_ASEs parameter value is less than 1"); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } else if (buf->len < req->num_ases) { - BT_WARN("Malformed ASE Release: len %u < %u", buf->len, req->num_ases); + LOG_WRN("Malformed ASE Release: len %u < %u", buf->len, req->num_ases); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } @@ -2243,19 +2233,19 @@ static ssize_t ascs_release(struct bt_ascs *ascs, struct net_buf_simple *buf) id = net_buf_simple_pull_u8(buf); - BT_DBG("ase 0x%02x", id); + LOG_DBG("ase 0x%02x", id); ase = ase_find(ascs, id); if (!ase) { ascs_cp_rsp_add(id, BT_ASCS_RELEASE_OP, BT_ASCS_RSP_INVALID_ASE, 0); - BT_WARN("Unknown ase 0x%02x", id); + LOG_WRN("Unknown ase 0x%02x", id); continue; } if (ase->ep.status.state == BT_AUDIO_EP_STATE_IDLE || ase->ep.status.state == BT_AUDIO_EP_STATE_RELEASING) { - BT_WARN("Invalid operation in state: %s", + LOG_WRN("Invalid operation in state: %s", bt_audio_ep_state_str(ase->ep.status.state)); ascs_cp_rsp_add(id, BT_ASCS_RELEASE_OP, BT_ASCS_RSP_INVALID_ASE_STATE, BT_ASCS_REASON_NONE); @@ -2289,8 +2279,8 @@ static ssize_t ascs_cp_write(struct bt_conn *conn, req = net_buf_simple_pull_mem(&buf, sizeof(*req)); - BT_DBG("conn %p attr %p buf %p len %u op %s (0x%02x)", conn, - attr, data, len, bt_ascs_op_str(req->op), req->op); + LOG_DBG("conn %p attr %p buf %p len %u op %s (0x%02x)", conn, attr, data, len, + bt_ascs_op_str(req->op), req->op); /* Reset/empty response buffer before using it again */ net_buf_simple_reset(&rsp_buf); @@ -2322,7 +2312,7 @@ static ssize_t ascs_cp_write(struct bt_conn *conn, break; default: ascs_cp_rsp_add(0x00, req->op, BT_ASCS_RSP_NOT_SUPPORTED, 0); - BT_DBG("Unknown opcode"); + LOG_DBG("Unknown opcode"); goto respond; } diff --git a/subsys/bluetooth/audio/bap_broadcast_assistant.c b/subsys/bluetooth/audio/bap_broadcast_assistant.c index 976fb785535..69afafd0a33 100644 --- a/subsys/bluetooth/audio/bap_broadcast_assistant.c +++ b/subsys/bluetooth/audio/bap_broadcast_assistant.c @@ -20,9 +20,10 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_BAP_BROADCAST_ASSISTANT) -#define LOG_MODULE_NAME bt_bap_broadcast_assistant -#include "common/log.h" +#include + +LOG_MODULE_REGISTER(bt_bap_broadcast_assistant, CONFIG_BT_BAP_BROADCAST_ASSISTANT_LOG_LEVEL); + #include "common/bt_str.h" #include "bap_internal.h" @@ -71,7 +72,7 @@ static int16_t lookup_index_by_handle(uint16_t handle) } } - BT_ERR("Unknown handle 0x%04x", handle); + LOG_ERR("Unknown handle 0x%04x", handle); return -1; } @@ -85,12 +86,12 @@ static int parse_recv_state(const void *data, uint16_t length, __ASSERT(recv_state, "NULL receive state"); if (data == NULL || length == 0) { - BT_DBG("NULL data"); + LOG_DBG("NULL data"); return -EINVAL; } if (length < MINIMUM_RECV_STATE_LEN) { - BT_DBG("Invalid receive state length %u, expected at least %u", + LOG_DBG("Invalid receive state length %u, expected at least %u", length, MINIMUM_RECV_STATE_LEN); return -EINVAL; } @@ -113,7 +114,7 @@ static int parse_recv_state(const void *data, uint16_t length, sizeof(recv_state->num_subgroups); if (buf.len < minimum_size) { - BT_DBG("Invalid receive state length %u, expected at least %zu", + LOG_DBG("Invalid receive state length %u, expected at least %zu", buf.len, minimum_size); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } @@ -130,7 +131,7 @@ static int parse_recv_state(const void *data, uint16_t length, uint8_t *metadata; if (buf.len < sizeof(subgroup->bis_sync)) { - BT_DBG("Invalid receive state length %u, expected at least %zu", + LOG_DBG("Invalid receive state length %u, expected at least %zu", buf.len, buf.len + sizeof(subgroup->bis_sync)); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } @@ -138,20 +139,20 @@ static int parse_recv_state(const void *data, uint16_t length, subgroup->bis_sync = net_buf_simple_pull_le32(&buf); if (buf.len < sizeof(subgroup->metadata_len)) { - BT_DBG("Invalid receive state length %u, expected at least %zu", + LOG_DBG("Invalid receive state length %u, expected at least %zu", buf.len, buf.len + sizeof(subgroup->metadata_len)); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } subgroup->metadata_len = net_buf_simple_pull_u8(&buf); if (buf.len < subgroup->metadata_len) { - BT_DBG("Invalid receive state length %u, expected at least %u", + LOG_DBG("Invalid receive state length %u, expected at least %u", buf.len, buf.len + subgroup->metadata_len); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } if (subgroup->metadata_len > sizeof(subgroup->metadata)) { - BT_DBG("Metadata too long: %u/%zu", + LOG_DBG("Metadata too long: %u/%zu", subgroup->metadata_len, sizeof(subgroup->metadata)); } @@ -163,7 +164,7 @@ static int parse_recv_state(const void *data, uint16_t length, } if (buf.len != 0) { - BT_DBG("Invalid receive state length %u, but only %u was parsed", + LOG_DBG("Invalid receive state length %u, but only %u was parsed", length, length - buf.len); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } @@ -182,7 +183,7 @@ static uint8_t notify_handler(struct bt_conn *conn, int16_t index; if (data == NULL) { - BT_DBG("[UNSUBSCRIBED] %u", handle); + LOG_DBG("[UNSUBSCRIBED] %u", handle); params->value_handle = 0U; return BT_GATT_ITER_STOP; @@ -192,7 +193,7 @@ static uint8_t notify_handler(struct bt_conn *conn, index = lookup_index_by_handle(handle); if (index < 0) { - BT_DBG("Invalid index"); + LOG_DBG("Invalid index"); return BT_GATT_ITER_STOP; } @@ -203,7 +204,7 @@ static uint8_t notify_handler(struct bt_conn *conn, /* TODO: Likely due to the length. * Start a read autonomously */ - BT_WARN("Invalid receive state received"); + LOG_WRN("Invalid receive state received"); return BT_GATT_ITER_STOP; } @@ -249,7 +250,7 @@ static uint8_t read_recv_state_cb(struct bt_conn *conn, uint8_t err, cb_err = parse_recv_state(data, length, &recv_state); if (cb_err != 0) { - BT_DBG("Invalid receive state"); + LOG_DBG("Invalid receive state"); } else { broadcast_assistant.src_ids[index] = recv_state.src_id; } @@ -257,7 +258,7 @@ static uint8_t read_recv_state_cb(struct bt_conn *conn, uint8_t err, } if (cb_err != 0) { - BT_DBG("err: %d", cb_err); + LOG_DBG("err: %d", cb_err); if (broadcast_assistant.discovering) { broadcast_assistant.discovering = false; if (broadcast_assistant_cbs != NULL && @@ -315,7 +316,7 @@ static uint8_t char_discover_func(struct bt_conn *conn, int err; if (attr == NULL) { - BT_DBG("Found %u BASS receive states", + LOG_DBG("Found %u BASS receive states", broadcast_assistant.recv_state_cnt); (void)memset(params, 0, sizeof(*params)); @@ -331,22 +332,21 @@ static uint8_t char_discover_func(struct bt_conn *conn, return BT_GATT_ITER_STOP; } - BT_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); + LOG_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); if (params->type == BT_GATT_DISCOVER_CHARACTERISTIC) { struct bt_gatt_chrc *chrc = (struct bt_gatt_chrc *)attr->user_data; if (bt_uuid_cmp(chrc->uuid, BT_UUID_BASS_CONTROL_POINT) == 0) { - BT_DBG("Control Point"); + LOG_DBG("Control Point"); broadcast_assistant.cp_handle = attr->handle + 1; } else if (bt_uuid_cmp(chrc->uuid, BT_UUID_BASS_RECV_STATE) == 0) { if (broadcast_assistant.recv_state_cnt < CONFIG_BT_BAP_BROADCAST_ASSISTANT_RECV_STATE_COUNT) { uint8_t idx = broadcast_assistant.recv_state_cnt++; - BT_DBG("Receive State %u", - broadcast_assistant.recv_state_cnt); + LOG_DBG("Receive State %u", broadcast_assistant.recv_state_cnt); broadcast_assistant.recv_state_handles[idx] = attr->handle + 1; sub_params = &broadcast_assistant.recv_state_sub_params[idx]; @@ -365,8 +365,8 @@ static uint8_t char_discover_func(struct bt_conn *conn, err = bt_gatt_subscribe(conn, sub_params); if (err != 0) { - BT_DBG("Could not subscribe to handle 0x%04x", - sub_params->value_handle); + LOG_DBG("Could not subscribe to handle 0x%04x", + sub_params->value_handle); broadcast_assistant.discovering = false; if (broadcast_assistant_cbs != NULL && @@ -392,7 +392,7 @@ static uint8_t service_discover_func(struct bt_conn *conn, struct bt_gatt_service_val *prim_service; if (attr == NULL) { - BT_DBG("Could not discover BASS"); + LOG_DBG("Could not discover BASS"); (void)memset(params, 0, sizeof(*params)); broadcast_assistant.discovering = false; @@ -406,7 +406,7 @@ static uint8_t service_discover_func(struct bt_conn *conn, return BT_GATT_ITER_STOP; } - BT_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); + LOG_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); if (params->type == BT_GATT_DISCOVER_PRIMARY) { prim_service = (struct bt_gatt_service_val *)attr->user_data; @@ -421,7 +421,7 @@ static uint8_t service_discover_func(struct bt_conn *conn, err = bt_gatt_discover(conn, &broadcast_assistant.disc_params); if (err != 0) { - BT_DBG("Discover failed (err %d)", err); + LOG_DBG("Discover failed (err %d)", err); broadcast_assistant.discovering = false; if (broadcast_assistant_cbs != NULL && @@ -477,7 +477,7 @@ static void bap_broadcast_assistant_write_cp_cb(struct bt_conn *conn, uint8_t er } break; default: - BT_DBG("Unknown opcode 0x%02x", opcode); + LOG_DBG("Unknown opcode 0x%02x", opcode); break; } } @@ -490,7 +490,7 @@ static int bt_bap_broadcast_assistant_common_cp(struct bt_conn *conn, if (conn == NULL) { return -EINVAL; } else if (broadcast_assistant.cp_handle == 0) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } @@ -533,8 +533,7 @@ static bool broadcast_source_found(struct bt_data *data, void *user_data) broadcast_id = sys_get_le24(data->data + BT_UUID_SIZE_16); - BT_DBG("Found BIS advertiser with address %s", - bt_addr_le_str(info->addr)); + LOG_DBG("Found BIS advertiser with address %s", bt_addr_le_str(info->addr)); if (broadcast_assistant_cbs != NULL && broadcast_assistant_cbs->scan != NULL) { @@ -617,7 +616,7 @@ int bt_bap_broadcast_assistant_scan_start(struct bt_conn *conn, bool start_scan) err = bt_le_scan_start(BT_LE_SCAN_PASSIVE, NULL); if (err != 0) { - BT_DBG("Could not start scan (%d)", err); + LOG_DBG("Could not start scan (%d)", err); return err; } @@ -650,7 +649,7 @@ int bt_bap_broadcast_assistant_scan_stop(struct bt_conn *conn) if (broadcast_assistant.scanning) { err = bt_le_scan_stop(); if (err != 0) { - BT_DBG("Could not stop scan (%d)", err); + LOG_DBG("Could not stop scan (%d)", err); return err; } @@ -714,8 +713,7 @@ int bt_bap_broadcast_assistant_add_src(struct bt_conn *conn, param->subgroups[i].metadata_len; if (cp_buf.len + subgroup_size > cp_buf.size) { - BT_DBG("MTU is too small to send %zu octets", - cp_buf.len + subgroup_size); + LOG_DBG("MTU is too small to send %zu octets", cp_buf.len + subgroup_size); return -EINVAL; } @@ -725,7 +723,7 @@ int bt_bap_broadcast_assistant_add_src(struct bt_conn *conn, subgroup->bis_sync = param->subgroups[i].bis_sync; CHECKIF(param->pa_sync == 0 && subgroup->bis_sync != 0) { - BT_DBG("Only syncing to BIS is not allowed"); + LOG_DBG("Only syncing to BIS is not allowed"); return -EINVAL; } @@ -783,8 +781,7 @@ int bt_bap_broadcast_assistant_mod_src(struct bt_conn *conn, param->subgroups[i].metadata_len; if (cp_buf.len + subgroup_size > cp_buf.size) { - BT_DBG("MTU is too small to send %zu octets", - cp_buf.len + subgroup_size); + LOG_DBG("MTU is too small to send %zu octets", cp_buf.len + subgroup_size); return -EINVAL; } subgroup = net_buf_simple_add(&cp_buf, subgroup_size); @@ -792,7 +789,7 @@ int bt_bap_broadcast_assistant_mod_src(struct bt_conn *conn, subgroup->bis_sync = param->subgroups[i].bis_sync; CHECKIF(param->pa_sync == 0 && subgroup->bis_sync != 0) { - BT_DBG("Only syncing to BIS is not allowed"); + LOG_DBG("Only syncing to BIS is not allowed"); return -EINVAL; } @@ -868,7 +865,7 @@ int bt_bap_broadcast_assistant_read_recv_state(struct bt_conn *conn, } if (broadcast_assistant.recv_state_handles[idx] == 0) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } diff --git a/subsys/bluetooth/audio/bap_scan_delegator.c b/subsys/bluetooth/audio/bap_scan_delegator.c index cb9299c9c51..983caf8e421 100644 --- a/subsys/bluetooth/audio/bap_scan_delegator.c +++ b/subsys/bluetooth/audio/bap_scan_delegator.c @@ -20,9 +20,10 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_BAP_SCAN_DELEGATOR) -#define LOG_MODULE_NAME bt_bap_scan_delegator -#include "common/log.h" +#include + +LOG_MODULE_REGISTER(bt_bap_scan_delegator, CONFIG_BT_BAP_SCAN_DELEGATOR_LOG_LEVEL); + #include "common/bt_str.h" #include "audio_internal.h" @@ -156,23 +157,21 @@ static void bt_debug_dump_recv_state(const struct bass_recv_state_internal *recv const bool is_bad_code = state->encrypt_state == BT_BAP_BIG_ENC_STATE_BAD_CODE; - BT_DBG("Receive State[%d]: src ID %u, addr %s, adv_sid %u, " - "broadcast_id %u, pa_sync_state %u, " - "encrypt state %u%s%s, num_subgroups %u", - recv_state->index, state->src_id, bt_addr_le_str(&state->addr), - state->adv_sid, state->broadcast_id, state->pa_sync_state, - state->encrypt_state, - is_bad_code ? ", bad code" : "", - is_bad_code ? bt_hex(state->bad_code, sizeof(state->bad_code)) : "", - state->num_subgroups); + LOG_DBG("Receive State[%d]: src ID %u, addr %s, adv_sid %u, " + "broadcast_id %u, pa_sync_state %u, " + "encrypt state %u%s%s, num_subgroups %u", + recv_state->index, state->src_id, bt_addr_le_str(&state->addr), state->adv_sid, + state->broadcast_id, state->pa_sync_state, state->encrypt_state, + is_bad_code ? ", bad code" : "", + is_bad_code ? bt_hex(state->bad_code, sizeof(state->bad_code)) : "", + state->num_subgroups); for (int i = 0; i < state->num_subgroups; i++) { const struct bt_bap_scan_delegator_subgroup *subgroup = &state->subgroups[i]; - BT_DBG("\tSubgroup[%d]: BIS sync %u (requested %u), metadata_len %u, metadata: %s", - i, subgroup->bis_sync, subgroup->requested_bis_sync, - subgroup->metadata_len, - bt_hex(subgroup->metadata, subgroup->metadata_len)); + LOG_DBG("\tSubgroup[%d]: BIS sync %u (requested %u), metadata_len %u, metadata: %s", + i, subgroup->bis_sync, subgroup->requested_bis_sync, subgroup->metadata_len, + bt_hex(subgroup->metadata, subgroup->metadata_len)); } } @@ -182,7 +181,7 @@ static void bass_notify_receive_state(const struct bass_recv_state_internal *sta state->attr, read_buf.data, read_buf.len); if (err != 0) { - BT_DBG("Could not notify receive state: %d", err); + LOG_DBG("Could not notify receive state: %d", err); } } @@ -230,7 +229,7 @@ static void scan_delegator_disconnected(struct bt_conn *conn, uint8_t reason) } if (assistant != NULL) { - BT_DBG("Instance %u with addr %s disconnected", + LOG_DBG("Instance %u with addr %s disconnected", i, bt_addr_le_str(bt_conn_get_dst(conn))); (void)memset(assistant, 0, sizeof(*assistant)); } @@ -263,7 +262,7 @@ static void scan_delegator_security_changed(struct bt_conn *conn, state->attr, read_buf.data, read_buf.len); if (err != 0) { - BT_WARN("Could not notify receive state[%d] to reconnecting assistant: %d", + LOG_WRN("Could not notify receive state[%d] to reconnecting assistant: %d", i, err); } } @@ -379,7 +378,7 @@ static void pa_synced(struct bt_le_per_adv_sync *sync, { struct bass_recv_state_internal *state; - BT_DBG("Synced%s", info->conn ? " via PAST" : ""); + LOG_DBG("Synced%s", info->conn ? " via PAST" : ""); if (info->conn != NULL) { state = bass_lookup_addr(info->addr); @@ -388,7 +387,7 @@ static void pa_synced(struct bt_le_per_adv_sync *sync, } if (state == NULL) { - BT_DBG("BASS receive state not found"); + LOG_DBG("BASS receive state not found"); return; } @@ -413,7 +412,7 @@ static void pa_terminated(struct bt_le_per_adv_sync *sync, { struct bass_recv_state_internal *state = bass_lookup_pa_sync(sync); - BT_DBG("Terminated"); + LOG_DBG("Terminated"); if (state != NULL) { state->state.pa_sync_state = BT_BAP_PA_STATE_NOT_SYNCED; @@ -476,7 +475,7 @@ static void biginfo_recv(struct bt_le_per_adv_sync *sync, int err = bis_sync(state); if (err != 0) { - BT_DBG("BIS sync failed %d", err); + LOG_DBG("BIS sync failed %d", err); } } @@ -498,7 +497,7 @@ static void pa_timer_handler(struct k_work *work) struct bass_recv_state_internal *recv_state = CONTAINER_OF( dwork, struct bass_recv_state_internal, pa_timer); - BT_DBG("PA timeout"); + LOG_DBG("PA timeout"); __ASSERT(recv_state, "NULL receive state"); @@ -508,7 +507,7 @@ static void pa_timer_handler(struct k_work *work) int err = bt_le_per_adv_sync_delete(recv_state->pa_sync); if (err != 0) { - BT_ERR("Could not delete BASS pa_sync"); + LOG_ERR("Could not delete BASS pa_sync"); } recv_state->state.pa_sync_state = BT_BAP_PA_STATE_FAILED; @@ -539,7 +538,7 @@ static int bis_sync(struct bass_recv_state_internal *state) param.mse = 0; param.sync_timeout = interval_to_sync_timeout(state->iso_interval); - BT_DBG("Bitfield %x", param.bis_bitfield); + LOG_DBG("Bitfield %x", param.bis_bitfield); if (param.bis_bitfield == 0) { /* Don't attempt to sync anything */ @@ -630,7 +629,7 @@ static void scan_delegator_pa_sync_no_past(struct bass_recv_state_internal *stat struct bt_le_per_adv_sync_param param = { 0 }; if (state->pa_sync_pending) { - BT_DBG("PA sync pending"); + LOG_DBG("PA sync pending"); return; } @@ -644,11 +643,10 @@ static void scan_delegator_pa_sync_no_past(struct bass_recv_state_internal *stat */ err = bt_le_per_adv_sync_create(¶m, &state->pa_sync); if (err != 0) { - BT_WARN("Could not sync per adv: %d", err); + LOG_WRN("Could not sync per adv: %d", err); recv_state->pa_sync_state = BT_BAP_PA_STATE_FAILED; } else { - BT_DBG("PA sync pending for addr %s", - bt_addr_le_str(&recv_state->addr)); + LOG_DBG("PA sync pending for addr %s", bt_addr_le_str(&recv_state->addr)); state->pa_sync_pending = true; (void)k_work_reschedule(&state->pa_timer, K_MSEC(param.timeout * 10)); @@ -668,7 +666,7 @@ static void scan_delegator_pa_sync_cancel(struct bass_recv_state_internal *state err = bt_le_per_adv_sync_delete(state->pa_sync); if (err != 0) { - BT_WARN("Could not delete per adv sync: %d", err); + LOG_WRN("Could not delete per adv sync: %d", err); } else { state->pa_sync_pending = false; state->pa_sync = NULL; @@ -682,7 +680,7 @@ static void scan_delegator_pa_sync(struct bt_conn *conn, { struct bt_bap_scan_delegator_recv_state *recv_state = &state->state; - BT_DBG("pa_past %u, pa_interval 0x%04x", pa_past, state->pa_interval); + LOG_DBG("pa_past %u, pa_interval 0x%04x", pa_past, state->pa_interval); if (recv_state->pa_sync_state == BT_BAP_PA_STATE_SYNCED || recv_state->pa_sync_state == BT_BAP_PA_STATE_INFO_REQ) { @@ -710,7 +708,7 @@ static int scan_delegator_add_source(struct bt_conn *conn, /* subtract 1 as the opcode has already been pulled */ if (buf->len < sizeof(struct bt_bap_bass_cp_add_src) - 1) { - BT_DBG("Invalid length %u", buf->size); + LOG_DBG("Invalid length %u", buf->size); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } @@ -724,7 +722,7 @@ static int scan_delegator_add_source(struct bt_conn *conn, } if (internal_state == NULL) { - BT_DBG("Could not add src"); + LOG_DBG("Could not add src"); return BT_GATT_ERR(BT_ATT_ERR_INSUFFICIENT_RESOURCES); } @@ -733,7 +731,7 @@ static int scan_delegator_add_source(struct bt_conn *conn, state->src_id = next_src_id(); state->addr.type = net_buf_simple_pull_u8(buf); if (state->addr.type > BT_ADDR_LE_RANDOM) { - BT_DBG("Invalid address type %u", state->addr.type); + LOG_DBG("Invalid address type %u", state->addr.type); return BT_GATT_ERR(BT_ATT_ERR_VALUE_NOT_ALLOWED); } @@ -742,7 +740,7 @@ static int scan_delegator_add_source(struct bt_conn *conn, state->adv_sid = net_buf_simple_pull_u8(buf); if (state->adv_sid > BT_GAP_SID_MAX) { - BT_DBG("Invalid adv SID %u", state->adv_sid); + LOG_DBG("Invalid adv SID %u", state->adv_sid); return BT_GATT_ERR(BT_ATT_ERR_VALUE_NOT_ALLOWED); } @@ -750,7 +748,7 @@ static int scan_delegator_add_source(struct bt_conn *conn, pa_sync = net_buf_simple_pull_u8(buf); if (pa_sync > BT_BAP_BASS_PA_REQ_SYNC) { - BT_DBG("Invalid PA sync value %u", pa_sync); + LOG_DBG("Invalid PA sync value %u", pa_sync); return BT_GATT_ERR(BT_ATT_ERR_VALUE_NOT_ALLOWED); } @@ -758,8 +756,8 @@ static int scan_delegator_add_source(struct bt_conn *conn, state->num_subgroups = net_buf_simple_pull_u8(buf); if (state->num_subgroups > CONFIG_BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS) { - BT_WARN("Too many subgroups %u/%u", - state->num_subgroups, CONFIG_BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS); + LOG_WRN("Too many subgroups %u/%u", state->num_subgroups, + CONFIG_BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS); return BT_GATT_ERR(BT_ATT_ERR_INSUFFICIENT_RESOURCES); } @@ -768,7 +766,7 @@ static int scan_delegator_add_source(struct bt_conn *conn, uint8_t *metadata; if (buf->len < (sizeof(subgroup->bis_sync) + sizeof(subgroup->metadata_len))) { - BT_DBG("Invalid length %u", buf->size); + LOG_DBG("Invalid length %u", buf->size); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } @@ -776,16 +774,15 @@ static int scan_delegator_add_source(struct bt_conn *conn, if (subgroup->requested_bis_sync && pa_sync == BT_BAP_BASS_PA_REQ_NO_SYNC) { - BT_DBG("Cannot sync to BIS without PA"); + LOG_DBG("Cannot sync to BIS without PA"); return BT_GATT_ERR(BT_ATT_ERR_VALUE_NOT_ALLOWED); } /* Verify that the request BIS sync indexes are unique or no preference */ if (bis_syncs_unique_or_no_pref(subgroup->requested_bis_sync, aggregated_bis_syncs)) { - BT_DBG("Duplicate BIS index [%d]%x (aggregated %x)", - i, subgroup->requested_bis_sync, - aggregated_bis_syncs); + LOG_DBG("Duplicate BIS index [%d]%x (aggregated %x)", i, + subgroup->requested_bis_sync, aggregated_bis_syncs); return BT_GATT_ERR(BT_ATT_ERR_VALUE_NOT_ALLOWED); } @@ -798,15 +795,14 @@ static int scan_delegator_add_source(struct bt_conn *conn, subgroup->metadata_len = net_buf_simple_pull_u8(buf); if (buf->len < subgroup->metadata_len) { - BT_DBG("Invalid length %u", buf->size); + LOG_DBG("Invalid length %u", buf->size); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } if (subgroup->metadata_len > CONFIG_BT_BAP_SCAN_DELEGATOR_MAX_METADATA_LEN) { - BT_WARN("Metadata too long %u/%u", - subgroup->metadata_len, + LOG_WRN("Metadata too long %u/%u", subgroup->metadata_len, CONFIG_BT_BAP_SCAN_DELEGATOR_MAX_METADATA_LEN); return BT_GATT_ERR(BT_ATT_ERR_INSUFFICIENT_RESOURCES); @@ -818,7 +814,7 @@ static int scan_delegator_add_source(struct bt_conn *conn, } if (buf->len != 0) { - BT_DBG("Invalid length %u", buf->size); + LOG_DBG("Invalid length %u", buf->size); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } @@ -831,8 +827,7 @@ static int scan_delegator_add_source(struct bt_conn *conn, (pa_sync == BT_BAP_BASS_PA_REQ_SYNC_PAST)); } - BT_DBG("Index %u: New source added: ID 0x%02x", - internal_state->index, state->src_id); + LOG_DBG("Index %u: New source added: ID 0x%02x", internal_state->index, state->src_id); bt_debug_dump_recv_state(internal_state); net_buf_put_recv_state(internal_state); @@ -860,7 +855,7 @@ static int scan_delegator_mod_src(struct bt_conn *conn, /* subtract 1 as the opcode has already been pulled */ if (buf->len < sizeof(struct bt_bap_bass_cp_mod_src) - 1) { - BT_DBG("Invalid length %u", buf->size); + LOG_DBG("Invalid length %u", buf->size); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } @@ -869,14 +864,14 @@ static int scan_delegator_mod_src(struct bt_conn *conn, internal_state = bass_lookup_src_id(src_id); if (internal_state == NULL) { - BT_DBG("Could not find state by src id %u", src_id); + LOG_DBG("Could not find state by src id %u", src_id); return BT_GATT_ERR(BT_BAP_BASS_ERR_INVALID_SRC_ID); } pa_sync = net_buf_simple_pull_u8(buf); if (pa_sync > BT_BAP_BASS_PA_REQ_SYNC) { - BT_DBG("Invalid PA sync value %u", pa_sync); + LOG_DBG("Invalid PA sync value %u", pa_sync); return BT_GATT_ERR(BT_ATT_ERR_VALUE_NOT_ALLOWED); } @@ -885,8 +880,7 @@ static int scan_delegator_mod_src(struct bt_conn *conn, num_subgroups = net_buf_simple_pull_u8(buf); if (num_subgroups > CONFIG_BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS) { - BT_WARN("Too many subgroups %u/%u", - num_subgroups, + LOG_WRN("Too many subgroups %u/%u", num_subgroups, CONFIG_BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS); return BT_GATT_ERR(BT_ATT_ERR_INSUFFICIENT_RESOURCES); @@ -897,23 +891,22 @@ static int scan_delegator_mod_src(struct bt_conn *conn, uint8_t *metadata; if (buf->len < (sizeof(subgroup->bis_sync) + sizeof(subgroup->metadata_len))) { - BT_DBG("Invalid length %u", buf->len); + LOG_DBG("Invalid length %u", buf->len); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } subgroup->requested_bis_sync = net_buf_simple_pull_le32(buf); if (subgroup->requested_bis_sync && pa_sync == BT_BAP_BASS_PA_REQ_NO_SYNC) { - BT_DBG("Cannot sync to BIS without PA"); + LOG_DBG("Cannot sync to BIS without PA"); return BT_GATT_ERR(BT_ATT_ERR_VALUE_NOT_ALLOWED); } /* Verify that the request BIS sync indexes are unique or no preference */ if (bis_syncs_unique_or_no_pref(subgroup->requested_bis_sync, aggregated_bis_syncs)) { - BT_DBG("Duplicate BIS index [%d]%x (aggregated %x)", - i, subgroup->requested_bis_sync, - aggregated_bis_syncs); + LOG_DBG("Duplicate BIS index [%d]%x (aggregated %x)", i, + subgroup->requested_bis_sync, aggregated_bis_syncs); return BT_GATT_ERR(BT_ATT_ERR_VALUE_NOT_ALLOWED); } @@ -925,13 +918,12 @@ static int scan_delegator_mod_src(struct bt_conn *conn, subgroup->metadata_len = net_buf_simple_pull_u8(buf); if (buf->len < subgroup->metadata_len) { - BT_DBG("Invalid length %u", buf->len); + LOG_DBG("Invalid length %u", buf->len); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } if (subgroup->metadata_len > CONFIG_BT_BAP_SCAN_DELEGATOR_MAX_METADATA_LEN) { - BT_WARN("Metadata too long %u/%u", - subgroup->metadata_len, + LOG_WRN("Metadata too long %u/%u", subgroup->metadata_len, CONFIG_BT_BAP_SCAN_DELEGATOR_MAX_METADATA_LEN); return BT_GATT_ERR(BT_ATT_ERR_INSUFFICIENT_RESOURCES); } @@ -943,7 +935,7 @@ static int scan_delegator_mod_src(struct bt_conn *conn, } if (buf->len != 0) { - BT_DBG("Invalid length %u", buf->size); + LOG_DBG("Invalid length %u", buf->size); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } @@ -999,7 +991,7 @@ static int scan_delegator_mod_src(struct bt_conn *conn, /* Terminated BIG first if existed */ err = bis_sync_cancel(internal_state); if (err != 0) { - BT_WARN("Could not terminate existing BIG %d", err); + LOG_WRN("Could not terminate existing BIG %d", err); return BT_GATT_ERR(BT_ATT_ERR_UNLIKELY); } @@ -1015,8 +1007,7 @@ static int scan_delegator_mod_src(struct bt_conn *conn, state_changed |= old_pa_sync_state != state->pa_sync_state; - BT_DBG("Index %u: Source modified: ID 0x%02x", - internal_state->index, state->src_id); + LOG_DBG("Index %u: Source modified: ID 0x%02x", internal_state->index, state->src_id); bt_debug_dump_recv_state(internal_state); /* Notify if changed */ @@ -1037,7 +1028,7 @@ static int scan_delegator_broadcast_code(struct net_buf_simple *buf) /* subtract 1 as the opcode has already been pulled */ if (buf->len != sizeof(struct bt_bap_bass_cp_broadcase_code) - 1) { - BT_DBG("Invalid length %u", buf->size); + LOG_DBG("Invalid length %u", buf->size); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } @@ -1045,7 +1036,7 @@ static int scan_delegator_broadcast_code(struct net_buf_simple *buf) internal_state = bass_lookup_src_id(src_id); if (internal_state == NULL) { - BT_DBG("Could not find state by src id %u", src_id); + LOG_DBG("Could not find state by src id %u", src_id); return BT_GATT_ERR(BT_BAP_BASS_ERR_INVALID_SRC_ID); } @@ -1054,9 +1045,8 @@ static int scan_delegator_broadcast_code(struct net_buf_simple *buf) (void)memcpy(internal_state->broadcast_code, broadcast_code, sizeof(internal_state->broadcast_code)); - BT_DBG("Index %u: broadcast code added: %s", internal_state->index, - bt_hex(internal_state->broadcast_code, - sizeof(internal_state->broadcast_code))); + LOG_DBG("Index %u: broadcast code added: %s", internal_state->index, + bt_hex(internal_state->broadcast_code, sizeof(internal_state->broadcast_code))); internal_state->broadcast_code_received = true; @@ -1064,11 +1054,11 @@ static int scan_delegator_broadcast_code(struct net_buf_simple *buf) return 0; } - BT_DBG("Syncing to BIS"); + LOG_DBG("Syncing to BIS"); err = bis_sync(internal_state); if (err != 0) { - BT_DBG("BIS sync failed %d", err); + LOG_DBG("BIS sync failed %d", err); return BT_GATT_ERR(BT_ATT_ERR_UNLIKELY); } @@ -1083,7 +1073,7 @@ static int scan_delegator_rem_src(struct net_buf_simple *buf) /* subtract 1 as the opcode has already been pulled */ if (buf->len != sizeof(struct bt_bap_bass_cp_rem_src) - 1) { - BT_DBG("Invalid length %u", buf->size); + LOG_DBG("Invalid length %u", buf->size); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } @@ -1091,7 +1081,7 @@ static int scan_delegator_rem_src(struct net_buf_simple *buf) internal_state = bass_lookup_src_id(src_id); if (internal_state == NULL) { - BT_DBG("Could not find state by src id %u", src_id); + LOG_DBG("Could not find state by src id %u", src_id); return BT_GATT_ERR(BT_BAP_BASS_ERR_INVALID_SRC_ID); } @@ -1100,18 +1090,17 @@ static int scan_delegator_rem_src(struct net_buf_simple *buf) /* Check if successful */ if (internal_state->pa_sync) { - BT_WARN("Could not terminate PA sync"); + LOG_WRN("Could not terminate PA sync"); return BT_GATT_ERR(BT_ATT_ERR_UNLIKELY); } err = bis_sync_cancel(internal_state); if (err != 0) { - BT_WARN("Could not terminate BIG %d", err); + LOG_WRN("Could not terminate BIG %d", err); return BT_GATT_ERR(BT_ATT_ERR_UNLIKELY); } - BT_DBG("Index %u: Removed source with ID 0x%02x", - internal_state->index, src_id); + LOG_DBG("Index %u: Removed source with ID 0x%02x", internal_state->index, src_id); internal_state->active = false; (void)memset(&internal_state->state, 0, sizeof(internal_state->state)); @@ -1162,60 +1151,60 @@ static ssize_t write_control_point(struct bt_conn *conn, switch (opcode) { case BT_BAP_BASS_OP_SCAN_STOP: - BT_DBG("Assistant stopping scanning"); + LOG_DBG("Assistant stopping scanning"); if (buf.len != 0) { - BT_DBG("Invalid length %u", buf.size); + LOG_DBG("Invalid length %u", buf.size); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } bap_broadcast_assistant->scanning = false; break; case BT_BAP_BASS_OP_SCAN_START: - BT_DBG("Assistant starting scanning"); + LOG_DBG("Assistant starting scanning"); if (buf.len != 0) { - BT_DBG("Invalid length %u", buf.size); + LOG_DBG("Invalid length %u", buf.size); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } bap_broadcast_assistant->scanning = true; break; case BT_BAP_BASS_OP_ADD_SRC: - BT_DBG("Assistant adding source"); + LOG_DBG("Assistant adding source"); err = scan_delegator_add_source(conn, &buf); if (err != 0) { - BT_DBG("Could not add source %d", err); + LOG_DBG("Could not add source %d", err); return err; } break; case BT_BAP_BASS_OP_MOD_SRC: - BT_DBG("Assistant modifying source"); + LOG_DBG("Assistant modifying source"); err = scan_delegator_mod_src(conn, &buf); if (err != 0) { - BT_DBG("Could not modify source %d", err); + LOG_DBG("Could not modify source %d", err); return err; } break; case BT_BAP_BASS_OP_BROADCAST_CODE: - BT_DBG("Assistant setting broadcast code"); + LOG_DBG("Assistant setting broadcast code"); err = scan_delegator_broadcast_code(&buf); if (err != 0) { - BT_DBG("Could not set broadcast code"); + LOG_DBG("Could not set broadcast code"); return err; } break; case BT_BAP_BASS_OP_REM_SRC: - BT_DBG("Assistant removing source"); + LOG_DBG("Assistant removing source"); err = scan_delegator_rem_src(&buf); if (err != 0) { - BT_DBG("Could not remove source %d", err); + LOG_DBG("Could not remove source %d", err); return err; } @@ -1230,7 +1219,7 @@ static ssize_t write_control_point(struct bt_conn *conn, static void recv_state_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("value 0x%04x", value); + LOG_DBG("value 0x%04x", value); } static ssize_t read_recv_state(struct bt_conn *conn, @@ -1242,7 +1231,7 @@ static ssize_t read_recv_state(struct bt_conn *conn, struct bt_bap_scan_delegator_recv_state *state = &recv_state->state; if (recv_state->active) { - BT_DBG("Index %u: Source ID 0x%02x", idx, state->src_id); + LOG_DBG("Index %u: Source ID 0x%02x", idx, state->src_id); bt_debug_dump_recv_state(recv_state); @@ -1251,7 +1240,7 @@ static ssize_t read_recv_state(struct bt_conn *conn, return bt_gatt_attr_read(conn, attr, buf, len, offset, read_buf.data, read_buf.len); } else { - BT_DBG("Index %u: Not active", idx); + LOG_DBG("Index %u: Not active", idx); return bt_gatt_attr_read(conn, attr, buf, len, offset, NULL, 0); } @@ -1334,15 +1323,15 @@ int bt_bap_scan_delegator_set_sync_state( if (bis_synced[i] != 0 && pa_sync_state == BT_BAP_PA_STATE_NOT_SYNCED) { - BT_DBG("Cannot set BIS sync when PA sync is not synced"); + LOG_DBG("Cannot set BIS sync when PA sync is not synced"); return -EINVAL; } if (bits_subset_of(bis_synced[i], subgroup->requested_bis_sync)) { - BT_DBG("Subgroup[%d] invalid bis_sync value %x for %x", - i, bis_synced[i], subgroup->requested_bis_sync); + LOG_DBG("Subgroup[%d] invalid bis_sync value %x for %x", i, bis_synced[i], + subgroup->requested_bis_sync); return -EINVAL; } @@ -1353,7 +1342,7 @@ int bt_bap_scan_delegator_set_sync_state( } } - BT_DBG("Index %u: Source ID 0x%02x synced", recv_state->index, src_id); + LOG_DBG("Index %u: Source ID 0x%02x synced", recv_state->index, src_id); if (recv_state->state.pa_sync_state != pa_sync_state || recv_state->state.encrypt_state != encrypt_state) { diff --git a/subsys/bluetooth/audio/broadcast_sink.c b/subsys/bluetooth/audio/broadcast_sink.c index 75edce9fec4..7c8855f74c9 100644 --- a/subsys/bluetooth/audio/broadcast_sink.c +++ b/subsys/bluetooth/audio/broadcast_sink.c @@ -22,9 +22,10 @@ #include "audio_iso.h" #include "endpoint.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_AUDIO_DEBUG_BROADCAST_SINK) -#define LOG_MODULE_NAME bt_audio_broadcast_sink -#include "common/log.h" +#include + +LOG_MODULE_REGISTER(bt_audio_broadcast_sink, CONFIG_BT_AUDIO_BROADCAST_SINK_LOG_LEVEL); + #include "common/bt_str.h" #define PA_SYNC_SKIP 5 @@ -77,34 +78,33 @@ static void broadcast_sink_set_ep_state(struct bt_audio_ep *ep, uint8_t state) old_state = ep->status.state; - BT_DBG("ep %p id 0x%02x %s -> %s", ep, ep->status.id, - bt_audio_ep_state_str(old_state), - bt_audio_ep_state_str(state)); + LOG_DBG("ep %p id 0x%02x %s -> %s", ep, ep->status.id, bt_audio_ep_state_str(old_state), + bt_audio_ep_state_str(state)); switch (old_state) { case BT_AUDIO_EP_STATE_IDLE: if (state != BT_AUDIO_EP_STATE_QOS_CONFIGURED) { - BT_DBG("Invalid broadcast sync endpoint state transition"); + LOG_DBG("Invalid broadcast sync endpoint state transition"); return; } break; case BT_AUDIO_EP_STATE_QOS_CONFIGURED: if (state != BT_AUDIO_EP_STATE_IDLE && state != BT_AUDIO_EP_STATE_STREAMING) { - BT_DBG("Invalid broadcast sync endpoint state transition"); + LOG_DBG("Invalid broadcast sync endpoint state transition"); return; } break; case BT_AUDIO_EP_STATE_STREAMING: if (state != BT_AUDIO_EP_STATE_IDLE) { - BT_DBG("Invalid broadcast sync endpoint state transition"); + LOG_DBG("Invalid broadcast sync endpoint state transition"); return; } break; default: - BT_ERR("Invalid broadcast sync endpoint state: %s", - bt_audio_ep_state_str(old_state)); + LOG_ERR("Invalid broadcast sync endpoint state: %s", + bt_audio_ep_state_str(old_state)); return; } @@ -132,27 +132,26 @@ static void broadcast_sink_iso_recv(struct bt_iso_chan *chan, struct bt_audio_ep *ep = iso->rx.ep; if (ep == NULL) { - BT_ERR("iso %p not bound with ep", chan); + LOG_ERR("iso %p not bound with ep", chan); return; } stream = ep->stream; if (stream == NULL) { - BT_ERR("No stream for ep %p", ep); + LOG_ERR("No stream for ep %p", ep); return; } ops = stream->ops; if (IS_ENABLED(CONFIG_BT_AUDIO_DEBUG_STREAM_DATA)) { - BT_DBG("stream %p ep %p len %zu", - stream, ep, net_buf_frags_len(buf)); + LOG_DBG("stream %p ep %p len %zu", stream, stream->ep, net_buf_frags_len(buf)); } if (ops != NULL && ops->recv != NULL) { ops->recv(stream, info, buf); } else { - BT_WARN("No callback for recv set"); + LOG_WRN("No callback for recv set"); } } @@ -164,26 +163,26 @@ static void broadcast_sink_iso_connected(struct bt_iso_chan *chan) struct bt_audio_ep *ep = iso->rx.ep; if (ep == NULL) { - BT_ERR("iso %p not bound with ep", chan); + LOG_ERR("iso %p not bound with ep", chan); return; } stream = ep->stream; if (stream == NULL) { - BT_ERR("No stream for ep %p", ep); + LOG_ERR("No stream for ep %p", ep); return; } ops = stream->ops; - BT_DBG("stream %p", stream); + LOG_DBG("stream %p", stream); broadcast_sink_set_ep_state(ep, BT_AUDIO_EP_STATE_STREAMING); if (ops != NULL && ops->started != NULL) { ops->started(stream); } else { - BT_WARN("No callback for connected set"); + LOG_WRN("No callback for connected set"); } } @@ -197,31 +196,31 @@ static void broadcast_sink_iso_disconnected(struct bt_iso_chan *chan, struct bt_audio_broadcast_sink *sink; if (ep == NULL) { - BT_ERR("iso %p not bound with ep", chan); + LOG_ERR("iso %p not bound with ep", chan); return; } stream = ep->stream; if (stream == NULL) { - BT_ERR("No stream for ep %p", ep); + LOG_ERR("No stream for ep %p", ep); return; } ops = stream->ops; - BT_DBG("stream %p ep %p reason 0x%02x", stream, ep, reason); + LOG_DBG("stream %p ep %p reason 0x%02x", stream, ep, reason); broadcast_sink_set_ep_state(ep, BT_AUDIO_EP_STATE_IDLE); if (ops != NULL && ops->stopped != NULL) { ops->stopped(stream); } else { - BT_WARN("No callback for stopped set"); + LOG_WRN("No callback for stopped set"); } sink = broadcast_sink_lookup_iso_chan(chan); if (sink == NULL) { - BT_ERR("Could not lookup sink by iso %p", chan); + LOG_ERR("Could not lookup sink by iso %p", chan); return; } @@ -287,7 +286,7 @@ static void pa_synced(struct bt_le_per_adv_sync *sync, return; } - BT_DBG("Synced to broadcast source with ID 0x%06X", sink->broadcast_id); + LOG_DBG("Synced to broadcast source with ID 0x%06X", sink->broadcast_id); sink->syncing = false; @@ -316,8 +315,7 @@ static void pa_term(struct bt_le_per_adv_sync *sync, return; } - BT_DBG("PA sync with broadcast source with ID 0x%06X lost", - sink->broadcast_id); + LOG_DBG("PA sync with broadcast source with ID 0x%06X lost", sink->broadcast_id); broadcast_sink_cleanup(sink); SYS_SLIST_FOR_EACH_CONTAINER(&sink_cbs, listener, _node) { if (listener->pa_sync_lost != NULL) { @@ -332,13 +330,13 @@ static bool net_buf_decode_codec_ltv(struct net_buf_simple *buf, void *value; if (buf->len < sizeof(codec_data->data.data_len)) { - BT_DBG("Not enough data for LTV length field: %u", buf->len); + LOG_DBG("Not enough data for LTV length field: %u", buf->len); return false; } codec_data->data.data_len = net_buf_simple_pull_u8(buf); if (buf->len < sizeof(codec_data->data.type)) { - BT_DBG("Not enough data for LTV type field: %u", buf->len); + LOG_DBG("Not enough data for LTV type field: %u", buf->len); return false; } @@ -351,8 +349,8 @@ static bool net_buf_decode_codec_ltv(struct net_buf_simple *buf, codec_data->data.data = codec_data->value; if (buf->len < codec_data->data.data_len) { - BT_DBG("Not enough data for LTV value field: %u/%zu", - buf->len, codec_data->data.data_len); + LOG_DBG("Not enough data for LTV value field: %u/%zu", buf->len, + codec_data->data.data_len); return false; } value = net_buf_simple_pull_mem(buf, codec_data->data.data_len); @@ -367,20 +365,20 @@ static bool net_buf_decode_bis_data(struct net_buf_simple *buf, uint8_t len; if (buf->len < BASE_BIS_DATA_MIN_SIZE) { - BT_DBG("Not enough bytes (%u) to decode BIS data", buf->len); + LOG_DBG("Not enough bytes (%u) to decode BIS data", buf->len); return false; } bis->index = net_buf_simple_pull_u8(buf); if (!IN_RANGE(bis->index, BT_ISO_BIS_INDEX_MIN, BT_ISO_BIS_INDEX_MAX)) { - BT_DBG("Invalid BIS index %u", bis->index); + LOG_DBG("Invalid BIS index %u", bis->index); return false; } /* codec config data length */ len = net_buf_simple_pull_u8(buf); if (len > buf->len) { - BT_DBG("Invalid BIS specific codec config data length: " + LOG_DBG("Invalid BIS specific codec config data length: " "%u (buf is %u)", len, buf->len); return false; } @@ -402,8 +400,8 @@ static bool net_buf_decode_bis_data(struct net_buf_simple *buf, if (!net_buf_decode_codec_ltv(<v_buf, bis_codec_data)) { - BT_DBG("Failed to decode BIS config data for entry %u", - bis->data_count); + LOG_DBG("Failed to decode BIS config data for entry %u", + bis->data_count); return false; } bis->data_count++; @@ -425,9 +423,8 @@ static bool net_buf_decode_subgroup(struct net_buf_simple *buf, subgroup->bis_count = net_buf_simple_pull_u8(buf); if (subgroup->bis_count > ARRAY_SIZE(subgroup->bis_data)) { - BT_DBG("BASE has more BIS %u than we support %u", - subgroup->bis_count, - (uint8_t)ARRAY_SIZE(subgroup->bis_data)); + LOG_DBG("BASE has more BIS %u than we support %u", subgroup->bis_count, + (uint8_t)ARRAY_SIZE(subgroup->bis_data)); return false; } codec->id = net_buf_simple_pull_u8(buf); @@ -437,8 +434,7 @@ static bool net_buf_decode_subgroup(struct net_buf_simple *buf, /* codec configuration data length */ len = net_buf_simple_pull_u8(buf); if (len > buf->len) { - BT_DBG("Invalid codec config data length: %u (buf is %u)", - len, buf->len); + LOG_DBG("Invalid codec config data length: %u (buf is %u)", len, buf->len); return false; } @@ -457,8 +453,8 @@ static bool net_buf_decode_subgroup(struct net_buf_simple *buf, struct bt_codec_data *codec_data = &codec->data[codec->data_count++]; if (!net_buf_decode_codec_ltv(<v_buf, codec_data)) { - BT_DBG("Failed to decode codec config data for entry %u", - codec->data_count - 1); + LOG_DBG("Failed to decode codec config data for entry %u", + codec->data_count - 1); return false; } } @@ -470,8 +466,7 @@ static bool net_buf_decode_subgroup(struct net_buf_simple *buf, /* codec metadata length */ len = net_buf_simple_pull_u8(buf); if (len > buf->len) { - BT_DBG("Invalid codec config data length: %u (buf is %u)", - len, buf->len); + LOG_DBG("Invalid codec config data length: %u (buf is %u)", len, buf->len); return false; } @@ -491,15 +486,15 @@ static bool net_buf_decode_subgroup(struct net_buf_simple *buf, struct bt_codec_data *metadata = &codec->meta[codec->meta_count++]; if (!net_buf_decode_codec_ltv(<v_buf, metadata)) { - BT_DBG("Failed to decode codec metadata for entry %u", - codec->meta_count - 1); + LOG_DBG("Failed to decode codec metadata for entry %u", + codec->meta_count - 1); return false; } } for (int i = 0; i < subgroup->bis_count; i++) { if (!net_buf_decode_bis_data(buf, &subgroup->bis_data[i])) { - BT_DBG("Failed to decode BIS data for bis %d", i); + LOG_DBG("Failed to decode BIS data for bis %d", i); return false; } } @@ -536,7 +531,7 @@ static bool pa_decode_base(struct bt_data *data, void *user_data) uuid = net_buf_simple_pull_mem(&net_buf, BT_UUID_SIZE_16); if (!bt_uuid_create(&broadcast_uuid.uuid, uuid, BT_UUID_SIZE_16)) { - BT_ERR("bt_uuid_create failed"); + LOG_ERR("bt_uuid_create failed"); return false; } @@ -549,15 +544,15 @@ static bool pa_decode_base(struct bt_data *data, void *user_data) base.subgroup_count = net_buf_simple_pull_u8(&net_buf); if (base.subgroup_count > ARRAY_SIZE(base.subgroups)) { - BT_DBG("Cannot decode BASE with %u subgroups (max supported is %zu)", - base.subgroup_count, ARRAY_SIZE(base.subgroups)); + LOG_DBG("Cannot decode BASE with %u subgroups (max supported is %zu)", + base.subgroup_count, ARRAY_SIZE(base.subgroups)); return false; } for (int i = 0; i < base.subgroup_count; i++) { if (!net_buf_decode_subgroup(&net_buf, &base.subgroups[i])) { - BT_DBG("Failed to decode subgroup %d", i); + LOG_DBG("Failed to decode subgroup %d", i); return false; } } @@ -570,7 +565,7 @@ static bool pa_decode_base(struct bt_data *data, void *user_data) } if (num_bis > sink->biginfo_num_bis) { - BT_WARN("BASE contains more BIS than reported by BIGInfo"); + LOG_WRN("BASE contains more BIS than reported by BIGInfo"); return false; } } @@ -684,10 +679,10 @@ static void sync_broadcast_pa(const struct bt_le_scan_recv_info *info, param.timeout = interval_to_sync_timeout(info->interval); err = bt_le_per_adv_sync_create(¶m, &sink->pa_sync); if (err != 0) { - BT_ERR("Could not sync to PA: %d", err); + LOG_ERR("Could not sync to PA: %d", err); err = bt_le_scan_stop(); if (err != 0 && err != -EALREADY) { - BT_ERR("Could not stop scan: %d", err); + LOG_ERR("Could not stop scan: %d", err); } SYS_SLIST_FOR_EACH_CONTAINER(&sink_cbs, listener, _node) { @@ -764,8 +759,8 @@ static void broadcast_scan_recv(const struct bt_le_scan_recv_info *info, * If it was then that means that we found a broadcast source */ if (broadcast_id != INVALID_BROADCAST_ID) { - BT_DBG("Found broadcast source with address %s and id 0x%6X", - bt_addr_le_str(info->addr), broadcast_id); + LOG_DBG("Found broadcast source with address %s and id 0x%6X", + bt_addr_le_str(info->addr), broadcast_id); SYS_SLIST_FOR_EACH_CONTAINER(&sink_cbs, listener, _node) { if (listener->scan_recv != NULL) { @@ -814,7 +809,7 @@ int bt_audio_broadcast_sink_scan_start(const struct bt_le_scan_param *param) int err; CHECKIF(param == NULL) { - BT_DBG("param is NULL"); + LOG_DBG("param is NULL"); return -EINVAL; } @@ -822,17 +817,17 @@ int bt_audio_broadcast_sink_scan_start(const struct bt_le_scan_param *param) /* This is to avoid having to re-implement the scan timeout * callback as well, and can be modified later if requested */ - BT_DBG("Scan param shall not have a timeout"); + LOG_DBG("Scan param shall not have a timeout"); return -EINVAL; } if (sys_slist_is_empty(&sink_cbs)) { - BT_WARN("No broadcast sink callbacks registered"); + LOG_WRN("No broadcast sink callbacks registered"); return -EINVAL; } if (broadcast_sink_free_get() == NULL) { - BT_DBG("No more free broadcast sinks"); + LOG_DBG("No more free broadcast sinks"); return -ENOMEM; } @@ -857,7 +852,7 @@ int bt_audio_broadcast_sink_scan_stop(void) if (sink != NULL) { err = bt_le_per_adv_sync_delete(sink->pa_sync); if (err != 0) { - BT_DBG("Could not delete PA sync: %d", err); + LOG_DBG("Could not delete PA sync: %d", err); return err; } sink->pa_sync = NULL; @@ -891,7 +886,7 @@ bool bt_audio_ep_is_broadcast_snk(const struct bt_audio_ep *ep) static void broadcast_sink_ep_init(struct bt_audio_ep *ep) { - BT_DBG("ep %p", ep); + LOG_DBG("ep %p", ep); (void)memset(ep, 0, sizeof(*ep)); ep->dir = BT_AUDIO_DIR_SINK; @@ -922,19 +917,19 @@ static int bt_audio_broadcast_sink_setup_stream(uint8_t index, struct bt_audio_ep *ep; if (stream->group != NULL) { - BT_DBG("Stream %p already in group %p", stream, stream->group); + LOG_DBG("Stream %p already in group %p", stream, stream->group); return -EALREADY; } ep = broadcast_sink_new_ep(index); if (ep == NULL) { - BT_DBG("Could not allocate new broadcast endpoint"); + LOG_DBG("Could not allocate new broadcast endpoint"); return -ENOMEM; } iso = bt_audio_iso_new(); if (iso == NULL) { - BT_DBG("Could not allocate iso"); + LOG_DBG("Could not allocate iso"); return -ENOMEM; } @@ -1019,27 +1014,27 @@ int bt_audio_broadcast_sink_sync(struct bt_audio_broadcast_sink *sink, int err; CHECKIF(sink == NULL) { - BT_DBG("sink is NULL"); + LOG_DBG("sink is NULL"); return -EINVAL; } CHECKIF(indexes_bitfield == 0) { - BT_DBG("indexes_bitfield is 0"); + LOG_DBG("indexes_bitfield is 0"); return -EINVAL; } CHECKIF(indexes_bitfield & BIT(0)) { - BT_DBG("BIT(0) is not a valid BIS index"); + LOG_DBG("BIT(0) is not a valid BIS index"); return -EINVAL; } CHECKIF(streams == NULL) { - BT_DBG("streams is NULL"); + LOG_DBG("streams is NULL"); return -EINVAL; } if (sink->pa_sync == NULL) { - BT_DBG("Sink is not PA synced"); + LOG_DBG("Sink is not PA synced"); return -EINVAL; } @@ -1048,12 +1043,12 @@ int bt_audio_broadcast_sink_sync(struct bt_audio_broadcast_sink *sink, * once the BIGInfo has been received, and then do the sync * then. This would be similar how LE Create Connection works. */ - BT_DBG("BIGInfo not received, cannot sync yet"); + LOG_DBG("BIGInfo not received, cannot sync yet"); return -EAGAIN; } CHECKIF(sink->big_encrypted && broadcast_code == NULL) { - BT_DBG("Broadcast code required"); + LOG_DBG("Broadcast code required"); return -EINVAL; } @@ -1065,7 +1060,7 @@ int bt_audio_broadcast_sink_sync(struct bt_audio_broadcast_sink *sink, struct codec_lookup_id_data lookup_data = { }; if (codec == NULL) { - BT_DBG("Index %d not found in BASE", i); + LOG_DBG("Index %d not found in BASE", i); return -EINVAL; } @@ -1075,7 +1070,7 @@ int bt_audio_broadcast_sink_sync(struct bt_audio_broadcast_sink *sink, bt_pacs_cap_foreach(BT_AUDIO_DIR_SINK, codec_lookup_id, &lookup_data); if (lookup_data.codec == NULL) { - BT_DBG("Codec with id %u is not supported by our capabilities", + LOG_DBG("Codec with id %u is not supported by our capabilities", codec->id); return -ENOENT; @@ -1086,8 +1081,8 @@ int bt_audio_broadcast_sink_sync(struct bt_audio_broadcast_sink *sink, codecs[stream_count++] = codec; if (stream_count > BROADCAST_SNK_STREAM_CNT) { - BT_DBG("Cannot sync to more than %d streams", - BROADCAST_SNK_STREAM_CNT); + LOG_DBG("Cannot sync to more than %d streams", + BROADCAST_SNK_STREAM_CNT); return -EINVAL; } } @@ -1095,7 +1090,7 @@ int bt_audio_broadcast_sink_sync(struct bt_audio_broadcast_sink *sink, for (size_t i = 0; i < stream_count; i++) { CHECKIF(streams[i] == NULL) { - BT_DBG("streams[%zu] is NULL", i); + LOG_DBG("streams[%zu] is NULL", i); return -EINVAL; } } @@ -1111,7 +1106,7 @@ int bt_audio_broadcast_sink_sync(struct bt_audio_broadcast_sink *sink, err = bt_audio_broadcast_sink_setup_stream(sink->index, stream, codec); if (err != 0) { - BT_DBG("Failed to setup streams[%zu]: %d", i, err); + LOG_DBG("Failed to setup streams[%zu]: %d", i, err); broadcast_sink_cleanup_streams(sink); return err; } @@ -1157,12 +1152,12 @@ int bt_audio_broadcast_sink_stop(struct bt_audio_broadcast_sink *sink) int err; CHECKIF(sink == NULL) { - BT_DBG("sink is NULL"); + LOG_DBG("sink is NULL"); return -EINVAL; } if (sys_slist_is_empty(&sink->streams)) { - BT_DBG("Source does not have any streams"); + LOG_DBG("Source does not have any streams"); return -EINVAL; } @@ -1173,20 +1168,20 @@ int bt_audio_broadcast_sink_stop(struct bt_audio_broadcast_sink *sink) * so we can just check the first stream */ if (stream->ep == NULL) { - BT_DBG("stream->ep is NULL"); + LOG_DBG("stream->ep is NULL"); return -EINVAL; } if (stream->ep->status.state != BT_AUDIO_EP_STATE_STREAMING && stream->ep->status.state != BT_AUDIO_EP_STATE_QOS_CONFIGURED) { - BT_DBG("Broadcast sink stream %p invalid state: %u", - stream, stream->ep->status.state); + LOG_DBG("Broadcast sink stream %p invalid state: %u", stream, + stream->ep->status.state); return -EBADMSG; } err = bt_iso_big_terminate(sink->big); if (err) { - BT_DBG("Failed to terminate BIG (err %d)", err); + LOG_DBG("Failed to terminate BIG (err %d)", err); return err; } @@ -1201,7 +1196,7 @@ int bt_audio_broadcast_sink_delete(struct bt_audio_broadcast_sink *sink) int err; CHECKIF(sink == NULL) { - BT_DBG("sink is NULL"); + LOG_DBG("sink is NULL"); return -EINVAL; } @@ -1216,20 +1211,19 @@ int bt_audio_broadcast_sink_delete(struct bt_audio_broadcast_sink *sink) * so we can just check the first stream */ if (stream->ep != NULL) { - BT_DBG("Sink is not stopped"); + LOG_DBG("Sink is not stopped"); return -EBADMSG; } } if (sink->pa_sync == NULL) { - BT_DBG("Broadcast sink is already deleted"); + LOG_DBG("Broadcast sink is already deleted"); return -EALREADY; } err = bt_le_per_adv_sync_delete(sink->pa_sync); if (err != 0) { - BT_DBG("Failed to delete periodic advertising sync (err %d)", - err); + LOG_DBG("Failed to delete periodic advertising sync (err %d)", err); return err; } diff --git a/subsys/bluetooth/audio/broadcast_source.c b/subsys/bluetooth/audio/broadcast_source.c index cc6335d1f17..06eb7ddf17f 100644 --- a/subsys/bluetooth/audio/broadcast_source.c +++ b/subsys/bluetooth/audio/broadcast_source.c @@ -15,9 +15,8 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_AUDIO_DEBUG_BROADCAST_SOURCE) -#define LOG_MODULE_NAME bt_audio_broadcast_source -#include "common/log.h" +#include +LOG_MODULE_REGISTER(bt_audio_broadcast_source, CONFIG_BT_AUDIO_BROADCAST_SOURCE_LOG_LEVEL); #include "audio_iso.h" #include "endpoint.h" @@ -68,39 +67,37 @@ static void broadcast_source_set_ep_state(struct bt_audio_ep *ep, uint8_t state) old_state = ep->status.state; - BT_DBG("ep %p id 0x%02x %s -> %s", ep, ep->status.id, - bt_audio_ep_state_str(old_state), - bt_audio_ep_state_str(state)); - + LOG_DBG("ep %p id 0x%02x %s -> %s", ep, ep->status.id, bt_audio_ep_state_str(old_state), + bt_audio_ep_state_str(state)); switch (old_state) { case BT_AUDIO_EP_STATE_IDLE: if (state != BT_AUDIO_EP_STATE_QOS_CONFIGURED) { - BT_DBG("Invalid broadcast sync endpoint state transition"); + LOG_DBG("Invalid broadcast sync endpoint state transition"); return; } break; case BT_AUDIO_EP_STATE_QOS_CONFIGURED: if (state != BT_AUDIO_EP_STATE_IDLE && state != BT_AUDIO_EP_STATE_ENABLING) { - BT_DBG("Invalid broadcast sync endpoint state transition"); + LOG_DBG("Invalid broadcast sync endpoint state transition"); return; } break; case BT_AUDIO_EP_STATE_ENABLING: if (state != BT_AUDIO_EP_STATE_STREAMING) { - BT_DBG("Invalid broadcast sync endpoint state transition"); + LOG_DBG("Invalid broadcast sync endpoint state transition"); return; } break; case BT_AUDIO_EP_STATE_STREAMING: if (state != BT_AUDIO_EP_STATE_QOS_CONFIGURED) { - BT_DBG("Invalid broadcast sync endpoint state transition"); + LOG_DBG("Invalid broadcast sync endpoint state transition"); return; } break; default: - BT_ERR("Invalid broadcast sync endpoint state: %s", + LOG_ERR("Invalid broadcast sync endpoint state: %s", bt_audio_ep_state_str(old_state)); return; } @@ -126,20 +123,20 @@ static void broadcast_source_iso_sent(struct bt_iso_chan *chan) struct bt_audio_ep *ep = iso->tx.ep; if (ep == NULL) { - BT_ERR("iso %p not bound with ep", chan); + LOG_ERR("iso %p not bound with ep", chan); return; } stream = ep->stream; if (stream == NULL) { - BT_ERR("No stream for ep %p", ep); + LOG_ERR("No stream for ep %p", ep); return; } ops = stream->ops; if (IS_ENABLED(CONFIG_BT_AUDIO_DEBUG_STREAM_DATA)) { - BT_DBG("stream %p ep %p", stream, stream->ep); + LOG_DBG("stream %p ep %p", stream, stream->ep); } if (ops != NULL && ops->sent != NULL) { @@ -155,26 +152,26 @@ static void broadcast_source_iso_connected(struct bt_iso_chan *chan) struct bt_audio_ep *ep = iso->tx.ep; if (ep == NULL) { - BT_ERR("iso %p not bound with ep", chan); + LOG_ERR("iso %p not bound with ep", chan); return; } stream = ep->stream; if (stream == NULL) { - BT_ERR("No stream for ep %p", ep); + LOG_ERR("No stream for ep %p", ep); return; } ops = stream->ops; - BT_DBG("stream %p ep %p", stream, ep); + LOG_DBG("stream %p ep %p", stream, ep); broadcast_source_set_ep_state(ep, BT_AUDIO_EP_STATE_STREAMING); if (ops != NULL && ops->started != NULL) { ops->started(stream); } else { - BT_WARN("No callback for connected set"); + LOG_WRN("No callback for connected set"); } } @@ -186,26 +183,26 @@ static void broadcast_source_iso_disconnected(struct bt_iso_chan *chan, uint8_t struct bt_audio_ep *ep = iso->tx.ep; if (ep == NULL) { - BT_ERR("iso %p not bound with ep", chan); + LOG_ERR("iso %p not bound with ep", chan); return; } stream = ep->stream; if (stream == NULL) { - BT_ERR("No stream for ep %p", ep); + LOG_ERR("No stream for ep %p", ep); return; } ops = stream->ops; - BT_DBG("stream %p ep %p reason 0x%02x", stream, stream->ep, reason); + LOG_DBG("stream %p ep %p reason 0x%02x", stream, stream->ep, reason); broadcast_source_set_ep_state(ep, BT_AUDIO_EP_STATE_QOS_CONFIGURED); if (ops != NULL && ops->stopped != NULL) { ops->stopped(stream); } else { - BT_WARN("No callback for stopped set"); + LOG_WRN("No callback for stopped set"); } } @@ -228,7 +225,7 @@ bool bt_audio_ep_is_broadcast_src(const struct bt_audio_ep *ep) static void broadcast_source_ep_init(struct bt_audio_ep *ep) { - BT_DBG("ep %p", ep); + LOG_DBG("ep %p", ep); (void)memset(ep, 0, sizeof(*ep)); ep->dir = BT_AUDIO_DIR_SOURCE; @@ -275,13 +272,13 @@ static int broadcast_source_setup_stream(uint8_t index, ep = broadcast_source_new_ep(index); if (ep == NULL) { - BT_DBG("Could not allocate new broadcast endpoint"); + LOG_DBG("Could not allocate new broadcast endpoint"); return -ENOMEM; } iso = bt_audio_iso_new(); if (iso == NULL) { - BT_DBG("Could not allocate iso"); + LOG_DBG("Could not allocate iso"); return -ENOMEM; } @@ -334,8 +331,7 @@ static bool encode_base_subgroup(struct bt_audio_broadcast_subgroup *subgroup, if ((buf->size - buf->len) < (sizeof(codec_data->data_len) + sizeof(codec_data->type) + codec_data->data_len)) { - BT_DBG("No room for codec[%d] with len %u", - i, codec_data->data_len); + LOG_DBG("No room for codec[%d] with len %u", i, codec_data->data_len); return false; } @@ -351,7 +347,7 @@ static bool encode_base_subgroup(struct bt_audio_broadcast_subgroup *subgroup, *start = len; if ((buf->size - buf->len) < sizeof(len)) { - BT_DBG("No room for metadata length"); + LOG_DBG("No room for metadata length"); return false; } @@ -364,8 +360,7 @@ static bool encode_base_subgroup(struct bt_audio_broadcast_subgroup *subgroup, if ((buf->size - buf->len) < (sizeof(metadata->data_len) + sizeof(metadata->type) + metadata->data_len)) { - BT_DBG("No room for metadata[%d] with len %u", - i, metadata->data_len); + LOG_DBG("No room for metadata[%d] with len %u", i, metadata->data_len); return false; } @@ -384,7 +379,7 @@ static bool encode_base_subgroup(struct bt_audio_broadcast_subgroup *subgroup, for (int i = 0; i < stream_count; i++) { bis_index++; if ((buf->size - buf->len) < (sizeof(bis_index) + sizeof(uint8_t))) { - BT_DBG("No room for BIS[%d] index", i); + LOG_DBG("No room for BIS[%d] index", i); return false; } @@ -392,7 +387,7 @@ static bool encode_base_subgroup(struct bt_audio_broadcast_subgroup *subgroup, net_buf_simple_add_u8(buf, bis_index); if ((buf->size - buf->len) < sizeof(len)) { - BT_DBG("No room for bis codec config length"); + LOG_DBG("No room for bis codec config length"); return false; } @@ -407,8 +402,8 @@ static bool encode_base_subgroup(struct bt_audio_broadcast_subgroup *subgroup, if ((buf->size - buf->len) < (sizeof(codec_data->data_len) + sizeof(codec_data->type) + codec_data->data_len)) { - BT_DBG("No room for BIS [%u] codec[%zu] with len %u", - bis_index, j, codec_data->data_len); + LOG_DBG("No room for BIS [%u] codec[%zu] with len %u", bis_index, j, + codec_data->data_len); return false; } @@ -528,23 +523,23 @@ static bool valid_create_param(const struct bt_audio_broadcast_source_create_par const struct bt_codec_qos *qos; CHECKIF(param == NULL) { - BT_DBG("param is NULL"); + LOG_DBG("param is NULL"); return false; } CHECKIF(param->params_count == 0U) { - BT_DBG("param->params_count is 0"); + LOG_DBG("param->params_count is 0"); return false; } qos = param->qos; CHECKIF(qos == NULL) { - BT_DBG("param->qos is NULL"); + LOG_DBG("param->qos is NULL"); return false; } CHECKIF(!bt_audio_valid_qos(qos)) { - BT_DBG("param->qos is invalid"); + LOG_DBG("param->qos is invalid"); return false; } @@ -554,12 +549,12 @@ static bool valid_create_param(const struct bt_audio_broadcast_source_create_par subgroup_param = ¶m->params[i]; CHECKIF(subgroup_param->params_count == 0U) { - BT_DBG("subgroup_params[%zu].count is 0", i); + LOG_DBG("subgroup_params[%zu].count is 0", i); return false; } CHECKIF(subgroup_param->codec == NULL) { - BT_DBG("subgroup_params[%zu].codec is NULL", i); + LOG_DBG("subgroup_params[%zu].codec is NULL", i); return false; } @@ -569,15 +564,15 @@ static bool valid_create_param(const struct bt_audio_broadcast_source_create_par stream_param = &subgroup_param->params[j]; CHECKIF(stream_param->stream == NULL) { - BT_DBG("subgroup_params[%zu].stream_params[%zu]->stream is NULL", - i, j); + LOG_DBG("subgroup_params[%zu].stream_params[%zu]->stream is NULL", + i, j); return false; } CHECKIF(stream_param->stream->group != NULL) { - BT_DBG("subgroup_params[%zu].stream_params[%zu]->stream is " - "already part of group %p", - i, j, stream_param->stream->group); + LOG_DBG("subgroup_params[%zu].stream_params[%zu]->stream is " + "already part of group %p", + i, j, stream_param->stream->group); return false; } } @@ -593,12 +588,12 @@ static enum bt_audio_state broadcast_source_get_state(struct bt_audio_broadcast_ sys_snode_t *head_node; if (source == NULL) { - BT_DBG("source is NULL"); + LOG_DBG("source is NULL"); return BT_AUDIO_EP_STATE_IDLE; } if (sys_slist_is_empty(&source->subgroups)) { - BT_DBG("Source does not have any streams"); + LOG_DBG("Source does not have any streams"); return BT_AUDIO_EP_STATE_IDLE; } @@ -613,7 +608,7 @@ static enum bt_audio_state broadcast_source_get_state(struct bt_audio_broadcast_ * so we can just check the first stream */ if (stream->ep == NULL) { - BT_DBG("stream->ep is NULL"); + LOG_DBG("stream->ep is NULL"); return BT_AUDIO_EP_STATE_IDLE; } @@ -631,14 +626,14 @@ int bt_audio_broadcast_source_create(struct bt_audio_broadcast_source_create_par int err; CHECKIF(out_source == NULL) { - BT_DBG("out_source is NULL"); + LOG_DBG("out_source is NULL"); return -EINVAL; } /* Set out_source to NULL until the source has actually been created */ *out_source = NULL; if (!valid_create_param(param)) { - BT_DBG("Invalid parameters"); + LOG_DBG("Invalid parameters"); return -EINVAL; } @@ -651,7 +646,7 @@ int bt_audio_broadcast_source_create(struct bt_audio_broadcast_source_create_par } if (source == NULL) { - BT_DBG("Could not allocate any more broadcast sources"); + LOG_DBG("Could not allocate any more broadcast sources"); return -ENOMEM; } @@ -668,7 +663,7 @@ int bt_audio_broadcast_source_create(struct bt_audio_broadcast_source_create_par subgroup = broadcast_source_new_subgroup(index); if (subgroup == NULL) { - BT_DBG("Could not allocate new broadcast subgroup"); + LOG_DBG("Could not allocate new broadcast subgroup"); broadcast_source_cleanup(source); return -ENOMEM; } @@ -678,8 +673,7 @@ int bt_audio_broadcast_source_create(struct bt_audio_broadcast_source_create_par /* Check that we are not above the maximum BIS count */ if (subgroup_param->params_count + stream_count > BROADCAST_STREAM_CNT) { - BT_DBG("Cannot create broadcaster with %zu streams", - stream_count); + LOG_DBG("Cannot create broadcaster with %zu streams", stream_count); broadcast_source_cleanup(source); return -ENOMEM; @@ -696,7 +690,7 @@ int bt_audio_broadcast_source_create(struct bt_audio_broadcast_source_create_par subgroup_param->codec, qos, source); if (err != 0) { - BT_DBG("Failed to setup streams[%zu]: %d", i, err); + LOG_DBG("Failed to setup streams[%zu]: %d", i, err); broadcast_source_cleanup(source); return err; } @@ -719,7 +713,7 @@ int bt_audio_broadcast_source_create(struct bt_audio_broadcast_source_create_par err = generate_broadcast_id(source); if (err != 0) { - BT_DBG("Could not generate broadcast id: %d", err); + LOG_DBG("Could not generate broadcast id: %d", err); return err; } @@ -734,7 +728,7 @@ int bt_audio_broadcast_source_create(struct bt_audio_broadcast_source_create_par } source->qos = qos; - BT_DBG("Broadcasting with ID 0x%6X", source->broadcast_id); + LOG_DBG("Broadcasting with ID 0x%6X", source->broadcast_id); *out_source = source; @@ -750,14 +744,13 @@ int bt_audio_broadcast_source_reconfig(struct bt_audio_broadcast_source *source, struct bt_audio_stream *stream; CHECKIF(source == NULL) { - BT_DBG("source is NULL"); + LOG_DBG("source is NULL"); return -EINVAL; } broadcast_state = broadcast_source_get_state(source); if (broadcast_source_get_state(source) != BT_AUDIO_EP_STATE_QOS_CONFIGURED) { - BT_DBG("Broadcast source invalid state: %u", - broadcast_state); + LOG_DBG("Broadcast source invalid state: %u", broadcast_state); return -EBADMSG; } @@ -784,13 +777,13 @@ int bt_audio_broadcast_source_start(struct bt_audio_broadcast_source *source, int err; CHECKIF(source == NULL) { - BT_DBG("source is NULL"); + LOG_DBG("source is NULL"); return -EINVAL; } broadcast_state = broadcast_source_get_state(source); if (broadcast_source_get_state(source) != BT_AUDIO_EP_STATE_QOS_CONFIGURED) { - BT_DBG("Broadcast source invalid state: %u", broadcast_state); + LOG_DBG("Broadcast source invalid state: %u", broadcast_state); return -EBADMSG; } @@ -811,7 +804,7 @@ int bt_audio_broadcast_source_start(struct bt_audio_broadcast_source *source, err = bt_iso_big_create(adv, ¶m, &source->big); if (err != 0) { - BT_DBG("Failed to create BIG: %d", err); + LOG_DBG("Failed to create BIG: %d", err); return err; } @@ -832,25 +825,25 @@ int bt_audio_broadcast_source_stop(struct bt_audio_broadcast_source *source) int err; CHECKIF(source == NULL) { - BT_DBG("source is NULL"); + LOG_DBG("source is NULL"); return -EINVAL; } broadcast_state = broadcast_source_get_state(source); if (broadcast_state != BT_AUDIO_EP_STATE_STREAMING && broadcast_state != BT_AUDIO_EP_STATE_ENABLING) { - BT_DBG("Broadcast source invalid state: %u", broadcast_state); + LOG_DBG("Broadcast source invalid state: %u", broadcast_state); return -EBADMSG; } if (source->big == NULL) { - BT_DBG("Source is not started"); + LOG_DBG("Source is not started"); return -EALREADY; } err = bt_iso_big_terminate(source->big); if (err) { - BT_DBG("Failed to terminate BIG (err %d)", err); + LOG_DBG("Failed to terminate BIG (err %d)", err); return err; } @@ -864,13 +857,13 @@ int bt_audio_broadcast_source_delete(struct bt_audio_broadcast_source *source) enum bt_audio_state broadcast_state; CHECKIF(source == NULL) { - BT_DBG("source is NULL"); + LOG_DBG("source is NULL"); return -EINVAL; } broadcast_state = broadcast_source_get_state(source); if (broadcast_state != BT_AUDIO_EP_STATE_QOS_CONFIGURED) { - BT_DBG("Broadcast source invalid state: %u", broadcast_state); + LOG_DBG("Broadcast source invalid state: %u", broadcast_state); return -EBADMSG; } @@ -884,12 +877,12 @@ int bt_audio_broadcast_source_get_id(const struct bt_audio_broadcast_source *sou uint32_t *const broadcast_id) { CHECKIF(source == NULL) { - BT_DBG("source is NULL"); + LOG_DBG("source is NULL"); return -EINVAL; } CHECKIF(broadcast_id == NULL) { - BT_DBG("broadcast_id is NULL"); + LOG_DBG("broadcast_id is NULL"); return -EINVAL; } @@ -902,8 +895,7 @@ int bt_audio_broadcast_source_get_base(struct bt_audio_broadcast_source *source, struct net_buf_simple *base_buf) { if (!encode_base(source, base_buf)) { - BT_DBG("base_buf %p with size %u not large enough", - base_buf, base_buf->size); + LOG_DBG("base_buf %p with size %u not large enough", base_buf, base_buf->size); return -EMSGSIZE; } diff --git a/subsys/bluetooth/audio/cap_acceptor.c b/subsys/bluetooth/audio/cap_acceptor.c index 70dc056765c..1f7950d4704 100644 --- a/subsys/bluetooth/audio/cap_acceptor.c +++ b/subsys/bluetooth/audio/cap_acceptor.c @@ -10,9 +10,9 @@ #include #include "cap_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_CAP_ACCEPTOR) -#define LOG_MODULE_NAME bt_cap_acceptor -#include "common/log.h" +#include + +LOG_MODULE_REGISTER(bt_cap_acceptor, LOG_LEVEL_DBG); #if defined(CONFIG_BT_CAP_ACCEPTOR_SET_MEMBER) @@ -29,7 +29,7 @@ int bt_cap_acceptor_register(const struct bt_csip_set_member_register_param *par err = bt_csip_set_member_register(param, svc_inst); if (err != 0) { - BT_DBG("Failed to register CSIP"); + LOG_DBG("Failed to register CSIP"); return err; } @@ -40,7 +40,7 @@ int bt_cap_acceptor_register(const struct bt_csip_set_member_register_param *par err = bt_gatt_service_register(&cas); if (err) { - BT_DBG("Failed to register CAS"); + LOG_DBG("Failed to register CAS"); return err; } diff --git a/subsys/bluetooth/audio/cap_initiator.c b/subsys/bluetooth/audio/cap_initiator.c index da591c5ee0e..6a1c467141b 100644 --- a/subsys/bluetooth/audio/cap_initiator.c +++ b/subsys/bluetooth/audio/cap_initiator.c @@ -11,21 +11,21 @@ #include "cap_internal.h" #include "csip_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_CAP_INITIATOR) -#define LOG_MODULE_NAME bt_cap_initiator -#include "common/log.h" +#include + +LOG_MODULE_REGISTER(bt_cap_initiator, LOG_LEVEL_DBG); static const struct bt_cap_initiator_cb *cap_cb; int bt_cap_initiator_register_cb(const struct bt_cap_initiator_cb *cb) { CHECKIF(cb == NULL) { - BT_DBG("cb is NULL"); + LOG_DBG("cb is NULL"); return -EINVAL; } CHECKIF(cap_cb != NULL) { - BT_DBG("callbacks already registered"); + LOG_DBG("callbacks already registered"); return -EALREADY; } @@ -74,7 +74,7 @@ static void csis_client_discover_cb(struct bt_conn *conn, struct cap_unicast_client *client; if (err != 0) { - BT_DBG("CSIS client discover failed: %d", err); + LOG_DBG("CSIS client discover failed: %d", err); if (cap_cb && cap_cb->unicast_discovery_complete) { cap_cb->unicast_discovery_complete(conn, err, NULL); @@ -88,14 +88,14 @@ static void csis_client_discover_cb(struct bt_conn *conn, conn, client->csis_start_handle); if (member == NULL || set_count == 0 || client->csis_inst == NULL) { - BT_ERR("Unable to find CSIS for CAS"); + LOG_ERR("Unable to find CSIS for CAS"); if (cap_cb && cap_cb->unicast_discovery_complete) { cap_cb->unicast_discovery_complete(conn, -ENODATA, NULL); } } else { - BT_DBG("Found CAS with CSIS"); + LOG_DBG("Found CAS with CSIS"); if (cap_cb && cap_cb->unicast_discovery_complete) { cap_cb->unicast_discovery_complete(conn, 0, client->csis_inst); @@ -110,7 +110,7 @@ static uint8_t cap_unicast_discover_included_cb(struct bt_conn *conn, params->func = NULL; if (attr == NULL) { - BT_DBG("CAS CSIS include not found"); + LOG_DBG("CAS CSIS include not found"); if (cap_cb && cap_cb->unicast_discovery_complete) { cap_cb->unicast_discovery_complete(conn, 0, NULL); @@ -137,7 +137,7 @@ static uint8_t cap_unicast_discover_included_cb(struct bt_conn *conn, static bool csis_cbs_registered; int err; - BT_DBG("CAS CSIS not known, discovering"); + LOG_DBG("CAS CSIS not known, discovering"); if (!csis_cbs_registered) { bt_csip_set_coordinator_register_cb(&csis_client_cb); @@ -146,7 +146,7 @@ static uint8_t cap_unicast_discover_included_cb(struct bt_conn *conn, err = bt_csip_set_coordinator_discover(conn); if (err != 0) { - BT_DBG("Discover failed (err %d)", err); + LOG_DBG("Discover failed (err %d)", err); if (cap_cb && cap_cb->unicast_discovery_complete) { cap_cb->unicast_discovery_complete(conn, err, @@ -154,7 +154,7 @@ static uint8_t cap_unicast_discover_included_cb(struct bt_conn *conn, } } } else if (cap_cb && cap_cb->unicast_discovery_complete) { - BT_DBG("Found CAS with CSIS"); + LOG_DBG("Found CAS with CSIS"); cap_cb->unicast_discovery_complete(conn, 0, client->csis_inst); } @@ -179,13 +179,13 @@ static uint8_t cap_unicast_discover_cas_cb(struct bt_conn *conn, int err; if (attr->handle == prim_service->end_handle) { - BT_DBG("Found CAS without CSIS"); + LOG_DBG("Found CAS without CSIS"); cap_cb->unicast_discovery_complete(conn, 0, NULL); return BT_GATT_ITER_STOP; } - BT_DBG("Found CAS, discovering included CSIS"); + LOG_DBG("Found CAS, discovering included CSIS"); params->uuid = NULL; params->start_handle = attr->handle + 1; @@ -195,7 +195,7 @@ static uint8_t cap_unicast_discover_cas_cb(struct bt_conn *conn, err = bt_gatt_discover(conn, params); if (err != 0) { - BT_DBG("Discover failed (err %d)", err); + LOG_DBG("Discover failed (err %d)", err); params->func = NULL; if (cap_cb && cap_cb->unicast_discovery_complete) { @@ -214,7 +214,7 @@ int bt_cap_initiator_unicast_discover(struct bt_conn *conn) int err; CHECKIF(conn == NULL) { - BT_DBG("NULL conn"); + LOG_DBG("NULL conn"); return -EINVAL; } diff --git a/subsys/bluetooth/audio/codec.c b/subsys/bluetooth/audio/codec.c index ed9bdfd68fa..c6815b12d1a 100644 --- a/subsys/bluetooth/audio/codec.c +++ b/subsys/bluetooth/audio/codec.c @@ -14,16 +14,16 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_AUDIO) -#define LOG_MODULE_NAME bt_audio -#include "common/log.h" +#include + +LOG_MODULE_REGISTER(bt_audio, LOG_LEVEL_DBG); bool bt_codec_get_val(const struct bt_codec *codec, uint8_t type, const struct bt_codec_data **data) { CHECKIF(codec == NULL) { - BT_DBG("codec is NULL"); + LOG_DBG("codec is NULL"); return false; } @@ -43,7 +43,7 @@ int bt_codec_cfg_get_freq(const struct bt_codec *codec) const struct bt_codec_data *element; CHECKIF(codec == NULL) { - BT_DBG("codec is NULL"); + LOG_DBG("codec is NULL"); return BT_AUDIO_CODEC_PARSE_ERR_INVALID_PARAM; } @@ -89,7 +89,7 @@ int bt_codec_cfg_get_frame_duration_us(const struct bt_codec *codec) const struct bt_codec_data *element; CHECKIF(codec == NULL) { - BT_DBG("codec is NULL"); + LOG_DBG("codec is NULL"); return BT_AUDIO_CODEC_PARSE_ERR_INVALID_PARAM; } @@ -113,7 +113,7 @@ int bt_codec_cfg_get_chan_allocation_val(const struct bt_codec *codec, const struct bt_codec_data *element; CHECKIF(codec == NULL) { - BT_DBG("codec is NULL"); + LOG_DBG("codec is NULL"); return BT_AUDIO_CODEC_PARSE_ERR_INVALID_PARAM; } @@ -137,7 +137,7 @@ int bt_codec_cfg_get_octets_per_frame(const struct bt_codec *codec) const struct bt_codec_data *element; CHECKIF(codec == NULL) { - BT_DBG("codec is NULL"); + LOG_DBG("codec is NULL"); return BT_AUDIO_CODEC_PARSE_ERR_INVALID_PARAM; } @@ -154,7 +154,7 @@ int bt_codec_cfg_get_frame_blocks_per_sdu(const struct bt_codec *codec, bool fal const struct bt_codec_data *element; CHECKIF(codec == NULL) { - BT_DBG("codec is NULL"); + LOG_DBG("codec is NULL"); return BT_AUDIO_CODEC_PARSE_ERR_INVALID_PARAM; } diff --git a/subsys/bluetooth/audio/csip_crypto.c b/subsys/bluetooth/audio/csip_crypto.c index 9b3b32aeb26..4011ba2b781 100644 --- a/subsys/bluetooth/audio/csip_crypto.c +++ b/subsys/bluetooth/audio/csip_crypto.c @@ -18,11 +18,12 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_CSIP_SET_MEMBER_CRYPTO) -#define LOG_MODULE_NAME bt_csip_crypto -#include "common/log.h" #include "common/bt_str.h" +#include + +LOG_MODULE_REGISTER(bt_csip_crypto, CONFIG_BT_CSIP_SET_MEMBER_CRYPTO_LOG_LEVEL); + #define BT_CSIP_CRYPTO_PADDING_SIZE 13 #define BT_CSIP_R_SIZE 3 /* r is 24 bit / 3 octet */ #define BT_CSIP_R_MASK BIT_MASK(24) /* r is 24 bit / 3 octet */ @@ -68,17 +69,17 @@ int bt_csip_sih(const uint8_t sirk[BT_CSIP_SET_SIRK_SIZE], uint32_t r, uint8_t sirk_tmp[BT_CSIP_SET_SIRK_SIZE]; if ((r & BIT(23)) || ((r & BIT(22)) == 0)) { - BT_DBG("Invalid r %0x06x", (uint32_t)(r & BT_CSIP_R_MASK)); + LOG_DBG("Invalid r %0x06x", (uint32_t)(r & BT_CSIP_R_MASK)); } - BT_DBG("SIRK %s", bt_hex(sirk, BT_CSIP_SET_SIRK_SIZE)); - BT_DBG("r 0x%06x", r); + LOG_DBG("SIRK %s", bt_hex(sirk, BT_CSIP_SET_SIRK_SIZE)); + LOG_DBG("r 0x%06x", r); /* r' = padding || r */ (void)memset(res, 0, BT_CSIP_CRYPTO_PADDING_SIZE); sys_put_be24(r, res + BT_CSIP_CRYPTO_PADDING_SIZE); - BT_DBG("BE: r' %s", bt_hex(res, sizeof(res))); + LOG_DBG("BE: r' %s", bt_hex(res, sizeof(res))); if (IS_ENABLED(CONFIG_LITTLE_ENDIAN)) { /* Swap to Big Endian (BE) */ @@ -100,12 +101,12 @@ int bt_csip_sih(const uint8_t sirk[BT_CSIP_SET_SIRK_SIZE], uint32_t r, * result of sih. */ - BT_DBG("BE: res %s", bt_hex(res, sizeof(res))); + LOG_DBG("BE: res %s", bt_hex(res, sizeof(res))); /* Result is the lowest 3 bytes */ *out = sys_get_be24(res + 13); - BT_DBG("sih 0x%06x", *out); + LOG_DBG("sih 0x%06x", *out); return 0; } @@ -141,13 +142,13 @@ static int k1(const uint8_t *n, size_t n_size, * k1(N, SALT, P) = AES-CMAC_T(P) */ - BT_DBG("BE: n %s", bt_hex(n, n_size)); - BT_DBG("BE: salt %s", bt_hex(salt, BT_CSIP_CRYPTO_SALT_SIZE)); - BT_DBG("BE: p %s", bt_hex(p, p_size)); + LOG_DBG("BE: n %s", bt_hex(n, n_size)); + LOG_DBG("BE: salt %s", bt_hex(salt, BT_CSIP_CRYPTO_SALT_SIZE)); + LOG_DBG("BE: p %s", bt_hex(p, p_size)); err = aes_cmac(salt, n, n_size, t); - BT_DBG("BE: t %s", bt_hex(t, sizeof(t))); + LOG_DBG("BE: t %s", bt_hex(t, sizeof(t))); if (err) { return err; @@ -155,7 +156,7 @@ static int k1(const uint8_t *n, size_t n_size, err = aes_cmac(t, p, p_size, out); - BT_DBG("BE: out %s", bt_hex(out, 16)); + LOG_DBG("BE: out %s", bt_hex(out, 16)); return err; } @@ -178,13 +179,13 @@ static int s1(const uint8_t *m, size_t m_size, * s1(M) = AES-CMAC_zero(M) */ - BT_DBG("BE: m %s", bt_hex(m, m_size)); + LOG_DBG("BE: m %s", bt_hex(m, m_size)); memset(zero, 0, sizeof(zero)); err = aes_cmac(zero, m, m_size, out); - BT_DBG("BE: out %s", bt_hex(out, 16)); + LOG_DBG("BE: out %s", bt_hex(out, 16)); return err; } @@ -204,7 +205,7 @@ int bt_csip_sef(const uint8_t k[BT_CSIP_CRYPTO_KEY_SIZE], * sef(K, SIRK) = k1(K, s1("SIRKenc"), "csis") ^ SIRK */ - BT_DBG("SIRK %s", bt_hex(sirk, BT_CSIP_SET_SIRK_SIZE)); + LOG_DBG("SIRK %s", bt_hex(sirk, BT_CSIP_SET_SIRK_SIZE)); if (IS_ENABLED(CONFIG_LITTLE_ENDIAN)) { /* Swap because aes_cmac is big endian @@ -214,21 +215,21 @@ int bt_csip_sef(const uint8_t k[BT_CSIP_CRYPTO_KEY_SIZE], } else { (void)memcpy(k1_tmp, k, sizeof(k1_tmp)); } - BT_DBG("BE: k %s", bt_hex(k1_tmp, sizeof(k1_tmp))); + LOG_DBG("BE: k %s", bt_hex(k1_tmp, sizeof(k1_tmp))); err = s1(m, sizeof(m), s1_out); if (err) { return err; } - BT_DBG("BE: s1 result %s", bt_hex(s1_out, sizeof(s1_out))); + LOG_DBG("BE: s1 result %s", bt_hex(s1_out, sizeof(s1_out))); err = k1(k1_tmp, sizeof(k1_tmp), s1_out, p, sizeof(p), k1_out); if (err) { return err; } - BT_DBG("BE: k1 result %s", bt_hex(k1_out, sizeof(k1_out))); + LOG_DBG("BE: k1 result %s", bt_hex(k1_out, sizeof(k1_out))); if (IS_ENABLED(CONFIG_LITTLE_ENDIAN)) { /* Swap result back to little endian */ @@ -236,7 +237,7 @@ int bt_csip_sef(const uint8_t k[BT_CSIP_CRYPTO_KEY_SIZE], } xor_128(k1_out, sirk, out_sirk); - BT_DBG("out %s", bt_hex(out_sirk, BT_CSIP_SET_SIRK_SIZE)); + LOG_DBG("out %s", bt_hex(out_sirk, BT_CSIP_SET_SIRK_SIZE)); return 0; } @@ -253,6 +254,6 @@ int bt_csip_sdf(const uint8_t k[BT_CSIP_CRYPTO_KEY_SIZE], * sdf(K, EncSIRK) = k1(K, s1("SIRKenc"), "csis") ^ EncSIRK */ - BT_DBG("Running SDF as SEF"); + LOG_DBG("Running SDF as SEF"); return bt_csip_sef(k, enc_sirk, out_sirk); } diff --git a/subsys/bluetooth/audio/csip_set_coordinator.c b/subsys/bluetooth/audio/csip_set_coordinator.c index d2a30fb6216..1f4bf593cac 100644 --- a/subsys/bluetooth/audio/csip_set_coordinator.c +++ b/subsys/bluetooth/audio/csip_set_coordinator.c @@ -36,9 +36,10 @@ #include "csip_internal.h" #include "../host/conn_internal.h" #include "../host/keys.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_CSIP_SET_COORDINATOR) -#define LOG_MODULE_NAME bt_csip_set_coordinator -#include "common/log.h" + +#include + +LOG_MODULE_REGISTER(bt_csip_set_coordinator, CONFIG_BT_CSIP_SET_COORDINATOR_LOG_LEVEL); static uint8_t gatt_write_buf[1]; static struct bt_gatt_write_params write_params; @@ -179,7 +180,7 @@ static struct bt_csip_set_coordinator_svc_inst *get_next_active_instance(void) svc_inst = lookup_instance_by_set_info(member, active.info); if (svc_inst == NULL) { - BT_DBG("Failed to lookup instance by set_info %p", active.info); + LOG_DBG("Failed to lookup instance by set_info %p", active.info); } return svc_inst; @@ -198,12 +199,12 @@ static int member_rank_compare_asc(const void *m1, const void *m2) svc_inst_2 = lookup_instance_by_set_info(member_2, active.info); if (svc_inst_1 == NULL) { - BT_ERR("svc_inst_1 was NULL for member %p", member_1); + LOG_ERR("svc_inst_1 was NULL for member %p", member_1); return 0; } if (svc_inst_2 == NULL) { - BT_ERR("svc_inst_2 was NULL for member %p", member_2); + LOG_ERR("svc_inst_2 was NULL for member %p", member_2); return 0; } @@ -269,7 +270,7 @@ static int sirk_decrypt(struct bt_conn *conn, 0x3c, 0xe5, 0xce, 0xd9}; static bool swapped; - BT_DBG("Decrypting with sample data K"); + LOG_DBG("Decrypting with sample data K"); if (!swapped && IS_ENABLED(CONFIG_LITTLE_ENDIAN)) { /* Swap test_k to little endian */ @@ -370,7 +371,7 @@ static uint8_t sirk_notify_func(struct bt_conn *conn, struct bt_csip_set_coordinator_svc_inst *svc_inst; if (data == NULL) { - BT_DBG("[UNSUBSCRIBED] %u", params->value_handle); + LOG_DBG("[UNSUBSCRIBED] %u", params->value_handle); params->value_handle = 0U; return BT_GATT_ITER_STOP; @@ -383,7 +384,7 @@ static uint8_t sirk_notify_func(struct bt_conn *conn, svc_inst = lookup_instance_by_handle(conn, handle); if (svc_inst != NULL) { - BT_DBG("Instance %u", svc_inst->idx); + LOG_DBG("Instance %u", svc_inst->idx); if (length == sizeof(struct bt_csip_set_sirk)) { struct bt_csip_set_sirk *sirk = (struct bt_csip_set_sirk *)data; @@ -393,9 +394,8 @@ static uint8_t sirk_notify_func(struct bt_conn *conn, client = &client_insts[bt_conn_index(conn)]; dst_sirk = client->set_member.insts[svc_inst->idx].info.set_sirk; - BT_DBG("Set SIRK %sencrypted", - sirk->type == BT_CSIP_SIRK_TYPE_PLAIN - ? "not " : ""); + LOG_DBG("Set SIRK %sencrypted", + sirk->type == BT_CSIP_SIRK_TYPE_PLAIN ? "not " : ""); /* Assuming not connected to other set devices */ if (sirk->type == BT_CSIP_SIRK_TYPE_ENCRYPTED) { @@ -407,11 +407,12 @@ static uint8_t sirk_notify_func(struct bt_conn *conn, err = sirk_decrypt(conn, sirk->value, dst_sirk); if (err != 0) { - BT_ERR("Could not decrypt " - "SIRK %d", err); + LOG_ERR("Could not decrypt " + "SIRK %d", + err); } } else { - BT_DBG("Encrypted SIRK not supported"); + LOG_DBG("Encrypted SIRK not supported"); return BT_GATT_ITER_CONTINUE; } } else { @@ -423,10 +424,10 @@ static uint8_t sirk_notify_func(struct bt_conn *conn, /* TODO: Notify app */ } else { - BT_DBG("Invalid length %u", length); + LOG_DBG("Invalid length %u", length); } } else { - BT_DBG("Notification/Indication on unknown service inst"); + LOG_DBG("Notification/Indication on unknown service inst"); } return BT_GATT_ITER_CONTINUE; @@ -441,7 +442,7 @@ static uint8_t size_notify_func(struct bt_conn *conn, struct bt_csip_set_coordinator_svc_inst *svc_inst; if (data == NULL) { - BT_DBG("[UNSUBSCRIBED] %u", params->value_handle); + LOG_DBG("[UNSUBSCRIBED] %u", params->value_handle); params->value_handle = 0U; return BT_GATT_ITER_STOP; @@ -462,17 +463,16 @@ static uint8_t size_notify_func(struct bt_conn *conn, set_info = &client->set_member.insts[svc_inst->idx].info; (void)memcpy(&set_size, data, length); - BT_DBG("Set size updated from %u to %u", - set_info->set_size, set_size); + LOG_DBG("Set size updated from %u to %u", set_info->set_size, set_size); set_info->set_size = set_size; /* TODO: Notify app */ } else { - BT_DBG("Invalid length %u", length); + LOG_DBG("Invalid length %u", length); } } else { - BT_DBG("Notification/Indication on unknown service inst"); + LOG_DBG("Notification/Indication on unknown service inst"); } LOG_HEXDUMP_DBG(data, length, "Value"); @@ -488,7 +488,7 @@ static uint8_t lock_notify_func(struct bt_conn *conn, struct bt_csip_set_coordinator_svc_inst *svc_inst; if (data == NULL) { - BT_DBG("[UNSUBSCRIBED] %u", params->value_handle); + LOG_DBG("[UNSUBSCRIBED] %u", params->value_handle); params->value_handle = 0U; return BT_GATT_ITER_STOP; @@ -509,26 +509,25 @@ static uint8_t lock_notify_func(struct bt_conn *conn, (void)memcpy(&value, data, length); if (value != BT_CSIP_RELEASE_VALUE && value != BT_CSIP_LOCK_VALUE) { - BT_DBG("Invalid value %u", value); + LOG_DBG("Invalid value %u", value); return BT_GATT_ITER_STOP; } (void)memcpy(&svc_inst->set_lock, data, length); locked = svc_inst->set_lock == BT_CSIP_LOCK_VALUE; - BT_DBG("Instance %u lock was %s", - svc_inst->idx, - locked ? "locked" : "released"); + LOG_DBG("Instance %u lock was %s", svc_inst->idx, + locked ? "locked" : "released"); client = &client_insts[bt_conn_index(conn)]; inst = &client->set_member.insts[svc_inst->idx]; lock_changed(inst, locked); } else { - BT_DBG("Invalid length %u", length); + LOG_DBG("Invalid length %u", length); } } else { - BT_DBG("Notification/Indication on unknown service inst"); + LOG_DBG("Notification/Indication on unknown service inst"); } LOG_HEXDUMP_DBG(data, length, "Value"); @@ -540,7 +539,7 @@ static int csip_set_coordinator_write_set_lock(struct bt_csip_set_coordinator_sv bt_gatt_write_func_t cb) { if (inst->set_lock_handle == 0) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); cur_inst = NULL; return -EINVAL; } @@ -566,7 +565,7 @@ static int read_set_sirk(struct bt_csip_set_coordinator_svc_inst *svc_inst) } if (svc_inst->set_sirk_handle == 0) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } @@ -591,13 +590,13 @@ static int csip_set_coordinator_read_set_size(struct bt_conn *conn, } else { cur_inst = lookup_instance_by_index(conn, inst_idx); if (cur_inst == NULL) { - BT_DBG("Inst not found"); + LOG_DBG("Inst not found"); return -EINVAL; } } if (cur_inst->set_size_handle == 0) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); cur_inst = NULL; return -EINVAL; } @@ -623,13 +622,13 @@ static int csip_set_coordinator_read_rank(struct bt_conn *conn, } else { cur_inst = lookup_instance_by_index(conn, inst_idx); if (cur_inst == NULL) { - BT_DBG("Inst not found"); + LOG_DBG("Inst not found"); return -EINVAL; } } if (cur_inst->rank_handle == 0) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); cur_inst = NULL; return -EINVAL; } @@ -665,8 +664,7 @@ static uint8_t discover_func(struct bt_conn *conn, void *notify_handler = NULL; if (attr == NULL) { - BT_DBG("Setup complete for %u / %u", - cur_inst->idx + 1, client->inst_count); + LOG_DBG("Setup complete for %u / %u", cur_inst->idx + 1, client->inst_count); (void)memset(params, 0, sizeof(*params)); if ((cur_inst->idx + 1) < client->inst_count) { @@ -681,7 +679,7 @@ static uint8_t discover_func(struct bt_conn *conn, err = bt_gatt_discover(conn, &discover_params); if (err != 0) { - BT_DBG("Discover failed (err %d)", err); + LOG_DBG("Discover failed (err %d)", err); discover_complete(client, err); } @@ -692,38 +690,38 @@ static uint8_t discover_func(struct bt_conn *conn, busy = false; err = csip_set_coordinator_discover_sets(&client->set_member); if (err != 0) { - BT_DBG("Discover sets failed (err %d)", err); + LOG_DBG("Discover sets failed (err %d)", err); discover_complete(client, err); } } return BT_GATT_ITER_STOP; } - BT_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); + LOG_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); if (params->type == BT_GATT_DISCOVER_CHARACTERISTIC && client->inst_count != 0) { chrc = (struct bt_gatt_chrc *)attr->user_data; if (bt_uuid_cmp(chrc->uuid, BT_UUID_CSIS_SET_SIRK) == 0) { - BT_DBG("Set SIRK"); + LOG_DBG("Set SIRK"); cur_inst->set_sirk_handle = chrc->value_handle; sub_params = &cur_inst->sirk_sub_params; sub_params->disc_params = &cur_inst->sirk_sub_disc_params; notify_handler = sirk_notify_func; } else if (bt_uuid_cmp(chrc->uuid, BT_UUID_CSIS_SET_SIZE) == 0) { - BT_DBG("Set size"); + LOG_DBG("Set size"); cur_inst->set_size_handle = chrc->value_handle; sub_params = &cur_inst->size_sub_params; sub_params->disc_params = &cur_inst->size_sub_disc_params; notify_handler = size_notify_func; } else if (bt_uuid_cmp(chrc->uuid, BT_UUID_CSIS_SET_LOCK) == 0) { - BT_DBG("Set lock"); + LOG_DBG("Set lock"); cur_inst->set_lock_handle = chrc->value_handle; sub_params = &cur_inst->lock_sub_params; sub_params->disc_params = &cur_inst->lock_sub_disc_params; notify_handler = lock_notify_func; } else if (bt_uuid_cmp(chrc->uuid, BT_UUID_CSIS_RANK) == 0) { - BT_DBG("Set rank"); + LOG_DBG("Set rank"); cur_inst->rank_handle = chrc->value_handle; } @@ -758,8 +756,7 @@ static uint8_t primary_discover_func(struct bt_conn *conn, if (attr == NULL || client->inst_count == CONFIG_BT_CSIP_SET_COORDINATOR_MAX_CSIS_INSTANCES) { - BT_DBG("Discover complete, found %u instances", - client->inst_count); + LOG_DBG("Discover complete, found %u instances", client->inst_count); (void)memset(params, 0, sizeof(*params)); if (client->inst_count != 0) { @@ -774,7 +771,7 @@ static uint8_t primary_discover_func(struct bt_conn *conn, err = bt_gatt_discover(conn, &discover_params); if (err != 0) { - BT_DBG("Discover failed (err %d)", err); + LOG_DBG("Discover failed (err %d)", err); discover_complete(client, err); } } else { @@ -784,7 +781,7 @@ static uint8_t primary_discover_func(struct bt_conn *conn, return BT_GATT_ITER_STOP; } - BT_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); + LOG_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); if (params->type == BT_GATT_DISCOVER_PRIMARY) { prim_service = (struct bt_gatt_service_val *)attr->user_data; @@ -812,7 +809,7 @@ bool bt_csip_set_coordinator_is_set_member(const uint8_t set_sirk[BT_CSIP_SET_SI uint32_t prand = sys_get_le24(data->data + 3); uint32_t calculated_hash; - BT_DBG("hash: 0x%06x, prand 0x%06x", hash, prand); + LOG_DBG("hash: 0x%06x, prand 0x%06x", hash, prand); err = bt_csip_sih(set_sirk, prand, &calculated_hash); if (err != 0) { return false; @@ -820,8 +817,7 @@ bool bt_csip_set_coordinator_is_set_member(const uint8_t set_sirk[BT_CSIP_SET_SI calculated_hash &= 0xffffff; - BT_DBG("calculated_hash: 0x%06x, hash 0x%06x", - calculated_hash, hash); + LOG_DBG("calculated_hash: 0x%06x, hash 0x%06x", calculated_hash, hash); return calculated_hash == hash; } @@ -842,7 +838,7 @@ static uint8_t csip_set_coordinator_discover_insts_read_rank_cb(struct bt_conn * busy = false; if (err != 0) { - BT_DBG("err: 0x%02X", err); + LOG_DBG("err: 0x%02X", err); discover_complete(client, err); } else if (data != NULL) { @@ -851,10 +847,9 @@ static uint8_t csip_set_coordinator_discover_insts_read_rank_cb(struct bt_conn * if (length == 1) { (void)memcpy(&client->svc_insts[cur_inst->idx].rank, data, length); - BT_DBG("%u", - client->svc_insts[cur_inst->idx].rank); + LOG_DBG("%u", client->svc_insts[cur_inst->idx].rank); } else { - BT_DBG("Invalid length, continuing to next member"); + LOG_DBG("Invalid length, continuing to next member"); } discover_insts_resume(conn, 0, 0, 0); @@ -874,7 +869,7 @@ static uint8_t csip_set_coordinator_discover_insts_read_set_size_cb( busy = false; if (err != 0) { - BT_DBG("err: 0x%02X", err); + LOG_DBG("err: 0x%02X", err); discover_complete(client, err); } else if (data != NULL) { @@ -886,9 +881,9 @@ static uint8_t csip_set_coordinator_discover_insts_read_set_size_cb( if (length == sizeof(set_info->set_size)) { (void)memcpy(&set_info->set_size, data, length); - BT_DBG("%u", set_info->set_size); + LOG_DBG("%u", set_info->set_size); } else { - BT_DBG("Invalid length"); + LOG_DBG("Invalid length"); } discover_insts_resume(conn, 0, 0, cur_inst->rank_handle); @@ -908,8 +903,8 @@ static int parse_sirk(struct bt_csip_set_coordinator_inst *client, struct bt_csip_set_sirk *sirk = (struct bt_csip_set_sirk *)data; - BT_DBG("Set SIRK %sencrypted", - sirk->type == BT_CSIP_SIRK_TYPE_PLAIN ? "not " : ""); + LOG_DBG("Set SIRK %sencrypted", + sirk->type == BT_CSIP_SIRK_TYPE_PLAIN ? "not " : ""); /* Assuming not connected to other set devices */ if (sirk->type == BT_CSIP_SIRK_TYPE_ENCRYPTED) { if (IS_ENABLED(CONFIG_BT_CSIP_SET_COORDINATOR_ENC_SIRK_SUPPORT)) { @@ -920,12 +915,13 @@ static int parse_sirk(struct bt_csip_set_coordinator_inst *client, err = sirk_decrypt(client->conn, sirk->value, set_sirk); if (err != 0) { - BT_ERR("Could not decrypt " - "SIRK %d", err); + LOG_ERR("Could not decrypt " + "SIRK %d", + err); return err; } } else { - BT_WARN("Encrypted SIRK not supported"); + LOG_WRN("Encrypted SIRK not supported"); set_sirk = NULL; return BT_ATT_ERR_INSUFFICIENT_ENCRYPTION; } @@ -938,7 +934,7 @@ static int parse_sirk(struct bt_csip_set_coordinator_inst *client, "Set SIRK"); } } else { - BT_DBG("Invalid length"); + LOG_DBG("Invalid length"); return BT_ATT_ERR_INVALID_ATTRIBUTE_LEN; } @@ -956,7 +952,7 @@ static uint8_t csip_set_coordinator_discover_insts_read_set_sirk_cb( busy = false; if (err != 0) { - BT_DBG("err: 0x%02X", err); + LOG_DBG("err: 0x%02X", err); discover_complete(client, err); } else if (data != NULL) { @@ -965,7 +961,7 @@ static uint8_t csip_set_coordinator_discover_insts_read_set_sirk_cb( cb_err = parse_sirk(client, data, length); if (cb_err != 0) { - BT_DBG("Could not parse SIRK: %d", cb_err); + LOG_DBG("Could not parse SIRK: %d", cb_err); } else { discover_insts_resume(conn, 0, cur_inst->set_size_handle, @@ -997,14 +993,14 @@ static void discover_insts_resume(struct bt_conn *conn, uint16_t sirk_handle, conn, cur_inst->idx, csip_set_coordinator_discover_insts_read_set_size_cb); if (cb_err != 0) { - BT_DBG("Could not read set size: %d", cb_err); + LOG_DBG("Could not read set size: %d", cb_err); } } else if (rank_handle != 0) { cb_err = csip_set_coordinator_read_rank( conn, cur_inst->idx, csip_set_coordinator_discover_insts_read_rank_cb); if (cb_err != 0) { - BT_DBG("Could not read set rank: %d", cb_err); + LOG_DBG("Could not read set rank: %d", cb_err); } } else { uint8_t next_idx = cur_inst->idx + 1; @@ -1036,15 +1032,14 @@ static void csip_set_coordinator_write_restore_cb(struct bt_conn *conn, busy = false; if (err != 0) { - BT_WARN("Could not restore (%d)", err); + LOG_WRN("Could not restore (%d)", err); release_set_complete(err); return; } active.members_restored++; - BT_DBG("Restored %u/%u members", - active.members_restored, active.members_handled); + LOG_DBG("Restored %u/%u members", active.members_restored, active.members_handled); if (active.members_restored < active.members_handled && CONFIG_BT_MAX_CONN > 1) { @@ -1065,9 +1060,8 @@ static void csip_set_coordinator_write_restore_cb(struct bt_conn *conn, if (csip_err == 0) { busy = true; } else { - BT_DBG("Failed to release next member[%u]: %d", - active.members_handled, - csip_err); + LOG_DBG("Failed to release next member[%u]: %d", active.members_handled, + csip_err); release_set_complete(csip_err); } @@ -1083,7 +1077,7 @@ static void csip_set_coordinator_write_lock_cb(struct bt_conn *conn, busy = false; if (err != 0) { - BT_DBG("Could not lock (0x%X)", err); + LOG_DBG("Could not lock (0x%X)", err); if (active.members_handled > 0 && CONFIG_BT_MAX_CONN > 1) { struct bt_csip_set_coordinator_set_member *member; int csip_err; @@ -1094,8 +1088,7 @@ static void csip_set_coordinator_write_lock_cb(struct bt_conn *conn, cur_inst = lookup_instance_by_set_info(member, active.info); if (cur_inst == NULL) { - BT_DBG("Failed to lookup instance by set_info %p", - active.info); + LOG_DBG("Failed to lookup instance by set_info %p", active.info); lock_set_complete(-ENOENT); } @@ -1106,7 +1099,7 @@ static void csip_set_coordinator_write_lock_cb(struct bt_conn *conn, if (csip_err == 0) { busy = true; } else { - BT_WARN("Could not release lock of previous locked member: %d", + LOG_WRN("Could not release lock of previous locked member: %d", csip_err); active_members_reset(); return; @@ -1119,8 +1112,7 @@ static void csip_set_coordinator_write_lock_cb(struct bt_conn *conn, } active.members_handled++; - BT_DBG("Locked %u/%u members", - active.members_handled, active.members_count); + LOG_DBG("Locked %u/%u members", active.members_handled, active.members_count); if (active.members_handled < active.members_count) { struct bt_csip_set_coordinator_svc_inst *prev_inst = cur_inst; @@ -1139,8 +1131,8 @@ static void csip_set_coordinator_write_lock_cb(struct bt_conn *conn, if (csip_err == 0) { busy = true; } else { - BT_DBG("Failed to lock next member[%u]: %d", - active.members_handled, csip_err); + LOG_DBG("Failed to lock next member[%u]: %d", active.members_handled, + csip_err); active.members_restored = 0; @@ -1150,7 +1142,7 @@ static void csip_set_coordinator_write_lock_cb(struct bt_conn *conn, if (csip_err == 0) { busy = true; } else { - BT_WARN("Could not release lock of previous locked member: %d", + LOG_WRN("Could not release lock of previous locked member: %d", csip_err); active_members_reset(); return; @@ -1167,15 +1159,14 @@ static void csip_set_coordinator_write_release_cb(struct bt_conn *conn, uint8_t busy = false; if (err != 0) { - BT_DBG("Could not release lock (%d)", err); + LOG_DBG("Could not release lock (%d)", err); release_set_complete(err); return; } active.members_handled++; - BT_DBG("Released %u/%u members", - active.members_handled, active.members_count); + LOG_DBG("Released %u/%u members", active.members_handled, active.members_count); if (active.members_handled < active.members_count) { int csip_err; @@ -1193,8 +1184,8 @@ static void csip_set_coordinator_write_release_cb(struct bt_conn *conn, uint8_t if (csip_err == 0) { busy = true; } else { - BT_DBG("Failed to release next member[%u]: %d", - active.members_handled, csip_err); + LOG_DBG("Failed to release next member[%u]: %d", active.members_handled, + csip_err); release_set_complete(csip_err); } @@ -1228,7 +1219,7 @@ static uint8_t csip_set_coordinator_read_lock_cb(struct bt_conn *conn, busy = false; if (err != 0) { - BT_DBG("Could not read lock value (0x%X)", err); + LOG_DBG("Could not read lock value (0x%X)", err); csip_set_coordinator_lock_state_read_cb(err, false); @@ -1236,11 +1227,10 @@ static uint8_t csip_set_coordinator_read_lock_cb(struct bt_conn *conn, } active.members_handled++; - BT_DBG("Read lock state on %u/%u members", - active.members_handled, active.members_count); + LOG_DBG("Read lock state on %u/%u members", active.members_handled, active.members_count); if (data == NULL || length != sizeof(cur_inst->set_lock)) { - BT_DBG("Invalid data %p or length %u", data, length); + LOG_DBG("Invalid data %p or length %u", data, length); csip_set_coordinator_lock_state_read_cb(err, false); @@ -1249,7 +1239,7 @@ static uint8_t csip_set_coordinator_read_lock_cb(struct bt_conn *conn, value = ((uint8_t *)data)[0]; if (value != BT_CSIP_RELEASE_VALUE && value != BT_CSIP_LOCK_VALUE) { - BT_DBG("Invalid value %u read", value); + LOG_DBG("Invalid value %u read", value); err = BT_ATT_ERR_UNLIKELY; csip_set_coordinator_lock_state_read_cb(err, false); @@ -1260,7 +1250,7 @@ static uint8_t csip_set_coordinator_read_lock_cb(struct bt_conn *conn, cur_inst->set_lock = value; if (value != BT_CSIP_RELEASE_VALUE) { - BT_DBG("Set member not unlocked"); + LOG_DBG("Set member not unlocked"); csip_set_coordinator_lock_state_read_cb(0, true); @@ -1281,8 +1271,8 @@ static uint8_t csip_set_coordinator_read_lock_cb(struct bt_conn *conn, if (csip_err == 0) { busy = true; } else { - BT_DBG("Failed to read next member[%u]: %d", - active.members_handled, csip_err); + LOG_DBG("Failed to read next member[%u]: %d", active.members_handled, + csip_err); csip_set_coordinator_lock_state_read_cb(err, false); } @@ -1296,7 +1286,7 @@ static uint8_t csip_set_coordinator_read_lock_cb(struct bt_conn *conn, static int csip_set_coordinator_read_set_lock(struct bt_csip_set_coordinator_svc_inst *inst) { if (inst->set_lock_handle == 0) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); cur_inst = NULL; return -EINVAL; } @@ -1386,7 +1376,7 @@ struct bt_csip_set_coordinator_csis_inst *bt_csip_set_coordinator_csis_inst_by_h int bt_csip_set_coordinator_register_cb(struct bt_csip_set_coordinator_cb *cb) { CHECKIF(cb == NULL) { - BT_DBG("cb is NULL"); + LOG_DBG("cb is NULL"); return -EINVAL; } @@ -1402,7 +1392,7 @@ int bt_csip_set_coordinator_discover(struct bt_conn *conn) struct bt_csip_set_coordinator_inst *client; CHECKIF(conn == NULL) { - BT_DBG("NULL conn"); + LOG_DBG("NULL conn"); return -EINVAL; } @@ -1443,8 +1433,8 @@ static int verify_members(const struct bt_csip_set_coordinator_set_member **memb uint8_t ranks[CONFIG_BT_MAX_CONN]; if (count > CONFIG_BT_MAX_CONN) { - BT_DBG("count (%u) larger than maximum support servers (%d)", - count, CONFIG_BT_MAX_CONN); + LOG_DBG("count (%u) larger than maximum support servers (%d)", count, + CONFIG_BT_MAX_CONN); return -EINVAL; } @@ -1457,26 +1447,25 @@ static int verify_members(const struct bt_csip_set_coordinator_set_member **memb struct bt_conn *conn; CHECKIF(member == NULL) { - BT_DBG("Invalid member[%d] was NULL", i); + LOG_DBG("Invalid member[%d] was NULL", i); return -EINVAL; } conn = client_inst->conn; CHECKIF(conn == NULL) { - BT_DBG("Member[%d] conn was NULL", i); + LOG_DBG("Member[%d] conn was NULL", i); return -EINVAL; } if (conn->state != BT_CONN_CONNECTED) { - BT_DBG("Member[%d] was not connected", i); + LOG_DBG("Member[%d] was not connected", i); return -ENOTCONN; } svc_inst = lookup_instance_by_set_info(member, set_info); if (svc_inst == NULL) { - BT_DBG("Member[%d] could not find matching instance for the set_info", - i); + LOG_DBG("Member[%d] could not find matching instance for the set_info", i); return -EINVAL; } @@ -1485,7 +1474,7 @@ static int verify_members(const struct bt_csip_set_coordinator_set_member **memb zero_rank = true; } else if (ranks[i] != 0 && zero_rank) { /* all members in a set shall either use rank, or not use rank */ - BT_DBG("Found mix of 0 and non-0 ranks"); + LOG_DBG("Found mix of 0 and non-0 ranks"); return -EINVAL; } @@ -1493,9 +1482,9 @@ static int verify_members(const struct bt_csip_set_coordinator_set_member **memb for (size_t j = 0U; j < i; j++) { if (ranks[j] == ranks[i]) { /* duplicate rank */ - BT_DBG("Duplicate rank (%u) for members[%zu] " - "and members[%zu]", - ranks[i], i, j); + LOG_DBG("Duplicate rank (%u) for members[%zu] " + "and members[%zu]", + ranks[i], i, j); return -EINVAL; } } @@ -1513,13 +1502,13 @@ static int bt_csip_set_coordinator_get_lock_state( int err; if (busy) { - BT_DBG("csip_set_coordinator busy"); + LOG_DBG("csip_set_coordinator busy"); return -EBUSY; } err = verify_members(members, count, set_info); if (err != 0) { - BT_DBG("Could not verify members: %d", err); + LOG_DBG("Could not verify members: %d", err); return err; } @@ -1527,7 +1516,7 @@ static int bt_csip_set_coordinator_get_lock_state( cur_inst = lookup_instance_by_set_info(active.members[0], active.info); if (cur_inst == NULL) { - BT_DBG("Failed to lookup instance by set_info %p", active.info); + LOG_DBG("Failed to lookup instance by set_info %p", active.info); active_members_reset(); return -ENOENT; @@ -1570,13 +1559,13 @@ int bt_csip_set_coordinator_lock( int err; CHECKIF(busy) { - BT_DBG("csip_set_coordinator busy"); + LOG_DBG("csip_set_coordinator busy"); return -EBUSY; } err = verify_members(members, count, set_info); if (err != 0) { - BT_DBG("Could not verify members: %d", err); + LOG_DBG("Could not verify members: %d", err); return err; } @@ -1584,7 +1573,7 @@ int bt_csip_set_coordinator_lock( cur_inst = lookup_instance_by_set_info(active.members[0], active.info); if (cur_inst == NULL) { - BT_DBG("Failed to lookup instance by set_info %p", active.info); + LOG_DBG("Failed to lookup instance by set_info %p", active.info); active_members_reset(); return -ENOENT; @@ -1606,13 +1595,13 @@ int bt_csip_set_coordinator_release(const struct bt_csip_set_coordinator_set_mem int err; CHECKIF(busy) { - BT_DBG("csip_set_coordinator busy"); + LOG_DBG("csip_set_coordinator busy"); return -EBUSY; } err = verify_members(members, count, set_info); if (err != 0) { - BT_DBG("Could not verify members: %d", err); + LOG_DBG("Could not verify members: %d", err); return err; } @@ -1620,7 +1609,7 @@ int bt_csip_set_coordinator_release(const struct bt_csip_set_coordinator_set_mem cur_inst = lookup_instance_by_set_info(active.members[0], active.info); if (cur_inst == NULL) { - BT_DBG("Failed to lookup instance by set_info %p", active.info); + LOG_DBG("Failed to lookup instance by set_info %p", active.info); active_members_reset(); return -ENOENT; diff --git a/subsys/bluetooth/audio/csip_set_member.c b/subsys/bluetooth/audio/csip_set_member.c index f3b70b3f849..b39b69a202b 100644 --- a/subsys/bluetooth/audio/csip_set_member.c +++ b/subsys/bluetooth/audio/csip_set_member.c @@ -32,11 +32,12 @@ #define BT_CSIP_SIH_HASH_SIZE 3 #define CSIP_SET_LOCK_TIMER_VALUE K_SECONDS(60) -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_CSIP_SET_MEMBER) -#define LOG_MODULE_NAME bt_csip_set_member -#include "common/log.h" #include "common/bt_str.h" +#include + +LOG_MODULE_REGISTER(bt_csip_set_member, CONFIG_BT_CSIP_SET_MEMBER_LOG_LEVEL); + struct bt_csip_set_member_svc_inst { struct bt_csip_set_sirk set_sirk; uint8_t set_size; @@ -155,7 +156,7 @@ static int sirk_encrypt(struct bt_conn *conn, sys_mem_swap(test_k, 16); swapped = true; } - BT_DBG("Encrypting test SIRK"); + LOG_DBG("Encrypting test SIRK"); k = test_k; } else { k = conn->le.keys->ltk.val; @@ -211,14 +212,14 @@ int bt_csip_set_member_generate_rsi(const struct bt_csip_set_member_svc_inst *sv res = generate_prand(&prand); if (res != 0) { - BT_WARN("Could not generate new prand"); + LOG_WRN("Could not generate new prand"); return res; } } res = bt_csip_sih(svc_inst->set_sirk.value, prand, &hash); if (res != 0) { - BT_WARN("Could not generate new RSI"); + LOG_WRN("Could not generate new RSI"); return res; } @@ -252,7 +253,7 @@ static ssize_t read_set_sirk(struct bt_conn *conn, err = sirk_encrypt(conn, &svc_inst->set_sirk, &enc_sirk); if (err != 0) { - BT_ERR("Could not encrypt SIRK: %d", + LOG_ERR("Could not encrypt SIRK: %d", err); gatt_err = BT_GATT_ERR(BT_ATT_ERR_UNLIKELY); } else { @@ -266,7 +267,7 @@ static ssize_t read_set_sirk(struct bt_conn *conn, } else if (cb_rsp == BT_CSIP_READ_SIRK_REQ_RSP_OOB_ONLY) { gatt_err = BT_GATT_ERR(BT_CSIP_ERROR_SIRK_OOB_ONLY); } else { - BT_ERR("Invalid callback response: %u", cb_rsp); + LOG_ERR("Invalid callback response: %u", cb_rsp); gatt_err = BT_GATT_ERR(BT_ATT_ERR_UNLIKELY); } @@ -278,7 +279,7 @@ static ssize_t read_set_sirk(struct bt_conn *conn, } - BT_DBG("Set sirk %sencrypted", + LOG_DBG("Set sirk %sencrypted", sirk->type == BT_CSIP_SIRK_TYPE_PLAIN ? "not " : ""); LOG_HEXDUMP_DBG(svc_inst->set_sirk.value, sizeof(svc_inst->set_sirk.value), "Set SIRK"); @@ -289,7 +290,7 @@ static ssize_t read_set_sirk(struct bt_conn *conn, static void set_sirk_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("value 0x%04x", value); + LOG_DBG("value 0x%04x", value); } static ssize_t read_set_size(struct bt_conn *conn, @@ -298,7 +299,7 @@ static ssize_t read_set_size(struct bt_conn *conn, { struct bt_csip_set_member_svc_inst *svc_inst = BT_AUDIO_CHRC_USER_DATA(attr); - BT_DBG("%u", svc_inst->set_size); + LOG_DBG("%u", svc_inst->set_size); return bt_gatt_attr_read(conn, attr, buf, len, offset, &svc_inst->set_size, @@ -308,7 +309,7 @@ static ssize_t read_set_size(struct bt_conn *conn, static void set_size_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("value 0x%04x", value); + LOG_DBG("value 0x%04x", value); } static ssize_t read_set_lock(struct bt_conn *conn, @@ -317,7 +318,7 @@ static ssize_t read_set_lock(struct bt_conn *conn, { struct bt_csip_set_member_svc_inst *svc_inst = BT_AUDIO_CHRC_USER_DATA(attr); - BT_DBG("%u", svc_inst->set_lock); + LOG_DBG("%u", svc_inst->set_lock); return bt_gatt_attr_read(conn, attr, buf, len, offset, &svc_inst->set_lock, @@ -372,7 +373,7 @@ static uint8_t set_lock(struct bt_conn *conn, (void)k_work_cancel_delayable(&svc_inst->set_lock_timer); } - BT_DBG("%u", svc_inst->set_lock); + LOG_DBG("%u", svc_inst->set_lock); if (notify) { /* @@ -420,7 +421,7 @@ static ssize_t write_set_lock(struct bt_conn *conn, static void set_lock_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("value 0x%04x", value); + LOG_DBG("value 0x%04x", value); } static ssize_t read_rank(struct bt_conn *conn, const struct bt_gatt_attr *attr, @@ -428,7 +429,7 @@ static ssize_t read_rank(struct bt_conn *conn, const struct bt_gatt_attr *attr, { struct bt_csip_set_member_svc_inst *svc_inst = BT_AUDIO_CHRC_USER_DATA(attr); - BT_DBG("%u", svc_inst->rank); + LOG_DBG("%u", svc_inst->rank); return bt_gatt_attr_read(conn, attr, buf, len, offset, &svc_inst->rank, @@ -445,7 +446,7 @@ static void set_lock_timer_handler(struct k_work *work) svc_inst = CONTAINER_OF(delayable, struct bt_csip_set_member_svc_inst, set_lock_timer); - BT_DBG("Lock timeout, releasing"); + LOG_DBG("Lock timeout, releasing"); svc_inst->set_lock = BT_CSIP_RELEASE_VALUE; notify_clients(svc_inst, NULL); @@ -488,7 +489,7 @@ static void csip_security_changed(struct bt_conn *conn, bt_security_t level, static void handle_csip_disconnect(struct bt_csip_set_member_svc_inst *svc_inst, struct bt_conn *conn) { - BT_DBG("Non-bonded device"); + LOG_DBG("Non-bonded device"); if (is_last_client_to_write(svc_inst, conn)) { (void)memset(&svc_inst->lock_client_addr, 0, sizeof(svc_inst->lock_client_addr)); @@ -519,8 +520,7 @@ static void handle_csip_disconnect(struct bt_csip_set_member_svc_inst *svc_inst, static void csip_disconnected(struct bt_conn *conn, uint8_t reason) { - BT_DBG("Disconnected: %s (reason %u)", - bt_addr_le_str(bt_conn_get_dst(conn)), reason); + LOG_DBG("Disconnected: %s (reason %u)", bt_addr_le_str(bt_conn_get_dst(conn)), reason); for (int i = 0; i < ARRAY_SIZE(svc_insts); i++) { handle_csip_disconnect(&svc_insts[i], conn); @@ -581,7 +581,7 @@ static void handle_csip_auth_complete(struct bt_csip_set_member_svc_inst *svc_in oldest->active = true; oldest->age = svc_inst->age_counter++; #else - BT_WARN("Could not add device to pending notification list"); + LOG_WRN("Could not add device to pending notification list"); #endif /* CONFIG_BT_KEYS_OVERWRITE_OLDEST */ } @@ -599,8 +599,8 @@ static void auth_pairing_complete(struct bt_conn *conn, bool bonded) * the oldest entry, following the behavior of the key storage. */ - BT_DBG("%s paired (%sbonded)", - bt_addr_le_str(bt_conn_get_dst(conn)), bonded ? "" : "not "); + LOG_DBG("%s paired (%sbonded)", bt_addr_le_str(bt_conn_get_dst(conn)), + bonded ? "" : "not "); if (!bonded) { return; @@ -677,19 +677,19 @@ void *bt_csip_set_member_svc_decl_get(const struct bt_csip_set_member_svc_inst * static bool valid_register_param(const struct bt_csip_set_member_register_param *param) { if (param->lockable && param->rank == 0) { - BT_DBG("Rank cannot be 0 if service is lockable"); + LOG_DBG("Rank cannot be 0 if service is lockable"); return false; } if (param->rank > 0 && param->rank > param->set_size) { - BT_DBG("Invalid rank: %u (shall be less than set_size: %u)", - param->set_size, param->set_size); + LOG_DBG("Invalid rank: %u (shall be less than set_size: %u)", param->set_size, + param->set_size); return false; } #if CONFIG_BT_CSIP_SET_MEMBER_MAX_INSTANCE_COUNT > 1 if (param->parent == NULL) { - BT_DBG("Parent service not provided"); + LOG_DBG("Parent service not provided"); return false; } #endif /* CONFIG_BT_CSIP_SET_MEMBER_MAX_INSTANCE_COUNT > 1 */ @@ -709,12 +709,12 @@ int bt_csip_set_member_register(const struct bt_csip_set_member_register_param * } CHECKIF(param == NULL) { - BT_DBG("NULL param"); + LOG_DBG("NULL param"); return -EINVAL; } CHECKIF(!valid_register_param(param)) { - BT_DBG("Invalid parameters"); + LOG_DBG("Invalid parameters"); return -EINVAL; } @@ -727,7 +727,7 @@ int bt_csip_set_member_register(const struct bt_csip_set_member_register_param * err = bt_gatt_service_register(inst->service_p); if (err != 0) { - BT_DBG("CSIS service register failed: %d", err); + LOG_DBG("CSIS service register failed: %d", err); return err; } @@ -747,7 +747,7 @@ int bt_csip_set_member_register(const struct bt_csip_set_member_register_param * (void)memcpy(inst->set_sirk.value, test_sirk, sizeof(test_sirk)); - BT_DBG("CSIP SIRK was overwritten by sample data SIRK"); + LOG_DBG("CSIP SIRK was overwritten by sample data SIRK"); } else { (void)memcpy(inst->set_sirk.value, param->set_sirk, sizeof(inst->set_sirk.value)); diff --git a/subsys/bluetooth/audio/has.c b/subsys/bluetooth/audio/has.c index 6e4ef5a6626..d0f02ed14eb 100644 --- a/subsys/bluetooth/audio/has.c +++ b/subsys/bluetooth/audio/has.c @@ -21,9 +21,9 @@ #include "audio_internal.h" #include "has_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HAS) -#define LOG_MODULE_NAME bt_has -#include "common/log.h" +#include + +LOG_MODULE_REGISTER(bt_has, CONFIG_BT_HAS_LOG_LEVEL); /* The service allows operations with paired devices only. * For now, the context is kept for connected devices only, thus the number of contexts is @@ -40,7 +40,7 @@ static ssize_t write_control_point(struct bt_conn *conn, const struct bt_gatt_at static ssize_t read_active_preset_index(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset) { - BT_DBG("conn %p attr %p offset %d", (void *)conn, attr, offset); + LOG_DBG("conn %p attr %p offset %d", (void *)conn, attr, offset); if (offset > sizeof(has.active_index)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); @@ -52,14 +52,14 @@ static ssize_t read_active_preset_index(struct bt_conn *conn, const struct bt_ga static void ccc_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("attr %p value 0x%04x", attr, value); + LOG_DBG("attr %p value 0x%04x", attr, value); } #endif /* CONFIG_BT_HAS_PRESET_SUPPORT */ static ssize_t read_features(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset) { - BT_DBG("conn %p attr %p offset %d", (void *)conn, attr, offset); + LOG_DBG("conn %p attr %p offset %d", (void *)conn, attr, offset); if (offset > sizeof(has.features)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); @@ -198,7 +198,7 @@ static void security_changed(struct bt_conn *conn, bt_security_t level, enum bt_ { struct has_client *client; - BT_DBG("conn %p level %d err %d", (void *)conn, level, err); + LOG_DBG("conn %p level %d err %d", (void *)conn, level, err); if (err != BT_SECURITY_ERR_SUCCESS) { return; @@ -206,7 +206,7 @@ static void security_changed(struct bt_conn *conn, bt_security_t level, enum bt_ client = client_get_or_new(conn); if (unlikely(!client)) { - BT_ERR("Failed to allocate client"); + LOG_ERR("Failed to allocate client"); return; } @@ -224,7 +224,7 @@ static void connected(struct bt_conn *conn, uint8_t err) { struct has_client *client; - BT_DBG("conn %p err %d", conn, err); + LOG_DBG("conn %p err %d", conn, err); if (err != 0 || !bt_addr_le_is_bonded(conn->id, &conn->le.dst)) { return; @@ -232,7 +232,7 @@ static void connected(struct bt_conn *conn, uint8_t err) client = client_get_or_new(conn); if (unlikely(!client)) { - BT_ERR("Failed to allocate client"); + LOG_ERR("Failed to allocate client"); return; } @@ -245,7 +245,7 @@ static void disconnected(struct bt_conn *conn, uint8_t reason) { struct has_client *client; - BT_DBG("conn %p reason %d", (void *)conn, reason); + LOG_DBG("conn %p reason %d", (void *)conn, reason); client = client_get(conn); if (client) { @@ -347,7 +347,7 @@ static void control_point_ntf_complete(struct bt_conn *conn, void *user_data) { struct has_client *client = client_get(conn); - BT_DBG("conn %p\n", (void *)conn); + LOG_DBG("conn %p\n", (void *)conn); /* Resubmit if needed */ if (client != NULL && @@ -362,7 +362,7 @@ static void control_point_ind_complete(struct bt_conn *conn, { if (err) { /* TODO: Handle error somehow */ - BT_ERR("conn %p err 0x%02x\n", (void *)conn, err); + LOG_ERR("conn %p err 0x%02x\n", (void *)conn, err); } control_point_ntf_complete(conn, NULL); @@ -430,7 +430,7 @@ static int bt_has_cp_read_preset_rsp(struct has_client *client, const struct has NET_BUF_SIMPLE_DEFINE(buf, sizeof(*hdr) + sizeof(*rsp) + BT_HAS_PRESET_NAME_MAX); - BT_DBG("conn %p preset %p is_last 0x%02x", (void *)client->conn, preset, is_last); + LOG_DBG("conn %p preset %p is_last 0x%02x", (void *)client->conn, preset, is_last); hdr = net_buf_simple_add(&buf, sizeof(*hdr)); hdr->opcode = BT_HAS_OP_READ_PRESET_RSP; @@ -530,7 +530,7 @@ static void process_control_point_work(struct k_work *work) err = bt_has_cp_read_preset_rsp(client, preset, is_last); if (err) { - BT_ERR("bt_has_cp_read_preset_rsp failed (err %d)", err); + LOG_ERR("bt_has_cp_read_preset_rsp failed (err %d)", err); } if (err || is_last) { @@ -558,7 +558,7 @@ static void process_control_point_work(struct k_work *work) err = bt_has_cp_generic_update(client, preset, is_last); if (err) { - BT_ERR("bt_has_cp_read_preset_rsp failed (err %d)", err); + LOG_ERR("bt_has_cp_read_preset_rsp failed (err %d)", err); } if (err || is_last) { @@ -594,7 +594,7 @@ static uint8_t handle_read_preset_req(struct bt_conn *conn, struct net_buf_simpl req = net_buf_simple_pull_mem(buf, sizeof(*req)); - BT_DBG("start_index %d num_presets %d", req->start_index, req->num_presets); + LOG_DBG("start_index %d num_presets %d", req->start_index, req->num_presets); /* Abort if there is no preset in requested index range */ preset_foreach(req->start_index, BT_HAS_PRESET_INDEX_LAST, preset_found, &preset); @@ -621,7 +621,7 @@ static int set_preset_name(uint8_t index, const char *name, size_t len) { struct has_preset *preset = NULL; - BT_DBG("index %d name_len %zu", index, len); + LOG_DBG("index %d name_len %zu", index, len); if (len < BT_HAS_PRESET_NAME_MIN || len > BT_HAS_PRESET_NAME_MAX) { return -EINVAL; @@ -846,8 +846,8 @@ static uint8_t handle_control_point_op(struct bt_conn *conn, struct net_buf_simp hdr = net_buf_simple_pull_mem(buf, sizeof(*hdr)); - BT_DBG("conn %p opcode %s (0x%02x)", (void *)conn, bt_has_op_str(hdr->opcode), - hdr->opcode); + LOG_DBG("conn %p opcode %s (0x%02x)", (void *)conn, bt_has_op_str(hdr->opcode), + hdr->opcode); switch (hdr->opcode) { case BT_HAS_OP_READ_PRESET_REQ: @@ -892,8 +892,8 @@ static ssize_t write_control_point(struct bt_conn *conn, const struct bt_gatt_at struct net_buf_simple buf; uint8_t err; - BT_DBG("conn %p attr %p data %p len %d offset %d flags 0x%02x", (void *)conn, attr, data, - len, offset, flags); + LOG_DBG("conn %p attr %p data %p len %d offset %d flags 0x%02x", (void *)conn, attr, data, + len, offset, flags); if (offset > 0) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); @@ -907,7 +907,7 @@ static ssize_t write_control_point(struct bt_conn *conn, const struct bt_gatt_at err = handle_control_point_op(conn, &buf); if (err) { - BT_WARN("err 0x%02x", err); + LOG_WRN("err 0x%02x", err); return BT_GATT_ERR(err); } @@ -920,38 +920,38 @@ int bt_has_preset_register(const struct bt_has_preset_register_param *param) size_t name_len; CHECKIF(param == NULL) { - BT_ERR("param is NULL"); + LOG_ERR("param is NULL"); return -EINVAL; } CHECKIF(param->index == BT_HAS_PRESET_INDEX_NONE) { - BT_ERR("param->index is invalid"); + LOG_ERR("param->index is invalid"); return -EINVAL; } CHECKIF(param->name == NULL) { - BT_ERR("param->name is NULL"); + LOG_ERR("param->name is NULL"); return -EINVAL; } name_len = strlen(param->name); CHECKIF(name_len < BT_HAS_PRESET_NAME_MIN) { - BT_ERR("param->name is too short (%zu < %u)", name_len, BT_HAS_PRESET_NAME_MIN); + LOG_ERR("param->name is too short (%zu < %u)", name_len, BT_HAS_PRESET_NAME_MIN); return -EINVAL; } CHECKIF(name_len > BT_HAS_PRESET_NAME_MAX) { - BT_WARN("param->name is too long (%zu > %u)", name_len, BT_HAS_PRESET_NAME_MAX); + LOG_WRN("param->name is too long (%zu > %u)", name_len, BT_HAS_PRESET_NAME_MAX); } CHECKIF(param->ops == NULL) { - BT_ERR("param->ops is NULL"); + LOG_ERR("param->ops is NULL"); return -EINVAL; } CHECKIF(param->ops->select == NULL) { - BT_ERR("param->ops->select is NULL"); + LOG_ERR("param->ops->select is NULL"); return -EINVAL; } @@ -976,7 +976,7 @@ int bt_has_preset_unregister(uint8_t index) sizeof(struct bt_has_cp_preset_changed) + sizeof(uint8_t)); CHECKIF(index == BT_HAS_PRESET_INDEX_NONE) { - BT_ERR("index is invalid"); + LOG_ERR("index is invalid"); return -EINVAL; } @@ -998,7 +998,7 @@ int bt_has_preset_available(uint8_t index) struct has_preset *preset = NULL; CHECKIF(index == BT_HAS_PRESET_INDEX_NONE) { - BT_ERR("index is invalid"); + LOG_ERR("index is invalid"); return -EINVAL; } @@ -1028,7 +1028,7 @@ int bt_has_preset_unavailable(uint8_t index) struct has_preset *preset = NULL; CHECKIF(index == BT_HAS_PRESET_INDEX_NONE) { - BT_ERR("index is invalid"); + LOG_ERR("index is invalid"); return -EINVAL; } diff --git a/subsys/bluetooth/audio/has_client.c b/subsys/bluetooth/audio/has_client.c index aa933da8068..144947d921c 100644 --- a/subsys/bluetooth/audio/has_client.c +++ b/subsys/bluetooth/audio/has_client.c @@ -15,9 +15,9 @@ #include "has_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HAS_CLIENT) -#define LOG_MODULE_NAME bt_has_client -#include "../common/log.h" +#include + +LOG_MODULE_REGISTER(bt_has_client, CONFIG_BT_HAS_CLIENT_LOG_LEVEL); #define HAS_INST(_has) CONTAINER_OF(_has, struct has_inst, has) #define HANDLE_IS_VALID(handle) ((handle) != 0x0000) @@ -95,17 +95,17 @@ static void handle_read_preset_rsp(struct has_inst *inst, struct net_buf_simple char name[BT_HAS_PRESET_NAME_MAX + 1]; /* + 1 byte for null-terminator */ size_t name_len; - BT_DBG("conn %p buf %p", (void *)inst->conn, buf); + LOG_DBG("conn %p buf %p", (void *)inst->conn, buf); if (buf->len < sizeof(*pdu)) { - BT_ERR("malformed PDU"); + LOG_ERR("malformed PDU"); return; } pdu = net_buf_simple_pull_mem(buf, sizeof(*pdu)); if (pdu->is_last > BT_HAS_IS_LAST) { - BT_WARN("unexpected is_last value 0x%02x", pdu->is_last); + LOG_WRN("unexpected is_last value 0x%02x", pdu->is_last); } record.index = pdu->index; @@ -114,7 +114,7 @@ static void handle_read_preset_rsp(struct has_inst *inst, struct net_buf_simple name_len = buf->len + 1; /* + 1 byte for NULL terminator */ if (name_len > ARRAY_SIZE(name)) { - BT_WARN("name is too long (%zu > %u)", buf->len, BT_HAS_PRESET_NAME_MAX); + LOG_WRN("name is too long (%zu > %u)", buf->len, BT_HAS_PRESET_NAME_MAX); name_len = ARRAY_SIZE(name); } @@ -132,7 +132,7 @@ static void handle_generic_update(struct has_inst *inst, struct net_buf_simple * size_t name_len; if (buf->len < sizeof(*pdu)) { - BT_ERR("malformed PDU"); + LOG_ERR("malformed PDU"); return; } @@ -144,7 +144,7 @@ static void handle_generic_update(struct has_inst *inst, struct net_buf_simple * name_len = buf->len + 1; /* + 1 byte for NULL terminator */ if (name_len > ARRAY_SIZE(name)) { - BT_WARN("name is too long (%zu > %u)", buf->len, BT_HAS_PRESET_NAME_MAX); + LOG_WRN("name is too long (%zu > %u)", buf->len, BT_HAS_PRESET_NAME_MAX); name_len = ARRAY_SIZE(name); } @@ -157,7 +157,7 @@ static void handle_generic_update(struct has_inst *inst, struct net_buf_simple * static void handle_preset_deleted(struct has_inst *inst, struct net_buf_simple *buf, bool is_last) { if (buf->len < sizeof(uint8_t)) { - BT_ERR("malformed PDU"); + LOG_ERR("malformed PDU"); return; } @@ -168,7 +168,7 @@ static void handle_preset_availability(struct has_inst *inst, struct net_buf_sim bool available, bool is_last) { if (buf->len < sizeof(uint8_t)) { - BT_ERR("malformed PDU"); + LOG_ERR("malformed PDU"); return; } @@ -180,17 +180,17 @@ static void handle_preset_changed(struct has_inst *inst, struct net_buf_simple * { const struct bt_has_cp_preset_changed *pdu; - BT_DBG("conn %p buf %p", (void *)inst->conn, buf); + LOG_DBG("conn %p buf %p", (void *)inst->conn, buf); if (buf->len < sizeof(*pdu)) { - BT_ERR("malformed PDU"); + LOG_ERR("malformed PDU"); return; } pdu = net_buf_simple_pull_mem(buf, sizeof(*pdu)); if (pdu->is_last > BT_HAS_IS_LAST) { - BT_WARN("unexpected is_last 0x%02x", pdu->is_last); + LOG_WRN("unexpected is_last 0x%02x", pdu->is_last); } switch (pdu->change_id) { @@ -215,7 +215,7 @@ static void handle_preset_changed(struct has_inst *inst, struct net_buf_simple * } return; default: - BT_WARN("unknown change_id 0x%02x", pdu->change_id); + LOG_WRN("unknown change_id 0x%02x", pdu->change_id); } } @@ -227,7 +227,7 @@ static uint8_t control_point_notify_cb(struct bt_conn *conn, struct net_buf_simple buf; struct has_inst *inst; - BT_DBG("conn %p params %p data %p len %u", (void *)conn, params, data, len); + LOG_DBG("conn %p params %p data %p len %u", (void *)conn, params, data, len); if (!conn) { /* Unpaired, continue receiving notifications */ return BT_GATT_ITER_CONTINUE; @@ -267,7 +267,7 @@ static uint8_t control_point_notify_cb(struct bt_conn *conn, static void discover_complete(struct has_inst *inst) { - BT_DBG("conn %p", (void *)inst->conn); + LOG_DBG("conn %p", (void *)inst->conn); atomic_clear_bit(inst->flags, HAS_DISCOVER_IN_PROGRESS); @@ -284,7 +284,7 @@ static void discover_complete(struct has_inst *inst) static void discover_failed(struct bt_conn *conn, int err) { - BT_DBG("conn %p", (void *)conn); + LOG_DBG("conn %p", (void *)conn); client_cb->discover(conn, err, NULL, 0, 0); } @@ -313,7 +313,7 @@ static void read_presets_req_cb(struct bt_conn *conn, uint8_t err, __ASSERT(inst, "no instance for conn %p", (void *)conn); - BT_DBG("conn %p err 0x%02x param %p", (void *)conn, err, params); + LOG_DBG("conn %p err 0x%02x param %p", (void *)conn, err, params); atomic_clear_bit(inst->flags, HAS_CP_OPERATION_IN_PROGRESS); @@ -329,8 +329,8 @@ static int read_presets_req(struct has_inst *inst, uint8_t start_index, uint8_t NET_BUF_SIMPLE_DEFINE(buf, sizeof(*hdr) + sizeof(*req)); - BT_DBG("conn %p start_index 0x%02x num_presets %d", (void *)inst->conn, start_index, - num_presets); + LOG_DBG("conn %p start_index 0x%02x num_presets %d", (void *)inst->conn, start_index, + num_presets); hdr = net_buf_simple_add(&buf, sizeof(*hdr)); hdr->opcode = BT_HAS_OP_READ_PRESET_REQ; @@ -348,7 +348,7 @@ static void set_active_preset_cb(struct bt_conn *conn, uint8_t err, __ASSERT(inst, "no instance for conn %p", (void *)conn); - BT_DBG("conn %p err 0x%02x param %p", (void *)conn, err, params); + LOG_DBG("conn %p err 0x%02x param %p", (void *)conn, err, params); atomic_clear_bit(inst->flags, HAS_CP_OPERATION_IN_PROGRESS); @@ -364,7 +364,7 @@ static int preset_set(struct has_inst *inst, uint8_t opcode, uint8_t index) NET_BUF_SIMPLE_DEFINE(buf, sizeof(*hdr) + sizeof(*req)); - BT_DBG("conn %p opcode 0x%02x index 0x%02x", (void *)inst->conn, opcode, index); + LOG_DBG("conn %p opcode 0x%02x index 0x%02x", (void *)inst->conn, opcode, index); hdr = net_buf_simple_add(&buf, sizeof(*hdr)); hdr->opcode = opcode; @@ -380,7 +380,7 @@ static int preset_set_next_or_prev(struct has_inst *inst, uint8_t opcode) NET_BUF_SIMPLE_DEFINE(buf, sizeof(*hdr)); - BT_DBG("conn %p opcode 0x%02x", (void *)inst->conn, opcode); + LOG_DBG("conn %p opcode 0x%02x", (void *)inst->conn, opcode); hdr = net_buf_simple_add(&buf, sizeof(*hdr)); hdr->opcode = opcode; @@ -397,7 +397,7 @@ static uint8_t active_index_update(struct has_inst *inst, const void *data, uint inst->has.active_index = net_buf_simple_pull_u8(&buf); - BT_DBG("conn %p index 0x%02x", (void *)inst->conn, inst->has.active_index); + LOG_DBG("conn %p index 0x%02x", (void *)inst->conn, inst->has.active_index); return prev; } @@ -409,7 +409,7 @@ static uint8_t active_preset_notify_cb(struct bt_conn *conn, struct has_inst *inst; uint8_t prev; - BT_DBG("conn %p params %p data %p len %u", (void *)conn, params, data, len); + LOG_DBG("conn %p params %p data %p len %u", (void *)conn, params, data, len); if (!conn) { /* Unpaired, stop receiving notifications from device */ @@ -457,7 +457,7 @@ static void active_index_subscribe_cb(struct bt_conn *conn, uint8_t att_err, __ASSERT(inst, "no instance for conn %p", (void *)conn); - BT_DBG("conn %p att_err 0x%02x params %p", (void *)inst->conn, att_err, params); + LOG_DBG("conn %p att_err 0x%02x params %p", (void *)inst->conn, att_err, params); if (att_err != BT_ATT_ERR_SUCCESS) { /* Cleanup instance so that it can be reused */ @@ -471,7 +471,7 @@ static void active_index_subscribe_cb(struct bt_conn *conn, uint8_t att_err, static int active_index_subscribe(struct has_inst *inst, uint16_t value_handle) { - BT_DBG("conn %p handle 0x%04x", (void *)inst->conn, value_handle); + LOG_DBG("conn %p handle 0x%04x", (void *)inst->conn, value_handle); inst->active_index_subscription.notify = active_preset_notify_cb; inst->active_index_subscription.subscribe = active_index_subscribe_cb; @@ -494,8 +494,8 @@ static uint8_t active_index_read_cb(struct bt_conn *conn, uint8_t att_err, __ASSERT(inst, "no instance for conn %p", (void *)conn); - BT_DBG("conn %p att_err 0x%02x params %p data %p len %u", (void *)conn, att_err, params, - data, len); + LOG_DBG("conn %p att_err 0x%02x params %p data %p len %u", (void *)conn, att_err, params, + data, len); if (att_err != BT_ATT_ERR_SUCCESS || len == 0) { goto fail; @@ -505,7 +505,7 @@ static uint8_t active_index_read_cb(struct bt_conn *conn, uint8_t att_err, err = active_index_subscribe(inst, params->by_uuid.start_handle); if (err) { - BT_ERR("Subscribe failed (err %d)", err); + LOG_ERR("Subscribe failed (err %d)", err); goto fail; } @@ -522,7 +522,7 @@ fail: static int active_index_read(struct has_inst *inst) { - BT_DBG("conn %p", (void *)inst->conn); + LOG_DBG("conn %p", (void *)inst->conn); (void)memset(&inst->params.read, 0, sizeof(inst->params.read)); @@ -545,7 +545,7 @@ static void control_point_subscribe_cb(struct bt_conn *conn, uint8_t att_err, __ASSERT(inst, "no instance for conn %p", (void *)conn); - BT_DBG("conn %p att_err 0x%02x", (void *)inst->conn, att_err); + LOG_DBG("conn %p att_err 0x%02x", (void *)inst->conn, att_err); if (att_err != BT_ATT_ERR_SUCCESS) { goto fail; @@ -553,7 +553,7 @@ static void control_point_subscribe_cb(struct bt_conn *conn, uint8_t att_err, err = active_index_read(inst); if (err) { - BT_ERR("Active Preset Index read failed (err %d)", err); + LOG_ERR("Active Preset Index read failed (err %d)", err); goto fail; } @@ -569,7 +569,7 @@ fail: static int control_point_subscribe(struct has_inst *inst, uint16_t value_handle, uint8_t properties) { - BT_DBG("conn %p handle 0x%04x", (void *)inst->conn, value_handle); + LOG_DBG("conn %p handle 0x%04x", (void *)inst->conn, value_handle); inst->control_point_subscription.notify = control_point_notify_cb; inst->control_point_subscription.subscribe = control_point_subscribe_cb; @@ -597,10 +597,10 @@ static uint8_t control_point_discover_cb(struct bt_conn *conn, const struct bt_g __ASSERT(inst, "no instance for conn %p", (void *)conn); - BT_DBG("conn %p attr %p params %p", (void *)inst->conn, attr, params); + LOG_DBG("conn %p attr %p params %p", (void *)inst->conn, attr, params); if (!attr) { - BT_INFO("Control Point not found"); + LOG_INF("Control Point not found"); discover_complete(inst); return BT_GATT_ITER_STOP; } @@ -609,7 +609,7 @@ static uint8_t control_point_discover_cb(struct bt_conn *conn, const struct bt_g err = control_point_subscribe(inst, chrc->value_handle, chrc->properties); if (err) { - BT_ERR("Subscribe failed (err %d)", err); + LOG_ERR("Subscribe failed (err %d)", err); /* Cleanup instance so that it can be reused */ inst_cleanup(inst); @@ -622,7 +622,7 @@ static uint8_t control_point_discover_cb(struct bt_conn *conn, const struct bt_g static int control_point_discover(struct has_inst *inst) { - BT_DBG("conn %p", (void *)inst->conn); + LOG_DBG("conn %p", (void *)inst->conn); (void)memset(&inst->params.discover, 0, sizeof(inst->params.discover)); @@ -645,7 +645,7 @@ static void features_update(struct has_inst *inst, const void *data, uint16_t le inst->has.features = net_buf_simple_pull_u8(&buf); - BT_DBG("conn %p features 0x%02x", (void *)inst->conn, inst->has.features); + LOG_DBG("conn %p features 0x%02x", (void *)inst->conn, inst->has.features); } static uint8_t features_read_cb(struct bt_conn *conn, uint8_t att_err, @@ -656,8 +656,8 @@ static uint8_t features_read_cb(struct bt_conn *conn, uint8_t att_err, __ASSERT(inst, "no instance for conn %p", (void *)conn); - BT_DBG("conn %p att_err 0x%02x params %p data %p len %u", (void *)conn, att_err, params, - data, len); + LOG_DBG("conn %p att_err 0x%02x params %p data %p len %u", (void *)conn, att_err, params, + data, len); if (att_err != BT_ATT_ERR_SUCCESS || len == 0) { goto fail; @@ -673,7 +673,7 @@ static uint8_t features_read_cb(struct bt_conn *conn, uint8_t att_err, err = control_point_discover(inst); if (err) { - BT_ERR("Control Point discover failed (err %d)", err); + LOG_ERR("Control Point discover failed (err %d)", err); goto fail; } @@ -690,7 +690,7 @@ fail: static int features_read(struct has_inst *inst, uint16_t value_handle) { - BT_DBG("conn %p handle 0x%04x", (void *)inst->conn, value_handle); + LOG_DBG("conn %p handle 0x%04x", (void *)inst->conn, value_handle); inst->params.read.func = features_read_cb; inst->params.read.handle_count = 1u; @@ -708,7 +708,7 @@ static void features_subscribe_cb(struct bt_conn *conn, uint8_t att_err, __ASSERT(inst, "no instance for conn %p", (void *)conn); - BT_DBG("conn %p att_err 0x%02x params %p", (void *)inst->conn, att_err, params); + LOG_DBG("conn %p att_err 0x%02x params %p", (void *)inst->conn, att_err, params); if (att_err != BT_ATT_ERR_SUCCESS) { goto fail; @@ -716,7 +716,7 @@ static void features_subscribe_cb(struct bt_conn *conn, uint8_t att_err, err = features_read(inst, inst->features_subscription.value_handle); if (err) { - BT_ERR("Read failed (err %d)", err); + LOG_ERR("Read failed (err %d)", err); goto fail; } @@ -734,7 +734,7 @@ static uint8_t features_notify_cb(struct bt_conn *conn, struct bt_gatt_subscribe { struct has_inst *inst; - BT_DBG("conn %p params %p data %p len %u", (void *)conn, params, data, len); + LOG_DBG("conn %p params %p data %p len %u", (void *)conn, params, data, len); if (!conn) { /* Unpaired, stop receiving notifications from device */ @@ -766,7 +766,7 @@ static uint8_t features_notify_cb(struct bt_conn *conn, struct bt_gatt_subscribe static int features_subscribe(struct has_inst *inst, uint16_t value_handle) { - BT_DBG("conn %p handle 0x%04x", (void *)inst->conn, value_handle); + LOG_DBG("conn %p handle 0x%04x", (void *)inst->conn, value_handle); inst->features_subscription.notify = features_notify_cb; inst->features_subscription.subscribe = features_subscribe_cb; @@ -789,7 +789,7 @@ static uint8_t features_discover_cb(struct bt_conn *conn, const struct bt_gatt_a __ASSERT(inst, "no instance for conn %p", (void *)conn); - BT_DBG("conn %p attr %p params %p", (void *)conn, attr, params); + LOG_DBG("conn %p attr %p params %p", (void *)conn, attr, params); if (!attr) { err = -ENOENT; @@ -802,13 +802,13 @@ static uint8_t features_discover_cb(struct bt_conn *conn, const struct bt_gatt_a if (chrc->properties & BT_GATT_CHRC_NOTIFY) { err = features_subscribe(inst, chrc->value_handle); if (err) { - BT_ERR("Subscribe failed (err %d)", err); + LOG_ERR("Subscribe failed (err %d)", err); goto fail; } } else { err = features_read(inst, chrc->value_handle); if (err) { - BT_ERR("Read failed (err %d)", err); + LOG_ERR("Read failed (err %d)", err); goto fail; } } @@ -826,7 +826,7 @@ fail: static int features_discover(struct has_inst *inst) { - BT_DBG("conn %p", (void *)inst->conn); + LOG_DBG("conn %p", (void *)inst->conn); (void)memset(&inst->params.discover, 0, sizeof(inst->params.discover)); @@ -869,7 +869,7 @@ int bt_has_client_discover(struct bt_conn *conn) struct has_inst *inst; int err; - BT_DBG("conn %p", (void *)conn); + LOG_DBG("conn %p", (void *)conn); CHECKIF(!conn || !client_cb || !client_cb->discover) { return -EINVAL; @@ -910,7 +910,7 @@ int bt_has_client_presets_read(struct bt_has *has, uint8_t start_index, uint8_t struct has_inst *inst = HAS_INST(has); int err; - BT_DBG("conn %p start_index 0x%02x count %d", (void *)inst->conn, start_index, count); + LOG_DBG("conn %p start_index 0x%02x count %d", (void *)inst->conn, start_index, count); if (!inst->conn) { return -ENOTCONN; @@ -942,7 +942,7 @@ int bt_has_client_preset_set(struct bt_has *has, uint8_t index, bool sync) struct has_inst *inst = HAS_INST(has); uint8_t opcode; - BT_DBG("conn %p index 0x%02x", (void *)inst->conn, index); + LOG_DBG("conn %p index 0x%02x", (void *)inst->conn, index); if (!inst->conn) { return -ENOTCONN; @@ -971,7 +971,7 @@ int bt_has_client_preset_next(struct bt_has *has, bool sync) struct has_inst *inst = HAS_INST(has); uint8_t opcode; - BT_DBG("conn %p sync %d", (void *)inst->conn, sync); + LOG_DBG("conn %p sync %d", (void *)inst->conn, sync); if (!inst->conn) { return -ENOTCONN; @@ -996,7 +996,7 @@ int bt_has_client_preset_prev(struct bt_has *has, bool sync) struct has_inst *inst = HAS_INST(has); uint8_t opcode; - BT_DBG("conn %p sync %d", (void *)inst->conn, sync); + LOG_DBG("conn %p sync %d", (void *)inst->conn, sync); if (!inst->conn) { return -ENOTCONN; diff --git a/subsys/bluetooth/audio/mcc.c b/subsys/bluetooth/audio/mcc.c index d1edfbe0397..c9dd092a5a0 100644 --- a/subsys/bluetooth/audio/mcc.c +++ b/subsys/bluetooth/audio/mcc.c @@ -27,19 +27,20 @@ /* Debug output of 48 bit Object ID value */ /* (Zephyr does not yet support debug output of more than 32 bit values.) */ /* Takes a text and a 64-bit integer as input */ -#define BT_DBG_OBJ_ID(text, id64) \ +#define LOG_DBG_OBJ_ID(text, id64) \ do { \ - if (IS_ENABLED(CONFIG_BT_DEBUG_MCS)) { \ + if (IS_ENABLED(CONFIG_BT_MCS_LOG_LEVEL)) { \ char t[BT_OTS_OBJ_ID_STR_LEN]; \ (void)bt_ots_obj_id_to_str(id64, t, sizeof(t)); \ - BT_DBG(text "0x%s", t); \ + LOG_DBG(text "0x%s", t); \ } \ } while (0) -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_MCC) -#define LOG_MODULE_NAME bt_mcc -#include "common/log.h" +#include + +LOG_MODULE_REGISTER(bt_mcc, CONFIG_BT_MCC_LOG_LEVEL); + #include "common/bt_str.h" struct mcs_instance_t { @@ -175,10 +176,10 @@ static uint8_t mcc_read_player_name_cb(struct bt_conn *conn, uint8_t err, char name[CONFIG_BT_MCC_MEDIA_PLAYER_NAME_MAX]; mcs_inst->busy = false; - BT_DBG("err: 0x%02x, length: %d, data: %p", err, length, data); + LOG_DBG("err: 0x%02x, length: %d, data: %p", err, length, data); if (err) { - BT_DBG("err: 0x%02x", err); + LOG_DBG("err: 0x%02x", err); } else if (!data) { cb_err = BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } else { @@ -190,7 +191,7 @@ static uint8_t mcc_read_player_name_cb(struct bt_conn *conn, uint8_t err, (void)memcpy(&name, data, length); name[length] = '\0'; - BT_DBG("Player name: %s", name); + LOG_DBG("Player name: %s", name); } if (mcc_cb && mcc_cb->read_player_name) { @@ -212,15 +213,15 @@ static uint8_t mcc_read_icon_obj_id_cb(struct bt_conn *conn, uint8_t err, uint64_t id = 0; mcs_inst->busy = false; - BT_DBG("err: 0x%02x, length: %d, data: %p", err, length, data); + LOG_DBG("err: 0x%02x, length: %d, data: %p", err, length, data); if (err) { - BT_DBG("err: 0x%02x", err); + LOG_DBG("err: 0x%02x", err); } else if ((!pid) || (length != BT_OTS_OBJ_ID_SIZE)) { cb_err = BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } else { LOG_HEXDUMP_DBG(pid, length, "Icon Object ID"); id = sys_get_le48(pid); - BT_DBG_OBJ_ID("Icon Object ID: ", id); + LOG_DBG_OBJ_ID("Icon Object ID: ", id); } if (mcc_cb && mcc_cb->read_icon_obj_id) { @@ -240,9 +241,9 @@ static uint8_t mcc_read_icon_url_cb(struct bt_conn *conn, uint8_t err, char url[CONFIG_BT_MCC_ICON_URL_MAX]; mcs_inst->busy = false; - BT_DBG("err: 0x%02x, length: %d, data: %p", err, length, data); + LOG_DBG("err: 0x%02x, length: %d, data: %p", err, length, data); if (err) { - BT_DBG("err: 0x%02x", err); + LOG_DBG("err: 0x%02x", err); } else if (!data) { cb_err = BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } else if (length >= sizeof(url)) { @@ -251,7 +252,7 @@ static uint8_t mcc_read_icon_url_cb(struct bt_conn *conn, uint8_t err, LOG_HEXDUMP_DBG(data, length, "Icon URL"); (void)memcpy(&url, data, length); url[length] = '\0'; - BT_DBG("Icon URL: %s", url); + LOG_DBG("Icon URL: %s", url); } if (mcc_cb && mcc_cb->read_icon_url) { @@ -271,7 +272,7 @@ static uint8_t mcc_read_track_title_cb(struct bt_conn *conn, uint8_t err, mcs_inst->busy = false; if (err) { - BT_DBG("err: 0x%02x", err); + LOG_DBG("err: 0x%02x", err); } else if (!data) { cb_err = BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } else { @@ -282,7 +283,7 @@ static uint8_t mcc_read_track_title_cb(struct bt_conn *conn, uint8_t err, } (void)memcpy(&title, data, length); title[length] = '\0'; - BT_DBG("Track title: %s", title); + LOG_DBG("Track title: %s", title); } if (mcc_cb && mcc_cb->read_track_title) { @@ -302,13 +303,13 @@ static uint8_t mcc_read_track_duration_cb(struct bt_conn *conn, uint8_t err, mcs_inst->busy = false; if (err) { - BT_DBG("err: 0x%02x", err); + LOG_DBG("err: 0x%02x", err); } else if ((!data) || (length != sizeof(dur))) { - BT_DBG("length: %d, data: %p", length, data); + LOG_DBG("length: %d, data: %p", length, data); cb_err = BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } else { dur = sys_get_le32((uint8_t *)data); - BT_DBG("Track duration: %d", dur); + LOG_DBG("Track duration: %d", dur); LOG_HEXDUMP_DBG(data, sizeof(int32_t), "Track duration"); } @@ -329,13 +330,13 @@ static uint8_t mcc_read_track_position_cb(struct bt_conn *conn, uint8_t err, mcs_inst->busy = false; if (err) { - BT_DBG("err: 0x%02x", err); + LOG_DBG("err: 0x%02x", err); } else if ((!data) || (length != sizeof(pos))) { - BT_DBG("length: %d, data: %p", length, data); + LOG_DBG("length: %d, data: %p", length, data); cb_err = BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } else { pos = sys_get_le32((uint8_t *)data); - BT_DBG("Track position: %d", pos); + LOG_DBG("Track position: %d", pos); LOG_HEXDUMP_DBG(data, sizeof(pos), "Track position"); } @@ -355,13 +356,13 @@ static void mcs_write_track_position_cb(struct bt_conn *conn, uint8_t err, mcs_inst->busy = false; if (err) { - BT_DBG("err: 0x%02x", err); + LOG_DBG("err: 0x%02x", err); } else if (!params->data || params->length != sizeof(pos)) { - BT_DBG("length: %d, data: %p", params->length, params->data); + LOG_DBG("length: %d, data: %p", params->length, params->data); cb_err = BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } else { pos = sys_get_le32((uint8_t *)params->data); - BT_DBG("Track position: %d", pos); + LOG_DBG("Track position: %d", pos); LOG_HEXDUMP_DBG(params->data, sizeof(pos), "Track position in callback"); } @@ -380,13 +381,13 @@ static uint8_t mcc_read_playback_speed_cb(struct bt_conn *conn, uint8_t err, mcs_inst->busy = false; if (err) { - BT_DBG("err: 0x%02x", err); + LOG_DBG("err: 0x%02x", err); } else if ((!data) || (length != sizeof(speed))) { - BT_DBG("length: %d, data: %p", length, data); + LOG_DBG("length: %d, data: %p", length, data); cb_err = BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } else { speed = *(int8_t *)data; - BT_DBG("Playback speed: %d", speed); + LOG_DBG("Playback speed: %d", speed); LOG_HEXDUMP_DBG(data, sizeof(int8_t), "Playback speed"); } @@ -406,13 +407,13 @@ static void mcs_write_playback_speed_cb(struct bt_conn *conn, uint8_t err, mcs_inst->busy = false; if (err) { - BT_DBG("err: 0x%02x", err); + LOG_DBG("err: 0x%02x", err); } else if (!params->data || params->length != sizeof(speed)) { - BT_DBG("length: %d, data: %p", params->length, params->data); + LOG_DBG("length: %d, data: %p", params->length, params->data); cb_err = BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } else { speed = *(int8_t *)params->data; - BT_DBG("Playback_speed: %d", speed); + LOG_DBG("Playback_speed: %d", speed); } if (mcc_cb && mcc_cb->set_playback_speed) { @@ -430,13 +431,13 @@ static uint8_t mcc_read_seeking_speed_cb(struct bt_conn *conn, uint8_t err, mcs_inst->busy = false; if (err) { - BT_DBG("err: 0x%02x", err); + LOG_DBG("err: 0x%02x", err); } else if ((!data) || (length != sizeof(speed))) { - BT_DBG("length: %d, data: %p", length, data); + LOG_DBG("length: %d, data: %p", length, data); cb_err = BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } else { speed = *(int8_t *)data; - BT_DBG("Seeking speed: %d", speed); + LOG_DBG("Seeking speed: %d", speed); LOG_HEXDUMP_DBG(data, sizeof(int8_t), "Seeking speed"); } @@ -459,15 +460,15 @@ static uint8_t mcc_read_segments_obj_id_cb(struct bt_conn *conn, uint8_t err, mcs_inst->busy = false; if (err) { - BT_DBG("err: 0x%02x", err); + LOG_DBG("err: 0x%02x", err); cb_err = err; } else if ((!pid) || (length != BT_OTS_OBJ_ID_SIZE)) { - BT_DBG("length: %d, data: %p", length, data); + LOG_DBG("length: %d, data: %p", length, data); cb_err = BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } else { LOG_HEXDUMP_DBG(pid, length, "Segments Object ID"); id = sys_get_le48(pid); - BT_DBG_OBJ_ID("Segments Object ID: ", id); + LOG_DBG_OBJ_ID("Segments Object ID: ", id); cb_err = 0; } @@ -489,15 +490,15 @@ static uint8_t mcc_read_current_track_obj_id_cb(struct bt_conn *conn, uint8_t er mcs_inst->busy = false; if (err) { - BT_DBG("err: 0x%02x", err); + LOG_DBG("err: 0x%02x", err); cb_err = err; } else if ((!pid) || (length != BT_OTS_OBJ_ID_SIZE)) { - BT_DBG("length: %d, data: %p", length, data); + LOG_DBG("length: %d, data: %p", length, data); cb_err = BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } else { LOG_HEXDUMP_DBG(pid, length, "Current Track Object ID"); id = sys_get_le48(pid); - BT_DBG_OBJ_ID("Current Track Object ID: ", id); + LOG_DBG_OBJ_ID("Current Track Object ID: ", id); cb_err = 0; } @@ -517,13 +518,13 @@ static void mcs_write_current_track_obj_id_cb(struct bt_conn *conn, uint8_t err, mcs_inst->busy = false; if (err) { - BT_DBG("err: 0x%02x", err); + LOG_DBG("err: 0x%02x", err); } else if (!params->data || params->length != BT_OTS_OBJ_ID_SIZE) { - BT_DBG("length: %d, data: %p", params->length, params->data); + LOG_DBG("length: %d, data: %p", params->length, params->data); cb_err = BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } else { obj_id = sys_get_le48((const uint8_t *)params->data); - BT_DBG_OBJ_ID("Object ID: ", obj_id); + LOG_DBG_OBJ_ID("Object ID: ", obj_id); } if (mcc_cb && mcc_cb->set_current_track_obj_id) { @@ -542,16 +543,16 @@ static uint8_t mcc_read_next_track_obj_id_cb(struct bt_conn *conn, uint8_t err, mcs_inst->busy = false; if (err) { - BT_DBG("err: 0x%02x", err); + LOG_DBG("err: 0x%02x", err); } else if (length == 0) { - BT_DBG("Characteristic is empty"); + LOG_DBG("Characteristic is empty"); } else if (!pid || (length != BT_OTS_OBJ_ID_SIZE)) { - BT_DBG("length: %d, data: %p", length, data); + LOG_DBG("length: %d, data: %p", length, data); cb_err = BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } else { LOG_HEXDUMP_DBG(pid, length, "Next Track Object ID"); id = sys_get_le48(pid); - BT_DBG_OBJ_ID("Next Track Object ID: ", id); + LOG_DBG_OBJ_ID("Next Track Object ID: ", id); } if (mcc_cb && mcc_cb->read_next_track_obj_id) { @@ -570,13 +571,13 @@ static void mcs_write_next_track_obj_id_cb(struct bt_conn *conn, uint8_t err, mcs_inst->busy = false; if (err) { - BT_DBG("err: 0x%02x", err); + LOG_DBG("err: 0x%02x", err); } else if (!params->data || params->length != BT_OTS_OBJ_ID_SIZE) { - BT_DBG("length: %d, data: %p", params->length, params->data); + LOG_DBG("length: %d, data: %p", params->length, params->data); cb_err = BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } else { obj_id = sys_get_le48((const uint8_t *)params->data); - BT_DBG_OBJ_ID("Object ID: ", obj_id); + LOG_DBG_OBJ_ID("Object ID: ", obj_id); } if (mcc_cb && mcc_cb->set_next_track_obj_id) { @@ -595,14 +596,14 @@ static uint8_t mcc_read_parent_group_obj_id_cb(struct bt_conn *conn, uint8_t err mcs_inst->busy = false; if (err) { - BT_DBG("err: 0x%02x", err); + LOG_DBG("err: 0x%02x", err); } else if (!pid || (length != BT_OTS_OBJ_ID_SIZE)) { - BT_DBG("length: %d, data: %p", length, data); + LOG_DBG("length: %d, data: %p", length, data); cb_err = BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } else { LOG_HEXDUMP_DBG(pid, length, "Parent Group Object ID"); id = sys_get_le48(pid); - BT_DBG_OBJ_ID("Parent Group Object ID: ", id); + LOG_DBG_OBJ_ID("Parent Group Object ID: ", id); } if (mcc_cb && mcc_cb->read_parent_group_obj_id) { @@ -623,14 +624,14 @@ static uint8_t mcc_read_current_group_obj_id_cb(struct bt_conn *conn, uint8_t er mcs_inst->busy = false; if (err) { - BT_DBG("err: 0x%02x", err); + LOG_DBG("err: 0x%02x", err); } else if (!pid || (length != BT_OTS_OBJ_ID_SIZE)) { - BT_DBG("length: %d, data: %p", length, data); + LOG_DBG("length: %d, data: %p", length, data); cb_err = BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } else { LOG_HEXDUMP_DBG(pid, length, "Current Group Object ID"); id = sys_get_le48(pid); - BT_DBG_OBJ_ID("Current Group Object ID: ", id); + LOG_DBG_OBJ_ID("Current Group Object ID: ", id); } if (mcc_cb && mcc_cb->read_current_group_obj_id) { @@ -649,13 +650,13 @@ static void mcs_write_current_group_obj_id_cb(struct bt_conn *conn, uint8_t err, mcs_inst->busy = false; if (err) { - BT_DBG("err: 0x%02x", err); + LOG_DBG("err: 0x%02x", err); } else if (!params->data || params->length != BT_OTS_OBJ_ID_SIZE) { - BT_DBG("length: %d, data: %p", params->length, params->data); + LOG_DBG("length: %d, data: %p", params->length, params->data); cb_err = BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } else { obj_id = sys_get_le48((const uint8_t *)params->data); - BT_DBG_OBJ_ID("Object ID: ", obj_id); + LOG_DBG_OBJ_ID("Object ID: ", obj_id); } if (mcc_cb && mcc_cb->set_current_group_obj_id) { @@ -674,13 +675,13 @@ static uint8_t mcc_read_playing_order_cb(struct bt_conn *conn, uint8_t err, mcs_inst->busy = false; if (err) { - BT_DBG("err: 0x%02x", err); + LOG_DBG("err: 0x%02x", err); } else if ((!data) || (length != sizeof(order))) { - BT_DBG("length: %d, data: %p", length, data); + LOG_DBG("length: %d, data: %p", length, data); cb_err = BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } else { order = *(uint8_t *)data; - BT_DBG("Playing order: %d", order); + LOG_DBG("Playing order: %d", order); LOG_HEXDUMP_DBG(data, sizeof(order), "Playing order"); } @@ -700,13 +701,13 @@ static void mcs_write_playing_order_cb(struct bt_conn *conn, uint8_t err, mcs_inst->busy = false; if (err) { - BT_DBG("err: 0x%02x", err); + LOG_DBG("err: 0x%02x", err); } else if (!params->data || params->length != sizeof(order)) { - BT_DBG("length: %d, data: %p", params->length, params->data); + LOG_DBG("length: %d, data: %p", params->length, params->data); cb_err = BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } else { order = *(uint8_t *)params->data; - BT_DBG("Playing order: %d", *(uint8_t *)params->data); + LOG_DBG("Playing order: %d", *(uint8_t *)params->data); } if (mcc_cb && mcc_cb->set_playing_order) { @@ -724,13 +725,13 @@ static uint8_t mcc_read_playing_orders_supported_cb(struct bt_conn *conn, uint8_ mcs_inst->busy = false; if (err) { - BT_DBG("err: 0x%02x", err); + LOG_DBG("err: 0x%02x", err); } else if (!data || length != sizeof(orders)) { - BT_DBG("length: %d, data: %p", length, data); + LOG_DBG("length: %d, data: %p", length, data); cb_err = BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } else { orders = sys_get_le16((uint8_t *)data); - BT_DBG("Playing orders_supported: %d", orders); + LOG_DBG("Playing orders_supported: %d", orders); LOG_HEXDUMP_DBG(data, sizeof(orders), "Playing orders supported"); } @@ -751,13 +752,13 @@ static uint8_t mcc_read_media_state_cb(struct bt_conn *conn, uint8_t err, mcs_inst->busy = false; if (err) { - BT_DBG("err: 0x%02x", err); + LOG_DBG("err: 0x%02x", err); } else if (!data || length != sizeof(state)) { - BT_DBG("length: %d, data: %p", length, data); + LOG_DBG("length: %d, data: %p", length, data); cb_err = BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } else { state = *(uint8_t *)data; - BT_DBG("Media state: %d", state); + LOG_DBG("Media state: %d", state); LOG_HEXDUMP_DBG(data, sizeof(uint8_t), "Media state"); } @@ -778,13 +779,13 @@ static void mcs_write_cp_cb(struct bt_conn *conn, uint8_t err, mcs_inst->busy = false; if (err) { - BT_DBG("err: 0x%02x", err); + LOG_DBG("err: 0x%02x", err); } else if (!params->data || (params->length != sizeof(cmd.opcode) && params->length != sizeof(cmd.opcode) + sizeof(cmd.param))) { /* Above: No data pointer, or length not equal to any of the */ /* two possible values */ - BT_DBG("length: %d, data: %p", params->length, params->data); + LOG_DBG("length: %d, data: %p", params->length, params->data); cb_err = BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } else { (void)memcpy(&cmd.opcode, params->data, sizeof(cmd.opcode)); @@ -793,7 +794,7 @@ static void mcs_write_cp_cb(struct bt_conn *conn, uint8_t err, (char *)(params->data) + sizeof(cmd.opcode), sizeof(cmd.param)); cmd.use_param = true; - BT_DBG("Command in callback: %d, param: %d", cmd.opcode, cmd.param); + LOG_DBG("Command in callback: %d, param: %d", cmd.opcode, cmd.param); } } @@ -813,14 +814,14 @@ static uint8_t mcc_read_opcodes_supported_cb(struct bt_conn *conn, uint8_t err, mcs_inst->busy = false; if (err) { - BT_DBG("err: 0x%02x", err); + LOG_DBG("err: 0x%02x", err); } else if ((!data) || (length != sizeof(operations))) { - BT_DBG("length: %d, data: %p", length, data); + LOG_DBG("length: %d, data: %p", length, data); cb_err = BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } else { operations = sys_get_le32((uint8_t *)data); - BT_DBG("Opcodes supported: %d", operations); + LOG_DBG("Opcodes supported: %d", operations); LOG_HEXDUMP_DBG(data, sizeof(operations), "Opcodes_supported"); } @@ -842,15 +843,15 @@ static void mcs_write_scp_cb(struct bt_conn *conn, uint8_t err, mcs_inst->busy = false; if (err) { - BT_DBG("err: 0x%02x", err); + LOG_DBG("err: 0x%02x", err); } else if (!params->data || (params->length > SEARCH_LEN_MAX)) { - BT_DBG("length: %d, data: %p", params->length, params->data); + LOG_DBG("length: %d, data: %p", params->length, params->data); cb_err = BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } else { search.len = params->length; (void)memcpy(search.search, params->data, params->length); - BT_DBG("Length of returned value in callback: %d", search.len); + LOG_DBG("Length of returned value in callback: %d", search.len); } if (mcc_cb && mcc_cb->send_search) { @@ -869,17 +870,17 @@ static uint8_t mcc_read_search_results_obj_id_cb(struct bt_conn *conn, uint8_t e mcs_inst->busy = false; if (err) { - BT_DBG("err: 0x%02x", err); + LOG_DBG("err: 0x%02x", err); } else if (length == 0) { /* OK - this characteristic may be zero length */ /* cb_err and id already have correct values */ - BT_DBG("Zero-length Search Results Object ID"); + LOG_DBG("Zero-length Search Results Object ID"); } else if (!pid || (length != BT_OTS_OBJ_ID_SIZE)) { - BT_DBG("length: %d, pid: %p", length, pid); + LOG_DBG("length: %d, pid: %p", length, pid); cb_err = BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } else { id = sys_get_le48(pid); - BT_DBG_OBJ_ID("Search Results Object ID: ", id); + LOG_DBG_OBJ_ID("Search Results Object ID: ", id); } if (mcc_cb && mcc_cb->read_search_results_obj_id) { @@ -901,14 +902,14 @@ static uint8_t mcc_read_content_control_id_cb(struct bt_conn *conn, uint8_t err, mcs_inst->busy = false; if (err) { - BT_DBG("err: 0x%02x", err); + LOG_DBG("err: 0x%02x", err); } else if ((!data) || (length != sizeof(ccid))) { - BT_DBG("length: %d, data: %p", length, data); + LOG_DBG("length: %d, data: %p", length, data); cb_err = BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } else { ccid = *(uint8_t *)data; - BT_DBG("Content control ID: %d", ccid); + LOG_DBG("Content control ID: %d", ccid); } if (mcc_cb && mcc_cb->read_content_control_id) { @@ -927,7 +928,7 @@ static uint8_t mcs_notify_handler(struct bt_conn *conn, struct mcs_instance_t *mcs_inst; if (data == NULL) { - BT_DBG("[UNSUBSCRIBED] 0x%04X", params->value_handle); + LOG_DBG("[UNSUBSCRIBED] 0x%04X", params->value_handle); params->value_handle = 0U; return BT_GATT_ITER_CONTINUE; @@ -935,8 +936,7 @@ static uint8_t mcs_notify_handler(struct bt_conn *conn, mcs_inst = lookup_inst_by_conn(conn); if (mcs_inst == NULL) { - BT_DBG("Could not find MCS instance from conn %p", - (void *)conn); + LOG_DBG("Could not find MCS instance from conn %p", (void *)conn); return BT_GATT_ITER_CONTINUE; } @@ -948,10 +948,10 @@ static uint8_t mcs_notify_handler(struct bt_conn *conn, */ read_params = &mcs_inst->read_params; - BT_DBG("Notification, handle: %d", handle); + LOG_DBG("Notification, handle: %d", handle); if (handle == mcs_inst->player_name_handle) { - BT_DBG("Player Name notification"); + LOG_DBG("Player Name notification"); mcc_read_player_name_cb(conn, 0, read_params, data, length); } else if (handle == mcs_inst->track_changed_handle) { @@ -959,11 +959,11 @@ static uint8_t mcs_notify_handler(struct bt_conn *conn, /* notified, so that is handled directly here */ int cb_err = 0; - BT_DBG("Track Changed notification"); - BT_DBG("data: %p, length: %u", data, length); + LOG_DBG("Track Changed notification"); + LOG_DBG("data: %p, length: %u", data, length); if (length != 0) { - BT_DBG("Non-zero length: %u", length); + LOG_DBG("Non-zero length: %u", length); cb_err = BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } @@ -972,53 +972,53 @@ static uint8_t mcs_notify_handler(struct bt_conn *conn, } } else if (handle == mcs_inst->track_title_handle) { - BT_DBG("Track Title notification"); + LOG_DBG("Track Title notification"); mcc_read_track_title_cb(conn, 0, read_params, data, length); } else if (handle == mcs_inst->track_duration_handle) { - BT_DBG("Track Duration notification"); + LOG_DBG("Track Duration notification"); mcc_read_track_duration_cb(conn, 0, read_params, data, length); } else if (handle == mcs_inst->track_position_handle) { - BT_DBG("Track Position notification"); + LOG_DBG("Track Position notification"); mcc_read_track_position_cb(conn, 0, read_params, data, length); } else if (handle == mcs_inst->playback_speed_handle) { - BT_DBG("Playback Speed notification"); + LOG_DBG("Playback Speed notification"); mcc_read_playback_speed_cb(conn, 0, read_params, data, length); } else if (handle == mcs_inst->seeking_speed_handle) { - BT_DBG("Seeking Speed notification"); + LOG_DBG("Seeking Speed notification"); mcc_read_seeking_speed_cb(conn, 0, read_params, data, length); #ifdef CONFIG_BT_MCC_OTS } else if (handle == mcs_inst->current_track_obj_id_handle) { - BT_DBG("Current Track notification"); + LOG_DBG("Current Track notification"); mcc_read_current_track_obj_id_cb(conn, 0, read_params, data, length); } else if (handle == mcs_inst->next_track_obj_id_handle) { - BT_DBG("Next Track notification"); + LOG_DBG("Next Track notification"); mcc_read_next_track_obj_id_cb(conn, 0, read_params, data, length); } else if (handle == mcs_inst->parent_group_obj_id_handle) { - BT_DBG("Parent Group notification"); + LOG_DBG("Parent Group notification"); mcc_read_parent_group_obj_id_cb(conn, 0, read_params, data, length); } else if (handle == mcs_inst->current_group_obj_id_handle) { - BT_DBG("Current Group notification"); + LOG_DBG("Current Group notification"); mcc_read_current_group_obj_id_cb(conn, 0, read_params, data, length); #endif /* CONFIG_BT_MCC_OTS */ } else if (handle == mcs_inst->playing_order_handle) { - BT_DBG("Playing Order notification"); + LOG_DBG("Playing Order notification"); mcc_read_playing_order_cb(conn, 0, read_params, data, length); } else if (handle == mcs_inst->media_state_handle) { - BT_DBG("Media State notification"); + LOG_DBG("Media State notification"); mcc_read_media_state_cb(conn, 0, read_params, data, length); } else if (handle == mcs_inst->cp_handle) { @@ -1027,15 +1027,15 @@ static uint8_t mcs_notify_handler(struct bt_conn *conn, struct mpl_cmd_ntf ntf = {0}; int cb_err = 0; - BT_DBG("Control Point notification"); + LOG_DBG("Control Point notification"); if (length == sizeof(ntf.requested_opcode) + sizeof(ntf.result_code)) { ntf.requested_opcode = *(uint8_t *)data; ntf.result_code = *((uint8_t *)data + sizeof(ntf.requested_opcode)); - BT_DBG("Command: %d, result: %d", + LOG_DBG("Command: %d, result: %d", ntf.requested_opcode, ntf.result_code); } else { - BT_DBG("length: %d, data: %p", length, data); + LOG_DBG("length: %d, data: %p", length, data); cb_err = BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } @@ -1044,7 +1044,7 @@ static uint8_t mcs_notify_handler(struct bt_conn *conn, } } else if (handle == mcs_inst->opcodes_supported_handle) { - BT_DBG("Opcodes Supported notification"); + LOG_DBG("Opcodes Supported notification"); mcc_read_opcodes_supported_cb(conn, 0, read_params, data, length); @@ -1055,12 +1055,12 @@ static uint8_t mcs_notify_handler(struct bt_conn *conn, int cb_err = 0; uint8_t result_code = 0; - BT_DBG("Search Control Point notification"); + LOG_DBG("Search Control Point notification"); if (length == sizeof(result_code)) { result_code = *(uint8_t *)data; - BT_DBG("Result: %d", result_code); + LOG_DBG("Result: %d", result_code); } else { - BT_DBG("length: %d, data: %p", length, data); + LOG_DBG("length: %d, data: %p", length, data); cb_err = BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } @@ -1069,12 +1069,12 @@ static uint8_t mcs_notify_handler(struct bt_conn *conn, } } else if (handle == mcs_inst->search_results_obj_id_handle) { - BT_DBG("Search Results notification"); + LOG_DBG("Search Results notification"); mcc_read_search_results_obj_id_cb(conn, 0, read_params, data, length); #endif /* CONFIG_BT_MCC_OTS */ } else { - BT_DBG("Unknown handle: %d (0x%04X)", handle, handle); + LOG_DBG("Unknown handle: %d (0x%04X)", handle, handle); } return BT_GATT_ITER_CONTINUE; @@ -1083,7 +1083,7 @@ static uint8_t mcs_notify_handler(struct bt_conn *conn, /* Called when discovery is completed - successfully or with error */ static void discovery_complete(struct bt_conn *conn, int err) { - BT_DBG("Discovery completed, err: %d", err); + LOG_DBG("Discovery completed, err: %d", err); /* TODO: Handle resets of instance, and re-discovery. * For now, reset instance on error. @@ -1116,7 +1116,7 @@ static uint8_t discover_otc_char_func(struct bt_conn *conn, if (attr) { /* Found an attribute */ - BT_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); + LOG_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); if (params->type != BT_GATT_DISCOVER_CHARACTERISTIC) { /* But it was not a characteristic - continue search */ @@ -1127,30 +1127,30 @@ static uint8_t discover_otc_char_func(struct bt_conn *conn, /* Find out which attribute, and subscribe if we should */ chrc = (struct bt_gatt_chrc *)attr->user_data; if (!bt_uuid_cmp(chrc->uuid, BT_UUID_OTS_FEATURE)) { - BT_DBG("OTS Features"); + LOG_DBG("OTS Features"); mcs_inst->otc.feature_handle = chrc->value_handle; } else if (!bt_uuid_cmp(chrc->uuid, BT_UUID_OTS_NAME)) { - BT_DBG("Object Name"); + LOG_DBG("Object Name"); mcs_inst->otc.obj_name_handle = chrc->value_handle; } else if (!bt_uuid_cmp(chrc->uuid, BT_UUID_OTS_TYPE)) { - BT_DBG("Object Type"); + LOG_DBG("Object Type"); mcs_inst->otc.obj_type_handle = chrc->value_handle; } else if (!bt_uuid_cmp(chrc->uuid, BT_UUID_OTS_SIZE)) { - BT_DBG("Object Size"); + LOG_DBG("Object Size"); mcs_inst->otc.obj_size_handle = chrc->value_handle; } else if (!bt_uuid_cmp(chrc->uuid, BT_UUID_OTS_ID)) { - BT_DBG("Object ID"); + LOG_DBG("Object ID"); mcs_inst->otc.obj_id_handle = chrc->value_handle; } else if (!bt_uuid_cmp(chrc->uuid, BT_UUID_OTS_PROPERTIES)) { - BT_DBG("Object properties %d", chrc->value_handle); + LOG_DBG("Object properties %d", chrc->value_handle); mcs_inst->otc.obj_properties_handle = chrc->value_handle; } else if (!bt_uuid_cmp(chrc->uuid, BT_UUID_OTS_ACTION_CP)) { - BT_DBG("Object Action Control Point"); + LOG_DBG("Object Action Control Point"); mcs_inst->otc.oacp_handle = chrc->value_handle; sub_params = &mcs_inst->otc.oacp_sub_params; sub_params->disc_params = &mcs_inst->otc.oacp_sub_disc_params; } else if (!bt_uuid_cmp(chrc->uuid, BT_UUID_OTS_LIST_CP)) { - BT_DBG("Object List Control Point"); + LOG_DBG("Object List Control Point"); mcs_inst->otc.olcp_handle = chrc->value_handle; sub_params = &mcs_inst->otc.olcp_sub_params; sub_params->disc_params = &mcs_inst->otc.olcp_sub_disc_params; @@ -1174,7 +1174,7 @@ static uint8_t discover_otc_char_func(struct bt_conn *conn, mcs_inst->otc.cb = &otc_cb; bt_ots_client_register(&mcs_inst->otc); - BT_DBG("Setup complete for included OTS"); + LOG_DBG("Setup complete for included OTS"); (void)memset(params, 0, sizeof(*params)); discovery_complete(conn, err); @@ -1202,23 +1202,23 @@ static uint8_t discover_include_func(struct bt_conn *conn, struct mcs_instance_t, discover_params); - BT_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); + LOG_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); __ASSERT(params->type == BT_GATT_DISCOVER_INCLUDE, "Wrong type"); /* We have found an included service */ include = (struct bt_gatt_include *)attr->user_data; - BT_DBG("Include UUID %s", bt_uuid_str(include->uuid)); + LOG_DBG("Include UUID %s", bt_uuid_str(include->uuid)); if (bt_uuid_cmp(include->uuid, BT_UUID_OTS)) { /* But it is not OTS - continue search */ - BT_WARN("Included service is not OTS"); + LOG_WRN("Included service is not OTS"); return BT_GATT_ITER_CONTINUE; } /* We have the included OTS service (MCS includes only one) */ - BT_DBG("Discover include complete for GMCS: OTS"); + LOG_DBG("Discover include complete for GMCS: OTS"); mcs_inst->otc.start_handle = include->start_handle; mcs_inst->otc.end_handle = include->end_handle; (void)memset(params, 0, sizeof(*params)); @@ -1229,16 +1229,16 @@ static uint8_t discover_include_func(struct bt_conn *conn, mcs_inst->discover_params.type = BT_GATT_DISCOVER_CHARACTERISTIC; mcs_inst->discover_params.func = discover_otc_char_func; - BT_DBG("Start discovery of OTS characteristics"); + LOG_DBG("Start discovery of OTS characteristics"); err = bt_gatt_discover(conn, &mcs_inst->discover_params); if (err) { - BT_DBG("Discovery of OTS chars. failed"); + LOG_DBG("Discovery of OTS chars. failed"); discovery_complete(conn, err); } return BT_GATT_ITER_STOP; } - BT_DBG("No included OTS found"); + LOG_DBG("No included OTS found"); /* This is OK, the server may not support OTS. But in that case, * discovery stops here. */ @@ -1256,10 +1256,10 @@ static void discover_included(struct mcs_instance_t *mcs_inst, struct bt_conn *c mcs_inst->discover_params.type = BT_GATT_DISCOVER_INCLUDE; mcs_inst->discover_params.func = discover_include_func; - BT_DBG("Start discovery of included services"); + LOG_DBG("Start discovery of included services"); err = bt_gatt_discover(conn, &mcs_inst->discover_params); if (err) { - BT_DBG("Discovery of included service failed: %d", err); + LOG_DBG("Discovery of included service failed: %d", err); discovery_complete(conn, err); } } @@ -1280,13 +1280,13 @@ static void subscribe_mcs_char_func(struct bt_conn *conn, uint8_t err, bool subscription_done; if (err) { - BT_DBG("Subscription callback error: %u", err); + LOG_DBG("Subscription callback error: %u", err); params->subscribe = NULL; discovery_complete(conn, err); return; } - BT_DBG("Subscribed: value handle: %d, ccc handle: %d", + LOG_DBG("Subscribed: value handle: %d, ccc handle: %d", params->value_handle, params->ccc_handle); /* Subscribe to next characteristic */ @@ -1318,7 +1318,7 @@ static int do_subscribe(struct mcs_instance_t *mcs_inst, struct bt_conn *conn, /* disc_params pointer is also used as subscription flag */ sub_params->disc_params = &mcs_inst->discover_params; - BT_DBG("Subscring to handle %d", handle); + LOG_DBG("Subscring to handle %d", handle); return bt_gatt_subscribe(conn, sub_params); } @@ -1435,7 +1435,7 @@ static bool subscribe_next_mcs_char(struct mcs_instance_t *mcs_inst, sub_params); if (err) { - BT_DBG("Could not subscribe: %d", err); + LOG_DBG("Could not subscribe: %d", err); discovery_complete(conn, err); } @@ -1464,7 +1464,7 @@ static uint8_t discover_mcs_char_func(struct bt_conn *conn, if (attr) { /* Found an attribute */ - BT_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); + LOG_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); if (params->type != BT_GATT_DISCOVER_CHARACTERISTIC) { /* But it was not a characteristic - continue search */ @@ -1476,7 +1476,7 @@ static uint8_t discover_mcs_char_func(struct bt_conn *conn, chrc = (struct bt_gatt_chrc *)attr->user_data; if (!bt_uuid_cmp(chrc->uuid, BT_UUID_MCS_PLAYER_NAME)) { - BT_DBG("Player name, UUID: %s", bt_uuid_str(chrc->uuid)); + LOG_DBG("Player name, UUID: %s", bt_uuid_str(chrc->uuid)); mcs_inst->player_name_handle = chrc->value_handle; /* Use discovery params pointer as subscription flag */ mcs_inst->player_name_sub_params.disc_params = NULL; @@ -1485,49 +1485,49 @@ static uint8_t discover_mcs_char_func(struct bt_conn *conn, } #ifdef CONFIG_BT_MCC_OTS } else if (!bt_uuid_cmp(chrc->uuid, BT_UUID_MCS_ICON_OBJ_ID)) { - BT_DBG("Icon Object, UUID: %s", bt_uuid_str(chrc->uuid)); + LOG_DBG("Icon Object, UUID: %s", bt_uuid_str(chrc->uuid)); mcs_inst->icon_obj_id_handle = chrc->value_handle; #endif /* CONFIG_BT_MCC_OTS */ } else if (!bt_uuid_cmp(chrc->uuid, BT_UUID_MCS_ICON_URL)) { - BT_DBG("Icon URL, UUID: %s", bt_uuid_str(chrc->uuid)); + LOG_DBG("Icon URL, UUID: %s", bt_uuid_str(chrc->uuid)); mcs_inst->icon_url_handle = chrc->value_handle; } else if (!bt_uuid_cmp(chrc->uuid, BT_UUID_MCS_TRACK_CHANGED)) { - BT_DBG("Track Changed, UUID: %s", bt_uuid_str(chrc->uuid)); + LOG_DBG("Track Changed, UUID: %s", bt_uuid_str(chrc->uuid)); mcs_inst->track_changed_handle = chrc->value_handle; mcs_inst->track_changed_sub_params.disc_params = NULL; if (chrc->properties & BT_GATT_CHRC_NOTIFY) { mcs_inst->track_changed_sub_params.value = BT_GATT_CCC_NOTIFY; } } else if (!bt_uuid_cmp(chrc->uuid, BT_UUID_MCS_TRACK_TITLE)) { - BT_DBG("Track Title, UUID: %s", bt_uuid_str(chrc->uuid)); + LOG_DBG("Track Title, UUID: %s", bt_uuid_str(chrc->uuid)); mcs_inst->track_title_handle = chrc->value_handle; mcs_inst->track_title_sub_params.disc_params = NULL; if (chrc->properties & BT_GATT_CHRC_NOTIFY) { mcs_inst->track_title_sub_params.value = BT_GATT_CCC_NOTIFY; } } else if (!bt_uuid_cmp(chrc->uuid, BT_UUID_MCS_TRACK_DURATION)) { - BT_DBG("Track Duration, UUID: %s", bt_uuid_str(chrc->uuid)); + LOG_DBG("Track Duration, UUID: %s", bt_uuid_str(chrc->uuid)); mcs_inst->track_duration_handle = chrc->value_handle; mcs_inst->track_duration_sub_params.disc_params = NULL; if (chrc->properties & BT_GATT_CHRC_NOTIFY) { mcs_inst->track_duration_sub_params.value = BT_GATT_CCC_NOTIFY; } } else if (!bt_uuid_cmp(chrc->uuid, BT_UUID_MCS_TRACK_POSITION)) { - BT_DBG("Track Position, UUID: %s", bt_uuid_str(chrc->uuid)); + LOG_DBG("Track Position, UUID: %s", bt_uuid_str(chrc->uuid)); mcs_inst->track_position_handle = chrc->value_handle; mcs_inst->track_position_sub_params.disc_params = NULL; if (chrc->properties & BT_GATT_CHRC_NOTIFY) { mcs_inst->track_position_sub_params.value = BT_GATT_CCC_NOTIFY; } } else if (!bt_uuid_cmp(chrc->uuid, BT_UUID_MCS_PLAYBACK_SPEED)) { - BT_DBG("Playback Speed, UUID: %s", bt_uuid_str(chrc->uuid)); + LOG_DBG("Playback Speed, UUID: %s", bt_uuid_str(chrc->uuid)); mcs_inst->playback_speed_handle = chrc->value_handle; mcs_inst->playback_speed_sub_params.disc_params = NULL; if (chrc->properties & BT_GATT_CHRC_NOTIFY) { mcs_inst->playback_speed_sub_params.value = BT_GATT_CCC_NOTIFY; } } else if (!bt_uuid_cmp(chrc->uuid, BT_UUID_MCS_SEEKING_SPEED)) { - BT_DBG("Seeking Speed, UUID: %s", bt_uuid_str(chrc->uuid)); + LOG_DBG("Seeking Speed, UUID: %s", bt_uuid_str(chrc->uuid)); mcs_inst->seeking_speed_handle = chrc->value_handle; mcs_inst->seeking_speed_sub_params.disc_params = NULL; if (chrc->properties & BT_GATT_CHRC_NOTIFY) { @@ -1535,10 +1535,10 @@ static uint8_t discover_mcs_char_func(struct bt_conn *conn, } #ifdef CONFIG_BT_MCC_OTS } else if (!bt_uuid_cmp(chrc->uuid, BT_UUID_MCS_TRACK_SEGMENTS_OBJ_ID)) { - BT_DBG("Track Segments Object, UUID: %s", bt_uuid_str(chrc->uuid)); + LOG_DBG("Track Segments Object, UUID: %s", bt_uuid_str(chrc->uuid)); mcs_inst->segments_obj_id_handle = chrc->value_handle; } else if (!bt_uuid_cmp(chrc->uuid, BT_UUID_MCS_CURRENT_TRACK_OBJ_ID)) { - BT_DBG("Current Track Object, UUID: %s", bt_uuid_str(chrc->uuid)); + LOG_DBG("Current Track Object, UUID: %s", bt_uuid_str(chrc->uuid)); mcs_inst->current_track_obj_id_handle = chrc->value_handle; mcs_inst->current_track_obj_sub_params.disc_params = NULL; if (chrc->properties & BT_GATT_CHRC_NOTIFY) { @@ -1546,14 +1546,14 @@ static uint8_t discover_mcs_char_func(struct bt_conn *conn, BT_GATT_CCC_NOTIFY; } } else if (!bt_uuid_cmp(chrc->uuid, BT_UUID_MCS_NEXT_TRACK_OBJ_ID)) { - BT_DBG("Next Track Object, UUID: %s", bt_uuid_str(chrc->uuid)); + LOG_DBG("Next Track Object, UUID: %s", bt_uuid_str(chrc->uuid)); mcs_inst->next_track_obj_id_handle = chrc->value_handle; mcs_inst->next_track_obj_sub_params.disc_params = NULL; if (chrc->properties & BT_GATT_CHRC_NOTIFY) { mcs_inst->next_track_obj_sub_params.value = BT_GATT_CCC_NOTIFY; } } else if (!bt_uuid_cmp(chrc->uuid, BT_UUID_MCS_PARENT_GROUP_OBJ_ID)) { - BT_DBG("Parent Group Object, UUID: %s", bt_uuid_str(chrc->uuid)); + LOG_DBG("Parent Group Object, UUID: %s", bt_uuid_str(chrc->uuid)); mcs_inst->parent_group_obj_id_handle = chrc->value_handle; mcs_inst->parent_group_obj_sub_params.disc_params = NULL; if (chrc->properties & BT_GATT_CHRC_NOTIFY) { @@ -1561,7 +1561,7 @@ static uint8_t discover_mcs_char_func(struct bt_conn *conn, BT_GATT_CCC_NOTIFY; } } else if (!bt_uuid_cmp(chrc->uuid, BT_UUID_MCS_CURRENT_GROUP_OBJ_ID)) { - BT_DBG("Group Object, UUID: %s", bt_uuid_str(chrc->uuid)); + LOG_DBG("Group Object, UUID: %s", bt_uuid_str(chrc->uuid)); mcs_inst->current_group_obj_id_handle = chrc->value_handle; mcs_inst->current_group_obj_sub_params.disc_params = NULL; if (chrc->properties & BT_GATT_CHRC_NOTIFY) { @@ -1570,31 +1570,31 @@ static uint8_t discover_mcs_char_func(struct bt_conn *conn, } #endif /* CONFIG_BT_MCC_OTS */ } else if (!bt_uuid_cmp(chrc->uuid, BT_UUID_MCS_PLAYING_ORDER)) { - BT_DBG("Playing Order, UUID: %s", bt_uuid_str(chrc->uuid)); + LOG_DBG("Playing Order, UUID: %s", bt_uuid_str(chrc->uuid)); mcs_inst->playing_order_handle = chrc->value_handle; mcs_inst->playing_order_sub_params.disc_params = NULL; if (chrc->properties & BT_GATT_CHRC_NOTIFY) { mcs_inst->playing_order_sub_params.value = BT_GATT_CCC_NOTIFY; } } else if (!bt_uuid_cmp(chrc->uuid, BT_UUID_MCS_PLAYING_ORDERS)) { - BT_DBG("Playing Orders supported, UUID: %s", bt_uuid_str(chrc->uuid)); + LOG_DBG("Playing Orders supported, UUID: %s", bt_uuid_str(chrc->uuid)); mcs_inst->playing_orders_supported_handle = chrc->value_handle; } else if (!bt_uuid_cmp(chrc->uuid, BT_UUID_MCS_MEDIA_STATE)) { - BT_DBG("Media State, UUID: %s", bt_uuid_str(chrc->uuid)); + LOG_DBG("Media State, UUID: %s", bt_uuid_str(chrc->uuid)); mcs_inst->media_state_handle = chrc->value_handle; mcs_inst->media_state_sub_params.disc_params = NULL; if (chrc->properties & BT_GATT_CHRC_NOTIFY) { mcs_inst->media_state_sub_params.value = BT_GATT_CCC_NOTIFY; } } else if (!bt_uuid_cmp(chrc->uuid, BT_UUID_MCS_MEDIA_CONTROL_POINT)) { - BT_DBG("Media Control Point, UUID: %s", bt_uuid_str(chrc->uuid)); + LOG_DBG("Media Control Point, UUID: %s", bt_uuid_str(chrc->uuid)); mcs_inst->cp_handle = chrc->value_handle; mcs_inst->cp_sub_params.disc_params = NULL; if (chrc->properties & BT_GATT_CHRC_NOTIFY) { mcs_inst->cp_sub_params.value = BT_GATT_CCC_NOTIFY; } } else if (!bt_uuid_cmp(chrc->uuid, BT_UUID_MCS_MEDIA_CONTROL_OPCODES)) { - BT_DBG("Media control opcodes supported, UUID: %s", + LOG_DBG("Media control opcodes supported, UUID: %s", bt_uuid_str(chrc->uuid)); mcs_inst->opcodes_supported_handle = chrc->value_handle; mcs_inst->opcodes_supported_sub_params.disc_params = NULL; @@ -1604,14 +1604,14 @@ static uint8_t discover_mcs_char_func(struct bt_conn *conn, } #ifdef CONFIG_BT_MCC_OTS } else if (!bt_uuid_cmp(chrc->uuid, BT_UUID_MCS_SEARCH_CONTROL_POINT)) { - BT_DBG("Search control point, UUID: %s", bt_uuid_str(chrc->uuid)); + LOG_DBG("Search control point, UUID: %s", bt_uuid_str(chrc->uuid)); mcs_inst->scp_handle = chrc->value_handle; mcs_inst->scp_sub_params.disc_params = NULL; if (chrc->properties & BT_GATT_CHRC_NOTIFY) { mcs_inst->scp_sub_params.value = BT_GATT_CCC_NOTIFY; } } else if (!bt_uuid_cmp(chrc->uuid, BT_UUID_MCS_SEARCH_RESULTS_OBJ_ID)) { - BT_DBG("Search Results object, UUID: %s", bt_uuid_str(chrc->uuid)); + LOG_DBG("Search Results object, UUID: %s", bt_uuid_str(chrc->uuid)); mcs_inst->search_results_obj_id_handle = chrc->value_handle; mcs_inst->search_results_obj_sub_params.disc_params = NULL; if (chrc->properties & BT_GATT_CHRC_NOTIFY) { @@ -1620,7 +1620,7 @@ static uint8_t discover_mcs_char_func(struct bt_conn *conn, } #endif /* CONFIG_BT_MCC_OTS */ } else if (!bt_uuid_cmp(chrc->uuid, BT_UUID_CCID)) { - BT_DBG("Content Control ID, UUID: %s", bt_uuid_str(chrc->uuid)); + LOG_DBG("Content Control ID, UUID: %s", bt_uuid_str(chrc->uuid)); mcs_inst->content_control_id_handle = chrc->value_handle; } @@ -1630,7 +1630,7 @@ static uint8_t discover_mcs_char_func(struct bt_conn *conn, } /* No more attributes found */ - BT_DBG("GMCS characteristics found"); + LOG_DBG("GMCS characteristics found"); (void)memset(params, 0, sizeof(*params)); /* Either subscribe to characteristics, or continue to discovery of @@ -1672,20 +1672,20 @@ static uint8_t discover_primary_func(struct bt_conn *conn, discover_params); int err; /* Found an attribute */ - BT_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); + LOG_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); if (params->type != BT_GATT_DISCOVER_PRIMARY) { /* But it was not a primary service - continue search */ - BT_WARN("Unexpected parameters"); + LOG_WRN("Unexpected parameters"); return BT_GATT_ITER_CONTINUE; } /* We have found an attribute, and it is a primary service */ /* (Must be GMCS, since that is the one we searched for.) */ - BT_DBG("Primary discovery complete"); - BT_DBG("UUID: %s", bt_uuid_str(attr->uuid)); + LOG_DBG("Primary discovery complete"); + LOG_DBG("UUID: %s", bt_uuid_str(attr->uuid)); prim_service = (struct bt_gatt_service_val *)attr->user_data; - BT_DBG("UUID: %s", bt_uuid_str(prim_service->uuid)); + LOG_DBG("UUID: %s", bt_uuid_str(prim_service->uuid)); mcs_inst->start_handle = attr->handle + 1; mcs_inst->end_handle = prim_service->end_handle; @@ -1697,17 +1697,17 @@ static uint8_t discover_primary_func(struct bt_conn *conn, mcs_inst->discover_params.type = BT_GATT_DISCOVER_CHARACTERISTIC; mcs_inst->discover_params.func = discover_mcs_char_func; - BT_DBG("Start discovery of GMCS characteristics"); + LOG_DBG("Start discovery of GMCS characteristics"); err = bt_gatt_discover(conn, &mcs_inst->discover_params); if (err) { - BT_DBG("Discovery failed: %d", err); + LOG_DBG("Discovery failed: %d", err); discovery_complete(conn, err); } return BT_GATT_ITER_STOP; } /* No attribute of the searched for type found */ - BT_DBG("Could not find an GMCS instance on the server"); + LOG_DBG("Could not find an GMCS instance on the server"); discovery_complete(conn, -ENODATA); return BT_GATT_ITER_STOP; @@ -1727,9 +1727,9 @@ int bt_mcc_init(struct bt_mcc_cb *cb) otc_cb.obj_selected = on_obj_selected; otc_cb.obj_metadata_read = on_object_metadata; - BT_DBG("Object selected callback: %p", otc_cb.obj_selected); - BT_DBG("Object content callback: %p", otc_cb.obj_data_read); - BT_DBG("Object metadata callback: %p", otc_cb.obj_metadata_read); + LOG_DBG("Object selected callback: %p", otc_cb.obj_selected); + LOG_DBG("Object content callback: %p", otc_cb.obj_data_read); + LOG_DBG("Object metadata callback: %p", otc_cb.obj_metadata_read); #endif /* CONFIG_BT_MCC_OTS */ return 0; @@ -1775,7 +1775,7 @@ int bt_mcc_discover_mcs(struct bt_conn *conn, bool subscribe) mcs_inst->discover_params.start_handle = BT_ATT_FIRST_ATTRIBUTE_HANDLE; mcs_inst->discover_params.end_handle = BT_ATT_LAST_ATTRIBUTE_HANDLE; - BT_DBG("start discovery of GMCS primary service"); + LOG_DBG("start discovery of GMCS primary service"); return bt_gatt_discover(conn, &mcs_inst->discover_params); } @@ -1785,22 +1785,22 @@ int bt_mcc_read_player_name(struct bt_conn *conn) int err; CHECKIF(conn == NULL) { - BT_DBG("conn is NULL"); + LOG_DBG("conn is NULL"); return -EINVAL; } mcs_inst = lookup_inst_by_conn(conn); if (mcs_inst == NULL) { - BT_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); + LOG_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); return -EINVAL; } else if (mcs_inst->busy) { - BT_DBG("mcs_inst busy"); + LOG_DBG("mcs_inst busy"); return -EBUSY; } else if (mcs_inst->player_name_handle == 0) { - BT_DBG("handle not set"); + LOG_DBG("handle not set"); return -EINVAL; } @@ -1825,22 +1825,22 @@ int bt_mcc_read_icon_obj_id(struct bt_conn *conn) int err; CHECKIF(conn == NULL) { - BT_DBG("conn is NULL"); + LOG_DBG("conn is NULL"); return -EINVAL; } mcs_inst = lookup_inst_by_conn(conn); if (mcs_inst == NULL) { - BT_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); + LOG_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); return -EINVAL; } else if (mcs_inst->busy) { - BT_DBG("mcs_inst busy"); + LOG_DBG("mcs_inst busy"); return -EBUSY; } else if (mcs_inst->icon_obj_id_handle == 0) { - BT_DBG("handle not set"); + LOG_DBG("handle not set"); return -EINVAL; } @@ -1864,22 +1864,22 @@ int bt_mcc_read_icon_url(struct bt_conn *conn) int err; CHECKIF(conn == NULL) { - BT_DBG("conn is NULL"); + LOG_DBG("conn is NULL"); return -EINVAL; } mcs_inst = lookup_inst_by_conn(conn); if (mcs_inst == NULL) { - BT_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); + LOG_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); return -EINVAL; } else if (mcs_inst->busy) { - BT_DBG("mcs_inst busy"); + LOG_DBG("mcs_inst busy"); return -EBUSY; } else if (mcs_inst->icon_url_handle == 0) { - BT_DBG("handle not set"); + LOG_DBG("handle not set"); return -EINVAL; } @@ -1902,22 +1902,22 @@ int bt_mcc_read_track_title(struct bt_conn *conn) int err; CHECKIF(conn == NULL) { - BT_DBG("conn is NULL"); + LOG_DBG("conn is NULL"); return -EINVAL; } mcs_inst = lookup_inst_by_conn(conn); if (mcs_inst == NULL) { - BT_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); + LOG_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); return -EINVAL; } else if (mcs_inst->busy) { - BT_DBG("mcs_inst busy"); + LOG_DBG("mcs_inst busy"); return -EBUSY; } else if (mcs_inst->track_title_handle == 0) { - BT_DBG("handle not set"); + LOG_DBG("handle not set"); return -EINVAL; } @@ -1940,22 +1940,22 @@ int bt_mcc_read_track_duration(struct bt_conn *conn) int err; CHECKIF(conn == NULL) { - BT_DBG("conn is NULL"); + LOG_DBG("conn is NULL"); return -EINVAL; } mcs_inst = lookup_inst_by_conn(conn); if (mcs_inst == NULL) { - BT_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); + LOG_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); return -EINVAL; } else if (mcs_inst->busy) { - BT_DBG("mcs_inst busy"); + LOG_DBG("mcs_inst busy"); return -EBUSY; } else if (mcs_inst->track_duration_handle == 0) { - BT_DBG("handle not set"); + LOG_DBG("handle not set"); return -EINVAL; } @@ -1978,22 +1978,22 @@ int bt_mcc_read_track_position(struct bt_conn *conn) int err; CHECKIF(conn == NULL) { - BT_DBG("conn is NULL"); + LOG_DBG("conn is NULL"); return -EINVAL; } mcs_inst = lookup_inst_by_conn(conn); if (mcs_inst == NULL) { - BT_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); + LOG_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); return -EINVAL; } else if (mcs_inst->busy) { - BT_DBG("mcs_inst busy"); + LOG_DBG("mcs_inst busy"); return -EBUSY; } else if (mcs_inst->track_position_handle == 0) { - BT_DBG("handle not set"); + LOG_DBG("handle not set"); return -EINVAL; } @@ -2016,22 +2016,22 @@ int bt_mcc_set_track_position(struct bt_conn *conn, int32_t pos) int err; CHECKIF(conn == NULL) { - BT_DBG("conn is NULL"); + LOG_DBG("conn is NULL"); return -EINVAL; } mcs_inst = lookup_inst_by_conn(conn); if (mcs_inst == NULL) { - BT_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); + LOG_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); return -EINVAL; } else if (mcs_inst->busy) { - BT_DBG("mcs_inst busy"); + LOG_DBG("mcs_inst busy"); return -EBUSY; } else if (mcs_inst->track_position_handle == 0) { - BT_DBG("handle not set"); + LOG_DBG("handle not set"); return -EINVAL; } @@ -2059,22 +2059,22 @@ int bt_mcc_read_playback_speed(struct bt_conn *conn) int err; CHECKIF(conn == NULL) { - BT_DBG("conn is NULL"); + LOG_DBG("conn is NULL"); return -EINVAL; } mcs_inst = lookup_inst_by_conn(conn); if (mcs_inst == NULL) { - BT_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); + LOG_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); return -EINVAL; } else if (mcs_inst->busy) { - BT_DBG("mcs_inst busy"); + LOG_DBG("mcs_inst busy"); return -EBUSY; } else if (mcs_inst->playback_speed_handle == 0) { - BT_DBG("handle not set"); + LOG_DBG("handle not set"); return -EINVAL; } @@ -2097,22 +2097,22 @@ int bt_mcc_set_playback_speed(struct bt_conn *conn, int8_t speed) int err; CHECKIF(conn == NULL) { - BT_DBG("conn is NULL"); + LOG_DBG("conn is NULL"); return -EINVAL; } mcs_inst = lookup_inst_by_conn(conn); if (mcs_inst == NULL) { - BT_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); + LOG_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); return -EINVAL; } else if (mcs_inst->busy) { - BT_DBG("mcs_inst busy"); + LOG_DBG("mcs_inst busy"); return -EBUSY; } else if (mcs_inst->playback_speed_handle == 0) { - BT_DBG("handle not set"); + LOG_DBG("handle not set"); return -EINVAL; } @@ -2140,22 +2140,22 @@ int bt_mcc_read_seeking_speed(struct bt_conn *conn) int err; CHECKIF(conn == NULL) { - BT_DBG("conn is NULL"); + LOG_DBG("conn is NULL"); return -EINVAL; } mcs_inst = lookup_inst_by_conn(conn); if (mcs_inst == NULL) { - BT_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); + LOG_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); return -EINVAL; } else if (mcs_inst->busy) { - BT_DBG("mcs_inst busy"); + LOG_DBG("mcs_inst busy"); return -EBUSY; } else if (mcs_inst->seeking_speed_handle == 0) { - BT_DBG("handle not set"); + LOG_DBG("handle not set"); return -EINVAL; } @@ -2179,22 +2179,22 @@ int bt_mcc_read_segments_obj_id(struct bt_conn *conn) int err; CHECKIF(conn == NULL) { - BT_DBG("conn is NULL"); + LOG_DBG("conn is NULL"); return -EINVAL; } mcs_inst = lookup_inst_by_conn(conn); if (mcs_inst == NULL) { - BT_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); + LOG_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); return -EINVAL; } else if (mcs_inst->busy) { - BT_DBG("mcs_inst busy"); + LOG_DBG("mcs_inst busy"); return -EBUSY; } else if (mcs_inst->segments_obj_id_handle == 0) { - BT_DBG("handle not set"); + LOG_DBG("handle not set"); return -EINVAL; } @@ -2217,22 +2217,22 @@ int bt_mcc_read_current_track_obj_id(struct bt_conn *conn) int err; CHECKIF(conn == NULL) { - BT_DBG("conn is NULL"); + LOG_DBG("conn is NULL"); return -EINVAL; } mcs_inst = lookup_inst_by_conn(conn); if (mcs_inst == NULL) { - BT_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); + LOG_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); return -EINVAL; } else if (mcs_inst->busy) { - BT_DBG("mcs_inst busy"); + LOG_DBG("mcs_inst busy"); return -EBUSY; } else if (mcs_inst->current_track_obj_id_handle == 0) { - BT_DBG("handle not set"); + LOG_DBG("handle not set"); return -EINVAL; } @@ -2255,27 +2255,27 @@ int bt_mcc_set_current_track_obj_id(struct bt_conn *conn, uint64_t obj_id) int err; CHECKIF(conn == NULL) { - BT_DBG("conn is NULL"); + LOG_DBG("conn is NULL"); return -EINVAL; } CHECKIF(obj_id < BT_OTS_OBJ_ID_MIN || obj_id > BT_OTS_OBJ_ID_MAX) { - BT_DBG("Object ID 0x%016x invalid", obj_id); + LOG_DBG("Object ID 0x%016x invalid", obj_id); return -EINVAL; } mcs_inst = lookup_inst_by_conn(conn); if (mcs_inst == NULL) { - BT_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); + LOG_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); return -EINVAL; } else if (mcs_inst->busy) { - BT_DBG("mcs_inst busy"); + LOG_DBG("mcs_inst busy"); return -EBUSY; } else if (mcs_inst->current_track_obj_id_handle == 0) { - BT_DBG("handle not set"); + LOG_DBG("handle not set"); return -EINVAL; } @@ -2302,22 +2302,22 @@ int bt_mcc_read_next_track_obj_id(struct bt_conn *conn) int err; CHECKIF(conn == NULL) { - BT_DBG("conn is NULL"); + LOG_DBG("conn is NULL"); return -EINVAL; } mcs_inst = lookup_inst_by_conn(conn); if (mcs_inst == NULL) { - BT_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); + LOG_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); return -EINVAL; } else if (mcs_inst->busy) { - BT_DBG("mcs_inst busy"); + LOG_DBG("mcs_inst busy"); return -EBUSY; } else if (mcs_inst->next_track_obj_id_handle == 0) { - BT_DBG("handle not set"); + LOG_DBG("handle not set"); return -EINVAL; } @@ -2340,27 +2340,27 @@ int bt_mcc_set_next_track_obj_id(struct bt_conn *conn, uint64_t obj_id) int err; CHECKIF(conn == NULL) { - BT_DBG("conn is NULL"); + LOG_DBG("conn is NULL"); return -EINVAL; } CHECKIF(obj_id < BT_OTS_OBJ_ID_MIN || obj_id > BT_OTS_OBJ_ID_MAX) { - BT_DBG("Object ID 0x%016x invalid", obj_id); + LOG_DBG("Object ID 0x%016x invalid", obj_id); return -EINVAL; } mcs_inst = lookup_inst_by_conn(conn); if (mcs_inst == NULL) { - BT_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); + LOG_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); return -EINVAL; } else if (mcs_inst->busy) { - BT_DBG("mcs_inst busy"); + LOG_DBG("mcs_inst busy"); return -EBUSY; } else if (mcs_inst->next_track_obj_id_handle == 0) { - BT_DBG("handle not set"); + LOG_DBG("handle not set"); return -EINVAL; } @@ -2387,22 +2387,22 @@ int bt_mcc_read_parent_group_obj_id(struct bt_conn *conn) int err; CHECKIF(conn == NULL) { - BT_DBG("conn is NULL"); + LOG_DBG("conn is NULL"); return -EINVAL; } mcs_inst = lookup_inst_by_conn(conn); if (mcs_inst == NULL) { - BT_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); + LOG_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); return -EINVAL; } else if (mcs_inst->busy) { - BT_DBG("mcs_inst busy"); + LOG_DBG("mcs_inst busy"); return -EBUSY; } else if (mcs_inst->parent_group_obj_id_handle == 0) { - BT_DBG("handle not set"); + LOG_DBG("handle not set"); return -EINVAL; } @@ -2425,22 +2425,22 @@ int bt_mcc_read_current_group_obj_id(struct bt_conn *conn) int err; CHECKIF(conn == NULL) { - BT_DBG("conn is NULL"); + LOG_DBG("conn is NULL"); return -EINVAL; } mcs_inst = lookup_inst_by_conn(conn); if (mcs_inst == NULL) { - BT_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); + LOG_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); return -EINVAL; } else if (mcs_inst->busy) { - BT_DBG("mcs_inst busy"); + LOG_DBG("mcs_inst busy"); return -EBUSY; } else if (mcs_inst->current_group_obj_id_handle == 0) { - BT_DBG("handle not set"); + LOG_DBG("handle not set"); return -EINVAL; } @@ -2463,27 +2463,27 @@ int bt_mcc_set_current_group_obj_id(struct bt_conn *conn, uint64_t obj_id) int err; CHECKIF(conn == NULL) { - BT_DBG("conn is NULL"); + LOG_DBG("conn is NULL"); return -EINVAL; } CHECKIF(obj_id < BT_OTS_OBJ_ID_MIN || obj_id > BT_OTS_OBJ_ID_MAX) { - BT_DBG("Object ID 0x%016x invalid", obj_id); + LOG_DBG("Object ID 0x%016x invalid", obj_id); return -EINVAL; } mcs_inst = lookup_inst_by_conn(conn); if (mcs_inst == NULL) { - BT_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); + LOG_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); return -EINVAL; } else if (mcs_inst->busy) { - BT_DBG("mcs_inst busy"); + LOG_DBG("mcs_inst busy"); return -EBUSY; } else if (mcs_inst->current_group_obj_id_handle == 0) { - BT_DBG("handle not set"); + LOG_DBG("handle not set"); return -EINVAL; } @@ -2511,22 +2511,22 @@ int bt_mcc_read_playing_order(struct bt_conn *conn) int err; CHECKIF(conn == NULL) { - BT_DBG("conn is NULL"); + LOG_DBG("conn is NULL"); return -EINVAL; } mcs_inst = lookup_inst_by_conn(conn); if (mcs_inst == NULL) { - BT_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); + LOG_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); return -EINVAL; } else if (mcs_inst->busy) { - BT_DBG("mcs_inst busy"); + LOG_DBG("mcs_inst busy"); return -EBUSY; } else if (mcs_inst->playing_order_handle == 0) { - BT_DBG("handle not set"); + LOG_DBG("handle not set"); return -EINVAL; } @@ -2549,22 +2549,22 @@ int bt_mcc_set_playing_order(struct bt_conn *conn, uint8_t order) int err; CHECKIF(conn == NULL) { - BT_DBG("conn is NULL"); + LOG_DBG("conn is NULL"); return -EINVAL; } mcs_inst = lookup_inst_by_conn(conn); if (mcs_inst == NULL) { - BT_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); + LOG_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); return -EINVAL; } else if (mcs_inst->busy) { - BT_DBG("mcs_inst busy"); + LOG_DBG("mcs_inst busy"); return -EBUSY; } else if (mcs_inst->playing_order_handle == 0) { - BT_DBG("handle not set"); + LOG_DBG("handle not set"); return -EINVAL; } @@ -2592,22 +2592,22 @@ int bt_mcc_read_playing_orders_supported(struct bt_conn *conn) int err; CHECKIF(conn == NULL) { - BT_DBG("conn is NULL"); + LOG_DBG("conn is NULL"); return -EINVAL; } mcs_inst = lookup_inst_by_conn(conn); if (mcs_inst == NULL) { - BT_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); + LOG_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); return -EINVAL; } else if (mcs_inst->busy) { - BT_DBG("mcs_inst busy"); + LOG_DBG("mcs_inst busy"); return -EBUSY; } else if (mcs_inst->playing_orders_supported_handle == 0) { - BT_DBG("handle not set"); + LOG_DBG("handle not set"); return -EINVAL; } @@ -2630,22 +2630,22 @@ int bt_mcc_read_media_state(struct bt_conn *conn) int err; CHECKIF(conn == NULL) { - BT_DBG("conn is NULL"); + LOG_DBG("conn is NULL"); return -EINVAL; } mcs_inst = lookup_inst_by_conn(conn); if (mcs_inst == NULL) { - BT_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); + LOG_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); return -EINVAL; } else if (mcs_inst->busy) { - BT_DBG("mcs_inst busy"); + LOG_DBG("mcs_inst busy"); return -EBUSY; } else if (mcs_inst->media_state_handle == 0) { - BT_DBG("handle not set"); + LOG_DBG("handle not set"); return -EINVAL; } @@ -2669,22 +2669,22 @@ int bt_mcc_send_cmd(struct bt_conn *conn, const struct mpl_cmd *cmd) int err; CHECKIF(conn == NULL) { - BT_DBG("conn is NULL"); + LOG_DBG("conn is NULL"); return -EINVAL; } mcs_inst = lookup_inst_by_conn(conn); if (mcs_inst == NULL) { - BT_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); + LOG_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); return -EINVAL; } else if (mcs_inst->busy) { - BT_DBG("mcs_inst busy"); + LOG_DBG("mcs_inst busy"); return -EBUSY; } else if (mcs_inst->cp_handle == 0) { - BT_DBG("handle not set"); + LOG_DBG("handle not set"); return -EINVAL; } @@ -2718,22 +2718,22 @@ int bt_mcc_read_opcodes_supported(struct bt_conn *conn) int err; CHECKIF(conn == NULL) { - BT_DBG("conn is NULL"); + LOG_DBG("conn is NULL"); return -EINVAL; } mcs_inst = lookup_inst_by_conn(conn); if (mcs_inst == NULL) { - BT_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); + LOG_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); return -EINVAL; } else if (mcs_inst->busy) { - BT_DBG("mcs_inst busy"); + LOG_DBG("mcs_inst busy"); return -EBUSY; } else if (mcs_inst->opcodes_supported_handle == 0) { - BT_DBG("handle not set"); + LOG_DBG("handle not set"); return -EINVAL; } @@ -2757,22 +2757,22 @@ int bt_mcc_send_search(struct bt_conn *conn, const struct mpl_search *search) int err; CHECKIF(conn == NULL) { - BT_DBG("conn is NULL"); + LOG_DBG("conn is NULL"); return -EINVAL; } mcs_inst = lookup_inst_by_conn(conn); if (mcs_inst == NULL) { - BT_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); + LOG_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); return -EINVAL; } else if (mcs_inst->busy) { - BT_DBG("mcs_inst busy"); + LOG_DBG("mcs_inst busy"); return -EBUSY; } else if (mcs_inst->scp_handle == 0) { - BT_DBG("handle not set"); + LOG_DBG("handle not set"); return -EINVAL; } @@ -2800,22 +2800,22 @@ int bt_mcc_read_search_results_obj_id(struct bt_conn *conn) int err; CHECKIF(conn == NULL) { - BT_DBG("conn is NULL"); + LOG_DBG("conn is NULL"); return -EINVAL; } mcs_inst = lookup_inst_by_conn(conn); if (mcs_inst == NULL) { - BT_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); + LOG_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); return -EINVAL; } else if (mcs_inst->busy) { - BT_DBG("mcs_inst busy"); + LOG_DBG("mcs_inst busy"); return -EBUSY; } else if (mcs_inst->search_results_obj_id_handle == 0) { - BT_DBG("handle not set"); + LOG_DBG("handle not set"); return -EINVAL; } @@ -2839,22 +2839,22 @@ int bt_mcc_read_content_control_id(struct bt_conn *conn) int err; CHECKIF(conn == NULL) { - BT_DBG("conn is NULL"); + LOG_DBG("conn is NULL"); return -EINVAL; } mcs_inst = lookup_inst_by_conn(conn); if (mcs_inst == NULL) { - BT_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); + LOG_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); return -EINVAL; } else if (mcs_inst->busy) { - BT_DBG("mcs_inst busy"); + LOG_DBG("mcs_inst busy"); return -EBUSY; } else if (mcs_inst->content_control_id_handle == 0) { - BT_DBG("handle not set"); + LOG_DBG("handle not set"); return -EINVAL; } @@ -2876,7 +2876,7 @@ int bt_mcc_read_content_control_id(struct bt_conn *conn) void on_obj_selected(struct bt_ots_client *otc_inst, struct bt_conn *conn, int result) { - BT_DBG("Current object selected"); + LOG_DBG("Current object selected"); /* TODO: Read metadata here? */ /* For now: Left to the application */ @@ -2898,13 +2898,13 @@ int on_icon_content(struct bt_ots_client *otc_inst, struct bt_conn *conn, { int cb_err = 0; - BT_DBG("Received Media Player Icon content, %i bytes at offset %i", + LOG_DBG("Received Media Player Icon content, %i bytes at offset %i", len, offset); LOG_HEXDUMP_DBG(data_p, len, "Icon content"); if (len > net_buf_simple_tailroom(&otc_obj_buf)) { - BT_WARN("Can not fit whole object"); + LOG_WRN("Can not fit whole object"); cb_err = -EMSGSIZE; } @@ -2912,7 +2912,7 @@ int on_icon_content(struct bt_ots_client *otc_inst, struct bt_conn *conn, MIN(net_buf_simple_tailroom(&otc_obj_buf), len)); if (is_complete) { - BT_DBG("Icon object received"); + LOG_DBG("Icon object received"); if (mcc_cb && mcc_cb->otc_icon_object) { mcc_cb->otc_icon_object(conn, cb_err, &otc_obj_buf); @@ -2925,7 +2925,7 @@ int on_icon_content(struct bt_ots_client *otc_inst, struct bt_conn *conn, return BT_OTS_CONTINUE; } -#if CONFIG_BT_DEBUG_MCC +#if CONFIG_BT_MCC_LOG_LEVEL_DBG struct track_seg_t { uint8_t name_len; char name[CONFIG_BT_MCC_SEGMENT_NAME_MAX]; @@ -2956,7 +2956,7 @@ static void decode_track_segments(struct net_buf_simple *buff, seg->name_len = net_buf_simple_pull_u8(&tmp_buf); if (seg->name_len + sizeof(int32_t) > tmp_buf.len) { - BT_WARN("Segment too long"); + LOG_WRN("Segment too long"); return; } @@ -2975,7 +2975,7 @@ static void decode_track_segments(struct net_buf_simple *buff, track_segs->segs[i].pos = (int32_t)net_buf_simple_pull_le32(&tmp_buf); } } -#endif /* CONFIG_BT_DEBUG_MCC */ +#endif /* CONFIG_BT_MCC_LOG_LEVEL_DBG */ int on_track_segments_content(struct bt_ots_client *otc_inst, struct bt_conn *conn, uint32_t offset, @@ -2983,11 +2983,11 @@ int on_track_segments_content(struct bt_ots_client *otc_inst, { int cb_err = 0; - BT_DBG("Received Track Segments content, %i bytes at offset %i", + LOG_DBG("Received Track Segments content, %i bytes at offset %i", len, offset); if (len > net_buf_simple_tailroom(&otc_obj_buf)) { - BT_WARN("Can not fit whole object"); + LOG_WRN("Can not fit whole object"); cb_err = -EMSGSIZE; } @@ -2995,20 +2995,20 @@ int on_track_segments_content(struct bt_ots_client *otc_inst, MIN(net_buf_simple_tailroom(&otc_obj_buf), len)); if (is_complete) { - BT_DBG("Track segment object received"); + LOG_DBG("Track segment object received"); -#if CONFIG_BT_DEBUG_MCC +#if CONFIG_BT_MCC_LOG_LEVEL_DBG struct track_segs_t track_segments; track_segments.cnt = 0; decode_track_segments(&otc_obj_buf, &track_segments); for (int i = 0; i < track_segments.cnt; i++) { - BT_DBG("Track segment %i:", i); - BT_DBG("\t-Name\t:%s", + LOG_DBG("Track segment %i:", i); + LOG_DBG("\t-Name\t:%s", track_segments.segs[i].name); - BT_DBG("\t-Position\t:%d", track_segments.segs[i].pos); + LOG_DBG("\t-Position\t:%d", track_segments.segs[i].pos); } -#endif /* CONFIG_BT_DEBUG_MCC */ +#endif /* CONFIG_BT_MCC_LOG_LEVEL_DBG */ if (mcc_cb && mcc_cb->otc_track_segments_object) { mcc_cb->otc_track_segments_object(conn, @@ -3027,13 +3027,13 @@ int on_current_track_content(struct bt_ots_client *otc_inst, { int cb_err = 0; - BT_DBG("Received Current Track content, %i bytes at offset %i", + LOG_DBG("Received Current Track content, %i bytes at offset %i", len, offset); LOG_HEXDUMP_DBG(data_p, len, "Track content"); if (len > net_buf_simple_tailroom(&otc_obj_buf)) { - BT_WARN("Can not fit whole object"); + LOG_WRN("Can not fit whole object"); cb_err = -EMSGSIZE; } @@ -3041,7 +3041,7 @@ int on_current_track_content(struct bt_ots_client *otc_inst, MIN(net_buf_simple_tailroom(&otc_obj_buf), len)); if (is_complete) { - BT_DBG("Current Track Object received"); + LOG_DBG("Current Track Object received"); if (mcc_cb && mcc_cb->otc_current_track_object) { mcc_cb->otc_current_track_object(conn, cb_err, &otc_obj_buf); @@ -3059,13 +3059,13 @@ int on_next_track_content(struct bt_ots_client *otc_inst, { int cb_err = 0; - BT_DBG("Received Next Track content, %i bytes at offset %i", + LOG_DBG("Received Next Track content, %i bytes at offset %i", len, offset); LOG_HEXDUMP_DBG(data_p, len, "Track content"); if (len > net_buf_simple_tailroom(&otc_obj_buf)) { - BT_WARN("Can not fit whole object"); + LOG_WRN("Can not fit whole object"); cb_err = -EMSGSIZE; } @@ -3073,7 +3073,7 @@ int on_next_track_content(struct bt_ots_client *otc_inst, MIN(net_buf_simple_tailroom(&otc_obj_buf), len)); if (is_complete) { - BT_DBG("Next Track Object received"); + LOG_DBG("Next Track Object received"); if (mcc_cb && mcc_cb->otc_next_track_object) { mcc_cb->otc_next_track_object(conn, cb_err, &otc_obj_buf); @@ -3086,7 +3086,7 @@ int on_next_track_content(struct bt_ots_client *otc_inst, } -#if CONFIG_BT_DEBUG_MCC +#if CONFIG_BT_MCC_LOG_LEVEL_DBG struct id_list_elem_t { uint8_t type; uint64_t id; @@ -3110,7 +3110,7 @@ static void decode_group(struct net_buf_simple *buff, ids->ids[ids->cnt++].id = net_buf_simple_pull_le48(&tmp_buf); } } -#endif /* CONFIG_BT_DEBUG_MCC */ +#endif /* CONFIG_BT_MCC_LOG_LEVEL_DBG */ int on_parent_group_content(struct bt_ots_client *otc_inst, struct bt_conn *conn, uint32_t offset, @@ -3118,13 +3118,13 @@ int on_parent_group_content(struct bt_ots_client *otc_inst, { int cb_err = 0; - BT_DBG("Received Parent Group content, %i bytes at offset %i", + LOG_DBG("Received Parent Group content, %i bytes at offset %i", len, offset); LOG_HEXDUMP_DBG(data_p, len, "Group content"); if (len > net_buf_simple_tailroom(&otc_obj_buf)) { - BT_WARN("Can not fit whole object"); + LOG_WRN("Can not fit whole object"); cb_err = -EMSGSIZE; } @@ -3132,9 +3132,9 @@ int on_parent_group_content(struct bt_ots_client *otc_inst, MIN(net_buf_simple_tailroom(&otc_obj_buf), len)); if (is_complete) { - BT_DBG("Parent Group object received"); + LOG_DBG("Parent Group object received"); -#if CONFIG_BT_DEBUG_MCC +#if CONFIG_BT_MCC_LOG_LEVEL_DBG struct id_list_t group = {0}; decode_group(&otc_obj_buf, &group); @@ -3143,10 +3143,10 @@ int on_parent_group_content(struct bt_ots_client *otc_inst, (void)bt_ots_obj_id_to_str(group.ids[i].id, t, BT_OTS_OBJ_ID_STR_LEN); - BT_DBG("Object type: %d, object ID: %s", + LOG_DBG("Object type: %d, object ID: %s", group.ids[i].type, t); } -#endif /* CONFIG_BT_DEBUG_MCC */ +#endif /* CONFIG_BT_MCC_LOG_LEVEL_DBG */ if (mcc_cb && mcc_cb->otc_parent_group_object) { mcc_cb->otc_parent_group_object(conn, cb_err, &otc_obj_buf); @@ -3164,13 +3164,13 @@ int on_current_group_content(struct bt_ots_client *otc_inst, { int cb_err = 0; - BT_DBG("Received Current Group content, %i bytes at offset %i", + LOG_DBG("Received Current Group content, %i bytes at offset %i", len, offset); LOG_HEXDUMP_DBG(data_p, len, "Group content"); if (len > net_buf_simple_tailroom(&otc_obj_buf)) { - BT_WARN("Can not fit whole object"); + LOG_WRN("Can not fit whole object"); cb_err = -EMSGSIZE; } @@ -3178,9 +3178,9 @@ int on_current_group_content(struct bt_ots_client *otc_inst, MIN(net_buf_simple_tailroom(&otc_obj_buf), len)); if (is_complete) { - BT_DBG("Current Group object received"); + LOG_DBG("Current Group object received"); -#if CONFIG_BT_DEBUG_MCC +#if CONFIG_BT_MCC_LOG_LEVEL_DBG struct id_list_t group = {0}; decode_group(&otc_obj_buf, &group); @@ -3189,10 +3189,10 @@ int on_current_group_content(struct bt_ots_client *otc_inst, (void)bt_ots_obj_id_to_str(group.ids[i].id, t, BT_OTS_OBJ_ID_STR_LEN); - BT_DBG("Object type: %d, object ID: %s", + LOG_DBG("Object type: %d, object ID: %s", group.ids[i].type, t); } -#endif /* CONFIG_BT_DEBUG_MCC */ +#endif /* CONFIG_BT_MCC_LOG_LEVEL_DBG */ if (mcc_cb && mcc_cb->otc_current_group_object) { mcc_cb->otc_current_group_object(conn, cb_err, &otc_obj_buf); @@ -3208,11 +3208,11 @@ void on_object_metadata(struct bt_ots_client *otc_inst, struct bt_conn *conn, int err, uint8_t metadata_read) { - BT_INFO("Object's meta data:"); - BT_INFO("\tCurrent size\t:%u", otc_inst->cur_object.size.cur); + LOG_INF("Object's meta data:"); + LOG_INF("\tCurrent size\t:%u", otc_inst->cur_object.size.cur); if (otc_inst->cur_object.size.cur > otc_obj_buf.size) { - BT_DBG("Object larger than allocated buffer"); + LOG_DBG("Object larger than allocated buffer"); } bt_ots_metadata_display(&otc_inst->cur_object, 1); @@ -3228,26 +3228,26 @@ int bt_mcc_otc_read_object_metadata(struct bt_conn *conn) int err; CHECKIF(conn == NULL) { - BT_DBG("conn is NULL"); + LOG_DBG("conn is NULL"); return -EINVAL; } mcs_inst = lookup_inst_by_conn(conn); if (mcs_inst == NULL) { - BT_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); + LOG_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); return -EINVAL; } else if (mcs_inst->busy) { - BT_DBG("mcs_inst busy"); + LOG_DBG("mcs_inst busy"); return -EBUSY; } err = bt_ots_client_read_object_metadata(&mcs_inst->otc, conn, BT_OTS_METADATA_REQ_ALL); if (err) { - BT_DBG("Error reading the object: %d", err); + LOG_DBG("Error reading the object: %d", err); } return err; @@ -3260,19 +3260,19 @@ int bt_mcc_otc_read_icon_object(struct bt_conn *conn) int err; CHECKIF(conn == NULL) { - BT_DBG("conn is NULL"); + LOG_DBG("conn is NULL"); return -EINVAL; } mcs_inst = lookup_inst_by_conn(conn); if (mcs_inst == NULL) { - BT_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); + LOG_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); return -EINVAL; } else if (mcs_inst->busy) { - BT_DBG("mcs_inst busy"); + LOG_DBG("mcs_inst busy"); return -EBUSY; } @@ -3280,7 +3280,7 @@ int bt_mcc_otc_read_icon_object(struct bt_conn *conn) err = bt_ots_client_read_object_data(&mcs_inst->otc, conn); if (err) { - BT_DBG("Error reading the object: %d", err); + LOG_DBG("Error reading the object: %d", err); } return err; @@ -3292,19 +3292,19 @@ int bt_mcc_otc_read_track_segments_object(struct bt_conn *conn) int err; CHECKIF(conn == NULL) { - BT_DBG("conn is NULL"); + LOG_DBG("conn is NULL"); return -EINVAL; } mcs_inst = lookup_inst_by_conn(conn); if (mcs_inst == NULL) { - BT_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); + LOG_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); return -EINVAL; } else if (mcs_inst->busy) { - BT_DBG("mcs_inst busy"); + LOG_DBG("mcs_inst busy"); return -EBUSY; } @@ -3313,7 +3313,7 @@ int bt_mcc_otc_read_track_segments_object(struct bt_conn *conn) err = bt_ots_client_read_object_data(&mcs_inst->otc, conn); if (err) { - BT_DBG("Error reading the object: %d", err); + LOG_DBG("Error reading the object: %d", err); } return err; @@ -3325,19 +3325,19 @@ int bt_mcc_otc_read_current_track_object(struct bt_conn *conn) int err; CHECKIF(conn == NULL) { - BT_DBG("conn is NULL"); + LOG_DBG("conn is NULL"); return -EINVAL; } mcs_inst = lookup_inst_by_conn(conn); if (mcs_inst == NULL) { - BT_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); + LOG_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); return -EINVAL; } else if (mcs_inst->busy) { - BT_DBG("mcs_inst busy"); + LOG_DBG("mcs_inst busy"); return -EBUSY; } @@ -3346,7 +3346,7 @@ int bt_mcc_otc_read_current_track_object(struct bt_conn *conn) err = bt_ots_client_read_object_data(&mcs_inst->otc, conn); if (err) { - BT_DBG("Error reading the object: %d", err); + LOG_DBG("Error reading the object: %d", err); } return err; @@ -3358,19 +3358,19 @@ int bt_mcc_otc_read_next_track_object(struct bt_conn *conn) int err; CHECKIF(conn == NULL) { - BT_DBG("conn is NULL"); + LOG_DBG("conn is NULL"); return -EINVAL; } mcs_inst = lookup_inst_by_conn(conn); if (mcs_inst == NULL) { - BT_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); + LOG_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); return -EINVAL; } else if (mcs_inst->busy) { - BT_DBG("mcs_inst busy"); + LOG_DBG("mcs_inst busy"); return -EBUSY; } @@ -3379,7 +3379,7 @@ int bt_mcc_otc_read_next_track_object(struct bt_conn *conn) err = bt_ots_client_read_object_data(&mcs_inst->otc, conn); if (err) { - BT_DBG("Error reading the object: %d", err); + LOG_DBG("Error reading the object: %d", err); } return err; @@ -3391,19 +3391,19 @@ int bt_mcc_otc_read_parent_group_object(struct bt_conn *conn) int err; CHECKIF(conn == NULL) { - BT_DBG("conn is NULL"); + LOG_DBG("conn is NULL"); return -EINVAL; } mcs_inst = lookup_inst_by_conn(conn); if (mcs_inst == NULL) { - BT_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); + LOG_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); return -EINVAL; } else if (mcs_inst->busy) { - BT_DBG("mcs_inst busy"); + LOG_DBG("mcs_inst busy"); return -EBUSY; } @@ -3414,7 +3414,7 @@ int bt_mcc_otc_read_parent_group_object(struct bt_conn *conn) err = bt_ots_client_read_object_data(&mcs_inst->otc, conn); if (err) { - BT_DBG("Error reading the object: %d", err); + LOG_DBG("Error reading the object: %d", err); } return err; @@ -3426,19 +3426,19 @@ int bt_mcc_otc_read_current_group_object(struct bt_conn *conn) int err; CHECKIF(conn == NULL) { - BT_DBG("conn is NULL"); + LOG_DBG("conn is NULL"); return -EINVAL; } mcs_inst = lookup_inst_by_conn(conn); if (mcs_inst == NULL) { - BT_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); + LOG_DBG("Could not lookup mcs_inst from conn %p", (void *)conn); return -EINVAL; } else if (mcs_inst->busy) { - BT_DBG("mcs_inst busy"); + LOG_DBG("mcs_inst busy"); return -EBUSY; } @@ -3447,7 +3447,7 @@ int bt_mcc_otc_read_current_group_object(struct bt_conn *conn) err = bt_ots_client_read_object_data(&mcs_inst->otc, conn); if (err) { - BT_DBG("Error reading the object: %d", err); + LOG_DBG("Error reading the object: %d", err); } return err; diff --git a/subsys/bluetooth/audio/mcs.c b/subsys/bluetooth/audio/mcs.c index 42b02dd9a20..1ca7a52fb45 100644 --- a/subsys/bluetooth/audio/mcs.c +++ b/subsys/bluetooth/audio/mcs.c @@ -26,9 +26,9 @@ #include "audio_internal.h" #include "media_proxy_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_MCS) -#define LOG_MODULE_NAME bt_mcs -#include "common/log.h" +#include + +LOG_MODULE_REGISTER(bt_mcs, CONFIG_BT_MCS_LOG_LEVEL); /* TODO Media control may send a large number of notifications for a * single command, so requires many buffers. @@ -51,7 +51,7 @@ static ssize_t read_player_name(struct bt_conn *conn, { const char *name = media_proxy_sctrl_get_player_name(); - BT_DBG("Player name read: %s", name); + LOG_DBG("Player name read: %s", name); return bt_gatt_attr_read(conn, attr, buf, len, offset, name, strlen(name)); @@ -60,7 +60,7 @@ static ssize_t read_player_name(struct bt_conn *conn, static void player_name_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("value 0x%04x", value); + LOG_DBG("value 0x%04x", value); } #ifdef CONFIG_BT_OTS @@ -70,7 +70,7 @@ static ssize_t read_icon_id(struct bt_conn *conn, { uint64_t icon_id = media_proxy_sctrl_get_icon_id(); - BT_DBG_OBJ_ID("Icon object read: ", icon_id); + LOG_DBG_OBJ_ID("Icon object read: ", icon_id); return bt_gatt_attr_read(conn, attr, buf, len, offset, &icon_id, BT_OTS_OBJ_ID_SIZE); } @@ -82,8 +82,7 @@ static ssize_t read_icon_url(struct bt_conn *conn, { const char *url = media_proxy_sctrl_get_icon_url(); - BT_DBG("Icon URL read, offset: %d, len:%d, URL: %s", offset, len, - url); + LOG_DBG("Icon URL read, offset: %d, len:%d, URL: %s", offset, len, url); return bt_gatt_attr_read(conn, attr, buf, len, offset, url, strlen(url)); @@ -91,7 +90,7 @@ static ssize_t read_icon_url(struct bt_conn *conn, static void track_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("value 0x%04x", value); + LOG_DBG("value 0x%04x", value); } static ssize_t read_track_title(struct bt_conn *conn, @@ -100,8 +99,7 @@ static ssize_t read_track_title(struct bt_conn *conn, { const char *title = media_proxy_sctrl_get_track_title(); - BT_DBG("Track title read, offset: %d, len:%d, title: %s", offset, len, - title); + LOG_DBG("Track title read, offset: %d, len:%d, title: %s", offset, len, title); return bt_gatt_attr_read(conn, attr, buf, len, offset, title, strlen(title)); @@ -110,7 +108,7 @@ static ssize_t read_track_title(struct bt_conn *conn, static void track_title_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("value 0x%04x", value); + LOG_DBG("value 0x%04x", value); } static ssize_t read_track_duration(struct bt_conn *conn, @@ -119,7 +117,7 @@ static ssize_t read_track_duration(struct bt_conn *conn, { int32_t duration = media_proxy_sctrl_get_track_duration(); - BT_DBG("Track duration read: %d (0x%08x)", duration, duration); + LOG_DBG("Track duration read: %d (0x%08x)", duration, duration); return bt_gatt_attr_read(conn, attr, buf, len, offset, &duration, sizeof(duration)); @@ -128,7 +126,7 @@ static ssize_t read_track_duration(struct bt_conn *conn, static void track_duration_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("value 0x%04x", value); + LOG_DBG("value 0x%04x", value); } static ssize_t read_track_position(struct bt_conn *conn, @@ -137,7 +135,7 @@ static ssize_t read_track_position(struct bt_conn *conn, { int32_t position = media_proxy_sctrl_get_track_position(); - BT_DBG("Track position read: %d (0x%08x)", position, position); + LOG_DBG("Track position read: %d (0x%08x)", position, position); return bt_gatt_attr_read(conn, attr, buf, len, offset, &position, sizeof(position)); @@ -161,7 +159,7 @@ static ssize_t write_track_position(struct bt_conn *conn, media_proxy_sctrl_set_track_position(position); - BT_DBG("Track position write: %d", position); + LOG_DBG("Track position write: %d", position); return len; } @@ -169,7 +167,7 @@ static ssize_t write_track_position(struct bt_conn *conn, static void track_position_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("value 0x%04x", value); + LOG_DBG("value 0x%04x", value); } static ssize_t read_playback_speed(struct bt_conn *conn, @@ -178,7 +176,7 @@ static ssize_t read_playback_speed(struct bt_conn *conn, { int8_t speed = media_proxy_sctrl_get_playback_speed(); - BT_DBG("Playback speed read: %d", speed); + LOG_DBG("Playback speed read: %d", speed); return bt_gatt_attr_read(conn, attr, buf, len, offset, &speed, sizeof(speed)); @@ -202,7 +200,7 @@ static ssize_t write_playback_speed(struct bt_conn *conn, media_proxy_sctrl_set_playback_speed(speed); - BT_DBG("Playback speed write: %d", speed); + LOG_DBG("Playback speed write: %d", speed); return len; } @@ -210,7 +208,7 @@ static ssize_t write_playback_speed(struct bt_conn *conn, static void playback_speed_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("value 0x%04x", value); + LOG_DBG("value 0x%04x", value); } static ssize_t read_seeking_speed(struct bt_conn *conn, @@ -219,7 +217,7 @@ static ssize_t read_seeking_speed(struct bt_conn *conn, { int8_t speed = media_proxy_sctrl_get_seeking_speed(); - BT_DBG("Seeking speed read: %d", speed); + LOG_DBG("Seeking speed read: %d", speed); return bt_gatt_attr_read(conn, attr, buf, len, offset, &speed, sizeof(speed)); @@ -228,7 +226,7 @@ static ssize_t read_seeking_speed(struct bt_conn *conn, static void seeking_speed_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("value 0x%04x", value); + LOG_DBG("value 0x%04x", value); } #ifdef CONFIG_BT_OTS @@ -238,7 +236,7 @@ static ssize_t read_track_segments_id(struct bt_conn *conn, { uint64_t track_segments_id = media_proxy_sctrl_get_track_segments_id(); - BT_DBG_OBJ_ID("Track segments ID read: ", track_segments_id); + LOG_DBG_OBJ_ID("Track segments ID read: ", track_segments_id); return bt_gatt_attr_read(conn, attr, buf, len, offset, &track_segments_id, BT_OTS_OBJ_ID_SIZE); } @@ -249,7 +247,7 @@ static ssize_t read_current_track_id(struct bt_conn *conn, { uint64_t track_id = media_proxy_sctrl_get_current_track_id(); - BT_DBG_OBJ_ID("Current track ID read: ", track_id); + LOG_DBG_OBJ_ID("Current track ID read: ", track_id); return bt_gatt_attr_read(conn, attr, buf, len, offset, &track_id, BT_OTS_OBJ_ID_SIZE); } @@ -262,22 +260,21 @@ static ssize_t write_current_track_id(struct bt_conn *conn, uint64_t id; if (offset != 0) { - BT_DBG("Invalid offset"); + LOG_DBG("Invalid offset"); return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); } if (len != BT_OTS_OBJ_ID_SIZE) { - BT_DBG("Invalid length"); + LOG_DBG("Invalid length"); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } id = sys_get_le48((uint8_t *)buf); - if (IS_ENABLED(CONFIG_BT_DEBUG_MCS)) { + if (IS_ENABLED(CONFIG_BT_MCS_LOG_LEVEL_DBG)) { char str[BT_OTS_OBJ_ID_STR_LEN]; (void)bt_ots_obj_id_to_str(id, str, sizeof(str)); - BT_DBG("Current track write: offset: %d, len: %d, track ID: %s", - offset, len, str); + LOG_DBG("Current track write: offset: %d, len: %d, track ID: %s", offset, len, str); } media_proxy_sctrl_set_current_track_id(id); @@ -288,7 +285,7 @@ static ssize_t write_current_track_id(struct bt_conn *conn, static void current_track_id_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("value 0x%04x", value); + LOG_DBG("value 0x%04x", value); } static ssize_t read_next_track_id(struct bt_conn *conn, @@ -298,13 +295,13 @@ static ssize_t read_next_track_id(struct bt_conn *conn, uint64_t track_id = media_proxy_sctrl_get_next_track_id(); if (track_id == MPL_NO_TRACK_ID) { - BT_DBG("Next track read, but it is empty"); + LOG_DBG("Next track read, but it is empty"); /* "If the media player has no next track, the length of the */ /* characteristic shall be zero." */ return bt_gatt_attr_read(conn, attr, buf, len, offset, NULL, 0); } - BT_DBG_OBJ_ID("Next track read: ", track_id); + LOG_DBG_OBJ_ID("Next track read: ", track_id); return bt_gatt_attr_read(conn, attr, buf, len, offset, &track_id, BT_OTS_OBJ_ID_SIZE); } @@ -317,22 +314,21 @@ static ssize_t write_next_track_id(struct bt_conn *conn, uint64_t id; if (offset != 0) { - BT_DBG("Invalid offset"); + LOG_DBG("Invalid offset"); return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); } if (len != BT_OTS_OBJ_ID_SIZE) { - BT_DBG("Invalid length"); + LOG_DBG("Invalid length"); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } id = sys_get_le48((uint8_t *)buf); - if (IS_ENABLED(CONFIG_BT_DEBUG_MCS)) { + if (IS_ENABLED(CONFIG_BT_MCS_LOG_LEVEL_DBG)) { char str[BT_OTS_OBJ_ID_STR_LEN]; (void)bt_ots_obj_id_to_str(id, str, sizeof(str)); - BT_DBG("Next track write: offset: %d, len: %d, track ID: %s", - offset, len, str); + LOG_DBG("Next track write: offset: %d, len: %d, track ID: %s", offset, len, str); } media_proxy_sctrl_set_next_track_id(id); @@ -343,7 +339,7 @@ static ssize_t write_next_track_id(struct bt_conn *conn, static void next_track_id_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("value 0x%04x", value); + LOG_DBG("value 0x%04x", value); } static ssize_t read_parent_group_id(struct bt_conn *conn, @@ -352,7 +348,7 @@ static ssize_t read_parent_group_id(struct bt_conn *conn, { uint64_t group_id = media_proxy_sctrl_get_parent_group_id(); - BT_DBG_OBJ_ID("Parent group read: ", group_id); + LOG_DBG_OBJ_ID("Parent group read: ", group_id); return bt_gatt_attr_read(conn, attr, buf, len, offset, &group_id, BT_OTS_OBJ_ID_SIZE); } @@ -360,7 +356,7 @@ static ssize_t read_parent_group_id(struct bt_conn *conn, static void parent_group_id_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("value 0x%04x", value); + LOG_DBG("value 0x%04x", value); } static ssize_t read_current_group_id(struct bt_conn *conn, @@ -369,7 +365,7 @@ static ssize_t read_current_group_id(struct bt_conn *conn, { uint64_t group_id = media_proxy_sctrl_get_current_group_id(); - BT_DBG_OBJ_ID("Current group read: ", group_id); + LOG_DBG_OBJ_ID("Current group read: ", group_id); return bt_gatt_attr_read(conn, attr, buf, len, offset, &group_id, BT_OTS_OBJ_ID_SIZE); } @@ -382,22 +378,22 @@ static ssize_t write_current_group_id(struct bt_conn *conn, uint64_t id; if (offset != 0) { - BT_DBG("Invalid offset"); + LOG_DBG("Invalid offset"); return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); } if (len != BT_OTS_OBJ_ID_SIZE) { - BT_DBG("Invalid length"); + LOG_DBG("Invalid length"); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } id = sys_get_le48((uint8_t *)buf); - if (IS_ENABLED(CONFIG_BT_DEBUG_MCS)) { + if (IS_ENABLED(CONFIG_BT_MCS_LOG_LEVEL_DBG)) { char str[BT_OTS_OBJ_ID_STR_LEN]; (void)bt_ots_obj_id_to_str(id, str, sizeof(str)); - BT_DBG("Current group ID write: offset: %d, len: %d, track ID: %s", - offset, len, str); + LOG_DBG("Current group ID write: offset: %d, len: %d, track ID: %s", offset, len, + str); } media_proxy_sctrl_set_current_group_id(id); @@ -407,7 +403,7 @@ static ssize_t write_current_group_id(struct bt_conn *conn, static void current_group_id_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("value 0x%04x", value); + LOG_DBG("value 0x%04x", value); } #endif /* CONFIG_BT_OTS */ @@ -417,7 +413,7 @@ static ssize_t read_playing_order(struct bt_conn *conn, { uint8_t order = media_proxy_sctrl_get_playing_order(); - BT_DBG("Playing order read: %d (0x%02x)", order, order); + LOG_DBG("Playing order read: %d (0x%02x)", order, order); return bt_gatt_attr_read(conn, attr, buf, len, offset, &order, sizeof(order)); @@ -428,7 +424,7 @@ static ssize_t write_playing_order(struct bt_conn *conn, const void *buf, uint16_t len, uint16_t offset, uint8_t flags) { - BT_DBG("Playing order write"); + LOG_DBG("Playing order write"); int8_t order; @@ -443,7 +439,7 @@ static ssize_t write_playing_order(struct bt_conn *conn, media_proxy_sctrl_set_playing_order(order); - BT_DBG("Playing order write: %d", order); + LOG_DBG("Playing order write: %d", order); return len; } @@ -451,7 +447,7 @@ static ssize_t write_playing_order(struct bt_conn *conn, static void playing_order_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("value 0x%04x", value); + LOG_DBG("value 0x%04x", value); } static ssize_t read_playing_orders_supported(struct bt_conn *conn, @@ -460,7 +456,7 @@ static ssize_t read_playing_orders_supported(struct bt_conn *conn, { uint16_t orders = media_proxy_sctrl_get_playing_orders_supported(); - BT_DBG("Playing orders read: %d (0x%04x)", orders, orders); + LOG_DBG("Playing orders read: %d (0x%04x)", orders, orders); return bt_gatt_attr_read(conn, attr, buf, len, offset, &orders, sizeof(orders)); @@ -472,7 +468,7 @@ static ssize_t read_media_state(struct bt_conn *conn, { uint8_t state = media_proxy_sctrl_get_media_state(); - BT_DBG("Media state read: %d", state); + LOG_DBG("Media state read: %d", state); return bt_gatt_attr_read(conn, attr, buf, len, offset, &state, sizeof(state)); @@ -481,7 +477,7 @@ static ssize_t read_media_state(struct bt_conn *conn, static void media_state_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("value 0x%04x", value); + LOG_DBG("value 0x%04x", value); } static ssize_t write_control_point(struct bt_conn *conn, @@ -501,7 +497,7 @@ static ssize_t write_control_point(struct bt_conn *conn, } memcpy(&command.opcode, buf, sizeof(command.opcode)); - BT_DBG("Opcode: %d", command.opcode); + LOG_DBG("Opcode: %d", command.opcode); command.use_param = false; if (len == sizeof(command.opcode) + sizeof(command.param)) { @@ -509,7 +505,7 @@ static ssize_t write_control_point(struct bt_conn *conn, (char *)buf + sizeof(command.opcode), sizeof(command.param)); command.use_param = true; - BT_DBG("Parameter: %d", command.param); + LOG_DBG("Parameter: %d", command.param); } media_proxy_sctrl_send_command(&command); @@ -520,7 +516,7 @@ static ssize_t write_control_point(struct bt_conn *conn, static void control_point_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("value 0x%04x", value); + LOG_DBG("value 0x%04x", value); } static ssize_t read_opcodes_supported(struct bt_conn *conn, @@ -529,7 +525,7 @@ static ssize_t read_opcodes_supported(struct bt_conn *conn, { uint32_t opcodes = media_proxy_sctrl_get_commands_supported(); - BT_DBG("Opcodes_supported read: %d (0x%08x)", opcodes, opcodes); + LOG_DBG("Opcodes_supported read: %d (0x%08x)", opcodes, opcodes); return bt_gatt_attr_read(conn, attr, buf, len, offset, &opcodes, BT_MCS_OPCODES_SUPPORTED_LEN); @@ -538,7 +534,7 @@ static ssize_t read_opcodes_supported(struct bt_conn *conn, static void opcodes_supported_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("value 0x%04x", value); + LOG_DBG("value 0x%04x", value); } #ifdef CONFIG_BT_OTS @@ -559,7 +555,7 @@ static ssize_t write_search_control_point(struct bt_conn *conn, memcpy(&search.search, (char *)buf, len); search.len = len; - BT_DBG("Search length: %d", len); + LOG_DBG("Search length: %d", len); LOG_HEXDUMP_DBG(&search.search, search.len, "Search content"); media_proxy_sctrl_send_search(&search); @@ -570,7 +566,7 @@ static ssize_t write_search_control_point(struct bt_conn *conn, static void search_control_point_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("value 0x%04x", value); + LOG_DBG("value 0x%04x", value); } static ssize_t read_search_results_id(struct bt_conn *conn, @@ -579,7 +575,7 @@ static ssize_t read_search_results_id(struct bt_conn *conn, { uint64_t search_id = media_proxy_sctrl_get_search_results_id(); - BT_DBG_OBJ_ID("Search results id read: ", search_id); + LOG_DBG_OBJ_ID("Search results id read: ", search_id); /* TODO: The permanent solution here should be that the call to */ /* mpl should fill the UUID in a pointed-to value, and return a */ @@ -602,7 +598,7 @@ static ssize_t read_search_results_id(struct bt_conn *conn, static void search_results_id_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("value 0x%04x", value); + LOG_DBG("value 0x%04x", value); } #endif /* CONFIG_BT_OTS */ @@ -612,7 +608,7 @@ static ssize_t read_content_ctrl_id(struct bt_conn *conn, { uint8_t id = media_proxy_sctrl_get_content_ctrl_id(); - BT_DBG("Content control ID read: %d", id); + LOG_DBG("Content control ID read: %d", id); return bt_gatt_attr_read(conn, attr, buf, len, offset, &id, sizeof(id)); @@ -772,9 +768,9 @@ static void notify(const struct bt_uuid *uuid, const void *data, uint16_t len) if (err) { if (err == -ENOTCONN) { - BT_DBG("Notification error: ENOTCONN (%d)", err); + LOG_DBG("Notification error: ENOTCONN (%d)", err); } else { - BT_ERR("Notification error: %d", err); + LOG_ERR("Notification error: %d", err); } } } @@ -812,43 +808,43 @@ static void notify_string(const struct bt_uuid *uuid, const char *str) void media_proxy_sctrl_track_changed_cb(void) { - BT_DBG("Notifying track change"); + LOG_DBG("Notifying track change"); notify(BT_UUID_MCS_TRACK_CHANGED, NULL, 0); } void media_proxy_sctrl_track_title_cb(const char *title) { - BT_DBG("Notifying track title: %s", title); + LOG_DBG("Notifying track title: %s", title); notify_string(BT_UUID_MCS_TRACK_TITLE, title); } void media_proxy_sctrl_track_position_cb(int32_t position) { - BT_DBG("Notifying track position: %d", position); + LOG_DBG("Notifying track position: %d", position); notify(BT_UUID_MCS_TRACK_POSITION, &position, sizeof(position)); } void media_proxy_sctrl_track_duration_cb(int32_t duration) { - BT_DBG("Notifying track duration: %d", duration); + LOG_DBG("Notifying track duration: %d", duration); notify(BT_UUID_MCS_TRACK_DURATION, &duration, sizeof(duration)); } void media_proxy_sctrl_playback_speed_cb(int8_t speed) { - BT_DBG("Notifying playback speed: %d", speed); + LOG_DBG("Notifying playback speed: %d", speed); notify(BT_UUID_MCS_PLAYBACK_SPEED, &speed, sizeof(speed)); } void media_proxy_sctrl_seeking_speed_cb(int8_t speed) { - BT_DBG("Notifying seeking speed: %d", speed); + LOG_DBG("Notifying seeking speed: %d", speed); notify(BT_UUID_MCS_SEEKING_SPEED, &speed, sizeof(speed)); } void media_proxy_sctrl_current_track_id_cb(uint64_t id) { - BT_DBG_OBJ_ID("Notifying current track ID: ", id); + LOG_DBG_OBJ_ID("Notifying current track ID: ", id); notify(BT_UUID_MCS_CURRENT_TRACK_OBJ_ID, &id, BT_OTS_OBJ_ID_SIZE); } @@ -857,63 +853,62 @@ void media_proxy_sctrl_next_track_id_cb(uint64_t id) if (id == MPL_NO_TRACK_ID) { /* "If the media player has no next track, the length of the */ /* characteristic shall be zero." */ - BT_DBG_OBJ_ID("Notifying EMPTY next track ID: ", id); + LOG_DBG_OBJ_ID("Notifying EMPTY next track ID: ", id); notify(BT_UUID_MCS_NEXT_TRACK_OBJ_ID, NULL, 0); } else { - BT_DBG_OBJ_ID("Notifying next track ID: ", id); + LOG_DBG_OBJ_ID("Notifying next track ID: ", id); notify(BT_UUID_MCS_NEXT_TRACK_OBJ_ID, &id, BT_OTS_OBJ_ID_SIZE); } } void media_proxy_sctrl_parent_group_id_cb(uint64_t id) { - BT_DBG_OBJ_ID("Notifying parent group ID: ", id); + LOG_DBG_OBJ_ID("Notifying parent group ID: ", id); notify(BT_UUID_MCS_PARENT_GROUP_OBJ_ID, &id, BT_OTS_OBJ_ID_SIZE); } void media_proxy_sctrl_current_group_id_cb(uint64_t id) { - BT_DBG_OBJ_ID("Notifying current group ID: ", id); + LOG_DBG_OBJ_ID("Notifying current group ID: ", id); notify(BT_UUID_MCS_CURRENT_GROUP_OBJ_ID, &id, BT_OTS_OBJ_ID_SIZE); } void media_proxy_sctrl_playing_order_cb(uint8_t order) { - BT_DBG("Notifying playing order: %d", order); + LOG_DBG("Notifying playing order: %d", order); notify(BT_UUID_MCS_PLAYING_ORDER, &order, sizeof(order)); } void media_proxy_sctrl_media_state_cb(uint8_t state) { - BT_DBG("Notifying media state: %d", state); + LOG_DBG("Notifying media state: %d", state); notify(BT_UUID_MCS_MEDIA_STATE, &state, sizeof(state)); } void media_proxy_sctrl_command_cb(const struct mpl_cmd_ntf *cmd_ntf) { - BT_DBG("Notifying control point command - opcode: %d, result: %d", - cmd_ntf->requested_opcode, cmd_ntf->result_code); + LOG_DBG("Notifying control point command - opcode: %d, result: %d", + cmd_ntf->requested_opcode, cmd_ntf->result_code); notify(BT_UUID_MCS_MEDIA_CONTROL_POINT, cmd_ntf, sizeof(*cmd_ntf)); } void media_proxy_sctrl_commands_supported_cb(uint32_t opcodes) { - BT_DBG("Notifying command opcodes supported: %d (0x%08x)", opcodes, - opcodes); + LOG_DBG("Notifying command opcodes supported: %d (0x%08x)", opcodes, opcodes); notify(BT_UUID_MCS_MEDIA_CONTROL_OPCODES, &opcodes, BT_MCS_OPCODES_SUPPORTED_LEN); } void media_proxy_sctrl_search_cb(uint8_t result_code) { - BT_DBG("Notifying search control point - result: %d", result_code); + LOG_DBG("Notifying search control point - result: %d", result_code); notify(BT_UUID_MCS_SEARCH_CONTROL_POINT, &result_code, sizeof(result_code)); } void media_proxy_sctrl_search_results_id_cb(uint64_t id) { - BT_DBG_OBJ_ID("Notifying search results ID: ", id); + LOG_DBG_OBJ_ID("Notifying search results ID: ", id); notify(BT_UUID_MCS_SEARCH_RESULTS_OBJ_ID, &id, BT_OTS_OBJ_ID_SIZE); } @@ -924,7 +919,7 @@ int bt_mcs_init(struct bt_ots_cb *ots_cbs) int err; if (initialized) { - BT_DBG("Already initialized"); + LOG_DBG("Already initialized"); return -EALREADY; } @@ -936,7 +931,7 @@ int bt_mcs_init(struct bt_ots_cb *ots_cbs) ots = bt_ots_free_instance_get(); if (!ots) { - BT_ERR("Failed to retrieve OTS instance\n"); + LOG_ERR("Failed to retrieve OTS instance\n"); return -ENOMEM; } @@ -949,7 +944,7 @@ int bt_mcs_init(struct bt_ots_cb *ots_cbs) /* Initialize OTS instance. */ err = bt_ots_init(ots, &ots_init); if (err) { - BT_ERR("Failed to init OTS (err:%d)\n", err); + LOG_ERR("Failed to init OTS (err:%d)\n", err); return err; } @@ -964,7 +959,7 @@ int bt_mcs_init(struct bt_ots_cb *ots_cbs) err = bt_gatt_service_register(&mcs); if (err) { - BT_ERR("Could not register the MCS service"); + LOG_ERR("Could not register the MCS service"); #ifdef CONFIG_BT_OTS /* TODO: How does one un-register the OTS? */ #endif /* CONFIG_BT_OTS */ diff --git a/subsys/bluetooth/audio/media_proxy.c b/subsys/bluetooth/audio/media_proxy.c index 865cdf8a260..2e6267b2bbc 100644 --- a/subsys/bluetooth/audio/media_proxy.c +++ b/subsys/bluetooth/audio/media_proxy.c @@ -14,10 +14,9 @@ #include "media_proxy_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_MCTL_DEBUG) -#define LOG_MODULE_NAME media_proxy -#include "common/log.h" +#include +LOG_MODULE_REGISTER(media_proxy, CONFIG_MCTL_LOG_LEVEL); /* Media player */ struct media_player { @@ -233,47 +232,47 @@ uint8_t media_proxy_sctrl_get_content_ctrl_id(void) static void mcc_discover_mcs_cb(struct bt_conn *conn, int err) { if (err) { - BT_ERR("Discovery failed (%d)", err); + LOG_ERR("Discovery failed (%d)", err); } - BT_DBG("Disovered player"); + LOG_DBG("Disovered player"); if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->discover_player) { mprx.ctrlr.cbs->discover_player(&mprx.remote_player, err); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } } static void mcc_read_player_name_cb(struct bt_conn *conn, int err, const char *name) { /* Debug statements for at least a couple of the callbacks, to show flow */ - BT_DBG("MCC player name callback"); + LOG_DBG("MCC player name callback"); if (err) { - BT_ERR("Player name failed"); + LOG_ERR("Player name failed"); } if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->player_name_recv) { mprx.ctrlr.cbs->player_name_recv(&mprx.remote_player, err, name); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } } #ifdef CONFIG_MCTL_REMOTE_PLAYER_CONTROL_OBJECTS static void mcc_read_icon_obj_id_cb(struct bt_conn *conn, int err, uint64_t id) { - BT_DBG("Icon Object ID callback"); + LOG_DBG("Icon Object ID callback"); if (err) { - BT_ERR("Icon Object ID read failed (%d)", err); + LOG_ERR("Icon Object ID read failed (%d)", err); } if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->icon_id_recv) { mprx.ctrlr.cbs->icon_id_recv(&mprx.remote_player, err, id); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } } #endif /* CONFIG_MCTL_REMOTE_PLAYER_CONTROL_OBJECTS */ @@ -281,118 +280,118 @@ static void mcc_read_icon_obj_id_cb(struct bt_conn *conn, int err, uint64_t id) static void mcc_read_icon_url_cb(struct bt_conn *conn, int err, const char *url) { if (err) { - BT_ERR("Icon URL read failed (%d)", err); + LOG_ERR("Icon URL read failed (%d)", err); } if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->icon_url_recv) { mprx.ctrlr.cbs->icon_url_recv(&mprx.remote_player, err, url); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } } static void mcc_track_changed_ntf_cb(struct bt_conn *conn, int err) { if (err) { - BT_ERR("Track change notification failed (%d)", err); + LOG_ERR("Track change notification failed (%d)", err); return; } if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->track_changed_recv) { mprx.ctrlr.cbs->track_changed_recv(&mprx.remote_player, err); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } } static void mcc_read_track_title_cb(struct bt_conn *conn, int err, const char *title) { if (err) { - BT_ERR("Track title read failed (%d)", err); + LOG_ERR("Track title read failed (%d)", err); } if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->track_title_recv) { mprx.ctrlr.cbs->track_title_recv(&mprx.remote_player, err, title); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } } static void mcc_read_track_duration_cb(struct bt_conn *conn, int err, int32_t dur) { if (err) { - BT_ERR("Track duration read failed (%d)", err); + LOG_ERR("Track duration read failed (%d)", err); } if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->track_duration_recv) { mprx.ctrlr.cbs->track_duration_recv(&mprx.remote_player, err, dur); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } } static void mcc_read_track_position_cb(struct bt_conn *conn, int err, int32_t pos) { if (err) { - BT_ERR("Track position read failed (%d)", err); + LOG_ERR("Track position read failed (%d)", err); } if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->track_position_recv) { mprx.ctrlr.cbs->track_position_recv(&mprx.remote_player, err, pos); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } } static void mcc_set_track_position_cb(struct bt_conn *conn, int err, int32_t pos) { if (err) { - BT_ERR("Track Position set failed (%d)", err); + LOG_ERR("Track Position set failed (%d)", err); } if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->track_position_write) { mprx.ctrlr.cbs->track_position_write(&mprx.remote_player, err, pos); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } } static void mcc_read_playback_speed_cb(struct bt_conn *conn, int err, int8_t speed) { if (err) { - BT_ERR("Playback speed read failed (%d)", err); + LOG_ERR("Playback speed read failed (%d)", err); } if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->playback_speed_recv) { mprx.ctrlr.cbs->playback_speed_recv(&mprx.remote_player, err, speed); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } } static void mcc_set_playback_speed_cb(struct bt_conn *conn, int err, int8_t speed) { if (err) { - BT_ERR("Playback speed set failed (%d)", err); + LOG_ERR("Playback speed set failed (%d)", err); } if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->playback_speed_write) { mprx.ctrlr.cbs->playback_speed_write(&mprx.remote_player, err, speed); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } } static void mcc_read_seeking_speed_cb(struct bt_conn *conn, int err, int8_t speed) { if (err) { - BT_ERR("Seeking speed read failed (%d)", err); + LOG_ERR("Seeking speed read failed (%d)", err); } if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->seeking_speed_recv) { mprx.ctrlr.cbs->seeking_speed_recv(&mprx.remote_player, err, speed); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } } @@ -400,26 +399,26 @@ static void mcc_read_seeking_speed_cb(struct bt_conn *conn, int err, int8_t spee static void mcc_read_segments_obj_id_cb(struct bt_conn *conn, int err, uint64_t id) { if (err) { - BT_ERR("Track Segments Object ID read failed (%d)", err); + LOG_ERR("Track Segments Object ID read failed (%d)", err); } if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->track_segments_id_recv) { mprx.ctrlr.cbs->track_segments_id_recv(&mprx.remote_player, err, id); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } } static void mcc_read_current_track_obj_id_cb(struct bt_conn *conn, int err, uint64_t id) { if (err) { - BT_ERR("Current Track Object ID read failed (%d)", err); + LOG_ERR("Current Track Object ID read failed (%d)", err); } if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->current_track_id_recv) { mprx.ctrlr.cbs->current_track_id_recv(&mprx.remote_player, err, id); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } } @@ -428,13 +427,13 @@ static void mcc_read_current_track_obj_id_cb(struct bt_conn *conn, int err, uint static void mcc_read_next_track_obj_id_cb(struct bt_conn *conn, int err, uint64_t id) { if (err) { - BT_ERR("Next Track Object ID read failed (%d)", err); + LOG_ERR("Next Track Object ID read failed (%d)", err); } if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->next_track_id_recv) { mprx.ctrlr.cbs->next_track_id_recv(&mprx.remote_player, err, id); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } } @@ -443,26 +442,26 @@ static void mcc_read_next_track_obj_id_cb(struct bt_conn *conn, int err, uint64_ static void mcc_read_parent_group_obj_id_cb(struct bt_conn *conn, int err, uint64_t id) { if (err) { - BT_ERR("Parent Group Object ID read failed (%d)", err); + LOG_ERR("Parent Group Object ID read failed (%d)", err); } if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->parent_group_id_recv) { mprx.ctrlr.cbs->parent_group_id_recv(&mprx.remote_player, err, id); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } } static void mcc_read_current_group_obj_id_cb(struct bt_conn *conn, int err, uint64_t id) { if (err) { - BT_ERR("Current Group Object ID read failed (%d)", err); + LOG_ERR("Current Group Object ID read failed (%d)", err); } if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->current_group_id_recv) { mprx.ctrlr.cbs->current_group_id_recv(&mprx.remote_player, err, id); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } } @@ -473,66 +472,66 @@ static void mcc_read_current_group_obj_id_cb(struct bt_conn *conn, int err, uint static void mcc_read_playing_order_cb(struct bt_conn *conn, int err, uint8_t order) { if (err) { - BT_ERR("Playing order read failed (%d)", err); + LOG_ERR("Playing order read failed (%d)", err); } if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->playing_order_recv) { mprx.ctrlr.cbs->playing_order_recv(&mprx.remote_player, err, order); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } } static void mcc_set_playing_order_cb(struct bt_conn *conn, int err, uint8_t order) { if (err) { - BT_ERR("Playing order set failed (%d)", err); + LOG_ERR("Playing order set failed (%d)", err); } if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->playing_order_write) { mprx.ctrlr.cbs->playing_order_write(&mprx.remote_player, err, order); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } } static void mcc_read_playing_orders_supported_cb(struct bt_conn *conn, int err, uint16_t orders) { if (err) { - BT_ERR("Playing orders supported read failed (%d)", err); + LOG_ERR("Playing orders supported read failed (%d)", err); } if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->playing_orders_supported_recv) { mprx.ctrlr.cbs->playing_orders_supported_recv(&mprx.remote_player, err, orders); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } } static void mcc_read_media_state_cb(struct bt_conn *conn, int err, uint8_t state) { if (err) { - BT_ERR("Media State read failed (%d)", err); + LOG_ERR("Media State read failed (%d)", err); } if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->media_state_recv) { mprx.ctrlr.cbs->media_state_recv(&mprx.remote_player, err, state); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } } static void mcc_send_cmd_cb(struct bt_conn *conn, int err, const struct mpl_cmd *cmd) { if (err) { - BT_ERR("Command send failed (%d) - opcode: %d, param: %d", - err, cmd->opcode, cmd->param); + LOG_ERR("Command send failed (%d) - opcode: %d, param: %d", err, cmd->opcode, + cmd->param); } if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->command_send) { mprx.ctrlr.cbs->command_send(&mprx.remote_player, err, cmd); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } } @@ -540,27 +539,27 @@ static void mcc_cmd_ntf_cb(struct bt_conn *conn, int err, const struct mpl_cmd_ntf *ntf) { if (err) { - BT_ERR("Command notification error (%d) - command opcode: %d, result: %d", - err, ntf->requested_opcode, ntf->result_code); + LOG_ERR("Command notification error (%d) - command opcode: %d, result: %d", err, + ntf->requested_opcode, ntf->result_code); } if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->command_recv) { mprx.ctrlr.cbs->command_recv(&mprx.remote_player, err, ntf); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } } static void mcc_read_opcodes_supported_cb(struct bt_conn *conn, int err, uint32_t opcodes) { if (err) { - BT_ERR("Opcodes supported read failed (%d)", err); + LOG_ERR("Opcodes supported read failed (%d)", err); } if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->commands_supported_recv) { mprx.ctrlr.cbs->commands_supported_recv(&mprx.remote_player, err, opcodes); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } } @@ -568,40 +567,39 @@ static void mcc_read_opcodes_supported_cb(struct bt_conn *conn, int err, uint32_ static void mcc_send_search_cb(struct bt_conn *conn, int err, const struct mpl_search *search) { if (err) { - BT_ERR("Search send failed (%d)", err); + LOG_ERR("Search send failed (%d)", err); } if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->search_send) { mprx.ctrlr.cbs->search_send(&mprx.remote_player, err, search); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } } static void mcc_search_ntf_cb(struct bt_conn *conn, int err, uint8_t result_code) { if (err) { - BT_ERR("Search notification error (%d), result code: %d", - err, result_code); + LOG_ERR("Search notification error (%d), result code: %d", err, result_code); } if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->search_recv) { mprx.ctrlr.cbs->search_recv(&mprx.remote_player, err, result_code); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } } static void mcc_read_search_results_obj_id_cb(struct bt_conn *conn, int err, uint64_t id) { if (err) { - BT_ERR("Search Results Object ID read failed (%d)", err); + LOG_ERR("Search Results Object ID read failed (%d)", err); } if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->search_results_id_recv) { mprx.ctrlr.cbs->search_results_id_recv(&mprx.remote_player, err, id); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } } #endif /* CONFIG_MCTL_REMOTE_PLAYER_CONTROL_OBJECTS */ @@ -609,13 +607,13 @@ static void mcc_read_search_results_obj_id_cb(struct bt_conn *conn, int err, uin static void mcc_read_content_control_id_cb(struct bt_conn *conn, int err, uint8_t ccid) { if (err) { - BT_ERR("Content Control ID read failed (%d)", err); + LOG_ERR("Content Control ID read failed (%d)", err); } if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->content_ctrl_id_recv) { mprx.ctrlr.cbs->content_ctrl_id_recv(&mprx.remote_player, err, ccid); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } } @@ -628,7 +626,7 @@ static void mcc_read_content_control_id_cb(struct bt_conn *conn, int err, uint8_ int media_proxy_ctrl_register(struct media_proxy_ctrl_cbs *ctrl_cbs) { CHECKIF(ctrl_cbs == NULL) { - BT_DBG("NULL callback pointer"); + LOG_DBG("NULL callback pointer"); return -EINVAL; } @@ -663,7 +661,7 @@ int media_proxy_ctrl_discover_player(struct bt_conn *conn) int err; CHECKIF(!conn) { - BT_DBG("NUll conn pointer"); + LOG_DBG("NUll conn pointer"); return -EINVAL; } @@ -705,14 +703,14 @@ int media_proxy_ctrl_discover_player(struct bt_conn *conn) err = bt_mcc_init(&mprx.mcc_cbs); if (err) { - BT_ERR("Failed to initialize MCC"); + LOG_ERR("Failed to initialize MCC"); return err; } /* Start discovery of remote MCS, subscribe to notifications */ err = bt_mcc_discover_mcs(conn, 1); if (err) { - BT_ERR("Discovery failed"); + LOG_ERR("Discovery failed"); return err; } @@ -731,33 +729,33 @@ int media_proxy_ctrl_discover_player(struct bt_conn *conn) int media_proxy_ctrl_get_player_name(struct media_player *player) { CHECKIF(player == NULL) { - BT_DBG("player is NULL"); + LOG_DBG("player is NULL"); return -EINVAL; } #if defined(CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL) if (mprx.local_player.registered && player == &mprx.local_player) { - BT_DBG("Local player"); + LOG_DBG("Local player"); if (mprx.local_player.calls->get_player_name) { if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->player_name_recv) { const char *name = mprx.local_player.calls->get_player_name(); mprx.ctrlr.cbs->player_name_recv(&mprx.local_player, 0, name); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } return 0; } - BT_DBG("No call"); + LOG_DBG("No call"); return -EOPNOTSUPP; } #endif /* CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL */ #if defined(CONFIG_MCTL_REMOTE_PLAYER_CONTROL) if (mprx.remote_player.registered && player == &mprx.remote_player) { - BT_DBG("Remote player"); + LOG_DBG("Remote player"); return bt_mcc_read_player_name(mprx.remote_player.conn); } #endif /* CONFIG_MCTL_REMOTE_PLAYER_CONTROL */ @@ -768,7 +766,7 @@ int media_proxy_ctrl_get_player_name(struct media_player *player) int media_proxy_ctrl_get_icon_id(struct media_player *player) { CHECKIF(player == NULL) { - BT_DBG("player is NULL"); + LOG_DBG("player is NULL"); return -EINVAL; } @@ -780,13 +778,13 @@ int media_proxy_ctrl_get_icon_id(struct media_player *player) mprx.ctrlr.cbs->icon_id_recv(&mprx.local_player, 0, id); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } return 0; } - BT_DBG("No call"); + LOG_DBG("No call"); return -EOPNOTSUPP; } #endif /* CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL */ @@ -803,7 +801,7 @@ int media_proxy_ctrl_get_icon_id(struct media_player *player) int media_proxy_ctrl_get_icon_url(struct media_player *player) { CHECKIF(player == NULL) { - BT_DBG("player is NULL"); + LOG_DBG("player is NULL"); return -EINVAL; } @@ -815,13 +813,13 @@ int media_proxy_ctrl_get_icon_url(struct media_player *player) mprx.ctrlr.cbs->icon_url_recv(player, 0, url); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } return 0; } - BT_DBG("No call"); + LOG_DBG("No call"); return -EOPNOTSUPP; } #endif /* CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL */ @@ -838,7 +836,7 @@ int media_proxy_ctrl_get_icon_url(struct media_player *player) int media_proxy_ctrl_get_track_title(struct media_player *player) { CHECKIF(player == NULL) { - BT_DBG("player is NULL"); + LOG_DBG("player is NULL"); return -EINVAL; } @@ -850,13 +848,13 @@ int media_proxy_ctrl_get_track_title(struct media_player *player) const char *title = mprx.local_player.calls->get_track_title(); mprx.ctrlr.cbs->track_title_recv(player, 0, title); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } return 0; } - BT_DBG("No call"); + LOG_DBG("No call"); return -EOPNOTSUPP; } #endif /* CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL */ @@ -873,7 +871,7 @@ int media_proxy_ctrl_get_track_title(struct media_player *player) int media_proxy_ctrl_get_track_duration(struct media_player *player) { CHECKIF(player == NULL) { - BT_DBG("player is NULL"); + LOG_DBG("player is NULL"); return -EINVAL; } @@ -886,13 +884,13 @@ int media_proxy_ctrl_get_track_duration(struct media_player *player) mprx.ctrlr.cbs->track_duration_recv(player, 0, duration); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } return 0; } - BT_DBG("No call"); + LOG_DBG("No call"); return -EOPNOTSUPP; } #endif /* CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL */ @@ -909,7 +907,7 @@ int media_proxy_ctrl_get_track_duration(struct media_player *player) int media_proxy_ctrl_get_track_position(struct media_player *player) { CHECKIF(player == NULL) { - BT_DBG("player is NULL"); + LOG_DBG("player is NULL"); return -EINVAL; } @@ -922,13 +920,13 @@ int media_proxy_ctrl_get_track_position(struct media_player *player) mprx.ctrlr.cbs->track_position_recv(player, 0, position); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } return 0; } - BT_DBG("No call"); + LOG_DBG("No call"); return -EOPNOTSUPP; } #endif /* CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL */ @@ -945,7 +943,7 @@ int media_proxy_ctrl_get_track_position(struct media_player *player) int media_proxy_ctrl_set_track_position(struct media_player *player, int32_t position) { CHECKIF(player == NULL) { - BT_DBG("player is NULL"); + LOG_DBG("player is NULL"); return -EINVAL; } @@ -957,13 +955,13 @@ int media_proxy_ctrl_set_track_position(struct media_player *player, int32_t pos if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->track_position_write) { mprx.ctrlr.cbs->track_position_write(player, 0, position); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } return 0; } - BT_DBG("No call"); + LOG_DBG("No call"); return -EOPNOTSUPP; } #endif /* CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL */ @@ -980,7 +978,7 @@ int media_proxy_ctrl_set_track_position(struct media_player *player, int32_t pos int media_proxy_ctrl_get_playback_speed(struct media_player *player) { CHECKIF(player == NULL) { - BT_DBG("player is NULL"); + LOG_DBG("player is NULL"); return -EINVAL; } @@ -992,13 +990,13 @@ int media_proxy_ctrl_get_playback_speed(struct media_player *player) mprx.ctrlr.cbs->playback_speed_recv(player, 0, speed); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } return 0; } - BT_DBG("No call"); + LOG_DBG("No call"); return -EOPNOTSUPP; } #endif /* CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL */ @@ -1015,7 +1013,7 @@ int media_proxy_ctrl_get_playback_speed(struct media_player *player) int media_proxy_ctrl_set_playback_speed(struct media_player *player, int8_t speed) { CHECKIF(player == NULL) { - BT_DBG("player is NULL"); + LOG_DBG("player is NULL"); return -EINVAL; } @@ -1027,13 +1025,13 @@ int media_proxy_ctrl_set_playback_speed(struct media_player *player, int8_t spee if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->playback_speed_write) { mprx.ctrlr.cbs->playback_speed_write(player, 0, speed); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } return 0; } - BT_DBG("No call"); + LOG_DBG("No call"); return -EOPNOTSUPP; } #endif /* CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL */ @@ -1050,7 +1048,7 @@ int media_proxy_ctrl_set_playback_speed(struct media_player *player, int8_t spee int media_proxy_ctrl_get_seeking_speed(struct media_player *player) { CHECKIF(player == NULL) { - BT_DBG("player is NULL"); + LOG_DBG("player is NULL"); return -EINVAL; } @@ -1062,13 +1060,13 @@ int media_proxy_ctrl_get_seeking_speed(struct media_player *player) mprx.ctrlr.cbs->seeking_speed_recv(player, 0, speed); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } return 0; } - BT_DBG("No call"); + LOG_DBG("No call"); return -EOPNOTSUPP; } #endif /* CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL */ @@ -1085,7 +1083,7 @@ int media_proxy_ctrl_get_seeking_speed(struct media_player *player) int media_proxy_ctrl_get_track_segments_id(struct media_player *player) { CHECKIF(player == NULL) { - BT_DBG("player is NULL"); + LOG_DBG("player is NULL"); return -EINVAL; } @@ -1098,13 +1096,13 @@ int media_proxy_ctrl_get_track_segments_id(struct media_player *player) mprx.ctrlr.cbs->track_segments_id_recv(player, 0, id); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } return 0; } - BT_DBG("No call"); + LOG_DBG("No call"); return -EOPNOTSUPP; } #endif /* CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL */ @@ -1121,7 +1119,7 @@ int media_proxy_ctrl_get_track_segments_id(struct media_player *player) int media_proxy_ctrl_get_current_track_id(struct media_player *player) { CHECKIF(player == NULL) { - BT_DBG("player is NULL"); + LOG_DBG("player is NULL"); return -EINVAL; } @@ -1133,13 +1131,13 @@ int media_proxy_ctrl_get_current_track_id(struct media_player *player) mprx.ctrlr.cbs->current_track_id_recv(player, 0, id); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } return 0; } - BT_DBG("No call"); + LOG_DBG("No call"); return -EOPNOTSUPP; } #endif /* CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL */ @@ -1156,13 +1154,13 @@ int media_proxy_ctrl_get_current_track_id(struct media_player *player) int media_proxy_ctrl_set_current_track_id(struct media_player *player, uint64_t id) { CHECKIF(player == NULL) { - BT_DBG("player is NULL"); + LOG_DBG("player is NULL"); return -EINVAL; } #if defined(CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL) CHECKIF(id < BT_OTS_OBJ_ID_MIN || id > BT_OTS_OBJ_ID_MAX) { - BT_DBG("Object ID invalid"); + LOG_DBG("Object ID invalid"); return -EINVAL; } @@ -1173,13 +1171,13 @@ int media_proxy_ctrl_set_current_track_id(struct media_player *player, uint64_t if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->current_track_id_write) { mprx.ctrlr.cbs->current_track_id_write(player, 0, id); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } return 0; } - BT_DBG("No call"); + LOG_DBG("No call"); return -EOPNOTSUPP; } #endif /* CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL */ @@ -1197,7 +1195,7 @@ int media_proxy_ctrl_set_current_track_id(struct media_player *player, uint64_t int media_proxy_ctrl_get_next_track_id(struct media_player *player) { CHECKIF(player == NULL) { - BT_DBG("player is NULL"); + LOG_DBG("player is NULL"); return -EINVAL; } @@ -1209,13 +1207,13 @@ int media_proxy_ctrl_get_next_track_id(struct media_player *player) mprx.ctrlr.cbs->next_track_id_recv(player, 0, id); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } return 0; } - BT_DBG("No call"); + LOG_DBG("No call"); return -EOPNOTSUPP; } #endif /* CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL */ @@ -1232,13 +1230,13 @@ int media_proxy_ctrl_get_next_track_id(struct media_player *player) int media_proxy_ctrl_set_next_track_id(struct media_player *player, uint64_t id) { CHECKIF(player == NULL) { - BT_DBG("player is NULL"); + LOG_DBG("player is NULL"); return -EINVAL; } #if defined(CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL) CHECKIF(id < BT_OTS_OBJ_ID_MIN || id > BT_OTS_OBJ_ID_MAX) { - BT_DBG("Object ID invalid"); + LOG_DBG("Object ID invalid"); return -EINVAL; } @@ -1249,13 +1247,13 @@ int media_proxy_ctrl_set_next_track_id(struct media_player *player, uint64_t id) if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->next_track_id_write) { mprx.ctrlr.cbs->next_track_id_write(player, 0, id); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } return 0; } - BT_DBG("No call"); + LOG_DBG("No call"); return -EOPNOTSUPP; } #endif /* CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL */ @@ -1273,7 +1271,7 @@ int media_proxy_ctrl_set_next_track_id(struct media_player *player, uint64_t id) int media_proxy_ctrl_get_parent_group_id(struct media_player *player) { CHECKIF(player == NULL) { - BT_DBG("player is NULL"); + LOG_DBG("player is NULL"); return -EINVAL; } @@ -1285,13 +1283,13 @@ int media_proxy_ctrl_get_parent_group_id(struct media_player *player) mprx.ctrlr.cbs->parent_group_id_recv(player, 0, id); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } return 0; } - BT_DBG("No call"); + LOG_DBG("No call"); return -EOPNOTSUPP; } #endif /* CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL */ @@ -1308,7 +1306,7 @@ int media_proxy_ctrl_get_parent_group_id(struct media_player *player) int media_proxy_ctrl_get_current_group_id(struct media_player *player) { CHECKIF(player == NULL) { - BT_DBG("player is NULL"); + LOG_DBG("player is NULL"); return -EINVAL; } @@ -1320,13 +1318,13 @@ int media_proxy_ctrl_get_current_group_id(struct media_player *player) mprx.ctrlr.cbs->current_group_id_recv(player, 0, id); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } return 0; } - BT_DBG("No call"); + LOG_DBG("No call"); return -EOPNOTSUPP; } #endif /* CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL */ @@ -1343,13 +1341,13 @@ int media_proxy_ctrl_get_current_group_id(struct media_player *player) int media_proxy_ctrl_set_current_group_id(struct media_player *player, uint64_t id) { CHECKIF(player == NULL) { - BT_DBG("player is NULL"); + LOG_DBG("player is NULL"); return -EINVAL; } #if defined(CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL) CHECKIF(id < BT_OTS_OBJ_ID_MIN || id > BT_OTS_OBJ_ID_MAX) { - BT_DBG("Object ID invalid"); + LOG_DBG("Object ID invalid"); return -EINVAL; } @@ -1360,13 +1358,13 @@ int media_proxy_ctrl_set_current_group_id(struct media_player *player, uint64_t if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->current_group_id_write) { mprx.ctrlr.cbs->current_group_id_write(player, 0, id); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } return 0; } - BT_DBG("No call"); + LOG_DBG("No call"); return -EOPNOTSUPP; } #endif /* CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL */ @@ -1384,7 +1382,7 @@ int media_proxy_ctrl_set_current_group_id(struct media_player *player, uint64_t int media_proxy_ctrl_get_playing_order(struct media_player *player) { CHECKIF(player == NULL) { - BT_DBG("player is NULL"); + LOG_DBG("player is NULL"); return -EINVAL; } @@ -1396,20 +1394,20 @@ int media_proxy_ctrl_get_playing_order(struct media_player *player) mprx.ctrlr.cbs->playing_order_recv(player, 0, order); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } return 0; } - BT_DBG("No call"); + LOG_DBG("No call"); return -EOPNOTSUPP; } #endif /* CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL */ #if defined(CONFIG_MCTL_REMOTE_PLAYER_CONTROL) if (mprx.remote_player.registered && player == &mprx.remote_player) { - BT_DBG("Remote player"); + LOG_DBG("Remote player"); return bt_mcc_read_playing_order(mprx.remote_player.conn); } #endif /* CONFIG_MCTL_REMOTE_PLAYER_CONTROL */ @@ -1420,7 +1418,7 @@ int media_proxy_ctrl_get_playing_order(struct media_player *player) int media_proxy_ctrl_set_playing_order(struct media_player *player, uint8_t order) { CHECKIF(player == NULL) { - BT_DBG("player is NULL"); + LOG_DBG("player is NULL"); return -EINVAL; } @@ -1432,13 +1430,13 @@ int media_proxy_ctrl_set_playing_order(struct media_player *player, uint8_t orde if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->playing_order_write) { mprx.ctrlr.cbs->playing_order_write(player, 0, order); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } return 0; } - BT_DBG("No call"); + LOG_DBG("No call"); return -EOPNOTSUPP; } #endif /* CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL */ @@ -1455,7 +1453,7 @@ int media_proxy_ctrl_set_playing_order(struct media_player *player, uint8_t orde int media_proxy_ctrl_get_playing_orders_supported(struct media_player *player) { CHECKIF(player == NULL) { - BT_DBG("player is NULL"); + LOG_DBG("player is NULL"); return -EINVAL; } @@ -1468,13 +1466,13 @@ int media_proxy_ctrl_get_playing_orders_supported(struct media_player *player) mprx.ctrlr.cbs->playing_orders_supported_recv(player, 0, orders); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } return 0; } - BT_DBG("No call"); + LOG_DBG("No call"); return -EOPNOTSUPP; } #endif /* CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL */ @@ -1491,7 +1489,7 @@ int media_proxy_ctrl_get_playing_orders_supported(struct media_player *player) int media_proxy_ctrl_get_media_state(struct media_player *player) { CHECKIF(player == NULL) { - BT_DBG("player is NULL"); + LOG_DBG("player is NULL"); return -EINVAL; } @@ -1503,13 +1501,13 @@ int media_proxy_ctrl_get_media_state(struct media_player *player) mprx.ctrlr.cbs->media_state_recv(player, 0, state); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } return 0; } - BT_DBG("No call"); + LOG_DBG("No call"); return -EOPNOTSUPP; } #endif /* CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL */ @@ -1526,7 +1524,7 @@ int media_proxy_ctrl_get_media_state(struct media_player *player) int media_proxy_ctrl_send_command(struct media_player *player, const struct mpl_cmd *cmd) { CHECKIF(player == NULL || cmd == NULL) { - BT_DBG("NULL pointer"); + LOG_DBG("NULL pointer"); return -EINVAL; } @@ -1538,13 +1536,13 @@ int media_proxy_ctrl_send_command(struct media_player *player, const struct mpl_ if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->command_send) { mprx.ctrlr.cbs->command_send(player, 0, cmd); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } return 0; } - BT_DBG("No call"); + LOG_DBG("No call"); return -EOPNOTSUPP; } #endif /* CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL */ @@ -1561,7 +1559,7 @@ int media_proxy_ctrl_send_command(struct media_player *player, const struct mpl_ int media_proxy_ctrl_get_commands_supported(struct media_player *player) { CHECKIF(player == NULL) { - BT_DBG("player is NULL"); + LOG_DBG("player is NULL"); return -EINVAL; } @@ -1574,13 +1572,13 @@ int media_proxy_ctrl_get_commands_supported(struct media_player *player) mprx.ctrlr.cbs->commands_supported_recv(player, 0, opcodes); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } return 0; } - BT_DBG("No call"); + LOG_DBG("No call"); return -EOPNOTSUPP; } #endif /* CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL */ @@ -1597,7 +1595,7 @@ int media_proxy_ctrl_get_commands_supported(struct media_player *player) int media_proxy_ctrl_send_search(struct media_player *player, const struct mpl_search *search) { CHECKIF(player == NULL || search == NULL) { - BT_DBG("NULL pointer"); + LOG_DBG("NULL pointer"); return -EINVAL; } @@ -1609,13 +1607,13 @@ int media_proxy_ctrl_send_search(struct media_player *player, const struct mpl_s if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->search_send) { mprx.ctrlr.cbs->search_send(player, 0, search); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } return 0; } - BT_DBG("No call"); + LOG_DBG("No call"); return -EOPNOTSUPP; } #endif /* CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL */ @@ -1632,7 +1630,7 @@ int media_proxy_ctrl_send_search(struct media_player *player, const struct mpl_s int media_proxy_ctrl_get_search_results_id(struct media_player *player) { CHECKIF(player == NULL) { - BT_DBG("player is NULL"); + LOG_DBG("player is NULL"); return -EINVAL; } @@ -1645,13 +1643,13 @@ int media_proxy_ctrl_get_search_results_id(struct media_player *player) mprx.ctrlr.cbs->search_results_id_recv(player, 0, id); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } return 0; } - BT_DBG("No call"); + LOG_DBG("No call"); return -EOPNOTSUPP; } #endif /* CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL */ @@ -1668,7 +1666,7 @@ int media_proxy_ctrl_get_search_results_id(struct media_player *player) uint8_t media_proxy_ctrl_get_content_ctrl_id(struct media_player *player) { CHECKIF(player == NULL) { - BT_DBG("player is NULL"); + LOG_DBG("player is NULL"); return -EINVAL; } @@ -1680,13 +1678,13 @@ uint8_t media_proxy_ctrl_get_content_ctrl_id(struct media_player *player) mprx.ctrlr.cbs->content_ctrl_id_recv(player, 0, ccid); } else { - BT_DBG("No callback"); + LOG_DBG("No callback"); } return 0; } - BT_DBG("No call"); + LOG_DBG("No call"); return -EOPNOTSUPP; } #endif /* CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL */ @@ -1709,148 +1707,148 @@ uint8_t media_proxy_ctrl_get_content_ctrl_id(struct media_player *player) static bool pl_calls_is_valid(const struct media_proxy_pl_calls *pl_calls) { if (pl_calls == NULL) { - BT_DBG("pl_calls is NULL"); + LOG_DBG("pl_calls is NULL"); return false; } if (pl_calls->get_player_name == NULL) { - BT_DBG("get_player_name is NULL"); + LOG_DBG("get_player_name is NULL"); return false; } #ifdef CONFIG_BT_MPL_OBJECTS if (pl_calls->get_icon_id == NULL) { - BT_DBG("get_icon_id is NULL"); + LOG_DBG("get_icon_id is NULL"); return false; } #endif /* CONFIG_BT_MPL_OBJECTS */ if (pl_calls->get_icon_url == NULL) { - BT_DBG("get_icon_url is NULL"); + LOG_DBG("get_icon_url is NULL"); return false; } if (pl_calls->get_track_title == NULL) { - BT_DBG("get_track_title is NULL"); + LOG_DBG("get_track_title is NULL"); return false; } if (pl_calls->get_track_duration == NULL) { - BT_DBG("get_track_duration is NULL"); + LOG_DBG("get_track_duration is NULL"); return false; } if (pl_calls->get_track_position == NULL) { - BT_DBG("get_track_position is NULL"); + LOG_DBG("get_track_position is NULL"); return false; } if (pl_calls->set_track_position == NULL) { - BT_DBG("set_track_position is NULL"); + LOG_DBG("set_track_position is NULL"); return false; } if (pl_calls->get_playback_speed == NULL) { - BT_DBG("get_playback_speed is NULL"); + LOG_DBG("get_playback_speed is NULL"); return false; } if (pl_calls->set_playback_speed == NULL) { - BT_DBG("set_playback_speed is NULL"); + LOG_DBG("set_playback_speed is NULL"); return false; } if (pl_calls->get_seeking_speed == NULL) { - BT_DBG("get_seeking_speed is NULL"); + LOG_DBG("get_seeking_speed is NULL"); return false; } #ifdef CONFIG_BT_MPL_OBJECTS if (pl_calls->get_track_segments_id == NULL) { - BT_DBG("get_track_segments_id is NULL"); + LOG_DBG("get_track_segments_id is NULL"); return false; } if (pl_calls->get_current_track_id == NULL) { - BT_DBG("get_current_track_id is NULL"); + LOG_DBG("get_current_track_id is NULL"); return false; } if (pl_calls->set_current_track_id == NULL) { - BT_DBG("set_current_track_id is NULL"); + LOG_DBG("set_current_track_id is NULL"); return false; } if (pl_calls->get_next_track_id == NULL) { - BT_DBG("get_next_track_id is NULL"); + LOG_DBG("get_next_track_id is NULL"); return false; } if (pl_calls->set_next_track_id == NULL) { - BT_DBG("set_next_track_id is NULL"); + LOG_DBG("set_next_track_id is NULL"); return false; } if (pl_calls->get_parent_group_id == NULL) { - BT_DBG("get_parent_group_id is NULL"); + LOG_DBG("get_parent_group_id is NULL"); return false; } if (pl_calls->get_current_group_id == NULL) { - BT_DBG("get_current_group_id is NULL"); + LOG_DBG("get_current_group_id is NULL"); return false; } if (pl_calls->set_current_group_id == NULL) { - BT_DBG("set_current_group_id is NULL"); + LOG_DBG("set_current_group_id is NULL"); return false; } #endif /* CONFIG_BT_MPL_OBJECTS */ if (pl_calls->get_playing_order == NULL) { - BT_DBG("get_playing_order is NULL"); + LOG_DBG("get_playing_order is NULL"); return false; } if (pl_calls->set_playing_order == NULL) { - BT_DBG("set_playing_order is NULL"); + LOG_DBG("set_playing_order is NULL"); return false; } if (pl_calls->get_playing_orders_supported == NULL) { - BT_DBG("get_playing_orders_supported is NULL"); + LOG_DBG("get_playing_orders_supported is NULL"); return false; } if (pl_calls->get_media_state == NULL) { - BT_DBG("get_media_state is NULL"); + LOG_DBG("get_media_state is NULL"); return false; } if (pl_calls->send_command == NULL) { - BT_DBG("send_command is NULL"); + LOG_DBG("send_command is NULL"); return false; } if (pl_calls->get_commands_supported == NULL) { - BT_DBG("get_commands_supported is NULL"); + LOG_DBG("get_commands_supported is NULL"); return false; } #ifdef CONFIG_BT_MPL_OBJECTS if (pl_calls->send_search == NULL) { - BT_DBG("send_search is NULL"); + LOG_DBG("send_search is NULL"); return false; } if (pl_calls->get_search_results_id == NULL) { - BT_DBG("get_search_results_id is NULL"); + LOG_DBG("get_search_results_id is NULL"); return false; } #endif /* CONFIG_BT_MPL_OBJECTS */ if (pl_calls->get_content_ctrl_id == NULL) { - BT_DBG("get_content_ctrl_id is NULL"); + LOG_DBG("get_content_ctrl_id is NULL"); return false; } @@ -1864,7 +1862,7 @@ int media_proxy_pl_register(struct media_proxy_pl_calls *pl_calls) } if (mprx.local_player.registered) { - BT_DBG("Player already registered"); + LOG_DBG("Player already registered"); return -EALREADY; } @@ -1889,7 +1887,7 @@ void media_proxy_pl_track_changed_cb(void) if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->track_changed_recv) { mprx.ctrlr.cbs->track_changed_recv(&mprx.local_player, 0); } else { - BT_DBG("No ctrlr track changed callback"); + LOG_DBG("No ctrlr track changed callback"); } } @@ -1900,7 +1898,7 @@ void media_proxy_pl_track_title_cb(char *title) if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->track_title_recv) { mprx.ctrlr.cbs->track_title_recv(&mprx.local_player, 0, title); } else { - BT_DBG("No ctrlr track title callback"); + LOG_DBG("No ctrlr track title callback"); } } @@ -1911,7 +1909,7 @@ void media_proxy_pl_track_duration_cb(int32_t duration) if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->track_duration_recv) { mprx.ctrlr.cbs->track_duration_recv(&mprx.local_player, 0, duration); } else { - BT_DBG("No ctrlr track duration callback"); + LOG_DBG("No ctrlr track duration callback"); } } @@ -1922,7 +1920,7 @@ void media_proxy_pl_track_position_cb(int32_t position) if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->track_position_recv) { mprx.ctrlr.cbs->track_position_recv(&mprx.local_player, 0, position); } else { - BT_DBG("No ctrlr track position callback"); + LOG_DBG("No ctrlr track position callback"); } } @@ -1933,7 +1931,7 @@ void media_proxy_pl_playback_speed_cb(int8_t speed) if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->playback_speed_recv) { mprx.ctrlr.cbs->playback_speed_recv(&mprx.local_player, 0, speed); } else { - BT_DBG("No ctrlr playback speed callback"); + LOG_DBG("No ctrlr playback speed callback"); } } @@ -1944,7 +1942,7 @@ void media_proxy_pl_seeking_speed_cb(int8_t speed) if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->seeking_speed_recv) { mprx.ctrlr.cbs->seeking_speed_recv(&mprx.local_player, 0, speed); } else { - BT_DBG("No ctrlr seeking speed callback"); + LOG_DBG("No ctrlr seeking speed callback"); } } @@ -1956,7 +1954,7 @@ void media_proxy_pl_current_track_id_cb(uint64_t id) if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->current_track_id_recv) { mprx.ctrlr.cbs->current_track_id_recv(&mprx.local_player, 0, id); } else { - BT_DBG("No ctrlr current track id callback"); + LOG_DBG("No ctrlr current track id callback"); } } @@ -1967,7 +1965,7 @@ void media_proxy_pl_next_track_id_cb(uint64_t id) if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->next_track_id_recv) { mprx.ctrlr.cbs->next_track_id_recv(&mprx.local_player, 0, id); } else { - BT_DBG("No ctrlr next track id callback"); + LOG_DBG("No ctrlr next track id callback"); } } @@ -1978,7 +1976,7 @@ void media_proxy_pl_parent_group_id_cb(uint64_t id) if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->parent_group_id_recv) { mprx.ctrlr.cbs->parent_group_id_recv(&mprx.local_player, 0, id); } else { - BT_DBG("No ctrlr parent group id callback"); + LOG_DBG("No ctrlr parent group id callback"); } } @@ -1989,7 +1987,7 @@ void media_proxy_pl_current_group_id_cb(uint64_t id) if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->current_group_id_recv) { mprx.ctrlr.cbs->current_group_id_recv(&mprx.local_player, 0, id); } else { - BT_DBG("No ctrlr current group id callback"); + LOG_DBG("No ctrlr current group id callback"); } } #endif /* CONFIG_BT_MPL_OBJECTS */ @@ -2001,7 +1999,7 @@ void media_proxy_pl_playing_order_cb(uint8_t order) if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->playing_order_recv) { mprx.ctrlr.cbs->playing_order_recv(&mprx.local_player, 0, order); } else { - BT_DBG("No ctrlr playing order callback"); + LOG_DBG("No ctrlr playing order callback"); } } @@ -2012,14 +2010,14 @@ void media_proxy_pl_media_state_cb(uint8_t state) if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->media_state_recv) { mprx.ctrlr.cbs->media_state_recv(&mprx.local_player, 0, state); } else { - BT_DBG("No ctrlr media state callback"); + LOG_DBG("No ctrlr media state callback"); } } void media_proxy_pl_command_cb(const struct mpl_cmd_ntf *cmd_ntf) { CHECKIF(cmd_ntf == NULL) { - BT_WARN("cmd_ntf is NULL"); + LOG_WRN("cmd_ntf is NULL"); return; } @@ -2028,7 +2026,7 @@ void media_proxy_pl_command_cb(const struct mpl_cmd_ntf *cmd_ntf) if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->command_recv) { mprx.ctrlr.cbs->command_recv(&mprx.local_player, 0, cmd_ntf); } else { - BT_DBG("No ctrlr command callback"); + LOG_DBG("No ctrlr command callback"); } } @@ -2039,7 +2037,7 @@ void media_proxy_pl_commands_supported_cb(uint32_t opcodes) if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->commands_supported_recv) { mprx.ctrlr.cbs->commands_supported_recv(&mprx.local_player, 0, opcodes); } else { - BT_DBG("No ctrlr commands supported callback"); + LOG_DBG("No ctrlr commands supported callback"); } } @@ -2051,7 +2049,7 @@ void media_proxy_pl_search_cb(uint8_t result_code) if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->search_recv) { mprx.ctrlr.cbs->search_recv(&mprx.local_player, 0, result_code); } else { - BT_DBG("No ctrlr search callback"); + LOG_DBG("No ctrlr search callback"); } } @@ -2062,7 +2060,7 @@ void media_proxy_pl_search_results_id_cb(uint64_t id) if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->search_results_id_recv) { mprx.ctrlr.cbs->search_results_id_recv(&mprx.local_player, 0, id); } else { - BT_DBG("No ctrlr search results id callback"); + LOG_DBG("No ctrlr search results id callback"); } } #endif /* CONFIG_BT_MPL_OBJECTS */ diff --git a/subsys/bluetooth/audio/media_proxy_internal.h b/subsys/bluetooth/audio/media_proxy_internal.h index 237a8d63fb6..338799cb3ad 100644 --- a/subsys/bluetooth/audio/media_proxy_internal.h +++ b/subsys/bluetooth/audio/media_proxy_internal.h @@ -16,12 +16,12 @@ /* Debug output of 48 bit Object ID value */ /* (Zephyr does not yet support debug output of more than 32 bit values.) */ /* Takes a text and a 64-bit integer as input */ -#define BT_DBG_OBJ_ID(text, id64) \ +#define LOG_DBG_OBJ_ID(text, id64) \ do { \ - if (IS_ENABLED(CONFIG_BT_DEBUG_MCS)) { \ + if (IS_ENABLED(CONFIG_BT_MCS_LOG_LEVEL_DBG)) { \ char t[BT_OTS_OBJ_ID_STR_LEN]; \ (void)bt_ots_obj_id_to_str(id64, t, sizeof(t)); \ - BT_DBG(text "0x%s", t); \ + LOG_DBG(text "0x%s", t); \ } \ } while (0) diff --git a/subsys/bluetooth/audio/micp_mic_ctlr.c b/subsys/bluetooth/audio/micp_mic_ctlr.c index d14f36e3fc2..227ebe22eba 100644 --- a/subsys/bluetooth/audio/micp_mic_ctlr.c +++ b/subsys/bluetooth/audio/micp_mic_ctlr.c @@ -20,9 +20,10 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_MICP_MIC_CTLR) -#define LOG_MODULE_NAME bt_micp_mic_ctlr -#include "common/log.h" +#include + +LOG_MODULE_REGISTER(bt_micp_mic_ctlr, CONFIG_BT_MICP_MIC_CTLR_LOG_LEVEL); + #include "common/bt_str.h" /* Callback functions */ @@ -65,15 +66,13 @@ static uint8_t mute_notify_handler(struct bt_conn *conn, if (data != NULL) { if (length == sizeof(*mute_val)) { mute_val = (uint8_t *)data; - BT_DBG("Mute %u", *mute_val); + LOG_DBG("Mute %u", *mute_val); if (micp_mic_ctlr_cb != NULL && micp_mic_ctlr_cb->mute != NULL) { micp_mic_ctlr_cb->mute(mic_ctlr, 0, *mute_val); } } else { - BT_DBG("Invalid length %u (expected %zu)", - length, sizeof(*mute_val)); - + LOG_DBG("Invalid length %u (expected %zu)", length, sizeof(*mute_val)); } } @@ -91,14 +90,13 @@ static uint8_t micp_mic_ctlr_read_mute_cb(struct bt_conn *conn, uint8_t err, mic_ctlr->busy = false; if (err > 0) { - BT_DBG("err: 0x%02X", err); + LOG_DBG("err: 0x%02X", err); } else if (data != NULL) { if (length == sizeof(mute_val)) { mute_val = ((uint8_t *)data)[0]; - BT_DBG("Mute %u", mute_val); + LOG_DBG("Mute %u", mute_val); } else { - BT_DBG("Invalid length %u (expected %zu)", - length, sizeof(mute_val)); + LOG_DBG("Invalid length %u (expected %zu)", length, sizeof(mute_val)); cb_err = BT_ATT_ERR_INVALID_ATTRIBUTE_LEN; } } @@ -116,7 +114,7 @@ static void micp_mic_ctlr_write_mics_mute_cb(struct bt_conn *conn, uint8_t err, struct bt_micp_mic_ctlr *mic_ctlr = &mic_ctlrs[bt_conn_index(conn)]; uint8_t mute_val = mic_ctlr->mute_val_buf[0]; - BT_DBG("Write %s (0x%02X)", err ? "failed" : "successful", err); + LOG_DBG("Write %s (0x%02X)", err ? "failed" : "successful", err); mic_ctlr->busy = false; @@ -161,7 +159,7 @@ static void aics_discover_cb(struct bt_aics *inst, int err) } if (err != 0) { - BT_DBG("Discover failed (err %d)", err); + LOG_DBG("Discover failed (err %d)", err); if (micp_mic_ctlr_cb != NULL && micp_mic_ctlr_cb->discover != NULL) { micp_mic_ctlr_cb->discover(mic_ctlr, err, 0); @@ -177,8 +175,7 @@ static uint8_t micp_discover_include_func( struct bt_micp_mic_ctlr *mic_ctlr = &mic_ctlrs[bt_conn_index(conn)]; if (attr == NULL) { - BT_DBG("Discover include complete for MICS: %u AICS", - mic_ctlr->aics_inst_cnt); + LOG_DBG("Discover include complete for MICS: %u AICS", mic_ctlr->aics_inst_cnt); (void)memset(params, 0, sizeof(*params)); if (micp_mic_ctlr_cb != NULL && @@ -190,12 +187,12 @@ static uint8_t micp_discover_include_func( return BT_GATT_ITER_STOP; } - BT_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); + LOG_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); if (params->type == BT_GATT_DISCOVER_INCLUDE) { struct bt_gatt_include *include = (struct bt_gatt_include *)attr->user_data; - BT_DBG("Include UUID %s", bt_uuid_str(include->uuid)); + LOG_DBG("Include UUID %s", bt_uuid_str(include->uuid)); if (bt_uuid_cmp(include->uuid, BT_UUID_AICS) == 0 && mic_ctlr->aics_inst_cnt < CONFIG_BT_MICP_MIC_CTLR_MAX_AICS_INST) { @@ -215,7 +212,7 @@ static uint8_t micp_discover_include_func( err = bt_aics_discover(conn, mic_ctlr->aics[inst_idx], ¶m); if (err != 0) { - BT_DBG("AICS Discover failed (err %d)", err); + LOG_DBG("AICS Discover failed (err %d)", err); if (micp_mic_ctlr_cb != NULL && micp_mic_ctlr_cb->discover != NULL) { micp_mic_ctlr_cb->discover(mic_ctlr, err, @@ -243,7 +240,7 @@ static uint8_t micp_discover_func(struct bt_conn *conn, if (attr == NULL) { int err = 0; - BT_DBG("Discovery complete"); + LOG_DBG("Discovery complete"); (void)memset(params, 0, sizeof(*params)); if (CONFIG_BT_MICP_MIC_CTLR_MAX_AICS_INST > 0) { /* Discover included services */ @@ -255,7 +252,7 @@ static uint8_t micp_discover_func(struct bt_conn *conn, err = bt_gatt_discover(conn, &mic_ctlr->discover_params); if (err != 0) { - BT_DBG("Discover AICS failed (err %d)", err); + LOG_DBG("Discover AICS failed (err %d)", err); if (micp_mic_ctlr_cb != NULL && micp_mic_ctlr_cb->discover != NULL) { micp_mic_ctlr_cb->discover(mic_ctlr, err, 0); @@ -270,14 +267,14 @@ static uint8_t micp_discover_func(struct bt_conn *conn, return BT_GATT_ITER_STOP; } - BT_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); + LOG_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); if (params->type == BT_GATT_DISCOVER_CHARACTERISTIC) { struct bt_gatt_chrc *chrc = (struct bt_gatt_chrc *)attr->user_data; struct bt_gatt_subscribe_params *sub_params = NULL; if (bt_uuid_cmp(chrc->uuid, BT_UUID_MICS_MUTE) == 0) { - BT_DBG("Mute"); + LOG_DBG("Mute"); mic_ctlr->mute_handle = chrc->value_handle; sub_params = &mic_ctlr->mute_sub_params; sub_params->disc_params = &mic_ctlr->mute_sub_disc_params; @@ -295,11 +292,10 @@ static uint8_t micp_discover_func(struct bt_conn *conn, err = bt_gatt_subscribe(conn, sub_params); if (err == 0) { - BT_DBG("Subscribed to handle 0x%04X", - attr->handle); + LOG_DBG("Subscribed to handle 0x%04X", attr->handle); } else { - BT_DBG("Could not subscribe to handle 0x%04X: %d", - attr->handle, err); + LOG_DBG("Could not subscribe to handle 0x%04X: %d", attr->handle, + err); } } } @@ -314,7 +310,7 @@ static uint8_t primary_discover_func(struct bt_conn *conn, struct bt_micp_mic_ctlr *mic_ctlr = &mic_ctlrs[bt_conn_index(conn)]; if (attr == NULL) { - BT_DBG("Could not find a MICS instance on the server"); + LOG_DBG("Could not find a MICS instance on the server"); if (micp_mic_ctlr_cb != NULL && micp_mic_ctlr_cb->discover != NULL) { micp_mic_ctlr_cb->discover(mic_ctlr, -ENODATA, 0); @@ -322,14 +318,14 @@ static uint8_t primary_discover_func(struct bt_conn *conn, return BT_GATT_ITER_STOP; } - BT_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); + LOG_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); if (params->type == BT_GATT_DISCOVER_PRIMARY) { struct bt_gatt_service_val *prim_service = (struct bt_gatt_service_val *)attr->user_data; int err; - BT_DBG("Primary discover complete"); + LOG_DBG("Primary discover complete"); mic_ctlr->start_handle = attr->handle + 1; mic_ctlr->end_handle = prim_service->end_handle; @@ -342,7 +338,7 @@ static uint8_t primary_discover_func(struct bt_conn *conn, err = bt_gatt_discover(conn, &mic_ctlr->discover_params); if (err != 0) { - BT_DBG("Discover failed (err %d)", err); + LOG_DBG("Discover failed (err %d)", err); if (micp_mic_ctlr_cb != NULL && micp_mic_ctlr_cb->discover != NULL) { micp_mic_ctlr_cb->discover(mic_ctlr, err, 0); @@ -407,7 +403,7 @@ int bt_micp_mic_ctlr_discover(struct bt_conn *conn, struct bt_micp_mic_ctlr **mi */ CHECKIF(conn == NULL) { - BT_DBG("NULL conn"); + LOG_DBG("NULL conn"); return -EINVAL; } @@ -460,7 +456,7 @@ int bt_micp_mic_ctlr_cb_register(struct bt_micp_mic_ctlr_cb *cb) /* Ensure that the cb->aics_cb.discover is the aics_discover_cb */ CHECKIF(cb->aics_cb.discover != NULL && cb->aics_cb.discover != aics_discover_cb) { - BT_ERR("AICS discover callback shall not be set"); + LOG_ERR("AICS discover callback shall not be set"); return -EINVAL; } cb->aics_cb.discover = aics_discover_cb; @@ -488,7 +484,7 @@ int bt_micp_mic_ctlr_included_get(struct bt_micp_mic_ctlr *mic_ctlr, struct bt_micp_included *included) { CHECKIF(mic_ctlr == NULL) { - BT_DBG("NULL mic_ctlr"); + LOG_DBG("NULL mic_ctlr"); return -EINVAL; } @@ -505,12 +501,12 @@ int bt_micp_mic_ctlr_included_get(struct bt_micp_mic_ctlr *mic_ctlr, int bt_micp_mic_ctlr_conn_get(const struct bt_micp_mic_ctlr *mic_ctlr, struct bt_conn **conn) { CHECKIF(mic_ctlr == NULL) { - BT_DBG("NULL mic_ctlr pointer"); + LOG_DBG("NULL mic_ctlr pointer"); return -EINVAL; } if (mic_ctlr->conn == NULL) { - BT_DBG("mic_ctlr pointer not associated with a connection. " + LOG_DBG("mic_ctlr pointer not associated with a connection. " "Do discovery first"); return -ENOTCONN; } @@ -524,12 +520,12 @@ int bt_micp_mic_ctlr_mute_get(struct bt_micp_mic_ctlr *mic_ctlr) int err; CHECKIF(mic_ctlr == NULL) { - BT_DBG("NULL mic_ctlr"); + LOG_DBG("NULL mic_ctlr"); return -EINVAL; } if (mic_ctlr->mute_handle == 0) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } else if (mic_ctlr->busy) { return -EBUSY; @@ -553,12 +549,12 @@ int bt_micp_mic_ctlr_write_mute(struct bt_micp_mic_ctlr *mic_ctlr, bool mute) int err; CHECKIF(mic_ctlr == NULL) { - BT_DBG("NULL mic_ctlr"); + LOG_DBG("NULL mic_ctlr"); return -EINVAL; } if (mic_ctlr->mute_handle == 0) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } else if (mic_ctlr->busy) { return -EBUSY; diff --git a/subsys/bluetooth/audio/micp_mic_dev.c b/subsys/bluetooth/audio/micp_mic_dev.c index 56329079f94..9ba3abdd236 100644 --- a/subsys/bluetooth/audio/micp_mic_dev.c +++ b/subsys/bluetooth/audio/micp_mic_dev.c @@ -21,9 +21,9 @@ #include "audio_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_MICP_MIC_DEV) -#define LOG_MODULE_NAME bt_micp -#include "common/log.h" +#include + +LOG_MODULE_REGISTER(bt_micp, CONFIG_BT_MICP_MIC_DEV_LOG_LEVEL); struct bt_micp_server { uint8_t mute; @@ -36,14 +36,14 @@ static struct bt_micp_server micp_inst; static void mute_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("value 0x%04x", value); + LOG_DBG("value 0x%04x", value); } static ssize_t read_mute(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset) { - BT_DBG("Mute %u", micp_inst.mute); + LOG_DBG("Mute %u", micp_inst.mute); return bt_gatt_attr_read(conn, attr, buf, len, offset, &micp_inst.mute, sizeof(micp_inst.mute)); @@ -72,7 +72,7 @@ static ssize_t write_mute(struct bt_conn *conn, const struct bt_gatt_attr *attr, return BT_GATT_ERR(BT_MICP_ERR_MUTE_DISABLED); } - BT_DBG("%u", *val); + LOG_DBG("%u", *val); if (*val != micp_inst.mute) { micp_inst.mute = *val; @@ -120,14 +120,14 @@ static int prepare_aics_inst(struct bt_micp_mic_dev_register_param *param) if (bt_uuid_cmp(mics_attrs[i].uuid, BT_UUID_GATT_INCLUDE) == 0) { micp_inst.aics_insts[j] = bt_aics_free_instance_get(); if (micp_inst.aics_insts[j] == NULL) { - BT_DBG("Could not get free AICS instances[%u]", j); + LOG_DBG("Could not get free AICS instances[%u]", j); return -ENOMEM; } err = bt_aics_register(micp_inst.aics_insts[j], ¶m->aics_param[j]); if (err != 0) { - BT_DBG("Could not register AICS instance[%u]: %d", j, err); + LOG_DBG("Could not register AICS instance[%u]: %d", j, err); return err; } @@ -162,7 +162,7 @@ int bt_micp_mic_dev_register(struct bt_micp_mic_dev_register_param *param) #if defined(CONFIG_BT_MICP_MIC_DEV_AICS) err = prepare_aics_inst(param); if (err != 0) { - BT_DBG("Failed to prepare AICS instances: %d", err); + LOG_DBG("Failed to prepare AICS instances: %d", err); return err; } @@ -173,7 +173,7 @@ int bt_micp_mic_dev_register(struct bt_micp_mic_dev_register_param *param) err = bt_gatt_service_register(&mics_svc); if (err != 0) { - BT_ERR("MICS service register failed: %d", err); + LOG_ERR("MICS service register failed: %d", err); } micp_inst.cb = param->cb; @@ -196,7 +196,7 @@ int bt_micp_mic_dev_mute_disable(void) int bt_micp_mic_dev_included_get(struct bt_micp_included *included) { CHECKIF(included == NULL) { - BT_DBG("NULL service pointer"); + LOG_DBG("NULL service pointer"); return -EINVAL; } diff --git a/subsys/bluetooth/audio/mpl.c b/subsys/bluetooth/audio/mpl.c index 439c33c950b..47535774253 100644 --- a/subsys/bluetooth/audio/mpl.c +++ b/subsys/bluetooth/audio/mpl.c @@ -14,9 +14,10 @@ #include "media_proxy_internal.h" #include "mpl_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_MPL) -#define LOG_MODULE_NAME bt_mpl -#include "common/log.h" +#include + +LOG_MODULE_REGISTER(bt_mpl, CONFIG_BT_MPL_LOG_LEVEL); + #include "ccid_internal.h" #include "mcs_internal.h" @@ -331,7 +332,7 @@ static uint32_t setup_segments_object(struct mpl_track *track) seg_size += seg->name_len; seg_size += sizeof(seg->pos); if (tot_size + seg_size > obj.content->size) { - BT_DBG("Segments object out of space"); + LOG_DBG("Segments object out of space"); break; } net_buf_simple_add_u8(obj.content, seg->name_len); @@ -344,9 +345,9 @@ static uint32_t setup_segments_object(struct mpl_track *track) } LOG_HEXDUMP_DBG(obj.content->data, obj.content->len, "Segments Object"); - BT_DBG("Segments object length: %d", obj.content->len); + LOG_DBG("Segments object length: %d", obj.content->len); } else { - BT_ERR("No seg!"); + LOG_ERR("No seg!"); } return obj.content->len; @@ -403,10 +404,10 @@ static uint32_t setup_parent_group_object(struct mpl_group *group) next_size += record_size; } if (next_size > obj.content->size) { - BT_WARN("Not room for full group in object"); + LOG_WRN("Not room for full group in object"); } LOG_HEXDUMP_DBG(obj.content->data, obj.content->len, "Parent Group Object"); - BT_DBG("Group object length: %d", obj.content->len); + LOG_DBG("Group object length: %d", obj.content->len); } return obj.content->len; } @@ -435,10 +436,10 @@ static uint32_t setup_group_object(struct mpl_group *group) next_size += record_size; } if (next_size > obj.content->size) { - BT_WARN("Not room for full group in object"); + LOG_WRN("Not room for full group in object"); } LOG_HEXDUMP_DBG(obj.content->data, obj.content->len, "Group Object"); - BT_DBG("Group object length: %d", obj.content->len); + LOG_DBG("Group object length: %d", obj.content->len); } return obj.content->len; } @@ -455,7 +456,7 @@ static int add_icon_object(struct mpl_mediaplayer *pl) if (obj.busy) { /* TODO: Can there be a collision between select and internal */ /* activities, like adding new objects? */ - BT_ERR("Object busy"); + LOG_ERR("Object busy"); return 0; } obj.busy = true; @@ -472,7 +473,7 @@ static int add_icon_object(struct mpl_mediaplayer *pl) ret = bt_ots_obj_add(bt_mcs_get_ots(), &add_param); if (ret < 0) { - BT_WARN("Unable to add icon object, error %d", ret); + LOG_WRN("Unable to add icon object, error %d", ret); obj.busy = false; return ret; @@ -490,7 +491,7 @@ static int add_current_track_segments_object(struct mpl_mediaplayer *pl) struct bt_uuid *segs_type = BT_UUID_OTS_TYPE_TRACK_SEGMENT; if (obj.busy) { - BT_ERR("Object busy"); + LOG_ERR("Object busy"); return 0; } obj.busy = true; @@ -507,7 +508,7 @@ static int add_current_track_segments_object(struct mpl_mediaplayer *pl) ret = bt_ots_obj_add(bt_mcs_get_ots(), &add_param); if (ret < 0) { - BT_WARN("Unable to add track segments object: %d", ret); + LOG_WRN("Unable to add track segments object: %d", ret); obj.busy = false; return ret; @@ -525,11 +526,11 @@ static int add_track_object(struct mpl_track *track) int ret; if (obj.busy) { - BT_ERR("Object busy"); + LOG_ERR("Object busy"); return 0; } if (!track) { - BT_ERR("No track"); + LOG_ERR("No track"); return -EINVAL; } @@ -549,7 +550,7 @@ static int add_track_object(struct mpl_track *track) ret = bt_ots_obj_add(bt_mcs_get_ots(), &add_param); if (ret < 0) { - BT_WARN("Unable to add track object: %d", ret); + LOG_WRN("Unable to add track object: %d", ret); obj.busy = false; return ret; @@ -567,7 +568,7 @@ static int add_parent_group_object(struct mpl_mediaplayer *pl) struct bt_uuid *group_type = BT_UUID_OTS_TYPE_GROUP; if (obj.busy) { - BT_ERR("Object busy"); + LOG_ERR("Object busy"); return 0; } obj.busy = true; @@ -584,7 +585,7 @@ static int add_parent_group_object(struct mpl_mediaplayer *pl) ret = bt_ots_obj_add(bt_mcs_get_ots(), &add_param); if (ret < 0) { - BT_WARN("Unable to add parent group object"); + LOG_WRN("Unable to add parent group object"); obj.busy = false; return ret; @@ -602,12 +603,12 @@ static int add_group_object(struct mpl_group *group) int ret; if (obj.busy) { - BT_ERR("Object busy"); + LOG_ERR("Object busy"); return 0; } if (!group) { - BT_ERR("No group"); + LOG_ERR("No group"); return -EINVAL; } @@ -627,7 +628,7 @@ static int add_group_object(struct mpl_group *group) ret = bt_ots_obj_add(bt_mcs_get_ots(), &add_param); if (ret < 0) { - BT_WARN("Unable to add group object: %d", ret); + LOG_WRN("Unable to add group object: %d", ret); obj.busy = false; return ret; @@ -698,7 +699,7 @@ static int add_group_and_track_objects(struct mpl_mediaplayer *pl) static int on_obj_deleted(struct bt_ots *ots, struct bt_conn *conn, uint64_t id) { - BT_DBG_OBJ_ID("Object Id deleted: ", id); + LOG_DBG_OBJ_ID("Object Id deleted: ", id); return 0; } @@ -709,38 +710,38 @@ static void on_obj_selected(struct bt_ots *ots, struct bt_conn *conn, if (obj.busy) { /* TODO: Can there be a collision between select and internal */ /* activities, like adding new objects? */ - BT_ERR("Object busy - select not performed"); + LOG_ERR("Object busy - select not performed"); return; } obj.busy = true; - BT_DBG_OBJ_ID("Object Id selected: ", id); + LOG_DBG_OBJ_ID("Object Id selected: ", id); if (id == pl.icon_id) { - BT_DBG("Icon Object ID"); + LOG_DBG("Icon Object ID"); (void)setup_icon_object(); } else if (id == pl.group->track->segments_id) { - BT_DBG("Current Track Segments Object ID"); + LOG_DBG("Current Track Segments Object ID"); (void)setup_segments_object(pl.group->track); } else if (id == pl.group->track->id) { - BT_DBG("Current Track Object ID"); + LOG_DBG("Current Track Object ID"); (void)setup_track_object(pl.group->track); } else if (pl.next_track_set && id == pl.next.track->id) { /* Next track, if the next track has been explicitly set */ - BT_DBG("Next Track Object ID"); + LOG_DBG("Next Track Object ID"); (void)setup_track_object(pl.next.track); } else if (id == pl.group->track->next->id) { /* Next track, if next track has not been explicitly set */ - BT_DBG("Next Track Object ID"); + LOG_DBG("Next Track Object ID"); (void)setup_track_object(pl.group->track->next); } else if (id == pl.group->parent->id) { - BT_DBG("Parent Group Object ID"); + LOG_DBG("Parent Group Object ID"); (void)setup_parent_group_object(pl.group); } else if (id == pl.group->id) { - BT_DBG("Current Group Object ID"); + LOG_DBG("Current Group Object ID"); (void)setup_group_object(pl.group); } else { - BT_ERR("Unknown Object ID"); + LOG_ERR("Unknown Object ID"); obj.busy = false; return; } @@ -753,58 +754,58 @@ static int on_obj_created(struct bt_ots *ots, struct bt_conn *conn, uint64_t id, const struct bt_ots_obj_add_param *add_param, struct bt_ots_obj_created_desc *created_desc) { - BT_DBG_OBJ_ID("Object Id created: ", id); + LOG_DBG_OBJ_ID("Object Id created: ", id); *created_desc = *obj.desc; if (!bt_uuid_cmp(&add_param->type.uuid, BT_UUID_OTS_TYPE_MPL_ICON)) { - BT_DBG("Icon Obj Type"); + LOG_DBG("Icon Obj Type"); if (obj.add_type == MPL_OBJ_ICON) { obj.add_type = MPL_OBJ_NONE; pl.icon_id = id; } else { - BT_DBG("Unexpected object creation"); + LOG_DBG("Unexpected object creation"); } } else if (!bt_uuid_cmp(&add_param->type.uuid, BT_UUID_OTS_TYPE_TRACK_SEGMENT)) { - BT_DBG("Track Segments Obj Type"); + LOG_DBG("Track Segments Obj Type"); if (obj.add_type == MPL_OBJ_TRACK_SEGMENTS) { obj.add_type = MPL_OBJ_NONE; pl.group->track->segments_id = id; } else { - BT_DBG("Unexpected object creation"); + LOG_DBG("Unexpected object creation"); } } else if (!bt_uuid_cmp(&add_param->type.uuid, BT_UUID_OTS_TYPE_TRACK)) { - BT_DBG("Track Obj Type"); + LOG_DBG("Track Obj Type"); if (obj.add_type == MPL_OBJ_TRACK) { obj.add_type = MPL_OBJ_NONE; obj.add_track->id = id; obj.add_track = NULL; } else { - BT_DBG("Unexpected object creation"); + LOG_DBG("Unexpected object creation"); } } else if (!bt_uuid_cmp(&add_param->type.uuid, BT_UUID_OTS_TYPE_GROUP)) { - BT_DBG("Group Obj Type"); + LOG_DBG("Group Obj Type"); if (obj.add_type == MPL_OBJ_PARENT_GROUP) { - BT_DBG("Parent group"); + LOG_DBG("Parent group"); obj.add_type = MPL_OBJ_NONE; pl.group->parent->id = id; } else if (obj.add_type == MPL_OBJ_GROUP) { - BT_DBG("Other group"); + LOG_DBG("Other group"); obj.add_type = MPL_OBJ_NONE; obj.add_group->id = id; obj.add_group = NULL; } else { - BT_DBG("Unexpected object creation"); + LOG_DBG("Unexpected object creation"); } } else { - BT_DBG("Unknown Object ID"); + LOG_DBG("Unknown Object ID"); } if (obj.add_type == MPL_OBJ_NONE) { @@ -821,39 +822,38 @@ static ssize_t on_object_send(struct bt_ots *ots, struct bt_conn *conn, if (obj.busy) { /* TODO: Can there be a collision between select and internal */ /* activities, like adding new objects? */ - BT_ERR("Object busy"); + LOG_ERR("Object busy"); return 0; } obj.busy = true; - if (IS_ENABLED(CONFIG_BT_DEBUG_MPL)) { + if (IS_ENABLED(CONFIG_BT_MPL_LOG_LEVEL_DBG)) { char t[BT_OTS_OBJ_ID_STR_LEN]; (void)bt_ots_obj_id_to_str(id, t, sizeof(t)); - BT_DBG("Object Id %s, offset %lu, length %zu", t, - (long)offset, len); + LOG_DBG("Object Id %s, offset %lu, length %zu", t, (long)offset, len); } if (id != obj.selected_id) { - BT_ERR("Read from unselected object"); + LOG_ERR("Read from unselected object"); obj.busy = false; return 0; } if (!data) { - BT_DBG("Read complete"); + LOG_DBG("Read complete"); obj.busy = false; return 0; } if (offset >= obj.content->len) { - BT_DBG("Offset too large"); + LOG_DBG("Offset too large"); obj.busy = false; return 0; } - if (IS_ENABLED(CONFIG_BT_DEBUG_MPL)) { + if (IS_ENABLED(CONFIG_BT_MPL_LOG_LEVEL_DBG)) { if (len > obj.content->len - offset) { - BT_DBG("Requested len too large"); + LOG_DBG("Requested len too large"); } } @@ -878,62 +878,53 @@ static struct bt_ots_cb ots_cbs = { void do_prev_segment(struct mpl_mediaplayer *pl) { - BT_DBG("Segment name before: %s", - pl->group->track->segment->name); + LOG_DBG("Segment name before: %s", pl->group->track->segment->name); if (pl->group->track->segment->prev != NULL) { pl->group->track->segment = pl->group->track->segment->prev; } - BT_DBG("Segment name after: %s", - pl->group->track->segment->name); + LOG_DBG("Segment name after: %s", pl->group->track->segment->name); } void do_next_segment(struct mpl_mediaplayer *pl) { - BT_DBG("Segment name before: %s", - pl->group->track->segment->name); + LOG_DBG("Segment name before: %s", pl->group->track->segment->name); if (pl->group->track->segment->next != NULL) { pl->group->track->segment = pl->group->track->segment->next; } - BT_DBG("Segment name after: %s", - pl->group->track->segment->name); + LOG_DBG("Segment name after: %s", pl->group->track->segment->name); } void do_first_segment(struct mpl_mediaplayer *pl) { - BT_DBG("Segment name before: %s", - pl->group->track->segment->name); + LOG_DBG("Segment name before: %s", pl->group->track->segment->name); while (pl->group->track->segment->prev != NULL) { pl->group->track->segment = pl->group->track->segment->prev; } - BT_DBG("Segment name after: %s", - pl->group->track->segment->name); + LOG_DBG("Segment name after: %s", pl->group->track->segment->name); } void do_last_segment(struct mpl_mediaplayer *pl) { - BT_DBG("Segment name before: %s", - pl->group->track->segment->name); + LOG_DBG("Segment name before: %s", pl->group->track->segment->name); while (pl->group->track->segment->next != NULL) { pl->group->track->segment = pl->group->track->segment->next; } - BT_DBG("Segment name after: %s", - pl->group->track->segment->name); + LOG_DBG("Segment name after: %s", pl->group->track->segment->name); } void do_goto_segment(struct mpl_mediaplayer *pl, int32_t segnum) { int32_t k; - BT_DBG("Segment name before: %s", - pl->group->track->segment->name); + LOG_DBG("Segment name before: %s", pl->group->track->segment->name); if (segnum > 0) { /* Goto first segment */ @@ -965,8 +956,7 @@ void do_goto_segment(struct mpl_mediaplayer *pl, int32_t segnum) } } - BT_DBG("Segment name after: %s", - pl->group->track->segment->name); + LOG_DBG("Segment name after: %s", pl->group->track->segment->name); } static bool do_prev_track(struct mpl_mediaplayer *pl) @@ -974,7 +964,7 @@ static bool do_prev_track(struct mpl_mediaplayer *pl) bool track_changed = false; #ifdef CONFIG_BT_MPL_OBJECTS - BT_DBG_OBJ_ID("Track ID before: ", pl->group->track->id); + LOG_DBG_OBJ_ID("Track ID before: ", pl->group->track->id); #endif /* CONFIG_BT_MPL_OBJECTS */ if (pl->group->track->prev != NULL) { @@ -983,7 +973,7 @@ static bool do_prev_track(struct mpl_mediaplayer *pl) } #ifdef CONFIG_BT_MPL_OBJECTS - BT_DBG_OBJ_ID("Track ID after: ", pl->group->track->id); + LOG_DBG_OBJ_ID("Track ID after: ", pl->group->track->id); #endif /* CONFIG_BT_MPL_OBJECTS */ return track_changed; @@ -995,7 +985,7 @@ static bool do_next_track_normal_order(struct mpl_mediaplayer *pl) bool track_changed = false; #ifdef CONFIG_BT_MPL_OBJECTS - BT_DBG_OBJ_ID("Track ID before: ", pl->group->track->id); + LOG_DBG_OBJ_ID("Track ID before: ", pl->group->track->id); #endif /* CONFIG_BT_MPL_OBJECTS */ if (pl->group->track->next != NULL) { @@ -1004,7 +994,7 @@ static bool do_next_track_normal_order(struct mpl_mediaplayer *pl) } #ifdef CONFIG_BT_MPL_OBJECTS - BT_DBG_OBJ_ID("Track ID after: ", pl->group->track->id); + LOG_DBG_OBJ_ID("Track ID after: ", pl->group->track->id); #endif /* CONFIG_BT_MPL_OBJECTS */ return track_changed; @@ -1040,7 +1030,7 @@ static bool do_first_track(struct mpl_mediaplayer *pl) bool track_changed = false; #ifdef CONFIG_BT_MPL_OBJECTS - BT_DBG_OBJ_ID("Track ID before: ", pl->group->track->id); + LOG_DBG_OBJ_ID("Track ID before: ", pl->group->track->id); #endif /* CONFIG_BT_MPL_OBJECTS */ if (pl->group->track->prev != NULL) { @@ -1052,7 +1042,7 @@ static bool do_first_track(struct mpl_mediaplayer *pl) } #ifdef CONFIG_BT_MPL_OBJECTS - BT_DBG_OBJ_ID("Track ID after: ", pl->group->track->id); + LOG_DBG_OBJ_ID("Track ID after: ", pl->group->track->id); #endif /* CONFIG_BT_MPL_OBJECTS */ return track_changed; @@ -1063,7 +1053,7 @@ static bool do_last_track(struct mpl_mediaplayer *pl) bool track_changed = false; #ifdef CONFIG_BT_MPL_OBJECTS - BT_DBG_OBJ_ID("Track ID before: ", pl->group->track->id); + LOG_DBG_OBJ_ID("Track ID before: ", pl->group->track->id); #endif /* CONFIG_BT_MPL_OBJECTS */ if (pl->group->track->next != NULL) { @@ -1075,7 +1065,7 @@ static bool do_last_track(struct mpl_mediaplayer *pl) } #ifdef CONFIG_BT_MPL_OBJECTS - BT_DBG_OBJ_ID("Track ID after: ", pl->group->track->id); + LOG_DBG_OBJ_ID("Track ID after: ", pl->group->track->id); #endif /* CONFIG_BT_MPL_OBJECTS */ return track_changed; @@ -1087,7 +1077,7 @@ static bool do_goto_track(struct mpl_mediaplayer *pl, int32_t tracknum) int32_t k; #ifdef CONFIG_BT_MPL_OBJECTS - BT_DBG_OBJ_ID("Track ID before: ", pl->group->track->id); + LOG_DBG_OBJ_ID("Track ID before: ", pl->group->track->id); #endif /* CONFIG_BT_MPL_OBJECTS */ if (tracknum > 0) { @@ -1121,7 +1111,7 @@ static bool do_goto_track(struct mpl_mediaplayer *pl, int32_t tracknum) } #ifdef CONFIG_BT_MPL_OBJECTS - BT_DBG_OBJ_ID("Track ID after: ", pl->group->track->id); + LOG_DBG_OBJ_ID("Track ID after: ", pl->group->track->id); #endif /* CONFIG_BT_MPL_OBJECTS */ /* The track has changed if we have moved more in one direction */ @@ -1135,7 +1125,7 @@ static bool do_prev_group(struct mpl_mediaplayer *pl) bool group_changed = false; #ifdef CONFIG_BT_MPL_OBJECTS - BT_DBG_OBJ_ID("Group ID before: ", pl->group->id); + LOG_DBG_OBJ_ID("Group ID before: ", pl->group->id); #endif /* CONFIG_BT_MPL_OBJECTS */ if (pl->group->prev != NULL) { @@ -1144,7 +1134,7 @@ static bool do_prev_group(struct mpl_mediaplayer *pl) } #ifdef CONFIG_BT_MPL_OBJECTS - BT_DBG_OBJ_ID("Group ID after: ", pl->group->id); + LOG_DBG_OBJ_ID("Group ID after: ", pl->group->id); #endif /* CONFIG_BT_MPL_OBJECTS */ return group_changed; @@ -1155,7 +1145,7 @@ static bool do_next_group(struct mpl_mediaplayer *pl) bool group_changed = false; #ifdef CONFIG_BT_MPL_OBJECTS - BT_DBG_OBJ_ID("Group ID before: ", pl->group->id); + LOG_DBG_OBJ_ID("Group ID before: ", pl->group->id); #endif /* CONFIG_BT_MPL_OBJECTS */ if (pl->group->next != NULL) { @@ -1164,7 +1154,7 @@ static bool do_next_group(struct mpl_mediaplayer *pl) } #ifdef CONFIG_BT_MPL_OBJECTS - BT_DBG_OBJ_ID("Group ID after: ", pl->group->id); + LOG_DBG_OBJ_ID("Group ID after: ", pl->group->id); #endif /* CONFIG_BT_MPL_OBJECTS */ return group_changed; @@ -1175,7 +1165,7 @@ static bool do_first_group(struct mpl_mediaplayer *pl) bool group_changed = false; #ifdef CONFIG_BT_MPL_OBJECTS - BT_DBG_OBJ_ID("Group ID before: ", pl->group->id); + LOG_DBG_OBJ_ID("Group ID before: ", pl->group->id); #endif /* CONFIG_BT_MPL_OBJECTS */ if (pl->group->prev != NULL) { @@ -1187,7 +1177,7 @@ static bool do_first_group(struct mpl_mediaplayer *pl) } #ifdef CONFIG_BT_MPL_OBJECTS - BT_DBG_OBJ_ID("Group ID after: ", pl->group->id); + LOG_DBG_OBJ_ID("Group ID after: ", pl->group->id); #endif /* CONFIG_BT_MPL_OBJECTS */ return group_changed; @@ -1198,7 +1188,7 @@ static bool do_last_group(struct mpl_mediaplayer *pl) bool group_changed = false; #ifdef CONFIG_BT_MPL_OBJECTS - BT_DBG_OBJ_ID("Group ID before: ", pl->group->id); + LOG_DBG_OBJ_ID("Group ID before: ", pl->group->id); #endif /* CONFIG_BT_MPL_OBJECTS */ if (pl->group->next != NULL) { @@ -1210,7 +1200,7 @@ static bool do_last_group(struct mpl_mediaplayer *pl) } #ifdef CONFIG_BT_MPL_OBJECTS - BT_DBG_OBJ_ID("Group ID after: ", pl->group->id); + LOG_DBG_OBJ_ID("Group ID after: ", pl->group->id); #endif /* CONFIG_BT_MPL_OBJECTS */ return group_changed; @@ -1222,7 +1212,7 @@ static bool do_goto_group(struct mpl_mediaplayer *pl, int32_t groupnum) int32_t k; #ifdef CONFIG_BT_MPL_OBJECTS - BT_DBG_OBJ_ID("Group ID before: ", pl->group->id); + LOG_DBG_OBJ_ID("Group ID before: ", pl->group->id); #endif /* CONFIG_BT_MPL_OBJECTS */ if (groupnum > 0) { @@ -1256,7 +1246,7 @@ static bool do_goto_group(struct mpl_mediaplayer *pl, int32_t groupnum) } #ifdef CONFIG_BT_MPL_OBJECTS - BT_DBG_OBJ_ID("Group ID after: ", pl->group->id); + LOG_DBG_OBJ_ID("Group ID after: ", pl->group->id); #endif /* CONFIG_BT_MPL_OBJECTS */ /* The group has changed if we have moved more in one direction */ @@ -1407,10 +1397,10 @@ void do_full_goto_group(struct mpl_mediaplayer *pl, int32_t groupnum) void inactive_state_command_handler(const struct mpl_cmd *command, struct mpl_cmd_ntf *ntf) { - BT_DBG("Command opcode: %d", command->opcode); - if (IS_ENABLED(CONFIG_BT_DEBUG_MPL)) { + LOG_DBG("Command opcode: %d", command->opcode); + if (IS_ENABLED(CONFIG_BT_MPL_LOG_LEVEL_DBG)) { if (command->use_param) { - BT_DBG("Command parameter: %d", command->param); + LOG_DBG("Command parameter: %d", command->param); } } switch (command->opcode) { @@ -1450,7 +1440,7 @@ void inactive_state_command_handler(const struct mpl_cmd *command, * with the "next" order hardcoded into the group and track structure */ if (pl.next_track_set) { - BT_DBG("Next track set"); + LOG_DBG("Next track set"); if (do_next_track_next_track_set(&pl)) { do_group_change_notifications(&pl); } @@ -1557,7 +1547,7 @@ void inactive_state_command_handler(const struct mpl_cmd *command, media_proxy_pl_command_cb(ntf); break; default: - BT_DBG("Invalid command: %d", command->opcode); + LOG_DBG("Invalid command: %d", command->opcode); ntf->result_code = MEDIA_PROXY_CMD_NOT_SUPPORTED; media_proxy_pl_command_cb(ntf); break; @@ -1567,10 +1557,10 @@ void inactive_state_command_handler(const struct mpl_cmd *command, void playing_state_command_handler(const struct mpl_cmd *command, struct mpl_cmd_ntf *ntf) { - BT_DBG("Command opcode: %d", command->opcode); - if (IS_ENABLED(CONFIG_BT_DEBUG_MPL)) { + LOG_DBG("Command opcode: %d", command->opcode); + if (IS_ENABLED(CONFIG_BT_MPL_LOG_LEVEL_DBG)) { if (command->use_param) { - BT_DBG("Command parameter: %d", command->param); + LOG_DBG("Command parameter: %d", command->param); } } switch (command->opcode) { @@ -1694,7 +1684,7 @@ void playing_state_command_handler(const struct mpl_cmd *command, break; case MEDIA_PROXY_OP_NEXT_TRACK: if (pl.next_track_set) { - BT_DBG("Next track set"); + LOG_DBG("Next track set"); if (do_next_track_next_track_set(&pl)) { do_group_change_notifications(&pl); } @@ -1783,7 +1773,7 @@ void playing_state_command_handler(const struct mpl_cmd *command, media_proxy_pl_command_cb(ntf); break; default: - BT_DBG("Invalid command: %d", command->opcode); + LOG_DBG("Invalid command: %d", command->opcode); ntf->result_code = MEDIA_PROXY_CMD_NOT_SUPPORTED; media_proxy_pl_command_cb(ntf); break; @@ -1793,10 +1783,10 @@ void playing_state_command_handler(const struct mpl_cmd *command, void paused_state_command_handler(const struct mpl_cmd *command, struct mpl_cmd_ntf *ntf) { - BT_DBG("Command opcode: %d", command->opcode); - if (IS_ENABLED(CONFIG_BT_DEBUG_MPL)) { + LOG_DBG("Command opcode: %d", command->opcode); + if (IS_ENABLED(CONFIG_BT_MPL_LOG_LEVEL_DBG)) { if (command->use_param) { - BT_DBG("Command parameter: %d", command->param); + LOG_DBG("Command parameter: %d", command->param); } } switch (command->opcode) { @@ -1920,7 +1910,7 @@ void paused_state_command_handler(const struct mpl_cmd *command, break; case MEDIA_PROXY_OP_NEXT_TRACK: if (pl.next_track_set) { - BT_DBG("Next track set"); + LOG_DBG("Next track set"); if (do_next_track_next_track_set(&pl)) { do_group_change_notifications(&pl); } @@ -2009,7 +1999,7 @@ void paused_state_command_handler(const struct mpl_cmd *command, media_proxy_pl_command_cb(ntf); break; default: - BT_DBG("Invalid command: %d", command->opcode); + LOG_DBG("Invalid command: %d", command->opcode); ntf->result_code = MEDIA_PROXY_CMD_NOT_SUPPORTED; media_proxy_pl_command_cb(ntf); break; @@ -2019,10 +2009,10 @@ void paused_state_command_handler(const struct mpl_cmd *command, void seeking_state_command_handler(const struct mpl_cmd *command, struct mpl_cmd_ntf *ntf) { - BT_DBG("Command opcode: %d", command->opcode); - if (IS_ENABLED(CONFIG_BT_DEBUG_MPL)) { + LOG_DBG("Command opcode: %d", command->opcode); + if (IS_ENABLED(CONFIG_BT_MPL_LOG_LEVEL_DBG)) { if (command->use_param) { - BT_DBG("Command parameter: %d", command->param); + LOG_DBG("Command parameter: %d", command->param); } } switch (command->opcode) { @@ -2164,7 +2154,7 @@ void seeking_state_command_handler(const struct mpl_cmd *command, break; case MEDIA_PROXY_OP_NEXT_TRACK: if (pl.next_track_set) { - BT_DBG("Next track set"); + LOG_DBG("Next track set"); if (do_next_track_next_track_set(&pl)) { do_group_change_notifications(&pl); } @@ -2275,7 +2265,7 @@ void seeking_state_command_handler(const struct mpl_cmd *command, media_proxy_pl_command_cb(ntf); break; default: - BT_DBG("Invalid command: %d", command->opcode); + LOG_DBG("Invalid command: %d", command->opcode); ntf->result_code = MEDIA_PROXY_CMD_NOT_SUPPORTED; media_proxy_pl_command_cb(ntf); break; @@ -2421,8 +2411,8 @@ void set_track_position(int32_t position) } } - BT_DBG("Pos. given: %d, resulting pos.: %d (duration is %d)", - position, new_pos, pl.group->track->duration); + LOG_DBG("Pos. given: %d, resulting pos.: %d (duration is %d)", position, new_pos, + pl.group->track->duration); if (new_pos != old_pos) { /* Set new position and notify it */ @@ -2466,7 +2456,7 @@ void set_current_track_id(uint64_t id) struct mpl_group *group; struct mpl_track *track; - BT_DBG_OBJ_ID("Track ID to set: ", id); + LOG_DBG_OBJ_ID("Track ID to set: ", id); if (find_track_by_id(&pl, id, &group, &track)) { @@ -2485,7 +2475,7 @@ void set_current_track_id(uint64_t id) return; } - BT_DBG("Track not found"); + LOG_DBG("Track not found"); /* TODO: Should an error be returned here? * That would require a rewrite of the MPL api to add return values to the functions. @@ -2513,7 +2503,7 @@ void set_next_track_id(uint64_t id) struct mpl_group *group; struct mpl_track *track; - BT_DBG_OBJ_ID("Next Track ID to set: ", id); + LOG_DBG_OBJ_ID("Next Track ID to set: ", id); if (find_track_by_id(&pl, id, &group, &track)) { @@ -2524,7 +2514,7 @@ void set_next_track_id(uint64_t id) return; } - BT_DBG("Track not found"); + LOG_DBG("Track not found"); } uint64_t get_parent_group_id(void) @@ -2542,7 +2532,7 @@ void set_current_group_id(uint64_t id) struct mpl_group *group; bool track_change; - BT_DBG_OBJ_ID("Group ID to set: ", id); + LOG_DBG_OBJ_ID("Group ID to set: ", id); if (find_group_by_id(&pl, id, &group)) { @@ -2560,7 +2550,7 @@ void set_current_group_id(uint64_t id) return; } - BT_DBG("Group not found"); + LOG_DBG("Group not found"); } #endif /* CONFIG_BT_MPL_OBJECTS */ @@ -2594,16 +2584,16 @@ void send_command(const struct mpl_cmd *command) struct mpl_cmd_ntf ntf; if (command->use_param) { - BT_DBG("opcode: %d, param: %d", command->opcode, command->param); + LOG_DBG("opcode: %d, param: %d", command->opcode, command->param); } else { - BT_DBG("opcode: %d", command->opcode); + LOG_DBG("opcode: %d", command->opcode); } if (pl.state < MEDIA_PROXY_STATE_LAST) { ntf.requested_opcode = command->opcode; command_handlers[pl.state](command, &ntf); } else { - BT_DBG("INVALID STATE"); + LOG_DBG("INVALID STATE"); } } @@ -2621,20 +2611,20 @@ static void parse_search(const struct mpl_search *search) bool search_failed = false; if (search->len > SEARCH_LEN_MAX) { - BT_WARN("Search too long (%d) - aborting", search->len); + LOG_WRN("Search too long (%d) - aborting", search->len); search_failed = true; } else { - BT_DBG("Parsing %d octets search", search->len); + LOG_DBG("Parsing %d octets search", search->len); while (search->len - index > 0) { sci.len = (uint8_t)search->search[index++]; if (sci.len < SEARCH_SCI_LEN_MIN) { - BT_WARN("Invalid length field - too small"); + LOG_WRN("Invalid length field - too small"); search_failed = true; break; } if (sci.len > (search->len - index)) { - BT_WARN("Incomplete search control item"); + LOG_WRN("Incomplete search control item"); search_failed = true; break; } @@ -2647,7 +2637,7 @@ static void parse_search(const struct mpl_search *search) (void)memcpy(&sci.param, &search->search[index], sci.len - 1); index += sci.len - 1; - BT_DBG("SCI # %d: type: %d", sci_num, sci.type); + LOG_DBG("SCI # %d: type: %d", sci_num, sci.type); LOG_HEXDUMP_DBG(sci.param, sci.len - 1, "param:"); sci_num++; } @@ -2671,7 +2661,7 @@ static void parse_search(const struct mpl_search *search) void send_search(const struct mpl_search *search) { if (search->len > SEARCH_LEN_MAX) { - BT_WARN("Search too long: %d", search->len); + LOG_WRN("Search too long: %d", search->len); } LOG_HEXDUMP_DBG(search->search, search->len, "Search"); @@ -2696,7 +2686,7 @@ int media_proxy_pl_init(void) int ret; if (initialized) { - BT_DBG("Already initialized"); + LOG_DBG("Already initialized"); return -EALREADY; } @@ -2712,11 +2702,11 @@ int media_proxy_pl_init(void) ret = bt_mcs_init(NULL); #endif /* CONFIG_BT_MPL_OBJECTS */ if (ret < 0) { - BT_ERR("Could not init MCS: %d", ret); + LOG_ERR("Could not init MCS: %d", ret); return ret; } #else - BT_WARN("MCS not configured"); + LOG_WRN("MCS not configured"); #endif /* CONFIG_BT_MCS */ /* Get a Content Control ID */ @@ -2729,14 +2719,14 @@ int media_proxy_pl_init(void) /* Icon Object */ ret = add_icon_object(&pl); if (ret < 0) { - BT_ERR("Unable to add icon object, error %d", ret); + LOG_ERR("Unable to add icon object, error %d", ret); return ret; } /* Add all tracks and groups to OTS */ ret = add_group_and_track_objects(&pl); if (ret < 0) { - BT_ERR("Error adding tracks and groups to OTS, error %d", ret); + LOG_ERR("Error adding tracks and groups to OTS, error %d", ret); return ret; } @@ -2745,7 +2735,7 @@ int media_proxy_pl_init(void) /* but for no only one of the tracks has segments .*/ ret = add_current_track_segments_object(&pl); if (ret < 0) { - BT_ERR("Error adding Track Segments Object to OTS, error %d", ret); + LOG_ERR("Error adding Track Segments Object to OTS, error %d", ret); return ret; } #endif /* CONFIG_BT_MPL_OBJECTS */ @@ -2787,7 +2777,7 @@ int media_proxy_pl_init(void) ret = media_proxy_pl_register(&pl.calls); if (ret < 0) { - BT_ERR("Unable to register player"); + LOG_ERR("Unable to register player"); return ret; } @@ -2795,7 +2785,7 @@ int media_proxy_pl_init(void) return 0; } -#if CONFIG_BT_DEBUG_MPL /* Special commands for debugging */ +#if CONFIG_BT_MPL_LOG_LEVEL_DBG /* Special commands for debugging */ void mpl_debug_dump_state(void) { @@ -2805,52 +2795,52 @@ void mpl_debug_dump_state(void) struct mpl_track *track; #endif /* CONFIG_BT_MPL_OBJECTS */ - BT_DBG("Mediaplayer name: %s", pl.name); + LOG_DBG("Mediaplayer name: %s", pl.name); #if CONFIG_BT_MPL_OBJECTS (void)bt_ots_obj_id_to_str(pl.icon_id, t, sizeof(t)); - BT_DBG("Icon ID: %s", t); + LOG_DBG("Icon ID: %s", t); #endif /* CONFIG_BT_MPL_OBJECTS */ - BT_DBG("Icon URL: %s", pl.icon_url); - BT_DBG("Track position: %d", pl.track_pos); - BT_DBG("Media state: %d", pl.state); - BT_DBG("Playback speed parameter: %d", pl.playback_speed_param); - BT_DBG("Seeking speed factor: %d", pl.seeking_speed_factor); - BT_DBG("Playing order: %d", pl.playing_order); - BT_DBG("Playing orders supported: 0x%x", pl.playing_orders_supported); - BT_DBG("Opcodes supported: %d", pl.opcodes_supported); - BT_DBG("Content control ID: %d", pl.content_ctrl_id); + LOG_DBG("Icon URL: %s", pl.icon_url); + LOG_DBG("Track position: %d", pl.track_pos); + LOG_DBG("Media state: %d", pl.state); + LOG_DBG("Playback speed parameter: %d", pl.playback_speed_param); + LOG_DBG("Seeking speed factor: %d", pl.seeking_speed_factor); + LOG_DBG("Playing order: %d", pl.playing_order); + LOG_DBG("Playing orders supported: 0x%x", pl.playing_orders_supported); + LOG_DBG("Opcodes supported: %d", pl.opcodes_supported); + LOG_DBG("Content control ID: %d", pl.content_ctrl_id); #if CONFIG_BT_MPL_OBJECTS (void)bt_ots_obj_id_to_str(pl.group->parent->id, t, sizeof(t)); - BT_DBG("Current group's parent: %s", t); + LOG_DBG("Current group's parent: %s", t); (void)bt_ots_obj_id_to_str(pl.group->id, t, sizeof(t)); - BT_DBG("Current group: %s", t); + LOG_DBG("Current group: %s", t); (void)bt_ots_obj_id_to_str(pl.group->track->id, t, sizeof(t)); - BT_DBG("Current track: %s", t); + LOG_DBG("Current track: %s", t); if (pl.next_track_set) { (void)bt_ots_obj_id_to_str(pl.next.track->id, t, sizeof(t)); - BT_DBG("Next track: %s", t); + LOG_DBG("Next track: %s", t); } else if (pl.group->track->next) { (void)bt_ots_obj_id_to_str(pl.group->track->next->id, t, sizeof(t)); - BT_DBG("Next track: %s", t); + LOG_DBG("Next track: %s", t); } else { - BT_DBG("No next track"); + LOG_DBG("No next track"); } if (pl.search_results_id) { (void)bt_ots_obj_id_to_str(pl.search_results_id, t, sizeof(t)); - BT_DBG("Search results: %s", t); + LOG_DBG("Search results: %s", t); } else { - BT_DBG("No search results"); + LOG_DBG("No search results"); } - BT_DBG("Groups and tracks:"); + LOG_DBG("Groups and tracks:"); group = pl.group; while (group->prev != NULL) { @@ -2859,12 +2849,10 @@ void mpl_debug_dump_state(void) while (group) { (void)bt_ots_obj_id_to_str(group->id, t, sizeof(t)); - BT_DBG("Group: %s, %s", t, - group->title); + LOG_DBG("Group: %s, %s", t, group->title); (void)bt_ots_obj_id_to_str(group->parent->id, t, sizeof(t)); - BT_DBG("\tParent: %s, %s", t, - group->parent->title); + LOG_DBG("\tParent: %s, %s", t, group->parent->title); track = group->track; while (track->prev != NULL) { @@ -2873,8 +2861,7 @@ void mpl_debug_dump_state(void) while (track) { (void)bt_ots_obj_id_to_str(track->id, t, sizeof(t)); - BT_DBG("\tTrack: %s, %s, duration: %d", t, - track->title, track->duration); + LOG_DBG("\tTrack: %s, %s, duration: %d", t, track->title, track->duration); track = track->next; } @@ -2882,15 +2869,15 @@ void mpl_debug_dump_state(void) } #endif /* CONFIG_BT_MPL_OBJECTS */ } -#endif /* CONFIG_BT_DEBUG_MPL */ +#endif /* CONFIG_BT_MPL_LOG_LEVEL_DBG */ - -#if defined(CONFIG_BT_DEBUG_MPL) && defined(CONFIG_BT_TESTING) /* Special commands for testing */ +#if defined(CONFIG_BT_MPL_LOG_LEVEL_DBG) && \ + defined(CONFIG_BT_TESTING) /* Special commands for testing */ #if CONFIG_BT_MPL_OBJECTS void mpl_test_unset_parent_group(void) { - BT_DBG("Setting current group to be it's own parent"); + LOG_DBG("Setting current group to be it's own parent"); pl.group->parent = pl.group; } #endif /* CONFIG_BT_MPL_OBJECTS */ @@ -2975,4 +2962,4 @@ void mpl_test_search_results_changed_cb(void) } #endif /* CONFIG_BT_MPL_OBJECTS */ -#endif /* CONFIG_BT_DEBUG_MPL && CONFIG_BT_TESTING */ +#endif /* CONFIG_BT_MPL_LOG_LEVEL_DBG && CONFIG_BT_TESTING */ diff --git a/subsys/bluetooth/audio/pacs.c b/subsys/bluetooth/audio/pacs.c index 206ec655487..5fe61560595 100644 --- a/subsys/bluetooth/audio/pacs.c +++ b/subsys/bluetooth/audio/pacs.c @@ -23,9 +23,10 @@ #include #include "../host/conn_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_PACS) -#define LOG_MODULE_NAME bt_pacs -#include "common/log.h" +#include + +LOG_MODULE_REGISTER(bt_pacs, CONFIG_BT_PACS_LOG_LEVEL); + #include "common/bt_str.h" #include "audio_internal.h" @@ -190,7 +191,7 @@ static void get_pac_records(struct bt_conn *conn, sys_slist_t *list, static void available_context_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("attr %p value 0x%04x", attr, value); + LOG_DBG("attr %p value 0x%04x", attr, value); } static ssize_t available_contexts_read(struct bt_conn *conn, @@ -202,8 +203,7 @@ static ssize_t available_contexts_read(struct bt_conn *conn, .src = sys_cpu_to_le16(src_available_contexts), }; - BT_DBG("conn %p attr %p buf %p len %u offset %u", conn, attr, buf, len, - offset); + LOG_DBG("conn %p attr %p buf %p len %u offset %u", conn, attr, buf, len, offset); return bt_gatt_attr_read(conn, attr, buf, len, offset, &context, sizeof(context)); @@ -212,7 +212,7 @@ static ssize_t available_contexts_read(struct bt_conn *conn, static void supported_context_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("attr %p value 0x%04x", attr, value); + LOG_DBG("attr %p value 0x%04x", attr, value); } static ssize_t supported_context_read(struct bt_conn *conn, @@ -224,8 +224,7 @@ static ssize_t supported_context_read(struct bt_conn *conn, .src = sys_cpu_to_le16(src_supported_contexts), }; - BT_DBG("conn %p attr %p buf %p len %u offset %u", conn, attr, buf, len, - offset); + LOG_DBG("conn %p attr %p buf %p len %u offset %u", conn, attr, buf, len, offset); return bt_gatt_attr_read(conn, attr, buf, len, offset, &context, sizeof(context)); @@ -264,8 +263,7 @@ static PACS(snk_pacs, pac_notify_snk); static ssize_t snk_read(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset) { - BT_DBG("conn %p attr %p buf %p len %u offset %u", conn, attr, buf, len, - offset); + LOG_DBG("conn %p attr %p buf %p len %u offset %u", conn, attr, buf, len, offset); get_pac_records(conn, &snk_pacs.list, &read_buf); @@ -275,7 +273,7 @@ static ssize_t snk_read(struct bt_conn *conn, const struct bt_gatt_attr *attr, static void snk_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("attr %p value 0x%04x", attr, value); + LOG_DBG("attr %p value 0x%04x", attr, value); } static inline int set_snk_available_contexts(uint16_t contexts) @@ -300,8 +298,7 @@ static ssize_t snk_loc_read(struct bt_conn *conn, { uint32_t location = sys_cpu_to_le32(snk_location.location); - BT_DBG("conn %p attr %p buf %p len %u offset %u", conn, attr, buf, len, - offset); + LOG_DBG("conn %p attr %p buf %p len %u offset %u", conn, attr, buf, len, offset); return bt_gatt_attr_read(conn, attr, buf, len, offset, &location, sizeof(location)); @@ -309,7 +306,7 @@ static ssize_t snk_loc_read(struct bt_conn *conn, static void snk_loc_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("attr %p value 0x%04x", attr, value); + LOG_DBG("attr %p value 0x%04x", attr, value); } static int set_snk_location(enum bt_audio_location audio_location) @@ -349,13 +346,13 @@ static ssize_t snk_loc_write(struct bt_conn *conn, location = (enum bt_audio_location)sys_get_le32(data); if (location > BT_AUDIO_LOCATION_MASK || location == 0) { - BT_DBG("Invalid location value: 0x%08X", location); + LOG_DBG("Invalid location value: 0x%08X", location); return BT_GATT_ERR(BT_ATT_ERR_WRITE_REQ_REJECTED); } err = set_snk_location(location); if (err != 0) { - BT_DBG("write_location returned %d", err); + LOG_DBG("write_location returned %d", err); return BT_GATT_ERR(BT_ATT_ERR_WRITE_REQ_REJECTED); } @@ -370,8 +367,7 @@ static PACS(src_pacs, pac_notify_src); static ssize_t src_read(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset) { - BT_DBG("conn %p attr %p buf %p len %u offset %u", conn, attr, buf, len, - offset); + LOG_DBG("conn %p attr %p buf %p len %u offset %u", conn, attr, buf, len, offset); get_pac_records(conn, &src_pacs.list, &read_buf); @@ -381,7 +377,7 @@ static ssize_t src_read(struct bt_conn *conn, const struct bt_gatt_attr *attr, static void src_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("attr %p value 0x%04x", attr, value); + LOG_DBG("attr %p value 0x%04x", attr, value); } static inline int set_src_available_contexts(uint16_t contexts) @@ -406,8 +402,7 @@ static ssize_t src_loc_read(struct bt_conn *conn, { uint32_t location = sys_cpu_to_le32(src_location.location); - BT_DBG("conn %p attr %p buf %p len %u offset %u", conn, attr, buf, len, - offset); + LOG_DBG("conn %p attr %p buf %p len %u offset %u", conn, attr, buf, len, offset); return bt_gatt_attr_read(conn, attr, buf, len, offset, &location, sizeof(location)); @@ -415,7 +410,7 @@ static ssize_t src_loc_read(struct bt_conn *conn, static void src_loc_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("attr %p value 0x%04x", attr, value); + LOG_DBG("attr %p value 0x%04x", attr, value); } static int set_src_location(enum bt_audio_location audio_location) @@ -455,13 +450,13 @@ static ssize_t src_loc_write(struct bt_conn *conn, location = (enum bt_audio_location)sys_get_le32(data); if (location > BT_AUDIO_LOCATION_MASK || location == 0) { - BT_DBG("Invalid location value: 0x%08X", location); + LOG_DBG("Invalid location value: 0x%08X", location); return BT_GATT_ERR(BT_ATT_ERR_WRITE_REQ_REJECTED); } err = set_src_location(location); if (err != 0) { - BT_DBG("write_location returned %d", err); + LOG_DBG("write_location returned %d", err); return BT_GATT_ERR(BT_ATT_ERR_WRITE_REQ_REJECTED); } @@ -535,7 +530,7 @@ static void pac_notify_snk_loc(struct k_work *work) err = bt_gatt_notify_uuid(NULL, BT_UUID_PACS_SNK_LOC, pacs_svc.attrs, &location_le, sizeof(location_le)); if (err != 0 && err != -ENOTCONN) { - BT_WARN("PACS notify_loc failed: %d", err); + LOG_WRN("PACS notify_loc failed: %d", err); } } #endif /* CONFIG_BT_PAC_SNK_LOC */ @@ -550,7 +545,7 @@ static void pac_notify_src_loc(struct k_work *work) err = bt_gatt_notify_uuid(NULL, BT_UUID_PACS_SRC_LOC, pacs_svc.attrs, &location_le, sizeof(location_le)); if (err != 0 && err != -ENOTCONN) { - BT_WARN("PACS notify_loc failed: %d", err); + LOG_WRN("PACS notify_loc failed: %d", err); } } #endif /* CONFIG_BT_PAC_SRC_LOC */ @@ -566,7 +561,7 @@ static void pac_notify_snk(struct k_work *work) err = bt_gatt_notify_uuid(NULL, BT_UUID_PACS_SNK, pacs_svc.attrs, read_buf.data, read_buf.len); if (err != 0 && err != -ENOTCONN) { - BT_WARN("PACS notify failed: %d", err); + LOG_WRN("PACS notify failed: %d", err); } } #endif /* CONFIG_BT_PAC_SNK */ @@ -582,7 +577,7 @@ static void pac_notify_src(struct k_work *work) err = bt_gatt_notify_uuid(NULL, BT_UUID_PACS_SRC, pacs_svc.attrs, read_buf.data, read_buf.len); if (err != 0 && err != -ENOTCONN) { - BT_WARN("PACS notify failed: %d", err); + LOG_WRN("PACS notify failed: %d", err); } } #endif /* CONFIG_BT_PAC_SRC */ @@ -603,7 +598,7 @@ static void available_contexts_notify(struct k_work *work) err = bt_gatt_notify_uuid(NULL, BT_UUID_PACS_AVAILABLE_CONTEXT, pacs_svc.attrs, &context, sizeof(context)); if (err != 0 && err != -ENOTCONN) { - BT_WARN("Available Audio Contexts notify failed: %d", err); + LOG_WRN("Available Audio Contexts notify failed: %d", err); } } @@ -641,7 +636,7 @@ void bt_pacs_cap_foreach(enum bt_audio_dir dir, bt_pacs_cap_foreach_func_t func, struct pacs *pac; CHECKIF(func == NULL) { - BT_ERR("func is NULL"); + LOG_ERR("func is NULL"); return; } @@ -667,7 +662,7 @@ int bt_pacs_cap_register(enum bt_audio_dir dir, struct bt_pacs_cap *cap) return -EINVAL; } - BT_DBG("cap %p dir 0x%02x codec 0x%02x codec cid 0x%04x " + LOG_DBG("cap %p dir 0x%02x codec 0x%02x codec cid 0x%04x " "codec vid 0x%04x", cap, dir, cap->codec->id, cap->codec->cid, cap->codec->vid); @@ -692,7 +687,7 @@ int bt_pacs_cap_unregister(enum bt_audio_dir dir, struct bt_pacs_cap *cap) return -EINVAL; } - BT_DBG("cap %p dir 0x%02x", cap, dir); + LOG_DBG("cap %p dir 0x%02x", cap, dir); if (!sys_slist_find_and_remove(&pac->list, &cap->_node)) { return -ENOENT; diff --git a/subsys/bluetooth/audio/stream.c b/subsys/bluetooth/audio/stream.c index 0745f5c6b44..8424eb76f4b 100644 --- a/subsys/bluetooth/audio/stream.c +++ b/subsys/bluetooth/audio/stream.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -25,9 +26,9 @@ #include "unicast_client_internal.h" #include "unicast_server.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_AUDIO_DEBUG_STREAM) -#define LOG_MODULE_NAME bt_audio_stream -#include "common/log.h" +#include + +LOG_MODULE_REGISTER(bt_audio_stream, CONFIG_BT_AUDIO_STREAM_LOG_LEVEL); static uint8_t pack_bt_codec_cc(const struct bt_codec *codec, uint8_t cc[]) { @@ -74,7 +75,7 @@ void bt_audio_stream_attach(struct bt_conn *conn, struct bt_audio_ep *ep, struct bt_codec *codec) { - BT_DBG("conn %p stream %p ep %p codec %p", conn, stream, ep, codec); + LOG_DBG("conn %p stream %p ep %p codec %p", conn, stream, ep, codec); if (conn != NULL) { __ASSERT(stream->conn == NULL || stream->conn == conn, @@ -106,31 +107,31 @@ bool bt_audio_valid_qos(const struct bt_codec_qos *qos) { if (qos->interval < BT_ISO_SDU_INTERVAL_MIN || qos->interval > BT_ISO_SDU_INTERVAL_MAX) { - BT_DBG("Interval not within allowed range: %u (%u-%u)", - qos->interval, BT_ISO_SDU_INTERVAL_MIN, BT_ISO_SDU_INTERVAL_MAX); + LOG_DBG("Interval not within allowed range: %u (%u-%u)", qos->interval, + BT_ISO_SDU_INTERVAL_MIN, BT_ISO_SDU_INTERVAL_MAX); return false; } if (qos->framing > BT_CODEC_QOS_FRAMED) { - BT_DBG("Invalid Framing 0x%02x", qos->framing); + LOG_DBG("Invalid Framing 0x%02x", qos->framing); return false; } if (qos->phy != BT_CODEC_QOS_1M && qos->phy != BT_CODEC_QOS_2M && qos->phy != BT_CODEC_QOS_CODED) { - BT_DBG("Invalid PHY 0x%02x", qos->phy); + LOG_DBG("Invalid PHY 0x%02x", qos->phy); return false; } if (qos->sdu > BT_ISO_MAX_SDU) { - BT_DBG("Invalid SDU %u", qos->sdu); + LOG_DBG("Invalid SDU %u", qos->sdu); return false; } if (qos->latency < BT_ISO_LATENCY_MIN || qos->latency > BT_ISO_LATENCY_MAX) { - BT_DBG("Invalid Latency %u", qos->latency); + LOG_DBG("Invalid Latency %u", qos->latency); return false; } @@ -149,8 +150,8 @@ int bt_audio_stream_send(struct bt_audio_stream *stream, struct net_buf *buf, ep = stream->ep; if (ep->status.state != BT_AUDIO_EP_STATE_STREAMING) { - BT_DBG("Channel %p not ready for streaming (state: %s)", - stream, bt_audio_ep_state_str(ep->status.state)); + LOG_DBG("Channel %p not ready for streaming (state: %s)", stream, + bt_audio_ep_state_str(ep->status.state)); return -EBADMSG; } @@ -174,7 +175,7 @@ static int bt_audio_stream_iso_accept(const struct bt_iso_accept_info *info, { int i; - BT_DBG("acl %p", info->acl); + LOG_DBG("acl %p", info->acl); for (i = 0; i < ARRAY_SIZE(enabling); i++) { struct bt_audio_stream *c = enabling[i]; @@ -184,13 +185,13 @@ static int bt_audio_stream_iso_accept(const struct bt_iso_accept_info *info, *iso_chan = &enabling[i]->ep->iso->chan; enabling[i] = NULL; - BT_DBG("iso_chan %p", *iso_chan); + LOG_DBG("iso_chan %p", *iso_chan); return 0; } } - BT_ERR("No channel listening"); + LOG_ERR("No channel listening"); return -EPERM; } @@ -206,7 +207,7 @@ int bt_audio_stream_iso_listen(struct bt_audio_stream *stream) int err, i; struct bt_audio_stream **free_stream = NULL; - BT_DBG("stream %p conn %p", stream, stream->conn); + LOG_DBG("stream %p conn %p", stream, stream->conn); if (server) { goto done; @@ -214,7 +215,7 @@ int bt_audio_stream_iso_listen(struct bt_audio_stream *stream) err = bt_iso_server_register(&iso_server); if (err) { - BT_ERR("bt_iso_server_register: %d", err); + LOG_ERR("bt_iso_server_register: %d", err); return err; } @@ -236,7 +237,7 @@ done: return 0; } - BT_ERR("Unable to listen: no slot left"); + LOG_ERR("Unable to listen: no slot left"); return -ENOSPC; } @@ -257,12 +258,11 @@ bool bt_audio_valid_stream_qos(const struct bt_audio_stream *stream, if (qos_pref->latency < qos->latency) { /* Latency is a preferred value. Print debug info but do not fail. */ - BT_DBG("Latency %u higher than preferred max %u", - qos->latency, qos_pref->latency); + LOG_DBG("Latency %u higher than preferred max %u", qos->latency, qos_pref->latency); } if (!IN_RANGE(qos->pd, qos_pref->pd_min, qos_pref->pd_max)) { - BT_DBG("Presentation Delay not within range: min %u max %u pd %u", + LOG_DBG("Presentation Delay not within range: min %u max %u pd %u", qos_pref->pd_min, qos_pref->pd_max, qos->pd); return false; } @@ -274,7 +274,7 @@ void bt_audio_stream_detach(struct bt_audio_stream *stream) { const bool is_broadcast = bt_audio_stream_is_broadcast(stream); - BT_DBG("stream %p", stream); + LOG_DBG("stream %p", stream); if (stream->conn != NULL) { bt_conn_unref(stream->conn); @@ -293,7 +293,7 @@ int bt_audio_stream_disconnect(struct bt_audio_stream *stream) { struct bt_iso_chan *iso_chan = bt_audio_stream_iso_chan_get(stream); - BT_DBG("stream %p iso %p", stream, iso_chan); + LOG_DBG("stream %p iso %p", stream, iso_chan); if (stream == NULL) { return -EINVAL; @@ -318,7 +318,7 @@ int bt_audio_stream_disconnect(struct bt_audio_stream *stream) void bt_audio_stream_reset(struct bt_audio_stream *stream) { - BT_DBG("stream %p", stream); + LOG_DBG("stream %p", stream); if (stream == NULL) { return; @@ -337,24 +337,24 @@ int bt_audio_stream_config(struct bt_conn *conn, uint8_t role; int err; - BT_DBG("conn %p stream %p, ep %p codec %p codec id 0x%02x " + LOG_DBG("conn %p stream %p, ep %p codec %p codec id 0x%02x " "codec cid 0x%04x codec vid 0x%04x", conn, stream, ep, codec, codec ? codec->id : 0, codec ? codec->cid : 0, codec ? codec->vid : 0); CHECKIF(conn == NULL || stream == NULL || codec == NULL) { - BT_DBG("NULL value(s) supplied)"); + LOG_DBG("NULL value(s) supplied)"); return -EINVAL; } if (stream->conn != NULL) { - BT_DBG("Stream already configured for conn %p", stream->conn); + LOG_DBG("Stream already configured for conn %p", stream->conn); return -EALREADY; } role = conn->role; if (role != BT_HCI_ROLE_CENTRAL) { - BT_DBG("Invalid conn role: %u, shall be central", role); + LOG_DBG("Invalid conn role: %u, shall be central", role); return -EINVAL; } @@ -367,8 +367,7 @@ int bt_audio_stream_config(struct bt_conn *conn, case BT_AUDIO_EP_STATE_QOS_CONFIGURED: break; default: - BT_ERR("Invalid state: %s", - bt_audio_ep_state_str(ep->status.state)); + LOG_ERR("Invalid state: %s", bt_audio_ep_state_str(ep->status.state)); return -EBADMSG; } @@ -376,7 +375,7 @@ int bt_audio_stream_config(struct bt_conn *conn, err = bt_unicast_client_config(stream, codec); if (err != 0) { - BT_DBG("Failed to configure stream: %d", err); + LOG_DBG("Failed to configure stream: %d", err); return err; } @@ -400,7 +399,7 @@ static int bt_audio_cig_create(struct bt_audio_unicast_group *group, uint8_t cis_count; int err; - BT_DBG("group %p qos %p", group, qos); + LOG_DBG("group %p qos %p", group, qos); cis_count = 0; for (size_t i = 0; i < ARRAY_SIZE(group->cis); i++) { @@ -415,7 +414,7 @@ static int bt_audio_cig_create(struct bt_audio_unicast_group *group, err = bt_iso_cig_create(¶m, &group->cig); if (err != 0) { - BT_ERR("bt_iso_cig_create failed: %d", err); + LOG_ERR("bt_iso_cig_create failed: %d", err); return err; } @@ -431,7 +430,7 @@ static int bt_audio_cig_reconfigure(struct bt_audio_unicast_group *group, uint8_t cis_count; int err; - BT_DBG("group %p qos %p", group, qos); + LOG_DBG("group %p qos %p", group, qos); cis_count = 0U; for (size_t i = 0; i < ARRAY_SIZE(group->cis); i++) { @@ -446,7 +445,7 @@ static int bt_audio_cig_reconfigure(struct bt_audio_unicast_group *group, err = bt_iso_cig_reconfigure(group->cig, ¶m); if (err != 0) { - BT_ERR("bt_iso_cig_create failed: %d", err); + LOG_ERR("bt_iso_cig_create failed: %d", err); return err; } @@ -482,26 +481,26 @@ int bt_audio_stream_qos(struct bt_conn *conn, uint8_t role; int err; - BT_DBG("conn %p group %p", conn, group); + LOG_DBG("conn %p group %p", conn, group); CHECKIF(conn == NULL) { - BT_DBG("conn is NULL"); + LOG_DBG("conn is NULL"); return -EINVAL; } CHECKIF(group == NULL) { - BT_DBG("group is NULL"); + LOG_DBG("group is NULL"); return -EINVAL; } if (sys_slist_is_empty(&group->streams)) { - BT_DBG("group stream list is empty"); + LOG_DBG("group stream list is empty"); return -ENOEXEC; } role = conn->role; if (role != BT_HCI_ROLE_CENTRAL) { - BT_DBG("Invalid conn role: %u, shall be central", role); + LOG_DBG("Invalid conn role: %u, shall be central", role); return -EINVAL; } @@ -525,7 +524,7 @@ int bt_audio_stream_qos(struct bt_conn *conn, ep = stream->ep; if (ep == NULL) { - BT_DBG("stream->ep is NULL"); + LOG_DBG("stream->ep is NULL"); return -EINVAL; } @@ -537,8 +536,8 @@ int bt_audio_stream_qos(struct bt_conn *conn, case BT_AUDIO_EP_STATE_QOS_CONFIGURED: break; default: - BT_DBG("Invalid state: %s", - bt_audio_ep_state_str(stream->ep->status.state)); + LOG_DBG("Invalid state: %s", + bt_audio_ep_state_str(stream->ep->status.state)); return -EINVAL; } @@ -560,13 +559,13 @@ int bt_audio_stream_qos(struct bt_conn *conn, /* This can only happen if the stream was somehow added * to a group without the audio_iso being bound to it */ - BT_ERR("Could not find audio_iso for stream %p", stream); + LOG_ERR("Could not find audio_iso for stream %p", stream); return -EINVAL; } } if (!conn_stream_found) { - BT_DBG("No streams in the group %p for conn %p", group, conn); + LOG_DBG("No streams in the group %p for conn %p", group, conn); return -EINVAL; } @@ -598,7 +597,7 @@ int bt_audio_stream_qos(struct bt_conn *conn, err = bt_unicast_client_ep_send(conn, ep, buf); if (err != 0) { - BT_DBG("Could not send config QoS: %d", err); + LOG_DBG("Could not send config QoS: %d", err); audio_stream_qos_cleanup(conn, group); return err; } @@ -613,29 +612,28 @@ int bt_audio_stream_enable(struct bt_audio_stream *stream, uint8_t role; int err; - BT_DBG("stream %p", stream); + LOG_DBG("stream %p", stream); if (stream == NULL || stream->ep == NULL || stream->conn == NULL) { - BT_DBG("Invalid stream"); + LOG_DBG("Invalid stream"); return -EINVAL; } role = stream->conn->role; if (role != BT_HCI_ROLE_CENTRAL) { - BT_DBG("Invalid conn role: %u, shall be central", role); + LOG_DBG("Invalid conn role: %u, shall be central", role); return -EINVAL; } /* Valid for an ASE only if ASE_State field = 0x02 (QoS Configured) */ if (stream->ep->status.state != BT_AUDIO_EP_STATE_QOS_CONFIGURED) { - BT_ERR("Invalid state: %s", - bt_audio_ep_state_str(stream->ep->status.state)); + LOG_ERR("Invalid state: %s", bt_audio_ep_state_str(stream->ep->status.state)); return -EBADMSG; } err = bt_unicast_client_enable(stream, meta, meta_count); if (err != 0) { - BT_DBG("Failed to enable stream: %d", err); + LOG_DBG("Failed to enable stream: %d", err); return err; } @@ -649,13 +647,13 @@ int bt_audio_stream_stop(struct bt_audio_stream *stream) int err; if (stream == NULL || stream->ep == NULL || stream->conn == NULL) { - BT_DBG("Invalid stream"); + LOG_DBG("Invalid stream"); return -EINVAL; } role = stream->conn->role; if (role != BT_HCI_ROLE_CENTRAL) { - BT_DBG("Invalid conn role: %u, shall be central", role); + LOG_DBG("Invalid conn role: %u, shall be central", role); return -EINVAL; } @@ -666,14 +664,13 @@ int bt_audio_stream_stop(struct bt_audio_stream *stream) case BT_AUDIO_EP_STATE_DISABLING: break; default: - BT_ERR("Invalid state: %s", - bt_audio_ep_state_str(ep->status.state)); + LOG_ERR("Invalid state: %s", bt_audio_ep_state_str(ep->status.state)); return -EBADMSG; } err = bt_unicast_client_stop(stream); if (err != 0) { - BT_DBG("Stopping stream failed: %d", err); + LOG_DBG("Stopping stream failed: %d", err); return err; } @@ -682,7 +679,7 @@ int bt_audio_stream_stop(struct bt_audio_stream *stream) int bt_audio_cig_terminate(struct bt_audio_unicast_group *group) { - BT_DBG("group %p", group); + LOG_DBG("group %p", group); return bt_iso_cig_terminate(group->cig); } @@ -694,7 +691,7 @@ int bt_audio_stream_connect(struct bt_audio_stream *stream) iso_chan = bt_audio_stream_iso_chan_get(stream); - BT_DBG("stream %p iso %p", stream, iso_chan); + LOG_DBG("stream %p iso %p", stream, iso_chan); if (stream == NULL || iso_chan == NULL) { return -EINVAL; @@ -846,7 +843,7 @@ static int unicast_group_add_stream(struct bt_audio_unicast_group *group, stream->unicast_group = group; sys_slist_append(&group->streams, &stream->_node); - BT_DBG("Added stream %p to group %p", stream, group); + LOG_DBG("Added stream %p to group %p", stream, group); return 0; } @@ -909,20 +906,19 @@ int bt_audio_unicast_group_create(struct bt_audio_unicast_group_param params[], int err; CHECKIF(out_unicast_group == NULL) { - BT_DBG("out_unicast_group is NULL"); + LOG_DBG("out_unicast_group is NULL"); return -EINVAL; } /* Set out_unicast_group to NULL until the source has actually been created */ *out_unicast_group = NULL; CHECKIF(params == NULL) { - BT_DBG("streams is NULL"); + LOG_DBG("streams is NULL"); return -EINVAL; } CHECKIF(num_param > UNICAST_GROUP_STREAM_CNT) { - BT_DBG("Too many streams provided: %u/%u", - num_param, UNICAST_GROUP_STREAM_CNT); + LOG_DBG("Too many streams provided: %u/%u", num_param, UNICAST_GROUP_STREAM_CNT); return -EINVAL; } @@ -931,32 +927,32 @@ int bt_audio_unicast_group_create(struct bt_audio_unicast_group_param params[], params[i].qos == NULL || (params[i].dir != BT_AUDIO_DIR_SINK && params[i].dir != BT_AUDIO_DIR_SOURCE)) { - BT_DBG("Invalid params[%zu] values", i); + LOG_DBG("Invalid params[%zu] values", i); return -EINVAL; } if (params[i].stream->group != NULL) { - BT_DBG("params[%zu] stream (%p) already part of group %p", - i, params[i].stream, params[i].stream->group); + LOG_DBG("params[%zu] stream (%p) already part of group %p", i, + params[i].stream, params[i].stream->group); return -EALREADY; } if (group_qos == NULL) { group_qos = params[i].qos; } else if (!unicast_group_valid_qos(group_qos, params[i].qos)) { - BT_DBG("Stream[%zu] QoS incompatible with group QoS", i); + LOG_DBG("Stream[%zu] QoS incompatible with group QoS", i); return -EINVAL; } CHECKIF(!bt_audio_valid_qos(params[i].qos)) { - BT_DBG("Invalid QoS"); + LOG_DBG("Invalid QoS"); return -EINVAL; } } unicast_group = unicast_group_alloc(); if (unicast_group == NULL) { - BT_DBG("Could not allocate any more unicast groups"); + LOG_DBG("Could not allocate any more unicast groups"); return -ENOMEM; } @@ -964,7 +960,7 @@ int bt_audio_unicast_group_create(struct bt_audio_unicast_group_param params[], err = unicast_group_add_stream(unicast_group, params[i].stream, params[i].qos, params[i].dir); if (err < 0) { - BT_DBG("unicast_group_add_stream failed: %d", err); + LOG_DBG("unicast_group_add_stream failed: %d", err); unicast_group_free(unicast_group); return err; @@ -973,7 +969,7 @@ int bt_audio_unicast_group_create(struct bt_audio_unicast_group_param params[], err = bt_audio_cig_create(unicast_group, group_qos); if (err != 0) { - BT_DBG("bt_audio_cig_create failed: %d", err); + LOG_DBG("bt_audio_cig_create failed: %d", err); unicast_group_free(unicast_group); return err; @@ -996,17 +992,17 @@ int bt_audio_unicast_group_add_streams(struct bt_audio_unicast_group *unicast_gr int err; CHECKIF(unicast_group == NULL) { - BT_DBG("unicast_group is NULL"); + LOG_DBG("unicast_group is NULL"); return -EINVAL; } CHECKIF(params == NULL) { - BT_DBG("params is NULL"); + LOG_DBG("params is NULL"); return -EINVAL; } CHECKIF(num_param == 0) { - BT_DBG("num_param is 0"); + LOG_DBG("num_param is 0"); return -EINVAL; } @@ -1015,20 +1011,20 @@ int bt_audio_unicast_group_add_streams(struct bt_audio_unicast_group *unicast_gr params[i].qos == NULL || (params[i].dir != BT_AUDIO_DIR_SINK && params[i].dir != BT_AUDIO_DIR_SOURCE)) { - BT_DBG("Invalid params[%zu] values", i); + LOG_DBG("Invalid params[%zu] values", i); return -EINVAL; } if (params[i].stream->group != NULL) { - BT_DBG("params[%zu] stream (%p) already part of group %p", - i, params[i].stream, params[i].stream->group); + LOG_DBG("params[%zu] stream (%p) already part of group %p", i, + params[i].stream, params[i].stream->group); return -EALREADY; } if (group_qos == NULL) { group_qos = params[i].qos; } else if (!unicast_group_valid_qos(group_qos, params[i].qos)) { - BT_DBG("Stream[%zu] QoS incompatible with group QoS", i); + LOG_DBG("Stream[%zu] QoS incompatible with group QoS", i); return -EINVAL; } } @@ -1039,8 +1035,8 @@ int bt_audio_unicast_group_add_streams(struct bt_audio_unicast_group *unicast_gr } if (total_stream_cnt > UNICAST_GROUP_STREAM_CNT) { - BT_DBG("Too many streams provided: %u/%u", - total_stream_cnt, UNICAST_GROUP_STREAM_CNT); + LOG_DBG("Too many streams provided: %u/%u", total_stream_cnt, + UNICAST_GROUP_STREAM_CNT); return -EINVAL; } @@ -1050,7 +1046,7 @@ int bt_audio_unicast_group_add_streams(struct bt_audio_unicast_group *unicast_gr */ cig = unicast_group->cig; if (cig != NULL && cig->state != BT_ISO_CIG_STATE_CONFIGURED) { - BT_DBG("At least one unicast group stream is started"); + LOG_DBG("At least one unicast group stream is started"); return -EBADMSG; } @@ -1060,14 +1056,14 @@ int bt_audio_unicast_group_add_streams(struct bt_audio_unicast_group *unicast_gr params[num_added].qos, params[num_added].dir); if (err < 0) { - BT_DBG("unicast_group_add_stream failed: %d", err); + LOG_DBG("unicast_group_add_stream failed: %d", err); goto fail; } } err = bt_audio_cig_reconfigure(unicast_group, group_qos); if (err != 0) { - BT_DBG("bt_audio_cig_reconfigure failed: %d", err); + LOG_DBG("bt_audio_cig_reconfigure failed: %d", err); goto fail; } @@ -1085,7 +1081,7 @@ fail: int bt_audio_unicast_group_delete(struct bt_audio_unicast_group *unicast_group) { CHECKIF(unicast_group == NULL) { - BT_DBG("unicast_group is NULL"); + LOG_DBG("unicast_group is NULL"); return -EINVAL; } @@ -1093,8 +1089,7 @@ int bt_audio_unicast_group_delete(struct bt_audio_unicast_group *unicast_group) const int err = bt_audio_cig_terminate(unicast_group); if (err != 0) { - BT_DBG("bt_audio_cig_terminate failed with err %d", - err); + LOG_DBG("bt_audio_cig_terminate failed with err %d", err); return err; } @@ -1114,15 +1109,15 @@ int bt_audio_stream_reconfig(struct bt_audio_stream *stream, uint8_t role; int err; - BT_DBG("stream %p codec %p", stream, codec); + LOG_DBG("stream %p codec %p", stream, codec); CHECKIF(stream == NULL || stream->ep == NULL || stream->conn == NULL) { - BT_DBG("Invalid stream"); + LOG_DBG("Invalid stream"); return -EINVAL; } CHECKIF(codec == NULL) { - BT_DBG("codec is NULL"); + LOG_DBG("codec is NULL"); return -EINVAL; } @@ -1136,7 +1131,7 @@ int bt_audio_stream_reconfig(struct bt_audio_stream *stream, case BT_AUDIO_EP_STATE_QOS_CONFIGURED: break; default: - BT_ERR("Invalid state: %s", bt_audio_ep_state_str(state)); + LOG_ERR("Invalid state: %s", bt_audio_ep_state_str(state)); return -EBADMSG; } @@ -1152,7 +1147,7 @@ int bt_audio_stream_reconfig(struct bt_audio_stream *stream, } if (err != 0) { - BT_DBG("reconfiguring stream failed: %d", err); + LOG_DBG("reconfiguring stream failed: %d", err); } else { stream->codec = codec; } @@ -1166,10 +1161,10 @@ int bt_audio_stream_start(struct bt_audio_stream *stream) uint8_t role; int err; - BT_DBG("stream %p ep %p", stream, stream == NULL ? NULL : stream->ep); + LOG_DBG("stream %p ep %p", stream, stream == NULL ? NULL : stream->ep); CHECKIF(stream == NULL || stream->ep == NULL || stream->conn == NULL) { - BT_DBG("Invalid stream"); + LOG_DBG("Invalid stream"); return -EINVAL; } @@ -1179,7 +1174,7 @@ int bt_audio_stream_start(struct bt_audio_stream *stream) case BT_AUDIO_EP_STATE_ENABLING: break; default: - BT_ERR("Invalid state: %s", bt_audio_ep_state_str(state)); + LOG_ERR("Invalid state: %s", bt_audio_ep_state_str(state)); return -EBADMSG; } @@ -1195,7 +1190,7 @@ int bt_audio_stream_start(struct bt_audio_stream *stream) } if (err != 0) { - BT_DBG("Starting stream failed: %d", err); + LOG_DBG("Starting stream failed: %d", err); return err; } @@ -1210,16 +1205,16 @@ int bt_audio_stream_metadata(struct bt_audio_stream *stream, uint8_t role; int err; - BT_DBG("stream %p metadata count %u", stream, meta_count); + LOG_DBG("stream %p metadata count %u", stream, meta_count); CHECKIF(stream == NULL || stream->ep == NULL || stream->conn == NULL) { - BT_DBG("Invalid stream"); + LOG_DBG("Invalid stream"); return -EINVAL; } CHECKIF((meta == NULL && meta_count != 0U) || (meta != NULL && meta_count == 0U)) { - BT_DBG("Invalid meta (%p) or count (%zu)", meta, meta_count); + LOG_DBG("Invalid meta (%p) or count (%zu)", meta, meta_count); return -EINVAL; } @@ -1231,7 +1226,7 @@ int bt_audio_stream_metadata(struct bt_audio_stream *stream, case BT_AUDIO_EP_STATE_STREAMING: break; default: - BT_ERR("Invalid state: %s", bt_audio_ep_state_str(state)); + LOG_ERR("Invalid state: %s", bt_audio_ep_state_str(state)); return -EBADMSG; } @@ -1247,7 +1242,7 @@ int bt_audio_stream_metadata(struct bt_audio_stream *stream, } if (err != 0) { - BT_DBG("Updating metadata failed: %d", err); + LOG_DBG("Updating metadata failed: %d", err); return err; } @@ -1260,10 +1255,10 @@ int bt_audio_stream_disable(struct bt_audio_stream *stream) uint8_t role; int err; - BT_DBG("stream %p", stream); + LOG_DBG("stream %p", stream); CHECKIF(stream == NULL || stream->ep == NULL || stream->conn == NULL) { - BT_DBG("Invalid stream"); + LOG_DBG("Invalid stream"); return -EINVAL; } @@ -1275,7 +1270,7 @@ int bt_audio_stream_disable(struct bt_audio_stream *stream) case BT_AUDIO_EP_STATE_STREAMING: break; default: - BT_ERR("Invalid state: %s", bt_audio_ep_state_str(state)); + LOG_ERR("Invalid state: %s", bt_audio_ep_state_str(state)); return -EBADMSG; } @@ -1291,7 +1286,7 @@ int bt_audio_stream_disable(struct bt_audio_stream *stream) } if (err != 0) { - BT_DBG("Disabling stream failed: %d", err); + LOG_DBG("Disabling stream failed: %d", err); return err; } @@ -1304,10 +1299,10 @@ int bt_audio_stream_release(struct bt_audio_stream *stream) uint8_t role; int err; - BT_DBG("stream %p", stream); + LOG_DBG("stream %p", stream); CHECKIF(stream == NULL || stream->ep == NULL || stream->conn == NULL) { - BT_DBG("Invalid stream"); + LOG_DBG("Invalid stream"); return -EINVAL; } @@ -1325,7 +1320,7 @@ int bt_audio_stream_release(struct bt_audio_stream *stream) case BT_AUDIO_EP_STATE_DISABLING: break; default: - BT_ERR("Invalid state: %s", bt_audio_ep_state_str(state)); + LOG_ERR("Invalid state: %s", bt_audio_ep_state_str(state)); return -EBADMSG; } @@ -1341,7 +1336,7 @@ int bt_audio_stream_release(struct bt_audio_stream *stream) } if (err != 0) { - BT_DBG("Releasing stream failed: %d", err); + LOG_DBG("Releasing stream failed: %d", err); return err; } diff --git a/subsys/bluetooth/audio/tbs.c b/subsys/bluetooth/audio/tbs.c index 0c6aee17369..339c350b189 100644 --- a/subsys/bluetooth/audio/tbs.c +++ b/subsys/bluetooth/audio/tbs.c @@ -21,9 +21,9 @@ #include "tbs_internal.h" #include "ccid_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_TBS) -#define LOG_MODULE_NAME bt_tbs -#include "common/log.h" +#include + +LOG_MODULE_REGISTER(bt_tbs, CONFIG_BT_TBS_LOG_LEVEL); #define BT_TBS_VALID_STATUS_FLAGS(val) ((val) <= (BIT(0) | BIT(1))) #define IS_GTBS_CHRC(_attr) \ @@ -281,8 +281,8 @@ static void tbs_set_terminate_reason(struct tbs_service_inst *inst, { inst->terminate_reason.call_index = call_index; inst->terminate_reason.reason = reason; - BT_DBG("Index %u: call index 0x%02x, reason %s", - inst->index, call_index, bt_tbs_term_reason_str(reason)); + LOG_DBG("Index %u: call index 0x%02x, reason %s", inst->index, call_index, + bt_tbs_term_reason_str(reason)); bt_gatt_notify_uuid(NULL, BT_UUID_TBS_TERMINATE_REASON, inst->service_p->attrs, @@ -322,7 +322,7 @@ static uint8_t next_free_call_index(void) } } - BT_DBG("No more free call spots"); + LOG_DBG("No more free call spots"); return BT_TBS_FREE_CALL_INDEX; } @@ -504,13 +504,12 @@ static ssize_t read_provider_name(struct bt_conn *conn, if (IS_GTBS_CHRC(attr)) { provider_name = gtbs_inst.provider_name; - BT_DBG("GTBS: Provider name %s", provider_name); + LOG_DBG("GTBS: Provider name %s", provider_name); } else { const struct tbs_service_inst *inst = BT_AUDIO_CHRC_USER_DATA(attr); provider_name = inst->provider_name; - BT_DBG("Index %u, Provider name %s", - inst->index, provider_name); + LOG_DBG("Index %u, Provider name %s", inst->index, provider_name); } return bt_gatt_attr_read(conn, attr, buf, len, offset, @@ -524,9 +523,9 @@ static void provider_name_cfg_changed(const struct bt_gatt_attr *attr, const struct tbs_service_inst *inst = lookup_inst_by_ccc(attr); if (inst != NULL) { - BT_DBG("Index %u: value 0x%04x", inst->index, value); + LOG_DBG("Index %u: value 0x%04x", inst->index, value); } else if (IS_ENABLED(CONFIG_BT_GTBS)) { - BT_DBG("GTBS: value 0x%04x", value); + LOG_DBG("GTBS: value 0x%04x", value); } } @@ -537,12 +536,12 @@ static ssize_t read_uci(struct bt_conn *conn, const struct bt_gatt_attr *attr, if (IS_GTBS_CHRC(attr)) { uci = gtbs_inst.uci; - BT_DBG("GTBS: UCI %s", uci); + LOG_DBG("GTBS: UCI %s", uci); } else { const struct tbs_service_inst *inst = BT_AUDIO_CHRC_USER_DATA(attr); uci = inst->uci; - BT_DBG("Index %u: UCI %s", inst->index, uci); + LOG_DBG("Index %u: UCI %s", inst->index, uci); } return bt_gatt_attr_read(conn, attr, buf, len, offset, @@ -557,12 +556,12 @@ static ssize_t read_technology(struct bt_conn *conn, if (IS_GTBS_CHRC(attr)) { technology = gtbs_inst.technology; - BT_DBG("GTBS: Technology 0x%02X", technology); + LOG_DBG("GTBS: Technology 0x%02X", technology); } else { const struct tbs_service_inst *inst = BT_AUDIO_CHRC_USER_DATA(attr); technology = inst->technology; - BT_DBG("Index %u: Technology 0x%02X", inst->index, technology); + LOG_DBG("Index %u: Technology 0x%02X", inst->index, technology); } return bt_gatt_attr_read(conn, attr, buf, len, offset, @@ -575,9 +574,9 @@ static void technology_cfg_changed(const struct bt_gatt_attr *attr, const struct tbs_service_inst *inst = lookup_inst_by_ccc(attr); if (inst != NULL) { - BT_DBG("Index %u: value 0x%04x", inst->index, value); + LOG_DBG("Index %u: value 0x%04x", inst->index, value); } else if (IS_ENABLED(CONFIG_BT_GTBS)) { - BT_DBG("GTBS: value 0x%04x", value); + LOG_DBG("GTBS: value 0x%04x", value); } } @@ -593,7 +592,7 @@ static ssize_t read_uri_scheme_list(struct bt_conn *conn, size_t uri_len = strlen(svc_insts[i].uri_scheme_list); if (read_buf.len + uri_len >= read_buf.size) { - BT_WARN("Cannot fit all TBS instances in GTBS " + LOG_WRN("Cannot fit all TBS instances in GTBS " "URI scheme list"); break; } @@ -604,7 +603,7 @@ static ssize_t read_uri_scheme_list(struct bt_conn *conn, } /* Add null terminator for printing */ read_buf.data[read_buf.len] = '\0'; - BT_DBG("GTBS: URI scheme %s", read_buf.data); + LOG_DBG("GTBS: URI scheme %s", read_buf.data); } else { const struct tbs_service_inst *inst = BT_AUDIO_CHRC_USER_DATA(attr); @@ -612,8 +611,7 @@ static ssize_t read_uri_scheme_list(struct bt_conn *conn, strlen(inst->uri_scheme_list)); /* Add null terminator for printing */ read_buf.data[read_buf.len] = '\0'; - BT_DBG("Index %u: URI scheme %s", inst->index, - read_buf.data); + LOG_DBG("Index %u: URI scheme %s", inst->index, read_buf.data); } return bt_gatt_attr_read(conn, attr, buf, len, offset, @@ -626,9 +624,9 @@ static void uri_scheme_list_cfg_changed(const struct bt_gatt_attr *attr, const struct tbs_service_inst *inst = lookup_inst_by_ccc(attr); if (inst != NULL) { - BT_DBG("Index %u: value 0x%04x", inst->index, value); + LOG_DBG("Index %u: value 0x%04x", inst->index, value); } else if (IS_ENABLED(CONFIG_BT_GTBS)) { - BT_DBG("GTBS: value 0x%04x", value); + LOG_DBG("GTBS: value 0x%04x", value); } } @@ -640,13 +638,12 @@ static ssize_t read_signal_strength(struct bt_conn *conn, if (IS_GTBS_CHRC(attr)) { signal_strength = gtbs_inst.signal_strength; - BT_DBG("GTBS: Signal strength 0x%02x", signal_strength); + LOG_DBG("GTBS: Signal strength 0x%02x", signal_strength); } else { const struct tbs_service_inst *inst = BT_AUDIO_CHRC_USER_DATA(attr); signal_strength = inst->signal_strength; - BT_DBG("Index %u: Signal strength 0x%02x", - inst->index, signal_strength); + LOG_DBG("Index %u: Signal strength 0x%02x", inst->index, signal_strength); } return bt_gatt_attr_read(conn, attr, buf, len, offset, @@ -659,9 +656,9 @@ static void signal_strength_cfg_changed(const struct bt_gatt_attr *attr, const struct tbs_service_inst *inst = lookup_inst_by_ccc(attr); if (inst != NULL) { - BT_DBG("Index %u: value 0x%04x", inst->index, value); + LOG_DBG("Index %u: value 0x%04x", inst->index, value); } else if (IS_ENABLED(CONFIG_BT_GTBS)) { - BT_DBG("GTBS: value 0x%04x", value); + LOG_DBG("GTBS: value 0x%04x", value); } } @@ -678,14 +675,13 @@ static ssize_t read_signal_strength_interval(struct bt_conn *conn, if (IS_GTBS_CHRC(attr)) { signal_strength_interval = gtbs_inst.signal_strength_interval; - BT_DBG("GTBS: Signal strength interval 0x%02x", - signal_strength_interval); + LOG_DBG("GTBS: Signal strength interval 0x%02x", signal_strength_interval); } else { const struct tbs_service_inst *inst = BT_AUDIO_CHRC_USER_DATA(attr); signal_strength_interval = inst->signal_strength_interval; - BT_DBG("Index %u: Signal strength interval 0x%02x", - inst->index, signal_strength_interval); + LOG_DBG("Index %u: Signal strength interval 0x%02x", inst->index, + signal_strength_interval); } return bt_gatt_attr_read(conn, attr, buf, len, offset, @@ -718,13 +714,12 @@ static ssize_t write_signal_strength_interval(struct bt_conn *conn, if (IS_GTBS_CHRC(attr)) { gtbs_inst.signal_strength_interval = signal_strength_interval; - BT_DBG("GTBS: 0x%02x", signal_strength_interval); + LOG_DBG("GTBS: 0x%02x", signal_strength_interval); } else { struct tbs_service_inst *inst = BT_AUDIO_CHRC_USER_DATA(attr); inst->signal_strength_interval = signal_strength_interval; - BT_DBG("Index %u: 0x%02x", - inst->index, signal_strength_interval); + LOG_DBG("Index %u: 0x%02x", inst->index, signal_strength_interval); } return len; @@ -736,10 +731,10 @@ static void current_calls_cfg_changed(const struct bt_gatt_attr *attr, struct tbs_service_inst *inst = lookup_inst_by_ccc(attr); if (inst != NULL) { - BT_DBG("Index %u: value 0x%04x", inst->index, value); + LOG_DBG("Index %u: value 0x%04x", inst->index, value); inst->notify_current_calls = (value == BT_GATT_CCC_NOTIFY); } else if (IS_ENABLED(CONFIG_BT_GTBS)) { - BT_DBG("GTBS: value 0x%04x", value); + LOG_DBG("GTBS: value 0x%04x", value); gtbs_inst.notify_current_calls = (value == BT_GATT_CCC_NOTIFY); } } @@ -751,11 +746,11 @@ static ssize_t read_current_calls(struct bt_conn *conn, net_buf_put_current_calls(BT_AUDIO_CHRC_USER_DATA(attr)); if (IS_GTBS_CHRC(attr)) { - BT_DBG("GTBS"); + LOG_DBG("GTBS"); } else { const struct tbs_service_inst *inst = BT_AUDIO_CHRC_USER_DATA(attr); - BT_DBG("Index %u", inst->index); + LOG_DBG("Index %u", inst->index); } if (offset == 0) { @@ -774,12 +769,12 @@ static ssize_t read_ccid(struct bt_conn *conn, if (IS_GTBS_CHRC(attr)) { ccid = gtbs_inst.ccid; - BT_DBG("GTBS: CCID 0x%02X", ccid); + LOG_DBG("GTBS: CCID 0x%02X", ccid); } else { const struct tbs_service_inst *inst = BT_AUDIO_CHRC_USER_DATA(attr); ccid = inst->ccid; - BT_DBG("Index %u: CCID 0x%02X", inst->index, ccid); + LOG_DBG("Index %u: CCID 0x%02X", inst->index, ccid); } return bt_gatt_attr_read(conn, attr, buf, len, offset, @@ -794,13 +789,12 @@ static ssize_t read_status_flags(struct bt_conn *conn, if (IS_GTBS_CHRC(attr)) { status_flags = gtbs_inst.status_flags; - BT_DBG("GTBS: status_flags 0x%04X", status_flags); + LOG_DBG("GTBS: status_flags 0x%04X", status_flags); } else { const struct tbs_service_inst *inst = BT_AUDIO_CHRC_USER_DATA(attr); status_flags = inst->status_flags; - BT_DBG("Index %u: status_flags 0x%04X", - inst->index, status_flags); + LOG_DBG("Index %u: status_flags 0x%04X", inst->index, status_flags); } return bt_gatt_attr_read(conn, attr, buf, len, offset, @@ -813,9 +807,9 @@ static void status_flags_cfg_changed(const struct bt_gatt_attr *attr, const struct tbs_service_inst *inst = lookup_inst_by_ccc(attr); if (inst != NULL) { - BT_DBG("Index %u: value 0x%04x", inst->index, value); + LOG_DBG("Index %u: value 0x%04x", inst->index, value); } else if (IS_ENABLED(CONFIG_BT_GTBS)) { - BT_DBG("GTBS: value 0x%04x", value); + LOG_DBG("GTBS: value 0x%04x", value); } } @@ -829,20 +823,18 @@ static ssize_t read_incoming_uri(struct bt_conn *conn, if (IS_GTBS_CHRC(attr)) { inc_call_target = >bs_inst.incoming_uri; - BT_DBG("GTBS: call index 0x%02X, URI %s", - inc_call_target->call_index, - inc_call_target->uri); + LOG_DBG("GTBS: call index 0x%02X, URI %s", inc_call_target->call_index, + inc_call_target->uri); } else { const struct tbs_service_inst *inst = BT_AUDIO_CHRC_USER_DATA(attr); inc_call_target = &inst->incoming_uri; - BT_DBG("Index %u: call index 0x%02X, URI %s", - inst->index, inc_call_target->call_index, - inc_call_target->uri); + LOG_DBG("Index %u: call index 0x%02X, URI %s", inst->index, + inc_call_target->call_index, inc_call_target->uri); } if (!inc_call_target->call_index) { - BT_DBG("URI not set"); + LOG_DBG("URI not set"); return bt_gatt_attr_read(conn, attr, buf, len, offset, NULL, 0); } @@ -860,9 +852,9 @@ static void incoming_uri_cfg_changed(const struct bt_gatt_attr *attr, const struct tbs_service_inst *inst = lookup_inst_by_ccc(attr); if (inst != NULL) { - BT_DBG("Index %u: value 0x%04x", inst->index, value); + LOG_DBG("Index %u: value 0x%04x", inst->index, value); } else if (IS_ENABLED(CONFIG_BT_GTBS)) { - BT_DBG("GTBS: value 0x%04x", value); + LOG_DBG("GTBS: value 0x%04x", value); } } @@ -873,11 +865,11 @@ static ssize_t read_call_state(struct bt_conn *conn, net_buf_put_call_state(BT_AUDIO_CHRC_USER_DATA(attr)); if (IS_GTBS_CHRC(attr)) { - BT_DBG("GTBS"); + LOG_DBG("GTBS"); } else { const struct tbs_service_inst *inst = BT_AUDIO_CHRC_USER_DATA(attr); - BT_DBG("Index %u", inst->index); + LOG_DBG("Index %u", inst->index); } if (offset == 0) { @@ -894,10 +886,10 @@ static void call_state_cfg_changed(const struct bt_gatt_attr *attr, struct tbs_service_inst *inst = lookup_inst_by_ccc(attr); if (inst != NULL) { - BT_DBG("Index %u: value 0x%04x", inst->index, value); + LOG_DBG("Index %u: value 0x%04x", inst->index, value); inst->notify_call_states = (value == BT_GATT_CCC_NOTIFY); } else if (IS_ENABLED(CONFIG_BT_GTBS)) { - BT_DBG("GTBS: value 0x%04x", value); + LOG_DBG("GTBS: value 0x%04x", value); gtbs_inst.notify_call_states = (value == BT_GATT_CCC_NOTIFY); } } @@ -911,8 +903,8 @@ static int notify_ccp(struct bt_conn *conn, const struct bt_gatt_attr *attr, .status = status }; - BT_DBG("Notifying CCP: Call index %u, %s opcode and status %s", - call_index, bt_tbs_opcode_str(opcode), bt_tbs_status_str(status)); + LOG_DBG("Notifying CCP: Call index %u, %s opcode and status %s", call_index, + bt_tbs_opcode_str(opcode), bt_tbs_status_str(status)); return bt_gatt_notify(conn, attr, &ccp_not, sizeof(ccp_not)); } @@ -1077,7 +1069,7 @@ static int originate_call(struct tbs_service_inst *inst, (void)memcpy(call->remote_uri, ccp->uri, uri_len); call->remote_uri[uri_len] = '\0'; if (!bt_tbs_valid_uri(call->remote_uri)) { - BT_DBG("Invalid URI: %s", call->remote_uri); + LOG_DBG("Invalid URI: %s", call->remote_uri); call->index = BT_TBS_FREE_CALL_INDEX; return BT_TBS_RESULT_CODE_INVALID_URI; @@ -1095,7 +1087,7 @@ static int originate_call(struct tbs_service_inst *inst, hold_other_calls(inst, 1, &call->index); notify_calls(inst); - BT_DBG("New call with call index %u", call->index); + LOG_DBG("New call with call index %u", call->index); return BT_TBS_RESULT_CODE_SUCCESS; } @@ -1211,16 +1203,14 @@ static void notify_app(struct bt_conn *conn, uint16_t len, inst = lookup_inst_by_call_index(call_index); if (inst == NULL) { - BT_DBG("Could not find instance by call index 0x%02X", - call_index); + LOG_DBG("Could not find instance by call index 0x%02X", call_index); break; } call = lookup_call_in_inst(inst, call_index); if (call == NULL) { - BT_DBG("Could not find call by call index 0x%02X", - call_index); + LOG_DBG("Could not find call by call index 0x%02X", call_index); break; } @@ -1295,13 +1285,12 @@ static ssize_t write_call_cp(struct bt_conn *conn, } if (is_gtbs) { - BT_DBG("GTBS: Processing the %s opcode", - bt_tbs_opcode_str(ccp->opcode)); + LOG_DBG("GTBS: Processing the %s opcode", bt_tbs_opcode_str(ccp->opcode)); } else { inst = BT_AUDIO_CHRC_USER_DATA(attr); - BT_DBG("Index %u: Processing the %s opcode", - inst->index, bt_tbs_opcode_str(ccp->opcode)); + LOG_DBG("Index %u: Processing the %s opcode", inst->index, + bt_tbs_opcode_str(ccp->opcode)); } switch (ccp->opcode) { @@ -1428,13 +1417,13 @@ static ssize_t write_call_cp(struct bt_conn *conn, if (inst != NULL) { if (is_gtbs) { - BT_DBG("GTBS: Processed the %s opcode with status %s " + LOG_DBG("GTBS: Processed the %s opcode with status %s " "for call index %u", bt_tbs_opcode_str(ccp->opcode), bt_tbs_status_str(status), call_index); } else { - BT_DBG("Index %u: Processed the %s opcode with status " + LOG_DBG("Index %u: Processed the %s opcode with status " "%s for call index %u", inst->index, bt_tbs_opcode_str(ccp->opcode), @@ -1446,10 +1435,10 @@ static ssize_t write_call_cp(struct bt_conn *conn, const struct bt_tbs_call *call = lookup_call(call_index); if (call != NULL) { - BT_DBG("Call is now in the %s state", - bt_tbs_state_str(call->state)); + LOG_DBG("Call is now in the %s state", + bt_tbs_state_str(call->state)); } else { - BT_DBG("Call is now terminated"); + LOG_DBG("Call is now terminated"); } } } @@ -1475,9 +1464,9 @@ static void call_cp_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) const struct tbs_service_inst *inst = lookup_inst_by_ccc(attr); if (inst != NULL) { - BT_DBG("Index %u: value 0x%04x", inst->index, value); + LOG_DBG("Index %u: value 0x%04x", inst->index, value); } else if (IS_ENABLED(CONFIG_BT_GTBS)) { - BT_DBG("GTBS: value 0x%04x", value); + LOG_DBG("GTBS: value 0x%04x", value); } } @@ -1489,13 +1478,12 @@ static ssize_t read_optional_opcodes(struct bt_conn *conn, if (IS_GTBS_CHRC(attr)) { optional_opcodes = gtbs_inst.optional_opcodes; - BT_DBG("GTBS: Supported opcodes 0x%02x", optional_opcodes); + LOG_DBG("GTBS: Supported opcodes 0x%02x", optional_opcodes); } else { const struct tbs_service_inst *inst = BT_AUDIO_CHRC_USER_DATA(attr); optional_opcodes = inst->optional_opcodes; - BT_DBG("Index %u: Supported opcodes 0x%02x", - inst->index, optional_opcodes); + LOG_DBG("Index %u: Supported opcodes 0x%02x", inst->index, optional_opcodes); } return bt_gatt_attr_read(conn, attr, buf, len, offset, @@ -1508,9 +1496,9 @@ static void terminate_reason_cfg_changed(const struct bt_gatt_attr *attr, const struct tbs_service_inst *inst = lookup_inst_by_ccc(attr); if (inst != NULL) { - BT_DBG("Index %u: value 0x%04x", inst->index, value); + LOG_DBG("Index %u: value 0x%04x", inst->index, value); } else if (IS_ENABLED(CONFIG_BT_GTBS)) { - BT_DBG("GTBS: value 0x%04x", value); + LOG_DBG("GTBS: value 0x%04x", value); } } @@ -1523,20 +1511,18 @@ static ssize_t read_friendly_name(struct bt_conn *conn, if (IS_GTBS_CHRC(attr)) { friendly_name = >bs_inst.friendly_name; - BT_DBG("GTBS: call index 0x%02X, URI %s", - friendly_name->call_index, - friendly_name->uri); + LOG_DBG("GTBS: call index 0x%02X, URI %s", friendly_name->call_index, + friendly_name->uri); } else { const struct tbs_service_inst *inst = BT_AUDIO_CHRC_USER_DATA(attr); friendly_name = &inst->friendly_name; - BT_DBG("Index %u: call index 0x%02X, URI %s", - inst->index, friendly_name->call_index, - friendly_name->uri); + LOG_DBG("Index %u: call index 0x%02X, URI %s", inst->index, + friendly_name->call_index, friendly_name->uri); } if (friendly_name->call_index == BT_TBS_FREE_CALL_INDEX) { - BT_DBG("URI not set"); + LOG_DBG("URI not set"); return bt_gatt_attr_read(conn, attr, buf, len, offset, NULL, 0); } @@ -1553,9 +1539,9 @@ static void friendly_name_cfg_changed(const struct bt_gatt_attr *attr, const struct tbs_service_inst *inst = lookup_inst_by_ccc(attr); if (inst != NULL) { - BT_DBG("Index %u: value 0x%04x", inst->index, value); + LOG_DBG("Index %u: value 0x%04x", inst->index, value); } else if (IS_ENABLED(CONFIG_BT_GTBS)) { - BT_DBG("GTBS: value 0x%04x", value); + LOG_DBG("GTBS: value 0x%04x", value); } } @@ -1568,19 +1554,17 @@ static ssize_t read_incoming_call(struct bt_conn *conn, if (IS_GTBS_CHRC(attr)) { remote_uri = >bs_inst.in_call; - BT_DBG("GTBS: call index 0x%02X, URI %s", - remote_uri->call_index, remote_uri->uri); + LOG_DBG("GTBS: call index 0x%02X, URI %s", remote_uri->call_index, remote_uri->uri); } else { const struct tbs_service_inst *inst = BT_AUDIO_CHRC_USER_DATA(attr); remote_uri = &inst->in_call; - BT_DBG("Index %u: call index 0x%02X, URI %s", - inst->index, remote_uri->call_index, - remote_uri->uri); + LOG_DBG("Index %u: call index 0x%02X, URI %s", inst->index, remote_uri->call_index, + remote_uri->uri); } if (remote_uri->call_index == BT_TBS_FREE_CALL_INDEX) { - BT_DBG("URI not set"); + LOG_DBG("URI not set"); return bt_gatt_attr_read(conn, attr, buf, len, offset, NULL, 0); } @@ -1597,9 +1581,9 @@ static void in_call_cfg_changed(const struct bt_gatt_attr *attr, const struct tbs_service_inst *inst = lookup_inst_by_ccc(attr); if (inst != NULL) { - BT_DBG("Index %u: value 0x%04x", inst->index, value); + LOG_DBG("Index %u: value 0x%04x", inst->index, value); } else if (IS_ENABLED(CONFIG_BT_GTBS)) { - BT_DBG("GTBS: value 0x%04x", value); + LOG_DBG("GTBS: value 0x%04x", value); } } @@ -1808,7 +1792,7 @@ static int bt_tbs_init(const struct device *unused) err = bt_gatt_service_register(svc_insts[i].service_p); if (err != 0) { - BT_ERR("Could not register TBS[%d]: %d", i, err); + LOG_ERR("Could not register TBS[%d]: %d", i, err); } } @@ -1930,7 +1914,7 @@ int bt_tbs_originate(uint8_t bearer_index, char *remote_uri, if (bearer_index >= CONFIG_BT_TBS_BEARER_COUNT) { return -EINVAL; } else if (!bt_tbs_valid_uri(remote_uri)) { - BT_DBG("Invalid URI %s", remote_uri); + LOG_DBG("Invalid URI %s", remote_uri); return -EINVAL; } @@ -2088,10 +2072,10 @@ int bt_tbs_remote_incoming(uint8_t bearer_index, const char *to, if (bearer_index >= CONFIG_BT_TBS_BEARER_COUNT) { return -EINVAL; } else if (!bt_tbs_valid_uri(to)) { - BT_DBG("Invalid \"to\" URI: %s", to); + LOG_DBG("Invalid \"to\" URI: %s", to); return -EINVAL; } else if (!bt_tbs_valid_uri(from)) { - BT_DBG("Invalid \"from\" URI: %s", from); + LOG_DBG("Invalid \"from\" URI: %s", from); return -EINVAL; } @@ -2186,7 +2170,7 @@ int bt_tbs_remote_incoming(uint8_t bearer_index, const char *to, notify_calls(inst); - BT_DBG("New call with call index %u", call->index); + LOG_DBG("New call with call index %u", call->index); return call->index; } @@ -2317,13 +2301,12 @@ int bt_tbs_set_signal_strength(uint8_t bearer_index, } } else { if (bearer_index == BT_TBS_GTBS_INDEX) { - BT_DBG("GTBS: Reporting signal strength in %d ms", - timer_status); + LOG_DBG("GTBS: Reporting signal strength in %d ms", timer_status); gtbs_inst.pending_signal_strength_notification = true; } else { - BT_DBG("Index %u: Reporting signal strength in %d ms", - bearer_index, timer_status); + LOG_DBG("Index %u: Reporting signal strength in %d ms", bearer_index, + timer_status); inst->pending_signal_strength_notification = true; } } @@ -2406,8 +2389,7 @@ int bt_tbs_set_uri_scheme_list(uint8_t bearer_index, const char **uri_list, /* Store final result */ (void)strcpy(inst->uri_scheme_list, uri_scheme_list); - BT_DBG("TBS instance %u uri prefix list is now %s", - bearer_index, inst->uri_scheme_list); + LOG_DBG("TBS instance %u uri prefix list is now %s", bearer_index, inst->uri_scheme_list); bt_gatt_notify_uuid(NULL, BT_UUID_TBS_URI_LIST, inst->service_p->attrs, &inst->uri_scheme_list, @@ -2421,7 +2403,7 @@ int bt_tbs_set_uri_scheme_list(uint8_t bearer_index, const char **uri_list, const size_t uri_len = strlen(svc_insts[i].uri_scheme_list); if (uri_scheme_buf.len + uri_len >= uri_scheme_buf.size) { - BT_WARN("Cannot fit all TBS instances in GTBS " + LOG_WRN("Cannot fit all TBS instances in GTBS " "URI scheme list"); break; } @@ -2433,7 +2415,7 @@ int bt_tbs_set_uri_scheme_list(uint8_t bearer_index, const char **uri_list, /* Add null terminator for printing */ uri_scheme_buf.data[uri_scheme_buf.len] = '\0'; - BT_DBG("GTBS: URI scheme %s", uri_scheme_buf.data); + LOG_DBG("GTBS: URI scheme %s", uri_scheme_buf.data); bt_gatt_notify_uuid(NULL, BT_UUID_TBS_URI_LIST, gtbs_inst.service_p->attrs, @@ -2448,11 +2430,11 @@ void bt_tbs_register_cb(struct bt_tbs_cb *cbs) tbs_cbs = cbs; } -#if defined(CONFIG_BT_DEBUG_TBS) +#if defined(CONFIG_BT_TBS_LOG_LEVEL_DBG) void bt_tbs_dbg_print_calls(void) { for (int i = 0; i < CONFIG_BT_TBS_BEARER_COUNT; i++) { - BT_DBG("Bearer #%u", i); + LOG_DBG("Bearer #%u", i); for (int j = 0; j < ARRAY_SIZE(svc_insts[i].calls); j++) { struct bt_tbs_call *call = &svc_insts[i].calls[j]; @@ -2460,11 +2442,11 @@ void bt_tbs_dbg_print_calls(void) continue; } - BT_DBG(" Call #%u", call->index); - BT_DBG(" State: %s", bt_tbs_state_str(call->state)); - BT_DBG(" Flags: 0x%02X", call->flags); - BT_DBG(" URI : %s", call->remote_uri); + LOG_DBG(" Call #%u", call->index); + LOG_DBG(" State: %s", bt_tbs_state_str(call->state)); + LOG_DBG(" Flags: 0x%02X", call->flags); + LOG_DBG(" URI : %s", call->remote_uri); } } } -#endif /* defined(CONFIG_BT_DEBUG_TBS) */ +#endif /* defined(CONFIG_BT_TBS_LOG_LEVEL_DBG) */ diff --git a/subsys/bluetooth/audio/tbs_client.c b/subsys/bluetooth/audio/tbs_client.c index ab49f185bbb..e3d38279aa9 100644 --- a/subsys/bluetooth/audio/tbs_client.c +++ b/subsys/bluetooth/audio/tbs_client.c @@ -21,9 +21,10 @@ #include "tbs_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_TBS_CLIENT) -#define LOG_MODULE_NAME bt_tbs_client -#include "common/log.h" +#include + +LOG_MODULE_REGISTER(bt_tbs_client, CONFIG_BT_TBS_CLIENT_LOG_LEVEL); + #include "common/bt_str.h" #define MAX_URI_SCHEME_LIST_SIZE 64 @@ -126,7 +127,7 @@ static struct bt_tbs_instance *lookup_inst_by_handle(struct bt_conn *conn, return &srv_inst->tbs_insts[i]; } } - BT_DBG("Could not find instance with handle 0x%04x", handle); + LOG_DBG("Could not find instance with handle 0x%04x", handle); return NULL; } @@ -135,7 +136,7 @@ static uint8_t net_buf_pull_call_state(struct net_buf_simple *buf, struct bt_tbs_client_call_state *call_state) { if (buf->len < sizeof(*call_state)) { - BT_DBG("Invalid buffer length %u", buf->len); + LOG_DBG("Invalid buffer length %u", buf->len); return BT_ATT_ERR_INVALID_ATTRIBUTE_LEN; } @@ -160,7 +161,7 @@ static uint8_t net_buf_pull_call(struct net_buf_simple *buf, __ASSERT(call, "NULL call"); if (buf->len < sizeof(item_len) + min_item_len) { - BT_DBG("Invalid buffer length %u", buf->len); + LOG_DBG("Invalid buffer length %u", buf->len); return BT_ATT_ERR_INVALID_ATTRIBUTE_LEN; } @@ -168,7 +169,7 @@ static uint8_t net_buf_pull_call(struct net_buf_simple *buf, uri_len = item_len - sizeof(call->call_info); if (item_len > buf->len || item_len < min_item_len) { - BT_DBG("Invalid current call item length %u", item_len); + LOG_DBG("Invalid current call item length %u", item_len); return BT_ATT_ERR_INVALID_ATTRIBUTE_LEN; } @@ -179,7 +180,7 @@ static uint8_t net_buf_pull_call(struct net_buf_simple *buf, uri = net_buf_simple_pull_mem(buf, uri_len); if (uri_len > CONFIG_BT_TBS_MAX_URI_LENGTH) { - BT_WARN("Current call (index %u) uri length larger than supported %u/%zu", + LOG_WRN("Current call (index %u) uri length larger than supported %u/%zu", call->call_info.index, uri_len, CONFIG_BT_TBS_MAX_URI_LENGTH); return BT_ATT_ERR_INSUFFICIENT_RESOURCES; } @@ -205,16 +206,16 @@ static void bearer_list_current_calls(struct bt_conn *conn, const struct bt_tbs_ err = net_buf_pull_call(buf, call); if (err == BT_ATT_ERR_INSUFFICIENT_RESOURCES) { - BT_WARN("Call with skipped due to too long URI"); + LOG_WRN("Call with skipped due to too long URI"); continue; } else if (err != 0) { - BT_DBG("Invalid current call notification: %d", err); + LOG_DBG("Invalid current call notification: %d", err); return; } cnt++; if (cnt == CONFIG_BT_TBS_CLIENT_MAX_CALLS) { - BT_WARN("Could not parse all calls due to memory restrictions"); + LOG_WRN("Could not parse all calls due to memory restrictions"); break; } } @@ -232,8 +233,8 @@ static void call_cp_callback_handler(struct bt_conn *conn, int err, { bt_tbs_client_cp_cb cp_cb = NULL; - BT_DBG("Status: %s for the %s opcode for call 0x%02x", - bt_tbs_status_str(err), bt_tbs_opcode_str(opcode), call_index); + LOG_DBG("Status: %s for the %s opcode for call 0x%02x", bt_tbs_status_str(err), + bt_tbs_opcode_str(opcode), call_index); if (tbs_client_cbs == NULL) { return; @@ -303,7 +304,7 @@ static void provider_name_notify_handler(struct bt_conn *conn, const char *name = parse_string_value(data, length, CONFIG_BT_TBS_MAX_PROVIDER_NAME_LENGTH); - BT_DBG("%s", name); + LOG_DBG("%s", name); if (tbs_client_cbs != NULL && tbs_client_cbs->bearer_provider_name != NULL) { tbs_client_cbs->bearer_provider_name(conn, 0, tbs_index(conn, tbs_inst), name); @@ -318,11 +319,11 @@ static void technology_notify_handler(struct bt_conn *conn, { uint8_t technology; - BT_DBG(""); + LOG_DBG(""); if (length == sizeof(technology)) { (void)memcpy(&technology, data, length); - BT_DBG("%s (0x%02x)", bt_tbs_technology_str(technology), technology); + LOG_DBG("%s (0x%02x)", bt_tbs_technology_str(technology), technology); if (tbs_client_cbs != NULL && tbs_client_cbs->technology != NULL) { tbs_client_cbs->technology(conn, 0, tbs_index(conn, tbs_inst), technology); @@ -338,11 +339,11 @@ static void signal_strength_notify_handler(struct bt_conn *conn, { uint8_t signal_strength; - BT_DBG(""); + LOG_DBG(""); if (length == sizeof(signal_strength)) { (void)memcpy(&signal_strength, data, length); - BT_DBG("0x%02x", signal_strength); + LOG_DBG("0x%02x", signal_strength); if (tbs_client_cbs != NULL && tbs_client_cbs->signal_strength != NULL) { tbs_client_cbs->signal_strength(conn, 0, tbs_index(conn, tbs_inst), @@ -359,7 +360,7 @@ static void current_calls_notify_handler(struct bt_conn *conn, { struct net_buf_simple buf; - BT_DBG(""); + LOG_DBG(""); net_buf_simple_init_with_data(&buf, (void *)data, length); @@ -376,11 +377,11 @@ static void status_flags_notify_handler(struct bt_conn *conn, { uint16_t status_flags; - BT_DBG(""); + LOG_DBG(""); if (length == sizeof(status_flags)) { (void)memcpy(&status_flags, data, length); - BT_DBG("0x%04x", status_flags); + LOG_DBG("0x%04x", status_flags); if (tbs_client_cbs != NULL && tbs_client_cbs->status_flags != NULL) { tbs_client_cbs->status_flags(conn, 0, tbs_index(conn, tbs_inst), status_flags); @@ -397,7 +398,7 @@ static void incoming_uri_notify_handler(struct bt_conn *conn, const char *uri = parse_string_value(data, length, CONFIG_BT_TBS_MAX_URI_LENGTH); - BT_DBG("%s", uri); + LOG_DBG("%s", uri); if (tbs_client_cbs != NULL && tbs_client_cbs->call_uri != NULL) { tbs_client_cbs->call_uri(conn, 0, tbs_index(conn, tbs_inst), uri); @@ -413,7 +414,7 @@ static void call_state_notify_handler(struct bt_conn *conn, uint8_t cnt = 0; struct net_buf_simple buf; - BT_DBG(""); + LOG_DBG(""); net_buf_simple_init_with_data(&buf, (void *)data, length); @@ -425,13 +426,13 @@ static void call_state_notify_handler(struct bt_conn *conn, err = net_buf_pull_call_state(&buf, call_state); if (err != 0) { - BT_DBG("Invalid current call notification: %d", err); + LOG_DBG("Invalid current call notification: %d", err); return; } cnt++; if (cnt == CONFIG_BT_TBS_CLIENT_MAX_CALLS) { - BT_WARN("Could not parse all calls due to memory restrictions"); + LOG_WRN("Could not parse all calls due to memory restrictions"); break; } } @@ -448,14 +449,13 @@ static void call_cp_notify_handler(struct bt_conn *conn, { struct bt_tbs_call_cp_notify *ind_val; - BT_DBG(""); + LOG_DBG(""); if (length == sizeof(*ind_val)) { ind_val = (struct bt_tbs_call_cp_notify *)data; - BT_DBG("Status: %s for the %s opcode for call 0x%02X", - bt_tbs_status_str(ind_val->status), - bt_tbs_opcode_str(ind_val->opcode), - ind_val->call_index); + LOG_DBG("Status: %s for the %s opcode for call 0x%02X", + bt_tbs_status_str(ind_val->status), bt_tbs_opcode_str(ind_val->opcode), + ind_val->call_index); call_cp_callback_handler(conn, ind_val->status, tbs_index(conn, tbs_inst), ind_val->opcode, ind_val->call_index); @@ -469,13 +469,12 @@ static void termination_reason_notify_handler(struct bt_conn *conn, { struct bt_tbs_terminate_reason reason; - BT_DBG(""); + LOG_DBG(""); if (length == sizeof(reason)) { (void)memcpy(&reason, data, length); - BT_DBG("ID 0x%02X, reason %s", - reason.call_index, - bt_tbs_term_reason_str(reason.reason)); + LOG_DBG("ID 0x%02X, reason %s", reason.call_index, + bt_tbs_term_reason_str(reason.reason)); if (tbs_client_cbs != NULL && tbs_client_cbs->termination_reason != NULL) { tbs_client_cbs->termination_reason(conn, 0, tbs_index(conn, tbs_inst), @@ -492,7 +491,7 @@ static void in_call_notify_handler(struct bt_conn *conn, const char *uri = parse_string_value(data, length, CONFIG_BT_TBS_MAX_URI_LENGTH); - BT_DBG("%s", uri); + LOG_DBG("%s", uri); if (tbs_client_cbs != NULL && tbs_client_cbs->remote_uri != NULL) { tbs_client_cbs->remote_uri(conn, 0, tbs_index(conn, tbs_inst), uri); @@ -508,7 +507,7 @@ static void friendly_name_notify_handler(struct bt_conn *conn, const char *name = parse_string_value(data, length, CONFIG_BT_TBS_MAX_URI_LENGTH); - BT_DBG("%s", name); + LOG_DBG("%s", name); if (tbs_client_cbs != NULL && tbs_client_cbs->friendly_name != NULL) { tbs_client_cbs->friendly_name(conn, 0, tbs_index(conn, tbs_inst), name); @@ -525,7 +524,7 @@ static uint8_t notify_handler(struct bt_conn *conn, struct bt_tbs_instance *tbs_inst = lookup_inst_by_handle(conn, handle); if (data == NULL) { - BT_DBG("[UNSUBSCRIBED] 0x%04X", params->value_handle); + LOG_DBG("[UNSUBSCRIBED] 0x%04X", params->value_handle); params->value_handle = 0U; if (tbs_inst != NULL) { tbs_inst->subscribe_cnt--; @@ -537,7 +536,7 @@ static uint8_t notify_handler(struct bt_conn *conn, if (tbs_inst != NULL) { uint8_t inst_index = tbs_index(conn, tbs_inst); - BT_DBG("Index %u", inst_index); + LOG_DBG("Index %u", inst_index); LOG_HEXDUMP_DBG(data, length, "notify handler value"); @@ -590,7 +589,7 @@ static uint8_t notify_handler(struct bt_conn *conn, #endif /* defined(CONFIG_BT_TBS_CLIENT_CALL_FRIENDLY_NAME) */ } } else { - BT_DBG("Notification/Indication on unknown TBS inst"); + LOG_DBG("Notification/Indication on unknown TBS inst"); } return BT_GATT_ITER_CONTINUE; @@ -611,7 +610,7 @@ static int tbs_client_common_call_control(struct bt_conn *conn, } if (inst->call_cp_sub_params.value_handle == 0) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } @@ -634,14 +633,14 @@ static uint8_t read_bearer_provider_name_cb(struct bt_conn *conn, uint8_t err, (void)memset(params, 0, sizeof(*params)); - BT_DBG("Index %u", inst_index); + LOG_DBG("Index %u", inst_index); if (err != 0) { - BT_DBG("err: 0x%02X", err); + LOG_DBG("err: 0x%02X", err); } else if (data != NULL) { provider_name = parse_string_value(data, length, CONFIG_BT_TBS_MAX_PROVIDER_NAME_LENGTH); - BT_DBG("%s", provider_name); + LOG_DBG("%s", provider_name); } inst->busy = false; @@ -665,13 +664,13 @@ static uint8_t read_bearer_uci_cb(struct bt_conn *conn, uint8_t err, (void)memset(params, 0, sizeof(*params)); - BT_DBG("Index %u", inst_index); + LOG_DBG("Index %u", inst_index); if (err != 0) { - BT_DBG("err: 0x%02X", err); + LOG_DBG("err: 0x%02X", err); } else if (data != NULL) { bearer_uci = parse_string_value(data, length, BT_TBS_MAX_UCI_SIZE); - BT_DBG("%s", bearer_uci); + LOG_DBG("%s", bearer_uci); } inst->busy = false; @@ -696,17 +695,17 @@ static uint8_t read_technology_cb(struct bt_conn *conn, uint8_t err, (void)memset(params, 0, sizeof(*params)); - BT_DBG("Index %u", inst_index); + LOG_DBG("Index %u", inst_index); if (err != 0) { - BT_DBG("err: 0x%02X", err); + LOG_DBG("err: 0x%02X", err); } else if (data != NULL) { LOG_HEXDUMP_DBG(data, length, "Data read"); if (length == sizeof(technology)) { (void)memcpy(&technology, data, length); - BT_DBG("%s (0x%02x)", bt_tbs_technology_str(technology), technology); + LOG_DBG("%s (0x%02x)", bt_tbs_technology_str(technology), technology); } else { - BT_DBG("Invalid length"); + LOG_DBG("Invalid length"); cb_err = BT_ATT_ERR_INVALID_ATTRIBUTE_LEN; } } @@ -732,14 +731,14 @@ static uint8_t read_uri_list_cb(struct bt_conn *conn, uint8_t err, (void)memset(params, 0, sizeof(*params)); - BT_DBG("Index %u", inst_index); + LOG_DBG("Index %u", inst_index); if (err != 0) { - BT_DBG("err: 0x%02X", err); + LOG_DBG("err: 0x%02X", err); } else if (data != NULL) { uri_scheme_list = parse_string_value(data, length, MAX_URI_SCHEME_LIST_SIZE); - BT_DBG("%s", uri_scheme_list); + LOG_DBG("%s", uri_scheme_list); } inst->busy = false; @@ -764,17 +763,17 @@ static uint8_t read_signal_strength_cb(struct bt_conn *conn, uint8_t err, (void)memset(params, 0, sizeof(*params)); - BT_DBG("Index %u", inst_index); + LOG_DBG("Index %u", inst_index); if (err != 0) { - BT_DBG("err: 0x%02X", err); + LOG_DBG("err: 0x%02X", err); } else if (data != NULL) { LOG_HEXDUMP_DBG(data, length, "Data read"); if (length == sizeof(signal_strength)) { (void)memcpy(&signal_strength, data, length); - BT_DBG("0x%02x", signal_strength); + LOG_DBG("0x%02x", signal_strength); } else { - BT_DBG("Invalid length"); + LOG_DBG("Invalid length"); cb_err = BT_ATT_ERR_INVALID_ATTRIBUTE_LEN; } } @@ -801,17 +800,17 @@ static uint8_t read_signal_interval_cb(struct bt_conn *conn, uint8_t err, (void)memset(params, 0, sizeof(*params)); - BT_DBG("Index %u", inst_index); + LOG_DBG("Index %u", inst_index); if (err != 0) { - BT_DBG("err: 0x%02X", err); + LOG_DBG("err: 0x%02X", err); } else if (data != NULL) { LOG_HEXDUMP_DBG(data, length, "Data read"); if (length == sizeof(signal_interval)) { (void)memcpy(&signal_interval, data, length); - BT_DBG("0x%02x", signal_interval); + LOG_DBG("0x%02x", signal_interval); } else { - BT_DBG("Invalid length"); + LOG_DBG("Invalid length"); cb_err = BT_ATT_ERR_INVALID_ATTRIBUTE_LEN; } } @@ -835,10 +834,10 @@ static uint8_t read_current_calls_cb(struct bt_conn *conn, uint8_t err, uint8_t inst_index = tbs_index(conn, inst); int tbs_err = err; - BT_DBG("Index %u", inst_index); + LOG_DBG("Index %u", inst_index); if (tbs_err != 0) { - BT_DBG("err: %d", tbs_err); + LOG_DBG("err: %d", tbs_err); (void)memset(params, 0, sizeof(*params)); if (tbs_client_cbs != NULL && tbs_client_cbs->current_calls != NULL) { @@ -849,11 +848,11 @@ static uint8_t read_current_calls_cb(struct bt_conn *conn, uint8_t err, } if (data != NULL) { - BT_DBG("Current calls read (offset %u): %s", - params->single.offset, bt_hex(data, length)); + LOG_DBG("Current calls read (offset %u): %s", params->single.offset, + bt_hex(data, length)); if (inst->net_buf.size < inst->net_buf.len + length) { - BT_DBG("Could not read all data, aborting"); + LOG_DBG("Could not read all data, aborting"); (void)memset(params, 0, sizeof(*params)); if (tbs_client_cbs != NULL && @@ -901,17 +900,17 @@ static uint8_t read_ccid_cb(struct bt_conn *conn, uint8_t err, (void)memset(params, 0, sizeof(*params)); - BT_DBG("Index %u", inst_index); + LOG_DBG("Index %u", inst_index); if (err != 0) { - BT_DBG("err: 0x%02X", err); + LOG_DBG("err: 0x%02X", err); } else if (data != NULL) { LOG_HEXDUMP_DBG(data, length, "Data read"); if (length == sizeof(ccid)) { (void)memcpy(&ccid, data, length); - BT_DBG("0x%02x", ccid); + LOG_DBG("0x%02x", ccid); } else { - BT_DBG("Invalid length"); + LOG_DBG("Invalid length"); cb_err = BT_ATT_ERR_INVALID_ATTRIBUTE_LEN; } } @@ -938,17 +937,17 @@ static uint8_t read_status_flags_cb(struct bt_conn *conn, uint8_t err, (void)memset(params, 0, sizeof(*params)); - BT_DBG("Index %u", inst_index); + LOG_DBG("Index %u", inst_index); if (err != 0) { - BT_DBG("err: 0x%02X", err); + LOG_DBG("err: 0x%02X", err); } else if (data != NULL) { LOG_HEXDUMP_DBG(data, length, "Data read"); if (length == sizeof(status_flags)) { (void)memcpy(&status_flags, data, length); - BT_DBG("0x%04x", status_flags); + LOG_DBG("0x%04x", status_flags); } else { - BT_DBG("Invalid length"); + LOG_DBG("Invalid length"); cb_err = BT_ATT_ERR_INVALID_ATTRIBUTE_LEN; } } @@ -975,13 +974,13 @@ static uint8_t read_call_uri_cb(struct bt_conn *conn, uint8_t err, (void)memset(params, 0, sizeof(*params)); - BT_DBG("Index %u", inst_index); + LOG_DBG("Index %u", inst_index); if (err != 0) { - BT_DBG("err: 0x%02X", err); + LOG_DBG("err: 0x%02X", err); } else if (data != NULL) { in_target_uri = parse_string_value(data, length, CONFIG_BT_TBS_MAX_URI_LENGTH); - BT_DBG("%s", in_target_uri); + LOG_DBG("%s", in_target_uri); } inst->busy = false; @@ -1004,10 +1003,10 @@ static uint8_t read_call_state_cb(struct bt_conn *conn, uint8_t err, struct bt_tbs_client_call_state call_states[CONFIG_BT_TBS_CLIENT_MAX_CALLS]; int tbs_err = err; - BT_DBG("Index %u", inst_index); + LOG_DBG("Index %u", inst_index); if (tbs_err != 0) { - BT_DBG("err: %d", tbs_err); + LOG_DBG("err: %d", tbs_err); (void)memset(params, 0, sizeof(*params)); if (tbs_client_cbs != NULL && tbs_client_cbs->call_state != NULL) { @@ -1018,11 +1017,11 @@ static uint8_t read_call_state_cb(struct bt_conn *conn, uint8_t err, } if (data != NULL) { - BT_DBG("Call states read (offset %u): %s", - params->single.offset, bt_hex(data, length)); + LOG_DBG("Call states read (offset %u): %s", params->single.offset, + bt_hex(data, length)); if (inst->net_buf.size < inst->net_buf.len + length) { - BT_DBG("Could not read all data, aborting"); + LOG_DBG("Could not read all data, aborting"); (void)memset(params, 0, sizeof(*params)); if (tbs_client_cbs != NULL && @@ -1056,13 +1055,13 @@ static uint8_t read_call_state_cb(struct bt_conn *conn, uint8_t err, tbs_err = net_buf_pull_call_state(&inst->net_buf, call_state); if (tbs_err != 0) { - BT_DBG("Invalid current call notification: %d", err); + LOG_DBG("Invalid current call notification: %d", err); break; } cnt++; if (cnt == CONFIG_BT_TBS_CLIENT_MAX_CALLS) { - BT_WARN("Could not parse all calls due to memory restrictions"); + LOG_WRN("Could not parse all calls due to memory restrictions"); break; } } @@ -1088,17 +1087,17 @@ static uint8_t read_optional_opcodes_cb(struct bt_conn *conn, uint8_t err, (void)memset(params, 0, sizeof(*params)); - BT_DBG("Index %u", inst_index); + LOG_DBG("Index %u", inst_index); if (err != 0) { - BT_DBG("err: 0x%02X", err); + LOG_DBG("err: 0x%02X", err); } else if (data != NULL) { LOG_HEXDUMP_DBG(data, length, "Data read"); if (length == sizeof(optional_opcodes)) { (void)memcpy(&optional_opcodes, data, length); - BT_DBG("0x%04x", optional_opcodes); + LOG_DBG("0x%04x", optional_opcodes); } else { - BT_DBG("Invalid length"); + LOG_DBG("Invalid length"); cb_err = BT_ATT_ERR_INVALID_ATTRIBUTE_LEN; } } @@ -1125,13 +1124,13 @@ static uint8_t read_remote_uri_cb(struct bt_conn *conn, uint8_t err, (void)memset(params, 0, sizeof(*params)); - BT_DBG("Index %u", inst_index); + LOG_DBG("Index %u", inst_index); if (err != 0) { - BT_DBG("err: 0x%02X", err); + LOG_DBG("err: 0x%02X", err); } else if (data != NULL) { remote_uri = parse_string_value(data, length, CONFIG_BT_TBS_MAX_URI_LENGTH); - BT_DBG("%s", remote_uri); + LOG_DBG("%s", remote_uri); } inst->busy = false; @@ -1156,13 +1155,13 @@ static uint8_t read_friendly_name_cb(struct bt_conn *conn, uint8_t err, (void)memset(params, 0, sizeof(*params)); - BT_DBG("Index %u", inst_index); + LOG_DBG("Index %u", inst_index); if (err != 0) { - BT_DBG("err: 0x%02X", err); + LOG_DBG("err: 0x%02X", err); } else if (data != NULL) { friendly_name = parse_string_value(data, length, CONFIG_BT_TBS_MAX_URI_LENGTH); - BT_DBG("%s", friendly_name); + LOG_DBG("%s", friendly_name); } inst->busy = false; @@ -1187,16 +1186,16 @@ static uint8_t disc_read_ccid_cb(struct bt_conn *conn, uint8_t err, (void)memset(params, 0, sizeof(*params)); - BT_DBG("Index %u", inst_index); + LOG_DBG("Index %u", inst_index); if (cb_err != 0) { - BT_DBG("err: 0x%02X", cb_err); + LOG_DBG("err: 0x%02X", cb_err); } else if (data != NULL) { if (length == sizeof(inst->ccid)) { inst->ccid = ((uint8_t *)data)[0]; - BT_DBG("0x%02x", inst->ccid); + LOG_DBG("0x%02x", inst->ccid); } else { - BT_DBG("Invalid length"); + LOG_DBG("Invalid length"); cb_err = BT_ATT_ERR_INVALID_ATTRIBUTE_LEN; } } @@ -1207,13 +1206,13 @@ static uint8_t disc_read_ccid_cb(struct bt_conn *conn, uint8_t err, tbs_client_cbs->discover(conn, cb_err, 0U, false); } else { if (IS_ENABLED(CONFIG_BT_TBS_CLIENT_GTBS) && inst == srv_inst->gtbs) { - BT_DBG("Setup complete GTBS"); + LOG_DBG("Setup complete GTBS"); inst_index = 0; } else { inst_index++; - BT_DBG("Setup complete for %u / %u TBS", inst_index, srv_inst->inst_cnt); + LOG_DBG("Setup complete for %u / %u TBS", inst_index, srv_inst->inst_cnt); } (void)memset(params, 0, sizeof(*params)); @@ -1281,7 +1280,7 @@ static uint8_t discover_func(struct bt_conn *conn, return BT_GATT_ITER_STOP; } - BT_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); + LOG_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); if (params->type == BT_GATT_DISCOVER_CHARACTERISTIC) { const struct bt_gatt_chrc *chrc; @@ -1290,37 +1289,37 @@ static uint8_t discover_func(struct bt_conn *conn, chrc = (struct bt_gatt_chrc *)attr->user_data; if (bt_uuid_cmp(chrc->uuid, BT_UUID_TBS_CALL_STATE) == 0) { - BT_DBG("Call state"); + LOG_DBG("Call state"); sub_params = ¤t_inst->call_state_sub_params; sub_params->value_handle = chrc->value_handle; sub_params->disc_params = ¤t_inst->call_state_sub_disc_params; #if defined(CONFIG_BT_TBS_CLIENT_BEARER_PROVIDER_NAME) } else if (bt_uuid_cmp(chrc->uuid, BT_UUID_TBS_PROVIDER_NAME) == 0) { - BT_DBG("Provider name"); + LOG_DBG("Provider name"); sub_params = ¤t_inst->name_sub_params; sub_params->value_handle = chrc->value_handle; sub_params->disc_params = ¤t_inst->name_sub_disc_params; #endif /* defined(CONFIG_BT_TBS_CLIENT_BEARER_PROVIDER_NAME) */ #if defined(CONFIG_BT_TBS_CLIENT_BEARER_UCI) } else if (bt_uuid_cmp(chrc->uuid, BT_UUID_TBS_UCI) == 0) { - BT_DBG("Bearer UCI"); + LOG_DBG("Bearer UCI"); current_inst->bearer_uci_handle = chrc->value_handle; #endif /* defined(CONFIG_BT_TBS_CLIENT_BEARER_UCI) */ #if defined(CONFIG_BT_TBS_CLIENT_BEARER_TECHNOLOGY) } else if (bt_uuid_cmp(chrc->uuid, BT_UUID_TBS_TECHNOLOGY) == 0) { - BT_DBG("Technology"); + LOG_DBG("Technology"); sub_params = ¤t_inst->technology_sub_params; sub_params->value_handle = chrc->value_handle; sub_params->disc_params = ¤t_inst->technology_sub_disc_params; #endif /* defined(CONFIG_BT_TBS_CLIENT_BEARER_TECHNOLOGY) */ #if defined(CONFIG_BT_TBS_CLIENT_BEARER_URI_SCHEMES_SUPPORTED_LIST) } else if (bt_uuid_cmp(chrc->uuid, BT_UUID_TBS_URI_LIST) == 0) { - BT_DBG("URI Scheme List"); + LOG_DBG("URI Scheme List"); current_inst->uri_list_handle = chrc->value_handle; #endif /* defined(CONFIG_BT_TBS_CLIENT_BEARER_URI_SCHEMES_SUPPORTED_LIST) */ #if defined(CONFIG_BT_TBS_CLIENT_BEARER_SIGNAL_STRENGTH) } else if (bt_uuid_cmp(chrc->uuid, BT_UUID_TBS_SIGNAL_STRENGTH) == 0) { - BT_DBG("Signal strength"); + LOG_DBG("Signal strength"); sub_params = ¤t_inst->signal_strength_sub_params; sub_params->value_handle = chrc->value_handle; sub_params->disc_params = ¤t_inst->signal_strength_sub_disc_params; @@ -1328,64 +1327,64 @@ static uint8_t discover_func(struct bt_conn *conn, #if defined(CONFIG_BT_TBS_CLIENT_READ_BEARER_SIGNAL_INTERVAL) \ || defined(CONFIG_BT_TBS_CLIENT_SET_BEARER_SIGNAL_INTERVAL) } else if (bt_uuid_cmp(chrc->uuid, BT_UUID_TBS_SIGNAL_INTERVAL) == 0) { - BT_DBG("Signal strength reporting interval"); + LOG_DBG("Signal strength reporting interval"); current_inst->signal_interval_handle = chrc->value_handle; #endif /* defined(CONFIG_BT_TBS_CLIENT_READ_BEARER_SIGNAL_INTERVAL) */ /* || defined(CONFIG_BT_TBS_CLIENT_SET_BEARER_SIGNAL_INTERVAL) */ #if defined(CONFIG_BT_TBS_CLIENT_BEARER_LIST_CURRENT_CALLS) } else if (bt_uuid_cmp(chrc->uuid, BT_UUID_TBS_LIST_CURRENT_CALLS) == 0) { - BT_DBG("Current calls"); + LOG_DBG("Current calls"); sub_params = ¤t_inst->current_calls_sub_params; sub_params->value_handle = chrc->value_handle; sub_params->disc_params = ¤t_inst->current_calls_sub_disc_params; #endif /* defined(CONFIG_BT_TBS_CLIENT_BEARER_LIST_CURRENT_CALLS) */ #if defined(CONFIG_BT_TBS_CLIENT_CCID) } else if (bt_uuid_cmp(chrc->uuid, BT_UUID_CCID) == 0) { - BT_DBG("CCID"); + LOG_DBG("CCID"); current_inst->ccid_handle = chrc->value_handle; #endif /* defined(CONFIG_BT_TBS_CLIENT_CCID) */ #if defined(CONFIG_BT_TBS_CLIENT_INCOMING_URI) } else if (bt_uuid_cmp(chrc->uuid, BT_UUID_TBS_INCOMING_URI) == 0) { - BT_DBG("Incoming target URI"); + LOG_DBG("Incoming target URI"); sub_params = ¤t_inst->in_target_uri_sub_params; sub_params->value_handle = chrc->value_handle; sub_params->disc_params = ¤t_inst->in_target_uri_sub_disc_params; #endif /* defined(CONFIG_BT_TBS_CLIENT_INCOMING_URI) */ #if defined(CONFIG_BT_TBS_CLIENT_STATUS_FLAGS) } else if (bt_uuid_cmp(chrc->uuid, BT_UUID_TBS_STATUS_FLAGS) == 0) { - BT_DBG("Status flags"); + LOG_DBG("Status flags"); sub_params = ¤t_inst->status_flags_sub_params; sub_params->value_handle = chrc->value_handle; sub_params->disc_params = ¤t_inst->status_sub_disc_params; #endif /* defined(CONFIG_BT_TBS_CLIENT_STATUS_FLAGS) */ #if defined(CONFIG_BT_TBS_CLIENT_CP_PROCEDURES) } else if (bt_uuid_cmp(chrc->uuid, BT_UUID_TBS_CALL_CONTROL_POINT) == 0) { - BT_DBG("Call control point"); + LOG_DBG("Call control point"); sub_params = ¤t_inst->call_cp_sub_params; sub_params->value_handle = chrc->value_handle; sub_params->disc_params = ¤t_inst->call_cp_sub_disc_params; #endif /* defined(CONFIG_BT_TBS_CLIENT_CP_PROCEDURES) */ #if defined(CONFIG_BT_TBS_CLIENT_OPTIONAL_OPCODES) } else if (bt_uuid_cmp(chrc->uuid, BT_UUID_TBS_OPTIONAL_OPCODES) == 0) { - BT_DBG("Supported opcodes"); + LOG_DBG("Supported opcodes"); current_inst->optional_opcodes_handle = chrc->value_handle; #endif /* defined(CONFIG_BT_TBS_CLIENT_OPTIONAL_OPCODES) */ } else if (bt_uuid_cmp(chrc->uuid, BT_UUID_TBS_TERMINATE_REASON) == 0) { - BT_DBG("Termination reason"); + LOG_DBG("Termination reason"); current_inst->termination_reason_handle = chrc->value_handle; sub_params = ¤t_inst->termination_sub_params; sub_params->value_handle = chrc->value_handle; sub_params->disc_params = ¤t_inst->termination_sub_disc_params; #if defined(CONFIG_BT_TBS_CLIENT_CALL_FRIENDLY_NAME) } else if (bt_uuid_cmp(chrc->uuid, BT_UUID_TBS_FRIENDLY_NAME) == 0) { - BT_DBG("Incoming friendly name"); + LOG_DBG("Incoming friendly name"); sub_params = ¤t_inst->friendly_name_sub_params; sub_params->value_handle = chrc->value_handle; sub_params->disc_params = ¤t_inst->friendly_name_sub_disc_params; #endif /* defined(CONFIG_BT_TBS_CLIENT_CALL_FRIENDLY_NAME) */ #if defined(CONFIG_BT_TBS_CLIENT_INCOMING_CALL) } else if (bt_uuid_cmp(chrc->uuid, BT_UUID_TBS_INCOMING_CALL) == 0) { - BT_DBG("Incoming call"); + LOG_DBG("Incoming call"); sub_params = ¤t_inst->incoming_call_sub_params; sub_params->value_handle = chrc->value_handle; sub_params->disc_params = ¤t_inst->incoming_call_sub_disc_params; @@ -1409,12 +1408,12 @@ static uint8_t discover_func(struct bt_conn *conn, sub_params->notify = notify_handler; err = bt_gatt_subscribe(conn, sub_params); if (err != 0) { - BT_DBG("Could not subscribe to " + LOG_DBG("Could not subscribe to " "characterstic at handle 0x%04X" "(%d)", sub_params->value_handle, err); } else { - BT_DBG("Subscribed to characterstic at " + LOG_DBG("Subscribed to characterstic at " "handle 0x%04X", sub_params->value_handle); } @@ -1442,7 +1441,7 @@ static void discover_next_instance(struct bt_conn *conn, uint8_t index) err = bt_gatt_discover(conn, &srv_inst->discover_params); if (err != 0) { - BT_DBG("Discover failed (err %d)", err); + LOG_DBG("Discover failed (err %d)", err); srv_inst->current_inst = NULL; if (tbs_client_cbs != NULL && tbs_client_cbs->discover != NULL) { @@ -1455,10 +1454,10 @@ static void discover_next_instance(struct bt_conn *conn, uint8_t index) static void primary_discover_complete(struct bt_tbs_server_inst *server, struct bt_conn *conn) { if (IS_ENABLED(CONFIG_BT_TBS_CLIENT_GTBS)) { - BT_DBG("Discover complete, found %u instances (GTBS%s found)", - server->inst_cnt, server->gtbs != NULL ? "" : " not"); + LOG_DBG("Discover complete, found %u instances (GTBS%s found)", server->inst_cnt, + server->gtbs != NULL ? "" : " not"); } else { - BT_DBG("Discover complete, found %u instances", server->inst_cnt); + LOG_DBG("Discover complete, found %u instances", server->inst_cnt); } if (IS_ENABLED(CONFIG_BT_TBS_CLIENT_GTBS) && server->gtbs != NULL) { @@ -1487,7 +1486,7 @@ static uint8_t primary_discover_tbs(struct bt_conn *conn, const struct bt_gatt_a if (attr != NULL) { const struct bt_gatt_service_val *prim_service; - BT_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); + LOG_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); prim_service = (struct bt_gatt_service_val *)attr->user_data; @@ -1514,7 +1513,7 @@ static uint8_t primary_discover_gtbs(struct bt_conn *conn, const struct bt_gatt_ if (attr != NULL) { const struct bt_gatt_service_val *prim_service; - BT_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); + LOG_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); prim_service = (struct bt_gatt_service_val *)attr->user_data; @@ -1538,7 +1537,7 @@ static uint8_t primary_discover_gtbs(struct bt_conn *conn, const struct bt_gatt_ return BT_GATT_ITER_STOP; } - BT_DBG("Discover failed (err %d)", err); + LOG_DBG("Discover failed (err %d)", err); } primary_discover_complete(srv_inst, conn); @@ -1597,7 +1596,7 @@ int bt_tbs_client_originate_call(struct bt_conn *conn, uint8_t inst_index, if (conn == NULL) { return -ENOTCONN; } else if (!bt_tbs_valid_uri(uri)) { - BT_DBG("Invalid URI: %s", uri); + LOG_DBG("Invalid URI: %s", uri); return -EINVAL; } @@ -1608,15 +1607,14 @@ int bt_tbs_client_originate_call(struct bt_conn *conn, uint8_t inst_index, /* Check if there are free spots */ if (!free_call_spot(inst)) { - BT_DBG("Cannot originate more calls"); + LOG_DBG("Cannot originate more calls"); return -ENOMEM; } uri_len = strlen(uri); if (uri_len > max_uri_len) { - BT_DBG("URI len (%zu) longer than maximum writable %zu", - uri_len, max_uri_len); + LOG_DBG("URI len (%zu) longer than maximum writable %zu", uri_len, max_uri_len); return -ENOMEM; } @@ -1653,13 +1651,13 @@ int bt_tbs_client_join_calls(struct bt_conn *conn, uint8_t inst_index, } if (inst->call_cp_sub_params.value_handle == 0) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } if (count > max_call_cnt) { - BT_DBG("Call count (%u) larger than maximum writable %zu", - count, max_call_cnt); + LOG_DBG("Call count (%u) larger than maximum writable %zu", count, + max_call_cnt); return -ENOMEM; } @@ -1697,7 +1695,7 @@ int bt_tbs_client_set_signal_strength_interval(struct bt_conn *conn, /* Populate Outgoing Remote URI */ if (inst->signal_interval_handle == 0) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } @@ -1725,7 +1723,7 @@ int bt_tbs_client_read_bearer_provider_name(struct bt_conn *conn, } if (inst->name_sub_params.value_handle == 0) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } @@ -1759,7 +1757,7 @@ int bt_tbs_client_read_bearer_uci(struct bt_conn *conn, uint8_t inst_index) } if (inst->bearer_uci_handle == 0) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } @@ -1793,7 +1791,7 @@ int bt_tbs_client_read_technology(struct bt_conn *conn, uint8_t inst_index) } if (inst->technology_sub_params.value_handle == 0) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } @@ -1827,7 +1825,7 @@ int bt_tbs_client_read_uri_list(struct bt_conn *conn, uint8_t inst_index) } if (inst->uri_list_handle == 0) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } @@ -1861,7 +1859,7 @@ int bt_tbs_client_read_signal_strength(struct bt_conn *conn, uint8_t inst_index) } if (inst->signal_strength_sub_params.value_handle == 0) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } @@ -1895,7 +1893,7 @@ int bt_tbs_client_read_signal_interval(struct bt_conn *conn, uint8_t inst_index) } if (inst->signal_interval_handle == 0) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } @@ -1929,7 +1927,7 @@ int bt_tbs_client_read_current_calls(struct bt_conn *conn, uint8_t inst_index) } if (inst->current_calls_sub_params.value_handle == 0) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } @@ -1963,7 +1961,7 @@ int bt_tbs_client_read_ccid(struct bt_conn *conn, uint8_t inst_index) } if (inst->ccid_handle == 0) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } @@ -1997,7 +1995,7 @@ int bt_tbs_client_read_call_uri(struct bt_conn *conn, uint8_t inst_index) } if (inst->in_target_uri_sub_params.value_handle == 0) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } @@ -2031,7 +2029,7 @@ int bt_tbs_client_read_status_flags(struct bt_conn *conn, uint8_t inst_index) } if (inst->status_flags_sub_params.value_handle == 0) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } @@ -2064,7 +2062,7 @@ int bt_tbs_client_read_call_state(struct bt_conn *conn, uint8_t inst_index) } if (inst->call_state_sub_params.value_handle == 0) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } @@ -2098,7 +2096,7 @@ int bt_tbs_client_read_optional_opcodes(struct bt_conn *conn, } if (inst->optional_opcodes_handle == 0) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } @@ -2132,7 +2130,7 @@ int bt_tbs_client_read_remote_uri(struct bt_conn *conn, uint8_t inst_index) } if (inst->incoming_call_sub_params.value_handle == 0) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } @@ -2166,7 +2164,7 @@ int bt_tbs_client_read_friendly_name(struct bt_conn *conn, uint8_t inst_index) } if (inst->friendly_name_sub_params.value_handle == 0) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } @@ -2207,7 +2205,7 @@ int bt_tbs_client_discover(struct bt_conn *conn, bool subscribe) srv_inst->subscribe_all = subscribe; (void)memset(&srv_inst->discover_params, 0, sizeof(srv_inst->discover_params)); if (IS_ENABLED(CONFIG_BT_TBS_CLIENT_GTBS)) { - BT_DBG("Discovering GTBS"); + LOG_DBG("Discovering GTBS"); srv_inst->discover_params.uuid = gtbs_uuid; srv_inst->discover_params.func = primary_discover_gtbs; } else { @@ -2233,7 +2231,7 @@ struct bt_tbs_instance *bt_tbs_client_get_by_ccid(const struct bt_conn *conn, struct bt_tbs_server_inst *server; CHECKIF(conn == NULL) { - BT_DBG("conn was NULL"); + LOG_DBG("conn was NULL"); return NULL; } diff --git a/subsys/bluetooth/audio/unicast_client.c b/subsys/bluetooth/audio/unicast_client.c index b82e49134b9..e10ff5d7cbb 100644 --- a/subsys/bluetooth/audio/unicast_client.c +++ b/subsys/bluetooth/audio/unicast_client.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include "../host/hci_core.h" @@ -26,9 +27,9 @@ #include "pacs_internal.h" #include "unicast_client_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_AUDIO_DEBUG_UNICAST_CLIENT) -#define LOG_MODULE_NAME bt_unicast_client -#include "common/log.h" +#include + +LOG_MODULE_REGISTER(bt_unicast_client, CONFIG_BT_AUDIO_UNICAST_CLIENT_LOG_LEVEL); #define PAC_DIR_UNUSED(dir) ((dir) != BT_AUDIO_DIR_SINK && (dir) != BT_AUDIO_DIR_SOURCE) @@ -85,33 +86,32 @@ static void unicast_client_ep_iso_recv(struct bt_iso_chan *chan, struct bt_audio_ep *ep = iso->rx.ep; if (ep == NULL) { - BT_ERR("iso %p not bound with ep", chan); + LOG_ERR("iso %p not bound with ep", chan); return; } if (ep->status.state != BT_AUDIO_EP_STATE_STREAMING) { - BT_DBG("ep %p is not in the streaming state: %s", + LOG_DBG("ep %p is not in the streaming state: %s", ep, bt_audio_ep_state_str(ep->status.state)); return; } stream = ep->stream; if (stream == NULL) { - BT_ERR("No stream for ep %p", ep); + LOG_ERR("No stream for ep %p", ep); return; } ops = stream->ops; if (IS_ENABLED(CONFIG_BT_AUDIO_DEBUG_STREAM_DATA)) { - BT_DBG("stream %p ep %p len %zu", - stream, ep, net_buf_frags_len(buf)); + LOG_DBG("stream %p ep %p len %zu", stream, ep, net_buf_frags_len(buf)); } if (ops != NULL && ops->recv != NULL) { ops->recv(stream, info, buf); } else { - BT_WARN("No callback for recv set"); + LOG_WRN("No callback for recv set"); } } @@ -122,18 +122,18 @@ static void unicast_client_ep_iso_sent(struct bt_iso_chan *chan) struct bt_audio_ep *ep = iso->tx.ep; if (ep == NULL) { - BT_ERR("iso %p not bound with ep", chan); + LOG_ERR("iso %p not bound with ep", chan); return; } stream = ep->stream; if (stream == NULL) { - BT_ERR("No stream for ep %p", ep); + LOG_ERR("No stream for ep %p", ep); return; } if (IS_ENABLED(CONFIG_BT_AUDIO_DEBUG_STREAM_DATA)) { - BT_DBG("stream %p ep %p", stream, ep); + LOG_DBG("stream %p ep %p", stream, ep); } if (stream->ops != NULL && stream->ops->sent != NULL) { @@ -146,18 +146,18 @@ static void unicast_client_ep_iso_connected(struct bt_audio_ep *ep) struct bt_audio_stream *stream; if (ep->status.state != BT_AUDIO_EP_STATE_ENABLING) { - BT_DBG("endpoint not in enabling state: %s", - bt_audio_ep_state_str(ep->status.state)); + LOG_DBG("endpoint not in enabling state: %s", + bt_audio_ep_state_str(ep->status.state)); return; } stream = ep->stream; if (stream == NULL) { - BT_ERR("No stream for ep %p", ep); + LOG_ERR("No stream for ep %p", ep); return; } - BT_DBG("stream %p ep %p dir %u", stream, ep, ep->dir); + LOG_DBG("stream %p ep %p dir %u", stream, ep, ep->dir); } static void unicast_client_iso_connected(struct bt_iso_chan *chan) @@ -165,7 +165,7 @@ static void unicast_client_iso_connected(struct bt_iso_chan *chan) struct bt_audio_iso *iso = CONTAINER_OF(chan, struct bt_audio_iso, chan); if (iso->rx.ep == NULL && iso->tx.ep == NULL) { - BT_ERR("iso %p not bound with ep", chan); + LOG_ERR("iso %p not bound with ep", chan); return; } @@ -185,16 +185,16 @@ static void unicast_client_ep_iso_disconnected(struct bt_audio_ep *ep, stream = ep->stream; if (stream == NULL) { - BT_ERR("Stream not associated with an ep"); + LOG_ERR("Stream not associated with an ep"); return; } - BT_DBG("stream %p ep %p reason 0x%02x", stream, ep, reason); + LOG_DBG("stream %p ep %p reason 0x%02x", stream, ep, reason); if (stream->ops != NULL && stream->ops->stopped != NULL) { stream->ops->stopped(stream); } else { - BT_WARN("No callback for stopped set"); + LOG_WRN("No callback for stopped set"); } } @@ -204,7 +204,7 @@ static void unicast_client_iso_disconnected(struct bt_iso_chan *chan, struct bt_audio_iso *iso = CONTAINER_OF(chan, struct bt_audio_iso, chan); if (iso->rx.ep == NULL && iso->tx.ep == NULL) { - BT_ERR("iso %p not bound with ep", chan); + LOG_ERR("iso %p not bound with ep", chan); return; } @@ -228,7 +228,7 @@ static void unicast_client_ep_init(struct bt_audio_ep *ep, uint16_t handle, uint8_t dir) { - BT_DBG("ep %p dir 0x%02x handle 0x%04x", ep, dir, handle); + LOG_DBG("ep %p dir 0x%02x handle 0x%04x", ep, dir, handle); (void)memset(ep, 0, sizeof(*ep)); ep->client.handle = handle; @@ -276,7 +276,7 @@ struct bt_audio_iso *bt_unicast_client_new_audio_iso(void) bt_audio_iso_init(audio_iso, &unicast_client_iso_ops); - BT_DBG("New audio_iso %p", audio_iso); + LOG_DBG("New audio_iso %p", audio_iso); return audio_iso; } @@ -345,7 +345,7 @@ static void unicast_client_ep_idle_state(struct bt_audio_ep *ep, if (ops != NULL && ops->released != NULL) { ops->released(stream); } else { - BT_WARN("No callback for released set"); + LOG_WRN("No callback for released set"); } bt_audio_stream_reset(stream); @@ -356,7 +356,7 @@ static void unicast_client_ep_qos_update(struct bt_audio_ep *ep, { struct bt_iso_chan_io_qos *iso_io_qos; - BT_DBG("ep %p dir %u audio_iso %p", ep, ep->dir, ep->iso); + LOG_DBG("ep %p dir %u audio_iso %p", ep, ep->dir, ep->iso); if (ep->dir == BT_AUDIO_DIR_SOURCE) { /* If the endpoint is a source, then we need to @@ -387,31 +387,30 @@ static void unicast_client_ep_config_state(struct bt_audio_ep *ep, void *cc; if (buf->len < sizeof(*cfg)) { - BT_ERR("Config status too short"); + LOG_ERR("Config status too short"); return; } stream = ep->stream; if (stream == NULL) { - BT_WARN("No stream active for endpoint"); + LOG_WRN("No stream active for endpoint"); return; } cfg = net_buf_simple_pull_mem(buf, sizeof(*cfg)); if (stream->codec == NULL) { - BT_ERR("Stream %p does not have a codec configured", stream); + LOG_ERR("Stream %p does not have a codec configured", stream); return; } else if (stream->codec->id != cfg->codec.id) { - BT_ERR("Codec configuration mismatched: %u, %u", - stream->codec->id, cfg->codec.id); + LOG_ERR("Codec configuration mismatched: %u, %u", stream->codec->id, cfg->codec.id); /* TODO: Release the stream? */ return; } if (buf->len < cfg->cc_len) { - BT_ERR("Malformed ASE Config status: buf->len %u < %u cc_len", - buf->len, cfg->cc_len); + LOG_ERR("Malformed ASE Config status: buf->len %u < %u cc_len", buf->len, + cfg->cc_len); return; } @@ -429,7 +428,7 @@ static void unicast_client_ep_config_state(struct bt_audio_ep *ep, pref->pref_pd_min = sys_get_le24(cfg->prefer_pd_min); pref->pref_pd_max = sys_get_le24(cfg->prefer_pd_max); - BT_DBG("dir 0x%02x unframed_supported 0x%02x phy 0x%02x rtn %u " + LOG_DBG("dir 0x%02x unframed_supported 0x%02x phy 0x%02x rtn %u " "latency %u pd_min %u pd_max %u codec 0x%02x ", ep->dir, pref->unframed_supported, pref->phy, pref->rtn, pref->latency, pref->pd_min, pref->pd_max, stream->codec->id); @@ -443,7 +442,7 @@ static void unicast_client_ep_config_state(struct bt_audio_ep *ep, if (stream->ops != NULL && stream->ops->configured != NULL) { stream->ops->configured(stream, pref); } else { - BT_WARN("No callback for configured set"); + LOG_WRN("No callback for configured set"); } } @@ -454,13 +453,13 @@ static void unicast_client_ep_qos_state(struct bt_audio_ep *ep, struct bt_audio_stream *stream; if (buf->len < sizeof(*qos)) { - BT_ERR("QoS status too short"); + LOG_ERR("QoS status too short"); return; } stream = ep->stream; if (stream == NULL) { - BT_ERR("No stream active for endpoint"); + LOG_ERR("No stream active for endpoint"); return; } @@ -481,7 +480,7 @@ static void unicast_client_ep_qos_state(struct bt_audio_ep *ep, (void)memcpy(&stream->qos->pd, sys_le24_to_cpu(qos->pd), sizeof(qos->pd)); - BT_DBG("dir 0x%02x cig 0x%02x cis 0x%02x codec 0x%02x interval %u " + LOG_DBG("dir 0x%02x cig 0x%02x cis 0x%02x codec 0x%02x interval %u " "framing 0x%02x phy 0x%02x rtn %u latency %u pd %u", ep->dir, ep->cig_id, ep->cis_id, stream->codec->id, stream->qos->interval, stream->qos->framing, @@ -515,7 +514,7 @@ static void unicast_client_ep_qos_state(struct bt_audio_ep *ep, if (stream->ops != NULL && stream->ops->qos_set != NULL) { stream->ops->qos_set(stream); } else { - BT_WARN("No callback for qos_set set"); + LOG_WRN("No callback for qos_set set"); } } @@ -528,28 +527,27 @@ static void unicast_client_ep_enabling_state(struct bt_audio_ep *ep, void *metadata; if (buf->len < sizeof(*enable)) { - BT_ERR("Enabling status too short"); + LOG_ERR("Enabling status too short"); return; } stream = ep->stream; if (stream == NULL) { - BT_ERR("No stream active for endpoint"); + LOG_ERR("No stream active for endpoint"); return; } enable = net_buf_simple_pull_mem(buf, sizeof(*enable)); if (buf->len < enable->metadata_len) { - BT_ERR("Malformed PDU: remaining len %u expected %u", - buf->len, enable->metadata_len); + LOG_ERR("Malformed PDU: remaining len %u expected %u", buf->len, + enable->metadata_len); return; } metadata = net_buf_simple_pull_mem(buf, enable->metadata_len); - BT_DBG("dir 0x%02x cig 0x%02x cis 0x%02x", - ep->dir, ep->cig_id, ep->cis_id); + LOG_DBG("dir 0x%02x cig 0x%02x cis 0x%02x", ep->dir, ep->cig_id, ep->cis_id); unicast_client_ep_set_metadata(ep, metadata, enable->metadata_len, NULL); @@ -561,14 +559,14 @@ static void unicast_client_ep_enabling_state(struct bt_audio_ep *ep, if (stream->ops != NULL && stream->ops->enabled != NULL) { stream->ops->enabled(stream); } else { - BT_WARN("No callback for enabled set"); + LOG_WRN("No callback for enabled set"); } } else { if (stream->ops != NULL && stream->ops->metadata_updated != NULL) { stream->ops->metadata_updated(stream); } else { - BT_WARN("No callback for metadata_updated set"); + LOG_WRN("No callback for metadata_updated set"); } } } @@ -581,20 +579,19 @@ static void unicast_client_ep_streaming_state(struct bt_audio_ep *ep, struct bt_audio_stream *stream; if (buf->len < sizeof(*stream_status)) { - BT_ERR("Streaming status too short"); + LOG_ERR("Streaming status too short"); return; } stream = ep->stream; if (stream == NULL) { - BT_ERR("No stream active for endpoint"); + LOG_ERR("No stream active for endpoint"); return; } stream_status = net_buf_simple_pull_mem(buf, sizeof(*stream_status)); - BT_DBG("dir 0x%02x cig 0x%02x cis 0x%02x", - ep->dir, ep->cig_id, ep->cis_id); + LOG_DBG("dir 0x%02x cig 0x%02x cis 0x%02x", ep->dir, ep->cig_id, ep->cis_id); /* Notify upper layer * @@ -604,14 +601,14 @@ static void unicast_client_ep_streaming_state(struct bt_audio_ep *ep, if (stream->ops != NULL && stream->ops->started != NULL) { stream->ops->started(stream); } else { - BT_WARN("No callback for started set"); + LOG_WRN("No callback for started set"); } } else { if (stream->ops != NULL && stream->ops->metadata_updated != NULL) { stream->ops->metadata_updated(stream); } else { - BT_WARN("No callback for metadata_updated set"); + LOG_WRN("No callback for metadata_updated set"); } } } @@ -623,26 +620,25 @@ static void unicast_client_ep_disabling_state(struct bt_audio_ep *ep, struct bt_audio_stream *stream; if (buf->len < sizeof(*disable)) { - BT_ERR("Disabling status too short"); + LOG_ERR("Disabling status too short"); return; } stream = ep->stream; if (stream == NULL) { - BT_ERR("No stream active for endpoint"); + LOG_ERR("No stream active for endpoint"); return; } disable = net_buf_simple_pull_mem(buf, sizeof(*disable)); - BT_DBG("dir 0x%02x cig 0x%02x cis 0x%02x", - ep->dir, ep->cig_id, ep->cis_id); + LOG_DBG("dir 0x%02x cig 0x%02x cis 0x%02x", ep->dir, ep->cig_id, ep->cis_id); /* Notify upper layer */ if (stream->ops != NULL && stream->ops->disabled != NULL) { stream->ops->disabled(stream); } else { - BT_WARN("No callback for disabled set"); + LOG_WRN("No callback for disabled set"); } } @@ -653,11 +649,11 @@ static void unicast_client_ep_releasing_state(struct bt_audio_ep *ep, stream = ep->stream; if (stream == NULL) { - BT_ERR("No stream active for endpoint"); + LOG_ERR("No stream active for endpoint"); return; } - BT_DBG("dir 0x%02x", ep->dir); + LOG_DBG("dir 0x%02x", ep->dir); /* The Unicast Client shall terminate any CIS established for that ASE * by following the Connected Isochronous Stream Terminate procedure @@ -684,10 +680,9 @@ static void unicast_client_ep_set_status(struct bt_audio_ep *ep, ep->status = *status; state_changed = old_state != ep->status.state; - BT_DBG("ep %p handle 0x%04x id 0x%02x dir %u state %s -> %s", ep, - ep->client.handle, status->id, ep->dir, - bt_audio_ep_state_str(old_state), - bt_audio_ep_state_str(status->state)); + LOG_DBG("ep %p handle 0x%04x id 0x%02x dir %u state %s -> %s", ep, ep->client.handle, + status->id, ep->dir, bt_audio_ep_state_str(old_state), + bt_audio_ep_state_str(status->state)); switch (status->state) { case BT_AUDIO_EP_STATE_IDLE: @@ -705,7 +700,7 @@ static void unicast_client_ep_set_status(struct bt_audio_ep *ep, case BT_AUDIO_EP_STATE_RELEASING: break; default: - BT_WARN("Invalid state transition: %s -> %s", + LOG_WRN("Invalid state transition: %s -> %s", bt_audio_ep_state_str(old_state), bt_audio_ep_state_str(ep->status.state)); return; @@ -725,7 +720,7 @@ static void unicast_client_ep_set_status(struct bt_audio_ep *ep, case BT_AUDIO_EP_STATE_DISABLING: break; default: - BT_WARN("Invalid state transition: %s -> %s", + LOG_WRN("Invalid state transition: %s -> %s", bt_audio_ep_state_str(old_state), bt_audio_ep_state_str(ep->status.state)); return; @@ -742,7 +737,7 @@ static void unicast_client_ep_set_status(struct bt_audio_ep *ep, case BT_AUDIO_EP_STATE_STREAMING: break; default: - BT_WARN("Invalid state transition: %s -> %s", + LOG_WRN("Invalid state transition: %s -> %s", bt_audio_ep_state_str(old_state), bt_audio_ep_state_str(ep->status.state)); return; @@ -759,7 +754,7 @@ static void unicast_client_ep_set_status(struct bt_audio_ep *ep, case BT_AUDIO_EP_STATE_ENABLING: break; default: - BT_WARN("Invalid state transition: %s -> %s", + LOG_WRN("Invalid state transition: %s -> %s", bt_audio_ep_state_str(old_state), bt_audio_ep_state_str(ep->status.state)); return; @@ -775,7 +770,7 @@ static void unicast_client_ep_set_status(struct bt_audio_ep *ep, case BT_AUDIO_EP_STATE_STREAMING: break; default: - BT_WARN("Invalid state transition: %s -> %s", + LOG_WRN("Invalid state transition: %s -> %s", bt_audio_ep_state_str(old_state), bt_audio_ep_state_str(ep->status.state)); return; @@ -792,16 +787,16 @@ static void unicast_client_ep_set_status(struct bt_audio_ep *ep, case BT_AUDIO_EP_STATE_STREAMING: break; default: - BT_WARN("Invalid state transition: %s -> %s", + LOG_WRN("Invalid state transition: %s -> %s", bt_audio_ep_state_str(old_state), bt_audio_ep_state_str(ep->status.state)); return; } } else { /* Sinks cannot go into the disabling state */ - BT_WARN("Invalid state transition: %s -> %s", - bt_audio_ep_state_str(old_state), - bt_audio_ep_state_str(ep->status.state)); + LOG_WRN("Invalid state transition: %s -> %s", + bt_audio_ep_state_str(old_state), + bt_audio_ep_state_str(ep->status.state)); return; } @@ -826,7 +821,7 @@ static void unicast_client_ep_set_status(struct bt_audio_ep *ep, /* fall through */ default: - BT_WARN("Invalid state transition: %s -> %s", + LOG_WRN("Invalid state transition: %s -> %s", bt_audio_ep_state_str(old_state), bt_audio_ep_state_str(ep->status.state)); return; @@ -846,8 +841,7 @@ static void unicast_client_codec_data_add(struct net_buf_simple *buf, const struct bt_data *d = &data[i].data; struct bt_ascs_codec_config *cc; - BT_DBG("#%u: %s type 0x%02x len %u", i, prefix, d->type, - d->data_len); + LOG_DBG("#%u: %s type 0x%02x len %u", i, prefix, d->type, d->data_len); LOG_HEXDUMP_DBG(d->data, d->data_len, prefix); cc = net_buf_simple_add(buf, sizeof(*cc)); @@ -864,20 +858,19 @@ static bool unicast_client_codec_config_store(struct bt_data *data, struct bt_codec_data *cdata; if (codec->data_count >= ARRAY_SIZE(codec->data)) { - BT_ERR("No slot available for Codec Config"); + LOG_ERR("No slot available for Codec Config"); return false; } cdata = &codec->data[codec->data_count]; if (data->data_len > sizeof(cdata->value)) { - BT_ERR("Not enough space for Codec Config: %u > %zu", - data->data_len, sizeof(cdata->value)); + LOG_ERR("Not enough space for Codec Config: %u > %zu", data->data_len, + sizeof(cdata->value)); return false; } - BT_DBG("#%u type 0x%02x len %u", codec->data_count, data->type, - data->data_len); + LOG_DBG("#%u type 0x%02x len %u", codec->data_count, data->type, data->data_len); cdata->data.type = data->type; cdata->data.data_len = data->data_len; @@ -904,8 +897,7 @@ static int unicast_client_ep_set_codec(struct bt_audio_ep *ep, uint8_t id, return -EINVAL; } - BT_DBG("ep %p codec id 0x%02x cid 0x%04x vid 0x%04x len %u", ep, id, - cid, vid, len); + LOG_DBG("ep %p codec id 0x%02x cid 0x%04x vid 0x%04x len %u", ep, id, cid, vid, len); if (!codec) { codec = &ep->codec; @@ -930,7 +922,7 @@ static int unicast_client_ep_set_codec(struct bt_audio_ep *ep, uint8_t id, /* Check if all entries could be parsed */ if (ad.len) { - BT_ERR("Unable to parse Codec Config: len %u", ad.len); + LOG_ERR("Unable to parse Codec Config: len %u", ad.len); goto fail; } @@ -948,20 +940,19 @@ static bool unicast_client_codec_metadata_store(struct bt_data *data, struct bt_codec_data *meta; if (codec->meta_count >= ARRAY_SIZE(codec->meta)) { - BT_ERR("No slot available for Codec Config Metadata"); + LOG_ERR("No slot available for Codec Config Metadata"); return false; } meta = &codec->meta[codec->meta_count]; if (data->data_len > sizeof(meta->value)) { - BT_ERR("Not enough space for Codec Config Metadata: %u > %zu", - data->data_len, sizeof(meta->value)); + LOG_ERR("Not enough space for Codec Config Metadata: %u > %zu", data->data_len, + sizeof(meta->value)); return false; } - BT_DBG("#%u type 0x%02x len %u", codec->meta_count, data->type, - data->data_len); + LOG_DBG("#%u type 0x%02x len %u", codec->meta_count, data->type, data->data_len); meta->data.type = data->type; meta->data.data_len = data->data_len; @@ -987,7 +978,7 @@ static int unicast_client_ep_set_metadata(struct bt_audio_ep *ep, void *data, return -EINVAL; } - BT_DBG("ep %p len %u codec %p", ep, len, codec); + LOG_DBG("ep %p len %u codec %p", ep, len, codec); if (!codec) { codec = &ep->codec; @@ -1008,7 +999,7 @@ static int unicast_client_ep_set_metadata(struct bt_audio_ep *ep, void *data, /* Check if all entries could be parsed */ if (meta.len) { - BT_ERR("Unable to parse Metadata: len %u", meta.len); + LOG_ERR("Unable to parse Metadata: len %u", meta.len); err = -EINVAL; if (meta.len > 2) { @@ -1036,10 +1027,10 @@ static uint8_t unicast_client_cp_notify(struct bt_conn *conn, struct net_buf_simple buf; - BT_DBG("conn %p len %u", conn, length); + LOG_DBG("conn %p len %u", conn, length); if (!data) { - BT_DBG("Unsubscribed"); + LOG_DBG("Unsubscribed"); params->value_handle = 0x0000; return BT_GATT_ITER_STOP; } @@ -1047,7 +1038,7 @@ static uint8_t unicast_client_cp_notify(struct bt_conn *conn, net_buf_simple_init_with_data(&buf, (void *)data, length); if (buf.len < sizeof(*rsp)) { - BT_ERR("Control Point Notification too small"); + LOG_ERR("Control Point Notification too small"); return BT_GATT_ITER_STOP; } @@ -1057,13 +1048,13 @@ static uint8_t unicast_client_cp_notify(struct bt_conn *conn, struct bt_ascs_cp_ase_rsp *ase_rsp; if (buf.len < sizeof(*ase_rsp)) { - BT_ERR("Control Point Notification too small"); + LOG_ERR("Control Point Notification too small"); return BT_GATT_ITER_STOP; } ase_rsp = net_buf_simple_pull_mem(&buf, sizeof(*ase_rsp)); - BT_DBG("op %s (0x%02x) id 0x%02x code %s (0x%02x) " + LOG_DBG("op %s (0x%02x) id 0x%02x code %s (0x%02x) " "reason %s (0x%02x)", bt_ascs_op_str(rsp->op), rsp->op, ase_rsp->id, bt_ascs_rsp_str(ase_rsp->code), ase_rsp->code, bt_ascs_reason_str(ase_rsp->reason), @@ -1082,10 +1073,10 @@ static uint8_t unicast_client_ep_notify(struct bt_conn *conn, ep = CONTAINER_OF(params, struct bt_audio_ep, subscribe); - BT_DBG("conn %p ep %p len %u", conn, ep, length); + LOG_DBG("conn %p ep %p len %u", conn, ep, length); if (!data) { - BT_DBG("Unsubscribed"); + LOG_DBG("Unsubscribed"); params->value_handle = 0x0000; return BT_GATT_ITER_STOP; } @@ -1093,7 +1084,7 @@ static uint8_t unicast_client_ep_notify(struct bt_conn *conn, net_buf_simple_init_with_data(&buf, (void *)data, length); if (buf.len < sizeof(struct bt_ascs_ase_status)) { - BT_ERR("Notification too small"); + LOG_ERR("Notification too small"); return BT_GATT_ITER_STOP; } @@ -1105,7 +1096,7 @@ static uint8_t unicast_client_ep_notify(struct bt_conn *conn, static int unicast_client_ep_subscribe(struct bt_conn *conn, struct bt_audio_ep *ep) { - BT_DBG("ep %p handle 0x%02x", ep, ep->client.handle); + LOG_DBG("ep %p handle 0x%02x", ep, ep->client.handle); if (ep->subscribe.value_handle) { return 0; @@ -1127,7 +1118,7 @@ static void unicast_client_ep_set_cp(struct bt_conn *conn, uint16_t handle) size_t i; uint8_t index; - BT_DBG("conn %p 0x%04x", conn, handle); + LOG_DBG("conn %p 0x%04x", conn, handle); index = bt_conn_index(conn); @@ -1183,7 +1174,7 @@ static int unicast_client_ep_config(struct bt_audio_ep *ep, struct bt_ascs_config *req; uint8_t cc_len; - BT_DBG("ep %p buf %p codec %p", ep, buf, codec); + LOG_DBG("ep %p buf %p codec %p", ep, buf, codec); if (!ep) { return -EINVAL; @@ -1198,13 +1189,11 @@ static int unicast_client_ep_config(struct bt_audio_ep *ep, case BT_AUDIO_EP_STATE_QOS_CONFIGURED: break; default: - BT_ERR("Invalid state: %s", - bt_audio_ep_state_str(ep->status.state)); + LOG_ERR("Invalid state: %s", bt_audio_ep_state_str(ep->status.state)); return -EINVAL; } - BT_DBG("id 0x%02x dir 0x%02x codec 0x%02x", ep->status.id, - ep->dir, codec->id); + LOG_DBG("id 0x%02x dir 0x%02x codec 0x%02x", ep->status.id, ep->dir, codec->id); req = net_buf_simple_add(buf, sizeof(*req)); req->ase = ep->status.id; @@ -1228,7 +1217,7 @@ int bt_unicast_client_ep_qos(struct bt_audio_ep *ep, struct net_buf_simple *buf, struct bt_ascs_qos *req; struct bt_conn_iso *conn_iso; - BT_DBG("ep %p buf %p qos %p", ep, buf, qos); + LOG_DBG("ep %p buf %p qos %p", ep, buf, qos); if (!ep) { return -EINVAL; @@ -1241,14 +1230,13 @@ int bt_unicast_client_ep_qos(struct bt_audio_ep *ep, struct net_buf_simple *buf, case BT_AUDIO_EP_STATE_QOS_CONFIGURED: break; default: - BT_ERR("Invalid state: %s", - bt_audio_ep_state_str(ep->status.state)); + LOG_ERR("Invalid state: %s", bt_audio_ep_state_str(ep->status.state)); return -EINVAL; } conn_iso = &ep->iso->chan.iso->iso; - BT_DBG("id 0x%02x cig 0x%02x cis 0x%02x interval %u framing 0x%02x " + LOG_DBG("id 0x%02x cig 0x%02x cis 0x%02x interval %u framing 0x%02x " "phy 0x%02x sdu %u rtn %u latency %u pd %u", ep->status.id, conn_iso->cig_id, conn_iso->cis_id, qos->interval, qos->framing, qos->phy, qos->sdu, @@ -1277,19 +1265,18 @@ static int unicast_client_ep_enable(struct bt_audio_ep *ep, { struct bt_ascs_metadata *req; - BT_DBG("ep %p buf %p metadata count %zu", ep, buf, meta_count); + LOG_DBG("ep %p buf %p metadata count %zu", ep, buf, meta_count); if (!ep) { return -EINVAL; } if (ep->status.state != BT_AUDIO_EP_STATE_QOS_CONFIGURED) { - BT_ERR("Invalid state: %s", - bt_audio_ep_state_str(ep->status.state)); + LOG_ERR("Invalid state: %s", bt_audio_ep_state_str(ep->status.state)); return -EINVAL; } - BT_DBG("id 0x%02x", ep->status.id); + LOG_DBG("id 0x%02x", ep->status.id); req = net_buf_simple_add(buf, sizeof(*req)); req->ase = ep->status.id; @@ -1308,7 +1295,7 @@ static int unicast_client_ep_metadata(struct bt_audio_ep *ep, { struct bt_ascs_metadata *req; - BT_DBG("ep %p buf %p metadata count %zu", ep, buf, meta_count); + LOG_DBG("ep %p buf %p metadata count %zu", ep, buf, meta_count); if (!ep) { return -EINVAL; @@ -1321,12 +1308,11 @@ static int unicast_client_ep_metadata(struct bt_audio_ep *ep, case BT_AUDIO_EP_STATE_STREAMING: break; default: - BT_ERR("Invalid state: %s", - bt_audio_ep_state_str(ep->status.state)); + LOG_ERR("Invalid state: %s", bt_audio_ep_state_str(ep->status.state)); return -EINVAL; } - BT_DBG("id 0x%02x", ep->status.id); + LOG_DBG("id 0x%02x", ep->status.id); req = net_buf_simple_add(buf, sizeof(*req)); req->ase = ep->status.id; @@ -1341,7 +1327,7 @@ static int unicast_client_ep_metadata(struct bt_audio_ep *ep, static int unicast_client_ep_start(struct bt_audio_ep *ep, struct net_buf_simple *buf) { - BT_DBG("ep %p buf %p", ep, buf); + LOG_DBG("ep %p buf %p", ep, buf); if (!ep) { return -EINVAL; @@ -1349,12 +1335,11 @@ static int unicast_client_ep_start(struct bt_audio_ep *ep, if (ep->status.state != BT_AUDIO_EP_STATE_ENABLING && ep->status.state != BT_AUDIO_EP_STATE_DISABLING) { - BT_ERR("Invalid state: %s", - bt_audio_ep_state_str(ep->status.state)); + LOG_ERR("Invalid state: %s", bt_audio_ep_state_str(ep->status.state)); return -EINVAL; } - BT_DBG("id 0x%02x", ep->status.id); + LOG_DBG("id 0x%02x", ep->status.id); net_buf_simple_add_u8(buf, ep->status.id); @@ -1364,7 +1349,7 @@ static int unicast_client_ep_start(struct bt_audio_ep *ep, static int unicast_client_ep_disable(struct bt_audio_ep *ep, struct net_buf_simple *buf) { - BT_DBG("ep %p buf %p", ep, buf); + LOG_DBG("ep %p buf %p", ep, buf); if (!ep) { return -EINVAL; @@ -1377,12 +1362,11 @@ static int unicast_client_ep_disable(struct bt_audio_ep *ep, case BT_AUDIO_EP_STATE_STREAMING: break; default: - BT_ERR("Invalid state: %s", - bt_audio_ep_state_str(ep->status.state)); + LOG_ERR("Invalid state: %s", bt_audio_ep_state_str(ep->status.state)); return -EINVAL; } - BT_DBG("id 0x%02x", ep->status.id); + LOG_DBG("id 0x%02x", ep->status.id); net_buf_simple_add_u8(buf, ep->status.id); @@ -1392,7 +1376,7 @@ static int unicast_client_ep_disable(struct bt_audio_ep *ep, static int unicast_client_ep_stop(struct bt_audio_ep *ep, struct net_buf_simple *buf) { - BT_DBG("ep %p buf %p", ep, buf); + LOG_DBG("ep %p buf %p", ep, buf); if (!ep) { return -EINVAL; @@ -1400,12 +1384,11 @@ static int unicast_client_ep_stop(struct bt_audio_ep *ep, /* Valid only if ASE_State field value = 0x05 (Disabling). */ if (ep->status.state != BT_AUDIO_EP_STATE_DISABLING) { - BT_ERR("Invalid state: %s", - bt_audio_ep_state_str(ep->status.state)); + LOG_ERR("Invalid state: %s", bt_audio_ep_state_str(ep->status.state)); return -EINVAL; } - BT_DBG("id 0x%02x", ep->status.id); + LOG_DBG("id 0x%02x", ep->status.id); net_buf_simple_add_u8(buf, ep->status.id); @@ -1415,7 +1398,7 @@ static int unicast_client_ep_stop(struct bt_audio_ep *ep, static int unicast_client_ep_release(struct bt_audio_ep *ep, struct net_buf_simple *buf) { - BT_DBG("ep %p buf %p", ep, buf); + LOG_DBG("ep %p buf %p", ep, buf); if (!ep) { return -EINVAL; @@ -1434,12 +1417,11 @@ static int unicast_client_ep_release(struct bt_audio_ep *ep, case BT_AUDIO_EP_STATE_DISABLING: break; default: - BT_ERR("Invalid state: %s", - bt_audio_ep_state_str(ep->status.state)); + LOG_ERR("Invalid state: %s", bt_audio_ep_state_str(ep->status.state)); return -EINVAL; } - BT_DBG("id 0x%02x", ep->status.id); + LOG_DBG("id 0x%02x", ep->status.id); net_buf_simple_add_u8(buf, ep->status.id); @@ -1449,7 +1431,7 @@ static int unicast_client_ep_release(struct bt_audio_ep *ep, int bt_unicast_client_ep_send(struct bt_conn *conn, struct bt_audio_ep *ep, struct net_buf_simple *buf) { - BT_DBG("conn %p ep %p buf %p len %u", conn, ep, buf, buf->len); + LOG_DBG("conn %p ep %p buf %p len %u", conn, ep, buf, buf->len); return bt_gatt_write_without_response(conn, ep->client.cp_handle, buf->data, buf->len, false); @@ -1457,7 +1439,7 @@ int bt_unicast_client_ep_send(struct bt_conn *conn, struct bt_audio_ep *ep, static void unicast_client_reset(struct bt_audio_ep *ep) { - BT_DBG("ep %p", ep); + LOG_DBG("ep %p", ep); bt_audio_stream_reset(ep->stream); @@ -1469,7 +1451,7 @@ static void unicast_client_ep_reset(struct bt_conn *conn) size_t i; uint8_t index; - BT_DBG("conn %p", conn); + LOG_DBG("conn %p", conn); index = bt_conn_index(conn); @@ -1521,7 +1503,7 @@ int bt_unicast_client_enable(struct bt_audio_stream *stream, struct bt_ascs_enable_op *req; int err; - BT_DBG("stream %p", stream); + LOG_DBG("stream %p", stream); buf = bt_unicast_client_ep_create_pdu(BT_ASCS_ENABLE_OP); @@ -1545,7 +1527,7 @@ int bt_unicast_client_metadata(struct bt_audio_stream *stream, struct bt_ascs_enable_op *req; int err; - BT_DBG("stream %p", stream); + LOG_DBG("stream %p", stream); buf = bt_unicast_client_ep_create_pdu(BT_ASCS_METADATA_OP); @@ -1567,7 +1549,7 @@ int bt_unicast_client_start(struct bt_audio_stream *stream) struct bt_ascs_start_op *req; int err; - BT_DBG("stream %p", stream); + LOG_DBG("stream %p", stream); buf = bt_unicast_client_ep_create_pdu(BT_ASCS_START_OP); @@ -1581,10 +1563,10 @@ int bt_unicast_client_start(struct bt_audio_stream *stream) */ err = bt_audio_stream_connect(stream); if (err && err != -EALREADY) { - BT_DBG("bt_audio_stream_connect failed: %d", err); + LOG_DBG("bt_audio_stream_connect failed: %d", err); return err; } else if (err == -EALREADY) { - BT_DBG("ISO %p already connected", bt_audio_stream_iso_chan_get(stream)); + LOG_DBG("ISO %p already connected", bt_audio_stream_iso_chan_get(stream)); } /* When initiated by the client, valid only if Direction field @@ -1610,7 +1592,7 @@ int bt_unicast_client_disable(struct bt_audio_stream *stream) struct bt_ascs_disable_op *req; int err; - BT_DBG("stream %p", stream); + LOG_DBG("stream %p", stream); buf = bt_unicast_client_ep_create_pdu(BT_ASCS_DISABLE_OP); @@ -1632,7 +1614,7 @@ int bt_unicast_client_stop(struct bt_audio_stream *stream) struct bt_ascs_start_op *req; int err; - BT_DBG("stream %p", stream); + LOG_DBG("stream %p", stream); buf = bt_unicast_client_ep_create_pdu(BT_ASCS_STOP_OP); @@ -1662,7 +1644,7 @@ int bt_unicast_client_release(struct bt_audio_stream *stream) struct bt_ascs_disable_op *req; int err, len; - BT_DBG("stream %p", stream); + LOG_DBG("stream %p", stream); if (stream->conn == NULL || stream->conn->state != BT_CONN_CONNECTED) { return -ENOTCONN; @@ -1704,7 +1686,7 @@ static uint8_t unicast_client_cp_discover_func(struct bt_conn *conn, if (!attr) { if (params->err) { - BT_ERR("Unable to find ASE Control Point"); + LOG_ERR("Unable to find ASE Control Point"); } params->func(conn, NULL, NULL, params); return BT_GATT_ITER_STOP; @@ -1712,7 +1694,7 @@ static uint8_t unicast_client_cp_discover_func(struct bt_conn *conn, chrc = attr->user_data; - BT_DBG("conn %p attr %p handle 0x%04x", conn, attr, chrc->value_handle); + LOG_DBG("conn %p attr %p handle 0x%04x", conn, attr, chrc->value_handle); params->err = 0; unicast_client_ep_set_cp(conn, chrc->value_handle); @@ -1725,7 +1707,7 @@ static uint8_t unicast_client_cp_discover_func(struct bt_conn *conn, static int unicast_client_ase_cp_discover(struct bt_conn *conn, struct bt_audio_discover_params *params) { - BT_DBG("conn %p params %p", conn, params); + LOG_DBG("conn %p params %p", conn, params); params->err = BT_ATT_ERR_ATTRIBUTE_NOT_FOUND; params->discover.uuid = cp_uuid; @@ -1747,12 +1729,12 @@ static uint8_t unicast_client_ase_read_func(struct bt_conn *conn, uint8_t err, params = CONTAINER_OF(read, struct bt_audio_discover_params, read); - BT_DBG("conn %p err 0x%02x len %u", conn, err, length); + LOG_DBG("conn %p err 0x%02x len %u", conn, err, length); if (err) { if (err == BT_ATT_ERR_ATTRIBUTE_NOT_FOUND && params->num_eps) { if (unicast_client_ase_cp_discover(conn, params) < 0) { - BT_ERR("Unable to discover ASE Control Point"); + LOG_ERR("Unable to discover ASE Control Point"); err = BT_ATT_ERR_UNLIKELY; goto fail; } @@ -1766,29 +1748,29 @@ static uint8_t unicast_client_ase_read_func(struct bt_conn *conn, uint8_t err, if (!data) { if (params->num_eps && unicast_client_ase_cp_discover(conn, params) < 0) { - BT_ERR("Unable to discover ASE Control Point"); + LOG_ERR("Unable to discover ASE Control Point"); err = BT_ATT_ERR_UNLIKELY; goto fail; } return BT_GATT_ITER_STOP; } - BT_DBG("handle 0x%04x", read->by_uuid.start_handle); + LOG_DBG("handle 0x%04x", read->by_uuid.start_handle); net_buf_simple_init_with_data(&buf, (void *)data, length); if (buf.len < sizeof(struct bt_ascs_ase_status)) { - BT_ERR("Read response too small"); + LOG_ERR("Read response too small"); goto fail; } ep = unicast_client_ep_get(conn, params->dir, read->by_uuid.start_handle); if (!ep) { - BT_WARN("No space left to parse ASE"); + LOG_WRN("No space left to parse ASE"); if (params->num_eps) { if (unicast_client_ase_cp_discover(conn, params) < 0) { - BT_ERR("Unable to discover ASE Control Point"); + LOG_ERR("Unable to discover ASE Control Point"); err = BT_ATT_ERR_UNLIKELY; goto fail; } @@ -1814,7 +1796,7 @@ fail: static int unicast_client_ase_discover(struct bt_conn *conn, struct bt_audio_discover_params *params) { - BT_DBG("conn %p params %p", conn, params); + LOG_DBG("conn %p params %p", conn, params); params->read.func = unicast_client_ase_read_func; params->read.handle_count = 0u; @@ -1845,11 +1827,10 @@ static uint8_t unicast_client_pacs_avail_ctx_read_func(struct bt_conn *conn, params = CONTAINER_OF(read, struct bt_audio_discover_params, read); - BT_DBG("conn %p err 0x%02x len %u", conn, err, length); + LOG_DBG("conn %p err 0x%02x len %u", conn, err, length); if (err || data == NULL || length != sizeof(context)) { - BT_DBG("Could not read available context: %d, %p, %u", - err, data, length); + LOG_DBG("Could not read available context: %d, %p, %u", err, data, length); params->func(conn, NULL, NULL, params); @@ -1860,7 +1841,7 @@ static uint8_t unicast_client_pacs_avail_ctx_read_func(struct bt_conn *conn, context.snk = net_buf_simple_pull_le16(&buf); context.src = net_buf_simple_pull_le16(&buf); - BT_DBG("sink context %u, source context %u", context.snk, context.src); + LOG_DBG("sink context %u, source context %u", context.snk, context.src); if (unicast_client_cbs != NULL && unicast_client_cbs->available_contexts != NULL) { @@ -1870,7 +1851,7 @@ static uint8_t unicast_client_pacs_avail_ctx_read_func(struct bt_conn *conn, /* Read ASE instances */ if (unicast_client_ase_discover(conn, params) < 0) { - BT_ERR("Unable to read ASE"); + LOG_ERR("Unable to read ASE"); params->func(conn, NULL, NULL, params); } @@ -1886,10 +1867,10 @@ static uint8_t unicast_client_pacs_avail_ctx_notify_cb(struct bt_conn *conn, struct bt_pacs_context context; struct net_buf_simple buf; - BT_DBG("conn %p len %u", conn, length); + LOG_DBG("conn %p len %u", conn, length); if (!data) { - BT_DBG("Unsubscribed"); + LOG_DBG("Unsubscribed"); params->value_handle = 0x0000; return BT_GATT_ITER_STOP; } @@ -1903,7 +1884,7 @@ static uint8_t unicast_client_pacs_avail_ctx_notify_cb(struct bt_conn *conn, net_buf_simple_init_with_data(&buf, (void *)data, length); if (buf.len != sizeof(context)) { - BT_ERR("Avail_ctx notification incorrect size: %u", length); + LOG_ERR("Avail_ctx notification incorrect size: %u", length); return BT_GATT_ITER_STOP; } @@ -1911,7 +1892,7 @@ static uint8_t unicast_client_pacs_avail_ctx_notify_cb(struct bt_conn *conn, context.snk = net_buf_simple_pull_le16(&buf); context.src = net_buf_simple_pull_le16(&buf); - BT_DBG("sink context %u, source context %u", context.snk, context.src); + LOG_DBG("sink context %u, source context %u", context.snk, context.src); if (unicast_client_cbs != NULL && unicast_client_cbs->available_contexts != NULL) { @@ -1926,7 +1907,7 @@ static int unicast_client_pacs_avail_ctx_read(struct bt_conn *conn, struct bt_audio_discover_params *params, uint16_t handle) { - BT_DBG("conn %p params %p", conn, params); + LOG_DBG("conn %p params %p", conn, params); params->read.func = unicast_client_pacs_avail_ctx_read_func; params->read.handle_count = 1U; @@ -1960,7 +1941,7 @@ static uint8_t unicast_client_pacs_avail_ctx_discover_cb(struct bt_conn *conn, chrc = attr->user_data; - BT_DBG("conn %p attr %p handle 0x%04x", conn, attr, chrc->value_handle); + LOG_DBG("conn %p attr %p handle 0x%04x", conn, attr, chrc->value_handle); if (chrc->properties & BT_GATT_CHRC_NOTIFY) { struct bt_gatt_subscribe_params *sub_params; @@ -1968,7 +1949,7 @@ static uint8_t unicast_client_pacs_avail_ctx_discover_cb(struct bt_conn *conn, sub_params = &avail_ctx_subscribe[index]; if (sub_params->value_handle == 0) { - BT_DBG("Subscribing to handle %u", chrc->value_handle); + LOG_DBG("Subscribing to handle %u", chrc->value_handle); sub_params->value_handle = chrc->value_handle; sub_params->ccc_handle = 0x0000; /* auto discover ccc */ sub_params->end_handle = BT_ATT_LAST_ATTRIBUTE_HANDLE; @@ -1978,11 +1959,11 @@ static uint8_t unicast_client_pacs_avail_ctx_discover_cb(struct bt_conn *conn, err = bt_gatt_subscribe(conn, sub_params); if (err != 0 && err != -EALREADY) { - BT_ERR("Failed to subscribe to avail_ctx: %d", err); + LOG_ERR("Failed to subscribe to avail_ctx: %d", err); } } /* else already subscribed */ } else { - BT_DBG("Invalid chrc->properties: %u", chrc->properties); + LOG_DBG("Invalid chrc->properties: %u", chrc->properties); /* If the characteristic is not subscribable we terminate the * discovery as BT_GATT_CHRC_NOTIFY is mandatory */ @@ -1994,7 +1975,7 @@ static uint8_t unicast_client_pacs_avail_ctx_discover_cb(struct bt_conn *conn, err = unicast_client_pacs_avail_ctx_read(conn, params, chrc->value_handle); if (err != 0) { - BT_DBG("Failed to read PACS avail_ctx: %d", err); + LOG_DBG("Failed to read PACS avail_ctx: %d", err); params->err = err; params->func(conn, NULL, NULL, params); @@ -2006,7 +1987,7 @@ static uint8_t unicast_client_pacs_avail_ctx_discover_cb(struct bt_conn *conn, static int unicast_client_pacs_avail_ctx_discover(struct bt_conn *conn, struct bt_audio_discover_params *params) { - BT_DBG("conn %p params %p", conn, params); + LOG_DBG("conn %p params %p", conn, params); params->discover.uuid = pacs_avail_ctx_uuid; params->discover.func = unicast_client_pacs_avail_ctx_discover_cb; @@ -2029,11 +2010,11 @@ static uint8_t unicast_client_pacs_location_read_func(struct bt_conn *conn, params = CONTAINER_OF(read, struct bt_audio_discover_params, read); - BT_DBG("conn %p err 0x%02x len %u", conn, err, length); + LOG_DBG("conn %p err 0x%02x len %u", conn, err, length); if (err || data == NULL || length != sizeof(location)) { - BT_DBG("Unable to read PACS location for dir %u: %u, %p, %u", - params->dir, err, data, length); + LOG_DBG("Unable to read PACS location for dir %u: %u, %p, %u", params->dir, err, + data, length); params->func(conn, NULL, NULL, params); @@ -2043,7 +2024,7 @@ static uint8_t unicast_client_pacs_location_read_func(struct bt_conn *conn, net_buf_simple_init_with_data(&buf, (void *)data, length); location = net_buf_simple_pull_le32(&buf); - BT_DBG("dir %u loc %X", params->dir, location); + LOG_DBG("dir %u loc %X", params->dir, location); if (unicast_client_cbs != NULL && unicast_client_cbs->location != NULL) { unicast_client_cbs->location(conn, params->dir, @@ -2052,7 +2033,7 @@ static uint8_t unicast_client_pacs_location_read_func(struct bt_conn *conn, /* Read available contexts */ if (unicast_client_pacs_avail_ctx_discover(conn, params) < 0) { - BT_ERR("Unable to read available contexts"); + LOG_ERR("Unable to read available contexts"); params->func(conn, NULL, NULL, params); } @@ -2069,10 +2050,10 @@ static uint8_t unicast_client_pacs_location_notify_cb(struct bt_conn *conn, enum bt_audio_dir dir; uint32_t location; - BT_DBG("conn %p len %u", conn, length); + LOG_DBG("conn %p len %u", conn, length); if (!data) { - BT_DBG("Unsubscribed"); + LOG_DBG("Unsubscribed"); params->value_handle = 0x0000; return BT_GATT_ITER_STOP; } @@ -2085,7 +2066,7 @@ static uint8_t unicast_client_pacs_location_notify_cb(struct bt_conn *conn, net_buf_simple_init_with_data(&buf, (void *)data, length); if (buf.len != sizeof(location)) { - BT_ERR("Location notification incorrect size: %u", length); + LOG_ERR("Location notification incorrect size: %u", length); return BT_GATT_ITER_STOP; } @@ -2094,7 +2075,7 @@ static uint8_t unicast_client_pacs_location_notify_cb(struct bt_conn *conn, } else if (PART_OF_ARRAY(src_loc_subscribe, params)) { dir = BT_AUDIO_DIR_SOURCE; } else { - BT_ERR("Invalid notification"); + LOG_ERR("Invalid notification"); return BT_GATT_ITER_CONTINUE; } @@ -2102,7 +2083,7 @@ static uint8_t unicast_client_pacs_location_notify_cb(struct bt_conn *conn, net_buf_simple_init_with_data(&buf, (void *)data, length); location = net_buf_simple_pull_le32(&buf); - BT_DBG("dir %u loc %X", dir, location); + LOG_DBG("dir %u loc %X", dir, location); if (unicast_client_cbs != NULL && unicast_client_cbs->location != NULL) { unicast_client_cbs->location(conn, dir, @@ -2116,7 +2097,7 @@ static int unicast_client_pacs_location_read(struct bt_conn *conn, struct bt_audio_discover_params *params, uint16_t handle) { - BT_DBG("conn %p params %p", conn, params); + LOG_DBG("conn %p params %p", conn, params); params->read.func = unicast_client_pacs_location_read_func; params->read.handle_count = 1U; @@ -2143,7 +2124,7 @@ static uint8_t unicast_client_pacs_location_discover_cb(struct bt_conn *conn, * available contexts, as location is optional. */ if (unicast_client_pacs_avail_ctx_discover(conn, params) < 0) { - BT_ERR("Unable to read available contexts"); + LOG_ERR("Unable to read available contexts"); params->func(conn, NULL, NULL, params); } @@ -2153,7 +2134,7 @@ static uint8_t unicast_client_pacs_location_discover_cb(struct bt_conn *conn, chrc = attr->user_data; - BT_DBG("conn %p attr %p handle 0x%04x", conn, attr, chrc->value_handle); + LOG_DBG("conn %p attr %p handle 0x%04x", conn, attr, chrc->value_handle); if (chrc->properties & BT_GATT_CHRC_NOTIFY) { struct bt_gatt_subscribe_params *sub_params; @@ -2173,13 +2154,13 @@ static uint8_t unicast_client_pacs_location_discover_cb(struct bt_conn *conn, err = bt_gatt_subscribe(conn, sub_params); if (err != 0 && err != -EALREADY) { - BT_ERR("Failed to subscribe to location: %d", err); + LOG_ERR("Failed to subscribe to location: %d", err); } } err = unicast_client_pacs_location_read(conn, params, chrc->value_handle); if (err != 0) { - BT_DBG("Failed to read PACS location: %d", err); + LOG_DBG("Failed to read PACS location: %d", err); params->err = err; params->func(conn, NULL, NULL, params); @@ -2191,7 +2172,7 @@ static uint8_t unicast_client_pacs_location_discover_cb(struct bt_conn *conn, static int unicast_client_pacs_location_discover(struct bt_conn *conn, struct bt_audio_discover_params *params) { - BT_DBG("conn %p params %p", conn, params); + LOG_DBG("conn %p params %p", conn, params); if (params->dir == BT_AUDIO_DIR_SINK) { params->discover.uuid = pacs_snk_loc_uuid; @@ -2222,7 +2203,7 @@ static uint8_t unicast_client_pacs_context_read_func(struct bt_conn *conn, params = CONTAINER_OF(read, struct bt_audio_discover_params, read); - BT_DBG("conn %p err 0x%02x len %u", conn, err, length); + LOG_DBG("conn %p err 0x%02x len %u", conn, err, length); if (err || length < sizeof(uint16_t) * 2) { goto discover_loc; @@ -2248,17 +2229,16 @@ static uint8_t unicast_client_pacs_context_read_func(struct bt_conn *conn, pac->context = sys_le16_to_cpu(context->src); break; default: - BT_WARN("Cached pac with invalid dir: %u", - pac->dir); + LOG_WRN("Cached pac with invalid dir: %u", pac->dir); } - BT_DBG("pac %p context 0x%04x", pac, pac->context); + LOG_DBG("pac %p context 0x%04x", pac, pac->context); } discover_loc: /* Read ASE instances */ if (unicast_client_pacs_location_discover(conn, params) < 0) { - BT_ERR("Unable to read PACS location"); + LOG_ERR("Unable to read PACS location"); params->func(conn, NULL, NULL, params); } @@ -2269,7 +2249,7 @@ discover_loc: static int unicast_client_pacs_context_discover(struct bt_conn *conn, struct bt_audio_discover_params *params) { - BT_DBG("conn %p params %p", conn, params); + LOG_DBG("conn %p params %p", conn, params); params->read.func = unicast_client_pacs_context_read_func; params->read.handle_count = 0u; @@ -2309,19 +2289,19 @@ static uint8_t unicast_client_read_func(struct bt_conn *conn, uint8_t err, params = CONTAINER_OF(read, struct bt_audio_discover_params, read); - BT_DBG("conn %p err 0x%02x len %u", conn, err, length); + LOG_DBG("conn %p err 0x%02x len %u", conn, err, length); if (err || !data) { params->err = err; goto fail; } - BT_DBG("handle 0x%04x", read->by_uuid.start_handle); + LOG_DBG("handle 0x%04x", read->by_uuid.start_handle); net_buf_simple_init_with_data(&buf, (void *)data, length); if (buf.len < sizeof(*rsp)) { - BT_ERR("Read response too small"); + LOG_ERR("Read response too small"); goto fail; } @@ -2338,41 +2318,39 @@ static uint8_t unicast_client_read_func(struct bt_conn *conn, uint8_t err, struct bt_pac_ltv_data *meta, *cc; void *cc_ltv, *meta_ltv; - BT_DBG("pac #%u", params->num_caps); + LOG_DBG("pac #%u", params->num_caps); if (buf.len < sizeof(*pac_codec)) { - BT_ERR("Malformed PAC: remaining len %u expected %zu", - buf.len, sizeof(*pac_codec)); + LOG_ERR("Malformed PAC: remaining len %u expected %zu", buf.len, + sizeof(*pac_codec)); break; } pac_codec = net_buf_simple_pull_mem(&buf, sizeof(*pac_codec)); if (buf.len < sizeof(*cc)) { - BT_ERR("Malformed PAC: remaining len %u expected %zu", - buf.len, sizeof(*cc)); + LOG_ERR("Malformed PAC: remaining len %u expected %zu", buf.len, + sizeof(*cc)); break; } cc = net_buf_simple_pull_mem(&buf, sizeof(*cc)); if (buf.len < cc->len) { - BT_ERR("Malformed PAC: remaining len %u expected %zu", - buf.len, cc->len); + LOG_ERR("Malformed PAC: remaining len %u expected %zu", buf.len, cc->len); break; } cc_ltv = net_buf_simple_pull_mem(&buf, cc->len); if (buf.len < sizeof(*meta)) { - BT_ERR("Malformed PAC: remaining len %u expected %zu", - buf.len, sizeof(*meta)); + LOG_ERR("Malformed PAC: remaining len %u expected %zu", buf.len, + sizeof(*meta)); break; } meta = net_buf_simple_pull_mem(&buf, sizeof(*meta)); if (buf.len < meta->len) { - BT_ERR("Malformed PAC: remaining len %u expected %u", - buf.len, meta->len); + LOG_ERR("Malformed PAC: remaining len %u expected %u", buf.len, meta->len); break; } @@ -2380,7 +2358,7 @@ static uint8_t unicast_client_read_func(struct bt_conn *conn, uint8_t err, bpac = unicast_client_pac_alloc(conn, params->dir); if (!bpac) { - BT_WARN("No space left to parse PAC"); + LOG_WRN("No space left to parse PAC"); break; } @@ -2389,18 +2367,17 @@ static uint8_t unicast_client_read_func(struct bt_conn *conn, uint8_t err, sys_le16_to_cpu(pac_codec->vid), cc_ltv, cc->len, &bpac->codec)) { - BT_ERR("Unable to parse Codec"); + LOG_ERR("Unable to parse Codec"); break; } if (unicast_client_ep_set_metadata(NULL, meta_ltv, meta->len, &bpac->codec)) { - BT_ERR("Unable to parse Codec Metadata"); + LOG_ERR("Unable to parse Codec Metadata"); break; } - BT_DBG("codec 0x%02x config count %u meta count %u ", - bpac->codec.id, bpac->codec.data_count, - bpac->codec.meta_count); + LOG_DBG("pac %p codec 0x%02x config count %u meta count %u ", bpac, bpac->codec.id, + bpac->codec.data_count, bpac->codec.meta_count); params->func(conn, &bpac->codec, NULL, params); @@ -2414,7 +2391,7 @@ static uint8_t unicast_client_read_func(struct bt_conn *conn, uint8_t err, /* Read PACS contexts */ if (unicast_client_pacs_context_discover(conn, params) < 0) { - BT_ERR("Unable to read PACS context"); + LOG_ERR("Unable to read PACS context"); goto fail; } @@ -2442,7 +2419,7 @@ static void unicast_client_pac_reset(struct bt_conn *conn, static void unicast_client_disconnected(struct bt_conn *conn, uint8_t reason) { - BT_DBG("conn %p reason 0x%02x", conn, reason); + LOG_DBG("conn %p reason 0x%02x", conn, reason); unicast_client_ep_reset(conn); unicast_client_pac_reset(conn, BT_AUDIO_DIR_SINK); @@ -2465,7 +2442,7 @@ int bt_audio_discover(struct bt_conn *conn, role = conn->role; if (role != BT_HCI_ROLE_CENTRAL) { - BT_DBG("Invalid conn role: %u, shall be central", role); + LOG_DBG("Invalid conn role: %u, shall be central", role); return -EINVAL; } @@ -2506,12 +2483,12 @@ int bt_audio_discover(struct bt_conn *conn, int bt_audio_unicast_client_register_cb(const struct bt_audio_unicast_client_cb *cbs) { CHECKIF(cbs == NULL) { - BT_DBG("cbs is NULL"); + LOG_DBG("cbs is NULL"); return -EINVAL; } if (unicast_client_cbs != NULL) { - BT_DBG("Callbacks already registered"); + LOG_DBG("Callbacks already registered"); return -EALREADY; } diff --git a/subsys/bluetooth/audio/unicast_server.c b/subsys/bluetooth/audio/unicast_server.c index ee01b989eae..f31efa9b7a3 100644 --- a/subsys/bluetooth/audio/unicast_server.c +++ b/subsys/bluetooth/audio/unicast_server.c @@ -13,21 +13,21 @@ #include "pacs_internal.h" #include "endpoint.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_AUDIO_DEBUG_UNICAST_SERVER) -#define LOG_MODULE_NAME bt_unicast_server -#include "common/log.h" +#include + +LOG_MODULE_REGISTER(bt_unicast_server, CONFIG_BT_AUDIO_UNICAST_SERVER_LOG_LEVEL); const struct bt_audio_unicast_server_cb *unicast_server_cb; int bt_audio_unicast_server_register_cb(const struct bt_audio_unicast_server_cb *cb) { CHECKIF(cb == NULL) { - BT_DBG("cb is NULL"); + LOG_DBG("cb is NULL"); return -EINVAL; } if (unicast_server_cb != NULL) { - BT_DBG("callback structure already registered"); + LOG_DBG("callback structure already registered"); return -EALREADY; } @@ -39,12 +39,12 @@ int bt_audio_unicast_server_register_cb(const struct bt_audio_unicast_server_cb int bt_audio_unicast_server_unregister_cb(const struct bt_audio_unicast_server_cb *cb) { CHECKIF(cb == NULL) { - BT_DBG("cb is NULL"); + LOG_DBG("cb is NULL"); return -EINVAL; } if (unicast_server_cb != cb) { - BT_DBG("callback structure not registered"); + LOG_DBG("callback structure not registered"); return -EINVAL; } diff --git a/subsys/bluetooth/audio/vcs.c b/subsys/bluetooth/audio/vcs.c index dcd5863b701..9e532647541 100644 --- a/subsys/bluetooth/audio/vcs.c +++ b/subsys/bluetooth/audio/vcs.c @@ -8,6 +8,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include + #include #include #include @@ -23,9 +25,9 @@ #include "audio_internal.h" #include "vcs_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_VCS) -#define LOG_MODULE_NAME bt_vcs -#include "common/log.h" +#define LOG_LEVEL CONFIG_BT_VCS_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_vcs); static bool valid_vocs_inst(struct bt_vcs *vcs, struct bt_vocs *vocs) { @@ -75,16 +77,15 @@ static struct bt_vcs vcs_inst; static void volume_state_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("value 0x%04x", value); + LOG_DBG("value 0x%04x", value); } static ssize_t read_vol_state(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset) { - BT_DBG("Volume %u, mute %u, counter %u", - vcs_inst.srv.state.volume, vcs_inst.srv.state.mute, - vcs_inst.srv.state.change_counter); + LOG_DBG("Volume %u, mute %u, counter %u", vcs_inst.srv.state.volume, + vcs_inst.srv.state.mute, vcs_inst.srv.state.change_counter); return bt_gatt_attr_read(conn, attr, buf, len, offset, &vcs_inst.srv.state, sizeof(vcs_inst.srv.state)); @@ -110,7 +111,7 @@ static ssize_t write_vcs_control(struct bt_conn *conn, /* Check opcode before length */ if (!VALID_VCS_OPCODE(cp_val->cp.opcode)) { - BT_DBG("Invalid opcode %u", cp_val->cp.opcode); + LOG_DBG("Invalid opcode %u", cp_val->cp.opcode); return BT_GATT_ERR(BT_VCS_ERR_OP_NOT_SUPPORTED); } @@ -123,7 +124,7 @@ static ssize_t write_vcs_control(struct bt_conn *conn, opcode = cp_val->cp.opcode; - BT_DBG("Opcode %u, counter %u", opcode, cp_val->cp.counter); + LOG_DBG("Opcode %u, counter %u", opcode, cp_val->cp.counter); if (cp_val->cp.counter != vcs_inst.srv.state.change_counter) { return BT_GATT_ERR(BT_VCS_ERR_INVALID_COUNTER); @@ -131,7 +132,7 @@ static ssize_t write_vcs_control(struct bt_conn *conn, switch (opcode) { case BT_VCS_OPCODE_REL_VOL_DOWN: - BT_DBG("Relative Volume Down (0x%x)", opcode); + LOG_DBG("Relative Volume Down (0x%x)", opcode); if (vcs_inst.srv.state.volume > 0) { vcs_inst.srv.state.volume = VOLUME_DOWN(vcs_inst.srv.state.volume); notify = true; @@ -139,7 +140,7 @@ static ssize_t write_vcs_control(struct bt_conn *conn, volume_change = true; break; case BT_VCS_OPCODE_REL_VOL_UP: - BT_DBG("Relative Volume Up (0x%x)", opcode); + LOG_DBG("Relative Volume Up (0x%x)", opcode); if (vcs_inst.srv.state.volume != UINT8_MAX) { vcs_inst.srv.state.volume = VOLUME_UP(vcs_inst.srv.state.volume); notify = true; @@ -147,7 +148,7 @@ static ssize_t write_vcs_control(struct bt_conn *conn, volume_change = true; break; case BT_VCS_OPCODE_UNMUTE_REL_VOL_DOWN: - BT_DBG("(Unmute) relative Volume Down (0x%x)", opcode); + LOG_DBG("(Unmute) relative Volume Down (0x%x)", opcode); if (vcs_inst.srv.state.volume > 0) { vcs_inst.srv.state.volume = VOLUME_DOWN(vcs_inst.srv.state.volume); notify = true; @@ -159,7 +160,7 @@ static ssize_t write_vcs_control(struct bt_conn *conn, volume_change = true; break; case BT_VCS_OPCODE_UNMUTE_REL_VOL_UP: - BT_DBG("(Unmute) relative Volume Up (0x%x)", opcode); + LOG_DBG("(Unmute) relative Volume Up (0x%x)", opcode); if (vcs_inst.srv.state.volume != UINT8_MAX) { vcs_inst.srv.state.volume = VOLUME_UP(vcs_inst.srv.state.volume); notify = true; @@ -171,7 +172,7 @@ static ssize_t write_vcs_control(struct bt_conn *conn, volume_change = true; break; case BT_VCS_OPCODE_SET_ABS_VOL: - BT_DBG("Set Absolute Volume (0x%x): Current volume %u", + LOG_DBG("Set Absolute Volume (0x%x): Current volume %u", opcode, vcs_inst.srv.state.volume); if (vcs_inst.srv.state.volume != cp_val->volume) { vcs_inst.srv.state.volume = cp_val->volume; @@ -180,29 +181,28 @@ static ssize_t write_vcs_control(struct bt_conn *conn, volume_change = true; break; case BT_VCS_OPCODE_UNMUTE: - BT_DBG("Unmute (0x%x)", opcode); + LOG_DBG("Unmute (0x%x)", opcode); if (vcs_inst.srv.state.mute) { vcs_inst.srv.state.mute = BT_VCS_STATE_UNMUTED; notify = true; } break; case BT_VCS_OPCODE_MUTE: - BT_DBG("Mute (0x%x)", opcode); + LOG_DBG("Mute (0x%x)", opcode); if (vcs_inst.srv.state.mute == BT_VCS_STATE_UNMUTED) { vcs_inst.srv.state.mute = BT_VCS_STATE_MUTED; notify = true; } break; default: - BT_DBG("Unknown opcode (0x%x)", opcode); + LOG_DBG("Unknown opcode (0x%x)", opcode); return BT_GATT_ERR(BT_VCS_ERR_OP_NOT_SUPPORTED); } if (notify) { vcs_inst.srv.state.change_counter++; - BT_DBG("New state: volume %u, mute %u, counter %u", - vcs_inst.srv.state.volume, vcs_inst.srv.state.mute, - vcs_inst.srv.state.change_counter); + LOG_DBG("New state: volume %u, mute %u, counter %u", vcs_inst.srv.state.volume, + vcs_inst.srv.state.mute, vcs_inst.srv.state.change_counter); bt_gatt_notify_uuid(NULL, BT_UUID_VCS_STATE, vcs_inst.srv.service_p->attrs, @@ -231,13 +231,13 @@ static ssize_t write_vcs_control(struct bt_conn *conn, static void flags_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("value 0x%04x", value); + LOG_DBG("value 0x%04x", value); } static ssize_t read_flags(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset) { - BT_DBG("0x%02x", vcs_inst.srv.flags); + LOG_DBG("0x%02x", vcs_inst.srv.flags); return bt_gatt_attr_read(conn, attr, buf, len, offset, &vcs_inst.srv.flags, sizeof(vcs_inst.srv.flags)); } @@ -283,16 +283,14 @@ static int prepare_vocs_inst(struct bt_vcs_register_param *param) vcs_inst.srv.vocs_insts[j] = bt_vocs_free_instance_get(); if (vcs_inst.srv.vocs_insts[j] == NULL) { - BT_ERR("Could not get free VOCS instances[%d]", - j); + LOG_ERR("Could not get free VOCS instances[%d]", j); return -ENOMEM; } err = bt_vocs_register(vcs_inst.srv.vocs_insts[j], ¶m->vocs_param[j]); if (err != 0) { - BT_DBG("Could not register VOCS instance[%d]: %d", - j, err); + LOG_DBG("Could not register VOCS instance[%d]: %d", j, err); return err; } @@ -325,23 +323,21 @@ static int prepare_aics_inst(struct bt_vcs_register_param *param) vcs_inst.srv.aics_insts[j] = bt_aics_free_instance_get(); if (vcs_inst.srv.aics_insts[j] == NULL) { - BT_ERR("Could not get free AICS instances[%d]", - j); + LOG_ERR("Could not get free AICS instances[%d]", j); return -ENOMEM; } err = bt_aics_register(vcs_inst.srv.aics_insts[j], ¶m->aics_param[j]); if (err != 0) { - BT_DBG("Could not register AICS instance[%d]: %d", - j, err); + LOG_DBG("Could not register AICS instance[%d]: %d", j, err); return err; } vcs_attrs[i].user_data = bt_aics_svc_decl_get(vcs_inst.srv.aics_insts[j]); j++; - BT_DBG("AICS P %p", vcs_attrs[i].user_data); + LOG_DBG("AICS P %p", vcs_attrs[i].user_data); if (j == CONFIG_BT_VCS_AICS_INSTANCE_COUNT) { break; @@ -362,17 +358,17 @@ int bt_vcs_register(struct bt_vcs_register_param *param, struct bt_vcs **vcs) int err; CHECKIF(param == NULL) { - BT_DBG("param is NULL"); + LOG_DBG("param is NULL"); return -EINVAL; } CHECKIF(param->mute > BT_VCS_STATE_MUTED) { - BT_DBG("Invalid mute value: %u", param->mute); + LOG_DBG("Invalid mute value: %u", param->mute); return -EINVAL; } CHECKIF(param->step == 0) { - BT_DBG("Invalid step value: %u", param->step); + LOG_DBG("Invalid step value: %u", param->step); return -EINVAL; } @@ -407,7 +403,7 @@ int bt_vcs_register(struct bt_vcs_register_param *param, struct bt_vcs **vcs) err = bt_gatt_service_register(&vcs_svc); if (err != 0) { - BT_DBG("VCS service register failed: %d", err); + LOG_DBG("VCS service register failed: %d", err); } vcs_inst.srv.cb = param->cb; @@ -421,12 +417,12 @@ int bt_vcs_register(struct bt_vcs_register_param *param, struct bt_vcs **vcs) int bt_vcs_aics_deactivate(struct bt_vcs *vcs, struct bt_aics *inst) { CHECKIF(vcs == NULL) { - BT_DBG("NULL vcs instance"); + LOG_DBG("NULL vcs instance"); return -EINVAL; } CHECKIF(inst == NULL) { - BT_DBG("NULL aics instance"); + LOG_DBG("NULL aics instance"); return -EINVAL; } @@ -440,12 +436,12 @@ int bt_vcs_aics_deactivate(struct bt_vcs *vcs, struct bt_aics *inst) int bt_vcs_aics_activate(struct bt_vcs *vcs, struct bt_aics *inst) { CHECKIF(vcs == NULL) { - BT_DBG("NULL vcs instance"); + LOG_DBG("NULL vcs instance"); return -EINVAL; } CHECKIF(inst == NULL) { - BT_DBG("NULL aics instance"); + LOG_DBG("NULL aics instance"); return -EINVAL; } @@ -461,7 +457,7 @@ int bt_vcs_aics_activate(struct bt_vcs *vcs, struct bt_aics *inst) int bt_vcs_included_get(struct bt_vcs *vcs, struct bt_vcs_included *included) { CHECKIF(vcs == NULL) { - BT_DBG("NULL vcs instance"); + LOG_DBG("NULL vcs instance"); return -EINVAL; } @@ -504,7 +500,7 @@ int bt_vcs_vol_step_set(uint8_t volume_step) int bt_vcs_vol_get(struct bt_vcs *vcs) { CHECKIF(vcs == NULL) { - BT_DBG("NULL vcs instance"); + LOG_DBG("NULL vcs instance"); return -EINVAL; } @@ -527,7 +523,7 @@ int bt_vcs_vol_get(struct bt_vcs *vcs) int bt_vcs_flags_get(struct bt_vcs *vcs) { CHECKIF(vcs == NULL) { - BT_DBG("NULL vcs instance"); + LOG_DBG("NULL vcs instance"); return -EINVAL; } @@ -549,7 +545,7 @@ int bt_vcs_flags_get(struct bt_vcs *vcs) int bt_vcs_vol_down(struct bt_vcs *vcs) { CHECKIF(vcs == NULL) { - BT_DBG("NULL vcs instance"); + LOG_DBG("NULL vcs instance"); return -EINVAL; } @@ -573,7 +569,7 @@ int bt_vcs_vol_down(struct bt_vcs *vcs) int bt_vcs_vol_up(struct bt_vcs *vcs) { CHECKIF(vcs == NULL) { - BT_DBG("NULL vcs instance"); + LOG_DBG("NULL vcs instance"); return -EINVAL; } @@ -597,7 +593,7 @@ int bt_vcs_vol_up(struct bt_vcs *vcs) int bt_vcs_unmute_vol_down(struct bt_vcs *vcs) { CHECKIF(vcs == NULL) { - BT_DBG("NULL vcs instance"); + LOG_DBG("NULL vcs instance"); return -EINVAL; } @@ -621,7 +617,7 @@ int bt_vcs_unmute_vol_down(struct bt_vcs *vcs) int bt_vcs_unmute_vol_up(struct bt_vcs *vcs) { CHECKIF(vcs == NULL) { - BT_DBG("NULL vcs instance"); + LOG_DBG("NULL vcs instance"); return -EINVAL; } @@ -645,7 +641,7 @@ int bt_vcs_unmute_vol_up(struct bt_vcs *vcs) int bt_vcs_vol_set(struct bt_vcs *vcs, uint8_t volume) { CHECKIF(vcs == NULL) { - BT_DBG("NULL vcs instance"); + LOG_DBG("NULL vcs instance"); return -EINVAL; } @@ -672,7 +668,7 @@ int bt_vcs_vol_set(struct bt_vcs *vcs, uint8_t volume) int bt_vcs_unmute(struct bt_vcs *vcs) { CHECKIF(vcs == NULL) { - BT_DBG("NULL vcs instance"); + LOG_DBG("NULL vcs instance"); return -EINVAL; } @@ -696,7 +692,7 @@ int bt_vcs_unmute(struct bt_vcs *vcs) int bt_vcs_mute(struct bt_vcs *vcs) { CHECKIF(vcs == NULL) { - BT_DBG("NULL vcs instance"); + LOG_DBG("NULL vcs instance"); return -EINVAL; } @@ -720,7 +716,7 @@ int bt_vcs_mute(struct bt_vcs *vcs) int bt_vcs_vocs_state_get(struct bt_vcs *vcs, struct bt_vocs *inst) { CHECKIF(vcs == NULL) { - BT_DBG("NULL vcs instance"); + LOG_DBG("NULL vcs instance"); return -EINVAL; } @@ -739,7 +735,7 @@ int bt_vcs_vocs_state_get(struct bt_vcs *vcs, struct bt_vocs *inst) int bt_vcs_vocs_location_get(struct bt_vcs *vcs, struct bt_vocs *inst) { CHECKIF(vcs == NULL) { - BT_DBG("NULL vcs instance"); + LOG_DBG("NULL vcs instance"); return -EINVAL; } @@ -759,7 +755,7 @@ int bt_vcs_vocs_location_set(struct bt_vcs *vcs, struct bt_vocs *inst, uint8_t location) { CHECKIF(vcs == NULL) { - BT_DBG("NULL vcs instance"); + LOG_DBG("NULL vcs instance"); return -EINVAL; } @@ -779,7 +775,7 @@ int bt_vcs_vocs_state_set(struct bt_vcs *vcs, struct bt_vocs *inst, int16_t offset) { CHECKIF(vcs == NULL) { - BT_DBG("NULL vcs instance"); + LOG_DBG("NULL vcs instance"); return -EINVAL; } @@ -798,7 +794,7 @@ int bt_vcs_vocs_state_set(struct bt_vcs *vcs, struct bt_vocs *inst, int bt_vcs_vocs_description_get(struct bt_vcs *vcs, struct bt_vocs *inst) { CHECKIF(vcs == NULL) { - BT_DBG("NULL vcs instance"); + LOG_DBG("NULL vcs instance"); return -EINVAL; } @@ -818,7 +814,7 @@ int bt_vcs_vocs_description_set(struct bt_vcs *vcs, struct bt_vocs *inst, const char *description) { CHECKIF(vcs == NULL) { - BT_DBG("NULL vcs instance"); + LOG_DBG("NULL vcs instance"); return -EINVAL; } @@ -837,7 +833,7 @@ int bt_vcs_vocs_description_set(struct bt_vcs *vcs, struct bt_vocs *inst, int bt_vcs_aics_state_get(struct bt_vcs *vcs, struct bt_aics *inst) { CHECKIF(vcs == NULL) { - BT_DBG("NULL vcs instance"); + LOG_DBG("NULL vcs instance"); return -EINVAL; } @@ -856,7 +852,7 @@ int bt_vcs_aics_state_get(struct bt_vcs *vcs, struct bt_aics *inst) int bt_vcs_aics_gain_setting_get(struct bt_vcs *vcs, struct bt_aics *inst) { CHECKIF(vcs == NULL) { - BT_DBG("NULL vcs instance"); + LOG_DBG("NULL vcs instance"); return -EINVAL; } @@ -875,7 +871,7 @@ int bt_vcs_aics_gain_setting_get(struct bt_vcs *vcs, struct bt_aics *inst) int bt_vcs_aics_type_get(struct bt_vcs *vcs, struct bt_aics *inst) { CHECKIF(vcs == NULL) { - BT_DBG("NULL vcs instance"); + LOG_DBG("NULL vcs instance"); return -EINVAL; } @@ -894,7 +890,7 @@ int bt_vcs_aics_type_get(struct bt_vcs *vcs, struct bt_aics *inst) int bt_vcs_aics_status_get(struct bt_vcs *vcs, struct bt_aics *inst) { CHECKIF(vcs == NULL) { - BT_DBG("NULL vcs instance"); + LOG_DBG("NULL vcs instance"); return -EINVAL; } @@ -913,7 +909,7 @@ int bt_vcs_aics_status_get(struct bt_vcs *vcs, struct bt_aics *inst) int bt_vcs_aics_unmute(struct bt_vcs *vcs, struct bt_aics *inst) { CHECKIF(vcs == NULL) { - BT_DBG("NULL vcs instance"); + LOG_DBG("NULL vcs instance"); return -EINVAL; } @@ -932,7 +928,7 @@ int bt_vcs_aics_unmute(struct bt_vcs *vcs, struct bt_aics *inst) int bt_vcs_aics_mute(struct bt_vcs *vcs, struct bt_aics *inst) { CHECKIF(vcs == NULL) { - BT_DBG("NULL vcs instance"); + LOG_DBG("NULL vcs instance"); return -EINVAL; } @@ -951,7 +947,7 @@ int bt_vcs_aics_mute(struct bt_vcs *vcs, struct bt_aics *inst) int bt_vcs_aics_manual_gain_set(struct bt_vcs *vcs, struct bt_aics *inst) { CHECKIF(vcs == NULL) { - BT_DBG("NULL vcs instance"); + LOG_DBG("NULL vcs instance"); return -EINVAL; } @@ -970,7 +966,7 @@ int bt_vcs_aics_manual_gain_set(struct bt_vcs *vcs, struct bt_aics *inst) int bt_vcs_aics_automatic_gain_set(struct bt_vcs *vcs, struct bt_aics *inst) { CHECKIF(vcs == NULL) { - BT_DBG("NULL vcs instance"); + LOG_DBG("NULL vcs instance"); return -EINVAL; } @@ -990,7 +986,7 @@ int bt_vcs_aics_gain_set(struct bt_vcs *vcs, struct bt_aics *inst, int8_t gain) { CHECKIF(vcs == NULL) { - BT_DBG("NULL vcs instance"); + LOG_DBG("NULL vcs instance"); return -EINVAL; } @@ -1009,7 +1005,7 @@ int bt_vcs_aics_gain_set(struct bt_vcs *vcs, struct bt_aics *inst, int bt_vcs_aics_description_get(struct bt_vcs *vcs, struct bt_aics *inst) { CHECKIF(vcs == NULL) { - BT_DBG("NULL vcs instance"); + LOG_DBG("NULL vcs instance"); return -EINVAL; } @@ -1029,7 +1025,7 @@ int bt_vcs_aics_description_set(struct bt_vcs *vcs, struct bt_aics *inst, const char *description) { CHECKIF(vcs == NULL) { - BT_DBG("NULL vcs instance"); + LOG_DBG("NULL vcs instance"); return -EINVAL; } diff --git a/subsys/bluetooth/audio/vcs_client.c b/subsys/bluetooth/audio/vcs_client.c index 07e18e74450..9656310a11c 100644 --- a/subsys/bluetooth/audio/vcs_client.c +++ b/subsys/bluetooth/audio/vcs_client.c @@ -22,9 +22,10 @@ #include "vcs_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_VCS_CLIENT) -#define LOG_MODULE_NAME bt_vcs_client -#include "common/log.h" +#include + +LOG_MODULE_REGISTER(bt_vcs_client, CONFIG_BT_VCS_CLIENT_LOG_LEVEL); + #include "common/bt_str.h" /* Callback functions */ @@ -103,9 +104,8 @@ static uint8_t vcs_client_notify_handler(struct bt_conn *conn, if (handle == vcs_inst->cli.state_handle && length == sizeof(vcs_inst->cli.state)) { memcpy(&vcs_inst->cli.state, data, length); - BT_DBG("Volume %u, mute %u, counter %u", - vcs_inst->cli.state.volume, vcs_inst->cli.state.mute, - vcs_inst->cli.state.change_counter); + LOG_DBG("Volume %u, mute %u, counter %u", vcs_inst->cli.state.volume, + vcs_inst->cli.state.mute, vcs_inst->cli.state.change_counter); if (vcs_client_cb && vcs_client_cb->state) { vcs_client_cb->state(vcs_inst, 0, vcs_inst->cli.state.volume, vcs_inst->cli.state.mute); @@ -113,7 +113,7 @@ static uint8_t vcs_client_notify_handler(struct bt_conn *conn, } else if (handle == vcs_inst->cli.flag_handle && length == sizeof(vcs_inst->cli.flags)) { memcpy(&vcs_inst->cli.flags, data, length); - BT_DBG("Flags %u", vcs_inst->cli.flags); + LOG_DBG("Flags %u", vcs_inst->cli.flags); if (vcs_client_cb && vcs_client_cb->flags) { vcs_client_cb->flags(vcs_inst, 0, vcs_inst->cli.flags); } @@ -132,17 +132,15 @@ static uint8_t vcs_client_read_vol_state_cb(struct bt_conn *conn, uint8_t err, vcs_inst->cli.busy = false; if (cb_err) { - BT_DBG("err: %d", cb_err); + LOG_DBG("err: %d", cb_err); } else if (data != NULL) { if (length == sizeof(vcs_inst->cli.state)) { memcpy(&vcs_inst->cli.state, data, length); - BT_DBG("Volume %u, mute %u, counter %u", - vcs_inst->cli.state.volume, - vcs_inst->cli.state.mute, - vcs_inst->cli.state.change_counter); + LOG_DBG("Volume %u, mute %u, counter %u", vcs_inst->cli.state.volume, + vcs_inst->cli.state.mute, vcs_inst->cli.state.change_counter); } else { - BT_DBG("Invalid length %u (expected %zu)", - length, sizeof(vcs_inst->cli.state)); + LOG_DBG("Invalid length %u (expected %zu)", length, + sizeof(vcs_inst->cli.state)); cb_err = BT_ATT_ERR_INVALID_ATTRIBUTE_LEN; } } @@ -170,14 +168,14 @@ static uint8_t vcs_client_read_flag_cb(struct bt_conn *conn, uint8_t err, vcs_inst->cli.busy = false; if (cb_err) { - BT_DBG("err: %d", cb_err); + LOG_DBG("err: %d", cb_err); } else if (data != NULL) { if (length == sizeof(vcs_inst->cli.flags)) { memcpy(&vcs_inst->cli.flags, data, length); - BT_DBG("Flags %u", vcs_inst->cli.flags); + LOG_DBG("Flags %u", vcs_inst->cli.flags); } else { - BT_DBG("Invalid length %u (expected %zu)", - length, sizeof(vcs_inst->cli.flags)); + LOG_DBG("Invalid length %u (expected %zu)", length, + sizeof(vcs_inst->cli.flags)); cb_err = BT_ATT_ERR_INVALID_ATTRIBUTE_LEN; } } @@ -236,7 +234,7 @@ static void vcs_cp_notify_app(struct bt_vcs *vcs, uint8_t opcode, int err) } break; default: - BT_DBG("Unknown opcode 0x%02x", opcode); + LOG_DBG("Unknown opcode 0x%02x", opcode); break; } } @@ -253,17 +251,15 @@ static uint8_t internal_read_vol_state_cb(struct bt_conn *conn, uint8_t err, memset(params, 0, sizeof(*params)); if (err > 0) { - BT_WARN("Volume state read failed: %d", err); + LOG_WRN("Volume state read failed: %d", err); cb_err = BT_ATT_ERR_UNLIKELY; } else if (data != NULL) { if (length == sizeof(vcs_inst->cli.state)) { int write_err; memcpy(&vcs_inst->cli.state, data, length); - BT_DBG("Volume %u, mute %u, counter %u", - vcs_inst->cli.state.volume, - vcs_inst->cli.state.mute, - vcs_inst->cli.state.change_counter); + LOG_DBG("Volume %u, mute %u, counter %u", vcs_inst->cli.state.volume, + vcs_inst->cli.state.mute, vcs_inst->cli.state.change_counter); /* clear busy flag to reuse function */ vcs_inst->cli.busy = false; @@ -278,8 +274,8 @@ static uint8_t internal_read_vol_state_cb(struct bt_conn *conn, uint8_t err, cb_err = BT_ATT_ERR_UNLIKELY; } } else { - BT_DBG("Invalid length %u (expected %zu)", - length, sizeof(vcs_inst->cli.state)); + LOG_DBG("Invalid length %u (expected %zu)", length, + sizeof(vcs_inst->cli.state)); cb_err = BT_ATT_ERR_UNLIKELY; } } @@ -299,7 +295,7 @@ static void vcs_client_write_vcs_cp_cb(struct bt_conn *conn, uint8_t err, uint8_t opcode = vcs_inst->cli.cp_val.cp.opcode; int cb_err = err; - BT_DBG("err: 0x%02X", err); + LOG_DBG("err: 0x%02X", err); memset(params, 0, sizeof(*params)); /* If the change counter is out of data when a write was attempted from @@ -319,7 +315,7 @@ static void vcs_client_write_vcs_cp_cb(struct bt_conn *conn, uint8_t err, cb_err = bt_gatt_read(conn, &vcs_inst->cli.read_params); if (cb_err) { - BT_WARN("Could not read Volume state: %d", cb_err); + LOG_WRN("Could not read Volume state: %d", cb_err); } else { vcs_inst->cli.cp_retried = true; /* Wait for read callback */ @@ -344,8 +340,8 @@ static uint8_t vcs_discover_include_func(struct bt_conn *conn, struct bt_vcs *vcs_inst = &vcs_insts[bt_conn_index(conn)]; if (attr == NULL) { - BT_DBG("Discover include complete for VCS: %u AICS and %u VOCS", - vcs_inst->cli.aics_inst_cnt, vcs_inst->cli.vocs_inst_cnt); + LOG_DBG("Discover include complete for VCS: %u AICS and %u VOCS", + vcs_inst->cli.aics_inst_cnt, vcs_inst->cli.vocs_inst_cnt); (void)memset(params, 0, sizeof(*params)); if (vcs_client_cb && vcs_client_cb->discover) { @@ -360,13 +356,13 @@ static uint8_t vcs_discover_include_func(struct bt_conn *conn, return BT_GATT_ITER_STOP; } - BT_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); + LOG_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); if (params->type == BT_GATT_DISCOVER_INCLUDE) { uint8_t conn_index = bt_conn_index(conn); include = (struct bt_gatt_include *)attr->user_data; - BT_DBG("Include UUID %s", bt_uuid_str(include->uuid)); + LOG_DBG("Include UUID %s", bt_uuid_str(include->uuid)); #if CONFIG_BT_VCS_CLIENT_MAX_AICS_INST > 0 if (bt_uuid_cmp(include->uuid, BT_UUID_AICS) == 0 && @@ -386,7 +382,7 @@ static uint8_t vcs_discover_include_func(struct bt_conn *conn, vcs_insts[conn_index].cli.aics[inst_idx], ¶m); if (err != 0) { - BT_DBG("AICS Discover failed (err %d)", err); + LOG_DBG("AICS Discover failed (err %d)", err); if (vcs_client_cb && vcs_client_cb->discover) { vcs_client_cb->discover(vcs_inst, err, 0, 0); @@ -414,7 +410,7 @@ static uint8_t vcs_discover_include_func(struct bt_conn *conn, vcs_insts[conn_index].cli.vocs[inst_idx], ¶m); if (err != 0) { - BT_DBG("VOCS Discover failed (err %d)", err); + LOG_DBG("VOCS Discover failed (err %d)", err); if (vcs_client_cb && vcs_client_cb->discover) { vcs_client_cb->discover(vcs_inst, err, 0, 0); @@ -445,7 +441,7 @@ static uint8_t vcs_discover_func(struct bt_conn *conn, struct bt_vcs *vcs_inst = &vcs_insts[bt_conn_index(conn)]; if (attr == NULL) { - BT_DBG("Setup complete for VCS"); + LOG_DBG("Setup complete for VCS"); (void)memset(params, 0, sizeof(*params)); #if (CONFIG_BT_VCS_CLIENT_MAX_AICS_INST > 0 || CONFIG_BT_VCS_CLIENT_MAX_VOCS_INST > 0) /* Discover included services */ @@ -456,7 +452,7 @@ static uint8_t vcs_discover_func(struct bt_conn *conn, err = bt_gatt_discover(conn, &vcs_inst->cli.discover_params); if (err != 0) { - BT_DBG("Discover failed (err %d)", err); + LOG_DBG("Discover failed (err %d)", err); if (vcs_client_cb && vcs_client_cb->discover) { vcs_client_cb->discover(vcs_inst, err, 0, 0); } @@ -470,21 +466,21 @@ static uint8_t vcs_discover_func(struct bt_conn *conn, return BT_GATT_ITER_STOP; } - BT_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); + LOG_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); if (params->type == BT_GATT_DISCOVER_CHARACTERISTIC) { chrc = (struct bt_gatt_chrc *)attr->user_data; if (bt_uuid_cmp(chrc->uuid, BT_UUID_VCS_STATE) == 0) { - BT_DBG("Volume state"); + LOG_DBG("Volume state"); vcs_inst->cli.state_handle = chrc->value_handle; sub_params = &vcs_inst->cli.state_sub_params; sub_params->disc_params = &vcs_inst->cli.state_sub_disc_params; } else if (bt_uuid_cmp(chrc->uuid, BT_UUID_VCS_CONTROL) == 0) { - BT_DBG("Control Point"); + LOG_DBG("Control Point"); vcs_inst->cli.control_handle = chrc->value_handle; } else if (bt_uuid_cmp(chrc->uuid, BT_UUID_VCS_FLAGS) == 0) { - BT_DBG("Flags"); + LOG_DBG("Flags"); vcs_inst->cli.flag_handle = chrc->value_handle; sub_params = &vcs_inst->cli.flag_sub_params; sub_params->disc_params = &vcs_inst->cli.flag_sub_disc_params; @@ -500,11 +496,9 @@ static uint8_t vcs_discover_func(struct bt_conn *conn, sub_params->notify = vcs_client_notify_handler; err = bt_gatt_subscribe(conn, sub_params); if (err == 0) { - BT_DBG("Subscribed to handle 0x%04X", - attr->handle); + LOG_DBG("Subscribed to handle 0x%04X", attr->handle); } else { - BT_DBG("Could not subscribe to handle 0x%04X", - attr->handle); + LOG_DBG("Could not subscribe to handle 0x%04X", attr->handle); } } } @@ -525,19 +519,19 @@ static uint8_t primary_discover_func(struct bt_conn *conn, struct bt_vcs *vcs_inst = &vcs_insts[bt_conn_index(conn)]; if (attr == NULL) { - BT_DBG("Could not find a VCS instance on the server"); + LOG_DBG("Could not find a VCS instance on the server"); if (vcs_client_cb && vcs_client_cb->discover) { vcs_client_cb->discover(vcs_inst, -ENODATA, 0, 0); } return BT_GATT_ITER_STOP; } - BT_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); + LOG_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); if (params->type == BT_GATT_DISCOVER_PRIMARY) { int err; - BT_DBG("Primary discover complete"); + LOG_DBG("Primary discover complete"); prim_service = (struct bt_gatt_service_val *)attr->user_data; vcs_inst->cli.start_handle = attr->handle + 1; @@ -552,7 +546,7 @@ static uint8_t primary_discover_func(struct bt_conn *conn, err = bt_gatt_discover(conn, &vcs_inst->cli.discover_params); if (err != 0) { - BT_DBG("Discover failed (err %d)", err); + LOG_DBG("Discover failed (err %d)", err); if (vcs_client_cb && vcs_client_cb->discover) { vcs_client_cb->discover(vcs_inst, err, 0, 0); } @@ -569,12 +563,12 @@ static int vcs_client_common_vcs_cp(struct bt_vcs *vcs, uint8_t opcode) int err; CHECKIF(vcs->cli.conn == NULL) { - BT_DBG("NULL conn"); + LOG_DBG("NULL conn"); return -EINVAL; } if (vcs->cli.control_handle == 0) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } else if (vcs->cli.busy) { return -EBUSY; @@ -623,7 +617,7 @@ static void aics_discover_cb(struct bt_aics *inst, int err) } if (err != 0) { - BT_DBG("Discover failed (err %d)", err); + LOG_DBG("Discover failed (err %d)", err); if (vcs_client_cb && vcs_client_cb->discover) { vcs_client_cb->discover(vcs_inst, err, 0, 0); } @@ -652,7 +646,7 @@ static void vocs_discover_cb(struct bt_vocs *inst, int err) struct bt_vcs *vcs_inst = lookup_vcs_by_vocs(inst); if (vcs_inst == NULL) { - BT_ERR("Could not lookup vcs_inst from vocs"); + LOG_ERR("Could not lookup vcs_inst from vocs"); if (vcs_client_cb && vcs_client_cb->discover) { vcs_client_cb->discover(vcs_inst, @@ -670,7 +664,7 @@ static void vocs_discover_cb(struct bt_vocs *inst, int err) } if (err != 0) { - BT_DBG("Discover failed (err %d)", err); + LOG_DBG("Discover failed (err %d)", err); if (vcs_client_cb && vcs_client_cb->discover) { vcs_client_cb->discover(vcs_inst, err, 0, 0); } @@ -774,7 +768,7 @@ int bt_vcs_discover(struct bt_conn *conn, struct bt_vcs **vcs) */ CHECKIF(conn == NULL) { - BT_DBG("NULL conn"); + LOG_DBG("NULL conn"); return -EINVAL; } @@ -817,7 +811,7 @@ int bt_vcs_client_cb_register(struct bt_vcs_cb *cb) /* Ensure that the cb->vocs_cb.discover is the vocs_discover_cb */ CHECKIF(cb->vocs_cb.discover != NULL && cb->vocs_cb.discover != vocs_discover_cb) { - BT_ERR("VOCS discover callback shall not be set"); + LOG_ERR("VOCS discover callback shall not be set"); return -EINVAL; } cb->vocs_cb.discover = vocs_discover_cb; @@ -843,7 +837,7 @@ int bt_vcs_client_cb_register(struct bt_vcs_cb *cb) /* Ensure that the cb->aics_cb.discover is the aics_discover_cb */ CHECKIF(cb->aics_cb.discover != NULL && cb->aics_cb.discover != aics_discover_cb) { - BT_ERR("AICS discover callback shall not be set"); + LOG_ERR("AICS discover callback shall not be set"); return -EINVAL; } cb->aics_cb.discover = aics_discover_cb; @@ -886,17 +880,17 @@ int bt_vcs_client_included_get(struct bt_vcs *vcs, int bt_vcs_client_conn_get(const struct bt_vcs *vcs, struct bt_conn **conn) { CHECKIF(vcs == NULL) { - BT_DBG("NULL vcs pointer"); + LOG_DBG("NULL vcs pointer"); return -EINVAL; } if (!vcs->client_instance) { - BT_DBG("vcs pointer shall be client instance"); + LOG_DBG("vcs pointer shall be client instance"); return -EINVAL; } if (vcs->cli.conn == NULL) { - BT_DBG("vcs pointer not associated with a connection. " + LOG_DBG("vcs pointer not associated with a connection. " "Do discovery first"); return -ENOTCONN; } @@ -910,12 +904,12 @@ int bt_vcs_client_read_vol_state(struct bt_vcs *vcs) int err; CHECKIF(vcs->cli.conn == NULL) { - BT_DBG("NULL conn"); + LOG_DBG("NULL conn"); return -EINVAL; } if (vcs->cli.state_handle == 0) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } else if (vcs->cli.busy) { return -EBUSY; @@ -939,12 +933,12 @@ int bt_vcs_client_read_flags(struct bt_vcs *vcs) int err; CHECKIF(vcs->cli.conn == NULL) { - BT_DBG("NULL conn"); + LOG_DBG("NULL conn"); return -EINVAL; } if (vcs->cli.flag_handle == 0) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } else if (vcs->cli.busy) { return -EBUSY; @@ -988,12 +982,12 @@ int bt_vcs_client_set_volume(struct bt_vcs *vcs, uint8_t volume) int err; CHECKIF(vcs->cli.conn == NULL) { - BT_DBG("NULL conn"); + LOG_DBG("NULL conn"); return -EINVAL; } if (vcs->cli.control_handle == 0) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } else if (vcs->cli.busy) { return -EBUSY; diff --git a/subsys/bluetooth/audio/vocs.c b/subsys/bluetooth/audio/vocs.c index 5a26e7c063b..26158b03181 100644 --- a/subsys/bluetooth/audio/vocs.c +++ b/subsys/bluetooth/audio/vocs.c @@ -20,16 +20,16 @@ #include "audio_internal.h" #include "vocs_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_VOCS) -#define LOG_MODULE_NAME bt_vocs -#include "common/log.h" +#define LOG_LEVEL CONFIG_BT_VOCS_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_vocs); #define VALID_VOCS_OPCODE(opcode) ((opcode) == BT_VOCS_OPCODE_SET_OFFSET) #if defined(CONFIG_BT_VOCS) static void offset_state_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("value 0x%04x", value); + LOG_DBG("value 0x%04x", value); } static ssize_t read_offset_state(struct bt_conn *conn, const struct bt_gatt_attr *attr, @@ -37,14 +37,14 @@ static ssize_t read_offset_state(struct bt_conn *conn, const struct bt_gatt_attr { struct bt_vocs *inst = BT_AUDIO_CHRC_USER_DATA(attr); - BT_DBG("offset %d, counter %u", inst->srv.state.offset, inst->srv.state.change_counter); + LOG_DBG("offset %d, counter %u", inst->srv.state.offset, inst->srv.state.change_counter); return bt_gatt_attr_read(conn, attr, buf, len, offset, &inst->srv.state, sizeof(inst->srv.state)); } static void location_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("value 0x%04x", value); + LOG_DBG("value 0x%04x", value); } #endif /* CONFIG_BT_VOCS */ @@ -64,7 +64,7 @@ static ssize_t write_location(struct bt_conn *conn, const struct bt_gatt_attr *a } memcpy(&inst->srv.location, buf, len); - BT_DBG("%02x", inst->srv.location); + LOG_DBG("%02x", inst->srv.location); if (old_location != inst->srv.location) { (void)bt_gatt_notify_uuid(NULL, BT_UUID_VOCS_LOCATION, @@ -86,7 +86,7 @@ static ssize_t read_location(struct bt_conn *conn, const struct bt_gatt_attr *at { struct bt_vocs *inst = BT_AUDIO_CHRC_USER_DATA(attr); - BT_DBG("0x%08x", inst->srv.location); + LOG_DBG("0x%08x", inst->srv.location); return bt_gatt_attr_read(conn, attr, buf, len, offset, &inst->srv.location, sizeof(inst->srv.location)); } @@ -109,7 +109,7 @@ static ssize_t write_vocs_control(struct bt_conn *conn, const struct bt_gatt_att /* Check opcode before length */ if (!VALID_VOCS_OPCODE(cp->opcode)) { - BT_DBG("Invalid opcode %u", cp->opcode); + LOG_DBG("Invalid opcode %u", cp->opcode); return BT_GATT_ERR(BT_VOCS_ERR_OP_NOT_SUPPORTED); } @@ -117,7 +117,7 @@ static ssize_t write_vocs_control(struct bt_conn *conn, const struct bt_gatt_att return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); } - BT_DBG("Opcode %u, counter %u", cp->opcode, cp->counter); + LOG_DBG("Opcode %u, counter %u", cp->opcode, cp->counter); if (cp->counter != inst->srv.state.change_counter) { @@ -126,7 +126,7 @@ static ssize_t write_vocs_control(struct bt_conn *conn, const struct bt_gatt_att switch (cp->opcode) { case BT_VOCS_OPCODE_SET_OFFSET: - BT_DBG("Set offset %d", cp->offset); + LOG_DBG("Set offset %d", cp->offset); if (cp->offset > BT_VOCS_MAX_OFFSET || cp->offset < BT_VOCS_MIN_OFFSET) { return BT_GATT_ERR(BT_VOCS_ERR_OUT_OF_RANGE); } @@ -142,8 +142,8 @@ static ssize_t write_vocs_control(struct bt_conn *conn, const struct bt_gatt_att if (notify) { inst->srv.state.change_counter++; - BT_DBG("New state: offset %d, counter %u", - inst->srv.state.offset, inst->srv.state.change_counter); + LOG_DBG("New state: offset %d, counter %u", inst->srv.state.offset, + inst->srv.state.change_counter); (void)bt_gatt_notify_uuid(NULL, BT_UUID_VOCS_STATE, inst->srv.service_p->attrs, &inst->srv.state, sizeof(inst->srv.state)); @@ -160,7 +160,7 @@ static ssize_t write_vocs_control(struct bt_conn *conn, const struct bt_gatt_att #if defined(CONFIG_BT_VOCS) static void output_desc_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("value 0x%04x", value); + LOG_DBG("value 0x%04x", value); } #endif /* CONFIG_BT_VOCS */ @@ -174,8 +174,8 @@ static ssize_t write_output_desc(struct bt_conn *conn, const struct bt_gatt_attr } if (len >= sizeof(inst->srv.output_desc)) { - BT_DBG("Output desc was clipped from length %u to %zu", - len, sizeof(inst->srv.output_desc) - 1); + LOG_DBG("Output desc was clipped from length %u to %zu", len, + sizeof(inst->srv.output_desc) - 1); /* We just clip the string value if it's too long */ len = (uint16_t)sizeof(inst->srv.output_desc) - 1; } @@ -194,7 +194,7 @@ static ssize_t write_output_desc(struct bt_conn *conn, const struct bt_gatt_attr } } - BT_DBG("%s", inst->srv.output_desc); + LOG_DBG("%s", inst->srv.output_desc); return len; } @@ -228,7 +228,7 @@ static ssize_t read_output_desc(struct bt_conn *conn, const struct bt_gatt_attr { struct bt_vocs *inst = BT_AUDIO_CHRC_USER_DATA(attr); - BT_DBG("%s", inst->srv.output_desc); + LOG_DBG("%s", inst->srv.output_desc); return bt_gatt_attr_read(conn, attr, buf, len, offset, &inst->srv.output_desc, strlen(inst->srv.output_desc)); } @@ -274,7 +274,7 @@ struct bt_vocs *bt_vocs_free_instance_get(void) void *bt_vocs_svc_decl_get(struct bt_vocs *vocs) { CHECKIF(!vocs) { - BT_DBG("Null VOCS pointer"); + LOG_DBG("Null VOCS pointer"); return NULL; } @@ -297,12 +297,12 @@ int bt_vocs_register(struct bt_vocs *vocs, static bool instances_prepared; CHECKIF(!vocs) { - BT_DBG("Null VOCS pointer"); + LOG_DBG("Null VOCS pointer"); return -EINVAL; } CHECKIF(!param) { - BT_DBG("NULL params pointer"); + LOG_DBG("NULL params pointer"); return -EINVAL; } @@ -312,12 +312,12 @@ int bt_vocs_register(struct bt_vocs *vocs, } CHECKIF(vocs->srv.initialized) { - BT_DBG("Already initialized VOCS instance"); + LOG_DBG("Already initialized VOCS instance"); return -EALREADY; } CHECKIF(param->offset > BT_VOCS_MAX_OFFSET || param->offset < BT_VOCS_MIN_OFFSET) { - BT_DBG("Invalid offset %d", param->offset); + LOG_DBG("Invalid offset %d", param->offset); return -EINVAL; } @@ -330,9 +330,9 @@ int bt_vocs_register(struct bt_vocs *vocs, sizeof(vocs->srv.output_desc) - 1); /* strncpy may not always null-terminate */ vocs->srv.output_desc[sizeof(vocs->srv.output_desc) - 1] = '\0'; - if (IS_ENABLED(CONFIG_BT_DEBUG_VOCS) && + if (IS_ENABLED(CONFIG_BT_VOCS_LOG_LEVEL_DBG) && strcmp(vocs->srv.output_desc, param->output_desc)) { - BT_DBG("Output desc clipped to %s", vocs->srv.output_desc); + LOG_DBG("Output desc clipped to %s", vocs->srv.output_desc); } } @@ -361,7 +361,7 @@ int bt_vocs_register(struct bt_vocs *vocs, err = bt_gatt_service_register(vocs->srv.service_p); if (err) { - BT_DBG("Could not register VOCS service"); + LOG_DBG("Could not register VOCS service"); return err; } @@ -373,7 +373,7 @@ int bt_vocs_register(struct bt_vocs *vocs, int bt_vocs_state_get(struct bt_vocs *inst) { CHECKIF(!inst) { - BT_DBG("Null VOCS pointer"); + LOG_DBG("Null VOCS pointer"); return -EINVAL; } @@ -392,7 +392,7 @@ int bt_vocs_state_get(struct bt_vocs *inst) int bt_vocs_location_get(struct bt_vocs *inst) { CHECKIF(!inst) { - BT_DBG("Null VOCS pointer"); + LOG_DBG("Null VOCS pointer"); return -EINVAL; } @@ -411,7 +411,7 @@ int bt_vocs_location_get(struct bt_vocs *inst) int bt_vocs_location_set(struct bt_vocs *inst, uint32_t location) { CHECKIF(!inst) { - BT_DBG("Null VOCS pointer"); + LOG_DBG("Null VOCS pointer"); return -EINVAL; } @@ -427,7 +427,7 @@ int bt_vocs_location_set(struct bt_vocs *inst, uint32_t location) int bt_vocs_state_set(struct bt_vocs *inst, int16_t offset) { CHECKIF(!inst) { - BT_DBG("Null VOCS pointer"); + LOG_DBG("Null VOCS pointer"); return -EINVAL; } @@ -449,7 +449,7 @@ int bt_vocs_state_set(struct bt_vocs *inst, int16_t offset) int bt_vocs_description_get(struct bt_vocs *inst) { CHECKIF(!inst) { - BT_DBG("Null VOCS pointer"); + LOG_DBG("Null VOCS pointer"); return -EINVAL; } @@ -468,12 +468,12 @@ int bt_vocs_description_get(struct bt_vocs *inst) int bt_vocs_description_set(struct bt_vocs *inst, const char *description) { CHECKIF(!inst) { - BT_DBG("Null VOCS pointer"); + LOG_DBG("Null VOCS pointer"); return -EINVAL; } CHECKIF(!description) { - BT_DBG("Null description pointer"); + LOG_DBG("Null description pointer"); return -EINVAL; } diff --git a/subsys/bluetooth/audio/vocs_client.c b/subsys/bluetooth/audio/vocs_client.c index 480c7aabeb8..8a8efbed58a 100644 --- a/subsys/bluetooth/audio/vocs_client.c +++ b/subsys/bluetooth/audio/vocs_client.c @@ -21,9 +21,9 @@ #include "vocs_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_VOCS_CLIENT) -#define LOG_MODULE_NAME bt_vocs_client -#include "common/log.h" +#include + +LOG_MODULE_REGISTER(bt_vocs_client, CONFIG_BT_VOCS_CLIENT_LOG_LEVEL); static struct bt_vocs vocs_insts[CONFIG_BT_MAX_CONN * CONFIG_BT_VOCS_CLIENT_MAX_INSTANCE_COUNT]; @@ -41,7 +41,7 @@ static struct bt_vocs *lookup_vocs_by_handle(struct bt_conn *conn, uint16_t hand } } - BT_DBG("Could not find VOCS instance with handle 0x%04x", handle); + LOG_DBG("Could not find VOCS instance with handle 0x%04x", handle); return NULL; } @@ -58,7 +58,7 @@ uint8_t vocs_client_notify_handler(struct bt_conn *conn, struct bt_gatt_subscrib inst = lookup_vocs_by_handle(conn, handle); if (!inst) { - BT_DBG("Instance not found"); + LOG_DBG("Instance not found"); return BT_GATT_ITER_STOP; } @@ -69,13 +69,13 @@ uint8_t vocs_client_notify_handler(struct bt_conn *conn, struct bt_gatt_subscrib if (handle == inst->cli.state_handle) { if (length == sizeof(inst->cli.state)) { memcpy(&inst->cli.state, data, length); - BT_DBG("Inst %p: Offset %d, counter %u", inst, inst->cli.state.offset, - inst->cli.state.change_counter); + LOG_DBG("Inst %p: Offset %d, counter %u", inst, inst->cli.state.offset, + inst->cli.state.change_counter); if (inst->cli.cb && inst->cli.cb->state) { inst->cli.cb->state(inst, 0, inst->cli.state.offset); } } else { - BT_DBG("Invalid state length %u", length); + LOG_DBG("Invalid state length %u", length); } } else if (handle == inst->cli.desc_handle) { char desc[MIN(BT_L2CAP_RX_MTU, BT_ATT_MAX_ATTRIBUTE_LEN) + 1]; @@ -83,26 +83,26 @@ uint8_t vocs_client_notify_handler(struct bt_conn *conn, struct bt_gatt_subscrib /* Truncate if too large */ if (length > sizeof(desc) - 1) { - BT_DBG("Description truncated from %u to %zu octets", - length, sizeof(desc) - 1); + LOG_DBG("Description truncated from %u to %zu octets", length, + sizeof(desc) - 1); } length = MIN(sizeof(desc) - 1, length); memcpy(desc, data, length); desc[length] = '\0'; - BT_DBG("Inst %p: Output description: %s", inst, desc); + LOG_DBG("Inst %p: Output description: %s", inst, desc); if (inst->cli.cb && inst->cli.cb->description) { inst->cli.cb->description(inst, 0, desc); } } else if (handle == inst->cli.location_handle) { if (length == sizeof(inst->cli.location)) { memcpy(&inst->cli.location, data, length); - BT_DBG("Inst %p: Location %u", inst, inst->cli.location); + LOG_DBG("Inst %p: Location %u", inst, inst->cli.location); if (inst->cli.cb && inst->cli.cb->location) { inst->cli.cb->location(inst, 0, inst->cli.location); } } else { - BT_DBG("Invalid location length %u", length); + LOG_DBG("Invalid location length %u", length); } } @@ -119,26 +119,27 @@ static uint8_t vocs_client_read_offset_state_cb(struct bt_conn *conn, uint8_t er memset(params, 0, sizeof(*params)); if (!inst) { - BT_DBG("Instance not found"); + LOG_DBG("Instance not found"); return BT_GATT_ITER_STOP; } - BT_DBG("Inst %p: err: 0x%02X", inst, err); + LOG_DBG("Inst %p: err: 0x%02X", inst, err); inst->cli.busy = false; if (cb_err) { - BT_DBG("Offset state read failed: %d", err); + LOG_DBG("Offset state read failed: %d", err); } else if (data) { if (length == sizeof(inst->cli.state)) { memcpy(&inst->cli.state, data, length); - BT_DBG("Offset %d, counter %u", - inst->cli.state.offset, inst->cli.state.change_counter); + LOG_DBG("Offset %d, counter %u", inst->cli.state.offset, + inst->cli.state.change_counter); } else { - BT_DBG("Invalid length %u (expected %zu)", length, sizeof(inst->cli.state)); + LOG_DBG("Invalid length %u (expected %zu)", length, + sizeof(inst->cli.state)); cb_err = BT_ATT_ERR_INVALID_ATTRIBUTE_LEN; } } else { - BT_DBG("Invalid state"); + LOG_DBG("Invalid state"); cb_err = BT_ATT_ERR_UNLIKELY; } @@ -160,26 +161,26 @@ static uint8_t vocs_client_read_location_cb(struct bt_conn *conn, uint8_t err, memset(params, 0, sizeof(*params)); if (!inst) { - BT_DBG("Instance not found"); + LOG_DBG("Instance not found"); return BT_GATT_ITER_STOP; } - BT_DBG("Inst %p: err: 0x%02X", inst, err); + LOG_DBG("Inst %p: err: 0x%02X", inst, err); inst->cli.busy = false; if (cb_err) { - BT_DBG("Offset state read failed: %d", err); + LOG_DBG("Offset state read failed: %d", err); } else if (data) { if (length == sizeof(inst->cli.location)) { memcpy(&inst->cli.location, data, length); - BT_DBG("Location %u", inst->cli.location); + LOG_DBG("Location %u", inst->cli.location); } else { - BT_DBG("Invalid length %u (expected %zu)", - length, sizeof(inst->cli.location)); + LOG_DBG("Invalid length %u (expected %zu)", length, + sizeof(inst->cli.location)); cb_err = BT_ATT_ERR_INVALID_ATTRIBUTE_LEN; } } else { - BT_DBG("Invalid location"); + LOG_DBG("Invalid location"); cb_err = BT_ATT_ERR_UNLIKELY; } @@ -201,21 +202,20 @@ static uint8_t internal_read_volume_offset_state_cb(struct bt_conn *conn, uint8_ memset(params, 0, sizeof(*params)); if (!inst) { - BT_ERR("Instance not found"); + LOG_ERR("Instance not found"); return BT_GATT_ITER_STOP; } if (err) { - BT_WARN("Volume offset state read failed: %d", err); + LOG_WRN("Volume offset state read failed: %d", err); cb_err = BT_ATT_ERR_UNLIKELY; } else if (data) { if (length == sizeof(inst->cli.state)) { int write_err; memcpy(&inst->cli.state, data, length); - BT_DBG("Offset %d, counter %u", - inst->cli.state.offset, - inst->cli.state.change_counter); + LOG_DBG("Offset %d, counter %u", inst->cli.state.offset, + inst->cli.state.change_counter); /* clear busy flag to reuse function */ inst->cli.busy = false; @@ -224,11 +224,12 @@ static uint8_t internal_read_volume_offset_state_cb(struct bt_conn *conn, uint8_ cb_err = BT_ATT_ERR_UNLIKELY; } } else { - BT_DBG("Invalid length %u (expected %zu)", length, sizeof(inst->cli.state)); + LOG_DBG("Invalid length %u (expected %zu)", length, + sizeof(inst->cli.state)); cb_err = BT_ATT_ERR_UNLIKELY; } } else { - BT_DBG("Invalid (empty) offset state read"); + LOG_DBG("Invalid (empty) offset state read"); cb_err = BT_ATT_ERR_UNLIKELY; } @@ -252,11 +253,11 @@ static void vcs_client_write_vocs_cp_cb(struct bt_conn *conn, uint8_t err, memset(params, 0, sizeof(*params)); if (!inst) { - BT_DBG("Instance not found"); + LOG_DBG("Instance not found"); return; } - BT_DBG("Inst %p: err: 0x%02X", inst, err); + LOG_DBG("Inst %p: err: 0x%02X", inst, err); /* If the change counter is out of data when a write was attempted from the application, * we automatically initiate a read to get the newest state and try again. Once the @@ -266,7 +267,7 @@ static void vcs_client_write_vocs_cp_cb(struct bt_conn *conn, uint8_t err, if (cb_err == BT_VOCS_ERR_INVALID_COUNTER && inst->cli.cp_retried) { cb_err = BT_ATT_ERR_UNLIKELY; } else if (cb_err == BT_VOCS_ERR_INVALID_COUNTER && inst->cli.state_handle) { - BT_DBG("Invalid change counter. Reading volume offset state from server."); + LOG_DBG("Invalid change counter. Reading volume offset state from server."); inst->cli.read_params.func = internal_read_volume_offset_state_cb; inst->cli.read_params.handle_count = 1; @@ -274,7 +275,7 @@ static void vcs_client_write_vocs_cp_cb(struct bt_conn *conn, uint8_t err, cb_err = bt_gatt_read(conn, &inst->cli.read_params); if (cb_err) { - BT_WARN("Could not read Volume offset state: %d", cb_err); + LOG_WRN("Could not read Volume offset state: %d", cb_err); } else { inst->cli.cp_retried = true; /* Wait for read callback */ @@ -301,22 +302,22 @@ static uint8_t vcs_client_read_output_desc_cb(struct bt_conn *conn, uint8_t err, memset(params, 0, sizeof(*params)); if (!inst) { - BT_DBG("Instance not found"); + LOG_DBG("Instance not found"); return BT_GATT_ITER_STOP; } - BT_DBG("Inst %p: err: 0x%02X", inst, err); + LOG_DBG("Inst %p: err: 0x%02X", inst, err); inst->cli.busy = false; if (cb_err) { - BT_DBG("Description read failed: %d", err); + LOG_DBG("Description read failed: %d", err); } else { if (data) { LOG_HEXDUMP_DBG(data, length, "Output description read"); if (length > sizeof(desc) - 1) { - BT_DBG("Description truncated from %u to %zu octets", - length, sizeof(desc) - 1); + LOG_DBG("Description truncated from %u to %zu octets", length, + sizeof(desc) - 1); } length = MIN(sizeof(desc) - 1, length); @@ -324,7 +325,7 @@ static uint8_t vcs_client_read_output_desc_cb(struct bt_conn *conn, uint8_t err, memcpy(desc, data, length); } desc[length] = '\0'; - BT_DBG("Output description: %s", desc); + LOG_DBG("Output description: %s", desc); } if (inst->cli.cb && inst->cli.cb->description) { @@ -351,7 +352,7 @@ static uint8_t vocs_discover_func(struct bt_conn *conn, const struct bt_gatt_att struct bt_vocs *inst = CONTAINER_OF(client_inst, struct bt_vocs, cli); if (!attr) { - BT_DBG("Discovery complete for VOCS %p", inst); + LOG_DBG("Discovery complete for VOCS %p", inst); inst->cli.busy = false; (void)memset(params, 0, sizeof(*params)); @@ -364,7 +365,7 @@ static uint8_t vocs_discover_func(struct bt_conn *conn, const struct bt_gatt_att return BT_GATT_ITER_STOP; } - BT_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); + LOG_DBG("[ATTRIBUTE] handle 0x%04X", attr->handle); if (params->type == BT_GATT_DISCOVER_CHARACTERISTIC) { struct bt_gatt_subscribe_params *sub_params = NULL; @@ -377,11 +378,11 @@ static uint8_t vocs_discover_func(struct bt_conn *conn, const struct bt_gatt_att inst->cli.end_handle = chrc->value_handle; if (!bt_uuid_cmp(chrc->uuid, BT_UUID_VOCS_STATE)) { - BT_DBG("Volume offset state"); + LOG_DBG("Volume offset state"); inst->cli.state_handle = chrc->value_handle; sub_params = &inst->cli.state_sub_params; } else if (!bt_uuid_cmp(chrc->uuid, BT_UUID_VOCS_LOCATION)) { - BT_DBG("Location"); + LOG_DBG("Location"); inst->cli.location_handle = chrc->value_handle; if (chrc->properties & BT_GATT_CHRC_NOTIFY) { sub_params = &inst->cli.location_sub_params; @@ -390,10 +391,10 @@ static uint8_t vocs_discover_func(struct bt_conn *conn, const struct bt_gatt_att inst->cli.location_writable = true; } } else if (!bt_uuid_cmp(chrc->uuid, BT_UUID_VOCS_CONTROL)) { - BT_DBG("Control point"); + LOG_DBG("Control point"); inst->cli.control_handle = chrc->value_handle; } else if (!bt_uuid_cmp(chrc->uuid, BT_UUID_VOCS_DESCRIPTION)) { - BT_DBG("Description"); + LOG_DBG("Description"); inst->cli.desc_handle = chrc->value_handle; if (chrc->properties & BT_GATT_CHRC_NOTIFY) { sub_params = &inst->cli.desc_sub_params; @@ -416,8 +417,7 @@ static uint8_t vocs_discover_func(struct bt_conn *conn, const struct bt_gatt_att sub_params->notify = vocs_client_notify_handler; err = bt_gatt_subscribe(conn, sub_params); if (err) { - BT_WARN("Could not subscribe to handle %u", - sub_params->ccc_handle); + LOG_WRN("Could not subscribe to handle %u", sub_params->ccc_handle); } } } @@ -430,22 +430,22 @@ int bt_vocs_client_state_get(struct bt_vocs *inst) int err; CHECKIF(!inst) { - BT_DBG("NULL instance"); + LOG_DBG("NULL instance"); return -EINVAL; } CHECKIF(inst->cli.conn == NULL) { - BT_DBG("NULL conn"); + LOG_DBG("NULL conn"); return -EINVAL; } if (!inst->cli.state_handle) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } if (inst->cli.busy) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EBUSY; } @@ -466,22 +466,22 @@ int bt_vocs_client_location_set(struct bt_vocs *inst, uint32_t location) { CHECKIF(!inst) { - BT_DBG("NULL instance"); + LOG_DBG("NULL instance"); return -EINVAL; } CHECKIF(inst->cli.conn == NULL) { - BT_DBG("NULL conn"); + LOG_DBG("NULL conn"); return -EINVAL; } if (!inst->cli.location_handle) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } else if (inst->cli.busy) { return -EBUSY; } else if (!inst->cli.location_writable) { - BT_DBG("Location is not writable on peer service instance"); + LOG_DBG("Location is not writable on peer service instance"); return -EPERM; } @@ -496,17 +496,17 @@ int bt_vocs_client_location_get(struct bt_vocs *inst) int err; CHECKIF(!inst) { - BT_DBG("NULL instance"); + LOG_DBG("NULL instance"); return -EINVAL; } CHECKIF(inst->cli.conn == NULL) { - BT_DBG("NULL conn"); + LOG_DBG("NULL conn"); return -EINVAL; } if (!inst->cli.location_handle) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } else if (inst->cli.busy) { return -EBUSY; @@ -530,17 +530,17 @@ int bt_vocs_client_state_set(struct bt_vocs *inst, int16_t offset) int err; CHECKIF(!inst) { - BT_DBG("NULL instance"); + LOG_DBG("NULL instance"); return -EINVAL; } CHECKIF(inst->cli.conn == NULL) { - BT_DBG("NULL conn"); + LOG_DBG("NULL conn"); return -EINVAL; } if (!inst->cli.control_handle) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } else if (inst->cli.busy) { return -EBUSY; @@ -569,17 +569,17 @@ int bt_vocs_client_description_get(struct bt_vocs *inst) int err; CHECKIF(!inst) { - BT_DBG("NULL instance"); + LOG_DBG("NULL instance"); return -EINVAL; } CHECKIF(inst->cli.conn == NULL) { - BT_DBG("NULL conn"); + LOG_DBG("NULL conn"); return -EINVAL; } if (!inst->cli.desc_handle) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } else if (inst->cli.busy) { return -EBUSY; @@ -602,22 +602,22 @@ int bt_vocs_client_description_set(struct bt_vocs *inst, const char *description) { CHECKIF(!inst) { - BT_DBG("NULL instance"); + LOG_DBG("NULL instance"); return -EINVAL; } CHECKIF(inst->cli.conn == NULL) { - BT_DBG("NULL conn"); + LOG_DBG("NULL conn"); return -EINVAL; } if (!inst->cli.desc_handle) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } else if (inst->cli.busy) { return -EBUSY; } else if (!inst->cli.desc_writable) { - BT_DBG("Description is not writable on peer service instance"); + LOG_DBG("Description is not writable on peer service instance"); return -EPERM; } @@ -643,17 +643,17 @@ struct bt_vocs *bt_vocs_client_free_instance_get(void) int bt_vocs_client_conn_get(const struct bt_vocs *vocs, struct bt_conn **conn) { CHECKIF(vocs == NULL) { - BT_DBG("NULL vocs pointer"); + LOG_DBG("NULL vocs pointer"); return -EINVAL; } if (!vocs->client_instance) { - BT_DBG("vocs pointer shall be client instance"); + LOG_DBG("vocs pointer shall be client instance"); return -EINVAL; } if (vocs->cli.conn == NULL) { - BT_DBG("vocs pointer not associated with a connection. " + LOG_DBG("vocs pointer not associated with a connection. " "Do discovery first"); return -ENOTCONN; } @@ -699,24 +699,25 @@ int bt_vocs_discover(struct bt_conn *conn, struct bt_vocs *inst, int err = 0; CHECKIF(!inst || !conn || !param) { - BT_DBG("%s cannot be NULL", - inst == NULL ? "inst" : conn == NULL ? "conn" : "param"); + LOG_DBG("%s cannot be NULL", inst == NULL ? "inst" + : conn == NULL ? "conn" + : "param"); return -EINVAL; } CHECKIF(param->end_handle < param->start_handle) { - BT_DBG("start_handle (%u) shall be less than end_handle (%u)", - param->start_handle, param->end_handle); + LOG_DBG("start_handle (%u) shall be less than end_handle (%u)", param->start_handle, + param->end_handle); return -EINVAL; } CHECKIF(!inst->cli.active) { - BT_DBG("Inactive instance"); + LOG_DBG("Inactive instance"); return -EINVAL; } if (inst->cli.busy) { - BT_DBG("Instance is busy"); + LOG_DBG("Instance is busy"); return -EBUSY; } @@ -730,7 +731,7 @@ int bt_vocs_discover(struct bt_conn *conn, struct bt_vocs *inst, err = bt_gatt_discover(conn, &inst->cli.discover_params); if (err) { - BT_DBG("Discover failed (err %d)", err); + LOG_DBG("Discover failed (err %d)", err); } else { inst->cli.busy = true; } @@ -741,7 +742,7 @@ int bt_vocs_discover(struct bt_conn *conn, struct bt_vocs *inst, void bt_vocs_client_cb_register(struct bt_vocs *inst, struct bt_vocs_cb *cb) { CHECKIF(!inst) { - BT_DBG("inst cannot be NULL"); + LOG_DBG("inst cannot be NULL"); return; } diff --git a/subsys/bluetooth/common/CMakeLists.txt b/subsys/bluetooth/common/CMakeLists.txt index 72d650445fe..2138b23c7d5 100644 --- a/subsys/bluetooth/common/CMakeLists.txt +++ b/subsys/bluetooth/common/CMakeLists.txt @@ -4,7 +4,6 @@ zephyr_library() zephyr_library_sources(addr.c) zephyr_library_sources(dummy.c) -zephyr_library_sources(log.c) zephyr_library_sources(bt_str.c) zephyr_library_sources_ifdef(CONFIG_BT_RPA rpa.c) diff --git a/subsys/bluetooth/common/Kconfig b/subsys/bluetooth/common/Kconfig index 70172203d0c..19a04d17182 100644 --- a/subsys/bluetooth/common/Kconfig +++ b/subsys/bluetooth/common/Kconfig @@ -373,16 +373,28 @@ if BT_DEBUG config BT_DEBUG_HCI_DRIVER bool "Bluetooth HCI driver debug" + select DEPRECATED help This option enables debug support for the active Bluetooth HCI driver, including the Controller-side HCI layer when included in the build. +module = BT_HCI_DRIVER +legacy-debug-sym = BT_DEBUG_HCI_DRIVER +module-str = "Bluetooth HCI driver" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_DEBUG_RPA bool "Bluetooth Resolvable Private Address (RPA) debug" + select DEPRECATED depends on BT_RPA help This option enables debug support for the Bluetooth Resolvable Private Address (RPA) generation and resolution. +module = BT_RPA +legacy-debug-sym = BT_DEBUG_RPA +module-str = "Bluetooth Resolvable Private Address (RPA)" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + endif # BT_DEBUG diff --git a/subsys/bluetooth/common/Kconfig.template.log_config_bt b/subsys/bluetooth/common/Kconfig.template.log_config_bt new file mode 100644 index 00000000000..189cb04f389 --- /dev/null +++ b/subsys/bluetooth/common/Kconfig.template.log_config_bt @@ -0,0 +1,17 @@ +# Copyright (c) 2022 Nordic Semicoductor ASA +# SPDX-License-Identifier: Apache-2.0 + +parent-module = BT + +choice "$(module)_LOG_LEVEL_CHOICE" + default $(module)_LOG_LEVEL_INHERIT if y + +config $(module)_LOG_LEVEL_INHERIT + bool "Inherit $(parent-module)_LOG_LEVEL" +endchoice + +config $(module)_LOG_LEVEL + default 4 if $(legacy-debug-sym) + default $(parent-module)_LOG_LEVEL if $(module)_LOG_LEVEL_INHERIT + +source "subsys/logging/Kconfig.template.log_config" diff --git a/subsys/bluetooth/common/log.c b/subsys/bluetooth/common/log.c deleted file mode 100644 index b72e45276c8..00000000000 --- a/subsys/bluetooth/common/log.c +++ /dev/null @@ -1,8 +0,0 @@ -/* log.c - logging helpers */ - -/* - * Copyright (c) 2017 Nordic Semiconductor ASA - * Copyright (c) 2016 Intel Corporation - * - * SPDX-License-Identifier: Apache-2.0 - */ diff --git a/subsys/bluetooth/common/log.h b/subsys/bluetooth/common/log.h deleted file mode 100644 index 920f8326161..00000000000 --- a/subsys/bluetooth/common/log.h +++ /dev/null @@ -1,46 +0,0 @@ -/** @file - * @brief Bluetooth subsystem logging helpers. - */ - -/* - * Copyright (c) 2017 Nordic Semiconductor ASA - * Copyright (c) 2015-2016 Intel Corporation - * - * SPDX-License-Identifier: Apache-2.0 - */ -#ifndef __BT_LOG_H -#define __BT_LOG_H - -#include -#include -#include -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#if !defined(BT_DBG_ENABLED) -#define BT_DBG_ENABLED 1 -#endif - -#if BT_DBG_ENABLED -#define LOG_LEVEL LOG_LEVEL_DBG -#else -#define LOG_LEVEL CONFIG_BT_LOG_LEVEL -#endif - -LOG_MODULE_REGISTER(LOG_MODULE_NAME, LOG_LEVEL); - -#define BT_DBG(fmt, ...) LOG_DBG(fmt, ##__VA_ARGS__) -#define BT_ERR(fmt, ...) LOG_ERR(fmt, ##__VA_ARGS__) -#define BT_WARN(fmt, ...) LOG_WRN(fmt, ##__VA_ARGS__) -#define BT_INFO(fmt, ...) LOG_INF(fmt, ##__VA_ARGS__) - -#ifdef __cplusplus -} -#endif - -#endif /* __BT_LOG_H */ diff --git a/subsys/bluetooth/common/rpa.c b/subsys/bluetooth/common/rpa.c index d6d8d17bbc0..b4650d5fba2 100644 --- a/subsys/bluetooth/common/rpa.c +++ b/subsys/bluetooth/common/rpa.c @@ -15,13 +15,14 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_RPA) -#define LOG_MODULE_NAME bt_rpa -#include "common/log.h" #include "common/bt_str.h" #include +#define LOG_LEVEL CONFIG_BT_RPA_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_rpa); + #if defined(CONFIG_BT_CTLR) && defined(CONFIG_BT_HOST_CRYPTO) #include "../controller/util/util.h" #include "../controller/hal/ecb.h" @@ -57,8 +58,8 @@ static int ah(const uint8_t irk[16], const uint8_t r[3], uint8_t out[3]) uint8_t res[16]; int err; - BT_DBG("irk %s", bt_hex(irk, 16)); - BT_DBG("r %s", bt_hex(r, 3)); + LOG_DBG("irk %s", bt_hex(irk, 16)); + LOG_DBG("r %s", bt_hex(r, 3)); /* r' = padding || r */ memcpy(res, r, 3); @@ -86,7 +87,7 @@ bool bt_rpa_irk_matches(const uint8_t irk[16], const bt_addr_t *addr) uint8_t hash[3]; int err; - BT_DBG("IRK %s bdaddr %s", bt_hex(irk, 16), bt_addr_str(addr)); + LOG_DBG("IRK %s bdaddr %s", bt_hex(irk, 16), bt_addr_str(addr)); err = ah(irk, addr->val + 3, hash); if (err) { @@ -114,7 +115,7 @@ int bt_rpa_create(const uint8_t irk[16], bt_addr_t *rpa) return err; } - BT_DBG("Created RPA %s", bt_addr_str((bt_addr_t *)rpa->val)); + LOG_DBG("Created RPA %s", bt_addr_str((bt_addr_t *)rpa->val)); return 0; } diff --git a/subsys/bluetooth/controller/crypto/crypto.c b/subsys/bluetooth/controller/crypto/crypto.c index 48aaaf01bd0..fbff335f288 100644 --- a/subsys/bluetooth/controller/crypto/crypto.c +++ b/subsys/bluetooth/controller/crypto/crypto.c @@ -4,9 +4,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_crypto -#include "common/log.h" #include "common/bt_str.h" #include "util/memq.h" @@ -14,6 +11,10 @@ #include "hal/ecb.h" #include "lll.h" +#define LOG_LEVEL CONFIG_BT_HCI_DRIVER_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_ctlr_crypto); + int bt_rand(void *buf, size_t len) { return lll_csrand_get(buf, len); @@ -22,12 +23,12 @@ int bt_rand(void *buf, size_t len) int bt_encrypt_le(const uint8_t key[16], const uint8_t plaintext[16], uint8_t enc_data[16]) { - BT_DBG("key %s", bt_hex(key, 16)); - BT_DBG("plaintext %s", bt_hex(plaintext, 16)); + LOG_DBG("key %s", bt_hex(key, 16)); + LOG_DBG("plaintext %s", bt_hex(plaintext, 16)); ecb_encrypt(key, plaintext, enc_data, NULL); - BT_DBG("enc_data %s", bt_hex(enc_data, 16)); + LOG_DBG("enc_data %s", bt_hex(enc_data, 16)); return 0; } @@ -35,12 +36,12 @@ int bt_encrypt_le(const uint8_t key[16], const uint8_t plaintext[16], int bt_encrypt_be(const uint8_t key[16], const uint8_t plaintext[16], uint8_t enc_data[16]) { - BT_DBG("key %s", bt_hex(key, 16)); - BT_DBG("plaintext %s", bt_hex(plaintext, 16)); + LOG_DBG("key %s", bt_hex(key, 16)); + LOG_DBG("plaintext %s", bt_hex(plaintext, 16)); ecb_encrypt_be(key, plaintext, enc_data); - BT_DBG("enc_data %s", bt_hex(enc_data, 16)); + LOG_DBG("enc_data %s", bt_hex(enc_data, 16)); return 0; } diff --git a/subsys/bluetooth/controller/hci/hci.c b/subsys/bluetooth/controller/hci/hci.c index 86d06c4bbba..88af97eb03f 100644 --- a/subsys/bluetooth/controller/hci/hci.c +++ b/subsys/bluetooth/controller/hci/hci.c @@ -89,12 +89,13 @@ #include "hci_user_ext.h" #endif /* CONFIG_BT_CTLR_USER_EXT */ -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_hci -#include "common/log.h" #include "common/bt_str.h" #include "hal/debug.h" +#define LOG_LEVEL CONFIG_BT_HCI_DRIVER_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_ctlr_hci); + #define STR_NULL_TERMINATOR 0x00 /* opcode of the HCI command currently being processed. The opcode is stored @@ -542,7 +543,7 @@ static void host_buffer_size(struct net_buf *buf, struct net_buf **evt) return; } - BT_DBG("FC: host buf size: %d", acl_pkts); + LOG_DBG("FC: host buf size: %d", acl_pkts); hci_hbuf_total = -acl_pkts; } @@ -580,7 +581,7 @@ static void host_num_completed_packets(struct net_buf *buf, count += c; } - BT_DBG("FC: acked: %d", count); + LOG_DBG("FC: acked: %d", count); hci_hbuf_acked += count; k_poll_signal_raise(hbuf_signal, 0x0); } @@ -1576,8 +1577,7 @@ static void le_read_supp_states(struct net_buf *buf, struct net_buf **evt) * Initiating State + Active Scanning */ states &= ~(BIT64(22) | BIT64(23)); - BT_DBG("states: 0x%08x%08x", (uint32_t)(states >> 32), - (uint32_t)(states & 0xffffffff)); + LOG_DBG("states: 0x%08x%08x", (uint32_t)(states >> 32), (uint32_t)(states & 0xffffffff)); sys_put_le64(states, rp->le_states); } @@ -5029,7 +5029,7 @@ struct net_buf *hci_vs_err_stack_frame(unsigned int reason, const z_arch_esf_t * vs_err_fatal_cpu_data_fill( (bt_hci_vs_fatal_error_cpu_data *)sf->cpu_data, esf); } else { - BT_ERR("Can't create HCI Fatal Error event"); + LOG_ERR("Can't create HCI Fatal Error event"); } return buf; @@ -5091,7 +5091,7 @@ static struct net_buf *hci_vs_err_trace_create(uint8_t data_type, net_buf_add_u8(buf, STR_NULL_TERMINATOR); net_buf_add_le32(buf, line); } else { - BT_ERR("Can't create HCI Fatal Error event"); + LOG_ERR("Can't create HCI Fatal Error event"); } } } @@ -5408,7 +5408,7 @@ static int mesh_cmd_handle(struct net_buf *cmd, struct net_buf **evt) uint8_t mesh_op; if (cmd->len < sizeof(*cp_mesh)) { - BT_ERR("No HCI VSD Command header"); + LOG_ERR("No HCI VSD Command header"); return -EINVAL; } @@ -5522,13 +5522,13 @@ struct net_buf *hci_cmd_handle(struct net_buf *cmd, void **node_rx) int err; if (cmd->len < sizeof(*chdr)) { - BT_ERR("No HCI Command header"); + LOG_ERR("No HCI Command header"); return NULL; } chdr = net_buf_pull_mem(cmd, sizeof(*chdr)); if (cmd->len < chdr->param_len) { - BT_ERR("Invalid HCI CMD packet length"); + LOG_ERR("Invalid HCI CMD packet length"); return NULL; } @@ -5603,7 +5603,7 @@ int hci_acl_handle(struct net_buf *buf, struct net_buf **evt) *evt = NULL; if (buf->len < sizeof(*acl)) { - BT_ERR("No HCI ACL header"); + LOG_ERR("No HCI ACL header"); return -EINVAL; } @@ -5612,12 +5612,12 @@ int hci_acl_handle(struct net_buf *buf, struct net_buf **evt) handle = sys_le16_to_cpu(acl->handle); if (buf->len < len) { - BT_ERR("Invalid HCI ACL packet length"); + LOG_ERR("Invalid HCI ACL packet length"); return -EINVAL; } if (len > LL_LENGTH_OCTETS_TX_MAX) { - BT_ERR("Invalid HCI ACL Data length"); + LOG_ERR("Invalid HCI ACL Data length"); return -EINVAL; } @@ -5627,7 +5627,7 @@ int hci_acl_handle(struct net_buf *buf, struct net_buf **evt) node_tx = ll_tx_mem_acquire(); if (!node_tx) { - BT_ERR("Tx Buffer Overflow"); + LOG_ERR("Tx Buffer Overflow"); data_buf_overflow(evt, BT_OVERFLOW_LINK_ACL); return -ENOBUFS; } @@ -5656,7 +5656,7 @@ int hci_acl_handle(struct net_buf *buf, struct net_buf **evt) memcpy(&pdu_data->lldata[0], buf->data, len); if (ll_tx_mem_enqueue(handle, node_tx)) { - BT_ERR("Invalid Tx Enqueue"); + LOG_ERR("Invalid Tx Enqueue"); ll_tx_mem_release(node_tx); return -EINVAL; } @@ -5686,7 +5686,7 @@ int hci_iso_handle(struct net_buf *buf, struct net_buf **evt) dp_in = NULL; if (buf->len < sizeof(*iso_hdr)) { - BT_ERR("No HCI ISO header"); + LOG_ERR("No HCI ISO header"); return -EINVAL; } @@ -5695,7 +5695,7 @@ int hci_iso_handle(struct net_buf *buf, struct net_buf **evt) len = sys_le16_to_cpu(iso_hdr->len); if (buf->len < len) { - BT_ERR("Invalid HCI ISO packet length"); + LOG_ERR("Invalid HCI ISO packet length"); return -EINVAL; } @@ -5786,7 +5786,7 @@ int hci_iso_handle(struct net_buf *buf, struct net_buf **evt) /* Get controller's input data path for CIS */ dp_in = hdr->datapath_in; if (!dp_in || dp_in->path_id != BT_HCI_DATAPATH_ID_HCI) { - BT_ERR("Input data path not set for HCI"); + LOG_ERR("Input data path not set for HCI"); return -EINVAL; } @@ -5815,7 +5815,7 @@ int hci_iso_handle(struct net_buf *buf, struct net_buf **evt) /* Check invalid BIS PDU length */ if (slen > LL_BIS_OCTETS_TX_MAX) { - BT_ERR("Invalid HCI ISO Data length"); + LOG_ERR("Invalid HCI ISO Data length"); return -EINVAL; } @@ -5830,7 +5830,7 @@ int hci_iso_handle(struct net_buf *buf, struct net_buf **evt) stream = ull_adv_iso_stream_get(stream_handle); if (!stream) { - BT_ERR("Invalid BIS stream"); + LOG_ERR("Invalid BIS stream"); return -EINVAL; } @@ -5838,14 +5838,14 @@ int hci_iso_handle(struct net_buf *buf, struct net_buf **evt) adv_iso = ull_adv_iso_by_stream_get(stream_handle); if (!adv_iso) { - BT_ERR("No BIG associated with stream handle"); + LOG_ERR("No BIG associated with stream handle"); return -EINVAL; } /* Get free node tx */ tx = ll_iso_tx_mem_acquire(); if (!tx) { - BT_ERR("ISO Tx Buffer Overflow"); + LOG_ERR("ISO Tx Buffer Overflow"); data_buf_overflow(evt, BT_OVERFLOW_LINK_ISO); return -ENOBUFS; } @@ -5884,7 +5884,7 @@ int hci_iso_handle(struct net_buf *buf, struct net_buf **evt) stream->pkt_seq_num++; if (ll_iso_tx_mem_enqueue(handle, tx, NULL)) { - BT_ERR("Invalid ISO Tx Enqueue"); + LOG_ERR("Invalid ISO Tx Enqueue"); ll_iso_tx_mem_release(tx); return -EINVAL; } @@ -6824,7 +6824,7 @@ static void le_ext_adv_report(struct pdu_data *pdu_data, /* The Link Layer currently returns RSSI as an absolute value */ rssi = -(node_rx_curr->hdr.rx_ftr.rssi); - BT_DBG("phy= 0x%x, type= 0x%x, len= %u, tat= %u, rat= %u," + LOG_DBG("phy= 0x%x, type= 0x%x, len= %u, tat= %u, rat= %u," " rssi=%d dB", phy, adv->type, adv->len, adv->tx_addr, adv->rx_addr, rssi); @@ -6832,8 +6832,7 @@ static void le_ext_adv_report(struct pdu_data *pdu_data, h = (void *)p->ext_hdr_adv_data; ptr = (void *)h; - BT_DBG(" Ext. adv mode= 0x%x, hdr len= %u", p->adv_mode, - p->ext_hdr_len); + LOG_DBG(" Ext. adv mode= 0x%x, hdr len= %u", p->adv_mode, p->ext_hdr_len); evt_type_curr = p->adv_mode; @@ -6855,7 +6854,7 @@ static void le_ext_adv_report(struct pdu_data *pdu_data, (void)memcpy(addr.a.val, ptr, sizeof(bt_addr_t)); ptr += BDADDR_SIZE; - BT_DBG(" AdvA: %s", bt_addr_le_str(&addr)); + LOG_DBG(" AdvA: %s", bt_addr_le_str(&addr)); } if (h->tgt_addr) { @@ -6885,7 +6884,7 @@ static void le_ext_adv_report(struct pdu_data *pdu_data, (void)memcpy(addr.a.val, direct_addr_curr, sizeof(bt_addr_t)); - BT_DBG(" TgtA: %s", bt_addr_le_str(&addr)); + LOG_DBG(" TgtA: %s", bt_addr_le_str(&addr)); } if (h->adi) { @@ -6893,8 +6892,8 @@ static void le_ext_adv_report(struct pdu_data *pdu_data, ptr += sizeof(*adi); - BT_DBG(" AdvDataInfo DID = 0x%x, SID = 0x%x", - adi_curr->did, adi_curr->sid); + LOG_DBG(" AdvDataInfo DID = 0x%x, SID = 0x%x", adi_curr->did, + adi_curr->sid); } if (h->aux_ptr) { @@ -6916,7 +6915,7 @@ static void le_ext_adv_report(struct pdu_data *pdu_data, aux_phy = BIT(PDU_ADV_AUX_PTR_PHY_GET(aux_ptr)); - BT_DBG(" AuxPtr chan_idx = %u, ca = %u, offs_units " + LOG_DBG(" AuxPtr chan_idx = %u, ca = %u, offs_units " "= %u offs = 0x%x, phy = 0x%x", aux_ptr->chan_idx, aux_ptr->ca, aux_ptr->offs_units, PDU_ADV_AUX_PTR_OFFSET_GET(aux_ptr), aux_phy); @@ -6930,7 +6929,7 @@ static void le_ext_adv_report(struct pdu_data *pdu_data, interval_le16 = si->interval; - BT_DBG(" SyncInfo offs = %u, offs_unit = 0x%x, " + LOG_DBG(" SyncInfo offs = %u, offs_unit = 0x%x, " "interval = 0x%x, sca = 0x%x, " "chan map = 0x%x 0x%x 0x%x 0x%x 0x%x, " "AA = 0x%x, CRC = 0x%x 0x%x 0x%x, " @@ -6954,14 +6953,13 @@ static void le_ext_adv_report(struct pdu_data *pdu_data, tx_pwr_curr = *(int8_t *)ptr; ptr++; - BT_DBG(" Tx pwr= %d dB", tx_pwr_curr); + LOG_DBG(" Tx pwr= %d dB", tx_pwr_curr); } hdr_len = ptr - (uint8_t *)p; hdr_buf_len = PDU_AC_EXT_HEADER_SIZE_MIN + p->ext_hdr_len; if (hdr_len > hdr_buf_len) { - BT_WARN(" Header length %u/%u, INVALID.", hdr_len, - p->ext_hdr_len); + LOG_WRN(" Header length %u/%u, INVALID.", hdr_len, p->ext_hdr_len); } else { uint8_t acad_len = hdr_buf_len - hdr_len; @@ -6976,7 +6974,7 @@ no_ext_hdr: data_len_curr = adv->len - hdr_len; data_curr = ptr; - BT_DBG(" AD Data (%u): ", data_len); + LOG_DBG(" AD Data (%u): ", data_len); } if (node_rx_curr == node_rx) { @@ -7378,14 +7376,13 @@ static void le_per_adv_sync_report(struct pdu_data *pdu_data, /* The Link Layer currently returns RSSI as an absolute value */ rssi = -(node_rx->hdr.rx_ftr.rssi); - BT_DBG("len = %u, rssi = %d", adv->len, rssi); + LOG_DBG("len = %u, rssi = %d", adv->len, rssi); p = (void *)&adv->adv_ext_ind; h = (void *)p->ext_hdr_adv_data; ptr = (void *)h; - BT_DBG(" Per. adv mode= 0x%x, hdr len= %u", p->adv_mode, - p->ext_hdr_len); + LOG_DBG(" Per. adv mode= 0x%x, hdr len= %u", p->adv_mode, p->ext_hdr_len); if (!p->ext_hdr_len) { hdr_len = PDU_AC_EXT_HEADER_SIZE_MIN; @@ -7410,7 +7407,7 @@ static void le_per_adv_sync_report(struct pdu_data *pdu_data, cte_type = cte_info->type; ptr++; - BT_DBG(" CTE type= %d", cte_type); + LOG_DBG(" CTE type= %d", cte_type); } if (h->adi) { @@ -7432,7 +7429,7 @@ static void le_per_adv_sync_report(struct pdu_data *pdu_data, aux_phy = BIT(PDU_ADV_AUX_PTR_PHY_GET(aux_ptr)); - BT_DBG(" AuxPtr chan_idx = %u, ca = %u, offs_units " + LOG_DBG(" AuxPtr chan_idx = %u, ca = %u, offs_units " "= %u offs = 0x%x, phy = 0x%x", aux_ptr->chan_idx, aux_ptr->ca, aux_ptr->offs_units, PDU_ADV_AUX_PTR_OFFSET_GET(aux_ptr), aux_phy); @@ -7448,14 +7445,13 @@ static void le_per_adv_sync_report(struct pdu_data *pdu_data, tx_pwr = *(int8_t *)ptr; ptr++; - BT_DBG(" Tx pwr= %d dB", tx_pwr); + LOG_DBG(" Tx pwr= %d dB", tx_pwr); } hdr_len = ptr - (uint8_t *)p; hdr_buf_len = PDU_AC_EXT_HEADER_SIZE_MIN + p->ext_hdr_len; if (hdr_len > hdr_buf_len) { - BT_WARN(" Header length %u/%u, INVALID.", hdr_len, - p->ext_hdr_len); + LOG_WRN(" Header length %u/%u, INVALID.", hdr_len, p->ext_hdr_len); } else { acad_len = hdr_buf_len - hdr_len; if (acad_len) { @@ -7471,7 +7467,7 @@ no_ext_hdr: data_len = adv->len - hdr_len; data = ptr; - BT_DBG(" AD Data (%u): ", data_len); + LOG_DBG(" AD Data (%u): ", data_len); } if (0) { @@ -7846,8 +7842,7 @@ static void le_scan_req_received(struct pdu_data *pdu_data, /* The Link Layer currently returns RSSI as an absolute value */ rssi = -(node_rx->hdr.rx_ftr.rssi); - BT_DBG("handle: %d, addr: %s, rssi: %d dB.", - handle, bt_addr_le_str(&addr), rssi); + LOG_DBG("handle: %d, addr: %s, rssi: %d dB.", handle, bt_addr_le_str(&addr), rssi); return; } @@ -8080,7 +8075,7 @@ static void le_chan_sel_algo(struct pdu_data *pdu_data, uint16_t handle, if (!(event_mask & BT_EVT_MASK_LE_META_EVENT) || !(le_event_mask & BT_EVT_MASK_LE_CHAN_SEL_ALGO)) { - BT_DBG("handle: 0x%04x, CSA: %x.", handle, cs->csa); + LOG_DBG("handle: 0x%04x, CSA: %x.", handle, cs->csa); return; } @@ -8102,10 +8097,8 @@ static void le_phy_upd_complete(struct pdu_data *pdu_data, uint16_t handle, if (!(event_mask & BT_EVT_MASK_LE_META_EVENT) || !(le_event_mask & BT_EVT_MASK_LE_PHY_UPDATE_COMPLETE)) { - BT_WARN("handle: 0x%04x, status: %x, tx: %x, rx: %x.", handle, - pu->status, - find_lsb_set(pu->tx), - find_lsb_set(pu->rx)); + LOG_WRN("handle: 0x%04x, status: %x, tx: %x, rx: %x.", handle, pu->status, + find_lsb_set(pu->tx), find_lsb_set(pu->rx)); return; } @@ -8129,7 +8122,7 @@ static void le_req_peer_sca_complete(struct pdu_data *pdu, uint16_t handle, if (!(event_mask & BT_EVT_MASK_LE_META_EVENT) || !(le_event_mask & BT_EVT_MASK_LE_REQ_PEER_SCA_COMPLETE)) { - BT_WARN("handle: 0x%04x, status: %x, sca: %x.", handle, + LOG_WRN("handle: 0x%04x, status: %x, sca: %x.", handle, scau->status, scau->sca); return; @@ -8292,8 +8285,7 @@ static void encode_control(struct node_rx_pdu *node_rx, #if defined(CONFIG_BT_CTLR_CONN_RSSI_EVENT) case NODE_RX_TYPE_RSSI: - BT_INFO("handle: 0x%04x, rssi: -%d dB.", handle, - pdu_data->rssi); + LOG_INF("handle: 0x%04x, rssi: -%d dB.", handle, pdu_data->rssi); return; #endif /* CONFIG_BT_CTLR_CONN_RSSI_EVENT */ @@ -8328,28 +8320,22 @@ static void encode_control(struct node_rx_pdu *node_rx, #if defined(CONFIG_BT_CTLR_ADV_INDICATION) case NODE_RX_TYPE_ADV_INDICATION: - BT_INFO("Advertised."); + LOG_INF("Advertised."); return; #endif /* CONFIG_BT_CTLR_ADV_INDICATION */ #if defined(CONFIG_BT_CTLR_SCAN_INDICATION) case NODE_RX_TYPE_SCAN_INDICATION: - BT_INFO("Scanned."); + LOG_INF("Scanned."); return; #endif /* CONFIG_BT_CTLR_SCAN_INDICATION */ #if defined(CONFIG_BT_CTLR_PROFILE_ISR) case NODE_RX_TYPE_PROFILE: - BT_INFO("l: %u, %u, %u; t: %u, %u, %u; cpu: %u, %u, %u, %u.", - pdu_data->profile.lcur, - pdu_data->profile.lmin, - pdu_data->profile.lmax, - pdu_data->profile.cur, - pdu_data->profile.min, - pdu_data->profile.max, - pdu_data->profile.radio, - pdu_data->profile.lll, - pdu_data->profile.ull_high, + LOG_INF("l: %u, %u, %u; t: %u, %u, %u; cpu: %u, %u, %u, %u.", + pdu_data->profile.lcur, pdu_data->profile.lmin, pdu_data->profile.lmax, + pdu_data->profile.cur, pdu_data->profile.min, pdu_data->profile.max, + pdu_data->profile.radio, pdu_data->profile.lll, pdu_data->profile.ull_high, pdu_data->profile.ull_low); return; #endif /* CONFIG_BT_CTLR_PROFILE_ISR */ @@ -8456,7 +8442,7 @@ static void le_unknown_rsp(struct pdu_data *pdu_data, uint16_t handle, break; #endif /* CONFIG_BT_CTLR_DF_CONN_CTE_REQ */ default: - BT_WARN("type: 0x%02x", pdu_data->llctrl.unknown_rsp.type); + LOG_WRN("type: 0x%02x", pdu_data->llctrl.unknown_rsp.type); break; } } @@ -8470,7 +8456,7 @@ static void le_reject_ext_ind(struct pdu_data *pdu, uint16_t handle, struct net_ break; #endif /* CONFIG_BT_CTLR_DF_CONN_CTE_REQ */ default: - BT_WARN("reject opcode: 0x%02x", pdu->llctrl.reject_ext_ind.reject_opcode); + LOG_WRN("reject opcode: 0x%02x", pdu->llctrl.reject_ext_ind.reject_opcode); break; } } diff --git a/subsys/bluetooth/controller/hci/hci_driver.c b/subsys/bluetooth/controller/hci/hci_driver.c index b0836767303..b1999a7981e 100644 --- a/subsys/bluetooth/controller/hci/hci_driver.c +++ b/subsys/bluetooth/controller/hci/hci_driver.c @@ -28,9 +28,6 @@ #include #endif -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_hci_driver -#include "common/log.h" #include "hal/debug.h" #include "util/util.h" @@ -63,6 +60,10 @@ #include "hci_internal.h" +#define LOG_LEVEL CONFIG_BT_HCI_DRIVER_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_ctlr_hci_driver); + static struct k_sem sem_prio_recv; static struct k_fifo recv_fifo; @@ -281,7 +282,7 @@ static void prio_recv_thread(void *p1, void *p2, void *p3) /* Send the rx node up to Host thread, * recv_thread() */ - BT_DBG("ISO RX node enqueue"); + LOG_DBG("ISO RX node enqueue"); k_fifo_put(&recv_fifo, node_rx); iso_received = true; @@ -296,7 +297,7 @@ static void prio_recv_thread(void *p1, void *p2, void *p3) buf = bt_buf_get_evt(BT_HCI_EVT_NUM_COMPLETED_PACKETS, false, K_FOREVER); hci_num_cmplt_encode(buf, handle, num_cmplt); - BT_DBG("Num Complete: 0x%04x:%u", handle, num_cmplt); + LOG_DBG("Num Complete: 0x%04x:%u", handle, num_cmplt); bt_recv_prio(buf); k_yield(); #endif /* CONFIG_BT_CONN || CONFIG_BT_CTLR_ADV_ISO || CONFIG_BT_CTLR_CONN_ISO */ @@ -315,7 +316,7 @@ static void prio_recv_thread(void *p1, void *p2, void *p3) buf = process_prio_evt(node_rx, &evt_flags); if (buf) { - BT_DBG("Priority event"); + LOG_DBG("Priority event"); if (!(evt_flags & BT_HCI_EVT_FLAG_RECV)) { node_rx->hdr.next = NULL; ll_rx_mem_release((void **)&node_rx); @@ -334,7 +335,7 @@ static void prio_recv_thread(void *p1, void *p2, void *p3) /* Send the rx node up to Host thread, * recv_thread() */ - BT_DBG("RX node enqueue"); + LOG_DBG("RX node enqueue"); k_fifo_put(&recv_fifo, node_rx); } } @@ -347,14 +348,14 @@ static void prio_recv_thread(void *p1, void *p2, void *p3) continue; } - BT_DBG("sem take..."); + LOG_DBG("sem take..."); /* Wait until ULL mayfly has something to give us. * Blocking-take of the semaphore; we take it once ULL mayfly * has let it go in ll_rx_sched(). */ k_sem_take(&sem_prio_recv, K_FOREVER); /* Now, ULL mayfly has something to give to us */ - BT_DBG("sem taken"); + LOG_DBG("sem taken"); } } @@ -476,7 +477,7 @@ static inline struct net_buf *process_node(struct node_rx_pdu *node_rx) case HCI_CLASS_ACL_DATA: if (pend || !hbuf_count) { sys_slist_append(&hbuf_pend, (void *)node_rx); - BT_DBG("FC: Queuing item: %d", class); + LOG_DBG("FC: Queuing item: %d", class); return NULL; } break; @@ -530,7 +531,7 @@ static inline struct net_buf *process_hbuf(struct node_rx_pdu *n) class == HCI_CLASS_EVT_LLCP || (class == HCI_CLASS_ACL_DATA && hbuf_count)) { /* node to process later, schedule an iteration */ - BT_DBG("FC: signalling"); + LOG_DBG("FC: signalling"); k_poll_signal_raise(&hbuf_signal, 0x0); } return NULL; @@ -539,12 +540,12 @@ static inline struct net_buf *process_hbuf(struct node_rx_pdu *n) switch (class) { case HCI_CLASS_EVT_CONNECTION: case HCI_CLASS_EVT_LLCP: - BT_DBG("FC: dequeueing event"); + LOG_DBG("FC: dequeueing event"); (void) sys_slist_get(&hbuf_pend); break; case HCI_CLASS_ACL_DATA: if (hbuf_count) { - BT_DBG("FC: dequeueing ACL data"); + LOG_DBG("FC: dequeueing ACL data"); (void) sys_slist_get(&hbuf_pend); } else { /* no buffers, HCI will signal */ @@ -573,7 +574,7 @@ static inline struct net_buf *process_hbuf(struct node_rx_pdu *n) /* more to process, schedule an * iteration */ - BT_DBG("FC: signalling"); + LOG_DBG("FC: signalling"); k_poll_signal_raise(&hbuf_signal, 0x0); } } @@ -605,7 +606,7 @@ static void recv_thread(void *p1, void *p2, void *p3) struct node_rx_pdu *node_rx = NULL; struct net_buf *buf = NULL; - BT_DBG("blocking"); + LOG_DBG("blocking"); #if defined(CONFIG_BT_HCI_ACL_FLOW_CONTROL) int err; @@ -627,7 +628,7 @@ static void recv_thread(void *p1, void *p2, void *p3) #else node_rx = k_fifo_get(&recv_fifo, K_FOREVER); #endif - BT_DBG("unblocked"); + LOG_DBG("unblocked"); if (node_rx && !buf) { /* process regular node from radio */ @@ -644,8 +645,7 @@ static void recv_thread(void *p1, void *p2, void *p3) buf = net_buf_frag_del(NULL, buf); if (frag->len) { - BT_DBG("Packet in: type:%u len:%u", - bt_buf_get_type(frag), + LOG_DBG("Packet in: type:%u len:%u", bt_buf_get_type(frag), frag->len); bt_recv(frag); @@ -665,11 +665,11 @@ static int cmd_handle(struct net_buf *buf) evt = hci_cmd_handle(buf, (void **) &node_rx); if (evt) { - BT_DBG("Replying with event of %u bytes", evt->len); + LOG_DBG("Replying with event of %u bytes", evt->len); bt_recv_prio(evt); if (node_rx) { - BT_DBG("RX node enqueue"); + LOG_DBG("RX node enqueue"); node_rx->hdr.user_meta = hci_get_class(node_rx); k_fifo_put(&recv_fifo, node_rx); } @@ -686,7 +686,7 @@ static int acl_handle(struct net_buf *buf) err = hci_acl_handle(buf, &evt); if (evt) { - BT_DBG("Replying with event of %u bytes", evt->len); + LOG_DBG("Replying with event of %u bytes", evt->len); bt_recv_prio(evt); } @@ -702,7 +702,7 @@ static int iso_handle(struct net_buf *buf) err = hci_iso_handle(buf, &evt); if (evt) { - BT_DBG("Replying with event of %u bytes", evt->len); + LOG_DBG("Replying with event of %u bytes", evt->len); bt_recv_prio(evt); } @@ -715,10 +715,10 @@ static int hci_driver_send(struct net_buf *buf) uint8_t type; int err; - BT_DBG("enter"); + LOG_DBG("enter"); if (!buf->len) { - BT_ERR("Empty HCI packet"); + LOG_ERR("Empty HCI packet"); return -EINVAL; } @@ -738,7 +738,7 @@ static int hci_driver_send(struct net_buf *buf) break; #endif /* CONFIG_BT_CTLR_ADV_ISO || CONFIG_BT_CTLR_CONN_ISO */ default: - BT_ERR("Unknown HCI type %u", type); + LOG_ERR("Unknown HCI type %u", type); return -EINVAL; } @@ -746,7 +746,7 @@ static int hci_driver_send(struct net_buf *buf) net_buf_unref(buf); } - BT_DBG("exit: %d", err); + LOG_DBG("exit: %d", err); return err; } @@ -762,7 +762,7 @@ static int hci_driver_open(void) err = ll_init(&sem_prio_recv); if (err) { - BT_ERR("LL initialization failed: %d", err); + LOG_ERR("LL initialization failed: %d", err); return err; } @@ -785,7 +785,7 @@ static int hci_driver_open(void) K_PRIO_COOP(CONFIG_BT_RX_PRIO), 0, K_NO_WAIT); k_thread_name_set(&recv_thread_data, "BT RX"); - BT_DBG("Success."); + LOG_DBG("Success."); return 0; } diff --git a/subsys/bluetooth/controller/ll_sw/isoal.c b/subsys/bluetooth/controller/ll_sw/isoal.c index 26a3dccb6e9..ef9a41d24cb 100644 --- a/subsys/bluetooth/controller/ll_sw/isoal.c +++ b/subsys/bluetooth/controller/ll_sw/isoal.c @@ -14,6 +14,7 @@ #include #include +#include #include "util/memq.h" @@ -29,8 +30,10 @@ #include "isoal.h" #include "ull_iso_types.h" -#define LOG_MODULE_NAME bt_ctlr_isoal -#include "common/log.h" +#include + +LOG_MODULE_REGISTER(bt_ctlr_isoal, LOG_LEVEL_DBG); + #include "hal/debug.h" #if defined(CONFIG_BT_CTLR_ADV_ISO) || defined(CONFIG_BT_CTLR_CONN_ISO) @@ -751,7 +754,7 @@ static isoal_status_t isoal_rx_unframed_consume(struct isoal_sink *sink, } else { /* Unsupported case */ err = ISOAL_STATUS_ERR_UNSPECIFIED; - BT_ERR("Invalid unframed LLID (%d)", llid); + LOG_ERR("Invalid unframed LLID (%d)", llid); LL_ASSERT(0); } break; @@ -1223,7 +1226,7 @@ static isoal_status_t isoal_check_source_hdl_valid(isoal_source_handle_t hdl) return ISOAL_STATUS_OK; } - BT_ERR("Invalid source handle (0x%02x)", hdl); + LOG_ERR("Invalid source handle (0x%02x)", hdl); return ISOAL_STATUS_ERR_UNSPECIFIED; } @@ -1404,7 +1407,7 @@ static isoal_status_t isoal_tx_pdu_emit(const struct isoal_source *source_ctx, /* If it fails, the node will be released and no further attempt * will be possible */ - BT_ERR("Failed to enqueue node (%p)", node_tx); + LOG_ERR("Failed to enqueue node (%p)", node_tx); source_ctx->session.pdu_release(node_tx, handle, status); } diff --git a/subsys/bluetooth/controller/ll_sw/ll_feat.c b/subsys/bluetooth/controller/ll_sw/ll_feat.c index a3161e57fa5..0f935fc22d8 100644 --- a/subsys/bluetooth/controller/ll_sw/ll_feat.c +++ b/subsys/bluetooth/controller/ll_sw/ll_feat.c @@ -24,9 +24,8 @@ #include "ll_feat.h" #include "ll_settings.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_ll_feat -#include "common/log.h" +#include + #include "hal/debug.h" #if defined(CONFIG_BT_CTLR_SET_HOST_FEATURE) diff --git a/subsys/bluetooth/controller/ll_sw/ll_settings.c b/subsys/bluetooth/controller/ll_sw/ll_settings.c index b01ea005fb7..75723e4cf62 100644 --- a/subsys/bluetooth/controller/ll_sw/ll_settings.c +++ b/subsys/bluetooth/controller/ll_sw/ll_settings.c @@ -12,8 +12,10 @@ #include "ll_settings.h" -#define LOG_MODULE_NAME bt_ctlr_ll_settings -#include "common/log.h" +#include + +LOG_MODULE_REGISTER(bt_ctlr_ll_settings, LOG_LEVEL_DBG); + #include "hal/debug.h" #if defined(CONFIG_BT_CTLR_VERSION_SETTINGS) @@ -56,20 +58,20 @@ static int ctlr_set(const char *name, size_t len_rd, if (!strncmp(name, "company", nlen)) { len = read_cb(store, &company_id, sizeof(company_id)); if (len < 0) { - BT_ERR("Failed to read Company Id from storage" + LOG_ERR("Failed to read Company Id from storage" " (err %zd)", len); } else { - BT_DBG("Company Id set to %04x", company_id); + LOG_DBG("Company Id set to %04x", company_id); } return 0; } if (!strncmp(name, "subver", nlen)) { len = read_cb(store, &subversion, sizeof(subversion)); if (len < 0) { - BT_ERR("Failed to read Subversion from storage" + LOG_ERR("Failed to read Subversion from storage" " (err %zd)", len); } else { - BT_DBG("Subversion set to %04x", subversion); + LOG_DBG("Subversion set to %04x", subversion); } return 0; } @@ -79,10 +81,10 @@ static int ctlr_set(const char *name, size_t len_rd, if (!strncmp(name, "smi_tx", nlen)) { len = read_cb(store, &smi_tx, sizeof(smi_tx)); if (len < 0) { - BT_ERR("Failed to read SMI TX flag from storage" + LOG_ERR("Failed to read SMI TX flag from storage" " (err %zd)", len); } else { - BT_DBG("SMI TX flag set to %04x", smi_tx); + LOG_DBG("SMI TX flag set to %04x", smi_tx); } return 0; } diff --git a/subsys/bluetooth/controller/ll_sw/lll_chan.c b/subsys/bluetooth/controller/ll_sw/lll_chan.c index fb657697ddf..0ab3843a81a 100644 --- a/subsys/bluetooth/controller/ll_sw/lll_chan.c +++ b/subsys/bluetooth/controller/ll_sw/lll_chan.c @@ -9,9 +9,6 @@ #include "hal/ccm.h" #include "hal/radio.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_lll_chan -#include "common/log.h" #include #include "hal/debug.h" diff --git a/subsys/bluetooth/controller/ll_sw/lll_common.c b/subsys/bluetooth/controller/ll_sw/lll_common.c index 407836850ae..a91e933b402 100644 --- a/subsys/bluetooth/controller/ll_sw/lll_common.c +++ b/subsys/bluetooth/controller/ll_sw/lll_common.c @@ -13,9 +13,6 @@ #include "lll.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_lll_common -#include "common/log.h" #include "hal/debug.h" /** diff --git a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/cntr.c b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/cntr.c index bca6f2eb2a2..c566a86c3ab 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/cntr.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/cntr.c @@ -11,9 +11,6 @@ #include "hal/cntr.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_hal_cntr -#include "common/log.h" #include "hal/debug.h" #ifndef NRF_RTC diff --git a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/ecb.c b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/ecb.c index ef7d8739567..9bf7eb3b10d 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/ecb.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/ecb.c @@ -14,9 +14,6 @@ #include "util/mem.h" #include "hal/ecb.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_hal_ecb -#include "common/log.h" #include "hal/debug.h" struct ecb_param { diff --git a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/mayfly.c b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/mayfly.c index 188b827ca59..d09960d49ed 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/mayfly.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/mayfly.c @@ -14,9 +14,6 @@ #include "ll_sw/lll.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_hal_mayfly -#include "common/log.h" #include "hal/debug.h" #define MAYFLY_CALL_ID_LLL TICKER_USER_ID_LLL diff --git a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/ticker.c b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/ticker.c index 1f925ecac3f..ae9dd686133 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/ticker.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/ticker.c @@ -18,9 +18,6 @@ #include "ll_sw/lll.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_hal_ticker -#include "common/log.h" #include "hal/debug.h" #define TICKER_MAYFLY_CALL_ID_ISR TICKER_USER_ID_LLL diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll.c index 6f85210cb53..bf5b5556022 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll.c @@ -33,9 +33,6 @@ #include "lll_internal.h" #include "lll_prof_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_lll -#include "common/log.h" #include "hal/debug.h" #if defined(CONFIG_BT_CTLR_ZLI) diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv.c index fa588ea3a3b..186170ba76d 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv.c @@ -47,9 +47,6 @@ #include "lll_prof_internal.h" #include "lll_df_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_lll_adv -#include "common/log.h" #include "hal/debug.h" #define PDU_FREE_TIMEOUT K_SECONDS(5) diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_aux.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_aux.c index 83aaaba56da..f0a4e9a8699 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_aux.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_aux.c @@ -40,9 +40,6 @@ #include "lll_adv_internal.h" #include "lll_prof_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_lll_adv_aux -#include "common/log.h" #include "hal/debug.h" static int init_reset(void); diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_iso.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_iso.c index 63717803d52..71b7826e314 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_iso.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_iso.c @@ -5,6 +5,7 @@ */ #include +#include #include #include @@ -35,9 +36,6 @@ #include "ll_feat.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_lll_adv_iso -#include "common/log.h" #include "hal/debug.h" #define TEST_WITH_DUMMY_PDU 0 diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_sync.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_sync.c index 01a607fca33..eae7ac929b5 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_sync.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_sync.c @@ -39,9 +39,6 @@ #include "lll_prof_internal.h" #include "lll_df_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_lll_adv_sync -#include "common/log.h" #include "hal/debug.h" static int init_reset(void); diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_central.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_central.c index 285aa5567b8..8261a7ba327 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_central.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_central.c @@ -35,9 +35,6 @@ #include "lll_df_internal.h" #include "lll_tim_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_lll_central -#include "common/log.h" #include #include "hal/debug.h" diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_central_iso.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_central_iso.c index 76753fc14a8..a86146ea27e 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_central_iso.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_central_iso.c @@ -21,8 +21,6 @@ #include "lll_conn_iso.h" #include "lll_peripheral_iso.h" -#define LOG_MODULE_NAME bt_ctlr_lll_peripheral_iso -#include "common/log.h" #include "hal/debug.h" int lll_central_iso_init(void) diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_clock.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_clock.c index b86d962b482..62ce2e1d26d 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_clock.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_clock.c @@ -10,9 +10,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_lll_clock -#include "common/log.h" #include "hal/debug.h" /* Clock setup timeouts are unlikely, below values are experimental */ diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_conn.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_conn.c index 56fbf2be4bf..9ec1390d86b 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_conn.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_conn.c @@ -37,9 +37,8 @@ #include "lll_tim_internal.h" #include "lll_prof_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_lll_conn -#include "common/log.h" +#include + #include "hal/debug.h" static int init_reset(void); diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_conn_iso.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_conn_iso.c index f2b7263f832..49f57ef0e68 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_conn_iso.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_conn_iso.c @@ -17,8 +17,6 @@ #include "lll.h" #include "lll_conn_iso.h" -#define LOG_MODULE_NAME bt_ctlr_lll_conn_iso -#include "common/log.h" #include #include "hal/debug.h" diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_df.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_df.c index f1957d2b5dd..63d8fcc4a13 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_df.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_df.c @@ -28,9 +28,6 @@ #include "lll_df.h" #include "lll_df_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_CTLR_DF_DEBUG_ENABLE) -#define LOG_MODULE_NAME bt_ctlr_lll_df -#include "common/log.h" #include #include "hal/debug.h" diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_peripheral.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_peripheral.c index 026ba1f9f35..7bdbcf6cd01 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_peripheral.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_peripheral.c @@ -34,9 +34,6 @@ #include "lll_df_internal.h" #include "lll_tim_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_lll_periph -#include "common/log.h" #include #include "hal/debug.h" diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_peripheral_iso.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_peripheral_iso.c index 04c784f5fa8..15b53111f16 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_peripheral_iso.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_peripheral_iso.c @@ -18,8 +18,6 @@ #include "lll_conn_iso.h" #include "lll_peripheral_iso.h" -#define LOG_MODULE_NAME bt_ctlr_lll_peripheral_iso -#include "common/log.h" #include "hal/debug.h" int lll_peripheral_iso_init(void) diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan.c index fc718bc7a0d..d33ae28a9a2 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan.c @@ -43,9 +43,6 @@ #include "lll_prof_internal.h" #include "lll_scan_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_lll_scan -#include "common/log.h" #include "hal/debug.h" /* Maximum primary Advertising Radio Channels to scan */ diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan_aux.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan_aux.c index 2f1c150bdb4..15162acfe88 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan_aux.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan_aux.c @@ -44,9 +44,6 @@ #include "ll_feat.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_lll_scan_aux -#include "common/log.h" #include #include #include "hal/debug.h" diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_sync.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_sync.c index b962d77314c..9081b199908 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_sync.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_sync.c @@ -38,9 +38,8 @@ #include "ll_feat.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_lll_sync -#include "common/log.h" +#include + #include #include "hal/debug.h" diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_sync_iso.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_sync_iso.c index 8b83c36425d..3b932916140 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_sync_iso.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_sync_iso.c @@ -5,6 +5,7 @@ */ #include +#include #include #include @@ -30,9 +31,6 @@ #include "ll_feat.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_lll_sync_iso -#include "common/log.h" #include "hal/debug.h" static int init_reset(void); diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_test.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_test.c index 5d32a848542..dfc8513dbfc 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_test.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_test.c @@ -39,9 +39,8 @@ #include "ull_df_internal.h" #endif /* CONFIG_BT_CTLR_DTM_HCI_DF_IQ_REPORT */ -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_lll_test -#include "common/log.h" +#include + #include "hal/debug.h" #define CNTR_MIN_DELTA 3 diff --git a/subsys/bluetooth/controller/ll_sw/openisa/hal/RV32M1/ecb.c b/subsys/bluetooth/controller/ll_sw/openisa/hal/RV32M1/ecb.c index 506214c68f0..8613c094528 100644 --- a/subsys/bluetooth/controller/ll_sw/openisa/hal/RV32M1/ecb.c +++ b/subsys/bluetooth/controller/ll_sw/openisa/hal/RV32M1/ecb.c @@ -8,16 +8,20 @@ #include +#include + #include #include #include "hal/ecb.h" -#define LOG_MODULE_NAME bt_ctlr_rv32m1_ecb -#include "common/log.h" +#include + #include "hal/debug.h" #include "fsl_cau3_ble.h" +LOG_MODULE_REGISTER(bt_ctlr_rv32m1_ecb, LOG_LEVEL_DBG); + void ecb_encrypt_be(uint8_t const *const key_be, uint8_t const *const clear_text_be, uint8_t *const cipher_text_be) { diff --git a/subsys/bluetooth/controller/ll_sw/openisa/hal/RV32M1/radio/radio.c b/subsys/bluetooth/controller/ll_sw/openisa/hal/RV32M1/radio/radio.c index ad35206678f..a89deff32f9 100644 --- a/subsys/bluetooth/controller/ll_sw/openisa/hal/RV32M1/radio/radio.c +++ b/subsys/bluetooth/controller/ll_sw/openisa/hal/RV32M1/radio/radio.c @@ -26,13 +26,15 @@ #include "hal/swi.h" #include "fsl_cau3_ble.h" /* must be after irq.h */ -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_openisa_radio -#include "common/log.h" #include "common/assert.h" + #include #include "hal/debug.h" +#define LOG_LEVEL CONFIG_BT_HCI_DRIVER_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_openisa_radio); + static radio_isr_cb_t isr_cb; static void *isr_cb_param; @@ -217,7 +219,7 @@ static void ar_execute(void *pkt) kCAU3_TaskDoneEvent); if (status != kStatus_Success) { radio_ar_ctx.irk_idx = RPA_NO_IRK_MATCH; - BT_ERR("CAUv3 RPA table search failed %d", status); + LOG_ERR("CAUv3 RPA table search failed %d", status); return; } } @@ -578,7 +580,7 @@ void radio_phy_set(uint8_t phy, uint8_t flags) err = XCVR_ChangeMode(GFSK_BT_0p5_h_0p5, DR_1MBPS); if (err) { - BT_ERR("Failed to change PHY to 1 Mbps"); + LOG_ERR("Failed to change PHY to 1 Mbps"); BT_ASSERT(0); } @@ -595,7 +597,7 @@ void radio_phy_set(uint8_t phy, uint8_t flags) err = XCVR_ChangeMode(GFSK_BT_0p5_h_0p5, DR_2MBPS); if (err) { - BT_ERR("Failed to change PHY to 2 Mbps"); + LOG_ERR("Failed to change PHY to 2 Mbps"); BT_ASSERT(0); } @@ -1263,9 +1265,9 @@ void *radio_ccm_rx_pkt_set_ut(struct ccm *ccm, uint8_t phy, void *pkt) radio_ccm_is_done(); if (ctx_ccm.auth_mic_valid == 1 && ((uint8_t *)pkt)[2] == 0x06) { - BT_INFO("Passed decrypt\n"); + LOG_INF("Passed decrypt\n"); } else { - BT_INFO("Failed decrypt\n"); + LOG_INF("Failed decrypt\n"); } return result; @@ -1298,7 +1300,7 @@ void *radio_ccm_rx_pkt_set(struct ccm *ccm, uint8_t phy, void *pkt) /* Loads the key into CAU3's DMEM and expands the AES key schedule. */ status = CAU3_AES_SetKey(CAU3, &handle, key_local, 16); if (status != kStatus_Success) { - BT_ERR("CAUv3 AES key set failed %d", status); + LOG_ERR("CAUv3 AES key set failed %d", status); return NULL; } @@ -1360,9 +1362,9 @@ void *radio_ccm_tx_pkt_set_ut(struct ccm *ccm, void *pkt) result = radio_ccm_tx_pkt_set(ccm, pkt); if (memcmp(result, data_ref_out, sizeof(data_ref_out))) { - BT_INFO("Failed encrypt\n"); + LOG_INF("Failed encrypt\n"); } else { - BT_INFO("Passed encrypt\n"); + LOG_INF("Passed encrypt\n"); } return result; @@ -1397,7 +1399,7 @@ void *radio_ccm_tx_pkt_set(struct ccm *ccm, void *pkt) /* Loads the key into CAU3's DMEM and expands the AES key schedule. */ status = CAU3_AES_SetKey(CAU3, &handle, key_local, 16); if (status != kStatus_Success) { - BT_ERR("CAUv3 AES key set failed %d", status); + LOG_ERR("CAUv3 AES key set failed %d", status); return NULL; } @@ -1410,7 +1412,7 @@ void *radio_ccm_tx_pkt_set(struct ccm *ccm, void *pkt) ctx_ccm.nonce.bytes, 13, &aad, 1, auth_mic, CAU3_BLE_MIC_SIZE); if (status != kStatus_Success) { - BT_ERR("CAUv3 AES CCM decrypt failed %d", status); + LOG_ERR("CAUv3 AES CCM decrypt failed %d", status); return 0; } @@ -1441,7 +1443,7 @@ uint32_t radio_ccm_is_done(void) ctx_ccm.nonce.bytes, 13, &aad, 1, auth_mic, CAU3_BLE_MIC_SIZE); if (status != kStatus_Success) { - BT_ERR("CAUv3 AES CCM decrypt failed %d", status); + LOG_ERR("CAUv3 AES CCM decrypt failed %d", status); return 0; } @@ -1479,14 +1481,13 @@ void radio_ar_configure(uint32_t nirk, void *irk) /* Initialize CAUv3 RPA table */ status = CAU3_RPAtableInit(CAU3, kCAU3_TaskDoneEvent); if (kStatus_Success != status) { - BT_ERR("CAUv3 RPA table init failed"); + LOG_ERR("CAUv3 RPA table init failed"); return; } /* CAUv3 RPA table is limited to CONFIG_BT_CTLR_RL_SIZE entries */ if (nirk > CONFIG_BT_CTLR_RL_SIZE) { - BT_WARN("Max CAUv3 RPA table size is %d", - CONFIG_BT_CTLR_RL_SIZE); + LOG_WRN("Max CAUv3 RPA table size is %d", CONFIG_BT_CTLR_RL_SIZE); nirk = CONFIG_BT_CTLR_RL_SIZE; } @@ -1497,7 +1498,7 @@ void radio_ar_configure(uint32_t nirk, void *irk) status = CAU3_RPAtableInsertKey(CAU3, (uint32_t *)&pirk, kCAU3_TaskDoneEvent); if (kStatus_Success != status) { - BT_ERR("CAUv3 RPA table insert failed"); + LOG_ERR("CAUv3 RPA table insert failed"); return; } } diff --git a/subsys/bluetooth/controller/ll_sw/openisa/lll/lll.c b/subsys/bluetooth/controller/ll_sw/openisa/lll/lll.c index 28e0e8593d1..f534e4c0105 100644 --- a/subsys/bluetooth/controller/ll_sw/openisa/lll/lll.c +++ b/subsys/bluetooth/controller/ll_sw/openisa/lll/lll.c @@ -32,9 +32,6 @@ #include "lll_vendor.h" #include "lll_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_llsw_openisa_lll -#include "common/log.h" #include "hal/debug.h" static struct { diff --git a/subsys/bluetooth/controller/ll_sw/openisa/lll/lll_clock.c b/subsys/bluetooth/controller/ll_sw/openisa/lll/lll_clock.c index a1e6f9c9608..ffc26e74607 100644 --- a/subsys/bluetooth/controller/ll_sw/openisa/lll/lll_clock.c +++ b/subsys/bluetooth/controller/ll_sw/openisa/lll/lll_clock.c @@ -9,8 +9,6 @@ #include #include -#define LOG_MODULE_NAME bt_ctlr_llsw_openisa_lll_clock -#include "common/log.h" #include "hal/debug.h" static uint16_t const sca_ppm_lut[] = {500, 250, 150, 100, 75, 50, 30, 20}; diff --git a/subsys/bluetooth/controller/ll_sw/openisa/lll/lll_conn.c b/subsys/bluetooth/controller/ll_sw/openisa/lll/lll_conn.c index ecb79f60d2b..4dde0d286a5 100644 --- a/subsys/bluetooth/controller/ll_sw/openisa/lll/lll_conn.c +++ b/subsys/bluetooth/controller/ll_sw/openisa/lll/lll_conn.c @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -30,8 +31,6 @@ #include "lll_tim_internal.h" #include "lll_prof_internal.h" -#define LOG_MODULE_NAME bt_ctlr_llsw_openisa_lll_conn -#include "common/log.h" #include "hal/debug.h" static int init_reset(void); diff --git a/subsys/bluetooth/controller/ll_sw/ull.c b/subsys/bluetooth/controller/ll_sw/ull.c index 5b8553dd8fe..79b3ea89a5f 100644 --- a/subsys/bluetooth/controller/ll_sw/ull.c +++ b/subsys/bluetooth/controller/ll_sw/ull.c @@ -81,9 +81,6 @@ #include "ll_test.h" #include "ll_settings.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_ull -#include "common/log.h" #include "hal/debug.h" #if defined(CONFIG_BT_BROADCASTER) diff --git a/subsys/bluetooth/controller/ll_sw/ull_adv.c b/subsys/bluetooth/controller/ll_sw/ull_adv.c index a1673e8b457..6c00c987840 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_adv.c +++ b/subsys/bluetooth/controller/ll_sw/ull_adv.c @@ -66,9 +66,6 @@ #include "ull_llcp.h" #endif /* !CONFIG_BT_LL_SW_LLCP_LEGACY */ -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_ull_adv -#include "common/log.h" #include "hal/debug.h" inline struct ll_adv_set *ull_adv_set_get(uint8_t handle); diff --git a/subsys/bluetooth/controller/ll_sw/ull_adv_aux.c b/subsys/bluetooth/controller/ll_sw/ull_adv_aux.c index 7bbc6d959e8..93f1f71cb40 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_adv_aux.c +++ b/subsys/bluetooth/controller/ll_sw/ull_adv_aux.c @@ -43,9 +43,6 @@ #include "ll.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_ull_adv_aux -#include "common/log.h" #include "hal/debug.h" static int init_reset(void); diff --git a/subsys/bluetooth/controller/ll_sw/ull_adv_iso.c b/subsys/bluetooth/controller/ll_sw/ull_adv_iso.c index 37b4e41f5ff..5be1ee56f13 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_adv_iso.c +++ b/subsys/bluetooth/controller/ll_sw/ull_adv_iso.c @@ -41,9 +41,8 @@ #include "ll.h" #include "ll_feat.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_ull_adv_iso -#include "common/log.h" +#include + #include "hal/debug.h" static int init_reset(void); diff --git a/subsys/bluetooth/controller/ll_sw/ull_adv_sync.c b/subsys/bluetooth/controller/ll_sw/ull_adv_sync.c index e5a89a2d936..c22e55cda73 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_adv_sync.c +++ b/subsys/bluetooth/controller/ll_sw/ull_adv_sync.c @@ -42,9 +42,6 @@ #include "ll.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_ull_adv_sync -#include "common/log.h" #include "hal/debug.h" static int init_reset(void); diff --git a/subsys/bluetooth/controller/ll_sw/ull_central.c b/subsys/bluetooth/controller/ll_sw/ull_central.c index f6ec7135f15..adfd7126178 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_central.c +++ b/subsys/bluetooth/controller/ll_sw/ull_central.c @@ -65,9 +65,6 @@ #include "ull_llcp.h" #endif /* !CONFIG_BT_LL_SW_LLCP_LEGACY */ -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_ull_central -#include "common/log.h" #include "hal/debug.h" static void ticker_op_stop_scan_cb(uint32_t status, void *param); diff --git a/subsys/bluetooth/controller/ll_sw/ull_central_iso.c b/subsys/bluetooth/controller/ll_sw/ull_central_iso.c index 78fffc79790..e6016731910 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_central_iso.c +++ b/subsys/bluetooth/controller/ll_sw/ull_central_iso.c @@ -40,9 +40,8 @@ #include "ll.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_ull_central_iso -#include "common/log.h" +#include + #include "hal/debug.h" /* Setup cache for CIG commit transaction */ diff --git a/subsys/bluetooth/controller/ll_sw/ull_conn.c b/subsys/bluetooth/controller/ll_sw/ull_conn.c index 2564b5b70ee..aa02f71147f 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_conn.c +++ b/subsys/bluetooth/controller/ll_sw/ull_conn.c @@ -70,11 +70,12 @@ #include "ull_llcp_features.h" #endif /* CONFIG_BT_LL_SW_LLCP_LEGACY */ -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_ull_conn -#include "common/log.h" #include "hal/debug.h" +#define LOG_LEVEL CONFIG_BT_HCI_DRIVER_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_ctlr_ull_conn); + static int init_reset(void); #if defined(CONFIG_BT_CTLR_RX_ENQUEUE_HOLD) static bool rx_hold_is_done(struct ll_conn *conn); @@ -343,8 +344,7 @@ int ll_tx_mem_enqueue(uint16_t handle, void *tx) force_md_cnt = force_md_cnt_calc(&conn->lll, tx_rate); previous = lll_conn_force_md_cnt_set(force_md_cnt); if (previous != force_md_cnt) { - BT_INFO("force_md_cnt: old= %u, new= %u.", - previous, force_md_cnt); + LOG_INF("force_md_cnt: old= %u, new= %u.", previous, force_md_cnt); } } #endif /* CONFIG_BT_CTLR_FORCE_MD_AUTO */ @@ -372,8 +372,7 @@ int ll_tx_mem_enqueue(uint16_t handle, void *tx) cycle_stamp = k_cycle_get_32(); delta = k_cyc_to_ns_floor64(cycle_stamp - last_cycle_stamp); if (delta > BT_CTLR_THROUGHPUT_PERIOD) { - BT_INFO("incoming Tx: count= %u, len= %u, rate= %u bps.", - tx_cnt, tx_len, tx_rate); + LOG_INF("incoming Tx: count= %u, len= %u, rate= %u bps.", tx_cnt, tx_len, tx_rate); last_cycle_stamp = cycle_stamp; tx_cnt = 0U; @@ -7878,7 +7877,7 @@ static uint8_t force_md_cnt_calc(struct lll_conn *lll_conn, uint32_t tx_rate) EVENT_IFS_US) << 1; force_md_cnt = (delta + (time_keep_alive - 1)) / time_keep_alive; - BT_DBG("Time: incoming= %u, expected outgoing= %u, delta= %u, " + LOG_DBG("Time: incoming= %u, expected outgoing= %u, delta= %u, " "keepalive= %u, force_md_cnt = %u.", time_incoming, time_outgoing, delta, time_keep_alive, force_md_cnt); diff --git a/subsys/bluetooth/controller/ll_sw/ull_conn_iso.c b/subsys/bluetooth/controller/ll_sw/ull_conn_iso.c index 4c96d9f6876..dda024011c3 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_conn_iso.c +++ b/subsys/bluetooth/controller/ll_sw/ull_conn_iso.c @@ -40,9 +40,8 @@ #include "ll.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_ull_conn_iso -#include "common/log.h" +#include + #include "hal/debug.h" /* Used by LISTIFY */ diff --git a/subsys/bluetooth/controller/ll_sw/ull_df.c b/subsys/bluetooth/controller/ll_sw/ull_df.c index b55ec2e22c4..64847ee8afa 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_df.c +++ b/subsys/bluetooth/controller/ll_sw/ull_df.c @@ -53,9 +53,6 @@ #include "ll.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_CTLR_DF_DEBUG_ENABLE) -#define LOG_MODULE_NAME bt_ctlr_ull_df -#include "common/log.h" #include "hal/debug.h" #if defined(CONFIG_BT_CTLR_DF_SCAN_CTE_RX) || defined(CONFIG_BT_CTLR_DF_CONN_CTE_RX) || \ diff --git a/subsys/bluetooth/controller/ll_sw/ull_filter.c b/subsys/bluetooth/controller/ll_sw/ull_filter.c index 093f759b1aa..3631cf7bf1f 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_filter.c +++ b/subsys/bluetooth/controller/ll_sw/ull_filter.c @@ -47,11 +47,12 @@ #include "ll.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_ull_filter -#include "common/log.h" #include "hal/debug.h" +#define LOG_LEVEL CONFIG_BT_HCI_DRIVER_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_ctlr_ull_filter); + #define ADDR_TYPE_ANON 0xFF #if defined(CONFIG_BT_CTLR_FILTER_ACCEPT_LIST) @@ -729,7 +730,7 @@ void ull_filter_rpa_update(bool timeout) int64_t now = k_uptime_get(); bool all = timeout || (rpa_last_ms == -1) || (now - rpa_last_ms >= rpa_timeout_ms); - BT_DBG(""); + LOG_DBG(""); for (i = 0U; i < CONFIG_BT_CTLR_RL_SIZE; i++) { if ((rl[i].taken) && (all || !rl[i].rpas_ready)) { @@ -1264,7 +1265,7 @@ static void rpa_timeout(struct k_work *work) static void rpa_refresh_start(void) { - BT_DBG(""); + LOG_DBG(""); k_work_schedule(&rpa_work, K_MSEC(rpa_timeout_ms)); } diff --git a/subsys/bluetooth/controller/ll_sw/ull_iso.c b/subsys/bluetooth/controller/ll_sw/ull_iso.c index da725f027d5..6ce614dcf0a 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_iso.c +++ b/subsys/bluetooth/controller/ll_sw/ull_iso.c @@ -53,11 +53,14 @@ #include "ull_conn_types.h" #include "ull_llcp.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_ull_iso -#include "common/log.h" +#include + #include "hal/debug.h" +#define LOG_LEVEL CONFIG_BT_HCI_DRIVER_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_ctlr_ull_iso); + #if defined(CONFIG_BT_CTLR_CONN_ISO_STREAMS) #define BT_CTLR_CONN_ISO_STREAMS CONFIG_BT_CTLR_CONN_ISO_STREAMS #else /* !CONFIG_BT_CTLR_CONN_ISO_STREAMS */ @@ -1562,7 +1565,7 @@ static isoal_status_t ll_iso_pdu_alloc(struct isoal_pdu_buffer *pdu_buffer) node_tx = ll_iso_tx_mem_acquire(); if (!node_tx) { - BT_ERR("Tx Buffer Overflow"); + LOG_ERR("Tx Buffer Overflow"); /* TODO: Report overflow to HCI and remove assert * data_buf_overflow(evt, BT_OVERFLOW_LINK_ISO) */ diff --git a/subsys/bluetooth/controller/ll_sw/ull_llcp.c b/subsys/bluetooth/controller/ll_sw/ull_llcp.c index 3bbcfe60e49..31cb678eb85 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_llcp.c +++ b/subsys/bluetooth/controller/ll_sw/ull_llcp.c @@ -45,9 +45,6 @@ #include "ull_llcp_internal.h" #include "ull_periph_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_ull_llcp -#include "common/log.h" #include #include "hal/debug.h" diff --git a/subsys/bluetooth/controller/ll_sw/ull_llcp_cc.c b/subsys/bluetooth/controller/ll_sw/ull_llcp_cc.c index dd663be1dec..f057e47e51c 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_llcp_cc.c +++ b/subsys/bluetooth/controller/ll_sw/ull_llcp_cc.c @@ -46,9 +46,6 @@ #include "ull_peripheral_iso_internal.h" #include "ull_central_iso_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_ull_llcp_cis -#include "common/log.h" #include #include "hal/debug.h" diff --git a/subsys/bluetooth/controller/ll_sw/ull_llcp_chmu.c b/subsys/bluetooth/controller/ll_sw/ull_llcp_chmu.c index 4f87d70760f..1f968d4de5f 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_llcp_chmu.c +++ b/subsys/bluetooth/controller/ll_sw/ull_llcp_chmu.c @@ -39,9 +39,6 @@ #include "ull_llcp_internal.h" #include "ull_conn_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_ull_llcp_chmu -#include "common/log.h" #include #include "hal/debug.h" diff --git a/subsys/bluetooth/controller/ll_sw/ull_llcp_common.c b/subsys/bluetooth/controller/ll_sw/ull_llcp_common.c index e445591279c..3fe88223f53 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_llcp_common.c +++ b/subsys/bluetooth/controller/ll_sw/ull_llcp_common.c @@ -45,9 +45,6 @@ #include "ull_llcp_features.h" #include "ull_llcp_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_ull_llcp_common -#include "common/log.h" #include #include "hal/debug.h" diff --git a/subsys/bluetooth/controller/ll_sw/ull_llcp_conn_upd.c b/subsys/bluetooth/controller/ll_sw/ull_llcp_conn_upd.c index 252533ed6fe..b1cdb7566b6 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_llcp_conn_upd.c +++ b/subsys/bluetooth/controller/ll_sw/ull_llcp_conn_upd.c @@ -48,9 +48,6 @@ #include "ull_llcp_features.h" #include "ull_llcp_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_ull_llcp_conn_upd -#include "common/log.h" #include #include "hal/debug.h" diff --git a/subsys/bluetooth/controller/ll_sw/ull_llcp_enc.c b/subsys/bluetooth/controller/ll_sw/ull_llcp_enc.c index 14b17d666d4..34c353ed048 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_llcp_enc.c +++ b/subsys/bluetooth/controller/ll_sw/ull_llcp_enc.c @@ -43,9 +43,6 @@ #include "ull_llcp_features.h" #include "ull_conn_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_ull_llcp_enc -#include "common/log.h" #include #include "hal/debug.h" diff --git a/subsys/bluetooth/controller/ll_sw/ull_llcp_local.c b/subsys/bluetooth/controller/ll_sw/ull_llcp_local.c index bfb4fc5b579..29c215c35e3 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_llcp_local.c +++ b/subsys/bluetooth/controller/ll_sw/ull_llcp_local.c @@ -39,9 +39,6 @@ #include "ull_llcp_internal.h" #include "ull_conn_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_ull_llcp_local -#include "common/log.h" #include #include "hal/debug.h" diff --git a/subsys/bluetooth/controller/ll_sw/ull_llcp_pdu.c b/subsys/bluetooth/controller/ll_sw/ull_llcp_pdu.c index f5fbb0583f0..d56f4ee716e 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_llcp_pdu.c +++ b/subsys/bluetooth/controller/ll_sw/ull_llcp_pdu.c @@ -41,9 +41,6 @@ #include "ll_feat.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_ull_llcp_pdu -#include "common/log.h" #include #include "hal/debug.h" diff --git a/subsys/bluetooth/controller/ll_sw/ull_llcp_phy.c b/subsys/bluetooth/controller/ll_sw/ull_llcp_phy.c index 6ffaa5b2d43..6088dc7378d 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_llcp_phy.c +++ b/subsys/bluetooth/controller/ll_sw/ull_llcp_phy.c @@ -42,9 +42,6 @@ #include "ull_llcp_internal.h" #include "ull_conn_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_ull_llcp_phy -#include "common/log.h" #include #include "hal/debug.h" diff --git a/subsys/bluetooth/controller/ll_sw/ull_llcp_remote.c b/subsys/bluetooth/controller/ll_sw/ull_llcp_remote.c index 0c8518685ec..f7d06280920 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_llcp_remote.c +++ b/subsys/bluetooth/controller/ll_sw/ull_llcp_remote.c @@ -41,9 +41,6 @@ #include "ull_llcp_features.h" #include "ull_llcp_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_ull_llcp_remote -#include "common/log.h" #include #include "hal/debug.h" diff --git a/subsys/bluetooth/controller/ll_sw/ull_peripheral.c b/subsys/bluetooth/controller/ll_sw/ull_peripheral.c index b1a0743b523..fa564521e6c 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_peripheral.c +++ b/subsys/bluetooth/controller/ll_sw/ull_peripheral.c @@ -60,9 +60,6 @@ #include "ull_llcp.h" #endif -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_ull_periph -#include "common/log.h" #include "hal/debug.h" static void invalid_release(struct ull_hdr *hdr, struct lll_conn *lll, diff --git a/subsys/bluetooth/controller/ll_sw/ull_peripheral_iso.c b/subsys/bluetooth/controller/ll_sw/ull_peripheral_iso.c index 752858c20d3..07f1af3f1e3 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_peripheral_iso.c +++ b/subsys/bluetooth/controller/ll_sw/ull_peripheral_iso.c @@ -41,17 +41,20 @@ #include "ull_conn_iso_internal.h" #include "lll_peripheral_iso.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_ull_peripheral_iso -#include "common/log.h" +#include + #include "hal/debug.h" +#define LOG_LEVEL CONFIG_BT_HCI_DRIVER_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_ctlr_ull_peripheral_iso); + static struct ll_conn *ll_cis_get_acl_awaiting_reply(uint16_t handle, uint8_t *error) { struct ll_conn *acl_conn = NULL; if (!IS_CIS_HANDLE(handle) || ll_conn_iso_stream_get(handle)->group == NULL) { - BT_ERR("Unknown CIS handle %u", handle); + LOG_ERR("Unknown CIS handle %u", handle); *error = BT_HCI_ERR_UNKNOWN_CONN_ID; return NULL; } @@ -72,13 +75,13 @@ static struct ll_conn *ll_cis_get_acl_awaiting_reply(uint16_t handle, uint8_t *e } if (!acl_conn) { - BT_ERR("No connection found for handle %u", handle); + LOG_ERR("No connection found for handle %u", handle); *error = BT_HCI_ERR_CMD_DISALLOWED; return NULL; } if (acl_conn->lll.role == BT_CONN_ROLE_CENTRAL) { - BT_ERR("Not allowed for central"); + LOG_ERR("Not allowed for central"); *error = BT_HCI_ERR_CMD_DISALLOWED; return NULL; } @@ -88,7 +91,7 @@ static struct ll_conn *ll_cis_get_acl_awaiting_reply(uint16_t handle, uint8_t *e #else if (!ull_cp_cc_awaiting_reply(acl_conn)) { #endif - BT_ERR("Not allowed in current procedure state"); + LOG_ERR("Not allowed in current procedure state"); *error = BT_HCI_ERR_CMD_DISALLOWED; return NULL; } diff --git a/subsys/bluetooth/controller/ll_sw/ull_scan.c b/subsys/bluetooth/controller/ll_sw/ull_scan.c index 3e9fe46b392..68d16a30259 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_scan.c +++ b/subsys/bluetooth/controller/ll_sw/ull_scan.c @@ -51,9 +51,6 @@ #include "ll.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_ull_scan -#include "common/log.h" #include "hal/debug.h" static int init_reset(void); diff --git a/subsys/bluetooth/controller/ll_sw/ull_scan_aux.c b/subsys/bluetooth/controller/ll_sw/ull_scan_aux.c index db510e6a3d3..f836352f743 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_scan_aux.c +++ b/subsys/bluetooth/controller/ll_sw/ull_scan_aux.c @@ -38,9 +38,8 @@ #include "ull_sync_iso_internal.h" #include "ull_df_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_ull_scan_aux -#include "common/log.h" +#include + #include #include "hal/debug.h" diff --git a/subsys/bluetooth/controller/ll_sw/ull_sched.c b/subsys/bluetooth/controller/ll_sw/ull_sched.c index 294c90152b9..4866b770db8 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_sched.c +++ b/subsys/bluetooth/controller/ll_sw/ull_sched.c @@ -44,9 +44,8 @@ #include "ull_adv_internal.h" #include "ull_conn_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_ull_sched -#include "common/log.h" +#include + #include "hal/debug.h" #if defined(CONFIG_BT_CTLR_CONN_PARAM_REQ) diff --git a/subsys/bluetooth/controller/ll_sw/ull_sync.c b/subsys/bluetooth/controller/ll_sw/ull_sync.c index 80fbb694776..5d69e03d539 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_sync.c +++ b/subsys/bluetooth/controller/ll_sw/ull_sync.c @@ -46,9 +46,6 @@ #include "ll.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_ull_sync -#include "common/log.h" #include #include "hal/debug.h" diff --git a/subsys/bluetooth/controller/ll_sw/ull_sync_iso.c b/subsys/bluetooth/controller/ll_sw/ull_sync_iso.c index 6b5d59e10af..048a0047cc1 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_sync_iso.c +++ b/subsys/bluetooth/controller/ll_sw/ull_sync_iso.c @@ -44,9 +44,8 @@ #include "ll.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_ull_sync_iso -#include "common/log.h" +#include + #include "hal/debug.h" static int init_reset(void); diff --git a/subsys/bluetooth/controller/ticker/ticker.c b/subsys/bluetooth/controller/ticker/ticker.c index 4b27fe6b09d..dcec8aac6ce 100644 --- a/subsys/bluetooth/controller/ticker/ticker.c +++ b/subsys/bluetooth/controller/ticker/ticker.c @@ -14,9 +14,6 @@ #include "ticker.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_ticker -#include "common/log.h" #include "hal/debug.h" /***************************************************************************** diff --git a/subsys/bluetooth/crypto/CMakeLists.txt b/subsys/bluetooth/crypto/CMakeLists.txt index cdb029c0989..9228fc9fd0b 100644 --- a/subsys/bluetooth/crypto/CMakeLists.txt +++ b/subsys/bluetooth/crypto/CMakeLists.txt @@ -3,3 +3,10 @@ zephyr_library() zephyr_library_sources(bt_crypto.c) + +if(CONFIG_BT_CRYPTO_LOG_LEVEL_DBG) + message(WARNING "CONFIG_BT_CRYPTO_LOG_LEVEL_DBG is enabled. + Private security keys such as the Long Term Key will be printed out. + Do not use in production." + ) +endif() diff --git a/subsys/bluetooth/crypto/Kconfig b/subsys/bluetooth/crypto/Kconfig index bbbefe1299f..7f61037e014 100644 --- a/subsys/bluetooth/crypto/Kconfig +++ b/subsys/bluetooth/crypto/Kconfig @@ -11,6 +11,7 @@ config BT_CRYPTO config BT_DEBUG_CRYPTO bool "Bluetooth Cryptographic Toolbox debug" + select DEPRECATED depends on BT_CRYPTO help This option enables debug log output for the Bluetooth @@ -19,3 +20,8 @@ config BT_DEBUG_CRYPTO WARNING: This option prints out private security keys such as the Long Term Key. Use of this feature in production is strongly discouraged. + +module = BT_CRYPTO +legacy-debug-sym = BT_DEBUG_CRYPTO +module-str = "Bluetooth Cryptographic Toolbox" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" diff --git a/subsys/bluetooth/crypto/bt_crypto.c b/subsys/bluetooth/crypto/bt_crypto.c index 828d4b65bd5..94666a5737e 100644 --- a/subsys/bluetooth/crypto/bt_crypto.c +++ b/subsys/bluetooth/crypto/bt_crypto.c @@ -10,13 +10,14 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_CRYPTO) -#define LOG_MODULE_NAME bt_crypto #include "common/bt_str.h" -#include "common/log.h" - #include "bt_crypto.h" +#define LOG_LEVEL CONFIG_BT_CRYPTO_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_crypto); + + int bt_crypto_aes_cmac(const uint8_t *key, const uint8_t *in, size_t len, uint8_t *out) { struct tc_aes_key_sched_struct sched; diff --git a/subsys/bluetooth/host/CMakeLists.txt b/subsys/bluetooth/host/CMakeLists.txt index 95461369a69..e67f7181798 100644 --- a/subsys/bluetooth/host/CMakeLists.txt +++ b/subsys/bluetooth/host/CMakeLists.txt @@ -88,9 +88,9 @@ if(CONFIG_BT_HCI_HOST) endif() endif() -if(CONFIG_BT_DEBUG_SMP OR CONFIG_BT_DEBUG_KEYS OR CONFIG_BT_LOG_SNIFFER_INFO) +if(CONFIG_BT_SMP_LOG_LEVEL_DBG OR CONFIG_BT_KEYS_LOG_LEVEL_DBG OR CONFIG_BT_LOG_SNIFFER_INFO) message(WARNING "One of these options are enabled: - CONFIG_BT_DEBUG_SMP CONFIG_BT_DEBUG_KEYS CONFIG_BT_LOG_SNIFFER_INFO. + CONFIG_BT_SMP_LOG_LEVEL_DBG CONFIG_BT_KEYS_LOG_LEVEL_DBG CONFIG_BT_LOG_SNIFFER_INFO. Private security keys such as the LTK will be printed out, do not use in production." ) diff --git a/subsys/bluetooth/host/Kconfig b/subsys/bluetooth/host/Kconfig index 1c9ebda17d6..2f15be84d0a 100644 --- a/subsys/bluetooth/host/Kconfig +++ b/subsys/bluetooth/host/Kconfig @@ -833,9 +833,15 @@ config BT_DF_VS_CONN_IQ_REPORT_16_BITS_IQ_SAMPLES config BT_DEBUG_DF bool "Bluetooth Direction Finding debug" + select DEPRECATED help This option enables debug support for Bluetooth Direction Finding +module = BT_DF +legacy-debug-sym = BT_DEBUG_DF +module-str = "Bluetooth Direction Finding" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + endif # BT_DF endif # BT_HCI_HOST @@ -883,34 +889,59 @@ config BT_PER_ADV_SYNC_BUF_SIZE Unfragmented reports are forwarded as they are received. if BT_DEBUG + config BT_DEBUG_SETTINGS bool "Bluetooth storage debug" + select DEPRECATED depends on BT_SETTINGS help This option enables debug support for Bluetooth storage. +module = BT_SETTINGS +legacy-debug-sym = BT_DEBUG_SETTINGS +module-str = "Bluetooth storage" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_DEBUG_HCI_CORE bool "Bluetooth HCI core debug" + select DEPRECATED help This option enables debug support for Bluetooth HCI core. +module = BT_HCI_CORE +legacy-debug-sym = BT_DEBUG_HCI_CORE +module-str = "Bluetooth HCI core" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_DEBUG_CONN bool "Bluetooth connection debug" + select DEPRECATED depends on BT_CONN || BT_ISO help This option enables debug support for Bluetooth connection handling. +module = BT_CONN +legacy-debug-sym = BT_DEBUG_CONN +module-str = "Bluetooth connection" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_DEBUG_ISO bool "ISO channel debug" + select DEPRECATED help Use this option to enable ISO channels debug logs for the Bluetooth Audio functionality. +module = BT_ISO +legacy-debug-sym = BT_DEBUG_ISO +module-str = "ISO channel" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_DEBUG_ISO_DATA bool "ISO channel data debug" - depends on BT_DEBUG_ISO + depends on BT_ISO_LOG_LEVEL_DBG help Use this option to enable ISO channels data debug logs for the Bluetooth Audio functionality. This will enable debug logs for all @@ -918,6 +949,7 @@ config BT_DEBUG_ISO_DATA config BT_DEBUG_KEYS bool "Bluetooth security keys debug" + select DEPRECATED depends on BT_HCI_HOST depends on BT_SMP help @@ -928,8 +960,14 @@ config BT_DEBUG_KEYS the Long Term Key. Use of this feature in production is strongly discouraged. +module = BT_KEYS +legacy-debug-sym = BT_DEBUG_KEYS +module-str = "Bluetooth security keys" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_DEBUG_SMP bool "Bluetooth Security Manager Protocol (SMP) debug" + select DEPRECATED depends on BT_HCI_HOST depends on BT_SMP help @@ -940,16 +978,21 @@ config BT_DEBUG_SMP the Long Term Key. Use of this feature in production is strongly discouraged. +module = BT_SMP +legacy-debug-sym = BT_DEBUG_SMP +module-str = "Bluetooth Security Manager Protocol" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_SMP_SELFTEST bool "Bluetooth SMP self tests executed on init" - depends on BT_DEBUG_SMP + depends on BT_SMP_LOG_LEVEL_DBG help This option enables SMP self-tests executed on startup to verify security and crypto functions. config BT_SMP_FORCE_BREDR bool "Force Bluetooth SMP over BR/EDR" - depends on BT_DEBUG_SMP + depends on BT_SMP_LOG_LEVEL_DBG help This option enables SMP over BR/EDR even if controller is not supporting BR/EDR Secure Connections. This option is solely for @@ -957,45 +1000,81 @@ config BT_SMP_FORCE_BREDR config BT_DEBUG_RFCOMM bool "Bluetooth RFCOMM debug" + select DEPRECATED depends on BT_RFCOMM help This option enables debug support for the Bluetooth RFCOMM layer. +module = BT_RFCOMM +legacy-debug-sym = BT_DEBUG_RFCOMM +module-str = "Bluetooth RFCOMM" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_DEBUG_HFP_HF bool "Bluetooth Hands Free Profile (HFP) debug" + select DEPRECATED depends on BT_HFP_HF help This option enables debug support for the Bluetooth Hands Free Profile (HFP). +module = BT_HFP_HF +legacy-debug-sym = BT_DEBUG_HFP_HF +module-str = "Bluetooth Hands Free Profile (HFP)" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_DEBUG_AVDTP bool "Bluetooth AVDTP debug" + select DEPRECATED depends on BT_AVDTP help This option enables debug support for the Bluetooth AVDTP. +module = BT_AVDTP +legacy-debug-sym = BT_DEBUG_AVDTP +module-str = "Bluetooth AVDTP debug" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_DEBUG_A2DP bool "Bluetooth A2DP debug" + select DEPRECATED depends on BT_A2DP help This option enables debug support for the Bluetooth A2DP profile. +module = BT_A2DP +legacy-debug-sym = BT_DEBUG_A2DP +module-str = "Bluetooth A2DP" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_DEBUG_SDP bool "Bluetooth Service Discovery Protocol (SDP) debug" + select DEPRECATED depends on BT_BREDR help This option enables debug support for the Bluetooth Service Discovery Protocol (SDP). +module = BT_SDP +legacy-debug-sym = BT_DEBUG_SDP +module-str = "Bluetooth Service Discovery Protocol (SDP)" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_DEBUG_SERVICE bool "Bluetooth Services debug" + select DEPRECATED depends on BT_CONN help This option enables debug support for the Bluetooth Services. +module = BT_SERVICE +legacy-debug-sym = BT_DEBUG_SERVICE +module-str = "Bluetooth Services" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + endif # BT_DEBUG config BT_LOG_SNIFFER_INFO diff --git a/subsys/bluetooth/host/Kconfig.gatt b/subsys/bluetooth/host/Kconfig.gatt index b2d75d23b4e..f20897f0290 100644 --- a/subsys/bluetooth/host/Kconfig.gatt +++ b/subsys/bluetooth/host/Kconfig.gatt @@ -267,16 +267,28 @@ if BT_DEBUG config BT_DEBUG_ATT bool "Bluetooth Attribute Protocol (ATT) debug" + select DEPRECATED help This option enables debug support for the Bluetooth Attribute Protocol (ATT). +module = BT_ATT +legacy-debug-sym = BT_DEBUG_ATT +module-str = "Bluetooth Attribute Protocol (ATT)" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_DEBUG_GATT bool "Bluetooth Generic Attribute Profile (GATT) debug" + select DEPRECATED help This option enables debug support for the Bluetooth Generic Attribute Profile (GATT). +module = BT_GATT +legacy-debug-sym = BT_DEBUG_GATT +module-str = "Bluetooth Generic Attribute Profile (GATT)" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + endif # BT_DEBUG endmenu diff --git a/subsys/bluetooth/host/Kconfig.l2cap b/subsys/bluetooth/host/Kconfig.l2cap index f712a610afa..dc5ec27bb53 100644 --- a/subsys/bluetooth/host/Kconfig.l2cap +++ b/subsys/bluetooth/host/Kconfig.l2cap @@ -60,9 +60,15 @@ config BT_L2CAP_ECRED config BT_DEBUG_L2CAP bool "Bluetooth L2CAP debug" + select DEPRECATED depends on BT_DEBUG help This option enables debug support for the Bluetooth L2ACP layer. +module = BT_L2CAP +legacy-debug-sym = BT_DEBUG_L2CAP +module-str = "Bluetooth L2CAP" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + endmenu diff --git a/subsys/bluetooth/host/a2dp.c b/subsys/bluetooth/host/a2dp.c index 916a966e8aa..1af7753306e 100644 --- a/subsys/bluetooth/host/a2dp.c +++ b/subsys/bluetooth/host/a2dp.c @@ -21,9 +21,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_A2DP) -#define LOG_MODULE_NAME bt_a2dp -#include "common/log.h" #include "common/assert.h" #include "hci_core.h" @@ -31,6 +28,10 @@ #include "avdtp_internal.h" #include "a2dp_internal.h" +#define LOG_LEVEL CONFIG_BT_A2DP_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_a2dp); + #define A2DP_NO_SPACE (-1) struct bt_a2dp { @@ -52,14 +53,14 @@ struct bt_a2dp *get_new_connection(struct bt_conn *conn) free = A2DP_NO_SPACE; if (!conn) { - BT_ERR("Invalid Input (err: %d)", -EINVAL); + LOG_ERR("Invalid Input (err: %d)", -EINVAL); return NULL; } /* Find a space */ for (i = 0; i < CONFIG_BT_MAX_CONN; i++) { if (connection[i].session.br_chan.chan.conn == conn) { - BT_DBG("Conn already exists"); + LOG_DBG("Conn already exists"); return NULL; } @@ -70,7 +71,7 @@ struct bt_a2dp *get_new_connection(struct bt_conn *conn) } if (free == A2DP_NO_SPACE) { - BT_DBG("More connection cannot be supported"); + LOG_DBG("More connection cannot be supported"); return NULL; } @@ -90,7 +91,7 @@ int a2dp_accept(struct bt_conn *conn, struct bt_avdtp **session) } *session = &(a2dp_conn->session); - BT_DBG("session: %p", &(a2dp_conn->session)); + LOG_DBG("session: %p", &(a2dp_conn->session)); return 0; } @@ -113,11 +114,11 @@ int bt_a2dp_init(void) /* Register event handlers with AVDTP */ err = bt_avdtp_register(&avdtp_cb); if (err < 0) { - BT_ERR("A2DP registration failed"); + LOG_ERR("A2DP registration failed"); return err; } - BT_DBG("A2DP Initialized successfully."); + LOG_DBG("A2DP Initialized successfully."); return 0; } @@ -128,7 +129,7 @@ struct bt_a2dp *bt_a2dp_connect(struct bt_conn *conn) a2dp_conn = get_new_connection(conn); if (!a2dp_conn) { - BT_ERR("Cannot allocate memory"); + LOG_ERR("Cannot allocate memory"); return NULL; } @@ -136,11 +137,11 @@ struct bt_a2dp *bt_a2dp_connect(struct bt_conn *conn) if (err < 0) { /* If error occurs, undo the saving and return the error */ a2d_reset(a2dp_conn); - BT_DBG("AVDTP Connect failed"); + LOG_DBG("AVDTP Connect failed"); return NULL; } - BT_DBG("Connect request sent"); + LOG_DBG("Connect request sent"); return a2dp_conn; } diff --git a/subsys/bluetooth/host/adv.c b/subsys/bluetooth/host/adv.c index d1f1c4f0f12..2075d58249f 100644 --- a/subsys/bluetooth/host/adv.c +++ b/subsys/bluetooth/host/adv.c @@ -17,11 +17,12 @@ #include "id.h" #include "scan.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_CORE) -#define LOG_MODULE_NAME bt_adv -#include "common/log.h" #include "common/bt_str.h" +#define LOG_LEVEL CONFIG_BT_HCI_CORE_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_adv); + enum adv_name_type { ADV_NAME_TYPE_NONE, ADV_NAME_TYPE_AD, @@ -508,7 +509,7 @@ static int set_data_add_complete(uint8_t *set_data, uint8_t set_data_len_max, if (!(type == BT_DATA_NAME_COMPLETE && shortened_len > 0)) { - BT_ERR("Too big advertising data"); + LOG_ERR("Too big advertising data"); return -EINVAL; } @@ -1064,7 +1065,7 @@ int bt_le_adv_start_legacy(struct bt_le_ext_adv *adv, err = bt_le_adv_set_enable(adv, true); if (err) { - BT_ERR("Failed to start advertiser"); + LOG_ERR("Failed to start advertiser"); if (IS_ENABLED(CONFIG_BT_PERIPHERAL) && conn) { bt_conn_set_state(conn, BT_CONN_DISCONNECTED); bt_conn_unref(conn); @@ -1308,7 +1309,7 @@ int bt_le_adv_start_ext(struct bt_le_ext_adv *adv, err = bt_le_adv_set_enable_ext(adv, true, &start_param); if (err) { - BT_ERR("Failed to start advertiser"); + LOG_ERR("Failed to start advertiser"); if (IS_ENABLED(CONFIG_BT_PERIPHERAL) && conn) { bt_conn_set_state(conn, BT_CONN_DISCONNECTED); bt_conn_unref(conn); @@ -1378,7 +1379,7 @@ int bt_le_adv_stop(void) int err; if (!adv) { - BT_ERR("No valid legacy adv"); + LOG_ERR("No valid legacy adv"); return 0; } @@ -1444,7 +1445,7 @@ void bt_le_adv_resume(void) int err; if (!adv) { - BT_DBG("No valid legacy adv"); + LOG_DBG("No valid legacy adv"); return; } @@ -1459,11 +1460,11 @@ void bt_le_adv_resume(void) err = le_adv_start_add_conn(adv, &conn); if (err) { - BT_DBG("Host cannot resume connectable advertising (%d)", err); + LOG_DBG("Host cannot resume connectable advertising (%d)", err); return; } - BT_DBG("Resuming connectable advertising"); + LOG_DBG("Resuming connectable advertising"); if (IS_ENABLED(CONFIG_BT_PRIVACY) && !atomic_test_bit(adv->flags, BT_ADV_USE_IDENTITY)) { @@ -1472,8 +1473,7 @@ void bt_le_adv_resume(void) err = bt_le_adv_set_enable(adv, true); if (err) { - BT_DBG("Controller cannot resume connectable advertising (%d)", - err); + LOG_DBG("Controller cannot resume connectable advertising (%d)", err); bt_conn_set_state(conn, BT_CONN_DISCONNECTED); /* Temporarily clear persist flag to avoid recursion in @@ -1608,7 +1608,7 @@ int bt_le_ext_adv_start(struct bt_le_ext_adv *adv, err = bt_le_adv_set_enable_ext(adv, true, param); if (err) { - BT_ERR("Failed to start advertiser"); + LOG_ERR("Failed to start advertiser"); if (IS_ENABLED(CONFIG_BT_PERIPHERAL) && conn) { bt_conn_set_state(conn, BT_CONN_DISCONNECTED); bt_conn_unref(conn); @@ -1692,7 +1692,7 @@ int bt_le_ext_adv_delete(struct bt_le_ext_adv *adv) buf = bt_hci_cmd_create(BT_HCI_OP_LE_REMOVE_ADV_SET, sizeof(*cp)); if (!buf) { - BT_WARN("No HCI buffers"); + LOG_WRN("No HCI buffers"); return -ENOBUFS; } @@ -1729,7 +1729,7 @@ static void adv_timeout(struct k_work *work) #else err = bt_le_adv_stop(); #endif - BT_WARN("Failed to stop advertising: %d", err); + LOG_WRN("Failed to stop advertising: %d", err); } #if defined(CONFIG_BT_PER_ADV) @@ -1939,12 +1939,11 @@ void bt_hci_le_adv_set_terminated(struct net_buf *buf) adv = bt_adv_lookup_handle(evt->adv_handle); conn_handle = sys_le16_to_cpu(evt->conn_handle); - BT_DBG("status 0x%02x adv_handle %u conn_handle 0x%02x num %u", - evt->status, evt->adv_handle, conn_handle, - evt->num_completed_ext_adv_evts); + LOG_DBG("status 0x%02x adv_handle %u conn_handle 0x%02x num %u", evt->status, + evt->adv_handle, conn_handle, evt->num_completed_ext_adv_evts); if (!adv) { - BT_ERR("No valid adv"); + LOG_ERR("No valid adv"); return; } @@ -2044,10 +2043,10 @@ void bt_hci_le_scan_req_received(struct net_buf *buf) evt = (void *)buf->data; adv = bt_adv_lookup_handle(evt->handle); - BT_DBG("handle %u peer %s", evt->handle, bt_addr_le_str(&evt->addr)); + LOG_DBG("handle %u peer %s", evt->handle, bt_addr_le_str(&evt->addr)); if (!adv) { - BT_ERR("No valid adv"); + LOG_ERR("No valid adv"); return; } diff --git a/subsys/bluetooth/host/aes_ccm.c b/subsys/bluetooth/host/aes_ccm.c index 37c0b818847..2e0022cf4eb 100644 --- a/subsys/bluetooth/host/aes_ccm.c +++ b/subsys/bluetooth/host/aes_ccm.c @@ -11,11 +11,12 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_CORE) -#define LOG_MODULE_NAME bt_aes_ccm -#include "common/log.h" #include "common/bt_str.h" +#define LOG_LEVEL CONFIG_BT_HCI_CORE_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_aes_ccm); + static inline void xor16(uint8_t *dst, const uint8_t *a, const uint8_t *b) { dst[0] = a[0] ^ b[0]; @@ -214,10 +215,10 @@ int bt_ccm_encrypt(const uint8_t key[16], uint8_t nonce[13], { uint8_t *mic = enc_data + len; - BT_DBG("key %s", bt_hex(key, 16)); - BT_DBG("nonce %s", bt_hex(nonce, 13)); - BT_DBG("msg (len %zu) %s", len, bt_hex(plaintext, len)); - BT_DBG("aad_len %zu mic_size %zu", aad_len, mic_size); + LOG_DBG("key %s", bt_hex(key, 16)); + LOG_DBG("nonce %s", bt_hex(nonce, 13)); + LOG_DBG("msg (len %zu) %s", len, bt_hex(plaintext, len)); + LOG_DBG("aad_len %zu mic_size %zu", aad_len, mic_size); /* Unsupported AAD size */ if (aad_len >= 0xff00 || mic_size > 16 || len > UINT16_MAX) { diff --git a/subsys/bluetooth/host/att.c b/subsys/bluetooth/host/att.c index 481db79ce17..7915d942da4 100644 --- a/subsys/bluetooth/host/att.c +++ b/subsys/bluetooth/host/att.c @@ -21,9 +21,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_ATT) -#define LOG_MODULE_NAME bt_att -#include "common/log.h" #include "common/bt_str.h" #include "hci_core.h" @@ -33,6 +30,10 @@ #include "att_internal.h" #include "gatt_internal.h" +#define LOG_LEVEL CONFIG_BT_ATT_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_att); + #define ATT_CHAN(_ch) CONTAINER_OF(_ch, struct bt_att_chan, chan.chan) #define ATT_REQ(_node) CONTAINER_OF(_node, struct bt_att_req, node) @@ -181,7 +182,7 @@ void att_sent(struct bt_conn *conn, void *user_data) struct bt_att_chan *att_chan = data->att_chan; struct bt_l2cap_chan *chan = &att_chan->chan.chan; - BT_DBG("conn %p chan %p", conn, chan); + LOG_DBG("conn %p chan %p", conn, chan); if (chan->ops->sent) { chan->ops->sent(chan); @@ -204,7 +205,7 @@ static int chan_send(struct bt_att_chan *chan, struct net_buf *buf) hdr = (void *)buf->data; - BT_DBG("code 0x%02x", hdr->code); + LOG_DBG("code 0x%02x", hdr->code); if (!atomic_test_bit(chan->flags, ATT_CONNECTED)) { return -EINVAL; @@ -256,7 +257,7 @@ static int chan_send(struct bt_att_chan *chan, struct net_buf *buf) err = bt_smp_sign(chan->att->conn, buf); if (err) { - BT_ERR("Error signing data"); + LOG_ERR("Error signing data"); tx_meta_data_free(bt_att_tx_meta_data(buf)); net_buf_unref(buf); return err; @@ -386,8 +387,7 @@ static int chan_req_send(struct bt_att_chan *chan, struct bt_att_req *req) return -EMSGSIZE; } - BT_DBG("chan %p req %p len %zu", chan, req, - net_buf_frags_len(req->buf)); + LOG_DBG("chan %p req %p len %zu", chan, req, net_buf_frags_len(req->buf)); chan->req = req; @@ -411,12 +411,12 @@ static void bt_att_sent(struct bt_l2cap_chan *ch) struct bt_att *att = chan->att; int err; - BT_DBG("chan %p", chan); + LOG_DBG("chan %p", chan); atomic_clear_bit(chan->flags, ATT_PENDING_SENT); if (!att) { - BT_DBG("Ignore sent on detached ATT chan"); + LOG_DBG("Ignore sent on detached ATT chan"); return; } @@ -451,7 +451,7 @@ static void chan_cfm_sent(struct bt_conn *conn, void *user_data, int err) struct bt_att_tx_meta_data *data = user_data; struct bt_att_chan *chan = data->att_chan; - BT_DBG("chan %p", chan); + LOG_DBG("chan %p", chan); if (IS_ENABLED(CONFIG_BT_ATT_ENFORCE_FLOW)) { atomic_clear_bit(chan->flags, ATT_PENDING_CFM); @@ -465,7 +465,7 @@ static void chan_rsp_sent(struct bt_conn *conn, void *user_data, int err) struct bt_att_tx_meta_data *data = user_data; struct bt_att_chan *chan = data->att_chan; - BT_DBG("chan %p", chan); + LOG_DBG("chan %p", chan); if (IS_ENABLED(CONFIG_BT_ATT_ENFORCE_FLOW)) { atomic_clear_bit(chan->flags, ATT_PENDING_RSP); @@ -479,7 +479,7 @@ static void chan_req_sent(struct bt_conn *conn, void *user_data, int err) struct bt_att_tx_meta_data *data = user_data; struct bt_att_chan *chan = data->att_chan; - BT_DBG("chan %p chan->req %p", chan, chan->req); + LOG_DBG("chan %p chan->req %p", chan, chan->req); /* Start timeout work */ if (chan->req) { @@ -497,7 +497,7 @@ static void chan_tx_complete(struct bt_conn *conn, void *user_data, int err) uint16_t attr_count = data->attr_count; void *ud = data->user_data; - BT_DBG("TX Complete chan %p CID 0x%04X", chan, chan->chan.tx.cid); + LOG_DBG("TX Complete chan %p CID 0x%04X", chan, chan->chan.tx.cid); tx_meta_data_free(data); @@ -611,8 +611,8 @@ struct net_buf *bt_att_chan_create_pdu(struct bt_att_chan *chan, uint8_t op, k_timeout_t timeout; if (len + sizeof(op) > chan->chan.tx.mtu) { - BT_WARN("ATT MTU exceeded, max %u, wanted %zu", - chan->chan.tx.mtu, len + sizeof(op)); + LOG_WRN("ATT MTU exceeded, max %u, wanted %zu", chan->chan.tx.mtu, + len + sizeof(op)); return NULL; } @@ -628,13 +628,13 @@ struct net_buf *bt_att_chan_create_pdu(struct bt_att_chan *chan, uint8_t op, buf = bt_l2cap_create_pdu_timeout(NULL, 0, timeout); if (!buf) { - BT_ERR("Unable to allocate buffer for op 0x%02x", op); + LOG_ERR("Unable to allocate buffer for op 0x%02x", op); return NULL; } data = tx_meta_data_alloc(timeout); if (!data) { - BT_WARN("Unable to allocate ATT TX meta"); + LOG_WRN("Unable to allocate ATT TX meta"); net_buf_unref(buf); return NULL; } @@ -649,8 +649,8 @@ struct net_buf *bt_att_chan_create_pdu(struct bt_att_chan *chan, uint8_t op, static int bt_att_chan_send(struct bt_att_chan *chan, struct net_buf *buf) { - BT_DBG("chan %p flags %lu code 0x%02x", chan, atomic_get(chan->flags), - ((struct bt_att_hdr *)buf->data)->code); + LOG_DBG("chan %p flags %lu code 0x%02x", chan, atomic_get(chan->flags), + ((struct bt_att_hdr *)buf->data)->code); if (IS_ENABLED(CONFIG_BT_EATT) && !att_chan_matches_chan_opt(chan, bt_att_tx_meta_data(buf)->chan_opt)) { @@ -740,7 +740,7 @@ static uint8_t att_mtu_req(struct bt_att_chan *chan, struct net_buf *buf) mtu_client = sys_le16_to_cpu(req->mtu); - BT_DBG("Client MTU %u", mtu_client); + LOG_DBG("Client MTU %u", mtu_client); /* Check if MTU is valid */ if (mtu_client < BT_ATT_DEFAULT_LE_MTU) { @@ -754,7 +754,7 @@ static uint8_t att_mtu_req(struct bt_att_chan *chan, struct net_buf *buf) mtu_server = BT_ATT_MTU; - BT_DBG("Server MTU %u", mtu_server); + LOG_DBG("Server MTU %u", mtu_server); rsp = net_buf_add(pdu, sizeof(*rsp)); rsp->mtu = sys_cpu_to_le16(mtu_server); @@ -769,7 +769,7 @@ static uint8_t att_mtu_req(struct bt_att_chan *chan, struct net_buf *buf) chan->chan.rx.mtu = MIN(mtu_client, mtu_server); chan->chan.tx.mtu = chan->chan.rx.mtu; - BT_DBG("Negotiated MTU %u", chan->chan.rx.mtu); + LOG_DBG("Negotiated MTU %u", chan->chan.rx.mtu); #if defined(CONFIG_BT_GATT_CLIENT) /* Mark the MTU Exchange as complete. @@ -794,7 +794,7 @@ static int bt_att_chan_req_send(struct bt_att_chan *chan, __ASSERT_NO_MSG(req->func); __ASSERT_NO_MSG(!chan->req); - BT_DBG("req %p", req); + LOG_DBG("req %p", req); return chan_req_send(chan, req); } @@ -843,14 +843,13 @@ static uint8_t att_handle_rsp(struct bt_att_chan *chan, void *pdu, uint16_t len, bt_att_func_t func = NULL; void *params; - BT_DBG("chan %p err 0x%02x len %u: %s", chan, err, len, - bt_hex(pdu, len)); + LOG_DBG("chan %p err 0x%02x len %u: %s", chan, err, len, bt_hex(pdu, len)); /* Cancel timeout if ongoing */ k_work_cancel_delayable(&chan->timeout_work); if (!chan->req) { - BT_WARN("No pending ATT request"); + LOG_WRN("No pending ATT request"); goto process; } @@ -889,7 +888,7 @@ static uint8_t att_mtu_rsp(struct bt_att_chan *chan, struct net_buf *buf) mtu = sys_le16_to_cpu(rsp->mtu); - BT_DBG("Server MTU %u", mtu); + LOG_DBG("Server MTU %u", mtu); /* Check if MTU is valid */ if (mtu < BT_ATT_DEFAULT_LE_MTU) { @@ -905,7 +904,7 @@ static uint8_t att_mtu_rsp(struct bt_att_chan *chan, struct net_buf *buf) */ chan->chan.tx.mtu = chan->chan.rx.mtu; - BT_DBG("Negotiated MTU %u", chan->chan.rx.mtu); + LOG_DBG("Negotiated MTU %u", chan->chan.rx.mtu); att_chan_mtu_updated(chan); @@ -950,7 +949,7 @@ static uint8_t find_info_cb(const struct bt_gatt_attr *attr, uint16_t handle, struct find_info_data *data = user_data; struct bt_att_chan *chan = data->chan; - BT_DBG("handle 0x%04x", handle); + LOG_DBG("handle 0x%04x", handle); /* Initialize rsp at first entry */ if (!data->rsp) { @@ -1036,8 +1035,7 @@ static uint8_t att_find_info_req(struct bt_att_chan *chan, struct net_buf *buf) start_handle = sys_le16_to_cpu(req->start_handle); end_handle = sys_le16_to_cpu(req->end_handle); - BT_DBG("start_handle 0x%04x end_handle 0x%04x", start_handle, - end_handle); + LOG_DBG("start_handle 0x%04x end_handle 0x%04x", start_handle, end_handle); if (!range_is_valid(start_handle, end_handle, &err_handle)) { send_err_rsp(chan, BT_ATT_OP_FIND_INFO_REQ, err_handle, @@ -1082,7 +1080,7 @@ static uint8_t find_type_cb(const struct bt_gatt_attr *attr, uint16_t handle, return BT_GATT_ITER_CONTINUE; } - BT_DBG("handle 0x%04x", handle); + LOG_DBG("handle 0x%04x", handle); /* stop if there is no space left */ if (chan->chan.tx.mtu - net_buf_frags_len(data->buf) < @@ -1122,11 +1120,11 @@ static uint8_t find_type_cb(const struct bt_gatt_attr *attr, uint16_t handle, struct bt_uuid_128 recvd_uuid; if (!bt_uuid_create(&recvd_uuid.uuid, data->value, data->value_len)) { - BT_WARN("Unable to create UUID: size %u", data->value_len); + LOG_WRN("Unable to create UUID: size %u", data->value_len); goto skip; } if (!bt_uuid_create(&ref_uuid.uuid, uuid, read)) { - BT_WARN("Unable to create UUID: size %d", read); + LOG_WRN("Unable to create UUID: size %d", read); goto skip; } if (bt_uuid_cmp(&recvd_uuid.uuid, &ref_uuid.uuid)) { @@ -1204,8 +1202,7 @@ static uint8_t att_find_type_req(struct bt_att_chan *chan, struct net_buf *buf) type = sys_le16_to_cpu(req->type); value = buf->data; - BT_DBG("start_handle 0x%04x end_handle 0x%04x type %u", start_handle, - end_handle, type); + LOG_DBG("start_handle 0x%04x end_handle 0x%04x type %u", start_handle, end_handle, type); if (!range_is_valid(start_handle, end_handle, &err_handle)) { send_err_rsp(chan, BT_ATT_OP_FIND_TYPE_REQ, err_handle, @@ -1230,7 +1227,7 @@ static uint8_t att_find_type_req(struct bt_att_chan *chan, struct net_buf *buf) static uint8_t err_to_att(int err) { - BT_DBG("%d", err); + LOG_DBG("%d", err); if (err < 0 && err >= -0xff) { return -err; @@ -1340,7 +1337,7 @@ static uint8_t read_type_cb(const struct bt_gatt_attr *attr, uint16_t handle, return BT_GATT_ITER_CONTINUE; } - BT_DBG("handle 0x%04x", handle); + LOG_DBG("handle 0x%04x", handle); /* * If an attribute in the set of requested attributes would cause an @@ -1448,8 +1445,8 @@ static uint8_t att_read_type_req(struct bt_att_chan *chan, struct net_buf *buf) return BT_ATT_ERR_UNLIKELY; } - BT_DBG("start_handle 0x%04x end_handle 0x%04x type %s", - start_handle, end_handle, bt_uuid_str(&u.uuid)); + LOG_DBG("start_handle 0x%04x end_handle 0x%04x type %s", start_handle, end_handle, + bt_uuid_str(&u.uuid)); if (!range_is_valid(start_handle, end_handle, &err_handle)) { send_err_rsp(chan, BT_ATT_OP_READ_TYPE_REQ, err_handle, @@ -1475,7 +1472,7 @@ static uint8_t read_cb(const struct bt_gatt_attr *attr, uint16_t handle, struct bt_conn *conn = chan->chan.chan.conn; int ret; - BT_DBG("handle 0x%04x", handle); + LOG_DBG("handle 0x%04x", handle); /* * If any attribute is founded in handle range it means that error @@ -1555,7 +1552,7 @@ static uint8_t att_read_req(struct bt_att_chan *chan, struct net_buf *buf) handle = sys_le16_to_cpu(req->handle); - BT_DBG("handle 0x%04x", handle); + LOG_DBG("handle 0x%04x", handle); return att_read_rsp(chan, BT_ATT_OP_READ_REQ, BT_ATT_OP_READ_RSP, handle, 0); @@ -1571,7 +1568,7 @@ static uint8_t att_read_blob_req(struct bt_att_chan *chan, struct net_buf *buf) handle = sys_le16_to_cpu(req->handle); offset = sys_le16_to_cpu(req->offset); - BT_DBG("handle 0x%04x offset %u", handle, offset); + LOG_DBG("handle 0x%04x offset %u", handle, offset); return att_read_rsp(chan, BT_ATT_OP_READ_BLOB_REQ, BT_ATT_OP_READ_BLOB_RSP, handle, offset); @@ -1604,7 +1601,7 @@ static uint8_t att_read_mult_req(struct bt_att_chan *chan, struct net_buf *buf) while (buf->len >= sizeof(uint16_t)) { handle = net_buf_pull_le16(buf); - BT_DBG("handle 0x%04x ", handle); + LOG_DBG("handle 0x%04x ", handle); /* An Error Response shall be sent by the server in response to * the Read Multiple Request [....] if a read operation is not @@ -1644,7 +1641,7 @@ static uint8_t read_vl_cb(const struct bt_gatt_attr *attr, uint16_t handle, struct bt_att_read_mult_vl_rsp *rsp; int read; - BT_DBG("handle 0x%04x", handle); + LOG_DBG("handle 0x%04x", handle); /* * If any attribute is founded in handle range it means that error @@ -1704,7 +1701,7 @@ static uint8_t att_read_mult_vl_req(struct bt_att_chan *chan, struct net_buf *bu while (buf->len >= sizeof(uint16_t)) { handle = net_buf_pull_le16(buf); - BT_DBG("handle 0x%04x ", handle); + LOG_DBG("handle 0x%04x ", handle); /* If handle is not valid then return invalid handle error. * If handle is found error will be cleared by read_cb. @@ -1779,7 +1776,7 @@ static uint8_t read_group_cb(const struct bt_gatt_attr *attr, uint16_t handle, return BT_GATT_ITER_CONTINUE; } - BT_DBG("handle 0x%04x", handle); + LOG_DBG("handle 0x%04x", handle); /* Stop if there is no space left */ if (data->rsp->len && @@ -1871,8 +1868,8 @@ static uint8_t att_read_group_req(struct bt_att_chan *chan, struct net_buf *buf) return BT_ATT_ERR_UNLIKELY; } - BT_DBG("start_handle 0x%04x end_handle 0x%04x type %s", - start_handle, end_handle, bt_uuid_str(&u.uuid)); + LOG_DBG("start_handle 0x%04x end_handle 0x%04x type %s", start_handle, end_handle, + bt_uuid_str(&u.uuid)); if (!range_is_valid(start_handle, end_handle, &err_handle)) { send_err_rsp(chan, BT_ATT_OP_READ_GROUP_REQ, err_handle, @@ -1914,7 +1911,7 @@ static uint8_t write_cb(const struct bt_gatt_attr *attr, uint16_t handle, int write; uint8_t flags = 0U; - BT_DBG("handle 0x%04x offset %u", handle, data->offset); + LOG_DBG("handle 0x%04x offset %u", handle, data->offset); /* Check attribute permissions */ data->err = bt_gatt_check_perm(data->conn, attr, @@ -2004,7 +2001,7 @@ static uint8_t att_write_req(struct bt_att_chan *chan, struct net_buf *buf) handle = net_buf_pull_le16(buf); - BT_DBG("handle 0x%04x", handle); + LOG_DBG("handle 0x%04x", handle); return att_write_rsp(chan, BT_ATT_OP_WRITE_REQ, BT_ATT_OP_WRITE_RSP, handle, 0, buf->data, buf->len); @@ -2027,7 +2024,7 @@ static uint8_t prep_write_cb(const struct bt_gatt_attr *attr, uint16_t handle, struct bt_attr_data *attr_data; int write; - BT_DBG("handle 0x%04x offset %u", handle, data->offset); + LOG_DBG("handle 0x%04x offset %u", handle, data->offset); /* Check attribute permissions */ data->err = bt_gatt_check_perm(data->conn, attr, @@ -2104,7 +2101,7 @@ static uint8_t att_prep_write_rsp(struct bt_att_chan *chan, uint16_t handle, return 0; } - BT_DBG("buf %p handle 0x%04x offset %u", data.buf, handle, offset); + LOG_DBG("buf %p handle 0x%04x offset %u", data.buf, handle, offset); /* Store buffer in the outstanding queue */ net_buf_slist_put(&chan->att->prep_queue, data.buf); @@ -2140,7 +2137,7 @@ static uint8_t att_prepare_write_req(struct bt_att_chan *chan, struct net_buf *b handle = sys_le16_to_cpu(req->handle); offset = sys_le16_to_cpu(req->offset); - BT_DBG("handle 0x%04x offset %u", handle, offset); + LOG_DBG("handle 0x%04x offset %u", handle, offset); return att_prep_write_rsp(chan, handle, offset, buf->data, buf->len); #endif /* CONFIG_BT_ATT_PREPARE_COUNT */ @@ -2158,8 +2155,8 @@ static uint8_t exec_write_reassemble(uint16_t handle, uint16_t offset, SYS_SLIST_FOR_EACH_CONTAINER_SAFE(list, entry, next, node) { struct bt_attr_data *tmp_data = net_buf_user_data(entry); - BT_DBG("entry %p handle 0x%04x, offset %u", - entry, tmp_data->handle, tmp_data->offset); + LOG_DBG("entry %p handle 0x%04x, offset %u", entry, tmp_data->handle, + tmp_data->offset); if (tmp_data->handle == handle) { if (tmp_data->offset == 0) { @@ -2170,7 +2167,7 @@ static uint8_t exec_write_reassemble(uint16_t handle, uint16_t offset, * first write. */ - BT_DBG("tmp_data->offset == 0"); + LOG_DBG("tmp_data->offset == 0"); break; } @@ -2179,8 +2176,8 @@ static uint8_t exec_write_reassemble(uint16_t handle, uint16_t offset, * properly to avoid badly reassembled buffers */ - BT_DBG("Bad offset %u (%u, %u)", - tmp_data->offset, buf->len, offset); + LOG_DBG("Bad offset %u (%u, %u)", tmp_data->offset, buf->len, + offset); return BT_ATT_ERR_INVALID_OFFSET; } @@ -2223,8 +2220,7 @@ static uint8_t att_exec_write_rsp(struct bt_att_chan *chan, uint8_t flags) data = net_buf_user_data(buf); handle = data->handle; - BT_DBG("buf %p handle 0x%04x offset %u", - buf, handle, data->offset); + LOG_DBG("buf %p handle 0x%04x offset %u", buf, handle, data->offset); net_buf_simple_reset(&reassembled_data); net_buf_simple_add_mem(&reassembled_data, buf->data, buf->len); @@ -2280,7 +2276,7 @@ static uint8_t att_exec_write_req(struct bt_att_chan *chan, struct net_buf *buf) req = (void *)buf->data; - BT_DBG("flags 0x%02x", req->flags); + LOG_DBG("flags 0x%02x", req->flags); return att_exec_write_rsp(chan, req->flags); #endif /* CONFIG_BT_ATT_PREPARE_COUNT */ @@ -2292,7 +2288,7 @@ static uint8_t att_write_cmd(struct bt_att_chan *chan, struct net_buf *buf) handle = net_buf_pull_le16(buf); - BT_DBG("handle 0x%04x", handle); + LOG_DBG("handle 0x%04x", handle); return att_write_rsp(chan, 0, 0, handle, 0, buf->data, buf->len); } @@ -2317,13 +2313,13 @@ static uint8_t att_signed_write_cmd(struct bt_att_chan *chan, struct net_buf *bu handle = sys_le16_to_cpu(req->handle); - BT_DBG("handle 0x%04x", handle); + LOG_DBG("handle 0x%04x", handle); /* Verifying data requires full buffer including attribute header */ net_buf_push(buf, sizeof(struct bt_att_hdr)); err = bt_smp_sign_verify(conn, buf); if (err) { - BT_ERR("Error verifying data"); + LOG_ERR("Error verifying data"); /* No response for this command */ return 0; } @@ -2406,8 +2402,8 @@ static uint8_t att_error_rsp(struct bt_att_chan *chan, struct net_buf *buf) rsp = (void *)buf->data; - BT_DBG("request 0x%02x handle 0x%04x error 0x%02x", rsp->request, - sys_le16_to_cpu(rsp->handle), rsp->error); + LOG_DBG("request 0x%02x handle 0x%04x error 0x%02x", rsp->request, + sys_le16_to_cpu(rsp->handle), rsp->error); /* Don't retry if there is no req pending or it has been cancelled. * @@ -2441,7 +2437,7 @@ done: static uint8_t att_handle_find_info_rsp(struct bt_att_chan *chan, struct net_buf *buf) { - BT_DBG(""); + LOG_DBG(""); return att_handle_rsp(chan, buf->data, buf->len, 0); } @@ -2449,7 +2445,7 @@ static uint8_t att_handle_find_info_rsp(struct bt_att_chan *chan, static uint8_t att_handle_find_type_rsp(struct bt_att_chan *chan, struct net_buf *buf) { - BT_DBG(""); + LOG_DBG(""); return att_handle_rsp(chan, buf->data, buf->len, 0); } @@ -2457,7 +2453,7 @@ static uint8_t att_handle_find_type_rsp(struct bt_att_chan *chan, static uint8_t att_handle_read_type_rsp(struct bt_att_chan *chan, struct net_buf *buf) { - BT_DBG(""); + LOG_DBG(""); return att_handle_rsp(chan, buf->data, buf->len, 0); } @@ -2465,7 +2461,7 @@ static uint8_t att_handle_read_type_rsp(struct bt_att_chan *chan, static uint8_t att_handle_read_rsp(struct bt_att_chan *chan, struct net_buf *buf) { - BT_DBG(""); + LOG_DBG(""); return att_handle_rsp(chan, buf->data, buf->len, 0); } @@ -2473,7 +2469,7 @@ static uint8_t att_handle_read_rsp(struct bt_att_chan *chan, static uint8_t att_handle_read_blob_rsp(struct bt_att_chan *chan, struct net_buf *buf) { - BT_DBG(""); + LOG_DBG(""); return att_handle_rsp(chan, buf->data, buf->len, 0); } @@ -2482,7 +2478,7 @@ static uint8_t att_handle_read_blob_rsp(struct bt_att_chan *chan, static uint8_t att_handle_read_mult_rsp(struct bt_att_chan *chan, struct net_buf *buf) { - BT_DBG(""); + LOG_DBG(""); return att_handle_rsp(chan, buf->data, buf->len, 0); } @@ -2493,7 +2489,7 @@ static uint8_t att_handle_read_mult_rsp(struct bt_att_chan *chan, static uint8_t att_handle_read_mult_vl_rsp(struct bt_att_chan *chan, struct net_buf *buf) { - BT_DBG(""); + LOG_DBG(""); return att_handle_rsp(chan, buf->data, buf->len, 0); } @@ -2502,7 +2498,7 @@ static uint8_t att_handle_read_mult_vl_rsp(struct bt_att_chan *chan, static uint8_t att_handle_read_group_rsp(struct bt_att_chan *chan, struct net_buf *buf) { - BT_DBG(""); + LOG_DBG(""); return att_handle_rsp(chan, buf->data, buf->len, 0); } @@ -2510,7 +2506,7 @@ static uint8_t att_handle_read_group_rsp(struct bt_att_chan *chan, static uint8_t att_handle_write_rsp(struct bt_att_chan *chan, struct net_buf *buf) { - BT_DBG(""); + LOG_DBG(""); return att_handle_rsp(chan, buf->data, buf->len, 0); } @@ -2518,7 +2514,7 @@ static uint8_t att_handle_write_rsp(struct bt_att_chan *chan, static uint8_t att_handle_prepare_write_rsp(struct bt_att_chan *chan, struct net_buf *buf) { - BT_DBG(""); + LOG_DBG(""); return att_handle_rsp(chan, buf->data, buf->len, 0); } @@ -2526,7 +2522,7 @@ static uint8_t att_handle_prepare_write_rsp(struct bt_att_chan *chan, static uint8_t att_handle_exec_write_rsp(struct bt_att_chan *chan, struct net_buf *buf) { - BT_DBG(""); + LOG_DBG(""); return att_handle_rsp(chan, buf->data, buf->len, 0); } @@ -2537,7 +2533,7 @@ static uint8_t att_notify(struct bt_att_chan *chan, struct net_buf *buf) handle = net_buf_pull_le16(buf); - BT_DBG("chan %p handle 0x%04x", chan, handle); + LOG_DBG("chan %p handle 0x%04x", chan, handle); bt_gatt_notification(chan->att->conn, handle, buf->data, buf->len); @@ -2550,7 +2546,7 @@ static uint8_t att_indicate(struct bt_att_chan *chan, struct net_buf *buf) handle = net_buf_pull_le16(buf); - BT_DBG("chan %p handle 0x%04x", chan, handle); + LOG_DBG("chan %p handle 0x%04x", chan, handle); bt_gatt_notification(chan->att->conn, handle, buf->data, buf->len); @@ -2566,7 +2562,7 @@ static uint8_t att_indicate(struct bt_att_chan *chan, struct net_buf *buf) static uint8_t att_notify_mult(struct bt_att_chan *chan, struct net_buf *buf) { - BT_DBG("chan %p", chan); + LOG_DBG("chan %p", chan); bt_gatt_mult_notification(chan->att->conn, buf->data, buf->len); @@ -2576,7 +2572,7 @@ static uint8_t att_notify_mult(struct bt_att_chan *chan, struct net_buf *buf) static uint8_t att_confirm(struct bt_att_chan *chan, struct net_buf *buf) { - BT_DBG(""); + LOG_DBG(""); return att_handle_rsp(chan, buf->data, buf->len, 0); } @@ -2784,16 +2780,16 @@ static int bt_att_recv(struct bt_l2cap_chan *chan, struct net_buf *buf) size_t i; if (buf->len < sizeof(*hdr)) { - BT_ERR("Too small ATT PDU received"); + LOG_ERR("Too small ATT PDU received"); return 0; } hdr = net_buf_pull_mem(buf, sizeof(*hdr)); - BT_DBG("Received ATT chan %p code 0x%02x len %zu", att_chan, hdr->code, - net_buf_frags_len(buf)); + LOG_DBG("Received ATT chan %p code 0x%02x len %zu", att_chan, hdr->code, + net_buf_frags_len(buf)); if (!att_chan->att) { - BT_DBG("Ignore recv on detached ATT chan"); + LOG_DBG("Ignore recv on detached ATT chan"); return 0; } @@ -2805,7 +2801,7 @@ static int bt_att_recv(struct bt_l2cap_chan *chan, struct net_buf *buf) } if (!handler) { - BT_WARN("Unhandled ATT code 0x%02x", hdr->code); + LOG_WRN("Unhandled ATT code 0x%02x", hdr->code); if (att_op_get_type(hdr->code) != ATT_COMMAND && att_op_get_type(hdr->code) != ATT_INDICATION) { send_err_rsp(att_chan, hdr->code, 0, @@ -2817,25 +2813,25 @@ static int bt_att_recv(struct bt_l2cap_chan *chan, struct net_buf *buf) if (IS_ENABLED(CONFIG_BT_ATT_ENFORCE_FLOW)) { if (handler->type == ATT_REQUEST && atomic_test_and_set_bit(att_chan->flags, ATT_PENDING_RSP)) { - BT_WARN("Ignoring unexpected request"); + LOG_WRN("Ignoring unexpected request"); return 0; } else if (handler->type == ATT_INDICATION && atomic_test_and_set_bit(att_chan->flags, ATT_PENDING_CFM)) { - BT_WARN("Ignoring unexpected indication"); + LOG_WRN("Ignoring unexpected indication"); return 0; } } if (buf->len < handler->expect_len) { - BT_ERR("Invalid len %u for code 0x%02x", buf->len, hdr->code); + LOG_ERR("Invalid len %u for code 0x%02x", buf->len, hdr->code); err = BT_ATT_ERR_INVALID_PDU; } else { err = handler->func(att_chan, buf); } if (handler->type == ATT_REQUEST && err) { - BT_DBG("ATT error 0x%02x", err); + LOG_DBG("ATT error 0x%02x", err); send_err_rsp(att_chan, hdr->code, 0, err); } @@ -2848,13 +2844,13 @@ static struct bt_att *att_get(struct bt_conn *conn) struct bt_att_chan *att_chan; if (conn->state != BT_CONN_CONNECTED) { - BT_WARN("Not connected"); + LOG_WRN("Not connected"); return NULL; } chan = bt_l2cap_le_lookup_rx_cid(conn, BT_L2CAP_CID_ATT); if (!chan) { - BT_ERR("Unable to find ATT channel"); + LOG_ERR("Unable to find ATT channel"); return NULL; } @@ -2883,7 +2879,7 @@ struct net_buf *bt_att_create_pdu(struct bt_conn *conn, uint8_t op, size_t len) return bt_att_chan_create_pdu(chan, op, len); } - BT_WARN("No ATT channel for MTU %zu", len + sizeof(op)); + LOG_WRN("No ATT channel for MTU %zu", len + sizeof(op)); return NULL; } @@ -2937,7 +2933,7 @@ static void att_chan_detach(struct bt_att_chan *chan) { struct net_buf *buf; - BT_DBG("chan %p", chan); + LOG_DBG("chan %p", chan); sys_slist_find_and_remove(&chan->att->chans, &chan->node); @@ -2961,7 +2957,7 @@ static void att_timeout(struct k_work *work) struct bt_att_chan *chan = CONTAINER_OF(dwork, struct bt_att_chan, timeout_work); - BT_ERR("ATT Timeout"); + LOG_ERR("ATT Timeout"); /* BLUETOOTH SPECIFICATION Version 4.2 [Vol 3, Part F] page 480: * @@ -2986,7 +2982,7 @@ static struct bt_att_chan *att_get_fixed_chan(struct bt_conn *conn) static void att_chan_attach(struct bt_att *att, struct bt_att_chan *chan) { - BT_DBG("att %p chan %p flags %lu", att, chan, atomic_get(chan->flags)); + LOG_DBG("att %p chan %p flags %lu", att, chan, atomic_get(chan->flags)); if (sys_slist_is_empty(&att->chans)) { /* Init general queues when attaching the first channel */ @@ -3003,8 +2999,8 @@ static void att_chan_attach(struct bt_att *att, struct bt_att_chan *chan) static void cap_eatt_mtu(struct bt_l2cap_le_chan *le_chan) { if (le_chan->tx.mtu > le_chan->rx.mtu) { - BT_DBG("chan %p (0x%04x): saturating TX MTU to ATT buffer size (%d)", - le_chan, le_chan->tx.cid, CONFIG_BT_L2CAP_TX_MTU); + LOG_DBG("chan %p (0x%04x): saturating TX MTU to ATT buffer size (%d)", le_chan, + le_chan->tx.cid, CONFIG_BT_L2CAP_TX_MTU); } le_chan->tx.mps = MIN(le_chan->tx.mps, @@ -3018,7 +3014,7 @@ static void bt_att_connected(struct bt_l2cap_chan *chan) struct bt_att_chan *att_chan = ATT_CHAN(chan); struct bt_l2cap_le_chan *le_chan = BT_L2CAP_LE_CHAN(chan); - BT_DBG("chan %p cid 0x%04x", le_chan, le_chan->tx.cid); + LOG_DBG("chan %p cid 0x%04x", le_chan, le_chan->tx.cid); atomic_set_bit(att_chan->flags, ATT_CONNECTED); @@ -3045,10 +3041,10 @@ static void bt_att_disconnected(struct bt_l2cap_chan *chan) struct bt_att *att = att_chan->att; struct bt_l2cap_le_chan *le_chan = BT_L2CAP_LE_CHAN(chan); - BT_DBG("chan %p cid 0x%04x", le_chan, le_chan->tx.cid); + LOG_DBG("chan %p cid 0x%04x", le_chan, le_chan->tx.cid); if (!att_chan->att) { - BT_DBG("Ignore disconnect on detached ATT chan"); + LOG_DBG("Ignore disconnect on detached ATT chan"); return; } @@ -3105,11 +3101,11 @@ static void bt_att_encrypt_change(struct bt_l2cap_chan *chan, struct bt_conn *conn = le_chan->chan.conn; uint8_t err; - BT_DBG("chan %p conn %p handle %u sec_level 0x%02x status 0x%02x", - le_chan, conn, conn->handle, conn->sec_level, hci_status); + LOG_DBG("chan %p conn %p handle %u sec_level 0x%02x status 0x%02x", le_chan, conn, + conn->handle, conn->sec_level, hci_status); if (!att_chan->att) { - BT_DBG("Ignore encrypt change on detached ATT chan"); + LOG_DBG("Ignore encrypt change on detached ATT chan"); return; } @@ -3136,11 +3132,11 @@ static void bt_att_encrypt_change(struct bt_l2cap_chan *chan, return; } - BT_DBG("Retrying"); + LOG_DBG("Retrying"); err = att_req_retry(att_chan); if (err) { - BT_DBG("Retry failed (%d)", err); + LOG_DBG("Retry failed (%d)", err); att_handle_rsp(att_chan, NULL, 0, err); } } @@ -3151,14 +3147,14 @@ static void bt_att_status(struct bt_l2cap_chan *ch, atomic_t *status) struct bt_att_chan *chan = ATT_CHAN(ch); sys_snode_t *node; - BT_DBG("chan %p status %p", ch, status); + LOG_DBG("chan %p status %p", ch, status); if (!atomic_test_bit(status, BT_L2CAP_STATUS_OUT)) { return; } if (!chan->att) { - BT_DBG("Ignore status on detached ATT chan"); + LOG_DBG("Ignore status on detached ATT chan"); return; } @@ -3185,7 +3181,7 @@ static void bt_att_released(struct bt_l2cap_chan *ch) { struct bt_att_chan *chan = ATT_CHAN(ch); - BT_DBG("chan %p", chan); + LOG_DBG("chan %p", chan); k_mem_slab_free(&chan_slab, (void **)&chan); } @@ -3195,7 +3191,7 @@ static void bt_att_reconfigured(struct bt_l2cap_chan *l2cap_chan) { struct bt_att_chan *att_chan = ATT_CHAN(l2cap_chan); - BT_DBG("chan %p", att_chan); + LOG_DBG("chan %p", att_chan); cap_eatt_mtu(BT_L2CAP_LE_CHAN(l2cap_chan)); @@ -3228,13 +3224,13 @@ static struct bt_att_chan *att_chan_new(struct bt_att *att, atomic_val_t flags) } if (quota == ATT_CHAN_MAX) { - BT_DBG("Maximum number of channels reached: %d", quota); + LOG_DBG("Maximum number of channels reached: %d", quota); return NULL; } } if (k_mem_slab_alloc(&chan_slab, (void **)&chan, K_NO_WAIT)) { - BT_WARN("No available ATT channel for conn %p", att->conn); + LOG_WRN("No available ATT channel for conn %p", att->conn); return NULL; } @@ -3280,12 +3276,12 @@ static void att_enhanced_connection_work_handler(struct k_work *work) const int err = bt_eatt_connect(att->conn, att->eatt.chans_to_connect); if (err == -ENOMEM) { - BT_DBG("Failed to connect %d EATT channels, central has probably " + LOG_DBG("Failed to connect %d EATT channels, central has probably " "already established some.", att->eatt.chans_to_connect); } else if (err < 0) { - BT_WARN("Failed to connect %d EATT channels (err: %d)", - att->eatt.chans_to_connect, err); + LOG_WRN("Failed to connect %d EATT channels (err: %d)", att->eatt.chans_to_connect, + err); } } @@ -3296,10 +3292,10 @@ static int bt_att_accept(struct bt_conn *conn, struct bt_l2cap_chan **ch) struct bt_att *att; struct bt_att_chan *chan; - BT_DBG("conn %p handle %u", conn, conn->handle); + LOG_DBG("conn %p handle %u", conn, conn->handle); if (k_mem_slab_alloc(&att_slab, (void **)&att, K_NO_WAIT)) { - BT_ERR("No available ATT context for conn %p", conn); + LOG_ERR("No available ATT context for conn %p", conn); return -ENOMEM; } @@ -3388,7 +3384,7 @@ static void handle_potential_collision(struct bt_att *att) if (att->eatt.prev_conn_rsp_result == BT_L2CAP_LE_ERR_NO_RESOURCES && att->eatt.prev_conn_req_result == BT_L2CAP_LE_ERR_NO_RESOURCES) { - BT_DBG("Credit based connection request collision detected"); + LOG_DBG("Credit based connection request collision detected"); /* Reset to not keep retrying on repeated failures */ att->eatt.prev_conn_rsp_result = 0; @@ -3401,7 +3397,7 @@ static void handle_potential_collision(struct bt_att *att) err = att_schedule_eatt_connect(att->conn, to_connect); if (err < 0) { - BT_ERR("Failed to schedule EATT connection retry (err: %d)", err); + LOG_ERR("Failed to schedule EATT connection retry (err: %d)", err); } } } @@ -3515,7 +3511,7 @@ static void eatt_auto_connect(struct bt_conn *conn, bt_security_t level, eatt_err = att_schedule_eatt_connect(conn, CONFIG_BT_EATT_MAX); if (eatt_err < 0) { - BT_WARN("Automatic creation of EATT bearers failed on " + LOG_WRN("Automatic creation of EATT bearers failed on " "connection %s with error %d", bt_addr_le_str(bt_conn_get_dst(conn)), eatt_err); } @@ -3608,7 +3604,7 @@ static int bt_eatt_accept(struct bt_conn *conn, struct bt_l2cap_chan **chan) struct bt_att_chan *att_chan = att_get_fixed_chan(conn); struct bt_att *att = att_chan->att; - BT_DBG("conn %p handle %u", conn, conn->handle); + LOG_DBG("conn %p handle %u", conn, conn->handle); att_chan = att_chan_new(att, BIT(ATT_ENHANCED)); if (att_chan) { @@ -3629,14 +3625,14 @@ static void bt_eatt_init(void) }; struct bt_l2cap_server *registered_server; - BT_DBG(""); + LOG_DBG(""); /* Check if eatt_l2cap server has already been registered. */ registered_server = bt_l2cap_server_lookup_psm(eatt_l2cap.psm); if (registered_server != &eatt_l2cap) { err = bt_l2cap_server_register(&eatt_l2cap); if (err < 0) { - BT_ERR("EATT Server registration failed %d", err); + LOG_ERR("EATT Server registration failed %d", err); } } @@ -3721,11 +3717,11 @@ struct bt_att_req *bt_att_req_alloc(k_timeout_t timeout) /* Reserve space for request */ if (k_mem_slab_alloc(&req_slab, (void **)&req, timeout)) { - BT_DBG("No space for req"); + LOG_DBG("No space for req"); return NULL; } - BT_DBG("req %p", req); + LOG_DBG("req %p", req); memset(req, 0, sizeof(*req)); @@ -3734,7 +3730,7 @@ struct bt_att_req *bt_att_req_alloc(k_timeout_t timeout) void bt_att_req_free(struct bt_att_req *req) { - BT_DBG("req %p", req); + LOG_DBG("req %p", req); if (req->buf) { tx_meta_data_free(bt_att_tx_meta_data(req->buf)); @@ -3769,7 +3765,7 @@ int bt_att_req_send(struct bt_conn *conn, struct bt_att_req *req) { struct bt_att *att; - BT_DBG("conn %p req %p", conn, req); + LOG_DBG("conn %p req %p", conn, req); __ASSERT_NO_MSG(conn); __ASSERT_NO_MSG(req); @@ -3804,7 +3800,7 @@ void bt_att_req_cancel(struct bt_conn *conn, struct bt_att_req *req) struct bt_att *att; struct bt_att_chan *chan, *tmp; - BT_DBG("req %p", req); + LOG_DBG("req %p", req); if (!conn || !req) { return; diff --git a/subsys/bluetooth/host/avdtp.c b/subsys/bluetooth/host/avdtp.c index e6173249318..5f8f130cb38 100644 --- a/subsys/bluetooth/host/avdtp.c +++ b/subsys/bluetooth/host/avdtp.c @@ -18,15 +18,15 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_AVDTP) -#define LOG_MODULE_NAME bt_avdtp -#include "common/log.h" - #include "hci_core.h" #include "conn_internal.h" #include "l2cap_internal.h" #include "avdtp_internal.h" +#define LOG_LEVEL CONFIG_BT_AVDTP_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_avdtp); + #define AVDTP_MSG_POISTION 0x00 #define AVDTP_PKT_POSITION 0x02 #define AVDTP_TID_POSITION 0x04 @@ -65,7 +65,7 @@ static int avdtp_send(struct bt_avdtp *session, result = bt_l2cap_chan_send(&session->br_chan.chan, buf); if (result < 0) { - BT_ERR("Error:L2CAP send fail - result = %d", result); + LOG_ERR("Error:L2CAP send fail - result = %d", result); net_buf_unref(buf); return result; } @@ -73,7 +73,7 @@ static int avdtp_send(struct bt_avdtp *session, /*Save the sent request*/ req->sig = AVDTP_GET_SIG_ID(hdr->signal_id); req->tid = AVDTP_GET_TR_ID(hdr->hdr); - BT_DBG("sig 0x%02X, tid 0x%02X", req->sig, req->tid); + LOG_DBG("sig 0x%02X, tid 0x%02X", req->sig, req->tid); session->req = req; /* Start timeout work */ @@ -89,7 +89,7 @@ static struct net_buf *avdtp_create_pdu(uint8_t msg_type, static uint8_t tid; struct bt_avdtp_single_sig_hdr *hdr; - BT_DBG(""); + LOG_DBG(""); buf = bt_l2cap_create_pdu(NULL, 0); @@ -100,14 +100,14 @@ static struct net_buf *avdtp_create_pdu(uint8_t msg_type, tid %= 16; /* Loop for 16*/ hdr->signal_id = sig_id & AVDTP_SIGID_MASK; - BT_DBG("hdr = 0x%02X, Signal_ID = 0x%02X", hdr->hdr, hdr->signal_id); + LOG_DBG("hdr = 0x%02X, Signal_ID = 0x%02X", hdr->hdr, hdr->signal_id); return buf; } /* Timeout handler */ static void avdtp_timeout(struct k_work *work) { - BT_DBG("Failed Signal_id = %d", (AVDTP_KWORK(work))->sig); + LOG_DBG("Failed Signal_id = %d", (AVDTP_KWORK(work))->sig); /* Gracefully Disconnect the Signalling and streaming L2cap chann*/ @@ -119,12 +119,12 @@ void bt_avdtp_l2cap_connected(struct bt_l2cap_chan *chan) struct bt_avdtp *session; if (!chan) { - BT_ERR("Invalid AVDTP chan"); + LOG_ERR("Invalid AVDTP chan"); return; } session = AVDTP_CHAN(chan); - BT_DBG("chan %p session %p", chan, session); + LOG_DBG("chan %p session %p", chan, session); /* Init the timer */ k_work_init_delayable(&session->req->timeout_work, avdtp_timeout); @@ -134,14 +134,14 @@ void bt_avdtp_l2cap_disconnected(struct bt_l2cap_chan *chan) { struct bt_avdtp *session = AVDTP_CHAN(chan); - BT_DBG("chan %p session %p", chan, session); + LOG_DBG("chan %p session %p", chan, session); session->br_chan.chan.conn = NULL; /* Clear the Pending req if set*/ } void bt_avdtp_l2cap_encrypt_changed(struct bt_l2cap_chan *chan, uint8_t status) { - BT_DBG(""); + LOG_DBG(""); } int bt_avdtp_l2cap_recv(struct bt_l2cap_chan *chan, struct net_buf *buf) @@ -151,7 +151,7 @@ int bt_avdtp_l2cap_recv(struct bt_l2cap_chan *chan, struct net_buf *buf) uint8_t i, msgtype, sigid, tid; if (buf->len < sizeof(*hdr)) { - BT_ERR("Recvd Wrong AVDTP Header"); + LOG_ERR("Recvd Wrong AVDTP Header"); return 0; } @@ -160,19 +160,18 @@ int bt_avdtp_l2cap_recv(struct bt_l2cap_chan *chan, struct net_buf *buf) sigid = AVDTP_GET_SIG_ID(hdr->signal_id); tid = AVDTP_GET_TR_ID(hdr->hdr); - BT_DBG("msg_type[0x%02x] sig_id[0x%02x] tid[0x%02x]", - msgtype, sigid, tid); + LOG_DBG("msg_type[0x%02x] sig_id[0x%02x] tid[0x%02x]", msgtype, sigid, tid); /* validate if there is an outstanding resp expected*/ if (msgtype != BT_AVDTP_CMD) { if (session->req == NULL) { - BT_DBG("Unexpected peer response"); + LOG_DBG("Unexpected peer response"); return 0; } if (session->req->sig != sigid || session->req->tid != tid) { - BT_DBG("Peer mismatch resp, expected sig[0x%02x]" + LOG_DBG("Peer mismatch resp, expected sig[0x%02x]" "tid[0x%02x]", session->req->sig, session->req->tid); return 0; @@ -216,7 +215,7 @@ int bt_avdtp_disconnect(struct bt_avdtp *session) return -EINVAL; } - BT_DBG("session %p", session); + LOG_DBG("session %p", session); return bt_l2cap_chan_disconnect(&session->br_chan.chan); } @@ -231,7 +230,7 @@ int bt_avdtp_l2cap_accept(struct bt_conn *conn, struct bt_l2cap_chan **chan) .recv = bt_avdtp_l2cap_recv, }; - BT_DBG("conn %p", conn); + LOG_DBG("conn %p", conn); /* Get the AVDTP session from upper layer */ result = event_cb->accept(conn, &session); if (result < 0) { @@ -246,7 +245,7 @@ int bt_avdtp_l2cap_accept(struct bt_conn *conn, struct bt_l2cap_chan **chan) /* Application will register its callback */ int bt_avdtp_register(struct bt_avdtp_event_cb *cb) { - BT_DBG(""); + LOG_DBG(""); if (event_cb) { return -EALREADY; @@ -260,7 +259,7 @@ int bt_avdtp_register(struct bt_avdtp_event_cb *cb) int bt_avdtp_register_sep(uint8_t media_type, uint8_t role, struct bt_avdtp_seid_lsep *lsep) { - BT_DBG(""); + LOG_DBG(""); static uint8_t bt_avdtp_seid = BT_AVDTP_MIN_SEID; @@ -293,12 +292,12 @@ int bt_avdtp_init(void) .accept = bt_avdtp_l2cap_accept, }; - BT_DBG(""); + LOG_DBG(""); /* Register AVDTP PSM with L2CAP */ err = bt_l2cap_br_server_register(&avdtp_l2cap); if (err < 0) { - BT_ERR("AVDTP L2CAP Registration failed %d", err); + LOG_ERR("AVDTP L2CAP Registration failed %d", err); } return err; @@ -310,9 +309,9 @@ int bt_avdtp_discover(struct bt_avdtp *session, { struct net_buf *buf; - BT_DBG(""); + LOG_DBG(""); if (!param || !session) { - BT_DBG("Error: Callback/Session not valid"); + LOG_DBG("Error: Callback/Session not valid"); return -EINVAL; } @@ -320,7 +319,7 @@ int bt_avdtp_discover(struct bt_avdtp *session, BT_AVDTP_PACKET_TYPE_SINGLE, BT_AVDTP_DISCOVER); if (!buf) { - BT_ERR("Error: No Buff available"); + LOG_ERR("Error: No Buff available"); return -ENOMEM; } diff --git a/subsys/bluetooth/host/br.c b/subsys/bluetooth/host/br.c index 0190486854c..811a41cc50f 100644 --- a/subsys/bluetooth/host/br.c +++ b/subsys/bluetooth/host/br.c @@ -12,15 +12,16 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_CORE) -#define LOG_MODULE_NAME bt_br -#include "common/log.h" #include "common/bt_str.h" #include "hci_core.h" #include "conn_internal.h" #include "keys.h" +#define LOG_LEVEL CONFIG_BT_HCI_CORE_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_br); + static bt_br_discovery_cb_t *discovery_cb; struct bt_br_discovery_result *discovery_results; static size_t discovery_results_size; @@ -111,8 +112,7 @@ static void bt_esco_conn_req(struct bt_hci_evt_conn_request *evt) } if (accept_sco_conn(&evt->bdaddr, sco_conn)) { - BT_ERR("Error accepting connection from %s", - bt_addr_str(&evt->bdaddr)); + LOG_ERR("Error accepting connection from %s", bt_addr_str(&evt->bdaddr)); reject_conn(&evt->bdaddr, BT_HCI_ERR_UNSPECIFIED); bt_sco_cleanup(sco_conn); return; @@ -128,8 +128,7 @@ void bt_hci_conn_req(struct net_buf *buf) struct bt_hci_evt_conn_request *evt = (void *)buf->data; struct bt_conn *conn; - BT_DBG("conn req from %s, type 0x%02x", bt_addr_str(&evt->bdaddr), - evt->link_type); + LOG_DBG("conn req from %s, type 0x%02x", bt_addr_str(&evt->bdaddr), evt->link_type); if (evt->link_type != BT_HCI_ACL) { bt_esco_conn_req(evt); @@ -159,7 +158,7 @@ static bool br_sufficient_key_size(struct bt_conn *conn) buf = bt_hci_cmd_create(BT_HCI_OP_READ_ENCRYPTION_KEY_SIZE, sizeof(*cp)); if (!buf) { - BT_ERR("Failed to allocate command buffer"); + LOG_ERR("Failed to allocate command buffer"); return false; } @@ -169,12 +168,12 @@ static bool br_sufficient_key_size(struct bt_conn *conn) err = bt_hci_cmd_send_sync(BT_HCI_OP_READ_ENCRYPTION_KEY_SIZE, buf, &rsp); if (err) { - BT_ERR("Failed to read encryption key size (err %d)", err); + LOG_ERR("Failed to read encryption key size (err %d)", err); return false; } if (rsp->len < sizeof(*rp)) { - BT_ERR("Too small command complete for encryption key size"); + LOG_ERR("Too small command complete for encryption key size"); net_buf_unref(rsp); return false; } @@ -183,7 +182,7 @@ static bool br_sufficient_key_size(struct bt_conn *conn) key_size = rp->key_size; net_buf_unref(rsp); - BT_DBG("Encryption key size is %u", key_size); + LOG_DBG("Encryption key size is %u", key_size); if (conn->sec_level == BT_SECURITY_L4) { return key_size == BT_HCI_ENCRYPTION_KEY_SIZE_MAX; @@ -210,18 +209,18 @@ bool bt_br_update_sec_level(struct bt_conn *conn) conn->sec_level = BT_SECURITY_L2; } } else { - BT_WARN("No BR/EDR link key found"); + LOG_WRN("No BR/EDR link key found"); conn->sec_level = BT_SECURITY_L2; } if (!br_sufficient_key_size(conn)) { - BT_ERR("Encryption key size is not sufficient"); + LOG_ERR("Encryption key size is not sufficient"); bt_conn_disconnect(conn, BT_HCI_ERR_AUTH_FAIL); return false; } if (conn->required_sec_level > conn->sec_level) { - BT_ERR("Failed to set required security level"); + LOG_ERR("Failed to set required security level"); bt_conn_disconnect(conn, BT_HCI_ERR_AUTH_FAIL); return false; } @@ -235,12 +234,11 @@ void bt_hci_synchronous_conn_complete(struct net_buf *buf) struct bt_conn *sco_conn; uint16_t handle = sys_le16_to_cpu(evt->handle); - BT_DBG("status 0x%02x, handle %u, type 0x%02x", evt->status, handle, - evt->link_type); + LOG_DBG("status 0x%02x, handle %u, type 0x%02x", evt->status, handle, evt->link_type); sco_conn = bt_conn_lookup_addr_sco(&evt->bdaddr); if (!sco_conn) { - BT_ERR("Unable to find conn for %s", bt_addr_str(&evt->bdaddr)); + LOG_ERR("Unable to find conn for %s", bt_addr_str(&evt->bdaddr)); return; } @@ -263,12 +261,11 @@ void bt_hci_conn_complete(struct net_buf *buf) struct bt_hci_cp_read_remote_features *cp; uint16_t handle = sys_le16_to_cpu(evt->handle); - BT_DBG("status 0x%02x, handle %u, type 0x%02x", evt->status, handle, - evt->link_type); + LOG_DBG("status 0x%02x, handle %u, type 0x%02x", evt->status, handle, evt->link_type); conn = bt_conn_lookup_addr_br(&evt->bdaddr); if (!conn) { - BT_ERR("Unable to find conn for %s", bt_addr_str(&evt->bdaddr)); + LOG_ERR("Unable to find conn for %s", bt_addr_str(&evt->bdaddr)); return; } @@ -415,7 +412,7 @@ void bt_hci_inquiry_complete(struct net_buf *buf) struct bt_hci_evt_inquiry_complete *evt = (void *)buf->data; if (evt->status) { - BT_ERR("Failed to complete inquiry"); + LOG_ERR("Failed to complete inquiry"); } report_discovery_results(); @@ -461,8 +458,8 @@ static struct bt_br_discovery_result *get_result_slot(const bt_addr_t *addr, } if (result) { - BT_DBG("Reusing slot (old %s rssi %d dBm)", - bt_addr_str(&result->addr), result->rssi); + LOG_DBG("Reusing slot (old %s rssi %d dBm)", bt_addr_str(&result->addr), + result->rssi); bt_addr_copy(&result->addr, addr); } @@ -478,7 +475,7 @@ void bt_hci_inquiry_result_with_rssi(struct net_buf *buf) return; } - BT_DBG("number of results: %u", num_reports); + LOG_DBG("number of results: %u", num_reports); while (num_reports--) { struct bt_hci_evt_inquiry_result_with_rssi *evt; @@ -486,12 +483,12 @@ void bt_hci_inquiry_result_with_rssi(struct net_buf *buf) struct discovery_priv *priv; if (buf->len < sizeof(*evt)) { - BT_ERR("Unexpected end to buffer"); + LOG_ERR("Unexpected end to buffer"); return; } evt = net_buf_pull_mem(buf, sizeof(*evt)); - BT_DBG("%s rssi %d dBm", bt_addr_str(&evt->addr), evt->rssi); + LOG_DBG("%s rssi %d dBm", bt_addr_str(&evt->addr), evt->rssi); result = get_result_slot(&evt->addr, evt->rssi); if (!result) { @@ -520,7 +517,7 @@ void bt_hci_extended_inquiry_result(struct net_buf *buf) return; } - BT_DBG("%s rssi %d dBm", bt_addr_str(&evt->addr), evt->rssi); + LOG_DBG("%s rssi %d dBm", bt_addr_str(&evt->addr), evt->rssi); result = get_result_slot(&evt->addr, evt->rssi); if (!result) { @@ -622,11 +619,11 @@ void bt_hci_read_remote_features_complete(struct net_buf *buf) struct bt_hci_cp_read_remote_ext_features *cp; struct bt_conn *conn; - BT_DBG("status 0x%02x handle %u", evt->status, handle); + LOG_DBG("status 0x%02x handle %u", evt->status, handle); conn = bt_conn_lookup_handle(handle); if (!conn) { - BT_ERR("Can't find conn for handle %u", handle); + LOG_ERR("Can't find conn for handle %u", handle); return; } @@ -663,11 +660,11 @@ void bt_hci_read_remote_ext_features_complete(struct net_buf *buf) uint16_t handle = sys_le16_to_cpu(evt->handle); struct bt_conn *conn; - BT_DBG("status 0x%02x handle %u", evt->status, handle); + LOG_DBG("status 0x%02x handle %u", evt->status, handle); conn = bt_conn_lookup_handle(handle); if (!conn) { - BT_ERR("Can't find conn for handle %u", handle); + LOG_ERR("Can't find conn for handle %u", handle); return; } @@ -684,8 +681,7 @@ void bt_hci_role_change(struct net_buf *buf) struct bt_hci_evt_role_change *evt = (void *)buf->data; struct bt_conn *conn; - BT_DBG("status 0x%02x role %u addr %s", evt->status, evt->role, - bt_addr_str(&evt->bdaddr)); + LOG_DBG("status 0x%02x role %u addr %s", evt->status, evt->role, bt_addr_str(&evt->bdaddr)); if (evt->status) { return; @@ -693,7 +689,7 @@ void bt_hci_role_change(struct net_buf *buf) conn = bt_conn_lookup_addr_br(&evt->bdaddr); if (!conn) { - BT_ERR("Can't find conn for %s", bt_addr_str(&evt->bdaddr)); + LOG_ERR("Can't find conn for %s", bt_addr_str(&evt->bdaddr)); return; } @@ -790,12 +786,12 @@ static void read_buffer_size_complete(struct net_buf *buf) struct bt_hci_rp_read_buffer_size *rp = (void *)buf->data; uint16_t pkts; - BT_DBG("status 0x%02x", rp->status); + LOG_DBG("status 0x%02x", rp->status); bt_dev.br.mtu = sys_le16_to_cpu(rp->acl_max_len); pkts = sys_le16_to_cpu(rp->acl_max_num); - BT_DBG("ACL BR/EDR buffers: pkts %u mtu %u", pkts, bt_dev.br.mtu); + LOG_DBG("ACL BR/EDR buffers: pkts %u mtu %u", pkts, bt_dev.br.mtu); k_sem_init(&bt_dev.br.pkts, pkts, pkts); } @@ -949,7 +945,7 @@ int bt_br_discovery_start(const struct bt_br_discovery_param *param, { int err; - BT_DBG(""); + LOG_DBG(""); if (!valid_br_discov_param(param, cnt)) { return -EINVAL; @@ -981,7 +977,7 @@ int bt_br_discovery_stop(void) int err; int i; - BT_DBG(""); + LOG_DBG(""); if (!atomic_test_bit(bt_dev.flags, BT_DEV_INQUIRY)) { return -EALREADY; @@ -1030,7 +1026,7 @@ static int write_scan_enable(uint8_t scan) struct net_buf *buf; int err; - BT_DBG("type %u", scan); + LOG_DBG("type %u", scan); buf = bt_hci_cmd_create(BT_HCI_OP_WRITE_SCAN_ENABLE, 1); if (!buf) { diff --git a/subsys/bluetooth/host/buf.c b/subsys/bluetooth/host/buf.c index 8c2d0b092ad..42b781f5875 100644 --- a/subsys/bluetooth/host/buf.c +++ b/subsys/bluetooth/host/buf.c @@ -12,9 +12,7 @@ #include "conn_internal.h" #include "iso_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_CORE) -#define LOG_MODULE_NAME bt_buf -#include "common/log.h" +#include #if defined(CONFIG_BT_CONN) #if defined(CONFIG_BT_ISO) diff --git a/subsys/bluetooth/host/conn.c b/subsys/bluetooth/host/conn.c index 74468c70f58..58e0d10c9b4 100644 --- a/subsys/bluetooth/host/conn.c +++ b/subsys/bluetooth/host/conn.c @@ -25,9 +25,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_CONN) -#define LOG_MODULE_NAME bt_conn -#include "common/log.h" #include "common/assert.h" #include "hci_core.h" @@ -42,6 +39,10 @@ #include "iso_internal.h" #include "direction_internal.h" +#define LOG_LEVEL CONFIG_BT_CONN_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_conn); + struct tx_meta { struct bt_conn_tx *tx; }; @@ -187,7 +188,7 @@ static void tx_free(struct bt_conn_tx *tx) static void tx_notify(struct bt_conn *conn) { - BT_DBG("conn %p", conn); + LOG_DBG("conn %p", conn); while (1) { struct bt_conn_tx *tx = NULL; @@ -206,7 +207,7 @@ static void tx_notify(struct bt_conn *conn) return; } - BT_DBG("tx %p cb %p user_data %p", tx, tx->cb, tx->user_data); + LOG_DBG("tx %p cb %p user_data %p", tx, tx->cb, tx->user_data); /* Copy over the params */ cb = tx->cb; @@ -270,32 +271,31 @@ static void bt_acl_recv(struct bt_conn *conn, struct net_buf *buf, switch (flags) { case BT_ACL_START: if (conn->rx) { - BT_ERR("Unexpected first L2CAP frame"); + LOG_ERR("Unexpected first L2CAP frame"); bt_conn_reset_rx_state(conn); } - BT_DBG("First, len %u final %u", buf->len, - (buf->len < sizeof(uint16_t)) ? - 0 : sys_get_le16(buf->data)); + LOG_DBG("First, len %u final %u", buf->len, + (buf->len < sizeof(uint16_t)) ? 0 : sys_get_le16(buf->data)); conn->rx = buf; break; case BT_ACL_CONT: if (!conn->rx) { - BT_ERR("Unexpected L2CAP continuation"); + LOG_ERR("Unexpected L2CAP continuation"); bt_conn_reset_rx_state(conn); net_buf_unref(buf); return; } if (!buf->len) { - BT_DBG("Empty ACL_CONT"); + LOG_DBG("Empty ACL_CONT"); net_buf_unref(buf); return; } if (buf->len > net_buf_tailroom(conn->rx)) { - BT_ERR("Not enough buffer space for L2CAP data"); + LOG_ERR("Not enough buffer space for L2CAP data"); /* Frame is not complete but we still pass it to L2CAP * so that it may handle error on protocol level @@ -315,7 +315,7 @@ static void bt_acl_recv(struct bt_conn *conn, struct net_buf *buf, * LE-U from Controller to Host. * Only BT_ACL_POINT_TO_POINT is supported. */ - BT_ERR("Unexpected ACL flags (0x%02x)", flags); + LOG_ERR("Unexpected ACL flags (0x%02x)", flags); bt_conn_reset_rx_state(conn); net_buf_unref(buf); return; @@ -336,8 +336,7 @@ static void bt_acl_recv(struct bt_conn *conn, struct net_buf *buf, } if (conn->rx->len > acl_total_len) { - BT_ERR("ACL len mismatch (%u > %u)", - conn->rx->len, acl_total_len); + LOG_ERR("ACL len mismatch (%u > %u)", conn->rx->len, acl_total_len); bt_conn_reset_rx_state(conn); return; } @@ -346,7 +345,7 @@ static void bt_acl_recv(struct bt_conn *conn, struct net_buf *buf, buf = conn->rx; conn->rx = NULL; - BT_DBG("Successfully parsed %u byte L2CAP packet", buf->len); + LOG_DBG("Successfully parsed %u byte L2CAP packet", buf->len); bt_l2cap_recv(conn, buf, true); } @@ -357,7 +356,7 @@ void bt_conn_recv(struct bt_conn *conn, struct net_buf *buf, uint8_t flags) */ tx_notify(conn); - BT_DBG("handle %u len %u flags %02x", conn->handle, buf->len, flags); + LOG_DBG("handle %u len %u flags %02x", conn->handle, buf->len, flags); if ((IS_ENABLED(CONFIG_BT_ISO_UNICAST) || IS_ENABLED(CONFIG_BT_ISO_SYNC_RECEIVER)) && @@ -381,14 +380,14 @@ static struct bt_conn_tx *conn_tx_alloc(void) return k_fifo_get(&free_tx, K_NO_WAIT); } - if (IS_ENABLED(CONFIG_BT_DEBUG_CONN)) { + if (IS_ENABLED(CONFIG_BT_CONN_LOG_LEVEL_DBG)) { struct bt_conn_tx *tx = k_fifo_get(&free_tx, K_NO_WAIT); if (tx) { return tx; } - BT_WARN("Unable to get an immediate free conn_tx"); + LOG_WRN("Unable to get an immediate free conn_tx"); } return k_fifo_get(&free_tx, K_FOREVER); @@ -399,24 +398,24 @@ int bt_conn_send_cb(struct bt_conn *conn, struct net_buf *buf, { struct bt_conn_tx *tx; - BT_DBG("conn handle %u buf len %u cb %p user_data %p", conn->handle, - buf->len, cb, user_data); + LOG_DBG("conn handle %u buf len %u cb %p user_data %p", conn->handle, buf->len, cb, + user_data); if (conn->state != BT_CONN_CONNECTED) { - BT_ERR("not connected!"); + LOG_ERR("not connected!"); return -ENOTCONN; } if (cb) { tx = conn_tx_alloc(); if (!tx) { - BT_ERR("Unable to allocate TX context"); + LOG_ERR("Unable to allocate TX context"); return -ENOBUFS; } /* Verify that we're still connected after blocking */ if (conn->state != BT_CONN_CONNECTED) { - BT_WARN("Disconnected while allocating context"); + LOG_WRN("Disconnected while allocating context"); tx_free(tx); return -ENOTCONN; } @@ -506,8 +505,7 @@ static bool send_frag(struct bt_conn *conn, struct net_buf *buf, uint8_t flags, unsigned int key; int err = 0; - BT_DBG("conn %p buf %p len %u flags 0x%02x", conn, buf, buf->len, - flags); + LOG_DBG("conn %p buf %p len %u flags 0x%02x", conn, buf, buf->len, flags); /* Wait until the controller can accept ACL packets */ k_sem_take(bt_conn_get_pkts(conn), K_FOREVER); @@ -544,7 +542,7 @@ static bool send_frag(struct bt_conn *conn, struct net_buf *buf, uint8_t flags, } if (err) { - BT_ERR("Unable to send to driver (err %d)", err); + LOG_ERR("Unable to send to driver (err %d)", err); key = irq_lock(); /* Roll back the pending TX info */ if (tx) { @@ -634,7 +632,7 @@ static bool send_buf(struct bt_conn *conn, struct net_buf *buf) { struct net_buf *frag; - BT_DBG("conn %p buf %p len %u", conn, buf, buf->len); + LOG_DBG("conn %p buf %p len %u", conn, buf, buf->len); /* Send directly if the packet fits the ACL MTU */ if (buf->len <= conn_mtu(conn)) { @@ -732,7 +730,7 @@ static int conn_prepare_events(struct bt_conn *conn, return -ENOTCONN; } - BT_DBG("Adding conn %p to poll list", conn); + LOG_DBG("Adding conn %p to poll list", conn); k_poll_event_init(&events[0], K_POLL_TYPE_FIFO_DATA_AVAILABLE, @@ -748,7 +746,7 @@ int bt_conn_prepare_events(struct k_poll_event events[]) int i, ev_count = 0; struct bt_conn *conn; - BT_DBG(""); + LOG_DBG(""); k_poll_signal_init(&conn_change); @@ -782,11 +780,11 @@ void bt_conn_process_tx(struct bt_conn *conn) { struct net_buf *buf; - BT_DBG("conn %p", conn); + LOG_DBG("conn %p", conn); if (conn->state == BT_CONN_DISCONNECTED && atomic_test_and_clear_bit(conn->flags, BT_CONN_CLEANUP)) { - BT_DBG("handle %u disconnected - cleaning up", conn->handle); + LOG_DBG("handle %u disconnected - cleaning up", conn->handle); conn_cleanup(conn); return; } @@ -879,10 +877,10 @@ void bt_conn_set_state(struct bt_conn *conn, bt_conn_state_t state) { bt_conn_state_t old_state; - BT_DBG("%s -> %s", state2str(conn->state), state2str(state)); + LOG_DBG("%s -> %s", state2str(conn->state), state2str(state)); if (conn->state == state) { - BT_WARN("no transition %s", state2str(state)); + LOG_WRN("no transition %s", state2str(state)); return; } @@ -1022,7 +1020,7 @@ void bt_conn_set_state(struct bt_conn *conn, bt_conn_state_t state) case BT_CONN_DISCONNECTING: case BT_CONN_DISCONNECTED: /* Cannot happen. */ - BT_WARN("Invalid (%u) old state", state); + LOG_WRN("Invalid (%u) old state", state); break; } break; @@ -1056,7 +1054,7 @@ void bt_conn_set_state(struct bt_conn *conn, bt_conn_state_t state) process_unack_tx(conn); break; default: - BT_WARN("no valid (%u) state was set", state); + LOG_WRN("no valid (%u) state was set", state); break; } @@ -1162,7 +1160,7 @@ struct bt_conn *bt_conn_ref(struct bt_conn *conn) } } while (!atomic_cas(&conn->ref, old, old + 1)); - BT_DBG("handle %u ref %ld -> %ld", conn->handle, old, old + 1); + LOG_DBG("handle %u ref %ld -> %ld", conn->handle, old, old + 1); return conn; } @@ -1173,8 +1171,7 @@ void bt_conn_unref(struct bt_conn *conn) old = atomic_dec(&conn->ref); - BT_DBG("handle %u ref %ld -> %ld", conn->handle, old, - atomic_get(&conn->ref)); + LOG_DBG("handle %u ref %ld -> %ld", conn->handle, old, atomic_get(&conn->ref)); __ASSERT(old > 0, "Conn reference counter is 0"); @@ -1244,14 +1241,14 @@ struct net_buf *bt_conn_create_pdu_timeout(struct net_buf_pool *pool, #endif /* CONFIG_BT_CONN */ } - if (IS_ENABLED(CONFIG_BT_DEBUG_CONN)) { + if (IS_ENABLED(CONFIG_BT_CONN_LOG_LEVEL_DBG)) { #if defined(CONFIG_NET_BUF_LOG) buf = net_buf_alloc_fixed_debug(pool, K_NO_WAIT, func, line); #else buf = net_buf_alloc(pool, K_NO_WAIT); #endif if (!buf) { - BT_WARN("Unable to allocate buffer with K_NO_WAIT"); + LOG_WRN("Unable to allocate buffer with K_NO_WAIT"); #if defined(CONFIG_NET_BUF_LOG) buf = net_buf_alloc_fixed_debug(pool, timeout, func, line); @@ -1269,7 +1266,7 @@ struct net_buf *bt_conn_create_pdu_timeout(struct net_buf_pool *pool, } if (!buf) { - BT_WARN("Unable to allocate buffer within timeout"); + LOG_WRN("Unable to allocate buffer within timeout"); return NULL; } @@ -1285,7 +1282,7 @@ static void tx_complete_work(struct k_work *work) struct bt_conn *conn = CONTAINER_OF(work, struct bt_conn, tx_complete_work); - BT_DBG("conn %p", conn); + LOG_DBG("conn %p", conn); tx_notify(conn); } @@ -1404,7 +1401,7 @@ void notify_remote_info(struct bt_conn *conn) err = bt_conn_get_remote_info(conn, &remote_info); if (err) { - BT_DBG("Notify remote info failed %d", err); + LOG_DBG("Notify remote info failed %d", err); return; } @@ -1541,9 +1538,8 @@ bool le_param_req(struct bt_conn *conn, struct bt_le_conn_param *param) static int send_conn_le_param_update(struct bt_conn *conn, const struct bt_le_conn_param *param) { - BT_DBG("conn %p features 0x%02x params (%d-%d %d %d)", conn, - conn->le.features[0], param->interval_min, - param->interval_max, param->latency, param->timeout); + LOG_DBG("conn %p features 0x%02x params (%d-%d %d %d)", conn, conn->le.features[0], + param->interval_min, param->interval_max, param->latency, param->timeout); /* Proceed only if connection parameters contains valid values*/ if (!bt_le_conn_params_valid(param)) { @@ -1607,7 +1603,7 @@ static void deferred_work(struct k_work *work) struct bt_conn *conn = CONTAINER_OF(dwork, struct bt_conn, deferred_work); const struct bt_le_conn_param *param; - BT_DBG("conn %p", conn); + LOG_DBG("conn %p", conn); if (conn->state == BT_CONN_DISCONNECTED) { #if defined(CONFIG_BT_ISO_UNICAST) @@ -1681,7 +1677,7 @@ static void deferred_work(struct k_work *work) atomic_clear_bit(conn->flags, BT_CONN_PERIPHERAL_PARAM_AUTO_UPDATE); } else { - BT_WARN("Send LE param update failed (err %d)", err); + LOG_WRN("Send LE param update failed (err %d)", err); } } else if (IS_ENABLED(CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS)) { #if defined(CONFIG_BT_GAP_PERIPHERAL_PREF_PARAMS) @@ -1698,7 +1694,7 @@ static void deferred_work(struct k_work *work) atomic_set_bit(conn->flags, BT_CONN_PERIPHERAL_PARAM_AUTO_UPDATE); } else { - BT_WARN("Send auto LE param update failed (err %d)", + LOG_WRN("Send auto LE param update failed (err %d)", err); } #endif @@ -1816,7 +1812,7 @@ struct bt_conn *bt_conn_create_sco(const bt_addr_t *peer) (void)memset(cp, 0, sizeof(*cp)); - BT_ERR("handle : %x", sco_conn->sco.acl->handle); + LOG_ERR("handle : %x", sco_conn->sco.acl->handle); cp->handle = sco_conn->sco.acl->handle; cp->pkt_type = sco_conn->sco.pkt_type; @@ -2188,8 +2184,7 @@ bool bt_conn_exists_le(uint8_t id, const bt_addr_le_t *peer) * still has valid references. The last reference of the stack * is released after the disconnected callback. */ - BT_WARN("Found valid connection in %s state", - state2str(conn->state)); + LOG_WRN("Found valid connection in %s state", state2str(conn->state)); bt_conn_unref(conn); return true; } @@ -2481,9 +2476,8 @@ int bt_conn_le_get_tx_power_level(struct bt_conn *conn, int bt_conn_le_param_update(struct bt_conn *conn, const struct bt_le_conn_param *param) { - BT_DBG("conn %p features 0x%02x params (%d-%d %d %d)", conn, - conn->le.features[0], param->interval_min, - param->interval_max, param->latency, param->timeout); + LOG_DBG("conn %p features 0x%02x params (%d-%d %d %d)", conn, conn->le.features[0], + param->interval_min, param->interval_max, param->latency, param->timeout); /* Check if there's a need to update conn params */ if (conn->le.interval >= param->interval_min && @@ -2654,7 +2648,7 @@ int bt_conn_le_create_auto(const struct bt_conn_le_create_param *create_param, err = bt_le_create_conn(conn); if (err) { - BT_ERR("Failed to start filtered scan"); + LOG_ERR("Failed to start filtered scan"); conn->err = 0; bt_conn_set_state(conn, BT_CONN_DISCONNECTED); bt_conn_unref(conn); @@ -2692,7 +2686,7 @@ int bt_conn_create_auto_stop(void) err = bt_le_create_conn_cancel(); if (err) { - BT_ERR("Failed to stop initiator"); + LOG_ERR("Failed to stop initiator"); return err; } @@ -3098,18 +3092,18 @@ void bt_hci_le_df_connection_iq_report_common(uint8_t event, struct net_buf *buf if (event == BT_HCI_EVT_LE_CONNECTION_IQ_REPORT) { err = hci_df_prepare_connection_iq_report(buf, &iq_report, &conn); if (err) { - BT_ERR("Prepare CTE conn IQ report failed %d", err); + LOG_ERR("Prepare CTE conn IQ report failed %d", err); return; } } else if (IS_ENABLED(CONFIG_BT_DF_VS_CONN_IQ_REPORT_16_BITS_IQ_SAMPLES) && event == BT_HCI_EVT_VS_LE_CONNECTION_IQ_REPORT) { err = hci_df_vs_prepare_connection_iq_report(buf, &iq_report, &conn); if (err) { - BT_ERR("Prepare CTE conn IQ report failed %d", err); + LOG_ERR("Prepare CTE conn IQ report failed %d", err); return; } } else { - BT_ERR("Unhandled VS connection IQ report"); + LOG_ERR("Unhandled VS connection IQ report"); return; } @@ -3152,7 +3146,7 @@ void bt_hci_le_df_cte_req_failed(struct net_buf *buf) err = hci_df_prepare_conn_cte_req_failed(buf, &iq_report, &conn); if (err) { - BT_ERR("Prepare CTE REQ failed IQ report failed %d", err); + LOG_ERR("Prepare CTE REQ failed IQ report failed %d", err); return; } diff --git a/subsys/bluetooth/host/crypto.c b/subsys/bluetooth/host/crypto.c index 85465cad8ca..1ffe94a4592 100644 --- a/subsys/bluetooth/host/crypto.c +++ b/subsys/bluetooth/host/crypto.c @@ -22,13 +22,14 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_CORE) -#define LOG_MODULE_NAME bt_host_crypto -#include "common/log.h" #include "common/bt_str.h" #include "hci_core.h" +#define LOG_LEVEL CONFIG_BT_HCI_CORE_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_host_crypto); + static struct tc_hmac_prng_struct prng; static int prng_reseed(struct tc_hmac_prng_struct *h) @@ -47,7 +48,7 @@ static int prng_reseed(struct tc_hmac_prng_struct *h) ret = tc_hmac_prng_reseed(h, seed, sizeof(seed), (uint8_t *)&extra, sizeof(extra)); if (ret == TC_CRYPTO_FAIL) { - BT_ERR("Failed to re-seed PRNG"); + LOG_ERR("Failed to re-seed PRNG"); return -EIO; } @@ -66,7 +67,7 @@ int prng_init(void) ret = tc_hmac_prng_init(&prng, perso, sizeof(perso)); if (ret == TC_CRYPTO_FAIL) { - BT_ERR("Failed to initialize PRNG"); + LOG_ERR("Failed to initialize PRNG"); return -EIO; } @@ -120,8 +121,8 @@ int bt_encrypt_le(const uint8_t key[16], const uint8_t plaintext[16], return -EINVAL; } - BT_DBG("key %s", bt_hex(key, 16)); - BT_DBG("plaintext %s", bt_hex(plaintext, 16)); + LOG_DBG("key %s", bt_hex(key, 16)); + LOG_DBG("plaintext %s", bt_hex(plaintext, 16)); sys_memcpy_swap(tmp, key, 16); @@ -137,7 +138,7 @@ int bt_encrypt_le(const uint8_t key[16], const uint8_t plaintext[16], sys_mem_swap(enc_data, 16); - BT_DBG("enc_data %s", bt_hex(enc_data, 16)); + LOG_DBG("enc_data %s", bt_hex(enc_data, 16)); return 0; } @@ -151,8 +152,8 @@ int bt_encrypt_be(const uint8_t key[16], const uint8_t plaintext[16], return -EINVAL; } - BT_DBG("key %s", bt_hex(key, 16)); - BT_DBG("plaintext %s", bt_hex(plaintext, 16)); + LOG_DBG("key %s", bt_hex(key, 16)); + LOG_DBG("plaintext %s", bt_hex(plaintext, 16)); if (tc_aes128_set_encrypt_key(&s, key) == TC_CRYPTO_FAIL) { return -EINVAL; @@ -162,7 +163,7 @@ int bt_encrypt_be(const uint8_t key[16], const uint8_t plaintext[16], return -EINVAL; } - BT_DBG("enc_data %s", bt_hex(enc_data, 16)); + LOG_DBG("enc_data %s", bt_hex(enc_data, 16)); return 0; } diff --git a/subsys/bluetooth/host/direction.c b/subsys/bluetooth/host/direction.c index 4b947c29dc6..c5cc3817bb7 100644 --- a/subsys/bluetooth/host/direction.c +++ b/subsys/bluetooth/host/direction.c @@ -20,9 +20,9 @@ #include "conn_internal.h" #include "direction_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_DF) -#define LOG_MODULE_NAME bt_df -#include "common/log.h" +#include + +LOG_MODULE_REGISTER(bt_df, CONFIG_BT_DF_LOG_LEVEL); /* @brief Antenna information for LE Direction Finding */ struct bt_le_df_ant_info { @@ -80,7 +80,7 @@ static uint8_t get_hci_cte_type(enum bt_df_cte_type type) case BT_DF_CTE_TYPE_AOD_2US: return BT_HCI_LE_AOD_CTE_2US; default: - BT_ERR("Wrong CTE type"); + LOG_ERR("Wrong CTE type"); return BT_HCI_LE_NO_CTE; } } @@ -176,13 +176,13 @@ static int hci_df_read_ant_info(uint8_t *switch_sample_rates, err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_READ_ANT_INFO, NULL, &rsp); if (err) { - BT_ERR("Failed to read antenna information"); + LOG_ERR("Failed to read antenna information"); return err; } rp = (void *)rsp->data; - BT_DBG("DF: sw. sampl rates: %x ant num: %u , max sw. pattern len: %u," + LOG_DBG("DF: sw. sampl rates: %x ant num: %u , max sw. pattern len: %u," "max CTE len %d", rp->switch_sample_rates, rp->num_ant, rp->max_switch_pattern_len, rp->max_cte_len); @@ -377,7 +377,7 @@ int hci_df_prepare_connectionless_iq_report(struct net_buf *buf, struct bt_le_per_adv_sync *per_adv_sync; if (buf->len < sizeof(*evt)) { - BT_ERR("Unexpected end of buffer"); + LOG_ERR("Unexpected end of buffer"); return -EINVAL; } @@ -386,18 +386,18 @@ int hci_df_prepare_connectionless_iq_report(struct net_buf *buf, per_adv_sync = bt_hci_get_per_adv_sync(sys_le16_to_cpu(evt->sync_handle)); if (!per_adv_sync) { - BT_ERR("Unknown handle 0x%04X for iq samples report", - sys_le16_to_cpu(evt->sync_handle)); + LOG_ERR("Unknown handle 0x%04X for iq samples report", + sys_le16_to_cpu(evt->sync_handle)); return -EINVAL; } if (!atomic_test_bit(per_adv_sync->flags, BT_PER_ADV_SYNC_CTE_ENABLED)) { - BT_ERR("Received PA CTE report when CTE receive disabled"); + LOG_ERR("Received PA CTE report when CTE receive disabled"); return -EINVAL; } if (!(per_adv_sync->cte_types & BIT(evt->cte_type))) { - BT_DBG("CTE filtered out by cte_type: %u", evt->cte_type); + LOG_DBG("CTE filtered out by cte_type: %u", evt->cte_type); return -EINVAL; } @@ -425,7 +425,7 @@ int hci_df_vs_prepare_connectionless_iq_report(struct net_buf *buf, struct bt_le_per_adv_sync *per_adv_sync; if (buf->len < sizeof(*evt)) { - BT_ERR("Unexpected end of buffer"); + LOG_ERR("Unexpected end of buffer"); return -EINVAL; } @@ -434,18 +434,18 @@ int hci_df_vs_prepare_connectionless_iq_report(struct net_buf *buf, per_adv_sync = bt_hci_get_per_adv_sync(sys_le16_to_cpu(evt->sync_handle)); if (!per_adv_sync) { - BT_ERR("Unknown handle 0x%04X for iq samples report", - sys_le16_to_cpu(evt->sync_handle)); + LOG_ERR("Unknown handle 0x%04X for iq samples report", + sys_le16_to_cpu(evt->sync_handle)); return -EINVAL; } if (!atomic_test_bit(per_adv_sync->flags, BT_PER_ADV_SYNC_CTE_ENABLED)) { - BT_ERR("Received PA CTE report when CTE receive disabled"); + LOG_ERR("Received PA CTE report when CTE receive disabled"); return -EINVAL; } if (!(per_adv_sync->cte_types & BIT(evt->cte_type))) { - BT_DBG("CTE filtered out by cte_type: %u", evt->cte_type); + LOG_DBG("CTE filtered out by cte_type: %u", evt->cte_type); return -EINVAL; } @@ -674,7 +674,7 @@ int hci_df_prepare_connection_iq_report(struct net_buf *buf, struct bt_conn *conn; if (buf->len < sizeof(*evt)) { - BT_ERR("Unexpected end of buffer"); + LOG_ERR("Unexpected end of buffer"); return -EINVAL; } @@ -682,18 +682,18 @@ int hci_df_prepare_connection_iq_report(struct net_buf *buf, conn = bt_conn_lookup_handle(sys_le16_to_cpu(evt->conn_handle)); if (!conn) { - BT_ERR("Unknown conn handle 0x%04X for iq samples report", - sys_le16_to_cpu(evt->conn_handle)); + LOG_ERR("Unknown conn handle 0x%04X for iq samples report", + sys_le16_to_cpu(evt->conn_handle)); return -EINVAL; } if (!atomic_test_bit(conn->flags, BT_CONN_CTE_RX_ENABLED)) { - BT_ERR("Received conn CTE report when CTE receive disabled"); + LOG_ERR("Received conn CTE report when CTE receive disabled"); return -EINVAL; } if (!(conn->cte_types & BIT(evt->cte_type))) { - BT_DBG("CTE filtered out by cte_type: %u", evt->cte_type); + LOG_DBG("CTE filtered out by cte_type: %u", evt->cte_type); return -EINVAL; } @@ -724,7 +724,7 @@ int hci_df_vs_prepare_connection_iq_report(struct net_buf *buf, struct bt_conn *conn; if (buf->len < sizeof(*evt)) { - BT_ERR("Unexpected end of buffer"); + LOG_ERR("Unexpected end of buffer"); return -EINVAL; } @@ -732,18 +732,18 @@ int hci_df_vs_prepare_connection_iq_report(struct net_buf *buf, conn = bt_conn_lookup_handle(sys_le16_to_cpu(evt->conn_handle)); if (!conn) { - BT_ERR("Unknown conn handle 0x%04X for iq samples report", - sys_le16_to_cpu(evt->conn_handle)); + LOG_ERR("Unknown conn handle 0x%04X for iq samples report", + sys_le16_to_cpu(evt->conn_handle)); return -EINVAL; } if (!atomic_test_bit(conn->flags, BT_CONN_CTE_RX_ENABLED)) { - BT_ERR("Received conn CTE report when CTE receive disabled"); + LOG_ERR("Received conn CTE report when CTE receive disabled"); return -EINVAL; } if (!(conn->cte_types & BIT(evt->cte_type))) { - BT_DBG("CTE filtered out by cte_type: %u", evt->cte_type); + LOG_DBG("CTE filtered out by cte_type: %u", evt->cte_type); return -EINVAL; } @@ -847,7 +847,7 @@ int hci_df_prepare_conn_cte_req_failed(struct net_buf *buf, struct bt_conn *conn; if (buf->len < sizeof(*evt)) { - BT_ERR("Unexpected end of buffer"); + LOG_ERR("Unexpected end of buffer"); return -EINVAL; } @@ -855,13 +855,13 @@ int hci_df_prepare_conn_cte_req_failed(struct net_buf *buf, conn = bt_conn_lookup_handle(sys_le16_to_cpu(evt->conn_handle)); if (!conn) { - BT_ERR("Unknown conn handle 0x%04X for iq samples report", - sys_le16_to_cpu(evt->conn_handle)); + LOG_ERR("Unknown conn handle 0x%04X for iq samples report", + sys_le16_to_cpu(evt->conn_handle)); return -EINVAL; } if (!atomic_test_bit(conn->flags, BT_CONN_CTE_REQ_ENABLED)) { - BT_ERR("Received conn CTE request notification when CTE REQ disabled"); + LOG_ERR("Received conn CTE request notification when CTE REQ disabled"); return -EINVAL; } @@ -948,7 +948,7 @@ int le_df_init(void) df_ant_info.max_cte_len = max_cte_len; df_ant_info.num_ant = num_ant; - BT_DBG("DF initialized."); + LOG_DBG("DF initialized."); return 0; } @@ -1063,12 +1063,12 @@ static int bt_df_set_conn_cte_rx_enable(struct bt_conn *conn, bool enable, const struct bt_df_conn_cte_rx_param *params) { if (!BT_FEAT_LE_RX_CTE(bt_dev.le.features)) { - BT_WARN("Receiving Constant Tone Extensions is not supported"); + LOG_WRN("Receiving Constant Tone Extensions is not supported"); return -ENOTSUP; } if (conn->state != BT_CONN_CONNECTED) { - BT_ERR("not connected!"); + LOG_ERR("not connected!"); return -ENOTCONN; } @@ -1110,12 +1110,12 @@ int bt_df_set_conn_cte_tx_param(struct bt_conn *conn, const struct bt_df_conn_ct } if (conn->state != BT_CONN_CONNECTED) { - BT_ERR("not connected!"); + LOG_ERR("not connected!"); return -ENOTCONN; } if (atomic_test_bit(conn->flags, BT_CONN_CTE_RSP_ENABLED)) { - BT_WARN("CTE response procedure is enabled"); + LOG_WRN("CTE response procedure is enabled"); return -EINVAL; } @@ -1129,17 +1129,17 @@ static int bt_df_set_conn_cte_req_enable(struct bt_conn *conn, bool enable, const struct bt_df_conn_cte_req_params *params) { if (!BT_FEAT_LE_CONNECTION_CTE_REQ(bt_dev.le.features)) { - BT_WARN("Constant Tone Extensions request procedure is not supported"); + LOG_WRN("Constant Tone Extensions request procedure is not supported"); return -ENOTSUP; } if (conn->state != BT_CONN_CONNECTED) { - BT_ERR("not connected!"); + LOG_ERR("not connected!"); return -ENOTCONN; } if (!atomic_test_bit(conn->flags, BT_CONN_CTE_RX_PARAMS_SET)) { - BT_ERR("Can't start CTE requres procedure before CTE RX params setup"); + LOG_ERR("Can't start CTE requres procedure before CTE RX params setup"); return -EINVAL; } @@ -1177,17 +1177,17 @@ static int bt_df_set_conn_cte_rsp_enable(struct bt_conn *conn, bool enable) } if (!BT_FEAT_LE_CONNECTION_CTE_RESP(bt_dev.le.features)) { - BT_WARN("CTE response procedure is not supported"); + LOG_WRN("CTE response procedure is not supported"); return -ENOTSUP; } if (conn->state != BT_CONN_CONNECTED) { - BT_ERR("not connected"); + LOG_ERR("not connected"); return -ENOTCONN; } if (!atomic_test_bit(conn->flags, BT_CONN_CTE_TX_PARAMS_SET)) { - BT_ERR("Can't start CTE response procedure before CTE TX params setup"); + LOG_ERR("Can't start CTE response procedure before CTE TX params setup"); return -EINVAL; } diff --git a/subsys/bluetooth/host/ecc.c b/subsys/bluetooth/host/ecc.c index 5156f5627b7..82afefc72eb 100644 --- a/subsys/bluetooth/host/ecc.c +++ b/subsys/bluetooth/host/ecc.c @@ -12,9 +12,9 @@ #include "ecc.h" #include "hci_core.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_CORE) -#define LOG_MODULE_NAME bt_ecc -#include "common/log.h" +#define LOG_LEVEL CONFIG_BT_HCI_CORE_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_ecc); static uint8_t pub_key[BT_PUB_KEY_LEN]; static sys_slist_t pub_key_cb_slist; @@ -51,13 +51,13 @@ int bt_pub_key_gen(struct bt_pub_key_cb *new_cb) */ if (!BT_CMD_TEST(bt_dev.supported_commands, 34, 1) || !BT_CMD_TEST(bt_dev.supported_commands, 34, 2)) { - BT_WARN("ECC HCI commands not available"); + LOG_WRN("ECC HCI commands not available"); return -ENOTSUP; } if (IS_ENABLED(CONFIG_BT_USE_DEBUG_KEYS)) { if (!BT_CMD_TEST(bt_dev.supported_commands, 41, 2)) { - BT_WARN("ECC Debug keys HCI command not available"); + LOG_WRN("ECC Debug keys HCI command not available"); } else { atomic_set_bit(bt_dev.flags, BT_DEV_HAS_PUB_KEY); new_cb->func(debug_public_key); @@ -71,7 +71,7 @@ int bt_pub_key_gen(struct bt_pub_key_cb *new_cb) SYS_SLIST_FOR_EACH_CONTAINER(&pub_key_cb_slist, cb, node) { if (cb == new_cb) { - BT_WARN("Callback already registered"); + LOG_WRN("Callback already registered"); return -EALREADY; } } @@ -87,7 +87,7 @@ int bt_pub_key_gen(struct bt_pub_key_cb *new_cb) err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_P256_PUBLIC_KEY, NULL, NULL); if (err) { - BT_ERR("Sending LE P256 Public Key command failed"); + LOG_ERR("Sending LE P256 Public Key command failed"); atomic_clear_bit(bt_dev.flags, BT_DEV_PUB_KEY_BUSY); SYS_SLIST_FOR_EACH_CONTAINER(&pub_key_cb_slist, cb, node) { @@ -193,7 +193,7 @@ int bt_dh_key_gen(const uint8_t remote_pk[BT_PUB_KEY_LEN], bt_dh_key_cb_t cb) if (err) { dh_key_cb = NULL; - BT_WARN("Failed to generate DHKey (err %d)", err); + LOG_WRN("Failed to generate DHKey (err %d)", err); return err; } @@ -205,7 +205,7 @@ void bt_hci_evt_le_pkey_complete(struct net_buf *buf) struct bt_hci_evt_le_p256_public_key_complete *evt = (void *)buf->data; struct bt_pub_key_cb *cb; - BT_DBG("status: 0x%02x", evt->status); + LOG_DBG("status: 0x%02x", evt->status); atomic_clear_bit(bt_dev.flags, BT_DEV_PUB_KEY_BUSY); @@ -227,7 +227,7 @@ void bt_hci_evt_le_dhkey_complete(struct net_buf *buf) { struct bt_hci_evt_le_generate_dhkey_complete *evt = (void *)buf->data; - BT_DBG("status: 0x%02x", evt->status); + LOG_DBG("status: 0x%02x", evt->status); if (dh_key_cb) { bt_dh_key_cb_t cb = dh_key_cb; diff --git a/subsys/bluetooth/host/gatt.c b/subsys/bluetooth/host/gatt.c index f6b3e8d34e5..d03e7af4f32 100644 --- a/subsys/bluetooth/host/gatt.c +++ b/subsys/bluetooth/host/gatt.c @@ -33,9 +33,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_GATT) -#define LOG_MODULE_NAME bt_gatt -#include "common/log.h" #include "common/bt_str.h" #include "hci_core.h" @@ -48,6 +45,10 @@ #include "gatt_internal.h" #include "long_wq.h" +#define LOG_LEVEL CONFIG_BT_GATT_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_gatt); + #define SC_TIMEOUT K_MSEC(10) #define CCC_STORE_DELAY K_SECONDS(1) @@ -311,7 +312,7 @@ static struct db_hash { static struct gatt_sc_cfg *find_sc_cfg(uint8_t id, const bt_addr_le_t *addr) { - BT_DBG("id: %u, addr: %s", id, bt_addr_le_str(addr)); + LOG_DBG("id: %u, addr: %s", id, bt_addr_le_str(addr)); for (size_t i = 0; i < ARRAY_SIZE(sc_cfg); i++) { if (id == sc_cfg[i].id && @@ -341,13 +342,12 @@ static void sc_store(struct gatt_sc_cfg *cfg) err = settings_save_one(key, (char *)&cfg->data, sizeof(cfg->data)); if (err) { - BT_ERR("failed to store SC (err %d)", err); + LOG_ERR("failed to store SC (err %d)", err); return; } - BT_DBG("stored SC for %s (%s, 0x%04x-0x%04x)", - bt_addr_le_str(&cfg->peer), key, cfg->data.start, - cfg->data.end); + LOG_DBG("stored SC for %s (%s, 0x%04x-0x%04x)", bt_addr_le_str(&cfg->peer), key, + cfg->data.start, cfg->data.end); } static void clear_sc_cfg(struct gatt_sc_cfg *cfg) @@ -382,11 +382,9 @@ static int bt_gatt_clear_sc(uint8_t id, const bt_addr_le_t *addr) err = settings_delete(key); if (err) { - BT_ERR("failed to delete SC (err %d)", err); + LOG_ERR("failed to delete SC (err %d)", err); } else { - BT_DBG("deleted SC for %s (%s)", - bt_addr_le_str(&cfg->peer), - key); + LOG_DBG("deleted SC for %s (%s)", bt_addr_le_str(&cfg->peer), key); } } @@ -402,7 +400,7 @@ static void sc_clear(struct bt_conn *conn) err = bt_gatt_clear_sc(conn->id, &conn->le.dst); if (err) { - BT_ERR("Failed to clear SC %d", err); + LOG_ERR("Failed to clear SC %d", err); } } else { struct gatt_sc_cfg *cfg; @@ -416,7 +414,7 @@ static void sc_clear(struct bt_conn *conn) static void sc_reset(struct gatt_sc_cfg *cfg) { - BT_DBG("peer %s", bt_addr_le_str(&cfg->peer)); + LOG_DBG("peer %s", bt_addr_le_str(&cfg->peer)); memset(&cfg->data, 0, sizeof(cfg->data)); @@ -428,8 +426,8 @@ static void sc_reset(struct gatt_sc_cfg *cfg) static bool update_range(uint16_t *start, uint16_t *end, uint16_t new_start, uint16_t new_end) { - BT_DBG("start 0x%04x end 0x%04x new_start 0x%04x new_end 0x%04x", - *start, *end, new_start, new_end); + LOG_DBG("start 0x%04x end 0x%04x new_start 0x%04x new_end 0x%04x", *start, *end, new_start, + new_end); /* Check if inside existing range */ if (new_start >= *start && new_end <= *end) { @@ -453,15 +451,14 @@ static void sc_save(uint8_t id, bt_addr_le_t *peer, uint16_t start, uint16_t end struct gatt_sc_cfg *cfg; bool modified = false; - BT_DBG("peer %s start 0x%04x end 0x%04x", bt_addr_le_str(peer), start, - end); + LOG_DBG("peer %s start 0x%04x end 0x%04x", bt_addr_le_str(peer), start, end); cfg = find_sc_cfg(id, peer); if (!cfg) { /* Find and initialize a free sc_cfg entry */ cfg = find_sc_cfg(BT_ID_DEFAULT, BT_ADDR_LE_ANY); if (!cfg) { - BT_ERR("unable to save SC: no cfg left"); + LOG_ERR("unable to save SC: no cfg left"); return; } @@ -489,7 +486,7 @@ done: static ssize_t sc_ccc_cfg_write(struct bt_conn *conn, const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("value 0x%04x", value); + LOG_DBG("value 0x%04x", value); if (value == BT_GATT_CCC_INDICATE) { /* Create a new SC configuration entry if subscribed */ @@ -603,8 +600,7 @@ static bool cf_set_value(struct gatt_cf_cfg *cfg, const uint8_t *value, uint16_t cfg->data[i] |= value[i]; } - BT_DBG("byte %u: data 0x%02x value 0x%02x", i, cfg->data[i], - value[i]); + LOG_DBG("byte %u: data 0x%02x value 0x%02x", i, cfg->data[i], value[i]); } return true; @@ -630,11 +626,11 @@ static ssize_t cf_write(struct bt_conn *conn, const struct bt_gatt_attr *attr, } if (!cfg) { - BT_WARN("No space to store Client Supported Features"); + LOG_WRN("No space to store Client Supported Features"); return BT_GATT_ERR(BT_ATT_ERR_INSUFFICIENT_RESOURCES); } - BT_DBG("handle 0x%04x len %u", attr->handle, len); + LOG_DBG("handle 0x%04x len %u", attr->handle, len); if (!cf_set_value(cfg, value, len)) { return BT_GATT_ERR(BT_ATT_ERR_VALUE_NOT_ALLOWED); @@ -768,10 +764,10 @@ static void db_hash_store(void) err = settings_save_one("bt/hash", &db_hash.hash, sizeof(db_hash.hash)); if (err) { - BT_ERR("Failed to save Database Hash (err %d)", err); + LOG_ERR("Failed to save Database Hash (err %d)", err); } - BT_DBG("Database Hash stored"); + LOG_DBG("Database Hash stored"); } static void db_hash_gen(bool store) @@ -781,14 +777,14 @@ static void db_hash_gen(bool store) struct gen_hash_state state; if (tc_cmac_setup(&state.state, key, &sched) == TC_CRYPTO_FAIL) { - BT_ERR("Unable to setup AES CMAC"); + LOG_ERR("Unable to setup AES CMAC"); return; } bt_gatt_foreach_attr(0x0001, 0xffff, gen_hash_m, &state); if (tc_cmac_final(db_hash.hash, &state.state) == TC_CRYPTO_FAIL) { - BT_ERR("Unable to calculate hash"); + LOG_ERR("Unable to calculate hash"); return; } @@ -825,7 +821,7 @@ static void db_hash_process(struct k_work *work) /* Check if hash matches then skip SC update */ if (!memcmp(db_hash.stored_hash, db_hash.hash, sizeof(db_hash.stored_hash))) { - BT_DBG("Database Hash matches"); + LOG_DBG("Database Hash matches"); k_work_cancel_delayable(&gatt_sc.work); atomic_clear_bit(gatt_sc.flags, SC_RANGE_CHANGED); return; @@ -931,7 +927,7 @@ static int bt_gatt_store_cf(struct bt_conn *conn) cfg = find_cf_cfg(conn); if (!cfg) { /* No cfg found, just clear it */ - BT_DBG("No config for CF"); + LOG_DBG("No config for CF"); str = NULL; len = 0; } else { @@ -954,11 +950,11 @@ static int bt_gatt_store_cf(struct bt_conn *conn) err = settings_save_one(key, str, len); if (err) { - BT_ERR("Failed to store Client Features (err %d)", err); + LOG_ERR("Failed to store Client Features (err %d)", err); return err; } - BT_DBG("Stored CF for %s (%s)", bt_addr_le_str(&conn->le.dst), key); + LOG_DBG("Stored CF for %s (%s)", bt_addr_le_str(&conn->le.dst), key); #endif /* CONFIG_BT_GATT_CACHING */ return 0; @@ -1116,14 +1112,12 @@ populate: handle = attrs->handle; } else if (find_attr(attrs->handle)) { /* Service has conflicting handles */ - BT_ERR("Unable to register handle 0x%04x", - attrs->handle); + LOG_ERR("Unable to register handle 0x%04x", attrs->handle); return -EINVAL; } - BT_DBG("attr %p handle 0x%04x uuid %s perm 0x%02x", - attrs, attrs->handle, bt_uuid_str(attrs->uuid), - attrs->perm); + LOG_DBG("attr %p handle 0x%04x uuid %s perm 0x%02x", attrs, attrs->handle, + bt_uuid_str(attrs->uuid), attrs->perm); } gatt_insert(svc, last_handle); @@ -1147,7 +1141,7 @@ static void sc_indicate_rsp(struct bt_conn *conn, struct gatt_cf_cfg *cfg; #endif - BT_DBG("err 0x%02x", err); + LOG_DBG("err 0x%02x", err); atomic_clear_bit(gatt_sc.flags, SC_INDICATE_PENDING); @@ -1169,7 +1163,7 @@ static void sc_indicate_rsp(struct bt_conn *conn, cfg = find_cf_cfg(conn); if (cfg && CF_ROBUST_CACHING(cfg)) { atomic_set_bit(cfg->flags, CF_CHANGE_AWARE); - BT_DBG("%s change-aware", bt_addr_le_str(&cfg->peer)); + LOG_DBG("%s change-aware", bt_addr_le_str(&cfg->peer)); } } #endif /* CONFIG_BT_GATT_CACHING */ @@ -1184,7 +1178,7 @@ static void sc_process(struct k_work *work) __ASSERT(!atomic_test_bit(sc->flags, SC_INDICATE_PENDING), "Indicate already pending"); - BT_DBG("start 0x%04x end 0x%04x", sc->start, sc->end); + LOG_DBG("start 0x%04x end 0x%04x", sc->start, sc->end); sc_range[0] = sys_cpu_to_le16(sc->start); sc_range[1] = sys_cpu_to_le16(sc->end); @@ -1350,7 +1344,7 @@ void bt_gatt_init(void) (defined(CONFIG_BT_GATT_CACHING) && defined(CONFIG_BT_SETTINGS)) static void sc_indicate(uint16_t start, uint16_t end) { - BT_DBG("start 0x%04x end 0x%04x", start, end); + LOG_DBG("start 0x%04x end 0x%04x", start, end); if (!atomic_test_and_set_bit(gatt_sc.flags, SC_RANGE_CHANGED)) { gatt_sc.start = start; @@ -1364,7 +1358,7 @@ static void sc_indicate(uint16_t start, uint16_t end) submit: if (atomic_test_bit(gatt_sc.flags, SC_INDICATE_PENDING)) { - BT_DBG("indicate pending, waiting until complete..."); + LOG_DBG("indicate pending, waiting until complete..."); return; } @@ -1415,8 +1409,7 @@ static void db_changed(void) atomic_clear_bit(cfg->flags, CF_DB_HASH_READ); if (atomic_test_and_clear_bit(cfg->flags, CF_CHANGE_AWARE)) { - BT_DBG("%s change-unaware", - bt_addr_le_str(&cfg->peer)); + LOG_DBG("%s change-unaware", bt_addr_le_str(&cfg->peer)); } } } @@ -1575,8 +1568,7 @@ ssize_t bt_gatt_attr_read(struct bt_conn *conn, const struct bt_gatt_attr *attr, len = MIN(buf_len, value_len - offset); - BT_DBG("handle 0x%04x offset %u length %u", attr->handle, offset, - len); + LOG_DBG("handle 0x%04x offset %u length %u", attr->handle, offset, len); memcpy(buf, (uint8_t *)value + offset, len); @@ -1926,7 +1918,7 @@ static void gatt_ccc_changed(const struct bt_gatt_attr *attr, } } - BT_DBG("ccc %p value 0x%04x", ccc, value); + LOG_DBG("ccc %p value 0x%04x", ccc, value); if (value != ccc->value) { ccc->value = value; @@ -1971,7 +1963,7 @@ ssize_t bt_gatt_attr_write_ccc(struct bt_conn *conn, cfg = find_ccc_cfg(NULL, ccc); if (!cfg) { - BT_WARN("No space to store CCC cfg"); + LOG_WRN("No space to store CCC cfg"); return BT_GATT_ERR(BT_ATT_ERR_INSUFFICIENT_RESOURCES); } @@ -1996,7 +1988,7 @@ ssize_t bt_gatt_attr_write_ccc(struct bt_conn *conn, value_changed = cfg->value != value; cfg->value = value; - BT_DBG("handle 0x%04x value %u", attr->handle, cfg->value); + LOG_DBG("handle 0x%04x value %u", attr->handle, cfg->value); /* Update cfg if don't match */ if (cfg->value != ccc->value) { @@ -2101,7 +2093,7 @@ static int gatt_notify_mult_send(struct bt_conn *conn, struct net_buf *buf) /* PDU structure is now [Opcode (1)] [Handle (1)] [Value] */ net_buf_push_le16(buf, handle); net_buf_push_u8(buf, BT_ATT_OP_NOTIFY); - BT_DBG("Converted BT_ATT_OP_NOTIFY_MULT with single attr to BT_ATT_OP_NOTIFY"); + LOG_DBG("Converted BT_ATT_OP_NOTIFY_MULT with single attr to BT_ATT_OP_NOTIFY"); } ret = bt_att_send(conn, buf); @@ -2218,7 +2210,7 @@ static int gatt_notify_mult(struct bt_conn *conn, uint16_t handle, bt_att_increment_tx_meta_data_attr_count(*buf, 1); } - BT_DBG("handle 0x%04x len %u", handle, params->len); + LOG_DBG("handle 0x%04x len %u", handle, params->len); gatt_add_nfy_to_buf(*buf, handle, params); /* Use `k_work_schedule` to keep the original deadline, instead of @@ -2253,7 +2245,7 @@ static int gatt_notify(struct bt_conn *conn, uint16_t handle, /* Confirm that the connection has the correct level of security */ if (bt_gatt_check_perm(conn, params->attr, BT_GATT_PERM_READ_ENCRYPT_MASK)) { - BT_WARN("Link is not encrypted"); + LOG_WRN("Link is not encrypted"); return -EPERM; } @@ -2263,7 +2255,7 @@ static int gatt_notify(struct bt_conn *conn, uint16_t handle, * but follows its spirit. */ if (!bt_gatt_is_subscribed(conn, params->attr, BT_GATT_CCC_NOTIFY)) { - BT_WARN("Device is not subscribed to characteristic"); + LOG_WRN("Device is not subscribed to characteristic"); return -EINVAL; } } @@ -2282,11 +2274,11 @@ static int gatt_notify(struct bt_conn *conn, uint16_t handle, buf = bt_att_create_pdu(conn, BT_ATT_OP_NOTIFY, sizeof(*nfy) + params->len); if (!buf) { - BT_WARN("No buffer available to send notification"); + LOG_WRN("No buffer available to send notification"); return -ENOMEM; } - BT_DBG("conn %p handle 0x%04x", conn, handle); + LOG_DBG("conn %p handle 0x%04x", conn, handle); nfy = net_buf_add(buf, sizeof(*nfy)); nfy->handle = sys_cpu_to_le16(handle); @@ -2406,7 +2398,7 @@ static int gatt_indicate(struct bt_conn *conn, uint16_t handle, /* Confirm that the connection has the correct level of security */ if (bt_gatt_check_perm(conn, params->attr, BT_GATT_PERM_READ_ENCRYPT_MASK)) { - BT_WARN("Link is not encrypted"); + LOG_WRN("Link is not encrypted"); return -EPERM; } @@ -2416,7 +2408,7 @@ static int gatt_indicate(struct bt_conn *conn, uint16_t handle, * but follows its spirit. */ if (!bt_gatt_is_subscribed(conn, params->attr, BT_GATT_CCC_INDICATE)) { - BT_WARN("Device is not subscribed to characteristic"); + LOG_WRN("Device is not subscribed to characteristic"); return -EINVAL; } } @@ -2436,7 +2428,7 @@ static int gatt_indicate(struct bt_conn *conn, uint16_t handle, buf = bt_att_create_pdu(conn, BT_ATT_OP_INDICATE, len); if (!buf) { - BT_WARN("No buffer available to send indication"); + LOG_WRN("No buffer available to send indication"); bt_att_req_free(req); return -ENOMEM; } @@ -2449,7 +2441,7 @@ static int gatt_indicate(struct bt_conn *conn, uint16_t handle, net_buf_add(buf, params->len); memcpy(ind->value, params->data, params->len); - BT_DBG("conn %p handle 0x%04x", conn, handle); + LOG_DBG("conn %p handle 0x%04x", conn, handle); req->buf = buf; @@ -2532,7 +2524,7 @@ static uint8_t notify_cb(const struct bt_gatt_attr *attr, uint16_t handle, /* Confirm that the connection has the correct level of security */ if (bt_gatt_check_perm(conn, attr, BT_GATT_PERM_READ_ENCRYPT_MASK)) { - BT_WARN("Link is not encrypted"); + LOG_WRN("Link is not encrypted"); bt_conn_unref(conn); continue; } @@ -2725,7 +2717,7 @@ static int gatt_notify_multiple_verify_params(struct bt_conn *conn, if (bt_gatt_check_perm(conn, params[i].attr, BT_GATT_PERM_READ_ENCRYPT | BT_GATT_PERM_READ_AUTHEN)) { - BT_WARN("Link is not encrypted"); + LOG_WRN("Link is not encrypted"); return -EPERM; } @@ -2750,7 +2742,7 @@ static int gatt_notify_multiple_verify_params(struct bt_conn *conn, /* Check if the characteristic is subscribed. */ if (!bt_gatt_is_subscribed(conn, params[i].attr, BT_GATT_CCC_NOTIFY)) { - BT_WARN("Device is not subscribed to characteristic"); + LOG_WRN("Device is not subscribed to characteristic"); return -EINVAL; } } @@ -2945,7 +2937,7 @@ static void sc_restore_rsp(struct bt_conn *conn, struct gatt_cf_cfg *cfg; #endif - BT_DBG("err 0x%02x", err); + LOG_DBG("err 0x%02x", err); #if defined(CONFIG_BT_GATT_CACHING) /* BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 3, Part G page 1476: @@ -2960,7 +2952,7 @@ static void sc_restore_rsp(struct bt_conn *conn, cfg = find_cf_cfg(conn); if (cfg && CF_ROBUST_CACHING(cfg)) { atomic_set_bit(cfg->flags, CF_CHANGE_AWARE); - BT_DBG("%s change-aware", bt_addr_le_str(&cfg->peer)); + LOG_DBG("%s change-aware", bt_addr_le_str(&cfg->peer)); } } #endif /* CONFIG_BT_GATT_CACHING */ @@ -2984,7 +2976,7 @@ static void sc_restore(struct bt_conn *conn) cfg = find_sc_cfg(conn->id, &conn->le.dst); if (!cfg) { - BT_DBG("no SC data found"); + LOG_DBG("no SC data found"); return; } @@ -2992,8 +2984,8 @@ static void sc_restore(struct bt_conn *conn) return; } - BT_DBG("peer %s start 0x%04x end 0x%04x", bt_addr_le_str(&cfg->peer), - cfg->data.start, cfg->data.end); + LOG_DBG("peer %s start 0x%04x end 0x%04x", bt_addr_le_str(&cfg->peer), cfg->data.start, + cfg->data.end); sc_range[0] = sys_cpu_to_le16(cfg->data.start); sc_range[1] = sys_cpu_to_le16(cfg->data.end); @@ -3005,7 +2997,7 @@ static void sc_restore(struct bt_conn *conn) sc_restore_params[index].len = sizeof(sc_range); if (bt_gatt_indicate(conn, &sc_restore_params[index])) { - BT_ERR("SC restore indication failed"); + LOG_ERR("SC restore indication failed"); } } @@ -3045,7 +3037,7 @@ static uint8_t update_ccc(const struct bt_gatt_attr *attr, uint16_t handle, bt_security_t sec; if (err == BT_ATT_ERR_WRITE_NOT_PERMITTED) { - BT_WARN("CCC %p not writable", attr); + LOG_WRN("CCC %p not writable", attr); continue; } @@ -3143,7 +3135,7 @@ static uint8_t disconnected_cb(const struct bt_gatt_attr *attr, uint16_t handle, ccc->cfg_changed(attr, ccc->value); } - BT_DBG("ccc %p reseted", ccc); + LOG_DBG("ccc %p reseted", ccc); } return BT_GATT_ITER_CONTINUE; @@ -3321,7 +3313,7 @@ void bt_gatt_notification(struct bt_conn *conn, uint16_t handle, struct bt_gatt_subscribe_params *params, *tmp; struct gatt_sub *sub; - BT_DBG("handle 0x%04x length %u", handle, length); + LOG_DBG("handle 0x%04x length %u", handle, length); sub = gatt_sub_find(conn); if (!sub) { @@ -3350,7 +3342,7 @@ void bt_gatt_mult_notification(struct bt_conn *conn, const void *data, struct net_buf_simple buf; struct gatt_sub *sub; - BT_DBG("length %u", length); + LOG_DBG("length %u", length); sub = gatt_sub_find(conn); if (!sub) { @@ -3368,10 +3360,10 @@ void bt_gatt_mult_notification(struct bt_conn *conn, const void *data, handle = sys_cpu_to_le16(nfy->handle); len = sys_cpu_to_le16(nfy->len); - BT_DBG("handle 0x%02x len %u", handle, len); + LOG_DBG("handle 0x%02x len %u", handle, len); if (len > buf.len) { - BT_ERR("Invalid data len %u > %u", len, length); + LOG_ERR("Invalid data len %u > %u", len, length); return; } @@ -3445,7 +3437,7 @@ static int gatt_exchange_mtu_encode(struct net_buf *buf, size_t len, mtu = BT_ATT_MTU; - BT_DBG("Client MTU %u", mtu); + LOG_DBG("Client MTU %u", mtu); req = net_buf_add(buf, sizeof(*req)); req->mtu = sys_cpu_to_le16(mtu); @@ -3520,7 +3512,7 @@ static void gatt_find_type_rsp(struct bt_conn *conn, uint8_t err, uint8_t count; uint16_t end_handle = 0U, start_handle; - BT_DBG("err 0x%02x", err); + LOG_DBG("err 0x%02x", err); if (err || (length % sizeof(struct bt_att_handle_group) != 0)) { goto done; @@ -3537,8 +3529,7 @@ static void gatt_find_type_rsp(struct bt_conn *conn, uint8_t err, start_handle = sys_le16_to_cpu(rsp[i].start_handle); end_handle = sys_le16_to_cpu(rsp[i].end_handle); - BT_DBG("start_handle 0x%04x end_handle 0x%04x", start_handle, - end_handle); + LOG_DBG("start_handle 0x%04x end_handle 0x%04x", start_handle, end_handle); uuid_svc.uuid.type = BT_UUID_TYPE_16; if (params->type == BT_GATT_DISCOVER_PRIMARY) { @@ -3587,9 +3578,8 @@ static int gatt_find_type_encode(struct net_buf *buf, size_t len, req->type = sys_cpu_to_le16(uuid_val); - BT_DBG("uuid %s start_handle 0x%04x end_handle 0x%04x", - bt_uuid_str(params->uuid), params->start_handle, - params->end_handle); + LOG_DBG("uuid %s start_handle 0x%04x end_handle 0x%04x", bt_uuid_str(params->uuid), + params->start_handle, params->end_handle); switch (params->uuid->type) { case BT_UUID_TYPE_16: @@ -3618,7 +3608,7 @@ static int gatt_find_type(struct bt_conn *conn, len += BT_UUID_SIZE_128; break; default: - BT_ERR("Unknown UUID type %u", params->uuid->type); + LOG_ERR("Unknown UUID type %u", params->uuid->type); return -EINVAL; } @@ -3641,7 +3631,7 @@ static void read_included_uuid_cb(struct bt_conn *conn, uint8_t err, } u; if (length != 16U) { - BT_ERR("Invalid data len %u", length); + LOG_ERR("Invalid data len %u", length); params->func(conn, NULL, params); return; } @@ -3653,7 +3643,7 @@ static void read_included_uuid_cb(struct bt_conn *conn, uint8_t err, u.uuid.type = BT_UUID_TYPE_128; memcpy(u.u128.val, pdu, length); - BT_DBG("handle 0x%04x uuid %s start_handle 0x%04x " + LOG_DBG("handle 0x%04x uuid %s start_handle 0x%04x " "end_handle 0x%04x\n", params->_included.attr_handle, bt_uuid_str(&u.uuid), value.start_handle, value.end_handle); @@ -3692,7 +3682,7 @@ static int read_included_uuid_encode(struct net_buf *buf, size_t len, static int read_included_uuid(struct bt_conn *conn, struct bt_gatt_discover_params *params) { - BT_DBG("handle 0x%04x", params->_included.start_handle); + LOG_DBG("handle 0x%04x", params->_included.start_handle); return gatt_req_send(conn, read_included_uuid_cb, params, read_included_uuid_encode, BT_ATT_OP_READ_REQ, @@ -3725,7 +3715,7 @@ static uint16_t parse_include(struct bt_conn *conn, const void *pdu, u.uuid.type = BT_UUID_TYPE_128; break; default: - BT_ERR("Invalid data len %u", rsp->len); + LOG_ERR("Invalid data len %u", rsp->len); goto done; } @@ -3762,7 +3752,7 @@ static uint16_t parse_include(struct bt_conn *conn, const void *pdu, return read_included_uuid(conn, params); } - BT_DBG("handle 0x%04x uuid %s start_handle 0x%04x " + LOG_DBG("handle 0x%04x uuid %s start_handle 0x%04x " "end_handle 0x%04x\n", handle, bt_uuid_str(&u.uuid), value.start_handle, value.end_handle); @@ -3813,7 +3803,7 @@ static uint16_t parse_characteristic(struct bt_conn *conn, const void *pdu, u.uuid.type = BT_UUID_TYPE_128; break; default: - BT_ERR("Invalid data len %u", rsp->len); + LOG_ERR("Invalid data len %u", rsp->len); goto done; } @@ -3840,8 +3830,8 @@ static uint16_t parse_characteristic(struct bt_conn *conn, const void *pdu, break; } - BT_DBG("handle 0x%04x uuid %s properties 0x%02x", handle, - bt_uuid_str(&u.uuid), chrc->properties); + LOG_DBG("handle 0x%04x uuid %s properties 0x%02x", handle, bt_uuid_str(&u.uuid), + chrc->properties); /* Skip if UUID is set but doesn't match */ if (params->uuid && bt_uuid_cmp(&u.uuid, params->uuid)) { @@ -3958,7 +3948,7 @@ static void gatt_read_type_rsp(struct bt_conn *conn, uint8_t err, struct bt_gatt_discover_params *params = user_data; uint16_t handle; - BT_DBG("err 0x%02x", err); + LOG_DBG("err 0x%02x", err); if (err) { params->func(conn, NULL, params); @@ -4009,8 +3999,7 @@ static int gatt_read_type_encode(struct net_buf *buf, size_t len, static int gatt_read_type(struct bt_conn *conn, struct bt_gatt_discover_params *params) { - BT_DBG("start_handle 0x%04x end_handle 0x%04x", params->start_handle, - params->end_handle); + LOG_DBG("start_handle 0x%04x end_handle 0x%04x", params->start_handle, params->end_handle); return gatt_req_send(conn, gatt_read_type_rsp, params, gatt_read_type_encode, BT_ATT_OP_READ_TYPE_REQ, @@ -4038,7 +4027,7 @@ static uint16_t parse_service(struct bt_conn *conn, const void *pdu, u.uuid.type = BT_UUID_TYPE_128; break; default: - BT_ERR("Invalid data len %u", rsp->len); + LOG_ERR("Invalid data len %u", rsp->len); goto done; } @@ -4070,8 +4059,8 @@ static uint16_t parse_service(struct bt_conn *conn, const void *pdu, break; } - BT_DBG("start_handle 0x%04x end_handle 0x%04x uuid %s", - start_handle, end_handle, bt_uuid_str(&u.uuid)); + LOG_DBG("start_handle 0x%04x end_handle 0x%04x uuid %s", start_handle, end_handle, + bt_uuid_str(&u.uuid)); uuid_svc.uuid.type = BT_UUID_TYPE_16; if (params->type == BT_GATT_DISCOVER_PRIMARY) { @@ -4109,7 +4098,7 @@ static void gatt_read_group_rsp(struct bt_conn *conn, uint8_t err, struct bt_gatt_discover_params *params = user_data; uint16_t handle; - BT_DBG("err 0x%02x", err); + LOG_DBG("err 0x%02x", err); if (err) { params->func(conn, NULL, params); @@ -4146,8 +4135,7 @@ static int gatt_read_group_encode(struct net_buf *buf, size_t len, static int gatt_read_group(struct bt_conn *conn, struct bt_gatt_discover_params *params) { - BT_DBG("start_handle 0x%04x end_handle 0x%04x", params->start_handle, - params->end_handle); + LOG_DBG("start_handle 0x%04x end_handle 0x%04x", params->start_handle, params->end_handle); return gatt_req_send(conn, gatt_read_group_rsp, params, gatt_read_group_encode, @@ -4176,7 +4164,7 @@ static void gatt_find_info_rsp(struct bt_conn *conn, uint8_t err, int i; bool skip = false; - BT_DBG("err 0x%02x", err); + LOG_DBG("err 0x%02x", err); if (err) { goto done; @@ -4193,7 +4181,7 @@ static void gatt_find_info_rsp(struct bt_conn *conn, uint8_t err, len = sizeof(*info.i128); break; default: - BT_ERR("Invalid format %u", rsp->format); + LOG_ERR("Invalid format %u", rsp->format); goto done; } @@ -4226,7 +4214,7 @@ static void gatt_find_info_rsp(struct bt_conn *conn, uint8_t err, break; } - BT_DBG("handle 0x%04x uuid %s", handle, bt_uuid_str(&u.uuid)); + LOG_DBG("handle 0x%04x uuid %s", handle, bt_uuid_str(&u.uuid)); /* Skip if UUID is set but doesn't match */ if (params->uuid && bt_uuid_cmp(&u.uuid, params->uuid)) { @@ -4287,8 +4275,7 @@ static int gatt_find_info_encode(struct net_buf *buf, size_t len, static int gatt_find_info(struct bt_conn *conn, struct bt_gatt_discover_params *params) { - BT_DBG("start_handle 0x%04x end_handle 0x%04x", params->start_handle, - params->end_handle); + LOG_DBG("start_handle 0x%04x end_handle 0x%04x", params->start_handle, params->end_handle); return gatt_req_send(conn, gatt_find_info_rsp, params, gatt_find_info_encode, BT_ATT_OP_FIND_INFO_REQ, @@ -4343,7 +4330,7 @@ int bt_gatt_discover(struct bt_conn *conn, case BT_GATT_DISCOVER_ATTRIBUTE: return gatt_find_info(conn, params); default: - BT_ERR("Invalid discovery type: %u", params->type); + LOG_ERR("Invalid discovery type: %u", params->type); } return -EINVAL; @@ -4366,13 +4353,13 @@ static void parse_read_by_uuid(struct bt_conn *conn, /* Handle 0 is invalid */ if (!handle) { - BT_ERR("Invalid handle"); + LOG_ERR("Invalid handle"); return; } len = rsp->len > length ? length - 2 : rsp->len - 2; - BT_DBG("handle 0x%04x len %u value %u", handle, rsp->len, len); + LOG_DBG("handle 0x%04x len %u value %u", handle, rsp->len, len); /* Update start_handle */ params->by_uuid.start_handle = handle; @@ -4407,7 +4394,7 @@ static void gatt_read_rsp(struct bt_conn *conn, uint8_t err, const void *pdu, { struct bt_gatt_read_params *params = user_data; - BT_DBG("err 0x%02x", err); + LOG_DBG("err 0x%02x", err); if (err || !length) { params->func(conn, err, params, NULL, 0); @@ -4458,8 +4445,7 @@ static int gatt_read_blob_encode(struct net_buf *buf, size_t len, static int gatt_read_blob(struct bt_conn *conn, struct bt_gatt_read_params *params) { - BT_DBG("handle 0x%04x offset 0x%04x", params->single.handle, - params->single.offset); + LOG_DBG("handle 0x%04x offset 0x%04x", params->single.handle, params->single.offset); return gatt_req_send(conn, gatt_read_rsp, params, gatt_read_blob_encode, BT_ATT_OP_READ_BLOB_REQ, @@ -4489,9 +4475,8 @@ static int gatt_read_uuid_encode(struct net_buf *buf, size_t len, static int gatt_read_uuid(struct bt_conn *conn, struct bt_gatt_read_params *params) { - BT_DBG("start_handle 0x%04x end_handle 0x%04x uuid %s", - params->by_uuid.start_handle, params->by_uuid.end_handle, - bt_uuid_str(params->by_uuid.uuid)); + LOG_DBG("start_handle 0x%04x end_handle 0x%04x uuid %s", params->by_uuid.start_handle, + params->by_uuid.end_handle, bt_uuid_str(params->by_uuid.uuid)); return gatt_req_send(conn, gatt_read_rsp, params, gatt_read_uuid_encode, BT_ATT_OP_READ_TYPE_REQ, @@ -4505,7 +4490,7 @@ static void gatt_read_mult_rsp(struct bt_conn *conn, uint8_t err, const void *pd { struct bt_gatt_read_params *params = user_data; - BT_DBG("err 0x%02x", err); + LOG_DBG("err 0x%02x", err); if (err || !length) { params->func(conn, err, params, NULL, 0); @@ -4534,7 +4519,7 @@ static int gatt_read_mult_encode(struct net_buf *buf, size_t len, static int gatt_read_mult(struct bt_conn *conn, struct bt_gatt_read_params *params) { - BT_DBG("handle_count %zu", params->handle_count); + LOG_DBG("handle_count %zu", params->handle_count); return gatt_req_send(conn, gatt_read_mult_rsp, params, gatt_read_mult_encode, BT_ATT_OP_READ_MULT_REQ, @@ -4559,7 +4544,7 @@ static void gatt_read_mult_vl_rsp(struct bt_conn *conn, uint8_t err, const struct bt_att_read_mult_vl_rsp *rsp; struct net_buf_simple buf; - BT_DBG("err 0x%02x", err); + LOG_DBG("err 0x%02x", err); if (err || !length) { params->func(conn, err, params, NULL, 0); @@ -4607,7 +4592,7 @@ static int gatt_read_mult_vl_encode(struct net_buf *buf, size_t len, static int gatt_read_mult_vl(struct bt_conn *conn, struct bt_gatt_read_params *params) { - BT_DBG("handle_count %zu", params->handle_count); + LOG_DBG("handle_count %zu", params->handle_count); return gatt_req_send(conn, gatt_read_mult_vl_rsp, params, gatt_read_mult_vl_encode, @@ -4660,7 +4645,7 @@ int bt_gatt_read(struct bt_conn *conn, struct bt_gatt_read_params *params) return gatt_read_blob(conn, params); } - BT_DBG("handle 0x%04x", params->single.handle); + LOG_DBG("handle 0x%04x", params->single.handle); return gatt_req_send(conn, gatt_read_rsp, params, gatt_read_encode, BT_ATT_OP_READ_REQ, sizeof(struct bt_att_read_req), @@ -4672,7 +4657,7 @@ static void gatt_write_rsp(struct bt_conn *conn, uint8_t err, const void *pdu, { struct bt_gatt_write_params *params = user_data; - BT_DBG("err 0x%02x", err); + LOG_DBG("err 0x%02x", err); params->func(conn, err, params); } @@ -4716,13 +4701,12 @@ int bt_gatt_write_without_response_cb(struct bt_conn *conn, uint16_t handle, write = net_buf_append_bytes(buf, length, data, K_NO_WAIT, NULL, NULL); if (write != length) { - BT_WARN("Unable to allocate length %u: only %zu written", - length, write); + LOG_WRN("Unable to allocate length %u: only %zu written", length, write); net_buf_unref(buf); return -ENOMEM; } - BT_DBG("handle 0x%04x length %u", handle, length); + LOG_DBG("handle 0x%04x length %u", handle, length); bt_att_set_tx_meta_data(buf, func, user_data, BT_ATT_CHAN_OPT_NONE); @@ -4742,7 +4726,7 @@ static int gatt_exec_encode(struct net_buf *buf, size_t len, void *user_data) static int gatt_exec_write(struct bt_conn *conn, struct bt_gatt_write_params *params) { - BT_DBG(""); + LOG_DBG(""); return gatt_req_send(conn, gatt_write_rsp, params, gatt_exec_encode, BT_ATT_OP_EXEC_WRITE_REQ, @@ -4763,7 +4747,7 @@ static int gatt_cancel_encode(struct net_buf *buf, size_t len, void *user_data) static int gatt_cancel_all_writes(struct bt_conn *conn, struct bt_gatt_write_params *params) { - BT_DBG(""); + LOG_DBG(""); return gatt_req_send(conn, gatt_write_rsp, params, gatt_cancel_encode, BT_ATT_OP_EXEC_WRITE_REQ, @@ -4780,7 +4764,7 @@ static void gatt_prepare_write_rsp(struct bt_conn *conn, uint8_t err, size_t len; bool data_valid; - BT_DBG("err 0x%02x", err); + LOG_DBG("err 0x%02x", err); /* Don't continue in case of error */ if (err) { @@ -4790,7 +4774,7 @@ static void gatt_prepare_write_rsp(struct bt_conn *conn, uint8_t err, len = length - sizeof(*rsp); if (len > params->length) { - BT_ERR("Incorrect length, canceling write"); + LOG_ERR("Incorrect length, canceling write"); if (gatt_cancel_all_writes(conn, params)) { goto fail; } @@ -4800,7 +4784,7 @@ static void gatt_prepare_write_rsp(struct bt_conn *conn, uint8_t err, data_valid = memcmp(params->data, rsp->value, len) == 0; if (params->offset != rsp->offset || !data_valid) { - BT_ERR("Incorrect offset or data in response, canceling write"); + LOG_ERR("Incorrect offset or data in response, canceling write"); if (gatt_cancel_all_writes(conn, params)) { goto fail; } @@ -4908,7 +4892,7 @@ int bt_gatt_write(struct bt_conn *conn, struct bt_gatt_write_params *params) return gatt_prepare_write(conn, params); } - BT_DBG("handle 0x%04x length %u", params->handle, params->length); + LOG_DBG("handle 0x%04x length %u", params->handle, params->length); return gatt_req_send(conn, gatt_write_rsp, params, gatt_write_encode, BT_ATT_OP_WRITE_REQ, len, BT_ATT_CHAN_OPT(params)); @@ -4920,7 +4904,7 @@ static void gatt_write_ccc_rsp(struct bt_conn *conn, uint8_t err, { struct bt_gatt_subscribe_params *params = user_data; - BT_DBG("err 0x%02x", err); + LOG_DBG("err 0x%02x", err); atomic_clear_bit(params->flags, BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING); @@ -4949,7 +4933,7 @@ static void gatt_write_ccc_rsp(struct bt_conn *conn, uint8_t err, params->subscribe(conn, err, params); } else if (params->write) { /* TODO: Remove after deprecation */ - BT_WARN("write callback is deprecated, use subscribe cb instead"); + LOG_WRN("write callback is deprecated, use subscribe cb instead"); params->write(conn, err, NULL); } } @@ -4974,7 +4958,7 @@ static int gatt_write_ccc(struct bt_conn *conn, { size_t len = sizeof(struct bt_att_write_req) + sizeof(uint16_t); - BT_DBG("handle 0x%04x value 0x%04x", params->ccc_handle, params->value); + LOG_DBG("handle 0x%04x value 0x%04x", params->ccc_handle, params->value); return gatt_req_send(conn, gatt_write_ccc_rsp, params, gatt_write_ccc_buf, BT_ATT_OP_WRITE_REQ, len, @@ -5032,7 +5016,7 @@ static int gatt_ccc_discover(struct bt_conn *conn, err = bt_gatt_discover(conn, params->disc_params); if (err) { - BT_DBG("CCC Discovery failed (err %d)", err); + LOG_DBG("CCC Discovery failed (err %d)", err); return err; } return 0; @@ -5248,7 +5232,7 @@ static void gatt_exchange_mtu_func(struct bt_conn *conn, uint8_t err, struct bt_gatt_exchange_params *params) { if (err) { - BT_WARN("conn %p err 0x%02x", conn, err); + LOG_WRN("conn %p err 0x%02x", conn, err); } } @@ -5293,7 +5277,7 @@ static void ccc_clear(struct _bt_gatt_ccc *ccc, cfg = ccc_find_cfg(ccc, addr, id); if (!cfg) { - BT_DBG("Unable to clear CCC: cfg not found"); + LOG_DBG("Unable to clear CCC: cfg not found"); return; } @@ -5329,21 +5313,21 @@ static uint8_t ccc_load(const struct bt_gatt_attr *attr, uint16_t handle, * be restored. */ if (load->entry->handle < handle) { - BT_DBG("Unable to restore CCC: handle 0x%04x cannot be" + LOG_DBG("Unable to restore CCC: handle 0x%04x cannot be" " found", load->entry->handle); goto next; } return BT_GATT_ITER_CONTINUE; } - BT_DBG("Restoring CCC: handle 0x%04x value 0x%04x", load->entry->handle, - load->entry->value); + LOG_DBG("Restoring CCC: handle 0x%04x value 0x%04x", load->entry->handle, + load->entry->value); cfg = ccc_find_cfg(ccc, load->addr_with_id.addr, load->addr_with_id.id); if (!cfg) { cfg = ccc_find_cfg(ccc, BT_ADDR_LE_ANY, 0); if (!cfg) { - BT_DBG("Unable to restore CCC: no cfg left"); + LOG_DBG("Unable to restore CCC: no cfg left"); goto next; } bt_addr_le_copy(&cfg->peer, load->addr_with_id.addr); @@ -5373,7 +5357,7 @@ static int ccc_set(const char *name, size_t len_rd, settings_read_cb read_cb, settings_name_next(name, &next); if (!name) { - BT_ERR("Insufficient number of arguments"); + LOG_ERR("Insufficient number of arguments"); return -EINVAL; } else if (!next) { load.addr_with_id.id = BT_ID_DEFAULT; @@ -5381,7 +5365,7 @@ static int ccc_set(const char *name, size_t len_rd, settings_read_cb read_cb, unsigned long next_id = strtoul(next, NULL, 10); if (next_id >= CONFIG_BT_ID_MAX) { - BT_ERR("Invalid local identity %lu", next_id); + LOG_ERR("Invalid local identity %lu", next_id); return -EINVAL; } @@ -5390,7 +5374,7 @@ static int ccc_set(const char *name, size_t len_rd, settings_read_cb read_cb, err = bt_settings_decode_key(name, &addr); if (err) { - BT_ERR("Unable to decode address %s", name); + LOG_ERR("Unable to decode address %s", name); return -EINVAL; } @@ -5400,7 +5384,7 @@ static int ccc_set(const char *name, size_t len_rd, settings_read_cb read_cb, len = read_cb(cb_arg, ccc_store, sizeof(ccc_store)); if (len < 0) { - BT_ERR("Failed to decode value (err %zd)", len); + LOG_ERR("Failed to decode value (err %zd)", len); return len; } @@ -5408,8 +5392,8 @@ static int ccc_set(const char *name, size_t len_rd, settings_read_cb read_cb, load.count = len / sizeof(*ccc_store); for (size_t i = 0; i < load.count; i++) { - BT_DBG("Read CCC: handle 0x%04x value 0x%04x", - ccc_store[i].handle, ccc_store[i].value); + LOG_DBG("Read CCC: handle 0x%04x value 0x%04x", ccc_store[i].handle, + ccc_store[i].value); } } else { load.entry = NULL; @@ -5418,9 +5402,8 @@ static int ccc_set(const char *name, size_t len_rd, settings_read_cb read_cb, bt_gatt_foreach_attr(0x0001, 0xffff, ccc_load, &load); - BT_DBG("Restored CCC for id:%" PRIu8 " addr:%s", - load.addr_with_id.id, - bt_addr_le_str(load.addr_with_id.addr)); + LOG_DBG("Restored CCC for id:%" PRIu8 " addr:%s", load.addr_with_id.id, + bt_addr_le_str(load.addr_with_id.addr)); } return 0; @@ -5445,11 +5428,11 @@ static int ccc_set_direct(const char *key, size_t len, settings_read_cb read_cb, if (IS_ENABLED(CONFIG_BT_SETTINGS)) { const char *name; - BT_DBG("key: %s", (const char *)param); + LOG_DBG("key: %s", (const char *)param); /* Only "bt/ccc" settings should ever come here */ if (!settings_name_steq((const char *)param, "bt/ccc", &name)) { - BT_ERR("Invalid key"); + LOG_ERR("Invalid key"); return -EINVAL; } @@ -5462,7 +5445,7 @@ void bt_gatt_connected(struct bt_conn *conn) { struct conn_data data; - BT_DBG("conn %p", conn); + LOG_DBG("conn %p", conn); data.conn = conn; data.sec = BT_SECURITY_L1; @@ -5511,8 +5494,7 @@ void bt_gatt_connected(struct bt_conn *conn) int err = bt_conn_set_security(conn, data.sec); if (err) { - BT_WARN("Failed to set security for bonded peer (%d)", - err); + LOG_WRN("Failed to set security for bonded peer (%d)", err); } } @@ -5523,7 +5505,7 @@ void bt_gatt_connected(struct bt_conn *conn) err = bt_gatt_exchange_mtu(conn, &gatt_exchange_params); if (err) { - BT_WARN("MTU Exchange failed (err %d)", err); + LOG_WRN("MTU Exchange failed (err %d)", err); } #endif /* CONFIG_BT_GATT_AUTO_UPDATE_MTU */ #endif /* CONFIG_BT_GATT_CLIENT */ @@ -5544,7 +5526,7 @@ void bt_gatt_encrypt_change(struct bt_conn *conn) { struct conn_data data; - BT_DBG("conn %p", conn); + LOG_DBG("conn %p", conn); data.conn = conn; data.sec = BT_SECURITY_L1; @@ -5583,7 +5565,7 @@ bool bt_gatt_change_aware(struct bt_conn *conn, bool req) if (atomic_test_and_clear_bit(cfg->flags, CF_DB_HASH_READ)) { bt_att_clear_out_of_sync_sent(conn); atomic_set_bit(cfg->flags, CF_CHANGE_AWARE); - BT_DBG("%s change-aware", bt_addr_le_str(&cfg->peer)); + LOG_DBG("%s change-aware", bt_addr_le_str(&cfg->peer)); return true; } @@ -5599,7 +5581,7 @@ bool bt_gatt_change_aware(struct bt_conn *conn, bool req) atomic_clear_bit(cfg->flags, CF_DB_HASH_READ); bt_att_clear_out_of_sync_sent(conn); atomic_set_bit(cfg->flags, CF_CHANGE_AWARE); - BT_DBG("%s change-aware", bt_addr_le_str(&cfg->peer)); + LOG_DBG("%s change-aware", bt_addr_le_str(&cfg->peer)); return true; } @@ -5654,7 +5636,7 @@ static uint8_t ccc_save(const struct bt_gatt_attr *attr, uint16_t handle, return BT_GATT_ITER_CONTINUE; } - BT_DBG("Storing CCCs handle 0x%04x value 0x%04x", handle, cfg->value); + LOG_DBG("Storing CCCs handle 0x%04x value 0x%04x", handle, cfg->value); save->store[save->count].handle = handle; save->store[save->count].value = cfg->value; @@ -5697,19 +5679,18 @@ int bt_gatt_store_ccc(uint8_t id, const bt_addr_le_t *addr) err = settings_save_one(key, str, len); if (err) { - BT_ERR("Failed to store CCCs (err %d)", err); + LOG_ERR("Failed to store CCCs (err %d)", err); return err; } - BT_DBG("Stored CCCs for %s (%s)", bt_addr_le_str(addr), - key); + LOG_DBG("Stored CCCs for %s (%s)", bt_addr_le_str(addr), key); if (len) { for (size_t i = 0; i < save.count; i++) { - BT_DBG(" CCC: handle 0x%04x value 0x%04x", - save.store[i].handle, save.store[i].value); + LOG_DBG(" CCC: handle 0x%04x value 0x%04x", save.store[i].handle, + save.store[i].value); } } else { - BT_DBG(" CCC: NULL"); + LOG_DBG(" CCC: NULL"); } return 0; @@ -5727,13 +5708,13 @@ static int sc_set(const char *name, size_t len_rd, settings_read_cb read_cb, const char *next; if (!name) { - BT_ERR("Insufficient number of arguments"); + LOG_ERR("Insufficient number of arguments"); return -EINVAL; } err = bt_settings_decode_key(name, &addr); if (err) { - BT_ERR("Unable to decode address %s", name); + LOG_ERR("Unable to decode address %s", name); return -EINVAL; } @@ -5745,7 +5726,7 @@ static int sc_set(const char *name, size_t len_rd, settings_read_cb read_cb, unsigned long next_id = strtoul(next, NULL, 10); if (next_id >= CONFIG_BT_ID_MAX) { - BT_ERR("Invalid local identity %lu", next_id); + LOG_ERR("Invalid local identity %lu", next_id); return -EINVAL; } @@ -5757,7 +5738,7 @@ static int sc_set(const char *name, size_t len_rd, settings_read_cb read_cb, /* Find and initialize a free sc_cfg entry */ cfg = find_sc_cfg(BT_ID_DEFAULT, BT_ADDR_LE_ANY); if (!cfg) { - BT_ERR("Unable to restore SC: no cfg left"); + LOG_ERR("Unable to restore SC: no cfg left"); return -ENOMEM; } @@ -5768,18 +5749,18 @@ static int sc_set(const char *name, size_t len_rd, settings_read_cb read_cb, if (len_rd) { len = read_cb(cb_arg, &cfg->data, sizeof(cfg->data)); if (len < 0) { - BT_ERR("Failed to decode value (err %zd)", len); + LOG_ERR("Failed to decode value (err %zd)", len); return len; } - BT_DBG("Read SC: len %zd", len); + LOG_DBG("Read SC: len %zd", len); - BT_DBG("Restored SC for %s", bt_addr_le_str(&addr)); + LOG_DBG("Restored SC for %s", bt_addr_le_str(&addr)); } else if (cfg) { /* Clear configuration */ memset(cfg, 0, sizeof(*cfg)); - BT_DBG("Removed SC for %s", bt_addr_le_str(&addr)); + LOG_DBG("Removed SC for %s", bt_addr_le_str(&addr)); } return 0; @@ -5812,13 +5793,13 @@ static int cf_set(const char *name, size_t len_rd, settings_read_cb read_cb, uint8_t id; if (!name) { - BT_ERR("Insufficient number of arguments"); + LOG_ERR("Insufficient number of arguments"); return -EINVAL; } err = bt_settings_decode_key(name, &addr); if (err) { - BT_ERR("Unable to decode address %s", name); + LOG_ERR("Unable to decode address %s", name); return -EINVAL; } @@ -5830,7 +5811,7 @@ static int cf_set(const char *name, size_t len_rd, settings_read_cb read_cb, unsigned long next_id = strtoul(next, NULL, 10); if (next_id >= CONFIG_BT_ID_MAX) { - BT_ERR("Invalid local identity %lu", next_id); + LOG_ERR("Invalid local identity %lu", next_id); return -EINVAL; } @@ -5841,7 +5822,7 @@ static int cf_set(const char *name, size_t len_rd, settings_read_cb read_cb, if (!cfg) { cfg = find_cf_cfg(NULL); if (!cfg) { - BT_ERR("Unable to restore CF: no cfg left"); + LOG_ERR("Unable to restore CF: no cfg left"); return -ENOMEM; } @@ -5852,16 +5833,16 @@ static int cf_set(const char *name, size_t len_rd, settings_read_cb read_cb, if (len_rd) { len = read_cb(cb_arg, cfg->data, sizeof(cfg->data)); if (len < 0) { - BT_ERR("Failed to decode value (err %zd)", len); + LOG_ERR("Failed to decode value (err %zd)", len); return len; } - BT_DBG("Read CF: len %zd", len); + LOG_DBG("Read CF: len %zd", len); } else { clear_cf_cfg(cfg); } - BT_DBG("Restored CF for %s", bt_addr_le_str(&addr)); + LOG_DBG("Restored CF for %s", bt_addr_le_str(&addr)); return 0; } @@ -5875,7 +5856,7 @@ static int db_hash_set(const char *name, size_t len_rd, len = read_cb(cb_arg, db_hash.stored_hash, sizeof(db_hash.stored_hash)); if (len < 0) { - BT_ERR("Failed to decode value (err %zd)", len); + LOG_ERR("Failed to decode value (err %zd)", len); return len; } @@ -5904,7 +5885,7 @@ static int db_hash_commit(void) } if (err) { - BT_ERR("Unable to reschedule database hash process (err %d)", err); + LOG_ERR("Unable to reschedule database hash process (err %d)", err); } return err; @@ -6063,7 +6044,7 @@ int bt_gatt_clear(uint8_t id, const bt_addr_le_t *addr) void bt_gatt_disconnected(struct bt_conn *conn) { - BT_DBG("conn %p", conn); + LOG_DBG("conn %p", conn); bt_gatt_foreach_attr(0x0001, 0xffff, disconnected_cb, conn); #if defined(CONFIG_BT_GATT_NOTIFY_MULTIPLE) diff --git a/subsys/bluetooth/host/hci_core.c b/subsys/bluetooth/host/hci_core.c index 821fcd1d761..1c2fc8dccf0 100644 --- a/subsys/bluetooth/host/hci_core.c +++ b/subsys/bluetooth/host/hci_core.c @@ -28,9 +28,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_CORE) -#define LOG_MODULE_NAME bt_hci_core -#include "common/log.h" #include "common/bt_str.h" #include "common/assert.h" @@ -60,6 +57,10 @@ #include "direction_internal.h" #endif /* CONFIG_BT_DF */ +#define LOG_LEVEL CONFIG_BT_HCI_CORE_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_hci_core); + #define HCI_CMD_TIMEOUT K_SECONDS(10) /* Stacks for the threads */ @@ -155,8 +156,7 @@ static int handle_event_common(uint8_t event, struct net_buf *buf, } if (buf->len < handler->min_len) { - BT_ERR("Too small (%u bytes) event 0x%02x", - buf->len, event); + LOG_ERR("Too small (%u bytes) event 0x%02x", buf->len, event); return -EINVAL; } @@ -174,7 +174,7 @@ static void handle_event(uint8_t event, struct net_buf *buf, const struct event_ err = handle_event_common(event, buf, handlers, num_handlers); if (err == -EOPNOTSUPP) { - BT_WARN("Unhandled event 0x%02x len %u: %s", event, buf->len, + LOG_WRN("Unhandled event 0x%02x len %u: %s", event, buf->len, bt_hex(buf->data, buf->len)); } @@ -188,7 +188,7 @@ static void handle_vs_event(uint8_t event, struct net_buf *buf, err = handle_event_common(event, buf, handlers, num_handlers); if (err == -EOPNOTSUPP) { - BT_WARN("Unhandled vendor-specific event: %s", bt_hex(buf->data, buf->len)); + LOG_WRN("Unhandled vendor-specific event: %s", bt_hex(buf->data, buf->len)); } /* Other possible errors are handled by handle_event_common function */ @@ -213,25 +213,25 @@ void bt_hci_host_num_completed_packets(struct net_buf *buf) conn = bt_conn_lookup_index(index); if (!conn) { - BT_WARN("Unable to look up conn with index 0x%02x", index); + LOG_WRN("Unable to look up conn with index 0x%02x", index); return; } if (conn->state != BT_CONN_CONNECTED && conn->state != BT_CONN_DISCONNECTING) { - BT_WARN("Not reporting packet for non-connected conn"); + LOG_WRN("Not reporting packet for non-connected conn"); bt_conn_unref(conn); return; } bt_conn_unref(conn); - BT_DBG("Reporting completed packet for handle %u", handle); + LOG_DBG("Reporting completed packet for handle %u", handle); buf = bt_hci_cmd_create(BT_HCI_OP_HOST_NUM_COMPLETED_PACKETS, sizeof(*cp) + sizeof(*hc)); if (!buf) { - BT_ERR("Unable to allocate new HCI command"); + LOG_ERR("Unable to allocate new HCI command"); return; } @@ -251,12 +251,12 @@ struct net_buf *bt_hci_cmd_create(uint16_t opcode, uint8_t param_len) struct bt_hci_cmd_hdr *hdr; struct net_buf *buf; - BT_DBG("opcode 0x%04x param_len %u", opcode, param_len); + LOG_DBG("opcode 0x%04x param_len %u", opcode, param_len); buf = net_buf_alloc(&hci_cmd_pool, K_FOREVER); __ASSERT_NO_MSG(buf); - BT_DBG("buf %p", buf); + LOG_DBG("buf %p", buf); net_buf_reserve(buf, BT_BUF_RESERVE); @@ -282,7 +282,7 @@ int bt_hci_cmd_send(uint16_t opcode, struct net_buf *buf) } } - BT_DBG("opcode 0x%04x len %u", opcode, buf->len); + LOG_DBG("opcode 0x%04x len %u", opcode, buf->len); /* Host Number of Completed Packets can ignore the ncmd value * and does not generate any cmd complete/status events. @@ -292,7 +292,7 @@ int bt_hci_cmd_send(uint16_t opcode, struct net_buf *buf) err = bt_send(buf); if (err) { - BT_ERR("Unable to send to driver (err %d)", err); + LOG_ERR("Unable to send to driver (err %d)", err); net_buf_unref(buf); } @@ -318,7 +318,7 @@ int bt_hci_cmd_send_sync(uint16_t opcode, struct net_buf *buf, } } - BT_DBG("buf %p opcode 0x%04x len %u", buf, opcode, buf->len); + LOG_DBG("buf %p opcode 0x%04x len %u", buf, opcode, buf->len); k_sem_init(&sync_sem, 0, 1); cmd(buf)->sync = &sync_sem; @@ -330,7 +330,7 @@ int bt_hci_cmd_send_sync(uint16_t opcode, struct net_buf *buf, status = cmd(buf)->status; if (status) { - BT_WARN("opcode 0x%04x status 0x%02x", opcode, status); + LOG_WRN("opcode 0x%04x status 0x%02x", opcode, status); net_buf_unref(buf); switch (status) { @@ -341,7 +341,7 @@ int bt_hci_cmd_send_sync(uint16_t opcode, struct net_buf *buf, } } - BT_DBG("rsp %p opcode 0x%04x len %u", buf, opcode, buf->len); + LOG_DBG("rsp %p opcode 0x%04x len %u", buf, opcode, buf->len); if (rsp) { *rsp = buf; @@ -392,7 +392,7 @@ static int hci_le_read_max_data_len(uint16_t *tx_octets, uint16_t *tx_time) err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_READ_MAX_DATA_LEN, NULL, &rsp); if (err) { - BT_ERR("Failed to read DLE max data len"); + LOG_ERR("Failed to read DLE max data len"); return err; } @@ -424,7 +424,7 @@ static void hci_num_completed_packets(struct net_buf *buf) struct bt_hci_evt_num_completed_packets *evt = (void *)buf->data; int i; - BT_DBG("num_handles %u", evt->num_handles); + LOG_DBG("num_handles %u", evt->num_handles); for (i = 0; i < evt->num_handles; i++) { uint16_t handle, count; @@ -433,11 +433,11 @@ static void hci_num_completed_packets(struct net_buf *buf) handle = sys_le16_to_cpu(evt->h[i].handle); count = sys_le16_to_cpu(evt->h[i].count); - BT_DBG("handle %u count %u", handle, count); + LOG_DBG("handle %u count %u", handle, count); conn = bt_conn_lookup_handle(handle); if (!conn) { - BT_ERR("No connection for handle %u", handle); + LOG_ERR("No connection for handle %u", handle); continue; } @@ -459,7 +459,7 @@ static void hci_num_completed_packets(struct net_buf *buf) irq_unlock(key); if (!node) { - BT_ERR("packets count mismatch"); + LOG_ERR("packets count mismatch"); break; } @@ -488,7 +488,7 @@ static void hci_acl(struct net_buf *buf) struct bt_conn *conn; uint8_t flags; - BT_DBG("buf %p", buf); + LOG_DBG("buf %p", buf); BT_ASSERT(buf->len >= sizeof(*hdr)); @@ -500,17 +500,17 @@ static void hci_acl(struct net_buf *buf) acl(buf)->handle = bt_acl_handle(handle); acl(buf)->index = BT_CONN_INDEX_INVALID; - BT_DBG("handle %u len %u flags %u", acl(buf)->handle, len, flags); + LOG_DBG("handle %u len %u flags %u", acl(buf)->handle, len, flags); if (buf->len != len) { - BT_ERR("ACL data length mismatch (%u != %u)", buf->len, len); + LOG_ERR("ACL data length mismatch (%u != %u)", buf->len, len); net_buf_unref(buf); return; } conn = bt_conn_lookup_handle(acl(buf)->handle); if (!conn) { - BT_ERR("Unable to find conn for handle %u", acl(buf)->handle); + LOG_ERR("Unable to find conn for handle %u", acl(buf)->handle); net_buf_unref(buf); return; } @@ -525,7 +525,7 @@ static void hci_data_buf_overflow(struct net_buf *buf) { struct bt_hci_evt_data_buf_overflow *evt = (void *)buf->data; - BT_WARN("Data buffer overflow (link type 0x%02x)", evt->link_type); + LOG_WRN("Data buffer overflow (link type 0x%02x)", evt->link_type); } #if defined(CONFIG_BT_CENTRAL) @@ -585,7 +585,7 @@ int bt_le_create_conn_ext(const struct bt_conn *conn) if (!bt_addr_le_eq(&conn->le.resp_addr, BT_ADDR_LE_ANY)) { /* Host resolving is used, use the RPA directly. */ peer_addr = &conn->le.resp_addr; - BT_DBG("Using resp_addr %s", bt_addr_le_str(peer_addr)); + LOG_DBG("Using resp_addr %s", bt_addr_le_str(peer_addr)); } bt_addr_le_copy(&cp->peer_addr, peer_addr); @@ -658,7 +658,7 @@ static int bt_le_create_conn_legacy(const struct bt_conn *conn) if (!bt_addr_le_eq(&conn->le.resp_addr, BT_ADDR_LE_ANY)) { /* Host resolving is used, use the RPA directly. */ peer_addr = &conn->le.resp_addr; - BT_DBG("Using resp_addr %s", bt_addr_le_str(peer_addr)); + LOG_DBG("Using resp_addr %s", bt_addr_le_str(peer_addr)); } bt_addr_le_copy(&cp->peer_addr, peer_addr); @@ -758,8 +758,7 @@ static void hci_disconn_complete_prio(struct net_buf *buf) uint16_t handle = sys_le16_to_cpu(evt->handle); struct bt_conn *conn; - BT_DBG("status 0x%02x handle %u reason 0x%02x", evt->status, handle, - evt->reason); + LOG_DBG("status 0x%02x handle %u reason 0x%02x", evt->status, handle, evt->reason); if (evt->status) { return; @@ -784,8 +783,7 @@ static void hci_disconn_complete(struct net_buf *buf) uint16_t handle = sys_le16_to_cpu(evt->handle); struct bt_conn *conn; - BT_DBG("status 0x%02x handle %u reason 0x%02x", evt->status, handle, - evt->reason); + LOG_DBG("status 0x%02x handle %u reason 0x%02x", evt->status, handle, evt->reason); if (evt->status) { return; @@ -793,7 +791,7 @@ static void hci_disconn_complete(struct net_buf *buf) conn = bt_conn_lookup_handle(handle); if (!conn) { - BT_ERR("Unable to look up conn with handle %u", handle); + LOG_ERR("Unable to look up conn with handle %u", handle); return; } @@ -1019,7 +1017,7 @@ static void conn_auto_initiate(struct bt_conn *conn) BT_FEAT_LE_PER_INIT_FEAT_XCHG(bt_dev.le.features))) { err = hci_le_read_remote_features(conn); if (err) { - BT_ERR("Failed read remote features (%d)", err); + LOG_ERR("Failed read remote features (%d)", err); } } @@ -1027,7 +1025,7 @@ static void conn_auto_initiate(struct bt_conn *conn) !atomic_test_bit(conn->flags, BT_CONN_AUTO_VERSION_INFO)) { err = hci_read_remote_version(conn); if (err) { - BT_ERR("Failed read remote version (%d)", err); + LOG_ERR("Failed read remote version (%d)", err); } } @@ -1038,7 +1036,7 @@ static void conn_auto_initiate(struct bt_conn *conn) BT_HCI_LE_PHY_PREFER_2M, BT_HCI_LE_PHY_CODED_ANY); if (err) { - BT_ERR("Failed LE Set PHY (%d)", err); + LOG_ERR("Failed LE Set PHY (%d)", err); } } @@ -1052,7 +1050,7 @@ static void conn_auto_initiate(struct bt_conn *conn) err = bt_le_set_data_len(conn, tx_octets, tx_time); if (err) { - BT_ERR("Failed to set data len (%d)", err); + LOG_ERR("Failed to set data len (%d)", err); } } } else { @@ -1074,7 +1072,7 @@ static void le_conn_complete_cancel(void) */ conn = find_pending_connect(BT_HCI_ROLE_CENTRAL, NULL); if (!conn) { - BT_ERR("No pending central connection"); + LOG_ERR("No pending central connection"); return; } @@ -1131,7 +1129,7 @@ static void le_conn_complete_adv_timeout(void) */ conn = find_pending_connect(BT_HCI_ROLE_PERIPHERAL, NULL); if (!conn) { - BT_ERR("No pending peripheral connection"); + LOG_ERR("No pending peripheral connection"); return; } @@ -1180,10 +1178,9 @@ void bt_hci_le_enh_conn_complete(struct bt_hci_evt_le_enh_conn_complete *evt) bt_addr_le_t peer_addr, id_addr; struct bt_conn *conn; - BT_DBG("status 0x%02x handle %u role %u peer %s peer RPA %s", - evt->status, handle, evt->role, bt_addr_le_str(&evt->peer_addr), - bt_addr_str(&evt->peer_rpa)); - BT_DBG("local RPA %s", bt_addr_str(&evt->local_rpa)); + LOG_DBG("status 0x%02x handle %u role %u peer %s peer RPA %s", evt->status, handle, + evt->role, bt_addr_le_str(&evt->peer_addr), bt_addr_str(&evt->peer_rpa)); + LOG_DBG("local RPA %s", bt_addr_str(&evt->local_rpa)); #if defined(CONFIG_BT_SMP) bt_id_pending_keys_update(); @@ -1203,7 +1200,7 @@ void bt_hci_le_enh_conn_complete(struct bt_hci_evt_le_enh_conn_complete *evt) return; } - BT_WARN("Unexpected status 0x%02x", evt->status); + LOG_WRN("Unexpected status 0x%02x", evt->status); return; } @@ -1248,8 +1245,7 @@ void bt_hci_le_enh_conn_complete(struct bt_hci_evt_le_enh_conn_complete *evt) } if (!conn) { - BT_ERR("No pending conn for peer %s", - bt_addr_le_str(&evt->peer_addr)); + LOG_ERR("No pending conn for peer %s", bt_addr_le_str(&evt->peer_addr)); bt_hci_disconnect(handle, BT_HCI_ERR_UNSPECIFIED); return; } @@ -1355,7 +1351,7 @@ void bt_hci_le_enh_conn_complete(struct bt_hci_evt_le_enh_conn_complete *evt) err = hci_le_read_phy(conn); if (err) { - BT_WARN("Failed to read PHY (%d)", err); + LOG_WRN("Failed to read PHY (%d)", err); } } #endif /* defined(CONFIG_BT_USER_PHY_UPDATE) */ @@ -1393,8 +1389,8 @@ static void le_legacy_conn_complete(struct net_buf *buf) struct bt_hci_evt_le_conn_complete *evt = (void *)buf->data; struct bt_hci_evt_le_enh_conn_complete enh; - BT_DBG("status 0x%02x role %u %s", evt->status, evt->role, - bt_addr_le_str(&evt->peer_addr)); + LOG_DBG("status 0x%02x role %u %s", evt->status, evt->role, + bt_addr_le_str(&evt->peer_addr)); enh.status = evt->status; enh.handle = evt->handle; @@ -1425,7 +1421,7 @@ static void le_remote_feat_complete(struct net_buf *buf) conn = bt_conn_lookup_handle(handle); if (!conn) { - BT_ERR("Unable to lookup conn for handle %u", handle); + LOG_ERR("Unable to lookup conn for handle %u", handle); return; } @@ -1453,7 +1449,7 @@ static void le_data_len_change(struct net_buf *buf) conn = bt_conn_lookup_handle(handle); if (!conn) { - BT_ERR("Unable to lookup conn for handle %u", handle); + LOG_ERR("Unable to lookup conn for handle %u", handle); return; } @@ -1463,8 +1459,8 @@ static void le_data_len_change(struct net_buf *buf) uint16_t max_tx_time = sys_le16_to_cpu(evt->max_tx_time); uint16_t max_rx_time = sys_le16_to_cpu(evt->max_rx_time); - BT_DBG("max. tx: %u (%uus), max. rx: %u (%uus)", - max_tx_octets, max_tx_time, max_rx_octets, max_rx_time); + LOG_DBG("max. tx: %u (%uus), max. rx: %u (%uus)", max_tx_octets, max_tx_time, max_rx_octets, + max_rx_time); conn->le.data_len.tx_max_len = max_tx_octets; conn->le.data_len.tx_max_time = max_tx_time; @@ -1486,12 +1482,12 @@ static void le_phy_update_complete(struct net_buf *buf) conn = bt_conn_lookup_handle(handle); if (!conn) { - BT_ERR("Unable to lookup conn for handle %u", handle); + LOG_ERR("Unable to lookup conn for handle %u", handle); return; } - BT_DBG("PHY updated: status: 0x%02x, tx: %u, rx: %u", - evt->status, evt->tx_phy, evt->rx_phy); + LOG_DBG("PHY updated: status: 0x%02x, tx: %u, rx: %u", evt->status, evt->tx_phy, + evt->rx_phy); #if defined(CONFIG_BT_USER_PHY_UPDATE) conn->le.phy.tx_phy = bt_get_phy(evt->tx_phy); @@ -1533,7 +1529,7 @@ static void le_conn_param_neg_reply(uint16_t handle, uint8_t reason) buf = bt_hci_cmd_create(BT_HCI_OP_LE_CONN_PARAM_REQ_NEG_REPLY, sizeof(*cp)); if (!buf) { - BT_ERR("Unable to allocate buffer"); + LOG_ERR("Unable to allocate buffer"); return; } @@ -1582,7 +1578,7 @@ static void le_conn_param_req(struct net_buf *buf) conn = bt_conn_lookup_handle(handle); if (!conn) { - BT_ERR("Unable to lookup conn for handle %u", handle); + LOG_ERR("Unable to lookup conn for handle %u", handle); le_conn_param_neg_reply(handle, BT_HCI_ERR_UNKNOWN_CONN_ID); return; } @@ -1604,11 +1600,11 @@ static void le_conn_update_complete(struct net_buf *buf) handle = sys_le16_to_cpu(evt->handle); - BT_DBG("status 0x%02x, handle %u", evt->status, handle); + LOG_DBG("status 0x%02x, handle %u", evt->status, handle); conn = bt_conn_lookup_handle(handle); if (!conn) { - BT_ERR("Unable to lookup conn for handle %u", handle); + LOG_ERR("Unable to lookup conn for handle %u", handle); return; } @@ -1663,7 +1659,7 @@ static int set_flow_control(void) /* Check if host flow control is actually supported */ if (!BT_CMD_TEST(bt_dev.supported_commands, 10, 5)) { - BT_WARN("Controller to host flow control not supported"); + LOG_WRN("Controller to host flow control not supported"); return 0; } @@ -1816,12 +1812,11 @@ static void hci_encrypt_change(struct net_buf *buf) uint8_t status = evt->status; struct bt_conn *conn; - BT_DBG("status 0x%02x handle %u encrypt 0x%02x", evt->status, handle, - evt->encrypt); + LOG_DBG("status 0x%02x handle %u encrypt 0x%02x", evt->status, handle, evt->encrypt); conn = bt_conn_lookup_handle(handle); if (!conn) { - BT_ERR("Unable to look up conn with handle %u", handle); + LOG_ERR("Unable to look up conn with handle %u", handle); return; } @@ -1876,7 +1871,7 @@ static void hci_encrypt_change(struct net_buf *buf) bt_conn_security_changed(conn, status, bt_security_err_get(status)); if (status) { - BT_ERR("Failed to set required security level"); + LOG_ERR("Failed to set required security level"); bt_conn_disconnect(conn, status); } @@ -1892,11 +1887,11 @@ static void hci_encrypt_key_refresh_complete(struct net_buf *buf) handle = sys_le16_to_cpu(evt->handle); - BT_DBG("status 0x%02x handle %u", evt->status, handle); + LOG_DBG("status 0x%02x handle %u", evt->status, handle); conn = bt_conn_lookup_handle(handle); if (!conn) { - BT_ERR("Unable to look up conn with handle %u", handle); + LOG_ERR("Unable to look up conn with handle %u", handle); return; } @@ -1933,7 +1928,7 @@ static void hci_encrypt_key_refresh_complete(struct net_buf *buf) bt_conn_security_changed(conn, status, bt_security_err_get(status)); if (status) { - BT_ERR("Failed to set required security level"); + LOG_ERR("Failed to set required security level"); bt_conn_disconnect(conn, status); } @@ -1952,7 +1947,7 @@ static void bt_hci_evt_read_remote_version_complete(struct net_buf *buf) handle = sys_le16_to_cpu(evt->handle); conn = bt_conn_lookup_handle(handle); if (!conn) { - BT_ERR("No connection for handle %u", handle); + LOG_ERR("No connection for handle %u", handle); return; } @@ -1979,7 +1974,7 @@ static void hci_hardware_error(struct net_buf *buf) evt = net_buf_pull_mem(buf, sizeof(*evt)); - BT_ERR("Hardware error, hardware code: %d", evt->hardware_code); + LOG_ERR("Hardware error, hardware code: %d", evt->hardware_code); } #if defined(CONFIG_BT_SMP) @@ -1990,7 +1985,7 @@ static void le_ltk_neg_reply(uint16_t handle) buf = bt_hci_cmd_create(BT_HCI_OP_LE_LTK_REQ_NEG_REPLY, sizeof(*cp)); if (!buf) { - BT_ERR("Out of command buffers"); + LOG_ERR("Out of command buffers"); return; } @@ -2009,7 +2004,7 @@ static void le_ltk_reply(uint16_t handle, uint8_t *ltk) buf = bt_hci_cmd_create(BT_HCI_OP_LE_LTK_REQ_REPLY, sizeof(*cp)); if (!buf) { - BT_ERR("Out of command buffers"); + LOG_ERR("Out of command buffers"); return; } @@ -2029,11 +2024,11 @@ static void le_ltk_request(struct net_buf *buf) handle = sys_le16_to_cpu(evt->handle); - BT_DBG("handle %u", handle); + LOG_DBG("handle %u", handle); conn = bt_conn_lookup_handle(handle); if (!conn) { - BT_ERR("Unable to lookup conn for handle %u", handle); + LOG_ERR("Unable to lookup conn for handle %u", handle); return; } @@ -2052,7 +2047,7 @@ static void hci_reset_complete(struct net_buf *buf) uint8_t status = buf->data[0]; atomic_t flags; - BT_DBG("status 0x%02x", status); + LOG_DBG("status 0x%02x", status); if (status) { return; @@ -2072,18 +2067,17 @@ static void hci_reset_complete(struct net_buf *buf) static void hci_cmd_done(uint16_t opcode, uint8_t status, struct net_buf *buf) { - BT_DBG("opcode 0x%04x status 0x%02x buf %p", opcode, status, buf); + LOG_DBG("opcode 0x%04x status 0x%02x buf %p", opcode, status, buf); if (net_buf_pool_get(buf->pool_id) != &hci_cmd_pool) { - BT_WARN("opcode 0x%04x pool id %u pool %p != &hci_cmd_pool %p", - opcode, buf->pool_id, net_buf_pool_get(buf->pool_id), - &hci_cmd_pool); + LOG_WRN("opcode 0x%04x pool id %u pool %p != &hci_cmd_pool %p", opcode, + buf->pool_id, net_buf_pool_get(buf->pool_id), &hci_cmd_pool); return; } if (cmd(buf)->opcode != opcode) { - BT_WARN("OpCode 0x%04x completed instead of expected 0x%04x", - opcode, cmd(buf)->opcode); + LOG_WRN("OpCode 0x%04x completed instead of expected 0x%04x", opcode, + cmd(buf)->opcode); return; } @@ -2115,7 +2109,7 @@ static void hci_cmd_complete(struct net_buf *buf) ncmd = evt->ncmd; opcode = sys_le16_to_cpu(evt->opcode); - BT_DBG("opcode 0x%04x", opcode); + LOG_DBG("opcode 0x%04x", opcode); /* All command return parameters have a 1-byte status in the * beginning, so we can safely make this generalization. @@ -2140,7 +2134,7 @@ static void hci_cmd_status(struct net_buf *buf) opcode = sys_le16_to_cpu(evt->opcode); ncmd = evt->ncmd; - BT_DBG("opcode 0x%04x", opcode); + LOG_DBG("opcode 0x%04x", opcode); hci_cmd_done(opcode, evt->status, buf); @@ -2213,7 +2207,7 @@ static void hci_vendor_event(struct net_buf *buf) evt = net_buf_pull_mem(buf, sizeof(*evt)); - BT_DBG("subevent 0x%02x", evt->subevent); + LOG_DBG("subevent 0x%02x", evt->subevent); handle_vs_event(evt->subevent, buf, vs_events, ARRAY_SIZE(vs_events)); } @@ -2334,7 +2328,7 @@ static void hci_le_meta_event(struct net_buf *buf) evt = net_buf_pull_mem(buf, sizeof(*evt)); - BT_DBG("subevent 0x%02x", evt->subevent); + LOG_DBG("subevent 0x%02x", evt->subevent); handle_event(evt->subevent, buf, meta_events, ARRAY_SIZE(meta_events)); } @@ -2419,7 +2413,7 @@ static void hci_event(struct net_buf *buf) BT_ASSERT(buf->len >= sizeof(*hdr)); hdr = net_buf_pull_mem(buf, sizeof(*hdr)); - BT_DBG("event 0x%02x", hdr->evt); + LOG_DBG("event 0x%02x", hdr->evt); BT_ASSERT(bt_hci_evt_get_flags(hdr->evt) & BT_HCI_EVT_FLAG_RECV); handle_event(hdr->evt, buf, normal_events, ARRAY_SIZE(normal_events)); @@ -2433,29 +2427,28 @@ static void send_cmd(void) int err; /* Get next command */ - BT_DBG("calling net_buf_get"); + LOG_DBG("calling net_buf_get"); buf = net_buf_get(&bt_dev.cmd_tx_queue, K_NO_WAIT); BT_ASSERT(buf); /* Wait until ncmd > 0 */ - BT_DBG("calling sem_take_wait"); + LOG_DBG("calling sem_take_wait"); k_sem_take(&bt_dev.ncmd_sem, K_FOREVER); /* Clear out any existing sent command */ if (bt_dev.sent_cmd) { - BT_ERR("Uncleared pending sent_cmd"); + LOG_ERR("Uncleared pending sent_cmd"); net_buf_unref(bt_dev.sent_cmd); bt_dev.sent_cmd = NULL; } bt_dev.sent_cmd = net_buf_ref(buf); - BT_DBG("Sending command 0x%04x (buf %p) to driver", - cmd(buf)->opcode, buf); + LOG_DBG("Sending command 0x%04x (buf %p) to driver", cmd(buf)->opcode, buf); err = bt_send(buf); if (err) { - BT_ERR("Unable to send to driver (err %d)", err); + LOG_ERR("Unable to send to driver (err %d)", err); k_sem_give(&bt_dev.ncmd_sem); hci_cmd_done(cmd(buf)->opcode, BT_HCI_ERR_UNSPECIFIED, buf); net_buf_unref(buf); @@ -2464,10 +2457,10 @@ static void send_cmd(void) static void process_events(struct k_poll_event *ev, int count) { - BT_DBG("count %d", count); + LOG_DBG("count %d", count); for (; count; ev++, count--) { - BT_DBG("ev->state %u", ev->state); + LOG_DBG("ev->state %u", ev->state); switch (ev->state) { case K_POLL_STATE_SIGNALED: @@ -2490,7 +2483,7 @@ static void process_events(struct k_poll_event *ev, int count) case K_POLL_STATE_NOT_READY: break; default: - BT_WARN("Unexpected k_poll event state %u", ev->state); + LOG_WRN("Unexpected k_poll event state %u", ev->state); break; } } @@ -2523,7 +2516,7 @@ static void hci_tx_thread(void *p1, void *p2, void *p3) BT_EVENT_CMD_TX), }; - BT_DBG("Started"); + LOG_DBG("Started"); while (1) { int ev_count, err; @@ -2535,7 +2528,7 @@ static void hci_tx_thread(void *p1, void *p2, void *p3) ev_count += bt_conn_prepare_events(&events[1]); } - BT_DBG("Calling k_poll with %d events", ev_count); + LOG_DBG("Calling k_poll with %d events", ev_count); err = k_poll(events, ev_count, K_FOREVER); BT_ASSERT(err == 0); @@ -2554,7 +2547,7 @@ static void read_local_ver_complete(struct net_buf *buf) { struct bt_hci_rp_read_local_version_info *rp = (void *)buf->data; - BT_DBG("status 0x%02x", rp->status); + LOG_DBG("status 0x%02x", rp->status); bt_dev.hci_version = rp->hci_version; bt_dev.hci_revision = sys_le16_to_cpu(rp->hci_revision); @@ -2567,7 +2560,7 @@ static void read_le_features_complete(struct net_buf *buf) { struct bt_hci_rp_le_read_local_features *rp = (void *)buf->data; - BT_DBG("status 0x%02x", rp->status); + LOG_DBG("status 0x%02x", rp->status); memcpy(bt_dev.le.features, rp->features, sizeof(bt_dev.le.features)); } @@ -2579,7 +2572,7 @@ static void read_buffer_size_complete(struct net_buf *buf) struct bt_hci_rp_read_buffer_size *rp = (void *)buf->data; uint16_t pkts; - BT_DBG("status 0x%02x", rp->status); + LOG_DBG("status 0x%02x", rp->status); /* If LE-side has buffers we can ignore the BR/EDR values */ if (bt_dev.le.acl_mtu) { @@ -2589,7 +2582,7 @@ static void read_buffer_size_complete(struct net_buf *buf) bt_dev.le.acl_mtu = sys_le16_to_cpu(rp->acl_max_len); pkts = sys_le16_to_cpu(rp->acl_max_num); - BT_DBG("ACL BR/EDR buffers: pkts %u mtu %u", pkts, bt_dev.le.acl_mtu); + LOG_DBG("ACL BR/EDR buffers: pkts %u mtu %u", pkts, bt_dev.le.acl_mtu); k_sem_init(&bt_dev.le.acl_pkts, pkts, pkts); } @@ -2600,7 +2593,7 @@ static void le_read_buffer_size_complete(struct net_buf *buf) { struct bt_hci_rp_le_read_buffer_size *rp = (void *)buf->data; - BT_DBG("status 0x%02x", rp->status); + LOG_DBG("status 0x%02x", rp->status); #if defined(CONFIG_BT_CONN) bt_dev.le.acl_mtu = sys_le16_to_cpu(rp->le_max_len); @@ -2608,8 +2601,7 @@ static void le_read_buffer_size_complete(struct net_buf *buf) return; } - BT_DBG("ACL LE buffers: pkts %u mtu %u", rp->le_max_num, - bt_dev.le.acl_mtu); + LOG_DBG("ACL LE buffers: pkts %u mtu %u", rp->le_max_num, bt_dev.le.acl_mtu); k_sem_init(&bt_dev.le.acl_pkts, rp->le_max_num, rp->le_max_num); #endif /* CONFIG_BT_CONN */ @@ -2620,7 +2612,7 @@ static void read_buffer_size_v2_complete(struct net_buf *buf) #if defined(CONFIG_BT_ISO) struct bt_hci_rp_le_read_buffer_size_v2 *rp = (void *)buf->data; - BT_DBG("status %u", rp->status); + LOG_DBG("status %u", rp->status); #if defined(CONFIG_BT_CONN) bt_dev.le.acl_mtu = sys_le16_to_cpu(rp->acl_max_len); @@ -2628,20 +2620,18 @@ static void read_buffer_size_v2_complete(struct net_buf *buf) return; } - BT_DBG("ACL LE buffers: pkts %u mtu %u", rp->acl_max_num, - bt_dev.le.acl_mtu); + LOG_DBG("ACL LE buffers: pkts %u mtu %u", rp->acl_max_num, bt_dev.le.acl_mtu); k_sem_init(&bt_dev.le.acl_pkts, rp->acl_max_num, rp->acl_max_num); #endif /* CONFIG_BT_CONN */ bt_dev.le.iso_mtu = sys_le16_to_cpu(rp->iso_max_len); if (!bt_dev.le.iso_mtu) { - BT_ERR("ISO buffer size not set"); + LOG_ERR("ISO buffer size not set"); return; } - BT_DBG("ISO buffers: pkts %u mtu %u", rp->iso_max_num, - bt_dev.le.iso_mtu); + LOG_DBG("ISO buffers: pkts %u mtu %u", rp->iso_max_num, bt_dev.le.iso_mtu); k_sem_init(&bt_dev.le.iso_pkts, rp->iso_max_num, rp->iso_max_num); bt_dev.le.iso_limit = rp->iso_max_num; @@ -2669,7 +2659,7 @@ static void read_supported_commands_complete(struct net_buf *buf) { struct bt_hci_rp_read_supported_commands *rp = (void *)buf->data; - BT_DBG("status 0x%02x", rp->status); + LOG_DBG("status 0x%02x", rp->status); memcpy(bt_dev.supported_commands, rp->commands, sizeof(bt_dev.supported_commands)); @@ -2686,7 +2676,7 @@ static void read_local_features_complete(struct net_buf *buf) { struct bt_hci_rp_read_local_features *rp = (void *)buf->data; - BT_DBG("status 0x%02x", rp->status); + LOG_DBG("status 0x%02x", rp->status); memcpy(bt_dev.features[0], rp->features, sizeof(bt_dev.features[0])); } @@ -2695,7 +2685,7 @@ static void le_read_supp_states_complete(struct net_buf *buf) { struct bt_hci_rp_le_read_supp_states *rp = (void *)buf->data; - BT_DBG("status 0x%02x", rp->status); + LOG_DBG("status 0x%02x", rp->status); bt_dev.le.states = sys_get_le64(rp->le_states); } @@ -2705,7 +2695,7 @@ static void le_read_resolving_list_size_complete(struct net_buf *buf) { struct bt_hci_rp_le_read_rl_size *rp = (void *)buf->data; - BT_DBG("Resolving List size %u", rp->rl_size); + LOG_DBG("Resolving List size %u", rp->rl_size); bt_dev.le.rl_size = rp->rl_size; } @@ -2916,7 +2906,7 @@ static int le_init_iso(void) net_buf_unref(rsp); } else if (IS_ENABLED(CONFIG_BT_CONN)) { - BT_WARN("Read Buffer Size V2 command is not supported." + LOG_WRN("Read Buffer Size V2 command is not supported." "No ISO buffers will be available"); /* Read LE Buffer Size */ @@ -2941,7 +2931,7 @@ static int le_init(void) /* For now we only support LE capable controllers */ if (!BT_FEAT_LE(bt_dev.features)) { - BT_ERR("Non-LE capable controller detected!"); + LOG_ERR("Non-LE capable controller detected!"); return -ENODEV; } @@ -3178,7 +3168,7 @@ static void bt_dev_show_info(void) { int i; - BT_INFO("Identity%s: %s", bt_dev.id_count > 1 ? "[0]" : "", + LOG_INF("Identity%s: %s", bt_dev.id_count > 1 ? "[0]" : "", bt_addr_le_str(&bt_dev.id_addr[0])); if (IS_ENABLED(CONFIG_BT_LOG_SNIFFER_INFO)) { @@ -3186,21 +3176,19 @@ static void bt_dev_show_info(void) uint8_t irk[16]; sys_memcpy_swap(irk, bt_dev.irk[0], 16); - BT_INFO("IRK%s: 0x%s", bt_dev.id_count > 1 ? "[0]" : "", - bt_hex(irk, 16)); + LOG_INF("IRK%s: 0x%s", bt_dev.id_count > 1 ? "[0]" : "", bt_hex(irk, 16)); #endif } for (i = 1; i < bt_dev.id_count; i++) { - BT_INFO("Identity[%d]: %s", - i, bt_addr_le_str(&bt_dev.id_addr[i])); + LOG_INF("Identity[%d]: %s", i, bt_addr_le_str(&bt_dev.id_addr[i])); if (IS_ENABLED(CONFIG_BT_LOG_SNIFFER_INFO)) { #if defined(CONFIG_BT_PRIVACY) uint8_t irk[16]; sys_memcpy_swap(irk, bt_dev.irk[i], 16); - BT_INFO("IRK[%d]: 0x%s", i, bt_hex(irk, 16)); + LOG_INF("IRK[%d]: 0x%s", i, bt_hex(irk, 16)); #endif } } @@ -3210,12 +3198,11 @@ static void bt_dev_show_info(void) bt_keys_foreach_type(BT_KEYS_ALL, bt_keys_show_sniffer_info, NULL); } - BT_INFO("HCI: version %s (0x%02x) revision 0x%04x, manufacturer 0x%04x", - ver_str(bt_dev.hci_version), bt_dev.hci_version, - bt_dev.hci_revision, bt_dev.manufacturer); - BT_INFO("LMP: version %s (0x%02x) subver 0x%04x", - ver_str(bt_dev.lmp_version), bt_dev.lmp_version, - bt_dev.lmp_subversion); + LOG_INF("HCI: version %s (0x%02x) revision 0x%04x, manufacturer 0x%04x", + ver_str(bt_dev.hci_version), bt_dev.hci_version, bt_dev.hci_revision, + bt_dev.manufacturer); + LOG_INF("LMP: version %s (0x%02x) subver 0x%04x", ver_str(bt_dev.lmp_version), + bt_dev.lmp_version, bt_dev.lmp_subversion); } #else static inline void bt_dev_show_info(void) @@ -3291,7 +3278,7 @@ static void hci_vs_init(void) if ((bt_dev.hci_version < BT_HCI_VERSION_5_0) || bt_id_read_public_addr(&addr)) { - BT_WARN("Controller doesn't seem to support " + LOG_WRN("Controller doesn't seem to support " "Zephyr vendor HCI"); return; } @@ -3299,29 +3286,27 @@ static void hci_vs_init(void) err = bt_hci_cmd_send_sync(BT_HCI_OP_VS_READ_VERSION_INFO, NULL, &rsp); if (err) { - BT_WARN("Vendor HCI extensions not available"); + LOG_WRN("Vendor HCI extensions not available"); return; } if (IS_ENABLED(CONFIG_BT_HCI_VS_EXT_DETECT) && rsp->len != sizeof(struct bt_hci_rp_vs_read_version_info)) { - BT_WARN("Invalid Vendor HCI extensions"); + LOG_WRN("Invalid Vendor HCI extensions"); net_buf_unref(rsp); return; } #if defined(CONFIG_BT_DEBUG) rp.info = (void *)rsp->data; - BT_INFO("HW Platform: %s (0x%04x)", - vs_hw_platform(sys_le16_to_cpu(rp.info->hw_platform)), + LOG_INF("HW Platform: %s (0x%04x)", vs_hw_platform(sys_le16_to_cpu(rp.info->hw_platform)), sys_le16_to_cpu(rp.info->hw_platform)); - BT_INFO("HW Variant: %s (0x%04x)", + LOG_INF("HW Variant: %s (0x%04x)", vs_hw_variant(sys_le16_to_cpu(rp.info->hw_platform), sys_le16_to_cpu(rp.info->hw_variant)), sys_le16_to_cpu(rp.info->hw_variant)); - BT_INFO("Firmware: %s (0x%02x) Version %u.%u Build %u", - vs_fw_variant(rp.info->fw_variant), rp.info->fw_variant, - rp.info->fw_version, sys_le16_to_cpu(rp.info->fw_revision), + LOG_INF("Firmware: %s (0x%02x) Version %u.%u Build %u", vs_fw_variant(rp.info->fw_variant), + rp.info->fw_variant, rp.info->fw_version, sys_le16_to_cpu(rp.info->fw_revision), sys_le32_to_cpu(rp.info->fw_build)); #endif /* CONFIG_BT_DEBUG */ @@ -3330,13 +3315,13 @@ static void hci_vs_init(void) err = bt_hci_cmd_send_sync(BT_HCI_OP_VS_READ_SUPPORTED_COMMANDS, NULL, &rsp); if (err) { - BT_WARN("Failed to read supported vendor commands"); + LOG_WRN("Failed to read supported vendor commands"); return; } if (IS_ENABLED(CONFIG_BT_HCI_VS_EXT_DETECT) && rsp->len != sizeof(struct bt_hci_rp_vs_read_supported_commands)) { - BT_WARN("Invalid Vendor HCI extensions"); + LOG_WRN("Invalid Vendor HCI extensions"); net_buf_unref(rsp); return; } @@ -3349,14 +3334,14 @@ static void hci_vs_init(void) err = bt_hci_cmd_send_sync(BT_HCI_OP_VS_READ_SUPPORTED_FEATURES, NULL, &rsp); if (err) { - BT_WARN("Failed to read supported vendor features"); + LOG_WRN("Failed to read supported vendor features"); return; } if (IS_ENABLED(CONFIG_BT_HCI_VS_EXT_DETECT) && rsp->len != sizeof(struct bt_hci_rp_vs_read_supported_features)) { - BT_WARN("Invalid Vendor HCI extensions"); + LOG_WRN("Invalid Vendor HCI extensions"); net_buf_unref(rsp); return; } @@ -3397,12 +3382,12 @@ static int hci_init(void) return err; } } else if (IS_ENABLED(CONFIG_BT_BREDR)) { - BT_ERR("Non-BR/EDR controller detected"); + LOG_ERR("Non-BR/EDR controller detected"); return -EIO; } #if defined(CONFIG_BT_CONN) else if (!bt_dev.le.acl_mtu) { - BT_ERR("ACL BR/EDR buffers not initialized"); + LOG_ERR("ACL BR/EDR buffers not initialized"); return -EIO; } #endif @@ -3425,7 +3410,7 @@ static int hci_init(void) int bt_send(struct net_buf *buf) { - BT_DBG("buf %p len %u type %u", buf, buf->len, bt_buf_get_type(buf)); + LOG_DBG("buf %p len %u type %u", buf, buf->len, bt_buf_get_type(buf)); bt_monitor_send(bt_monitor_opcode(buf), buf->data, buf->len); @@ -3489,7 +3474,7 @@ static void rx_queue_put(struct net_buf *buf) const int err = k_work_submit_to_queue(&bt_workq, &rx_work); #endif /* CONFIG_BT_RECV_WORKQ_SYS */ if (err < 0) { - BT_ERR("Could not submit rx_work: %d", err); + LOG_ERR("Could not submit rx_work: %d", err); } } #endif /* !CONFIG_BT_RECV_BLOCKING */ @@ -3498,7 +3483,7 @@ int bt_recv(struct net_buf *buf) { bt_monitor_send(bt_monitor_opcode(buf), buf->data, buf->len); - BT_DBG("buf %p len %u", buf, buf->len); + LOG_DBG("buf %p len %u", buf, buf->len); switch (bt_buf_get_type(buf)) { #if defined(CONFIG_BT_CONN) @@ -3539,7 +3524,7 @@ int bt_recv(struct net_buf *buf) return 0; #endif /* CONFIG_BT_ISO */ default: - BT_ERR("Invalid buf type %u", bt_buf_get_type(buf)); + LOG_ERR("Invalid buf type %u", bt_buf_get_type(buf)); net_buf_unref(buf); return -EINVAL; } @@ -3568,7 +3553,7 @@ int bt_hci_driver_register(const struct bt_hci_driver *drv) bt_dev.drv = drv; - BT_DBG("Registered %s", drv->name ? drv->name : ""); + LOG_DBG("Registered %s", drv->name ? drv->name : ""); bt_monitor_new_index(BT_MONITOR_TYPE_PRIMARY, drv->bus, BT_ADDR_ANY, drv->name ? drv->name : "bt0"); @@ -3612,7 +3597,7 @@ static int bt_init(void) if (IS_ENABLED(CONFIG_BT_SETTINGS)) { if (!bt_dev.id_count) { - BT_INFO("No ID address. App must call settings_load()"); + LOG_INF("No ID address. App must call settings_load()"); return 0; } @@ -3640,14 +3625,13 @@ static void rx_work_handler(struct k_work *work) struct net_buf *buf; - BT_DBG("Getting net_buf from queue"); + LOG_DBG("Getting net_buf from queue"); buf = net_buf_slist_get(&bt_dev.rx_queue); if (!buf) { return; } - BT_DBG("buf %p type %u len %u", buf, bt_buf_get_type(buf), - buf->len); + LOG_DBG("buf %p type %u len %u", buf, bt_buf_get_type(buf), buf->len); switch (bt_buf_get_type(buf)) { #if defined(CONFIG_BT_CONN) @@ -3664,7 +3648,7 @@ static void rx_work_handler(struct k_work *work) hci_event(buf); break; default: - BT_ERR("Unknown buf type %u", bt_buf_get_type(buf)); + LOG_ERR("Unknown buf type %u", bt_buf_get_type(buf)); net_buf_unref(buf); break; } @@ -3682,7 +3666,7 @@ static void rx_work_handler(struct k_work *work) err = k_work_submit_to_queue(&bt_workq, &rx_work); #endif if (err < 0) { - BT_ERR("Could not submit rx_work: %d", err); + LOG_ERR("Could not submit rx_work: %d", err); } } } @@ -3693,7 +3677,7 @@ int bt_enable(bt_ready_cb_t cb) int err; if (!bt_dev.drv) { - BT_ERR("No HCI driver registered"); + LOG_ERR("No HCI driver registered"); return -ENODEV; } @@ -3711,7 +3695,7 @@ int bt_enable(bt_ready_cb_t cb) } else if (IS_ENABLED(CONFIG_BT_DEVICE_NAME_DYNAMIC)) { err = bt_set_name(CONFIG_BT_DEVICE_NAME); if (err) { - BT_WARN("Failed to set device name (%d)", err); + LOG_WRN("Failed to set device name (%d)", err); } } @@ -3746,7 +3730,7 @@ int bt_enable(bt_ready_cb_t cb) err = bt_dev.drv->open(); if (err) { - BT_ERR("HCI driver open failed (%d)", err); + LOG_ERR("HCI driver open failed (%d)", err); return err; } @@ -3765,7 +3749,7 @@ int bt_disable(void) int err; if (!bt_dev.drv) { - BT_ERR("No HCI driver registered"); + LOG_ERR("No HCI driver registered"); return -ENODEV; } @@ -3782,7 +3766,7 @@ int bt_disable(void) err = bt_dev.drv->close(); if (err) { - BT_ERR("HCI driver close failed (%d)", err); + LOG_ERR("HCI driver close failed (%d)", err); /* Re-enable BT_DEV_READY to avoid inconsistent stack state */ atomic_set_bit(bt_dev.flags, BT_DEV_READY); @@ -3865,7 +3849,7 @@ int bt_set_name(const char *name) if (IS_ENABLED(CONFIG_BT_SETTINGS)) { err = settings_save_one("bt/name", bt_dev.name, len); if (err) { - BT_WARN("Unable to store name"); + LOG_WRN("Unable to store name"); } } @@ -3902,7 +3886,7 @@ int bt_set_appearance(uint16_t appearance) sizeof(appearance)); if (err) { - BT_ERR("Unable to save setting 'bt/appearance' (err %d).", err); + LOG_ERR("Unable to save setting 'bt/appearance' (err %d).", err); return err; } } @@ -3947,7 +3931,7 @@ int bt_le_filter_accept_list_add(const bt_addr_le_t *addr) err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_ADD_DEV_TO_FAL, buf, NULL); if (err) { - BT_ERR("Failed to add device to filter accept list"); + LOG_ERR("Failed to add device to filter accept list"); return err; } @@ -3975,7 +3959,7 @@ int bt_le_filter_accept_list_remove(const bt_addr_le_t *addr) err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_REM_DEV_FROM_FAL, buf, NULL); if (err) { - BT_ERR("Failed to remove device from filter accept list"); + LOG_ERR("Failed to remove device from filter accept list"); return err; } @@ -3992,7 +3976,7 @@ int bt_le_filter_accept_list_clear(void) err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_CLEAR_FAL, NULL, NULL); if (err) { - BT_ERR("Failed to clear filter accept list"); + LOG_ERR("Failed to clear filter accept list"); return err; } @@ -4010,7 +3994,7 @@ int bt_le_set_chan_map(uint8_t chan_map[5]) } if (!BT_CMD_TEST(bt_dev.supported_commands, 27, 3)) { - BT_WARN("Set Host Channel Classification command is " + LOG_WRN("Set Host Channel Classification command is " "not supported"); return -ENOTSUP; } @@ -4063,7 +4047,7 @@ void bt_data_parse(struct net_buf_simple *ad, } if (len > ad->len) { - BT_WARN("malformed advertising data"); + LOG_WRN("malformed advertising data"); return; } diff --git a/subsys/bluetooth/host/hci_ecc.c b/subsys/bluetooth/host/hci_ecc.c index 161406afd35..444f80bc962 100644 --- a/subsys/bluetooth/host/hci_ecc.c +++ b/subsys/bluetooth/host/hci_ecc.c @@ -23,9 +23,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_CORE) -#define LOG_MODULE_NAME bt_hci_ecc -#include "common/log.h" #include "common/bt_str.h" #include "hci_ecc.h" @@ -39,6 +36,10 @@ #endif #include "long_wq.h" +#define LOG_LEVEL CONFIG_BT_HCI_CORE_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_hci_ecc); + static void ecc_process(struct k_work *work); K_WORK_DEFINE(ecc_work, ecc_process); @@ -77,7 +78,7 @@ static void send_cmd_status(uint16_t opcode, uint8_t status) struct bt_hci_evt_hdr *hdr; struct net_buf *buf; - BT_DBG("opcode %x status %x", opcode, status); + LOG_DBG("opcode %x status %x", opcode, status); buf = bt_buf_get_evt(BT_HCI_EVT_CMD_STATUS, false, K_FOREVER); bt_buf_set_type(buf, BT_BUF_EVT); @@ -106,7 +107,7 @@ static uint8_t generate_keys(void) rc = uECC_make_key(ecc.public_key_be, ecc.private_key_be, &curve_secp256r1); if (rc == TC_CRYPTO_FAIL) { - BT_ERR("Failed to create ECC public/private pair"); + LOG_ERR("Failed to create ECC public/private pair"); return BT_HCI_ERR_UNSPECIFIED; } @@ -114,7 +115,7 @@ static uint8_t generate_keys(void) } while (memcmp(ecc.private_key_be, debug_private_key_be, BT_PRIV_KEY_LEN) == 0); if (IS_ENABLED(CONFIG_BT_LOG_SNIFFER_INFO)) { - BT_INFO("SC private key 0x%s", bt_hex(ecc.private_key_be, BT_PRIV_KEY_LEN)); + LOG_INF("SC private key 0x%s", bt_hex(ecc.private_key_be, BT_PRIV_KEY_LEN)); } return 0; @@ -128,7 +129,7 @@ static void emulate_le_p256_public_key_cmd(void) struct net_buf *buf; uint8_t status; - BT_DBG(""); + LOG_DBG(""); status = generate_keys(); @@ -170,7 +171,7 @@ static void emulate_le_generate_dhkey(void) ret = uECC_valid_public_key(ecc.public_key_be, &curve_secp256r1); if (ret < 0) { - BT_ERR("public key is not valid (ret %d)", ret); + LOG_ERR("public key is not valid (ret %d)", ret); ret = TC_CRYPTO_FAIL; } else { bool use_debug = atomic_test_bit(flags, USE_DEBUG_KEY); diff --git a/subsys/bluetooth/host/hci_raw.c b/subsys/bluetooth/host/hci_raw.c index 37f1d3bebe2..0af4a5edfa1 100644 --- a/subsys/bluetooth/host/hci_raw.c +++ b/subsys/bluetooth/host/hci_raw.c @@ -16,14 +16,16 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_CORE) -#define LOG_MODULE_NAME bt_hci_raw -#include "common/log.h" +#include #include "hci_ecc.h" #include "monitor.h" #include "hci_raw_internal.h" +#define LOG_LEVEL CONFIG_BT_HCI_CORE_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_hci_raw); + #define H4_CMD 0x01 #define H4_ACL 0x02 #define H4_SCO 0x03 @@ -65,7 +67,7 @@ int bt_hci_driver_register(const struct bt_hci_driver *drv) bt_dev.drv = drv; - BT_DBG("Registered %s", drv->name ? drv->name : ""); + LOG_DBG("Registered %s", drv->name ? drv->name : ""); bt_monitor_new_index(BT_MONITOR_TYPE_PRIMARY, drv->bus, BT_ADDR_ANY, drv->name ? drv->name : "bt0"); @@ -83,7 +85,7 @@ struct net_buf *bt_buf_get_rx(enum bt_buf_type type, k_timeout_t timeout) case BT_BUF_ISO_IN: break; default: - BT_ERR("Invalid rx type: %u", type); + LOG_ERR("Invalid rx type: %u", type); return NULL; } @@ -146,7 +148,7 @@ struct net_buf *bt_buf_get_tx(enum bt_buf_type type, k_timeout_t timeout, } __fallthrough; default: - BT_ERR("Invalid tx type: %u", type); + LOG_ERR("Invalid tx type: %u", type); return NULL; } @@ -182,7 +184,7 @@ struct net_buf *bt_buf_get_evt(uint8_t evt, bool discardable, k_timeout_t timeou int bt_recv(struct net_buf *buf) { - BT_DBG("buf %p len %u", buf, buf->len); + LOG_DBG("buf %p len %u", buf, buf->len); bt_monitor_send(bt_monitor_opcode(buf), buf->data, buf->len); @@ -202,7 +204,7 @@ int bt_recv(struct net_buf *buf) } __fallthrough; default: - BT_ERR("Unknown type %u", bt_buf_get_type(buf)); + LOG_ERR("Unknown type %u", bt_buf_get_type(buf)); return -EINVAL; } } @@ -262,13 +264,13 @@ static uint8_t bt_send_ext(struct net_buf *buf) net_buf_simple_save(&buf->b, &state); if (buf->len < sizeof(*hdr)) { - BT_ERR("No HCI Command header"); + LOG_ERR("No HCI Command header"); return BT_HCI_ERR_INVALID_PARAM; } hdr = net_buf_pull_mem(buf, sizeof(*hdr)); if (buf->len < hdr->param_len) { - BT_ERR("Invalid HCI CMD packet length"); + LOG_ERR("Invalid HCI CMD packet length"); return BT_HCI_ERR_INVALID_PARAM; } @@ -300,7 +302,7 @@ static uint8_t bt_send_ext(struct net_buf *buf) int bt_send(struct net_buf *buf) { - BT_DBG("buf %p len %u", buf, buf->len); + LOG_DBG("buf %p len %u", buf, buf->len); if (buf->len == 0) { return BT_HCI_ERR_INVALID_PARAM; @@ -327,7 +329,7 @@ int bt_send(struct net_buf *buf) int bt_hci_raw_set_mode(uint8_t mode) { - BT_DBG("mode %u", mode); + LOG_DBG("mode %u", mode); if (IS_ENABLED(CONFIG_BT_HCI_RAW_H4)) { switch (mode) { @@ -363,22 +365,22 @@ int bt_enable_raw(struct k_fifo *rx_queue) const struct bt_hci_driver *drv = bt_dev.drv; int err; - BT_DBG(""); + LOG_DBG(""); raw_rx = rx_queue; if (!bt_dev.drv) { - BT_ERR("No HCI driver registered"); + LOG_ERR("No HCI driver registered"); return -ENODEV; } err = drv->open(); if (err) { - BT_ERR("HCI driver open failed (%d)", err); + LOG_ERR("HCI driver open failed (%d)", err); return err; } - BT_INFO("Bluetooth enabled in RAW mode"); + LOG_INF("Bluetooth enabled in RAW mode"); return 0; } diff --git a/subsys/bluetooth/host/hfp_hf.c b/subsys/bluetooth/host/hfp_hf.c index cbbe442d85e..8487bea2081 100644 --- a/subsys/bluetooth/host/hfp_hf.c +++ b/subsys/bluetooth/host/hfp_hf.c @@ -14,9 +14,6 @@ #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HFP_HF) -#define LOG_MODULE_NAME bt_hfp_hf -#include "common/log.h" #include "common/assert.h" #include @@ -29,6 +26,10 @@ #include "at.h" #include "hfp_internal.h" +#define LOG_LEVEL CONFIG_BT_HFP_HF_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_hfp_hf); + #define MAX_IND_STR_LEN 17 struct bt_hfp_hf_cb *bt_hf; @@ -58,10 +59,10 @@ void hf_slc_error(struct at_client *hf_at) struct bt_hfp_hf *hf = CONTAINER_OF(hf_at, struct bt_hfp_hf, at); int err; - BT_ERR("SLC error: disconnecting"); + LOG_ERR("SLC error: disconnecting"); err = bt_rfcomm_dlc_disconnect(&hf->rfcomm_dlc); if (err) { - BT_ERR("Rfcomm: Unable to disconnect :%d", -err); + LOG_ERR("Rfcomm: Unable to disconnect :%d", -err); } } @@ -77,14 +78,14 @@ int hfp_hf_send_cmd(struct bt_hfp_hf *hf, at_resp_cb_t resp, buf = bt_rfcomm_create_pdu(&hf_pool); if (!buf) { - BT_ERR("No Buffers!"); + LOG_ERR("No Buffers!"); return -ENOMEM; } va_start(vargs, format); ret = vsnprintk(buf->data, (net_buf_tailroom(buf) - 1), format, vargs); if (ret < 0) { - BT_ERR("Unable to format variable arguments"); + LOG_ERR("Unable to format variable arguments"); return ret; } va_end(vargs); @@ -94,7 +95,7 @@ int hfp_hf_send_cmd(struct bt_hfp_hf *hf, at_resp_cb_t resp, ret = bt_rfcomm_dlc_send(&hf->rfcomm_dlc, buf); if (ret < 0) { - BT_ERR("Rfcomm send error :(%d)", ret); + LOG_ERR("Rfcomm send error :(%d)", ret); return ret; } @@ -109,7 +110,7 @@ int brsf_handle(struct at_client *hf_at) ret = at_get_number(hf_at, &val); if (ret < 0) { - BT_ERR("Error getting value"); + LOG_ERR("Error getting value"); return ret; } @@ -122,7 +123,7 @@ int brsf_resp(struct at_client *hf_at, struct net_buf *buf) { int err; - BT_DBG(""); + LOG_DBG(""); err = at_parse_cmd_input(hf_at, buf, "BRSF", brsf_handle, AT_CMD_TYPE_NORMAL); @@ -130,7 +131,7 @@ int brsf_resp(struct at_client *hf_at, struct net_buf *buf) /* Returning negative value is avoided before SLC connection * established. */ - BT_ERR("Error parsing CMD input"); + LOG_ERR("Error parsing CMD input"); hf_slc_error(hf_at); } @@ -143,14 +144,14 @@ static void cind_handle_values(struct at_client *hf_at, uint32_t index, struct bt_hfp_hf *hf = CONTAINER_OF(hf_at, struct bt_hfp_hf, at); int i; - BT_DBG("index: %u, name: %s, min: %u, max:%u", index, name, min, max); + LOG_DBG("index: %u, name: %s, min: %u, max:%u", index, name, min, max); for (i = 0; i < ARRAY_SIZE(ag_ind); i++) { if (strcmp(name, ag_ind[i].name) != 0) { continue; } if (min != ag_ind[i].min || max != ag_ind[i].max) { - BT_ERR("%s indicator min/max value not matching", name); + LOG_ERR("%s indicator min/max value not matching", name); } hf->ind_table[index] = i; @@ -168,32 +169,32 @@ int cind_handle(struct at_client *hf_at) uint32_t min, max; if (at_open_list(hf_at) < 0) { - BT_ERR("Could not get open list"); + LOG_ERR("Could not get open list"); goto error; } if (at_list_get_string(hf_at, name, sizeof(name)) < 0) { - BT_ERR("Could not get string"); + LOG_ERR("Could not get string"); goto error; } if (at_open_list(hf_at) < 0) { - BT_ERR("Could not get open list"); + LOG_ERR("Could not get open list"); goto error; } if (at_list_get_range(hf_at, &min, &max) < 0) { - BT_ERR("Could not get range"); + LOG_ERR("Could not get range"); goto error; } if (at_close_list(hf_at) < 0) { - BT_ERR("Could not get close list"); + LOG_ERR("Could not get close list"); goto error; } if (at_close_list(hf_at) < 0) { - BT_ERR("Could not get close list"); + LOG_ERR("Could not get close list"); goto error; } @@ -203,7 +204,7 @@ int cind_handle(struct at_client *hf_at) return 0; error: - BT_ERR("Error on CIND response"); + LOG_ERR("Error on CIND response"); hf_slc_error(hf_at); return -EINVAL; } @@ -215,7 +216,7 @@ int cind_resp(struct at_client *hf_at, struct net_buf *buf) err = at_parse_cmd_input(hf_at, buf, "CIND", cind_handle, AT_CMD_TYPE_NORMAL); if (err < 0) { - BT_ERR("Error parsing CMD input"); + LOG_ERR("Error parsing CMD input"); hf_slc_error(hf_at); } @@ -228,17 +229,16 @@ void ag_indicator_handle_values(struct at_client *hf_at, uint32_t index, struct bt_hfp_hf *hf = CONTAINER_OF(hf_at, struct bt_hfp_hf, at); struct bt_conn *conn = hf->rfcomm_dlc.session->br_chan.chan.conn; - BT_DBG("Index :%u, Value :%u", index, value); + LOG_DBG("Index :%u, Value :%u", index, value); if (index >= ARRAY_SIZE(ag_ind)) { - BT_ERR("Max only %zu indicators are supported", - ARRAY_SIZE(ag_ind)); + LOG_ERR("Max only %zu indicators are supported", ARRAY_SIZE(ag_ind)); return; } if (value > ag_ind[hf->ind_table[index]].max || value < ag_ind[hf->ind_table[index]].min) { - BT_ERR("Indicators out of range - value: %u", value); + LOG_ERR("Indicators out of range - value: %u", value); return; } @@ -279,7 +279,7 @@ void ag_indicator_handle_values(struct at_client *hf_at, uint32_t index, } break; default: - BT_ERR("Unknown AG indicator"); + LOG_ERR("Unknown AG indicator"); break; } } @@ -294,7 +294,7 @@ int cind_status_handle(struct at_client *hf_at) ret = at_get_number(hf_at, &value); if (ret < 0) { - BT_ERR("could not get the value"); + LOG_ERR("could not get the value"); return ret; } @@ -313,7 +313,7 @@ int cind_status_resp(struct at_client *hf_at, struct net_buf *buf) err = at_parse_cmd_input(hf_at, buf, "CIND", cind_status_handle, AT_CMD_TYPE_NORMAL); if (err < 0) { - BT_ERR("Error parsing CMD input"); + LOG_ERR("Error parsing CMD input"); hf_slc_error(hf_at); } @@ -327,18 +327,18 @@ int ciev_handle(struct at_client *hf_at) ret = at_get_number(hf_at, &index); if (ret < 0) { - BT_ERR("could not get the Index"); + LOG_ERR("could not get the Index"); return ret; } /* The first element of the list shall have 1 */ if (!index) { - BT_ERR("Invalid index value '0'"); + LOG_ERR("Invalid index value '0'"); return 0; } ret = at_get_number(hf_at, &value); if (ret < 0) { - BT_ERR("could not get the value"); + LOG_ERR("could not get the value"); return ret; } @@ -388,7 +388,7 @@ int unsolicited_cb(struct at_client *hf_at, struct net_buf *buf) handler = hfp_hf_unsol_lookup(hf_at); if (!handler) { - BT_ERR("Unhandled unsolicited response"); + LOG_ERR("Unhandled unsolicited response"); return -ENOMSG; } @@ -407,7 +407,7 @@ int cmd_complete(struct at_client *hf_at, enum at_result result, struct bt_conn *conn = hf->rfcomm_dlc.session->br_chan.chan.conn; struct bt_hfp_hf_cmd_complete cmd = { 0 }; - BT_DBG(""); + LOG_DBG(""); switch (result) { case AT_RESULT_OK: @@ -421,7 +421,7 @@ int cmd_complete(struct at_client *hf_at, enum at_result result, cmd.cme = cme_err; break; default: - BT_ERR("Unknown error code"); + LOG_ERR("Unknown error code"); cmd.type = HFP_HF_CMD_UNKNOWN_ERROR; break; } @@ -437,7 +437,7 @@ int cmee_finish(struct at_client *hf_at, enum at_result result, enum at_cme cme_err) { if (result != AT_RESULT_OK) { - BT_ERR("SLC Connection ERROR in response"); + LOG_ERR("SLC Connection ERROR in response"); return -EINVAL; } @@ -454,7 +454,7 @@ static void slc_completed(struct at_client *hf_at) } if (hfp_hf_send_cmd(hf, NULL, cmee_finish, "AT+CMEE=1") < 0) { - BT_ERR("Error Sending AT+CMEE"); + LOG_ERR("Error Sending AT+CMEE"); } } @@ -462,7 +462,7 @@ int cmer_finish(struct at_client *hf_at, enum at_result result, enum at_cme cme_err) { if (result != AT_RESULT_OK) { - BT_ERR("SLC Connection ERROR in response"); + LOG_ERR("SLC Connection ERROR in response"); hf_slc_error(hf_at); return -EINVAL; } @@ -479,7 +479,7 @@ int cind_status_finish(struct at_client *hf_at, enum at_result result, int err; if (result != AT_RESULT_OK) { - BT_ERR("SLC Connection ERROR in response"); + LOG_ERR("SLC Connection ERROR in response"); hf_slc_error(hf_at); return -EINVAL; } @@ -501,7 +501,7 @@ int cind_finish(struct at_client *hf_at, enum at_result result, int err; if (result != AT_RESULT_OK) { - BT_ERR("SLC Connection ERROR in response"); + LOG_ERR("SLC Connection ERROR in response"); hf_slc_error(hf_at); return -EINVAL; } @@ -523,7 +523,7 @@ int brsf_finish(struct at_client *hf_at, enum at_result result, int err; if (result != AT_RESULT_OK) { - BT_ERR("SLC Connection ERROR in response"); + LOG_ERR("SLC Connection ERROR in response"); hf_slc_error(hf_at); return -EINVAL; } @@ -541,7 +541,7 @@ int hf_slc_establish(struct bt_hfp_hf *hf) { int err; - BT_DBG(""); + LOG_DBG(""); err = hfp_hf_send_cmd(hf, brsf_resp, brsf_finish, "AT+BRSF=%u", hf->hf_features); @@ -573,16 +573,16 @@ int bt_hfp_hf_send_cmd(struct bt_conn *conn, enum bt_hfp_hf_at_cmd cmd) struct bt_hfp_hf *hf; int err; - BT_DBG(""); + LOG_DBG(""); if (!conn) { - BT_ERR("Invalid connection"); + LOG_ERR("Invalid connection"); return -ENOTCONN; } hf = bt_hfp_hf_lookup_bt_conn(conn); if (!hf) { - BT_ERR("No HF connection found"); + LOG_ERR("No HF connection found"); return -ENOTCONN; } @@ -590,19 +590,19 @@ int bt_hfp_hf_send_cmd(struct bt_conn *conn, enum bt_hfp_hf_at_cmd cmd) case BT_HFP_HF_ATA: err = hfp_hf_send_cmd(hf, NULL, cmd_complete, "ATA"); if (err < 0) { - BT_ERR("Failed ATA"); + LOG_ERR("Failed ATA"); return err; } break; case BT_HFP_HF_AT_CHUP: err = hfp_hf_send_cmd(hf, NULL, cmd_complete, "AT+CHUP"); if (err < 0) { - BT_ERR("Failed AT+CHUP"); + LOG_ERR("Failed AT+CHUP"); return err; } break; default: - BT_ERR("Invalid AT Command"); + LOG_ERR("Invalid AT Command"); return -EINVAL; } @@ -613,7 +613,7 @@ static void hfp_hf_connected(struct bt_rfcomm_dlc *dlc) { struct bt_hfp_hf *hf = CONTAINER_OF(dlc, struct bt_hfp_hf, rfcomm_dlc); - BT_DBG("hf connected"); + LOG_DBG("hf connected"); BT_ASSERT(hf); hf_slc_establish(hf); @@ -623,7 +623,7 @@ static void hfp_hf_disconnected(struct bt_rfcomm_dlc *dlc) { struct bt_conn *conn = dlc->session->br_chan.chan.conn; - BT_DBG("hf disconnected!"); + LOG_DBG("hf disconnected!"); if (bt_hf->disconnected) { bt_hf->disconnected(conn); } @@ -634,7 +634,7 @@ static void hfp_hf_recv(struct bt_rfcomm_dlc *dlc, struct net_buf *buf) struct bt_hfp_hf *hf = CONTAINER_OF(dlc, struct bt_hfp_hf, rfcomm_dlc); if (at_parse_input(&hf->at, buf) < 0) { - BT_ERR("Parsing failed"); + LOG_ERR("Parsing failed"); } } @@ -647,7 +647,7 @@ static int bt_hfp_hf_accept(struct bt_conn *conn, struct bt_rfcomm_dlc **dlc) .recv = hfp_hf_recv, }; - BT_DBG("conn %p", conn); + LOG_DBG("conn %p", conn); for (i = 0; i < ARRAY_SIZE(bt_hfp_hf_pool); i++) { struct bt_hfp_hf *hf = &bt_hfp_hf_pool[i]; @@ -675,7 +675,7 @@ static int bt_hfp_hf_accept(struct bt_conn *conn, struct bt_rfcomm_dlc **dlc) return 0; } - BT_ERR("Unable to establish HF connection (%p)", conn); + LOG_ERR("Unable to establish HF connection (%p)", conn); return -ENOMEM; } diff --git a/subsys/bluetooth/host/id.c b/subsys/bluetooth/host/id.c index a6fc343137f..fadab916537 100644 --- a/subsys/bluetooth/host/id.c +++ b/subsys/bluetooth/host/id.c @@ -29,11 +29,14 @@ #include "settings.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_CORE) -#define LOG_MODULE_NAME bt_id -#include "common/log.h" +#include + #include "common/bt_str.h" +#define LOG_LEVEL CONFIG_BT_HCI_CORE_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_id); + struct bt_adv_id_check_data { uint8_t id; bool adv_enabled; @@ -51,9 +54,8 @@ const bt_addr_le_t *bt_lookup_id_addr(uint8_t id, const bt_addr_le_t *addr) keys = bt_keys_find_irk(id, addr); if (keys) { - BT_DBG("Identity %s matched RPA %s", - bt_addr_le_str(&keys->addr), - bt_addr_le_str(addr)); + LOG_DBG("Identity %s matched RPA %s", bt_addr_le_str(&keys->addr), + bt_addr_le_str(addr)); return &keys->addr; } } @@ -123,7 +125,7 @@ static int set_random_address(const bt_addr_t *addr) struct net_buf *buf; int err; - BT_DBG("%s", bt_addr_str(addr)); + LOG_DBG("%s", bt_addr_str(addr)); /* Do nothing if we already have the right address */ if (!bt_addr_cmp(addr, &bt_dev.random_addr.a)) { @@ -163,7 +165,7 @@ int bt_id_set_adv_random_addr(struct bt_le_ext_adv *adv, return set_random_address(addr); } - BT_DBG("%s", bt_addr_str(addr)); + LOG_DBG("%s", bt_addr_str(addr)); if (!atomic_test_bit(adv->flags, BT_ADV_PARAMS_SET)) { bt_addr_copy(&adv->random_addr.a, addr); @@ -250,7 +252,7 @@ static void le_rpa_timeout_update(void) buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_RPA_TIMEOUT, sizeof(*cp)); if (!buf) { - BT_ERR("Failed to create HCI RPA timeout command"); + LOG_ERR("Failed to create HCI RPA timeout command"); err = -ENOBUFS; goto submit; } @@ -259,7 +261,7 @@ static void le_rpa_timeout_update(void) cp->rpa_timeout = sys_cpu_to_le16(bt_dev.rpa_timeout); err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_SET_RPA_TIMEOUT, buf, NULL); if (err) { - BT_ERR("Failed to send HCI RPA timeout command"); + LOG_ERR("Failed to send HCI RPA timeout command"); goto submit; } } @@ -310,7 +312,7 @@ int bt_id_set_private_addr(uint8_t id) } if (IS_ENABLED(CONFIG_BT_LOG_SNIFFER_INFO)) { - BT_INFO("RPA: %s", bt_addr_str(&rpa)); + LOG_INF("RPA: %s", bt_addr_str(&rpa)); } return 0; @@ -376,7 +378,7 @@ int bt_id_set_adv_private_addr(struct bt_le_ext_adv *adv) } if (IS_ENABLED(CONFIG_BT_LOG_SNIFFER_INFO)) { - BT_INFO("RPA: %s", bt_addr_str(&rpa)); + LOG_INF("RPA: %s", bt_addr_str(&rpa)); } return 0; @@ -404,7 +406,7 @@ int bt_id_set_private_addr(uint8_t id) } if (IS_ENABLED(CONFIG_BT_LOG_SNIFFER_INFO)) { - BT_INFO("NRPA: %s", bt_addr_str(&nrpa)); + LOG_INF("NRPA: %s", bt_addr_str(&nrpa)); } return 0; @@ -432,7 +434,7 @@ int bt_id_set_adv_private_addr(struct bt_le_ext_adv *adv) } if (IS_ENABLED(CONFIG_BT_LOG_SNIFFER_INFO)) { - BT_INFO("NRPA: %s", bt_addr_str(&nrpa)); + LOG_INF("NRPA: %s", bt_addr_str(&nrpa)); } return 0; @@ -451,7 +453,7 @@ static void adv_pause_rpa(struct bt_le_ext_adv *adv, void *data) err = bt_le_adv_set_enable_ext(adv, false, NULL); if (err) { - BT_ERR("Failed to disable advertising (err %d)", err); + LOG_ERR("Failed to disable advertising (err %d)", err); } atomic_set_bit(adv->flags, BT_ADV_RPA_UPDATE); @@ -484,13 +486,12 @@ static void adv_enable_rpa(struct bt_le_ext_adv *adv, void *data) err = bt_id_set_adv_private_addr(adv); if (err) { - BT_WARN("Failed to update advertiser RPA address (%d)", - err); + LOG_WRN("Failed to update advertiser RPA address (%d)", err); } err = bt_le_adv_set_enable_ext(adv, true, NULL); if (err) { - BT_ERR("Failed to enable advertising (err %d)", err); + LOG_ERR("Failed to enable advertising (err %d)", err); } } } @@ -541,7 +542,7 @@ static void le_update_private_addr(void) */ err = bt_id_set_private_addr(id); if (err) { - BT_WARN("Failed to update RPA address (%d)", err); + LOG_WRN("Failed to update RPA address (%d)", err); return; } @@ -580,7 +581,7 @@ static void rpa_timeout(struct k_work *work) { bool adv_enabled; - BT_DBG(""); + LOG_DBG(""); if (IS_ENABLED(CONFIG_BT_CENTRAL)) { struct bt_conn *conn = @@ -736,11 +737,11 @@ static int le_set_privacy_mode(const bt_addr_le_t *addr, uint8_t mode) /* Check if set privacy mode command is supported */ if (!BT_CMD_TEST(bt_dev.supported_commands, 39, 2)) { - BT_WARN("Set privacy mode command is not supported"); + LOG_WRN("Set privacy mode command is not supported"); return 0; } - BT_DBG("addr %s mode 0x%02x", bt_addr_le_str(addr), mode); + LOG_DBG("addr %s mode 0x%02x", bt_addr_le_str(addr), mode); bt_addr_le_copy(&cp.id_addr, addr); cp.mode = mode; @@ -764,7 +765,7 @@ static int addr_res_enable(uint8_t enable) { struct net_buf *buf; - BT_DBG("%s", enable ? "enabled" : "disabled"); + LOG_DBG("%s", enable ? "enabled" : "disabled"); buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_ADDR_RES_ENABLE, 1); if (!buf) { @@ -786,7 +787,7 @@ static int hci_id_add(uint8_t id, const bt_addr_le_t *addr, uint8_t peer_irk[16] return -EINVAL; } - BT_DBG("addr %s", bt_addr_le_str(addr)); + LOG_DBG("addr %s", bt_addr_le_str(addr)); buf = bt_hci_cmd_create(BT_HCI_OP_LE_ADD_DEV_TO_RL, sizeof(*cp)); if (!buf) { @@ -902,7 +903,7 @@ void bt_id_add(struct bt_keys *keys) struct bt_conn *conn; int err; - BT_DBG("addr %s", bt_addr_le_str(&keys->addr)); + LOG_DBG("addr %s", bt_addr_le_str(&keys->addr)); __ASSERT_NO_MSG(keys != NULL); /* We assume (and could assert) !bt_id_find_conflict(keys) here. */ @@ -956,17 +957,17 @@ void bt_id_add(struct bt_keys *keys) if (bt_dev.le.rl_entries) { err = addr_res_enable(BT_HCI_ADDR_RES_DISABLE); if (err) { - BT_WARN("Failed to disable address resolution"); + LOG_WRN("Failed to disable address resolution"); goto done; } } if (bt_dev.le.rl_entries == bt_dev.le.rl_size) { - BT_WARN("Resolving list size exceeded. Switching to host."); + LOG_WRN("Resolving list size exceeded. Switching to host."); err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_CLEAR_RL, NULL, NULL); if (err) { - BT_ERR("Failed to clear resolution list"); + LOG_ERR("Failed to clear resolution list"); goto done; } @@ -978,7 +979,7 @@ void bt_id_add(struct bt_keys *keys) err = hci_id_add(keys->id, &keys->addr, keys->irk.val); if (err) { - BT_ERR("Failed to add IRK to controller"); + LOG_ERR("Failed to add IRK to controller"); goto done; } @@ -999,7 +1000,7 @@ void bt_id_add(struct bt_keys *keys) */ err = le_set_privacy_mode(&keys->addr, BT_HCI_LE_PRIVACY_MODE_DEVICE); if (err) { - BT_ERR("Failed to set privacy mode"); + LOG_ERR("Failed to set privacy mode"); goto done; } @@ -1029,7 +1030,7 @@ static int hci_id_del(const bt_addr_le_t *addr) struct bt_hci_cp_le_rem_dev_from_rl *cp; struct net_buf *buf; - BT_DBG("addr %s", bt_addr_le_str(addr)); + LOG_DBG("addr %s", bt_addr_le_str(addr)); buf = bt_hci_cmd_create(BT_HCI_OP_LE_REM_DEV_FROM_RL, sizeof(*cp)); if (!buf) { @@ -1051,7 +1052,7 @@ void bt_id_del(struct bt_keys *keys) return; } - BT_DBG("addr %s", bt_addr_le_str(&keys->addr)); + LOG_DBG("addr %s", bt_addr_le_str(&keys->addr)); if (!bt_dev.le.rl_size || bt_dev.le.rl_entries > bt_dev.le.rl_size + 1) { @@ -1102,7 +1103,7 @@ void bt_id_del(struct bt_keys *keys) err = addr_res_enable(BT_HCI_ADDR_RES_DISABLE); if (err) { - BT_ERR("Disabling address resolution failed (err %d)", err); + LOG_ERR("Disabling address resolution failed (err %d)", err); goto done; } @@ -1121,7 +1122,7 @@ void bt_id_del(struct bt_keys *keys) err = hci_id_del(&keys->addr); if (err) { - BT_ERR("Failed to remove IRK from controller"); + LOG_ERR("Failed to remove IRK from controller"); goto done; } @@ -1234,7 +1235,7 @@ int bt_id_create(bt_addr_le_t *addr, uint8_t *irk) if (addr && !bt_addr_le_eq(addr, BT_ADDR_LE_ANY)) { if (addr->type != BT_ADDR_LE_RANDOM || !BT_ADDR_IS_STATIC(&addr->a)) { - BT_ERR("Only static random identity address supported"); + LOG_ERR("Only static random identity address supported"); return -EINVAL; } @@ -1283,7 +1284,7 @@ int bt_id_reset(uint8_t id, bt_addr_le_t *addr, uint8_t *irk) if (addr && !bt_addr_le_eq(addr, BT_ADDR_LE_ANY)) { if (addr->type != BT_ADDR_LE_RANDOM || !BT_ADDR_IS_STATIC(&addr->a)) { - BT_ERR("Only static random identity address supported"); + LOG_ERR("Only static random identity address supported"); return -EINVAL; } @@ -1394,13 +1395,13 @@ static void bt_read_identity_root(uint8_t *ir) err = bt_hci_cmd_send_sync(BT_HCI_OP_VS_READ_KEY_HIERARCHY_ROOTS, NULL, &rsp); if (err) { - BT_WARN("Failed to read identity root"); + LOG_WRN("Failed to read identity root"); return; } if (IS_ENABLED(CONFIG_BT_HCI_VS_EXT_DETECT) && rsp->len != sizeof(struct bt_hci_rp_vs_read_key_hierarchy_roots)) { - BT_WARN("Invalid Vendor HCI extensions"); + LOG_WRN("Invalid Vendor HCI extensions"); net_buf_unref(rsp); return; } @@ -1420,14 +1421,14 @@ uint8_t bt_id_read_public_addr(bt_addr_le_t *addr) int err; CHECKIF(addr == NULL) { - BT_WARN("Invalid input parameters"); + LOG_WRN("Invalid input parameters"); return 0U; } /* Read Bluetooth Address */ err = bt_hci_cmd_send_sync(BT_HCI_OP_READ_BD_ADDR, NULL, &rsp); if (err) { - BT_WARN("Failed to read public address"); + LOG_WRN("Failed to read public address"); return 0U; } @@ -1435,7 +1436,7 @@ uint8_t bt_id_read_public_addr(bt_addr_le_t *addr) if (!bt_addr_cmp(&rp->bdaddr, BT_ADDR_ANY) || !bt_addr_cmp(&rp->bdaddr, BT_ADDR_NONE)) { - BT_DBG("Controller has no public address"); + LOG_DBG("Controller has no public address"); net_buf_unref(rsp); return 0U; } @@ -1493,19 +1494,19 @@ uint8_t bt_read_static_addr(struct bt_hci_vs_static_addr addrs[], uint8_t size) uint8_t cnt; if (!BT_VS_CMD_READ_STATIC_ADDRS(bt_dev.vs_commands)) { - BT_WARN("Read Static Addresses command not available"); + LOG_WRN("Read Static Addresses command not available"); return 0; } err = bt_hci_cmd_send_sync(BT_HCI_OP_VS_READ_STATIC_ADDRS, NULL, &rsp); if (err) { - BT_WARN("Failed to read static addresses"); + LOG_WRN("Failed to read static addresses"); return 0; } if (IS_ENABLED(CONFIG_BT_HCI_VS_EXT_DETECT) && rsp->len < sizeof(struct bt_hci_rp_vs_read_static_addrs)) { - BT_WARN("Invalid Vendor HCI extensions"); + LOG_WRN("Invalid Vendor HCI extensions"); net_buf_unref(rsp); return 0; } @@ -1517,7 +1518,7 @@ uint8_t bt_read_static_addr(struct bt_hci_vs_static_addr addrs[], uint8_t size) rsp->len != (sizeof(struct bt_hci_rp_vs_read_static_addrs) + rp->num_addrs * sizeof(struct bt_hci_vs_static_addr))) { - BT_WARN("Invalid Vendor HCI extensions"); + LOG_WRN("Invalid Vendor HCI extensions"); net_buf_unref(rsp); return 0; } @@ -1528,7 +1529,7 @@ uint8_t bt_read_static_addr(struct bt_hci_vs_static_addr addrs[], uint8_t size) net_buf_unref(rsp); if (!cnt) { - BT_WARN("No static addresses stored in controller"); + LOG_WRN("No static addresses stored in controller"); } return cnt; @@ -1707,7 +1708,7 @@ int bt_id_set_scan_own_addr(bool active_scan, uint8_t *own_addr_type) return err; } - BT_WARN("Ignoring failure to set address for passive scan (%d)", + LOG_WRN("Ignoring failure to set address for passive scan (%d)", err); } @@ -2026,21 +2027,21 @@ int bt_id_init(void) int err; if (!IS_ENABLED(CONFIG_BT_SETTINGS) && !bt_dev.id_count) { - BT_DBG("No user identity. Trying to set public."); + LOG_DBG("No user identity. Trying to set public."); err = bt_setup_public_id_addr(); if (err) { - BT_ERR("Unable to set identity address"); + LOG_ERR("Unable to set identity address"); return err; } } if (!IS_ENABLED(CONFIG_BT_SETTINGS) && !bt_dev.id_count) { - BT_DBG("No public address. Trying to set static random."); + LOG_DBG("No public address. Trying to set static random."); err = bt_setup_random_id_addr(); if (err) { - BT_ERR("Unable to set identity address"); + LOG_ERR("Unable to set identity address"); return err; } @@ -2051,7 +2052,7 @@ int bt_id_init(void) */ err = set_random_address(&bt_dev.id_addr[0].a); if (err) { - BT_ERR("Unable to set random address"); + LOG_ERR("Unable to set random address"); return err; } } diff --git a/subsys/bluetooth/host/iso.c b/subsys/bluetooth/host/iso.c index 8bb59116ded..35dec7df104 100644 --- a/subsys/bluetooth/host/iso.c +++ b/subsys/bluetooth/host/iso.c @@ -20,13 +20,14 @@ #include "host/conn_internal.h" #include "iso_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_ISO) -#define LOG_MODULE_NAME bt_iso -#include "common/log.h" #include "common/assert.h" +#define LOG_LEVEL CONFIG_BT_ISO_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_iso); + #if defined(CONFIG_BT_DEBUG_ISO_DATA) -#define BT_ISO_DATA_DBG(fmt, ...) BT_DBG(fmt, ##__VA_ARGS__) +#define BT_ISO_DATA_DBG(fmt, ...) LOG_DBG(fmt, ##__VA_ARGS__) #else #define BT_ISO_DATA_DBG(fmt, ...) #endif /* CONFIG_BT_DEBUG_ISO_DATA */ @@ -116,14 +117,14 @@ void hci_iso(struct net_buf *buf) iso(buf)->handle, len, flags); if (buf->len != len) { - BT_ERR("ISO data length mismatch (%u != %u)", buf->len, len); + LOG_ERR("ISO data length mismatch (%u != %u)", buf->len, len); net_buf_unref(buf); return; } iso = bt_conn_lookup_handle(iso(buf)->handle); if (iso == NULL) { - BT_ERR("Unable to find conn for handle %u", iso(buf)->handle); + LOG_ERR("Unable to find conn for handle %u", iso(buf)->handle); net_buf_unref(buf); return; } @@ -141,7 +142,7 @@ static struct bt_conn *iso_new(void) if (iso) { iso->type = BT_CONN_TYPE_ISO; } else { - BT_DBG("Could not create new ISO"); + LOG_DBG("Could not create new ISO"); } return iso; @@ -208,8 +209,7 @@ static int hci_le_setup_iso_data_path(const struct bt_conn *iso, uint8_t dir, if ((path->cc == NULL && path->cc_len != 0) || (path->cc != NULL && path->cc_len == 0)) { - BT_DBG("Invalid ISO data path CC: %p %u", - path->cc, path->cc_len); + LOG_DBG("Invalid ISO data path CC: %p %u", path->cc, path->cc_len); return -EINVAL; } @@ -252,7 +252,7 @@ static void bt_iso_chan_add(struct bt_conn *iso, struct bt_iso_chan *chan) chan->iso = iso; iso->iso.chan = chan; - BT_DBG("iso %p chan %p", iso, chan); + LOG_DBG("iso %p chan %p", iso, chan); } static int bt_iso_setup_data_path(struct bt_iso_chan *chan) @@ -307,7 +307,7 @@ static int bt_iso_setup_data_path(struct bt_iso_chan *chan) dir = BT_HCI_DATAPATH_DIR_HOST_TO_CTLR; err = hci_le_setup_iso_data_path(iso, dir, in_path); if (err != 0) { - BT_DBG("Failed to set broadcaster data path: %d", err); + LOG_DBG("Failed to set broadcaster data path: %d", err); } return err; @@ -317,8 +317,7 @@ static int bt_iso_setup_data_path(struct bt_iso_chan *chan) dir = BT_HCI_DATAPATH_DIR_CTLR_TO_HOST; err = hci_le_setup_iso_data_path(iso, dir, out_path); if (err != 0) { - BT_DBG("Failed to set sync receiver data path: %d", - err); + LOG_DBG("Failed to set sync receiver data path: %d", err); } return err; @@ -356,22 +355,21 @@ void bt_iso_connected(struct bt_conn *iso) int err; if (iso == NULL || iso->type != BT_CONN_TYPE_ISO) { - BT_DBG("Invalid parameters: iso %p iso->type %u", iso, - iso ? iso->type : 0); + LOG_DBG("Invalid parameters: iso %p iso->type %u", iso, iso ? iso->type : 0); return; } - BT_DBG("%p", iso); + LOG_DBG("%p", iso); chan = iso_chan(iso); if (chan == NULL) { - BT_ERR("Could not lookup chan from connected ISO"); + LOG_ERR("Could not lookup chan from connected ISO"); return; } err = bt_iso_setup_data_path(chan); if (err != 0) { - BT_ERR("Unable to setup data path: %d", err); + LOG_ERR("Unable to setup data path: %d", err); #if defined(CONFIG_BT_ISO_BROADCAST) if (iso->iso.info.type == BT_ISO_CHAN_TYPE_BROADCASTER || iso->iso.info.type == BT_ISO_CHAN_TYPE_SYNC_RECEIVER) { @@ -382,7 +380,7 @@ void bt_iso_connected(struct bt_conn *iso) err = bt_iso_big_terminate(big); if (err != 0) { - BT_ERR("Could not terminate BIG: %d", err); + LOG_ERR("Could not terminate BIG: %d", err); } } #endif /* CONFIG_BT_ISO_BROADCAST */ @@ -406,7 +404,7 @@ void bt_iso_connected(struct bt_conn *iso) static void bt_iso_chan_disconnected(struct bt_iso_chan *chan, uint8_t reason) { - BT_DBG("%p, reason 0x%02x", chan, reason); + LOG_DBG("%p, reason 0x%02x", chan, reason); __ASSERT(chan->iso != NULL, "NULL conn for iso chan %p", chan); @@ -463,23 +461,22 @@ void bt_iso_disconnected(struct bt_conn *iso) struct bt_iso_chan *chan; if (iso == NULL || iso->type != BT_CONN_TYPE_ISO) { - BT_DBG("Invalid parameters: iso %p iso->type %u", iso, - iso ? iso->type : 0); + LOG_DBG("Invalid parameters: iso %p iso->type %u", iso, iso ? iso->type : 0); return; } - BT_DBG("%p", iso); + LOG_DBG("%p", iso); chan = iso_chan(iso); if (chan == NULL) { - BT_ERR("Could not lookup chan from disconnected ISO"); + LOG_ERR("Could not lookup chan from disconnected ISO"); return; } bt_iso_chan_disconnected(chan, iso->err); } -#if defined(CONFIG_BT_DEBUG_ISO) +#if defined(CONFIG_BT_ISO_LOG_LEVEL_DBG) const char *bt_iso_chan_state_str(uint8_t state) { switch (state) { @@ -502,9 +499,8 @@ void bt_iso_chan_set_state_debug(struct bt_iso_chan *chan, enum bt_iso_state state, const char *func, int line) { - BT_DBG("chan %p iso %p %s -> %s", chan, chan->iso, - bt_iso_chan_state_str(chan->state), - bt_iso_chan_state_str(state)); + LOG_DBG("chan %p iso %p %s -> %s", chan, chan->iso, bt_iso_chan_state_str(chan->state), + bt_iso_chan_state_str(state)); /* check transitions validness */ switch (state) { @@ -515,22 +511,22 @@ void bt_iso_chan_set_state_debug(struct bt_iso_chan *chan, __fallthrough; case BT_ISO_STATE_CONNECTING: if (chan->state != BT_ISO_STATE_DISCONNECTED) { - BT_WARN("%s()%d: invalid transition", func, line); + LOG_WRN("%s()%d: invalid transition", func, line); } break; case BT_ISO_STATE_CONNECTED: if (chan->state != BT_ISO_STATE_CONNECTING) { - BT_WARN("%s()%d: invalid transition", func, line); + LOG_WRN("%s()%d: invalid transition", func, line); } break; case BT_ISO_STATE_DISCONNECTING: if (chan->state != BT_ISO_STATE_CONNECTING && chan->state != BT_ISO_STATE_CONNECTED) { - BT_WARN("%s()%d: invalid transition", func, line); + LOG_WRN("%s()%d: invalid transition", func, line); } break; default: - BT_ERR("%s()%d: unknown (%u) state was set", func, line, state); + LOG_ERR("%s()%d: unknown (%u) state was set", func, line, state); return; } @@ -541,23 +537,23 @@ void bt_iso_chan_set_state(struct bt_iso_chan *chan, enum bt_iso_state state) { chan->state = state; } -#endif /* CONFIG_BT_DEBUG_ISO */ +#endif /* CONFIG_BT_ISO_LOG_LEVEL_DBG */ int bt_iso_chan_get_info(const struct bt_iso_chan *chan, struct bt_iso_info *info) { CHECKIF(chan == NULL) { - BT_DBG("chan is NULL"); + LOG_DBG("chan is NULL"); return -EINVAL; } CHECKIF(chan->iso == NULL) { - BT_DBG("chan->iso is NULL"); + LOG_DBG("chan->iso is NULL"); return -EINVAL; } CHECKIF(info == NULL) { - BT_DBG("info is NULL"); + LOG_DBG("info is NULL"); return -EINVAL; } @@ -630,7 +626,7 @@ void bt_iso_recv(struct bt_conn *iso, struct net_buf *buf, uint8_t flags) } else if (flags == BT_ISO_DATA_NOP) { iso_info(buf)->flags |= BT_ISO_FLAGS_LOST; } else { - BT_WARN("Invalid ISO packet status flag: %u", flags); + LOG_WRN("Invalid ISO packet status flag: %u", flags); iso_info(buf)->flags = 0; } @@ -639,8 +635,8 @@ void bt_iso_recv(struct bt_conn *iso, struct net_buf *buf, uint8_t flags) buf->len, len, flags, iso_info(buf)->ts); if (iso->rx) { - BT_ERR("Unexpected ISO %s fragment", - pb == BT_ISO_START ? "Start" : "Single"); + LOG_ERR("Unexpected ISO %s fragment", + pb == BT_ISO_START ? "Start" : "Single"); bt_conn_reset_rx_state(iso); } @@ -651,7 +647,7 @@ void bt_iso_recv(struct bt_conn *iso, struct net_buf *buf, uint8_t flags) * buf->len and cannot fit in a SINGLE package */ if (pb == BT_ISO_SINGLE) { - BT_ERR("Unexpected ISO single fragment"); + LOG_ERR("Unexpected ISO single fragment"); bt_conn_reset_rx_state(iso); } return; @@ -663,7 +659,7 @@ void bt_iso_recv(struct bt_conn *iso, struct net_buf *buf, uint8_t flags) * an SDU. */ if (!iso->rx) { - BT_ERR("Unexpected ISO continuation fragment"); + LOG_ERR("Unexpected ISO continuation fragment"); net_buf_unref(buf); return; } @@ -672,7 +668,7 @@ void bt_iso_recv(struct bt_conn *iso, struct net_buf *buf, uint8_t flags) buf->len, iso->rx_len); if (buf->len > net_buf_tailroom(iso->rx)) { - BT_ERR("Not enough buffer space for ISO data"); + LOG_ERR("Not enough buffer space for ISO data"); bt_conn_reset_rx_state(iso); net_buf_unref(buf); return; @@ -690,13 +686,13 @@ void bt_iso_recv(struct bt_conn *iso, struct net_buf *buf, uint8_t flags) BT_ISO_DATA_DBG("End, len %u rx_len %u", buf->len, iso->rx_len); if (iso->rx == NULL) { - BT_ERR("Unexpected ISO end fragment"); + LOG_ERR("Unexpected ISO end fragment"); net_buf_unref(buf); return; } if (buf->len > net_buf_tailroom(iso->rx)) { - BT_ERR("Not enough buffer space for ISO data"); + LOG_ERR("Not enough buffer space for ISO data"); bt_conn_reset_rx_state(iso); net_buf_unref(buf); return; @@ -708,7 +704,7 @@ void bt_iso_recv(struct bt_conn *iso, struct net_buf *buf, uint8_t flags) break; default: - BT_ERR("Unexpected ISO pb flags (0x%02x)", pb); + LOG_ERR("Unexpected ISO pb flags (0x%02x)", pb); bt_conn_reset_rx_state(iso); net_buf_unref(buf); return; @@ -716,7 +712,7 @@ void bt_iso_recv(struct bt_conn *iso, struct net_buf *buf, uint8_t flags) chan = iso_chan(iso); if (chan == NULL) { - BT_ERR("Could not lookup chan from receiving ISO"); + LOG_ERR("Could not lookup chan from receiving ISO"); } else if (chan->ops->recv != NULL) { chan->ops->recv(chan, iso_info(iso->rx), iso->rx); } @@ -754,39 +750,37 @@ int bt_iso_chan_send(struct bt_iso_chan *chan, struct net_buf *buf, struct bt_conn *iso_conn; CHECKIF(!chan || !buf) { - BT_DBG("Invalid parameters: chan %p buf %p", chan, buf); + LOG_DBG("Invalid parameters: chan %p buf %p", chan, buf); return -EINVAL; } BT_ISO_DATA_DBG("chan %p len %zu", chan, net_buf_frags_len(buf)); if (chan->state != BT_ISO_STATE_CONNECTED) { - BT_DBG("Not connected"); + LOG_DBG("Not connected"); return -ENOTCONN; } iso_conn = chan->iso; if (!iso_conn->iso.info.can_send) { - BT_DBG("Channel not able to send"); + LOG_DBG("Channel not able to send"); return -EINVAL; } if (ts == BT_ISO_TIMESTAMP_NONE && buf->size < BT_HCI_ISO_DATA_HDR_SIZE) { - BT_DBG("Cannot send ISO packet with buffer size %u", buf->size); + LOG_DBG("Cannot send ISO packet with buffer size %u", buf->size); return -EMSGSIZE; } else if (buf->size < BT_HCI_ISO_TS_DATA_HDR_SIZE) { - BT_DBG("Cannot send ISO packet with timestamp with buffer size %u", - buf->size); + LOG_DBG("Cannot send ISO packet with timestamp with buffer size %u", buf->size); return -EMSGSIZE; } max_data_len = iso_chan_max_data_len(chan, ts); if (buf->len > max_data_len) { - BT_DBG("Cannot send %u octets, maximum %u", - buf->len, max_data_len); + LOG_DBG("Cannot send %u octets, maximum %u", buf->len, max_data_len); return -EMSGSIZE; } @@ -820,13 +814,12 @@ static bool valid_chan_io_qos(const struct bt_iso_chan_io_qos *io_qos, const size_t max_sdu = MIN(max_mtu, BT_ISO_MAX_SDU); if (io_qos->sdu > max_sdu) { - BT_DBG("sdu (%u) shall be smaller than %zu", - io_qos->sdu, max_sdu); + LOG_DBG("sdu (%u) shall be smaller than %zu", io_qos->sdu, max_sdu); return false; } if (io_qos->phy > BT_GAP_LE_PHY_CODED) { - BT_DBG("Invalid phy %u", io_qos->phy); + LOG_DBG("Invalid phy %u", io_qos->phy); return false; } @@ -843,17 +836,17 @@ int bt_iso_chan_get_tx_sync(const struct bt_iso_chan *chan, struct bt_iso_tx_inf int err; CHECKIF(chan == NULL) { - BT_DBG("chan is NULL"); + LOG_DBG("chan is NULL"); return -EINVAL; } CHECKIF(chan->iso == NULL) { - BT_DBG("chan->iso is NULL"); + LOG_DBG("chan->iso is NULL"); return -EINVAL; } CHECKIF(info == NULL) { - BT_DBG("info is NULL"); + LOG_DBG("info is NULL"); return -EINVAL; } @@ -894,17 +887,17 @@ int bt_iso_chan_get_tx_sync(const struct bt_iso_chan *chan, struct bt_iso_tx_inf int bt_iso_chan_disconnect(struct bt_iso_chan *chan) { CHECKIF(!chan) { - BT_DBG("Invalid parameter: chan %p", chan); + LOG_DBG("Invalid parameter: chan %p", chan); return -EINVAL; } CHECKIF(chan->iso == NULL) { - BT_DBG("Channel has not been initialized in a CIG"); + LOG_DBG("Channel has not been initialized in a CIG"); return -EINVAL; } if (chan->iso->iso.acl == NULL) { - BT_DBG("Channel is not connected"); + LOG_DBG("Channel is not connected"); return -ENOTCONN; } @@ -913,7 +906,7 @@ int bt_iso_chan_disconnect(struct bt_iso_chan *chan) void bt_iso_cleanup_acl(struct bt_conn *iso) { - BT_DBG("%p", iso); + LOG_DBG("%p", iso); if (iso->iso.acl) { bt_conn_unref(iso->iso.acl); @@ -955,17 +948,17 @@ void hci_le_cis_established(struct net_buf *buf) uint16_t handle = sys_le16_to_cpu(evt->conn_handle); struct bt_conn *iso; - BT_DBG("status %u handle %u", evt->status, handle); + LOG_DBG("status %u handle %u", evt->status, handle); /* ISO connection handles are already assigned at this point */ iso = bt_conn_lookup_handle(handle); if (!iso) { - BT_ERR("No connection found for handle %u", handle); + LOG_ERR("No connection found for handle %u", handle); return; } CHECKIF(iso->type != BT_CONN_TYPE_ISO) { - BT_DBG("Invalid connection type %u", iso->type); + LOG_DBG("Invalid connection type %u", iso->type); return; } @@ -983,7 +976,7 @@ void hci_le_cis_established(struct net_buf *buf) tx = chan->qos->tx; rx = chan->qos->rx; - BT_DBG("iso_chan %p tx %p rx %p", chan, tx, rx); + LOG_DBG("iso_chan %p tx %p rx %p", chan, tx, rx); if (iso->role == BT_HCI_ROLE_PERIPHERAL) { rx = chan->qos->rx; @@ -1041,7 +1034,7 @@ void hci_le_cis_established(struct net_buf *buf) int bt_iso_server_register(struct bt_iso_server *server) { CHECKIF(!server) { - BT_DBG("Invalid parameter: server %p", server); + LOG_DBG("Invalid parameter: server %p", server); return -EINVAL; } @@ -1067,7 +1060,7 @@ int bt_iso_server_register(struct bt_iso_server *server) } #endif /* CONFIG_BT_SMP */ - BT_DBG("%p", server); + LOG_DBG("%p", server); iso_server = server; @@ -1081,12 +1074,11 @@ static int iso_accept(struct bt_conn *acl, struct bt_conn *iso) int err; CHECKIF(!iso || iso->type != BT_CONN_TYPE_ISO) { - BT_DBG("Invalid parameters: iso %p iso->type %u", iso, - iso ? iso->type : 0); + LOG_DBG("Invalid parameters: iso %p iso->type %u", iso, iso ? iso->type : 0); return -EINVAL; } - BT_DBG("%p", iso); + LOG_DBG("%p", iso); accept_info.acl = acl; accept_info.cig_id = iso->iso.cig_id; @@ -1094,7 +1086,7 @@ static int iso_accept(struct bt_conn *acl, struct bt_conn *iso) err = iso_server->accept(&accept_info, &chan); if (err < 0) { - BT_ERR("Server failed to accept: %d", err); + LOG_ERR("Server failed to accept: %d", err); return err; } @@ -1179,11 +1171,11 @@ void hci_le_cis_req(struct net_buf *buf) uint8_t sec_err; int err; - BT_DBG("acl_handle %u cis_handle %u cig_id %u cis %u", - acl_handle, cis_handle, evt->cig_id, evt->cis_id); + LOG_DBG("acl_handle %u cis_handle %u cig_id %u cis %u", acl_handle, cis_handle, evt->cig_id, + evt->cis_id); if (iso_server == NULL) { - BT_DBG("No ISO server registered"); + LOG_DBG("No ISO server registered"); hci_le_reject_cis(cis_handle, BT_HCI_ERR_UNSPECIFIED); return; } @@ -1191,7 +1183,7 @@ void hci_le_cis_req(struct net_buf *buf) /* Lookup existing connection with same handle */ iso = bt_conn_lookup_handle(cis_handle); if (iso) { - BT_ERR("Invalid ISO handle %u", cis_handle); + LOG_ERR("Invalid ISO handle %u", cis_handle); hci_le_reject_cis(cis_handle, BT_HCI_ERR_CONN_LIMIT_EXCEEDED); bt_conn_unref(iso); return; @@ -1200,17 +1192,17 @@ void hci_le_cis_req(struct net_buf *buf) /* Lookup ACL connection to attach */ acl = bt_conn_lookup_handle(acl_handle); if (!acl) { - BT_ERR("Invalid ACL handle %u", acl_handle); + LOG_ERR("Invalid ACL handle %u", acl_handle); hci_le_reject_cis(cis_handle, BT_HCI_ERR_UNKNOWN_CONN_ID); return; } sec_err = iso_server_check_security(acl); if (sec_err != BT_HCI_ERR_SUCCESS) { - BT_DBG("Insufficient security %u", sec_err); + LOG_DBG("Insufficient security %u", sec_err); err = hci_le_reject_cis(cis_handle, sec_err); if (err != 0) { - BT_ERR("Failed to reject CIS"); + LOG_ERR("Failed to reject CIS"); } return; } @@ -1221,7 +1213,7 @@ void hci_le_cis_req(struct net_buf *buf) bt_conn_unref(acl); if (!iso) { - BT_ERR("Could not create and add ISO to ACL %u", acl_handle); + LOG_ERR("Could not create and add ISO to ACL %u", acl_handle); hci_le_reject_cis(cis_handle, BT_HCI_ERR_INSUFFICIENT_RESOURCES); return; @@ -1234,7 +1226,7 @@ void hci_le_cis_req(struct net_buf *buf) /* Request application to accept */ err = iso_accept(acl, iso); if (err) { - BT_DBG("App rejected ISO %d", err); + LOG_DBG("App rejected ISO %d", err); bt_conn_unref(iso); hci_le_reject_cis(cis_handle, BT_HCI_ERR_INSUFFICIENT_RESOURCES); @@ -1259,7 +1251,7 @@ static struct bt_conn *bt_conn_add_iso(struct bt_conn *acl) struct bt_conn *iso = iso_new(); if (iso == NULL) { - BT_ERR("Unable to allocate ISO connection"); + LOG_ERR("Unable to allocate ISO connection"); return NULL; } @@ -1305,7 +1297,7 @@ static void bt_iso_remove_data_path(struct bt_conn *iso) { enum bt_iso_chan_type type = iso->iso.info.type; - BT_DBG("%p", iso); + LOG_DBG("%p", iso); /* TODO: Removing the ISO data path is never used for broadcast: * Remove the following broadcast implementation? @@ -1353,17 +1345,17 @@ static bool valid_chan_qos(const struct bt_iso_chan_qos *qos) { if (qos->rx != NULL) { if (!valid_chan_io_qos(qos->rx, false)) { - BT_DBG("Invalid rx qos"); + LOG_DBG("Invalid rx qos"); return false; } } else if (qos->tx == NULL) { - BT_DBG("Both rx and tx qos are NULL"); + LOG_DBG("Both rx and tx qos are NULL"); return false; } if (qos->tx != NULL) { if (!valid_chan_io_qos(qos->tx, true)) { - BT_DBG("Invalid tx qos"); + LOG_DBG("Invalid tx qos"); return false; } } @@ -1420,9 +1412,9 @@ static struct net_buf *hci_le_set_cig_params(const struct bt_iso_cig *cig, req->framing = param->framing; req->num_cis = param->num_cis; - BT_DBG("id %u, latency %u, interval %u, sca %u, packing %u, framing %u, num_cis %u", - cig->id, param->latency, param->interval, param->sca, - param->packing, param->framing, param->num_cis); + LOG_DBG("id %u, latency %u, interval %u, sca %u, packing %u, framing %u, num_cis %u", + cig->id, param->latency, param->interval, param->sca, param->packing, + param->framing, param->num_cis); /* Program the cis parameters */ for (i = 0; i < param->num_cis; i++) { @@ -1436,7 +1428,7 @@ static struct net_buf *hci_le_set_cig_params(const struct bt_iso_cig *cig, cis_param->cis_id = cis->iso->iso.cis_id; if (!qos->tx && !qos->rx) { - BT_ERR("Both TX and RX QoS are disabled"); + LOG_ERR("Both TX and RX QoS are disabled"); net_buf_unref(buf); return NULL; } @@ -1463,10 +1455,9 @@ static struct net_buf *hci_le_set_cig_params(const struct bt_iso_cig *cig, cis_param->p_rtn = qos->rx->rtn; } - BT_DBG("[%d]: id %u, c_phy %u, c_sdu %u, c_rtn %u, p_phy %u, p_sdu %u, p_rtn %u", - i, cis_param->cis_id, cis_param->c_phy, cis_param->c_sdu, - cis_param->c_rtn, cis_param->p_phy, cis_param->p_sdu, - cis_param->p_rtn); + LOG_DBG("[%d]: id %u, c_phy %u, c_sdu %u, c_rtn %u, p_phy %u, p_sdu %u, p_rtn %u", + i, cis_param->cis_id, cis_param->c_phy, cis_param->c_sdu, cis_param->c_rtn, + cis_param->p_phy, cis_param->p_sdu, cis_param->p_rtn); } err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_SET_CIG_PARAMS, buf, &rsp); @@ -1502,7 +1493,7 @@ static struct bt_iso_cig *get_free_cig(void) } } - BT_DBG("Could not allocate any more CIGs"); + LOG_DBG("Could not allocate any more CIGs"); return NULL; } @@ -1524,7 +1515,7 @@ static int cig_init_cis(struct bt_iso_cig *cig, cis->iso = iso_new(); if (cis->iso == NULL) { - BT_ERR("Unable to allocate CIS connection"); + LOG_ERR("Unable to allocate CIS connection"); return -ENOMEM; } iso_conn = &cis->iso->iso; @@ -1568,23 +1559,23 @@ static bool valid_cig_param(const struct bt_iso_cig_param *param) struct bt_iso_chan *cis = param->cis_channels[i]; if (cis == NULL) { - BT_DBG("cis_channels[%d]: NULL channel", i); + LOG_DBG("cis_channels[%d]: NULL channel", i); return false; } if (cis->iso != NULL) { - BT_DBG("cis_channels[%d]: already allocated", i); + LOG_DBG("cis_channels[%d]: already allocated", i); return false; } if (!valid_chan_qos(cis->qos)) { - BT_DBG("cis_channels[%d]: Invalid QOS", i); + LOG_DBG("cis_channels[%d]: Invalid QOS", i); return false; } for (uint8_t j = 0; j < i; j++) { if (cis == param->cis_channels[j]) { - BT_DBG("ISO %p duplicated at index %u and %u", cis, i, j); + LOG_DBG("ISO %p duplicated at index %u and %u", cis, i, j); return false; } } @@ -1592,32 +1583,32 @@ static bool valid_cig_param(const struct bt_iso_cig_param *param) if (param->framing != BT_ISO_FRAMING_UNFRAMED && param->framing != BT_ISO_FRAMING_FRAMED) { - BT_DBG("Invalid framing parameter: %u", param->framing); + LOG_DBG("Invalid framing parameter: %u", param->framing); return false; } if (param->packing != BT_ISO_PACKING_SEQUENTIAL && param->packing != BT_ISO_PACKING_INTERLEAVED) { - BT_DBG("Invalid packing parameter: %u", param->packing); + LOG_DBG("Invalid packing parameter: %u", param->packing); return false; } if (param->num_cis > BT_ISO_MAX_GROUP_ISO_COUNT || param->num_cis > CONFIG_BT_ISO_MAX_CHAN) { - BT_DBG("num_cis (%u) shall be lower than: %u", param->num_cis, - MAX(CONFIG_BT_ISO_MAX_CHAN, BT_ISO_MAX_GROUP_ISO_COUNT)); + LOG_DBG("num_cis (%u) shall be lower than: %u", param->num_cis, + MAX(CONFIG_BT_ISO_MAX_CHAN, BT_ISO_MAX_GROUP_ISO_COUNT)); return false; } if (param->interval < BT_ISO_SDU_INTERVAL_MIN || param->interval > BT_ISO_SDU_INTERVAL_MAX) { - BT_DBG("Invalid interval: %u", param->interval); + LOG_DBG("Invalid interval: %u", param->interval); return false; } if (param->latency < BT_ISO_LATENCY_MIN || param->latency > BT_ISO_LATENCY_MAX) { - BT_DBG("Invalid latency: %u", param->latency); + LOG_DBG("Invalid latency: %u", param->latency); return false; } @@ -1635,7 +1626,7 @@ int bt_iso_cig_create(const struct bt_iso_cig_param *param, int i; CHECKIF(out_cig == NULL) { - BT_DBG("out_cig is NULL"); + LOG_DBG("out_cig is NULL"); return -EINVAL; } @@ -1648,17 +1639,17 @@ int bt_iso_cig_create(const struct bt_iso_cig_param *param, /* TBD: Should we allow creating empty CIGs? */ CHECKIF(param->cis_channels == NULL) { - BT_DBG("NULL CIS channels"); + LOG_DBG("NULL CIS channels"); return -EINVAL; } CHECKIF(param->num_cis == 0) { - BT_DBG("Invalid number of CIS %u", param->num_cis); + LOG_DBG("Invalid number of CIS %u", param->num_cis); return -EINVAL; } CHECKIF(!valid_cig_param(param)) { - BT_DBG("Invalid CIG params"); + LOG_DBG("Invalid CIG params"); return -EINVAL; } @@ -1670,14 +1661,14 @@ int bt_iso_cig_create(const struct bt_iso_cig_param *param, err = cig_init_cis(cig, param); if (err) { - BT_DBG("Could not init CIS %d", err); + LOG_DBG("Could not init CIS %d", err); cleanup_cig(cig); return err; } rsp = hci_le_set_cig_params(cig, param); if (rsp == NULL) { - BT_WARN("Unexpected response to hci_le_set_cig_params"); + LOG_WRN("Unexpected response to hci_le_set_cig_params"); err = -EIO; cleanup_cig(cig); return err; @@ -1687,7 +1678,7 @@ int bt_iso_cig_create(const struct bt_iso_cig_param *param, if (rsp->len < sizeof(cig_rsp) || cig_rsp->num_handles != param->num_cis) { - BT_WARN("Unexpected response to hci_le_set_cig_params"); + LOG_WRN("Unexpected response to hci_le_set_cig_params"); err = -EIO; net_buf_unref(rsp); cleanup_cig(cig); @@ -1741,17 +1732,17 @@ int bt_iso_cig_reconfigure(struct bt_iso_cig *cig, int i; CHECKIF(cig == NULL) { - BT_DBG("cig is NULL"); + LOG_DBG("cig is NULL"); return -EINVAL; } if (cig->state != BT_ISO_CIG_STATE_CONFIGURED) { - BT_DBG("Invalid CIG state: %u", cig->state); + LOG_DBG("Invalid CIG state: %u", cig->state); return -EINVAL; } CHECKIF(!valid_cig_param(param)) { - BT_DBG("Invalid CIG params"); + LOG_DBG("Invalid CIG params"); return -EINVAL; } @@ -1759,7 +1750,7 @@ int bt_iso_cig_reconfigure(struct bt_iso_cig *cig, struct bt_iso_chan *cis = param->cis_channels[i]; if (cis->iso != NULL && !cis_is_in_cig(cig, cis)) { - BT_DBG("Cannot reconfigure other CIG's (id 0x%02X) CIS " + LOG_DBG("Cannot reconfigure other CIG's (id 0x%02X) CIS " "with this CIG (id 0x%02X)", cis->iso->iso.cig_id, cig->id); return -EINVAL; @@ -1771,14 +1762,14 @@ int bt_iso_cig_reconfigure(struct bt_iso_cig *cig, err = cig_init_cis(cig, param); if (err != 0) { - BT_DBG("Could not init CIS %d", err); + LOG_DBG("Could not init CIS %d", err); restore_cig(cig, existing_num_cis); return err; } rsp = hci_le_set_cig_params(cig, param); if (rsp == NULL) { - BT_WARN("Unexpected response to hci_le_set_cig_params"); + LOG_WRN("Unexpected response to hci_le_set_cig_params"); err = -EIO; restore_cig(cig, existing_num_cis); return err; @@ -1788,7 +1779,7 @@ int bt_iso_cig_reconfigure(struct bt_iso_cig *cig, if (rsp->len < sizeof(cig_rsp) || cig_rsp->num_handles != param->num_cis) { - BT_WARN("Unexpected response to hci_le_set_cig_params"); + LOG_WRN("Unexpected response to hci_le_set_cig_params"); err = -EIO; net_buf_unref(rsp); restore_cig(cig, existing_num_cis); @@ -1813,19 +1804,19 @@ int bt_iso_cig_terminate(struct bt_iso_cig *cig) int err; CHECKIF(cig == NULL) { - BT_DBG("cig is NULL"); + LOG_DBG("cig is NULL"); return -EINVAL; } if (cig->state != BT_ISO_CIG_STATE_INACTIVE && cig->state != BT_ISO_CIG_STATE_CONFIGURED) { - BT_DBG("Invalid CIG state: %u", cig->state); + LOG_DBG("Invalid CIG state: %u", cig->state); return -EINVAL; } err = hci_le_remove_cig(cig->id); if (err != 0) { - BT_DBG("Failed to terminate CIG: %d", err); + LOG_DBG("Failed to terminate CIG: %d", err); return err; } @@ -1870,8 +1861,7 @@ void bt_iso_security_changed(struct bt_conn *acl, uint8_t hci_status) param[param_count].iso_chan = iso_chan; param_count++; } else { - BT_DBG("Failed to encrypt ACL %p for ISO %p: %u", - acl, iso, hci_status); + LOG_DBG("Failed to encrypt ACL %p for ISO %p: %u", acl, iso, hci_status); /* We utilize the disconnected callback to make the * upper layers aware of the error @@ -1892,7 +1882,7 @@ void bt_iso_security_changed(struct bt_conn *acl, uint8_t hci_status) err = hci_le_create_cis(param, param_count); if (err != 0) { - BT_ERR("Failed to connect CISes: %d", err); + LOG_ERR("Failed to connect CISes: %d", err); for (size_t i = 0; i < param_count; i++) { struct bt_iso_chan *iso_chan = param[i].iso_chan; @@ -1992,8 +1982,7 @@ static int iso_chan_connect_security(const struct bt_iso_connect_param *param, err = bt_conn_set_security(acl, iso_chan->required_sec_level); if (err != 0) { - BT_DBG("[%zu]: Failed to set security: %d", - i, err); + LOG_DBG("[%zu]: Failed to set security: %d", i, err); /* Restore states */ for (size_t j = 0; j < i; j++) { @@ -2045,12 +2034,12 @@ int bt_iso_chan_connect(const struct bt_iso_connect_param *param, size_t count) int err; CHECKIF(param == NULL || count == 0) { - BT_DBG("param is NULL"); + LOG_DBG("param is NULL"); return -EINVAL; } CHECKIF(count == 0) { - BT_DBG("Invalid count %zu", count); + LOG_DBG("Invalid count %zu", count); return -EINVAL; } @@ -2061,36 +2050,35 @@ int bt_iso_chan_connect(const struct bt_iso_connect_param *param, size_t count) /* Validate input */ for (size_t i = 0; i < count; i++) { CHECKIF(param[i].iso_chan == NULL) { - BT_DBG("[%zu]: Invalid iso (%p)", i, param[i].iso_chan); + LOG_DBG("[%zu]: Invalid iso (%p)", i, param[i].iso_chan); return -EINVAL; } CHECKIF(param[i].acl == NULL) { - BT_DBG("[%zu]: Invalid acl (%p)", i, param[i].acl); + LOG_DBG("[%zu]: Invalid acl (%p)", i, param[i].acl); return -EINVAL; } CHECKIF((param[i].acl->type & BT_CONN_TYPE_LE) == 0) { - BT_DBG("[%zu]: acl type (%u) shall be an LE connection", - i, param[i].acl->type); + LOG_DBG("[%zu]: acl type (%u) shall be an LE connection", i, + param[i].acl->type); return -EINVAL; } if (param[i].iso_chan->iso == NULL) { - BT_DBG("[%zu]: ISO has not been initialized in a CIG", - i); + LOG_DBG("[%zu]: ISO has not been initialized in a CIG", i); return -EINVAL; } if (param[i].iso_chan->state != BT_ISO_STATE_DISCONNECTED) { - BT_DBG("[%zu]: ISO is not in the BT_ISO_STATE_DISCONNECTED state: %u", - i, param[i].iso_chan->state); + LOG_DBG("[%zu]: ISO is not in the BT_ISO_STATE_DISCONNECTED state: %u", i, + param[i].iso_chan->state); return -EINVAL; } } if (iso_chans_connecting()) { - BT_DBG("There are pending ISO connections"); + LOG_DBG("There are pending ISO connections"); return -EBUSY; } @@ -2100,18 +2088,18 @@ int bt_iso_chan_connect(const struct bt_iso_connect_param *param, size_t count) */ err = iso_chan_connect_security(param, count); if (err != 0) { - BT_DBG("Failed to initate security for all CIS: %d", err); + LOG_DBG("Failed to initate security for all CIS: %d", err); return err; } #endif /* CONFIG_BT_SMP */ err = hci_le_create_cis(param, count); if (err == -ECANCELED) { - BT_DBG("All channels are pending on security"); + LOG_DBG("All channels are pending on security"); return 0; } else if (err != 0) { - BT_DBG("Failed to connect CISes: %d", err); + LOG_DBG("Failed to connect CISes: %d", err); return err; } @@ -2159,7 +2147,7 @@ static struct bt_iso_big *get_free_big(void) } } - BT_DBG("Could not allocate any more BIGs"); + LOG_DBG("Could not allocate any more BIGs"); return NULL; } @@ -2172,7 +2160,7 @@ static struct bt_iso_big *big_lookup_flag(int bit) } } - BT_DBG("No BIG with flag bit %d set", bit); + LOG_DBG("No BIG with flag bit %d set", bit); return NULL; } @@ -2216,7 +2204,7 @@ static int big_init_bis(struct bt_iso_big *big, bis->iso = iso_new(); if (!bis->iso) { - BT_ERR("Unable to allocate BIS connection"); + LOG_ERR("Unable to allocate BIS connection"); return -ENOMEM; } iso_conn = &bis->iso->iso; @@ -2296,17 +2284,17 @@ int bt_iso_big_create(struct bt_le_ext_adv *padv, struct bt_iso_big_create_param struct bt_iso_big *big; if (!atomic_test_bit(padv->flags, BT_PER_ADV_PARAMS_SET)) { - BT_DBG("PA params not set; invalid adv object"); + LOG_DBG("PA params not set; invalid adv object"); return -EINVAL; } CHECKIF(!param->bis_channels) { - BT_DBG("NULL BIS channels"); + LOG_DBG("NULL BIS channels"); return -EINVAL; } CHECKIF(!param->num_bis) { - BT_DBG("Invalid number of BIS %u", param->num_bis); + LOG_DBG("Invalid number of BIS %u", param->num_bis); return -EINVAL; } @@ -2314,55 +2302,55 @@ int bt_iso_big_create(struct bt_le_ext_adv *padv, struct bt_iso_big_create_param struct bt_iso_chan *bis = param->bis_channels[i]; CHECKIF(bis == NULL) { - BT_DBG("bis_channels[%u]: NULL channel", i); + LOG_DBG("bis_channels[%u]: NULL channel", i); return -EINVAL; } if (bis->iso) { - BT_DBG("bis_channels[%u]: already allocated", i); + LOG_DBG("bis_channels[%u]: already allocated", i); return -EALREADY; } CHECKIF(bis->qos == NULL) { - BT_DBG("bis_channels[%u]: qos is NULL", i); + LOG_DBG("bis_channels[%u]: qos is NULL", i); return -EINVAL; } CHECKIF(bis->qos->tx == NULL || !valid_chan_io_qos(bis->qos->tx, true)) { - BT_DBG("bis_channels[%u]: Invalid QOS", i); + LOG_DBG("bis_channels[%u]: Invalid QOS", i); return -EINVAL; } } CHECKIF(param->framing != BT_ISO_FRAMING_UNFRAMED && param->framing != BT_ISO_FRAMING_FRAMED) { - BT_DBG("Invalid framing parameter: %u", param->framing); + LOG_DBG("Invalid framing parameter: %u", param->framing); return -EINVAL; } CHECKIF(param->packing != BT_ISO_PACKING_SEQUENTIAL && param->packing != BT_ISO_PACKING_INTERLEAVED) { - BT_DBG("Invalid packing parameter: %u", param->packing); + LOG_DBG("Invalid packing parameter: %u", param->packing); return -EINVAL; } CHECKIF(param->num_bis > BT_ISO_MAX_GROUP_ISO_COUNT || param->num_bis > CONFIG_BT_ISO_MAX_CHAN) { - BT_DBG("num_bis (%u) shall be lower than: %u", param->num_bis, - MAX(CONFIG_BT_ISO_MAX_CHAN, BT_ISO_MAX_GROUP_ISO_COUNT)); + LOG_DBG("num_bis (%u) shall be lower than: %u", param->num_bis, + MAX(CONFIG_BT_ISO_MAX_CHAN, BT_ISO_MAX_GROUP_ISO_COUNT)); return -EINVAL; } CHECKIF(param->interval < BT_ISO_SDU_INTERVAL_MIN || param->interval > BT_ISO_SDU_INTERVAL_MAX) { - BT_DBG("Invalid interval: %u", param->interval); + LOG_DBG("Invalid interval: %u", param->interval); return -EINVAL; } CHECKIF(param->latency < BT_ISO_LATENCY_MIN || param->latency > BT_ISO_LATENCY_MAX) { - BT_DBG("Invalid latency: %u", param->latency); + LOG_DBG("Invalid latency: %u", param->latency); return -EINVAL; } @@ -2374,7 +2362,7 @@ int bt_iso_big_create(struct bt_le_ext_adv *padv, struct bt_iso_big_create_param err = big_init_bis(big, param->bis_channels, param->num_bis, true); if (err) { - BT_DBG("Could not init BIG %d", err); + LOG_DBG("Could not init BIG %d", err); cleanup_big(big); return err; } @@ -2382,7 +2370,7 @@ int bt_iso_big_create(struct bt_le_ext_adv *padv, struct bt_iso_big_create_param err = hci_le_create_big(padv, big, param); if (err) { - BT_DBG("Could not create BIG %d", err); + LOG_DBG("Could not create BIG %d", err); cleanup_big(big); return err; } @@ -2421,7 +2409,7 @@ void hci_le_big_complete(struct net_buf *buf) int i; if (evt->big_handle >= ARRAY_SIZE(bigs)) { - BT_WARN("Invalid BIG handle"); + LOG_WRN("Invalid BIG handle"); big = big_lookup_flag(BT_BIG_PENDING); if (big) { @@ -2435,12 +2423,12 @@ void hci_le_big_complete(struct net_buf *buf) big = lookup_big_by_handle(evt->big_handle); atomic_clear_bit(big->flags, BT_BIG_PENDING); - BT_DBG("BIG[%u] %p completed, status %u", big->handle, big, evt->status); + LOG_DBG("BIG[%u] %p completed, status %u", big->handle, big, evt->status); if (evt->status || evt->num_bis != big->num_bis) { if (evt->status == BT_HCI_ERR_SUCCESS && evt->num_bis != big->num_bis) { - BT_ERR("Invalid number of BIS created, was %u expected %u", - evt->num_bis, big->num_bis); + LOG_ERR("Invalid number of BIS created, was %u expected %u", evt->num_bis, + big->num_bis); } big_disconnect(big, evt->status ? evt->status : BT_HCI_ERR_UNSPECIFIED); cleanup_big(big); @@ -2464,13 +2452,13 @@ void hci_le_big_terminate(struct net_buf *buf) struct bt_iso_big *big; if (evt->big_handle >= ARRAY_SIZE(bigs)) { - BT_WARN("Invalid BIG handle"); + LOG_WRN("Invalid BIG handle"); return; } big = lookup_big_by_handle(evt->big_handle); - BT_DBG("BIG[%u] %p terminated", big->handle, big); + LOG_DBG("BIG[%u] %p terminated", big->handle, big); big_disconnect(big, evt->reason); cleanup_big(big); @@ -2530,7 +2518,7 @@ int bt_iso_big_terminate(struct bt_iso_big *big) int err; if (!atomic_test_bit(big->flags, BT_BIG_INITIALIZED) || !big->num_bis) { - BT_DBG("BIG not initialized"); + LOG_DBG("BIG not initialized"); return -EINVAL; } @@ -2562,7 +2550,7 @@ int bt_iso_big_terminate(struct bt_iso_big *big) } if (err) { - BT_DBG("Could not terminate BIG %d", err); + LOG_DBG("Could not terminate BIG %d", err); } return err; @@ -2596,7 +2584,7 @@ void hci_le_big_sync_established(struct net_buf *buf) int i; if (evt->big_handle >= ARRAY_SIZE(bigs)) { - BT_WARN("Invalid BIG handle"); + LOG_WRN("Invalid BIG handle"); big = big_lookup_flag(BT_BIG_SYNCING); if (big) { big_disconnect(big, evt->status ? evt->status : BT_HCI_ERR_UNSPECIFIED); @@ -2609,12 +2597,12 @@ void hci_le_big_sync_established(struct net_buf *buf) big = lookup_big_by_handle(evt->big_handle); atomic_clear_bit(big->flags, BT_BIG_SYNCING); - BT_DBG("BIG[%u] %p sync established, status %u", big->handle, big, evt->status); + LOG_DBG("BIG[%u] %p sync established, status %u", big->handle, big, evt->status); if (evt->status || evt->num_bis != big->num_bis) { if (evt->status == BT_HCI_ERR_SUCCESS && evt->num_bis != big->num_bis) { - BT_ERR("Invalid number of BIS synced, was %u expected %u", - evt->num_bis, big->num_bis); + LOG_ERR("Invalid number of BIS synced, was %u expected %u", evt->num_bis, + big->num_bis); } big_disconnect(big, evt->status ? evt->status : BT_HCI_ERR_UNSPECIFIED); cleanup_big(big); @@ -2638,13 +2626,13 @@ void hci_le_big_sync_lost(struct net_buf *buf) struct bt_iso_big *big; if (evt->big_handle >= ARRAY_SIZE(bigs)) { - BT_WARN("Invalid BIG handle"); + LOG_WRN("Invalid BIG handle"); return; } big = lookup_big_by_handle(evt->big_handle); - BT_DBG("BIG[%u] %p sync lost", big->handle, big); + LOG_DBG("BIG[%u] %p sync lost", big->handle, big); big_disconnect(big, evt->reason); cleanup_big(big); @@ -2680,7 +2668,7 @@ static int hci_le_big_create_sync(const struct bt_le_per_adv_sync *sync, struct for (int i = 1; i <= BT_ISO_MAX_GROUP_ISO_COUNT; i++) { if (param->bis_bitfield & BIT(i)) { if (bit_idx == big->num_bis) { - BT_DBG("BIG cannot contain %u BISes", bit_idx + 1); + LOG_DBG("BIG cannot contain %u BISes", bit_idx + 1); return -EINVAL; } req->bis[bit_idx++] = i; @@ -2688,8 +2676,8 @@ static int hci_le_big_create_sync(const struct bt_le_per_adv_sync *sync, struct } if (bit_idx != big->num_bis) { - BT_DBG("Number of bits in bis_bitfield (%u) doesn't match num_bis (%u)", - bit_idx, big->num_bis); + LOG_DBG("Number of bits in bis_bitfield (%u) doesn't match num_bis (%u)", bit_idx, + big->num_bis); return -EINVAL; } @@ -2707,33 +2695,33 @@ int bt_iso_big_sync(struct bt_le_per_adv_sync *sync, struct bt_iso_big_sync_para struct bt_iso_big *big; if (!atomic_test_bit(sync->flags, BT_PER_ADV_SYNC_SYNCED)) { - BT_DBG("PA sync not synced"); + LOG_DBG("PA sync not synced"); return -EINVAL; } CHECKIF(param->mse > BT_ISO_SYNC_MSE_MAX) { - BT_DBG("Invalid MSE 0x%02x", param->mse); + LOG_DBG("Invalid MSE 0x%02x", param->mse); return -EINVAL; } CHECKIF(param->sync_timeout < BT_ISO_SYNC_TIMEOUT_MIN || param->sync_timeout > BT_ISO_SYNC_TIMEOUT_MAX) { - BT_DBG("Invalid sync timeout 0x%04x", param->sync_timeout); + LOG_DBG("Invalid sync timeout 0x%04x", param->sync_timeout); return -EINVAL; } CHECKIF(param->bis_bitfield <= BIT(0)) { - BT_DBG("Invalid BIS bitfield 0x%08x", param->bis_bitfield); + LOG_DBG("Invalid BIS bitfield 0x%08x", param->bis_bitfield); return -EINVAL; } CHECKIF(!param->bis_channels) { - BT_DBG("NULL BIS channels"); + LOG_DBG("NULL BIS channels"); return -EINVAL; } CHECKIF(!param->num_bis) { - BT_DBG("Invalid number of BIS %u", param->num_bis); + LOG_DBG("Invalid number of BIS %u", param->num_bis); return -EINVAL; } @@ -2741,22 +2729,22 @@ int bt_iso_big_sync(struct bt_le_per_adv_sync *sync, struct bt_iso_big_sync_para struct bt_iso_chan *bis = param->bis_channels[i]; CHECKIF(bis == NULL) { - BT_DBG("bis_channels[%u]: NULL channel", i); + LOG_DBG("bis_channels[%u]: NULL channel", i); return -EINVAL; } if (bis->iso) { - BT_DBG("bis_channels[%u]: already allocated", i); + LOG_DBG("bis_channels[%u]: already allocated", i); return -EALREADY; } CHECKIF(bis->qos == NULL) { - BT_DBG("bis_channels[%u]: qos is NULL", i); + LOG_DBG("bis_channels[%u]: qos is NULL", i); return -EINVAL; } CHECKIF(bis->qos->rx == NULL) { - BT_DBG("bis_channels[%u]: qos->rx is NULL", i); + LOG_DBG("bis_channels[%u]: qos->rx is NULL", i); return -EINVAL; } } @@ -2769,7 +2757,7 @@ int bt_iso_big_sync(struct bt_le_per_adv_sync *sync, struct bt_iso_big_sync_para err = big_init_bis(big, param->bis_channels, param->num_bis, false); if (err) { - BT_DBG("Could not init BIG %d", err); + LOG_DBG("Could not init BIG %d", err); cleanup_big(big); return err; } @@ -2777,7 +2765,7 @@ int bt_iso_big_sync(struct bt_le_per_adv_sync *sync, struct bt_iso_big_sync_para err = hci_le_big_create_sync(sync, big, param); if (err) { - BT_DBG("Could not create BIG sync %d", err); + LOG_DBG("Could not create BIG sync %d", err); cleanup_big(big); return err; } diff --git a/subsys/bluetooth/host/iso_internal.h b/subsys/bluetooth/host/iso_internal.h index 604c4f5ebfd..5c20fe6acd0 100644 --- a/subsys/bluetooth/host/iso_internal.h +++ b/subsys/bluetooth/host/iso_internal.h @@ -150,7 +150,7 @@ struct net_buf *bt_iso_create_frag_timeout(size_t reserve, k_timeout_t timeout); bt_iso_create_frag_timeout(_reserve, K_FOREVER) #endif -#if defined(CONFIG_BT_DEBUG_ISO) +#if defined(CONFIG_BT_ISO_LOG_LEVEL_DBG) void bt_iso_chan_set_state_debug(struct bt_iso_chan *chan, enum bt_iso_state state, const char *func, int line); @@ -158,7 +158,7 @@ void bt_iso_chan_set_state_debug(struct bt_iso_chan *chan, bt_iso_chan_set_state_debug(_chan, _state, __func__, __LINE__) #else void bt_iso_chan_set_state(struct bt_iso_chan *chan, enum bt_iso_state state); -#endif /* CONFIG_BT_DEBUG_ISO */ +#endif /* CONFIG_BT_ISO_LOG_LEVEL_DBG */ /* Process incoming data for a connection */ void bt_iso_recv(struct bt_conn *iso, struct net_buf *buf, uint8_t flags); diff --git a/subsys/bluetooth/host/keys.c b/subsys/bluetooth/host/keys.c index 7a718f566de..65170c4f03c 100644 --- a/subsys/bluetooth/host/keys.c +++ b/subsys/bluetooth/host/keys.c @@ -20,9 +20,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_KEYS) -#define LOG_MODULE_NAME bt_keys -#include "common/log.h" #include "common/bt_str.h" #include "common/rpa.h" @@ -33,6 +30,10 @@ #include "settings.h" #include "keys.h" +#define LOG_LEVEL CONFIG_BT_KEYS_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_keys); + static struct bt_keys key_pool[CONFIG_BT_MAX_PAIRED]; #define BT_KEYS_STORAGE_LEN_COMPAT (BT_KEYS_STORAGE_LEN - sizeof(uint32_t)) @@ -63,8 +64,8 @@ static void find_key_in_use(struct bt_conn *conn, void *data) /* Ensure that the reference returned matches the current pool item */ if (key == &key_pool[kdata->id]) { kdata->in_use = true; - BT_DBG("Connected device %s is using key_pool[%d]", - bt_addr_le_str(bt_conn_get_dst(conn)), kdata->id); + LOG_DBG("Connected device %s is using key_pool[%d]", + bt_addr_le_str(bt_conn_get_dst(conn)), kdata->id); } } } @@ -87,7 +88,7 @@ struct bt_keys *bt_keys_get_addr(uint8_t id, const bt_addr_le_t *addr) __ASSERT_NO_MSG(addr != NULL); - BT_DBG("%s", bt_addr_le_str(addr)); + LOG_DBG("%s", bt_addr_le_str(addr)); for (i = 0; i < ARRAY_SIZE(key_pool); i++) { keys = &key_pool[i]; @@ -120,7 +121,7 @@ struct bt_keys *bt_keys_get_addr(uint8_t id, const bt_addr_le_t *addr) } if (oldest == NULL) { - BT_DBG("unable to create keys for %s", bt_addr_le_str(addr)); + LOG_DBG("unable to create keys for %s", bt_addr_le_str(addr)); return NULL; } @@ -141,11 +142,11 @@ struct bt_keys *bt_keys_get_addr(uint8_t id, const bt_addr_le_t *addr) keys->aging_counter = ++aging_counter_val; last_keys_updated = keys; #endif /* CONFIG_BT_KEYS_OVERWRITE_OLDEST */ - BT_DBG("created %p for %s", keys, bt_addr_le_str(addr)); + LOG_DBG("created %p for %s", keys, bt_addr_le_str(addr)); return keys; } - BT_DBG("unable to create keys for %s", bt_addr_le_str(addr)); + LOG_DBG("unable to create keys for %s", bt_addr_le_str(addr)); return NULL; } @@ -190,7 +191,7 @@ struct bt_keys *bt_keys_find(enum bt_keys_type type, uint8_t id, const bt_addr_l __ASSERT_NO_MSG(addr != NULL); - BT_DBG("type %d %s", type, bt_addr_le_str(addr)); + LOG_DBG("type %d %s", type, bt_addr_le_str(addr)); for (i = 0; i < ARRAY_SIZE(key_pool); i++) { if ((key_pool[i].keys & type) && key_pool[i].id == id && @@ -208,7 +209,7 @@ struct bt_keys *bt_keys_get_type(enum bt_keys_type type, uint8_t id, const bt_ad __ASSERT_NO_MSG(addr != NULL); - BT_DBG("type %d %s", type, bt_addr_le_str(addr)); + LOG_DBG("type %d %s", type, bt_addr_le_str(addr)); keys = bt_keys_find(type, id, addr); if (keys) { @@ -231,7 +232,7 @@ struct bt_keys *bt_keys_find_irk(uint8_t id, const bt_addr_le_t *addr) __ASSERT_NO_MSG(addr != NULL); - BT_DBG("%s", bt_addr_le_str(addr)); + LOG_DBG("%s", bt_addr_le_str(addr)); if (!bt_addr_le_is_rpa(addr)) { return NULL; @@ -244,9 +245,8 @@ struct bt_keys *bt_keys_find_irk(uint8_t id, const bt_addr_le_t *addr) if (key_pool[i].id == id && !bt_addr_cmp(&addr->a, &key_pool[i].irk.rpa)) { - BT_DBG("cached RPA %s for %s", - bt_addr_str(&key_pool[i].irk.rpa), - bt_addr_le_str(&key_pool[i].addr)); + LOG_DBG("cached RPA %s for %s", bt_addr_str(&key_pool[i].irk.rpa), + bt_addr_le_str(&key_pool[i].addr)); return &key_pool[i]; } } @@ -261,9 +261,8 @@ struct bt_keys *bt_keys_find_irk(uint8_t id, const bt_addr_le_t *addr) } if (bt_rpa_irk_matches(key_pool[i].irk.val, &addr->a)) { - BT_DBG("RPA %s matches %s", - bt_addr_str(&key_pool[i].irk.rpa), - bt_addr_le_str(&key_pool[i].addr)); + LOG_DBG("RPA %s matches %s", bt_addr_str(&key_pool[i].irk.rpa), + bt_addr_le_str(&key_pool[i].addr)); bt_addr_copy(&key_pool[i].irk.rpa, &addr->a); @@ -271,7 +270,7 @@ struct bt_keys *bt_keys_find_irk(uint8_t id, const bt_addr_le_t *addr) } } - BT_DBG("No IRK for %s", bt_addr_le_str(addr)); + LOG_DBG("No IRK for %s", bt_addr_le_str(addr)); return NULL; } @@ -282,7 +281,7 @@ struct bt_keys *bt_keys_find_addr(uint8_t id, const bt_addr_le_t *addr) __ASSERT_NO_MSG(addr != NULL); - BT_DBG("%s", bt_addr_le_str(addr)); + LOG_DBG("%s", bt_addr_le_str(addr)); for (i = 0; i < ARRAY_SIZE(key_pool); i++) { if (key_pool[i].id == id && @@ -305,7 +304,7 @@ void bt_keys_clear(struct bt_keys *keys) { __ASSERT_NO_MSG(keys != NULL); - BT_DBG("%s (keys 0x%04x)", bt_addr_le_str(&keys->addr), keys->keys); + LOG_DBG("%s (keys 0x%04x)", bt_addr_le_str(&keys->addr), keys->keys); if (keys->state & BT_KEYS_ID_ADDED) { bt_id_del(keys); @@ -326,7 +325,7 @@ void bt_keys_clear(struct bt_keys *keys) &keys->addr, NULL); } - BT_DBG("Deleting key %s", key); + LOG_DBG("Deleting key %s", key); settings_delete(key); } @@ -354,12 +353,11 @@ int bt_keys_store(struct bt_keys *keys) err = settings_save_one(key, keys->storage_start, BT_KEYS_STORAGE_LEN); if (err) { - BT_ERR("Failed to save keys (err %d)", err); + LOG_ERR("Failed to save keys (err %d)", err); return err; } - BT_DBG("Stored keys for %s (%s)", bt_addr_le_str(&keys->addr), - key); + LOG_DBG("Stored keys for %s (%s)", bt_addr_le_str(&keys->addr), key); return 0; } @@ -376,22 +374,21 @@ static int keys_set(const char *name, size_t len_rd, settings_read_cb read_cb, const char *next; if (!name) { - BT_ERR("Insufficient number of arguments"); + LOG_ERR("Insufficient number of arguments"); return -EINVAL; } len = read_cb(cb_arg, val, sizeof(val)); if (len < 0) { - BT_ERR("Failed to read value (err %zd)", len); + LOG_ERR("Failed to read value (err %zd)", len); return -EINVAL; } - BT_DBG("name %s val %s", name, - (len) ? bt_hex(val, sizeof(val)) : "(null)"); + LOG_DBG("name %s val %s", name, (len) ? bt_hex(val, sizeof(val)) : "(null)"); err = bt_settings_decode_key(name, &addr); if (err) { - BT_ERR("Unable to decode address %s", name); + LOG_ERR("Unable to decode address %s", name); return -EINVAL; } @@ -403,7 +400,7 @@ static int keys_set(const char *name, size_t len_rd, settings_read_cb read_cb, unsigned long next_id = strtoul(next, NULL, 10); if (next_id >= CONFIG_BT_ID_MAX) { - BT_ERR("Invalid local identity %lu", next_id); + LOG_ERR("Invalid local identity %lu", next_id); return -EINVAL; } @@ -414,10 +411,9 @@ static int keys_set(const char *name, size_t len_rd, settings_read_cb read_cb, keys = bt_keys_find(BT_KEYS_ALL, id, &addr); if (keys) { (void)memset(keys, 0, sizeof(*keys)); - BT_DBG("Cleared keys for %s", bt_addr_le_str(&addr)); + LOG_DBG("Cleared keys for %s", bt_addr_le_str(&addr)); } else { - BT_WARN("Unable to find deleted keys for %s", - bt_addr_le_str(&addr)); + LOG_WRN("Unable to find deleted keys for %s", bt_addr_le_str(&addr)); } return 0; @@ -425,7 +421,7 @@ static int keys_set(const char *name, size_t len_rd, settings_read_cb read_cb, keys = bt_keys_get_addr(id, &addr); if (!keys) { - BT_ERR("Failed to allocate keys for %s", bt_addr_le_str(&addr)); + LOG_ERR("Failed to allocate keys for %s", bt_addr_le_str(&addr)); return -ENOMEM; } if (len != BT_KEYS_STORAGE_LEN) { @@ -434,12 +430,10 @@ static int keys_set(const char *name, size_t len_rd, settings_read_cb read_cb, /* Load shorter structure for compatibility with old * records format with no counter. */ - BT_WARN("Keys for %s have no aging counter", - bt_addr_le_str(&addr)); + LOG_WRN("Keys for %s have no aging counter", bt_addr_le_str(&addr)); memcpy(keys->storage_start, val, len); } else { - BT_ERR("Invalid key length %zd != %zu", len, - BT_KEYS_STORAGE_LEN); + LOG_ERR("Invalid key length %zd != %zu", len, BT_KEYS_STORAGE_LEN); bt_keys_clear(keys); return -EINVAL; @@ -448,7 +442,7 @@ static int keys_set(const char *name, size_t len_rd, settings_read_cb read_cb, memcpy(keys->storage_start, val, len); } - BT_DBG("Successfully restored keys for %s", bt_addr_le_str(&addr)); + LOG_DBG("Successfully restored keys for %s", bt_addr_le_str(&addr)); #if IS_ENABLED(CONFIG_BT_KEYS_OVERWRITE_OLDEST) if (aging_counter_val < keys->aging_counter) { aging_counter_val = keys->aging_counter; @@ -502,8 +496,7 @@ void bt_keys_update_usage(uint8_t id, const bt_addr_le_t *addr) keys->aging_counter = ++aging_counter_val; last_keys_updated = keys; - BT_DBG("Aging counter for %s is set to %u", bt_addr_le_str(addr), - keys->aging_counter); + LOG_DBG("Aging counter for %s is set to %u", bt_addr_le_str(addr), keys->aging_counter); if (IS_ENABLED(CONFIG_BT_KEYS_SAVE_AGING_COUNTER_ON_PAIRING)) { bt_keys_store(keys); @@ -521,21 +514,19 @@ void bt_keys_show_sniffer_info(struct bt_keys *keys, void *data) if (keys->keys & BT_KEYS_LTK_P256) { sys_memcpy_swap(ltk, keys->ltk.val, keys->enc_size); - BT_INFO("SC LTK: 0x%s", bt_hex(ltk, keys->enc_size)); + LOG_INF("SC LTK: 0x%s", bt_hex(ltk, keys->enc_size)); } #if !defined(CONFIG_BT_SMP_SC_PAIR_ONLY) if (keys->keys & BT_KEYS_PERIPH_LTK) { sys_memcpy_swap(ltk, keys->periph_ltk.val, keys->enc_size); - BT_INFO("Legacy LTK: 0x%s (peripheral)", - bt_hex(ltk, keys->enc_size)); + LOG_INF("Legacy LTK: 0x%s (peripheral)", bt_hex(ltk, keys->enc_size)); } #endif /* !CONFIG_BT_SMP_SC_PAIR_ONLY */ if (keys->keys & BT_KEYS_LTK) { sys_memcpy_swap(ltk, keys->ltk.val, keys->enc_size); - BT_INFO("Legacy LTK: 0x%s (central)", - bt_hex(ltk, keys->enc_size)); + LOG_INF("Legacy LTK: 0x%s (central)", bt_hex(ltk, keys->enc_size)); } } #endif /* defined(CONFIG_BT_LOG_SNIFFER_INFO) */ diff --git a/subsys/bluetooth/host/keys_br.c b/subsys/bluetooth/host/keys_br.c index c7d736f476c..b08fde96a6d 100644 --- a/subsys/bluetooth/host/keys_br.c +++ b/subsys/bluetooth/host/keys_br.c @@ -16,15 +16,16 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_KEYS) -#define LOG_MODULE_NAME bt_keys_br -#include "common/log.h" #include "common/bt_str.h" #include "hci_core.h" #include "settings.h" #include "keys.h" +#define LOG_LEVEL CONFIG_BT_KEYS_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_keys_br); + static struct bt_keys_link_key key_pool[CONFIG_BT_MAX_PAIRED]; #if IS_ENABLED(CONFIG_BT_KEYS_OVERWRITE_OLDEST) @@ -37,7 +38,7 @@ struct bt_keys_link_key *bt_keys_find_link_key(const bt_addr_t *addr) struct bt_keys_link_key *key; int i; - BT_DBG("%s", bt_addr_str(addr)); + LOG_DBG("%s", bt_addr_str(addr)); for (i = 0; i < ARRAY_SIZE(key_pool); i++) { key = &key_pool[i]; @@ -85,11 +86,11 @@ struct bt_keys_link_key *bt_keys_get_link_key(const bt_addr_t *addr) key->aging_counter = ++aging_counter_val; last_keys_updated = key; #endif - BT_DBG("created %p for %s", key, bt_addr_str(addr)); + LOG_DBG("created %p for %s", key, bt_addr_str(addr)); return key; } - BT_DBG("unable to create keys for %s", bt_addr_str(addr)); + LOG_DBG("unable to create keys for %s", bt_addr_str(addr)); return NULL; } @@ -107,7 +108,7 @@ void bt_keys_link_key_clear(struct bt_keys_link_key *link_key) settings_delete(key); } - BT_DBG("%s", bt_addr_str(&link_key->addr)); + LOG_DBG("%s", bt_addr_str(&link_key->addr)); (void)memset(link_key, 0, sizeof(*link_key)); } @@ -145,7 +146,7 @@ void bt_keys_link_key_store(struct bt_keys_link_key *link_key) err = settings_save_one(key, link_key->storage_start, BT_KEYS_LINK_KEY_STORAGE_LEN); if (err) { - BT_ERR("Failed to save link key (err %d)", err); + LOG_ERR("Failed to save link key (err %d)", err); } } } @@ -162,22 +163,21 @@ static int link_key_set(const char *name, size_t len_rd, char val[BT_KEYS_LINK_KEY_STORAGE_LEN]; if (!name) { - BT_ERR("Insufficient number of arguments"); + LOG_ERR("Insufficient number of arguments"); return -EINVAL; } len = read_cb(cb_arg, val, sizeof(val)); if (len < 0) { - BT_ERR("Failed to read value (err %zu)", len); + LOG_ERR("Failed to read value (err %zu)", len); return -EINVAL; } - BT_DBG("name %s val %s", name, - len ? bt_hex(val, sizeof(val)) : "(null)"); + LOG_DBG("name %s val %s", name, len ? bt_hex(val, sizeof(val)) : "(null)"); err = bt_settings_decode_key(name, &le_addr); if (err) { - BT_ERR("Unable to decode address %s", name); + LOG_ERR("Unable to decode address %s", name); return -EINVAL; } @@ -185,18 +185,16 @@ static int link_key_set(const char *name, size_t len_rd, if (len != BT_KEYS_LINK_KEY_STORAGE_LEN) { if (link_key) { bt_keys_link_key_clear(link_key); - BT_DBG("Clear keys for %s", bt_addr_le_str(&le_addr)); + LOG_DBG("Clear keys for %s", bt_addr_le_str(&le_addr)); } else { - BT_WARN("Unable to find deleted keys for %s", - bt_addr_le_str(&le_addr)); + LOG_WRN("Unable to find deleted keys for %s", bt_addr_le_str(&le_addr)); } return 0; } memcpy(link_key->storage_start, val, len); - BT_DBG("Successfully restored link key for %s", - bt_addr_le_str(&le_addr)); + LOG_DBG("Successfully restored link key for %s", bt_addr_le_str(&le_addr)); #if IS_ENABLED(CONFIG_BT_KEYS_OVERWRITE_OLDEST) if (aging_counter_val < link_key->aging_counter) { aging_counter_val = link_key->aging_counter; @@ -225,8 +223,7 @@ void bt_keys_link_key_update_usage(const bt_addr_t *addr) link_key->aging_counter = ++aging_counter_val; last_keys_updated = link_key; - BT_DBG("Aging counter for %s is set to %u", bt_addr_str(addr), - link_key->aging_counter); + LOG_DBG("Aging counter for %s is set to %u", bt_addr_str(addr), link_key->aging_counter); if (IS_ENABLED(CONFIG_BT_KEYS_SAVE_AGING_COUNTER_ON_PAIRING)) { bt_keys_link_key_store(link_key); diff --git a/subsys/bluetooth/host/l2cap.c b/subsys/bluetooth/host/l2cap.c index a14f3b5dc76..a9124a24162 100644 --- a/subsys/bluetooth/host/l2cap.c +++ b/subsys/bluetooth/host/l2cap.c @@ -19,15 +19,16 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_L2CAP) -#define LOG_MODULE_NAME bt_l2cap -#include "common/log.h" +#define LOG_DBG_ENABLED IS_ENABLED(CONFIG_BT_L2CAP_LOG_LEVEL_DBG) #include "hci_core.h" #include "conn_internal.h" #include "l2cap_internal.h" #include "keys.h" +#include +LOG_MODULE_REGISTER(bt_l2cap, CONFIG_BT_L2CAP_LOG_LEVEL); + #define LE_CHAN_RTX(_w) CONTAINER_OF(_w, struct bt_l2cap_le_chan, rtx_work) #define CHAN_RX(_w) CONTAINER_OF(_w, struct bt_l2cap_le_chan, rx_work) @@ -204,16 +205,15 @@ const char *bt_l2cap_chan_state_str(bt_l2cap_chan_state_t state) } #if defined(CONFIG_BT_L2CAP_DYNAMIC_CHANNEL) -#if defined(CONFIG_BT_DEBUG_L2CAP) +#if defined(CONFIG_BT_L2CAP_LOG_LEVEL_DBG) void bt_l2cap_chan_set_state_debug(struct bt_l2cap_chan *chan, bt_l2cap_chan_state_t state, const char *func, int line) { struct bt_l2cap_le_chan *le_chan = BT_L2CAP_LE_CHAN(chan); - BT_DBG("chan %p psm 0x%04x %s -> %s", chan, le_chan->psm, - bt_l2cap_chan_state_str(le_chan->state), - bt_l2cap_chan_state_str(state)); + LOG_DBG("chan %p psm 0x%04x %s -> %s", chan, le_chan->psm, + bt_l2cap_chan_state_str(le_chan->state), bt_l2cap_chan_state_str(state)); /* check transitions validness */ switch (state) { @@ -222,28 +222,28 @@ void bt_l2cap_chan_set_state_debug(struct bt_l2cap_chan *chan, break; case BT_L2CAP_CONNECTING: if (le_chan->state != BT_L2CAP_DISCONNECTED) { - BT_WARN("%s()%d: invalid transition", func, line); + LOG_WRN("%s()%d: invalid transition", func, line); } break; case BT_L2CAP_CONFIG: if (le_chan->state != BT_L2CAP_CONNECTING) { - BT_WARN("%s()%d: invalid transition", func, line); + LOG_WRN("%s()%d: invalid transition", func, line); } break; case BT_L2CAP_CONNECTED: if (le_chan->state != BT_L2CAP_CONFIG && le_chan->state != BT_L2CAP_CONNECTING) { - BT_WARN("%s()%d: invalid transition", func, line); + LOG_WRN("%s()%d: invalid transition", func, line); } break; case BT_L2CAP_DISCONNECTING: if (le_chan->state != BT_L2CAP_CONFIG && le_chan->state != BT_L2CAP_CONNECTED) { - BT_WARN("%s()%d: invalid transition", func, line); + LOG_WRN("%s()%d: invalid transition", func, line); } break; default: - BT_ERR("%s()%d: unknown (%u) state was set", func, line, state); + LOG_ERR("%s()%d: unknown (%u) state was set", func, line, state); return; } @@ -255,14 +255,14 @@ void bt_l2cap_chan_set_state(struct bt_l2cap_chan *chan, { BT_L2CAP_LE_CHAN(chan)->state = state; } -#endif /* CONFIG_BT_DEBUG_L2CAP */ +#endif /* CONFIG_BT_L2CAP_LOG_LEVEL_DBG */ #endif /* CONFIG_BT_L2CAP_DYNAMIC_CHANNEL */ void bt_l2cap_chan_del(struct bt_l2cap_chan *chan) { const struct bt_l2cap_chan_ops *ops = chan->ops; - BT_DBG("conn %p chan %p", chan->conn, chan); + LOG_DBG("conn %p chan %p", chan->conn, chan); if (!chan->conn) { goto destroy; @@ -295,7 +295,7 @@ static void l2cap_rtx_timeout(struct k_work *work) struct bt_l2cap_le_chan *chan = LE_CHAN_RTX(work); struct bt_conn *conn = chan->chan.conn; - BT_ERR("chan %p timeout", chan); + LOG_ERR("chan %p timeout", chan); bt_l2cap_chan_remove(conn, &chan->chan); bt_l2cap_chan_del(&chan->chan); @@ -315,7 +315,7 @@ static void l2cap_rx_process(struct k_work *work) struct net_buf *buf; while ((buf = net_buf_get(&ch->rx_queue, K_NO_WAIT))) { - BT_DBG("ch %p buf %p", ch, buf); + LOG_DBG("ch %p buf %p", ch, buf); l2cap_chan_le_recv(ch, buf); net_buf_unref(buf); } @@ -330,7 +330,7 @@ void bt_l2cap_chan_add(struct bt_conn *conn, struct bt_l2cap_chan *chan, chan->conn = conn; chan->destroy = destroy; - BT_DBG("conn %p chan %p", conn, chan); + LOG_DBG("conn %p chan %p", conn, chan); } static bool l2cap_chan_add(struct bt_conn *conn, struct bt_l2cap_chan *chan, @@ -345,7 +345,7 @@ static bool l2cap_chan_add(struct bt_conn *conn, struct bt_l2cap_chan *chan, #endif if (!le_chan) { - BT_ERR("Unable to allocate L2CAP channel ID"); + LOG_ERR("Unable to allocate L2CAP channel ID"); return false; } @@ -441,7 +441,7 @@ static struct net_buf *l2cap_create_le_sig_pdu(struct net_buf *buf, /* If it was not possible to allocate a buffer within the * timeout return NULL. */ - BT_ERR("Unable to allocate buffer for op 0x%02x", code); + LOG_ERR("Unable to allocate buffer for op 0x%02x", code); return NULL; } @@ -644,7 +644,7 @@ int bt_l2cap_send_cb(struct bt_conn *conn, uint16_t cid, struct net_buf *buf, { struct bt_l2cap_hdr *hdr; - BT_DBG("conn %p cid %u len %zu", conn, cid, net_buf_frags_len(buf)); + LOG_DBG("conn %p cid %u len %zu", conn, cid, net_buf_frags_len(buf)); hdr = net_buf_push(buf, sizeof(*hdr)); hdr->len = sys_cpu_to_le16(buf->len - sizeof(*hdr)); @@ -680,11 +680,11 @@ static void le_conn_param_rsp(struct bt_l2cap *l2cap, struct net_buf *buf) struct bt_l2cap_conn_param_rsp *rsp = (void *)buf->data; if (buf->len < sizeof(*rsp)) { - BT_ERR("Too small LE conn param rsp"); + LOG_ERR("Too small LE conn param rsp"); return; } - BT_DBG("LE conn param rsp result %u", sys_le16_to_cpu(rsp->result)); + LOG_DBG("LE conn param rsp result %u", sys_le16_to_cpu(rsp->result)); } static void le_conn_param_update_req(struct bt_l2cap *l2cap, uint8_t ident, @@ -697,12 +697,12 @@ static void le_conn_param_update_req(struct bt_l2cap *l2cap, uint8_t ident, bool accepted; if (buf->len < sizeof(*req)) { - BT_ERR("Too small LE conn update param req"); + LOG_ERR("Too small LE conn update param req"); return; } if (conn->state != BT_CONN_CONNECTED) { - BT_WARN("Not connected"); + LOG_WRN("Not connected"); return; } @@ -717,9 +717,8 @@ static void le_conn_param_update_req(struct bt_l2cap *l2cap, uint8_t ident, param.latency = sys_le16_to_cpu(req->latency); param.timeout = sys_le16_to_cpu(req->timeout); - BT_DBG("min 0x%04x max 0x%04x latency: 0x%04x timeout: 0x%04x", - param.interval_min, param.interval_max, param.latency, - param.timeout); + LOG_DBG("min 0x%04x max 0x%04x latency: 0x%04x timeout: 0x%04x", param.interval_min, + param.interval_max, param.latency, param.timeout); buf = l2cap_create_le_sig_pdu(buf, BT_L2CAP_CONN_PARAM_RSP, ident, sizeof(*rsp)); @@ -799,7 +798,7 @@ int bt_l2cap_server_register(struct bt_l2cap_server *server) /* Check if given PSM is already in use */ if (bt_l2cap_server_lookup_psm(server->psm)) { - BT_DBG("PSM already registered"); + LOG_DBG("PSM already registered"); return -EADDRINUSE; } } else { @@ -813,11 +812,11 @@ int bt_l2cap_server_register(struct bt_l2cap_server *server) } if (psm > L2CAP_LE_PSM_DYN_END) { - BT_WARN("No free dynamic PSMs available"); + LOG_WRN("No free dynamic PSMs available"); return -EADDRNOTAVAIL; } - BT_DBG("Allocated PSM 0x%04x for new server", psm); + LOG_DBG("Allocated PSM 0x%04x for new server", psm); server->psm = psm; } @@ -828,7 +827,7 @@ int bt_l2cap_server_register(struct bt_l2cap_server *server) server->sec_level = BT_SECURITY_L1; } - BT_DBG("PSM 0x%04x", server->psm); + LOG_DBG("PSM 0x%04x", server->psm); sys_slist_append(&servers, &server->node); @@ -837,7 +836,7 @@ int bt_l2cap_server_register(struct bt_l2cap_server *server) static void l2cap_chan_rx_init(struct bt_l2cap_le_chan *chan) { - BT_DBG("chan %p", chan); + LOG_DBG("chan %p", chan); /* Use existing MTU if defined */ if (!chan->rx.mtu) { @@ -858,7 +857,7 @@ static void l2cap_chan_rx_init(struct bt_l2cap_le_chan *chan) */ if (!chan->chan.ops->alloc_buf && (chan->rx.mps < chan->rx.mtu + BT_L2CAP_SDU_HDR_SIZE)) { - BT_WARN("Segmentation disabled but MTU > MPS, truncating MTU"); + LOG_WRN("Segmentation disabled but MTU > MPS, truncating MTU"); chan->rx.mtu = chan->rx.mps - BT_L2CAP_SDU_HDR_SIZE; } @@ -876,10 +875,10 @@ static void l2cap_chan_rx_init(struct bt_l2cap_le_chan *chan) atomic_set(&chan->rx.credits, 0); - if (BT_DBG_ENABLED && + if (LOG_DBG_ENABLED && chan->rx.init_credits * chan->rx.mps < chan->rx.mtu + BT_L2CAP_SDU_HDR_SIZE) { - BT_WARN("Not enough credits for a full packet"); + LOG_WRN("Not enough credits for a full packet"); } } @@ -911,7 +910,7 @@ static void l2cap_chan_tx_process(struct k_work *work) while ((buf = l2cap_chan_le_get_tx_buf(ch))) { int sent = l2cap_tx_meta_data(buf)->sent; - BT_DBG("buf %p sent %u", buf, sent); + LOG_DBG("buf %p sent %u", buf, sent); sent = l2cap_chan_le_send_sdu(ch, &buf, sent); if (sent < 0) { @@ -933,7 +932,7 @@ static void l2cap_chan_tx_process(struct k_work *work) static void l2cap_chan_tx_init(struct bt_l2cap_le_chan *chan) { - BT_DBG("chan %p", chan); + LOG_DBG("chan %p", chan); (void)memset(&chan->tx, 0, sizeof(chan->tx)); atomic_set(&chan->tx.credits, 0); @@ -944,7 +943,7 @@ static void l2cap_chan_tx_init(struct bt_l2cap_le_chan *chan) static void l2cap_chan_tx_give_credits(struct bt_l2cap_le_chan *chan, uint16_t credits) { - BT_DBG("chan %p credits %u", chan, credits); + LOG_DBG("chan %p credits %u", chan, credits); atomic_add(&chan->tx.credits, credits); @@ -957,7 +956,7 @@ static void l2cap_chan_tx_give_credits(struct bt_l2cap_le_chan *chan, static void l2cap_chan_rx_give_credits(struct bt_l2cap_le_chan *chan, uint16_t credits) { - BT_DBG("chan %p credits %u", chan, credits); + LOG_DBG("chan %p credits %u", chan, credits); atomic_add(&chan->rx.credits, credits); } @@ -967,7 +966,7 @@ static void l2cap_chan_destroy(struct bt_l2cap_chan *chan) struct bt_l2cap_le_chan *le_chan = BT_L2CAP_LE_CHAN(chan); struct net_buf *buf; - BT_DBG("chan %p cid 0x%04x", le_chan, le_chan->rx.cid); + LOG_DBG("chan %p cid 0x%04x", le_chan, le_chan->rx.cid); /* Cancel ongoing work. Since the channel can be re-used after this * we need to sync to make sure that the kernel does not have it @@ -1033,7 +1032,7 @@ static uint16_t l2cap_chan_accept(struct bt_conn *conn, struct bt_l2cap_le_chan *le_chan; int err; - BT_DBG("conn %p scid 0x%04x chan %p", conn, scid, chan); + LOG_DBG("conn %p scid 0x%04x chan %p", conn, scid, chan); if (!L2CAP_LE_CID_IS_DYN(scid)) { return BT_L2CAP_LE_ERR_INVALID_SCID; @@ -1053,7 +1052,7 @@ static uint16_t l2cap_chan_accept(struct bt_conn *conn, } if (!(*chan)->ops->recv) { - BT_ERR("Mandatory callback 'recv' missing"); + LOG_ERR("Mandatory callback 'recv' missing"); return BT_L2CAP_LE_ERR_UNACCEPT_PARAMS; } @@ -1143,7 +1142,7 @@ static void le_conn_req(struct bt_l2cap *l2cap, uint8_t ident, uint16_t result; if (buf->len < sizeof(*req)) { - BT_ERR("Too small LE conn req packet size"); + LOG_ERR("Too small LE conn req packet size"); return; } @@ -1153,11 +1152,10 @@ static void le_conn_req(struct bt_l2cap *l2cap, uint8_t ident, mps = sys_le16_to_cpu(req->mps); credits = sys_le16_to_cpu(req->credits); - BT_DBG("psm 0x%02x scid 0x%04x mtu %u mps %u credits %u", psm, scid, - mtu, mps, credits); + LOG_DBG("psm 0x%02x scid 0x%04x mtu %u mps %u credits %u", psm, scid, mtu, mps, credits); if (mtu < L2CAP_LE_MIN_MTU || mps < L2CAP_LE_MIN_MTU) { - BT_ERR("Invalid LE-Conn Req params"); + LOG_ERR("Invalid LE-Conn Req params"); return; } @@ -1223,7 +1221,7 @@ static void le_ecred_conn_req(struct bt_l2cap *l2cap, uint8_t ident, /* set dcid to zeros here, in case of all connections refused error */ memset(dcid, 0, sizeof(dcid)); if (buf->len < sizeof(*req)) { - BT_ERR("Too small LE conn req packet size"); + LOG_ERR("Too small LE conn req packet size"); result = BT_L2CAP_LE_ERR_INVALID_PARAMS; req_cid_count = 0; goto response; @@ -1233,7 +1231,7 @@ static void le_ecred_conn_req(struct bt_l2cap *l2cap, uint8_t ident, req_cid_count = buf->len / sizeof(scid); if (buf->len > sizeof(dcid)) { - BT_ERR("Too large LE conn req packet size"); + LOG_ERR("Too large LE conn req packet size"); req_cid_count = L2CAP_ECRED_CHAN_MAX_PER_REQ; result = BT_L2CAP_LE_ERR_INVALID_PARAMS; goto response; @@ -1244,10 +1242,10 @@ static void le_ecred_conn_req(struct bt_l2cap *l2cap, uint8_t ident, mps = sys_le16_to_cpu(req->mps); credits = sys_le16_to_cpu(req->credits); - BT_DBG("psm 0x%02x mtu %u mps %u credits %u", psm, mtu, mps, credits); + LOG_DBG("psm 0x%02x mtu %u mps %u credits %u", psm, mtu, mps, credits); if (mtu < L2CAP_ECRED_MIN_MTU || mps < L2CAP_ECRED_MIN_MTU) { - BT_ERR("Invalid ecred conn req params"); + LOG_ERR("Invalid ecred conn req params"); result = BT_L2CAP_LE_ERR_INVALID_PARAMS; goto response; } @@ -1333,7 +1331,7 @@ static void le_ecred_reconf_req(struct bt_l2cap *l2cap, uint8_t ident, bool mps_reduced = false; if (buf->len < sizeof(*req)) { - BT_ERR("Too small ecred reconf req packet size"); + LOG_ERR("Too small ecred reconf req packet size"); return; } @@ -1362,8 +1360,8 @@ static void le_ecred_reconf_req(struct bt_l2cap *l2cap, uint8_t ident, } if (BT_L2CAP_LE_CHAN(chan)->tx.mtu > mtu) { - BT_ERR("chan %p decreased MTU %u -> %u", chan, - BT_L2CAP_LE_CHAN(chan)->tx.mtu, mtu); + LOG_ERR("chan %p decreased MTU %u -> %u", chan, + BT_L2CAP_LE_CHAN(chan)->tx.mtu, mtu); result = BT_L2CAP_RECONF_INVALID_MTU; goto response; } @@ -1394,7 +1392,7 @@ static void le_ecred_reconf_req(struct bt_l2cap *l2cap, uint8_t ident, } } - BT_DBG("mtu %u mps %u", mtu, mps); + LOG_DBG("mtu %u mps %u", mtu, mps); response: buf = l2cap_create_le_sig_pdu(buf, BT_L2CAP_ECRED_RECONF_RSP, ident, @@ -1415,7 +1413,7 @@ static void le_ecred_reconf_rsp(struct bt_l2cap *l2cap, uint8_t ident, uint16_t result; if (buf->len < sizeof(*rsp)) { - BT_ERR("Too small ecred reconf rsp packet size"); + LOG_ERR("Too small ecred reconf rsp packet size"); return; } @@ -1476,13 +1474,13 @@ static void le_disconn_req(struct bt_l2cap *l2cap, uint8_t ident, uint16_t dcid; if (buf->len < sizeof(*req)) { - BT_ERR("Too small LE conn req packet size"); + LOG_ERR("Too small LE conn req packet size"); return; } dcid = sys_le16_to_cpu(req->dcid); - BT_DBG("dcid 0x%04x scid 0x%04x", dcid, sys_le16_to_cpu(req->scid)); + LOG_DBG("dcid 0x%04x scid 0x%04x", dcid, sys_le16_to_cpu(req->scid)); chan = l2cap_remove_rx_cid(conn, dcid); if (!chan) { @@ -1567,7 +1565,7 @@ static void le_ecred_conn_rsp(struct bt_l2cap *l2cap, uint8_t ident, uint8_t succeeded = 0; if (buf->len < sizeof(*rsp)) { - BT_ERR("Too small ecred conn rsp packet size"); + LOG_ERR("Too small ecred conn rsp packet size"); return; } @@ -1577,8 +1575,7 @@ static void le_ecred_conn_rsp(struct bt_l2cap *l2cap, uint8_t ident, credits = sys_le16_to_cpu(rsp->credits); result = sys_le16_to_cpu(rsp->result); - BT_DBG("mtu 0x%04x mps 0x%04x credits 0x%04x result %u", mtu, - mps, credits, result); + LOG_DBG("mtu 0x%04x mps 0x%04x credits 0x%04x result %u", mtu, mps, credits, result); chan = l2cap_lookup_ident(conn, ident); if (chan) { @@ -1617,7 +1614,7 @@ static void le_ecred_conn_rsp(struct bt_l2cap *l2cap, uint8_t ident, k_work_cancel_delayable(&chan->rtx_work); if (buf->len < sizeof(dcid)) { - BT_ERR("Fewer dcid values than expected"); + LOG_ERR("Fewer dcid values than expected"); bt_l2cap_chan_remove(conn, &chan->chan); bt_l2cap_chan_del(&chan->chan); continue; @@ -1626,7 +1623,7 @@ static void le_ecred_conn_rsp(struct bt_l2cap *l2cap, uint8_t ident, dcid = net_buf_pull_le16(buf); attempted++; - BT_DBG("dcid 0x%04x", dcid); + LOG_DBG("dcid 0x%04x", dcid); /* If a Destination CID is 0x0000, the channel was not * established. @@ -1697,7 +1694,7 @@ static void le_conn_rsp(struct bt_l2cap *l2cap, uint8_t ident, uint16_t dcid, mtu, mps, credits, result; if (buf->len < sizeof(*rsp)) { - BT_ERR("Too small LE conn rsp packet size"); + LOG_ERR("Too small LE conn rsp packet size"); return; } @@ -1707,8 +1704,8 @@ static void le_conn_rsp(struct bt_l2cap *l2cap, uint8_t ident, credits = sys_le16_to_cpu(rsp->credits); result = sys_le16_to_cpu(rsp->result); - BT_DBG("dcid 0x%04x mtu %u mps %u credits %u result 0x%04x", dcid, - mtu, mps, credits, result); + LOG_DBG("dcid 0x%04x mtu %u mps %u credits %u result 0x%04x", dcid, mtu, mps, credits, + result); /* Keep the channel in case of security errors */ if (result == BT_L2CAP_LE_SUCCESS || @@ -1720,7 +1717,7 @@ static void le_conn_rsp(struct bt_l2cap *l2cap, uint8_t ident, } if (!chan) { - BT_ERR("Cannot find channel for ident %u", ident); + LOG_ERR("Cannot find channel for ident %u", ident); return; } @@ -1770,13 +1767,13 @@ static void le_disconn_rsp(struct bt_l2cap *l2cap, uint8_t ident, uint16_t scid; if (buf->len < sizeof(*rsp)) { - BT_ERR("Too small LE disconn rsp packet size"); + LOG_ERR("Too small LE disconn rsp packet size"); return; } scid = sys_le16_to_cpu(rsp->scid); - BT_DBG("dcid 0x%04x scid 0x%04x", sys_le16_to_cpu(rsp->dcid), scid); + LOG_DBG("dcid 0x%04x scid 0x%04x", sys_le16_to_cpu(rsp->dcid), scid); chan = l2cap_remove_rx_cid(conn, scid); if (!chan) { @@ -1853,7 +1850,7 @@ segment: net_buf_add_mem(seg, buf->data, len); net_buf_pull(buf, len); - BT_DBG("ch %p seg %p len %u", ch, seg, seg->len); + LOG_DBG("ch %p seg %p len %u", ch, seg, seg->len); return seg; } @@ -1887,7 +1884,7 @@ static void l2cap_chan_sdu_sent(struct bt_conn *conn, void *user_data, int err) void *cb_user_data = data->user_data; uint16_t cid = data->cid; - BT_DBG("conn %p CID 0x%04x err %d", conn, cid, err); + LOG_DBG("conn %p CID 0x%04x err %d", conn, cid, err); free_tx_meta_data(data); @@ -1929,7 +1926,7 @@ static void l2cap_chan_seg_sent(struct bt_conn *conn, void *user_data, int err) struct l2cap_tx_meta_data *data = user_data; struct bt_l2cap_chan *chan; - BT_DBG("conn %p CID 0x%04x err %d", conn, data->cid, err); + LOG_DBG("conn %p CID 0x%04x err %d", conn, data->cid, err); if (err) { return; @@ -1978,7 +1975,7 @@ static int l2cap_chan_le_send(struct bt_l2cap_le_chan *ch, int len, err; if (!test_and_dec(&ch->tx.credits)) { - BT_WARN("No credits to transmit packet"); + LOG_WRN("No credits to transmit packet"); return -EAGAIN; } @@ -1991,8 +1988,8 @@ static int l2cap_chan_le_send(struct bt_l2cap_le_chan *ch, return -EAGAIN; } - BT_DBG("ch %p cid 0x%04x len %u credits %lu", ch, ch->tx.cid, - seg->len, atomic_get(&ch->tx.credits)); + LOG_DBG("ch %p cid 0x%04x len %u credits %lu", ch, ch->tx.cid, seg->len, + atomic_get(&ch->tx.credits)); len = seg->len - sdu_hdr_len; @@ -2008,7 +2005,7 @@ static int l2cap_chan_le_send(struct bt_l2cap_le_chan *ch, } if (err) { - BT_WARN("Unable to send seg %d", err); + LOG_WRN("Unable to send seg %d", err); atomic_inc(&ch->tx.credits); /* The host takes ownership of the reference in seg when @@ -2089,8 +2086,7 @@ static int l2cap_chan_le_send_sdu(struct bt_l2cap_le_chan *ch, } } - BT_DBG("ch %p cid 0x%04x sent %u total_len %u", ch, ch->tx.cid, sent, - total_len); + LOG_DBG("ch %p cid 0x%04x sent %u total_len %u", ch, ch->tx.cid, sent, total_len); net_buf_unref(frag); @@ -2107,33 +2103,32 @@ static void le_credits(struct bt_l2cap *l2cap, uint8_t ident, uint16_t credits, cid; if (buf->len < sizeof(*ev)) { - BT_ERR("Too small LE Credits packet size"); + LOG_ERR("Too small LE Credits packet size"); return; } cid = sys_le16_to_cpu(ev->cid); credits = sys_le16_to_cpu(ev->credits); - BT_DBG("cid 0x%04x credits %u", cid, credits); + LOG_DBG("cid 0x%04x credits %u", cid, credits); chan = bt_l2cap_le_lookup_tx_cid(conn, cid); if (!chan) { - BT_ERR("Unable to find channel of LE Credits packet"); + LOG_ERR("Unable to find channel of LE Credits packet"); return; } le_chan = BT_L2CAP_LE_CHAN(chan); if (atomic_get(&le_chan->tx.credits) + credits > UINT16_MAX) { - BT_ERR("Credits overflow"); + LOG_ERR("Credits overflow"); bt_l2cap_chan_disconnect(chan); return; } l2cap_chan_tx_give_credits(le_chan, credits); - BT_DBG("chan %p total credits %lu", - le_chan, atomic_get(&le_chan->tx.credits)); + LOG_DBG("chan %p total credits %lu", le_chan, atomic_get(&le_chan->tx.credits)); l2cap_chan_tx_resume(le_chan); } @@ -2161,23 +2156,22 @@ static int l2cap_recv(struct bt_l2cap_chan *chan, struct net_buf *buf) uint16_t len; if (buf->len < sizeof(*hdr)) { - BT_ERR("Too small L2CAP signaling PDU"); + LOG_ERR("Too small L2CAP signaling PDU"); return 0; } hdr = net_buf_pull_mem(buf, sizeof(*hdr)); len = sys_le16_to_cpu(hdr->len); - BT_DBG("Signaling code 0x%02x ident %u len %u", hdr->code, - hdr->ident, len); + LOG_DBG("Signaling code 0x%02x ident %u len %u", hdr->code, hdr->ident, len); if (buf->len != len) { - BT_ERR("L2CAP length mismatch (%u != %u)", buf->len, len); + LOG_ERR("L2CAP length mismatch (%u != %u)", buf->len, len); return 0; } if (!hdr->ident) { - BT_ERR("Invalid ident value in L2CAP PDU"); + LOG_ERR("Invalid ident value in L2CAP PDU"); return 0; } @@ -2230,7 +2224,7 @@ static int l2cap_recv(struct bt_l2cap_chan *chan, struct net_buf *buf) } __fallthrough; default: - BT_WARN("Rejecting unknown L2CAP PDU code 0x%02x", hdr->code); + LOG_WRN("Rejecting unknown L2CAP PDU code 0x%02x", hdr->code); l2cap_send_reject(chan->conn, hdr->ident, BT_L2CAP_REJ_NOT_UNDERSTOOD, NULL, 0); break; @@ -2245,7 +2239,7 @@ static void l2cap_chan_shutdown(struct bt_l2cap_chan *chan) struct bt_l2cap_le_chan *le_chan = BT_L2CAP_LE_CHAN(chan); struct net_buf *buf; - BT_DBG("chan %p", chan); + LOG_DBG("chan %p", chan); atomic_set_bit(chan->status, BT_L2CAP_STATUS_SHUTDOWN); @@ -2316,7 +2310,7 @@ static void l2cap_chan_send_credits(struct bt_l2cap_le_chan *chan, buf = l2cap_create_le_sig_pdu(buf, BT_L2CAP_LE_CREDITS, get_ident(), sizeof(*ev)); if (!buf) { - BT_ERR("Unable to send credits update"); + LOG_ERR("Unable to send credits update"); /* Disconnect would probably not work either so the only * option left is to shutdown the channel. */ @@ -2332,7 +2326,7 @@ static void l2cap_chan_send_credits(struct bt_l2cap_le_chan *chan, l2cap_send(chan->chan.conn, BT_L2CAP_CID_LE_SIG, buf); - BT_DBG("chan %p credits %lu", chan, atomic_get(&chan->rx.credits)); + LOG_DBG("chan %p credits %lu", chan, atomic_get(&chan->rx.credits)); } static void l2cap_chan_update_credits(struct bt_l2cap_le_chan *chan, @@ -2345,7 +2339,7 @@ static void l2cap_chan_update_credits(struct bt_l2cap_le_chan *chan, credits = ((chan->_sdu_len - net_buf_frags_len(buf)) + (chan->rx.mps - 1)) / chan->rx.mps; - BT_DBG("cred %d old %d", credits, (int)old_credits); + LOG_DBG("cred %d old %d", credits, (int)old_credits); if (credits < old_credits) { return; @@ -2372,7 +2366,7 @@ int bt_l2cap_chan_recv_complete(struct bt_l2cap_chan *chan, struct net_buf *buf) return -ENOTSUP; } - BT_DBG("chan %p buf %p", chan, buf); + LOG_DBG("chan %p buf %p", chan, buf); if (bt_l2cap_chan_get_state(&le_chan->chan) == BT_L2CAP_CONNECTED) { uint16_t credits; @@ -2398,7 +2392,7 @@ static struct net_buf *l2cap_alloc_frag(k_timeout_t timeout, void *user_data) return NULL; } - BT_DBG("frag %p tailroom %zu", frag, net_buf_tailroom(frag)); + LOG_DBG("frag %p tailroom %zu", frag, net_buf_tailroom(frag)); return frag; } @@ -2408,7 +2402,7 @@ static void l2cap_chan_le_recv_sdu(struct bt_l2cap_le_chan *chan, { int err; - BT_DBG("chan %p len %zu", chan, net_buf_frags_len(buf)); + LOG_DBG("chan %p len %zu", chan, net_buf_frags_len(buf)); __ASSERT_NO_MSG(bt_l2cap_chan_get_state(&chan->chan) == BT_L2CAP_CONNECTED); @@ -2416,7 +2410,7 @@ static void l2cap_chan_le_recv_sdu(struct bt_l2cap_le_chan *chan, err = chan->chan.ops->recv(&chan->chan, buf); if (err < 0) { if (err != -EINPROGRESS) { - BT_ERR("err %d", err); + LOG_ERR("err %d", err); bt_l2cap_chan_disconnect(&chan->chan); net_buf_unref(buf); } @@ -2442,7 +2436,7 @@ static void l2cap_chan_le_recv_seg(struct bt_l2cap_le_chan *chan, } if (len + buf->len > chan->_sdu_len) { - BT_ERR("SDU length mismatch"); + LOG_ERR("SDU length mismatch"); bt_l2cap_chan_disconnect(&chan->chan); return; } @@ -2451,13 +2445,13 @@ static void l2cap_chan_le_recv_seg(struct bt_l2cap_le_chan *chan, /* Store received segments in user_data */ memcpy(net_buf_user_data(chan->_sdu), &seg, sizeof(seg)); - BT_DBG("chan %p seg %d len %zu", chan, seg, net_buf_frags_len(buf)); + LOG_DBG("chan %p seg %d len %zu", chan, seg, net_buf_frags_len(buf)); /* Append received segment to SDU */ len = net_buf_append_bytes(chan->_sdu, buf->len, buf->data, K_NO_WAIT, l2cap_alloc_frag, chan); if (len != buf->len) { - BT_ERR("Unable to store SDU"); + LOG_ERR("Unable to store SDU"); bt_l2cap_chan_disconnect(&chan->chan); return; } @@ -2488,7 +2482,7 @@ static void l2cap_chan_le_recv(struct bt_l2cap_le_chan *chan, int err; if (!test_and_dec(&chan->rx.credits)) { - BT_ERR("No credits to receive packet"); + LOG_ERR("No credits to receive packet"); bt_l2cap_chan_disconnect(&chan->chan); return; } @@ -2500,17 +2494,17 @@ static void l2cap_chan_le_recv(struct bt_l2cap_le_chan *chan, } if (buf->len < 2) { - BT_WARN("Too short data packet"); + LOG_WRN("Too short data packet"); bt_l2cap_chan_disconnect(&chan->chan); return; } sdu_len = net_buf_pull_le16(buf); - BT_DBG("chan %p len %u sdu_len %u", chan, buf->len, sdu_len); + LOG_DBG("chan %p len %u sdu_len %u", chan, buf->len, sdu_len); if (sdu_len > chan->rx.mtu) { - BT_ERR("Invalid SDU length"); + LOG_ERR("Invalid SDU length"); bt_l2cap_chan_disconnect(&chan->chan); return; } @@ -2519,7 +2513,7 @@ static void l2cap_chan_le_recv(struct bt_l2cap_le_chan *chan, if (chan->chan.ops->alloc_buf) { chan->_sdu = chan->chan.ops->alloc_buf(&chan->chan); if (!chan->_sdu) { - BT_ERR("Unable to allocate buffer for SDU"); + LOG_ERR("Unable to allocate buffer for SDU"); bt_l2cap_chan_disconnect(&chan->chan); return; } @@ -2531,7 +2525,7 @@ static void l2cap_chan_le_recv(struct bt_l2cap_le_chan *chan, err = chan->chan.ops->recv(&chan->chan, buf); if (err < 0) { if (err != -EINPROGRESS) { - BT_ERR("err %d", err); + LOG_ERR("err %d", err); bt_l2cap_chan_disconnect(&chan->chan); } return; @@ -2544,13 +2538,13 @@ static void l2cap_chan_recv_queue(struct bt_l2cap_le_chan *chan, struct net_buf *buf) { if (chan->state == BT_L2CAP_DISCONNECTING) { - BT_WARN("Ignoring data received while disconnecting"); + LOG_WRN("Ignoring data received while disconnecting"); net_buf_unref(buf); return; } if (atomic_test_bit(chan->chan.status, BT_L2CAP_STATUS_SHUTDOWN)) { - BT_WARN("Ignoring data received while channel has shutdown"); + LOG_WRN("Ignoring data received while channel has shutdown"); net_buf_unref(buf); return; } @@ -2587,7 +2581,7 @@ static void l2cap_chan_recv(struct bt_l2cap_chan *chan, struct net_buf *buf, } #endif /* CONFIG_BT_L2CAP_DYNAMIC_CHANNEL */ - BT_DBG("chan %p len %u", chan, buf->len); + LOG_DBG("chan %p len %u", chan, buf->len); chan->ops->recv(chan, buf); net_buf_unref(buf); @@ -2606,7 +2600,7 @@ void bt_l2cap_recv(struct bt_conn *conn, struct net_buf *buf, bool complete) } if (buf->len < sizeof(*hdr)) { - BT_ERR("Too small L2CAP PDU received"); + LOG_ERR("Too small L2CAP PDU received"); net_buf_unref(buf); return; } @@ -2614,11 +2608,11 @@ void bt_l2cap_recv(struct bt_conn *conn, struct net_buf *buf, bool complete) hdr = net_buf_pull_mem(buf, sizeof(*hdr)); cid = sys_le16_to_cpu(hdr->cid); - BT_DBG("Packet for CID %u len %u", cid, buf->len); + LOG_DBG("Packet for CID %u len %u", cid, buf->len); chan = bt_l2cap_le_lookup_rx_cid(conn, cid); if (!chan) { - BT_WARN("Ignoring data for unknown channel ID 0x%04x", cid); + LOG_WRN("Ignoring data for unknown channel ID 0x%04x", cid); net_buf_unref(buf); return; } @@ -2656,15 +2650,14 @@ int bt_l2cap_update_conn_param(struct bt_conn *conn, static void l2cap_connected(struct bt_l2cap_chan *chan) { - BT_DBG("ch %p cid 0x%04x", BT_L2CAP_LE_CHAN(chan), - BT_L2CAP_LE_CHAN(chan)->rx.cid); + LOG_DBG("ch %p cid 0x%04x", BT_L2CAP_LE_CHAN(chan), BT_L2CAP_LE_CHAN(chan)->rx.cid); } static void l2cap_disconnected(struct bt_l2cap_chan *chan) { struct bt_l2cap_le_chan *le_chan = BT_L2CAP_LE_CHAN(chan); - BT_DBG("ch %p cid 0x%04x", le_chan, le_chan->rx.cid); + LOG_DBG("ch %p cid 0x%04x", le_chan, le_chan->rx.cid); #if defined(CONFIG_BT_L2CAP_DYNAMIC_CHANNEL) /* Cancel RTX work on signal channel. @@ -2684,7 +2677,7 @@ static int l2cap_accept(struct bt_conn *conn, struct bt_l2cap_chan **chan) .recv = l2cap_recv, }; - BT_DBG("conn %p handle %u", conn, conn->handle); + LOG_DBG("conn %p handle %u", conn, conn->handle); for (i = 0; i < ARRAY_SIZE(bt_l2cap_pool); i++) { struct bt_l2cap *l2cap = &bt_l2cap_pool[i]; @@ -2699,7 +2692,7 @@ static int l2cap_accept(struct bt_conn *conn, struct bt_l2cap_chan **chan) return 0; } - BT_ERR("No available L2CAP context for conn %p", conn); + LOG_ERR("No available L2CAP context for conn %p", conn); return -ENOMEM; } @@ -2784,8 +2777,8 @@ static int l2cap_ecred_init(struct bt_conn *conn, ch->psm = psm; - BT_DBG("ch %p psm 0x%02x mtu %u mps %u credits %u", ch, ch->psm, - ch->rx.mtu, ch->rx.mps, ch->rx.init_credits); + LOG_DBG("ch %p psm 0x%02x mtu %u mps %u credits %u", ch, ch->psm, ch->rx.mtu, ch->rx.mps, + ch->rx.init_credits); return 0; } @@ -2795,7 +2788,7 @@ int bt_l2cap_ecred_chan_connect(struct bt_conn *conn, { int i, err; - BT_DBG("conn %p chan %p psm 0x%04x", conn, chan, psm); + LOG_DBG("conn %p chan %p psm 0x%04x", conn, chan, psm); if (!conn || !chan) { return -EINVAL; @@ -2850,7 +2843,7 @@ int bt_l2cap_ecred_chan_reconfigure(struct bt_l2cap_chan **chans, uint16_t mtu) uint8_t ident; int i; - BT_DBG("chans %p mtu 0x%04x", chans, mtu); + LOG_DBG("chans %p mtu 0x%04x", chans, mtu); if (!chans) { return -EINVAL; @@ -2936,7 +2929,7 @@ int bt_l2cap_chan_connect(struct bt_conn *conn, struct bt_l2cap_chan *chan, { struct bt_l2cap_le_chan *le_chan = BT_L2CAP_LE_CHAN(chan); - BT_DBG("conn %p chan %p psm 0x%04x", conn, chan, psm); + LOG_DBG("conn %p chan %p psm 0x%04x", conn, chan, psm); if (!conn || conn->state != BT_CONN_CONNECTED) { return -ENOTCONN; @@ -2978,8 +2971,7 @@ int bt_l2cap_chan_disconnect(struct bt_l2cap_chan *chan) le_chan = BT_L2CAP_LE_CHAN(chan); - BT_DBG("chan %p scid 0x%04x dcid 0x%04x", chan, le_chan->rx.cid, - le_chan->tx.cid); + LOG_DBG("chan %p scid 0x%04x dcid 0x%04x", chan, le_chan->rx.cid, le_chan->tx.cid); le_chan->ident = get_ident(); @@ -3011,7 +3003,7 @@ int bt_l2cap_chan_send_cb(struct bt_l2cap_chan *chan, struct net_buf *buf, bt_co return -EINVAL; } - BT_DBG("chan %p buf %p len %zu", chan, buf, net_buf_frags_len(buf)); + LOG_DBG("chan %p buf %p len %zu", chan, buf, net_buf_frags_len(buf)); if (!chan->conn || chan->conn->state != BT_CONN_CONNECTED) { return -ENOTCONN; @@ -3028,7 +3020,7 @@ int bt_l2cap_chan_send_cb(struct bt_l2cap_chan *chan, struct net_buf *buf, bt_co data = alloc_tx_meta_data(); if (!data) { - BT_WARN("Unable to allocate TX context"); + LOG_WRN("Unable to allocate TX context"); return -ENOBUFS; } @@ -3057,7 +3049,7 @@ int bt_l2cap_chan_send_cb(struct bt_l2cap_chan *chan, struct net_buf *buf, bt_co return l2cap_tx_meta_data(buf)->sent; } - BT_ERR("failed to send message %d", err); + LOG_ERR("failed to send message %d", err); l2cap_tx_meta_data(buf) = old_user_data; free_tx_meta_data(data); diff --git a/subsys/bluetooth/host/l2cap_br.c b/subsys/bluetooth/host/l2cap_br.c index 01f083cc662..0117a24cbfe 100644 --- a/subsys/bluetooth/host/l2cap_br.c +++ b/subsys/bluetooth/host/l2cap_br.c @@ -18,10 +18,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_L2CAP) -#define LOG_MODULE_NAME bt_l2cap_br -#include "common/log.h" - #include "hci_core.h" #include "conn_internal.h" #include "l2cap_internal.h" @@ -30,6 +26,9 @@ #include "rfcomm_internal.h" #include "sdp_internal.h" +#include +LOG_MODULE_REGISTER(bt_l2cap_br, CONFIG_BT_L2CAP_LOG_LEVEL); + #define BR_CHAN_RTX(_w) CONTAINER_OF(_w, struct bt_l2cap_br_chan, rtx_work) #define L2CAP_BR_PSM_START 0x0001 @@ -155,7 +154,7 @@ static void l2cap_br_chan_destroy(struct bt_l2cap_chan *chan) { struct bt_l2cap_br_chan *br_chan = BR_CHAN(chan); - BT_DBG("chan %p cid 0x%04x", br_chan, br_chan->rx.cid); + LOG_DBG("chan %p cid 0x%04x", br_chan, br_chan->rx.cid); /* Cancel ongoing work. Since the channel can be re-used after this * we need to sync to make sure that the kernel does not have it @@ -177,17 +176,15 @@ static void l2cap_br_rtx_timeout(struct k_work *work) { struct bt_l2cap_br_chan *chan = BR_CHAN_RTX(work); - BT_WARN("chan %p timeout", chan); + LOG_WRN("chan %p timeout", chan); if (chan->rx.cid == BT_L2CAP_CID_BR_SIG) { - BT_DBG("Skip BR/EDR signalling channel "); + LOG_DBG("Skip BR/EDR signalling channel "); atomic_clear_bit(chan->flags, L2CAP_FLAG_SIG_INFO_PENDING); return; } - BT_DBG("chan %p %s scid 0x%04x", chan, - bt_l2cap_chan_state_str(chan->state), - chan->rx.cid); + LOG_DBG("chan %p %s scid 0x%04x", chan, bt_l2cap_chan_state_str(chan->state), chan->rx.cid); switch (chan->state) { case BT_L2CAP_CONFIG: @@ -208,7 +205,7 @@ static bool l2cap_br_chan_add(struct bt_conn *conn, struct bt_l2cap_chan *chan, struct bt_l2cap_br_chan *ch = l2cap_br_chan_alloc_cid(conn, chan); if (!ch) { - BT_DBG("Unable to allocate L2CAP CID"); + LOG_DBG("Unable to allocate L2CAP CID"); return false; } @@ -276,7 +273,7 @@ static void l2cap_br_get_info(struct bt_l2cap_br *l2cap, uint16_t info_type) struct net_buf *buf; struct bt_l2cap_sig_hdr *hdr; - BT_DBG("info type %u", info_type); + LOG_DBG("info type %u", info_type); if (atomic_test_bit(l2cap->chan.flags, L2CAP_FLAG_SIG_INFO_PENDING)) { return; @@ -287,7 +284,7 @@ static void l2cap_br_get_info(struct bt_l2cap_br *l2cap, uint16_t info_type) case BT_L2CAP_INFO_FIXED_CHAN: break; default: - BT_WARN("Unsupported info type %u", info_type); + LOG_WRN("Unsupported info type %u", info_type); return; } @@ -353,13 +350,13 @@ static int l2cap_br_info_rsp(struct bt_l2cap_br *l2cap, uint8_t ident, } if (buf->len < sizeof(*rsp)) { - BT_ERR("Too small info rsp packet size"); + LOG_ERR("Too small info rsp packet size"); err = -EINVAL; goto done; } if (ident != l2cap->info_ident) { - BT_WARN("Idents mismatch"); + LOG_WRN("Idents mismatch"); err = -EINVAL; goto done; } @@ -367,7 +364,7 @@ static int l2cap_br_info_rsp(struct bt_l2cap_br *l2cap, uint8_t ident, rsp = net_buf_pull_mem(buf, sizeof(*rsp)); result = sys_le16_to_cpu(rsp->result); if (result != BT_L2CAP_INFO_SUCCESS) { - BT_WARN("Result unsuccessful"); + LOG_WRN("Result unsuccessful"); err = -EINVAL; goto done; } @@ -377,7 +374,7 @@ static int l2cap_br_info_rsp(struct bt_l2cap_br *l2cap, uint8_t ident, switch (type) { case BT_L2CAP_INFO_FEAT_MASK: l2cap->info_feat_mask = net_buf_pull_le32(buf); - BT_DBG("remote info mask 0x%08x", l2cap->info_feat_mask); + LOG_DBG("remote info mask 0x%08x", l2cap->info_feat_mask); if (!(l2cap->info_feat_mask & L2CAP_FEAT_FIXED_CHAN_MASK)) { break; @@ -387,14 +384,13 @@ static int l2cap_br_info_rsp(struct bt_l2cap_br *l2cap, uint8_t ident, return 0; case BT_L2CAP_INFO_FIXED_CHAN: l2cap->info_fixed_chan = net_buf_pull_u8(buf); - BT_DBG("remote fixed channel mask 0x%02x", - l2cap->info_fixed_chan); + LOG_DBG("remote fixed channel mask 0x%02x", l2cap->info_fixed_chan); connect_optional_fixed_channels(l2cap); break; default: - BT_WARN("type 0x%04x unsupported", type); + LOG_WRN("type 0x%04x unsupported", type); err = -EINVAL; break; } @@ -427,14 +423,14 @@ static int l2cap_br_info_req(struct bt_l2cap_br *l2cap, uint8_t ident, uint16_t type; if (buf->len < sizeof(*req)) { - BT_ERR("Too small info req packet size"); + LOG_ERR("Too small info req packet size"); return -EINVAL; } rsp_buf = bt_l2cap_create_pdu(&br_sig_pool, 0); type = sys_le16_to_cpu(req->type); - BT_DBG("type 0x%04x", type); + LOG_DBG("type 0x%04x", type); hdr_info = net_buf_add(rsp_buf, sizeof(*hdr_info)); hdr_info->code = BT_L2CAP_INFO_RSP; @@ -702,14 +698,14 @@ static void l2cap_br_conn_req(struct bt_l2cap_br *l2cap, uint8_t ident, struct bt_l2cap_br_chan *br_chan; if (buf->len < sizeof(*req)) { - BT_ERR("Too small L2CAP conn req packet size"); + LOG_ERR("Too small L2CAP conn req packet size"); return; } psm = sys_le16_to_cpu(req->psm); scid = sys_le16_to_cpu(req->scid); - BT_DBG("psm 0x%02x scid 0x%04x", psm, scid); + LOG_DBG("psm 0x%02x scid 0x%04x", psm, scid); /* Check if there is a server registered */ server = l2cap_br_server_lookup_psm(psm); @@ -810,7 +806,7 @@ static void l2cap_br_conf_rsp(struct bt_l2cap_br *l2cap, uint8_t ident, struct bt_l2cap_br_chan *br_chan; if (buf->len < sizeof(*rsp)) { - BT_ERR("Too small L2CAP conf rsp packet size"); + LOG_ERR("Too small L2CAP conf rsp packet size"); return; } @@ -819,12 +815,11 @@ static void l2cap_br_conf_rsp(struct bt_l2cap_br *l2cap, uint8_t ident, result = sys_le16_to_cpu(rsp->result); opt_len = len - sizeof(*rsp); - BT_DBG("scid 0x%04x flags 0x%02x result 0x%02x len %u", scid, flags, - result, opt_len); + LOG_DBG("scid 0x%04x flags 0x%02x result 0x%02x len %u", scid, flags, result, opt_len); chan = bt_l2cap_br_lookup_rx_cid(conn, scid); if (!chan) { - BT_ERR("channel mismatch!"); + LOG_ERR("channel mismatch!"); return; } @@ -844,8 +839,8 @@ static void l2cap_br_conf_rsp(struct bt_l2cap_br *l2cap, uint8_t ident, if (br_chan->state == BT_L2CAP_CONFIG && atomic_test_bit(br_chan->flags, L2CAP_FLAG_CONN_RCONF_DONE)) { - BT_DBG("scid 0x%04x rx MTU %u dcid 0x%04x tx MTU %u", - br_chan->rx.cid, br_chan->rx.mtu, br_chan->tx.cid, br_chan->tx.mtu); + LOG_DBG("scid 0x%04x rx MTU %u dcid 0x%04x tx MTU %u", br_chan->rx.cid, + br_chan->rx.mtu, br_chan->tx.cid, br_chan->tx.mtu); bt_l2cap_chan_set_state(chan, BT_L2CAP_CONNECTED); if (chan->ops && chan->ops->connected) { @@ -880,11 +875,11 @@ int bt_l2cap_br_server_register(struct bt_l2cap_server *server) /* Check if given PSM is already in use */ if (l2cap_br_server_lookup_psm(server->psm)) { - BT_DBG("PSM already registered"); + LOG_DBG("PSM already registered"); return -EADDRINUSE; } - BT_DBG("PSM 0x%04x", server->psm); + LOG_DBG("PSM 0x%04x", server->psm); sys_slist_append(&br_servers, &server->node); @@ -927,7 +922,7 @@ static uint16_t l2cap_br_conf_opt_mtu(struct bt_l2cap_chan *chan, /* Core 4.2 [Vol 3, Part A, 5.1] MTU payload length */ if (len != 2) { - BT_ERR("tx MTU length %zu invalid", len); + LOG_ERR("tx MTU length %zu invalid", len); result = BT_L2CAP_CONF_REJECT; goto done; } @@ -937,12 +932,12 @@ static uint16_t l2cap_br_conf_opt_mtu(struct bt_l2cap_chan *chan, if (mtu < L2CAP_BR_MIN_MTU) { result = BT_L2CAP_CONF_UNACCEPT; BR_CHAN(chan)->tx.mtu = L2CAP_BR_MIN_MTU; - BT_DBG("tx MTU %u invalid", mtu); + LOG_DBG("tx MTU %u invalid", mtu); goto done; } BR_CHAN(chan)->tx.mtu = mtu; - BT_DBG("tx MTU %u", mtu); + LOG_DBG("tx MTU %u", mtu); done: return result; } @@ -959,7 +954,7 @@ static void l2cap_br_conf_req(struct bt_l2cap_br *l2cap, uint8_t ident, uint16_t flags, dcid, opt_len, hint, result = BT_L2CAP_CONF_SUCCESS; if (buf->len < sizeof(*req)) { - BT_ERR("Too small L2CAP conf req packet size"); + LOG_ERR("Too small L2CAP conf req packet size"); return; } @@ -968,11 +963,11 @@ static void l2cap_br_conf_req(struct bt_l2cap_br *l2cap, uint8_t ident, dcid = sys_le16_to_cpu(req->dcid); opt_len = len - sizeof(*req); - BT_DBG("dcid 0x%04x flags 0x%02x len %u", dcid, flags, opt_len); + LOG_DBG("dcid 0x%04x flags 0x%02x len %u", dcid, flags, opt_len); chan = bt_l2cap_br_lookup_rx_cid(conn, dcid); if (!chan) { - BT_ERR("rx channel mismatch!"); + LOG_ERR("rx channel mismatch!"); struct bt_l2cap_cmd_reject_cid_data data = {.scid = req->dcid, .dcid = 0, }; @@ -983,7 +978,7 @@ static void l2cap_br_conf_req(struct bt_l2cap_br *l2cap, uint8_t ident, } if (!opt_len) { - BT_DBG("tx default MTU %u", L2CAP_BR_DEFAULT_MTU); + LOG_DBG("tx default MTU %u", L2CAP_BR_DEFAULT_MTU); BR_CHAN(chan)->tx.mtu = L2CAP_BR_DEFAULT_MTU; goto send_rsp; } @@ -993,7 +988,7 @@ static void l2cap_br_conf_req(struct bt_l2cap_br *l2cap, uint8_t ident, /* make sure opt object can get safe dereference in iteration */ if (buf->len < opt->len) { - BT_ERR("Received too short option data"); + LOG_ERR("Received too short option data"); result = BT_L2CAP_CONF_REJECT; break; } @@ -1013,7 +1008,7 @@ static void l2cap_br_conf_req(struct bt_l2cap_br *l2cap, uint8_t ident, goto send_rsp; default: if (!hint) { - BT_DBG("option %u not handled", opt->type); + LOG_DBG("option %u not handled", opt->type); goto send_rsp; } @@ -1056,9 +1051,8 @@ send_rsp: if (atomic_test_bit(BR_CHAN(chan)->flags, L2CAP_FLAG_CONN_LCONF_DONE) && BR_CHAN(chan)->state == BT_L2CAP_CONFIG) { - BT_DBG("scid 0x%04x rx MTU %u dcid 0x%04x tx MTU %u", - BR_CHAN(chan)->rx.cid, BR_CHAN(chan)->rx.mtu, - BR_CHAN(chan)->tx.cid, BR_CHAN(chan)->tx.mtu); + LOG_DBG("scid 0x%04x rx MTU %u dcid 0x%04x tx MTU %u", BR_CHAN(chan)->rx.cid, + BR_CHAN(chan)->rx.mtu, BR_CHAN(chan)->tx.cid, BR_CHAN(chan)->tx.mtu); bt_l2cap_chan_set_state(chan, BT_L2CAP_CONNECTED); if (chan->ops && chan->ops->connected) { @@ -1101,14 +1095,14 @@ static void l2cap_br_disconn_req(struct bt_l2cap_br *l2cap, uint8_t ident, uint16_t scid, dcid; if (buf->len < sizeof(*req)) { - BT_ERR("Too small disconn req packet size"); + LOG_ERR("Too small disconn req packet size"); return; } dcid = sys_le16_to_cpu(req->dcid); scid = sys_le16_to_cpu(req->scid); - BT_DBG("scid 0x%04x dcid 0x%04x", dcid, scid); + LOG_DBG("scid 0x%04x dcid 0x%04x", dcid, scid); chan = l2cap_br_remove_tx_cid(conn, scid); if (!chan) { @@ -1139,14 +1133,14 @@ static void l2cap_br_disconn_req(struct bt_l2cap_br *l2cap, uint8_t ident, static void l2cap_br_connected(struct bt_l2cap_chan *chan) { - BT_DBG("ch %p cid 0x%04x", BR_CHAN(chan), BR_CHAN(chan)->rx.cid); + LOG_DBG("ch %p cid 0x%04x", BR_CHAN(chan), BR_CHAN(chan)->rx.cid); } static void l2cap_br_disconnected(struct bt_l2cap_chan *chan) { struct bt_l2cap_br_chan *br_chan = BR_CHAN(chan); - BT_DBG("ch %p cid 0x%04x", br_chan, br_chan->rx.cid); + LOG_DBG("ch %p cid 0x%04x", br_chan, br_chan->rx.cid); if (atomic_test_and_clear_bit(br_chan->flags, L2CAP_FLAG_SIG_INFO_PENDING)) { @@ -1176,8 +1170,7 @@ int bt_l2cap_br_chan_disconnect(struct bt_l2cap_chan *chan) return -EALREADY; } - BT_DBG("chan %p scid 0x%04x dcid 0x%04x", chan, br_chan->rx.cid, - br_chan->tx.cid); + LOG_DBG("chan %p scid 0x%04x dcid 0x%04x", chan, br_chan->rx.cid, br_chan->tx.cid); buf = bt_l2cap_create_pdu(&br_sig_pool, 0); @@ -1205,18 +1198,18 @@ static void l2cap_br_disconn_rsp(struct bt_l2cap_br *l2cap, uint8_t ident, uint16_t dcid, scid; if (buf->len < sizeof(*rsp)) { - BT_ERR("Too small disconn rsp packet size"); + LOG_ERR("Too small disconn rsp packet size"); return; } dcid = sys_le16_to_cpu(rsp->dcid); scid = sys_le16_to_cpu(rsp->scid); - BT_DBG("dcid 0x%04x scid 0x%04x", dcid, scid); + LOG_DBG("dcid 0x%04x scid 0x%04x", dcid, scid); chan = l2cap_br_remove_tx_cid(conn, dcid); if (!chan) { - BT_WARN("No dcid 0x%04x channel found", dcid); + LOG_WRN("No dcid 0x%04x channel found", dcid); return; } @@ -1314,7 +1307,7 @@ static void l2cap_br_conn_rsp(struct bt_l2cap_br *l2cap, uint8_t ident, struct bt_l2cap_br_chan *br_chan; if (buf->len < sizeof(*rsp)) { - BT_ERR("Too small L2CAP conn rsp packet size"); + LOG_ERR("Too small L2CAP conn rsp packet size"); return; } @@ -1323,12 +1316,11 @@ static void l2cap_br_conn_rsp(struct bt_l2cap_br *l2cap, uint8_t ident, result = sys_le16_to_cpu(rsp->result); status = sys_le16_to_cpu(rsp->status); - BT_DBG("dcid 0x%04x scid 0x%04x result %u status %u", dcid, scid, - result, status); + LOG_DBG("dcid 0x%04x scid 0x%04x result %u status %u", dcid, scid, result, status); chan = bt_l2cap_br_lookup_rx_cid(conn, scid); if (!chan) { - BT_ERR("No scid 0x%04x channel found", scid); + LOG_ERR("No scid 0x%04x channel found", scid); return; } @@ -1338,8 +1330,8 @@ static void l2cap_br_conn_rsp(struct bt_l2cap_br *l2cap, uint8_t ident, k_work_cancel_delayable(&br_chan->rtx_work); if (br_chan->state != BT_L2CAP_CONNECTING) { - BT_DBG("Invalid channel %p state %s", chan, - bt_l2cap_chan_state_str(br_chan->state)); + LOG_DBG("Invalid channel %p state %s", chan, + bt_l2cap_chan_state_str(br_chan->state)); return; } @@ -1384,23 +1376,22 @@ static int l2cap_br_recv(struct bt_l2cap_chan *chan, struct net_buf *buf) uint16_t len; if (buf->len < sizeof(*hdr)) { - BT_ERR("Too small L2CAP signaling PDU"); + LOG_ERR("Too small L2CAP signaling PDU"); return 0; } hdr = net_buf_pull_mem(buf, sizeof(*hdr)); len = sys_le16_to_cpu(hdr->len); - BT_DBG("Signaling code 0x%02x ident %u len %u", hdr->code, - hdr->ident, len); + LOG_DBG("Signaling code 0x%02x ident %u len %u", hdr->code, hdr->ident, len); if (buf->len != len) { - BT_ERR("L2CAP length mismatch (%u != %u)", buf->len, len); + LOG_ERR("L2CAP length mismatch (%u != %u)", buf->len, len); return 0; } if (!hdr->ident) { - BT_ERR("Invalid ident value in L2CAP PDU"); + LOG_ERR("Invalid ident value in L2CAP PDU"); return 0; } @@ -1430,7 +1421,7 @@ static int l2cap_br_recv(struct bt_l2cap_chan *chan, struct net_buf *buf) l2cap_br_conn_rsp(l2cap, hdr->ident, buf); break; default: - BT_WARN("Unknown/Unsupported L2CAP PDU code 0x%02x", hdr->code); + LOG_WRN("Unknown/Unsupported L2CAP PDU code 0x%02x", hdr->code); l2cap_br_send_reject(chan->conn, hdr->ident, BT_L2CAP_REJ_NOT_UNDERSTOOD, NULL, 0); break; @@ -1449,8 +1440,7 @@ static void l2cap_br_conn_pend(struct bt_l2cap_chan *chan, uint8_t status) return; } - BT_DBG("chan %p status 0x%02x encr 0x%02x", chan, status, - chan->conn->encrypt); + LOG_DBG("chan %p status 0x%02x encr 0x%02x", chan, status, chan->conn->encrypt); if (status) { /* @@ -1530,7 +1520,7 @@ void bt_l2cap_br_recv(struct bt_conn *conn, struct net_buf *buf) uint16_t cid; if (buf->len < sizeof(*hdr)) { - BT_ERR("Too small L2CAP PDU received"); + LOG_ERR("Too small L2CAP PDU received"); net_buf_unref(buf); return; } @@ -1540,7 +1530,7 @@ void bt_l2cap_br_recv(struct bt_conn *conn, struct net_buf *buf) chan = bt_l2cap_br_lookup_rx_cid(conn, cid); if (!chan) { - BT_WARN("Ignoring data for unknown channel ID 0x%04x", cid); + LOG_WRN("Ignoring data for unknown channel ID 0x%04x", cid); net_buf_unref(buf); return; } @@ -1564,7 +1554,7 @@ static int l2cap_br_accept(struct bt_conn *conn, struct bt_l2cap_chan **chan) .recv = l2cap_br_recv, }; - BT_DBG("conn %p handle %u", conn, conn->handle); + LOG_DBG("conn %p handle %u", conn, conn->handle); for (i = 0; i < ARRAY_SIZE(bt_l2cap_br_pool); i++) { struct bt_l2cap_br *l2cap = &bt_l2cap_br_pool[i]; @@ -1579,7 +1569,7 @@ static int l2cap_br_accept(struct bt_conn *conn, struct bt_l2cap_chan **chan) return 0; } - BT_ERR("No available L2CAP context for conn %p", conn); + LOG_ERR("No available L2CAP context for conn %p", conn); return -ENOMEM; } diff --git a/subsys/bluetooth/host/l2cap_internal.h b/subsys/bluetooth/host/l2cap_internal.h index 323bd70f31c..2a54dbeec72 100644 --- a/subsys/bluetooth/host/l2cap_internal.h +++ b/subsys/bluetooth/host/l2cap_internal.h @@ -274,7 +274,7 @@ void bt_l2cap_chan_del(struct bt_l2cap_chan *chan); const char *bt_l2cap_chan_state_str(bt_l2cap_chan_state_t state); -#if defined(CONFIG_BT_DEBUG_L2CAP) +#if defined(CONFIG_BT_L2CAP_LOG_LEVEL_DBG) void bt_l2cap_chan_set_state_debug(struct bt_l2cap_chan *chan, bt_l2cap_chan_state_t state, const char *func, int line); @@ -283,7 +283,7 @@ void bt_l2cap_chan_set_state_debug(struct bt_l2cap_chan *chan, #else void bt_l2cap_chan_set_state(struct bt_l2cap_chan *chan, bt_l2cap_chan_state_t state); -#endif /* CONFIG_BT_DEBUG_L2CAP */ +#endif /* CONFIG_BT_L2CAP_LOG_LEVEL_DBG */ /* * Notify L2CAP channels of a change in encryption state passing additionally diff --git a/subsys/bluetooth/host/rfcomm.c b/subsys/bluetooth/host/rfcomm.c index 284f4c8a24f..8316f890495 100644 --- a/subsys/bluetooth/host/rfcomm.c +++ b/subsys/bluetooth/host/rfcomm.c @@ -20,10 +20,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_RFCOMM) -#define LOG_MODULE_NAME bt_rfcomm -#include "common/log.h" - #include #include "hci_core.h" @@ -31,6 +27,10 @@ #include "l2cap_internal.h" #include "rfcomm_internal.h" +#define LOG_LEVEL CONFIG_BT_RFCOMM_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_rfcomm); + #define RFCOMM_CHANNEL_START 0x01 #define RFCOMM_CHANNEL_END 0x1e @@ -205,11 +205,11 @@ int bt_rfcomm_server_register(struct bt_rfcomm_server *server) /* Check if given channel is already in use */ if (rfcomm_server_lookup_channel(server->channel)) { - BT_DBG("Channel already registered"); + LOG_DBG("Channel already registered"); return -EADDRINUSE; } - BT_DBG("Channel 0x%02x", server->channel); + LOG_DBG("Channel 0x%02x", server->channel); server->_next = servers; servers = server; @@ -220,19 +220,18 @@ int bt_rfcomm_server_register(struct bt_rfcomm_server *server) static void rfcomm_dlc_tx_give_credits(struct bt_rfcomm_dlc *dlc, uint8_t credits) { - BT_DBG("dlc %p credits %u", dlc, credits); + LOG_DBG("dlc %p credits %u", dlc, credits); while (credits--) { k_sem_give(&dlc->tx_credits); } - BT_DBG("dlc %p updated credits %u", dlc, - k_sem_count_get(&dlc->tx_credits)); + LOG_DBG("dlc %p updated credits %u", dlc, k_sem_count_get(&dlc->tx_credits)); } static void rfcomm_dlc_destroy(struct bt_rfcomm_dlc *dlc) { - BT_DBG("dlc %p", dlc); + LOG_DBG("dlc %p", dlc); k_work_cancel_delayable(&dlc->rtx_work); dlc->state = BT_RFCOMM_STATE_IDLE; @@ -247,7 +246,7 @@ static void rfcomm_dlc_disconnect(struct bt_rfcomm_dlc *dlc) { uint8_t old_state = dlc->state; - BT_DBG("dlc %p", dlc); + LOG_DBG("dlc %p", dlc); if (dlc->state == BT_RFCOMM_STATE_DISCONNECTED) { return; @@ -279,7 +278,7 @@ static void rfcomm_session_disconnected(struct bt_rfcomm_session *session) { struct bt_rfcomm_dlc *dlc; - BT_DBG("Session %p", session); + LOG_DBG("Session %p", session); if (session->state == BT_RFCOMM_STATE_DISCONNECTED) { return; @@ -349,7 +348,7 @@ static int rfcomm_send_disc(struct bt_rfcomm_session *session, uint8_t dlci) struct net_buf *buf; uint8_t fcs, cr; - BT_DBG("dlci %d", dlci); + LOG_DBG("dlci %d", dlci); buf = bt_l2cap_create_pdu(NULL, 0); @@ -403,7 +402,7 @@ static void rfcomm_connected(struct bt_l2cap_chan *chan) { struct bt_rfcomm_session *session = RFCOMM_SESSION(chan); - BT_DBG("Session %p", session); + LOG_DBG("Session %p", session); /* Need to include UIH header and FCS*/ session->mtu = MIN(session->br_chan.rx.mtu, @@ -419,7 +418,7 @@ static void rfcomm_disconnected(struct bt_l2cap_chan *chan) { struct bt_rfcomm_session *session = RFCOMM_SESSION(chan); - BT_DBG("Session %p", session); + LOG_DBG("Session %p", session); k_work_cancel_delayable(&session->rtx_work); rfcomm_session_disconnected(session); @@ -431,7 +430,7 @@ static void rfcomm_dlc_rtx_timeout(struct k_work *work) struct bt_rfcomm_dlc *dlc = DLC_RTX(work); struct bt_rfcomm_session *session = dlc->session; - BT_WARN("dlc %p state %d timeout", dlc, dlc->state); + LOG_WRN("dlc %p state %d timeout", dlc, dlc->state); rfcomm_dlcs_remove_dlci(session->dlcs, dlc->dlci); rfcomm_dlc_disconnect(dlc); @@ -443,7 +442,7 @@ static void rfcomm_dlc_init(struct bt_rfcomm_dlc *dlc, uint8_t dlci, bt_rfcomm_role_t role) { - BT_DBG("dlc %p", dlc); + LOG_DBG("dlc %p", dlc); dlc->dlci = dlci; dlc->session = session; @@ -469,12 +468,12 @@ static struct bt_rfcomm_dlc *rfcomm_dlc_accept(struct bt_rfcomm_session *session channel = BT_RFCOMM_GET_CHANNEL(dlci); server = rfcomm_server_lookup_channel(channel); if (!server) { - BT_ERR("Server Channel not registered"); + LOG_ERR("Server Channel not registered"); return NULL; } if (server->accept(session->br_chan.chan.conn, &dlc) < 0) { - BT_DBG("Incoming connection rejected"); + LOG_DBG("Incoming connection rejected"); return NULL; } @@ -495,7 +494,7 @@ static int rfcomm_send_dm(struct bt_rfcomm_session *session, uint8_t dlci) struct net_buf *buf; uint8_t fcs, cr; - BT_DBG("dlci %d", dlci); + LOG_DBG("dlci %d", dlci); buf = bt_l2cap_create_pdu(NULL, 0); @@ -513,9 +512,9 @@ static int rfcomm_send_dm(struct bt_rfcomm_session *session, uint8_t dlci) static void rfcomm_check_fc(struct bt_rfcomm_dlc *dlc) { - BT_DBG("%p", dlc); + LOG_DBG("%p", dlc); - BT_DBG("Wait for credits or MSC FC %p", dlc); + LOG_DBG("Wait for credits or MSC FC %p", dlc); /* Wait for credits or MSC FC */ k_sem_take(&dlc->tx_credits, K_FOREVER); @@ -540,12 +539,12 @@ static void rfcomm_dlc_tx_thread(void *p1, void *p2, void *p3) k_timeout_t timeout = K_FOREVER; struct net_buf *buf; - BT_DBG("Started for dlc %p", dlc); + LOG_DBG("Started for dlc %p", dlc); while (dlc->state == BT_RFCOMM_STATE_CONNECTED || dlc->state == BT_RFCOMM_STATE_USER_DISCONNECT) { /* Get next packet for dlc */ - BT_DBG("Wait for buf %p", dlc); + LOG_DBG("Wait for buf %p", dlc); buf = net_buf_get(&dlc->tx_queue, timeout); /* If its dummy buffer or non user disconnect then break */ if ((dlc->state != BT_RFCOMM_STATE_CONNECTED && @@ -575,7 +574,7 @@ static void rfcomm_dlc_tx_thread(void *p1, void *p2, void *p3) } } - BT_DBG("dlc %p disconnected - cleaning up", dlc); + LOG_DBG("dlc %p disconnected - cleaning up", dlc); /* Give back any allocated buffers */ while ((buf = net_buf_get(&dlc->tx_queue, K_NO_WAIT))) { @@ -593,7 +592,7 @@ static void rfcomm_dlc_tx_thread(void *p1, void *p2, void *p3) rfcomm_dlc_destroy(dlc); } - BT_DBG("dlc %p exiting", dlc); + LOG_DBG("dlc %p exiting", dlc); } static int rfcomm_send_ua(struct bt_rfcomm_session *session, uint8_t dlci) @@ -746,7 +745,7 @@ static void rfcomm_dlc_connected(struct bt_rfcomm_dlc *dlc) } if (dlc->session->cfc == BT_RFCOMM_CFC_NOT_SUPPORTED) { - BT_DBG("CFC not supported %p", dlc); + LOG_DBG("CFC not supported %p", dlc); rfcomm_send_fcon(dlc->session, BT_RFCOMM_MSG_CMD_CR); /* Use tx_credits as binary sem for MSC FC */ k_sem_init(&dlc->tx_credits, 0, 1); @@ -777,7 +776,7 @@ static enum security_result rfcomm_dlc_security(struct bt_rfcomm_dlc *dlc) { struct bt_conn *conn = dlc->session->br_chan.chan.conn; - BT_DBG("dlc %p", dlc); + LOG_DBG("dlc %p", dlc); /* If current security level is greater than or equal to required * security level then return SUCCESS. @@ -799,7 +798,7 @@ static enum security_result rfcomm_dlc_security(struct bt_rfcomm_dlc *dlc) static void rfcomm_dlc_drop(struct bt_rfcomm_dlc *dlc) { - BT_DBG("dlc %p", dlc); + LOG_DBG("dlc %p", dlc); rfcomm_dlcs_remove_dlci(dlc->session->dlcs, dlc->dlci); rfcomm_dlc_destroy(dlc); @@ -807,7 +806,7 @@ static void rfcomm_dlc_drop(struct bt_rfcomm_dlc *dlc) static int rfcomm_dlc_close(struct bt_rfcomm_dlc *dlc) { - BT_DBG("dlc %p", dlc); + LOG_DBG("dlc %p", dlc); switch (dlc->state) { case BT_RFCOMM_STATE_SECURITY_PENDING: @@ -903,7 +902,7 @@ static int rfcomm_send_pn(struct bt_rfcomm_dlc *dlc, uint8_t cr) buf = rfcomm_make_uih_msg(dlc->session, cr, BT_RFCOMM_PN, sizeof(*pn)); - BT_DBG("mtu %x", dlc->mtu); + LOG_DBG("mtu %x", dlc->mtu); pn = net_buf_add(buf, sizeof(*pn)); pn->dlci = dlc->dlci; @@ -940,7 +939,7 @@ static int rfcomm_send_credit(struct bt_rfcomm_dlc *dlc, uint8_t credits) struct net_buf *buf; uint8_t fcs, cr; - BT_DBG("Dlc %p credits %d", dlc, credits); + LOG_DBG("Dlc %p credits %d", dlc, credits); buf = bt_l2cap_create_pdu(NULL, 0); @@ -961,7 +960,7 @@ static int rfcomm_dlc_start(struct bt_rfcomm_dlc *dlc) { enum security_result result; - BT_DBG("dlc %p", dlc); + LOG_DBG("dlc %p", dlc); result = rfcomm_dlc_security(dlc); switch (result) { @@ -1038,7 +1037,7 @@ static void rfcomm_handle_dm(struct bt_rfcomm_session *session, uint8_t dlci) { struct bt_rfcomm_dlc *dlc; - BT_DBG("dlci %d", dlci); + LOG_DBG("dlci %d", dlci); dlc = rfcomm_dlcs_remove_dlci(session->dlcs, dlci); if (!dlc) { @@ -1056,7 +1055,7 @@ static void rfcomm_handle_msc(struct bt_rfcomm_session *session, struct bt_rfcomm_dlc *dlc; uint8_t dlci = BT_RFCOMM_GET_DLCI(msc->dlci); - BT_DBG("dlci %d", dlci); + LOG_DBG("dlci %d", dlci); dlc = rfcomm_dlcs_lookup_dlci(session->dlcs, dlci); if (!dlc) { @@ -1096,7 +1095,7 @@ static void rfcomm_handle_rls(struct bt_rfcomm_session *session, uint8_t dlci = BT_RFCOMM_GET_DLCI(rls->dlci); struct bt_rfcomm_dlc *dlc; - BT_DBG("dlci %d", dlci); + LOG_DBG("dlci %d", dlci); if (!cr) { /* Ignore if its a response */ @@ -1121,7 +1120,7 @@ static void rfcomm_handle_rpn(struct bt_rfcomm_session *session, /* Exclude fcs to get number of value bytes */ uint8_t value_len = buf->len - 1; - BT_DBG("dlci %d", dlci); + LOG_DBG("dlci %d", dlci); if (!cr) { /* Ignore if its a response */ @@ -1172,7 +1171,7 @@ static void rfcomm_handle_pn(struct bt_rfcomm_session *session, } if (!BT_RFCOMM_CHECK_MTU(pn->mtu)) { - BT_ERR("Invalid mtu %d", pn->mtu); + LOG_ERR("Invalid mtu %d", pn->mtu); rfcomm_send_dm(session, pn->dlci); return; } @@ -1183,7 +1182,7 @@ static void rfcomm_handle_pn(struct bt_rfcomm_session *session, return; } - BT_DBG("Incoming connection accepted dlc %p", dlc); + LOG_DBG("Incoming connection accepted dlc %p", dlc); dlc->mtu = MIN(dlc->mtu, sys_le16_to_cpu(pn->mtu)); @@ -1205,7 +1204,7 @@ static void rfcomm_handle_pn(struct bt_rfcomm_session *session, /* If its a command */ if (cr) { if (!BT_RFCOMM_CHECK_MTU(pn->mtu)) { - BT_ERR("Invalid mtu %d", pn->mtu); + LOG_ERR("Invalid mtu %d", pn->mtu); rfcomm_dlc_close(dlc); return; } @@ -1237,7 +1236,7 @@ static void rfcomm_handle_disc(struct bt_rfcomm_session *session, uint8_t dlci) { struct bt_rfcomm_dlc *dlc; - BT_DBG("Dlci %d", dlci); + LOG_DBG("Dlci %d", dlci); if (dlci) { dlc = rfcomm_dlcs_remove_dlci(session->dlcs, dlci); @@ -1269,7 +1268,7 @@ static void rfcomm_handle_msg(struct bt_rfcomm_session *session, uint8_t msg_type, len, cr; if (buf->len < sizeof(*hdr)) { - BT_ERR("Too small RFCOMM message"); + LOG_ERR("Too small RFCOMM message"); return; } @@ -1278,7 +1277,7 @@ static void rfcomm_handle_msg(struct bt_rfcomm_session *session, cr = BT_RFCOMM_GET_MSG_CR(hdr->type); len = BT_RFCOMM_GET_LEN(hdr->len); - BT_DBG("msg type %x cr %x", msg_type, cr); + LOG_DBG("msg type %x cr %x", msg_type, cr); switch (msg_type) { case BT_RFCOMM_PN: @@ -1302,7 +1301,7 @@ static void rfcomm_handle_msg(struct bt_rfcomm_session *session, break; case BT_RFCOMM_FCON: if (session->cfc == BT_RFCOMM_CFC_SUPPORTED) { - BT_ERR("FCON received when CFC is supported "); + LOG_ERR("FCON received when CFC is supported "); return; } @@ -1318,7 +1317,7 @@ static void rfcomm_handle_msg(struct bt_rfcomm_session *session, break; case BT_RFCOMM_FCOFF: if (session->cfc == BT_RFCOMM_CFC_SUPPORTED) { - BT_ERR("FCOFF received when CFC is supported "); + LOG_ERR("FCOFF received when CFC is supported "); return; } @@ -1336,7 +1335,7 @@ static void rfcomm_handle_msg(struct bt_rfcomm_session *session, rfcomm_send_fcoff(session, BT_RFCOMM_MSG_RESP_CR); break; default: - BT_WARN("Unknown/Unsupported RFCOMM Msg type 0x%02x", msg_type); + LOG_WRN("Unknown/Unsupported RFCOMM Msg type 0x%02x", msg_type); rfcomm_send_nsc(session, hdr->type); break; } @@ -1350,7 +1349,7 @@ static void rfcomm_dlc_update_credits(struct bt_rfcomm_dlc *dlc) return; } - BT_DBG("dlc %p credits %u", dlc, dlc->rx_credit); + LOG_DBG("dlc %p credits %u", dlc, dlc->rx_credit); /* Only give more credits if it went below the defined threshold */ if (dlc->rx_credit > RFCOMM_CREDITS_THRESHOLD) { @@ -1370,16 +1369,16 @@ static void rfcomm_handle_data(struct bt_rfcomm_session *session, { struct bt_rfcomm_dlc *dlc; - BT_DBG("dlci %d, pf %d", dlci, pf); + LOG_DBG("dlci %d, pf %d", dlci, pf); dlc = rfcomm_dlcs_lookup_dlci(session->dlcs, dlci); if (!dlc) { - BT_ERR("Data recvd in non existing DLC"); + LOG_ERR("Data recvd in non existing DLC"); rfcomm_send_dm(session, dlci); return; } - BT_DBG("dlc %p rx credit %d", dlc, dlc->rx_credit); + LOG_DBG("dlc %p rx credit %d", dlc, dlc->rx_credit); if (dlc->state != BT_RFCOMM_STATE_CONNECTED) { return; @@ -1392,7 +1391,7 @@ static void rfcomm_handle_data(struct bt_rfcomm_session *session, if (buf->len > BT_RFCOMM_FCS_SIZE) { if (dlc->session->cfc == BT_RFCOMM_CFC_SUPPORTED && !dlc->rx_credit) { - BT_ERR("Data recvd when rx credit is 0"); + LOG_ERR("Data recvd when rx credit is 0"); rfcomm_dlc_close(dlc); return; } @@ -1416,7 +1415,7 @@ int bt_rfcomm_dlc_send(struct bt_rfcomm_dlc *dlc, struct net_buf *buf) return -EINVAL; } - BT_DBG("dlc %p tx credit %d", dlc, k_sem_count_get(&dlc->tx_credits)); + LOG_DBG("dlc %p tx credit %d", dlc, k_sem_count_get(&dlc->tx_credits)); if (dlc->state != BT_RFCOMM_STATE_CONNECTED) { return -ENOTCONN; @@ -1457,20 +1456,20 @@ static int rfcomm_recv(struct bt_l2cap_chan *chan, struct net_buf *buf) /* Need to consider FCS also*/ if (buf->len < (sizeof(*hdr) + 1)) { - BT_ERR("Too small RFCOMM Frame"); + LOG_ERR("Too small RFCOMM Frame"); return 0; } dlci = BT_RFCOMM_GET_DLCI(hdr->address); frame_type = BT_RFCOMM_GET_FRAME_TYPE(hdr->control); - BT_DBG("session %p dlci %x type %x", session, dlci, frame_type); + LOG_DBG("session %p dlci %x type %x", session, dlci, frame_type); fcs_len = (frame_type == BT_RFCOMM_UIH) ? BT_RFCOMM_FCS_LEN_UIH : BT_RFCOMM_FCS_LEN_NON_UIH; fcs = *(net_buf_tail(buf) - 1); if (!rfcomm_check_fcs(fcs_len, buf->data, fcs)) { - BT_ERR("FCS check failed"); + LOG_ERR("FCS check failed"); return 0; } @@ -1502,8 +1501,7 @@ static int rfcomm_recv(struct bt_l2cap_chan *chan, struct net_buf *buf) rfcomm_handle_dm(session, dlci); break; default: - BT_WARN("Unknown/Unsupported RFCOMM Frame type 0x%02x", - frame_type); + LOG_WRN("Unknown/Unsupported RFCOMM Frame type 0x%02x", frame_type); break; } @@ -1517,8 +1515,7 @@ static void rfcomm_encrypt_change(struct bt_l2cap_chan *chan, struct bt_conn *conn = chan->conn; struct bt_rfcomm_dlc *dlc, *next; - BT_DBG("session %p status 0x%02x encr 0x%02x", session, hci_status, - conn->encrypt); + LOG_DBG("session %p status 0x%02x encr 0x%02x", session, hci_status, conn->encrypt); for (dlc = session->dlcs; dlc; dlc = next) { next = dlc->_next; @@ -1548,7 +1545,7 @@ static void rfcomm_session_rtx_timeout(struct k_work *work) { struct bt_rfcomm_session *session = SESSION_RTX(work); - BT_WARN("session %p state %d timeout", session, session->state); + LOG_WRN("session %p state %d timeout", session, session->state); switch (session->state) { case BT_RFCOMM_STATE_CONNECTED: @@ -1580,7 +1577,7 @@ static struct bt_rfcomm_session *rfcomm_session_new(bt_rfcomm_role_t role) continue; } - BT_DBG("session %p initialized", session); + LOG_DBG("session %p initialized", session); session->br_chan.chan.ops = &ops; session->br_chan.rx.mtu = CONFIG_BT_RFCOMM_L2CAP_MTU; @@ -1605,7 +1602,7 @@ int bt_rfcomm_dlc_connect(struct bt_conn *conn, struct bt_rfcomm_dlc *dlc, uint8_t dlci; int ret; - BT_DBG("conn %p dlc %p channel %d", conn, dlc, channel); + LOG_DBG("conn %p dlc %p channel %d", conn, dlc, channel); if (!dlc) { return -EINVAL; @@ -1665,7 +1662,7 @@ int bt_rfcomm_dlc_connect(struct bt_conn *conn, struct bt_rfcomm_dlc *dlc, k_work_cancel_delayable(&session->rtx_work); break; default: - BT_ERR("Invalid session state %d", session->state); + LOG_ERR("Invalid session state %d", session->state); ret = -EINVAL; goto fail; } @@ -1681,7 +1678,7 @@ fail: int bt_rfcomm_dlc_disconnect(struct bt_rfcomm_dlc *dlc) { - BT_DBG("dlc %p", dlc); + LOG_DBG("dlc %p", dlc); if (!dlc) { return -EINVAL; @@ -1709,7 +1706,7 @@ static int rfcomm_accept(struct bt_conn *conn, struct bt_l2cap_chan **chan) { struct bt_rfcomm_session *session; - BT_DBG("conn %p", conn); + LOG_DBG("conn %p", conn); session = rfcomm_session_new(BT_RFCOMM_ROLE_ACCEPTOR); if (session) { @@ -1717,7 +1714,7 @@ static int rfcomm_accept(struct bt_conn *conn, struct bt_l2cap_chan **chan) return 0; } - BT_ERR("No available RFCOMM context for conn %p", conn); + LOG_ERR("No available RFCOMM context for conn %p", conn); return -ENOMEM; } diff --git a/subsys/bluetooth/host/scan.c b/subsys/bluetooth/host/scan.c index 54873758c66..2afcb9bc716 100644 --- a/subsys/bluetooth/host/scan.c +++ b/subsys/bluetooth/host/scan.c @@ -22,11 +22,12 @@ #include "direction_internal.h" #include "id.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_CORE) -#define LOG_MODULE_NAME bt_scan -#include "common/log.h" #include "common/bt_str.h" +#define LOG_LEVEL CONFIG_BT_HCI_CORE_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_scan); + static bt_le_scan_cb_t *scan_dev_found_cb; static sys_slist_t scan_cbs = SYS_SLIST_STATIC_INIT(&scan_cbs); @@ -441,14 +442,14 @@ static void le_adv_recv(bt_addr_le_t *addr, struct bt_le_scan_recv_info *info, struct net_buf_simple_state state; bt_addr_le_t id_addr; - BT_DBG("%s event %u, len %u, rssi %d dBm", bt_addr_le_str(addr), - info->adv_type, len, info->rssi); + LOG_DBG("%s event %u, len %u, rssi %d dBm", bt_addr_le_str(addr), info->adv_type, len, + info->rssi); if (!IS_ENABLED(CONFIG_BT_PRIVACY) && !IS_ENABLED(CONFIG_BT_SCAN_WITH_IDENTITY) && atomic_test_bit(bt_dev.flags, BT_DEV_EXPLICIT_SCAN) && (info->adv_props & BT_HCI_LE_ADV_PROP_DIRECT)) { - BT_DBG("Dropped direct adv report"); + LOG_DBG("Dropped direct adv report"); return; } @@ -580,7 +581,7 @@ void bt_hci_le_adv_ext_report(struct net_buf *buf) { uint8_t num_reports = net_buf_pull_u8(buf); - BT_DBG("Adv number of reports %u", num_reports); + LOG_DBG("Adv number of reports %u", num_reports); while (num_reports--) { struct bt_hci_evt_le_ext_advertising_info *evt; @@ -591,7 +592,7 @@ void bt_hci_le_adv_ext_report(struct net_buf *buf) bool is_new_advertiser; if (buf->len < sizeof(*evt)) { - BT_ERR("Unexpected end of buffer"); + LOG_ERR("Unexpected end of buffer"); break; } @@ -623,7 +624,7 @@ void bt_hci_le_adv_ext_report(struct net_buf *buf) } if (is_new_advertiser && reassembling_advertiser.state == FRAG_ADV_REASSEMBLING) { - BT_WARN("Received an incomplete advertising report while reassembling " + LOG_WRN("Received an incomplete advertising report while reassembling " "advertising reports from a different advertiser. The advertising " "report is discarded and future scan results may be incomplete. " "Interleaving of fragmented advertising reports from different " @@ -772,7 +773,7 @@ void bt_hci_le_per_adv_report(struct net_buf *buf) struct bt_le_per_adv_sync_recv_info info; if (buf->len < sizeof(*evt)) { - BT_ERR("Unexpected end of buffer"); + LOG_ERR("Unexpected end of buffer"); return; } @@ -781,14 +782,14 @@ void bt_hci_le_per_adv_report(struct net_buf *buf) per_adv_sync = bt_hci_get_per_adv_sync(sys_le16_to_cpu(evt->handle)); if (!per_adv_sync) { - BT_ERR("Unknown handle 0x%04X for periodic advertising report", - sys_le16_to_cpu(evt->handle)); + LOG_ERR("Unknown handle 0x%04X for periodic advertising report", + sys_le16_to_cpu(evt->handle)); return; } if (atomic_test_bit(per_adv_sync->flags, BT_PER_ADV_SYNC_RECV_DISABLED)) { - BT_ERR("Received PA adv report when receive disabled"); + LOG_ERR("Received PA adv report when receive disabled"); return; } @@ -809,7 +810,7 @@ void bt_hci_le_per_adv_report(struct net_buf *buf) } else { if (net_buf_simple_tailroom(&per_adv_sync->reassembly) < evt->length) { /* The buffer is too small for the entire report. Drop it */ - BT_WARN("Buffer is too small to reassemble the report. " + LOG_WRN("Buffer is too small to reassemble the report. " "Use CONFIG_BT_PER_ADV_SYNC_BUF_SIZE to change " "the buffer size."); @@ -897,7 +898,7 @@ void bt_hci_le_per_adv_sync_established(struct net_buf *buf) err = bt_le_scan_update(false); if (err) { - BT_ERR("Could not update scan (%d)", err); + LOG_ERR("Could not update scan (%d)", err); } } @@ -906,7 +907,7 @@ void bt_hci_le_per_adv_sync_established(struct net_buf *buf) if (pending_per_adv_sync) { per_adv_sync_delete(pending_per_adv_sync); } else { - BT_ERR("Unexpected per adv sync cancelled event"); + LOG_ERR("Unexpected per adv sync cancelled event"); } return; @@ -917,7 +918,7 @@ void bt_hci_le_per_adv_sync_established(struct net_buf *buf) BT_PER_ADV_SYNC_SYNCING_USE_LIST) && ((pending_per_adv_sync->sid != evt->sid) || !bt_addr_le_eq(&pending_per_adv_sync->addr, &evt->adv_addr)))) { - BT_ERR("Unexpected per adv sync established event"); + LOG_ERR("Unexpected per adv sync established event"); /* Request terminate of pending periodic advertising in controller */ per_adv_sync_terminate(sys_le16_to_cpu(evt->handle)); @@ -1002,8 +1003,8 @@ void bt_hci_le_per_adv_sync_lost(struct net_buf *buf) per_adv_sync = bt_hci_get_per_adv_sync(sys_le16_to_cpu(evt->handle)); if (!per_adv_sync) { - BT_ERR("Unknown handle 0x%04Xfor periodic adv sync lost", - sys_le16_to_cpu(evt->handle)); + LOG_ERR("Unknown handle 0x%04Xfor periodic adv sync lost", + sys_le16_to_cpu(evt->handle)); return; } @@ -1022,7 +1023,7 @@ void bt_hci_le_past_received(struct net_buf *buf) if (evt->status) { /* No sync created, don't notify app */ - BT_DBG("PAST receive failed with status 0x%02X", evt->status); + LOG_DBG("PAST receive failed with status 0x%02X", evt->status); return; } @@ -1030,14 +1031,14 @@ void bt_hci_le_past_received(struct net_buf *buf) sys_le16_to_cpu(evt->conn_handle)); if (!sync_info.conn) { - BT_ERR("Could not lookup connection handle from PAST"); + LOG_ERR("Could not lookup connection handle from PAST"); per_adv_sync_terminate(sys_le16_to_cpu(evt->sync_handle)); return; } per_adv_sync = per_adv_sync_new(); if (!per_adv_sync) { - BT_WARN("Could not allocate new PA sync from PAST"); + LOG_WRN("Could not allocate new PA sync from PAST"); per_adv_sync_terminate(sys_le16_to_cpu(evt->sync_handle)); return; } @@ -1078,8 +1079,8 @@ void bt_hci_le_biginfo_adv_report(struct net_buf *buf) per_adv_sync = bt_hci_get_per_adv_sync(sys_le16_to_cpu(evt->sync_handle)); if (!per_adv_sync) { - BT_ERR("Unknown handle 0x%04X for periodic advertising report", - sys_le16_to_cpu(evt->sync_handle)); + LOG_ERR("Unknown handle 0x%04X for periodic advertising report", + sys_le16_to_cpu(evt->sync_handle)); return; } @@ -1117,18 +1118,18 @@ static void bt_hci_le_df_connectionless_iq_report_common(uint8_t event, struct n if (event == BT_HCI_EVT_LE_CONNECTIONLESS_IQ_REPORT) { err = hci_df_prepare_connectionless_iq_report(buf, &cte_report, &per_adv_sync); if (err) { - BT_ERR("Prepare CTE conn IQ report failed %d", err); + LOG_ERR("Prepare CTE conn IQ report failed %d", err); return; } } else if (IS_ENABLED(CONFIG_BT_DF_VS_CL_IQ_REPORT_16_BITS_IQ_SAMPLES) && event == BT_HCI_EVT_VS_LE_CONNECTIONLESS_IQ_REPORT) { err = hci_df_vs_prepare_connectionless_iq_report(buf, &cte_report, &per_adv_sync); if (err) { - BT_ERR("Prepare CTE conn IQ report failed %d", err); + LOG_ERR("Prepare CTE conn IQ report failed %d", err); return; } } else { - BT_ERR("Unhandled VS connectionless IQ report"); + LOG_ERR("Unhandled VS connectionless IQ report"); return; } @@ -1160,13 +1161,13 @@ void bt_hci_le_adv_report(struct net_buf *buf) uint8_t num_reports = net_buf_pull_u8(buf); struct bt_hci_evt_le_advertising_info *evt; - BT_DBG("Adv number of reports %u", num_reports); + LOG_DBG("Adv number of reports %u", num_reports); while (num_reports--) { struct bt_le_scan_recv_info adv_info; if (buf->len < sizeof(*evt)) { - BT_ERR("Unexpected end of buffer"); + LOG_ERR("Unexpected end of buffer"); break; } @@ -1824,7 +1825,7 @@ int bt_le_per_adv_list_add(const bt_addr_le_t *addr, uint8_t sid) err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_ADD_DEV_TO_PER_ADV_LIST, buf, NULL); if (err) { - BT_ERR("Failed to add device to periodic advertiser list"); + LOG_ERR("Failed to add device to periodic advertiser list"); return err; } @@ -1855,7 +1856,7 @@ int bt_le_per_adv_list_remove(const bt_addr_le_t *addr, uint8_t sid) err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_REM_DEV_FROM_PER_ADV_LIST, buf, NULL); if (err) { - BT_ERR("Failed to remove device from periodic advertiser list"); + LOG_ERR("Failed to remove device from periodic advertiser list"); return err; } @@ -1872,7 +1873,7 @@ int bt_le_per_adv_list_clear(void) err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_CLEAR_PER_ADV_LIST, NULL, NULL); if (err) { - BT_ERR("Failed to clear periodic advertiser list"); + LOG_ERR("Failed to clear periodic advertiser list"); return err; } diff --git a/subsys/bluetooth/host/sdp.c b/subsys/bluetooth/host/sdp.c index f07ea1ef4cd..ae20b5dfa79 100644 --- a/subsys/bluetooth/host/sdp.c +++ b/subsys/bluetooth/host/sdp.c @@ -16,9 +16,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_SDP) -#define LOG_MODULE_NAME bt_sdp -#include "common/log.h" #include "common/bt_str.h" #include "common/assert.h" @@ -27,6 +24,10 @@ #include "l2cap_internal.h" #include "sdp_internal.h" +#define LOG_LEVEL CONFIG_BT_SDP_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_sdp); + #define SDP_PSM 0x0001 #define SDP_CHAN(_ch) CONTAINER_OF(_ch, struct bt_sdp, chan.chan) @@ -159,7 +160,7 @@ static void bt_sdp_connected(struct bt_l2cap_chan *chan) struct bt_sdp *sdp = CONTAINER_OF(ch, struct bt_sdp, chan); - BT_DBG("chan %p cid 0x%04x", ch, ch->tx.cid); + LOG_DBG("chan %p cid 0x%04x", ch, ch->tx.cid); k_fifo_init(&sdp->partial_resp_queue); } @@ -180,7 +181,7 @@ static void bt_sdp_disconnected(struct bt_l2cap_chan *chan) struct bt_sdp *sdp = CONTAINER_OF(ch, struct bt_sdp, chan); - BT_DBG("chan %p cid 0x%04x", ch, ch->tx.cid); + LOG_DBG("chan %p cid 0x%04x", ch, ch->tx.cid); (void)memset(sdp, 0, sizeof(*sdp)); } @@ -244,7 +245,7 @@ static void send_err_rsp(struct bt_l2cap_chan *chan, uint16_t err, { struct net_buf *buf; - BT_DBG("tid %u, error %u", tid, err); + LOG_DBG("tid %u, error %u", tid, err); buf = bt_sdp_create_pdu(); @@ -270,7 +271,7 @@ static uint16_t parse_data_elem(struct net_buf *buf, uint8_t size_field_len = 0U; /* Space used to accommodate the size */ if (buf->len < 1) { - BT_WARN("Malformed packet"); + LOG_WRN("Malformed packet"); return BT_SDP_INVALID_SYNTAX; } @@ -291,7 +292,7 @@ static uint16_t parse_data_elem(struct net_buf *buf, size_field_len = BIT((data_elem->type & BT_SDP_SIZE_DESC_MASK) - BT_SDP_SIZE_INDEX_OFFSET); if (buf->len < size_field_len) { - BT_WARN("Malformed packet"); + LOG_WRN("Malformed packet"); return BT_SDP_INVALID_SYNTAX; } switch (size_field_len) { @@ -305,17 +306,17 @@ static uint16_t parse_data_elem(struct net_buf *buf, data_elem->data_size = net_buf_pull_be32(buf); break; default: - BT_WARN("Invalid size in remote request"); + LOG_WRN("Invalid size in remote request"); return BT_SDP_INVALID_SYNTAX; } break; default: - BT_WARN("Invalid type in remote request"); + LOG_WRN("Invalid type in remote request"); return BT_SDP_INVALID_SYNTAX; } if (buf->len < data_elem->data_size) { - BT_WARN("Malformed packet"); + LOG_WRN("Malformed packet"); return BT_SDP_INVALID_SYNTAX; } @@ -384,7 +385,7 @@ static uint32_t search_uuid(struct bt_sdp_data_elem *elem, struct bt_uuid *uuid, *found = true; } } else { - BT_WARN("Invalid UUID size in local database"); + LOG_WRN("Invalid UUID size in local database"); BT_ASSERT(0); } } @@ -485,8 +486,7 @@ static uint16_t find_services(struct net_buf *buf, if (((data_elem.type & BT_SDP_TYPE_DESC_MASK) != BT_SDP_SEQ_UNSPEC) && ((data_elem.type & BT_SDP_TYPE_DESC_MASK) != BT_SDP_ALT_UNSPEC)) { - BT_WARN("Invalid type %x in service search pattern", - data_elem.type); + LOG_WRN("Invalid type %x in service search pattern", data_elem.type); return BT_SDP_INVALID_SYNTAX; } @@ -503,13 +503,12 @@ static uint16_t find_services(struct net_buf *buf, if ((data_elem.type & BT_SDP_TYPE_DESC_MASK) != BT_SDP_UUID_UNSPEC) { - BT_WARN("Invalid type %u in service search pattern", - data_elem.type); + LOG_WRN("Invalid type %u in service search pattern", data_elem.type); return BT_SDP_INVALID_SYNTAX; } if (buf->len < data_elem.data_size) { - BT_WARN("Malformed packet"); + LOG_WRN("Malformed packet"); return BT_SDP_INVALID_SYNTAX; } @@ -525,7 +524,7 @@ static uint16_t find_services(struct net_buf *buf, data_elem.data_size); net_buf_pull(buf, data_elem.data_size); } else { - BT_WARN("Invalid UUID len %u in service search pattern", + LOG_WRN("Invalid UUID len %u in service search pattern", data_elem.data_size); net_buf_pull(buf, data_elem.data_size); } @@ -594,7 +593,7 @@ static uint16_t sdp_svc_search_req(struct bt_sdp *sdp, struct net_buf *buf, } if (buf->len < 3) { - BT_WARN("Malformed packet"); + LOG_WRN("Malformed packet"); return BT_SDP_INVALID_SYNTAX; } @@ -618,12 +617,12 @@ static uint16_t sdp_svc_search_req(struct bt_sdp *sdp, struct net_buf *buf, */ if (cont_state_size) { if (cont_state_size != SDP_SS_CONT_STATE_SIZE) { - BT_WARN("Invalid cont state size %u", cont_state_size); + LOG_WRN("Invalid cont state size %u", cont_state_size); return BT_SDP_INVALID_CSTATE; } if (buf->len < cont_state_size) { - BT_WARN("Malformed packet"); + LOG_WRN("Malformed packet"); return BT_SDP_INVALID_SYNTAX; } @@ -634,7 +633,7 @@ static uint16_t sdp_svc_search_req(struct bt_sdp *sdp, struct net_buf *buf, total_recs = net_buf_pull_be16(buf); } - BT_DBG("max_rec_count %u, cont_state %u", max_rec_count, cont_state); + LOG_DBG("max_rec_count %u, cont_state %u", max_rec_count, cont_state); resp_buf = bt_sdp_create_pdu(); rsp = net_buf_add(resp_buf, sizeof(*rsp)); @@ -664,8 +663,7 @@ static uint16_t sdp_svc_search_req(struct bt_sdp *sdp, struct net_buf *buf, if (pkt_full) { /* Packet exhausted: Add continuation state and break */ - BT_DBG("Packet full, num_services_covered %u", - cont_state); + LOG_DBG("Packet full, num_services_covered %u", cont_state); net_buf_add_u8(resp_buf, SDP_SS_CONT_STATE_SIZE); net_buf_add_u8(resp_buf, cont_state); @@ -695,7 +693,7 @@ static uint16_t sdp_svc_search_req(struct bt_sdp *sdp, struct net_buf *buf, rsp->total_recs = sys_cpu_to_be16(total_recs); rsp->current_recs = sys_cpu_to_be16(current_recs); - BT_DBG("Sending response, len %u", resp_buf->len); + LOG_DBG("Sending response, len %u", resp_buf->len); bt_sdp_send(&sdp->chan.chan, resp_buf, BT_SDP_SVC_SEARCH_RSP, tid); return 0; @@ -1006,13 +1004,12 @@ static uint16_t get_att_search_list(struct net_buf *buf, uint32_t *filter, } if ((data_elem.type & BT_SDP_TYPE_DESC_MASK) != BT_SDP_UINT8) { - BT_WARN("Invalid type %u in attribute ID list", - data_elem.type); + LOG_WRN("Invalid type %u in attribute ID list", data_elem.type); return BT_SDP_INVALID_SYNTAX; } if (buf->len < data_elem.data_size) { - BT_WARN("Malformed packet"); + LOG_WRN("Malformed packet"); return BT_SDP_INVALID_SYNTAX; } @@ -1081,7 +1078,7 @@ static uint16_t sdp_svc_att_req(struct bt_sdp *sdp, struct net_buf *buf, uint8_t num_filters, cont_state_size, next_att = 0U; if (buf->len < 6) { - BT_WARN("Malformed packet"); + LOG_WRN("Malformed packet"); return BT_SDP_INVALID_SYNTAX; } @@ -1096,7 +1093,7 @@ static uint16_t sdp_svc_att_req(struct bt_sdp *sdp, struct net_buf *buf, } if (buf->len < 1) { - BT_WARN("Malformed packet"); + LOG_WRN("Malformed packet"); return BT_SDP_INVALID_SYNTAX; } @@ -1107,12 +1104,12 @@ static uint16_t sdp_svc_att_req(struct bt_sdp *sdp, struct net_buf *buf, */ if (cont_state_size) { if (cont_state_size != SDP_SA_CONT_STATE_SIZE) { - BT_WARN("Invalid cont state size %u", cont_state_size); + LOG_WRN("Invalid cont state size %u", cont_state_size); return BT_SDP_INVALID_CSTATE; } if (buf->len < cont_state_size) { - BT_WARN("Malformed packet"); + LOG_WRN("Malformed packet"); return BT_SDP_INVALID_SYNTAX; } @@ -1120,14 +1117,14 @@ static uint16_t sdp_svc_att_req(struct bt_sdp *sdp, struct net_buf *buf, next_att = state.last_att; } - BT_DBG("svc_rec_hdl %u, max_att_len 0x%04x, cont_state %u", svc_rec_hdl, - max_att_len, next_att); + LOG_DBG("svc_rec_hdl %u, max_att_len 0x%04x, cont_state %u", svc_rec_hdl, max_att_len, + next_att); /* Find the service */ record = bt_sdp_foreach_svc(find_handle, &svc_rec_hdl); if (!record) { - BT_WARN("Handle %u not found", svc_rec_hdl); + LOG_WRN("Handle %u not found", svc_rec_hdl); return BT_SDP_INVALID_RECORD_HANDLE; } @@ -1153,7 +1150,7 @@ static uint16_t sdp_svc_att_req(struct bt_sdp *sdp, struct net_buf *buf, /* Add continuation state */ if (state.pkt_full) { - BT_DBG("Packet full, state.last_att %u", state.last_att); + LOG_DBG("Packet full, state.last_att %u", state.last_att); net_buf_add_u8(rsp_buf, 1); net_buf_add_u8(rsp_buf, state.last_att); } else { @@ -1162,7 +1159,7 @@ static uint16_t sdp_svc_att_req(struct bt_sdp *sdp, struct net_buf *buf, rsp->att_list_len = sys_cpu_to_be16(att_list_len); - BT_DBG("Sending response, len %u", rsp_buf->len); + LOG_DBG("Sending response, len %u", rsp_buf->len); bt_sdp_send(&sdp->chan.chan, rsp_buf, BT_SDP_SVC_ATTR_RSP, tid); return 0; @@ -1203,7 +1200,7 @@ static uint16_t sdp_svc_search_att_req(struct bt_sdp *sdp, struct net_buf *buf, } if (buf->len < 2) { - BT_WARN("Malformed packet"); + LOG_WRN("Malformed packet"); return BT_SDP_INVALID_SYNTAX; } @@ -1218,7 +1215,7 @@ static uint16_t sdp_svc_search_att_req(struct bt_sdp *sdp, struct net_buf *buf, } if (buf->len < 1) { - BT_WARN("Malformed packet"); + LOG_WRN("Malformed packet"); return BT_SDP_INVALID_SYNTAX; } @@ -1229,12 +1226,12 @@ static uint16_t sdp_svc_search_att_req(struct bt_sdp *sdp, struct net_buf *buf, */ if (cont_state_size) { if (cont_state_size != SDP_SSA_CONT_STATE_SIZE) { - BT_WARN("Invalid cont state size %u", cont_state_size); + LOG_WRN("Invalid cont state size %u", cont_state_size); return BT_SDP_INVALID_CSTATE; } if (buf->len < cont_state_size) { - BT_WARN("Malformed packet"); + LOG_WRN("Malformed packet"); return BT_SDP_INVALID_SYNTAX; } @@ -1244,8 +1241,8 @@ static uint16_t sdp_svc_search_att_req(struct bt_sdp *sdp, struct net_buf *buf, next_att = state.last_att; } - BT_DBG("max_att_len 0x%04x, state.current_svc %u, state.last_att %u", - max_att_len, state.current_svc, state.last_att); + LOG_DBG("max_att_len 0x%04x, state.current_svc %u, state.last_att %u", max_att_len, + state.current_svc, state.last_att); rsp_buf = bt_sdp_create_pdu(); @@ -1277,8 +1274,7 @@ static uint16_t sdp_svc_search_att_req(struct bt_sdp *sdp, struct net_buf *buf, /* Check if packet is full and not dry run */ if (state.pkt_full && !dry_run) { - BT_DBG("Packet full, state.last_att %u", - state.last_att); + LOG_DBG("Packet full, state.last_att %u", state.last_att); dry_run = true; /* Add continuation state */ @@ -1315,7 +1311,7 @@ static uint16_t sdp_svc_search_att_req(struct bt_sdp *sdp, struct net_buf *buf, seq->size = sys_cpu_to_be16(state.att_list_size); } - BT_DBG("Sending response, len %u", rsp_buf->len); + LOG_DBG("Sending response, len %u", rsp_buf->len); bt_sdp_send(&sdp->chan.chan, rsp_buf, BT_SDP_SVC_SEARCH_ATTR_RSP, tid); @@ -1350,17 +1346,17 @@ static int bt_sdp_recv(struct bt_l2cap_chan *chan, struct net_buf *buf) uint16_t err = BT_SDP_INVALID_SYNTAX; size_t i; - BT_DBG("chan %p, ch %p, cid 0x%04x", chan, ch, ch->tx.cid); + LOG_DBG("chan %p, ch %p, cid 0x%04x", chan, ch, ch->tx.cid); BT_ASSERT(sdp); if (buf->len < sizeof(*hdr)) { - BT_ERR("Too small SDP PDU received"); + LOG_ERR("Too small SDP PDU received"); return 0; } hdr = net_buf_pull_mem(buf, sizeof(*hdr)); - BT_DBG("Received SDP code 0x%02x len %u", hdr->op_code, buf->len); + LOG_DBG("Received SDP code 0x%02x len %u", hdr->op_code, buf->len); if (sys_cpu_to_be16(hdr->param_len) != buf->len) { err = BT_SDP_INVALID_PDU_SIZE; @@ -1376,7 +1372,7 @@ static int bt_sdp_recv(struct bt_l2cap_chan *chan, struct net_buf *buf) } if (err) { - BT_WARN("SDP error 0x%02x", err); + LOG_WRN("SDP error 0x%02x", err); send_err_rsp(chan, err, hdr->tid); } @@ -1402,7 +1398,7 @@ static int bt_sdp_accept(struct bt_conn *conn, struct bt_l2cap_chan **chan) }; int i; - BT_DBG("conn %p", conn); + LOG_DBG("conn %p", conn); for (i = 0; i < ARRAY_SIZE(bt_sdp_pool); i++) { struct bt_sdp *sdp = &bt_sdp_pool[i]; @@ -1419,7 +1415,7 @@ static int bt_sdp_accept(struct bt_conn *conn, struct bt_l2cap_chan **chan) return 0; } - BT_ERR("No available SDP context for conn %p", conn); + LOG_ERR("No available SDP context for conn %p", conn); return -ENOMEM; } @@ -1435,7 +1431,7 @@ void bt_sdp_init(void) res = bt_l2cap_br_server_register(&server); if (res) { - BT_ERR("L2CAP server registration failed with error %d", res); + LOG_ERR("L2CAP server registration failed with error %d", res); } } @@ -1444,12 +1440,12 @@ int bt_sdp_register_service(struct bt_sdp_record *service) uint32_t handle = SDP_SERVICE_HANDLE_BASE; if (!service) { - BT_ERR("No service record specified"); + LOG_ERR("No service record specified"); return 0; } if (num_services == BT_SDP_MAX_SERVICES) { - BT_ERR("Reached max allowed registrations"); + LOG_ERR("Reached max allowed registrations"); return -ENOMEM; } @@ -1463,7 +1459,7 @@ int bt_sdp_register_service(struct bt_sdp_record *service) *((uint32_t *)(service->attrs[0].val.data)) = handle; db = service; - BT_DBG("Service registered at %u", handle); + LOG_DBG("Service registered at %u", handle); return 0; } @@ -1490,7 +1486,7 @@ static int sdp_client_ssa_search(struct bt_sdp_client *session) } if (!param) { - BT_WARN("No UUIDs to be resolved on remote"); + LOG_WRN("No UUIDs to be resolved on remote"); return -EINVAL; } @@ -1520,7 +1516,7 @@ static int sdp_client_ssa_search(struct bt_sdp_client *session) ARRAY_SIZE(BT_UUID_128(param->uuid)->val)); break; default: - BT_ERR("Unknown UUID type %u", param->uuid->type); + LOG_ERR("Unknown UUID type %u", param->uuid->type); return -EINVAL; } @@ -1570,7 +1566,7 @@ static void sdp_client_params_iterator(struct bt_sdp_client *session) continue; } - BT_DBG(""); + LOG_DBG(""); /* Remove already checked UUID node */ sys_slist_remove(&session->reqs, NULL, ¶m->_node); @@ -1617,12 +1613,12 @@ static uint16_t sdp_client_get_total(struct bt_sdp_client *session, pulled += 2U; break; default: - BT_WARN("Sequence type 0x%02x not handled", seq); + LOG_WRN("Sequence type 0x%02x not handled", seq); *total = 0U; break; } - BT_DBG("Total %u octets of all attributes", *total); + LOG_DBG("Total %u octets of all attributes", *total); } else { pulled = 0U; *total = 0U; @@ -1646,12 +1642,12 @@ static uint16_t get_record_len(struct net_buf *buf) len = net_buf_pull_be16(buf); break; default: - BT_WARN("Sequence type 0x%02x not handled", seq); + LOG_WRN("Sequence type 0x%02x not handled", seq); len = 0U; break; } - BT_DBG("Record len %u", len); + LOG_DBG("Record len %u", len); return len; } @@ -1723,31 +1719,31 @@ static int sdp_client_receive(struct bt_l2cap_chan *chan, struct net_buf *buf) uint16_t len, tid, frame_len; uint16_t total; - BT_DBG("session %p buf %p", session, buf); + LOG_DBG("session %p buf %p", session, buf); if (buf->len < sizeof(*hdr)) { - BT_ERR("Too small SDP PDU"); + LOG_ERR("Too small SDP PDU"); return 0; } hdr = net_buf_pull_mem(buf, sizeof(*hdr)); if (hdr->op_code == BT_SDP_ERROR_RSP) { - BT_INFO("Error SDP PDU response"); + LOG_INF("Error SDP PDU response"); return 0; } len = sys_be16_to_cpu(hdr->param_len); tid = sys_be16_to_cpu(hdr->tid); - BT_DBG("SDP PDU tid %u len %u", tid, len); + LOG_DBG("SDP PDU tid %u len %u", tid, len); if (buf->len != len) { - BT_ERR("SDP PDU length mismatch (%u != %u)", buf->len, len); + LOG_ERR("SDP PDU length mismatch (%u != %u)", buf->len, len); return 0; } if (tid != session->tid) { - BT_ERR("Mismatch transaction ID value in SDP PDU"); + LOG_ERR("Mismatch transaction ID value in SDP PDU"); return 0; } @@ -1757,12 +1753,12 @@ static int sdp_client_receive(struct bt_l2cap_chan *chan, struct net_buf *buf) frame_len = net_buf_pull_be16(buf); /* Check valid buf len for attribute list and cont state */ if (buf->len < frame_len + SDP_CONT_STATE_LEN_SIZE) { - BT_ERR("Invalid frame payload length"); + LOG_ERR("Invalid frame payload length"); return 0; } /* Check valid range of attributes length */ if (frame_len < 2) { - BT_ERR("Invalid attributes data length"); + LOG_ERR("Invalid attributes data length"); return 0; } @@ -1770,14 +1766,13 @@ static int sdp_client_receive(struct bt_l2cap_chan *chan, struct net_buf *buf) cstate = (struct bt_sdp_pdu_cstate *)(buf->data + frame_len); if (cstate->length > BT_SDP_MAX_PDU_CSTATE_LEN) { - BT_ERR("Invalid SDP PDU Continuation State length %u", - cstate->length); + LOG_ERR("Invalid SDP PDU Continuation State length %u", cstate->length); return 0; } if ((frame_len + SDP_CONT_STATE_LEN_SIZE + cstate->length) > buf->len) { - BT_ERR("Invalid frame payload length"); + LOG_ERR("Invalid frame payload length"); return 0; } @@ -1788,7 +1783,7 @@ static int sdp_client_receive(struct bt_l2cap_chan *chan, struct net_buf *buf) */ if (frame_len == 2U && cstate->length == 0U && session->cstate.length == 0U) { - BT_DBG("record for UUID 0x%s not found", + LOG_DBG("record for UUID 0x%s not found", bt_uuid_str(session->param->uuid)); /* Call user UUID handler */ sdp_client_notify_result(session, UUID_NOT_RESOLVED); @@ -1800,7 +1795,7 @@ static int sdp_client_receive(struct bt_l2cap_chan *chan, struct net_buf *buf) frame_len -= sdp_client_get_total(session, buf, &total); if (total > net_buf_tailroom(session->rec_buf)) { - BT_WARN("Not enough room for getting records data"); + LOG_WRN("Not enough room for getting records data"); goto iterate; } @@ -1826,14 +1821,14 @@ static int sdp_client_receive(struct bt_l2cap_chan *chan, struct net_buf *buf) net_buf_pull(buf, sizeof(cstate->length)); - BT_DBG("UUID 0x%s resolved", bt_uuid_str(session->param->uuid)); + LOG_DBG("UUID 0x%s resolved", bt_uuid_str(session->param->uuid)); sdp_client_notify_result(session, UUID_RESOLVED); iterate: /* Get next UUID and start resolving it */ sdp_client_params_iterator(session); break; default: - BT_DBG("PDU 0x%0x response not handled", hdr->op_code); + LOG_DBG("PDU 0x%0x response not handled", hdr->op_code); break; } @@ -1851,7 +1846,7 @@ static struct net_buf *sdp_client_alloc_buf(struct bt_l2cap_chan *chan) struct bt_sdp_client *session = SDP_CLIENT_CHAN(chan); struct net_buf *buf; - BT_DBG("session %p chan %p", session, chan); + LOG_DBG("session %p chan %p", session, chan); session->param = GET_PARAM(sys_slist_peek_head(&session->reqs)); @@ -1865,7 +1860,7 @@ static void sdp_client_connected(struct bt_l2cap_chan *chan) { struct bt_sdp_client *session = SDP_CLIENT_CHAN(chan); - BT_DBG("session %p chan %p connected", session, chan); + LOG_DBG("session %p chan %p connected", session, chan); session->rec_buf = chan->ops->alloc_buf(chan); @@ -1876,7 +1871,7 @@ static void sdp_client_disconnected(struct bt_l2cap_chan *chan) { struct bt_sdp_client *session = SDP_CLIENT_CHAN(chan); - BT_DBG("session %p chan %p disconnected", session, chan); + LOG_DBG("session %p chan %p disconnected", session, chan); net_buf_unref(session->rec_buf); @@ -1916,14 +1911,14 @@ static struct bt_sdp_client *sdp_client_new_session(struct bt_conn *conn) err = sdp_client_chan_connect(session); if (err) { (void)memset(session, 0, sizeof(*session)); - BT_ERR("Cannot connect %d", err); + LOG_ERR("Cannot connect %d", err); return NULL; } return session; } - BT_ERR("No available SDP client context"); + LOG_ERR("No available SDP client context"); return NULL; } @@ -1951,7 +1946,7 @@ int bt_sdp_discover(struct bt_conn *conn, struct bt_sdp_client *session; if (!params || !params->uuid || !params->func || !params->pool) { - BT_WARN("Invalid user params"); + LOG_WRN("Invalid user params"); return -EINVAL; } @@ -2005,11 +2000,11 @@ static inline ssize_t sdp_get_int_len(const uint8_t *data, size_t len) case BT_SDP_INT128: case BT_SDP_UINT128: default: - BT_ERR("Invalid/unhandled DTD 0x%02x", data[0]); + LOG_ERR("Invalid/unhandled DTD 0x%02x", data[0]); return -EINVAL; } - BT_ERR("Too short buffer length %zu", len); + LOG_ERR("Too short buffer length %zu", len); return -EMSGSIZE; } @@ -2033,11 +2028,11 @@ static inline ssize_t sdp_get_uuid_len(const uint8_t *data, size_t len) return 5; case BT_SDP_UUID128: default: - BT_ERR("Invalid/unhandled DTD 0x%02x", data[0]); + LOG_ERR("Invalid/unhandled DTD 0x%02x", data[0]); return -EINVAL; } - BT_ERR("Too short buffer length %zu", len); + LOG_ERR("Too short buffer length %zu", len); return -EMSGSIZE; } @@ -2078,11 +2073,11 @@ static inline ssize_t sdp_get_str_len(const uint8_t *data, size_t len) case BT_SDP_TEXT_STR32: case BT_SDP_URL_STR32: default: - BT_ERR("Invalid/unhandled DTD 0x%02x", data[0]); + LOG_ERR("Invalid/unhandled DTD 0x%02x", data[0]); return -EINVAL; } err: - BT_ERR("Too short buffer length %zu", len); + LOG_ERR("Too short buffer length %zu", len); return -EMSGSIZE; } @@ -2123,11 +2118,11 @@ static inline ssize_t sdp_get_seq_len(const uint8_t *data, size_t len) case BT_SDP_SEQ32: case BT_SDP_ALT32: default: - BT_ERR("Invalid/unhandled DTD 0x%02x", data[0]); + LOG_ERR("Invalid/unhandled DTD 0x%02x", data[0]); return -EINVAL; } err: - BT_ERR("Too short buffer length %zu", len); + LOG_ERR("Too short buffer length %zu", len); return -EMSGSIZE; } @@ -2136,7 +2131,7 @@ static ssize_t sdp_get_attr_value_len(const uint8_t *data, size_t len) { BT_ASSERT(data); - BT_DBG("Attr val DTD 0x%02x", data[0]); + LOG_DBG("Attr val DTD 0x%02x", data[0]); if (len < 1) { goto err; @@ -2175,11 +2170,11 @@ static ssize_t sdp_get_attr_value_len(const uint8_t *data, size_t len) case BT_SDP_ALT32: return sdp_get_seq_len(data, len); default: - BT_ERR("Unknown DTD 0x%02x", data[0]); + LOG_ERR("Unknown DTD 0x%02x", data[0]); return -EINVAL; } err: - BT_ERR("Too short buffer length %zu", len); + LOG_ERR("Too short buffer length %zu", len); return -EMSGSIZE; } @@ -2220,7 +2215,7 @@ static int bt_sdp_get_attr(const struct net_buf *buf, /* data need to point to attribute id descriptor field (DTD)*/ if (data[0] != BT_SDP_UINT16) { - BT_ERR("Invalid descriptor 0x%02x", data[0]); + LOG_ERR("Invalid descriptor 0x%02x", data[0]); return -EINVAL; } @@ -2229,18 +2224,18 @@ static int bt_sdp_get_attr(const struct net_buf *buf, return -EINVAL; } id = sys_get_be16(data); - BT_DBG("Attribute ID 0x%04x", id); + LOG_DBG("Attribute ID 0x%04x", id); data += sizeof(uint16_t); dlen = sdp_get_attr_value_len(data, buf->len - (data - buf->data)); if (dlen < 0) { - BT_ERR("Invalid attribute value data"); + LOG_ERR("Invalid attribute value data"); return -EINVAL; } if (id == attr_id) { - BT_DBG("Attribute ID 0x%04x Value found", id); + LOG_DBG("Attribute ID 0x%04x Value found", id); /* * Initialize attribute value buffer data using selected * data slice from original buffer. @@ -2305,11 +2300,11 @@ static ssize_t sdp_get_seq_len_item(uint8_t **data, size_t len) *data += 5; return sys_get_be32(pnext); default: - BT_ERR("Invalid/unhandled DTD 0x%02x", *data[0]); + LOG_ERR("Invalid/unhandled DTD 0x%02x", *data[0]); return -EINVAL; } err: - BT_ERR("Too short buffer length %zu", len); + LOG_ERR("Too short buffer length %zu", len); return -EMSGSIZE; } @@ -2403,7 +2398,7 @@ static int sdp_get_uuid_data(const struct bt_sdp_attr_item *attr, left -= sizeof(BT_UUID_SIZE_32); break; default: - BT_ERR("Invalid/unhandled DTD 0x%02x\n", dtd); + LOG_ERR("Invalid/unhandled DTD 0x%02x\n", dtd); return -EINVAL; } @@ -2416,7 +2411,7 @@ static int sdp_get_uuid_data(const struct bt_sdp_attr_item *attr, pd->params = p; pd->params_len = left; - BT_DBG("UUID 0x%s found", bt_uuid_str(&pd->uuid)); + LOG_DBG("UUID 0x%s found", bt_uuid_str(&pd->uuid)); if (proto_profile_index > 0U) { proto_profile_index--; p += left; @@ -2430,7 +2425,7 @@ static int sdp_get_uuid_data(const struct bt_sdp_attr_item *attr, p += left; } - BT_DBG("Value 0x%04x index %d not found", proto_profile, proto_profile_index); + LOG_DBG("Value 0x%04x index %d not found", proto_profile, proto_profile_index); return -ENOENT; } @@ -2445,7 +2440,7 @@ static int sdp_get_param_item(struct bt_sdp_uuid_desc *pd_item, uint16_t *param) BT_ASSERT(p); - BT_DBG("Getting UUID's 0x%s params", bt_uuid_str(&pd_item->uuid)); + LOG_DBG("Getting UUID's 0x%s params", bt_uuid_str(&pd_item->uuid)); switch (p[0]) { case BT_SDP_UINT8: @@ -2476,7 +2471,7 @@ static int sdp_get_param_item(struct bt_sdp_uuid_desc *pd_item, uint16_t *param) p += sizeof(uint32_t); break; default: - BT_ERR("Invalid/unhandled DTD 0x%02x\n", p[0]); + LOG_ERR("Invalid/unhandled DTD 0x%02x\n", p[0]); return -EINVAL; } /* @@ -2484,7 +2479,7 @@ static int sdp_get_param_item(struct bt_sdp_uuid_desc *pd_item, uint16_t *param) * valid case after getting parameter we should reach data buf end. */ if (p - pd_item->params != pd_item->params_len || len_err) { - BT_DBG("Invalid param buffer length"); + LOG_DBG("Invalid param buffer length"); return -EMSGSIZE; } @@ -2499,21 +2494,19 @@ int bt_sdp_get_proto_param(const struct net_buf *buf, enum bt_sdp_proto proto, int res; if (proto != BT_SDP_PROTO_RFCOMM && proto != BT_SDP_PROTO_L2CAP) { - BT_ERR("Invalid protocol specifier"); + LOG_ERR("Invalid protocol specifier"); return -EINVAL; } res = bt_sdp_get_attr(buf, &attr, BT_SDP_ATTR_PROTO_DESC_LIST); if (res < 0) { - BT_WARN("Attribute 0x%04x not found, err %d", - BT_SDP_ATTR_PROTO_DESC_LIST, res); + LOG_WRN("Attribute 0x%04x not found, err %d", BT_SDP_ATTR_PROTO_DESC_LIST, res); return res; } res = sdp_get_uuid_data(&attr, &pd, proto, 0U); if (res < 0) { - BT_WARN("Protocol specifier 0x%04x not found, err %d", proto, - res); + LOG_WRN("Protocol specifier 0x%04x not found, err %d", proto, res); return res; } @@ -2528,21 +2521,19 @@ int bt_sdp_get_addl_proto_param(const struct net_buf *buf, enum bt_sdp_proto pro int res; if (proto != BT_SDP_PROTO_RFCOMM && proto != BT_SDP_PROTO_L2CAP) { - BT_ERR("Invalid protocol specifier"); + LOG_ERR("Invalid protocol specifier"); return -EINVAL; } res = bt_sdp_get_attr(buf, &attr, BT_SDP_ATTR_ADD_PROTO_DESC_LIST); if (res < 0) { - BT_WARN("Attribute 0x%04x not found, err %d", - BT_SDP_ATTR_PROTO_DESC_LIST, res); + LOG_WRN("Attribute 0x%04x not found, err %d", BT_SDP_ATTR_PROTO_DESC_LIST, res); return res; } res = sdp_get_uuid_data(&attr, &pd, proto, param_index); if (res < 0) { - BT_WARN("Protocol specifier 0x%04x not found, err %d", proto, - res); + LOG_WRN("Protocol specifier 0x%04x not found, err %d", proto, res); return res; } @@ -2558,14 +2549,13 @@ int bt_sdp_get_profile_version(const struct net_buf *buf, uint16_t profile, res = bt_sdp_get_attr(buf, &attr, BT_SDP_ATTR_PROFILE_DESC_LIST); if (res < 0) { - BT_WARN("Attribute 0x%04x not found, err %d", - BT_SDP_ATTR_PROFILE_DESC_LIST, res); + LOG_WRN("Attribute 0x%04x not found, err %d", BT_SDP_ATTR_PROFILE_DESC_LIST, res); return res; } res = sdp_get_uuid_data(&attr, &pd, profile, 0U); if (res < 0) { - BT_WARN("Profile 0x%04x not found, err %d", profile, res); + LOG_WRN("Profile 0x%04x not found, err %d", profile, res); return res; } @@ -2580,8 +2570,7 @@ int bt_sdp_get_features(const struct net_buf *buf, uint16_t *features) res = bt_sdp_get_attr(buf, &attr, BT_SDP_ATTR_SUPPORTED_FEATURES); if (res < 0) { - BT_WARN("Attribute 0x%04x not found, err %d", - BT_SDP_ATTR_SUPPORTED_FEATURES, res); + LOG_WRN("Attribute 0x%04x not found, err %d", BT_SDP_ATTR_SUPPORTED_FEATURES, res); return res; } @@ -2589,13 +2578,13 @@ int bt_sdp_get_features(const struct net_buf *buf, uint16_t *features) BT_ASSERT(p); if (p[0] != BT_SDP_UINT16) { - BT_ERR("Invalid DTD 0x%02x", p[0]); + LOG_ERR("Invalid DTD 0x%02x", p[0]); return -EINVAL; } /* assert 16bit can be read safely */ if (attr.len < 3) { - BT_ERR("Data length too short %u", attr.len); + LOG_ERR("Data length too short %u", attr.len); return -EMSGSIZE; } @@ -2603,7 +2592,7 @@ int bt_sdp_get_features(const struct net_buf *buf, uint16_t *features) p += sizeof(uint16_t); if (p - attr.val != attr.len) { - BT_ERR("Invalid data length %u", attr.len); + LOG_ERR("Invalid data length %u", attr.len); return -EMSGSIZE; } diff --git a/subsys/bluetooth/host/settings.c b/subsys/bluetooth/host/settings.c index 1ab915ffe94..b0abba0fb73 100644 --- a/subsys/bluetooth/host/settings.c +++ b/subsys/bluetooth/host/settings.c @@ -11,15 +11,17 @@ #include #include +#include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_SETTINGS) -#define LOG_MODULE_NAME bt_settings -#include "common/log.h" #include "common/bt_str.h" #include "hci_core.h" #include "settings.h" +#define LOG_LEVEL CONFIG_BT_SETTINGS_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_settings); + #if defined(CONFIG_BT_SETTINGS_USE_PRINTK) void bt_settings_encode_key(char *path, size_t path_size, const char *subsys, const bt_addr_le_t *addr, const char *key) @@ -38,7 +40,7 @@ void bt_settings_encode_key(char *path, size_t path_size, const char *subsys, addr->type); } - BT_DBG("Encoded path %s", path); + LOG_DBG("Encoded path %s", path); } #else void bt_settings_encode_key(char *path, size_t path_size, const char *subsys, @@ -87,7 +89,7 @@ void bt_settings_encode_key(char *path, size_t path_size, const char *subsys, *path = '\0'; } - BT_DBG("Encoded path %s", path); + LOG_DBG("Encoded path %s", path); } #endif @@ -109,7 +111,7 @@ int bt_settings_decode_key(const char *key, bt_addr_le_t *addr) hex2bin(&key[i * 2], 2, &addr->a.val[5 - i], 1); } - BT_DBG("Decoded %s as %s", key, bt_addr_le_str(addr)); + LOG_DBG("Decoded %s as %s", key, bt_addr_le_str(addr)); return 0; } @@ -131,7 +133,7 @@ static int set_setting(const char *name, size_t len_rd, settings_read_cb read_cb } if (!name) { - BT_ERR("Insufficient number of arguments"); + LOG_ERR("Insufficient number of arguments"); return -ENOENT; } @@ -140,17 +142,17 @@ static int set_setting(const char *name, size_t len_rd, settings_read_cb read_cb if (!strncmp(name, "id", len)) { /* Any previously provided identities supersede flash */ if (atomic_test_bit(bt_dev.flags, BT_DEV_PRESET_ID)) { - BT_WARN("Ignoring identities stored in flash"); + LOG_WRN("Ignoring identities stored in flash"); return 0; } len = read_cb(cb_arg, &bt_dev.id_addr, sizeof(bt_dev.id_addr)); if (len < sizeof(bt_dev.id_addr[0])) { if (len < 0) { - BT_ERR("Failed to read ID address from storage" + LOG_ERR("Failed to read ID address from storage" " (err %zd)", len); } else { - BT_ERR("Invalid length ID address in storage"); + LOG_ERR("Invalid length ID address in storage"); LOG_HEXDUMP_DBG(&bt_dev.id_addr, len, "data read"); } (void)memset(bt_dev.id_addr, 0, @@ -161,8 +163,7 @@ static int set_setting(const char *name, size_t len_rd, settings_read_cb read_cb bt_dev.id_count = len / sizeof(bt_dev.id_addr[0]); for (i = 0; i < bt_dev.id_count; i++) { - BT_DBG("ID[%d] %s", i, - bt_addr_le_str(&bt_dev.id_addr[i])); + LOG_DBG("ID[%d] %s", i, bt_addr_le_str(&bt_dev.id_addr[i])); } } @@ -173,12 +174,12 @@ static int set_setting(const char *name, size_t len_rd, settings_read_cb read_cb if (!strncmp(name, "name", len)) { len = read_cb(cb_arg, &bt_dev.name, sizeof(bt_dev.name) - 1); if (len < 0) { - BT_ERR("Failed to read device name from storage" + LOG_ERR("Failed to read device name from storage" " (err %zd)", len); } else { bt_dev.name[len] = '\0'; - BT_DBG("Name set to %s", bt_dev.name); + LOG_DBG("Name set to %s", bt_dev.name); } return 0; } @@ -187,7 +188,7 @@ static int set_setting(const char *name, size_t len_rd, settings_read_cb read_cb #if defined(CONFIG_BT_DEVICE_APPEARANCE_DYNAMIC) if (!strncmp(name, "appearance", len)) { if (len_rd != sizeof(bt_dev.appearance)) { - BT_ERR("Ignoring settings entry 'bt/appearance'. Wrong length."); + LOG_ERR("Ignoring settings entry 'bt/appearance'. Wrong length."); return -EINVAL; } @@ -205,10 +206,10 @@ static int set_setting(const char *name, size_t len_rd, settings_read_cb read_cb len = read_cb(cb_arg, bt_dev.irk, sizeof(bt_dev.irk)); if (len < sizeof(bt_dev.irk[0])) { if (len < 0) { - BT_ERR("Failed to read IRK from storage" + LOG_ERR("Failed to read IRK from storage" " (err %zd)", len); } else { - BT_ERR("Invalid length IRK in storage"); + LOG_ERR("Invalid length IRK in storage"); (void)memset(bt_dev.irk, 0, sizeof(bt_dev.irk)); } } else { @@ -216,8 +217,7 @@ static int set_setting(const char *name, size_t len_rd, settings_read_cb read_cb count = len / sizeof(bt_dev.irk[0]); for (i = 0; i < count; i++) { - BT_DBG("IRK[%d] %s", i, - bt_hex(bt_dev.irk[i], 16)); + LOG_DBG("IRK[%d] %s", i, bt_hex(bt_dev.irk[i], 16)); } } @@ -233,17 +233,17 @@ static int set_setting(const char *name, size_t len_rd, settings_read_cb read_cb static void save_id(struct k_work *work) { int err; - BT_INFO("Saving ID"); + LOG_INF("Saving ID"); err = settings_save_one("bt/id", &bt_dev.id_addr, ID_DATA_LEN(bt_dev.id_addr)); if (err) { - BT_ERR("Failed to save ID (err %d)", err); + LOG_ERR("Failed to save ID (err %d)", err); } #if defined(CONFIG_BT_PRIVACY) err = settings_save_one("bt/irk", bt_dev.irk, ID_DATA_LEN(bt_dev.irk)); if (err) { - BT_ERR("Failed to save IRK (err %d)", err); + LOG_ERR("Failed to save IRK (err %d)", err); } #endif } @@ -259,7 +259,7 @@ static int commit_settings(void) { int err; - BT_DBG(""); + LOG_DBG(""); if (!atomic_test_bit(bt_dev.flags, BT_DEV_ENABLE)) { /* The Bluetooth settings loader needs to communicate with the Bluetooth @@ -279,7 +279,7 @@ static int commit_settings(void) if (!bt_dev.id_count) { err = bt_setup_public_id_addr(); if (err) { - BT_ERR("Unable to setup an identity address"); + LOG_ERR("Unable to setup an identity address"); return err; } } @@ -287,7 +287,7 @@ static int commit_settings(void) if (!bt_dev.id_count) { err = bt_setup_random_id_addr(); if (err) { - BT_ERR("Unable to setup an identity address"); + LOG_ERR("Unable to setup an identity address"); return err; } } @@ -300,7 +300,7 @@ static int commit_settings(void) * generated this Identity needs to be saved persistently. */ if (atomic_test_and_clear_bit(bt_dev.flags, BT_DEV_STORE_ID)) { - BT_DBG("Storing Identity Information"); + LOG_DBG("Storing Identity Information"); bt_settings_save_id(); } @@ -313,11 +313,11 @@ int bt_settings_init(void) { int err; - BT_DBG(""); + LOG_DBG(""); err = settings_subsys_init(); if (err) { - BT_ERR("settings_subsys_init failed (err %d)", err); + LOG_ERR("settings_subsys_init failed (err %d)", err); return err; } diff --git a/subsys/bluetooth/host/smp.c b/subsys/bluetooth/host/smp.c index e398e3fd7b8..ed964f7aea1 100644 --- a/subsys/bluetooth/host/smp.c +++ b/subsys/bluetooth/host/smp.c @@ -27,9 +27,6 @@ #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_SMP) -#define LOG_MODULE_NAME bt_smp -#include "common/log.h" #include "common/bt_str.h" #include "crypto/bt_crypto.h" @@ -41,6 +38,10 @@ #include "l2cap_internal.h" #include "smp.h" +#define LOG_LEVEL CONFIG_BT_SMP_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_smp); + #define SMP_TIMEOUT K_SECONDS(30) #if defined(CONFIG_BT_SIGNING) @@ -665,7 +666,7 @@ static void sc_derive_link_key(struct bt_smp *smp) struct bt_keys_link_key *link_key; uint8_t ilk[16]; - BT_DBG(""); + LOG_DBG(""); /* TODO handle errors? */ @@ -736,7 +737,7 @@ static void smp_pairing_br_complete(struct bt_smp_br *smp, uint8_t status) struct bt_keys *keys; bt_addr_le_t addr; - BT_DBG("status 0x%x", status); + LOG_DBG("status 0x%x", status); /* For dualmode devices LE address is same as BR/EDR address * and is of public type. @@ -784,7 +785,7 @@ static void smp_br_timeout(struct k_work *work) struct k_work_delayable *dwork = k_work_delayable_from_work(work); struct bt_smp_br *smp = CONTAINER_OF(dwork, struct bt_smp_br, work); - BT_ERR("SMP Timeout"); + LOG_ERR("SMP Timeout"); smp_pairing_br_complete(smp, BT_SMP_ERR_UNSPECIFIED); atomic_set_bit(smp->flags, SMP_FLAG_TIMEOUT); @@ -805,8 +806,8 @@ static void bt_smp_br_connected(struct bt_l2cap_chan *chan) { struct bt_smp_br *smp = CONTAINER_OF(chan, struct bt_smp_br, chan); - BT_DBG("chan %p cid 0x%04x", chan, - CONTAINER_OF(chan, struct bt_l2cap_br_chan, chan)->tx.cid); + LOG_DBG("chan %p cid 0x%04x", chan, + CONTAINER_OF(chan, struct bt_l2cap_br_chan, chan)->tx.cid); atomic_set_bit(smp->flags, SMP_FLAG_BR_CONNECTED); @@ -823,8 +824,8 @@ static void bt_smp_br_disconnected(struct bt_l2cap_chan *chan) { struct bt_smp_br *smp = CONTAINER_OF(chan, struct bt_smp_br, chan); - BT_DBG("chan %p cid 0x%04x", chan, - CONTAINER_OF(chan, struct bt_l2cap_br_chan, chan)->tx.cid); + LOG_DBG("chan %p cid 0x%04x", chan, + CONTAINER_OF(chan, struct bt_l2cap_br_chan, chan)->tx.cid); /* Channel disconnected callback is always called from a work handler * so canceling of the timeout work should always succeed. @@ -854,14 +855,14 @@ static void smp_br_derive_ltk(struct bt_smp_br *smp) bt_addr_le_t addr; uint8_t ilk[16]; - BT_DBG(""); + LOG_DBG(""); if (!link_key) { return; } if (IS_ENABLED(CONFIG_BT_SMP_FORCE_BREDR) && conn->encrypt != 0x02) { - BT_WARN("Using P192 Link Key for P256 LTK derivation"); + LOG_WRN("Using P192 Link Key for P256 LTK derivation"); } /* @@ -873,7 +874,7 @@ static void smp_br_derive_ltk(struct bt_smp_br *smp) keys = bt_keys_get_type(BT_KEYS_LTK_P256, conn->id, &addr); if (!keys) { - BT_ERR("Unable to get keys for %s", bt_addr_le_str(&addr)); + LOG_ERR("Unable to get keys for %s", bt_addr_le_str(&addr)); return; } @@ -913,7 +914,7 @@ static void smp_br_derive_ltk(struct bt_smp_br *smp) keys->flags &= ~BT_KEYS_AUTHENTICATED; } - BT_DBG("LTK derived from LinkKey"); + LOG_DBG("LTK derived from LinkKey"); } static struct net_buf *smp_br_create_pdu(struct bt_smp_br *smp, uint8_t op, @@ -963,7 +964,7 @@ static void smp_br_distribute_keys(struct bt_smp_br *smp) keys = bt_keys_get_addr(conn->id, &addr); if (!keys) { - BT_ERR("No keys space for %s", bt_addr_le_str(&addr)); + LOG_ERR("No keys space for %s", bt_addr_le_str(&addr)); return; } @@ -978,7 +979,7 @@ static void smp_br_distribute_keys(struct bt_smp_br *smp) buf = smp_br_create_pdu(smp, BT_SMP_CMD_IDENT_INFO, sizeof(*id_info)); if (!buf) { - BT_ERR("Unable to allocate Ident Info buffer"); + LOG_ERR("Unable to allocate Ident Info buffer"); return; } @@ -990,7 +991,7 @@ static void smp_br_distribute_keys(struct bt_smp_br *smp) buf = smp_br_create_pdu(smp, BT_SMP_CMD_IDENT_ADDR_INFO, sizeof(*id_addr_info)); if (!buf) { - BT_ERR("Unable to allocate Ident Addr Info buffer"); + LOG_ERR("Unable to allocate Ident Addr Info buffer"); return; } @@ -1011,14 +1012,14 @@ static void smp_br_distribute_keys(struct bt_smp_br *smp) buf = smp_br_create_pdu(smp, BT_SMP_CMD_SIGNING_INFO, sizeof(*info)); if (!buf) { - BT_ERR("Unable to allocate Signing Info buffer"); + LOG_ERR("Unable to allocate Signing Info buffer"); return; } info = net_buf_add(buf, sizeof(*info)); if (bt_rand(info->csrk, sizeof(info->csrk))) { - BT_ERR("Unable to get random bytes"); + LOG_ERR("Unable to get random bytes"); return; } @@ -1041,7 +1042,7 @@ static bool smp_br_pairing_allowed(struct bt_smp_br *smp) if (IS_ENABLED(CONFIG_BT_SMP_FORCE_BREDR) && smp->chan.chan.conn->encrypt == 0x01) { - BT_WARN("Allowing BR/EDR SMP with P-192 key"); + LOG_WRN("Allowing BR/EDR SMP with P-192 key"); return true; } @@ -1056,7 +1057,7 @@ static uint8_t smp_br_pairing_req(struct bt_smp_br *smp, struct net_buf *buf) struct net_buf *rsp_buf; uint8_t max_key_size; - BT_DBG(""); + LOG_DBG(""); /* * If a Pairing Request is received over the BR/EDR transport when @@ -1071,7 +1072,7 @@ static uint8_t smp_br_pairing_req(struct bt_smp_br *smp, struct net_buf *buf) max_key_size = bt_conn_enc_key_size(conn); if (!max_key_size) { - BT_DBG("Invalid encryption key size"); + LOG_DBG("Invalid encryption key size"); return BT_SMP_ERR_UNSPECIFIED; } @@ -1140,11 +1141,11 @@ static uint8_t smp_br_pairing_rsp(struct bt_smp_br *smp, struct net_buf *buf) struct bt_conn *conn = smp->chan.chan.conn; uint8_t max_key_size; - BT_DBG(""); + LOG_DBG(""); max_key_size = bt_conn_enc_key_size(conn); if (!max_key_size) { - BT_DBG("Invalid encryption key size"); + LOG_DBG("Invalid encryption key size"); return BT_SMP_ERR_UNSPECIFIED; } @@ -1193,7 +1194,7 @@ static uint8_t smp_br_pairing_failed(struct bt_smp_br *smp, struct net_buf *buf) { struct bt_smp_pairing_fail *req = (void *)buf->data; - BT_ERR("pairing failed (peer reason 0x%x)", req->reason); + LOG_ERR("pairing failed (peer reason 0x%x)", req->reason); smp_pairing_br_complete(smp, req->reason); smp_br_reset(smp); @@ -1209,7 +1210,7 @@ static uint8_t smp_br_ident_info(struct bt_smp_br *smp, struct net_buf *buf) struct bt_keys *keys; bt_addr_le_t addr; - BT_DBG(""); + LOG_DBG(""); /* TODO should we resolve LE address if matching RPA is connected? */ @@ -1222,7 +1223,7 @@ static uint8_t smp_br_ident_info(struct bt_smp_br *smp, struct net_buf *buf) keys = bt_keys_get_type(BT_KEYS_IRK, conn->id, &addr); if (!keys) { - BT_ERR("Unable to get keys for %s", bt_addr_le_str(&addr)); + LOG_ERR("Unable to get keys for %s", bt_addr_le_str(&addr)); return BT_SMP_ERR_UNSPECIFIED; } @@ -1240,7 +1241,7 @@ static uint8_t smp_br_ident_addr_info(struct bt_smp_br *smp, struct bt_smp_ident_addr_info *req = (void *)buf->data; bt_addr_le_t addr; - BT_DBG("identity %s", bt_addr_le_str(&req->addr)); + LOG_DBG("identity %s", bt_addr_le_str(&req->addr)); /* * For dual mode device identity address must be same as BR/EDR address @@ -1281,7 +1282,7 @@ static uint8_t smp_br_signing_info(struct bt_smp_br *smp, struct net_buf *buf) struct bt_keys *keys; bt_addr_le_t addr; - BT_DBG(""); + LOG_DBG(""); /* * For dualmode devices LE address is same as BR/EDR address and is of @@ -1292,7 +1293,7 @@ static uint8_t smp_br_signing_info(struct bt_smp_br *smp, struct net_buf *buf) keys = bt_keys_get_type(BT_KEYS_REMOTE_CSRK, conn->id, &addr); if (!keys) { - BT_ERR("Unable to get keys for %s", bt_addr_le_str(&addr)); + LOG_ERR("Unable to get keys for %s", bt_addr_le_str(&addr)); return BT_SMP_ERR_UNSPECIFIED; } @@ -1372,12 +1373,12 @@ static int bt_smp_br_recv(struct bt_l2cap_chan *chan, struct net_buf *buf) uint8_t err; if (buf->len < sizeof(*hdr)) { - BT_ERR("Too small SMP PDU received"); + LOG_ERR("Too small SMP PDU received"); return 0; } hdr = net_buf_pull_mem(buf, sizeof(*hdr)); - BT_DBG("Received SMP code 0x%02x len %u", hdr->code, buf->len); + LOG_DBG("Received SMP code 0x%02x len %u", hdr->code, buf->len); /* * If SMP timeout occurred "no further SMP commands shall be sent over @@ -1385,26 +1386,25 @@ static int bt_smp_br_recv(struct bt_l2cap_chan *chan, struct net_buf *buf) * performed when a new physical link has been established." */ if (atomic_test_bit(smp->flags, SMP_FLAG_TIMEOUT)) { - BT_WARN("SMP command (code 0x%02x) received after timeout", - hdr->code); + LOG_WRN("SMP command (code 0x%02x) received after timeout", hdr->code); return 0; } if (hdr->code >= ARRAY_SIZE(br_handlers) || !br_handlers[hdr->code].func) { - BT_WARN("Unhandled SMP code 0x%02x", hdr->code); + LOG_WRN("Unhandled SMP code 0x%02x", hdr->code); smp_br_error(smp, BT_SMP_ERR_CMD_NOTSUPP); return 0; } if (!atomic_test_and_clear_bit(smp->allowed_cmds, hdr->code)) { - BT_WARN("Unexpected SMP code 0x%02x", hdr->code); + LOG_WRN("Unexpected SMP code 0x%02x", hdr->code); smp_br_error(smp, BT_SMP_ERR_UNSPECIFIED); return 0; } if (buf->len != br_handlers[hdr->code].expect_len) { - BT_ERR("Invalid len %u for code 0x%02x", buf->len, hdr->code); + LOG_ERR("Invalid len %u for code 0x%02x", buf->len, hdr->code); smp_br_error(smp, BT_SMP_ERR_INVALID_PARAMS); return 0; } @@ -1420,7 +1420,7 @@ static int bt_smp_br_recv(struct bt_l2cap_chan *chan, struct net_buf *buf) static bool br_sc_supported(void) { if (IS_ENABLED(CONFIG_BT_SMP_FORCE_BREDR)) { - BT_WARN("Enabling BR/EDR SMP without BR/EDR SC support"); + LOG_WRN("Enabling BR/EDR SMP without BR/EDR SC support"); return true; } @@ -1441,7 +1441,7 @@ static int bt_smp_br_accept(struct bt_conn *conn, struct bt_l2cap_chan **chan) return -ENOTSUP; } - BT_DBG("conn %p handle %u", conn, conn->handle); + LOG_DBG("conn %p handle %u", conn, conn->handle); for (i = 0; i < ARRAY_SIZE(bt_smp_pool); i++) { struct bt_smp_br *smp = &bt_smp_br_pool[i]; @@ -1460,7 +1460,7 @@ static int bt_smp_br_accept(struct bt_conn *conn, struct bt_l2cap_chan **chan) return 0; } - BT_ERR("No available SMP context for conn %p", conn); + LOG_ERR("No available SMP context for conn %p", conn); return -ENOMEM; } @@ -1471,7 +1471,7 @@ static struct bt_smp_br *smp_br_chan_get(struct bt_conn *conn) chan = bt_l2cap_br_lookup_rx_cid(conn, BT_L2CAP_CID_BR_SMP); if (!chan) { - BT_ERR("Unable to find SMP channel"); + LOG_ERR("Unable to find SMP channel"); return NULL; } @@ -1513,7 +1513,7 @@ int bt_smp_br_send_pairing_req(struct bt_conn *conn) max_key_size = bt_conn_enc_key_size(conn); if (!max_key_size) { - BT_DBG("Invalid encryption key size"); + LOG_DBG("Invalid encryption key size"); return -EIO; } @@ -1610,7 +1610,7 @@ static void smp_pairing_complete(struct bt_smp *smp, uint8_t status) { struct bt_conn *conn = smp->chan.chan.conn; - BT_DBG("status 0x%x", status); + LOG_DBG("status 0x%x", status); if (!status) { #if defined(CONFIG_BT_BREDR) @@ -1688,7 +1688,7 @@ static void smp_timeout(struct k_work *work) { struct bt_smp *smp = CONTAINER_OF(work, struct bt_smp, work); - BT_ERR("SMP Timeout"); + LOG_ERR("SMP Timeout"); smp_pairing_complete(smp, BT_SMP_ERR_UNSPECIFIED); @@ -1729,7 +1729,7 @@ static int smp_error(struct bt_smp *smp, uint8_t reason) } if (remote_already_completed) { - BT_WARN("SMP does not allow a pairing failure at this point. Known issue. " + LOG_WRN("SMP does not allow a pairing failure at this point. Known issue. " "Disconnecting instead."); /* We are probably here because we are, as a peripheral, rejecting a pairing based * on the central's identity address information, but that was the last key to @@ -1793,12 +1793,12 @@ static int smp_c1(const uint8_t k[16], const uint8_t r[16], uint8_t p1[16], p2[16]; int err; - BT_DBG("k %s", bt_hex(k, 16)); - BT_DBG("r %s", bt_hex(r, 16)); - BT_DBG("ia %s", bt_addr_le_str(ia)); - BT_DBG("ra %s", bt_addr_le_str(ra)); - BT_DBG("preq %s", bt_hex(preq, 7)); - BT_DBG("pres %s", bt_hex(pres, 7)); + LOG_DBG("k %s", bt_hex(k, 16)); + LOG_DBG("r %s", bt_hex(r, 16)); + LOG_DBG("ia %s", bt_addr_le_str(ia)); + LOG_DBG("ra %s", bt_addr_le_str(ra)); + LOG_DBG("preq %s", bt_hex(preq, 7)); + LOG_DBG("pres %s", bt_hex(pres, 7)); /* pres, preq, rat and iat are concatenated to generate p1 */ p1[0] = ia->type; @@ -1806,7 +1806,7 @@ static int smp_c1(const uint8_t k[16], const uint8_t r[16], memcpy(p1 + 2, preq, 7); memcpy(p1 + 9, pres, 7); - BT_DBG("p1 %s", bt_hex(p1, 16)); + LOG_DBG("p1 %s", bt_hex(p1, 16)); /* c1 = e(k, e(k, r XOR p1) XOR p2) */ @@ -1823,7 +1823,7 @@ static int smp_c1(const uint8_t k[16], const uint8_t r[16], memcpy(p2 + 6, ia->a.val, 6); (void)memset(p2 + 12, 0, 4); - BT_DBG("p2 %s", bt_hex(p2, 16)); + LOG_DBG("p2 %s", bt_hex(p2, 16)); xor_128(enc_data, p2, enc_data); @@ -1855,7 +1855,7 @@ static uint8_t smp_send_pairing_confirm(struct bt_smp *smp) r |= 0x80; break; default: - BT_ERR("Unknown pairing method (%u)", smp->method); + LOG_ERR("Unknown pairing method (%u)", smp->method); return BT_SMP_ERR_UNSPECIFIED; } @@ -1903,14 +1903,14 @@ static void legacy_distribute_keys(struct bt_smp *smp) } rand; if (bt_rand((void *)&rand, sizeof(rand))) { - BT_ERR("Unable to get random bytes"); + LOG_ERR("Unable to get random bytes"); return; } buf = smp_create_pdu(smp, BT_SMP_CMD_ENCRYPT_INFO, sizeof(*info)); if (!buf) { - BT_ERR("Unable to allocate Encrypt Info buffer"); + LOG_ERR("Unable to allocate Encrypt Info buffer"); return; } @@ -1928,7 +1928,7 @@ static void legacy_distribute_keys(struct bt_smp *smp) buf = smp_create_pdu(smp, BT_SMP_CMD_CENTRAL_IDENT, sizeof(*ident)); if (!buf) { - BT_ERR("Unable to allocate Central Ident buffer"); + LOG_ERR("Unable to allocate Central Ident buffer"); return; } @@ -1958,7 +1958,7 @@ static uint8_t bt_smp_distribute_keys(struct bt_smp *smp) struct bt_keys *keys = conn->le.keys; if (!keys) { - BT_ERR("No keys space for %s", bt_addr_le_str(&conn->le.dst)); + LOG_ERR("No keys space for %s", bt_addr_le_str(&conn->le.dst)); return BT_SMP_ERR_UNSPECIFIED; } @@ -1978,7 +1978,7 @@ static uint8_t bt_smp_distribute_keys(struct bt_smp *smp) buf = smp_create_pdu(smp, BT_SMP_CMD_IDENT_INFO, sizeof(*id_info)); if (!buf) { - BT_ERR("Unable to allocate Ident Info buffer"); + LOG_ERR("Unable to allocate Ident Info buffer"); return BT_SMP_ERR_UNSPECIFIED; } @@ -1990,7 +1990,7 @@ static uint8_t bt_smp_distribute_keys(struct bt_smp *smp) buf = smp_create_pdu(smp, BT_SMP_CMD_IDENT_ADDR_INFO, sizeof(*id_addr_info)); if (!buf) { - BT_ERR("Unable to allocate Ident Addr Info buffer"); + LOG_ERR("Unable to allocate Ident Addr Info buffer"); return BT_SMP_ERR_UNSPECIFIED; } @@ -2009,7 +2009,7 @@ static uint8_t bt_smp_distribute_keys(struct bt_smp *smp) buf = smp_create_pdu(smp, BT_SMP_CMD_SIGNING_INFO, sizeof(*info)); if (!buf) { - BT_ERR("Unable to allocate Signing Info buffer"); + LOG_ERR("Unable to allocate Signing Info buffer"); return BT_SMP_ERR_UNSPECIFIED; } @@ -2146,7 +2146,7 @@ static uint8_t legacy_request_tk(struct bt_smp *smp) keys = bt_keys_find_addr(conn->id, &conn->le.dst); if (keys && (keys->flags & BT_KEYS_AUTHENTICATED) && smp->method == JUST_WORKS) { - BT_ERR("JustWorks failed, authenticated keys present"); + LOG_ERR("JustWorks failed, authenticated keys present"); return BT_SMP_ERR_UNSPECIFIED; } @@ -2177,7 +2177,7 @@ static uint8_t legacy_request_tk(struct bt_smp *smp) } if (IS_ENABLED(CONFIG_BT_LOG_SNIFFER_INFO)) { - BT_INFO("Legacy passkey %u", passkey); + LOG_INF("Legacy passkey %u", passkey); } if (smp_auth_cb && smp_auth_cb->passkey_display) { @@ -2195,7 +2195,7 @@ static uint8_t legacy_request_tk(struct bt_smp *smp) case JUST_WORKS: break; default: - BT_ERR("Unknown pairing method (%u)", smp->method); + LOG_ERR("Unknown pairing method (%u)", smp->method); return BT_SMP_ERR_UNSPECIFIED; } @@ -2234,7 +2234,7 @@ static uint8_t legacy_pairing_req(struct bt_smp *smp) const struct bt_conn_auth_cb *smp_auth_cb = latch_auth_cb(smp); uint8_t ret; - BT_DBG(""); + LOG_DBG(""); ret = legacy_request_tk(smp); if (ret) { @@ -2262,7 +2262,7 @@ static uint8_t legacy_pairing_random(struct bt_smp *smp) uint8_t tmp[16]; int err; - BT_DBG(""); + LOG_DBG(""); /* calculate confirmation */ err = smp_c1(smp->tk, smp->rrnd, smp->preq, smp->prsp, @@ -2271,8 +2271,8 @@ static uint8_t legacy_pairing_random(struct bt_smp *smp) return BT_SMP_ERR_UNSPECIFIED; } - BT_DBG("pcnf %s", bt_hex(smp->pcnf, 16)); - BT_DBG("cfm %s", bt_hex(tmp, 16)); + LOG_DBG("pcnf %s", bt_hex(smp->pcnf, 16)); + LOG_DBG("cfm %s", bt_hex(tmp, 16)); if (memcmp(smp->pcnf, tmp, sizeof(smp->pcnf))) { return BT_SMP_ERR_CONFIRM_FAILED; @@ -2293,7 +2293,7 @@ static uint8_t legacy_pairing_random(struct bt_smp *smp) (void)memset(rand, 0, sizeof(rand)); if (bt_conn_le_start_encryption(conn, rand, ediv, tmp, get_encryption_key_size(smp))) { - BT_ERR("Failed to start encryption"); + LOG_ERR("Failed to start encryption"); return BT_SMP_ERR_UNSPECIFIED; } @@ -2318,12 +2318,12 @@ static uint8_t legacy_pairing_random(struct bt_smp *smp) if (IS_ENABLED(CONFIG_BT_PERIPHERAL)) { err = smp_s1(smp->tk, smp->prnd, smp->rrnd, tmp); if (err) { - BT_ERR("Calculate STK failed"); + LOG_ERR("Calculate STK failed"); return BT_SMP_ERR_UNSPECIFIED; } memcpy(smp->tk, tmp, sizeof(smp->tk)); - BT_DBG("generated STK %s", bt_hex(smp->tk, 16)); + LOG_DBG("generated STK %s", bt_hex(smp->tk, 16)); atomic_set_bit(smp->flags, SMP_FLAG_ENC_PENDING); @@ -2335,7 +2335,7 @@ static uint8_t legacy_pairing_random(struct bt_smp *smp) static uint8_t legacy_pairing_confirm(struct bt_smp *smp) { - BT_DBG(""); + LOG_DBG(""); if (IS_ENABLED(CONFIG_BT_CENTRAL) && smp->chan.chan.conn->role == BT_HCI_ROLE_CENTRAL) { @@ -2389,7 +2389,7 @@ static void legacy_passkey_entry(struct bt_smp *smp, unsigned int passkey) static uint8_t smp_encrypt_info(struct bt_smp *smp, struct net_buf *buf) { - BT_DBG(""); + LOG_DBG(""); if (atomic_test_bit(smp->flags, SMP_FLAG_BOND)) { struct bt_smp_encrypt_info *req = (void *)buf->data; @@ -2398,8 +2398,7 @@ static uint8_t smp_encrypt_info(struct bt_smp *smp, struct net_buf *buf) keys = bt_keys_get_type(BT_KEYS_LTK, conn->id, &conn->le.dst); if (!keys) { - BT_ERR("Unable to get keys for %s", - bt_addr_le_str(&conn->le.dst)); + LOG_ERR("Unable to get keys for %s", bt_addr_le_str(&conn->le.dst)); return BT_SMP_ERR_UNSPECIFIED; } @@ -2416,7 +2415,7 @@ static uint8_t smp_central_ident(struct bt_smp *smp, struct net_buf *buf) struct bt_conn *conn = smp->chan.chan.conn; uint8_t err; - BT_DBG(""); + LOG_DBG(""); if (atomic_test_bit(smp->flags, SMP_FLAG_BOND)) { struct bt_smp_central_ident *req = (void *)buf->data; @@ -2424,8 +2423,7 @@ static uint8_t smp_central_ident(struct bt_smp *smp, struct net_buf *buf) keys = bt_keys_get_type(BT_KEYS_LTK, conn->id, &conn->le.dst); if (!keys) { - BT_ERR("Unable to get keys for %s", - bt_addr_le_str(&conn->le.dst)); + LOG_ERR("Unable to get keys for %s", bt_addr_le_str(&conn->le.dst)); return BT_SMP_ERR_UNSPECIFIED; } @@ -2463,7 +2461,7 @@ static uint8_t legacy_pairing_rsp(struct bt_smp *smp) const struct bt_conn_auth_cb *smp_auth_cb = latch_auth_cb(smp); uint8_t ret; - BT_DBG(""); + LOG_DBG(""); ret = legacy_request_tk(smp); if (ret) { @@ -2514,7 +2512,7 @@ static int smp_init(struct bt_smp *smp) return BT_SMP_ERR_UNSPECIFIED; } - BT_DBG("prnd %s", bt_hex(smp->prnd, 16)); + LOG_DBG("prnd %s", bt_hex(smp->prnd, 16)); atomic_set_bit(smp->allowed_cmds, BT_SMP_CMD_PAIRING_FAIL); @@ -2623,7 +2621,7 @@ static struct bt_smp *smp_chan_get(struct bt_conn *conn) chan = bt_l2cap_le_lookup_rx_cid(conn, BT_L2CAP_CID_SMP); if (!chan) { - BT_ERR("Unable to find SMP channel"); + LOG_ERR("Unable to find SMP channel"); return NULL; } @@ -2723,7 +2721,7 @@ static int smp_send_security_req(struct bt_conn *conn) struct net_buf *req_buf; int err; - BT_DBG(""); + LOG_DBG(""); smp = smp_chan_get(conn); if (!smp) { return -ENOTCONN; @@ -2790,7 +2788,7 @@ static uint8_t smp_pairing_req(struct bt_smp *smp, struct net_buf *buf) struct bt_smp_pairing *rsp; uint8_t err; - BT_DBG(""); + LOG_DBG(""); if ((req->max_key_size > BT_SMP_MAX_ENC_KEY_SIZE) || (req->max_key_size < BT_SMP_MIN_ENC_KEY_SIZE)) { @@ -2800,8 +2798,7 @@ static uint8_t smp_pairing_req(struct bt_smp *smp, struct net_buf *buf) if (!conn->le.keys) { conn->le.keys = bt_keys_get_addr(conn->id, &conn->le.dst); if (!conn->le.keys) { - BT_DBG("Unable to get keys for %s", - bt_addr_le_str(&conn->le.dst)); + LOG_DBG("Unable to get keys for %s", bt_addr_le_str(&conn->le.dst)); return BT_SMP_ERR_UNSPECIFIED; } } @@ -2854,7 +2851,7 @@ static uint8_t smp_pairing_req(struct bt_smp *smp, struct net_buf *buf) atomic_set_bit(smp->flags, SMP_FLAG_BOND); } else if (IS_ENABLED(CONFIG_BT_BONDING_REQUIRED)) { /* Reject pairing req if not both intend to bond */ - BT_DBG("Bonding required"); + LOG_DBG("Bonding required"); return BT_SMP_ERR_UNSPECIFIED; } @@ -2943,7 +2940,7 @@ static int smp_send_pairing_req(struct bt_conn *conn) struct bt_smp_pairing *req; struct net_buf *req_buf; - BT_DBG(""); + LOG_DBG(""); smp = smp_chan_get(conn); if (!smp) { @@ -3027,7 +3024,7 @@ static uint8_t smp_pairing_rsp(struct bt_smp *smp, struct net_buf *buf) struct bt_smp_pairing *req = (struct bt_smp_pairing *)&smp->preq[1]; uint8_t err; - BT_DBG(""); + LOG_DBG(""); if ((rsp->max_key_size > BT_SMP_MAX_ENC_KEY_SIZE) || (rsp->max_key_size < BT_SMP_MIN_ENC_KEY_SIZE)) { @@ -3056,7 +3053,7 @@ static uint8_t smp_pairing_rsp(struct bt_smp *smp, struct net_buf *buf) atomic_set_bit(smp->flags, SMP_FLAG_BOND); } else if (IS_ENABLED(CONFIG_BT_BONDING_REQUIRED)) { /* Reject pairing req if not both intend to bond */ - BT_DBG("Bonding required"); + LOG_DBG("Bonding required"); return BT_SMP_ERR_UNSPECIFIED; } @@ -3126,7 +3123,7 @@ static uint8_t smp_pairing_confirm(struct bt_smp *smp, struct net_buf *buf) { struct bt_smp_pairing_confirm *req = (void *)buf->data; - BT_DBG(""); + LOG_DBG(""); atomic_clear_bit(smp->flags, SMP_FLAG_DISPLAY); @@ -3163,7 +3160,7 @@ static uint8_t smp_pairing_confirm(struct bt_smp *smp, struct net_buf *buf) case JUST_WORKS: case PASSKEY_CONFIRM: default: - BT_ERR("Unknown pairing method (%u)", smp->method); + LOG_ERR("Unknown pairing method (%u)", smp->method); return BT_SMP_ERR_UNSPECIFIED; } } @@ -3173,7 +3170,7 @@ static uint8_t sc_smp_send_dhkey_check(struct bt_smp *smp, const uint8_t *e) struct bt_smp_dhkey_check *req; struct net_buf *buf; - BT_DBG(""); + LOG_DBG(""); buf = smp_create_pdu(smp, BT_SMP_DHKEY_CHECK, sizeof(*req)); if (!buf) { @@ -3209,21 +3206,21 @@ static uint8_t compute_and_send_central_dhcheck(struct bt_smp *smp) } break; default: - BT_ERR("Unknown pairing method (%u)", smp->method); + LOG_ERR("Unknown pairing method (%u)", smp->method); return BT_SMP_ERR_UNSPECIFIED; } /* calculate LTK and mackey */ if (bt_crypto_f5(smp->dhkey, smp->prnd, smp->rrnd, &smp->chan.chan.conn->le.init_addr, &smp->chan.chan.conn->le.resp_addr, smp->mackey, smp->tk)) { - BT_ERR("Calculate LTK failed"); + LOG_ERR("Calculate LTK failed"); return BT_SMP_ERR_UNSPECIFIED; } /* calculate local DHKey check */ if (bt_crypto_f6(smp->mackey, smp->prnd, smp->rrnd, r, &smp->preq[1], &smp->chan.chan.conn->le.init_addr, &smp->chan.chan.conn->le.resp_addr, e)) { - BT_ERR("Calculate local DHKey check failed"); + LOG_ERR("Calculate local DHKey check failed"); return BT_SMP_ERR_UNSPECIFIED; } @@ -3254,14 +3251,14 @@ static uint8_t compute_and_check_and_send_periph_dhcheck(struct bt_smp *smp) } break; default: - BT_ERR("Unknown pairing method (%u)", smp->method); + LOG_ERR("Unknown pairing method (%u)", smp->method); return BT_SMP_ERR_UNSPECIFIED; } /* calculate LTK and mackey */ if (bt_crypto_f5(smp->dhkey, smp->rrnd, smp->prnd, &smp->chan.chan.conn->le.init_addr, &smp->chan.chan.conn->le.resp_addr, smp->mackey, smp->tk)) { - BT_ERR("Calculate LTK failed"); + LOG_ERR("Calculate LTK failed"); return BT_SMP_ERR_UNSPECIFIED; } @@ -3269,7 +3266,7 @@ static uint8_t compute_and_check_and_send_periph_dhcheck(struct bt_smp *smp) if (bt_crypto_f6(smp->mackey, smp->prnd, smp->rrnd, r, &smp->prsp[1], &smp->chan.chan.conn->le.resp_addr, &smp->chan.chan.conn->le.init_addr, e)) { - BT_ERR("Calculate local DHKey check failed"); + LOG_ERR("Calculate local DHKey check failed"); return BT_SMP_ERR_UNSPECIFIED; } @@ -3285,7 +3282,7 @@ static uint8_t compute_and_check_and_send_periph_dhcheck(struct bt_smp *smp) if (bt_crypto_f6(smp->mackey, smp->rrnd, smp->prnd, r, &smp->preq[1], &smp->chan.chan.conn->le.init_addr, &smp->chan.chan.conn->le.resp_addr, re)) { - BT_ERR("Calculate remote DHKey check failed"); + LOG_ERR("Calculate remote DHKey check failed"); return BT_SMP_ERR_UNSPECIFIED; } @@ -3315,7 +3312,7 @@ static uint8_t smp_dhkey_generate(struct bt_smp *smp) if (err) { atomic_clear_bit(smp->flags, SMP_FLAG_DHKEY_GEN); - BT_ERR("Failed to generate DHKey"); + LOG_ERR("Failed to generate DHKey"); return BT_SMP_ERR_UNSPECIFIED; } @@ -3372,7 +3369,7 @@ static struct bt_smp *smp_find(int flag) static void bt_smp_dhkey_ready(const uint8_t *dhkey) { - BT_DBG("%p", dhkey); + LOG_DBG("%p", dhkey); int err; struct bt_smp *smp = smp_find(SMP_FLAG_DHKEY_GEN); @@ -3421,17 +3418,17 @@ static uint8_t sc_smp_check_confirm(struct bt_smp *smp) r |= 0x80; break; default: - BT_ERR("Unknown pairing method (%u)", smp->method); + LOG_ERR("Unknown pairing method (%u)", smp->method); return BT_SMP_ERR_UNSPECIFIED; } if (bt_crypto_f4(smp->pkey, sc_public_key, smp->rrnd, r, cfm)) { - BT_ERR("Calculate confirm failed"); + LOG_ERR("Calculate confirm failed"); return BT_SMP_ERR_UNSPECIFIED; } - BT_DBG("pcnf %s", bt_hex(smp->pcnf, 16)); - BT_DBG("cfm %s", bt_hex(cfm, 16)); + LOG_DBG("pcnf %s", bt_hex(smp->pcnf, 16)); + LOG_DBG("cfm %s", bt_hex(cfm, 16)); if (memcmp(smp->pcnf, cfm, 16)) { return BT_SMP_ERR_CONFIRM_FAILED; @@ -3492,7 +3489,7 @@ static uint8_t smp_pairing_random(struct bt_smp *smp, struct net_buf *buf) uint32_t passkey; uint8_t err; - BT_DBG(""); + LOG_DBG(""); memcpy(smp->rrnd, req->val, sizeof(smp->rrnd)); @@ -3540,7 +3537,7 @@ static uint8_t smp_pairing_random(struct bt_smp *smp, struct net_buf *buf) BT_SMP_CMD_PAIRING_CONFIRM); return smp_send_pairing_confirm(smp); default: - BT_ERR("Unknown pairing method (%u)", smp->method); + LOG_ERR("Unknown pairing method (%u)", smp->method); return BT_SMP_ERR_UNSPECIFIED; } @@ -3617,7 +3614,7 @@ static uint8_t smp_pairing_random(struct bt_smp *smp, struct net_buf *buf) return BT_SMP_ERR_OOB_NOT_AVAIL; } default: - BT_ERR("Unknown pairing method (%u)", smp->method); + LOG_ERR("Unknown pairing method (%u)", smp->method); return BT_SMP_ERR_UNSPECIFIED; } @@ -3635,7 +3632,7 @@ static uint8_t smp_pairing_failed(struct bt_smp *smp, struct net_buf *buf) const struct bt_conn_auth_cb *smp_auth_cb = latch_auth_cb(smp); struct bt_smp_pairing_fail *req = (void *)buf->data; - BT_ERR("pairing failed (peer reason 0x%x)", req->reason); + LOG_ERR("pairing failed (peer reason 0x%x)", req->reason); if (atomic_test_and_clear_bit(smp->flags, SMP_FLAG_USER) || atomic_test_and_clear_bit(smp->flags, SMP_FLAG_DISPLAY)) { @@ -3652,7 +3649,7 @@ static uint8_t smp_pairing_failed(struct bt_smp *smp, struct net_buf *buf) static uint8_t smp_ident_info(struct bt_smp *smp, struct net_buf *buf) { - BT_DBG(""); + LOG_DBG(""); if (atomic_test_bit(smp->flags, SMP_FLAG_BOND)) { struct bt_smp_ident_info *req = (void *)buf->data; @@ -3661,8 +3658,7 @@ static uint8_t smp_ident_info(struct bt_smp *smp, struct net_buf *buf) keys = bt_keys_get_type(BT_KEYS_IRK, conn->id, &conn->le.dst); if (!keys) { - BT_ERR("Unable to get keys for %s", - bt_addr_le_str(&conn->le.dst)); + LOG_ERR("Unable to get keys for %s", bt_addr_le_str(&conn->le.dst)); return BT_SMP_ERR_UNSPECIFIED; } @@ -3685,11 +3681,11 @@ static uint8_t smp_id_add_replace(struct bt_smp *smp, struct bt_keys *new_bond) conflict = bt_id_find_conflict(new_bond); if (conflict) { - BT_DBG("New bond conflicts with a bond on id %d.", conflict->id); + LOG_DBG("New bond conflicts with a bond on id %d.", conflict->id); } if (conflict && !IS_ENABLED(CONFIG_BT_ID_UNPAIR_MATCHING_BONDS)) { - BT_WARN("Refusing new pairing. The old bond must be unpaired first."); + LOG_WRN("Refusing new pairing. The old bond must be unpaired first."); return BT_SMP_ERR_AUTH_REQUIREMENTS; } @@ -3699,11 +3695,11 @@ static uint8_t smp_id_add_replace(struct bt_smp *smp, struct bt_keys *new_bond) trust_ok = update_keys_check(smp, conflict); if (!trust_ok) { - BT_WARN("Refusing new pairing. The old bond has more trust."); + LOG_WRN("Refusing new pairing. The old bond has more trust."); return BT_SMP_ERR_AUTH_REQUIREMENTS; } - BT_DBG("Un-pairing old conflicting bond and finalizing new."); + LOG_DBG("Un-pairing old conflicting bond and finalizing new."); unpair_err = bt_unpair(conflict->id, &conflict->addr); __ASSERT_NO_MSG(!unpair_err); @@ -3720,13 +3716,13 @@ static uint8_t smp_ident_addr_info(struct bt_smp *smp, struct net_buf *buf) struct bt_smp_ident_addr_info *req = (void *)buf->data; uint8_t err; - BT_DBG("identity %s", bt_addr_le_str(&req->addr)); + LOG_DBG("identity %s", bt_addr_le_str(&req->addr)); smp->remote_dist &= ~BT_SMP_DIST_ID_KEY; if (!bt_addr_le_is_identity(&req->addr)) { - BT_ERR("Invalid identity %s", bt_addr_le_str(&req->addr)); - BT_ERR(" for %s", bt_addr_le_str(&conn->le.dst)); + LOG_ERR("Invalid identity %s", bt_addr_le_str(&req->addr)); + LOG_ERR(" for %s", bt_addr_le_str(&conn->le.dst)); return BT_SMP_ERR_INVALID_PARAMS; } @@ -3748,8 +3744,7 @@ static uint8_t smp_ident_addr_info(struct bt_smp *smp, struct net_buf *buf) keys = bt_keys_get_type(BT_KEYS_IRK, conn->id, &conn->le.dst); if (!keys) { - BT_ERR("Unable to get keys for %s", - bt_addr_le_str(&conn->le.dst)); + LOG_ERR("Unable to get keys for %s", bt_addr_le_str(&conn->le.dst)); return BT_SMP_ERR_UNSPECIFIED; } @@ -3815,7 +3810,7 @@ static uint8_t smp_signing_info(struct bt_smp *smp, struct net_buf *buf) struct bt_conn *conn = smp->chan.chan.conn; uint8_t err; - BT_DBG(""); + LOG_DBG(""); if (atomic_test_bit(smp->flags, SMP_FLAG_BOND)) { struct bt_smp_signing_info *req = (void *)buf->data; @@ -3824,8 +3819,7 @@ static uint8_t smp_signing_info(struct bt_smp *smp, struct net_buf *buf) keys = bt_keys_get_type(BT_KEYS_REMOTE_CSRK, conn->id, &conn->le.dst); if (!keys) { - BT_ERR("Unable to get keys for %s", - bt_addr_le_str(&conn->le.dst)); + LOG_ERR("Unable to get keys for %s", bt_addr_le_str(&conn->le.dst)); return BT_SMP_ERR_UNSPECIFIED; } @@ -3864,7 +3858,7 @@ static uint8_t smp_security_request(struct bt_smp *smp, struct net_buf *buf) struct bt_smp_security_request *req = (void *)buf->data; uint8_t auth; - BT_DBG(""); + LOG_DBG(""); /* A higher security level is requested during the key distribution * phase, once pairing is complete a new pairing procedure will start. @@ -3897,7 +3891,7 @@ static uint8_t smp_security_request(struct bt_smp *smp, struct net_buf *buf) if (IS_ENABLED(CONFIG_BT_BONDING_REQUIRED) && !(bondable && (auth & BT_SMP_AUTH_BONDING))) { /* Reject security req if not both intend to bond */ - BT_DBG("Bonding required"); + LOG_DBG("Bonding required"); return BT_SMP_ERR_UNSPECIFIED; } @@ -3923,20 +3917,18 @@ static uint8_t smp_security_request(struct bt_smp *smp, struct net_buf *buf) if ((auth & BT_SMP_AUTH_MITM) && !(conn->le.keys->flags & BT_KEYS_AUTHENTICATED)) { if (get_io_capa(smp) != BT_SMP_IO_NO_INPUT_OUTPUT) { - BT_INFO("New auth requirements: 0x%x, repairing", - auth); + LOG_INF("New auth requirements: 0x%x, repairing", auth); goto pair; } - BT_WARN("Unsupported auth requirements: 0x%x, repairing", - auth); + LOG_WRN("Unsupported auth requirements: 0x%x, repairing", auth); goto pair; } /* if LE SC required and no p256 key present repair */ if ((auth & BT_SMP_AUTH_SC) && !(conn->le.keys->keys & BT_KEYS_LTK_P256)) { - BT_INFO("New auth requirements: 0x%x, repairing", auth); + LOG_INF("New auth requirements: 0x%x, repairing", auth); goto pair; } @@ -3944,7 +3936,7 @@ static uint8_t smp_security_request(struct bt_smp *smp, struct net_buf *buf) conn->le.keys->ltk.ediv, conn->le.keys->ltk.val, conn->le.keys->enc_size) < 0) { - BT_ERR("Failed to start encryption"); + LOG_ERR("Failed to start encryption"); return BT_SMP_ERR_UNSPECIFIED; } @@ -4020,7 +4012,7 @@ static uint8_t smp_public_key_periph(struct bt_smp *smp) /* Deny public key with identitcal X coordinate unless it is the * debug public key. */ - BT_WARN("Remote public key rejected"); + LOG_WRN("Remote public key rejected"); return BT_SMP_ERR_UNSPECIFIED; } @@ -4058,7 +4050,7 @@ static uint8_t smp_public_key_periph(struct bt_smp *smp) atomic_set_bit(smp->allowed_cmds, BT_SMP_CMD_PAIRING_RANDOM); break; default: - BT_ERR("Unknown pairing method (%u)", smp->method); + LOG_ERR("Unknown pairing method (%u)", smp->method); return BT_SMP_ERR_UNSPECIFIED; } @@ -4072,14 +4064,14 @@ static uint8_t smp_public_key(struct bt_smp *smp, struct net_buf *buf) struct bt_smp_public_key *req = (void *)buf->data; uint8_t err; - BT_DBG(""); + LOG_DBG(""); memcpy(smp->pkey, req->x, BT_PUB_KEY_COORD_LEN); memcpy(&smp->pkey[BT_PUB_KEY_COORD_LEN], req->y, BT_PUB_KEY_COORD_LEN); /* mark key as debug if remote is using it */ if (bt_pub_key_is_debug(smp->pkey)) { - BT_INFO("Remote is using Debug Public key"); + LOG_INF("Remote is using Debug Public key"); atomic_set_bit(smp->flags, SMP_FLAG_SC_DEBUG_KEY); /* Don't allow a bond established without debug key to be @@ -4097,7 +4089,7 @@ static uint8_t smp_public_key(struct bt_smp *smp, struct net_buf *buf) /* Deny public key with identitcal X coordinate unless * it is the debug public key. */ - BT_WARN("Remote public key rejected"); + LOG_WRN("Remote public key rejected"); return BT_SMP_ERR_UNSPECIFIED; } @@ -4157,7 +4149,7 @@ static uint8_t smp_public_key(struct bt_smp *smp, struct net_buf *buf) } break; default: - BT_ERR("Unknown pairing method (%u)", smp->method); + LOG_ERR("Unknown pairing method (%u)", smp->method); return BT_SMP_ERR_UNSPECIFIED; } @@ -4183,7 +4175,7 @@ static uint8_t smp_dhkey_check(struct bt_smp *smp, struct net_buf *buf) { struct bt_smp_dhkey_check *req = (void *)buf->data; - BT_DBG(""); + LOG_DBG(""); if (IS_ENABLED(CONFIG_BT_CENTRAL) && smp->chan.chan.conn->role == BT_HCI_ROLE_CENTRAL) { @@ -4206,7 +4198,7 @@ static uint8_t smp_dhkey_check(struct bt_smp *smp, struct net_buf *buf) } break; default: - BT_ERR("Unknown pairing method (%u)", smp->method); + LOG_ERR("Unknown pairing method (%u)", smp->method); return BT_SMP_ERR_UNSPECIFIED; } @@ -4228,7 +4220,7 @@ static uint8_t smp_dhkey_check(struct bt_smp *smp, struct net_buf *buf) (void)memset(rand, 0, sizeof(rand)); if (bt_conn_le_start_encryption(smp->chan.chan.conn, rand, ediv, smp->tk, enc_size) < 0) { - BT_ERR("Failed to start encryption"); + LOG_ERR("Failed to start encryption"); return BT_SMP_ERR_UNSPECIFIED; } @@ -4276,7 +4268,7 @@ static uint8_t smp_keypress_notif(struct bt_smp *smp, struct net_buf *buf) ARG_UNUSED(smp); ARG_UNUSED(buf); - BT_DBG(""); + LOG_DBG(""); /* Ignore packets until keypress notifications are fully supported. */ atomic_set_bit(smp->allowed_cmds, BT_SMP_KEYPRESS_NOTIFICATION); @@ -4311,12 +4303,12 @@ static int bt_smp_recv(struct bt_l2cap_chan *chan, struct net_buf *buf) uint8_t err; if (buf->len < sizeof(*hdr)) { - BT_ERR("Too small SMP PDU received"); + LOG_ERR("Too small SMP PDU received"); return 0; } hdr = net_buf_pull_mem(buf, sizeof(*hdr)); - BT_DBG("Received SMP code 0x%02x len %u", hdr->code, buf->len); + LOG_DBG("Received SMP code 0x%02x len %u", hdr->code, buf->len); /* * If SMP timeout occurred "no further SMP commands shall be sent over @@ -4324,8 +4316,7 @@ static int bt_smp_recv(struct bt_l2cap_chan *chan, struct net_buf *buf) * performed when a new physical link has been established." */ if (atomic_test_bit(smp->flags, SMP_FLAG_TIMEOUT)) { - BT_WARN("SMP command (code 0x%02x) received after timeout", - hdr->code); + LOG_WRN("SMP command (code 0x%02x) received after timeout", hdr->code); return 0; } @@ -4335,18 +4326,18 @@ static int bt_smp_recv(struct bt_l2cap_chan *chan, struct net_buf *buf) * it shall be ignored. */ if (hdr->code >= ARRAY_SIZE(handlers)) { - BT_WARN("Received reserved SMP code 0x%02x", hdr->code); + LOG_WRN("Received reserved SMP code 0x%02x", hdr->code); return 0; } if (!handlers[hdr->code].func) { - BT_WARN("Unhandled SMP code 0x%02x", hdr->code); + LOG_WRN("Unhandled SMP code 0x%02x", hdr->code); smp_error(smp, BT_SMP_ERR_CMD_NOTSUPP); return 0; } if (!atomic_test_and_clear_bit(smp->allowed_cmds, hdr->code)) { - BT_WARN("Unexpected SMP code 0x%02x", hdr->code); + LOG_WRN("Unexpected SMP code 0x%02x", hdr->code); /* Don't send error responses to error PDUs */ if (hdr->code != BT_SMP_CMD_PAIRING_FAIL) { smp_error(smp, BT_SMP_ERR_UNSPECIFIED); @@ -4355,7 +4346,7 @@ static int bt_smp_recv(struct bt_l2cap_chan *chan, struct net_buf *buf) } if (buf->len != handlers[hdr->code].expect_len) { - BT_ERR("Invalid len %u for code 0x%02x", buf->len, hdr->code); + LOG_ERR("Invalid len %u for code 0x%02x", buf->len, hdr->code); smp_error(smp, BT_SMP_ERR_INVALID_PARAMS); return 0; } @@ -4372,12 +4363,12 @@ static void bt_smp_pkey_ready(const uint8_t *pkey) { int i; - BT_DBG(""); + LOG_DBG(""); sc_public_key = pkey; if (!pkey) { - BT_WARN("Public key not available"); + LOG_WRN("Public key not available"); return; } @@ -4416,8 +4407,8 @@ static void bt_smp_connected(struct bt_l2cap_chan *chan) { struct bt_smp *smp = CONTAINER_OF(chan, struct bt_smp, chan); - BT_DBG("chan %p cid 0x%04x", chan, - CONTAINER_OF(chan, struct bt_l2cap_le_chan, chan)->tx.cid); + LOG_DBG("chan %p cid 0x%04x", chan, + CONTAINER_OF(chan, struct bt_l2cap_le_chan, chan)->tx.cid); k_work_init_delayable(&smp->work, smp_timeout); smp_reset(smp); @@ -4430,8 +4421,8 @@ static void bt_smp_disconnected(struct bt_l2cap_chan *chan) struct bt_smp *smp = CONTAINER_OF(chan, struct bt_smp, chan); struct bt_keys *keys = chan->conn->le.keys; - BT_DBG("chan %p cid 0x%04x", chan, - CONTAINER_OF(chan, struct bt_l2cap_le_chan, chan)->tx.cid); + LOG_DBG("chan %p cid 0x%04x", chan, + CONTAINER_OF(chan, struct bt_l2cap_le_chan, chan)->tx.cid); /* Channel disconnected callback is always called from a work handler * so canceling of the timeout work should always succeed. @@ -4465,8 +4456,8 @@ static void bt_smp_encrypt_change(struct bt_l2cap_chan *chan, struct bt_smp *smp = CONTAINER_OF(chan, struct bt_smp, chan); struct bt_conn *conn = chan->conn; - BT_DBG("chan %p conn %p handle %u encrypt 0x%02x hci status 0x%02x", - chan, conn, conn->handle, conn->encrypt, hci_status); + LOG_DBG("chan %p conn %p handle %u encrypt 0x%02x hci status 0x%02x", chan, conn, + conn->handle, conn->encrypt, hci_status); if (!atomic_test_and_clear_bit(smp->flags, SMP_FLAG_ENC_PENDING)) { /* We where not waiting for encryption procedure. @@ -4598,15 +4589,14 @@ static int smp_sign_buf(const uint8_t *key, uint8_t *msg, uint16_t len) uint8_t key_s[16], tmp[16]; int err; - BT_DBG("Signing msg %s len %u key %s", bt_hex(msg, len), len, - bt_hex(key, 16)); + LOG_DBG("Signing msg %s len %u key %s", bt_hex(msg, len), len, bt_hex(key, 16)); sys_mem_swap(m, len + sizeof(cnt)); sys_memcpy_swap(key_s, key, 16); err = bt_crypto_aes_cmac(key_s, m, len + sizeof(cnt), tmp); if (err) { - BT_ERR("Data signing failed"); + LOG_ERR("Data signing failed"); return err; } @@ -4618,7 +4608,7 @@ static int smp_sign_buf(const uint8_t *key, uint8_t *msg, uint16_t len) memcpy(sig, tmp + 4, 12); - BT_DBG("sig %s", bt_hex(sig, 12)); + LOG_DBG("sig %s", bt_hex(sig, 12)); return 0; } @@ -4637,8 +4627,7 @@ int bt_smp_sign_verify(struct bt_conn *conn, struct net_buf *buf) keys = bt_keys_find(BT_KEYS_REMOTE_CSRK, conn->id, &conn->le.dst); if (!keys) { - BT_ERR("Unable to find Remote CSRK for %s", - bt_addr_le_str(&conn->le.dst)); + LOG_ERR("Unable to find Remote CSRK for %s", bt_addr_le_str(&conn->le.dst)); return -ENOENT; } @@ -4646,20 +4635,18 @@ int bt_smp_sign_verify(struct bt_conn *conn, struct net_buf *buf) cnt = sys_cpu_to_le32(keys->remote_csrk.cnt); memcpy(net_buf_tail(buf) - sizeof(sig), &cnt, sizeof(cnt)); - BT_DBG("Sign data len %zu key %s count %u", buf->len - sizeof(sig), - bt_hex(keys->remote_csrk.val, 16), keys->remote_csrk.cnt); + LOG_DBG("Sign data len %zu key %s count %u", buf->len - sizeof(sig), + bt_hex(keys->remote_csrk.val, 16), keys->remote_csrk.cnt); err = smp_sign_buf(keys->remote_csrk.val, buf->data, buf->len - sizeof(sig)); if (err) { - BT_ERR("Unable to create signature for %s", - bt_addr_le_str(&conn->le.dst)); + LOG_ERR("Unable to create signature for %s", bt_addr_le_str(&conn->le.dst)); return -EIO; } if (memcmp(sig, net_buf_tail(buf) - sizeof(sig), sizeof(sig))) { - BT_ERR("Unable to verify signature for %s", - bt_addr_le_str(&conn->le.dst)); + LOG_ERR("Unable to verify signature for %s", bt_addr_le_str(&conn->le.dst)); return -EBADMSG; } @@ -4676,8 +4663,7 @@ int bt_smp_sign(struct bt_conn *conn, struct net_buf *buf) keys = bt_keys_find(BT_KEYS_LOCAL_CSRK, conn->id, &conn->le.dst); if (!keys) { - BT_ERR("Unable to find local CSRK for %s", - bt_addr_le_str(&conn->le.dst)); + LOG_ERR("Unable to find local CSRK for %s", bt_addr_le_str(&conn->le.dst)); return -ENOENT; } @@ -4688,13 +4674,12 @@ int bt_smp_sign(struct bt_conn *conn, struct net_buf *buf) cnt = sys_cpu_to_le32(keys->local_csrk.cnt); memcpy(net_buf_tail(buf) - 12, &cnt, sizeof(cnt)); - BT_DBG("Sign data len %u key %s count %u", buf->len, - bt_hex(keys->local_csrk.val, 16), keys->local_csrk.cnt); + LOG_DBG("Sign data len %u key %s count %u", buf->len, bt_hex(keys->local_csrk.val, 16), + keys->local_csrk.cnt); err = smp_sign_buf(keys->local_csrk.val, buf->data, buf->len - 12); if (err) { - BT_ERR("Unable to create signature for %s", - bt_addr_le_str(&conn->le.dst)); + LOG_ERR("Unable to create signature for %s", bt_addr_le_str(&conn->le.dst)); return -EIO; } @@ -4718,7 +4703,7 @@ static int smp_d1(const uint8_t *key, uint16_t d, uint16_t r, uint8_t res[16]) { int err; - BT_DBG("key %s d %u r %u", bt_hex(key, 16), d, r); + LOG_DBG("key %s d %u r %u", bt_hex(key, 16), d, r); sys_put_le16(d, &res[0]); sys_put_le16(r, &res[2]); @@ -4729,7 +4714,7 @@ static int smp_d1(const uint8_t *key, uint16_t d, uint16_t r, uint8_t res[16]) return err; } - BT_DBG("res %s", bt_hex(res, 16)); + LOG_DBG("res %s", bt_hex(res, 16)); return 0; } @@ -4770,13 +4755,13 @@ static int aes_test(const char *prefix, const uint8_t *key, const uint8_t *m, { uint8_t out[16]; - BT_DBG("%s: AES CMAC of message with len %u", prefix, len); + LOG_DBG("%s: AES CMAC of message with len %u", prefix, len); bt_crypto_aes_cmac(key, m, len, out); if (!memcmp(out, mac, 16)) { - BT_DBG("%s: Success", prefix); + LOG_DBG("%s: Success", prefix); } else { - BT_ERR("%s: Failed", prefix); + LOG_ERR("%s: Failed", prefix); return -1; } @@ -4834,7 +4819,7 @@ static int sign_test(const char *prefix, const uint8_t *key, const uint8_t *m, uint8_t *out = msg + len; int err; - BT_DBG("%s: Sign message with len %u", prefix, len); + LOG_DBG("%s: Sign message with len %u", prefix, len); (void)memset(msg, 0, sizeof(msg)); memcpy(msg, m, len); @@ -4849,18 +4834,18 @@ static int sign_test(const char *prefix, const uint8_t *key, const uint8_t *m, /* Check original message */ if (!memcmp(msg, orig, len + sizeof(uint32_t))) { - BT_DBG("%s: Original message intact", prefix); + LOG_DBG("%s: Original message intact", prefix); } else { - BT_ERR("%s: Original message modified", prefix); - BT_DBG("%s: orig %s", prefix, bt_hex(orig, sizeof(orig))); - BT_DBG("%s: msg %s", prefix, bt_hex(msg, sizeof(msg))); + LOG_ERR("%s: Original message modified", prefix); + LOG_DBG("%s: orig %s", prefix, bt_hex(orig, sizeof(orig))); + LOG_DBG("%s: msg %s", prefix, bt_hex(msg, sizeof(msg))); return -1; } if (!memcmp(out, sig, 12)) { - BT_DBG("%s: Success", prefix); + LOG_DBG("%s: Success", prefix); } else { - BT_ERR("%s: Failed", prefix); + LOG_ERR("%s: Failed", prefix); return -1; } @@ -5117,56 +5102,56 @@ static int smp_self_test(void) err = smp_aes_cmac_test(); if (err) { - BT_ERR("SMP AES-CMAC self tests failed"); + LOG_ERR("SMP AES-CMAC self tests failed"); return err; } err = smp_sign_test(); if (err) { - BT_ERR("SMP signing self tests failed"); + LOG_ERR("SMP signing self tests failed"); return err; } err = smp_f4_test(); if (err) { - BT_ERR("SMP f4 self test failed"); + LOG_ERR("SMP f4 self test failed"); return err; } err = smp_f5_test(); if (err) { - BT_ERR("SMP f5 self test failed"); + LOG_ERR("SMP f5 self test failed"); return err; } err = smp_f6_test(); if (err) { - BT_ERR("SMP f6 self test failed"); + LOG_ERR("SMP f6 self test failed"); return err; } err = smp_g2_test(); if (err) { - BT_ERR("SMP g2 self test failed"); + LOG_ERR("SMP g2 self test failed"); return err; } #if defined(CONFIG_BT_BREDR) err = smp_h6_test(); if (err) { - BT_ERR("SMP h6 self test failed"); + LOG_ERR("SMP h6 self test failed"); return err; } err = smp_h7_test(); if (err) { - BT_ERR("SMP h7 self test failed"); + LOG_ERR("SMP h7 self test failed"); return err; } #endif /* CONFIG_BT_BREDR */ err = smp_h8_test(); if (err) { - BT_ERR("SMP h8 self test failed"); + LOG_ERR("SMP h8 self test failed"); return err; } @@ -5301,7 +5286,7 @@ int bt_smp_le_oob_set_tk(struct bt_conn *conn, const uint8_t *tk) return -EINVAL; } - BT_DBG("%s", bt_hex(tk, 16)); + LOG_DBG("%s", bt_hex(tk, 16)); if (!atomic_test_and_clear_bit(smp->flags, SMP_FLAG_USER)) { return -EINVAL; @@ -5311,7 +5296,7 @@ int bt_smp_le_oob_set_tk(struct bt_conn *conn, const uint8_t *tk) uint8_t oob[16]; sys_memcpy_swap(oob, tk, 16); - BT_INFO("Legacy OOB data 0x%s", bt_hex(oob, 16)); + LOG_INF("Legacy OOB data 0x%s", bt_hex(oob, 16)); } memcpy(smp->tk, tk, 16*sizeof(uint8_t)); @@ -5351,7 +5336,8 @@ int bt_smp_le_oob_generate_sc_data(struct bt_le_oob_sc_data *le_sc_oob) } } - err = bt_crypto_f4(sc_public_key, sc_public_key, le_sc_oob->r, 0, le_sc_oob->c); + err = bt_crypto_f4(sc_public_key, sc_public_key, le_sc_oob->r, 0, + le_sc_oob->c); if (err) { return err; } @@ -5478,7 +5464,7 @@ int bt_smp_auth_cancel(struct bt_conn *conn) return -EINVAL; } - BT_DBG(""); + LOG_DBG(""); switch (smp->method) { case PASSKEY_INPUT: @@ -5492,7 +5478,7 @@ int bt_smp_auth_cancel(struct bt_conn *conn) case JUST_WORKS: return smp_error(smp, BT_SMP_ERR_UNSPECIFIED); default: - BT_ERR("Unknown pairing method (%u)", smp->method); + LOG_ERR("Unknown pairing method (%u)", smp->method); return 0; } } @@ -5643,8 +5629,7 @@ void bt_smp_update_keys(struct bt_conn *conn) conn->le.keys = bt_keys_get_addr(conn->id, &conn->le.dst); if (!conn->le.keys) { - BT_ERR("Unable to get keys for %s", - bt_addr_le_str(&conn->le.dst)); + LOG_ERR("Unable to get keys for %s", bt_addr_le_str(&conn->le.dst)); smp_error(smp, BT_SMP_ERR_UNSPECIFIED); return; } @@ -5699,8 +5684,7 @@ void bt_smp_update_keys(struct bt_conn *conn) uint8_t ltk[16]; sys_memcpy_swap(ltk, smp->tk, conn->le.keys->enc_size); - BT_INFO("SC LTK: 0x%s (No bonding)", - bt_hex(ltk, conn->le.keys->enc_size)); + LOG_INF("SC LTK: 0x%s (No bonding)", bt_hex(ltk, conn->le.keys->enc_size)); } } else { conn->le.keys->flags &= ~BT_KEYS_SC; @@ -5717,7 +5701,7 @@ static int bt_smp_accept(struct bt_conn *conn, struct bt_l2cap_chan **chan) .recv = bt_smp_recv, }; - BT_DBG("conn %p handle %u", conn, conn->handle); + LOG_DBG("conn %p handle %u", conn, conn->handle); for (i = 0; i < ARRAY_SIZE(bt_smp_pool); i++) { struct bt_smp *smp = &bt_smp_pool[i]; @@ -5733,7 +5717,7 @@ static int bt_smp_accept(struct bt_conn *conn, struct bt_l2cap_chan **chan) return 0; } - BT_ERR("No available SMP context for conn %p", conn); + LOG_ERR("No available SMP context for conn %p", conn); return -ENOMEM; } @@ -5752,16 +5736,16 @@ int bt_smp_init(void) sc_supported = le_sc_supported(); if (IS_ENABLED(CONFIG_BT_SMP_SC_PAIR_ONLY) && !sc_supported) { - BT_ERR("SC Pair Only Mode selected but LE SC not supported"); + LOG_ERR("SC Pair Only Mode selected but LE SC not supported"); return -ENOENT; } if (IS_ENABLED(CONFIG_BT_SMP_USB_HCI_CTLR_WORKAROUND)) { - BT_WARN("BT_SMP_USB_HCI_CTLR_WORKAROUND is enabled, which " + LOG_WRN("BT_SMP_USB_HCI_CTLR_WORKAROUND is enabled, which " "exposes a security vulnerability!"); } - BT_DBG("LE SC %s", sc_supported ? "enabled" : "disabled"); + LOG_DBG("LE SC %s", sc_supported ? "enabled" : "disabled"); if (!IS_ENABLED(CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY)) { bt_pub_key_gen(&pub_key_cb); diff --git a/subsys/bluetooth/host/smp_null.c b/subsys/bluetooth/host/smp_null.c index bf5cc18db49..6f558bffadd 100644 --- a/subsys/bluetooth/host/smp_null.c +++ b/subsys/bluetooth/host/smp_null.c @@ -18,15 +18,15 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_CORE) -#define LOG_MODULE_NAME bt_smp -#include "common/log.h" - #include "hci_core.h" #include "conn_internal.h" #include "l2cap_internal.h" #include "smp.h" +#define LOG_LEVEL CONFIG_BT_HCI_CORE_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_smp); + static struct bt_l2cap_le_chan bt_smp_pool[CONFIG_BT_MAX_CONN]; int bt_smp_sign_verify(struct bt_conn *conn, struct net_buf *buf) @@ -77,7 +77,7 @@ static int bt_smp_accept(struct bt_conn *conn, struct bt_l2cap_chan **chan) .recv = bt_smp_recv, }; - BT_DBG("conn %p handle %u", conn, conn->handle); + LOG_DBG("conn %p handle %u", conn, conn->handle); for (i = 0; i < ARRAY_SIZE(bt_smp_pool); i++) { struct bt_l2cap_le_chan *smp = &bt_smp_pool[i]; @@ -93,7 +93,7 @@ static int bt_smp_accept(struct bt_conn *conn, struct bt_l2cap_chan **chan) return 0; } - BT_ERR("No available SMP context for conn %p", conn); + LOG_ERR("No available SMP context for conn %p", conn); return -ENOMEM; } diff --git a/subsys/bluetooth/host/ssp.c b/subsys/bluetooth/host/ssp.c index f06c07c81ec..0c8ba58c218 100644 --- a/subsys/bluetooth/host/ssp.c +++ b/subsys/bluetooth/host/ssp.c @@ -13,9 +13,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_CORE) -#define LOG_MODULE_NAME bt_ssp -#include "common/log.h" #include "common/bt_str.h" #include "keys.h" @@ -23,6 +20,10 @@ #include "hci_core.h" #include "conn_internal.h" +#define LOG_LEVEL CONFIG_BT_HCI_CORE_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_ssp); + enum pairing_method { LEGACY, /* Legacy (pre-SSP) pairing */ JUST_WORKS, /* JustWorks pairing */ @@ -44,7 +45,7 @@ static int pin_code_neg_reply(const bt_addr_t *bdaddr) struct bt_hci_cp_pin_code_neg_reply *cp; struct net_buf *buf; - BT_DBG(""); + LOG_DBG(""); buf = bt_hci_cmd_create(BT_HCI_OP_PIN_CODE_NEG_REPLY, sizeof(*cp)); if (!buf) { @@ -62,7 +63,7 @@ static int pin_code_reply(struct bt_conn *conn, const char *pin, uint8_t len) struct bt_hci_cp_pin_code_reply *cp; struct net_buf *buf; - BT_DBG(""); + LOG_DBG(""); buf = bt_hci_cmd_create(BT_HCI_OP_PIN_CODE_REPLY, sizeof(*cp)); if (!buf) { @@ -96,8 +97,7 @@ int bt_conn_auth_pincode_entry(struct bt_conn *conn, const char *pin) } if (conn->required_sec_level == BT_SECURITY_L3 && len < 16) { - BT_WARN("PIN code for %s is not 16 bytes wide", - bt_addr_str(&conn->br.dst)); + LOG_WRN("PIN code for %s is not 16 bytes wide", bt_addr_str(&conn->br.dst)); return -EPERM; } @@ -179,7 +179,7 @@ static int ssp_confirm_reply(struct bt_conn *conn) struct bt_hci_cp_user_confirm_reply *cp; struct net_buf *buf; - BT_DBG(""); + LOG_DBG(""); buf = bt_hci_cmd_create(BT_HCI_OP_USER_CONFIRM_REPLY, sizeof(*cp)); if (!buf) { @@ -197,7 +197,7 @@ static int ssp_confirm_neg_reply(struct bt_conn *conn) struct bt_hci_cp_user_confirm_reply *cp; struct net_buf *buf; - BT_DBG(""); + LOG_DBG(""); buf = bt_hci_cmd_create(BT_HCI_OP_USER_CONFIRM_NEG_REPLY, sizeof(*cp)); if (!buf) { @@ -245,7 +245,7 @@ static void ssp_auth(struct bt_conn *conn, uint32_t passkey) */ if (conn->required_sec_level > BT_SECURITY_L2 && conn->br.pairing_method == JUST_WORKS) { - BT_DBG("MITM protection infeasible for required security"); + LOG_DBG("MITM protection infeasible for required security"); ssp_confirm_neg_reply(conn); return; } @@ -288,7 +288,7 @@ static int ssp_passkey_reply(struct bt_conn *conn, unsigned int passkey) struct bt_hci_cp_user_passkey_reply *cp; struct net_buf *buf; - BT_DBG(""); + LOG_DBG(""); buf = bt_hci_cmd_create(BT_HCI_OP_USER_PASSKEY_REPLY, sizeof(*cp)); if (!buf) { @@ -307,7 +307,7 @@ static int ssp_passkey_neg_reply(struct bt_conn *conn) struct bt_hci_cp_user_passkey_neg_reply *cp; struct net_buf *buf; - BT_DBG(""); + LOG_DBG(""); buf = bt_hci_cmd_create(BT_HCI_OP_USER_PASSKEY_NEG_REPLY, sizeof(*cp)); if (!buf) { @@ -326,7 +326,7 @@ static int conn_auth(struct bt_conn *conn) struct bt_hci_cp_auth_requested *auth; struct net_buf *buf; - BT_DBG(""); + LOG_DBG(""); buf = bt_hci_cmd_create(BT_HCI_OP_AUTH_REQUESTED, sizeof(*auth)); if (!buf) { @@ -418,11 +418,11 @@ void bt_hci_pin_code_req(struct net_buf *buf) struct bt_hci_evt_pin_code_req *evt = (void *)buf->data; struct bt_conn *conn; - BT_DBG(""); + LOG_DBG(""); conn = bt_conn_lookup_addr_br(&evt->bdaddr); if (!conn) { - BT_ERR("Can't find conn for %s", bt_addr_str(&evt->bdaddr)); + LOG_ERR("Can't find conn for %s", bt_addr_str(&evt->bdaddr)); return; } @@ -437,17 +437,17 @@ void bt_hci_link_key_notify(struct net_buf *buf) conn = bt_conn_lookup_addr_br(&evt->bdaddr); if (!conn) { - BT_ERR("Can't find conn for %s", bt_addr_str(&evt->bdaddr)); + LOG_ERR("Can't find conn for %s", bt_addr_str(&evt->bdaddr)); return; } - BT_DBG("%s, link type 0x%02x", bt_addr_str(&evt->bdaddr), evt->key_type); + LOG_DBG("%s, link type 0x%02x", bt_addr_str(&evt->bdaddr), evt->key_type); if (!conn->br.link_key) { conn->br.link_key = bt_keys_get_link_key(&evt->bdaddr); } if (!conn->br.link_key) { - BT_ERR("Can't update keys for %s", bt_addr_str(&evt->bdaddr)); + LOG_ERR("Can't update keys for %s", bt_addr_str(&evt->bdaddr)); bt_conn_unref(conn); return; } @@ -492,7 +492,7 @@ void bt_hci_link_key_notify(struct net_buf *buf) memcpy(conn->br.link_key->val, evt->link_key, 16); break; default: - BT_WARN("Unsupported Link Key type %u", evt->key_type); + LOG_WRN("Unsupported Link Key type %u", evt->key_type); (void)memset(conn->br.link_key->val, 0, sizeof(conn->br.link_key->val)); break; @@ -511,11 +511,11 @@ void link_key_neg_reply(const bt_addr_t *bdaddr) struct bt_hci_cp_link_key_neg_reply *cp; struct net_buf *buf; - BT_DBG(""); + LOG_DBG(""); buf = bt_hci_cmd_create(BT_HCI_OP_LINK_KEY_NEG_REPLY, sizeof(*cp)); if (!buf) { - BT_ERR("Out of command buffers"); + LOG_ERR("Out of command buffers"); return; } @@ -529,11 +529,11 @@ void link_key_reply(const bt_addr_t *bdaddr, const uint8_t *lk) struct bt_hci_cp_link_key_reply *cp; struct net_buf *buf; - BT_DBG(""); + LOG_DBG(""); buf = bt_hci_cmd_create(BT_HCI_OP_LINK_KEY_REPLY, sizeof(*cp)); if (!buf) { - BT_ERR("Out of command buffers"); + LOG_ERR("Out of command buffers"); return; } @@ -548,11 +548,11 @@ void bt_hci_link_key_req(struct net_buf *buf) struct bt_hci_evt_link_key_req *evt = (void *)buf->data; struct bt_conn *conn; - BT_DBG("%s", bt_addr_str(&evt->bdaddr)); + LOG_DBG("%s", bt_addr_str(&evt->bdaddr)); conn = bt_conn_lookup_addr_br(&evt->bdaddr); if (!conn) { - BT_ERR("Can't find conn for %s", bt_addr_str(&evt->bdaddr)); + LOG_ERR("Can't find conn for %s", bt_addr_str(&evt->bdaddr)); link_key_neg_reply(&evt->bdaddr); return; } @@ -590,7 +590,7 @@ void io_capa_neg_reply(const bt_addr_t *bdaddr, const uint8_t reason) resp_buf = bt_hci_cmd_create(BT_HCI_OP_IO_CAPABILITY_NEG_REPLY, sizeof(*cp)); if (!resp_buf) { - BT_ERR("Out of command buffers"); + LOG_ERR("Out of command buffers"); return; } @@ -605,18 +605,18 @@ void bt_hci_io_capa_resp(struct net_buf *buf) struct bt_hci_evt_io_capa_resp *evt = (void *)buf->data; struct bt_conn *conn; - BT_DBG("remote %s, IOcapa 0x%02x, auth 0x%02x", - bt_addr_str(&evt->bdaddr), evt->capability, evt->authentication); + LOG_DBG("remote %s, IOcapa 0x%02x, auth 0x%02x", bt_addr_str(&evt->bdaddr), evt->capability, + evt->authentication); if (evt->authentication > BT_HCI_GENERAL_BONDING_MITM) { - BT_ERR("Invalid remote authentication requirements"); + LOG_ERR("Invalid remote authentication requirements"); io_capa_neg_reply(&evt->bdaddr, BT_HCI_ERR_UNSUPP_FEATURE_PARAM_VAL); return; } if (evt->capability > BT_IO_NO_INPUT_OUTPUT) { - BT_ERR("Invalid remote io capability requirements"); + LOG_ERR("Invalid remote io capability requirements"); io_capa_neg_reply(&evt->bdaddr, BT_HCI_ERR_UNSUPP_FEATURE_PARAM_VAL); return; @@ -624,7 +624,7 @@ void bt_hci_io_capa_resp(struct net_buf *buf) conn = bt_conn_lookup_addr_br(&evt->bdaddr); if (!conn) { - BT_ERR("Unable to find conn for %s", bt_addr_str(&evt->bdaddr)); + LOG_ERR("Unable to find conn for %s", bt_addr_str(&evt->bdaddr)); return; } @@ -642,18 +642,18 @@ void bt_hci_io_capa_req(struct net_buf *buf) struct bt_hci_cp_io_capability_reply *cp; uint8_t auth; - BT_DBG(""); + LOG_DBG(""); conn = bt_conn_lookup_addr_br(&evt->bdaddr); if (!conn) { - BT_ERR("Can't find conn for %s", bt_addr_str(&evt->bdaddr)); + LOG_ERR("Can't find conn for %s", bt_addr_str(&evt->bdaddr)); return; } resp_buf = bt_hci_cmd_create(BT_HCI_OP_IO_CAPABILITY_REPLY, sizeof(*cp)); if (!resp_buf) { - BT_ERR("Out of command buffers"); + LOG_ERR("Out of command buffers"); bt_conn_unref(conn); return; } @@ -688,11 +688,11 @@ void bt_hci_ssp_complete(struct net_buf *buf) struct bt_hci_evt_ssp_complete *evt = (void *)buf->data; struct bt_conn *conn; - BT_DBG("status 0x%02x", evt->status); + LOG_DBG("status 0x%02x", evt->status); conn = bt_conn_lookup_addr_br(&evt->bdaddr); if (!conn) { - BT_ERR("Can't find conn for %s", bt_addr_str(&evt->bdaddr)); + LOG_ERR("Can't find conn for %s", bt_addr_str(&evt->bdaddr)); return; } @@ -711,7 +711,7 @@ void bt_hci_user_confirm_req(struct net_buf *buf) conn = bt_conn_lookup_addr_br(&evt->bdaddr); if (!conn) { - BT_ERR("Can't find conn for %s", bt_addr_str(&evt->bdaddr)); + LOG_ERR("Can't find conn for %s", bt_addr_str(&evt->bdaddr)); return; } @@ -724,11 +724,11 @@ void bt_hci_user_passkey_notify(struct net_buf *buf) struct bt_hci_evt_user_passkey_notify *evt = (void *)buf->data; struct bt_conn *conn; - BT_DBG(""); + LOG_DBG(""); conn = bt_conn_lookup_addr_br(&evt->bdaddr); if (!conn) { - BT_ERR("Can't find conn for %s", bt_addr_str(&evt->bdaddr)); + LOG_ERR("Can't find conn for %s", bt_addr_str(&evt->bdaddr)); return; } @@ -743,7 +743,7 @@ void bt_hci_user_passkey_req(struct net_buf *buf) conn = bt_conn_lookup_addr_br(&evt->bdaddr); if (!conn) { - BT_ERR("Can't find conn for %s", bt_addr_str(&evt->bdaddr)); + LOG_ERR("Can't find conn for %s", bt_addr_str(&evt->bdaddr)); return; } @@ -756,11 +756,11 @@ static void link_encr(const uint16_t handle) struct bt_hci_cp_set_conn_encrypt *encr; struct net_buf *buf; - BT_DBG(""); + LOG_DBG(""); buf = bt_hci_cmd_create(BT_HCI_OP_SET_CONN_ENCRYPT, sizeof(*encr)); if (!buf) { - BT_ERR("Out of command buffers"); + LOG_ERR("Out of command buffers"); return; } @@ -777,11 +777,11 @@ void bt_hci_auth_complete(struct net_buf *buf) struct bt_conn *conn; uint16_t handle = sys_le16_to_cpu(evt->handle); - BT_DBG("status 0x%02x, handle %u", evt->status, handle); + LOG_DBG("status 0x%02x, handle %u", evt->status, handle); conn = bt_conn_lookup_handle(handle); if (!conn) { - BT_ERR("Can't find conn for handle %u", handle); + LOG_ERR("Can't find conn for handle %u", handle); return; } diff --git a/subsys/bluetooth/mesh/Kconfig b/subsys/bluetooth/mesh/Kconfig index 3f46b6005aa..31827a696de 100644 --- a/subsys/bluetooth/mesh/Kconfig +++ b/subsys/bluetooth/mesh/Kconfig @@ -950,12 +950,18 @@ endif # BT_SETTINGS config BT_MESH_DEBUG bool "Debug logs" + select DEPRECATED depends on BT_DEBUG help Use this option to enable debug logs for the Bluetooth Mesh functionality. -if BT_MESH_DEBUG +module = BT_MESH +legacy-debug-sym = BT_MESH_DEBUG +module-str = "Debug logs" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + +if BT_MESH_LOG_LEVEL_DBG config BT_MESH_DEBUG_USE_ID_ADDR bool "Use identity address for all advertising" @@ -967,112 +973,220 @@ config BT_MESH_DEBUG_USE_ID_ADDR config BT_MESH_DEBUG_NET bool "Network layer debug" + select DEPRECATED help Use this option to enable Network layer debug logs for the Bluetooth mesh functionality. +module = BT_MESH_NET +legacy-debug-sym = BT_MESH_DEBUG_NET +module-str = "Network layer" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_MESH_DEBUG_RPL bool "Replay protection list debug" + select DEPRECATED help Use this option to enable Replay protection list debug logs for the Bluetooth mesh functionality. +module = BT_MESH_RPL +legacy-debug-sym = BT_MESH_DEBUG_RPL +module-str = "Replay protection list" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_MESH_DEBUG_TRANS bool "Transport layer debug" + select DEPRECATED help Use this option to enable Transport layer debug logs for the Bluetooth mesh functionality. +module = BT_MESH_TRANS +legacy-debug-sym = BT_MESH_DEBUG_TRANS +module-str = "Transport layer" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_MESH_DEBUG_BEACON bool "Beacon debug" + select DEPRECATED help Use this option to enable Beacon-related debug logs for the Bluetooth mesh functionality. +module = BT_MESH_BEACON +legacy-debug-sym = BT_MESH_DEBUG_BEACON +module-str = "Beacon" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_MESH_DEBUG_CRYPTO bool "Crypto debug" + select DEPRECATED help Use this option to enable cryptographic debug logs for the Bluetooth mesh functionality. +module = BT_MESH_CRYPTO +legacy-debug-sym = BT_MESH_DEBUG_CRYPTO +module-str = "Crypto" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_MESH_DEBUG_KEYS bool "Key management debug" + select DEPRECATED help Use this option to enable key management debug logs for the Bluetooth mesh functionality. +module = BT_MESH_KEYS +legacy-debug-sym = BT_MESH_DEBUG_KEYS +module-str = "Key management" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_MESH_DEBUG_PROV bool "Provisioning debug" + select DEPRECATED help Use this option to enable Provisioning debug logs for the Bluetooth mesh functionality. +module = BT_MESH_PROV +legacy-debug-sym = BT_MESH_DEBUG_PROV +module-str = "Provisioning" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_MESH_DEBUG_PROVISIONER bool "Provisioner debug" + select DEPRECATED help Use this option to enable Provisioner debug logs for the Bluetooth mesh functionality. +module = BT_MESH_PROVISIONER +legacy-debug-sym = BT_MESH_DEBUG_PROVISIONER +module-str = "Provisioner" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_MESH_DEBUG_PROV_DEVICE bool "Provisioning device debug" + select DEPRECATED help Use this option to enable Provisioning device debug logs for the Bluetooth Mesh functionality. +module = BT_MESH_PROV_DEVICE +legacy-debug-sym = BT_MESH_DEBUG_PROV_DEVICE +module-str = "Provisioning device" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_MESH_DEBUG_ACCESS bool "Access layer debug" + select DEPRECATED help Use this option to enable Access layer and device composition related debug logs for Bluetooth mesh. +module = BT_MESH_ACCESS +legacy-debug-sym = BT_MESH_DEBUG_ACCESS +module-str = "Access layer" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_MESH_DEBUG_MODEL bool "Foundation model debug" + select DEPRECATED help Use this option to enable debug logs for the Foundation Models. +module = BT_MESH_MODEL +legacy-debug-sym = BT_MESH_DEBUG_MODEL +module-str = "Foundation model" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_MESH_DEBUG_ADV bool "Advertising debug" + select DEPRECATED help Use this option to enable advertising debug logs for the Bluetooth mesh functionality. +module = BT_MESH_ADV +legacy-debug-sym = BT_MESH_DEBUG_ADV +module-str = "Advertising" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_MESH_DEBUG_LOW_POWER bool "Low Power debug" + select DEPRECATED help Use this option to enable Low Power debug logs for the Bluetooth mesh functionality. +module = BT_MESH_LOW_POWER +legacy-debug-sym = BT_MESH_DEBUG_LOW_POWER +module-str = "Low Power" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_MESH_DEBUG_FRIEND bool "Friend debug" + select DEPRECATED help Use this option to enable Friend debug logs for the Bluetooth mesh functionality. +module = BT_MESH_FRIEND +legacy-debug-sym = BT_MESH_DEBUG_FRIEND +module-str = "Friend" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_MESH_DEBUG_PROXY bool "Proxy debug" + select DEPRECATED depends on BT_MESH_GATT help Use this option to enable Proxy protocol debug logs. +module = BT_MESH_PROXY +legacy-debug-sym = BT_MESH_DEBUG_PROXY +module-str = "Proxy" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_MESH_DEBUG_SETTINGS bool "Persistent settings debug" + select DEPRECATED depends on BT_SETTINGS help Use this option to enable persistent settings debug logs. +module = BT_MESH_SETTINGS +legacy-debug-sym = BT_MESH_DEBUG_SETTINGS +module-str = "Persistent settings" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_MESH_DEBUG_CDB bool "Configuration database debug" + select DEPRECATED depends on BT_MESH_CDB help Use this option to enable configuration database debug logs. +module = BT_MESH_CDB +legacy-debug-sym = BT_MESH_DEBUG_CDB +module-str = "Configuration database" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + config BT_MESH_DEBUG_CFG bool "Configuration debug" + select DEPRECATED help Use this option to enable node configuration debug logs for the Bluetooth mesh functionality. -endif # BT_MESH_DEBUG +module = BT_MESH_CFG +legacy-debug-sym = BT_MESH_DEBUG_CFG +module-str = "Configuration" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + +endif # BT_MESH_LOG_LEVEL_DBG endif # BT_MESH diff --git a/subsys/bluetooth/mesh/access.c b/subsys/bluetooth/mesh/access.c index 123b89887e5..7d74fd70819 100644 --- a/subsys/bluetooth/mesh/access.c +++ b/subsys/bluetooth/mesh/access.c @@ -14,9 +14,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_ACCESS) -#define LOG_MODULE_NAME bt_mesh_access -#include "common/log.h" #include "common/bt_str.h" #include "mesh.h" @@ -28,6 +25,10 @@ #include "foundation.h" #include "settings.h" +#define LOG_LEVEL CONFIG_BT_MESH_ACCESS_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_mesh_access); + /* bt_mesh_model.flags */ enum { BT_MESH_MOD_BIND_PENDING = BIT(0), @@ -119,7 +120,7 @@ static int32_t next_period(struct bt_mesh_model *mod) uint32_t elapsed; elapsed = k_uptime_get_32() - pub->period_start; - BT_DBG("Publishing took %ums", elapsed); + LOG_DBG("Publishing took %ums", elapsed); if (mod->pub->count) { /* If a message is to be retransmitted, period should include time since the first @@ -129,7 +130,7 @@ static int32_t next_period(struct bt_mesh_model *mod) period *= BT_MESH_PUB_MSG_NUM(mod->pub); if (period && elapsed >= period) { - BT_WARN("Retransmission interval is too short"); + LOG_WRN("Retransmission interval is too short"); /* Return smallest positive number since 0 means disabled */ return 1; } @@ -143,7 +144,7 @@ static int32_t next_period(struct bt_mesh_model *mod) } if (elapsed >= period) { - BT_WARN("Publication sending took longer than the period"); + LOG_WRN("Publication sending took longer than the period"); /* Return smallest positive number since 0 means disabled */ return 1; } @@ -156,12 +157,12 @@ static void publish_sent(int err, void *user_data) struct bt_mesh_model *mod = user_data; int32_t delay; - BT_DBG("err %d, time %u", err, k_uptime_get_32()); + LOG_DBG("err %d, time %u", err, k_uptime_get_32()); delay = next_period(mod); if (delay) { - BT_DBG("Publishing next time in %dms", delay); + LOG_DBG("Publishing next time in %dms", delay); /* Using schedule() in case the application has already called * bt_mesh_publish, and a publication is pending. */ @@ -172,7 +173,7 @@ static void publish_sent(int err, void *user_data) static void publish_start(uint16_t duration, int err, void *user_data) { if (err) { - BT_ERR("Failed to publish: err %d", err); + LOG_ERR("Failed to publish: err %d", err); publish_sent(err, user_data); return; } @@ -219,7 +220,7 @@ static int pub_period_start(struct bt_mesh_model_pub *pub) if (err) { /* Skip this publish attempt. */ - BT_DBG("Update failed, skipping publish (err: %d)", err); + LOG_DBG("Update failed, skipping publish (err: %d)", err); pub->count = 0; publish_sent(err, pub->mod); return err; @@ -244,7 +245,7 @@ static void mod_publish(struct k_work *work) return; } - BT_DBG("%u", k_uptime_get_32()); + LOG_DBG("%u", k_uptime_get_32()); if (pub->count) { pub->count--; @@ -267,7 +268,7 @@ static void mod_publish(struct k_work *work) err = publish_transmit(pub->mod); if (err) { - BT_ERR("Failed to publish (err %d)", err); + LOG_ERR("Failed to publish (err %d)", err); publish_sent(err, pub->mod); } } @@ -282,7 +283,7 @@ struct bt_mesh_model *bt_mesh_model_get(bool vnd, uint8_t elem_idx, uint8_t mod_ struct bt_mesh_elem *elem; if (elem_idx >= dev_comp->elem_count) { - BT_ERR("Invalid element index %u", elem_idx); + LOG_ERR("Invalid element index %u", elem_idx); return NULL; } @@ -290,14 +291,14 @@ struct bt_mesh_model *bt_mesh_model_get(bool vnd, uint8_t elem_idx, uint8_t mod_ if (vnd) { if (mod_idx >= elem->vnd_model_count) { - BT_ERR("Invalid vendor model index %u", mod_idx); + LOG_ERR("Invalid vendor model index %u", mod_idx); return NULL; } return &elem->vnd_models[mod_idx]; } else { if (mod_idx >= elem->model_count) { - BT_ERR("Invalid SIG model index %u", mod_idx); + LOG_ERR("Invalid SIG model index %u", mod_idx); return NULL; } @@ -318,7 +319,7 @@ static int bt_mesh_vnd_mod_msg_cid_check(struct bt_mesh_model *mod) continue; } - BT_ERR("Invalid vendor model(company:0x%04x" + LOG_ERR("Invalid vendor model(company:0x%04x" " id:0x%04x) message opcode 0x%08x", mod->vnd.company, mod->vnd.id, op->opcode); @@ -391,21 +392,21 @@ void bt_mesh_comp_provision(uint16_t addr) dev_primary_addr = addr; - BT_DBG("addr 0x%04x elem_count %zu", addr, dev_comp->elem_count); + LOG_DBG("addr 0x%04x elem_count %zu", addr, dev_comp->elem_count); for (i = 0; i < dev_comp->elem_count; i++) { struct bt_mesh_elem *elem = &dev_comp->elem[i]; elem->addr = addr++; - BT_DBG("addr 0x%04x mod_count %u vnd_mod_count %u", - elem->addr, elem->model_count, elem->vnd_model_count); + LOG_DBG("addr 0x%04x mod_count %u vnd_mod_count %u", elem->addr, elem->model_count, + elem->vnd_model_count); } } void bt_mesh_comp_unprovision(void) { - BT_DBG(""); + LOG_DBG(""); dev_primary_addr = BT_MESH_ADDR_UNASSIGNED; } @@ -548,12 +549,12 @@ int bt_mesh_access_send(struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf, .src = src_addr, }; - BT_DBG("net_idx 0x%04x app_idx 0x%04x dst 0x%04x", tx.ctx->net_idx, - tx.ctx->app_idx, tx.ctx->addr); - BT_DBG("len %u: %s", buf->len, bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x dst 0x%04x", tx.ctx->net_idx, tx.ctx->app_idx, + tx.ctx->addr); + LOG_DBG("len %u: %s", buf->len, bt_hex(buf->data, buf->len)); if (!bt_mesh_is_provisioned()) { - BT_ERR("Local node is not yet provisioned"); + LOG_ERR("Local node is not yet provisioned"); return -EAGAIN; } @@ -648,7 +649,7 @@ static int get_opcode(struct net_buf_simple *buf, uint32_t *opcode) case 0x00: case 0x01: if (buf->data[0] == 0x7f) { - BT_ERR("Ignoring RFU OpCode"); + LOG_ERR("Ignoring RFU OpCode"); return -EINVAL; } @@ -656,7 +657,7 @@ static int get_opcode(struct net_buf_simple *buf, uint32_t *opcode) return 0; case 0x02: if (buf->len < 2) { - BT_ERR("Too short payload for 2-octet OpCode"); + LOG_ERR("Too short payload for 2-octet OpCode"); return -EINVAL; } @@ -664,7 +665,7 @@ static int get_opcode(struct net_buf_simple *buf, uint32_t *opcode) return 0; case 0x03: if (buf->len < 3) { - BT_ERR("Too short payload for 3-octet OpCode"); + LOG_ERR("Too short payload for 3-octet OpCode"); return -EINVAL; } @@ -687,23 +688,23 @@ void bt_mesh_model_recv(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf) uint32_t opcode; int i; - BT_DBG("app_idx 0x%04x src 0x%04x dst 0x%04x", rx->ctx.app_idx, - rx->ctx.addr, rx->ctx.recv_dst); - BT_DBG("len %u: %s", buf->len, bt_hex(buf->data, buf->len)); + LOG_DBG("app_idx 0x%04x src 0x%04x dst 0x%04x", rx->ctx.app_idx, rx->ctx.addr, + rx->ctx.recv_dst); + LOG_DBG("len %u: %s", buf->len, bt_hex(buf->data, buf->len)); if (get_opcode(buf, &opcode) < 0) { - BT_WARN("Unable to decode OpCode"); + LOG_WRN("Unable to decode OpCode"); return; } - BT_DBG("OpCode 0x%08x", opcode); + LOG_DBG("OpCode 0x%08x", opcode); for (i = 0; i < dev_comp->elem_count; i++) { struct net_buf_simple_state state; op = find_op(&dev_comp->elem[i], opcode, &model); if (!op) { - BT_DBG("No OpCode 0x%08x for elem %d", opcode, i); + LOG_DBG("No OpCode 0x%08x for elem %d", opcode, i); continue; } @@ -716,11 +717,10 @@ void bt_mesh_model_recv(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf) } if ((op->len >= 0) && (buf->len < (size_t)op->len)) { - BT_ERR("Too short message for OpCode 0x%08x", opcode); + LOG_ERR("Too short message for OpCode 0x%08x", opcode); continue; } else if ((op->len < 0) && (buf->len != (size_t)(-op->len))) { - BT_ERR("Invalid message size for OpCode 0x%08x", - opcode); + LOG_ERR("Invalid message size for OpCode 0x%08x", opcode); continue; } @@ -743,7 +743,7 @@ int bt_mesh_model_send(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, const struct bt_mesh_send_cb *cb, void *cb_data) { if (!bt_mesh_model_has_key(model, ctx->app_idx)) { - BT_ERR("Model not bound to AppKey 0x%04x", ctx->app_idx); + LOG_ERR("Model not bound to AppKey 0x%04x", ctx->app_idx); return -EINVAL; } @@ -758,32 +758,32 @@ int bt_mesh_model_publish(struct bt_mesh_model *model) return -ENOTSUP; } - BT_DBG(""); + LOG_DBG(""); if (pub->addr == BT_MESH_ADDR_UNASSIGNED) { return -EADDRNOTAVAIL; } if (!pub->msg || !pub->msg->len) { - BT_ERR("No publication message"); + LOG_ERR("No publication message"); return -EINVAL; } if (pub->msg->len + BT_MESH_MIC_SHORT > BT_MESH_TX_SDU_MAX) { - BT_ERR("Message does not fit maximum SDU size"); + LOG_ERR("Message does not fit maximum SDU size"); return -EMSGSIZE; } if (pub->count) { - BT_WARN("Clearing publish retransmit timer"); + LOG_WRN("Clearing publish retransmit timer"); } /* Account for initial transmission */ pub->count = BT_MESH_PUB_MSG_TOTAL(pub); pub->period_start = k_uptime_get_32(); - BT_DBG("Publish Retransmit Count %u Interval %ums", pub->count, - BT_MESH_PUB_TRANSMIT_INT(pub->retransmit)); + LOG_DBG("Publish Retransmit Count %u Interval %ums", pub->count, + BT_MESH_PUB_TRANSMIT_INT(pub->retransmit)); k_work_reschedule(&pub->timer, K_NO_WAIT); @@ -904,19 +904,19 @@ static int mod_set_bind(struct bt_mesh_model *mod, size_t len_rd, } if (len_rd == 0) { - BT_DBG("Cleared bindings for model"); + LOG_DBG("Cleared bindings for model"); return 0; } len = read_cb(cb_arg, mod->keys, mod->keys_cnt * sizeof(mod->keys[0])); if (len < 0) { - BT_ERR("Failed to read value (err %zd)", len); + LOG_ERR("Failed to read value (err %zd)", len); return len; } LOG_HEXDUMP_DBG(mod->keys, len, "val"); - BT_DBG("Decoded %zu bound keys for model", len / sizeof(mod->keys[0])); + LOG_DBG("Decoded %zu bound keys for model", len / sizeof(mod->keys[0])); return 0; } @@ -930,20 +930,19 @@ static int mod_set_sub(struct bt_mesh_model *mod, size_t len_rd, (void)memset(mod->groups, 0, size); if (len_rd == 0) { - BT_DBG("Cleared subscriptions for model"); + LOG_DBG("Cleared subscriptions for model"); return 0; } len = read_cb(cb_arg, mod->groups, size); if (len < 0) { - BT_ERR("Failed to read value (err %zd)", len); + LOG_ERR("Failed to read value (err %zd)", len); return len; } LOG_HEXDUMP_DBG(mod->groups, len, "val"); - BT_DBG("Decoded %zu subscribed group addresses for model", - len / sizeof(mod->groups[0])); + LOG_DBG("Decoded %zu subscribed group addresses for model", len / sizeof(mod->groups[0])); return 0; } @@ -954,7 +953,7 @@ static int mod_set_pub(struct bt_mesh_model *mod, size_t len_rd, int err; if (!mod->pub) { - BT_WARN("Model has no publication context!"); + LOG_WRN("Model has no publication context!"); return -EINVAL; } @@ -967,7 +966,7 @@ static int mod_set_pub(struct bt_mesh_model *mod, size_t len_rd, mod->pub->retransmit = 0U; mod->pub->count = 0U; - BT_DBG("Cleared publication for model"); + LOG_DBG("Cleared publication for model"); return 0; } @@ -977,7 +976,7 @@ static int mod_set_pub(struct bt_mesh_model *mod, size_t len_rd, err = bt_mesh_settings_set(read_cb, cb_arg, &pub, sizeof(pub)); if (err) { - BT_ERR("Failed to set \'model-pub\'"); + LOG_ERR("Failed to set \'model-pub\'"); return err; } @@ -990,8 +989,7 @@ static int mod_set_pub(struct bt_mesh_model *mod, size_t len_rd, mod->pub->period_div = pub.period_div; mod->pub->count = 0U; - BT_DBG("Restored model publication, dst 0x%04x app_idx 0x%03x", - pub.addr, pub.key); + LOG_DBG("Restored model publication, dst 0x%04x app_idx 0x%03x", pub.addr, pub.key); return 0; } @@ -1022,7 +1020,7 @@ static int mod_set(bool vnd, const char *name, size_t len_rd, const char *next; if (!name) { - BT_ERR("Insufficient number of arguments"); + LOG_ERR("Insufficient number of arguments"); return -ENOENT; } @@ -1030,20 +1028,18 @@ static int mod_set(bool vnd, const char *name, size_t len_rd, elem_idx = mod_key >> 8; mod_idx = mod_key; - BT_DBG("Decoded mod_key 0x%04x as elem_idx %u mod_idx %u", - mod_key, elem_idx, mod_idx); + LOG_DBG("Decoded mod_key 0x%04x as elem_idx %u mod_idx %u", mod_key, elem_idx, mod_idx); mod = bt_mesh_model_get(vnd, elem_idx, mod_idx); if (!mod) { - BT_ERR("Failed to get model for elem_idx %u mod_idx %u", - elem_idx, mod_idx); + LOG_ERR("Failed to get model for elem_idx %u mod_idx %u", elem_idx, mod_idx); return -ENOENT; } len = settings_name_next(name, &next); if (!next) { - BT_ERR("Insufficient number of arguments"); + LOG_ERR("Insufficient number of arguments"); return -ENOENT; } @@ -1063,7 +1059,7 @@ static int mod_set(bool vnd, const char *name, size_t len_rd, return mod_data_set(mod, next, len_rd, read_cb, cb_arg); } - BT_WARN("Unknown module key %s", next); + LOG_WRN("Unknown module key %s", next); return -ENOENT; } @@ -1104,7 +1100,7 @@ static void store_pending_mod_bind(struct bt_mesh_model *mod, bool vnd) for (i = 0, count = 0; i < mod->keys_cnt; i++) { if (mod->keys[i] != BT_MESH_KEY_UNUSED) { keys[count++] = mod->keys[i]; - BT_DBG("model key 0x%04x", mod->keys[i]); + LOG_DBG("model key 0x%04x", mod->keys[i]); } } @@ -1117,9 +1113,9 @@ static void store_pending_mod_bind(struct bt_mesh_model *mod, bool vnd) } if (err) { - BT_ERR("Failed to store %s value", path); + LOG_ERR("Failed to store %s value", path); } else { - BT_DBG("Stored %s value", path); + LOG_DBG("Stored %s value", path); } } @@ -1145,9 +1141,9 @@ static void store_pending_mod_sub(struct bt_mesh_model *mod, bool vnd) } if (err) { - BT_ERR("Failed to store %s value", path); + LOG_ERR("Failed to store %s value", path); } else { - BT_DBG("Stored %s value", path); + LOG_DBG("Stored %s value", path); } } @@ -1174,9 +1170,9 @@ static void store_pending_mod_pub(struct bt_mesh_model *mod, bool vnd) } if (err) { - BT_ERR("Failed to store %s value", path); + LOG_ERR("Failed to store %s value", path); } else { - BT_DBG("Stored %s value", path); + LOG_DBG("Stored %s value", path); } } @@ -1247,9 +1243,9 @@ int bt_mesh_model_data_store(struct bt_mesh_model *mod, bool vnd, } if (err) { - BT_ERR("Failed to store %s value", path); + LOG_ERR("Failed to store %s value", path); } else { - BT_DBG("Stored %s value", path); + LOG_DBG("Stored %s value", path); } return err; } @@ -1262,7 +1258,7 @@ static void commit_mod(struct bt_mesh_model *mod, struct bt_mesh_elem *elem, int32_t ms = bt_mesh_model_pub_period_get(mod); if (ms > 0) { - BT_DBG("Starting publish timer (period %u ms)", ms); + LOG_DBG("Starting publish timer (period %u ms)", ms); k_work_schedule(&mod->pub->timer, K_MSEC(ms)); } } diff --git a/subsys/bluetooth/mesh/adv.c b/subsys/bluetooth/mesh/adv.c index d3d0add80f0..b517c59617d 100644 --- a/subsys/bluetooth/mesh/adv.c +++ b/subsys/bluetooth/mesh/adv.c @@ -15,9 +15,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_ADV) -#define LOG_MODULE_NAME bt_mesh_adv -#include "common/log.h" #include "common/bt_str.h" #include "adv.h" @@ -29,6 +26,10 @@ #include "proxy.h" #include "pb_gatt_srv.h" +#define LOG_LEVEL CONFIG_BT_MESH_ADV_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_mesh_adv); + /* Window and Interval are equal for continuous scanning */ #define MESH_SCAN_INTERVAL BT_MESH_ADV_SCAN_UNIT(BT_MESH_SCAN_INTERVAL_MS) #define MESH_SCAN_WINDOW BT_MESH_ADV_SCAN_UNIT(BT_MESH_SCAN_WINDOW_MS) @@ -76,7 +77,7 @@ static struct net_buf *bt_mesh_adv_create_from_pool(struct net_buf_pool *buf_poo struct net_buf *buf; if (atomic_test_bit(bt_mesh.flags, BT_MESH_SUSPENDED)) { - BT_WARN("Refusing to allocate buffer while suspended"); + LOG_WRN("Refusing to allocate buffer while suspended"); return NULL; } @@ -117,7 +118,7 @@ struct net_buf *bt_mesh_adv_create(enum bt_mesh_adv_type type, static struct net_buf *process_events(struct k_poll_event *ev, int count) { for (; count; ev++, count--) { - BT_DBG("ev->state %u", ev->state); + LOG_DBG("ev->state %u", ev->state); switch (ev->state) { case K_POLL_STATE_FIFO_DATA_AVAILABLE: @@ -126,7 +127,7 @@ static struct net_buf *process_events(struct k_poll_event *ev, int count) case K_POLL_STATE_CANCELLED: break; default: - BT_WARN("Unexpected k_poll event state %u", ev->state); + LOG_WRN("Unexpected k_poll event state %u", ev->state); break; } } @@ -189,7 +190,7 @@ struct net_buf *bt_mesh_adv_buf_get_by_tag(uint8_t tag, k_timeout_t timeout) void bt_mesh_adv_buf_get_cancel(void) { - BT_DBG(""); + LOG_DBG(""); k_fifo_cancel_wait(&bt_mesh_adv_queue); @@ -202,8 +203,8 @@ void bt_mesh_adv_buf_get_cancel(void) void bt_mesh_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *cb, void *cb_data) { - BT_DBG("type 0x%02x len %u: %s", BT_MESH_ADV(buf)->type, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("type 0x%02x len %u: %s", BT_MESH_ADV(buf)->type, buf->len, + bt_hex(buf->data, buf->len)); BT_MESH_ADV(buf)->cb = cb; BT_MESH_ADV(buf)->cb_data = cb_data; @@ -227,11 +228,11 @@ int bt_mesh_adv_gatt_send(void) { if (bt_mesh_is_provisioned()) { if (IS_ENABLED(CONFIG_BT_MESH_GATT_PROXY)) { - BT_DBG("Proxy Advertising"); + LOG_DBG("Proxy Advertising"); return bt_mesh_proxy_adv_start(); } } else if (IS_ENABLED(CONFIG_BT_MESH_PB_GATT)) { - BT_DBG("PB-GATT Advertising"); + LOG_DBG("PB-GATT Advertising"); return bt_mesh_pb_gatt_srv_adv_start(); } @@ -245,7 +246,7 @@ static void bt_mesh_scan_cb(const bt_addr_le_t *addr, int8_t rssi, return; } - BT_DBG("len %u: %s", buf->len, bt_hex(buf->data, buf->len)); + LOG_DBG("len %u: %s", buf->len, bt_hex(buf->data, buf->len)); while (buf->len > 1) { struct net_buf_simple_state state; @@ -258,7 +259,7 @@ static void bt_mesh_scan_cb(const bt_addr_le_t *addr, int8_t rssi, } if (len > buf->len) { - BT_WARN("AD malformed"); + LOG_WRN("AD malformed"); return; } @@ -298,11 +299,11 @@ int bt_mesh_scan_enable(void) .window = MESH_SCAN_WINDOW }; int err; - BT_DBG(""); + LOG_DBG(""); err = bt_le_scan_start(&scan_param, bt_mesh_scan_cb); if (err && err != -EALREADY) { - BT_ERR("starting scan failed (err %d)", err); + LOG_ERR("starting scan failed (err %d)", err); return err; } @@ -313,11 +314,11 @@ int bt_mesh_scan_disable(void) { int err; - BT_DBG(""); + LOG_DBG(""); err = bt_le_scan_stop(); if (err && err != -EALREADY) { - BT_ERR("stopping scan failed (err %d)", err); + LOG_ERR("stopping scan failed (err %d)", err); return err; } diff --git a/subsys/bluetooth/mesh/adv_ext.c b/subsys/bluetooth/mesh/adv_ext.c index effebff941d..c175bc03dde 100644 --- a/subsys/bluetooth/mesh/adv_ext.c +++ b/subsys/bluetooth/mesh/adv_ext.c @@ -11,11 +11,9 @@ #include #include +#include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_ADV) -#define LOG_MODULE_NAME bt_mesh_adv_ext -#include "common/log.h" #include "common/bt_str.h" #include "host/hci_core.h" @@ -24,6 +22,10 @@ #include "net.h" #include "proxy.h" +#define LOG_LEVEL CONFIG_BT_MESH_ADV_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_mesh_adv_ext); + /* Convert from ms to 0.625ms units */ #define ADV_INT_FAST_MS 20 @@ -126,19 +128,19 @@ static int adv_start(struct bt_mesh_ext_adv *adv, int err; if (!adv->instance) { - BT_ERR("Mesh advertiser not enabled"); + LOG_ERR("Mesh advertiser not enabled"); return -ENODEV; } if (atomic_test_and_set_bit(adv->flags, ADV_FLAG_ACTIVE)) { - BT_ERR("Advertiser is busy"); + LOG_ERR("Advertiser is busy"); return -EBUSY; } if (atomic_test_bit(adv->flags, ADV_FLAG_UPDATE_PARAMS)) { err = bt_le_ext_adv_update_param(adv->instance, param); if (err) { - BT_ERR("Failed updating adv params: %d", err); + LOG_ERR("Failed updating adv params: %d", err); atomic_clear_bit(adv->flags, ADV_FLAG_ACTIVE); return err; } @@ -149,7 +151,7 @@ static int adv_start(struct bt_mesh_ext_adv *adv, err = bt_le_ext_adv_set_data(adv->instance, ad, ad_len, sd, sd_len); if (err) { - BT_ERR("Failed setting adv data: %d", err); + LOG_ERR("Failed setting adv data: %d", err); atomic_clear_bit(adv->flags, ADV_FLAG_ACTIVE); return err; } @@ -158,7 +160,7 @@ static int adv_start(struct bt_mesh_ext_adv *adv, err = bt_le_ext_adv_start(adv->instance, start); if (err) { - BT_ERR("Advertising failed: err %d", err); + LOG_ERR("Advertising failed: err %d", err); atomic_clear_bit(adv->flags, ADV_FLAG_ACTIVE); } @@ -180,11 +182,10 @@ static int buf_send(struct bt_mesh_ext_adv *adv, struct net_buf *buf) /* Upper boundary estimate: */ duration = start.num_events * (adv_int + 10); - BT_DBG("type %u len %u: %s", BT_MESH_ADV(buf)->type, - buf->len, bt_hex(buf->data, buf->len)); - BT_DBG("count %u interval %ums duration %ums", - BT_MESH_TRANSMIT_COUNT(BT_MESH_ADV(buf)->xmit) + 1, adv_int, - duration); + LOG_DBG("type %u len %u: %s", BT_MESH_ADV(buf)->type, buf->len, + bt_hex(buf->data, buf->len)); + LOG_DBG("count %u interval %ums duration %ums", + BT_MESH_TRANSMIT_COUNT(BT_MESH_ADV(buf)->xmit) + 1, adv_int, duration); ad.type = bt_mesh_adv_type[BT_MESH_ADV(buf)->type]; ad.data_len = buf->len; @@ -222,7 +223,7 @@ static void send_pending_adv(struct k_work *work) */ int64_t duration = k_uptime_delta(&adv->timestamp); - BT_DBG("Advertising stopped after %u ms", (uint32_t)duration); + LOG_DBG("Advertising stopped after %u ms", (uint32_t)duration); atomic_clear_bit(adv->flags, ADV_FLAG_ACTIVE); atomic_clear_bit(adv->flags, ADV_FLAG_PROXY); @@ -364,7 +365,7 @@ static void adv_sent(struct bt_le_ext_adv *instance, struct bt_mesh_ext_adv *adv = adv_instance_find(instance); if (!adv) { - BT_WARN("Unexpected adv instance"); + LOG_WRN("Unexpected adv instance"); return; } @@ -429,7 +430,7 @@ int bt_mesh_adv_gatt_start(const struct bt_le_adv_param *param, .timeout = (duration == SYS_FOREVER_MS) ? 0 : MAX(1, duration / 10), }; - BT_DBG("Start advertising %d ms", duration); + LOG_DBG("Start advertising %d ms", duration); atomic_set_bit(adv->flags, ADV_FLAG_UPDATE_PARAMS); diff --git a/subsys/bluetooth/mesh/adv_legacy.c b/subsys/bluetooth/mesh/adv_legacy.c index 5a6279d940f..464a09c540b 100644 --- a/subsys/bluetooth/mesh/adv_legacy.c +++ b/subsys/bluetooth/mesh/adv_legacy.c @@ -15,9 +15,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_ADV) -#define LOG_MODULE_NAME bt_mesh_adv_legacy -#include "common/log.h" #include "common/bt_str.h" #include "host/hci_core.h" @@ -29,6 +26,10 @@ #include "host/ecc.h" #include "prov.h" +#define LOG_LEVEL CONFIG_BT_MESH_ADV_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_mesh_adv_legacy); + /* Pre-5.0 controllers enforce a minimum interval of 100ms * whereas 5.0+ controllers can go down to 20ms. */ @@ -76,11 +77,10 @@ static inline void adv_send(struct net_buf *buf) duration += BT_MESH_SCAN_WINDOW_MS; } - BT_DBG("type %u len %u: %s", BT_MESH_ADV(buf)->type, - buf->len, bt_hex(buf->data, buf->len)); - BT_DBG("count %u interval %ums duration %ums", - BT_MESH_TRANSMIT_COUNT(BT_MESH_ADV(buf)->xmit) + 1, adv_int, - duration); + LOG_DBG("type %u len %u: %s", BT_MESH_ADV(buf)->type, buf->len, + bt_hex(buf->data, buf->len)); + LOG_DBG("count %u interval %ums duration %ums", + BT_MESH_TRANSMIT_COUNT(BT_MESH_ADV(buf)->xmit) + 1, adv_int, duration); ad.type = bt_mesh_adv_type[BT_MESH_ADV(buf)->type]; ad.data_len = buf->len; @@ -105,26 +105,26 @@ static inline void adv_send(struct net_buf *buf) bt_mesh_adv_send_start(duration, err, BT_MESH_ADV(buf)); if (err) { - BT_ERR("Advertising failed: err %d", err); + LOG_ERR("Advertising failed: err %d", err); return; } - BT_DBG("Advertising started. Sleeping %u ms", duration); + LOG_DBG("Advertising started. Sleeping %u ms", duration); k_sleep(K_MSEC(duration)); err = bt_le_adv_stop(); if (err) { - BT_ERR("Stopping advertising failed: err %d", err); + LOG_ERR("Stopping advertising failed: err %d", err); return; } - BT_DBG("Advertising stopped (%u ms)", (uint32_t) k_uptime_delta(&time)); + LOG_DBG("Advertising stopped (%u ms)", (uint32_t) k_uptime_delta(&time)); } static void adv_thread(void *p1, void *p2, void *p3) { - BT_DBG("started"); + LOG_DBG("started"); while (1) { struct net_buf *buf; diff --git a/subsys/bluetooth/mesh/app_keys.c b/subsys/bluetooth/mesh/app_keys.c index f3602584438..fd644be7c0a 100644 --- a/subsys/bluetooth/mesh/app_keys.c +++ b/subsys/bluetooth/mesh/app_keys.c @@ -21,11 +21,12 @@ #include "foundation.h" #include "access.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_KEYS) -#define LOG_MODULE_NAME bt_mesh_app_keys -#include "common/log.h" #include "common/bt_str.h" +#define LOG_LEVEL CONFIG_BT_MESH_KEYS_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_mesh_app_keys); + /* Tracking of what storage changes are pending for App Keys. We track this in * a separate array here instead of within the respective bt_mesh_app_key * struct itself, since once a key gets deleted its struct becomes invalid @@ -83,9 +84,9 @@ static void clear_app_key(uint16_t app_idx) snprintk(path, sizeof(path), "bt/mesh/AppKey/%x", app_idx); err = settings_delete(path); if (err) { - BT_ERR("Failed to clear AppKeyIndex 0x%03x", app_idx); + LOG_ERR("Failed to clear AppKeyIndex 0x%03x", app_idx); } else { - BT_DBG("Cleared AppKeyIndex 0x%03x", app_idx); + LOG_DBG("Cleared AppKeyIndex 0x%03x", app_idx); } } @@ -100,7 +101,7 @@ static void store_app_key(uint16_t app_idx) app = app_get(app_idx); if (!app) { - BT_WARN("ApKeyIndex 0x%03x not found", app_idx); + LOG_WRN("ApKeyIndex 0x%03x not found", app_idx); return; } @@ -112,9 +113,9 @@ static void store_app_key(uint16_t app_idx) err = settings_save_one(path, &key, sizeof(key)); if (err) { - BT_ERR("Failed to store AppKey %s value", path); + LOG_ERR("Failed to store AppKey %s value", path); } else { - BT_DBG("Stored AppKey %s value", path); + LOG_DBG("Stored AppKey %s value", path); } } @@ -148,7 +149,7 @@ static void update_app_key_settings(uint16_t app_idx, bool store) struct app_key_update *update, *free_slot; uint8_t clear = store ? 0U : 1U; - BT_DBG("AppKeyIndex 0x%03x", app_idx); + LOG_DBG("AppKeyIndex 0x%03x", app_idx); update = app_key_update_find(app_idx, &free_slot); if (update) { @@ -201,7 +202,7 @@ static struct app_key *app_key_alloc(uint16_t app_idx) static void app_key_del(struct app_key *app) { - BT_DBG("AppIdx 0x%03x", app->app_idx); + LOG_DBG("AppIdx 0x%03x", app->app_idx); if (IS_ENABLED(CONFIG_BT_SETTINGS)) { update_app_key_settings(app->app_idx, false); @@ -236,8 +237,7 @@ uint8_t bt_mesh_app_key_add(uint16_t app_idx, uint16_t net_idx, { struct app_key *app; - BT_DBG("net_idx 0x%04x app_idx %04x val %s", net_idx, app_idx, - bt_hex(key, 16)); + LOG_DBG("net_idx 0x%04x app_idx %04x val %s", net_idx, app_idx, bt_hex(key, 16)); if (!bt_mesh_subnet_get(net_idx)) { return STATUS_INVALID_NETKEY; @@ -264,7 +264,7 @@ uint8_t bt_mesh_app_key_add(uint16_t app_idx, uint16_t net_idx, return STATUS_CANNOT_SET; } - BT_DBG("AppIdx 0x%04x AID 0x%02x", app_idx, app->keys[0].id); + LOG_DBG("AppIdx 0x%04x AID 0x%02x", app_idx, app->keys[0].id); app->net_idx = net_idx; app->app_idx = app_idx; @@ -272,7 +272,7 @@ uint8_t bt_mesh_app_key_add(uint16_t app_idx, uint16_t net_idx, memcpy(app->keys[0].val, key, 16); if (IS_ENABLED(CONFIG_BT_SETTINGS)) { - BT_DBG("Storing AppKey persistently"); + LOG_DBG("Storing AppKey persistently"); update_app_key_settings(app->app_idx, true); } @@ -287,8 +287,7 @@ uint8_t bt_mesh_app_key_update(uint16_t app_idx, uint16_t net_idx, struct app_key *app; struct bt_mesh_subnet *sub; - BT_DBG("net_idx 0x%04x app_idx %04x val %s", net_idx, app_idx, - bt_hex(key, 16)); + LOG_DBG("net_idx 0x%04x app_idx %04x val %s", net_idx, app_idx, bt_hex(key, 16)); app = app_get(app_idx); if (!app) { @@ -325,13 +324,13 @@ uint8_t bt_mesh_app_key_update(uint16_t app_idx, uint16_t net_idx, return STATUS_CANNOT_UPDATE; } - BT_DBG("app_idx 0x%04x AID 0x%02x", app_idx, app->keys[1].id); + LOG_DBG("app_idx 0x%04x AID 0x%02x", app_idx, app->keys[1].id); app->updated = true; memcpy(app->keys[1].val, key, 16); if (IS_ENABLED(CONFIG_BT_SETTINGS)) { - BT_DBG("Storing AppKey persistently"); + LOG_DBG("Storing AppKey persistently"); update_app_key_settings(app->app_idx, true); } @@ -344,7 +343,7 @@ uint8_t bt_mesh_app_key_del(uint16_t app_idx, uint16_t net_idx) { struct app_key *app; - BT_DBG("AppIdx 0x%03x", app_idx); + LOG_DBG("AppIdx 0x%03x", app_idx); if (net_idx != BT_MESH_KEY_UNUSED && !bt_mesh_subnet_get(net_idx)) { return STATUS_INVALID_NETKEY; @@ -381,7 +380,7 @@ int bt_mesh_app_key_set(uint16_t app_idx, uint16_t net_idx, return 0; } - BT_DBG("AppIdx 0x%04x AID 0x%02x", app_idx, app->keys[0].id); + LOG_DBG("AppIdx 0x%04x AID 0x%02x", app_idx, app->keys[0].id); memcpy(app->keys[0].val, old_key, 16); if (bt_mesh_app_id(old_key, &app->keys[0].id)) { @@ -456,7 +455,7 @@ int bt_mesh_keys_resolve(struct bt_mesh_msg_ctx *ctx, */ *sub = bt_mesh_subnet_get(ctx->net_idx); if (!*sub) { - BT_WARN("Unknown NetKey 0x%03x", ctx->net_idx); + LOG_WRN("Unknown NetKey 0x%03x", ctx->net_idx); return -EINVAL; } @@ -465,13 +464,13 @@ int bt_mesh_keys_resolve(struct bt_mesh_msg_ctx *ctx, struct bt_mesh_cdb_node *node; if (!IS_ENABLED(CONFIG_BT_MESH_CDB)) { - BT_WARN("No DevKey for 0x%04x", ctx->addr); + LOG_WRN("No DevKey for 0x%04x", ctx->addr); return -EINVAL; } node = bt_mesh_cdb_node_get(ctx->addr); if (!node) { - BT_WARN("No DevKey for 0x%04x", ctx->addr); + LOG_WRN("No DevKey for 0x%04x", ctx->addr); return -EINVAL; } @@ -486,13 +485,13 @@ int bt_mesh_keys_resolve(struct bt_mesh_msg_ctx *ctx, app = app_get(ctx->app_idx); if (!app) { - BT_WARN("Unknown AppKey 0x%03x", ctx->app_idx); + LOG_WRN("Unknown AppKey 0x%03x", ctx->app_idx); return -EINVAL; } *sub = bt_mesh_subnet_get(app->net_idx); if (!*sub) { - BT_WARN("Unknown NetKey 0x%03x", app->net_idx); + LOG_WRN("Unknown NetKey 0x%03x", app->net_idx); return -EINVAL; } @@ -626,7 +625,7 @@ static int app_key_set(const char *name, size_t len_rd, int err; if (!name) { - BT_ERR("Insufficient number of arguments"); + LOG_ERR("Insufficient number of arguments"); return -ENOENT; } @@ -644,11 +643,11 @@ static int app_key_set(const char *name, size_t len_rd, err = bt_mesh_app_key_set(app_idx, key.net_idx, key.val[0], key.updated ? key.val[1] : NULL); if (err) { - BT_ERR("Failed to set \'app-key\'"); + LOG_ERR("Failed to set \'app-key\'"); return err; } - BT_DBG("AppKeyIndex 0x%03x recovered from storage", app_idx); + LOG_DBG("AppKeyIndex 0x%03x recovered from storage", app_idx); return 0; } diff --git a/subsys/bluetooth/mesh/beacon.c b/subsys/bluetooth/mesh/beacon.c index 8aafe999fed..2ff9a67b9f8 100644 --- a/subsys/bluetooth/mesh/beacon.c +++ b/subsys/bluetooth/mesh/beacon.c @@ -13,9 +13,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_BEACON) -#define LOG_MODULE_NAME bt_mesh_beacon -#include "common/log.h" #include "common/bt_str.h" #include "adv.h" @@ -27,6 +24,10 @@ #include "beacon.h" #include "foundation.h" +#define LOG_LEVEL CONFIG_BT_MESH_BEACON_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_mesh_beacon); + #define PROVISIONED_INTERVAL K_SECONDS(10) #define BEACON_TYPE_UNPROVISIONED 0x00 @@ -59,7 +60,7 @@ static void beacon_complete(int err, void *user_data) { struct bt_mesh_subnet *sub = user_data; - BT_DBG("err %d", err); + LOG_DBG("err %d", err); sub->beacon_sent = k_uptime_get_32(); } @@ -84,10 +85,9 @@ void bt_mesh_beacon_create(struct bt_mesh_subnet *sub, net_buf_simple_add_mem(buf, sub->auth, 8); - BT_DBG("net_idx 0x%04x flags 0x%02x NetID %s", sub->net_idx, - flags, bt_hex(keys->net_id, 8)); - BT_DBG("IV Index 0x%08x Auth %s", bt_mesh.iv_index, - bt_hex(sub->auth, 8)); + LOG_DBG("net_idx 0x%04x flags 0x%02x NetID %s", sub->net_idx, flags, + bt_hex(keys->net_id, 8)); + LOG_DBG("IV Index 0x%08x Auth %s", bt_mesh.iv_index, bt_hex(sub->auth, 8)); } /* If the interval has passed or is within 5 seconds from now send a beacon */ @@ -104,7 +104,7 @@ static bool secure_beacon_send(struct bt_mesh_subnet *sub, void *cb_data) uint32_t time_diff; uint32_t time_since_last_recv; - BT_DBG(""); + LOG_DBG(""); time_diff = now - sub->beacon_sent; time_since_last_recv = now - sub->beacon_recv; @@ -117,7 +117,7 @@ static bool secure_beacon_send(struct bt_mesh_subnet *sub, void *cb_data) buf = bt_mesh_adv_create(BT_MESH_ADV_BEACON, BT_MESH_LOCAL_ADV, PROV_XMIT, K_NO_WAIT); if (!buf) { - BT_ERR("Unable to allocate beacon buffer"); + LOG_ERR("Unable to allocate beacon buffer"); return true; /* Bail out */ } @@ -136,12 +136,12 @@ static int unprovisioned_beacon_send(void) struct net_buf *buf; uint16_t oob_info; - BT_DBG(""); + LOG_DBG(""); buf = bt_mesh_adv_create(BT_MESH_ADV_BEACON, BT_MESH_LOCAL_ADV, UNPROV_XMIT, K_NO_WAIT); if (!buf) { - BT_ERR("Unable to allocate beacon buffer"); + LOG_ERR("Unable to allocate beacon buffer"); return -ENOBUFS; } @@ -168,13 +168,13 @@ static int unprovisioned_beacon_send(void) buf = bt_mesh_adv_create(BT_MESH_ADV_URI, BT_MESH_LOCAL_ADV, UNPROV_XMIT, K_NO_WAIT); if (!buf) { - BT_ERR("Unable to allocate URI buffer"); + LOG_ERR("Unable to allocate URI buffer"); return -ENOBUFS; } len = strlen(prov->uri); if (net_buf_tailroom(buf) < len) { - BT_WARN("Too long URI to fit advertising data"); + LOG_WRN("Too long URI to fit advertising data"); } else { net_buf_add_mem(buf, prov->uri, len); bt_mesh_adv_send(buf, NULL, NULL); @@ -201,7 +201,7 @@ static void unprovisioned_beacon_recv(struct net_buf_simple *buf) } if (buf->len != 18 && buf->len != 22) { - BT_ERR("Invalid unprovisioned beacon length (%u)", buf->len); + LOG_ERR("Invalid unprovisioned beacon length (%u)", buf->len); return; } @@ -213,7 +213,7 @@ static void unprovisioned_beacon_recv(struct net_buf_simple *buf) uri_hash = &uri_hash_val; } - BT_DBG("uuid %s", bt_hex(uuid, 16)); + LOG_DBG("uuid %s", bt_hex(uuid, 16)); prov->unprovisioned_beacon(uuid, (bt_mesh_prov_oob_info_t)oob_info, @@ -244,7 +244,7 @@ static void update_beacon_observation(void) static void beacon_send(struct k_work *work) { - BT_DBG(""); + LOG_DBG(""); if (bt_mesh_is_provisioned()) { if (!bt_mesh_beacon_enabled() && @@ -292,8 +292,8 @@ static bool auth_match(struct bt_mesh_subnet_keys *keys, params->iv_index, net_auth); if (memcmp(params->auth, net_auth, 8)) { - BT_WARN("Authentication Value %s != %s", - bt_hex(params->auth, 8), bt_hex(net_auth, 8)); + LOG_WRN("Authentication Value %s != %s", bt_hex(params->auth, 8), + bt_hex(net_auth, 8)); return false; } @@ -321,7 +321,7 @@ static void secure_beacon_recv(struct net_buf_simple *buf) uint8_t *data; if (buf->len < 21) { - BT_ERR("Too short secure beacon (len %u)", buf->len); + LOG_ERR("Too short secure beacon (len %u)", buf->len); return; } @@ -339,17 +339,17 @@ static void secure_beacon_recv(struct net_buf_simple *buf) params.iv_index = net_buf_simple_pull_be32(buf); params.auth = buf->data; - BT_DBG("flags 0x%02x id %s iv_index 0x%08x", - params.flags, bt_hex(params.net_id, 8), params.iv_index); + LOG_DBG("flags 0x%02x id %s iv_index 0x%08x", params.flags, bt_hex(params.net_id, 8), + params.iv_index); sub = bt_mesh_subnet_find(subnet_by_id, ¶ms); if (!sub) { - BT_DBG("No subnet that matched beacon"); + LOG_DBG("No subnet that matched beacon"); return; } if (sub->kr_phase == BT_MESH_KR_PHASE_2 && !params.new_key) { - BT_WARN("Ignoring Phase 2 KR Update secured using old key"); + LOG_WRN("Ignoring Phase 2 KR Update secured using old key"); return; } @@ -361,12 +361,12 @@ static void secure_beacon_recv(struct net_buf_simple *buf) /* If we have NetKey0 accept initiation only from it */ if (bt_mesh_subnet_get(BT_MESH_KEY_PRIMARY) && sub->net_idx != BT_MESH_KEY_PRIMARY) { - BT_WARN("Ignoring secure beacon on non-primary subnet"); + LOG_WRN("Ignoring secure beacon on non-primary subnet"); goto update_stats; } - BT_DBG("net_idx 0x%04x iv_index 0x%08x, current iv_index 0x%08x", - sub->net_idx, params.iv_index, bt_mesh.iv_index); + LOG_DBG("net_idx 0x%04x iv_index 0x%08x, current iv_index 0x%08x", sub->net_idx, + params.iv_index, bt_mesh.iv_index); if (atomic_test_bit(bt_mesh.flags, BT_MESH_IVU_INITIATOR) && (atomic_test_bit(bt_mesh.flags, BT_MESH_IVU_IN_PROGRESS) == @@ -388,10 +388,10 @@ void bt_mesh_beacon_recv(struct net_buf_simple *buf) { uint8_t type; - BT_DBG("%u bytes: %s", buf->len, bt_hex(buf->data, buf->len)); + LOG_DBG("%u bytes: %s", buf->len, bt_hex(buf->data, buf->len)); if (buf->len < 1) { - BT_ERR("Too short beacon"); + LOG_ERR("Too short beacon"); return; } @@ -406,7 +406,7 @@ void bt_mesh_beacon_recv(struct net_buf_simple *buf) secure_beacon_recv(buf); break; default: - BT_WARN("Unknown beacon type 0x%02x", type); + LOG_WRN("Unknown beacon type 0x%02x", type); break; } } @@ -419,14 +419,14 @@ void bt_mesh_beacon_update(struct bt_mesh_subnet *sub) keys = &sub->keys[SUBNET_KEY_TX_IDX(sub)]; - BT_DBG("NetIndex 0x%03x Using %s key", sub->net_idx, - SUBNET_KEY_TX_IDX(sub) ? "new" : "current"); - BT_DBG("flags 0x%02x, IVI 0x%08x", flags, bt_mesh.iv_index); + LOG_DBG("NetIndex 0x%03x Using %s key", sub->net_idx, + SUBNET_KEY_TX_IDX(sub) ? "new" : "current"); + LOG_DBG("flags 0x%02x, IVI 0x%08x", flags, bt_mesh.iv_index); err = bt_mesh_beacon_auth(keys->beacon, flags, keys->net_id, bt_mesh.iv_index, sub->auth); if (err) { - BT_ERR("Failed updating net beacon for 0x%03x", sub->net_idx); + LOG_ERR("Failed updating net beacon for 0x%03x", sub->net_idx); } } diff --git a/subsys/bluetooth/mesh/cdb.c b/subsys/bluetooth/mesh/cdb.c index 353328b9ea1..89c5fe3d53b 100644 --- a/subsys/bluetooth/mesh/cdb.c +++ b/subsys/bluetooth/mesh/cdb.c @@ -12,9 +12,6 @@ #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_CDB) -#define LOG_MODULE_NAME bt_mesh_cdb -#include "common/log.h" #include "common/bt_str.h" #include "cdb.h" @@ -23,6 +20,10 @@ #include "rpl.h" #include "settings.h" +#define LOG_LEVEL CONFIG_BT_MESH_CDB_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_mesh_cdb); + /* Tracking of what storage changes are pending for App and Net Keys. We * track this in a separate array here instead of within the respective * bt_mesh_app_key and bt_mesh_subnet structs themselves, since once a key @@ -177,7 +178,7 @@ static int cdb_net_set(const char *name, size_t len_rd, int err; if (len_rd == 0) { - BT_DBG("val (null)"); + LOG_DBG("val (null)"); return 0; } @@ -186,7 +187,7 @@ static int cdb_net_set(const char *name, size_t len_rd, /* Try to recover previous version of the network settings without address. */ err = bt_mesh_settings_set(read_cb, cb_arg, &net, sizeof(net.iv)); if (err) { - BT_ERR("Failed to set \'cdb_net\'"); + LOG_ERR("Failed to set \'cdb_net\'"); return err; } @@ -215,15 +216,15 @@ static int cdb_node_set(const char *name, size_t len_rd, int err; if (!name) { - BT_ERR("Insufficient number of arguments"); + LOG_ERR("Insufficient number of arguments"); return -ENOENT; } addr = strtol(name, NULL, 16); if (len_rd == 0) { - BT_DBG("val (null)"); - BT_DBG("Deleting node 0x%04x", addr); + LOG_DBG("val (null)"); + LOG_DBG("Deleting node 0x%04x", addr); node = bt_mesh_cdb_node_get(addr); if (node) { @@ -235,7 +236,7 @@ static int cdb_node_set(const char *name, size_t len_rd, err = bt_mesh_settings_set(read_cb, cb_arg, &val, sizeof(val)); if (err) { - BT_ERR("Failed to set \'node\'"); + LOG_ERR("Failed to set \'node\'"); return err; } @@ -246,7 +247,7 @@ static int cdb_node_set(const char *name, size_t len_rd, } if (!node) { - BT_ERR("No space for a new node"); + LOG_ERR("No space for a new node"); return -ENOMEM; } @@ -257,7 +258,7 @@ static int cdb_node_set(const char *name, size_t len_rd, memcpy(node->uuid, val.uuid, 16); memcpy(node->dev_key, val.dev_key, 16); - BT_DBG("Node 0x%04x recovered from storage", addr); + LOG_DBG("Node 0x%04x recovered from storage", addr); return 0; } @@ -271,7 +272,7 @@ static int cdb_subnet_set(const char *name, size_t len_rd, int err; if (!name) { - BT_ERR("Insufficient number of arguments"); + LOG_ERR("Insufficient number of arguments"); return -ENOENT; } @@ -279,25 +280,25 @@ static int cdb_subnet_set(const char *name, size_t len_rd, sub = bt_mesh_cdb_subnet_get(net_idx); if (len_rd == 0) { - BT_DBG("val (null)"); + LOG_DBG("val (null)"); if (!sub) { - BT_ERR("No subnet with NetKeyIndex 0x%03x", net_idx); + LOG_ERR("No subnet with NetKeyIndex 0x%03x", net_idx); return -ENOENT; } - BT_DBG("Deleting NetKeyIndex 0x%03x", net_idx); + LOG_DBG("Deleting NetKeyIndex 0x%03x", net_idx); bt_mesh_cdb_subnet_del(sub, false); return 0; } err = bt_mesh_settings_set(read_cb, cb_arg, &key, sizeof(key)); if (err) { - BT_ERR("Failed to set \'net-key\'"); + LOG_ERR("Failed to set \'net-key\'"); return err; } if (sub) { - BT_DBG("Updating existing NetKeyIndex 0x%03x", net_idx); + LOG_DBG("Updating existing NetKeyIndex 0x%03x", net_idx); sub->kr_phase = key.kr_phase; memcpy(sub->keys[0].net_key, &key.val[0], 16); @@ -308,7 +309,7 @@ static int cdb_subnet_set(const char *name, size_t len_rd, sub = bt_mesh_cdb_subnet_alloc(net_idx); if (!sub) { - BT_ERR("No space to allocate a new subnet"); + LOG_ERR("No space to allocate a new subnet"); return -ENOMEM; } @@ -316,7 +317,7 @@ static int cdb_subnet_set(const char *name, size_t len_rd, memcpy(sub->keys[0].net_key, &key.val[0], 16); memcpy(sub->keys[1].net_key, &key.val[1], 16); - BT_DBG("NetKeyIndex 0x%03x recovered from storage", net_idx); + LOG_DBG("NetKeyIndex 0x%03x recovered from storage", net_idx); return 0; } @@ -330,15 +331,15 @@ static int cdb_app_key_set(const char *name, size_t len_rd, int err; if (!name) { - BT_ERR("Insufficient number of arguments"); + LOG_ERR("Insufficient number of arguments"); return -ENOENT; } app_idx = strtol(name, NULL, 16); if (len_rd == 0) { - BT_DBG("val (null)"); - BT_DBG("Deleting AppKeyIndex 0x%03x", app_idx); + LOG_DBG("val (null)"); + LOG_DBG("Deleting AppKeyIndex 0x%03x", app_idx); app = bt_mesh_cdb_app_key_get(app_idx); if (app) { @@ -350,7 +351,7 @@ static int cdb_app_key_set(const char *name, size_t len_rd, err = bt_mesh_settings_set(read_cb, cb_arg, &key, sizeof(key)); if (err) { - BT_ERR("Failed to set \'app-key\'"); + LOG_ERR("Failed to set \'app-key\'"); return err; } @@ -360,14 +361,14 @@ static int cdb_app_key_set(const char *name, size_t len_rd, } if (!app) { - BT_ERR("No space for a new app key"); + LOG_ERR("No space for a new app key"); return -ENOMEM; } memcpy(app->keys[0].app_key, key.val[0], 16); memcpy(app->keys[1].app_key, key.val[1], 16); - BT_DBG("AppKeyIndex 0x%03x recovered from storage", app_idx); + LOG_DBG("AppKeyIndex 0x%03x recovered from storage", app_idx); return 0; } @@ -379,7 +380,7 @@ static int cdb_set(const char *name, size_t len_rd, const char *next; if (!name) { - BT_ERR("Insufficient number of arguments"); + LOG_ERR("Insufficient number of arguments"); return -ENOENT; } @@ -391,7 +392,7 @@ static int cdb_set(const char *name, size_t len_rd, len = settings_name_next(name, &next); if (!next) { - BT_ERR("Insufficient number of arguments"); + LOG_ERR("Insufficient number of arguments"); return -ENOENT; } @@ -407,7 +408,7 @@ static int cdb_set(const char *name, size_t len_rd, return cdb_app_key_set(next, len_rd, read_cb, cb_arg); } - BT_WARN("Unknown module key %s", name); + LOG_WRN("Unknown module key %s", name); return -ENOENT; } @@ -434,9 +435,9 @@ static void store_cdb_node(const struct bt_mesh_cdb_node *node) err = settings_save_one(path, &val, sizeof(val)); if (err) { - BT_ERR("Failed to store Node %s value", path); + LOG_ERR("Failed to store Node %s value", path); } else { - BT_DBG("Stored Node %s value", path); + LOG_DBG("Stored Node %s value", path); } } @@ -445,14 +446,14 @@ static void clear_cdb_node(uint16_t addr) char path[30]; int err; - BT_DBG("Node 0x%04x", addr); + LOG_DBG("Node 0x%04x", addr); snprintk(path, sizeof(path), "bt/mesh/cdb/Node/%x", addr); err = settings_delete(path); if (err) { - BT_ERR("Failed to clear Node 0x%04x", addr); + LOG_ERR("Failed to clear Node 0x%04x", addr); } else { - BT_DBG("Cleared Node 0x%04x", addr); + LOG_DBG("Cleared Node 0x%04x", addr); } } @@ -462,8 +463,7 @@ static void store_cdb_subnet(const struct bt_mesh_cdb_subnet *sub) char path[30]; int err; - BT_DBG("NetKeyIndex 0x%03x NetKey %s", sub->net_idx, - bt_hex(sub->keys[0].net_key, 16)); + LOG_DBG("NetKeyIndex 0x%03x NetKey %s", sub->net_idx, bt_hex(sub->keys[0].net_key, 16)); memcpy(&key.val[0], sub->keys[0].net_key, 16); memcpy(&key.val[1], sub->keys[1].net_key, 16); @@ -474,9 +474,9 @@ static void store_cdb_subnet(const struct bt_mesh_cdb_subnet *sub) err = settings_save_one(path, &key, sizeof(key)); if (err) { - BT_ERR("Failed to store Subnet value"); + LOG_ERR("Failed to store Subnet value"); } else { - BT_DBG("Stored Subnet value"); + LOG_DBG("Stored Subnet value"); } } @@ -485,14 +485,14 @@ static void clear_cdb_subnet(uint16_t net_idx) char path[30]; int err; - BT_DBG("NetKeyIndex 0x%03x", net_idx); + LOG_DBG("NetKeyIndex 0x%03x", net_idx); snprintk(path, sizeof(path), "bt/mesh/cdb/Subnet/%x", net_idx); err = settings_delete(path); if (err) { - BT_ERR("Failed to clear NetKeyIndex 0x%03x", net_idx); + LOG_ERR("Failed to clear NetKeyIndex 0x%03x", net_idx); } else { - BT_DBG("Cleared NetKeyIndex 0x%03x", net_idx); + LOG_DBG("Cleared NetKeyIndex 0x%03x", net_idx); } } @@ -511,9 +511,9 @@ static void store_cdb_app_key(const struct bt_mesh_cdb_app_key *app) err = settings_save_one(path, &key, sizeof(key)); if (err) { - BT_ERR("Failed to store AppKey %s value", path); + LOG_ERR("Failed to store AppKey %s value", path); } else { - BT_DBG("Stored AppKey %s value", path); + LOG_DBG("Stored AppKey %s value", path); } } @@ -525,9 +525,9 @@ static void clear_cdb_app_key(uint16_t app_idx) snprintk(path, sizeof(path), "bt/mesh/cdb/AppKey/%x", app_idx); err = settings_delete(path); if (err) { - BT_ERR("Failed to clear AppKeyIndex 0x%03x", app_idx); + LOG_ERR("Failed to clear AppKeyIndex 0x%03x", app_idx); } else { - BT_DBG("Cleared AppKeyIndex 0x%03x", app_idx); + LOG_DBG("Cleared AppKeyIndex 0x%03x", app_idx); } } @@ -572,7 +572,7 @@ static void update_cdb_node_settings(const struct bt_mesh_cdb_node *node, { struct node_update *update, *free_slot; - BT_DBG("Node 0x%04x", node->addr); + LOG_DBG("Node 0x%04x", node->addr); update = cdb_node_update_find(node->addr, &free_slot); if (update) { @@ -631,7 +631,7 @@ static void update_cdb_subnet_settings(const struct bt_mesh_cdb_subnet *sub, struct key_update *update, *free_slot; uint8_t clear = store ? 0U : 1U; - BT_DBG("NetKeyIndex 0x%03x", sub->net_idx); + LOG_DBG("NetKeyIndex 0x%03x", sub->net_idx); update = cdb_key_update_find(false, sub->net_idx, &free_slot); if (update) { @@ -663,7 +663,7 @@ static void update_cdb_app_key_settings(const struct bt_mesh_cdb_app_key *key, struct key_update *update, *free_slot; uint8_t clear = store ? 0U : 1U; - BT_DBG("AppKeyIndex 0x%03x", key->app_idx); + LOG_DBG("AppKeyIndex 0x%03x", key->app_idx); update = cdb_key_update_find(true, key->app_idx, &free_slot); if (update) { @@ -748,7 +748,7 @@ void bt_mesh_cdb_clear(void) void bt_mesh_cdb_iv_update(uint32_t iv_index, bool iv_update) { - BT_DBG("Updating IV index to %d\n", iv_index); + LOG_DBG("Updating IV index to %d\n", iv_index); /* Reset the last deleted addr when IV Index is updated or recovered. */ if (!iv_update || iv_index > bt_mesh_cdb.iv_index + 1) { @@ -791,7 +791,7 @@ struct bt_mesh_cdb_subnet *bt_mesh_cdb_subnet_alloc(uint16_t net_idx) void bt_mesh_cdb_subnet_del(struct bt_mesh_cdb_subnet *sub, bool store) { - BT_DBG("NetIdx 0x%03x store %u", sub->net_idx, store); + LOG_DBG("NetIdx 0x%03x store %u", sub->net_idx, store); if (IS_ENABLED(CONFIG_BT_SETTINGS) && store) { update_cdb_subnet_settings(sub, false); @@ -849,8 +849,7 @@ struct bt_mesh_cdb_node *bt_mesh_cdb_node_alloc(const uint8_t uuid[16], uint16_t } else if (addr < bt_mesh_cdb.lowest_avail_addr) { return NULL; } else if (addr_is_free(addr, num_elem, NULL) < 0) { - BT_DBG("Address range 0x%04x-0x%04x is not free", addr, - addr + num_elem - 1); + LOG_DBG("Address range 0x%04x-0x%04x is not free", addr, addr + num_elem - 1); return NULL; } @@ -872,7 +871,7 @@ struct bt_mesh_cdb_node *bt_mesh_cdb_node_alloc(const uint8_t uuid[16], uint16_t void bt_mesh_cdb_node_del(struct bt_mesh_cdb_node *node, bool store) { - BT_DBG("Node addr 0x%04x store %u", node->addr, store); + LOG_DBG("Node addr 0x%04x store %u", node->addr, store); if (IS_ENABLED(CONFIG_BT_SETTINGS) && store) { update_cdb_node_settings(node, false); @@ -953,7 +952,7 @@ struct bt_mesh_cdb_app_key *bt_mesh_cdb_app_key_alloc(uint16_t net_idx, void bt_mesh_cdb_app_key_del(struct bt_mesh_cdb_app_key *key, bool store) { - BT_DBG("AppIdx 0x%03x store %u", key->app_idx, store); + LOG_DBG("AppIdx 0x%03x store %u", key->app_idx, store); if (IS_ENABLED(CONFIG_BT_SETTINGS) && store) { update_cdb_app_key_settings(key, false); @@ -992,9 +991,9 @@ static void clear_cdb_net(void) err = settings_delete("bt/mesh/cdb/Net"); if (err) { - BT_ERR("Failed to clear Network"); + LOG_ERR("Failed to clear Network"); } else { - BT_DBG("Cleared Network"); + LOG_DBG("Cleared Network"); } } @@ -1003,7 +1002,7 @@ static void store_cdb_pending_net(void) struct net_val net; int err; - BT_DBG(""); + LOG_DBG(""); net.iv.index = bt_mesh_cdb.iv_index; net.iv.update = atomic_test_bit(bt_mesh_cdb.flags, @@ -1012,9 +1011,9 @@ static void store_cdb_pending_net(void) err = settings_save_one("bt/mesh/cdb/Net", &net, sizeof(net)); if (err) { - BT_ERR("Failed to store Network value"); + LOG_ERR("Failed to store Network value"); } else { - BT_DBG("Stored Network value"); + LOG_DBG("Stored Network value"); } } @@ -1029,7 +1028,7 @@ static void store_cdb_pending_nodes(void) continue; } - BT_DBG("addr: 0x%04x, clear: %d", update->addr, update->clear); + LOG_DBG("addr: 0x%04x, clear: %d", update->addr, update->clear); if (update->clear) { clear_cdb_node(update->addr); @@ -1040,7 +1039,7 @@ static void store_cdb_pending_nodes(void) if (node) { store_cdb_node(node); } else { - BT_WARN("Node 0x%04x not found", update->addr); + LOG_WRN("Node 0x%04x not found", update->addr); } } @@ -1073,8 +1072,7 @@ static void store_cdb_pending_keys(void) if (key) { store_cdb_app_key(key); } else { - BT_WARN("AppKeyIndex 0x%03x not found", - update->key_idx); + LOG_WRN("AppKeyIndex 0x%03x not found", update->key_idx); } } else { struct bt_mesh_cdb_subnet *sub; @@ -1083,8 +1081,7 @@ static void store_cdb_pending_keys(void) if (sub) { store_cdb_subnet(sub); } else { - BT_WARN("NetKeyIndex 0x%03x not found", - update->key_idx); + LOG_WRN("NetKeyIndex 0x%03x not found", update->key_idx); } } } diff --git a/subsys/bluetooth/mesh/cfg.c b/subsys/bluetooth/mesh/cfg.c index 42cac41e5fc..28997513ffd 100644 --- a/subsys/bluetooth/mesh/cfg.c +++ b/subsys/bluetooth/mesh/cfg.c @@ -17,9 +17,9 @@ #include "cfg.h" #include "adv.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_CFG) -#define LOG_MODULE_NAME bt_mesh_cfg -#include "common/log.h" +#define LOG_LEVEL CONFIG_BT_MESH_CFG_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_mesh_cfg); /* Miscellaneous configuration server model states */ struct cfg_val { @@ -301,13 +301,13 @@ static int cfg_set(const char *name, size_t len_rd, int err; if (len_rd == 0) { - BT_DBG("Cleared configuration state"); + LOG_DBG("Cleared configuration state"); return 0; } err = bt_mesh_settings_set(read_cb, cb_arg, &cfg, sizeof(cfg)); if (err) { - BT_ERR("Failed to set \'cfg\'"); + LOG_ERR("Failed to set \'cfg\'"); return err; } @@ -318,7 +318,7 @@ static int cfg_set(const char *name, size_t len_rd, bt_mesh_friend_set(cfg.frnd); bt_mesh_default_ttl_set(cfg.default_ttl); - BT_DBG("Restored configuration state"); + LOG_DBG("Restored configuration state"); return 0; } @@ -331,9 +331,9 @@ static void clear_cfg(void) err = settings_delete("bt/mesh/Cfg"); if (err) { - BT_ERR("Failed to clear configuration"); + LOG_ERR("Failed to clear configuration"); } else { - BT_DBG("Cleared configuration"); + LOG_DBG("Cleared configuration"); } } @@ -352,9 +352,9 @@ static void store_pending_cfg(void) err = settings_save_one("bt/mesh/Cfg", &val, sizeof(val)); if (err) { - BT_ERR("Failed to store configuration value"); + LOG_ERR("Failed to store configuration value"); } else { - BT_DBG("Stored configuration value"); + LOG_DBG("Stored configuration value"); LOG_HEXDUMP_DBG(&val, sizeof(val), "raw value"); } } diff --git a/subsys/bluetooth/mesh/cfg_cli.c b/subsys/bluetooth/mesh/cfg_cli.c index 5fcc6d1a399..c2bfdada0ac 100644 --- a/subsys/bluetooth/mesh/cfg_cli.c +++ b/subsys/bluetooth/mesh/cfg_cli.c @@ -17,15 +17,16 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_MODEL) -#define LOG_MODULE_NAME bt_mesh_cfg_cli -#include "common/log.h" #include "common/bt_str.h" #include "net.h" #include "foundation.h" #include "msg.h" +#define LOG_LEVEL CONFIG_BT_MESH_MODEL_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_mesh_cfg_cli); + #define CID_NVAL 0xffff /* 2 byte dummy opcode for getting compile time buffer sizes. */ @@ -48,9 +49,8 @@ static int comp_data_status(struct bt_mesh_model *model, uint8_t page; size_t to_copy; - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); page = net_buf_simple_pull_u8(buf); @@ -78,9 +78,8 @@ static uint8_t state_status_u8(struct bt_mesh_model *model, uint8_t *param; uint8_t status; - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); status = net_buf_simple_pull_u8(buf); @@ -171,9 +170,8 @@ static int krp_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, uint16_t net_idx; uint8_t status, phase; - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); status = net_buf_simple_pull_u8(buf); net_idx = net_buf_simple_pull_le16(buf) & 0xfff; @@ -211,9 +209,8 @@ static int relay_status(struct bt_mesh_model *model, uint8_t status; uint8_t transmit; - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); status = net_buf_simple_pull_u8(buf); transmit = net_buf_simple_pull_u8(buf); @@ -267,9 +264,8 @@ static int net_key_status(struct bt_mesh_model *model, uint8_t status; int err; - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); status = net_buf_simple_pull_u8(buf); net_idx = net_buf_simple_pull_le16(buf) & 0xfff; @@ -278,7 +274,7 @@ static int net_key_status(struct bt_mesh_model *model, (void **)¶m)) { if (param->net_idx != net_idx) { - BT_WARN("Net Key Status key index does not match"); + LOG_WRN("Net Key Status key index does not match"); err = -ENOENT; goto done; } @@ -312,9 +308,8 @@ static int net_key_list(struct bt_mesh_model *model, struct net_key_list_param *param; int i; - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); if (bt_mesh_msg_ack_ctx_match(&cli->ack_ctx, OP_NET_KEY_LIST, ctx->addr, (void **)¶m)) { @@ -332,7 +327,8 @@ static int net_key_list(struct bt_mesh_model *model, } if (buf->len > 0) { - BT_ERR("The message size for the application opcode is incorrect."); + LOG_ERR("The message size for the application opcode is " + "incorrect."); return -EMSGSIZE; } @@ -351,8 +347,7 @@ static int node_reset_status(struct bt_mesh_model *model, { bool *param = NULL; - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x", - ctx->net_idx, ctx->app_idx, ctx->addr); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x", ctx->net_idx, ctx->app_idx, ctx->addr); if (bt_mesh_msg_ack_ctx_match(&cli->ack_ctx, OP_NODE_RESET_STATUS, ctx->addr, (void **)¶m)) { @@ -386,9 +381,8 @@ static int app_key_status(struct bt_mesh_model *model, uint8_t status; int err; - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); status = net_buf_simple_pull_u8(buf); key_idx_unpack(buf, &net_idx, &app_idx); @@ -397,7 +391,7 @@ static int app_key_status(struct bt_mesh_model *model, (void **)¶m)) { if (param->net_idx != net_idx || param->app_idx != app_idx) { - BT_WARN("App Key Status key indices did not match"); + LOG_WRN("App Key Status key indices did not match"); err = -ENOENT; goto done; } @@ -436,9 +430,8 @@ static int app_key_list(struct bt_mesh_model *model, uint8_t status; int i; - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); status = net_buf_simple_pull_u8(buf); net_idx = net_buf_simple_pull_le16(buf) & 0xfff; @@ -447,7 +440,7 @@ static int app_key_list(struct bt_mesh_model *model, (void **)¶m)) { if (param->net_idx != net_idx) { - BT_WARN("App Key List Net Key index did not match"); + LOG_WRN("App Key List Net Key index did not match"); return -ENOENT; } @@ -463,7 +456,8 @@ static int app_key_list(struct bt_mesh_model *model, } if (buf->len > 0U) { - BT_ERR("The message size for the application opcode is incorrect."); + LOG_ERR("The message size for the application opcode is " + "incorrect."); return -EMSGSIZE; } @@ -496,12 +490,11 @@ static int mod_app_status(struct bt_mesh_model *model, uint8_t status; int err; - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); if ((buf->len != 7U) && (buf->len != 9U)) { - BT_ERR("The message size for the application opcode is incorrect."); + LOG_ERR("The message size for the application opcode is incorrect."); return -EMSGSIZE; } @@ -523,7 +516,7 @@ static int mod_app_status(struct bt_mesh_model *model, if (param->elem_addr != elem_addr || param->mod_app_idx != mod_app_idx || param->mod_id != mod_id || param->cid != cid) { - BT_WARN("Model App Status parameters did not match"); + LOG_WRN("Model App Status parameters did not match"); err = -ENOENT; goto done; } @@ -565,7 +558,7 @@ static int mod_member_list_handle(struct bt_mesh_msg_ctx *ctx, int i; if ((vnd && buf->len < 7U) || (buf->len < 5U)) { - BT_ERR("The message size for the application opcode is incorrect."); + LOG_ERR("The message size for the application opcode is incorrect."); return -EMSGSIZE; } @@ -582,12 +575,12 @@ static int mod_member_list_handle(struct bt_mesh_msg_ctx *ctx, if (param->elem_addr != elem_addr || param->mod_id != mod_id || (vnd && param->cid != cid)) { - BT_WARN("Model Member List parameters did not match"); + LOG_WRN("Model Member List parameters did not match"); return -ENOENT; } if (buf->len % 2) { - BT_WARN("Model Member List invalid length"); + LOG_WRN("Model Member List invalid length"); return -EMSGSIZE; } @@ -612,9 +605,8 @@ static int mod_member_list_handle(struct bt_mesh_msg_ctx *ctx, static int mod_app_list(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); return mod_member_list_handle(ctx, buf, OP_SIG_MOD_APP_LIST, false); } @@ -623,9 +615,8 @@ static int mod_app_list_vnd(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); return mod_member_list_handle(ctx, buf, OP_VND_MOD_APP_LIST, true); } @@ -647,12 +638,11 @@ static int mod_pub_status(struct bt_mesh_model *model, struct bt_mesh_cfg_cli_mod_pub pub; uint8_t status; - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); if ((buf->len != 12U) && (buf->len != 14U)) { - BT_ERR("The message size for the application opcode is incorrect."); + LOG_ERR("The message size for the application opcode is incorrect."); return -EINVAL; } @@ -679,12 +669,12 @@ static int mod_pub_status(struct bt_mesh_model *model, if (bt_mesh_msg_ack_ctx_match(&cli->ack_ctx, OP_MOD_PUB_STATUS, ctx->addr, (void **)¶m)) { if (mod_id != param->mod_id || cid != param->cid) { - BT_WARN("Mod Pub Model ID or Company ID mismatch"); + LOG_WRN("Mod Pub Model ID or Company ID mismatch"); return -ENOENT; } if (elem_addr != param->elem_addr) { - BT_WARN("Model Pub Status for unexpected element (0x%04x)", elem_addr); + LOG_WRN("Model Pub Status for unexpected element (0x%04x)", elem_addr); return -ENOENT; } @@ -719,12 +709,11 @@ static int mod_sub_status(struct bt_mesh_model *model, uint8_t status; int err = 0; - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); if ((buf->len != 7U) && (buf->len != 9U)) { - BT_ERR("The message size for the application opcode is incorrect."); + LOG_ERR("The message size for the application opcode is incorrect."); return -EINVAL; } @@ -745,7 +734,7 @@ static int mod_sub_status(struct bt_mesh_model *model, if (param->elem_addr != elem_addr || param->mod_id != mod_id || (param->expect_sub && *param->expect_sub != sub_addr) || param->cid != cid) { - BT_WARN("Model Subscription Status parameters did not match"); + LOG_WRN("Model Subscription Status parameters did not match"); err = -ENOENT; goto done; } @@ -773,9 +762,8 @@ done: static int mod_sub_list(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); return mod_member_list_handle(ctx, buf, OP_MOD_SUB_LIST, false); } @@ -784,9 +772,8 @@ static int mod_sub_list_vnd(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); return mod_member_list_handle(ctx, buf, OP_MOD_SUB_LIST_VND, true); } @@ -804,9 +791,8 @@ static int hb_sub_status(struct bt_mesh_model *model, struct bt_mesh_cfg_cli_hb_sub sub; uint8_t status; - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); status = net_buf_simple_pull_u8(buf); sub.src = net_buf_simple_pull_le16(buf); @@ -844,9 +830,8 @@ static int hb_pub_status(struct bt_mesh_model *model, uint8_t status; struct bt_mesh_cfg_cli_hb_pub pub; - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); status = net_buf_simple_pull_u8(buf); pub.dst = net_buf_simple_pull_le16(buf); @@ -885,9 +870,8 @@ static int node_identity_status(struct bt_mesh_model *model, uint16_t net_idx, identity; uint8_t status; - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); status = net_buf_simple_pull_u8(buf); net_idx = net_buf_simple_pull_le16(buf) & 0xfff; @@ -927,9 +911,8 @@ static int lpn_timeout_status(struct bt_mesh_model *model, struct bt_mesh_msg_ct int32_t polltimeout; int err; - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); unicast_addr = net_buf_simple_pull_le16(buf); polltimeout = net_buf_simple_pull_le24(buf); @@ -990,12 +973,12 @@ const struct bt_mesh_model_op bt_mesh_cfg_cli_op[] = { static int cfg_cli_init(struct bt_mesh_model *model) { if (!bt_mesh_model_in_primary(model)) { - BT_ERR("Configuration Client only allowed in primary element"); + LOG_ERR("Configuration Client only allowed in primary element"); return -EINVAL; } if (!model->user_data) { - BT_ERR("No Configuration Client context provided"); + LOG_ERR("No Configuration Client context provided"); return -EINVAL; } @@ -1999,8 +1982,8 @@ static int mod_member_list_get(uint32_t op, uint32_t expect_op, uint16_t net_idx .timeout = msg_timeout, }; - BT_DBG("net_idx 0x%04x addr 0x%04x elem_addr 0x%04x", net_idx, addr, elem_addr); - BT_DBG("mod_id 0x%04x cid 0x%04x op: %x", mod_id, cid, op); + LOG_DBG("net_idx 0x%04x addr 0x%04x elem_addr 0x%04x", net_idx, addr, elem_addr); + LOG_DBG("mod_id 0x%04x cid 0x%04x op: %x", mod_id, cid, op); bt_mesh_model_msg_init(&msg, op); net_buf_simple_add_le16(&msg, elem_addr); @@ -2187,9 +2170,9 @@ static int mod_sub_va(uint32_t op, uint16_t net_idx, uint16_t addr, uint16_t ele .timeout = msg_timeout, }; - BT_DBG("net_idx 0x%04x addr 0x%04x elem_addr 0x%04x label %s", net_idx, addr, elem_addr, - bt_hex(label, 16)); - BT_DBG("mod_id 0x%04x cid 0x%04x", mod_id, cid); + LOG_DBG("net_idx 0x%04x addr 0x%04x elem_addr 0x%04x label %s", net_idx, addr, elem_addr, + bt_hex(label, 16)); + LOG_DBG("mod_id 0x%04x cid 0x%04x", mod_id, cid); bt_mesh_model_msg_init(&msg, op); net_buf_simple_add_le16(&msg, elem_addr); @@ -2404,7 +2387,7 @@ static int mod_pub_va_set(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, u .timeout = msg_timeout, }; - BT_DBG("app_idx 0x%04x", pub->app_idx); + LOG_DBG("app_idx 0x%04x", pub->app_idx); bt_mesh_model_msg_init(&msg, OP_MOD_PUB_VA_SET); net_buf_simple_add_le16(&msg, elem_addr); diff --git a/subsys/bluetooth/mesh/cfg_srv.c b/subsys/bluetooth/mesh/cfg_srv.c index a0a081069f2..162649524c6 100644 --- a/subsys/bluetooth/mesh/cfg_srv.c +++ b/subsys/bluetooth/mesh/cfg_srv.c @@ -16,9 +16,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_MODEL) -#define LOG_MODULE_NAME bt_mesh_cfg_srv -#include "common/log.h" #include "common/bt_str.h" #include "host/testing.h" @@ -39,6 +36,10 @@ #include "settings.h" #include "cfg.h" +#define LOG_LEVEL CONFIG_BT_MESH_MODEL_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_mesh_cfg_srv); + static void node_reset_pending_handler(struct k_work *work) { bt_mesh_reset(); @@ -54,7 +55,7 @@ static int comp_add_elem(struct net_buf_simple *buf, struct bt_mesh_elem *elem, if (net_buf_simple_tailroom(buf) < 4 + (elem->model_count * 2U) + (elem->vnd_model_count * 4U)) { - BT_ERR("Too large device composition"); + LOG_ERR("Too large device composition"); return -E2BIG; } @@ -127,13 +128,12 @@ static int dev_comp_data_get(struct bt_mesh_model *model, uint8_t page; int err; - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); page = net_buf_simple_pull_u8(buf); if (page != 0U) { - BT_DBG("Composition page %u not available", page); + LOG_DBG("Composition page %u not available", page); page = 0U; } @@ -142,12 +142,12 @@ static int dev_comp_data_get(struct bt_mesh_model *model, net_buf_simple_add_u8(&sdu, page); err = comp_get_page_0(&sdu); if (err) { - BT_ERR("Unable to get composition page 0"); + LOG_ERR("Unable to get composition page 0"); return err; } if (bt_mesh_model_send(model, ctx, &sdu, NULL, NULL)) { - BT_ERR("Unable to send Device Composition Status response"); + LOG_ERR("Unable to send Device Composition Status response"); } return err; @@ -161,7 +161,7 @@ static struct bt_mesh_model *get_model(struct bt_mesh_elem *elem, id = net_buf_simple_pull_le16(buf); - BT_DBG("ID 0x%04x addr 0x%04x", id, elem->addr); + LOG_DBG("ID 0x%04x addr 0x%04x", id, elem->addr); *vnd = false; @@ -172,8 +172,7 @@ static struct bt_mesh_model *get_model(struct bt_mesh_elem *elem, company = net_buf_simple_pull_le16(buf); id = net_buf_simple_pull_le16(buf); - BT_DBG("Company 0x%04x ID 0x%04x addr 0x%04x", company, id, - elem->addr); + LOG_DBG("Company 0x%04x ID 0x%04x addr 0x%04x", company, id, elem->addr); *vnd = true; @@ -249,7 +248,7 @@ static uint8_t _mod_pub_set(struct bt_mesh_model *model, uint16_t pub_addr, int32_t period_ms; period_ms = bt_mesh_model_pub_period_get(model); - BT_DBG("period %u ms", period_ms); + LOG_DBG("period %u ms", period_ms); if (period_ms > 0) { k_work_reschedule(&model->pub->timer, @@ -273,7 +272,7 @@ static uint8_t mod_bind(struct bt_mesh_model *model, uint16_t key_idx) { int i; - BT_DBG("model %p key_idx 0x%03x", model, key_idx); + LOG_DBG("model %p key_idx 0x%03x", model, key_idx); if (!bt_mesh_app_key_exists(key_idx)) { return STATUS_INVALID_APPKEY; @@ -305,7 +304,7 @@ static uint8_t mod_unbind(struct bt_mesh_model *model, uint16_t key_idx, bool st { int i; - BT_DBG("model %p key_idx 0x%03x store %u", model, key_idx, store); + LOG_DBG("model %p key_idx 0x%03x store %u", model, key_idx, store); if (!bt_mesh_app_key_exists(key_idx)) { return STATUS_INVALID_APPKEY; @@ -343,7 +342,7 @@ static int send_app_key_status(struct bt_mesh_model *model, key_idx_pack(&msg, net_idx, app_idx); if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { - BT_ERR("Unable to send App Key Status response"); + LOG_ERR("Unable to send App Key Status response"); } return 0; @@ -358,7 +357,7 @@ static int app_key_add(struct bt_mesh_model *model, key_idx_unpack(buf, &key_net_idx, &key_app_idx); - BT_DBG("AppIdx 0x%04x NetIdx 0x%04x", key_app_idx, key_net_idx); + LOG_DBG("AppIdx 0x%04x NetIdx 0x%04x", key_app_idx, key_net_idx); status = bt_mesh_app_key_add(key_app_idx, key_net_idx, buf->data); @@ -374,10 +373,10 @@ static int app_key_update(struct bt_mesh_model *model, key_idx_unpack(buf, &key_net_idx, &key_app_idx); - BT_DBG("AppIdx 0x%04x NetIdx 0x%04x", key_app_idx, key_net_idx); + LOG_DBG("AppIdx 0x%04x NetIdx 0x%04x", key_app_idx, key_net_idx); status = bt_mesh_app_key_update(key_app_idx, key_net_idx, buf->data); - BT_DBG("status 0x%02x", status); + LOG_DBG("status 0x%02x", status); return send_app_key_status(model, ctx, status, key_app_idx, key_net_idx); } @@ -410,7 +409,7 @@ static int app_key_del(struct bt_mesh_model *model, key_idx_unpack(buf, &key_net_idx, &key_app_idx); - BT_DBG("AppIdx 0x%04x NetIdx 0x%04x", key_app_idx, key_net_idx); + LOG_DBG("AppIdx 0x%04x NetIdx 0x%04x", key_app_idx, key_net_idx); status = bt_mesh_app_key_del(key_app_idx, key_net_idx); @@ -434,11 +433,11 @@ static int app_key_get(struct bt_mesh_model *model, get_idx = net_buf_simple_pull_le16(buf); if (get_idx > 0xfff) { - BT_ERR("Invalid NetKeyIndex 0x%04x", get_idx); + LOG_ERR("Invalid NetKeyIndex 0x%04x", get_idx); return -EINVAL; } - BT_DBG("idx 0x%04x", get_idx); + LOG_DBG("idx 0x%04x", get_idx); bt_mesh_model_msg_init(&msg, OP_APP_KEY_LIST); @@ -470,7 +469,7 @@ static int app_key_get(struct bt_mesh_model *model, send_status: if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { - BT_ERR("Unable to send AppKey List"); + LOG_ERR("Unable to send AppKey List"); } return 0; @@ -482,15 +481,14 @@ static int beacon_get(struct bt_mesh_model *model, { BT_MESH_MODEL_BUF_DEFINE(msg, OP_BEACON_STATUS, 1); - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); bt_mesh_model_msg_init(&msg, OP_BEACON_STATUS); net_buf_simple_add_u8(&msg, bt_mesh_beacon_enabled()); if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { - BT_ERR("Unable to send Config Beacon Status response"); + LOG_ERR("Unable to send Config Beacon Status response"); } return 0; @@ -502,12 +500,11 @@ static int beacon_set(struct bt_mesh_model *model, { BT_MESH_MODEL_BUF_DEFINE(msg, OP_BEACON_STATUS, 1); - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); if (buf->data[0] != 0x00 && buf->data[0] != 0x01) { - BT_WARN("Invalid Config Beacon value 0x%02x", buf->data[0]); + LOG_WRN("Invalid Config Beacon value 0x%02x", buf->data[0]); return -EINVAL; } @@ -517,7 +514,7 @@ static int beacon_set(struct bt_mesh_model *model, net_buf_simple_add_u8(&msg, buf->data[0]); if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { - BT_ERR("Unable to send Config Beacon Status response"); + LOG_ERR("Unable to send Config Beacon Status response"); } return 0; @@ -529,15 +526,14 @@ static int default_ttl_get(struct bt_mesh_model *model, { BT_MESH_MODEL_BUF_DEFINE(msg, OP_DEFAULT_TTL_STATUS, 1); - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); bt_mesh_model_msg_init(&msg, OP_DEFAULT_TTL_STATUS); net_buf_simple_add_u8(&msg, bt_mesh_default_ttl_get()); if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { - BT_ERR("Unable to send Default TTL Status response"); + LOG_ERR("Unable to send Default TTL Status response"); } return 0; @@ -550,13 +546,12 @@ static int default_ttl_set(struct bt_mesh_model *model, BT_MESH_MODEL_BUF_DEFINE(msg, OP_DEFAULT_TTL_STATUS, 1); int err; - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); err = bt_mesh_default_ttl_set(buf->data[0]); if (err) { - BT_WARN("Prohibited Default TTL value 0x%02x", buf->data[0]); + LOG_WRN("Prohibited Default TTL value 0x%02x", buf->data[0]); return err; } @@ -564,7 +559,7 @@ static int default_ttl_set(struct bt_mesh_model *model, net_buf_simple_add_u8(&msg, buf->data[0]); if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { - BT_ERR("Unable to send Default TTL Status response"); + LOG_ERR("Unable to send Default TTL Status response"); } return 0; @@ -579,7 +574,7 @@ static int send_gatt_proxy_status(struct bt_mesh_model *model, net_buf_simple_add_u8(&msg, bt_mesh_gatt_proxy_get()); if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { - BT_ERR("Unable to send GATT Proxy Status"); + LOG_ERR("Unable to send GATT Proxy Status"); } return 0; @@ -589,9 +584,8 @@ static int gatt_proxy_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); return send_gatt_proxy_status(model, ctx); } @@ -600,12 +594,11 @@ static int gatt_proxy_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); if (buf->data[0] != 0x00 && buf->data[0] != 0x01) { - BT_WARN("Invalid GATT Proxy value 0x%02x", buf->data[0]); + LOG_WRN("Invalid GATT Proxy value 0x%02x", buf->data[0]); return -EINVAL; } @@ -620,15 +613,14 @@ static int net_transmit_get(struct bt_mesh_model *model, { BT_MESH_MODEL_BUF_DEFINE(msg, OP_NET_TRANSMIT_STATUS, 1); - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); bt_mesh_model_msg_init(&msg, OP_NET_TRANSMIT_STATUS); net_buf_simple_add_u8(&msg, bt_mesh_net_transmit_get()); if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { - BT_ERR("Unable to send Config Network Transmit Status"); + LOG_ERR("Unable to send Config Network Transmit Status"); } return 0; @@ -640,13 +632,11 @@ static int net_transmit_set(struct bt_mesh_model *model, { BT_MESH_MODEL_BUF_DEFINE(msg, OP_NET_TRANSMIT_STATUS, 1); - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); - BT_DBG("Transmit 0x%02x (count %u interval %ums)", buf->data[0], - BT_MESH_TRANSMIT_COUNT(buf->data[0]), - BT_MESH_TRANSMIT_INT(buf->data[0])); + LOG_DBG("Transmit 0x%02x (count %u interval %ums)", buf->data[0], + BT_MESH_TRANSMIT_COUNT(buf->data[0]), BT_MESH_TRANSMIT_INT(buf->data[0])); bt_mesh_net_transmit_set(buf->data[0]); @@ -654,7 +644,7 @@ static int net_transmit_set(struct bt_mesh_model *model, net_buf_simple_add_u8(&msg, buf->data[0]); if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { - BT_ERR("Unable to send Network Transmit Status"); + LOG_ERR("Unable to send Network Transmit Status"); } return 0; @@ -666,16 +656,15 @@ static int relay_get(struct bt_mesh_model *model, { BT_MESH_MODEL_BUF_DEFINE(msg, OP_RELAY_STATUS, 2); - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); bt_mesh_model_msg_init(&msg, OP_RELAY_STATUS); net_buf_simple_add_u8(&msg, bt_mesh_relay_get()); net_buf_simple_add_u8(&msg, bt_mesh_relay_retransmit_get()); if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { - BT_ERR("Unable to send Config Relay Status response"); + LOG_ERR("Unable to send Config Relay Status response"); } return 0; @@ -687,12 +676,11 @@ static int relay_set(struct bt_mesh_model *model, { BT_MESH_MODEL_BUF_DEFINE(msg, OP_RELAY_STATUS, 2); - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); if (buf->data[0] != 0x00 && buf->data[0] != 0x01) { - BT_WARN("Invalid Relay value 0x%02x", buf->data[0]); + LOG_WRN("Invalid Relay value 0x%02x", buf->data[0]); return -EINVAL; } @@ -703,7 +691,7 @@ static int relay_set(struct bt_mesh_model *model, net_buf_simple_add_u8(&msg, bt_mesh_relay_retransmit_get()); if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { - BT_ERR("Unable to send Relay Status response"); + LOG_ERR("Unable to send Relay Status response"); } return 0; @@ -743,7 +731,7 @@ static int send_mod_pub_status(struct bt_mesh_model *cfg_mod, } if (bt_mesh_model_send(cfg_mod, ctx, &msg, NULL, NULL)) { - BT_ERR("Unable to send Model Publication Status"); + LOG_ERR("Unable to send Model Publication Status"); } return 0; @@ -759,19 +747,19 @@ static int mod_pub_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, bool vnd; if ((buf->len != 4U) && (buf->len != 6U)) { - BT_ERR("The message size for the application opcode is incorrect."); + LOG_ERR("The message size for the application opcode is incorrect."); return -EMSGSIZE; } elem_addr = net_buf_simple_pull_le16(buf); if (!BT_MESH_ADDR_IS_UNICAST(elem_addr)) { - BT_WARN("Prohibited element address"); + LOG_WRN("Prohibited element address"); return -EINVAL; } mod_id = buf->data; - BT_DBG("elem_addr 0x%04x", elem_addr); + LOG_DBG("elem_addr 0x%04x", elem_addr); elem = bt_mesh_elem_find(elem_addr); if (!elem) { @@ -812,13 +800,13 @@ static int mod_pub_set(struct bt_mesh_model *model, bool vnd; if ((buf->len != 11U) && (buf->len != 13U)) { - BT_ERR("The message size for the application opcode is incorrect."); + LOG_ERR("The message size for the application opcode is incorrect."); return -EMSGSIZE; } elem_addr = net_buf_simple_pull_le16(buf); if (!BT_MESH_ADDR_IS_UNICAST(elem_addr)) { - BT_WARN("Prohibited element address"); + LOG_WRN("Prohibited element address"); return -EINVAL; } @@ -829,7 +817,7 @@ static int mod_pub_set(struct bt_mesh_model *model, pub_ttl = net_buf_simple_pull_u8(buf); if (pub_ttl > BT_MESH_TTL_MAX && pub_ttl != BT_MESH_TTL_DEFAULT) { - BT_ERR("Invalid TTL value 0x%02x", pub_ttl); + LOG_ERR("Invalid TTL value 0x%02x", pub_ttl); return -EINVAL; } @@ -837,13 +825,11 @@ static int mod_pub_set(struct bt_mesh_model *model, retransmit = net_buf_simple_pull_u8(buf); mod_id = buf->data; - BT_DBG("elem_addr 0x%04x pub_addr 0x%04x cred_flag %u", - elem_addr, pub_addr, cred_flag); - BT_DBG("pub_app_idx 0x%03x, pub_ttl %u pub_period 0x%02x", - pub_app_idx, pub_ttl, pub_period); - BT_DBG("retransmit 0x%02x (count %u interval %ums)", retransmit, - BT_MESH_PUB_TRANSMIT_COUNT(retransmit), - BT_MESH_PUB_TRANSMIT_INT(retransmit)); + LOG_DBG("elem_addr 0x%04x pub_addr 0x%04x cred_flag %u", elem_addr, pub_addr, cred_flag); + LOG_DBG("pub_app_idx 0x%03x, pub_ttl %u pub_period 0x%02x", pub_app_idx, pub_ttl, + pub_period); + LOG_DBG("retransmit 0x%02x (count %u interval %ums)", retransmit, + BT_MESH_PUB_TRANSMIT_COUNT(retransmit), BT_MESH_PUB_TRANSMIT_INT(retransmit)); elem = bt_mesh_elem_find(elem_addr); if (!elem) { @@ -892,7 +878,7 @@ static size_t mod_sub_list_clear(struct bt_mesh_model *mod) if (label_uuid) { bt_mesh_va_del(label_uuid, NULL); } else { - BT_ERR("Label UUID not found"); + LOG_ERR("Label UUID not found"); } } @@ -912,13 +898,13 @@ static int mod_pub_va_set(struct bt_mesh_model *model, bool vnd; if ((buf->len != 25U) && (buf->len != 27U)) { - BT_ERR("The message size for the application opcode is incorrect."); + LOG_ERR("The message size for the application opcode is incorrect."); return -EMSGSIZE; } elem_addr = net_buf_simple_pull_le16(buf); if (!BT_MESH_ADDR_IS_UNICAST(elem_addr)) { - BT_WARN("Prohibited element address"); + LOG_WRN("Prohibited element address"); return -EINVAL; } @@ -928,7 +914,7 @@ static int mod_pub_va_set(struct bt_mesh_model *model, pub_app_idx &= BIT_MASK(12); pub_ttl = net_buf_simple_pull_u8(buf); if (pub_ttl > BT_MESH_TTL_MAX && pub_ttl != BT_MESH_TTL_DEFAULT) { - BT_ERR("Invalid TTL value 0x%02x", pub_ttl); + LOG_ERR("Invalid TTL value 0x%02x", pub_ttl); return -EINVAL; } @@ -936,12 +922,11 @@ static int mod_pub_va_set(struct bt_mesh_model *model, retransmit = net_buf_simple_pull_u8(buf); mod_id = buf->data; - BT_DBG("elem_addr 0x%04x cred_flag %u", elem_addr, cred_flag); - BT_DBG("pub_app_idx 0x%03x, pub_ttl %u pub_period 0x%02x", - pub_app_idx, pub_ttl, pub_period); - BT_DBG("retransmit 0x%02x (count %u interval %ums)", retransmit, - BT_MESH_PUB_TRANSMIT_COUNT(retransmit), - BT_MESH_PUB_TRANSMIT_INT(retransmit)); + LOG_DBG("elem_addr 0x%04x cred_flag %u", elem_addr, cred_flag); + LOG_DBG("pub_app_idx 0x%03x, pub_ttl %u pub_period 0x%02x", pub_app_idx, pub_ttl, + pub_period); + LOG_DBG("retransmit 0x%02x (count %u interval %ums)", retransmit, + BT_MESH_PUB_TRANSMIT_COUNT(retransmit), BT_MESH_PUB_TRANSMIT_INT(retransmit)); elem = bt_mesh_elem_find(elem_addr); if (!elem) { @@ -982,8 +967,7 @@ static int send_mod_sub_status(struct bt_mesh_model *model, { BT_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_SUB_STATUS, 9); - BT_DBG("status 0x%02x elem_addr 0x%04x sub_addr 0x%04x", status, - elem_addr, sub_addr); + LOG_DBG("status 0x%02x elem_addr 0x%04x sub_addr 0x%04x", status, elem_addr, sub_addr); bt_mesh_model_msg_init(&msg, OP_MOD_SUB_STATUS); @@ -998,7 +982,7 @@ static int send_mod_sub_status(struct bt_mesh_model *model, } if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { - BT_ERR("Unable to send Model Subscription Status"); + LOG_ERR("Unable to send Model Subscription Status"); } return 0; @@ -1017,19 +1001,19 @@ static int mod_sub_add(struct bt_mesh_model *model, bool vnd; if ((buf->len != 6U) && (buf->len != 8U)) { - BT_ERR("The message size for the application opcode is incorrect."); + LOG_ERR("The message size for the application opcode is incorrect."); return -EMSGSIZE; } elem_addr = net_buf_simple_pull_le16(buf); if (!BT_MESH_ADDR_IS_UNICAST(elem_addr)) { - BT_WARN("Prohibited element address"); + LOG_WRN("Prohibited element address"); return -EINVAL; } sub_addr = net_buf_simple_pull_le16(buf); - BT_DBG("elem_addr 0x%04x, sub_addr 0x%04x", elem_addr, sub_addr); + LOG_DBG("elem_addr 0x%04x, sub_addr 0x%04x", elem_addr, sub_addr); mod_id = buf->data; @@ -1054,7 +1038,7 @@ static int mod_sub_add(struct bt_mesh_model *model, if (bt_mesh_model_find_group(&mod, sub_addr)) { /* Tried to add existing subscription */ - BT_DBG("found existing subscription"); + LOG_DBG("found existing subscription"); status = STATUS_SUCCESS; goto send_status; } @@ -1095,19 +1079,19 @@ static int mod_sub_del(struct bt_mesh_model *model, bool vnd; if ((buf->len != 6U) && (buf->len != 8U)) { - BT_ERR("The message size for the application opcode is incorrect."); + LOG_ERR("The message size for the application opcode is incorrect."); return -EMSGSIZE; } elem_addr = net_buf_simple_pull_le16(buf); if (!BT_MESH_ADDR_IS_UNICAST(elem_addr)) { - BT_WARN("Prohibited element address"); + LOG_WRN("Prohibited element address"); return -EINVAL; } sub_addr = net_buf_simple_pull_le16(buf); - BT_DBG("elem_addr 0x%04x sub_addr 0x%04x", elem_addr, sub_addr); + LOG_DBG("elem_addr 0x%04x sub_addr 0x%04x", elem_addr, sub_addr); mod_id = buf->data; @@ -1176,19 +1160,19 @@ static int mod_sub_overwrite(struct bt_mesh_model *model, bool vnd; if ((buf->len != 6U) && (buf->len != 8U)) { - BT_ERR("The message size for the application opcode is incorrect."); + LOG_ERR("The message size for the application opcode is incorrect."); return -EMSGSIZE; } elem_addr = net_buf_simple_pull_le16(buf); if (!BT_MESH_ADDR_IS_UNICAST(elem_addr)) { - BT_WARN("Prohibited element address"); + LOG_WRN("Prohibited element address"); return -EINVAL; } sub_addr = net_buf_simple_pull_le16(buf); - BT_DBG("elem_addr 0x%04x sub_addr 0x%04x", elem_addr, sub_addr); + LOG_DBG("elem_addr 0x%04x sub_addr 0x%04x", elem_addr, sub_addr); mod_id = buf->data; @@ -1247,17 +1231,17 @@ static int mod_sub_del_all(struct bt_mesh_model *model, bool vnd; if ((buf->len != 4U) && (buf->len != 6U)) { - BT_ERR("The message size for the application opcode is incorrect."); + LOG_ERR("The message size for the application opcode is incorrect."); return -EMSGSIZE; } elem_addr = net_buf_simple_pull_le16(buf); if (!BT_MESH_ADDR_IS_UNICAST(elem_addr)) { - BT_WARN("Prohibited element address"); + LOG_WRN("Prohibited element address"); return -EINVAL; } - BT_DBG("elem_addr 0x%04x", elem_addr); + LOG_DBG("elem_addr 0x%04x", elem_addr); mod_id = buf->data; @@ -1310,7 +1294,7 @@ static enum bt_mesh_walk mod_sub_list_visitor(struct bt_mesh_model *mod, void *c if (net_buf_simple_tailroom(visit->msg) < 2 + BT_MESH_MIC_SHORT) { - BT_WARN("No room for all groups"); + LOG_WRN("No room for all groups"); return BT_MESH_WALK_STOP; } @@ -1318,8 +1302,7 @@ static enum bt_mesh_walk mod_sub_list_visitor(struct bt_mesh_model *mod, void *c count++; } - BT_DBG("sublist: model %u:%x: %u groups", mod->elem_idx, mod->id, - count); + LOG_DBG("sublist: model %u:%x: %u groups", mod->elem_idx, mod->id, count); return BT_MESH_WALK_CONTINUE; } @@ -1336,13 +1319,13 @@ static int mod_sub_get(struct bt_mesh_model *model, addr = net_buf_simple_pull_le16(buf); if (!BT_MESH_ADDR_IS_UNICAST(addr)) { - BT_WARN("Prohibited element address"); + LOG_WRN("Prohibited element address"); return -EINVAL; } id = net_buf_simple_pull_le16(buf); - BT_DBG("addr 0x%04x id 0x%04x", addr, id); + LOG_DBG("addr 0x%04x id 0x%04x", addr, id); bt_mesh_model_msg_init(&msg, OP_MOD_SUB_LIST); @@ -1373,7 +1356,7 @@ static int mod_sub_get(struct bt_mesh_model *model, send_list: if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { - BT_ERR("Unable to send Model Subscription List"); + LOG_ERR("Unable to send Model Subscription List"); } return 0; @@ -1391,14 +1374,14 @@ static int mod_sub_get_vnd(struct bt_mesh_model *model, addr = net_buf_simple_pull_le16(buf); if (!BT_MESH_ADDR_IS_UNICAST(addr)) { - BT_WARN("Prohibited element address"); + LOG_WRN("Prohibited element address"); return -EINVAL; } company = net_buf_simple_pull_le16(buf); id = net_buf_simple_pull_le16(buf); - BT_DBG("addr 0x%04x company 0x%04x id 0x%04x", addr, company, id); + LOG_DBG("addr 0x%04x company 0x%04x id 0x%04x", addr, company, id); bt_mesh_model_msg_init(&msg, OP_MOD_SUB_LIST_VND); @@ -1432,7 +1415,7 @@ static int mod_sub_get_vnd(struct bt_mesh_model *model, send_list: if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { - BT_ERR("Unable to send Vendor Model Subscription List"); + LOG_ERR("Unable to send Vendor Model Subscription List"); } return 0; @@ -1452,19 +1435,19 @@ static int mod_sub_va_add(struct bt_mesh_model *model, bool vnd; if ((buf->len != 20U) && (buf->len != 22U)) { - BT_ERR("The message size for the application opcode is incorrect."); + LOG_ERR("The message size for the application opcode is incorrect."); return -EMSGSIZE; } elem_addr = net_buf_simple_pull_le16(buf); if (!BT_MESH_ADDR_IS_UNICAST(elem_addr)) { - BT_WARN("Prohibited element address"); + LOG_WRN("Prohibited element address"); return -EINVAL; } label_uuid = net_buf_simple_pull_mem(buf, 16); - BT_DBG("elem_addr 0x%04x", elem_addr); + LOG_DBG("elem_addr 0x%04x", elem_addr); mod_id = buf->data; elem = bt_mesh_elem_find(elem_addr); @@ -1534,19 +1517,19 @@ static int mod_sub_va_del(struct bt_mesh_model *model, bool vnd; if ((buf->len != 20U) && (buf->len != 22U)) { - BT_ERR("The message size for the application opcode is incorrect."); + LOG_ERR("The message size for the application opcode is incorrect."); return -EMSGSIZE; } elem_addr = net_buf_simple_pull_le16(buf); if (!BT_MESH_ADDR_IS_UNICAST(elem_addr)) { - BT_WARN("Prohibited element address"); + LOG_WRN("Prohibited element address"); return -EINVAL; } label_uuid = net_buf_simple_pull_mem(buf, 16); - BT_DBG("elem_addr 0x%04x", elem_addr); + LOG_DBG("elem_addr 0x%04x", elem_addr); mod_id = buf->data; @@ -1606,19 +1589,19 @@ static int mod_sub_va_overwrite(struct bt_mesh_model *model, bool vnd; if ((buf->len != 20U) && (buf->len != 22U)) { - BT_ERR("The message size for the application opcode is incorrect."); + LOG_ERR("The message size for the application opcode is incorrect."); return -EMSGSIZE; } elem_addr = net_buf_simple_pull_le16(buf); if (!BT_MESH_ADDR_IS_UNICAST(elem_addr)) { - BT_WARN("Prohibited element address"); + LOG_WRN("Prohibited element address"); return -EINVAL; } label_uuid = net_buf_simple_pull_mem(buf, 16); - BT_DBG("elem_addr 0x%04x", elem_addr); + LOG_DBG("elem_addr 0x%04x", elem_addr); mod_id = buf->data; @@ -1673,7 +1656,7 @@ static int send_net_key_status(struct bt_mesh_model *model, net_buf_simple_add_le16(&msg, idx); if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { - BT_ERR("Unable to send NetKey Status"); + LOG_ERR("Unable to send NetKey Status"); } return 0; @@ -1687,11 +1670,11 @@ static int net_key_add(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, idx = net_buf_simple_pull_le16(buf); if (idx > 0xfff) { - BT_ERR("Invalid NetKeyIndex 0x%04x", idx); + LOG_ERR("Invalid NetKeyIndex 0x%04x", idx); return -EINVAL; } - BT_DBG("idx 0x%04x", idx); + LOG_DBG("idx 0x%04x", idx); status = bt_mesh_subnet_add(idx, buf->data); @@ -1707,7 +1690,7 @@ static int net_key_update(struct bt_mesh_model *model, idx = net_buf_simple_pull_le16(buf); if (idx > 0xfff) { - BT_ERR("Invalid NetKeyIndex 0x%04x", idx); + LOG_ERR("Invalid NetKeyIndex 0x%04x", idx); return -EINVAL; } @@ -1724,11 +1707,11 @@ static int net_key_del(struct bt_mesh_model *model, del_idx = net_buf_simple_pull_le16(buf); if (del_idx > 0xfff) { - BT_ERR("Invalid NetKeyIndex 0x%04x", del_idx); + LOG_ERR("Invalid NetKeyIndex 0x%04x", del_idx); return -EINVAL; } - BT_DBG("idx 0x%04x", del_idx); + LOG_DBG("idx 0x%04x", del_idx); /* The key that the message was encrypted with cannot be removed. * The NetKey List must contain a minimum of one NetKey. @@ -1769,7 +1752,7 @@ static int net_key_get(struct bt_mesh_model *model, } if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { - BT_ERR("Unable to send NetKey List"); + LOG_ERR("Unable to send NetKey List"); } return 0; @@ -1788,7 +1771,7 @@ static int send_node_id_status(struct bt_mesh_model *model, net_buf_simple_add_u8(&msg, node_id); if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { - BT_ERR("Unable to send Node Identity Status"); + LOG_ERR("Unable to send Node Identity Status"); } return 0; @@ -1802,13 +1785,12 @@ static int node_identity_get(struct bt_mesh_model *model, uint8_t status; uint16_t idx; - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); idx = net_buf_simple_pull_le16(buf); if (idx > 0xfff) { - BT_ERR("Invalid NetKeyIndex 0x%04x", idx); + LOG_ERR("Invalid NetKeyIndex 0x%04x", idx); return -EINVAL; } @@ -1824,19 +1806,18 @@ static int node_identity_set(struct bt_mesh_model *model, uint8_t node_id, status; uint16_t idx; - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); idx = net_buf_simple_pull_le16(buf); if (idx > 0xfff) { - BT_WARN("Invalid NetKeyIndex 0x%04x", idx); + LOG_WRN("Invalid NetKeyIndex 0x%04x", idx); return -EINVAL; } node_id = net_buf_simple_pull_u8(buf); if (node_id != 0x00 && node_id != 0x01) { - BT_WARN("Invalid Node ID value 0x%02x", node_id); + LOG_WRN("Invalid Node ID value 0x%02x", node_id); return -EINVAL; } @@ -1885,13 +1866,13 @@ static int mod_app_bind(struct bt_mesh_model *model, bool vnd; if ((buf->len != 6U) && (buf->len != 8U)) { - BT_ERR("The message size for the application opcode is incorrect."); + LOG_ERR("The message size for the application opcode is incorrect."); return -EMSGSIZE; } elem_addr = net_buf_simple_pull_le16(buf); if (!BT_MESH_ADDR_IS_UNICAST(elem_addr)) { - BT_WARN("Prohibited element address"); + LOG_WRN("Prohibited element address"); return -EINVAL; } @@ -1914,7 +1895,7 @@ static int mod_app_bind(struct bt_mesh_model *model, /* Configuration Server only allows device key based access */ if (model == mod) { - BT_ERR("Client tried to bind AppKey to Configuration Model"); + LOG_ERR("Client tried to bind AppKey to Configuration Model"); status = STATUS_CANNOT_BIND; goto send_status; } @@ -1926,12 +1907,12 @@ static int mod_app_bind(struct bt_mesh_model *model, } send_status: - BT_DBG("status 0x%02x", status); + LOG_DBG("status 0x%02x", status); create_mod_app_status(&msg, mod, vnd, elem_addr, key_app_idx, status, mod_id); if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { - BT_ERR("Unable to send Model App Bind Status response"); + LOG_ERR("Unable to send Model App Bind Status response"); } return 0; @@ -1949,13 +1930,13 @@ static int mod_app_unbind(struct bt_mesh_model *model, bool vnd; if ((buf->len != 6U) && (buf->len != 8U)) { - BT_ERR("The message size for the application opcode is incorrect."); + LOG_ERR("The message size for the application opcode is incorrect."); return -EMSGSIZE; } elem_addr = net_buf_simple_pull_le16(buf); if (!BT_MESH_ADDR_IS_UNICAST(elem_addr)) { - BT_WARN("Prohibited element address"); + LOG_WRN("Prohibited element address"); return -EINVAL; } @@ -1983,12 +1964,12 @@ static int mod_app_unbind(struct bt_mesh_model *model, } send_status: - BT_DBG("status 0x%02x", status); + LOG_DBG("status 0x%02x", status); create_mod_app_status(&msg, mod, vnd, elem_addr, key_app_idx, status, mod_id); if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { - BT_ERR("Unable to send Model App Unbind Status response"); + LOG_ERR("Unable to send Model App Unbind Status response"); } return 0; @@ -2012,19 +1993,19 @@ static int mod_app_get(struct bt_mesh_model *model, bool vnd; if ((buf->len != 4U) && (buf->len != 6U)) { - BT_ERR("The message size for the application opcode is incorrect."); + LOG_ERR("The message size for the application opcode is incorrect."); return -EMSGSIZE; } elem_addr = net_buf_simple_pull_le16(buf); if (!BT_MESH_ADDR_IS_UNICAST(elem_addr)) { - BT_WARN("Prohibited element address"); + LOG_WRN("Prohibited element address"); return -EINVAL; } mod_id = buf->data; - BT_DBG("elem_addr 0x%04x", elem_addr); + LOG_DBG("elem_addr 0x%04x", elem_addr); elem = bt_mesh_elem_find(elem_addr); if (!elem) { @@ -2069,7 +2050,7 @@ send_list: } if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { - BT_ERR("Unable to send Model Application List message"); + LOG_ERR("Unable to send Model Application List message"); } return 0; @@ -2078,7 +2059,7 @@ send_list: static void reset_send_start(uint16_t duration, int err, void *cb_data) { if (err) { - BT_ERR("Sending Node Reset Status failed (err %d)", err); + LOG_ERR("Sending Node Reset Status failed (err %d)", err); k_work_submit(&node_reset_pending); } } @@ -2098,14 +2079,13 @@ static int node_reset(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, BT_MESH_MODEL_BUF_DEFINE(msg, OP_NODE_RESET_STATUS, 0); - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); bt_mesh_model_msg_init(&msg, OP_NODE_RESET_STATUS); if (bt_mesh_model_send(model, ctx, &msg, &reset_cb, NULL)) { - BT_ERR("Unable to send Node Reset Status"); + LOG_ERR("Unable to send Node Reset Status"); } return 0; @@ -2120,7 +2100,7 @@ static int send_friend_status(struct bt_mesh_model *model, net_buf_simple_add_u8(&msg, bt_mesh_friend_get()); if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { - BT_ERR("Unable to send Friend Status"); + LOG_ERR("Unable to send Friend Status"); } return 0; @@ -2130,9 +2110,8 @@ static int friend_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); return send_friend_status(model, ctx); } @@ -2141,12 +2120,11 @@ static int friend_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); if (buf->data[0] != 0x00 && buf->data[0] != 0x01) { - BT_WARN("Invalid Friend value 0x%02x", buf->data[0]); + LOG_WRN("Invalid Friend value 0x%02x", buf->data[0]); return -EINVAL; } @@ -2166,11 +2144,11 @@ static int lpn_timeout_get(struct bt_mesh_model *model, lpn_addr = net_buf_simple_pull_le16(buf); - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x lpn_addr 0x%02x", - ctx->net_idx, ctx->app_idx, ctx->addr, lpn_addr); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x lpn_addr 0x%02x", ctx->net_idx, + ctx->app_idx, ctx->addr, lpn_addr); if (!BT_MESH_ADDR_IS_UNICAST(lpn_addr)) { - BT_WARN("Invalid LPNAddress; ignoring msg"); + LOG_WRN("Invalid LPNAddress; ignoring msg"); return -EINVAL; } @@ -2195,7 +2173,7 @@ send_rsp: net_buf_simple_add_le24(&msg, timeout_steps); if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { - BT_ERR("Unable to send LPN PollTimeout Status"); + LOG_ERR("Unable to send LPN PollTimeout Status"); } return 0; @@ -2214,7 +2192,7 @@ static int send_krp_status(struct bt_mesh_model *model, net_buf_simple_add_u8(&msg, phase); if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { - BT_ERR("Unable to send Key Refresh State Status"); + LOG_ERR("Unable to send Key Refresh State Status"); } return 0; @@ -2228,11 +2206,11 @@ static int krp_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, idx = net_buf_simple_pull_le16(buf); if (idx > 0xfff) { - BT_ERR("Invalid NetKeyIndex 0x%04x", idx); + LOG_ERR("Invalid NetKeyIndex 0x%04x", idx); return -EINVAL; } - BT_DBG("idx 0x%04x", idx); + LOG_DBG("idx 0x%04x", idx); status = bt_mesh_subnet_kr_phase_get(idx, &kr_phase); @@ -2249,13 +2227,13 @@ static int krp_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, phase = net_buf_simple_pull_u8(buf); if (idx > 0xfff) { - BT_ERR("Invalid NetKeyIndex 0x%04x", idx); + LOG_ERR("Invalid NetKeyIndex 0x%04x", idx); return -EINVAL; } status = bt_mesh_subnet_kr_phase_set(idx, &phase); if (status == STATUS_CANNOT_UPDATE) { - BT_ERR("Invalid kr phase transition 0x%02x", phase); + LOG_ERR("Invalid kr phase transition 0x%02x", phase); return -EINVAL; } @@ -2290,7 +2268,7 @@ static int hb_pub_send_status(struct bt_mesh_model *model, { BT_MESH_MODEL_BUF_DEFINE(msg, OP_HEARTBEAT_PUB_STATUS, 10); - BT_DBG("src 0x%04x status 0x%02x", ctx->addr, status); + LOG_DBG("src 0x%04x status 0x%02x", ctx->addr, status); bt_mesh_model_msg_init(&msg, OP_HEARTBEAT_PUB_STATUS); @@ -2304,7 +2282,7 @@ static int hb_pub_send_status(struct bt_mesh_model *model, net_buf_simple_add_le16(&msg, pub->net_idx); if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { - BT_ERR("Unable to send Heartbeat Publication Status"); + LOG_ERR("Unable to send Heartbeat Publication Status"); } return 0; @@ -2316,7 +2294,7 @@ static int heartbeat_pub_get(struct bt_mesh_model *model, { struct bt_mesh_hb_pub pub; - BT_DBG("src 0x%04x", ctx->addr); + LOG_DBG("src 0x%04x", ctx->addr); bt_mesh_hb_pub_get(&pub); @@ -2331,7 +2309,7 @@ static int heartbeat_pub_set(struct bt_mesh_model *model, struct bt_mesh_hb_pub pub; uint8_t status; - BT_DBG("src 0x%04x", ctx->addr); + LOG_DBG("src 0x%04x", ctx->addr); pub.dst = sys_le16_to_cpu(param->dst); pub.count = bt_mesh_hb_pwr2(param->count_log); @@ -2357,12 +2335,12 @@ static int heartbeat_pub_set(struct bt_mesh_model *model, } if (param->ttl > BT_MESH_TTL_MAX && param->ttl != BT_MESH_TTL_DEFAULT) { - BT_ERR("Invalid TTL value 0x%02x", param->ttl); + LOG_ERR("Invalid TTL value 0x%02x", param->ttl); return -EINVAL; } if (pub.net_idx > 0xfff) { - BT_ERR("Invalid NetKeyIndex 0x%04x", pub.net_idx); + LOG_ERR("Invalid NetKeyIndex 0x%04x", pub.net_idx); return -EINVAL; } @@ -2378,7 +2356,7 @@ static int hb_sub_send_status(struct bt_mesh_model *model, { BT_MESH_MODEL_BUF_DEFINE(msg, OP_HEARTBEAT_SUB_STATUS, 9); - BT_DBG("src 0x%04x ", ctx->addr); + LOG_DBG("src 0x%04x ", ctx->addr); bt_mesh_model_msg_init(&msg, OP_HEARTBEAT_SUB_STATUS); @@ -2391,7 +2369,7 @@ static int hb_sub_send_status(struct bt_mesh_model *model, net_buf_simple_add_u8(&msg, sub->max_hops); if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { - BT_ERR("Unable to send Heartbeat Subscription Status"); + LOG_ERR("Unable to send Heartbeat Subscription Status"); } return 0; @@ -2403,7 +2381,7 @@ static int heartbeat_sub_get(struct bt_mesh_model *model, { struct bt_mesh_hb_sub sub; - BT_DBG("src 0x%04x", ctx->addr); + LOG_DBG("src 0x%04x", ctx->addr); bt_mesh_hb_sub_get(&sub); @@ -2420,17 +2398,16 @@ static int heartbeat_sub_set(struct bt_mesh_model *model, uint32_t period; int err; - BT_DBG("src 0x%04x", ctx->addr); + LOG_DBG("src 0x%04x", ctx->addr); sub_src = net_buf_simple_pull_le16(buf); sub_dst = net_buf_simple_pull_le16(buf); period_log = net_buf_simple_pull_u8(buf); - BT_DBG("sub_src 0x%04x sub_dst 0x%04x period 0x%02x", - sub_src, sub_dst, period_log); + LOG_DBG("sub_src 0x%04x sub_dst 0x%04x period 0x%02x", sub_src, sub_dst, period_log); if (period_log > 0x11) { - BT_WARN("Prohibited subscription period 0x%02x", period_log); + LOG_WRN("Prohibited subscription period 0x%02x", period_log); return -EINVAL; } @@ -2523,7 +2500,7 @@ const struct bt_mesh_model_op bt_mesh_cfg_srv_op[] = { static int cfg_srv_init(struct bt_mesh_model *model) { if (!bt_mesh_model_in_primary(model)) { - BT_ERR("Configuration Server only allowed in primary element"); + LOG_ERR("Configuration Server only allowed in primary element"); return -EINVAL; } diff --git a/subsys/bluetooth/mesh/crypto.c b/subsys/bluetooth/mesh/crypto.c index 181dcf35ecc..3687a2f0e57 100644 --- a/subsys/bluetooth/mesh/crypto.c +++ b/subsys/bluetooth/mesh/crypto.c @@ -24,14 +24,15 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_CRYPTO) -#define LOG_MODULE_NAME bt_mesh_tc_crypto -#include "common/log.h" #include "common/bt_str.h" #include "mesh.h" #include "crypto.h" +#define LOG_LEVEL CONFIG_BT_MESH_CRYPTO_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_mesh_tc_crypto); + #define NET_MIC_LEN(pdu) (((pdu)[1] & 0x80) ? 8 : 4) #define APP_MIC_LEN(aszmic) ((aszmic) ? 8 : 4) @@ -102,8 +103,8 @@ int bt_mesh_k2(const uint8_t n[16], const uint8_t *p, size_t p_len, uint8_t pad; int err; - BT_DBG("n %s", bt_hex(n, 16)); - BT_DBG("p %s", bt_hex(p, p_len)); + LOG_DBG("n %s", bt_hex(n, 16)); + LOG_DBG("p %s", bt_hex(p, p_len)); err = bt_mesh_s1("smk2", salt); if (err) { @@ -151,8 +152,8 @@ int bt_mesh_k2(const uint8_t n[16], const uint8_t *p, size_t p_len, memcpy(priv_key, out, 16); - BT_DBG("NID 0x%02x enc_key %s", net_id[0], bt_hex(enc_key, 16)); - BT_DBG("priv_key %s", bt_hex(priv_key, 16)); + LOG_DBG("NID 0x%02x enc_key %s", net_id[0], bt_hex(enc_key, 16)); + LOG_DBG("priv_key %s", bt_hex(priv_key, 16)); return 0; } @@ -284,12 +285,12 @@ int bt_mesh_net_obfuscate(uint8_t *pdu, uint32_t iv_index, uint8_t tmp[16]; int err, i; - BT_DBG("IVIndex %u, PrivacyKey %s", iv_index, bt_hex(privacy_key, 16)); + LOG_DBG("IVIndex %u, PrivacyKey %s", iv_index, bt_hex(privacy_key, 16)); sys_put_be32(iv_index, &priv_rand[5]); memcpy(&priv_rand[9], &pdu[7], 7); - BT_DBG("PrivacyRandom %s", bt_hex(priv_rand, 16)); + LOG_DBG("PrivacyRandom %s", bt_hex(priv_rand, 16)); err = bt_encrypt_be(privacy_key, priv_rand, tmp); if (err) { @@ -310,9 +311,8 @@ int bt_mesh_net_encrypt(const uint8_t key[16], struct net_buf_simple *buf, uint8_t nonce[13]; int err; - BT_DBG("IVIndex %u EncKey %s mic_len %u", iv_index, bt_hex(key, 16), - mic_len); - BT_DBG("PDU (len %u) %s", buf->len, bt_hex(buf->data, buf->len)); + LOG_DBG("IVIndex %u EncKey %s mic_len %u", iv_index, bt_hex(key, 16), mic_len); + LOG_DBG("PDU (len %u) %s", buf->len, bt_hex(buf->data, buf->len)); if (IS_ENABLED(CONFIG_BT_MESH_PROXY) && proxy) { create_proxy_nonce(nonce, buf->data, iv_index); @@ -320,7 +320,7 @@ int bt_mesh_net_encrypt(const uint8_t key[16], struct net_buf_simple *buf, create_net_nonce(nonce, buf->data, iv_index); } - BT_DBG("Nonce %s", bt_hex(nonce, 13)); + LOG_DBG("Nonce %s", bt_hex(nonce, 13)); err = bt_ccm_encrypt(key, nonce, &buf->data[7], buf->len - 7, NULL, 0, &buf->data[7], mic_len); @@ -337,9 +337,8 @@ int bt_mesh_net_decrypt(const uint8_t key[16], struct net_buf_simple *buf, uint8_t mic_len = NET_MIC_LEN(buf->data); uint8_t nonce[13]; - BT_DBG("PDU (%u bytes) %s", buf->len, bt_hex(buf->data, buf->len)); - BT_DBG("iv_index %u, key %s mic_len %u", iv_index, bt_hex(key, 16), - mic_len); + LOG_DBG("PDU (%u bytes) %s", buf->len, bt_hex(buf->data, buf->len)); + LOG_DBG("iv_index %u, key %s mic_len %u", iv_index, bt_hex(key, 16), mic_len); if (IS_ENABLED(CONFIG_BT_MESH_PROXY) && proxy) { create_proxy_nonce(nonce, buf->data, iv_index); @@ -347,7 +346,7 @@ int bt_mesh_net_decrypt(const uint8_t key[16], struct net_buf_simple *buf, create_net_nonce(nonce, buf->data, iv_index); } - BT_DBG("Nonce %s", bt_hex(nonce, 13)); + LOG_DBG("Nonce %s", bt_hex(nonce, 13)); buf->len -= mic_len; @@ -379,22 +378,21 @@ int bt_mesh_app_encrypt(const uint8_t key[16], uint8_t nonce[13]; int err; - BT_DBG("AppKey %s", bt_hex(key, 16)); - BT_DBG("dev_key %u src 0x%04x dst 0x%04x", ctx->dev_key, ctx->src, - ctx->dst); - BT_DBG("seq_num 0x%08x iv_index 0x%08x", ctx->seq_num, ctx->iv_index); - BT_DBG("Clear: %s", bt_hex(buf->data, buf->len)); + LOG_DBG("AppKey %s", bt_hex(key, 16)); + LOG_DBG("dev_key %u src 0x%04x dst 0x%04x", ctx->dev_key, ctx->src, ctx->dst); + LOG_DBG("seq_num 0x%08x iv_index 0x%08x", ctx->seq_num, ctx->iv_index); + LOG_DBG("Clear: %s", bt_hex(buf->data, buf->len)); create_app_nonce(nonce, ctx); - BT_DBG("Nonce %s", bt_hex(nonce, 13)); + LOG_DBG("Nonce %s", bt_hex(nonce, 13)); err = bt_ccm_encrypt(key, nonce, buf->data, buf->len, ctx->ad, ctx->ad ? 16 : 0, buf->data, APP_MIC_LEN(ctx->aszmic)); if (!err) { net_buf_simple_add(buf, APP_MIC_LEN(ctx->aszmic)); - BT_DBG("Encr: %s", bt_hex(buf->data, buf->len)); + LOG_DBG("Encr: %s", bt_hex(buf->data, buf->len)); } return err; @@ -407,13 +405,12 @@ int bt_mesh_app_decrypt(const uint8_t key[16], uint8_t nonce[13]; int err; - BT_DBG("EncData (len %u) %s", buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("EncData (len %u) %s", buf->len, bt_hex(buf->data, buf->len)); create_app_nonce(nonce, ctx); - BT_DBG("AppKey %s", bt_hex(key, 16)); - BT_DBG("Nonce %s", bt_hex(nonce, 13)); + LOG_DBG("AppKey %s", bt_hex(key, 16)); + LOG_DBG("Nonce %s", bt_hex(nonce, 13)); err = bt_ccm_decrypt(key, nonce, buf->data, buf->len, ctx->ad, ctx->ad ? 16 : 0, out->data, @@ -476,7 +473,7 @@ uint8_t bt_mesh_fcs_calc(const uint8_t *data, uint8_t data_len) fcs = crc_table[fcs ^ *data++]; } - BT_DBG("fcs 0x%02x", 0xff - fcs); + LOG_DBG("fcs 0x%02x", 0xff - fcs); return 0xff - fcs; } @@ -546,9 +543,9 @@ int bt_mesh_prov_conf(const uint8_t conf_key[16], const uint8_t rand[16], { struct bt_mesh_sg sg[] = { { rand, 16 }, { auth, 16 } }; - BT_DBG("ConfirmationKey %s", bt_hex(conf_key, 16)); - BT_DBG("RandomDevice %s", bt_hex(rand, 16)); - BT_DBG("AuthValue %s", bt_hex(auth, 16)); + LOG_DBG("ConfirmationKey %s", bt_hex(conf_key, 16)); + LOG_DBG("RandomDevice %s", bt_hex(rand, 16)); + LOG_DBG("AuthValue %s", bt_hex(auth, 16)); return bt_mesh_aes_cmac(conf_key, sg, ARRAY_SIZE(sg), conf); } @@ -572,15 +569,15 @@ int bt_mesh_beacon_auth(const uint8_t beacon_key[16], uint8_t flags, uint8_t msg[13], tmp[16]; int err; - BT_DBG("BeaconKey %s", bt_hex(beacon_key, 16)); - BT_DBG("NetId %s", bt_hex(net_id, 8)); - BT_DBG("IV Index 0x%08x", iv_index); + LOG_DBG("BeaconKey %s", bt_hex(beacon_key, 16)); + LOG_DBG("NetId %s", bt_hex(net_id, 8)); + LOG_DBG("IV Index 0x%08x", iv_index); msg[0] = flags; memcpy(&msg[1], net_id, 8); sys_put_be32(iv_index, &msg[9]); - BT_DBG("BeaconMsg %s", bt_hex(msg, sizeof(msg))); + LOG_DBG("BeaconMsg %s", bt_hex(msg, sizeof(msg))); err = bt_mesh_aes_cmac_one(beacon_key, msg, sizeof(msg), tmp); if (!err) { @@ -593,11 +590,11 @@ int bt_mesh_beacon_auth(const uint8_t beacon_key[16], uint8_t flags, int bt_mesh_dhkey_gen(const uint8_t *pub_key, const uint8_t *priv_key, uint8_t *dhkey) { if (uECC_valid_public_key(pub_key, &curve_secp256r1)) { - BT_ERR("Public key is not valid"); + LOG_ERR("Public key is not valid"); return -EIO; } else if (uECC_shared_secret(pub_key, priv_key, dhkey, &curve_secp256r1) != TC_CRYPTO_SUCCESS) { - BT_ERR("DHKey generation failed"); + LOG_ERR("DHKey generation failed"); return -EIO; } diff --git a/subsys/bluetooth/mesh/friend.c b/subsys/bluetooth/mesh/friend.c index 270df86b5ff..69fda51cf23 100644 --- a/subsys/bluetooth/mesh/friend.c +++ b/subsys/bluetooth/mesh/friend.c @@ -12,10 +12,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_FRIEND) -#define LOG_MODULE_NAME bt_mesh_friend -#include "common/log.h" - #include "crypto.h" #include "adv.h" #include "mesh.h" @@ -26,6 +22,10 @@ #include "foundation.h" #include "friend.h" +#define LOG_LEVEL CONFIG_BT_MESH_FRIEND_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_mesh_friend); + /* We reserve one extra buffer for each friendship, since we need to be able * to resend the last sent PDU, which sits separately outside of the queue. */ @@ -83,7 +83,7 @@ struct bt_mesh_friend *bt_mesh_friend_find(uint16_t net_idx, uint16_t lpn_addr, { int i; - BT_DBG("net_idx 0x%04x lpn_addr 0x%04x", net_idx, lpn_addr); + LOG_DBG("net_idx 0x%04x lpn_addr 0x%04x", net_idx, lpn_addr); for (i = 0; i < ARRAY_SIZE(bt_mesh.frnd); i++) { struct bt_mesh_friend *frnd = &bt_mesh.frnd[i]; @@ -149,7 +149,7 @@ static void friend_clear(struct bt_mesh_friend *frnd) { int i; - BT_DBG("LPN 0x%04x", frnd->lpn); + LOG_DBG("LPN 0x%04x", frnd->lpn); /* If cancelling the timer fails, we'll exit early in the work handler. */ (void)k_work_cancel_delayable(&frnd->timer); @@ -190,7 +190,7 @@ void bt_mesh_friends_clear(void) { int i; - BT_DBG(""); + LOG_DBG(""); for (i = 0; i < ARRAY_SIZE(bt_mesh.frnd); i++) { struct bt_mesh_friend *frnd = &bt_mesh.frnd[i]; @@ -209,7 +209,7 @@ void bt_mesh_friend_sec_update(uint16_t net_idx) { int i; - BT_DBG("net_idx 0x%04x", net_idx); + LOG_DBG("net_idx 0x%04x", net_idx); for (i = 0; i < ARRAY_SIZE(bt_mesh.frnd); i++) { struct bt_mesh_friend *frnd = &bt_mesh.frnd[i]; @@ -239,18 +239,18 @@ int bt_mesh_friend_clear(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf) struct bt_mesh_ctl_friend_clear_confirm cfm; if (buf->len < sizeof(*msg)) { - BT_WARN("Too short Friend Clear"); + LOG_WRN("Too short Friend Clear"); return -EINVAL; } lpn_addr = sys_be16_to_cpu(msg->lpn_addr); lpn_counter = sys_be16_to_cpu(msg->lpn_counter); - BT_DBG("LPN addr 0x%04x counter 0x%04x", lpn_addr, lpn_counter); + LOG_DBG("LPN addr 0x%04x counter 0x%04x", lpn_addr, lpn_counter); frnd = bt_mesh_friend_find(rx->sub->net_idx, lpn_addr, false, false); if (!frnd) { - BT_WARN("No matching LPN addr 0x%04x", lpn_addr); + LOG_WRN("No matching LPN addr 0x%04x", lpn_addr); return 0; } @@ -261,8 +261,7 @@ int bt_mesh_friend_clear(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf) * 65536, is in the range 0 to 255 inclusive. */ if (lpn_counter - frnd->lpn_counter > 255) { - BT_WARN("LPN Counter out of range (old %u new %u)", - frnd->lpn_counter, lpn_counter); + LOG_WRN("LPN Counter out of range (old %u new %u)", frnd->lpn_counter, lpn_counter); return 0; } @@ -296,7 +295,7 @@ static void friend_sub_add(struct bt_mesh_friend *frnd, uint16_t addr) if (empty_idx != INT_MAX) { frnd->sub_list[empty_idx] = addr; } else { - BT_WARN("No space in friend subscription list"); + LOG_WRN("No space in friend subscription list"); } } @@ -448,12 +447,11 @@ static int unseg_app_sdu_prepare(struct bt_mesh_friend *frnd, return 0; } - BT_DBG("Re-encrypting friend pdu (SeqNum %06x -> %06x)", - meta.crypto.seq_num, bt_mesh.seq); + LOG_DBG("Re-encrypting friend pdu (SeqNum %06x -> %06x)", meta.crypto.seq_num, bt_mesh.seq); err = unseg_app_sdu_decrypt(frnd, buf, &meta); if (err) { - BT_WARN("Decryption failed! %d", err); + LOG_WRN("Decryption failed! %d", err); return err; } @@ -461,7 +459,7 @@ static int unseg_app_sdu_prepare(struct bt_mesh_friend *frnd, err = unseg_app_sdu_encrypt(frnd, buf, &meta); if (err) { - BT_WARN("Re-encryption failed! %d", err); + LOG_WRN("Re-encryption failed! %d", err); } return err; @@ -507,12 +505,12 @@ static int encrypt_friend_pdu(struct bt_mesh_friend *frnd, struct net_buf *buf, buf->data[0] = (cred->nid | (iv_index & 1) << 7); if (bt_mesh_net_encrypt(cred->enc, &buf->b, iv_index, false)) { - BT_ERR("Encrypting failed"); + LOG_ERR("Encrypting failed"); return -EINVAL; } if (bt_mesh_net_obfuscate(buf->data, iv_index, cred->privacy)) { - BT_ERR("Obfuscating failed"); + LOG_ERR("Obfuscating failed"); return -EINVAL; } @@ -525,7 +523,7 @@ static struct net_buf *encode_friend_ctl(struct bt_mesh_friend *frnd, { struct friend_pdu_info info; - BT_DBG("LPN 0x%04x", frnd->lpn); + LOG_DBG("LPN 0x%04x", frnd->lpn); net_buf_simple_push_u8(sdu, TRANS_CTL_HDR(ctl_op, 0)); @@ -549,7 +547,7 @@ static struct net_buf *encode_update(struct bt_mesh_friend *frnd, uint8_t md) __ASSERT_NO_MSG(friend_is_allocated(frnd)); - BT_DBG("lpn 0x%04x md 0x%02x", frnd->lpn, md); + LOG_DBG("lpn 0x%04x md 0x%02x", frnd->lpn, md); net_buf_simple_reserve(&sdu, 1); @@ -567,7 +565,7 @@ static void enqueue_sub_cfm(struct bt_mesh_friend *frnd, uint8_t xact) NET_BUF_SIMPLE_DEFINE(sdu, 1 + sizeof(*cfm)); struct net_buf *buf; - BT_DBG("lpn 0x%04x xact 0x%02x", frnd->lpn, xact); + LOG_DBG("lpn 0x%04x xact 0x%02x", frnd->lpn, xact); net_buf_simple_reserve(&sdu, 1); @@ -576,7 +574,7 @@ static void enqueue_sub_cfm(struct bt_mesh_friend *frnd, uint8_t xact) buf = encode_friend_ctl(frnd, TRANS_CTL_OP_FRIEND_SUB_CFM, &sdu); if (!buf) { - BT_ERR("Unable to encode Subscription List Confirmation"); + LOG_ERR("Unable to encode Subscription List Confirmation"); return; } @@ -585,7 +583,7 @@ static void enqueue_sub_cfm(struct bt_mesh_friend *frnd, uint8_t xact) } if (frnd->last) { - BT_DBG("Discarding last PDU"); + LOG_DBG("Discarding last PDU"); net_buf_unref(frnd->last); } @@ -599,7 +597,7 @@ static void friend_recv_delay(struct bt_mesh_friend *frnd) frnd->pending_req = 1U; k_work_reschedule(&frnd->timer, K_MSEC(delay)); - BT_DBG("Waiting RecvDelay of %d ms", delay); + LOG_DBG("Waiting RecvDelay of %d ms", delay); } int bt_mesh_friend_sub_add(struct bt_mesh_net_rx *rx, @@ -609,18 +607,18 @@ int bt_mesh_friend_sub_add(struct bt_mesh_net_rx *rx, uint8_t xact; if (buf->len < BT_MESH_FRIEND_SUB_MIN_LEN) { - BT_WARN("Too short Friend Subscription Add"); + LOG_WRN("Too short Friend Subscription Add"); return -EINVAL; } frnd = bt_mesh_friend_find(rx->sub->net_idx, rx->ctx.addr, true, true); if (!frnd) { - BT_WARN("No matching LPN addr 0x%04x", rx->ctx.addr); + LOG_WRN("No matching LPN addr 0x%04x", rx->ctx.addr); return 0; } if (frnd->pending_buf) { - BT_WARN("Previous buffer not yet sent!"); + LOG_WRN("Previous buffer not yet sent!"); return 0; } @@ -644,18 +642,18 @@ int bt_mesh_friend_sub_rem(struct bt_mesh_net_rx *rx, uint8_t xact; if (buf->len < BT_MESH_FRIEND_SUB_MIN_LEN) { - BT_WARN("Too short Friend Subscription Remove"); + LOG_WRN("Too short Friend Subscription Remove"); return -EINVAL; } frnd = bt_mesh_friend_find(rx->sub->net_idx, rx->ctx.addr, true, true); if (!frnd) { - BT_WARN("No matching LPN addr 0x%04x", rx->ctx.addr); + LOG_WRN("No matching LPN addr 0x%04x", rx->ctx.addr); return 0; } if (frnd->pending_buf) { - BT_WARN("Previous buffer not yet sent!"); + LOG_WRN("Previous buffer not yet sent!"); return 0; } @@ -684,7 +682,7 @@ static void enqueue_update(struct bt_mesh_friend *frnd, uint8_t md) buf = encode_update(frnd, md); if (!buf) { - BT_ERR("Unable to encode Friend Update"); + LOG_ERR("Unable to encode Friend Update"); return; } @@ -697,27 +695,27 @@ int bt_mesh_friend_poll(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf) struct bt_mesh_friend *frnd; if (buf->len < sizeof(*msg)) { - BT_WARN("Too short Friend Poll"); + LOG_WRN("Too short Friend Poll"); return -EINVAL; } frnd = bt_mesh_friend_find(rx->sub->net_idx, rx->ctx.addr, true, false); if (!frnd) { - BT_WARN("No matching LPN addr 0x%04x", rx->ctx.addr); + LOG_WRN("No matching LPN addr 0x%04x", rx->ctx.addr); return 0; } if (msg->fsn & ~1) { - BT_WARN("Prohibited (non-zero) padding bits"); + LOG_WRN("Prohibited (non-zero) padding bits"); return -EINVAL; } if (frnd->pending_buf) { - BT_WARN("Previous buffer not yet sent"); + LOG_WRN("Previous buffer not yet sent"); return 0; } - BT_DBG("msg->fsn %u frnd->fsn %u", (msg->fsn & 1), frnd->fsn); + LOG_DBG("msg->fsn %u frnd->fsn %u", (msg->fsn & 1), frnd->fsn); friend_recv_delay(frnd); @@ -728,7 +726,7 @@ int bt_mesh_friend_poll(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf) } if (!frnd->established) { - BT_DBG("Friendship established with 0x%04x", frnd->lpn); + LOG_DBG("Friendship established with 0x%04x", frnd->lpn); frnd->established = 1U; STRUCT_SECTION_FOREACH(bt_mesh_friend_cb, cb) { @@ -740,7 +738,7 @@ int bt_mesh_friend_poll(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf) } if (msg->fsn == frnd->fsn && frnd->last) { - BT_DBG("Re-sending last PDU"); + LOG_DBG("Re-sending last PDU"); frnd->send_last = 1U; } else { if (frnd->last) { @@ -752,7 +750,7 @@ int bt_mesh_friend_poll(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf) if (sys_slist_is_empty(&frnd->queue)) { enqueue_update(frnd, 0); - BT_DBG("Enqueued Friend Update to empty queue"); + LOG_DBG("Enqueued Friend Update to empty queue"); } } @@ -806,7 +804,7 @@ static void send_friend_clear(struct bt_mesh_friend *frnd) .lpn_counter = sys_cpu_to_be16(frnd->lpn_counter), }; - BT_DBG(""); + LOG_DBG(""); bt_mesh_ctl_send(&tx, TRANS_CTL_OP_FRIEND_CLEAR, &req, sizeof(req), &clear_sent_cb, frnd); @@ -824,11 +822,11 @@ static void clear_timeout(struct k_work *work) return; } - BT_DBG("LPN 0x%04x (old) Friend 0x%04x", frnd->lpn, frnd->clear.frnd); + LOG_DBG("LPN 0x%04x (old) Friend 0x%04x", frnd->lpn, frnd->clear.frnd); duration = k_uptime_get_32() - frnd->clear.start; if (duration > 2 * frnd->poll_to) { - BT_DBG("Clear Procedure timer expired"); + LOG_DBG("Clear Procedure timer expired"); frnd->clear.frnd = BT_MESH_ADDR_UNASSIGNED; return; } @@ -838,7 +836,7 @@ static void clear_timeout(struct k_work *work) static void clear_procedure_start(struct bt_mesh_friend *frnd) { - BT_DBG("LPN 0x%04x (old) Friend 0x%04x", frnd->lpn, frnd->clear.frnd); + LOG_DBG("LPN 0x%04x (old) Friend 0x%04x", frnd->lpn, frnd->clear.frnd); frnd->clear.start = k_uptime_get_32(); frnd->clear.repeat_sec = 1U; @@ -853,30 +851,28 @@ int bt_mesh_friend_clear_cfm(struct bt_mesh_net_rx *rx, struct bt_mesh_friend *frnd; uint16_t lpn_addr, lpn_counter; - BT_DBG(""); + LOG_DBG(""); if (buf->len < sizeof(*msg)) { - BT_WARN("Too short Friend Clear Confirm"); + LOG_WRN("Too short Friend Clear Confirm"); return -EINVAL; } frnd = find_clear(rx->ctx.addr); if (!frnd) { - BT_WARN("No pending clear procedure for 0x%02x", rx->ctx.addr); + LOG_WRN("No pending clear procedure for 0x%02x", rx->ctx.addr); return 0; } lpn_addr = sys_be16_to_cpu(msg->lpn_addr); if (lpn_addr != frnd->lpn) { - BT_WARN("LPN address mismatch (0x%04x != 0x%04x)", - lpn_addr, frnd->lpn); + LOG_WRN("LPN address mismatch (0x%04x != 0x%04x)", lpn_addr, frnd->lpn); return 0; } lpn_counter = sys_be16_to_cpu(msg->lpn_counter); if (lpn_counter != frnd->lpn_counter) { - BT_WARN("LPN counter mismatch (0x%04x != 0x%04x)", - lpn_counter, frnd->lpn_counter); + LOG_WRN("LPN counter mismatch (0x%04x != 0x%04x)", lpn_counter, frnd->lpn_counter); return 0; } @@ -893,7 +889,7 @@ static void enqueue_offer(struct bt_mesh_friend *frnd, int8_t rssi) NET_BUF_SIMPLE_DEFINE(sdu, 1 + sizeof(*off)); struct net_buf *buf; - BT_DBG(""); + LOG_DBG(""); net_buf_simple_reserve(&sdu, 1); @@ -911,7 +907,7 @@ static void enqueue_offer(struct bt_mesh_friend *frnd, int8_t rssi) buf = encode_friend_ctl(frnd, TRANS_CTL_OP_FRIEND_OFFER, &sdu); if (!buf) { - BT_ERR("Unable to encode Friend Offer"); + LOG_ERR("Unable to encode Friend Offer"); return; } @@ -941,16 +937,15 @@ static int32_t offer_delay(struct bt_mesh_friend *frnd, int8_t rssi, uint8_t cri static const uint8_t fact[] = { 10, 15, 20, 25 }; int32_t delay; - BT_DBG("ReceiveWindowFactor %u ReceiveWindow %u RSSIFactor %u RSSI %d", - fact[RECV_WIN_FACT(crit)], RECV_WIN, - fact[RSSI_FACT(crit)], rssi); + LOG_DBG("ReceiveWindowFactor %u ReceiveWindow %u RSSIFactor %u RSSI %d", + fact[RECV_WIN_FACT(crit)], RECV_WIN, fact[RSSI_FACT(crit)], rssi); /* Delay = ReceiveWindowFactor * ReceiveWindow - RSSIFactor * RSSI */ delay = (int32_t)fact[RECV_WIN_FACT(crit)] * RECV_WIN; delay -= (int32_t)fact[RSSI_FACT(crit)] * rssi; delay /= 10; - BT_DBG("Local Delay calculated as %d ms", delay); + LOG_DBG("Local Delay calculated as %d ms", delay); return MAX(delay, 100); } @@ -964,52 +959,51 @@ int bt_mesh_friend_req(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf) int i, err; if (rx->net_if == BT_MESH_NET_IF_LOCAL) { - BT_DBG("Ignoring Friend request from local interface"); + LOG_DBG("Ignoring Friend request from local interface"); return 0; } if (buf->len < sizeof(*msg)) { - BT_WARN("Too short Friend Request"); + LOG_WRN("Too short Friend Request"); return -EINVAL; } if (msg->recv_delay <= 0x09) { - BT_WARN("Prohibited ReceiveDelay (0x%02x)", msg->recv_delay); + LOG_WRN("Prohibited ReceiveDelay (0x%02x)", msg->recv_delay); return -EINVAL; } poll_to = sys_get_be24(msg->poll_to); if (poll_to <= 0x000009 || poll_to >= 0x34bc00) { - BT_WARN("Prohibited PollTimeout (0x%06x)", poll_to); + LOG_WRN("Prohibited PollTimeout (0x%06x)", poll_to); return -EINVAL; } if (msg->num_elem == 0x00) { - BT_WARN("Prohibited NumElements value (0x00)"); + LOG_WRN("Prohibited NumElements value (0x00)"); return -EINVAL; } if (!BT_MESH_ADDR_IS_UNICAST(rx->ctx.addr + msg->num_elem - 1)) { - BT_WARN("LPN elements stretch outside of unicast range"); + LOG_WRN("LPN elements stretch outside of unicast range"); return -EINVAL; } if (!MIN_QUEUE_SIZE_LOG(msg->criteria)) { - BT_WARN("Prohibited Minimum Queue Size in Friend Request"); + LOG_WRN("Prohibited Minimum Queue Size in Friend Request"); return -EINVAL; } if (CONFIG_BT_MESH_FRIEND_QUEUE_SIZE < MIN_QUEUE_SIZE(msg->criteria)) { - BT_WARN("We have a too small Friend Queue size (%u < %u)", - CONFIG_BT_MESH_FRIEND_QUEUE_SIZE, - MIN_QUEUE_SIZE(msg->criteria)); + LOG_WRN("We have a too small Friend Queue size (%u < %u)", + CONFIG_BT_MESH_FRIEND_QUEUE_SIZE, MIN_QUEUE_SIZE(msg->criteria)); return 0; } frnd = bt_mesh_friend_find(rx->sub->net_idx, rx->ctx.addr, true, false); if (frnd) { - BT_WARN("Existing LPN re-requesting Friendship"); + LOG_WRN("Existing LPN re-requesting Friendship"); friend_clear(frnd); goto init_friend; } @@ -1022,7 +1016,7 @@ int bt_mesh_friend_req(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf) } if (!frnd) { - BT_WARN("No free Friend contexts for new LPN"); + LOG_WRN("No free Friend contexts for new LPN"); return -ENOMEM; } @@ -1037,13 +1031,13 @@ init_friend: err = friend_cred_create(frnd, SUBNET_KEY_TX_IDX(frnd->subnet)); if (err) { - BT_ERR("Failed to create friend credentials"); + LOG_ERR("Failed to create friend credentials"); friend_clear(frnd); return -EIO; } - BT_DBG("LPN 0x%04x rssi %d recv_delay %u poll_to %ums", - frnd->lpn, rx->ctx.recv_rssi, frnd->recv_delay, frnd->poll_to); + LOG_DBG("LPN 0x%04x rssi %d recv_delay %u poll_to %ums", frnd->lpn, rx->ctx.recv_rssi, + frnd->recv_delay, frnd->poll_to); if (BT_MESH_ADDR_IS_UNICAST(frnd->clear.frnd) && !bt_mesh_has_addr(frnd->clear.frnd)) { @@ -1112,7 +1106,7 @@ static void enqueue_friend_pdu(struct bt_mesh_friend *frnd, { struct bt_mesh_friend_seg *seg; - BT_DBG("type %u", type); + LOG_DBG("type %u", type); if (type == BT_MESH_FRIEND_PDU_SINGLE) { enqueue_buf(frnd, buf); @@ -1123,7 +1117,7 @@ static void enqueue_friend_pdu(struct bt_mesh_friend *frnd, seg = get_seg(frnd, src, seq_zero, seg_count); if (!seg) { - BT_ERR("No free friend segment RX contexts for 0x%04x", src); + LOG_ERR("No free friend segment RX contexts for 0x%04x", src); net_buf_unref(buf); return; } @@ -1145,10 +1139,10 @@ static void buf_send_start(uint16_t duration, int err, void *user_data) { struct bt_mesh_friend *frnd = user_data; - BT_DBG("err %d", err); + LOG_DBG("err %d", err); if (!frnd->pending_buf) { - BT_WARN("Attempt of sending to removed friend"); + LOG_WRN("Attempt of sending to removed friend"); return; } @@ -1165,21 +1159,21 @@ static void buf_send_end(int err, void *user_data) { struct bt_mesh_friend *frnd = user_data; - BT_DBG("err %d", err); + LOG_DBG("err %d", err); if (frnd->pending_req || frnd->pending_buf) { - BT_WARN("Another request before previous completed sending"); + LOG_WRN("Another request before previous completed sending"); return; } if (frnd->established) { /* Always restart poll timeout timer after sending */ k_work_reschedule(&frnd->timer, K_MSEC(frnd->poll_to)); - BT_DBG("Waiting %u ms for next poll", frnd->poll_to); + LOG_DBG("Waiting %u ms for next poll", frnd->poll_to); } else { /* Friend offer timeout is 1 second */ k_work_reschedule(&frnd->timer, K_SECONDS(1)); - BT_DBG("Waiting for first poll"); + LOG_DBG("Waiting for first poll"); } } @@ -1208,7 +1202,7 @@ static void update_overwrite(struct net_buf *buf, uint8_t md) } upd = net_buf_pull_mem(buf, sizeof(*upd)); - BT_DBG("Update Previous Friend Update MD 0x%02x -> 0x%02x", upd->md, md); + LOG_DBG("Update Previous Friend Update MD 0x%02x -> 0x%02x", upd->md, md); upd->md = md; end: @@ -1233,25 +1227,23 @@ static void friend_timeout(struct k_work *work) __ASSERT_NO_MSG(frnd->pending_buf == 0U); - BT_DBG("lpn 0x%04x send_last %u last %p", frnd->lpn, - frnd->send_last, frnd->last); + LOG_DBG("lpn 0x%04x send_last %u last %p", frnd->lpn, frnd->send_last, frnd->last); if (frnd->send_last && frnd->last) { - BT_DBG("Sending frnd->last %p", frnd->last); + LOG_DBG("Sending frnd->last %p", frnd->last); frnd->send_last = 0U; goto send_last; } if (frnd->established && !frnd->pending_req) { - BT_WARN("Friendship lost with 0x%04x", frnd->lpn); + LOG_WRN("Friendship lost with 0x%04x", frnd->lpn); friend_clear(frnd); return; } frnd->last = (void *)sys_slist_get(&frnd->queue); if (!frnd->last) { - BT_WARN("Friendship not established with 0x%04x", - frnd->lpn); + LOG_WRN("Friendship not established with 0x%04x", frnd->lpn); friend_clear(frnd); return; } @@ -1268,15 +1260,14 @@ static void friend_timeout(struct k_work *work) frnd->last->flags &= ~NET_BUF_FRAGS; frnd->last->frags = NULL; - BT_DBG("Sending buf %p from Friend Queue of LPN 0x%04x", - frnd->last, frnd->lpn); + LOG_DBG("Sending buf %p from Friend Queue of LPN 0x%04x", frnd->last, frnd->lpn); frnd->queue_size--; send_last: buf = bt_mesh_adv_create(BT_MESH_ADV_DATA, BT_MESH_LOCAL_ADV, FRIEND_XMIT, K_NO_WAIT); if (!buf) { - BT_ERR("Unable to allocate friend adv buffer"); + LOG_ERR("Unable to allocate friend adv buffer"); return; } @@ -1305,15 +1296,14 @@ static void subnet_evt(struct bt_mesh_subnet *sub, enum bt_mesh_key_evt evt) switch (evt) { case BT_MESH_KEY_DELETED: - BT_DBG("Cleared network for 0x%04x", frnd->lpn); + LOG_DBG("Cleared network for 0x%04x", frnd->lpn); friend_clear(frnd); break; case BT_MESH_KEY_UPDATED: - BT_DBG("Generating new keys for 0x%04x", frnd->lpn); + LOG_DBG("Generating new keys for 0x%04x", frnd->lpn); err = friend_cred_create(frnd, 1); if (err) { - BT_ERR("Failed updating friend cred for 0x%04x", - frnd->lpn); + LOG_ERR("Failed updating friend cred for 0x%04x", frnd->lpn); friend_clear(frnd); } break; @@ -1321,7 +1311,7 @@ static void subnet_evt(struct bt_mesh_subnet *sub, enum bt_mesh_key_evt evt) enqueue_update(frnd, 0); break; case BT_MESH_KEY_REVOKED: - BT_DBG("Revoking old keys for 0x%04x", frnd->lpn); + LOG_DBG("Revoking old keys for 0x%04x", frnd->lpn); memcpy(&frnd->cred[0], &frnd->cred[1], sizeof(frnd->cred[0])); memset(&frnd->cred[1], 0, sizeof(frnd->cred[1])); @@ -1399,14 +1389,14 @@ static void friend_purge_old_ack(struct bt_mesh_friend *frnd, { sys_snode_t *cur, *prev = NULL; - BT_DBG("SeqAuth %llx src 0x%04x", *seq_auth, src); + LOG_DBG("SeqAuth %llx src 0x%04x", *seq_auth, src); for (cur = sys_slist_peek_head(&frnd->queue); cur != NULL; prev = cur, cur = sys_slist_peek_next(cur)) { struct net_buf *buf = (void *)cur; if (is_segack(buf, seq_auth, src)) { - BT_DBG("Removing old ack from Friend Queue"); + LOG_DBG("Removing old ack from Friend Queue"); sys_slist_remove(&frnd->queue, prev, cur); frnd->queue_size--; @@ -1436,7 +1426,7 @@ static void friend_lpn_enqueue_rx(struct bt_mesh_friend *frnd, return; } - BT_DBG("LPN 0x%04x queue_size %u", frnd->lpn, frnd->queue_size); + LOG_DBG("LPN 0x%04x queue_size %u", frnd->lpn, frnd->queue_size); if (type == BT_MESH_FRIEND_PDU_SINGLE && seq_auth) { friend_purge_old_ack(frnd, seq_auth, rx->ctx.addr); @@ -1459,14 +1449,13 @@ static void friend_lpn_enqueue_rx(struct bt_mesh_friend *frnd, buf = create_friend_pdu(frnd, &info, sbuf); if (!buf) { - BT_ERR("Failed to encode Friend buffer"); + LOG_ERR("Failed to encode Friend buffer"); return; } enqueue_friend_pdu(frnd, type, info.src, seg_count, buf); - BT_DBG("Queued message for LPN 0x%04x, queue_size %u", - frnd->lpn, frnd->queue_size); + LOG_DBG("Queued message for LPN 0x%04x, queue_size %u", frnd->lpn, frnd->queue_size); } static void friend_lpn_enqueue_tx(struct bt_mesh_friend *frnd, @@ -1478,7 +1467,7 @@ static void friend_lpn_enqueue_tx(struct bt_mesh_friend *frnd, struct friend_pdu_info info; struct net_buf *buf; - BT_DBG("LPN 0x%04x", frnd->lpn); + LOG_DBG("LPN 0x%04x", frnd->lpn); if (type == BT_MESH_FRIEND_PDU_SINGLE && seq_auth) { friend_purge_old_ack(frnd, seq_auth, tx->src); @@ -1496,7 +1485,7 @@ static void friend_lpn_enqueue_tx(struct bt_mesh_friend *frnd, buf = create_friend_pdu(frnd, &info, sbuf); if (!buf) { - BT_ERR("Failed to encode Friend buffer"); + LOG_ERR("Failed to encode Friend buffer"); return; } @@ -1510,7 +1499,7 @@ static void friend_lpn_enqueue_tx(struct bt_mesh_friend *frnd, enqueue_friend_pdu(frnd, type, info.src, seg_count, buf); - BT_DBG("Queued message for LPN 0x%04x", frnd->lpn); + LOG_DBG("Queued message for LPN 0x%04x", frnd->lpn); } static bool friend_lpn_matches(struct bt_mesh_friend *frnd, uint16_t net_idx, @@ -1547,13 +1536,12 @@ bool bt_mesh_friend_match(uint16_t net_idx, uint16_t addr) struct bt_mesh_friend *frnd = &bt_mesh.frnd[i]; if (friend_lpn_matches(frnd, net_idx, addr)) { - BT_DBG("LPN 0x%04x matched address 0x%04x", - frnd->lpn, addr); + LOG_DBG("LPN 0x%04x matched address 0x%04x", frnd->lpn, addr); return true; } } - BT_DBG("No matching LPN for address 0x%04x", addr); + LOG_DBG("No matching LPN for address 0x%04x", addr); return false; } @@ -1641,7 +1629,7 @@ static bool friend_queue_prepare_space(struct bt_mesh_friend *frnd, uint16_t add struct net_buf *buf = (void *)sys_slist_get(&frnd->queue); if (!buf) { - BT_ERR("Unable to free up enough buffers"); + LOG_ERR("Unable to free up enough buffers"); return false; } @@ -1673,9 +1661,8 @@ void bt_mesh_friend_enqueue_rx(struct bt_mesh_net_rx *rx, return; } - BT_DBG("recv_ttl %u net_idx 0x%04x src 0x%04x dst 0x%04x", - rx->ctx.recv_ttl, rx->sub->net_idx, rx->ctx.addr, - rx->ctx.recv_dst); + LOG_DBG("recv_ttl %u net_idx 0x%04x src 0x%04x dst 0x%04x", rx->ctx.recv_ttl, + rx->sub->net_idx, rx->ctx.addr, rx->ctx.recv_dst); for (i = 0; i < ARRAY_SIZE(bt_mesh.frnd); i++) { struct bt_mesh_friend *frnd = &bt_mesh.frnd[i]; @@ -1713,8 +1700,7 @@ bool bt_mesh_friend_enqueue_tx(struct bt_mesh_net_tx *tx, return matched; } - BT_DBG("net_idx 0x%04x dst 0x%04x src 0x%04x", tx->sub->net_idx, - tx->ctx->addr, tx->src); + LOG_DBG("net_idx 0x%04x dst 0x%04x src 0x%04x", tx->sub->net_idx, tx->ctx->addr, tx->src); for (i = 0; i < ARRAY_SIZE(bt_mesh.frnd); i++) { struct bt_mesh_friend *frnd = &bt_mesh.frnd[i]; @@ -1756,7 +1742,7 @@ void bt_mesh_friend_clear_incomplete(struct bt_mesh_subnet *sub, uint16_t src, { int i; - BT_DBG(""); + LOG_DBG(""); for (i = 0; i < ARRAY_SIZE(bt_mesh.frnd); i++) { struct bt_mesh_friend *frnd = &bt_mesh.frnd[i]; @@ -1773,7 +1759,7 @@ void bt_mesh_friend_clear_incomplete(struct bt_mesh_subnet *sub, uint16_t src, continue; } - BT_WARN("Clearing incomplete segments for 0x%04x", src); + LOG_WRN("Clearing incomplete segments for 0x%04x", src); purge_buffers(&seg->queue); seg->seg_count = 0U; diff --git a/subsys/bluetooth/mesh/gatt_cli.c b/subsys/bluetooth/mesh/gatt_cli.c index 7c4dfd84091..6b0f56b6a53 100644 --- a/subsys/bluetooth/mesh/gatt_cli.c +++ b/subsys/bluetooth/mesh/gatt_cli.c @@ -15,9 +15,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_PROXY) -#define LOG_MODULE_NAME bt_mesh_gatt_client -#include "common/log.h" #include "common/bt_str.h" #include "mesh.h" @@ -36,6 +33,10 @@ #include "gatt_cli.h" #include "pb_gatt_cli.h" +#define LOG_LEVEL CONFIG_BT_MESH_PROXY_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_mesh_gatt_client); + static struct bt_mesh_gatt_server { struct bt_conn *conn; uint16_t svc_start_handle; @@ -61,13 +62,13 @@ static uint8_t notify_func(struct bt_conn *conn, const uint8_t *val = data; if (!data) { - BT_WARN("[UNSUBSCRIBED]"); + LOG_WRN("[UNSUBSCRIBED]"); params->value_handle = 0U; return BT_GATT_ITER_STOP; } if (length < 1) { - BT_WARN("Too small Proxy PDU"); + LOG_WRN("Too small Proxy PDU"); return BT_GATT_ITER_STOP; } @@ -82,11 +83,11 @@ static void notify_enabled(struct bt_conn *conn, uint8_t err, struct bt_mesh_gatt_server *server = get_server(conn); if (err != 0) { - BT_WARN("Enable notify failed(err:%d)", err); + LOG_WRN("Enable notify failed(err:%d)", err); return; } - BT_DBG("[SUBSCRIBED]"); + LOG_DBG("[SUBSCRIBED]"); server->gatt->link_open(conn); } @@ -99,13 +100,13 @@ static uint8_t discover_func(struct bt_conn *conn, struct bt_mesh_gatt_server *server = get_server(conn); if (!attr) { - BT_DBG("GATT Services Discover complete"); + LOG_DBG("GATT Services Discover complete"); (void)memset(params, 0, sizeof(*params)); return BT_GATT_ITER_STOP; } - BT_DBG("[ATTRIBUTE UUID 0x%04x] handle %u", - BT_UUID_16(server->discover.uuid)->val, attr->handle); + LOG_DBG("[ATTRIBUTE UUID 0x%04x] handle %u", BT_UUID_16(server->discover.uuid)->val, + attr->handle); if (!bt_uuid_cmp(server->discover.uuid, &server->gatt->srv_uuid.uuid)) { server->svc_start_handle = attr->handle; @@ -116,7 +117,7 @@ static uint8_t discover_func(struct bt_conn *conn, err = bt_gatt_discover(conn, &server->discover); if (err) { - BT_DBG("Discover GATT data in char failed (err %d)", err); + LOG_DBG("Discover GATT data in char failed (err %d)", err); } } else if (!bt_uuid_cmp(server->discover.uuid, &server->gatt->data_in_uuid.uuid)) { @@ -128,7 +129,7 @@ static uint8_t discover_func(struct bt_conn *conn, err = bt_gatt_discover(conn, &server->discover); if (err) { - BT_DBG("Discover GATT data out char failed (err %d)", err); + LOG_DBG("Discover GATT data out char failed (err %d)", err); } } else if (!bt_uuid_cmp(server->discover.uuid, &server->gatt->data_out_uuid.uuid)) { @@ -138,7 +139,7 @@ static uint8_t discover_func(struct bt_conn *conn, err = bt_gatt_discover(conn, &server->discover); if (err) { - BT_DBG("Discover GATT CCCD failed (err %d)", err); + LOG_DBG("Discover GATT CCCD failed (err %d)", err); } } else { (void)memset(&server->subscribe, 0, sizeof(server->subscribe)); @@ -151,7 +152,7 @@ static uint8_t discover_func(struct bt_conn *conn, err = bt_gatt_subscribe(conn, &server->subscribe); if (err && err != -EALREADY) { - BT_DBG("Subscribe failed (err %d)", err); + LOG_DBG("Subscribe failed (err %d)", err); } } @@ -164,7 +165,7 @@ int bt_mesh_gatt_send(struct bt_conn *conn, { struct bt_mesh_gatt_server *server = get_server(conn); - BT_DBG("%u bytes: %s", len, bt_hex(data, len)); + LOG_DBG("%u bytes: %s", len, bt_hex(data, len)); return bt_gatt_write_without_response_cb(conn, server->data_in_handle, data, len, false, end, user_data); @@ -183,7 +184,7 @@ static void gatt_connected(struct bt_conn *conn, uint8_t conn_err) } if (conn_err) { - BT_ERR("Failed to connect GATT Services(%u)", conn_err); + LOG_ERR("Failed to connect GATT Services(%u)", conn_err); bt_conn_unref(server->conn); server->conn = NULL; @@ -193,7 +194,7 @@ static void gatt_connected(struct bt_conn *conn, uint8_t conn_err) return; } - BT_DBG("conn %p err 0x%02x", (void *)conn, conn_err); + LOG_DBG("conn %p err 0x%02x", (void *)conn, conn_err); server->gatt->connected(conn, server->user_data); @@ -206,7 +207,7 @@ static void gatt_connected(struct bt_conn *conn, uint8_t conn_err) server->discover.type = BT_GATT_DISCOVER_PRIMARY; err = bt_gatt_discover(conn, &server->discover); if (err) { - BT_ERR("Unable discover GATT Services (err %d)", err); + LOG_ERR("Unable discover GATT Services (err %d)", err); } } @@ -248,12 +249,12 @@ int bt_mesh_gatt_cli_connect(const bt_addr_le_t *addr, return err; } - BT_DBG("Try to connect services"); + LOG_DBG("Try to connect services"); err = bt_conn_le_create(addr, BT_CONN_LE_CREATE_CONN, BT_LE_CONN_PARAM_DEFAULT, &conn); if (err) { - BT_ERR("Connection failed (err:%d)", err); + LOG_ERR("Connection failed (err:%d)", err); (void)bt_mesh_scan_enable(); @@ -317,7 +318,7 @@ static void scan_recv(const struct bt_le_scan_recv_info *info, } if (len > buf->len) { - BT_WARN("AD malformed"); + LOG_WRN("AD malformed"); return; } diff --git a/subsys/bluetooth/mesh/health_cli.c b/subsys/bluetooth/mesh/health_cli.c index 47d9acb9f60..dbd52c0f2b1 100644 --- a/subsys/bluetooth/mesh/health_cli.c +++ b/subsys/bluetooth/mesh/health_cli.c @@ -16,15 +16,16 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_MODEL) -#define LOG_MODULE_NAME bt_mesh_health_cli -#include "common/log.h" #include "common/bt_str.h" #include "net.h" #include "foundation.h" #include "msg.h" +#define LOG_LEVEL CONFIG_BT_MESH_MODEL_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_mesh_health_cli); + static int32_t msg_timeout; static struct bt_mesh_health_cli *health_cli; @@ -46,9 +47,8 @@ static int health_fault_status(struct bt_mesh_model *model, uint8_t test_id; uint16_t cid; - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); test_id = net_buf_simple_pull_u8(buf); cid = net_buf_simple_pull_le16(buf); @@ -71,7 +71,7 @@ static int health_fault_status(struct bt_mesh_model *model, if (param->faults && param->fault_count) { if (buf->len > *param->fault_count) { - BT_WARN("Got more faults than there's space for"); + LOG_WRN("Got more faults than there's space for"); } else { *param->fault_count = buf->len; } @@ -99,15 +99,13 @@ static int health_current_status(struct bt_mesh_model *model, uint8_t test_id; uint16_t cid; - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); test_id = net_buf_simple_pull_u8(buf); cid = net_buf_simple_pull_le16(buf); - BT_DBG("Test ID 0x%02x Company ID 0x%04x Fault Count %u", test_id, cid, - buf->len); + LOG_DBG("Test ID 0x%02x Company ID 0x%04x Fault Count %u", test_id, cid, buf->len); if (cli->current_status) { cli->current_status(cli, ctx->addr, test_id, cid, @@ -129,9 +127,8 @@ static int health_period_status(struct bt_mesh_model *model, struct health_period_param *param; uint8_t divisor; - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); divisor = net_buf_simple_pull_u8(buf); @@ -164,9 +161,8 @@ static int health_attention_status(struct bt_mesh_model *model, struct health_attention_param *param; uint8_t attention; - BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", - ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, - bt_hex(buf->data, buf->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, + ctx->addr, buf->len, bt_hex(buf->data, buf->len)); attention = net_buf_simple_pull_u8(buf); @@ -540,7 +536,7 @@ void bt_mesh_health_cli_timeout_set(int32_t timeout) int bt_mesh_health_cli_set(struct bt_mesh_model *model) { if (!model->user_data) { - BT_ERR("No Health Client context for given model"); + LOG_ERR("No Health Client context for given model"); return -EINVAL; } @@ -554,10 +550,10 @@ static int health_cli_init(struct bt_mesh_model *model) { struct bt_mesh_health_cli *cli = model->user_data; - BT_DBG("primary %u", bt_mesh_model_in_primary(model)); + LOG_DBG("primary %u", bt_mesh_model_in_primary(model)); if (!cli) { - BT_ERR("No Health Client context provided"); + LOG_ERR("No Health Client context provided"); return -EINVAL; } diff --git a/subsys/bluetooth/mesh/health_srv.c b/subsys/bluetooth/mesh/health_srv.c index 25360ef1864..8ea2ec4398c 100644 --- a/subsys/bluetooth/mesh/health_srv.c +++ b/subsys/bluetooth/mesh/health_srv.c @@ -15,10 +15,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_MODEL) -#define LOG_MODULE_NAME bt_mesh_health_srv -#include "common/log.h" - #include "mesh.h" #include "adv.h" #include "net.h" @@ -26,6 +22,10 @@ #include "access.h" #include "foundation.h" +#define LOG_LEVEL CONFIG_BT_MESH_MODEL_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_mesh_health_srv); + #define HEALTH_TEST_STANDARD 0x00 /* Health Server context of the primary element */ @@ -38,7 +38,7 @@ static void health_get_registered(struct bt_mesh_model *mod, struct bt_mesh_health_srv *srv = mod->user_data; uint8_t *test_id; - BT_DBG("Company ID 0x%04x", company_id); + LOG_DBG("Company ID 0x%04x", company_id); bt_mesh_model_msg_init(msg, OP_HEALTH_FAULT_STATUS); @@ -53,13 +53,13 @@ static void health_get_registered(struct bt_mesh_model *mod, net_buf_simple_tail(msg), &fault_count); if (err) { - BT_ERR("Failed to get faults (err %d)", err); + LOG_ERR("Failed to get faults (err %d)", err); *test_id = HEALTH_TEST_STANDARD; } else { net_buf_simple_add(msg, fault_count); } } else { - BT_WARN("No callback for getting faults"); + LOG_WRN("No callback for getting faults"); *test_id = HEALTH_TEST_STANDARD; } } @@ -87,7 +87,7 @@ static size_t health_get_current(struct bt_mesh_model *mod, net_buf_simple_tail(msg), &fault_count); if (err) { - BT_ERR("Failed to get faults (err %d)", err); + LOG_ERR("Failed to get faults (err %d)", err); sys_put_le16(comp->cid, company_ptr); *test_id = HEALTH_TEST_STANDARD; fault_count = 0U; @@ -96,7 +96,7 @@ static size_t health_get_current(struct bt_mesh_model *mod, net_buf_simple_add(msg, fault_count); } } else { - BT_WARN("No callback for getting faults"); + LOG_WRN("No callback for getting faults"); sys_put_le16(comp->cid, company_ptr); *test_id = HEALTH_TEST_STANDARD; fault_count = 0U; @@ -114,12 +114,12 @@ static int health_fault_get(struct bt_mesh_model *model, company_id = net_buf_simple_pull_le16(buf); - BT_DBG("company_id 0x%04x", company_id); + LOG_DBG("company_id 0x%04x", company_id); health_get_registered(model, company_id, &sdu); if (bt_mesh_model_send(model, ctx, &sdu, NULL, NULL)) { - BT_ERR("Unable to send Health Current Status response"); + LOG_ERR("Unable to send Health Current Status response"); } return 0; @@ -134,7 +134,7 @@ static int health_fault_clear_unrel(struct bt_mesh_model *model, company_id = net_buf_simple_pull_le16(buf); - BT_DBG("company_id 0x%04x", company_id); + LOG_DBG("company_id 0x%04x", company_id); if (srv->cb && srv->cb->fault_clear) { return srv->cb->fault_clear(model, company_id); @@ -153,7 +153,7 @@ static int health_fault_clear(struct bt_mesh_model *model, company_id = net_buf_simple_pull_le16(buf); - BT_DBG("company_id 0x%04x", company_id); + LOG_DBG("company_id 0x%04x", company_id); if (srv->cb && srv->cb->fault_clear) { int err; @@ -167,7 +167,7 @@ static int health_fault_clear(struct bt_mesh_model *model, health_get_registered(model, company_id, &sdu); if (bt_mesh_model_send(model, ctx, &sdu, NULL, NULL)) { - BT_ERR("Unable to send Health Current Status response"); + LOG_ERR("Unable to send Health Current Status response"); } return 0; @@ -184,7 +184,7 @@ static int health_fault_test_unrel(struct bt_mesh_model *model, test_id = net_buf_simple_pull_u8(buf); company_id = net_buf_simple_pull_le16(buf); - BT_DBG("test 0x%02x company 0x%04x", test_id, company_id); + LOG_DBG("test 0x%02x company 0x%04x", test_id, company_id); if (srv->cb && srv->cb->fault_test) { return srv->cb->fault_test(model, test_id, company_id); @@ -202,19 +202,19 @@ static int health_fault_test(struct bt_mesh_model *model, uint16_t company_id; uint8_t test_id; - BT_DBG(""); + LOG_DBG(""); test_id = net_buf_simple_pull_u8(buf); company_id = net_buf_simple_pull_le16(buf); - BT_DBG("test 0x%02x company 0x%04x", test_id, company_id); + LOG_DBG("test 0x%02x company 0x%04x", test_id, company_id); if (srv->cb && srv->cb->fault_test) { int err; err = srv->cb->fault_test(model, test_id, company_id); if (err) { - BT_WARN("Running fault test failed with err %d", err); + LOG_WRN("Running fault test failed with err %d", err); return err; } } @@ -222,7 +222,7 @@ static int health_fault_test(struct bt_mesh_model *model, health_get_registered(model, company_id, &sdu); if (bt_mesh_model_send(model, ctx, &sdu, NULL, NULL)) { - BT_ERR("Unable to send Health Current Status response"); + LOG_ERR("Unable to send Health Current Status response"); } return 0; @@ -238,14 +238,14 @@ static int send_attention_status(struct bt_mesh_model *model, time = k_ticks_to_ms_floor32( k_work_delayable_remaining_get(&srv->attn_timer)) / 1000U; - BT_DBG("%u second%s", time, (time == 1U) ? "" : "s"); + LOG_DBG("%u second%s", time, (time == 1U) ? "" : "s"); bt_mesh_model_msg_init(&msg, OP_ATTENTION_STATUS); net_buf_simple_add_u8(&msg, time); if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { - BT_ERR("Unable to send Attention Status"); + LOG_ERR("Unable to send Attention Status"); } return 0; @@ -255,7 +255,7 @@ static int attention_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - BT_DBG(""); + LOG_DBG(""); return send_attention_status(model, ctx); } @@ -268,7 +268,7 @@ static int attention_set_unrel(struct bt_mesh_model *model, time = net_buf_simple_pull_u8(buf); - BT_DBG("%u second%s", time, (time == 1U) ? "" : "s"); + LOG_DBG("%u second%s", time, (time == 1U) ? "" : "s"); bt_mesh_attention(model, time); @@ -281,7 +281,7 @@ static int attention_set(struct bt_mesh_model *model, { int err; - BT_DBG(""); + LOG_DBG(""); err = attention_set_unrel(model, ctx, buf); if (err) { @@ -302,7 +302,7 @@ static int send_health_period_status(struct bt_mesh_model *model, net_buf_simple_add_u8(&msg, model->pub->period_div); if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { - BT_ERR("Unable to send Health Period Status"); + LOG_ERR("Unable to send Health Period Status"); } return 0; @@ -312,7 +312,7 @@ static int health_period_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - BT_DBG(""); + LOG_DBG(""); return send_health_period_status(model, ctx); } @@ -325,11 +325,11 @@ static int health_period_set_unrel(struct bt_mesh_model *model, period = net_buf_simple_pull_u8(buf); if (period > 15) { - BT_WARN("Prohibited period value %u", period); + LOG_WRN("Prohibited period value %u", period); return -EINVAL; } - BT_DBG("period %u", period); + LOG_DBG("period %u", period); model->pub->period_div = period; @@ -342,7 +342,7 @@ static int health_period_set(struct bt_mesh_model *model, { int err; - BT_DBG(""); + LOG_DBG(""); err = health_period_set_unrel(model, ctx, buf); if (err) { @@ -372,7 +372,7 @@ static int health_pub_update(struct bt_mesh_model *mod) struct bt_mesh_model_pub *pub = mod->pub; size_t count; - BT_DBG(""); + LOG_DBG(""); count = health_get_current(mod, pub->msg); if (count) { @@ -416,7 +416,7 @@ static void attention_off(struct k_work *work) struct bt_mesh_health_srv *srv = CONTAINER_OF(dwork, struct bt_mesh_health_srv, attn_timer); - BT_DBG(""); + LOG_DBG(""); if (srv->cb && srv->cb->attn_off) { srv->cb->attn_off(srv->model); @@ -428,12 +428,12 @@ static int health_srv_init(struct bt_mesh_model *model) struct bt_mesh_health_srv *srv = model->user_data; if (!srv) { - BT_ERR("No Health Server context provided"); + LOG_ERR("No Health Server context provided"); return -EINVAL; } if (!model->pub) { - BT_ERR("Health Server has no publication support"); + LOG_ERR("Health Server has no publication support"); return -EINVAL; } @@ -461,7 +461,7 @@ void bt_mesh_attention(struct bt_mesh_model *model, uint8_t time) if (!model) { srv = health_srv; if (!srv) { - BT_WARN("No Health Server available"); + LOG_WRN("No Health Server available"); return; } diff --git a/subsys/bluetooth/mesh/heartbeat.c b/subsys/bluetooth/mesh/heartbeat.c index 7b40a45bf14..f842994f35a 100644 --- a/subsys/bluetooth/mesh/heartbeat.c +++ b/subsys/bluetooth/mesh/heartbeat.c @@ -14,9 +14,9 @@ #include "heartbeat.h" #include "foundation.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_TRANS) -#define LOG_MODULE_NAME bt_mesh_hb -#include "common/log.h" +#define LOG_LEVEL CONFIG_BT_MESH_TRANS_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_mesh_hb); /* Heartbeat Publication information for persistent storage. */ struct hb_pub_val { @@ -143,7 +143,7 @@ static int heartbeat_send(const struct bt_mesh_send_cb *cb, void *cb_data) hb.feat = sys_cpu_to_be16(feat); - BT_DBG("InitTTL %u feat 0x%04x", pub.ttl, feat); + LOG_DBG("InitTTL %u feat 0x%04x", pub.ttl, feat); return bt_mesh_ctl_send(&tx, TRANS_CTL_OP_HEARTBEAT, &hb, sizeof(hb), cb, cb_data); @@ -165,7 +165,7 @@ static void hb_publish(struct k_work *work) struct bt_mesh_subnet *sub; int err; - BT_DBG("hb_pub.count: %u", pub.count); + LOG_DBG("hb_pub.count: %u", pub.count); /* Fast exit if disabled or expired */ if (pub.period == 0U || pub.count == 0U) { @@ -174,7 +174,7 @@ static void hb_publish(struct k_work *work) sub = bt_mesh_subnet_get(pub.net_idx); if (!sub) { - BT_ERR("No matching subnet for idx 0x%02x", pub.net_idx); + LOG_ERR("No matching subnet for idx 0x%02x", pub.net_idx); pub.dst = BT_MESH_ADDR_UNASSIGNED; return; } @@ -191,7 +191,7 @@ int bt_mesh_hb_recv(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf) uint16_t feat; if (buf->len < 3) { - BT_ERR("Too short heartbeat message"); + LOG_ERR("Too short heartbeat message"); return -EINVAL; } @@ -201,12 +201,12 @@ int bt_mesh_hb_recv(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf) hops = (init_ttl - rx->ctx.recv_ttl + 1); if (rx->ctx.addr != sub.src || rx->ctx.recv_dst != sub.dst) { - BT_DBG("No subscription for received heartbeat"); + LOG_DBG("No subscription for received heartbeat"); return 0; } if (!k_work_delayable_is_pending(&sub_timer)) { - BT_DBG("Heartbeat subscription inactive"); + LOG_DBG("Heartbeat subscription inactive"); return 0; } @@ -217,9 +217,8 @@ int bt_mesh_hb_recv(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf) sub.count++; } - BT_DBG("src 0x%04x TTL %u InitTTL %u (%u hop%s) feat 0x%04x", - rx->ctx.addr, rx->ctx.recv_ttl, init_ttl, hops, - (hops == 1U) ? "" : "s", feat); + LOG_DBG("src 0x%04x TTL %u InitTTL %u (%u hop%s) feat 0x%04x", rx->ctx.addr, + rx->ctx.recv_ttl, init_ttl, hops, (hops == 1U) ? "" : "s", feat); notify_recv(hops, feat); @@ -228,7 +227,7 @@ int bt_mesh_hb_recv(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf) static void pub_disable(void) { - BT_DBG(""); + LOG_DBG(""); pub.dst = BT_MESH_ADDR_UNASSIGNED; pub.count = 0U; @@ -257,7 +256,7 @@ uint8_t bt_mesh_hb_pub_set(struct bt_mesh_hb_pub *new_pub) } if (!bt_mesh_subnet_get(new_pub->net_idx)) { - BT_ERR("Unknown NetKey 0x%04x", new_pub->net_idx); + LOG_ERR("Unknown NetKey 0x%04x", new_pub->net_idx); return STATUS_INVALID_NETKEY; } @@ -293,18 +292,18 @@ void bt_mesh_hb_pub_get(struct bt_mesh_hb_pub *get) uint8_t bt_mesh_hb_sub_set(uint16_t src, uint16_t dst, uint32_t period) { if (src != BT_MESH_ADDR_UNASSIGNED && !BT_MESH_ADDR_IS_UNICAST(src)) { - BT_WARN("Prohibited source address"); + LOG_WRN("Prohibited source address"); return STATUS_INVALID_ADDRESS; } if (BT_MESH_ADDR_IS_VIRTUAL(dst) || BT_MESH_ADDR_IS_RFU(dst) || (BT_MESH_ADDR_IS_UNICAST(dst) && dst != bt_mesh_primary_addr())) { - BT_WARN("Prohibited destination address"); + LOG_WRN("Prohibited destination address"); return STATUS_INVALID_ADDRESS; } if (period > (1U << 16)) { - BT_WARN("Prohibited subscription period %u s", period); + LOG_WRN("Prohibited subscription period %u s", period); return STATUS_CANNOT_SET; } @@ -385,7 +384,7 @@ void bt_mesh_hb_init(void) void bt_mesh_hb_start(void) { if (pub.count && pub.period) { - BT_DBG("Starting heartbeat publication"); + LOG_DBG("Starting heartbeat publication"); k_work_reschedule(&pub_timer, K_NO_WAIT); } } @@ -401,7 +400,7 @@ void bt_mesh_hb_suspend(void) void bt_mesh_hb_resume(void) { if (pub.period && pub.count) { - BT_DBG("Starting heartbeat publication"); + LOG_DBG("Starting heartbeat publication"); k_work_reschedule(&pub_timer, K_NO_WAIT); } } @@ -415,7 +414,7 @@ static int hb_pub_set(const char *name, size_t len_rd, err = bt_mesh_settings_set(read_cb, cb_arg, &hb_val, sizeof(hb_val)); if (err) { - BT_ERR("Failed to set \'hb_val\'"); + LOG_ERR("Failed to set \'hb_val\'"); return err; } @@ -433,7 +432,7 @@ static int hb_pub_set(const char *name, size_t len_rd, (void)bt_mesh_hb_pub_set(&pub); - BT_DBG("Restored heartbeat publication"); + LOG_DBG("Restored heartbeat publication"); return 0; } @@ -461,8 +460,8 @@ void bt_mesh_hb_pub_pending_store(void) } if (err) { - BT_ERR("Failed to store Heartbeat Publication"); + LOG_ERR("Failed to store Heartbeat Publication"); } else { - BT_DBG("Stored Heartbeat Publication"); + LOG_DBG("Stored Heartbeat Publication"); } } diff --git a/subsys/bluetooth/mesh/lpn.c b/subsys/bluetooth/mesh/lpn.c index 6cc526e2210..56322a2b435 100644 --- a/subsys/bluetooth/mesh/lpn.c +++ b/subsys/bluetooth/mesh/lpn.c @@ -12,10 +12,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_LOW_POWER) -#define LOG_MODULE_NAME bt_mesh_lpn -#include "common/log.h" - #include "crypto.h" #include "adv.h" #include "mesh.h" @@ -27,6 +23,10 @@ #include "foundation.h" #include "lpn.h" +#define LOG_LEVEL CONFIG_BT_MESH_LOW_POWER_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_mesh_lpn); + #if defined(CONFIG_BT_MESH_LPN_AUTO) #define LPN_AUTO_TIMEOUT (CONFIG_BT_MESH_LPN_AUTO_TIMEOUT * MSEC_PER_SEC) #else @@ -71,7 +71,7 @@ /* 1 transmission, 20ms interval */ #define POLL_XMIT BT_MESH_TRANSMIT(0, 20) -#if defined(CONFIG_BT_MESH_DEBUG_LOW_POWER) +#if defined(CONFIG_BT_MESH_LOW_POWER_LOG_LEVEL_DBG) static const char *state2str(int state) { switch (state) { @@ -97,7 +97,7 @@ static const char *state2str(int state) return "(unknown)"; } } -#endif /* CONFIG_BT_MESH_DEBUG_LOW_POWER */ +#endif /* CONFIG_BT_MESH_LOW_POWER_LOG_LEVEL_DBG */ static int32_t poll_timeout(struct bt_mesh_lpn *lpn) { @@ -112,15 +112,15 @@ static int32_t poll_timeout(struct bt_mesh_lpn *lpn) MIN(lpn->poll_timeout, POLL_TIMEOUT_MAX(lpn)); } - BT_DBG("Poll Timeout is %ums", lpn->poll_timeout); + LOG_DBG("Poll Timeout is %ums", lpn->poll_timeout); return lpn->poll_timeout; } static inline void lpn_set_state(int state) { -#if defined(CONFIG_BT_MESH_DEBUG_LOW_POWER) - BT_DBG("%s -> %s", state2str(bt_mesh.lpn.state), state2str(state)); +#if defined(CONFIG_BT_MESH_LOW_POWER_LOG_LEVEL_DBG) + LOG_DBG("%s -> %s", state2str(bt_mesh.lpn.state), state2str(state)); #endif bt_mesh.lpn.state = state; } @@ -175,7 +175,7 @@ static void friend_clear_sent(int err, void *user_data) lpn->req_attempts++; if (err) { - BT_ERR("Sending Friend Request failed (err %d)", err); + LOG_ERR("Sending Friend Request failed (err %d)", err); lpn_set_state(BT_MESH_LPN_ENABLED); clear_friendship(false, lpn->disable); return; @@ -208,7 +208,7 @@ static int send_friend_clear(void) .lpn_counter = sys_cpu_to_be16(bt_mesh.lpn.lpn_counter), }; - BT_DBG(""); + LOG_DBG(""); return bt_mesh_ctl_send(&tx, TRANS_CTL_OP_FRIEND_CLEAR, &req, sizeof(req), &clear_sent_cb, NULL); @@ -218,7 +218,7 @@ static void clear_friendship(bool force, bool disable) { struct bt_mesh_lpn *lpn = &bt_mesh.lpn; - BT_DBG("force %u disable %u", force, disable); + LOG_DBG("force %u disable %u", force, disable); if (!force && lpn->established && !lpn->clear_success && lpn->req_attempts < CLEAR_ATTEMPTS) { @@ -295,7 +295,7 @@ static void friend_req_sent(uint16_t duration, int err, void *user_data) } if (err) { - BT_ERR("Sending Friend Request failed (err %d)", err); + LOG_ERR("Sending Friend Request failed (err %d)", err); return; } @@ -340,11 +340,11 @@ static int send_friend_req(struct bt_mesh_lpn *lpn) .lpn_counter = sys_cpu_to_be16(lpn->lpn_counter), }; - BT_DBG(""); + LOG_DBG(""); lpn->sub = bt_mesh_subnet_next(NULL); if (!lpn->sub) { - BT_ERR("No subnets, can't start LPN mode"); + LOG_ERR("No subnets, can't start LPN mode"); return -ENOENT; } @@ -363,13 +363,13 @@ static void req_sent(uint16_t duration, int err, void *user_data) return; } -#if defined(CONFIG_BT_MESH_DEBUG_LOW_POWER) - BT_DBG("req 0x%02x duration %u err %d state %s", - lpn->sent_req, duration, err, state2str(lpn->state)); +#if defined(CONFIG_BT_MESH_LOW_POWER_LOG_LEVEL_DBG) + LOG_DBG("req 0x%02x duration %u err %d state %s", lpn->sent_req, duration, err, + state2str(lpn->state)); #endif if (err) { - BT_ERR("Sending request failed (err %d)", err); + LOG_ERR("Sending request failed (err %d)", err); lpn->sent_req = 0U; group_zero(lpn->pending); return; @@ -422,7 +422,7 @@ static int send_friend_poll(void) uint8_t fsn = lpn->fsn; int err; - BT_DBG("lpn->sent_req 0x%02x", lpn->sent_req); + LOG_DBG("lpn->sent_req 0x%02x", lpn->sent_req); if (lpn->sent_req) { if (lpn->sent_req != TRANS_CTL_OP_FRIEND_POLL) { @@ -501,7 +501,7 @@ int bt_mesh_lpn_set(bool enable) static void friend_response_received(struct bt_mesh_lpn *lpn) { - BT_DBG("lpn->sent_req 0x%02x", lpn->sent_req); + LOG_DBG("lpn->sent_req 0x%02x", lpn->sent_req); if (lpn->sent_req == TRANS_CTL_OP_FRIEND_POLL) { lpn->fsn++; @@ -525,7 +525,7 @@ void bt_mesh_lpn_msg_received(struct bt_mesh_net_rx *rx) struct bt_mesh_lpn *lpn = &bt_mesh.lpn; if (lpn->state == BT_MESH_LPN_TIMER) { - BT_DBG("Restarting establishment timer"); + LOG_DBG("Restarting establishment timer"); k_work_reschedule(&lpn->timer, K_MSEC(LPN_AUTO_TIMEOUT)); return; } @@ -539,13 +539,13 @@ void bt_mesh_lpn_msg_received(struct bt_mesh_net_rx *rx) } if (lpn->sent_req != TRANS_CTL_OP_FRIEND_POLL) { - BT_WARN("Unexpected message without a preceding Poll"); + LOG_WRN("Unexpected message without a preceding Poll"); return; } friend_response_received(lpn); - BT_DBG("Requesting more messages from Friend"); + LOG_DBG("Requesting more messages from Friend"); send_friend_poll(); } @@ -569,25 +569,24 @@ int bt_mesh_lpn_friend_offer(struct bt_mesh_net_rx *rx, int err; if (buf->len < sizeof(*msg)) { - BT_WARN("Too short Friend Offer"); + LOG_WRN("Too short Friend Offer"); return -EINVAL; } if (lpn->state != BT_MESH_LPN_WAIT_OFFER) { - BT_WARN("Ignoring unexpected Friend Offer"); + LOG_WRN("Ignoring unexpected Friend Offer"); return 0; } if (!msg->recv_win) { - BT_WARN("Prohibited ReceiveWindow value"); + LOG_WRN("Prohibited ReceiveWindow value"); return -EINVAL; } frnd_counter = sys_be16_to_cpu(msg->frnd_counter); - BT_DBG("recv_win %u queue_size %u sub_list_size %u rssi %d counter %u", - msg->recv_win, msg->queue_size, msg->sub_list_size, msg->rssi, - frnd_counter); + LOG_DBG("recv_win %u queue_size %u sub_list_size %u rssi %d counter %u", msg->recv_win, + msg->queue_size, msg->sub_list_size, msg->rssi, frnd_counter); lpn->frnd_counter = frnd_counter; lpn->frnd = rx->ctx.addr; @@ -633,22 +632,22 @@ int bt_mesh_lpn_friend_clear_cfm(struct bt_mesh_net_rx *rx, uint16_t addr, counter; if (buf->len < sizeof(*msg)) { - BT_WARN("Too short Friend Clear Confirm"); + LOG_WRN("Too short Friend Clear Confirm"); return -EINVAL; } if (lpn->state != BT_MESH_LPN_CLEAR) { - BT_WARN("Ignoring unexpected Friend Clear Confirm"); + LOG_WRN("Ignoring unexpected Friend Clear Confirm"); return 0; } addr = sys_be16_to_cpu(msg->lpn_addr); counter = sys_be16_to_cpu(msg->lpn_counter); - BT_DBG("LPNAddress 0x%04x LPNCounter 0x%04x", addr, counter); + LOG_DBG("LPNAddress 0x%04x LPNCounter 0x%04x", addr, counter); if (addr != bt_mesh_primary_addr() || counter != lpn->lpn_counter) { - BT_WARN("Invalid parameters in Friend Clear Confirm"); + LOG_WRN("Invalid parameters in Friend Clear Confirm"); return 0; } @@ -676,7 +675,7 @@ static void lpn_group_add(uint16_t group) } if (!free_slot) { - BT_WARN("Friend Subscription List exceeded!"); + LOG_WRN("Friend Subscription List exceeded!"); return; } @@ -735,7 +734,7 @@ static bool sub_update(uint8_t op) struct bt_mesh_ctl_friend_sub req; size_t i, g; - BT_DBG("op 0x%02x sent_req 0x%02x", op, lpn->sent_req); + LOG_DBG("op 0x%02x sent_req 0x%02x", op, lpn->sent_req); if (lpn->sent_req) { return false; @@ -757,7 +756,7 @@ static bool sub_update(uint8_t op) } if (added_count + g >= lpn->queue_size) { - BT_WARN("Friend Queue Size exceeded"); + LOG_WRN("Friend Queue Size exceeded"); break; } @@ -790,7 +789,7 @@ static bool sub_update(uint8_t op) static void update_timeout(struct bt_mesh_lpn *lpn) { if (lpn->established) { - BT_WARN("No response from Friend during ReceiveWindow"); + LOG_WRN("No response from Friend during ReceiveWindow"); bt_mesh_scan_disable(); lpn_set_state(BT_MESH_LPN_ESTABLISHED); k_work_reschedule(&lpn->timer, K_MSEC(POLL_RETRY_TIMEOUT)); @@ -800,14 +799,14 @@ static void update_timeout(struct bt_mesh_lpn *lpn) } if (lpn->req_attempts < REQ_ATTEMPTS(lpn)) { - BT_WARN("Retrying first Friend Poll"); + LOG_WRN("Retrying first Friend Poll"); lpn->sent_req = 0U; if (send_friend_poll() == 0) { return; } } - BT_ERR("Timed out waiting for first Friend Update"); + LOG_ERR("Timed out waiting for first Friend Update"); clear_friendship(false, false); } } @@ -816,8 +815,8 @@ static void lpn_timeout(struct k_work *work) { struct bt_mesh_lpn *lpn = &bt_mesh.lpn; -#if defined(CONFIG_BT_MESH_DEBUG_LOW_POWER) - BT_DBG("state: %s", state2str(lpn->state)); +#if defined(CONFIG_BT_MESH_LOW_POWER_LOG_LEVEL_DBG) + LOG_DBG("state: %s", state2str(lpn->state)); #endif switch (lpn->state) { @@ -827,7 +826,7 @@ static void lpn_timeout(struct k_work *work) clear_friendship(false, bt_mesh.lpn.disable); break; case BT_MESH_LPN_TIMER: - BT_DBG("Starting to look for Friend nodes"); + LOG_DBG("Starting to look for Friend nodes"); lpn_set_state(BT_MESH_LPN_ENABLED); if (IS_ENABLED(CONFIG_BT_MESH_LPN_ESTABLISHMENT)) { bt_mesh_scan_disable(); @@ -843,7 +842,7 @@ static void lpn_timeout(struct k_work *work) lpn_set_state(BT_MESH_LPN_WAIT_OFFER); break; case BT_MESH_LPN_WAIT_OFFER: - BT_WARN("No acceptable Friend Offers received"); + LOG_WRN("No acceptable Friend Offers received"); if (IS_ENABLED(CONFIG_BT_MESH_LPN_ESTABLISHMENT)) { bt_mesh_scan_disable(); } @@ -867,8 +866,7 @@ static void lpn_timeout(struct k_work *work) break; } - BT_ERR("No response from Friend after %u retries", - lpn->req_attempts); + LOG_ERR("No response from Friend after %u retries", lpn->req_attempts); lpn->req_attempts = 0U; clear_friendship(true, false); break; @@ -890,7 +888,7 @@ static void lpn_timeout(struct k_work *work) void bt_mesh_lpn_group_add(uint16_t group) { - BT_DBG("group 0x%04x", group); + LOG_DBG("group 0x%04x", group); lpn_group_add(group); @@ -907,7 +905,7 @@ void bt_mesh_lpn_group_del(uint16_t *groups, size_t group_count) for (i = 0; i < group_count; i++) { if (groups[i] != BT_MESH_ADDR_UNASSIGNED) { - BT_DBG("group 0x%04x", groups[i]); + LOG_DBG("group 0x%04x", groups[i]); lpn_group_del(groups[i]); } } @@ -926,20 +924,19 @@ int bt_mesh_lpn_friend_sub_cfm(struct bt_mesh_net_rx *rx, struct bt_mesh_lpn *lpn = &bt_mesh.lpn; if (buf->len < sizeof(*msg)) { - BT_WARN("Too short Friend Subscription Confirm"); + LOG_WRN("Too short Friend Subscription Confirm"); return -EINVAL; } - BT_DBG("xact 0x%02x", msg->xact); + LOG_DBG("xact 0x%02x", msg->xact); if (!lpn->sent_req) { - BT_WARN("No pending subscription list message"); + LOG_WRN("No pending subscription list message"); return 0; } if (msg->xact != lpn->xact_pending) { - BT_WARN("Transaction mismatch (0x%02x != 0x%02x)", - msg->xact, lpn->xact_pending); + LOG_WRN("Transaction mismatch (0x%02x != 0x%02x)", msg->xact, lpn->xact_pending); return 0; } @@ -958,7 +955,7 @@ int bt_mesh_lpn_friend_sub_cfm(struct bt_mesh_net_rx *rx, } } } else { - BT_WARN("Unexpected Friend Subscription Confirm"); + LOG_WRN("Unexpected Friend Subscription Confirm"); return 0; } @@ -989,17 +986,17 @@ int bt_mesh_lpn_friend_update(struct bt_mesh_net_rx *rx, uint32_t iv_index; if (buf->len < sizeof(*msg)) { - BT_WARN("Too short Friend Update"); + LOG_WRN("Too short Friend Update"); return -EINVAL; } if (lpn->sent_req != TRANS_CTL_OP_FRIEND_POLL) { - BT_WARN("Unexpected friend update"); + LOG_WRN("Unexpected friend update"); return 0; } if (sub->kr_phase == BT_MESH_KR_PHASE_2 && !rx->new_key) { - BT_WARN("Ignoring Phase 2 KR Update secured using old key"); + LOG_WRN("Ignoring Phase 2 KR Update secured using old key"); return 0; } @@ -1016,13 +1013,13 @@ int bt_mesh_lpn_friend_update(struct bt_mesh_net_rx *rx, * Credentials) were used for this message. */ if (!rx->friend_cred) { - BT_WARN("Friend Update with wrong credentials"); + LOG_WRN("Friend Update with wrong credentials"); return -EINVAL; } lpn->established = 1U; - BT_INFO("Friendship established with 0x%04x", lpn->frnd); + LOG_INF("Friendship established with 0x%04x", lpn->frnd); bt_mesh_hb_feature_changed(BT_MESH_FEAT_LOW_POWER); @@ -1042,8 +1039,7 @@ int bt_mesh_lpn_friend_update(struct bt_mesh_net_rx *rx, iv_index = sys_be32_to_cpu(msg->iv_index); - BT_DBG("flags 0x%02x iv_index 0x%08x md %u", msg->flags, iv_index, - msg->md); + LOG_DBG("flags 0x%02x iv_index 0x%08x md %u", msg->flags, iv_index, msg->md); bt_mesh_kr_update(sub, BT_MESH_KEY_REFRESH(msg->flags), rx->new_key); bt_mesh_net_iv_update(iv_index, BT_MESH_IV_UPDATE(msg->flags)); @@ -1058,7 +1054,7 @@ int bt_mesh_lpn_friend_update(struct bt_mesh_net_rx *rx, } if (msg->md) { - BT_DBG("Requesting for more messages"); + LOG_DBG("Requesting for more messages"); send_friend_poll(); } @@ -1071,7 +1067,7 @@ int bt_mesh_lpn_poll(void) return -EAGAIN; } - BT_DBG("Requesting more messages"); + LOG_DBG("Requesting more messages"); return send_friend_poll(); } @@ -1081,12 +1077,12 @@ static void subnet_evt(struct bt_mesh_subnet *sub, enum bt_mesh_key_evt evt) switch (evt) { case BT_MESH_KEY_DELETED: if (sub == bt_mesh.lpn.sub) { - BT_DBG("NetKey deleted"); + LOG_DBG("NetKey deleted"); clear_friendship(true, false); } break; case BT_MESH_KEY_UPDATED: - BT_DBG("NetKey updated"); + LOG_DBG("NetKey updated"); friend_cred_create(&bt_mesh.lpn.cred[1], sub->keys[1].net); break; default: @@ -1102,7 +1098,7 @@ int bt_mesh_lpn_init(void) { struct bt_mesh_lpn *lpn = &bt_mesh.lpn; - BT_DBG(""); + LOG_DBG(""); k_work_init_delayable(&lpn->timer, lpn_timeout); @@ -1118,7 +1114,7 @@ int bt_mesh_lpn_init(void) bt_mesh_scan_enable(); if (IS_ENABLED(CONFIG_BT_MESH_LPN_AUTO)) { - BT_DBG("Waiting %u ms for messages", LPN_AUTO_TIMEOUT); + LOG_DBG("Waiting %u ms for messages", LPN_AUTO_TIMEOUT); lpn_set_state(BT_MESH_LPN_TIMER); k_work_reschedule(&lpn->timer, K_MSEC(LPN_AUTO_TIMEOUT)); diff --git a/subsys/bluetooth/mesh/main.c b/subsys/bluetooth/mesh/main.c index 956146d78dd..0022e3f7c72 100644 --- a/subsys/bluetooth/mesh/main.c +++ b/subsys/bluetooth/mesh/main.c @@ -14,9 +14,7 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG) -#define LOG_MODULE_NAME bt_mesh_main -#include "common/log.h" +#include #include "test.h" #include "adv.h" @@ -41,6 +39,8 @@ #include "mesh.h" #include "gatt_cli.h" +LOG_MODULE_REGISTER(bt_mesh_main, CONFIG_BT_MESH_LOG_LEVEL); + int bt_mesh_provision(const uint8_t net_key[16], uint16_t net_idx, uint8_t flags, uint32_t iv_index, uint16_t addr, const uint8_t dev_key[16]) @@ -48,9 +48,8 @@ int bt_mesh_provision(const uint8_t net_key[16], uint16_t net_idx, int err; struct bt_mesh_cdb_subnet *subnet = NULL; - BT_INFO("Primary Element: 0x%04x", addr); - BT_DBG("net_idx 0x%04x flags 0x%02x iv_index 0x%04x", - net_idx, flags, iv_index); + LOG_INF("Primary Element: 0x%04x", addr); + LOG_DBG("net_idx 0x%04x flags 0x%02x iv_index 0x%04x", net_idx, flags, iv_index); if (atomic_test_and_set_bit(bt_mesh.flags, BT_MESH_VALID)) { return -EALREADY; @@ -64,14 +63,14 @@ int bt_mesh_provision(const uint8_t net_key[16], uint16_t net_idx, comp = bt_mesh_comp_get(); if (comp == NULL) { - BT_ERR("Failed to get node composition"); + LOG_ERR("Failed to get node composition"); atomic_clear_bit(bt_mesh.flags, BT_MESH_VALID); return -EINVAL; } subnet = bt_mesh_cdb_subnet_get(net_idx); if (!subnet) { - BT_ERR("No subnet with idx %d", net_idx); + LOG_ERR("No subnet with idx %d", net_idx); atomic_clear_bit(bt_mesh.flags, BT_MESH_VALID); return -ENOENT; } @@ -80,7 +79,7 @@ int bt_mesh_provision(const uint8_t net_key[16], uint16_t net_idx, node = bt_mesh_cdb_node_alloc(prov->uuid, addr, comp->elem_count, net_idx); if (node == NULL) { - BT_ERR("Failed to allocate database node"); + LOG_ERR("Failed to allocate database node"); atomic_clear_bit(bt_mesh.flags, BT_MESH_VALID); return -ENOMEM; } @@ -271,7 +270,7 @@ int bt_mesh_suspend(void) err = bt_mesh_scan_disable(); if (err) { atomic_clear_bit(bt_mesh.flags, BT_MESH_SUSPENDED); - BT_WARN("Disabling scanning failed (err %d)", err); + LOG_WRN("Disabling scanning failed (err %d)", err); return err; } @@ -317,7 +316,7 @@ int bt_mesh_resume(void) err = bt_mesh_scan_enable(); if (err) { - BT_WARN("Re-enabling scanning failed (err %d)", err); + LOG_WRN("Re-enabling scanning failed (err %d)", err); atomic_set_bit(bt_mesh.flags, BT_MESH_SUSPENDED); return err; } @@ -383,7 +382,7 @@ int bt_mesh_start(void) err = bt_mesh_adv_enable(); if (err) { - BT_ERR("Failed enabling advertiser"); + LOG_ERR("Failed enabling advertiser"); return err; } diff --git a/subsys/bluetooth/mesh/msg.c b/subsys/bluetooth/mesh/msg.c index 9d465bd28bf..458b387539f 100644 --- a/subsys/bluetooth/mesh/msg.c +++ b/subsys/bluetooth/mesh/msg.c @@ -6,12 +6,12 @@ #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_ACCESS) -#define LOG_MODULE_NAME bt_mesh_msg -#include "common/log.h" - #include "msg.h" +#define LOG_LEVEL CONFIG_BT_MESH_ACCESS_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_mesh_msg); + void bt_mesh_model_msg_init(struct net_buf_simple *msg, uint32_t opcode) { net_buf_simple_init(msg, 0); @@ -32,7 +32,7 @@ void bt_mesh_model_msg_init(struct net_buf_simple *msg, uint32_t opcode) net_buf_simple_add_le16(msg, opcode & 0xffff); break; default: - BT_WARN("Unknown opcode format"); + LOG_WRN("Unknown opcode format"); break; } } @@ -48,7 +48,7 @@ int bt_mesh_msg_ack_ctx_prepare(struct bt_mesh_msg_ack_ctx *ack, uint32_t op, uint16_t dst, void *user_data) { if (ack->op) { - BT_WARN("Another synchronous operation pending"); + LOG_WRN("Another synchronous operation pending"); return -EBUSY; } diff --git a/subsys/bluetooth/mesh/net.c b/subsys/bluetooth/mesh/net.c index 5246d7f75e5..3e9e48e66cf 100644 --- a/subsys/bluetooth/mesh/net.c +++ b/subsys/bluetooth/mesh/net.c @@ -17,9 +17,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_NET) -#define LOG_MODULE_NAME bt_mesh_net -#include "common/log.h" #include "common/bt_str.h" #include "crypto.h" @@ -40,6 +37,10 @@ #include "prov.h" #include "cfg.h" +#define LOG_LEVEL CONFIG_BT_MESH_NET_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_mesh_net); + #define LOOPBACK_MAX_PDU_LEN (BT_MESH_NET_HDR_LEN + 16) /* Seq limit after IV Update is triggered */ @@ -192,9 +193,9 @@ int bt_mesh_net_create(uint16_t idx, uint8_t flags, const uint8_t key[16], { int err; - BT_DBG("idx %u flags 0x%02x iv_index %u", idx, flags, iv_index); + LOG_DBG("idx %u flags 0x%02x iv_index %u", idx, flags, iv_index); - BT_DBG("NetKey %s", bt_hex(key, 16)); + LOG_DBG("NetKey %s", bt_hex(key, 16)); if (BT_MESH_KEY_REFRESH(flags)) { err = bt_mesh_subnet_set(idx, BT_MESH_KR_PHASE_2, NULL, key); @@ -203,7 +204,7 @@ int bt_mesh_net_create(uint16_t idx, uint8_t flags, const uint8_t key[16], } if (err) { - BT_ERR("Failed creating subnet"); + LOG_ERR("Failed creating subnet"); return err; } @@ -223,7 +224,7 @@ int bt_mesh_net_create(uint16_t idx, uint8_t flags, const uint8_t key[16], } if (IS_ENABLED(CONFIG_BT_SETTINGS)) { - BT_DBG("Storing network information persistently"); + LOG_DBG("Storing network information persistently"); bt_mesh_subnet_store(idx); store_iv(false); } @@ -242,7 +243,7 @@ void bt_mesh_iv_update_test(bool enable) bool bt_mesh_iv_update(void) { if (!bt_mesh_is_provisioned()) { - BT_ERR("Not yet provisioned"); + LOG_ERR("Not yet provisioned"); return false; } @@ -261,8 +262,7 @@ bool bt_mesh_net_iv_update(uint32_t iv_index, bool iv_update) /* Check if IV index should to be recovered. */ if (iv_index < bt_mesh.iv_index || iv_index > bt_mesh.iv_index + 42) { - BT_ERR("IV Index out of sync: 0x%08x != 0x%08x", - iv_index, bt_mesh.iv_index); + LOG_ERR("IV Index out of sync: 0x%08x != 0x%08x", iv_index, bt_mesh.iv_index); return false; } @@ -271,7 +271,7 @@ bool bt_mesh_net_iv_update(uint32_t iv_index, bool iv_update) (atomic_test_bit(bt_mesh.flags, BT_MESH_IVU_IN_PROGRESS) || !iv_update))) { if (ivi_was_recovered && (bt_mesh.ivu_duration < (2 * BT_MESH_IVU_MIN_HOURS))) { - BT_ERR("IV Index Recovery before minimum delay"); + LOG_ERR("IV Index Recovery before minimum delay"); return false; } @@ -287,7 +287,7 @@ bool bt_mesh_net_iv_update(uint32_t iv_index, bool iv_update) * current IV Update procedure state from the values in * this Secure Network beacon. */ - BT_WARN("Performing IV Index Recovery"); + LOG_WRN("Performing IV Index Recovery"); ivi_was_recovered = true; bt_mesh_rpl_clear(); bt_mesh.iv_index = iv_index; @@ -297,34 +297,33 @@ bool bt_mesh_net_iv_update(uint32_t iv_index, bool iv_update) } if (atomic_test_bit(bt_mesh.flags, BT_MESH_IVU_IN_PROGRESS) == iv_update) { - BT_DBG("No change for IV Update procedure"); + LOG_DBG("No change for IV Update procedure"); return false; } if (!(IS_ENABLED(CONFIG_BT_MESH_IV_UPDATE_TEST) && atomic_test_bit(bt_mesh.flags, BT_MESH_IVU_TEST))) { if (bt_mesh.ivu_duration < BT_MESH_IVU_MIN_HOURS) { - BT_WARN("IV Update before minimum duration"); + LOG_WRN("IV Update before minimum duration"); return false; } } /* Defer change to Normal Operation if there are pending acks */ if (!iv_update && bt_mesh_tx_in_progress()) { - BT_WARN("IV Update deferred because of pending transfer"); + LOG_WRN("IV Update deferred because of pending transfer"); atomic_set_bit(bt_mesh.flags, BT_MESH_IVU_PENDING); return false; } if (iv_update) { bt_mesh.iv_index = iv_index; - BT_DBG("IV Update state entered. New index 0x%08x", - bt_mesh.iv_index); + LOG_DBG("IV Update state entered. New index 0x%08x", bt_mesh.iv_index); bt_mesh_rpl_reset(); ivi_was_recovered = false; } else { - BT_DBG("Normal mode entered"); + LOG_DBG("Normal mode entered"); bt_mesh.seq = 0U; } @@ -404,8 +403,8 @@ static void bt_mesh_net_local(struct k_work *work) .friend_match = 0U, }; - BT_DBG("src: 0x%04x dst: 0x%04x seq 0x%06x sub %p", rx.ctx.addr, - rx.ctx.addr, rx.seq, buf->sub); + LOG_DBG("src: 0x%04x dst: 0x%04x seq 0x%06x sub %p", rx.ctx.addr, rx.ctx.addr, + rx.seq, buf->sub); net_buf_simple_init_with_data(&sbuf, buf->data, buf->len); (void)bt_mesh_trans_recv(&sbuf, &rx); @@ -431,15 +430,15 @@ static int net_header_encode(struct bt_mesh_net_tx *tx, uint8_t nid, const bool ctl = (tx->ctx->app_idx == BT_MESH_KEY_UNUSED); if (ctl && net_buf_simple_tailroom(buf) < 8) { - BT_ERR("Insufficient MIC space for CTL PDU"); + LOG_ERR("Insufficient MIC space for CTL PDU"); return -EINVAL; } else if (net_buf_simple_tailroom(buf) < 4) { - BT_ERR("Insufficient MIC space for PDU"); + LOG_ERR("Insufficient MIC space for PDU"); return -EINVAL; } - BT_DBG("src 0x%04x dst 0x%04x ctl %u seq 0x%06x", - tx->src, tx->ctx->addr, ctl, bt_mesh.seq); + LOG_DBG("src 0x%04x dst 0x%04x ctl %u seq 0x%06x", tx->src, tx->ctx->addr, ctl, + bt_mesh.seq); net_buf_simple_push_be16(buf, tx->ctx->addr); net_buf_simple_push_be16(buf, tx->src); @@ -493,7 +492,7 @@ static int net_loopback(const struct bt_mesh_net_tx *tx, const uint8_t *data, err = k_mem_slab_alloc(&loopback_buf_pool, (void **)&buf, K_NO_WAIT); if (err) { - BT_WARN("Unable to allocate loopback"); + LOG_WRN("Unable to allocate loopback"); return -ENOMEM; } @@ -515,11 +514,10 @@ int bt_mesh_net_send(struct bt_mesh_net_tx *tx, struct net_buf *buf, const struct bt_mesh_net_cred *cred; int err; - BT_DBG("src 0x%04x dst 0x%04x len %u headroom %zu tailroom %zu", - tx->src, tx->ctx->addr, buf->len, net_buf_headroom(buf), - net_buf_tailroom(buf)); - BT_DBG("Payload len %u: %s", buf->len, bt_hex(buf->data, buf->len)); - BT_DBG("Seq 0x%06x", bt_mesh.seq); + LOG_DBG("src 0x%04x dst 0x%04x len %u headroom %zu tailroom %zu", tx->src, tx->ctx->addr, + buf->len, net_buf_headroom(buf), net_buf_tailroom(buf)); + LOG_DBG("Payload len %u: %s", buf->len, bt_hex(buf->data, buf->len)); + LOG_DBG("Seq 0x%06x", bt_mesh.seq); cred = net_tx_cred_get(tx); err = net_header_encode(tx, cred->nid, &buf->b); @@ -587,7 +585,7 @@ void bt_mesh_net_loopback_clear(uint16_t net_idx) sys_slist_t new_list; sys_snode_t *node; - BT_DBG("0x%04x", net_idx); + LOG_DBG("0x%04x", net_idx); sys_slist_init(&new_list); @@ -595,7 +593,7 @@ void bt_mesh_net_loopback_clear(uint16_t net_idx) struct loopback_buf *buf = CONTAINER_OF(node, struct loopback_buf, node); if (net_idx == BT_MESH_KEY_ANY || net_idx == buf->sub->net_idx) { - BT_DBG("Dropped 0x%06x", SEQ(buf->data)); + LOG_DBG("Dropped 0x%06x", SEQ(buf->data)); k_mem_slab_free(&loopback_buf_pool, (void **)&buf); } else { sys_slist_append(&new_list, &buf->node); @@ -615,8 +613,8 @@ static bool net_decrypt(struct bt_mesh_net_rx *rx, struct net_buf_simple *in, return false; } - BT_DBG("NID 0x%02x", NID(in->data)); - BT_DBG("IVI %u net->iv_index 0x%08x", IVI(in->data), bt_mesh.iv_index); + LOG_DBG("NID 0x%02x", NID(in->data)); + LOG_DBG("IVI %u net->iv_index 0x%08x", IVI(in->data), bt_mesh.iv_index); rx->old_iv = (IVI(in->data) != (bt_mesh.iv_index & 0x01)); @@ -630,21 +628,21 @@ static bool net_decrypt(struct bt_mesh_net_rx *rx, struct net_buf_simple *in, rx->ctx.addr = SRC(out->data); if (!BT_MESH_ADDR_IS_UNICAST(rx->ctx.addr)) { - BT_DBG("Ignoring non-unicast src addr 0x%04x", rx->ctx.addr); + LOG_DBG("Ignoring non-unicast src addr 0x%04x", rx->ctx.addr); return false; } if (bt_mesh_has_addr(rx->ctx.addr)) { - BT_DBG("Dropping locally originated packet"); + LOG_DBG("Dropping locally originated packet"); return false; } if (rx->net_if == BT_MESH_NET_IF_ADV && msg_cache_match(out)) { - BT_DBG("Duplicate found in Network Message Cache"); + LOG_DBG("Duplicate found in Network Message Cache"); return false; } - BT_DBG("src 0x%04x", rx->ctx.addr); + LOG_DBG("src 0x%04x", rx->ctx.addr); return bt_mesh_net_decrypt(cred->enc, out, BT_MESH_NET_IVI_RX(rx), proxy) == 0; @@ -685,8 +683,7 @@ static void bt_mesh_net_relay(struct net_buf_simple *sbuf, return; } - BT_DBG("TTL %u CTL %u dst 0x%04x", rx->ctx.recv_ttl, rx->ctl, - rx->ctx.recv_dst); + LOG_DBG("TTL %u CTL %u dst 0x%04x", rx->ctx.recv_ttl, rx->ctl, rx->ctx.recv_dst); /* The Relay Retransmit state is only applied to adv-adv relaying. * Anything else (like GATT to adv, or locally originated packets) @@ -701,7 +698,7 @@ static void bt_mesh_net_relay(struct net_buf_simple *sbuf, buf = bt_mesh_adv_create(BT_MESH_ADV_DATA, BT_MESH_RELAY_ADV, transmit, K_NO_WAIT); if (!buf) { - BT_DBG("Out of relay buffers"); + LOG_DBG("Out of relay buffers"); return; } @@ -713,7 +710,7 @@ static void bt_mesh_net_relay(struct net_buf_simple *sbuf, cred = &rx->sub->keys[SUBNET_KEY_TX_IDX(rx->sub)].msg; - BT_DBG("Relaying packet. TTL is now %u", TTL(buf->data)); + LOG_DBG("Relaying packet. TTL is now %u", TTL(buf->data)); /* Update NID if RX or RX was with friend credentials */ if (rx->friend_cred) { @@ -726,7 +723,7 @@ static void bt_mesh_net_relay(struct net_buf_simple *sbuf, * layer nonce includes the IVI. */ if (net_encrypt(&buf->b, cred, BT_MESH_NET_IVI_RX(rx), false)) { - BT_ERR("Re-encrypting failed"); + LOG_ERR("Re-encrypting failed"); goto done; } @@ -763,13 +760,13 @@ int bt_mesh_net_decode(struct net_buf_simple *in, enum bt_mesh_net_if net_if, struct bt_mesh_net_rx *rx, struct net_buf_simple *out) { if (in->len < BT_MESH_NET_MIN_PDU_LEN) { - BT_WARN("Dropping too short mesh packet (len %u)", in->len); - BT_WARN("%s", bt_hex(in->data, in->len)); + LOG_WRN("Dropping too short mesh packet (len %u)", in->len); + LOG_WRN("%s", bt_hex(in->data, in->len)); return -EINVAL; } if (in->len > BT_MESH_NET_MAX_PDU_LEN) { - BT_WARN("Dropping too long mesh packet (len %u)", in->len); + LOG_WRN("Dropping too long mesh packet (len %u)", in->len); return -EINVAL; } @@ -777,12 +774,12 @@ int bt_mesh_net_decode(struct net_buf_simple *in, enum bt_mesh_net_if net_if, return -EINVAL; } - BT_DBG("%u bytes: %s", in->len, bt_hex(in->data, in->len)); + LOG_DBG("%u bytes: %s", in->len, bt_hex(in->data, in->len)); rx->net_if = net_if; if (!bt_mesh_net_cred_find(rx, in, out, net_decrypt)) { - BT_DBG("Unable to find matching net for packet"); + LOG_DBG("Unable to find matching net for packet"); return -ENOENT; } @@ -802,17 +799,16 @@ int bt_mesh_net_decode(struct net_buf_simple *in, enum bt_mesh_net_if net_if, rx->seq = SEQ(out->data); rx->ctx.recv_dst = DST(out->data); - BT_DBG("Decryption successful. Payload len %u", out->len); + LOG_DBG("Decryption successful. Payload len %u", out->len); if (net_if != BT_MESH_NET_IF_PROXY_CFG && rx->ctx.recv_dst == BT_MESH_ADDR_UNASSIGNED) { - BT_ERR("Destination address is unassigned; dropping packet"); + LOG_ERR("Destination address is unassigned; dropping packet"); return -EBADMSG; } - BT_DBG("src 0x%04x dst 0x%04x ttl %u", rx->ctx.addr, rx->ctx.recv_dst, - rx->ctx.recv_ttl); - BT_DBG("PDU: %s", bt_hex(out->data, out->len)); + LOG_DBG("src 0x%04x dst 0x%04x ttl %u", rx->ctx.addr, rx->ctx.recv_dst, rx->ctx.recv_ttl); + LOG_DBG("PDU: %s", bt_hex(out->data, out->len)); msg_cache_add(rx); @@ -826,7 +822,7 @@ void bt_mesh_net_recv(struct net_buf_simple *data, int8_t rssi, struct bt_mesh_net_rx rx = { .ctx.recv_rssi = rssi }; struct net_buf_simple_state state; - BT_DBG("rssi %d net_if %u", rssi, net_if); + LOG_DBG("rssi %d net_if %u", rssi, net_if); if (!bt_mesh_is_provisioned()) { return; @@ -848,7 +844,7 @@ void bt_mesh_net_recv(struct net_buf_simple *data, int8_t rssi, if (bt_mesh_gatt_proxy_get() == BT_MESH_GATT_PROXY_DISABLED && !rx.local_match) { - BT_INFO("Proxy is disabled; ignoring message"); + LOG_INF("Proxy is disabled; ignoring message"); return; } } @@ -861,7 +857,7 @@ void bt_mesh_net_recv(struct net_buf_simple *data, int8_t rssi, * it again in the future. */ if (bt_mesh_trans_recv(&buf, &rx) == -EAGAIN) { - BT_WARN("Removing rejected message from Network Message Cache"); + LOG_WRN("Removing rejected message from Network Message Cache"); /* Rewind the next index now that we're not using this entry */ msg_cache[--msg_cache_next].src = BT_MESH_ADDR_UNASSIGNED; dup_cache[--dup_cache_next] = 0; @@ -886,10 +882,10 @@ static void ivu_refresh(struct k_work *work) bt_mesh.ivu_duration = MIN(UINT8_MAX, bt_mesh.ivu_duration + BT_MESH_IVU_HOURS); - BT_DBG("%s for %u hour%s", - atomic_test_bit(bt_mesh.flags, BT_MESH_IVU_IN_PROGRESS) ? - "IVU in Progress" : "IVU Normal mode", - bt_mesh.ivu_duration, bt_mesh.ivu_duration == 1U ? "" : "s"); + LOG_DBG("%s for %u hour%s", + atomic_test_bit(bt_mesh.flags, BT_MESH_IVU_IN_PROGRESS) ? "IVU in Progress" + : "IVU Normal mode", + bt_mesh.ivu_duration, bt_mesh.ivu_duration == 1U ? "" : "s"); if (bt_mesh.ivu_duration < BT_MESH_IVU_MIN_HOURS) { if (IS_ENABLED(CONFIG_BT_SETTINGS)) { @@ -932,7 +928,7 @@ static int net_set(const char *name, size_t len_rd, settings_read_cb read_cb, int err; if (len_rd == 0) { - BT_DBG("val (null)"); + LOG_DBG("val (null)"); bt_mesh_comp_unprovision(); (void)memset(bt_mesh.dev_key, 0, sizeof(bt_mesh.dev_key)); @@ -941,15 +937,15 @@ static int net_set(const char *name, size_t len_rd, settings_read_cb read_cb, err = bt_mesh_settings_set(read_cb, cb_arg, &net, sizeof(net)); if (err) { - BT_ERR("Failed to set \'net\'"); + LOG_ERR("Failed to set \'net\'"); return err; } memcpy(bt_mesh.dev_key, net.dev_key, sizeof(bt_mesh.dev_key)); bt_mesh_comp_provision(net.primary_addr); - BT_DBG("Provisioned with primary address 0x%04x", net.primary_addr); - BT_DBG("Recovered DevKey %s", bt_hex(bt_mesh.dev_key, 16)); + LOG_DBG("Provisioned with primary address 0x%04x", net.primary_addr); + LOG_DBG("Recovered DevKey %s", bt_hex(bt_mesh.dev_key, 16)); return 0; } @@ -963,7 +959,7 @@ static int iv_set(const char *name, size_t len_rd, settings_read_cb read_cb, int err; if (len_rd == 0) { - BT_DBG("IV deleted"); + LOG_DBG("IV deleted"); bt_mesh.iv_index = 0U; atomic_clear_bit(bt_mesh.flags, BT_MESH_IVU_IN_PROGRESS); @@ -972,7 +968,7 @@ static int iv_set(const char *name, size_t len_rd, settings_read_cb read_cb, err = bt_mesh_settings_set(read_cb, cb_arg, &iv, sizeof(iv)); if (err) { - BT_ERR("Failed to set \'iv\'"); + LOG_ERR("Failed to set \'iv\'"); return err; } @@ -980,8 +976,8 @@ static int iv_set(const char *name, size_t len_rd, settings_read_cb read_cb, atomic_set_bit_to(bt_mesh.flags, BT_MESH_IVU_IN_PROGRESS, iv.iv_update); bt_mesh.ivu_duration = iv.iv_duration; - BT_DBG("IV Index 0x%04x (IV Update Flag %u) duration %u hours", - iv.iv_index, iv.iv_update, iv.iv_duration); + LOG_DBG("IV Index 0x%04x (IV Update Flag %u) duration %u hours", iv.iv_index, iv.iv_update, + iv.iv_duration); return 0; } @@ -995,7 +991,7 @@ static int seq_set(const char *name, size_t len_rd, settings_read_cb read_cb, int err; if (len_rd == 0) { - BT_DBG("val (null)"); + LOG_DBG("val (null)"); bt_mesh.seq = 0U; return 0; @@ -1003,7 +999,7 @@ static int seq_set(const char *name, size_t len_rd, settings_read_cb read_cb, err = bt_mesh_settings_set(read_cb, cb_arg, &seq, sizeof(seq)); if (err) { - BT_ERR("Failed to set \'seq\'"); + LOG_ERR("Failed to set \'seq\'"); return err; } @@ -1019,7 +1015,7 @@ static int seq_set(const char *name, size_t len_rd, settings_read_cb read_cb, bt_mesh.seq--; } - BT_DBG("Sequence Number 0x%06x", bt_mesh.seq); + LOG_DBG("Sequence Number 0x%06x", bt_mesh.seq); return 0; } @@ -1032,9 +1028,9 @@ static void clear_iv(void) err = settings_delete("bt/mesh/IV"); if (err) { - BT_ERR("Failed to clear IV"); + LOG_ERR("Failed to clear IV"); } else { - BT_DBG("Cleared IV"); + LOG_DBG("Cleared IV"); } } @@ -1049,9 +1045,9 @@ static void store_pending_iv(void) err = settings_save_one("bt/mesh/IV", &iv, sizeof(iv)); if (err) { - BT_ERR("Failed to store IV value"); + LOG_ERR("Failed to store IV value"); } else { - BT_DBG("Stored IV value"); + LOG_DBG("Stored IV value"); } } @@ -1070,9 +1066,9 @@ static void clear_net(void) err = settings_delete("bt/mesh/Net"); if (err) { - BT_ERR("Failed to clear Network"); + LOG_ERR("Failed to clear Network"); } else { - BT_DBG("Cleared Network"); + LOG_DBG("Cleared Network"); } } @@ -1081,17 +1077,16 @@ static void store_pending_net(void) struct net_val net; int err; - BT_DBG("addr 0x%04x DevKey %s", bt_mesh_primary_addr(), - bt_hex(bt_mesh.dev_key, 16)); + LOG_DBG("addr 0x%04x DevKey %s", bt_mesh_primary_addr(), bt_hex(bt_mesh.dev_key, 16)); net.primary_addr = bt_mesh_primary_addr(); memcpy(net.dev_key, bt_mesh.dev_key, 16); err = settings_save_one("bt/mesh/Net", &net, sizeof(net)); if (err) { - BT_ERR("Failed to store Network value"); + LOG_ERR("Failed to store Network value"); } else { - BT_DBG("Stored Network value"); + LOG_DBG("Stored Network value"); } } @@ -1114,16 +1109,16 @@ void bt_mesh_net_pending_seq_store(void) err = settings_save_one("bt/mesh/Seq", &seq, sizeof(seq)); if (err) { - BT_ERR("Failed to stor Seq value"); + LOG_ERR("Failed to stor Seq value"); } else { - BT_DBG("Stored Seq value"); + LOG_DBG("Stored Seq value"); } } else { err = settings_delete("bt/mesh/Seq"); if (err) { - BT_ERR("Failed to clear Seq value"); + LOG_ERR("Failed to clear Seq value"); } else { - BT_DBG("Cleared Seq value"); + LOG_DBG("Cleared Seq value"); } } } diff --git a/subsys/bluetooth/mesh/pb_adv.c b/subsys/bluetooth/mesh/pb_adv.c index b745ca0bb8e..7666374167c 100644 --- a/subsys/bluetooth/mesh/pb_adv.c +++ b/subsys/bluetooth/mesh/pb_adv.c @@ -17,11 +17,12 @@ #include "host/ecc.h" #include "prov.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_PROV) -#define LOG_MODULE_NAME bt_mesh_pb_adv -#include "common/log.h" #include "common/bt_str.h" +#define LOG_LEVEL CONFIG_BT_MESH_PROV_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_mesh_pb_adv); + #define GPCF(gpc) (gpc & 0x03) #define GPC_START(last_seg) (((last_seg) << 2) | 0x00) #define GPC_ACK 0x01 @@ -186,7 +187,7 @@ static uint8_t next_transaction_id(uint8_t id) static void prov_clear_tx(void) { - BT_DBG(""); + LOG_DBG(""); /* If this fails, the work handler will not find any buffers to send, * and return without rescheduling. The work handler also checks the @@ -200,7 +201,7 @@ static void prov_clear_tx(void) static void reset_adv_link(void) { - BT_DBG(""); + LOG_DBG(""); prov_clear_tx(); /* If this fails, the work handler will exit early on the LINK_ACTIVE @@ -250,7 +251,7 @@ static struct net_buf *adv_buf_create(uint8_t retransmits) BT_MESH_TRANSMIT(retransmits, 20), BUF_TIMEOUT); if (!buf) { - BT_ERR("Out of provisioning buffers"); + LOG_ERR("Out of provisioning buffers"); return NULL; } @@ -259,7 +260,7 @@ static struct net_buf *adv_buf_create(uint8_t retransmits) static void ack_complete(uint16_t duration, int err, void *user_data) { - BT_DBG("xact 0x%x complete", (uint8_t)link.tx.pending_ack); + LOG_DBG("xact 0x%x complete", (uint8_t)link.tx.pending_ack); atomic_clear_bit(link.flags, ADV_ACK_PENDING); } @@ -270,7 +271,7 @@ static bool ack_pending(void) static void prov_failed(uint8_t err) { - BT_DBG("%u", err); + LOG_DBG("%u", err); link.cb->error(&bt_mesh_pb_adv, link.cb_data, err); atomic_set_bit(link.flags, ADV_LINK_INVALID); } @@ -280,15 +281,14 @@ static void prov_msg_recv(void) k_work_reschedule(&link.prot_timer, PROTOCOL_TIMEOUT); if (!bt_mesh_fcs_check(link.rx.buf, link.rx.fcs)) { - BT_ERR("Incorrect FCS"); + LOG_ERR("Incorrect FCS"); return; } gen_prov_ack_send(link.rx.id); if (atomic_test_bit(link.flags, ADV_LINK_INVALID)) { - BT_WARN("Unexpected msg 0x%02x on invalidated link", - link.rx.buf->data[0]); + LOG_WRN("Unexpected msg 0x%02x on invalidated link", link.rx.buf->data[0]); prov_failed(PROV_ERR_UNEXP_PDU); return; } @@ -302,7 +302,7 @@ static void protocol_timeout(struct k_work *work) return; } - BT_DBG(""); + LOG_DBG(""); link.rx.seg = 0U; prov_link_close(PROV_BEARER_LINK_STATUS_TIMEOUT); @@ -320,10 +320,10 @@ static void gen_prov_ack_send(uint8_t xact_id) struct net_buf *buf; bool pending = atomic_test_and_set_bit(link.flags, ADV_ACK_PENDING); - BT_DBG("xact_id 0x%x", xact_id); + LOG_DBG("xact_id 0x%x", xact_id); if (pending && link.tx.pending_ack == xact_id) { - BT_DBG("Not sending duplicate ack"); + LOG_DBG("Not sending duplicate ack"); return; } @@ -352,11 +352,11 @@ static void gen_prov_cont(struct prov_rx *rx, struct net_buf_simple *buf) { uint8_t seg = CONT_SEG_INDEX(rx->gpc); - BT_DBG("len %u, seg_index %u", buf->len, seg); + LOG_DBG("len %u, seg_index %u", buf->len, seg); if (!link.rx.seg && link.rx.id == rx->xact_id) { if (!ack_pending()) { - BT_DBG("Resending ack"); + LOG_DBG("Resending ack"); gen_prov_ack_send(rx->xact_id); } @@ -365,7 +365,7 @@ static void gen_prov_cont(struct prov_rx *rx, struct net_buf_simple *buf) if (!link.rx.seg && next_transaction_id(link.rx.id) == rx->xact_id) { - BT_DBG("Start segment lost"); + LOG_DBG("Start segment lost"); link.rx.id = rx->xact_id; @@ -376,24 +376,23 @@ static void gen_prov_cont(struct prov_rx *rx, struct net_buf_simple *buf) prov_clear_tx(); } else if (rx->xact_id != link.rx.id) { - BT_WARN("Data for unknown transaction (0x%x != 0x%x)", - rx->xact_id, link.rx.id); + LOG_WRN("Data for unknown transaction (0x%x != 0x%x)", rx->xact_id, link.rx.id); return; } if (seg > link.rx.last_seg) { - BT_ERR("Invalid segment index %u", seg); + LOG_ERR("Invalid segment index %u", seg); prov_failed(PROV_ERR_NVAL_FMT); return; } if (!(link.rx.seg & BIT(seg))) { - BT_DBG("Ignoring already received segment"); + LOG_DBG("Ignoring already received segment"); return; } if (XACT_SEG_OFFSET(seg) + buf->len > RX_BUFFER_MAX) { - BT_WARN("Rx buffer overflow. Malformed generic prov frame?"); + LOG_WRN("Rx buffer overflow. Malformed generic prov frame?"); return; } @@ -406,8 +405,7 @@ static void gen_prov_cont(struct prov_rx *rx, struct net_buf_simple *buf) expect_len = (link.rx.buf->len - 20U - ((link.rx.last_seg - 1) * 23U)); if (expect_len != buf->len) { - BT_ERR("Incorrect last seg len: %u != %u", expect_len, - buf->len); + LOG_ERR("Incorrect last seg len: %u != %u", expect_len, buf->len); prov_failed(PROV_ERR_NVAL_FMT); return; } @@ -420,7 +418,7 @@ static void gen_prov_cont(struct prov_rx *rx, struct net_buf_simple *buf) static void gen_prov_ack(struct prov_rx *rx, struct net_buf_simple *buf) { - BT_DBG("len %u", buf->len); + LOG_DBG("len %u", buf->len); if (!link.tx.buf[0]) { return; @@ -445,7 +443,7 @@ static void gen_prov_start(struct prov_rx *rx, struct net_buf_simple *buf) if (rx->xact_id == link.rx.id) { if (!link.rx.seg) { if (!ack_pending()) { - BT_DBG("Resending ack"); + LOG_DBG("Resending ack"); gen_prov_ack_send(rx->xact_id); } @@ -453,11 +451,11 @@ static void gen_prov_start(struct prov_rx *rx, struct net_buf_simple *buf) } if (!(link.rx.seg & BIT(0))) { - BT_DBG("Ignoring duplicate segment"); + LOG_DBG("Ignoring duplicate segment"); return; } } else if (rx->xact_id != next_transaction_id(link.rx.id)) { - BT_WARN("Unexpected xact 0x%x, expected 0x%x", rx->xact_id, + LOG_WRN("Unexpected xact 0x%x, expected 0x%x", rx->xact_id, next_transaction_id(link.rx.id)); return; } @@ -467,31 +465,30 @@ static void gen_prov_start(struct prov_rx *rx, struct net_buf_simple *buf) link.rx.id = rx->xact_id; link.rx.fcs = net_buf_simple_pull_u8(buf); - BT_DBG("len %u last_seg %u total_len %u fcs 0x%02x", buf->len, - START_LAST_SEG(rx->gpc), link.rx.buf->len, link.rx.fcs); + LOG_DBG("len %u last_seg %u total_len %u fcs 0x%02x", buf->len, START_LAST_SEG(rx->gpc), + link.rx.buf->len, link.rx.fcs); if (link.rx.buf->len < 1) { - BT_ERR("Ignoring zero-length provisioning PDU"); + LOG_ERR("Ignoring zero-length provisioning PDU"); prov_failed(PROV_ERR_NVAL_FMT); return; } if (link.rx.buf->len > link.rx.buf->size) { - BT_ERR("Too large provisioning PDU (%u bytes)", - link.rx.buf->len); + LOG_ERR("Too large provisioning PDU (%u bytes)", link.rx.buf->len); prov_failed(PROV_ERR_NVAL_FMT); return; } if (START_LAST_SEG(rx->gpc) > 0 && link.rx.buf->len <= 20U) { - BT_ERR("Too small total length for multi-segment PDU"); + LOG_ERR("Too small total length for multi-segment PDU"); prov_failed(PROV_ERR_NVAL_FMT); return; } if (START_LAST_SEG(rx->gpc) != last_seg(link.rx.buf->len)) { - BT_ERR("Invalid SegN (%u, calculated %u)", START_LAST_SEG(rx->gpc), - last_seg(link.rx.buf->len)); + LOG_ERR("Invalid SegN (%u, calculated %u)", START_LAST_SEG(rx->gpc), + last_seg(link.rx.buf->len)); prov_failed(PROV_ERR_NVAL_FMT); return; } @@ -502,7 +499,7 @@ static void gen_prov_start(struct prov_rx *rx, struct net_buf_simple *buf) if ((link.rx.seg & BIT(0)) && (find_msb_set((~link.rx.seg) & SEG_NVAL) - 1 > link.rx.last_seg)) { - BT_ERR("Invalid segment index %u", seg); + LOG_ERR("Invalid segment index %u", seg); prov_failed(PROV_ERR_NVAL_FMT); return; } @@ -522,7 +519,7 @@ static void gen_prov_start(struct prov_rx *rx, struct net_buf_simple *buf) static void gen_prov_ctl(struct prov_rx *rx, struct net_buf_simple *buf) { - BT_DBG("op 0x%02x len %u", BEARER_CTL(rx->gpc), buf->len); + LOG_DBG("op 0x%02x len %u", BEARER_CTL(rx->gpc), buf->len); switch (BEARER_CTL(rx->gpc)) { case LINK_OPEN: @@ -543,7 +540,7 @@ static void gen_prov_ctl(struct prov_rx *rx, struct net_buf_simple *buf) link_close(rx, buf); break; default: - BT_ERR("Unknown bearer opcode: 0x%02x", BEARER_CTL(rx->gpc)); + LOG_ERR("Unknown bearer opcode: 0x%02x", BEARER_CTL(rx->gpc)); if (IS_ENABLED(CONFIG_BT_TESTING)) { bt_test_mesh_prov_invalid_bearer(BEARER_CTL(rx->gpc)); @@ -567,13 +564,13 @@ static const struct { static void gen_prov_recv(struct prov_rx *rx, struct net_buf_simple *buf) { if (buf->len < gen_prov[GPCF(rx->gpc)].min_len) { - BT_ERR("Too short GPC message type %u", GPCF(rx->gpc)); + LOG_ERR("Too short GPC message type %u", GPCF(rx->gpc)); return; } if (!atomic_test_bit(link.flags, ADV_LINK_ACTIVE) && gen_prov[GPCF(rx->gpc)].require_link) { - BT_DBG("Ignoring message that requires active link"); + LOG_DBG("Ignoring message that requires active link"); return; } @@ -599,7 +596,7 @@ static void send_reliable(void) continue; } - BT_DBG("%u bytes: %s", buf->len, bt_hex(buf->data, buf->len)); + LOG_DBG("%u bytes: %s", buf->len, bt_hex(buf->data, buf->len)); bt_mesh_adv_send(buf, NULL, NULL); } @@ -609,15 +606,15 @@ static void send_reliable(void) static void prov_retransmit(struct k_work *work) { - BT_DBG(""); + LOG_DBG(""); if (!atomic_test_bit(link.flags, ADV_LINK_ACTIVE)) { - BT_WARN("Link not active"); + LOG_WRN("Link not active"); return; } if (k_uptime_get() - link.tx.start > TRANSACTION_TIMEOUT) { - BT_WARN("Giving up transaction"); + LOG_WRN("Giving up transaction"); prov_link_close(PROV_BEARER_LINK_STATUS_FAIL); return; } @@ -630,7 +627,7 @@ static struct net_buf *ctl_buf_create(uint8_t op, const void *data, uint8_t data { struct net_buf *buf; - BT_DBG("op 0x%02x data_len %u", op, data_len); + LOG_DBG("op 0x%02x data_len %u", op, data_len); buf = adv_buf_create(retransmits); if (!buf) { @@ -704,17 +701,17 @@ static int prov_send_adv(struct net_buf_simple *msg, link.tx.cb_data = cb_data; link.tx.start = k_uptime_get(); - BT_DBG("xact_id: 0x%x len: %u", link.tx.id, msg->len); + LOG_DBG("xact_id: 0x%x len: %u", link.tx.id, msg->len); seg_len = MIN(msg->len, START_PAYLOAD_MAX); - BT_DBG("seg 0 len %u: %s", seg_len, bt_hex(msg->data, seg_len)); + LOG_DBG("seg 0 len %u: %s", seg_len, bt_hex(msg->data, seg_len)); net_buf_add_mem(start, msg->data, seg_len); net_buf_simple_pull(msg, seg_len); buf = start; for (seg_id = 1U; msg->len > 0; seg_id++) { if (seg_id >= ARRAY_SIZE(link.tx.buf)) { - BT_ERR("Too big message"); + LOG_ERR("Too big message"); free_segments(); return -E2BIG; } @@ -729,8 +726,7 @@ static int prov_send_adv(struct net_buf_simple *msg, seg_len = MIN(msg->len, CONT_PAYLOAD_MAX); - BT_DBG("seg %u len %u: %s", seg_id, seg_len, - bt_hex(msg->data, seg_len)); + LOG_DBG("seg %u len %u: %s", seg_id, seg_len, bt_hex(msg->data, seg_len)); net_buf_add_be32(buf, link.id); net_buf_add_u8(buf, link.tx.id); @@ -752,28 +748,28 @@ static void link_open(struct prov_rx *rx, struct net_buf_simple *buf) { int err; - BT_DBG("len %u", buf->len); + LOG_DBG("len %u", buf->len); if (buf->len < 16) { - BT_ERR("Too short bearer open message (len %u)", buf->len); + LOG_ERR("Too short bearer open message (len %u)", buf->len); return; } if (atomic_test_bit(link.flags, ADV_LINK_ACTIVE)) { /* Send another link ack if the provisioner missed the last */ if (link.id != rx->link_id) { - BT_DBG("Ignoring bearer open: link already active"); + LOG_DBG("Ignoring bearer open: link already active"); return; } - BT_DBG("Resending link ack"); + LOG_DBG("Resending link ack"); /* Ignore errors, message will be attempted again if we keep receiving link open: */ (void)bearer_ctl_send_unacked(ctl_buf_create(LINK_ACK, NULL, 0, RETRANSMITS_ACK)); return; } if (memcmp(buf->data, bt_mesh_prov_get()->uuid, 16)) { - BT_DBG("Bearer open message not for us"); + LOG_DBG("Bearer open message not for us"); return; } @@ -792,7 +788,7 @@ static void link_open(struct prov_rx *rx, struct net_buf_simple *buf) static void link_ack(struct prov_rx *rx, struct net_buf_simple *buf) { - BT_DBG("len %u", buf->len); + LOG_DBG("len %u", buf->len); if (atomic_test_bit(link.flags, ADV_PROVISIONER)) { if (atomic_test_and_set_bit(link.flags, ADV_LINK_ACK_RECVD)) { @@ -807,7 +803,7 @@ static void link_ack(struct prov_rx *rx, struct net_buf_simple *buf) static void link_close(struct prov_rx *rx, struct net_buf_simple *buf) { - BT_DBG("len %u", buf->len); + LOG_DBG("len %u", buf->len); if (buf->len != 1) { return; @@ -829,7 +825,7 @@ void bt_mesh_pb_adv_recv(struct net_buf_simple *buf) } if (buf->len < 6) { - BT_WARN("Too short provisioning packet (len %u)", buf->len); + LOG_WRN("Too short provisioning packet (len %u)", buf->len); return; } @@ -841,7 +837,7 @@ void bt_mesh_pb_adv_recv(struct net_buf_simple *buf) return; } - BT_DBG("link_id 0x%08x xact_id 0x%x", rx.link_id, rx.xact_id); + LOG_DBG("link_id 0x%08x xact_id 0x%x", rx.link_id, rx.xact_id); gen_prov_recv(&rx, buf); } @@ -851,11 +847,11 @@ static int prov_link_open(const uint8_t uuid[16], k_timeout_t timeout, { int err; - BT_DBG("uuid %s", bt_hex(uuid, 16)); + LOG_DBG("uuid %s", bt_hex(uuid, 16)); err = bt_mesh_adv_enable(); if (err) { - BT_ERR("Failed enabling advertiser"); + LOG_ERR("Failed enabling advertiser"); return err; } @@ -882,7 +878,7 @@ static int prov_link_accept(const struct prov_bearer_cb *cb, void *cb_data) err = bt_mesh_adv_enable(); if (err) { - BT_ERR("Failed enabling advertiser"); + LOG_ERR("Failed enabling advertiser"); return err; } diff --git a/subsys/bluetooth/mesh/pb_gatt.c b/subsys/bluetooth/mesh/pb_gatt.c index fe2f340ef20..958ee6abae8 100644 --- a/subsys/bluetooth/mesh/pb_gatt.c +++ b/subsys/bluetooth/mesh/pb_gatt.c @@ -16,11 +16,14 @@ #include "pb_gatt_srv.h" #include "pb_gatt_cli.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_PROV) -#define LOG_MODULE_NAME bt_mesh_pb_gatt -#include "common/log.h" +#include + #include "common/bt_str.h" +#define LOG_LEVEL CONFIG_BT_MESH_PROV_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_mesh_pb_gatt); + struct prov_bearer_send_cb { prov_bearer_send_complete_t cb; void *cb_data; @@ -74,22 +77,22 @@ static void protocol_timeout(struct k_work *work) } } - BT_DBG("Protocol timeout"); + LOG_DBG("Protocol timeout"); link_closed(PROV_BEARER_LINK_STATUS_TIMEOUT); } int bt_mesh_pb_gatt_recv(struct bt_conn *conn, struct net_buf_simple *buf) { - BT_DBG("%u bytes: %s", buf->len, bt_hex(buf->data, buf->len)); + LOG_DBG("%u bytes: %s", buf->len, bt_hex(buf->data, buf->len)); if (link.conn != conn || !link.cb) { - BT_WARN("Data for unexpected connection"); + LOG_WRN("Data for unexpected connection"); return -ENOTCONN; } if (buf->len < 1) { - BT_WARN("Too short provisioning packet (len %u)", buf->len); + LOG_WRN("Too short provisioning packet (len %u)", buf->len); return -EINVAL; } @@ -102,7 +105,7 @@ int bt_mesh_pb_gatt_recv(struct bt_conn *conn, struct net_buf_simple *buf) int bt_mesh_pb_gatt_start(struct bt_conn *conn) { - BT_DBG("conn %p", (void *)conn); + LOG_DBG("conn %p", (void *)conn); if (link.conn) { return -EBUSY; @@ -118,10 +121,10 @@ int bt_mesh_pb_gatt_start(struct bt_conn *conn) int bt_mesh_pb_gatt_close(struct bt_conn *conn) { - BT_DBG("conn %p", (void *)conn); + LOG_DBG("conn %p", (void *)conn); if (link.conn != conn) { - BT_DBG("Not connected"); + LOG_DBG("Not connected"); return -ENOTCONN; } @@ -133,7 +136,7 @@ int bt_mesh_pb_gatt_close(struct bt_conn *conn) #if defined(CONFIG_BT_MESH_PB_GATT_CLIENT) int bt_mesh_pb_gatt_cli_start(struct bt_conn *conn) { - BT_DBG("conn %p", (void *)conn); + LOG_DBG("conn %p", (void *)conn); if (link.conn) { return -EBUSY; @@ -147,10 +150,10 @@ int bt_mesh_pb_gatt_cli_start(struct bt_conn *conn) int bt_mesh_pb_gatt_cli_open(struct bt_conn *conn) { - BT_DBG("conn %p", (void *)conn); + LOG_DBG("conn %p", (void *)conn); if (link.conn != conn) { - BT_DBG("Not connected"); + LOG_DBG("Not connected"); return -ENOTCONN; } @@ -162,7 +165,7 @@ int bt_mesh_pb_gatt_cli_open(struct bt_conn *conn) static int prov_link_open(const uint8_t uuid[16], k_timeout_t timeout, const struct prov_bearer_cb *cb, void *cb_data) { - BT_DBG("uuid %s", bt_hex(uuid, 16)); + LOG_DBG("uuid %s", bt_hex(uuid, 16)); link.cb = cb; link.cb_data = cb_data; @@ -185,7 +188,7 @@ static int link_accept(const struct prov_bearer_cb *cb, void *cb_data) err = bt_mesh_adv_enable(); if (err) { - BT_ERR("Failed enabling advertiser"); + LOG_ERR("Failed enabling advertiser"); return err; } diff --git a/subsys/bluetooth/mesh/pb_gatt_cli.c b/subsys/bluetooth/mesh/pb_gatt_cli.c index c6cc7eb1865..28dbe8d5044 100644 --- a/subsys/bluetooth/mesh/pb_gatt_cli.c +++ b/subsys/bluetooth/mesh/pb_gatt_cli.c @@ -15,10 +15,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_PROV) -#define LOG_MODULE_NAME bt_mesh_pb_gatt_client -#include "common/log.h" - #include "mesh.h" #include "adv.h" #include "net.h" @@ -34,6 +30,10 @@ #include "gatt_cli.h" #include "proxy_msg.h" +#define LOG_LEVEL CONFIG_BT_MESH_PROV_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_mesh_pb_gatt_client); + static struct { const uint8_t *target; struct bt_mesh_proxy_role *srv; @@ -43,11 +43,11 @@ static void pb_gatt_msg_recv(struct bt_mesh_proxy_role *role) { switch (role->msg_type) { case BT_MESH_PROXY_PROV: - BT_DBG("Mesh Provisioning PDU"); + LOG_DBG("Mesh Provisioning PDU"); bt_mesh_pb_gatt_recv(role->conn, &role->buf); break; default: - BT_WARN("Unhandled Message Type 0x%02x", role->msg_type); + LOG_WRN("Unhandled Message Type 0x%02x", role->msg_type); break; } } diff --git a/subsys/bluetooth/mesh/pb_gatt_srv.c b/subsys/bluetooth/mesh/pb_gatt_srv.c index 8dbe7eb0fa3..87905649491 100644 --- a/subsys/bluetooth/mesh/pb_gatt_srv.c +++ b/subsys/bluetooth/mesh/pb_gatt_srv.c @@ -14,9 +14,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_PROV) -#define LOG_MODULE_NAME bt_mesh_pb_gatt_srv -#include "common/log.h" #include "common/bt_str.h" #include "mesh.h" @@ -34,6 +31,10 @@ #include "proxy_msg.h" #include "pb_gatt_srv.h" +#define LOG_LEVEL CONFIG_BT_MESH_PROV_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_mesh_pb_gatt_srv); + #if defined(CONFIG_BT_MESH_PB_GATT_USE_DEVICE_NAME) #define ADV_OPT_USE_NAME BT_LE_ADV_OPT_USE_NAME #else @@ -60,12 +61,12 @@ static void proxy_msg_recv(struct bt_mesh_proxy_role *role) { switch (role->msg_type) { case BT_MESH_PROXY_PROV: - BT_DBG("Mesh Provisioning PDU"); + LOG_DBG("Mesh Provisioning PDU"); bt_mesh_pb_gatt_recv(role->conn, &role->buf); break; default: - BT_WARN("Unhandled Message Type 0x%02x", role->msg_type); + LOG_WRN("Unhandled Message Type 0x%02x", role->msg_type); break; } } @@ -77,17 +78,17 @@ static ssize_t gatt_recv(struct bt_conn *conn, const uint8_t *data = buf; if (cli->conn != conn) { - BT_ERR("No PB-GATT Client found"); + LOG_ERR("No PB-GATT Client found"); return -ENOTCONN; } if (len < 1) { - BT_WARN("Too small Proxy PDU"); + LOG_WRN("Too small Proxy PDU"); return -EINVAL; } if (PDU_TYPE(data) != BT_MESH_PROXY_PROV) { - BT_WARN("Proxy PDU type doesn't match GATT service"); + LOG_WRN("Proxy PDU type doesn't match GATT service"); return -EINVAL; } @@ -106,7 +107,7 @@ static void gatt_connected(struct bt_conn *conn, uint8_t err) cli = bt_mesh_proxy_role_setup(conn, gatt_send, proxy_msg_recv); - BT_DBG("conn %p err 0x%02x", (void *)conn, err); + LOG_DBG("conn %p err 0x%02x", (void *)conn, err); } static void gatt_disconnected(struct bt_conn *conn, uint8_t reason) @@ -131,21 +132,21 @@ static void gatt_disconnected(struct bt_conn *conn, uint8_t reason) static void prov_ccc_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("value 0x%04x", value); + LOG_DBG("value 0x%04x", value); } static ssize_t prov_ccc_write(struct bt_conn *conn, const struct bt_gatt_attr *attr, uint16_t value) { if (cli->conn != conn) { - BT_ERR("No PB-GATT Client found"); + LOG_ERR("No PB-GATT Client found"); return -ENOTCONN; } - BT_DBG("value 0x%04x", value); + LOG_DBG("value 0x%04x", value); if (value != BT_GATT_CCC_NOTIFY) { - BT_WARN("Client wrote 0x%04x instead enabling notify", value); + LOG_WRN("Client wrote 0x%04x instead enabling notify", value); return BT_GATT_ERR(BT_ATT_ERR_VALUE_NOT_ALLOWED); } @@ -177,7 +178,7 @@ static struct bt_gatt_service prov_svc = BT_GATT_SERVICE(prov_attrs); int bt_mesh_pb_gatt_srv_enable(void) { - BT_DBG(""); + LOG_DBG(""); if (bt_mesh_is_provisioned()) { return -ENOTSUP; @@ -196,7 +197,7 @@ int bt_mesh_pb_gatt_srv_enable(void) int bt_mesh_pb_gatt_srv_disable(void) { - BT_DBG(""); + LOG_DBG(""); if (!service_registered) { return -EALREADY; @@ -236,7 +237,7 @@ static size_t gatt_prov_adv_create(struct bt_data prov_sd[1]) uri_len = strlen(prov->uri); if (uri_len > 29) { /* There's no way to shorten an URI */ - BT_WARN("Too long URI to fit advertising packet"); + LOG_WRN("Too long URI to fit advertising packet"); return 0; } @@ -251,7 +252,7 @@ static int gatt_send(struct bt_conn *conn, const void *data, uint16_t len, bt_gatt_complete_func_t end, void *user_data) { - BT_DBG("%u bytes: %s", len, bt_hex(data, len)); + LOG_DBG("%u bytes: %s", len, bt_hex(data, len)); struct bt_gatt_notify_params params = { .data = data, @@ -266,7 +267,7 @@ static int gatt_send(struct bt_conn *conn, int bt_mesh_pb_gatt_srv_adv_start(void) { - BT_DBG(""); + LOG_DBG(""); if (!service_registered || bt_mesh_is_provisioned() || !bt_mesh_proxy_has_avail_conn()) { @@ -294,7 +295,7 @@ int bt_mesh_pb_gatt_srv_adv_start(void) ARRAY_SIZE(prov_ad), prov_sd, prov_sd_len); } - BT_DBG("remaining fast adv time (%lld ms)", (FAST_ADV_TIME - elapsed_time)); + LOG_DBG("remaining fast adv time (%lld ms)", (FAST_ADV_TIME - elapsed_time)); /* Advertise 60 seconds using fast interval */ return bt_mesh_adv_gatt_start(&fast_adv_param, (FAST_ADV_TIME - elapsed_time), prov_ad, ARRAY_SIZE(prov_ad), diff --git a/subsys/bluetooth/mesh/prov.c b/subsys/bluetooth/mesh/prov.c index db4e33bb126..89f68f863d6 100644 --- a/subsys/bluetooth/mesh/prov.c +++ b/subsys/bluetooth/mesh/prov.c @@ -17,10 +17,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_PROV) -#define LOG_MODULE_NAME bt_mesh_prov -#include "common/log.h" - #include "host/ecc.h" #include "host/testing.h" @@ -31,6 +27,10 @@ #include "foundation.h" #include "prov.h" +#define LOG_LEVEL CONFIG_BT_MESH_PROV_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_mesh_prov); + struct bt_mesh_prov_link bt_mesh_prov_link; const struct bt_mesh_prov *bt_mesh_prov; @@ -41,11 +41,11 @@ BUILD_ASSERT(sizeof(bt_mesh_prov_link.conf_inputs) == 145, static void pub_key_ready(const uint8_t *pkey) { if (!pkey) { - BT_WARN("Public key not available"); + LOG_WRN("Public key not available"); return; } - BT_DBG("Local public key ready"); + LOG_DBG("Local public key ready"); } int bt_mesh_prov_reset_state(void (*func)(const uint8_t key[BT_PUB_KEY_LEN])) @@ -67,7 +67,7 @@ int bt_mesh_prov_reset_state(void (*func)(const uint8_t key[BT_PUB_KEY_LEN])) err = bt_pub_key_gen(&pub_key_cb); if (err) { - BT_ERR("Failed to generate public key (%d)", err); + LOG_ERR("Failed to generate public key (%d)", err); return err; } return 0; @@ -287,7 +287,7 @@ int bt_mesh_prov_auth(bool is_provisioner, uint8_t method, uint8_t action, uint8 int bt_mesh_input_number(uint32_t num) { - BT_DBG("%u", num); + LOG_DBG("%u", num); if (!atomic_test_and_clear_bit(bt_mesh_prov_link.flags, WAIT_NUMBER)) { return -EINVAL; @@ -302,7 +302,7 @@ int bt_mesh_input_number(uint32_t num) int bt_mesh_input_string(const char *str) { - BT_DBG("%s", str); + LOG_DBG("%s", str); if (strlen(str) > PROV_IO_OOB_SIZE_MAX || strlen(str) > bt_mesh_prov_link.oob_size) { @@ -348,23 +348,23 @@ static void prov_recv(const struct prov_bearer *bearer, void *cb_data, uint8_t type = buf->data[0]; - BT_DBG("type 0x%02x len %u", type, buf->len); + LOG_DBG("type 0x%02x len %u", type, buf->len); if (type >= ARRAY_SIZE(bt_mesh_prov_link.role->op)) { - BT_ERR("Unknown provisioning PDU type 0x%02x", type); + LOG_ERR("Unknown provisioning PDU type 0x%02x", type); bt_mesh_prov_link.role->error(PROV_ERR_NVAL_PDU); return; } if ((type != PROV_FAILED && type != bt_mesh_prov_link.expect) || !bt_mesh_prov_link.role->op[type]) { - BT_WARN("Unexpected msg 0x%02x != 0x%02x", type, bt_mesh_prov_link.expect); + LOG_WRN("Unexpected msg 0x%02x != 0x%02x", type, bt_mesh_prov_link.expect); bt_mesh_prov_link.role->error(PROV_ERR_UNEXP_PDU); return; } if (1 + op_len[type] != buf->len) { - BT_ERR("Invalid length %u for type 0x%02x", buf->len, type); + LOG_ERR("Invalid length %u for type 0x%02x", buf->len, type); bt_mesh_prov_link.role->error(PROV_ERR_NVAL_FMT); return; } @@ -390,7 +390,7 @@ static void prov_link_opened(const struct prov_bearer *bearer, void *cb_data) static void prov_link_closed(const struct prov_bearer *bearer, void *cb_data, enum prov_bearer_link_status reason) { - BT_DBG("%u", reason); + LOG_DBG("%u", reason); if (bt_mesh_prov_link.role->link_closed) { bt_mesh_prov_link.role->link_closed(); @@ -448,7 +448,7 @@ void bt_mesh_prov_reset(void) int bt_mesh_prov_init(const struct bt_mesh_prov *prov_info) { if (!prov_info) { - BT_ERR("No provisioning context provided"); + LOG_ERR("No provisioning context provided"); return -EINVAL; } diff --git a/subsys/bluetooth/mesh/prov_device.c b/subsys/bluetooth/mesh/prov_device.c index 699fa54f7dc..1ac57b256b4 100644 --- a/subsys/bluetooth/mesh/prov_device.c +++ b/subsys/bluetooth/mesh/prov_device.c @@ -17,9 +17,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_PROV_DEVICE) -#define LOG_MODULE_NAME bt_mesh_prov_device -#include "common/log.h" #include "common/bt_str.h" #include "host/ecc.h" @@ -38,6 +35,10 @@ #include "prov.h" #include "settings.h" +#define LOG_LEVEL CONFIG_BT_MESH_PROV_DEVICE_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_mesh_prov_device); + static void send_pub_key(void); static void pub_key_ready(const uint8_t *pkey); @@ -50,7 +51,7 @@ static void prov_send_fail_msg(uint8_t err) { PROV_BUF(buf, PDU_LEN_FAILED); - BT_DBG("%u", err); + LOG_DBG("%u", err); bt_mesh_prov_link.expect = PROV_NO_PDU; @@ -58,7 +59,7 @@ static void prov_send_fail_msg(uint8_t err) net_buf_simple_add_u8(&buf, err); if (bt_mesh_prov_send(&buf, NULL)) { - BT_ERR("Failed to send Provisioning Failed message"); + LOG_ERR("Failed to send Provisioning Failed message"); } } @@ -76,7 +77,7 @@ static void prov_invite(const uint8_t *data) { PROV_BUF(buf, PDU_LEN_CAPABILITIES); - BT_DBG("Attention Duration: %u seconds", data[0]); + LOG_DBG("Attention Duration: %u seconds", data[0]); if (data[0]) { bt_mesh_attention(NULL, data[0]); @@ -114,7 +115,7 @@ static void prov_invite(const uint8_t *data) memcpy(bt_mesh_prov_link.conf_inputs.capabilities, &buf.data[1], PDU_LEN_CAPABILITIES); if (bt_mesh_prov_send(&buf, NULL)) { - BT_ERR("Failed to send capabilities"); + LOG_ERR("Failed to send capabilities"); return; } @@ -123,14 +124,14 @@ static void prov_invite(const uint8_t *data) static void prov_start(const uint8_t *data) { - BT_DBG("Algorithm: 0x%02x", data[0]); - BT_DBG("Public Key: 0x%02x", data[1]); - BT_DBG("Auth Method: 0x%02x", data[2]); - BT_DBG("Auth Action: 0x%02x", data[3]); - BT_DBG("Auth Size: 0x%02x", data[4]); + LOG_DBG("Algorithm: 0x%02x", data[0]); + LOG_DBG("Public Key: 0x%02x", data[1]); + LOG_DBG("Auth Method: 0x%02x", data[2]); + LOG_DBG("Auth Action: 0x%02x", data[3]); + LOG_DBG("Auth Size: 0x%02x", data[4]); if (data[0] != PROV_ALG_P256) { - BT_ERR("Unknown algorithm 0x%02x", data[0]); + LOG_ERR("Unknown algorithm 0x%02x", data[0]); prov_fail(PROV_ERR_NVAL_FMT); return; } @@ -138,7 +139,7 @@ static void prov_start(const uint8_t *data) if (data[1] > PUB_KEY_OOB || (data[1] == PUB_KEY_OOB && (!IS_ENABLED(CONFIG_BT_MESH_PROV_OOB_PUBLIC_KEY) || !bt_mesh_prov->public_key_be))) { - BT_ERR("Invalid public key type: 0x%02x", data[1]); + LOG_ERR("Invalid public key type: 0x%02x", data[1]); prov_fail(PROV_ERR_NVAL_FMT); return; } @@ -153,7 +154,7 @@ static void prov_start(const uint8_t *data) bt_mesh_prov_link.oob_size = data[4]; if (bt_mesh_prov_auth(false, data[2], data[3], data[4]) < 0) { - BT_ERR("Invalid authentication method: 0x%02x; " + LOG_ERR("Invalid authentication method: 0x%02x; " "action: 0x%02x; size: 0x%02x", data[2], data[3], data[4]); prov_fail(PROV_ERR_NVAL_FMT); @@ -172,46 +173,46 @@ static void send_confirm(void) PROV_BUF(cfm, PDU_LEN_CONFIRM); uint8_t *inputs = (uint8_t *)&bt_mesh_prov_link.conf_inputs; - BT_DBG("ConfInputs[0] %s", bt_hex(inputs, 64)); - BT_DBG("ConfInputs[64] %s", bt_hex(&inputs[64], 64)); - BT_DBG("ConfInputs[128] %s", bt_hex(&inputs[128], 17)); + LOG_DBG("ConfInputs[0] %s", bt_hex(inputs, 64)); + LOG_DBG("ConfInputs[64] %s", bt_hex(&inputs[64], 64)); + LOG_DBG("ConfInputs[128] %s", bt_hex(&inputs[128], 17)); if (bt_mesh_prov_conf_salt(inputs, bt_mesh_prov_link.conf_salt)) { - BT_ERR("Unable to generate confirmation salt"); + LOG_ERR("Unable to generate confirmation salt"); prov_fail(PROV_ERR_UNEXP_ERR); return; } - BT_DBG("ConfirmationSalt: %s", bt_hex(bt_mesh_prov_link.conf_salt, 16)); + LOG_DBG("ConfirmationSalt: %s", bt_hex(bt_mesh_prov_link.conf_salt, 16)); if (bt_mesh_prov_conf_key(bt_mesh_prov_link.dhkey, bt_mesh_prov_link.conf_salt, bt_mesh_prov_link.conf_key)) { - BT_ERR("Unable to generate confirmation key"); + LOG_ERR("Unable to generate confirmation key"); prov_fail(PROV_ERR_UNEXP_ERR); return; } - BT_DBG("ConfirmationKey: %s", bt_hex(bt_mesh_prov_link.conf_key, 16)); + LOG_DBG("ConfirmationKey: %s", bt_hex(bt_mesh_prov_link.conf_key, 16)); if (bt_rand(bt_mesh_prov_link.rand, 16)) { - BT_ERR("Unable to generate random number"); + LOG_ERR("Unable to generate random number"); prov_fail(PROV_ERR_UNEXP_ERR); return; } - BT_DBG("LocalRandom: %s", bt_hex(bt_mesh_prov_link.rand, 16)); + LOG_DBG("LocalRandom: %s", bt_hex(bt_mesh_prov_link.rand, 16)); bt_mesh_prov_buf_init(&cfm, PROV_CONFIRM); if (bt_mesh_prov_conf(bt_mesh_prov_link.conf_key, bt_mesh_prov_link.rand, bt_mesh_prov_link.auth, net_buf_simple_add(&cfm, 16))) { - BT_ERR("Unable to generate confirmation value"); + LOG_ERR("Unable to generate confirmation value"); prov_fail(PROV_ERR_UNEXP_ERR); return; } if (bt_mesh_prov_send(&cfm, NULL)) { - BT_ERR("Failed to send Provisioning Confirm"); + LOG_ERR("Failed to send Provisioning Confirm"); return; } @@ -225,7 +226,7 @@ static void send_input_complete(void) bt_mesh_prov_buf_init(&buf, PROV_INPUT_COMPLETE); if (bt_mesh_prov_send(&buf, NULL)) { - BT_ERR("Failed to send Provisioning Input Complete"); + LOG_ERR("Failed to send Provisioning Input Complete"); } bt_mesh_prov_link.expect = PROV_CONFIRM; } @@ -257,7 +258,7 @@ static void send_pub_key(void) key = bt_pub_key_get(); if (!key) { - BT_ERR("No public key available"); + LOG_ERR("No public key available"); prov_fail(PROV_ERR_UNEXP_ERR); return; } @@ -269,13 +270,13 @@ static void send_pub_key(void) sys_memcpy_swap(net_buf_simple_add(&buf, BT_PUB_KEY_COORD_LEN), &key[BT_PUB_KEY_COORD_LEN], BT_PUB_KEY_COORD_LEN); - BT_DBG("Local Public Key: %s", bt_hex(buf.data + 1, BT_PUB_KEY_LEN)); + LOG_DBG("Local Public Key: %s", bt_hex(buf.data + 1, BT_PUB_KEY_LEN)); /* PublicKeyDevice */ memcpy(bt_mesh_prov_link.conf_inputs.pub_key_device, &buf.data[1], PDU_LEN_PUB_KEY); if (bt_mesh_prov_send(&buf, public_key_sent)) { - BT_ERR("Failed to send Public Key"); + LOG_ERR("Failed to send Public Key"); return; } @@ -284,7 +285,7 @@ static void send_pub_key(void) static void dh_key_gen_complete(void) { - BT_DBG("DHkey: %s", bt_hex(bt_mesh_prov_link.dhkey, BT_DH_KEY_LEN)); + LOG_DBG("DHkey: %s", bt_hex(bt_mesh_prov_link.dhkey, BT_DH_KEY_LEN)); if (!atomic_test_and_clear_bit(bt_mesh_prov_link.flags, WAIT_DH_KEY) && atomic_test_bit(bt_mesh_prov_link.flags, OOB_PUB_KEY)) { @@ -296,10 +297,10 @@ static void dh_key_gen_complete(void) static void prov_dh_key_cb(const uint8_t dhkey[BT_DH_KEY_LEN]) { - BT_DBG("%p", dhkey); + LOG_DBG("%p", dhkey); if (!dhkey) { - BT_ERR("DHKey generation failed"); + LOG_ERR("DHKey generation failed"); prov_fail(PROV_ERR_UNEXP_ERR); return; } @@ -338,14 +339,14 @@ static void prov_dh_key_gen(void) BT_PUB_KEY_COORD_LEN); if (bt_dh_key_gen(remote_pk_le, prov_dh_key_cb)) { - BT_ERR("Failed to generate DHKey"); + LOG_ERR("Failed to generate DHKey"); prov_fail(PROV_ERR_UNEXP_ERR); } } static void prov_pub_key(const uint8_t *data) { - BT_DBG("Remote Public Key: %s", bt_hex(data, BT_PUB_KEY_LEN)); + LOG_DBG("Remote Public Key: %s", bt_hex(data, BT_PUB_KEY_LEN)); /* PublicKeyProvisioner */ memcpy(bt_mesh_prov_link.conf_inputs.pub_key_provisioner, data, PDU_LEN_PUB_KEY); @@ -353,7 +354,7 @@ static void prov_pub_key(const uint8_t *data) if (IS_ENABLED(CONFIG_BT_MESH_PROV_OOB_PUBLIC_KEY) && atomic_test_bit(bt_mesh_prov_link.flags, OOB_PUB_KEY)) { if (!bt_mesh_prov->public_key_be || !bt_mesh_prov->private_key_be) { - BT_ERR("Public or private key is not ready"); + LOG_ERR("Public or private key is not ready"); prov_fail(PROV_ERR_UNEXP_ERR); return; } @@ -369,7 +370,7 @@ static void prov_pub_key(const uint8_t *data) /* Clear retransmit timer */ bt_mesh_prov_link.bearer->clear_tx(); atomic_set_bit(bt_mesh_prov_link.flags, WAIT_PUB_KEY); - BT_WARN("Waiting for local public key"); + LOG_WRN("Waiting for local public key"); return; } @@ -379,11 +380,11 @@ static void prov_pub_key(const uint8_t *data) static void pub_key_ready(const uint8_t *pkey) { if (!pkey) { - BT_WARN("Public key not available"); + LOG_WRN("Public key not available"); return; } - BT_DBG("Local public key ready"); + LOG_DBG("Local public key ready"); if (atomic_test_and_clear_bit(bt_mesh_prov_link.flags, WAIT_PUB_KEY)) { prov_dh_key_gen(); @@ -407,7 +408,7 @@ static void send_random(void) net_buf_simple_add_mem(&rnd, bt_mesh_prov_link.rand, 16); if (bt_mesh_prov_send(&rnd, NULL)) { - BT_ERR("Failed to send Provisioning Random"); + LOG_ERR("Failed to send Provisioning Random"); return; } @@ -418,43 +419,43 @@ static void prov_random(const uint8_t *data) { uint8_t conf_verify[16]; - BT_DBG("Remote Random: %s", bt_hex(data, 16)); + LOG_DBG("Remote Random: %s", bt_hex(data, 16)); if (!memcmp(data, bt_mesh_prov_link.rand, 16)) { - BT_ERR("Random value is identical to ours, rejecting."); + LOG_ERR("Random value is identical to ours, rejecting."); prov_fail(PROV_ERR_CFM_FAILED); return; } if (bt_mesh_prov_conf(bt_mesh_prov_link.conf_key, data, bt_mesh_prov_link.auth, conf_verify)) { - BT_ERR("Unable to calculate confirmation verification"); + LOG_ERR("Unable to calculate confirmation verification"); prov_fail(PROV_ERR_UNEXP_ERR); return; } if (memcmp(conf_verify, bt_mesh_prov_link.conf, 16)) { - BT_ERR("Invalid confirmation value"); - BT_DBG("Received: %s", bt_hex(bt_mesh_prov_link.conf, 16)); - BT_DBG("Calculated: %s", bt_hex(conf_verify, 16)); + LOG_ERR("Invalid confirmation value"); + LOG_DBG("Received: %s", bt_hex(bt_mesh_prov_link.conf, 16)); + LOG_DBG("Calculated: %s", bt_hex(conf_verify, 16)); prov_fail(PROV_ERR_CFM_FAILED); return; } if (bt_mesh_prov_salt(bt_mesh_prov_link.conf_salt, data, bt_mesh_prov_link.rand, bt_mesh_prov_link.prov_salt)) { - BT_ERR("Failed to generate provisioning salt"); + LOG_ERR("Failed to generate provisioning salt"); prov_fail(PROV_ERR_UNEXP_ERR); return; } - BT_DBG("ProvisioningSalt: %s", bt_hex(bt_mesh_prov_link.prov_salt, 16)); + LOG_DBG("ProvisioningSalt: %s", bt_hex(bt_mesh_prov_link.prov_salt, 16)); send_random(); } static void prov_confirm(const uint8_t *data) { - BT_DBG("Remote Confirm: %s", bt_hex(data, 16)); + LOG_DBG("Remote Confirm: %s", bt_hex(data, 16)); memcpy(bt_mesh_prov_link.conf, data, 16); @@ -485,31 +486,31 @@ static void prov_data(const uint8_t *data) int err; bool identity_enable; - BT_DBG(""); + LOG_DBG(""); err = bt_mesh_session_key(bt_mesh_prov_link.dhkey, bt_mesh_prov_link.prov_salt, session_key); if (err) { - BT_ERR("Unable to generate session key"); + LOG_ERR("Unable to generate session key"); prov_fail(PROV_ERR_UNEXP_ERR); return; } - BT_DBG("SessionKey: %s", bt_hex(session_key, 16)); + LOG_DBG("SessionKey: %s", bt_hex(session_key, 16)); err = bt_mesh_prov_nonce(bt_mesh_prov_link.dhkey, bt_mesh_prov_link.prov_salt, nonce); if (err) { - BT_ERR("Unable to generate session nonce"); + LOG_ERR("Unable to generate session nonce"); prov_fail(PROV_ERR_UNEXP_ERR); return; } - BT_DBG("Nonce: %s", bt_hex(nonce, 13)); + LOG_DBG("Nonce: %s", bt_hex(nonce, 13)); err = bt_mesh_prov_decrypt(session_key, nonce, data, pdu); if (err) { - BT_ERR("Unable to decrypt provisioning data"); + LOG_ERR("Unable to decrypt provisioning data"); prov_fail(PROV_ERR_DECRYPT); return; } @@ -517,24 +518,23 @@ static void prov_data(const uint8_t *data) err = bt_mesh_dev_key(bt_mesh_prov_link.dhkey, bt_mesh_prov_link.prov_salt, dev_key); if (err) { - BT_ERR("Unable to generate device key"); + LOG_ERR("Unable to generate device key"); prov_fail(PROV_ERR_UNEXP_ERR); return; } - BT_DBG("DevKey: %s", bt_hex(dev_key, 16)); + LOG_DBG("DevKey: %s", bt_hex(dev_key, 16)); net_idx = sys_get_be16(&pdu[16]); flags = pdu[18]; iv_index = sys_get_be32(&pdu[19]); addr = sys_get_be16(&pdu[23]); - BT_DBG("net_idx %u iv_index 0x%08x, addr 0x%04x", - net_idx, iv_index, addr); + LOG_DBG("net_idx %u iv_index 0x%08x, addr 0x%04x", net_idx, iv_index, addr); bt_mesh_prov_buf_init(&msg, PROV_COMPLETE); if (bt_mesh_prov_send(&msg, NULL)) { - BT_ERR("Failed to send Provisioning Complete"); + LOG_ERR("Failed to send Provisioning Complete"); return; } @@ -550,7 +550,7 @@ static void prov_data(const uint8_t *data) err = bt_mesh_provision(pdu, net_idx, flags, iv_index, addr, dev_key); if (err) { - BT_ERR("Failed to provision (err %d)", err); + LOG_ERR("Failed to provision (err %d)", err); return; } @@ -607,7 +607,7 @@ int bt_mesh_prov_enable(bt_mesh_prov_bearer_t bearers) struct bt_uuid_128 uuid = { .uuid = { BT_UUID_TYPE_128 } }; memcpy(uuid.val, bt_mesh_prov->uuid, 16); - BT_INFO("Device UUID: %s", bt_uuid_str(&uuid.uuid)); + LOG_INF("Device UUID: %s", bt_uuid_str(&uuid.uuid)); } if (IS_ENABLED(CONFIG_BT_MESH_PB_ADV) && diff --git a/subsys/bluetooth/mesh/provisioner.c b/subsys/bluetooth/mesh/provisioner.c index a3137a1883d..0e8cb29ed6f 100644 --- a/subsys/bluetooth/mesh/provisioner.c +++ b/subsys/bluetooth/mesh/provisioner.c @@ -18,9 +18,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_PROVISIONER) -#define LOG_MODULE_NAME bt_mesh_provisioner -#include "common/log.h" #include "common/bt_str.h" #include "host/ecc.h" @@ -38,6 +35,10 @@ #include "prov.h" #include "settings.h" +#define LOG_LEVEL CONFIG_BT_MESH_PROVISIONER_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_mesh_provisioner); + static struct { struct bt_mesh_cdb_node *node; uint16_t addr; @@ -61,7 +62,7 @@ static int reset_state(void) static void prov_link_close(enum prov_bearer_link_status status) { - BT_DBG("%u", status); + LOG_DBG("%u", status); bt_mesh_prov_link.expect = PROV_NO_PDU; bt_mesh_prov_link.bearer->link_close(status); @@ -81,7 +82,7 @@ static void send_invite(void) { PROV_BUF(inv, PDU_LEN_INVITE); - BT_DBG(""); + LOG_DBG(""); bt_mesh_prov_buf_init(&inv, PROV_INVITE); net_buf_simple_add_u8(&inv, prov_device.attention_duration); @@ -90,7 +91,7 @@ static void send_invite(void) PDU_LEN_INVITE); if (bt_mesh_prov_send(&inv, NULL)) { - BT_ERR("Failed to send invite"); + LOG_ERR("Failed to send invite"); return; } @@ -101,7 +102,7 @@ static void start_sent(int err, void *cb_data) { if (!bt_pub_key_get()) { atomic_set_bit(bt_mesh_prov_link.flags, WAIT_PUB_KEY); - BT_WARN("Waiting for local public key"); + LOG_WRN("Waiting for local public key"); } else { send_pub_key(); } @@ -109,7 +110,7 @@ static void start_sent(int err, void *cb_data) static void send_start(void) { - BT_DBG(""); + LOG_DBG(""); PROV_BUF(start, PDU_LEN_START); @@ -135,14 +136,14 @@ static void send_start(void) if (bt_mesh_prov_auth(true, bt_mesh_prov_link.oob_method, bt_mesh_prov_link.oob_action, bt_mesh_prov_link.oob_size) < 0) { - BT_ERR("Invalid authentication method: 0x%02x; " + LOG_ERR("Invalid authentication method: 0x%02x; " "action: 0x%02x; size: 0x%02x", bt_mesh_prov_link.oob_method, bt_mesh_prov_link.oob_action, bt_mesh_prov_link.oob_size); return; } if (bt_mesh_prov_send(&start, start_sent)) { - BT_ERR("Failed to send Provisioning Start"); + LOG_ERR("Failed to send Provisioning Start"); return; } } @@ -151,19 +152,19 @@ static bool prov_check_method(struct bt_mesh_dev_capabilities *caps) { if (bt_mesh_prov_link.oob_method == AUTH_METHOD_STATIC) { if (!caps->static_oob) { - BT_WARN("Device not support OOB static authentication provisioning"); + LOG_WRN("Device not support OOB static authentication provisioning"); return false; } } else if (bt_mesh_prov_link.oob_method == AUTH_METHOD_INPUT) { if (bt_mesh_prov_link.oob_size > caps->input_size) { - BT_WARN("The required input length (0x%02x) " + LOG_WRN("The required input length (0x%02x) " "exceeds the device capacity (0x%02x)", bt_mesh_prov_link.oob_size, caps->input_size); return false; } if (!(BIT(bt_mesh_prov_link.oob_action) & caps->input_actions)) { - BT_WARN("The required input action (0x%04x) " + LOG_WRN("The required input action (0x%04x) " "not supported by the device (0x%02x)", (uint16_t)BIT(bt_mesh_prov_link.oob_action), caps->input_actions); return false; @@ -171,32 +172,32 @@ static bool prov_check_method(struct bt_mesh_dev_capabilities *caps) if (bt_mesh_prov_link.oob_action == INPUT_OOB_STRING) { if (!bt_mesh_prov->output_string) { - BT_WARN("Not support output string"); + LOG_WRN("Not support output string"); return false; } } else { if (!bt_mesh_prov->output_number) { - BT_WARN("Not support output number"); + LOG_WRN("Not support output number"); return false; } } } else if (bt_mesh_prov_link.oob_method == AUTH_METHOD_OUTPUT) { if (bt_mesh_prov_link.oob_size > caps->output_size) { - BT_WARN("The required output length (0x%02x) " + LOG_WRN("The required output length (0x%02x) " "exceeds the device capacity (0x%02x)", bt_mesh_prov_link.oob_size, caps->output_size); return false; } if (!(BIT(bt_mesh_prov_link.oob_action) & caps->output_actions)) { - BT_WARN("The required output action (0x%04x) " + LOG_WRN("The required output action (0x%04x) " "not supported by the device (0x%02x)", (uint16_t)BIT(bt_mesh_prov_link.oob_action), caps->output_actions); return false; } if (!bt_mesh_prov->input) { - BT_WARN("Not support input"); + LOG_WRN("Not support input"); return false; } } @@ -209,29 +210,29 @@ static void prov_capabilities(const uint8_t *data) struct bt_mesh_dev_capabilities caps; caps.elem_count = data[0]; - BT_DBG("Elements: %u", caps.elem_count); + LOG_DBG("Elements: %u", caps.elem_count); caps.algorithms = sys_get_be16(&data[1]); - BT_DBG("Algorithms: %u", caps.algorithms); + LOG_DBG("Algorithms: %u", caps.algorithms); caps.pub_key_type = data[3]; caps.static_oob = data[4]; caps.output_size = data[5]; - BT_DBG("Public Key Type: 0x%02x", caps.pub_key_type); - BT_DBG("Static OOB Type: 0x%02x", caps.static_oob); - BT_DBG("Output OOB Size: %u", caps.output_size); + LOG_DBG("Public Key Type: 0x%02x", caps.pub_key_type); + LOG_DBG("Static OOB Type: 0x%02x", caps.static_oob); + LOG_DBG("Output OOB Size: %u", caps.output_size); caps.output_actions = (bt_mesh_output_action_t) (sys_get_be16(&data[6])); caps.input_size = data[8]; caps.input_actions = (bt_mesh_input_action_t) (sys_get_be16(&data[9])); - BT_DBG("Output OOB Action: 0x%04x", caps.output_actions); - BT_DBG("Input OOB Size: %u", caps.input_size); - BT_DBG("Input OOB Action: 0x%04x", caps.input_actions); + LOG_DBG("Output OOB Action: 0x%04x", caps.output_actions); + LOG_DBG("Input OOB Size: %u", caps.input_size); + LOG_DBG("Input OOB Action: 0x%04x", caps.input_actions); if (data[0] == 0) { - BT_ERR("Invalid number of elements"); + LOG_ERR("Invalid number of elements"); prov_fail(PROV_ERR_NVAL_FMT); return; } @@ -241,7 +242,7 @@ static void prov_capabilities(const uint8_t *data) prov_device.addr, data[0], prov_device.net_idx); if (prov_device.node == NULL) { - BT_ERR("Failed allocating node 0x%04x", prov_device.addr); + LOG_ERR("Failed allocating node 0x%04x", prov_device.addr); prov_fail(PROV_ERR_RESOURCES); return; } @@ -265,41 +266,41 @@ static void send_confirm(void) PROV_BUF(cfm, PDU_LEN_CONFIRM); uint8_t *inputs = (uint8_t *)&bt_mesh_prov_link.conf_inputs; - BT_DBG("ConfInputs[0] %s", bt_hex(inputs, 64)); - BT_DBG("ConfInputs[64] %s", bt_hex(&inputs[64], 64)); - BT_DBG("ConfInputs[128] %s", bt_hex(&inputs[128], 17)); + LOG_DBG("ConfInputs[0] %s", bt_hex(inputs, 64)); + LOG_DBG("ConfInputs[64] %s", bt_hex(&inputs[64], 64)); + LOG_DBG("ConfInputs[128] %s", bt_hex(&inputs[128], 17)); if (bt_mesh_prov_conf_salt(inputs, bt_mesh_prov_link.conf_salt)) { - BT_ERR("Unable to generate confirmation salt"); + LOG_ERR("Unable to generate confirmation salt"); prov_fail(PROV_ERR_UNEXP_ERR); return; } - BT_DBG("ConfirmationSalt: %s", bt_hex(bt_mesh_prov_link.conf_salt, 16)); + LOG_DBG("ConfirmationSalt: %s", bt_hex(bt_mesh_prov_link.conf_salt, 16)); if (bt_mesh_prov_conf_key(bt_mesh_prov_link.dhkey, bt_mesh_prov_link.conf_salt, bt_mesh_prov_link.conf_key)) { - BT_ERR("Unable to generate confirmation key"); + LOG_ERR("Unable to generate confirmation key"); prov_fail(PROV_ERR_UNEXP_ERR); return; } - BT_DBG("ConfirmationKey: %s", bt_hex(bt_mesh_prov_link.conf_key, 16)); + LOG_DBG("ConfirmationKey: %s", bt_hex(bt_mesh_prov_link.conf_key, 16)); if (bt_rand(bt_mesh_prov_link.rand, 16)) { - BT_ERR("Unable to generate random number"); + LOG_ERR("Unable to generate random number"); prov_fail(PROV_ERR_UNEXP_ERR); return; } - BT_DBG("LocalRandom: %s", bt_hex(bt_mesh_prov_link.rand, 16)); + LOG_DBG("LocalRandom: %s", bt_hex(bt_mesh_prov_link.rand, 16)); bt_mesh_prov_buf_init(&cfm, PROV_CONFIRM); if (bt_mesh_prov_conf(bt_mesh_prov_link.conf_key, bt_mesh_prov_link.rand, bt_mesh_prov_link.auth, bt_mesh_prov_link.conf)) { - BT_ERR("Unable to generate confirmation value"); + LOG_ERR("Unable to generate confirmation value"); prov_fail(PROV_ERR_UNEXP_ERR); return; } @@ -307,7 +308,7 @@ static void send_confirm(void) net_buf_simple_add_mem(&cfm, bt_mesh_prov_link.conf, 16); if (bt_mesh_prov_send(&cfm, NULL)) { - BT_ERR("Failed to send Provisioning Confirm"); + LOG_ERR("Failed to send Provisioning Confirm"); return; } @@ -332,7 +333,7 @@ static void send_pub_key(void) key = bt_pub_key_get(); if (!key) { - BT_ERR("No public key available"); + LOG_ERR("No public key available"); prov_fail(PROV_ERR_UNEXP_ERR); return; } @@ -344,13 +345,13 @@ static void send_pub_key(void) sys_memcpy_swap(net_buf_simple_add(&buf, BT_PUB_KEY_COORD_LEN), &key[BT_PUB_KEY_COORD_LEN], BT_PUB_KEY_COORD_LEN); - BT_DBG("Local Public Key: %s", bt_hex(buf.data + 1, BT_PUB_KEY_LEN)); + LOG_DBG("Local Public Key: %s", bt_hex(buf.data + 1, BT_PUB_KEY_LEN)); /* PublicKeyProvisioner */ memcpy(bt_mesh_prov_link.conf_inputs.pub_key_provisioner, &buf.data[1], PDU_LEN_PUB_KEY); if (bt_mesh_prov_send(&buf, public_key_sent)) { - BT_ERR("Failed to send Public Key"); + LOG_ERR("Failed to send Public Key"); return; } @@ -359,17 +360,17 @@ static void send_pub_key(void) static void prov_dh_key_cb(const uint8_t dhkey[BT_DH_KEY_LEN]) { - BT_DBG("%p", dhkey); + LOG_DBG("%p", dhkey); if (!dhkey) { - BT_ERR("DHKey generation failed"); + LOG_ERR("DHKey generation failed"); prov_fail(PROV_ERR_UNEXP_ERR); return; } sys_memcpy_swap(bt_mesh_prov_link.dhkey, dhkey, BT_DH_KEY_LEN); - BT_DBG("DHkey: %s", bt_hex(bt_mesh_prov_link.dhkey, BT_DH_KEY_LEN)); + LOG_DBG("DHkey: %s", bt_hex(bt_mesh_prov_link.dhkey, BT_DH_KEY_LEN)); if (atomic_test_bit(bt_mesh_prov_link.flags, WAIT_STRING) || atomic_test_bit(bt_mesh_prov_link.flags, WAIT_NUMBER) || @@ -399,13 +400,13 @@ static void prov_dh_key_gen(void) BT_PUB_KEY_COORD_LEN); if (!memcmp(local_pk, remote_pk, BT_PUB_KEY_LEN)) { - BT_ERR("Public keys are identical"); + LOG_ERR("Public keys are identical"); prov_fail(PROV_ERR_NVAL_FMT); return; } if (bt_dh_key_gen(remote_pk_le, prov_dh_key_cb)) { - BT_ERR("Failed to generate DHKey"); + LOG_ERR("Failed to generate DHKey"); prov_fail(PROV_ERR_UNEXP_ERR); } @@ -416,7 +417,7 @@ static void prov_dh_key_gen(void) static void prov_pub_key(const uint8_t *data) { - BT_DBG("Remote Public Key: %s", bt_hex(data, BT_PUB_KEY_LEN)); + LOG_DBG("Remote Public Key: %s", bt_hex(data, BT_PUB_KEY_LEN)); atomic_set_bit(bt_mesh_prov_link.flags, REMOTE_PUB_KEY); @@ -430,11 +431,11 @@ static void prov_pub_key(const uint8_t *data) static void pub_key_ready(const uint8_t *pkey) { if (!pkey) { - BT_WARN("Public key not available"); + LOG_WRN("Public key not available"); return; } - BT_DBG("Local public key ready"); + LOG_DBG("Local public key ready"); if (atomic_test_and_clear_bit(bt_mesh_prov_link.flags, WAIT_PUB_KEY)) { send_pub_key(); @@ -452,7 +453,7 @@ static void notify_input_complete(void) static void prov_input_complete(const uint8_t *data) { - BT_DBG(""); + LOG_DBG(""); notify_input_complete(); @@ -472,37 +473,36 @@ static void send_prov_data(void) err = bt_mesh_session_key(bt_mesh_prov_link.dhkey, bt_mesh_prov_link.prov_salt, session_key); if (err) { - BT_ERR("Unable to generate session key"); + LOG_ERR("Unable to generate session key"); prov_fail(PROV_ERR_UNEXP_ERR); return; } - BT_DBG("SessionKey: %s", bt_hex(session_key, 16)); + LOG_DBG("SessionKey: %s", bt_hex(session_key, 16)); err = bt_mesh_prov_nonce(bt_mesh_prov_link.dhkey, bt_mesh_prov_link.prov_salt, nonce); if (err) { - BT_ERR("Unable to generate session nonce"); + LOG_ERR("Unable to generate session nonce"); prov_fail(PROV_ERR_UNEXP_ERR); return; } - BT_DBG("Nonce: %s", bt_hex(nonce, 13)); + LOG_DBG("Nonce: %s", bt_hex(nonce, 13)); err = bt_mesh_dev_key(bt_mesh_prov_link.dhkey, bt_mesh_prov_link.prov_salt, prov_device.node->dev_key); if (err) { - BT_ERR("Unable to generate device key"); + LOG_ERR("Unable to generate device key"); prov_fail(PROV_ERR_UNEXP_ERR); return; } - BT_DBG("DevKey: %s", bt_hex(prov_device.node->dev_key, 16)); + LOG_DBG("DevKey: %s", bt_hex(prov_device.node->dev_key, 16)); sub = bt_mesh_cdb_subnet_get(prov_device.node->net_idx); if (sub == NULL) { - BT_ERR("No subnet with net_idx %u", - prov_device.node->net_idx); + LOG_ERR("No subnet with net_idx %u", prov_device.node->net_idx); prov_fail(PROV_ERR_UNEXP_ERR); return; } @@ -515,20 +515,19 @@ static void send_prov_data(void) net_buf_simple_add_be16(&pdu, prov_device.node->addr); net_buf_simple_add(&pdu, 8); /* For MIC */ - BT_DBG("net_idx %u, iv_index 0x%08x, addr 0x%04x", - prov_device.node->net_idx, bt_mesh.iv_index, - prov_device.node->addr); + LOG_DBG("net_idx %u, iv_index 0x%08x, addr 0x%04x", prov_device.node->net_idx, + bt_mesh.iv_index, prov_device.node->addr); err = bt_mesh_prov_encrypt(session_key, nonce, &pdu.data[1], &pdu.data[1]); if (err) { - BT_ERR("Unable to encrypt provisioning data"); + LOG_ERR("Unable to encrypt provisioning data"); prov_fail(PROV_ERR_DECRYPT); return; } if (bt_mesh_prov_send(&pdu, NULL)) { - BT_ERR("Failed to send Provisioning Data"); + LOG_ERR("Failed to send Provisioning Data"); return; } @@ -539,9 +538,8 @@ static void prov_complete(const uint8_t *data) { struct bt_mesh_cdb_node *node = prov_device.node; - BT_DBG("key %s, net_idx %u, num_elem %u, addr 0x%04x", - bt_hex(node->dev_key, 16), node->net_idx, node->num_elem, - node->addr); + LOG_DBG("key %s, net_idx %u, num_elem %u, addr 0x%04x", bt_hex(node->dev_key, 16), + node->net_idx, node->num_elem, node->addr); if (IS_ENABLED(CONFIG_BT_SETTINGS)) { bt_mesh_cdb_node_store(node); @@ -564,7 +562,7 @@ static void send_random(void) net_buf_simple_add_mem(&rnd, bt_mesh_prov_link.rand, 16); if (bt_mesh_prov_send(&rnd, NULL)) { - BT_ERR("Failed to send Provisioning Random"); + LOG_ERR("Failed to send Provisioning Random"); return; } @@ -575,46 +573,46 @@ static void prov_random(const uint8_t *data) { uint8_t conf_verify[16]; - BT_DBG("Remote Random: %s", bt_hex(data, 16)); + LOG_DBG("Remote Random: %s", bt_hex(data, 16)); if (!memcmp(data, bt_mesh_prov_link.rand, 16)) { - BT_ERR("Random value is identical to ours, rejecting."); + LOG_ERR("Random value is identical to ours, rejecting."); prov_fail(PROV_ERR_CFM_FAILED); return; } if (bt_mesh_prov_conf(bt_mesh_prov_link.conf_key, data, bt_mesh_prov_link.auth, conf_verify)) { - BT_ERR("Unable to calculate confirmation verification"); + LOG_ERR("Unable to calculate confirmation verification"); prov_fail(PROV_ERR_UNEXP_ERR); return; } if (memcmp(conf_verify, bt_mesh_prov_link.conf, 16)) { - BT_ERR("Invalid confirmation value"); - BT_DBG("Received: %s", bt_hex(bt_mesh_prov_link.conf, 16)); - BT_DBG("Calculated: %s", bt_hex(conf_verify, 16)); + LOG_ERR("Invalid confirmation value"); + LOG_DBG("Received: %s", bt_hex(bt_mesh_prov_link.conf, 16)); + LOG_DBG("Calculated: %s", bt_hex(conf_verify, 16)); prov_fail(PROV_ERR_CFM_FAILED); return; } if (bt_mesh_prov_salt(bt_mesh_prov_link.conf_salt, bt_mesh_prov_link.rand, data, bt_mesh_prov_link.prov_salt)) { - BT_ERR("Failed to generate provisioning salt"); + LOG_ERR("Failed to generate provisioning salt"); prov_fail(PROV_ERR_UNEXP_ERR); return; } - BT_DBG("ProvisioningSalt: %s", bt_hex(bt_mesh_prov_link.prov_salt, 16)); + LOG_DBG("ProvisioningSalt: %s", bt_hex(bt_mesh_prov_link.prov_salt, 16)); send_prov_data(); } static void prov_confirm(const uint8_t *data) { - BT_DBG("Remote Confirm: %s", bt_hex(data, 16)); + LOG_DBG("Remote Confirm: %s", bt_hex(data, 16)); if (!memcmp(data, bt_mesh_prov_link.conf, 16)) { - BT_ERR("Confirm value is identical to ours, rejecting."); + LOG_ERR("Confirm value is identical to ours, rejecting."); prov_fail(PROV_ERR_CFM_FAILED); return; } @@ -626,7 +624,7 @@ static void prov_confirm(const uint8_t *data) static void prov_failed(const uint8_t *data) { - BT_WARN("Error: 0x%02x", data[0]); + LOG_WRN("Error: 0x%02x", data[0]); reset_state(); } @@ -739,7 +737,7 @@ static int bt_mesh_provisioner_open(const struct prov_bearer *bearer, struct bt_uuid_128 uuid_repr = { .uuid = { BT_UUID_TYPE_128 } }; memcpy(uuid_repr.val, uuid, 16); - BT_DBG("Provisioning %s", bt_uuid_str(&uuid_repr.uuid)); + LOG_DBG("Provisioning %s", bt_uuid_str(&uuid_repr.uuid)); atomic_set_bit(bt_mesh_prov_link.flags, PROVISIONER); memcpy(prov_device.uuid, uuid, 16); diff --git a/subsys/bluetooth/mesh/proxy_cli.c b/subsys/bluetooth/mesh/proxy_cli.c index 9b7f5b27516..9eede97fa1a 100644 --- a/subsys/bluetooth/mesh/proxy_cli.c +++ b/subsys/bluetooth/mesh/proxy_cli.c @@ -15,10 +15,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_PROXY) -#define LOG_MODULE_NAME bt_mesh_proxy_client -#include "common/log.h" - #include "mesh.h" #include "adv.h" #include "net.h" @@ -33,6 +29,10 @@ #include "gatt_cli.h" #include "proxy_msg.h" +#define LOG_LEVEL CONFIG_BT_MESH_PROXY_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_mesh_proxy_client); + static struct bt_mesh_proxy_server { struct bt_mesh_proxy_role *role; bool link_opened; @@ -105,19 +105,19 @@ static void proxy_msg_recv(struct bt_mesh_proxy_role *role) { switch (role->msg_type) { case BT_MESH_PROXY_NET_PDU: - BT_DBG("Mesh Network PDU"); + LOG_DBG("Mesh Network PDU"); bt_mesh_net_recv(&role->buf, 0, BT_MESH_NET_IF_PROXY); break; case BT_MESH_PROXY_BEACON: - BT_DBG("Mesh Beacon PDU"); + LOG_DBG("Mesh Beacon PDU"); bt_mesh_beacon_recv(&role->buf); break; case BT_MESH_PROXY_CONFIG: - BT_DBG("Mesh Configuration PDU"); + LOG_DBG("Mesh Configuration PDU"); /* TODO */ break; default: - BT_WARN("Unhandled Message Type 0x%02x", role->msg_type); + LOG_WRN("Unhandled Message Type 0x%02x", role->msg_type); break; } } diff --git a/subsys/bluetooth/mesh/proxy_msg.c b/subsys/bluetooth/mesh/proxy_msg.c index a927c41a684..ed5c404064f 100644 --- a/subsys/bluetooth/mesh/proxy_msg.c +++ b/subsys/bluetooth/mesh/proxy_msg.c @@ -16,9 +16,8 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_PROXY) -#define LOG_MODULE_NAME bt_mesh_proxy -#include "common/log.h" +#include + #include "common/bt_str.h" #include "mesh.h" @@ -34,6 +33,10 @@ #include "proxy.h" #include "proxy_msg.h" +#define LOG_LEVEL CONFIG_BT_MESH_PROXY_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_mesh_proxy); + #define PDU_SAR(data) (data[0] >> 6) /* Mesh Profile 1.0 Section 6.6: @@ -60,7 +63,7 @@ static void proxy_sar_timeout(struct k_work *work) struct bt_mesh_proxy_role *role; struct k_work_delayable *dwork = k_work_delayable_from_work(work); - BT_WARN("Proxy SAR timeout"); + LOG_WRN("Proxy SAR timeout"); role = CONTAINER_OF(dwork, struct bt_mesh_proxy_role, sar_timer); if (role->conn) { @@ -78,7 +81,7 @@ ssize_t bt_mesh_proxy_msg_recv(struct bt_conn *conn, switch (PDU_SAR(data)) { case SAR_COMPLETE: if (role->buf.len) { - BT_WARN("Complete PDU while a pending incomplete one"); + LOG_WRN("Complete PDU while a pending incomplete one"); return -EINVAL; } @@ -90,7 +93,7 @@ ssize_t bt_mesh_proxy_msg_recv(struct bt_conn *conn, case SAR_FIRST: if (role->buf.len) { - BT_WARN("First PDU while a pending incomplete one"); + LOG_WRN("First PDU while a pending incomplete one"); return -EINVAL; } @@ -101,12 +104,12 @@ ssize_t bt_mesh_proxy_msg_recv(struct bt_conn *conn, case SAR_CONT: if (!role->buf.len) { - BT_WARN("Continuation with no prior data"); + LOG_WRN("Continuation with no prior data"); return -EINVAL; } if (role->msg_type != PDU_TYPE(data)) { - BT_WARN("Unexpected message type in continuation"); + LOG_WRN("Unexpected message type in continuation"); return -EINVAL; } @@ -116,12 +119,12 @@ ssize_t bt_mesh_proxy_msg_recv(struct bt_conn *conn, case SAR_LAST: if (!role->buf.len) { - BT_WARN("Last SAR PDU with no prior data"); + LOG_WRN("Last SAR PDU with no prior data"); return -EINVAL; } if (role->msg_type != PDU_TYPE(data)) { - BT_WARN("Unexpected message type in last SAR PDU"); + LOG_WRN("Unexpected message type in last SAR PDU"); return -EINVAL; } @@ -146,8 +149,8 @@ int bt_mesh_proxy_msg_send(struct bt_conn *conn, uint8_t type, uint16_t mtu; struct bt_mesh_proxy_role *role = &roles[bt_conn_index(conn)]; - BT_DBG("conn %p type 0x%02x len %u: %s", (void *)conn, type, msg->len, - bt_hex(msg->data, msg->len)); + LOG_DBG("conn %p type 0x%02x len %u: %s", (void *)conn, type, msg->len, + bt_hex(msg->data, msg->len)); /* ATT_MTU - OpCode (1 byte) - Handle (2 bytes) */ mtu = bt_gatt_get_mtu(conn) - 3; @@ -211,7 +214,7 @@ int bt_mesh_proxy_relay_send(struct bt_conn *conn, struct net_buf *buf) bt_mesh_adv_send_start(0, err, BT_MESH_ADV(buf)); if (err) { - BT_ERR("Failed to send proxy message (err %d)", err); + LOG_ERR("Failed to send proxy message (err %d)", err); /* If segment_and_send() fails the buf_send_end() callback will * not be called, so we need to clear the user data (net_buf, diff --git a/subsys/bluetooth/mesh/proxy_srv.c b/subsys/bluetooth/mesh/proxy_srv.c index e051f33e2b1..507e68d7412 100644 --- a/subsys/bluetooth/mesh/proxy_srv.c +++ b/subsys/bluetooth/mesh/proxy_srv.c @@ -14,9 +14,8 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_PROXY) -#define LOG_MODULE_NAME bt_mesh_gatt -#include "common/log.h" +#include + #include "common/bt_str.h" #include "mesh.h" @@ -32,6 +31,10 @@ #include "proxy.h" #include "proxy_msg.h" +#define LOG_LEVEL CONFIG_BT_MESH_PROXY_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_mesh_gatt); + #if defined(CONFIG_BT_MESH_PROXY_USE_DEVICE_NAME) #define ADV_OPT_USE_NAME BT_LE_ADV_OPT_USE_NAME #else @@ -77,12 +80,12 @@ static ssize_t gatt_recv(struct bt_conn *conn, const uint8_t *data = buf; if (len < 1) { - BT_WARN("Too small Proxy PDU"); + LOG_WRN("Too small Proxy PDU"); return -EINVAL; } if (PDU_TYPE(data) == BT_MESH_PROXY_PROV) { - BT_WARN("Proxy PDU type doesn't match GATT service"); + LOG_WRN("Proxy PDU type doesn't match GATT service"); return -EINVAL; } @@ -98,12 +101,12 @@ static int filter_set(struct bt_mesh_proxy_client *client, uint8_t type; if (buf->len < 1) { - BT_WARN("Too short Filter Set message"); + LOG_WRN("Too short Filter Set message"); return -EINVAL; } type = net_buf_simple_pull_u8(buf); - BT_DBG("type 0x%02x", type); + LOG_DBG("type 0x%02x", type); switch (type) { case 0x00: @@ -115,7 +118,7 @@ static int filter_set(struct bt_mesh_proxy_client *client, client->filter_type = REJECT; break; default: - BT_WARN("Prohibited Filter Type 0x%02x", type); + LOG_WRN("Prohibited Filter Type 0x%02x", type); return -EINVAL; } @@ -126,7 +129,7 @@ static void filter_add(struct bt_mesh_proxy_client *client, uint16_t addr) { int i; - BT_DBG("addr 0x%04x", addr); + LOG_DBG("addr 0x%04x", addr); if (addr == BT_MESH_ADDR_UNASSIGNED) { return; @@ -150,7 +153,7 @@ static void filter_remove(struct bt_mesh_proxy_client *client, uint16_t addr) { int i; - BT_DBG("addr 0x%04x", addr); + LOG_DBG("addr 0x%04x", addr); if (addr == BT_MESH_ADDR_UNASSIGNED) { return; @@ -198,18 +201,18 @@ static void send_filter_status(struct bt_mesh_proxy_client *client, net_buf_simple_add_be16(buf, filter_size); - BT_DBG("%u bytes: %s", buf->len, bt_hex(buf->data, buf->len)); + LOG_DBG("%u bytes: %s", buf->len, bt_hex(buf->data, buf->len)); err = bt_mesh_net_encode(&tx, buf, true); if (err) { - BT_ERR("Encoding Proxy cfg message failed (err %d)", err); + LOG_ERR("Encoding Proxy cfg message failed (err %d)", err); return; } err = bt_mesh_proxy_msg_send(client->cli->conn, BT_MESH_PROXY_CONFIG, buf, NULL, NULL); if (err) { - BT_ERR("Failed to send proxy cfg message (err %d)", err); + LOG_ERR("Failed to send proxy cfg message (err %d)", err); } } @@ -246,7 +249,7 @@ static void proxy_filter_recv(struct bt_conn *conn, send_filter_status(client, rx, buf); break; default: - BT_WARN("Unhandled configuration OpCode 0x%02x", opcode); + LOG_WRN("Unhandled configuration OpCode 0x%02x", opcode); break; } } @@ -260,25 +263,25 @@ static void proxy_cfg(struct bt_mesh_proxy_role *role) err = bt_mesh_net_decode(&role->buf, BT_MESH_NET_IF_PROXY_CFG, &rx, &buf); if (err) { - BT_ERR("Failed to decode Proxy Configuration (err %d)", err); + LOG_ERR("Failed to decode Proxy Configuration (err %d)", err); return; } rx.local_match = 1U; if (bt_mesh_rpl_check(&rx, NULL)) { - BT_WARN("Replay: src 0x%04x dst 0x%04x seq 0x%06x", - rx.ctx.addr, rx.ctx.recv_dst, rx.seq); + LOG_WRN("Replay: src 0x%04x dst 0x%04x seq 0x%06x", rx.ctx.addr, rx.ctx.recv_dst, + rx.seq); return; } /* Remove network headers */ net_buf_simple_pull(&buf, BT_MESH_NET_HDR_LEN); - BT_DBG("%u bytes: %s", buf.len, bt_hex(buf.data, buf.len)); + LOG_DBG("%u bytes: %s", buf.len, bt_hex(buf.data, buf.len)); if (buf.len < 1) { - BT_WARN("Too short proxy configuration PDU"); + LOG_WRN("Too short proxy configuration PDU"); return; } @@ -289,19 +292,19 @@ static void proxy_msg_recv(struct bt_mesh_proxy_role *role) { switch (role->msg_type) { case BT_MESH_PROXY_NET_PDU: - BT_DBG("Mesh Network PDU"); + LOG_DBG("Mesh Network PDU"); bt_mesh_net_recv(&role->buf, 0, BT_MESH_NET_IF_PROXY); break; case BT_MESH_PROXY_BEACON: - BT_DBG("Mesh Beacon PDU"); + LOG_DBG("Mesh Beacon PDU"); bt_mesh_beacon_recv(&role->buf); break; case BT_MESH_PROXY_CONFIG: - BT_DBG("Mesh Configuration PDU"); + LOG_DBG("Mesh Configuration PDU"); proxy_cfg(role); break; default: - BT_WARN("Unhandled Message Type 0x%02x", role->msg_type); + LOG_WRN("Unhandled Message Type 0x%02x", role->msg_type); break; } } @@ -385,7 +388,7 @@ void bt_mesh_proxy_identity_stop(struct bt_mesh_subnet *sub) int bt_mesh_proxy_identity_enable(void) { - BT_DBG(""); + LOG_DBG(""); if (!bt_mesh_is_provisioned()) { return -EAGAIN; @@ -430,7 +433,7 @@ static int node_id_adv(struct bt_mesh_subnet *sub, int32_t duration) uint8_t tmp[16]; int err; - BT_DBG(""); + LOG_DBG(""); proxy_svc_data[2] = BT_MESH_ID_TYPE_NODE; @@ -454,7 +457,7 @@ static int node_id_adv(struct bt_mesh_subnet *sub, int32_t duration) err = bt_mesh_adv_gatt_start(&fast_adv_param, duration, node_id_ad, ARRAY_SIZE(node_id_ad), NULL, 0); if (err) { - BT_WARN("Failed to advertise using Node ID (err %d)", err); + LOG_WRN("Failed to advertise using Node ID (err %d)", err); return err; } @@ -469,19 +472,18 @@ static int net_id_adv(struct bt_mesh_subnet *sub, int32_t duration) }; int err; - BT_DBG(""); + LOG_DBG(""); proxy_svc_data[2] = BT_MESH_ID_TYPE_NET; - BT_DBG("Advertising with NetId %s", - bt_hex(sub->keys[SUBNET_KEY_TX_IDX(sub)].net_id, 8)); + LOG_DBG("Advertising with NetId %s", bt_hex(sub->keys[SUBNET_KEY_TX_IDX(sub)].net_id, 8)); memcpy(proxy_svc_data + 3, sub->keys[SUBNET_KEY_TX_IDX(sub)].net_id, 8); err = bt_mesh_adv_gatt_start(&slow_adv_param, duration, net_id_ad, ARRAY_SIZE(net_id_ad), NULL, 0); if (err) { - BT_WARN("Failed to advertise using Network ID (err %d)", err); + LOG_WRN("Failed to advertise using Network ID (err %d)", err); return err; } @@ -554,21 +556,21 @@ static int gatt_proxy_advertise(struct bt_mesh_subnet *sub) int err = -EBUSY; bool planned = false; - BT_DBG(""); + LOG_DBG(""); if (!bt_mesh_proxy_has_avail_conn()) { - BT_DBG("Connectable advertising deferred (max connections)"); + LOG_DBG("Connectable advertising deferred (max connections)"); return -ENOMEM; } sub = beacon_sub ? beacon_sub : bt_mesh_subnet_next(beacon_sub); if (!sub) { - BT_WARN("No subnets to advertise on"); + LOG_WRN("No subnets to advertise on"); return -ENOENT; } subnet_count = sub_count(); - BT_DBG("sub_count %u", subnet_count); + LOG_DBG("sub_count %u", subnet_count); if (subnet_count > 1) { int32_t max_timeout; @@ -592,13 +594,13 @@ static int gatt_proxy_advertise(struct bt_mesh_subnet *sub) if (active < NODE_ID_TIMEOUT) { remaining = MIN(remaining, NODE_ID_TIMEOUT - active); - BT_DBG("Node ID active for %u ms, %d ms remaining", - active, remaining); + LOG_DBG("Node ID active for %u ms, %d ms remaining", active, + remaining); err = node_id_adv(sub, remaining); planned = true; } else { bt_mesh_proxy_identity_stop(sub); - BT_DBG("Node ID stopped"); + LOG_DBG("Node ID stopped"); } } @@ -615,7 +617,7 @@ static int gatt_proxy_advertise(struct bt_mesh_subnet *sub) beacon_sub = bt_mesh_subnet_next(sub); if (planned) { - BT_DBG("Advertising %d ms for net_idx 0x%04x", remaining, sub->net_idx); + LOG_DBG("Advertising %d ms for net_idx 0x%04x", remaining, sub->net_idx); return err; } @@ -643,7 +645,7 @@ BT_MESH_SUBNET_CB_DEFINE(gatt_services) = { static void proxy_ccc_changed(const struct bt_gatt_attr *attr, uint16_t value) { - BT_DBG("value 0x%04x", value); + LOG_DBG("value 0x%04x", value); } static ssize_t proxy_ccc_write(struct bt_conn *conn, @@ -651,10 +653,10 @@ static ssize_t proxy_ccc_write(struct bt_conn *conn, { struct bt_mesh_proxy_client *client; - BT_DBG("value: 0x%04x", value); + LOG_DBG("value: 0x%04x", value); if (value != BT_GATT_CCC_NOTIFY) { - BT_WARN("Client wrote 0x%04x instead enabling notify", value); + LOG_WRN("Client wrote 0x%04x instead enabling notify", value); return BT_GATT_ERR(BT_ATT_ERR_VALUE_NOT_ALLOWED); } @@ -693,7 +695,7 @@ int bt_mesh_proxy_gatt_enable(void) { int i; - BT_DBG(""); + LOG_DBG(""); if (!bt_mesh_is_provisioned()) { return -ENOTSUP; @@ -719,7 +721,7 @@ void bt_mesh_proxy_gatt_disconnect(void) { int i; - BT_DBG(""); + LOG_DBG(""); for (i = 0; i < ARRAY_SIZE(clients); i++) { struct bt_mesh_proxy_client *client = &clients[i]; @@ -735,7 +737,7 @@ void bt_mesh_proxy_gatt_disconnect(void) int bt_mesh_proxy_gatt_disable(void) { - BT_DBG(""); + LOG_DBG(""); if (!service_registered) { return -EALREADY; @@ -757,7 +759,7 @@ void bt_mesh_proxy_addr_add(struct net_buf_simple *buf, uint16_t addr) client = find_client(cli->conn); - BT_DBG("filter_type %u addr 0x%04x", client->filter_type, addr); + LOG_DBG("filter_type %u addr 0x%04x", client->filter_type, addr); if (client->filter_type == ACCEPT) { filter_add(client, addr); @@ -771,7 +773,7 @@ static bool client_filter_match(struct bt_mesh_proxy_client *client, { int i; - BT_DBG("filter_type %u addr 0x%04x", client->filter_type, addr); + LOG_DBG("filter_type %u addr 0x%04x", client->filter_type, addr); if (client->filter_type == REJECT) { for (i = 0; i < ARRAY_SIZE(client->filter); i++) { @@ -803,7 +805,7 @@ bool bt_mesh_proxy_relay(struct net_buf *buf, uint16_t dst) bool relayed = false; int i; - BT_DBG("%u bytes to dst 0x%04x", buf->len, dst); + LOG_DBG("%u bytes to dst 0x%04x", buf->len, dst); for (i = 0; i < ARRAY_SIZE(clients); i++) { struct bt_mesh_proxy_client *client = &clients[i]; @@ -837,7 +839,7 @@ static void gatt_connected(struct bt_conn *conn, uint8_t err) return; } - BT_DBG("conn %p err 0x%02x", (void *)conn, err); + LOG_DBG("conn %p err 0x%02x", (void *)conn, err); client = find_client(conn); @@ -878,7 +880,7 @@ static int proxy_send(struct bt_conn *conn, const void *data, uint16_t len, bt_gatt_complete_func_t end, void *user_data) { - BT_DBG("%u bytes: %s", len, bt_hex(data, len)); + LOG_DBG("%u bytes: %s", len, bt_hex(data, len)); struct bt_gatt_notify_params params = { .data = data, @@ -893,7 +895,7 @@ static int proxy_send(struct bt_conn *conn, int bt_mesh_proxy_adv_start(void) { - BT_DBG(""); + LOG_DBG(""); if (!service_registered || !bt_mesh_is_provisioned()) { return -ENOTSUP; diff --git a/subsys/bluetooth/mesh/rpl.c b/subsys/bluetooth/mesh/rpl.c index 84aa912383e..43c280af135 100644 --- a/subsys/bluetooth/mesh/rpl.c +++ b/subsys/bluetooth/mesh/rpl.c @@ -19,16 +19,16 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_RPL) -#define LOG_MODULE_NAME bt_mesh_rpl -#include "common/log.h" - #include "mesh.h" #include "adv.h" #include "net.h" #include "rpl.h" #include "settings.h" +#define LOG_LEVEL CONFIG_BT_MESH_RPL_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_mesh_rpl); + /* Replay Protection List information for persistent storage. */ struct rpl_val { uint32_t seq:24, @@ -56,9 +56,9 @@ static void clear_rpl(struct bt_mesh_rpl *rpl) snprintk(path, sizeof(path), "bt/mesh/RPL/%x", rpl->src); err = settings_delete(path); if (err) { - BT_ERR("Failed to clear RPL"); + LOG_ERR("Failed to clear RPL"); } else { - BT_DBG("Cleared RPL"); + LOG_DBG("Cleared RPL"); } (void)memset(rpl, 0, sizeof(*rpl)); @@ -152,13 +152,13 @@ bool bt_mesh_rpl_check(struct bt_mesh_net_rx *rx, } } - BT_ERR("RPL is full!"); + LOG_ERR("RPL is full!"); return true; } void bt_mesh_rpl_clear(void) { - BT_DBG(""); + LOG_DBG(""); if (!IS_ENABLED(CONFIG_BT_SETTINGS)) { (void)memset(replay_list, 0, sizeof(replay_list)); @@ -245,7 +245,7 @@ static int rpl_set(const char *name, size_t len_rd, uint16_t src; if (!name) { - BT_ERR("Insufficient number of arguments"); + LOG_ERR("Insufficient number of arguments"); return -ENOENT; } @@ -253,11 +253,11 @@ static int rpl_set(const char *name, size_t len_rd, entry = bt_mesh_rpl_find(src); if (len_rd == 0) { - BT_DBG("val (null)"); + LOG_DBG("val (null)"); if (entry) { (void)memset(entry, 0, sizeof(*entry)); } else { - BT_WARN("Unable to find RPL entry for 0x%04x", src); + LOG_WRN("Unable to find RPL entry for 0x%04x", src); } return 0; @@ -266,22 +266,22 @@ static int rpl_set(const char *name, size_t len_rd, if (!entry) { entry = bt_mesh_rpl_alloc(src); if (!entry) { - BT_ERR("Unable to allocate RPL entry for 0x%04x", src); + LOG_ERR("Unable to allocate RPL entry for 0x%04x", src); return -ENOMEM; } } err = bt_mesh_settings_set(read_cb, cb_arg, &rpl, sizeof(rpl)); if (err) { - BT_ERR("Failed to set `net`"); + LOG_ERR("Failed to set `net`"); return err; } entry->seq = rpl.seq; entry->old_iv = rpl.old_iv; - BT_DBG("RPL entry for 0x%04x: Seq 0x%06x old_iv %u", entry->src, - entry->seq, entry->old_iv); + LOG_DBG("RPL entry for 0x%04x: Seq 0x%06x old_iv %u", entry->src, entry->seq, + entry->old_iv); return 0; } @@ -298,8 +298,7 @@ static void store_rpl(struct bt_mesh_rpl *entry) return; } - BT_DBG("src 0x%04x seq 0x%06x old_iv %u", entry->src, entry->seq, - entry->old_iv); + LOG_DBG("src 0x%04x seq 0x%06x old_iv %u", entry->src, entry->seq, entry->old_iv); rpl.seq = entry->seq; rpl.old_iv = entry->old_iv; @@ -308,9 +307,9 @@ static void store_rpl(struct bt_mesh_rpl *entry) err = settings_save_one(path, &rpl, sizeof(rpl)); if (err) { - BT_ERR("Failed to store RPL %s value", path); + LOG_ERR("Failed to store RPL %s value", path); } else { - BT_DBG("Stored RPL %s value", path); + LOG_DBG("Stored RPL %s value", path); } } diff --git a/subsys/bluetooth/mesh/settings.c b/subsys/bluetooth/mesh/settings.c index a5c295ce23e..722715b62e5 100644 --- a/subsys/bluetooth/mesh/settings.c +++ b/subsys/bluetooth/mesh/settings.c @@ -9,11 +9,9 @@ #include #include -#include +#include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_SETTINGS) -#define LOG_MODULE_NAME bt_mesh_settings -#include "common/log.h" +#include #include "host/hci_core.h" #include "mesh.h" @@ -31,6 +29,10 @@ #include "settings.h" #include "cfg.h" +#define LOG_LEVEL CONFIG_BT_MESH_SETTINGS_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_mesh_settings); + #ifdef CONFIG_BT_MESH_RPL_STORE_TIMEOUT #define RPL_STORE_TIMEOUT CONFIG_BT_MESH_RPL_STORE_TIMEOUT #else @@ -47,14 +49,14 @@ int bt_mesh_settings_set(settings_read_cb read_cb, void *cb_arg, len = read_cb(cb_arg, out, read_len); if (len < 0) { - BT_ERR("Failed to read value (err %zd)", len); + LOG_ERR("Failed to read value (err %zd)", len); return len; } LOG_HEXDUMP_DBG(out, len, "val"); if (len != read_len) { - BT_ERR("Unexpected value length (%zd != %zu)", len, read_len); + LOG_ERR("Unexpected value length (%zd != %zu)", len, read_len); return -EINVAL; } @@ -126,7 +128,7 @@ void bt_mesh_settings_store_schedule(enum bt_mesh_settings_flag flag) } remaining_ms = k_ticks_to_ms_floor32(k_work_delayable_remaining_get(&pending_store)); - BT_DBG("Waiting %u ms vs rem %u ms", timeout_ms, remaining_ms); + LOG_DBG("Waiting %u ms vs rem %u ms", timeout_ms, remaining_ms); /* If the new deadline is sooner, override any existing * deadline; otherwise schedule without changing any existing @@ -146,7 +148,7 @@ void bt_mesh_settings_store_cancel(enum bt_mesh_settings_flag flag) static void store_pending(struct k_work *work) { - BT_DBG(""); + LOG_DBG(""); if (IS_ENABLED(CONFIG_BT_MESH_RPL_STORAGE_MODE_SETTINGS) && atomic_test_and_clear_bit(pending_flags, BT_MESH_SETTINGS_RPL_PENDING)) { diff --git a/subsys/bluetooth/mesh/subnet.c b/subsys/bluetooth/mesh/subnet.c index ee2daf149a6..ebf0ee07510 100644 --- a/subsys/bluetooth/mesh/subnet.c +++ b/subsys/bluetooth/mesh/subnet.c @@ -19,9 +19,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_KEYS) -#define LOG_MODULE_NAME bt_mesh_net_keys -#include "common/log.h" #include "common/bt_str.h" #include "crypto.h" @@ -40,6 +37,10 @@ #include "host/ecc.h" #include "prov.h" +#define LOG_LEVEL CONFIG_BT_MESH_KEYS_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_mesh_net_keys); + /* Tracking of what storage changes are pending for Net Keys. We track this in * a separate array here instead of within the respective bt_mesh_subnet * struct itself, since once a key gets deleted its struct becomes invalid @@ -78,14 +79,14 @@ static void clear_net_key(uint16_t net_idx) char path[20]; int err; - BT_DBG("NetKeyIndex 0x%03x", net_idx); + LOG_DBG("NetKeyIndex 0x%03x", net_idx); snprintk(path, sizeof(path), "bt/mesh/NetKey/%x", net_idx); err = settings_delete(path); if (err) { - BT_ERR("Failed to clear NetKeyIndex 0x%03x", net_idx); + LOG_ERR("Failed to clear NetKeyIndex 0x%03x", net_idx); } else { - BT_DBG("Cleared NetKeyIndex 0x%03x", net_idx); + LOG_DBG("Cleared NetKeyIndex 0x%03x", net_idx); } } @@ -98,11 +99,11 @@ static void store_subnet(uint16_t net_idx) sub = bt_mesh_subnet_get(net_idx); if (!sub) { - BT_WARN("NetKeyIndex 0x%03x not found", net_idx); + LOG_WRN("NetKeyIndex 0x%03x not found", net_idx); return; } - BT_DBG("NetKeyIndex 0x%03x", net_idx); + LOG_DBG("NetKeyIndex 0x%03x", net_idx); snprintk(path, sizeof(path), "bt/mesh/NetKey/%x", net_idx); @@ -113,9 +114,9 @@ static void store_subnet(uint16_t net_idx) err = settings_save_one(path, &key, sizeof(key)); if (err) { - BT_ERR("Failed to store NetKey value"); + LOG_ERR("Failed to store NetKey value"); } else { - BT_DBG("Stored NetKey value"); + LOG_DBG("Stored NetKey value"); } } @@ -164,7 +165,7 @@ static void update_subnet_settings(uint16_t net_idx, bool store) struct net_key_update *update, *free_slot; uint8_t clear = store ? 0U : 1U; - BT_DBG("NetKeyIndex 0x%03x", net_idx); + LOG_DBG("NetKeyIndex 0x%03x", net_idx); update = net_key_update_find(net_idx, &free_slot); if (update) { @@ -197,7 +198,7 @@ void bt_mesh_subnet_store(uint16_t net_idx) static void key_refresh(struct bt_mesh_subnet *sub, uint8_t new_phase) { - BT_DBG("Phase 0x%02x -> 0x%02x", sub->kr_phase, new_phase); + LOG_DBG("Phase 0x%02x -> 0x%02x", sub->kr_phase, new_phase); switch (new_phase) { /* Added second set of keys */ @@ -225,7 +226,7 @@ static void key_refresh(struct bt_mesh_subnet *sub, uint8_t new_phase) } if (IS_ENABLED(CONFIG_BT_SETTINGS)) { - BT_DBG("Storing Updated NetKey persistently"); + LOG_DBG("Storing Updated NetKey persistently"); bt_mesh_subnet_store(sub->net_idx); } } @@ -292,41 +293,40 @@ static int net_keys_create(struct bt_mesh_subnet_keys *keys, err = msg_cred_create(&keys->msg, &p, 1, key); if (err) { - BT_ERR("Unable to generate NID, EncKey & PrivacyKey"); + LOG_ERR("Unable to generate NID, EncKey & PrivacyKey"); return err; } memcpy(keys->net, key, 16); - BT_DBG("NID 0x%02x EncKey %s", keys->msg.nid, - bt_hex(keys->msg.enc, 16)); - BT_DBG("PrivacyKey %s", bt_hex(keys->msg.privacy, 16)); + LOG_DBG("NID 0x%02x EncKey %s", keys->msg.nid, bt_hex(keys->msg.enc, 16)); + LOG_DBG("PrivacyKey %s", bt_hex(keys->msg.privacy, 16)); err = bt_mesh_k3(key, keys->net_id); if (err) { - BT_ERR("Unable to generate Net ID"); + LOG_ERR("Unable to generate Net ID"); return err; } - BT_DBG("NetID %s", bt_hex(keys->net_id, 8)); + LOG_DBG("NetID %s", bt_hex(keys->net_id, 8)); #if defined(CONFIG_BT_MESH_GATT_PROXY) err = bt_mesh_identity_key(key, keys->identity); if (err) { - BT_ERR("Unable to generate IdentityKey"); + LOG_ERR("Unable to generate IdentityKey"); return err; } - BT_DBG("IdentityKey %s", bt_hex(keys->identity, 16)); + LOG_DBG("IdentityKey %s", bt_hex(keys->identity, 16)); #endif /* GATT_PROXY */ err = bt_mesh_beacon_key(key, keys->beacon); if (err) { - BT_ERR("Unable to generate beacon key"); + LOG_ERR("Unable to generate beacon key"); return err; } - BT_DBG("BeaconKey %s", bt_hex(keys->beacon, 16)); + LOG_DBG("BeaconKey %s", bt_hex(keys->beacon, 16)); keys->valid = 1U; @@ -338,7 +338,7 @@ uint8_t bt_mesh_subnet_add(uint16_t net_idx, const uint8_t key[16]) struct bt_mesh_subnet *sub = NULL; int err; - BT_DBG("0x%03x", net_idx); + LOG_DBG("0x%03x", net_idx); sub = subnet_alloc(net_idx); if (!sub) { @@ -370,7 +370,7 @@ uint8_t bt_mesh_subnet_add(uint16_t net_idx, const uint8_t key[16]) subnet_evt(sub, BT_MESH_KEY_ADDED); if (IS_ENABLED(CONFIG_BT_SETTINGS)) { - BT_DBG("Storing NetKey persistently"); + LOG_DBG("Storing NetKey persistently"); bt_mesh_subnet_store(sub->net_idx); } @@ -387,7 +387,7 @@ uint8_t bt_mesh_subnet_update(uint16_t net_idx, const uint8_t key[16]) struct bt_mesh_subnet *sub; int err; - BT_DBG("0x%03x", net_idx); + LOG_DBG("0x%03x", net_idx); sub = bt_mesh_subnet_get(net_idx); if (!sub) { @@ -430,7 +430,7 @@ uint8_t bt_mesh_subnet_del(uint16_t net_idx) { struct bt_mesh_subnet *sub; - BT_DBG("0x%03x", net_idx); + LOG_DBG("0x%03x", net_idx); sub = bt_mesh_subnet_get(net_idx); if (!sub) { @@ -471,7 +471,7 @@ uint8_t bt_mesh_subnet_kr_phase_set(uint16_t net_idx, uint8_t *phase) }; struct bt_mesh_subnet *sub; - BT_DBG("0x%03x", net_idx); + LOG_DBG("0x%03x", net_idx); sub = bt_mesh_subnet_get(net_idx); if (!sub) { @@ -492,8 +492,7 @@ uint8_t bt_mesh_subnet_kr_phase_set(uint16_t net_idx, uint8_t *phase) return STATUS_SUCCESS; } - BT_WARN("Invalid KR transition: 0x%02x -> 0x%02x", sub->kr_phase, - *phase); + LOG_WRN("Invalid KR transition: 0x%02x -> 0x%02x", sub->kr_phase, *phase); *phase = sub->kr_phase; @@ -718,7 +717,7 @@ bool bt_mesh_net_cred_find(struct bt_mesh_net_rx *rx, struct net_buf_simple *in, { int i, j; - BT_DBG(""); + LOG_DBG(""); #if defined(CONFIG_BT_MESH_LOW_POWER) if (bt_mesh_lpn_waiting_update()) { @@ -801,18 +800,18 @@ static int net_key_set(const char *name, size_t len_rd, uint16_t net_idx; if (!name) { - BT_ERR("Insufficient number of arguments"); + LOG_ERR("Insufficient number of arguments"); return -ENOENT; } net_idx = strtol(name, NULL, 16); err = bt_mesh_settings_set(read_cb, cb_arg, &key, sizeof(key)); if (err) { - BT_ERR("Failed to set \'net-key\'"); + LOG_ERR("Failed to set \'net-key\'"); return err; } - BT_DBG("NetKeyIndex 0x%03x recovered from storage", net_idx); + LOG_DBG("NetKeyIndex 0x%03x recovered from storage", net_idx); return bt_mesh_subnet_set( net_idx, key.kr_phase, key.val[0], diff --git a/subsys/bluetooth/mesh/test.c b/subsys/bluetooth/mesh/test.c index d8f302b5e26..2c12da01fca 100644 --- a/subsys/bluetooth/mesh/test.c +++ b/subsys/bluetooth/mesh/test.c @@ -9,9 +9,6 @@ #include -#define LOG_MODULE_NAME bt_mesh_test -#include "common/log.h" - #include "mesh.h" #include "test.h" diff --git a/subsys/bluetooth/mesh/transport.c b/subsys/bluetooth/mesh/transport.c index e615523bdee..a221ce5144c 100644 --- a/subsys/bluetooth/mesh/transport.c +++ b/subsys/bluetooth/mesh/transport.c @@ -17,9 +17,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_TRANS) -#define LOG_MODULE_NAME bt_mesh_transport -#include "common/log.h" #include "common/bt_str.h" #include "host/testing.h" @@ -38,6 +35,10 @@ #include "heartbeat.h" #include "transport.h" +#define LOG_LEVEL CONFIG_BT_MESH_TRANS_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_mesh_transport); + #define AID_MASK ((uint8_t)(BIT_MASK(6))) #define SEG(data) ((data)[0] >> 7) @@ -148,7 +149,7 @@ static int send_unseg(struct bt_mesh_net_tx *tx, struct net_buf_simple *sdu, buf = bt_mesh_adv_create(BT_MESH_ADV_DATA, BT_MESH_LOCAL_ADV, tx->xmit, BUF_TIMEOUT); if (!buf) { - BT_ERR("Out of network buffers"); + LOG_ERR("Out of network buffers"); return -ENOBUFS; } @@ -169,11 +170,11 @@ static int send_unseg(struct bt_mesh_net_tx *tx, struct net_buf_simple *sdu, tx->src, tx->ctx->addr, NULL, 1)) { if (BT_MESH_ADDR_IS_UNICAST(tx->ctx->addr)) { - BT_ERR("Not enough space in Friend Queue"); + LOG_ERR("Not enough space in Friend Queue"); net_buf_unref(buf); return -ENOBUFS; } else { - BT_WARN("No space in Friend Queue"); + LOG_WRN("No space in Friend Queue"); goto send; } } @@ -244,8 +245,7 @@ static void seg_tx_unblock_check(struct seg_tx *tx) } if (blocked) { - BT_DBG("Unblocked 0x%04x", - (uint16_t)(blocked->seq_auth & TRANS_SEQ_ZERO_MASK)); + LOG_DBG("Unblocked 0x%04x", (uint16_t)(blocked->seq_auth & TRANS_SEQ_ZERO_MASK)); blocked->blocked = false; k_work_reschedule(&blocked->retransmit, K_NO_WAIT); } @@ -279,7 +279,7 @@ static void seg_tx_reset(struct seg_tx *tx) tx->seg_send_started = 0; if (atomic_test_and_clear_bit(bt_mesh.flags, BT_MESH_IVU_PENDING)) { - BT_DBG("Proceeding with pending IV Update"); + LOG_DBG("Proceeding with pending IV Update"); /* bt_mesh_net_iv_update() will re-enable the flag if this * wasn't the only transfer. */ @@ -307,7 +307,7 @@ static void schedule_retransmit(struct seg_tx *tx) return; } - BT_DBG(""); + LOG_DBG(""); /* If we haven't gone through all the segments for this attempt yet, * (likely because of a buffer allocation failure or because we @@ -391,7 +391,7 @@ static void seg_tx_send_unacked(struct seg_tx *tx) if (!tx->attempts) { if (BT_MESH_ADDR_IS_UNICAST(tx->dst)) { - BT_ERR("Ran out of retransmit attempts"); + LOG_ERR("Ran out of retransmit attempts"); seg_tx_complete(tx, -ETIMEDOUT); } else { /* Segmented sending to groups doesn't have acks, so @@ -403,8 +403,8 @@ static void seg_tx_send_unacked(struct seg_tx *tx) return; } - BT_DBG("SeqZero: 0x%04x Attempts: %u", - (uint16_t)(tx->seq_auth & TRANS_SEQ_ZERO_MASK), tx->attempts); + LOG_DBG("SeqZero: 0x%04x Attempts: %u", (uint16_t)(tx->seq_auth & TRANS_SEQ_ZERO_MASK), + tx->attempts); while (tx->seg_o <= tx->seg_n) { struct net_buf *seg; @@ -419,18 +419,18 @@ static void seg_tx_send_unacked(struct seg_tx *tx) seg = bt_mesh_adv_create(BT_MESH_ADV_DATA, BT_MESH_LOCAL_ADV, tx->xmit, BUF_TIMEOUT); if (!seg) { - BT_DBG("Allocating segment failed"); + LOG_DBG("Allocating segment failed"); goto end; } net_buf_reserve(seg, BT_MESH_NET_HDR_LEN); seg_tx_buf_build(tx, tx->seg_o, &seg->b); - BT_DBG("Sending %u/%u", tx->seg_o, tx->seg_n); + LOG_DBG("Sending %u/%u", tx->seg_o, tx->seg_n); err = bt_mesh_net_send(&net_tx, seg, &seg_sent_cb, tx); if (err) { - BT_DBG("Sending segment failed"); + LOG_DBG("Sending segment failed"); goto end; } @@ -469,9 +469,8 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, struct net_buf_simple *sdu, uint8_t seg_o; int i; - BT_DBG("src 0x%04x dst 0x%04x app_idx 0x%04x aszmic %u sdu_len %u", - net_tx->src, net_tx->ctx->addr, net_tx->ctx->app_idx, - net_tx->aszmic, sdu->len); + LOG_DBG("src 0x%04x dst 0x%04x app_idx 0x%04x aszmic %u sdu_len %u", net_tx->src, + net_tx->ctx->addr, net_tx->ctx->app_idx, net_tx->aszmic, sdu->len); for (tx = NULL, i = 0; i < ARRAY_SIZE(seg_tx); i++) { if (seg_tx[i].nack_count) { @@ -483,7 +482,7 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, struct net_buf_simple *sdu, } if (!tx) { - BT_ERR("No multi-segment message contexts available"); + LOG_ERR("No multi-segment message contexts available"); return -EBUSY; } @@ -515,16 +514,15 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, struct net_buf_simple *sdu, tx->ctl = !!ctl_op; tx->ttl = net_tx->ctx->send_ttl; - BT_DBG("SeqZero 0x%04x (segs: %u)", - (uint16_t)(tx->seq_auth & TRANS_SEQ_ZERO_MASK), tx->nack_count); + LOG_DBG("SeqZero 0x%04x (segs: %u)", (uint16_t)(tx->seq_auth & TRANS_SEQ_ZERO_MASK), + tx->nack_count); if (IS_ENABLED(CONFIG_BT_MESH_FRIEND) && !bt_mesh_friend_queue_has_space(tx->sub->net_idx, net_tx->src, tx->dst, &tx->seq_auth, tx->seg_n + 1) && BT_MESH_ADDR_IS_UNICAST(tx->dst)) { - BT_ERR("Not enough space in Friend Queue for %u segments", - tx->seg_n + 1); + LOG_ERR("Not enough space in Friend Queue for %u segments", tx->seg_n + 1); seg_tx_reset(tx); return -ENOBUFS; } @@ -536,7 +534,7 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, struct net_buf_simple *sdu, err = k_mem_slab_alloc(&segs, &buf, BUF_TIMEOUT); if (err) { - BT_ERR("Out of segment buffers"); + LOG_ERR("Out of segment buffers"); seg_tx_reset(tx); return -ENOBUFS; } @@ -544,7 +542,7 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, struct net_buf_simple *sdu, len = MIN(sdu->len, seg_len(!!ctl_op)); memcpy(buf, net_buf_simple_pull_mem(sdu, len), len); - BT_DBG("seg %u: %s", seg_o, bt_hex(buf, len)); + LOG_DBG("seg %u: %s", seg_o, bt_hex(buf, len)); tx->seg[seg_o] = buf; @@ -593,7 +591,7 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, struct net_buf_simple *sdu, * this one is blocked. */ bt_mesh_next_seq(); - BT_DBG("Blocked."); + LOG_DBG("Blocked."); return 0; } @@ -629,24 +627,24 @@ int bt_mesh_trans_send(struct bt_mesh_net_tx *tx, struct net_buf_simple *msg, int err; if (msg->len < 1) { - BT_ERR("Zero-length SDU not allowed"); + LOG_ERR("Zero-length SDU not allowed"); return -EINVAL; } if (msg->len > BT_MESH_TX_SDU_MAX - BT_MESH_MIC_SHORT) { - BT_ERR("Message too big: %u", msg->len); + LOG_ERR("Message too big: %u", msg->len); return -EMSGSIZE; } if (net_buf_simple_tailroom(msg) < BT_MESH_MIC_SHORT) { - BT_ERR("Insufficient tailroom for Transport MIC"); + LOG_ERR("Insufficient tailroom for Transport MIC"); return -EINVAL; } if (tx->ctx->send_ttl == BT_MESH_TTL_DEFAULT) { tx->ctx->send_ttl = bt_mesh_default_ttl_get(); } else if (tx->ctx->send_ttl > BT_MESH_TTL_MAX) { - BT_ERR("TTL too large (max 127)"); + LOG_ERR("TTL too large (max 127)"); return -EINVAL; } @@ -657,7 +655,7 @@ int bt_mesh_trans_send(struct bt_mesh_net_tx *tx, struct net_buf_simple *msg, if (tx->ctx->addr == BT_MESH_ADDR_UNASSIGNED || (!BT_MESH_ADDR_IS_UNICAST(tx->ctx->addr) && BT_MESH_IS_DEV_KEY(tx->ctx->app_idx))) { - BT_ERR("Invalid destination address"); + LOG_ERR("Invalid destination address"); return -EINVAL; } @@ -666,9 +664,9 @@ int bt_mesh_trans_send(struct bt_mesh_net_tx *tx, struct net_buf_simple *msg, return err; } - BT_DBG("net_idx 0x%04x app_idx 0x%04x dst 0x%04x", tx->sub->net_idx, - tx->ctx->app_idx, tx->ctx->addr); - BT_DBG("len %u: %s", msg->len, bt_hex(msg->data, msg->len)); + LOG_DBG("net_idx 0x%04x app_idx 0x%04x dst 0x%04x", tx->sub->net_idx, tx->ctx->app_idx, + tx->ctx->addr); + LOG_DBG("len %u: %s", msg->len, bt_hex(msg->data, msg->len)); tx->xmit = bt_mesh_net_transmit_get(); tx->aid = aid; @@ -751,7 +749,7 @@ static int sdu_recv(struct bt_mesh_net_rx *rx, uint8_t hdr, uint8_t aszmic, .seg = seg, }; - BT_DBG("AKF %u AID 0x%02x", !ctx.crypto.dev_key, AID(&hdr)); + LOG_DBG("AKF %u AID 0x%02x", !ctx.crypto.dev_key, AID(&hdr)); if (!rx->local_match) { return 0; @@ -764,11 +762,11 @@ static int sdu_recv(struct bt_mesh_net_rx *rx, uint8_t hdr, uint8_t aszmic, rx->ctx.app_idx = bt_mesh_app_key_find(ctx.crypto.dev_key, AID(&hdr), rx, sdu_try_decrypt, &ctx); if (rx->ctx.app_idx == BT_MESH_KEY_UNUSED) { - BT_DBG("No matching AppKey"); + LOG_DBG("No matching AppKey"); return 0; } - BT_DBG("Decrypted (AppIdx: 0x%03x)", rx->ctx.app_idx); + LOG_DBG("Decrypted (AppIdx: 0x%03x)", rx->ctx.app_idx); bt_mesh_model_recv(rx, sdu); @@ -815,7 +813,7 @@ static int trans_ack(struct bt_mesh_net_rx *rx, uint8_t hdr, uint8_t obo; if (buf->len < 6) { - BT_ERR("Too short ack message"); + LOG_ERR("Too short ack message"); return -EINVAL; } @@ -824,7 +822,7 @@ static int trans_ack(struct bt_mesh_net_rx *rx, uint8_t hdr, seq_zero = (seq_zero >> 2) & TRANS_SEQ_ZERO_MASK; if (IS_ENABLED(CONFIG_BT_MESH_FRIEND) && rx->friend_match) { - BT_DBG("Ack for LPN 0x%04x of this Friend", rx->ctx.recv_dst); + LOG_DBG("Ack for LPN 0x%04x of this Friend", rx->ctx.recv_dst); /* Best effort - we don't have enough info for true SeqAuth */ *seq_auth = SEQ_AUTH(BT_MESH_NET_IVI_RX(rx), seq_zero); return 0; @@ -832,35 +830,35 @@ static int trans_ack(struct bt_mesh_net_rx *rx, uint8_t hdr, ack = net_buf_simple_pull_be32(buf); - BT_DBG("OBO %u seq_zero 0x%04x ack 0x%08x", obo, seq_zero, ack); + LOG_DBG("OBO %u seq_zero 0x%04x ack 0x%08x", obo, seq_zero, ack); tx = seg_tx_lookup(seq_zero, obo, rx->ctx.addr); if (!tx) { - BT_WARN("No matching TX context for ack"); + LOG_WRN("No matching TX context for ack"); return -EINVAL; } if (!BT_MESH_ADDR_IS_UNICAST(tx->dst)) { - BT_ERR("Received ack for group seg"); + LOG_ERR("Received ack for group seg"); return -EINVAL; } *seq_auth = tx->seq_auth; if (!ack) { - BT_WARN("SDU canceled"); + LOG_WRN("SDU canceled"); seg_tx_complete(tx, -ECANCELED); return 0; } if (find_msb_set(ack) - 1 > tx->seg_n) { - BT_ERR("Too large segment number in ack"); + LOG_ERR("Too large segment number in ack"); return -EINVAL; } while ((bit = find_lsb_set(ack))) { if (tx->seg[bit - 1]) { - BT_DBG("seg %u/%u acked", bit - 1, tx->seg_n); + LOG_DBG("seg %u/%u acked", bit - 1, tx->seg_n); seg_tx_done(tx, bit - 1); } @@ -878,7 +876,7 @@ static int trans_ack(struct bt_mesh_net_rx *rx, uint8_t hdr, k_work_reschedule(&tx->retransmit, K_NO_WAIT); } } else { - BT_DBG("SDU TX complete"); + LOG_DBG("SDU TX complete"); seg_tx_complete(tx, 0); } @@ -890,7 +888,7 @@ static int ctl_recv(struct bt_mesh_net_rx *rx, uint8_t hdr, { uint8_t ctl_op = TRANS_CTL_OP(&hdr); - BT_DBG("OpCode 0x%02x len %u", ctl_op, buf->len); + LOG_DBG("OpCode 0x%02x len %u", ctl_op, buf->len); switch (ctl_op) { case TRANS_CTL_OP_ACK: @@ -932,7 +930,7 @@ static int ctl_recv(struct bt_mesh_net_rx *rx, uint8_t hdr, } if (!rx->friend_cred) { - BT_WARN("Message from friend with wrong credentials"); + LOG_WRN("Message from friend with wrong credentials"); return -EINVAL; } @@ -945,7 +943,7 @@ static int ctl_recv(struct bt_mesh_net_rx *rx, uint8_t hdr, } #endif /* CONFIG_BT_MESH_LOW_POWER */ - BT_WARN("Unhandled TransOpCode 0x%02x", ctl_op); + LOG_WRN("Unhandled TransOpCode 0x%02x", ctl_op); return -ENOENT; } @@ -956,16 +954,16 @@ static int trans_unseg(struct net_buf_simple *buf, struct bt_mesh_net_rx *rx, NET_BUF_SIMPLE_DEFINE_STATIC(sdu, BT_MESH_SDU_UNSEG_MAX); uint8_t hdr; - BT_DBG("AFK %u AID 0x%02x", AKF(buf->data), AID(buf->data)); + LOG_DBG("AFK %u AID 0x%02x", AKF(buf->data), AID(buf->data)); if (buf->len < 1) { - BT_ERR("Too small unsegmented PDU"); + LOG_ERR("Too small unsegmented PDU"); return -EINVAL; } if (bt_mesh_rpl_check(rx, NULL)) { - BT_WARN("Replay: src 0x%04x dst 0x%04x seq 0x%06x", - rx->ctx.addr, rx->ctx.recv_dst, rx->seq); + LOG_WRN("Replay: src 0x%04x dst 0x%04x seq 0x%06x", rx->ctx.addr, rx->ctx.recv_dst, + rx->seq); return -EINVAL; } @@ -976,7 +974,7 @@ static int trans_unseg(struct net_buf_simple *buf, struct bt_mesh_net_rx *rx, } if (buf->len < 1 + APP_MIC_LEN(0)) { - BT_ERR("Too short SDU + MIC"); + LOG_ERR("Too short SDU + MIC"); return -EINVAL; } @@ -1022,7 +1020,7 @@ int bt_mesh_ctl_send(struct bt_mesh_net_tx *tx, uint8_t ctl_op, void *data, if (tx->ctx->send_ttl == BT_MESH_TTL_DEFAULT) { tx->ctx->send_ttl = bt_mesh_default_ttl_get(); } else if (tx->ctx->send_ttl > BT_MESH_TTL_MAX) { - BT_ERR("TTL too large (max 127)"); + LOG_ERR("TTL too large (max 127)"); return -EINVAL; } @@ -1036,13 +1034,13 @@ int bt_mesh_ctl_send(struct bt_mesh_net_tx *tx, uint8_t ctl_op, void *data, if (tx->ctx->addr == BT_MESH_ADDR_UNASSIGNED || BT_MESH_ADDR_IS_VIRTUAL(tx->ctx->addr)) { - BT_ERR("Invalid destination address"); + LOG_ERR("Invalid destination address"); return -EINVAL; } - BT_DBG("src 0x%04x dst 0x%04x ttl 0x%02x ctl 0x%02x", tx->src, - tx->ctx->addr, tx->ctx->send_ttl, ctl_op); - BT_DBG("len %zu: %s", data_len, bt_hex(data, data_len)); + LOG_DBG("src 0x%04x dst 0x%04x ttl 0x%02x ctl 0x%02x", tx->src, tx->ctx->addr, + tx->ctx->send_ttl, ctl_op); + LOG_DBG("len %zu: %s", data_len, bt_hex(data, data_len)); if (tx->ctx->send_rel) { return send_seg(tx, &buf, cb, cb_data, &ctl_op); @@ -1069,10 +1067,10 @@ static int send_ack(struct bt_mesh_subnet *sub, uint16_t src, uint16_t dst, uint16_t seq_zero = *seq_auth & TRANS_SEQ_ZERO_MASK; uint8_t buf[6]; - BT_DBG("SeqZero 0x%04x Block 0x%08x OBO %u", seq_zero, block, obo); + LOG_DBG("SeqZero 0x%04x Block 0x%08x OBO %u", seq_zero, block, obo); if (bt_mesh_lpn_established()) { - BT_WARN("Not sending ack when LPN is enabled"); + LOG_WRN("Not sending ack when LPN is enabled"); return 0; } @@ -1080,7 +1078,7 @@ static int send_ack(struct bt_mesh_subnet *sub, uint16_t src, uint16_t dst, * or virtual address. */ if (!BT_MESH_ADDR_IS_UNICAST(src)) { - BT_DBG("Not sending ack for non-unicast address"); + LOG_DBG("Not sending ack for non-unicast address"); return 0; } @@ -1095,7 +1093,7 @@ static void seg_rx_reset(struct seg_rx *rx, bool full_reset) { int i; - BT_DBG("rx %p", rx); + LOG_DBG("rx %p", rx); /* If this fails, the handler will exit early on the next execution, as * it checks rx->in_use. @@ -1104,7 +1102,7 @@ static void seg_rx_reset(struct seg_rx *rx, bool full_reset) if (IS_ENABLED(CONFIG_BT_MESH_FRIEND) && rx->obo && rx->block != BLOCK_COMPLETE(rx->seg_n)) { - BT_WARN("Clearing incomplete buffers from Friend queue"); + LOG_WRN("Clearing incomplete buffers from Friend queue"); bt_mesh_friend_clear_incomplete(rx->sub, rx->src, rx->dst, &rx->seq_auth); } @@ -1148,10 +1146,10 @@ static void seg_ack(struct k_work *work) return; } - BT_DBG("rx %p", rx); + LOG_DBG("rx %p", rx); if (k_uptime_get_32() - rx->last > (60 * MSEC_PER_SEC)) { - BT_WARN("Incomplete timer expired"); + LOG_WRN("Incomplete timer expired"); seg_rx_reset(rx, false); if (IS_ENABLED(CONFIG_BT_TESTING)) { @@ -1194,8 +1192,7 @@ static struct seg_rx *seg_rx_find(struct bt_mesh_net_rx *net_rx, } if (rx->in_use) { - BT_WARN("Duplicate SDU from src 0x%04x", - net_rx->ctx.addr); + LOG_WRN("Duplicate SDU from src 0x%04x", net_rx->ctx.addr); /* Clear out the old context since the sender * has apparently started sending a new SDU. @@ -1214,17 +1211,17 @@ static bool seg_rx_is_valid(struct seg_rx *rx, struct bt_mesh_net_rx *net_rx, const uint8_t *hdr, uint8_t seg_n) { if (rx->hdr != *hdr || rx->seg_n != seg_n) { - BT_ERR("Invalid segment for ongoing session"); + LOG_ERR("Invalid segment for ongoing session"); return false; } if (rx->src != net_rx->ctx.addr || rx->dst != net_rx->ctx.recv_dst) { - BT_ERR("Invalid source or destination for segment"); + LOG_ERR("Invalid source or destination for segment"); return false; } if (rx->ctl != net_rx->ctl) { - BT_ERR("Inconsistent CTL in segment"); + LOG_ERR("Inconsistent CTL in segment"); return false; } @@ -1241,7 +1238,7 @@ static struct seg_rx *seg_rx_alloc(struct bt_mesh_net_rx *net_rx, * the collaborative Bluetooth rx thread: */ if (k_mem_slab_num_free_get(&segs) < 1) { - BT_WARN("Not enough segments for incoming message"); + LOG_WRN("Not enough segments for incoming message"); return NULL; } @@ -1263,8 +1260,7 @@ static struct seg_rx *seg_rx_alloc(struct bt_mesh_net_rx *net_rx, rx->dst = net_rx->ctx.recv_dst; rx->block = 0U; - BT_DBG("New RX context. Block Complete 0x%08x", - BLOCK_COMPLETE(seg_n)); + LOG_DBG("New RX context. Block Complete 0x%08x", BLOCK_COMPLETE(seg_n)); return rx; } @@ -1286,17 +1282,17 @@ static int trans_seg(struct net_buf_simple *buf, struct bt_mesh_net_rx *net_rx, int err; if (buf->len < 5) { - BT_ERR("Too short segmented message (len %u)", buf->len); + LOG_ERR("Too short segmented message (len %u)", buf->len); return -EINVAL; } if (bt_mesh_rpl_check(net_rx, &rpl)) { - BT_WARN("Replay: src 0x%04x dst 0x%04x seq 0x%06x", - net_rx->ctx.addr, net_rx->ctx.recv_dst, net_rx->seq); + LOG_WRN("Replay: src 0x%04x dst 0x%04x seq 0x%06x", net_rx->ctx.addr, + net_rx->ctx.recv_dst, net_rx->seq); return -EINVAL; } - BT_DBG("ASZMIC %u AKF %u AID 0x%02x", ASZMIC(hdr), AKF(hdr), AID(hdr)); + LOG_DBG("ASZMIC %u AKF %u AID 0x%02x", ASZMIC(hdr), AKF(hdr), AID(hdr)); net_buf_simple_pull(buf, 1); @@ -1307,10 +1303,10 @@ static int trans_seg(struct net_buf_simple *buf, struct bt_mesh_net_rx *net_rx, seg_o |= seg_n >> 5; seg_n &= 0x1f; - BT_DBG("SeqZero 0x%04x SegO %u SegN %u", seq_zero, seg_o, seg_n); + LOG_DBG("SeqZero 0x%04x SegO %u SegN %u", seq_zero, seg_o, seg_n); if (seg_o > seg_n) { - BT_ERR("SegO greater than SegN (%u > %u)", seg_o, seg_n); + LOG_ERR("SegO greater than SegN (%u > %u)", seg_o, seg_n); return -EINVAL; } @@ -1339,7 +1335,7 @@ static int trans_seg(struct net_buf_simple *buf, struct bt_mesh_net_rx *net_rx, if (rx) { /* Discard old SeqAuth packet */ if (rx->seq_auth > *seq_auth) { - BT_WARN("Ignoring old SeqAuth"); + LOG_WRN("Ignoring old SeqAuth"); return -EINVAL; } @@ -1348,12 +1344,12 @@ static int trans_seg(struct net_buf_simple *buf, struct bt_mesh_net_rx *net_rx, } if (rx->in_use) { - BT_DBG("Existing RX context. Block 0x%08x", rx->block); + LOG_DBG("Existing RX context. Block 0x%08x", rx->block); goto found_rx; } if (rx->block == BLOCK_COMPLETE(rx->seg_n)) { - BT_DBG("Got segment for already complete SDU"); + LOG_DBG("Got segment for already complete SDU"); send_ack(net_rx->sub, net_rx->ctx.recv_dst, net_rx->ctx.addr, net_rx->ctx.send_ttl, @@ -1370,13 +1366,13 @@ static int trans_seg(struct net_buf_simple *buf, struct bt_mesh_net_rx *net_rx, * ack timer is always smaller than the incomplete * timer, i.e. the sender is misbehaving. */ - BT_WARN("Got segment for canceled SDU"); + LOG_WRN("Got segment for canceled SDU"); return -EINVAL; } /* Bail out early if we're not ready to receive such a large SDU */ if (!sdu_len_is_ok(net_rx->ctl, seg_n)) { - BT_ERR("Too big incoming SDU length"); + LOG_ERR("Too big incoming SDU length"); send_ack(net_rx->sub, net_rx->ctx.recv_dst, net_rx->ctx.addr, net_rx->ctx.send_ttl, seq_auth, 0, net_rx->friend_match); @@ -1392,7 +1388,7 @@ static int trans_seg(struct net_buf_simple *buf, struct bt_mesh_net_rx *net_rx, net_rx->ctx.addr, net_rx->ctx.recv_dst, seq_auth, *seg_count)) { - BT_ERR("No space in Friend Queue for %u segments", *seg_count); + LOG_ERR("No space in Friend Queue for %u segments", *seg_count); send_ack(net_rx->sub, net_rx->ctx.recv_dst, net_rx->ctx.addr, net_rx->ctx.send_ttl, seq_auth, 0, net_rx->friend_match); @@ -1417,7 +1413,7 @@ static int trans_seg(struct net_buf_simple *buf, struct bt_mesh_net_rx *net_rx, */ if (rpl && rpl->src && auth_seqnum <= rpl->seg && (!rpl->old_iv || net_rx->old_iv)) { - BT_WARN("Ignoring old SeqAuth 0x%06x", auth_seqnum); + LOG_WRN("Ignoring old SeqAuth 0x%06x", auth_seqnum); return -EALREADY; } @@ -1428,7 +1424,7 @@ static int trans_seg(struct net_buf_simple *buf, struct bt_mesh_net_rx *net_rx, * eventually be freed up and we'll be able to process * this one. */ - BT_WARN("No free slots for new incoming segmented messages"); + LOG_WRN("No free slots for new incoming segmented messages"); return -ENOMEM; } @@ -1436,7 +1432,7 @@ static int trans_seg(struct net_buf_simple *buf, struct bt_mesh_net_rx *net_rx, found_rx: if (BIT(seg_o) & rx->block) { - BT_DBG("Received already received fragment"); + LOG_DBG("Received already received fragment"); return -EALREADY; } @@ -1447,11 +1443,10 @@ found_rx: if (seg_o == seg_n) { /* Set the expected final buffer length */ rx->len = seg_n * seg_len(rx->ctl) + buf->len; - BT_DBG("Target len %u * %u + %u = %u", seg_n, seg_len(rx->ctl), - buf->len, rx->len); + LOG_DBG("Target len %u * %u + %u = %u", seg_n, seg_len(rx->ctl), buf->len, rx->len); if (rx->len > BT_MESH_RX_SDU_MAX) { - BT_ERR("Too large SDU len"); + LOG_ERR("Too large SDU len"); send_ack(net_rx->sub, net_rx->ctx.recv_dst, net_rx->ctx.addr, net_rx->ctx.send_ttl, seq_auth, 0, rx->obo); @@ -1460,7 +1455,7 @@ found_rx: } } else { if (buf->len != seg_len(rx->ctl)) { - BT_ERR("Incorrect segment size for message type"); + LOG_ERR("Incorrect segment size for message type"); return -EINVAL; } } @@ -1477,13 +1472,13 @@ found_rx: /* Allocated segment here */ err = k_mem_slab_alloc(&segs, &rx->seg[seg_o], K_NO_WAIT); if (err) { - BT_WARN("Unable allocate buffer for Seg %u", seg_o); + LOG_WRN("Unable allocate buffer for Seg %u", seg_o); return -ENOBUFS; } memcpy(rx->seg[seg_o], buf->data, buf->len); - BT_DBG("Received %u/%u", seg_o, seg_n); + LOG_DBG("Received %u/%u", seg_o, seg_n); /* Mark segment as received */ rx->block |= BIT(seg_o); @@ -1493,7 +1488,7 @@ found_rx: return 0; } - BT_DBG("Complete SDU"); + LOG_DBG("Complete SDU"); if (rpl) { bt_mesh_rpl_update(rpl, net_rx); @@ -1519,7 +1514,7 @@ found_rx: seg_rx_assemble(rx, &sdu, 0U); err = ctl_recv(net_rx, *hdr, &sdu, seq_auth); } else if (rx->len < 1 + APP_MIC_LEN(ASZMIC(hdr))) { - BT_ERR("Too short SDU + MIC"); + LOG_ERR("Too short SDU + MIC"); err = -EINVAL; } else { NET_BUF_SIMPLE_DEFINE_STATIC(seg_buf, BT_MESH_RX_SDU_MAX); @@ -1556,13 +1551,13 @@ int bt_mesh_trans_recv(struct net_buf_simple *buf, struct bt_mesh_net_rx *rx) rx->friend_match = false; } - BT_DBG("src 0x%04x dst 0x%04x seq 0x%08x friend_match %u", - rx->ctx.addr, rx->ctx.recv_dst, rx->seq, rx->friend_match); + LOG_DBG("src 0x%04x dst 0x%04x seq 0x%08x friend_match %u", rx->ctx.addr, rx->ctx.recv_dst, + rx->seq, rx->friend_match); /* Remove network headers */ net_buf_simple_pull(buf, BT_MESH_NET_HDR_LEN); - BT_DBG("Payload %s", bt_hex(buf->data, buf->len)); + LOG_DBG("Payload %s", bt_hex(buf->data, buf->len)); if (IS_ENABLED(CONFIG_BT_TESTING)) { bt_test_mesh_net_recv(rx->ctx.recv_ttl, rx->ctl, rx->ctx.addr, @@ -1576,7 +1571,7 @@ int bt_mesh_trans_recv(struct net_buf_simple *buf, struct bt_mesh_net_rx *rx) if (IS_ENABLED(CONFIG_BT_MESH_LOW_POWER) && bt_mesh_lpn_established() && rx->net_if == BT_MESH_NET_IF_ADV && (!bt_mesh_lpn_waiting_update() || !rx->friend_cred)) { - BT_WARN("Ignoring unexpected message in Low Power mode"); + LOG_WRN("Ignoring unexpected message in Low Power mode"); return -EAGAIN; } @@ -1623,7 +1618,7 @@ void bt_mesh_rx_reset(void) { int i; - BT_DBG(""); + LOG_DBG(""); for (i = 0; i < ARRAY_SIZE(seg_rx); i++) { seg_rx_reset(&seg_rx[i], true); @@ -1641,7 +1636,7 @@ void bt_mesh_trans_reset(void) bt_mesh_rx_reset(); - BT_DBG(""); + LOG_DBG(""); for (i = 0; i < ARRAY_SIZE(seg_tx); i++) { seg_tx_reset(&seg_tx[i]); @@ -1754,17 +1749,17 @@ uint8_t *bt_mesh_va_label_get(uint16_t addr) { int i; - BT_DBG("addr 0x%04x", addr); + LOG_DBG("addr 0x%04x", addr); for (i = 0; i < ARRAY_SIZE(virtual_addrs); i++) { if (virtual_addrs[i].ref && virtual_addrs[i].addr == addr) { - BT_DBG("Found Label UUID for 0x%04x: %s", addr, - bt_hex(virtual_addrs[i].uuid, 16)); + LOG_DBG("Found Label UUID for 0x%04x: %s", addr, + bt_hex(virtual_addrs[i].uuid, 16)); return virtual_addrs[i].uuid; } } - BT_WARN("No matching Label UUID for 0x%04x", addr); + LOG_WRN("No matching Label UUID for 0x%04x", addr); return NULL; } @@ -1788,31 +1783,31 @@ static int va_set(const char *name, size_t len_rd, int err; if (!name) { - BT_ERR("Insufficient number of arguments"); + LOG_ERR("Insufficient number of arguments"); return -ENOENT; } index = strtol(name, NULL, 16); if (len_rd == 0) { - BT_WARN("Mesh Virtual Address length = 0"); + LOG_WRN("Mesh Virtual Address length = 0"); return 0; } err = bt_mesh_settings_set(read_cb, cb_arg, &va, sizeof(va)); if (err) { - BT_ERR("Failed to set \'virtual address\'"); + LOG_ERR("Failed to set \'virtual address\'"); return err; } if (va.ref == 0) { - BT_WARN("Ignore Mesh Virtual Address ref = 0"); + LOG_WRN("Ignore Mesh Virtual Address ref = 0"); return 0; } lab = bt_mesh_va_get(index); if (lab == NULL) { - BT_WARN("Out of labels buffers"); + LOG_WRN("Out of labels buffers"); return -ENOBUFS; } @@ -1820,8 +1815,7 @@ static int va_set(const char *name, size_t len_rd, lab->addr = va.addr; lab->ref = va.ref; - BT_DBG("Restored Virtual Address, addr 0x%04x ref 0x%04x", - lab->addr, lab->ref); + LOG_DBG("Restored Virtual Address, addr 0x%04x ref 0x%04x", lab->addr, lab->ref); return 0; } @@ -1857,13 +1851,10 @@ void bt_mesh_va_pending_store(void) } if (err) { - BT_ERR("Failed to %s %s value (err %d)", - IS_VA_DEL(lab) ? "delete" : "store", - path, err); + LOG_ERR("Failed to %s %s value (err %d)", + IS_VA_DEL(lab) ? "delete" : "store", path, err); } else { - BT_DBG("%s %s value", - IS_VA_DEL(lab) ? "Deleted" : "Stored", - path); + LOG_DBG("%s %s value", IS_VA_DEL(lab) ? "Deleted" : "Stored", path); } } } diff --git a/subsys/bluetooth/services/dis.c b/subsys/bluetooth/services/dis.c index f1a87420a38..9af78df9b66 100644 --- a/subsys/bluetooth/services/dis.c +++ b/subsys/bluetooth/services/dis.c @@ -25,9 +25,9 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_SERVICE) -#define LOG_MODULE_NAME bt_dis -#include "common/log.h" +#define LOG_LEVEL CONFIG_BT_SERVICE_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_dis); #if CONFIG_BT_DIS_PNP struct dis_pnp { @@ -153,24 +153,24 @@ static int dis_set(const char *name, size_t len_rd, if (!strncmp(name, "manuf", nlen)) { len = read_cb(store, &dis_manuf, sizeof(dis_manuf) - 1); if (len < 0) { - BT_ERR("Failed to read manufacturer from storage" + LOG_ERR("Failed to read manufacturer from storage" " (err %zd)", len); } else { dis_manuf[len] = '\0'; - BT_DBG("Manufacturer set to %s", dis_manuf); + LOG_DBG("Manufacturer set to %s", dis_manuf); } return 0; } if (!strncmp(name, "model", nlen)) { len = read_cb(store, &dis_model, sizeof(dis_model) - 1); if (len < 0) { - BT_ERR("Failed to read model from storage" + LOG_ERR("Failed to read model from storage" " (err %zd)", len); } else { dis_model[len] = '\0'; - BT_DBG("Model set to %s", dis_model); + LOG_DBG("Model set to %s", dis_model); } return 0; } @@ -179,12 +179,12 @@ static int dis_set(const char *name, size_t len_rd, len = read_cb(store, &dis_serial_number, sizeof(dis_serial_number) - 1); if (len < 0) { - BT_ERR("Failed to read serial number from storage" + LOG_ERR("Failed to read serial number from storage" " (err %zd)", len); } else { dis_serial_number[len] = '\0'; - BT_DBG("Serial number set to %s", dis_serial_number); + LOG_DBG("Serial number set to %s", dis_serial_number); } return 0; } @@ -193,12 +193,12 @@ static int dis_set(const char *name, size_t len_rd, if (!strncmp(name, "fw", nlen)) { len = read_cb(store, &dis_fw_rev, sizeof(dis_fw_rev) - 1); if (len < 0) { - BT_ERR("Failed to read firmware revision from storage" + LOG_ERR("Failed to read firmware revision from storage" " (err %zd)", len); } else { dis_fw_rev[len] = '\0'; - BT_DBG("Firmware revision set to %s", dis_fw_rev); + LOG_DBG("Firmware revision set to %s", dis_fw_rev); } return 0; } @@ -207,12 +207,12 @@ static int dis_set(const char *name, size_t len_rd, if (!strncmp(name, "hw", nlen)) { len = read_cb(store, &dis_hw_rev, sizeof(dis_hw_rev) - 1); if (len < 0) { - BT_ERR("Failed to read hardware revision from storage" + LOG_ERR("Failed to read hardware revision from storage" " (err %zd)", len); } else { dis_hw_rev[len] = '\0'; - BT_DBG("Hardware revision set to %s", dis_hw_rev); + LOG_DBG("Hardware revision set to %s", dis_hw_rev); } return 0; } @@ -221,12 +221,12 @@ static int dis_set(const char *name, size_t len_rd, if (!strncmp(name, "sw", nlen)) { len = read_cb(store, &dis_sw_rev, sizeof(dis_sw_rev) - 1); if (len < 0) { - BT_ERR("Failed to read software revision from storage" + LOG_ERR("Failed to read software revision from storage" " (err %zd)", len); } else { dis_sw_rev[len] = '\0'; - BT_DBG("Software revision set to %s", dis_sw_rev); + LOG_DBG("Software revision set to %s", dis_sw_rev); } return 0; } diff --git a/subsys/bluetooth/services/ias/Kconfig.ias b/subsys/bluetooth/services/ias/Kconfig.ias index 0a77ea1d91c..6e4d1519ec9 100644 --- a/subsys/bluetooth/services/ias/Kconfig.ias +++ b/subsys/bluetooth/services/ias/Kconfig.ias @@ -39,10 +39,16 @@ config BT_IAS_CLIENT config BT_DEBUG_IAS_CLIENT bool "Immediate Alert Service Client debug" + select DEPRECATED depends on BT_IAS_CLIENT help This option enables enables Immediate Alert Service Client debug logs. +module = BT_IAS_CLIENT +legacy-debug-sym = BT_DEBUG_IAS_CLIENT +module-str = "Immediate Alert Service Client" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + module = BT_IAS module-str = IAS source "${ZEPHYR_BASE}/subsys/logging/Kconfig.template.log_config" diff --git a/subsys/bluetooth/services/ias/ias_client.c b/subsys/bluetooth/services/ias/ias_client.c index dd96477f2f6..27ee63ce46b 100644 --- a/subsys/bluetooth/services/ias/ias_client.c +++ b/subsys/bluetooth/services/ias/ias_client.c @@ -8,14 +8,13 @@ #include #include #include + +LOG_MODULE_REGISTER(bt_ias_client, CONFIG_BT_IAS_CLIENT_LOG_LEVEL); + #include #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_IAS_CLIENT) -#define LOG_MODULE_NAME bt_ias_client -#include "../../common/log.h" - enum { IAS_DISCOVER_IN_PROGRESS, @@ -51,11 +50,11 @@ static void client_cleanup(struct bt_ias_client *ias_client) static void discover_complete(struct bt_conn *conn, int err) { - BT_DBG("conn %p", (void *)conn); + LOG_DBG("conn %p", (void *)conn); if (err) { client_cleanup(client_by_conn(conn)); - BT_DBG("Discover failed (err %d\n)", err); + LOG_DBG("Discover failed (err %d\n)", err); } if (ias_client_cb != NULL && ias_client_cb->discover != NULL) { @@ -79,7 +78,7 @@ int bt_ias_client_alert_write(struct bt_conn *conn, enum bt_ias_alert_lvl lvl) lvl_u8 = (uint8_t)lvl; if (lvl_u8 < BT_IAS_ALERT_LVL_NO_ALERT || lvl_u8 > BT_IAS_ALERT_LVL_HIGH_ALERT) { - BT_ERR("Invalid alert value: %u", lvl_u8); + LOG_ERR("Invalid alert value: %u", lvl_u8); return -EINVAL; } @@ -87,7 +86,7 @@ int bt_ias_client_alert_write(struct bt_conn *conn, enum bt_ias_alert_lvl lvl) client_by_conn(conn)->alert_level_handle, &lvl_u8, sizeof(lvl_u8), false); if (err < 0) { - BT_ERR("IAS client level %d write failed: %d", lvl, err); + LOG_ERR("IAS client level %d write failed: %d", lvl, err); } return err; diff --git a/subsys/bluetooth/services/ots/Kconfig b/subsys/bluetooth/services/ots/Kconfig index 80b923f4302..89de483b125 100644 --- a/subsys/bluetooth/services/ots/Kconfig +++ b/subsys/bluetooth/services/ots/Kconfig @@ -79,11 +79,18 @@ if BT_OTS_CLIENT # TODO: Unify logging for OTS server and client - the client uses # "BT" debugging, the server does not. + config BT_DEBUG_OTS_CLIENT bool "Object Transfer Service Client debug" + select DEPRECATED help Use this option to enable Object Transfer Client debug logs +module = BT_OTS_CLIENT +legacy-debug-sym = BT_DEBUG_OTS_CLIENT +module-str = "Object Transfer Service Client" +source "subsys/bluetooth/common/Kconfig.template.log_config_bt" + endif # BT_OTS_CLIENT if BT_OTS || BT_OTS_CLIENT diff --git a/subsys/bluetooth/services/ots/ots_client.c b/subsys/bluetooth/services/ots/ots_client.c index 6e4151781a4..4fa0f800d71 100644 --- a/subsys/bluetooth/services/ots/ots_client.c +++ b/subsys/bluetooth/services/ots/ots_client.c @@ -27,9 +27,9 @@ #include "ots_oacp_internal.h" #include "ots_olcp_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_OTS_CLIENT) -#define LOG_MODULE_NAME bt_otc -#include "common/log.h" +#define LOG_LEVEL CONFIG_BT_OTS_CLIENT_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_otc); /* TODO: KConfig options */ #define OTS_CLIENT_INST_COUNT 1 @@ -136,7 +136,7 @@ static void tx_done(struct bt_gatt_ots_l2cap *l2cap_ctx, struct bt_conn *conn) { /* Not doing any writes yet */ - BT_ERR("Unexpected call, context: %p, conn: %p", l2cap_ctx, (void *)conn); + LOG_ERR("Unexpected call, context: %p, conn: %p", l2cap_ctx, (void *)conn); } static void write_obj_tx_done(struct bt_gatt_ots_l2cap *l2cap_ctx, @@ -146,17 +146,16 @@ static void write_obj_tx_done(struct bt_gatt_ots_l2cap *l2cap_ctx, size_t written; if (cur_inst == NULL) { - BT_ERR("OTS instance invalid\n"); + LOG_ERR("OTS instance invalid\n"); return; } written = cur_inst->sent_size; - BT_DBG("ctx: %p, conn: %p, written: %d", - l2cap_ctx, (void *)conn, written); + LOG_DBG("ctx: %p, conn: %p, written: %d", l2cap_ctx, (void *)conn, written); err = bt_gatt_ots_l2cap_disconnect(l2cap_ctx); if (err < 0) { - BT_WARN("Disconnecting L2CAP returned error %d", err); + LOG_WRN("Disconnecting L2CAP returned error %d", err); } if ((cur_inst->otc_inst != NULL) && (cur_inst->otc_inst->cb != NULL)) { @@ -177,8 +176,8 @@ static ssize_t rx_done(struct bt_gatt_ots_l2cap *l2cap_ctx, &cur_inst->otc_inst->cur_object; int cb_ret; - BT_DBG("Incoming L2CAP data, context: %p, conn: %p, len: %u, offset: %u", - l2cap_ctx, (void *)conn, buf->len, offset); + LOG_DBG("Incoming L2CAP data, context: %p, conn: %p, len: %u, offset: %u", l2cap_ctx, + (void *)conn, buf->len, offset); cur_inst->rcvd_size += buf->len; @@ -187,8 +186,8 @@ static ssize_t rx_done(struct bt_gatt_ots_l2cap *l2cap_ctx, } if (cur_inst->rcvd_size > cur_object->size.cur) { - BT_WARN("Received %u but expected maximum %u", - cur_inst->rcvd_size, cur_object->size.cur); + LOG_WRN("Received %u but expected maximum %u", cur_inst->rcvd_size, + cur_object->size.cur); } cb_ret = cur_inst->otc_inst->cb->obj_data_read(0, conn, offset, @@ -199,11 +198,11 @@ static ssize_t rx_done(struct bt_gatt_ots_l2cap *l2cap_ctx, const uint32_t rcv_size = cur_object->size.cur; int err; - BT_DBG("Received the whole object (%u bytes). " + LOG_DBG("Received the whole object (%u bytes). " "Disconnecting L2CAP CoC", rcv_size); err = bt_gatt_ots_l2cap_disconnect(l2cap_ctx); if (err < 0) { - BT_WARN("Disconnecting L2CAP returned error %d", err); + LOG_WRN("Disconnecting L2CAP returned error %d", err); } cur_inst = NULL; @@ -211,12 +210,12 @@ static ssize_t rx_done(struct bt_gatt_ots_l2cap *l2cap_ctx, const uint32_t rcv_size = cur_object->size.cur; int err; - BT_DBG("Stopped receiving after%u bytes. " + LOG_DBG("Stopped receiving after%u bytes. " "Disconnecting L2CAP CoC", rcv_size); err = bt_gatt_ots_l2cap_disconnect(l2cap_ctx); if (err < 0) { - BT_WARN("Disconnecting L2CAP returned error %d", err); + LOG_WRN("Disconnecting L2CAP returned error %d", err); } cur_inst = NULL; @@ -228,24 +227,22 @@ static ssize_t rx_done(struct bt_gatt_ots_l2cap *l2cap_ctx, static void chan_closed(struct bt_gatt_ots_l2cap *l2cap_ctx, struct bt_conn *conn) { - BT_DBG("L2CAP closed, context: %p, conn: %p", l2cap_ctx, (void *)conn); + LOG_DBG("L2CAP closed, context: %p, conn: %p", l2cap_ctx, (void *)conn); } /* End L2CAP callbacks */ static void print_oacp_response(enum bt_gatt_ots_oacp_proc_type req_opcode, enum bt_gatt_ots_oacp_res_code result_code) { - BT_DBG("Request OP Code: %s", lit_request[req_opcode]); - BT_DBG("Result Code : %s", lit_result[result_code]); + LOG_DBG("Request OP Code: %s", lit_request[req_opcode]); + LOG_DBG("Result Code : %s", lit_result[result_code]); } static void print_olcp_response(enum bt_gatt_ots_olcp_proc_type req_opcode, enum bt_gatt_ots_olcp_res_code result_code) { - BT_DBG("Request OP Code: %s", - lit_olcp_request[req_opcode]); - BT_DBG("Result Code : %s", - lit_olcp_result[result_code]); + LOG_DBG("Request OP Code: %s", lit_olcp_request[req_opcode]); + LOG_DBG("Result Code : %s", lit_olcp_result[result_code]); } static void date_time_decode(struct net_buf_simple *buf, @@ -269,7 +266,7 @@ static struct bt_otc_internal_instance_t *lookup_inst_by_handle(uint16_t handle) } } - BT_DBG("Could not find OTS instance with handle 0x%04x", handle); + LOG_DBG("Could not find OTS instance with handle 0x%04x", handle); return NULL; } @@ -285,7 +282,7 @@ static void on_object_selected(struct bt_conn *conn, otc_inst->cb->obj_selected(otc_inst, conn, res); } - BT_DBG("Object selected"); + LOG_DBG("Object selected"); } static void olcp_ind_handler(struct bt_conn *conn, @@ -299,7 +296,7 @@ static void olcp_ind_handler(struct bt_conn *conn, op_code = net_buf_simple_pull_u8(&net_buf); - BT_DBG("OLCP indication"); + LOG_DBG("OLCP indication"); if (op_code == BT_GATT_OTS_OLCP_PROC_RESP) { enum bt_gatt_ots_olcp_proc_type req_opcode = @@ -311,46 +308,46 @@ static void olcp_ind_handler(struct bt_conn *conn, switch (req_opcode) { case BT_GATT_OTS_OLCP_PROC_FIRST: - BT_DBG("First"); + LOG_DBG("First"); on_object_selected(conn, result_code, otc_inst); break; case BT_GATT_OTS_OLCP_PROC_LAST: - BT_DBG("Last"); + LOG_DBG("Last"); on_object_selected(conn, result_code, otc_inst); break; case BT_GATT_OTS_OLCP_PROC_PREV: - BT_DBG("Previous"); + LOG_DBG("Previous"); on_object_selected(conn, result_code, otc_inst); break; case BT_GATT_OTS_OLCP_PROC_NEXT: - BT_DBG("Next"); + LOG_DBG("Next"); on_object_selected(conn, result_code, otc_inst); break; case BT_GATT_OTS_OLCP_PROC_GOTO: - BT_DBG("Goto"); + LOG_DBG("Goto"); on_object_selected(conn, result_code, otc_inst); break; case BT_GATT_OTS_OLCP_PROC_ORDER: - BT_DBG("Order"); + LOG_DBG("Order"); on_object_selected(conn, result_code, otc_inst); break; case BT_GATT_OTS_OLCP_PROC_REQ_NUM_OBJS: - BT_DBG("Request number of objects"); + LOG_DBG("Request number of objects"); if (net_buf.len == sizeof(uint32_t)) { uint32_t obj_cnt = net_buf_simple_pull_le32(&net_buf); - BT_DBG("Number of objects %u", obj_cnt); + LOG_DBG("Number of objects %u", obj_cnt); } break; case BT_GATT_OTS_OLCP_PROC_CLEAR_MARKING: - BT_DBG("Clear marking"); + LOG_DBG("Clear marking"); break; default: - BT_DBG("Invalid indication req opcode %u", req_opcode); + LOG_DBG("Invalid indication req opcode %u", req_opcode); break; } } else { - BT_DBG("Invalid indication opcode %u", op_code); + LOG_DBG("Invalid indication opcode %u", op_code); } } @@ -365,7 +362,7 @@ static void oacp_ind_handler(struct bt_conn *conn, op_code = net_buf_simple_pull_u8(&net_buf); - BT_DBG("OACP indication"); + LOG_DBG("OACP indication"); if (op_code == BT_GATT_OTS_OACP_PROC_RESP) { enum bt_gatt_ots_oacp_proc_type req_opcode = @@ -374,7 +371,7 @@ static void oacp_ind_handler(struct bt_conn *conn, net_buf_simple_pull_u8(&net_buf); print_oacp_response(req_opcode, result_code); } else { - BT_DBG("Invalid indication opcode %u", op_code); + LOG_DBG("Invalid indication opcode %u", op_code); } } @@ -396,7 +393,7 @@ uint8_t bt_ots_client_indicate_handler(struct bt_conn *conn, */ if (!inst) { - BT_ERR("Instance not found"); + LOG_ERR("Instance not found"); return BT_GATT_ITER_STOP; } @@ -424,14 +421,14 @@ static uint8_t read_feature_cb(struct bt_conn *conn, uint8_t err, net_buf_simple_init_with_data(&net_buf, (void *)data, length); if (!inst) { - BT_ERR("Instance not found"); + LOG_ERR("Instance not found"); return BT_GATT_ITER_STOP; } inst->busy = false; if (err) { - BT_DBG("err: 0x%02X", err); + LOG_DBG("err: 0x%02X", err); } else if (data) { if (length == OTS_FEATURE_LEN) { inst->otc_inst->features.oacp = @@ -440,12 +437,10 @@ static uint8_t read_feature_cb(struct bt_conn *conn, uint8_t err, inst->otc_inst->features.olcp = net_buf_simple_pull_le32(&net_buf); - BT_DBG("features : oacp 0x%x, olcp 0x%x", - inst->otc_inst->features.oacp, - inst->otc_inst->features.olcp); + LOG_DBG("features : oacp 0x%x, olcp 0x%x", inst->otc_inst->features.oacp, + inst->otc_inst->features.olcp); } else { - BT_DBG("Invalid length %u (expected %u)", - length, OTS_FEATURE_LEN); + LOG_DBG("Invalid length %u (expected %u)", length, OTS_FEATURE_LEN); cb_err = BT_ATT_ERR_INVALID_ATTRIBUTE_LEN; } } @@ -462,10 +457,10 @@ int bt_ots_client_register(struct bt_ots_client *otc_inst) continue; } - BT_DBG("%u", i); + LOG_DBG("%u", i); err = bt_gatt_ots_l2cap_register(&otc_insts[i].l2cap_ctx); if (err) { - BT_WARN("Could not register L2CAP context %d", err); + LOG_WRN("Could not register L2CAP context %d", err); return err; } @@ -495,20 +490,20 @@ int bt_ots_client_read_feature(struct bt_ots_client *otc_inst, int err; if (!conn) { - BT_WARN("Invalid Connection"); + LOG_WRN("Invalid Connection"); return -ENOTCONN; } else if (!otc_inst) { - BT_ERR("Invalid OTC instance"); + LOG_ERR("Invalid OTC instance"); return -EINVAL; } else if (!otc_inst->feature_handle) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } inst = lookup_inst_by_handle(otc_inst->start_handle); if (!inst) { - BT_ERR("Invalid OTC instance"); + LOG_ERR("Invalid OTC instance"); return -EINVAL; } else if (inst->busy) { return -EBUSY; @@ -526,7 +521,7 @@ int bt_ots_client_read_feature(struct bt_ots_client *otc_inst, return err; } - BT_DBG("Not supported"); + LOG_DBG("Not supported"); return -EOPNOTSUPP; } @@ -536,10 +531,10 @@ static void write_olcp_cb(struct bt_conn *conn, uint8_t err, struct bt_otc_internal_instance_t *inst = lookup_inst_by_handle(params->handle); - BT_DBG("Write %s (0x%02X)", err ? "failed" : "successful", err); + LOG_DBG("Write %s (0x%02X)", err ? "failed" : "successful", err); if (!inst) { - BT_ERR("Instance not found"); + LOG_ERR("Instance not found"); return; } @@ -583,20 +578,20 @@ int bt_ots_client_select_id(struct bt_ots_client *otc_inst, uint8_t param[BT_OTS_OBJ_ID_SIZE]; if (!conn) { - BT_WARN("Invalid Connection"); + LOG_WRN("Invalid Connection"); return -ENOTCONN; } else if (!otc_inst) { - BT_ERR("Invalid OTC instance"); + LOG_ERR("Invalid OTC instance"); return -EINVAL; } else if (!otc_inst->olcp_handle) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } inst = lookup_inst_by_handle(otc_inst->start_handle); if (!inst) { - BT_ERR("Invalid OTC instance"); + LOG_ERR("Invalid OTC instance"); return -EINVAL; } else if (inst->busy) { return -EBUSY; @@ -610,7 +605,7 @@ int bt_ots_client_select_id(struct bt_ots_client *otc_inst, param, BT_OTS_OBJ_ID_SIZE); } - BT_DBG("Not supported"); + LOG_DBG("Not supported"); return -EOPNOTSUPP; } @@ -621,20 +616,20 @@ int bt_ots_client_select_first(struct bt_ots_client *otc_inst, struct bt_otc_internal_instance_t *inst; if (!conn) { - BT_WARN("Invalid Connection"); + LOG_WRN("Invalid Connection"); return -ENOTCONN; } else if (!otc_inst) { - BT_ERR("Invalid OTC instance"); + LOG_ERR("Invalid OTC instance"); return -EINVAL; } else if (!otc_inst->olcp_handle) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } inst = lookup_inst_by_handle(otc_inst->start_handle); if (!inst) { - BT_ERR("Invalid OTC instance"); + LOG_ERR("Invalid OTC instance"); return -EINVAL; } else if (inst->busy) { return -EBUSY; @@ -644,7 +639,7 @@ int bt_ots_client_select_first(struct bt_ots_client *otc_inst, NULL, 0); } - BT_DBG("Not supported"); + LOG_DBG("Not supported"); return -EOPNOTSUPP; } @@ -655,20 +650,20 @@ int bt_ots_client_select_last(struct bt_ots_client *otc_inst, struct bt_otc_internal_instance_t *inst; if (!conn) { - BT_WARN("Invalid Connection"); + LOG_WRN("Invalid Connection"); return -ENOTCONN; } else if (!otc_inst) { - BT_ERR("Invalid OTC instance"); + LOG_ERR("Invalid OTC instance"); return -EINVAL; } else if (!otc_inst->olcp_handle) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } inst = lookup_inst_by_handle(otc_inst->start_handle); if (!inst) { - BT_ERR("Invalid OTC instance"); + LOG_ERR("Invalid OTC instance"); return -EINVAL; } else if (inst->busy) { return -EBUSY; @@ -679,7 +674,7 @@ int bt_ots_client_select_last(struct bt_ots_client *otc_inst, } - BT_DBG("Not supported"); + LOG_DBG("Not supported"); return -EOPNOTSUPP; } @@ -690,20 +685,20 @@ int bt_ots_client_select_next(struct bt_ots_client *otc_inst, struct bt_otc_internal_instance_t *inst; if (!conn) { - BT_WARN("Invalid Connection"); + LOG_WRN("Invalid Connection"); return -ENOTCONN; } else if (!otc_inst) { - BT_ERR("Invalid OTC instance"); + LOG_ERR("Invalid OTC instance"); return -EINVAL; } else if (!otc_inst->olcp_handle) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } inst = lookup_inst_by_handle(otc_inst->start_handle); if (!inst) { - BT_ERR("Invalid OTC instance"); + LOG_ERR("Invalid OTC instance"); return -EINVAL; } else if (inst->busy) { return -EBUSY; @@ -713,7 +708,7 @@ int bt_ots_client_select_next(struct bt_ots_client *otc_inst, NULL, 0); } - BT_DBG("Not supported"); + LOG_DBG("Not supported"); return -EOPNOTSUPP; } @@ -724,20 +719,20 @@ int bt_ots_client_select_prev(struct bt_ots_client *otc_inst, struct bt_otc_internal_instance_t *inst; if (!conn) { - BT_WARN("Invalid Connection"); + LOG_WRN("Invalid Connection"); return -ENOTCONN; } else if (!otc_inst) { - BT_ERR("Invalid OTC instance"); + LOG_ERR("Invalid OTC instance"); return -EINVAL; } else if (!otc_inst->olcp_handle) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } inst = lookup_inst_by_handle(otc_inst->start_handle); if (!inst) { - BT_ERR("Invalid OTC instance"); + LOG_ERR("Invalid OTC instance"); return -EINVAL; } else if (inst->busy) { return -EBUSY; @@ -747,7 +742,7 @@ int bt_ots_client_select_prev(struct bt_ots_client *otc_inst, NULL, 0); } - BT_DBG("Not supported"); + LOG_DBG("Not supported"); return -EOPNOTSUPP; } @@ -761,19 +756,18 @@ static uint8_t read_object_size_cb(struct bt_conn *conn, uint8_t err, net_buf_simple_init_with_data(&net_buf, (void *)data, length); - BT_DBG("handle %d, length %u", params->single.handle, length); + LOG_DBG("handle %d, length %u", params->single.handle, length); if (!inst) { - BT_ERR("Instance not found"); + LOG_ERR("Instance not found"); return BT_GATT_ITER_STOP; } if (err) { - BT_DBG("err: 0x%02X", err); + LOG_DBG("err: 0x%02X", err); } else if (data) { if (length != OTS_SIZE_LEN) { - BT_DBG("Invalid length %u (expected %u)", - length, OTS_SIZE_LEN); + LOG_DBG("Invalid length %u (expected %u)", length, OTS_SIZE_LEN); err = BT_ATT_ERR_INVALID_ATTRIBUTE_LEN; } else { struct bt_ots_obj_metadata *cur_object = @@ -783,18 +777,18 @@ static uint8_t read_object_size_cb(struct bt_conn *conn, uint8_t err, cur_object->size.alloc = net_buf_simple_pull_le32(&net_buf); - BT_DBG("Object Size : current size %u, " + LOG_DBG("Object Size : current size %u, " "allocated size %u", cur_object->size.cur, cur_object->size.alloc); if (cur_object->size.cur == 0) { - BT_WARN("Obj size read returned a current " + LOG_WRN("Obj size read returned a current " "size of 0"); } else if (cur_object->size.cur > cur_object->size.alloc && cur_object->size.alloc != 0) { - BT_WARN("Allocated size %u is smaller than " + LOG_WRN("Allocated size %u is smaller than " "current size %u", cur_object->size.alloc, cur_object->size.cur); @@ -805,7 +799,7 @@ static uint8_t read_object_size_cb(struct bt_conn *conn, uint8_t err, } if (err) { - BT_WARN("err: 0x%02X", err); + LOG_WRN("err: 0x%02X", err); if (!inst->metadata_err) { inst->metadata_err = err; } @@ -826,15 +820,15 @@ static uint8_t read_obj_id_cb(struct bt_conn *conn, uint8_t err, net_buf_simple_init_with_data(&net_buf, (void *)data, length); - BT_DBG("handle %d, length %u", params->single.handle, length); + LOG_DBG("handle %d, length %u", params->single.handle, length); if (!inst) { - BT_ERR("Instance not found"); + LOG_ERR("Instance not found"); return BT_GATT_ITER_STOP; } if (err) { - BT_DBG("err: 0x%02X", err); + LOG_DBG("err: 0x%02X", err); } else if (data) { if (length == BT_OTS_OBJ_ID_SIZE) { uint64_t obj_id = net_buf_simple_pull_le48(&net_buf); @@ -843,7 +837,7 @@ static uint8_t read_obj_id_cb(struct bt_conn *conn, uint8_t err, &inst->otc_inst->cur_object; (void)bt_ots_obj_id_to_str(obj_id, t, sizeof(t)); - BT_DBG("Object Id : %s", t); + LOG_DBG("Object Id : %s", t); if (cur_object->id != OTS_CLIENT_UNKNOWN_ID && cur_object->id != obj_id) { @@ -851,23 +845,21 @@ static uint8_t read_obj_id_cb(struct bt_conn *conn, uint8_t err, (void)bt_ots_obj_id_to_str(cur_object->id, str, sizeof(str)); - BT_INFO("Read Obj Id %s not selected obj Id %s", - t, str); + LOG_INF("Read Obj Id %s not selected obj Id %s", t, str); } else { - BT_INFO("Read Obj Id confirmed correct Obj Id"); + LOG_INF("Read Obj Id confirmed correct Obj Id"); cur_object->id = obj_id; BT_OTS_SET_METADATA_REQ_ID(inst->metadata_read); } } else { - BT_DBG("Invalid length %u (expected %u)", - length, BT_OTS_OBJ_ID_SIZE); + LOG_DBG("Invalid length %u (expected %u)", length, BT_OTS_OBJ_ID_SIZE); err = BT_ATT_ERR_INVALID_ATTRIBUTE_LEN; } } if (err) { - BT_WARN("err: 0x%02X", err); + LOG_WRN("err: 0x%02X", err); if (!inst->metadata_err) { inst->metadata_err = err; } @@ -885,10 +877,10 @@ static uint8_t read_obj_name_cb(struct bt_conn *conn, uint8_t err, struct bt_otc_internal_instance_t *inst = lookup_inst_by_handle(params->single.handle); - BT_DBG("handle %d, length %u", params->single.handle, length); + LOG_DBG("handle %d, length %u", params->single.handle, length); if (!inst) { - BT_ERR("Instance not found"); + LOG_ERR("Instance not found"); return BT_GATT_ITER_STOP; } @@ -897,14 +889,14 @@ static uint8_t read_obj_name_cb(struct bt_conn *conn, uint8_t err, memcpy(inst->otc_inst->cur_object.name_c, data, length); inst->otc_inst->cur_object.name_c[length] = '\0'; } else { - BT_WARN("Invalid length %u (expected max %u)", - length, CONFIG_BT_OTS_OBJ_MAX_NAME_LEN); + LOG_WRN("Invalid length %u (expected max %u)", length, + CONFIG_BT_OTS_OBJ_MAX_NAME_LEN); err = BT_ATT_ERR_INVALID_ATTRIBUTE_LEN; } } if (err) { - BT_WARN("err: 0x%02X", err); + LOG_WRN("err: 0x%02X", err); if (!inst->metadata_err) { inst->metadata_err = err; } @@ -922,10 +914,10 @@ static uint8_t read_obj_type_cb(struct bt_conn *conn, uint8_t err, struct bt_otc_internal_instance_t *inst = lookup_inst_by_handle(params->single.handle); - BT_DBG("handle %d, length %u", params->single.handle, length); + LOG_DBG("handle %d, length %u", params->single.handle, length); if (!inst) { - BT_ERR("Instance not found"); + LOG_ERR("Instance not found"); return BT_GATT_ITER_STOP; } @@ -938,18 +930,17 @@ static uint8_t read_obj_type_cb(struct bt_conn *conn, uint8_t err, bt_uuid_create(uuid, data, length); bt_uuid_to_str(uuid, uuid_str, sizeof(uuid_str)); - BT_DBG("UUID type read: %s", uuid_str); + LOG_DBG("UUID type read: %s", uuid_str); BT_OTS_SET_METADATA_REQ_TYPE(inst->metadata_read); } else { - BT_WARN("Invalid length %u (expected max %u)", - length, OTS_TYPE_MAX_LEN); + LOG_WRN("Invalid length %u (expected max %u)", length, OTS_TYPE_MAX_LEN); err = BT_ATT_ERR_INVALID_ATTRIBUTE_LEN; } } if (err) { - BT_WARN("err: 0x%02X", err); + LOG_WRN("err: 0x%02X", err); if (!inst->metadata_err) { inst->metadata_err = err; } @@ -971,10 +962,10 @@ static uint8_t read_obj_created_cb(struct bt_conn *conn, uint8_t err, net_buf_simple_init_with_data(&net_buf, (void *)data, length); - BT_DBG("handle %d, length %u", params->single.handle, length); + LOG_DBG("handle %d, length %u", params->single.handle, length); if (!inst) { - BT_ERR("Instance not found"); + LOG_ERR("Instance not found"); return BT_GATT_ITER_STOP; } @@ -984,14 +975,14 @@ static uint8_t read_obj_created_cb(struct bt_conn *conn, uint8_t err, &net_buf, &inst->otc_inst->cur_object.first_created); } else { - BT_WARN("Invalid length %u (expected max %u)", - length, BT_OTS_DATE_TIME_FIELD_SIZE); + LOG_WRN("Invalid length %u (expected max %u)", length, + BT_OTS_DATE_TIME_FIELD_SIZE); err = BT_ATT_ERR_INVALID_ATTRIBUTE_LEN; } } if (err) { - BT_WARN("err: 0x%02X", err); + LOG_WRN("err: 0x%02X", err); if (!inst->metadata_err) { inst->metadata_err = err; } @@ -1012,10 +1003,10 @@ static uint8_t read_obj_modified_cb(struct bt_conn *conn, uint8_t err, net_buf_simple_init_with_data(&net_buf, (void *)data, length); - BT_DBG("handle %d, length %u", params->single.handle, length); + LOG_DBG("handle %d, length %u", params->single.handle, length); if (!inst) { - BT_ERR("Instance not found"); + LOG_ERR("Instance not found"); return BT_GATT_ITER_STOP; } @@ -1024,14 +1015,14 @@ static uint8_t read_obj_modified_cb(struct bt_conn *conn, uint8_t err, date_time_decode(&net_buf, &inst->otc_inst->cur_object.modified); } else { - BT_WARN("Invalid length %u (expected max %u)", - length, BT_OTS_DATE_TIME_FIELD_SIZE); + LOG_WRN("Invalid length %u (expected max %u)", length, + BT_OTS_DATE_TIME_FIELD_SIZE); err = BT_ATT_ERR_INVALID_ATTRIBUTE_LEN; } } if (err) { - BT_WARN("err: 0x%02X", err); + LOG_WRN("err: 0x%02X", err); if (!inst->metadata_err) { inst->metadata_err = err; } @@ -1047,10 +1038,10 @@ static int read_attr(struct bt_conn *conn, uint16_t handle, bt_gatt_read_func_t cb) { if (!handle) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } else if (cb == NULL) { - BT_ERR("No callback set"); + LOG_ERR("No callback set"); return -EINVAL; } @@ -1074,37 +1065,35 @@ static uint8_t read_obj_properties_cb(struct bt_conn *conn, uint8_t err, net_buf_simple_init_with_data(&net_buf, (void *)data, length); - BT_INFO("handle %d, length %u", params->single.handle, length); + LOG_INF("handle %d, length %u", params->single.handle, length); if (!inst) { - BT_ERR("Instance not found"); + LOG_ERR("Instance not found"); return BT_GATT_ITER_STOP; } if (err) { - BT_WARN("err: 0x%02X", err); + LOG_WRN("err: 0x%02X", err); } else if (data && length <= OTS_PROPERTIES_LEN) { struct bt_ots_obj_metadata *cur_object = &inst->otc_inst->cur_object; cur_object->props = net_buf_simple_pull_le32(&net_buf); - BT_INFO("Object properties (raw) : 0x%x", - cur_object->props); + LOG_INF("Object properties (raw) : 0x%x", cur_object->props); if (!BT_OTS_OBJ_GET_PROP_READ(cur_object->props)) { - BT_WARN("Obj properties: Obj read not supported"); + LOG_WRN("Obj properties: Obj read not supported"); } BT_OTS_SET_METADATA_REQ_PROPS(inst->metadata_read); } else { - BT_WARN("Invalid length %u (expected %u)", - length, OTS_PROPERTIES_LEN); + LOG_WRN("Invalid length %u (expected %u)", length, OTS_PROPERTIES_LEN); cb_err = BT_ATT_ERR_INVALID_ATTRIBUTE_LEN; } if (err) { - BT_WARN("err: 0x%02X", err); + LOG_WRN("err: 0x%02X", err); if (!inst->metadata_err) { inst->metadata_err = err; } @@ -1121,10 +1110,10 @@ static void write_oacp_cp_cb(struct bt_conn *conn, uint8_t err, struct bt_otc_internal_instance_t *inst = lookup_inst_by_handle(params->handle); - BT_DBG("Write %s (0x%02X)", err ? "failed" : "successful", err); + LOG_DBG("Write %s (0x%02X)", err ? "failed" : "successful", err); if (!inst) { - BT_ERR("Instance not found"); + LOG_ERR("Instance not found"); return; } @@ -1138,9 +1127,9 @@ static void write_oacp_cp_write_req_cb(struct bt_conn *conn, uint8_t err, lookup_inst_by_handle(params->handle); uint32_t len; - BT_DBG("Write Object request %s (0x%02X)", err ? "failed" : "successful", err); + LOG_DBG("Write Object request %s (0x%02X)", err ? "failed" : "successful", err); if (!inst) { - BT_ERR("Instance not found"); + LOG_ERR("Instance not found"); return; } @@ -1148,7 +1137,7 @@ static void write_oacp_cp_write_req_cb(struct bt_conn *conn, uint8_t err, inst->l2cap_ctx.tx.len = 0; err = bt_gatt_ots_l2cap_send(&inst->l2cap_ctx, inst->l2cap_ctx.tx.data, len); if (err) { - BT_WARN("L2CAP CoC error: %d while trying to execute OACP " + LOG_WRN("L2CAP CoC error: %d while trying to execute OACP " "Read procedure", err); } @@ -1164,7 +1153,7 @@ static int oacp_read(struct bt_conn *conn, struct bt_gatt_ots_l2cap *l2cap; if (!inst->otc_inst->oacp_handle) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } else if (inst->busy) { return -EBUSY; @@ -1178,7 +1167,7 @@ static int oacp_read(struct bt_conn *conn, err = bt_gatt_ots_l2cap_connect(conn, &l2cap); if (err) { - BT_DBG("Could not connect l2cap: %d", err); + LOG_DBG("Could not connect l2cap: %d", err); return err; } @@ -1224,7 +1213,7 @@ static int oacp_write(struct bt_conn *conn, struct bt_otc_internal_instance_t *i struct bt_gatt_ots_l2cap *l2cap; if (!inst->otc_inst->oacp_handle) { - BT_DBG("Handle not set"); + LOG_DBG("Handle not set"); return -EINVAL; } else if (inst->busy) { return -EBUSY; @@ -1234,7 +1223,7 @@ static int oacp_write(struct bt_conn *conn, struct bt_otc_internal_instance_t *i err = bt_gatt_ots_l2cap_connect(conn, &l2cap); if (err) { - BT_DBG("Could not connect l2cap: %d", err); + LOG_DBG("Could not connect l2cap: %d", err); return err; } @@ -1280,22 +1269,22 @@ int bt_ots_client_read_object_data(struct bt_ots_client *otc_inst, struct bt_otc_internal_instance_t *inst; if (!conn) { - BT_WARN("Invalid Connection"); + LOG_WRN("Invalid Connection"); return -ENOTCONN; } else if (!otc_inst) { - BT_ERR("Invalid OTC instance"); + LOG_ERR("Invalid OTC instance"); return -EINVAL; } inst = lookup_inst_by_handle(otc_inst->start_handle); if (!inst) { - BT_ERR("Invalid OTC instance"); + LOG_ERR("Invalid OTC instance"); return -EINVAL; } if (otc_inst->cur_object.size.cur == 0) { - BT_WARN("Unknown object size"); + LOG_WRN("Unknown object size"); return -EINVAL; } @@ -1309,18 +1298,18 @@ int bt_ots_client_write_object_data(struct bt_ots_client *otc_inst, struct bt_otc_internal_instance_t *inst; CHECKIF(!conn) { - BT_WARN("Invalid Connection"); + LOG_WRN("Invalid Connection"); return -ENOTCONN; } CHECKIF(!otc_inst) { - BT_ERR("Invalid OTC instance"); + LOG_ERR("Invalid OTC instance"); return -EINVAL; } CHECKIF((mode != BT_OTS_OACP_WRITE_OP_MODE_NONE) && (mode != BT_OTS_OACP_WRITE_OP_MODE_TRUNCATE)) { - BT_ERR("Invalid write object mode parameter %d", mode); + LOG_ERR("Invalid write object mode parameter %d", mode); return -EINVAL; } @@ -1328,34 +1317,34 @@ int bt_ots_client_write_object_data(struct bt_ots_client *otc_inst, * Offset and Length field are UINT32 Length */ CHECKIF(len > UINT32_MAX) { - BT_ERR("length exceeds UINT32"); + LOG_ERR("length exceeds UINT32"); return -EINVAL; } CHECKIF(len == 0) { - BT_ERR("length equals zero"); + LOG_ERR("length equals zero"); return -EINVAL; } CHECKIF((offset > UINT32_MAX) || (offset < 0)) { - BT_ERR("offset exceeds UINT32"); + LOG_ERR("offset exceeds UINT32"); return -EINVAL; } CHECKIF(offset > otc_inst->cur_object.size.cur) { - BT_ERR("offset %ld exceeds cur size %zu", offset, otc_inst->cur_object.size.cur); + LOG_ERR("offset %ld exceeds cur size %zu", offset, otc_inst->cur_object.size.cur); return -EINVAL; } CHECKIF((offset < otc_inst->cur_object.size.cur) && !BT_OTS_OBJ_GET_PROP_PATCH(otc_inst->cur_object.props)) { - BT_ERR("Patch is not supported"); + LOG_ERR("Patch is not supported"); return -EACCES; } CHECKIF(((len + offset) > otc_inst->cur_object.size.alloc) && !BT_OTS_OBJ_GET_PROP_APPEND(otc_inst->cur_object.props)) { - BT_ERR("APPEND is not supported. Invalid new end of object %lu alloc %zu." + LOG_ERR("APPEND is not supported. Invalid new end of object %lu alloc %zu." , (len + offset), otc_inst->cur_object.size.alloc); return -EINVAL; } @@ -1363,7 +1352,7 @@ int bt_ots_client_write_object_data(struct bt_ots_client *otc_inst, inst = lookup_inst_by_handle(otc_inst->start_handle); if (!inst) { - BT_ERR("Invalid OTC instance"); + LOG_ERR("Invalid OTC instance"); return -EINVAL; } @@ -1377,7 +1366,7 @@ static void read_next_metadata(struct bt_conn *conn, inst->metadata_to_read ^ inst->metadata_read_attempted; int err = 0; - BT_DBG("Attempting to read metadata 0x%02X", metadata_remaining); + LOG_DBG("Attempting to read metadata 0x%02X", metadata_remaining); if (BT_OTS_GET_METADATA_REQ_NAME(metadata_remaining)) { BT_OTS_SET_METADATA_REQ_NAME(inst->metadata_read_attempted); @@ -1419,7 +1408,7 @@ static void read_next_metadata(struct bt_conn *conn, } if (err) { - BT_DBG("Metadata read failed (%d), trying next", err); + LOG_DBG("Metadata read failed (%d), trying next", err); read_next_metadata(conn, inst); } } @@ -1431,20 +1420,20 @@ int bt_ots_client_read_object_metadata(struct bt_ots_client *otc_inst, struct bt_otc_internal_instance_t *inst; if (!conn) { - BT_WARN("Invalid Connection"); + LOG_WRN("Invalid Connection"); return -ENOTCONN; } else if (!otc_inst) { - BT_ERR("Invalid OTC instance"); + LOG_ERR("Invalid OTC instance"); return -EINVAL; } else if (!metadata) { - BT_WARN("No metadata to read"); + LOG_WRN("No metadata to read"); return -ENOEXEC; } inst = lookup_inst_by_handle(otc_inst->start_handle); if (!inst) { - BT_ERR("Invalid OTC instance"); + LOG_ERR("Invalid OTC instance"); return -EINVAL; } else if (inst->busy) { return -EBUSY; @@ -1468,14 +1457,14 @@ static int decode_record(struct net_buf_simple *buf, rec->len = net_buf_simple_pull_le16(buf); if (rec->len > buf->len) { - BT_WARN("incorrect DirListing record length %u, " + LOG_WRN("incorrect DirListing record length %u, " "longer than remaining size %u", rec->len, buf->len); return -EINVAL; } if ((start_len - buf->len) + BT_OTS_OBJ_ID_SIZE > rec->len) { - BT_WARN("incorrect DirListing record, reclen %u too short, " + LOG_WRN("incorrect DirListing record, reclen %u too short, " "includes only record length", rec->len); return -EINVAL; @@ -1483,15 +1472,15 @@ static int decode_record(struct net_buf_simple *buf, rec->metadata.id = net_buf_simple_pull_le48(buf); - if (IS_ENABLED(CONFIG_BT_DEBUG_OTS_CLIENT)) { + if (IS_ENABLED(CONFIG_BT_OTS_CLIENT_LOG_LEVEL_DBG)) { char t[BT_OTS_OBJ_ID_STR_LEN]; (void)bt_ots_obj_id_to_str(rec->metadata.id, t, sizeof(t)); - BT_DBG("Object ID 0x%s", t); + LOG_DBG("Object ID 0x%s", t); } if ((start_len - buf->len) + sizeof(uint8_t) > rec->len) { - BT_WARN("incorrect DirListing record, reclen %u too short, " + LOG_WRN("incorrect DirListing record, reclen %u too short, " "includes only record length + ObjId", rec->len); return -EINVAL; @@ -1503,7 +1492,7 @@ static int decode_record(struct net_buf_simple *buf, uint8_t *name; if ((start_len - buf->len) + rec->name_len > rec->len) { - BT_WARN("incorrect DirListing record, remaining length " + LOG_WRN("incorrect DirListing record, remaining length " "%u shorter than name length %u", rec->len - (start_len - buf->len), rec->name_len); @@ -1511,8 +1500,7 @@ static int decode_record(struct net_buf_simple *buf, } if (rec->name_len >= sizeof(rec->metadata.name_c)) { - BT_WARN("Name length %u too long, invalid record", - rec->name_len); + LOG_WRN("Name length %u too long, invalid record", rec->name_len); return -EINVAL; } @@ -1524,22 +1512,22 @@ static int decode_record(struct net_buf_simple *buf, rec->flags = 0; if ((start_len - buf->len) + sizeof(uint8_t) > rec->len) { - BT_WARN("incorrect DirListing record, reclen %u too short, " + LOG_WRN("incorrect DirListing record, reclen %u too short, " "does not include flags", rec->len); return -EINVAL; } rec->flags = net_buf_simple_pull_u8(buf); - BT_DBG("flags 0x%x", rec->flags); + LOG_DBG("flags 0x%x", rec->flags); if (BT_OTS_DIR_LIST_GET_FLAG_TYPE_128(rec->flags)) { uint8_t *uuid; if ((start_len - buf->len) + BT_UUID_SIZE_128 > rec->len) { - BT_WARN("incorrect DirListing record, reclen %u " + LOG_WRN("incorrect DirListing record, reclen %u " "flags indicates uuid128, too short", rec->len); - BT_INFO("flags 0x%x", rec->flags); + LOG_INF("flags 0x%x", rec->flags); return -EINVAL; } @@ -1548,10 +1536,10 @@ static int decode_record(struct net_buf_simple *buf, uuid, BT_UUID_SIZE_128); } else { if ((start_len - buf->len) + BT_UUID_SIZE_16 > rec->len) { - BT_WARN("incorrect DirListing record, reclen %u " + LOG_WRN("incorrect DirListing record, reclen %u " "flags indicates uuid16, too short", rec->len); - BT_INFO("flags 0x%x", rec->flags); + LOG_INF("flags 0x%x", rec->flags); return -EINVAL; } @@ -1561,10 +1549,10 @@ static int decode_record(struct net_buf_simple *buf, if (BT_OTS_DIR_LIST_GET_FLAG_CUR_SIZE(rec->flags)) { if ((start_len - buf->len) + sizeof(uint32_t) > rec->len) { - BT_WARN("incorrect DirListing record, reclen %u " + LOG_WRN("incorrect DirListing record, reclen %u " "flags indicates cur_size, too short", rec->len); - BT_INFO("flags 0x%x", rec->flags); + LOG_INF("flags 0x%x", rec->flags); return -EINVAL; } @@ -1573,10 +1561,10 @@ static int decode_record(struct net_buf_simple *buf, if (BT_OTS_DIR_LIST_GET_FLAG_ALLOC_SIZE(rec->flags)) { if ((start_len - buf->len) + sizeof(uint32_t) > rec->len) { - BT_WARN("incorrect DirListing record, reclen %u " + LOG_WRN("incorrect DirListing record, reclen %u " "flags indicates allocated size, too short", rec->len); - BT_INFO("flags 0x%x", rec->flags); + LOG_INF("flags 0x%x", rec->flags); return -EINVAL; } @@ -1585,10 +1573,10 @@ static int decode_record(struct net_buf_simple *buf, if (BT_OTS_DIR_LIST_GET_FLAG_FIRST_CREATED(rec->flags)) { if ((start_len - buf->len) + BT_OTS_DATE_TIME_FIELD_SIZE > rec->len) { - BT_WARN("incorrect DirListing record, reclen %u " + LOG_WRN("incorrect DirListing record, reclen %u " "too short flags indicates first_created", rec->len); - BT_INFO("flags 0x%x", rec->flags); + LOG_INF("flags 0x%x", rec->flags); return -EINVAL; } @@ -1597,10 +1585,10 @@ static int decode_record(struct net_buf_simple *buf, if (BT_OTS_DIR_LIST_GET_FLAG_LAST_MODIFIED(rec->flags)) { if ((start_len - buf->len) + BT_OTS_DATE_TIME_FIELD_SIZE > rec->len) { - BT_WARN("incorrect DirListing record, reclen %u " + LOG_WRN("incorrect DirListing record, reclen %u " "flags indicates las_mod, too short", rec->len); - BT_INFO("flags 0x%x", rec->flags); + LOG_INF("flags 0x%x", rec->flags); return -EINVAL; } @@ -1609,10 +1597,10 @@ static int decode_record(struct net_buf_simple *buf, if (BT_OTS_DIR_LIST_GET_FLAG_PROPERTIES(rec->flags)) { if ((start_len - buf->len) + sizeof(uint32_t) > rec->len) { - BT_WARN("incorrect DirListing record, reclen %u " + LOG_WRN("incorrect DirListing record, reclen %u " "flags indicates properties, too short", rec->len); - BT_INFO("flags 0x%x", rec->flags); + LOG_INF("flags 0x%x", rec->flags); return -EINVAL; } @@ -1641,16 +1629,15 @@ int bt_ots_client_decode_dirlisting(uint8_t *data, uint16_t length, count++; if (net_buf.len < sizeof(uint16_t)) { - BT_WARN("incorrect DirListing record, len %u too short", - net_buf.len); + LOG_WRN("incorrect DirListing record, len %u too short", net_buf.len); return -EINVAL; } - BT_DBG("Decoding record %u", count); + LOG_DBG("Decoding record %u", count); ret = decode_record(&net_buf, &record); if (ret < 0) { - BT_WARN("DirListing, record %u invalid", count); + LOG_WRN("DirListing, record %u invalid", count); return ret; } @@ -1667,67 +1654,67 @@ int bt_ots_client_decode_dirlisting(uint8_t *data, uint16_t length, void bt_ots_metadata_display(struct bt_ots_obj_metadata *metadata, uint16_t count) { - BT_INFO("--- Displaying %u metadata records ---", count); + LOG_INF("--- Displaying %u metadata records ---", count); for (int i = 0; i < count; i++) { char t[BT_OTS_OBJ_ID_STR_LEN]; (void)bt_ots_obj_id_to_str(metadata->id, t, sizeof(t)); - BT_INFO("Object ID: 0x%s", t); - BT_INFO("Object name: %s", metadata->name_c); - BT_INFO("Object Current Size: %u", metadata->size.cur); - BT_INFO("Object Allocate Size: %u", metadata->size.alloc); + LOG_INF("Object ID: 0x%s", t); + LOG_INF("Object name: %s", metadata->name_c); + LOG_INF("Object Current Size: %u", metadata->size.cur); + LOG_INF("Object Allocate Size: %u", metadata->size.alloc); if (!bt_uuid_cmp(&metadata->type.uuid, BT_UUID_OTS_TYPE_MPL_ICON)) { - BT_INFO("Type: Icon Obj Type"); + LOG_INF("Type: Icon Obj Type"); } else if (!bt_uuid_cmp(&metadata->type.uuid, BT_UUID_OTS_TYPE_TRACK_SEGMENT)) { - BT_INFO("Type: Track Segment Obj Type"); + LOG_INF("Type: Track Segment Obj Type"); } else if (!bt_uuid_cmp(&metadata->type.uuid, BT_UUID_OTS_TYPE_TRACK)) { - BT_INFO("Type: Track Obj Type"); + LOG_INF("Type: Track Obj Type"); } else if (!bt_uuid_cmp(&metadata->type.uuid, BT_UUID_OTS_TYPE_GROUP)) { - BT_INFO("Type: Group Obj Type"); + LOG_INF("Type: Group Obj Type"); } else if (!bt_uuid_cmp(&metadata->type.uuid, BT_UUID_OTS_DIRECTORY_LISTING)) { - BT_INFO("Type: Directory Listing"); + LOG_INF("Type: Directory Listing"); } - BT_INFO("Properties:0x%x", metadata->props); + LOG_INF("Properties:0x%x", metadata->props); if (BT_OTS_OBJ_GET_PROP_APPEND(metadata->props)) { - BT_INFO(" - append permitted"); + LOG_INF(" - append permitted"); } if (BT_OTS_OBJ_GET_PROP_DELETE(metadata->props)) { - BT_INFO(" - delete permitted"); + LOG_INF(" - delete permitted"); } if (BT_OTS_OBJ_GET_PROP_EXECUTE(metadata->props)) { - BT_INFO(" - execute permitted"); + LOG_INF(" - execute permitted"); } if (BT_OTS_OBJ_GET_PROP_MARKED(metadata->props)) { - BT_INFO(" - marked"); + LOG_INF(" - marked"); } if (BT_OTS_OBJ_GET_PROP_PATCH(metadata->props)) { - BT_INFO(" - patch permitted"); + LOG_INF(" - patch permitted"); } if (BT_OTS_OBJ_GET_PROP_READ(metadata->props)) { - BT_INFO(" - read permitted"); + LOG_INF(" - read permitted"); } if (BT_OTS_OBJ_GET_PROP_TRUNCATE(metadata->props)) { - BT_INFO(" - truncate permitted"); + LOG_INF(" - truncate permitted"); } if (BT_OTS_OBJ_GET_PROP_WRITE(metadata->props)) { - BT_INFO(" - write permitted"); + LOG_INF(" - write permitted"); } } } diff --git a/subsys/bluetooth/shell/mcc.c b/subsys/bluetooth/shell/mcc.c index 7a2c72b49ec..dbfa0611095 100644 --- a/subsys/bluetooth/shell/mcc.c +++ b/subsys/bluetooth/shell/mcc.c @@ -21,9 +21,9 @@ #include "../services/ots/ots_client_internal.h" #include "../audio/media_proxy_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_MCC) -#define LOG_MODULE_NAME bt_mcc_shell -#include "common/log.h" +#include + +LOG_MODULE_REGISTER(bt_mcc_shell, CONFIG_BT_MCC_LOG_LEVEL); static struct bt_mcc_cb cb; @@ -975,7 +975,7 @@ int cmd_mcc_send_search_raw(const struct shell *sh, size_t argc, char *argv[]) search.len = strlen(argv[1]); memcpy(search.search, argv[1], search.len); - BT_DBG("Search string: %s", argv[1]); + LOG_DBG("Search string: %s", argv[1]); result = bt_mcc_send_search(default_conn, &search); if (result) { @@ -1083,7 +1083,7 @@ int cmd_mcc_send_search_ioptest(const struct shell *sh, size_t argc, return result; } -#if defined(CONFIG_BT_DEBUG_MCC) && defined(CONFIG_BT_TESTING) +#if defined(CONFIG_BT_MCC_LOG_LEVEL_DBG) && defined(CONFIG_BT_TESTING) int cmd_mcc_test_send_search_iop_invalid_type(const struct shell *sh, size_t argc, char *argv[]) { @@ -1130,7 +1130,7 @@ int cmd_mcc_test_send_search_invalid_sci_len(const struct shell *sh, return result; } -#endif /* CONFIG_BT_DEBUG_MCC && CONFIG_BT_TESTING */ +#endif /* CONFIG_BT_MCC_LOG_LEVEL_DBG && CONFIG_BT_TESTING */ int cmd_mcc_read_search_results_obj_id(const struct shell *sh, size_t argc, char *argv[]) @@ -1484,14 +1484,14 @@ SHELL_STATIC_SUBCMD_SET_CREATE(mcc_cmds, SHELL_CMD_ARG(send_search_scp_ioptest, NULL, "Send search - IOP test round as input ", cmd_mcc_send_search_ioptest, 2, 0), -#if defined(CONFIG_BT_DEBUG_MCC) && defined(CONFIG_BT_TESTING) +#if defined(CONFIG_BT_MCC_LOG_LEVEL_DBG) && defined(CONFIG_BT_TESTING) SHELL_CMD_ARG(test_send_search_iop_invalid_type, NULL, "Send search - IOP test, invalid type value (test)", cmd_mcc_test_send_search_iop_invalid_type, 1, 0), SHELL_CMD_ARG(test_send_Search_invalid_sci_len, NULL, "Send search - invalid sci length (test)", cmd_mcc_test_send_search_invalid_sci_len, 1, 0), -#endif /* CONFIG_BT_DEBUG_MCC && CONFIG_BT_TESTING */ +#endif /* CONFIG_BT_MCC_LOG_LEVEL_DBG && CONFIG_BT_TESTING */ SHELL_CMD_ARG(read_search_results_obj_id, NULL, "Read Search Results Object ID", cmd_mcc_read_search_results_obj_id, 1, 0), diff --git a/subsys/bluetooth/shell/media_controller.c b/subsys/bluetooth/shell/media_controller.c index 5e74ed8b51a..ae7122aa10b 100644 --- a/subsys/bluetooth/shell/media_controller.c +++ b/subsys/bluetooth/shell/media_controller.c @@ -20,9 +20,9 @@ #include #include "../audio/media_proxy_internal.h" /* For MPL_NO_TRACK_ID - TODO: Fix */ -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_MCS) -#define LOG_MODULE_NAME bt_media_controller_shell -#include "common/log.h" +#include + +LOG_MODULE_REGISTER(bt_media_controller_shell, CONFIG_BT_MCS_LOG_LEVEL); static struct media_proxy_ctrl_cbs cbs; @@ -767,7 +767,7 @@ int cmd_media_set_search(const struct shell *sh, size_t argc, char *argv[]) search.len = strlen(argv[1]); memcpy(search.search, argv[1], search.len); - BT_DBG("Search string: %s", argv[1]); + LOG_DBG("Search string: %s", argv[1]); err = media_proxy_ctrl_send_search(current_player, &search); if (err) { diff --git a/subsys/bluetooth/shell/mpl.c b/subsys/bluetooth/shell/mpl.c index 54829529b73..69658a96c7a 100644 --- a/subsys/bluetooth/shell/mpl.c +++ b/subsys/bluetooth/shell/mpl.c @@ -19,13 +19,13 @@ #include #include "../audio/mpl_internal.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_MPL) -#define LOG_MODULE_NAME bt_mpl_shell -#include "common/log.h" +#include + +LOG_MODULE_REGISTER(bt_mpl_shell, CONFIG_BT_MPL_LOG_LEVEL); #if defined(CONFIG_BT_MPL) -#if defined(CONFIG_BT_DEBUG_MPL) && defined(CONFIG_BT_TESTING) +#if defined(CONFIG_BT_MPL_LOG_LEVEL_DBG) && defined(CONFIG_BT_TESTING) int cmd_mpl_test_set_media_state(const struct shell *sh, size_t argc, char *argv[]) { @@ -45,9 +45,9 @@ int cmd_mpl_test_unset_parent_group(const struct shell *sh, size_t argc, return 0; } #endif /* CONFIG_BT_MPL_OBJECTS */ -#endif /* CONFIG_BT_DEBUG_MPL && CONFIG_BT_TESTING */ +#endif /* CONFIG_BT_MPL_LOG_LEVEL_DBG && CONFIG_BT_TESTING */ -#if defined(CONFIG_BT_DEBUG_MPL) +#if defined(CONFIG_BT_MPL_LOG_LEVEL_DBG) int cmd_mpl_debug_dump_state(const struct shell *sh, size_t argc, char *argv[]) { @@ -55,7 +55,7 @@ int cmd_mpl_debug_dump_state(const struct shell *sh, size_t argc, return 0; } -#endif /* CONFIG_BT_DEBUG_MPL */ +#endif /* CONFIG_BT_MPL_LOG_LEVEL_DBG */ int cmd_media_proxy_pl_init(const struct shell *sh, size_t argc, char *argv[]) { @@ -183,7 +183,7 @@ static int cmd_mpl(const struct shell *sh, size_t argc, char **argv) } SHELL_STATIC_SUBCMD_SET_CREATE(mpl_cmds, -#if defined(CONFIG_BT_DEBUG_MPL) && defined(CONFIG_BT_TESTING) +#if defined(CONFIG_BT_MPL_LOG_LEVEL_DBG) && defined(CONFIG_BT_TESTING) SHELL_CMD_ARG(test_set_media_state, NULL, "Set the media player state (test) ", cmd_mpl_test_set_media_state, 2, 0), @@ -192,12 +192,12 @@ SHELL_STATIC_SUBCMD_SET_CREATE(mpl_cmds, "Set current group to be its own parent (test)", cmd_mpl_test_unset_parent_group, 1, 0), #endif /* CONFIG_BT_MPL_OBJECTS */ -#endif /* CONFIG_BT_DEBUG_MPL && CONFIG_BT_TESTING */ -#if defined(CONFIG_BT_DEBUG_MPL) +#endif /* CONFIG_BT_MPL_LOG_LEVEL_DBG && CONFIG_BT_TESTING */ +#if defined(CONFIG_BT_MPL_LOG_LEVEL_DBG) SHELL_CMD_ARG(debug_dump_state, NULL, "Dump media player's state as debug output (debug)", cmd_mpl_debug_dump_state, 1, 0), -#endif /* CONFIG_BT_DEBUG_MPL */ +#endif /* CONFIG_BT_MPL_LOG_LEVEL_DBG */ SHELL_CMD_ARG(init, NULL, "Initialize media player", cmd_media_proxy_pl_init, 1, 0), diff --git a/subsys/bluetooth/shell/tbs.c b/subsys/bluetooth/shell/tbs.c index dad8932e82f..111e9db67be 100644 --- a/subsys/bluetooth/shell/tbs.c +++ b/subsys/bluetooth/shell/tbs.c @@ -508,7 +508,7 @@ static int cmd_tbs_set_uri_scheme_list(const struct shell *sh, size_t argc, static int cmd_tbs_print_calls(const struct shell *sh, size_t argc, char *argv[]) { - if (IS_ENABLED(CONFIG_BT_DEBUG_TBS)) { + if (IS_ENABLED(CONFIG_BT_TBS_LOG_LEVEL_DBG)) { bt_tbs_dbg_print_calls(); return 0; } diff --git a/tests/bluetooth/bsim_bt/bsim_test_audio/prj.conf b/tests/bluetooth/bsim_bt/bsim_test_audio/prj.conf index 124ff394f0e..d561a60af56 100644 --- a/tests/bluetooth/bsim_bt/bsim_test_audio/prj.conf +++ b/tests/bluetooth/bsim_bt/bsim_test_audio/prj.conf @@ -116,37 +116,37 @@ CONFIG_BT_CAP_INITIATOR=y # DEBUGGING CONFIG_BT_DEBUG_LOG=y -CONFIG_BT_DEBUG_VCS=y -CONFIG_BT_DEBUG_VCS_CLIENT=y -CONFIG_BT_DEBUG_AICS=y -CONFIG_BT_DEBUG_AICS_CLIENT=y -CONFIG_BT_DEBUG_VOCS=y -CONFIG_BT_DEBUG_VOCS_CLIENT=y -CONFIG_BT_DEBUG_MICP_MIC_DEV=y -CONFIG_BT_DEBUG_MICP_MIC_CTLR=y -CONFIG_BT_DEBUG_MPL=y -CONFIG_BT_DEBUG_TBS=y -CONFIG_BT_DEBUG_TBS_CLIENT=y -CONFIG_BT_DEBUG_MCS=y -CONFIG_BT_DEBUG_MCC=y +CONFIG_BT_VCS_LOG_LEVEL_DBG=y +CONFIG_BT_VCS_CLIENT_LOG_LEVEL_DBG=y +CONFIG_BT_AICS_LOG_LEVEL_DBG=y +CONFIG_BT_AICS_CLIENT_LOG_LEVEL_DBG=y +CONFIG_BT_VOCS_LOG_LEVEL_DBG=y +CONFIG_BT_VOCS_CLIENT_LOG_LEVEL_DBG=y +CONFIG_BT_MICP_MIC_DEV_LOG_LEVEL_DBG=y +CONFIG_BT_MICP_MIC_CTLR_LOG_LEVEL_DBG=y +CONFIG_BT_MPL_LOG_LEVEL_DBG=y +CONFIG_BT_TBS_LOG_LEVEL_DBG=y +CONFIG_BT_TBS_CLIENT_LOG_LEVEL_DBG=y +CONFIG_BT_MCS_LOG_LEVEL_DBG=y +CONFIG_BT_MCC_LOG_LEVEL_DBG=y CONFIG_BT_OTS_LOG_LEVEL_DBG=y -CONFIG_BT_DEBUG_OTS_CLIENT=y -CONFIG_MCTL_DEBUG=y -CONFIG_BT_DEBUG_CSIP_SET_MEMBER=y -CONFIG_BT_DEBUG_CSIP_SET_COORDINATOR=y -CONFIG_BT_DEBUG_CSIP_SET_MEMBER_CRYPTO=y -CONFIG_BT_AUDIO_DEBUG_UNICAST_CLIENT=y -CONFIG_BT_AUDIO_DEBUG_UNICAST_SERVER=y -CONFIG_BT_AUDIO_DEBUG_BROADCAST_SINK=y -CONFIG_BT_AUDIO_DEBUG_BROADCAST_SOURCE=y -CONFIG_BT_DEBUG_ASCS=y -CONFIG_BT_DEBUG_PACS=y -CONFIG_BT_AUDIO_DEBUG_STREAM=y -CONFIG_BT_DEBUG_BAP_SCAN_DELEGATOR=y -CONFIG_BT_DEBUG_BAP_BROADCAST_ASSISTANT=y -CONFIG_BT_DEBUG_HAS=y -CONFIG_BT_DEBUG_HAS_CLIENT=y -CONFIG_BT_DEBUG_CAP_ACCEPTOR=y +CONFIG_BT_OTS_CLIENT_LOG_LEVEL_DBG=y +CONFIG_MCTL_LOG_LEVEL_DBG=y +CONFIG_BT_CSIP_SET_MEMBER_LOG_LEVEL_DBG=y +CONFIG_BT_CSIP_SET_COORDINATOR_LOG_LEVEL_DBG=y +CONFIG_BT_CSIP_SET_MEMBER_CRYPTO_LOG_LEVEL_DBG=y +CONFIG_BT_AUDIO_UNICAST_CLIENT_LOG_LEVEL_DBG=y +CONFIG_BT_AUDIO_UNICAST_SERVER_LOG_LEVEL_DBG=y +CONFIG_BT_AUDIO_BROADCAST_SINK_LOG_LEVEL_DBG=y +CONFIG_BT_AUDIO_BROADCAST_SOURCE_LOG_LEVEL_DBG=y +CONFIG_BT_ASCS_LOG_LEVEL_DBG=y +CONFIG_BT_PACS_LOG_LEVEL_DBG=y +CONFIG_BT_AUDIO_STREAM_LOG_LEVEL_DBG=y +CONFIG_BT_BAP_SCAN_DELEGATOR_LOG_LEVEL_DBG=y +CONFIG_BT_BAP_BROADCAST_ASSISTANT_LOG_LEVEL_DBG=y +CONFIG_BT_HAS_LOG_LEVEL_DBG=y +CONFIG_BT_HAS_CLIENT_LOG_LEVEL_DBG=y +CONFIG_BT_CAP_ACCEPTOR_LOG_LEVEL_DBG=y CONFIG_BT_DEBUG_CAP_INITIATOR=y # LOGGING diff --git a/tests/bluetooth/bsim_bt/bsim_test_l2cap/prj.conf b/tests/bluetooth/bsim_bt/bsim_test_l2cap/prj.conf index 6d25419317c..430196744e3 100644 --- a/tests/bluetooth/bsim_bt/bsim_test_l2cap/prj.conf +++ b/tests/bluetooth/bsim_bt/bsim_test_l2cap/prj.conf @@ -19,6 +19,6 @@ CONFIG_BT_CTLR_DATA_LENGTH_MAX=69 CONFIG_LOG=y -CONFIG_BT_DEBUG_L2CAP=y +CONFIG_BT_L2CAP_LOG_LEVEL_DBG=y CONFIG_ASSERT=y diff --git a/tests/bluetooth/bsim_bt/bsim_test_mesh/prj.conf b/tests/bluetooth/bsim_bt/bsim_test_mesh/prj.conf index bff0f4335aa..11eeee853c5 100644 --- a/tests/bluetooth/bsim_bt/bsim_test_mesh/prj.conf +++ b/tests/bluetooth/bsim_bt/bsim_test_mesh/prj.conf @@ -44,4 +44,4 @@ CONFIG_BT_MESH_PROV_OOB_PUBLIC_KEY=y CONFIG_BT_MESH_MODEL_EXTENSIONS=y CONFIG_BT_MESH_SUBNET_COUNT=5 -CONFIG_BT_MESH_DEBUG=y +CONFIG_BT_MESH_LOG_LEVEL_DBG=y diff --git a/tests/bluetooth/bsim_bt/bsim_test_mesh/prj_gatt.conf b/tests/bluetooth/bsim_bt/bsim_test_mesh/prj_gatt.conf index 0aa9c282cd1..b3df1305bd5 100644 --- a/tests/bluetooth/bsim_bt/bsim_test_mesh/prj_gatt.conf +++ b/tests/bluetooth/bsim_bt/bsim_test_mesh/prj_gatt.conf @@ -41,4 +41,4 @@ CONFIG_BT_MESH_PROV_OOB_PUBLIC_KEY=y CONFIG_BT_MESH_MODEL_EXTENSIONS=y CONFIG_BT_MESH_SUBNET_COUNT=5 -CONFIG_BT_MESH_DEBUG=y +CONFIG_BT_MESH_LOG_LEVEL_DBG=y diff --git a/tests/bluetooth/bsim_bt/bsim_test_mesh/prj_low_lat.conf b/tests/bluetooth/bsim_bt/bsim_test_mesh/prj_low_lat.conf index 29c54fe052b..91f03a80d27 100644 --- a/tests/bluetooth/bsim_bt/bsim_test_mesh/prj_low_lat.conf +++ b/tests/bluetooth/bsim_bt/bsim_test_mesh/prj_low_lat.conf @@ -48,4 +48,4 @@ CONFIG_BT_MESH_CDB=y CONFIG_BT_MESH_CDB_NODE_COUNT=3 CONFIG_BT_MESH_MODEL_EXTENSIONS=y -CONFIG_BT_MESH_DEBUG=y +CONFIG_BT_MESH_LOG_LEVEL_DBG=y diff --git a/tests/bluetooth/bsim_bt/bsim_test_mesh/prj_pst.conf b/tests/bluetooth/bsim_bt/bsim_test_mesh/prj_pst.conf index 8a20fcf7c17..db58c2141fb 100644 --- a/tests/bluetooth/bsim_bt/bsim_test_mesh/prj_pst.conf +++ b/tests/bluetooth/bsim_bt/bsim_test_mesh/prj_pst.conf @@ -1,6 +1,6 @@ CONFIG_SETTINGS=y CONFIG_SETTINGS_CUSTOM=y -CONFIG_BT_MESH_DEBUG_SETTINGS=y +CONFIG_BT_MESH_SETTINGS_LOG_LEVEL_DBG=y CONFIG_SYS_CLOCK_TICKS_PER_SEC=32768 CONFIG_BT=y @@ -56,4 +56,4 @@ CONFIG_BT_MESH_SEQ_STORE_RATE=1 CONFIG_BT_MESH_RPL_STORE_TIMEOUT=1 CONFIG_BT_MESH_STORE_TIMEOUT=1 -CONFIG_BT_MESH_DEBUG=y +CONFIG_BT_MESH_LOG_LEVEL_DBG=y diff --git a/tests/bluetooth/bsim_bt/edtt_ble_test_app/hci_test_app/src/main.c b/tests/bluetooth/bsim_bt/edtt_ble_test_app/hci_test_app/src/main.c index d470f13178c..e0382a702cd 100644 --- a/tests/bluetooth/bsim_bt/edtt_ble_test_app/hci_test_app/src/main.c +++ b/tests/bluetooth/bsim_bt/edtt_ble_test_app/hci_test_app/src/main.c @@ -27,7 +27,7 @@ #include "bs_tracing.h" #include "commands.h" -#if IS_ENABLED(CONFIG_BT_DEBUG_HCI_CORE) +#if IS_ENABLED(CONFIG_BT_HCI_CORE_LOG_LEVEL_DBG) #define LOG_LEVEL LOG_LEVEL_DBG #else #define LOG_LEVEL CONFIG_BT_LOG_LEVEL diff --git a/tests/bluetooth/controller/mock_ctrl/src/lll_clock.c b/tests/bluetooth/controller/mock_ctrl/src/lll_clock.c index 9d5f58853ca..96a0df59d2b 100644 --- a/tests/bluetooth/controller/mock_ctrl/src/lll_clock.c +++ b/tests/bluetooth/controller/mock_ctrl/src/lll_clock.c @@ -7,9 +7,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_lll_clock -#include "common/log.h" #include "hal/debug.h" /* Clock setup timeouts are unlikely, below values are experimental */ diff --git a/tests/bluetooth/controller/mock_ctrl/src/ull_conn_iso.c b/tests/bluetooth/controller/mock_ctrl/src/ull_conn_iso.c index 306f0d7c823..5aff63a0e01 100644 --- a/tests/bluetooth/controller/mock_ctrl/src/ull_conn_iso.c +++ b/tests/bluetooth/controller/mock_ctrl/src/ull_conn_iso.c @@ -37,9 +37,6 @@ #include "ull_internal.h" #include "lll/lll_vendor.h" -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) -#define LOG_MODULE_NAME bt_ctlr_ull_conn_iso -#include "common/log.h" #include "hal/debug.h" static struct ll_conn_iso_group cig = { 0 }; diff --git a/tests/bluetooth/hci_prop_evt/prj.conf b/tests/bluetooth/hci_prop_evt/prj.conf index 2d4e19be4d9..7bc1a2cad71 100644 --- a/tests/bluetooth/hci_prop_evt/prj.conf +++ b/tests/bluetooth/hci_prop_evt/prj.conf @@ -10,7 +10,7 @@ CONFIG_BT_RECV_BLOCKING=y CONFIG_BT_HCI_VS_EVT_USER=y CONFIG_BT_DEBUG_LOG=y -CONFIG_BT_DEBUG_HCI_CORE=y -CONFIG_BT_DEBUG_HCI_DRIVER=y +CONFIG_BT_HCI_CORE_LOG_LEVEL_DBG=y +CONFIG_BT_HCI_DRIVER_LOG_LEVEL_DBG=y CONFIG_HEAP_MEM_POOL_SIZE=2048 diff --git a/tests/bluetooth/host_long_adv_recv/prj.conf b/tests/bluetooth/host_long_adv_recv/prj.conf index 94b6d77fe99..e58a5236e27 100644 --- a/tests/bluetooth/host_long_adv_recv/prj.conf +++ b/tests/bluetooth/host_long_adv_recv/prj.conf @@ -12,8 +12,8 @@ CONFIG_BT_RECV_BLOCKING=y CONFIG_BT_EXT_ADV=y CONFIG_BT_DEBUG_LOG=y -CONFIG_BT_DEBUG_HCI_CORE=n -CONFIG_BT_DEBUG_HCI_DRIVER=n +CONFIG_BT_HCI_CORE_LOG_LEVEL_DBG=n +CONFIG_BT_HCI_DRIVER_LOG_LEVEL_DBG=n CONFIG_BT_LOG_LEVEL_DBG=y CONFIG_BT_EXT_SCAN_BUF_SIZE=91 diff --git a/tests/bluetooth/init/prj_17.conf b/tests/bluetooth/init/prj_17.conf index dd60510942f..d1fd95b5cdf 100644 --- a/tests/bluetooth/init/prj_17.conf +++ b/tests/bluetooth/init/prj_17.conf @@ -9,15 +9,15 @@ CONFIG_BT_USE_DEBUG_KEYS=y CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y CONFIG_BT_GATT_CLIENT=y CONFIG_BT_DEBUG_LOG=y -CONFIG_BT_DEBUG_HCI_CORE=y -CONFIG_BT_DEBUG_CONN=y -CONFIG_BT_DEBUG_KEYS=y -CONFIG_BT_DEBUG_L2CAP=y -CONFIG_BT_DEBUG_SMP=y -CONFIG_BT_DEBUG_HCI_DRIVER=y +CONFIG_BT_HCI_CORE_LOG_LEVEL_DBG=y +CONFIG_BT_CONN_LOG_LEVEL_DBG=y +CONFIG_BT_KEYS_LOG_LEVEL_DBG=y +CONFIG_BT_L2CAP_LOG_LEVEL_DBG=y +CONFIG_BT_SMP_LOG_LEVEL_DBG=y +CONFIG_BT_HCI_DRIVER_LOG_LEVEL_DBG=y CONFIG_BT_SMP_SELFTEST=y -CONFIG_BT_DEBUG_ATT=y -CONFIG_BT_DEBUG_GATT=y +CONFIG_BT_ATT_LOG_LEVEL_DBG=y +CONFIG_BT_GATT_LOG_LEVEL_DBG=y CONFIG_BT_BREDR=y CONFIG_ZTEST=y CONFIG_ZTEST_NEW_API=y diff --git a/tests/bluetooth/init/prj_20.conf b/tests/bluetooth/init/prj_20.conf index 95d2cd1f55e..23b7ed7cb6f 100644 --- a/tests/bluetooth/init/prj_20.conf +++ b/tests/bluetooth/init/prj_20.conf @@ -10,21 +10,21 @@ CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y CONFIG_BT_GATT_CLIENT=y CONFIG_BT_DEBUG_MONITOR_UART=y CONFIG_UART_CONSOLE=n -CONFIG_BT_DEBUG_HCI_CORE=y -CONFIG_BT_DEBUG_CONN=y -CONFIG_BT_DEBUG_KEYS=y -CONFIG_BT_DEBUG_L2CAP=y -CONFIG_BT_DEBUG_SMP=y -CONFIG_BT_DEBUG_HCI_DRIVER=y +CONFIG_BT_HCI_CORE_LOG_LEVEL_DBG=y +CONFIG_BT_CONN_LOG_LEVEL_DBG=y +CONFIG_BT_KEYS_LOG_LEVEL_DBG=y +CONFIG_BT_L2CAP_LOG_LEVEL_DBG=y +CONFIG_BT_SMP_LOG_LEVEL_DBG=y +CONFIG_BT_HCI_DRIVER_LOG_LEVEL_DBG=y CONFIG_BT_SMP_SELFTEST=y -CONFIG_BT_DEBUG_ATT=y -CONFIG_BT_DEBUG_GATT=y +CONFIG_BT_ATT_LOG_LEVEL_DBG=y +CONFIG_BT_GATT_LOG_LEVEL_DBG=y CONFIG_BT_BREDR=y CONFIG_BT_RFCOMM=y CONFIG_BT_AVDTP=y -CONFIG_BT_DEBUG_AVDTP=y +CONFIG_BT_AVDTP_LOG_LEVEL_DBG=y CONFIG_BT_A2DP=y CONFIG_BT_HFP_HF=y -CONFIG_BT_DEBUG_HFP_HF=y +CONFIG_BT_HFP_HF_LOG_LEVEL_DBG=y CONFIG_ZTEST=y CONFIG_ZTEST_NEW_API=y diff --git a/tests/bluetooth/init/prj_21.conf b/tests/bluetooth/init/prj_21.conf index d4917865640..5ddee9de9e1 100644 --- a/tests/bluetooth/init/prj_21.conf +++ b/tests/bluetooth/init/prj_21.conf @@ -9,15 +9,15 @@ CONFIG_BT_USE_DEBUG_KEYS=y CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y CONFIG_BT_GATT_CLIENT=y CONFIG_BT_DEBUG_MONITOR_UART=y -CONFIG_BT_DEBUG_HCI_CORE=y -CONFIG_BT_DEBUG_CONN=y -CONFIG_BT_DEBUG_KEYS=y -CONFIG_BT_DEBUG_L2CAP=y -CONFIG_BT_DEBUG_SMP=y -CONFIG_BT_DEBUG_HCI_DRIVER=y +CONFIG_BT_HCI_CORE_LOG_LEVEL_DBG=y +CONFIG_BT_CONN_LOG_LEVEL_DBG=y +CONFIG_BT_KEYS_LOG_LEVEL_DBG=y +CONFIG_BT_L2CAP_LOG_LEVEL_DBG=y +CONFIG_BT_SMP_LOG_LEVEL_DBG=y +CONFIG_BT_HCI_DRIVER_LOG_LEVEL_DBG=y CONFIG_BT_SMP_SELFTEST=y -CONFIG_BT_DEBUG_ATT=y -CONFIG_BT_DEBUG_GATT=y +CONFIG_BT_ATT_LOG_LEVEL_DBG=y +CONFIG_BT_GATT_LOG_LEVEL_DBG=y CONFIG_BT_BREDR=y CONFIG_ZTEST=y CONFIG_ZTEST_NEW_API=y diff --git a/tests/bluetooth/init/prj_ctlr_dbg.conf b/tests/bluetooth/init/prj_ctlr_dbg.conf index b9e464b85e2..6aff0965ce9 100644 --- a/tests/bluetooth/init/prj_ctlr_dbg.conf +++ b/tests/bluetooth/init/prj_ctlr_dbg.conf @@ -45,15 +45,15 @@ CONFIG_BT_USE_DEBUG_KEYS=y CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y CONFIG_BT_GATT_CLIENT=y CONFIG_BT_DEBUG_MONITOR_UART=y -CONFIG_BT_DEBUG_HCI_CORE=y -CONFIG_BT_DEBUG_CONN=y -CONFIG_BT_DEBUG_KEYS=y -CONFIG_BT_DEBUG_L2CAP=y -CONFIG_BT_DEBUG_SMP=y -CONFIG_BT_DEBUG_HCI_DRIVER=y +CONFIG_BT_HCI_CORE_LOG_LEVEL_DBG=y +CONFIG_BT_CONN_LOG_LEVEL_DBG=y +CONFIG_BT_KEYS_LOG_LEVEL_DBG=y +CONFIG_BT_L2CAP_LOG_LEVEL_DBG=y +CONFIG_BT_SMP_LOG_LEVEL_DBG=y +CONFIG_BT_HCI_DRIVER_LOG_LEVEL_DBG=y CONFIG_BT_SMP_SELFTEST=y -CONFIG_BT_DEBUG_ATT=y -CONFIG_BT_DEBUG_GATT=y +CONFIG_BT_ATT_LOG_LEVEL_DBG=y +CONFIG_BT_GATT_LOG_LEVEL_DBG=y CONFIG_BT_BREDR=n CONFIG_DEBUG=y CONFIG_FLASH=y diff --git a/tests/bluetooth/init/prj_h5_dbg.conf b/tests/bluetooth/init/prj_h5_dbg.conf index 07c84746863..f8733eb2ee2 100644 --- a/tests/bluetooth/init/prj_h5_dbg.conf +++ b/tests/bluetooth/init/prj_h5_dbg.conf @@ -1,6 +1,6 @@ CONFIG_BT=y CONFIG_BT_H5=y CONFIG_BT_DEBUG_LOG=y -CONFIG_BT_DEBUG_HCI_DRIVER=y +CONFIG_BT_HCI_DRIVER_LOG_LEVEL_DBG=y CONFIG_ZTEST=y CONFIG_ZTEST_NEW_API=y diff --git a/tests/bluetooth/mesh/dbg.conf b/tests/bluetooth/mesh/dbg.conf index b513b13e82e..d4da938c358 100644 --- a/tests/bluetooth/mesh/dbg.conf +++ b/tests/bluetooth/mesh/dbg.conf @@ -44,16 +44,16 @@ CONFIG_BT_MESH_IV_UPDATE_TEST=y #CONFIG_BT_DEBUG_MONITOR_UART=y CONFIG_BT_DEBUG_LOG=y -CONFIG_BT_MESH_DEBUG=y -CONFIG_BT_MESH_DEBUG_PROV=y -CONFIG_BT_MESH_DEBUG_PROXY=y -CONFIG_BT_MESH_DEBUG_BEACON=y -CONFIG_BT_MESH_DEBUG_NET=y -CONFIG_BT_MESH_DEBUG_TRANS=y -CONFIG_BT_MESH_DEBUG_LOW_POWER=y -CONFIG_BT_MESH_DEBUG_FRIEND=y -CONFIG_BT_MESH_DEBUG_MODEL=y -CONFIG_BT_MESH_DEBUG_ACCESS=y -CONFIG_BT_MESH_DEBUG_CRYPTO=y -CONFIG_BT_MESH_DEBUG_ADV=y +CONFIG_BT_MESH_LOG_LEVEL_DBG=y +CONFIG_BT_MESH_PROV_LOG_LEVEL_DBG=y +CONFIG_BT_MESH_PROXY_LOG_LEVEL_DBG=y +CONFIG_BT_MESH_BEACON_LOG_LEVEL_DBG=y +CONFIG_BT_MESH_NET_LOG_LEVEL_DBG=y +CONFIG_BT_MESH_TRANS_LOG_LEVEL_DBG=y +CONFIG_BT_MESH_LOW_POWER_LOG_LEVEL_DBG=y +CONFIG_BT_MESH_FRIEND_LOG_LEVEL_DBG=y +CONFIG_BT_MESH_MODEL_LOG_LEVEL_DBG=y +CONFIG_BT_MESH_ACCESS_LOG_LEVEL_DBG=y +CONFIG_BT_MESH_CRYPTO_LOG_LEVEL_DBG=y +CONFIG_BT_MESH_ADV_LOG_LEVEL_DBG=y CONFIG_BT_MESH_SELF_TEST=y diff --git a/tests/bluetooth/mesh/ext_adv.conf b/tests/bluetooth/mesh/ext_adv.conf index f77f948a689..7760f74202d 100644 --- a/tests/bluetooth/mesh/ext_adv.conf +++ b/tests/bluetooth/mesh/ext_adv.conf @@ -44,16 +44,16 @@ CONFIG_BT_MESH_IV_UPDATE_TEST=y #CONFIG_BT_DEBUG_MONITOR_UART=y CONFIG_BT_DEBUG_LOG=y -CONFIG_BT_MESH_DEBUG=y -CONFIG_BT_MESH_DEBUG_PROV=y -CONFIG_BT_MESH_DEBUG_PROXY=y -#CONFIG_BT_MESH_DEBUG_BEACON=y -CONFIG_BT_MESH_DEBUG_NET=y -#CONFIG_BT_MESH_DEBUG_TRANS=y -#CONFIG_BT_MESH_DEBUG_LOW_POWER=y -#CONFIG_BT_MESH_DEBUG_FRIEND=y -#CONFIG_BT_MESH_DEBUG_MODEL=y -CONFIG_BT_MESH_DEBUG_ACCESS=y -CONFIG_BT_MESH_DEBUG_CRYPTO=y -CONFIG_BT_MESH_DEBUG_ADV=y +CONFIG_BT_MESH_LOG_LEVEL_DBG=y +CONFIG_BT_MESH_PROV_LOG_LEVEL_DBG=y +CONFIG_BT_MESH_PROXY_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_BEACON_LOG_LEVEL_DBG=y +CONFIG_BT_MESH_NET_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_TRANS_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_LOW_POWER_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_FRIEND_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_MODEL_LOG_LEVEL_DBG=y +CONFIG_BT_MESH_ACCESS_LOG_LEVEL_DBG=y +CONFIG_BT_MESH_CRYPTO_LOG_LEVEL_DBG=y +CONFIG_BT_MESH_ADV_LOG_LEVEL_DBG=y #CONFIG_BT_MESH_SELF_TEST=y diff --git a/tests/bluetooth/mesh/friend.conf b/tests/bluetooth/mesh/friend.conf index f685cdb570b..b40f8daaad1 100644 --- a/tests/bluetooth/mesh/friend.conf +++ b/tests/bluetooth/mesh/friend.conf @@ -41,16 +41,16 @@ CONFIG_BT_MESH_LABEL_COUNT=3 #CONFIG_BT_DEBUG_MONITOR_UART=y #CONFIG_BT_DEBUG_LOG=y -#CONFIG_BT_MESH_DEBUG=y -#CONFIG_BT_MESH_DEBUG_PROV=y -#CONFIG_BT_MESH_DEBUG_PROXY=y -#CONFIG_BT_MESH_DEBUG_BEACON=y -#CONFIG_BT_MESH_DEBUG_NET=y -#CONFIG_BT_MESH_DEBUG_TRANS=y -#CONFIG_BT_MESH_DEBUG_LOW_POWER=y -#CONFIG_BT_MESH_DEBUG_FRIEND=y -#CONFIG_BT_MESH_DEBUG_MODEL=y -#CONFIG_BT_MESH_DEBUG_ACCESS=y -#CONFIG_BT_MESH_DEBUG_CRYPTO=y -#CONFIG_BT_MESH_DEBUG_ADV=y +#CONFIG_BT_MESH_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_PROXY_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_BEACON_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_NET_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_TRANS_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_LOW_POWER_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_FRIEND_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_MODEL_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_ACCESS_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_CRYPTO_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_ADV_LOG_LEVEL_DBG=y #CONFIG_BT_MESH_SELF_TEST=y diff --git a/tests/bluetooth/mesh/gatt.conf b/tests/bluetooth/mesh/gatt.conf index f3e575236a0..8388ddcb7c1 100644 --- a/tests/bluetooth/mesh/gatt.conf +++ b/tests/bluetooth/mesh/gatt.conf @@ -44,16 +44,16 @@ CONFIG_BT_MESH_LABEL_COUNT=3 #CONFIG_BT_DEBUG_MONITOR_UART=y #CONFIG_BT_DEBUG_LOG=y -#CONFIG_BT_MESH_DEBUG=y -#CONFIG_BT_MESH_DEBUG_PROV=y -#CONFIG_BT_MESH_DEBUG_PROXY=y -#CONFIG_BT_MESH_DEBUG_BEACON=y -#CONFIG_BT_MESH_DEBUG_NET=y -#CONFIG_BT_MESH_DEBUG_TRANS=y -#CONFIG_BT_MESH_DEBUG_LOW_POWER=y -#CONFIG_BT_MESH_DEBUG_FRIEND=y -#CONFIG_BT_MESH_DEBUG_MODEL=y -#CONFIG_BT_MESH_DEBUG_ACCESS=y -#CONFIG_BT_MESH_DEBUG_CRYPTO=y -#CONFIG_BT_MESH_DEBUG_ADV=y +#CONFIG_BT_MESH_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_PROXY_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_BEACON_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_NET_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_TRANS_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_LOW_POWER_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_FRIEND_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_MODEL_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_ACCESS_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_CRYPTO_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_ADV_LOG_LEVEL_DBG=y #CONFIG_BT_MESH_SELF_TEST=y diff --git a/tests/bluetooth/mesh/lpn.conf b/tests/bluetooth/mesh/lpn.conf index b3a858c4630..7ca1c8cb6d7 100644 --- a/tests/bluetooth/mesh/lpn.conf +++ b/tests/bluetooth/mesh/lpn.conf @@ -44,16 +44,16 @@ CONFIG_BT_MESH_IV_UPDATE_TEST=y #CONFIG_BT_DEBUG_MONITOR_UART=y CONFIG_BT_DEBUG_LOG=y -CONFIG_BT_MESH_DEBUG=y -#CONFIG_BT_MESH_DEBUG_PROV=y -#CONFIG_BT_MESH_DEBUG_PROXY=y -#CONFIG_BT_MESH_DEBUG_BEACON=y -CONFIG_BT_MESH_DEBUG_NET=y -#CONFIG_BT_MESH_DEBUG_TRANS=y -CONFIG_BT_MESH_DEBUG_LOW_POWER=y -#CONFIG_BT_MESH_DEBUG_FRIEND=y -#CONFIG_BT_MESH_DEBUG_MODEL=y -CONFIG_BT_MESH_DEBUG_ACCESS=y -#CONFIG_BT_MESH_DEBUG_CRYPTO=y -#CONFIG_BT_MESH_DEBUG_ADV=y +CONFIG_BT_MESH_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_PROV_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_PROXY_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_BEACON_LOG_LEVEL_DBG=y +CONFIG_BT_MESH_NET_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_TRANS_LOG_LEVEL_DBG=y +CONFIG_BT_MESH_LOW_POWER_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_FRIEND_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_MODEL_LOG_LEVEL_DBG=y +CONFIG_BT_MESH_ACCESS_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_CRYPTO_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_ADV_LOG_LEVEL_DBG=y #CONFIG_BT_MESH_SELF_TEST=y diff --git a/tests/bluetooth/mesh/microbit.conf b/tests/bluetooth/mesh/microbit.conf index b480ac696f3..7bb9e5bc4ee 100644 --- a/tests/bluetooth/mesh/microbit.conf +++ b/tests/bluetooth/mesh/microbit.conf @@ -45,13 +45,13 @@ CONFIG_BT_MESH_LABEL_COUNT=0 #CONFIG_BT_DEBUG_LOG=y -#CONFIG_BT_MESH_DEBUG=y -#CONFIG_BT_MESH_DEBUG_NET=y -#CONFIG_BT_MESH_DEBUG_TRANS=y -#CONFIG_BT_MESH_DEBUG_PROV=y -#CONFIG_BT_MESH_DEBUG_BEACON=y -#CONFIG_BT_MESH_DEBUG_CRYPTO=y -#CONFIG_BT_MESH_DEBUG_ADV=y -#CONFIG_BT_MESH_DEBUG_ACCESS=y +#CONFIG_BT_MESH_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_NET_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_TRANS_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_BEACON_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_CRYPTO_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_ADV_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_ACCESS_LOG_LEVEL_DBG=y CONFIG_CLOCK_CONTROL_NRF_CALIBRATION_MAX_SKIP=0 diff --git a/tests/bluetooth/mesh/microbit_gatt.conf b/tests/bluetooth/mesh/microbit_gatt.conf index daa5c083637..17c656d25f6 100644 --- a/tests/bluetooth/mesh/microbit_gatt.conf +++ b/tests/bluetooth/mesh/microbit_gatt.conf @@ -46,12 +46,12 @@ CONFIG_BT_MESH_LABEL_COUNT=0 #CONFIG_BT_DEBUG_MONITOR_UART=y #CONFIG_BT_DEBUG_LOG=y -#CONFIG_BT_MESH_DEBUG=y -#CONFIG_BT_MESH_DEBUG_NET=y -#CONFIG_BT_MESH_DEBUG_PROXY=y -#CONFIG_BT_MESH_DEBUG_TRANS=y -#CONFIG_BT_MESH_DEBUG_PROV=y -#CONFIG_BT_MESH_DEBUG_BEACON=y -#CONFIG_BT_MESH_DEBUG_CRYPTO=y -#CONFIG_BT_MESH_DEBUG_ADV=y -#CONFIG_BT_MESH_DEBUG_ACCESS=y +#CONFIG_BT_MESH_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_NET_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_PROXY_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_TRANS_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_BEACON_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_CRYPTO_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_ADV_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_ACCESS_LOG_LEVEL_DBG=y diff --git a/tests/bluetooth/mesh/multi_ext_adv.conf b/tests/bluetooth/mesh/multi_ext_adv.conf index 666b2b92bd4..19eaee8e3a6 100644 --- a/tests/bluetooth/mesh/multi_ext_adv.conf +++ b/tests/bluetooth/mesh/multi_ext_adv.conf @@ -42,13 +42,13 @@ CONFIG_BT_MESH_IV_UPDATE_TEST=y CONFIG_BT_DEBUG_LOG=y -CONFIG_BT_MESH_DEBUG=y -CONFIG_BT_MESH_DEBUG_PROV=y -CONFIG_BT_MESH_DEBUG_PROXY=y -CONFIG_BT_MESH_DEBUG_NET=y -CONFIG_BT_MESH_DEBUG_ACCESS=y -CONFIG_BT_MESH_DEBUG_CRYPTO=y -CONFIG_BT_MESH_DEBUG_ADV=y +CONFIG_BT_MESH_LOG_LEVEL_DBG=y +CONFIG_BT_MESH_PROV_LOG_LEVEL_DBG=y +CONFIG_BT_MESH_PROXY_LOG_LEVEL_DBG=y +CONFIG_BT_MESH_NET_LOG_LEVEL_DBG=y +CONFIG_BT_MESH_ACCESS_LOG_LEVEL_DBG=y +CONFIG_BT_MESH_CRYPTO_LOG_LEVEL_DBG=y +CONFIG_BT_MESH_ADV_LOG_LEVEL_DBG=y CONFIG_BT_EXT_ADV_MAX_ADV_SET=3 CONFIG_BT_MESH_RELAY_ADV_SETS=1 diff --git a/tests/bluetooth/mesh/nrf51-16k.conf b/tests/bluetooth/mesh/nrf51-16k.conf index fa991836b7c..3ab55ee85e2 100644 --- a/tests/bluetooth/mesh/nrf51-16k.conf +++ b/tests/bluetooth/mesh/nrf51-16k.conf @@ -27,11 +27,11 @@ CONFIG_BT_MESH_LABEL_COUNT=0 #CONFIG_BT_DEBUG_MONITOR_UART=y #CONFIG_BT_DEBUG_LOG=y -#CONFIG_BT_MESH_DEBUG=y -#CONFIG_BT_MESH_DEBUG_NET=y -#CONFIG_BT_MESH_DEBUG_TRANS=y -#CONFIG_BT_MESH_DEBUG_PROV=y -#CONFIG_BT_MESH_DEBUG_BEACON=y -#CONFIG_BT_MESH_DEBUG_CRYPTO=y -#CONFIG_BT_MESH_DEBUG_ADV=y -#CONFIG_BT_MESH_DEBUG_ACCESS=y +#CONFIG_BT_MESH_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_NET_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_TRANS_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_BEACON_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_CRYPTO_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_ADV_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_ACCESS_LOG_LEVEL_DBG=y diff --git a/tests/bluetooth/mesh/pb_gatt.conf b/tests/bluetooth/mesh/pb_gatt.conf index db9a522d64c..d1fe13c0049 100644 --- a/tests/bluetooth/mesh/pb_gatt.conf +++ b/tests/bluetooth/mesh/pb_gatt.conf @@ -44,16 +44,16 @@ CONFIG_BT_MESH_LABEL_COUNT=3 #CONFIG_BT_DEBUG_MONITOR_UART=y #CONFIG_BT_DEBUG_LOG=y -#CONFIG_BT_MESH_DEBUG=y -#CONFIG_BT_MESH_DEBUG_PROV=y -#CONFIG_BT_MESH_DEBUG_PROXY=y -#CONFIG_BT_MESH_DEBUG_BEACON=y -#CONFIG_BT_MESH_DEBUG_NET=y -#CONFIG_BT_MESH_DEBUG_TRANS=y -#CONFIG_BT_MESH_DEBUG_LOW_POWER=y -#CONFIG_BT_MESH_DEBUG_FRIEND=y -#CONFIG_BT_MESH_DEBUG_MODEL=y -#CONFIG_BT_MESH_DEBUG_ACCESS=y -#CONFIG_BT_MESH_DEBUG_CRYPTO=y -#CONFIG_BT_MESH_DEBUG_ADV=y +#CONFIG_BT_MESH_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_PROXY_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_BEACON_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_NET_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_TRANS_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_LOW_POWER_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_FRIEND_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_MODEL_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_ACCESS_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_CRYPTO_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_ADV_LOG_LEVEL_DBG=y #CONFIG_BT_MESH_SELF_TEST=y diff --git a/tests/bluetooth/mesh/prj.conf b/tests/bluetooth/mesh/prj.conf index 643a467debc..6e1fcb0f44f 100644 --- a/tests/bluetooth/mesh/prj.conf +++ b/tests/bluetooth/mesh/prj.conf @@ -46,16 +46,16 @@ CONFIG_BT_MESH_IV_UPDATE_TEST=y #CONFIG_BT_DEBUG_MONITOR_UART=y CONFIG_BT_DEBUG_LOG=y -CONFIG_BT_MESH_DEBUG=y -CONFIG_BT_MESH_DEBUG_PROV=y -CONFIG_BT_MESH_DEBUG_PROXY=y -#CONFIG_BT_MESH_DEBUG_BEACON=y -CONFIG_BT_MESH_DEBUG_NET=y -#CONFIG_BT_MESH_DEBUG_TRANS=y -#CONFIG_BT_MESH_DEBUG_LOW_POWER=y -#CONFIG_BT_MESH_DEBUG_FRIEND=y -#CONFIG_BT_MESH_DEBUG_MODEL=y -CONFIG_BT_MESH_DEBUG_ACCESS=y -CONFIG_BT_MESH_DEBUG_CRYPTO=y -CONFIG_BT_MESH_DEBUG_ADV=y +CONFIG_BT_MESH_LOG_LEVEL_DBG=y +CONFIG_BT_MESH_PROV_LOG_LEVEL_DBG=y +CONFIG_BT_MESH_PROXY_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_BEACON_LOG_LEVEL_DBG=y +CONFIG_BT_MESH_NET_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_TRANS_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_LOW_POWER_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_FRIEND_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_MODEL_LOG_LEVEL_DBG=y +CONFIG_BT_MESH_ACCESS_LOG_LEVEL_DBG=y +CONFIG_BT_MESH_CRYPTO_LOG_LEVEL_DBG=y +CONFIG_BT_MESH_ADV_LOG_LEVEL_DBG=y #CONFIG_BT_MESH_SELF_TEST=y diff --git a/tests/bluetooth/mesh/proxy.conf b/tests/bluetooth/mesh/proxy.conf index 7a6df1d1892..78de4dacb68 100644 --- a/tests/bluetooth/mesh/proxy.conf +++ b/tests/bluetooth/mesh/proxy.conf @@ -47,16 +47,16 @@ CONFIG_BT_MESH_IV_UPDATE_TEST=y #CONFIG_BT_DEBUG_MONITOR_UART=y #CONFIG_BT_DEBUG_LOG=y -#CONFIG_BT_MESH_DEBUG=y -#CONFIG_BT_MESH_DEBUG_PROV=y -#CONFIG_BT_MESH_DEBUG_PROXY=y -#CONFIG_BT_MESH_DEBUG_BEACON=y -CONFIG_BT_MESH_DEBUG_NET=y -#CONFIG_BT_MESH_DEBUG_TRANS=y -#CONFIG_BT_MESH_DEBUG_LOW_POWER=y -#CONFIG_BT_MESH_DEBUG_FRIEND=y -#CONFIG_BT_MESH_DEBUG_MODEL=y -#CONFIG_BT_MESH_DEBUG_ACCESS=y -#CONFIG_BT_MESH_DEBUG_CRYPTO=y -#CONFIG_BT_MESH_DEBUG_ADV=y +#CONFIG_BT_MESH_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_PROXY_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_BEACON_LOG_LEVEL_DBG=y +CONFIG_BT_MESH_NET_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_TRANS_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_LOW_POWER_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_FRIEND_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_MODEL_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_ACCESS_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_CRYPTO_LOG_LEVEL_DBG=y +#CONFIG_BT_MESH_ADV_LOG_LEVEL_DBG=y #CONFIG_BT_MESH_SELF_TEST=y diff --git a/tests/bluetooth/mesh_shell/prj.conf b/tests/bluetooth/mesh_shell/prj.conf index 61ce4e04d3b..bf3a0c8250e 100644 --- a/tests/bluetooth/mesh_shell/prj.conf +++ b/tests/bluetooth/mesh_shell/prj.conf @@ -68,4 +68,4 @@ CONFIG_BT_MESH_LABEL_COUNT=1 CONFIG_BT_DEBUG_LOG=y CONFIG_BT_MESH_IV_UPDATE_TEST=y -CONFIG_BT_MESH_DEBUG=y +CONFIG_BT_MESH_LOG_LEVEL_DBG=y diff --git a/tests/bluetooth/shell/audio.conf b/tests/bluetooth/shell/audio.conf index 762f7462556..8ca4276a654 100644 --- a/tests/bluetooth/shell/audio.conf +++ b/tests/bluetooth/shell/audio.conf @@ -138,28 +138,28 @@ CONFIG_BT_CAP_INITIATOR=y # DEBUGGING CONFIG_BT_DEBUG_LOG=y -CONFIG_BT_DEBUG_MPL=y -CONFIG_BT_DEBUG_MCS=y -CONFIG_BT_DEBUG_MCC=y +CONFIG_BT_MPL_LOG_LEVEL_DBG=y +CONFIG_BT_MCS_LOG_LEVEL_DBG=y +CONFIG_BT_MCC_LOG_LEVEL_DBG=y CONFIG_BT_OTS_LOG_LEVEL_DBG=y -CONFIG_BT_DEBUG_OTS_CLIENT=y -CONFIG_MCTL_DEBUG=y -CONFIG_BT_DEBUG_ASCS=y -CONFIG_BT_DEBUG_PACS=y -CONFIG_BT_AUDIO_DEBUG_UNICAST_SERVER=y -CONFIG_BT_AUDIO_DEBUG_UNICAST_CLIENT=y -CONFIG_BT_AUDIO_DEBUG_BROADCAST_SOURCE=y -CONFIG_BT_AUDIO_DEBUG_BROADCAST_SINK=y -CONFIG_BT_DEBUG_HAS=y -CONFIG_BT_DEBUG_HAS_CLIENT=y -CONFIG_BT_DEBUG_TBS=y -CONFIG_BT_DEBUG_VCS_CLIENT=y -CONFIG_BT_DEBUG_VCS=y -CONFIG_BT_DEBUG_MICP_MIC_CTLR=y -CONFIG_BT_DEBUG_MICP_MIC_DEV=y -CONFIG_BT_DEBUG_AICS_CLIENT=y -CONFIG_BT_DEBUG_VOCS_CLIENT=y -CONFIG_BT_DEBUG_AICS=y -CONFIG_BT_DEBUG_VOCS=y -CONFIG_BT_AUDIO_DEBUG_STREAM=y -CONFIG_BT_DEBUG_CSIP_SET_COORDINATOR=y +CONFIG_BT_OTS_CLIENT_LOG_LEVEL_DBG=y +CONFIG_MCTL_LOG_LEVEL_DBG=y +CONFIG_BT_ASCS_LOG_LEVEL_DBG=y +CONFIG_BT_PACS_LOG_LEVEL_DBG=y +CONFIG_BT_AUDIO_UNICAST_SERVER_LOG_LEVEL_DBG=y +CONFIG_BT_AUDIO_UNICAST_CLIENT_LOG_LEVEL_DBG=y +CONFIG_BT_AUDIO_BROADCAST_SOURCE_LOG_LEVEL_DBG=y +CONFIG_BT_AUDIO_BROADCAST_SINK_LOG_LEVEL_DBG=y +CONFIG_BT_HAS_LOG_LEVEL_DBG=y +CONFIG_BT_HAS_CLIENT_LOG_LEVEL_DBG=y +CONFIG_BT_TBS_LOG_LEVEL_DBG=y +CONFIG_BT_VCS_CLIENT_LOG_LEVEL_DBG=y +CONFIG_BT_VCS_LOG_LEVEL_DBG=y +CONFIG_BT_MICP_MIC_CTLR_LOG_LEVEL_DBG=y +CONFIG_BT_MICP_MIC_DEV_LOG_LEVEL_DBG=y +CONFIG_BT_AICS_CLIENT_LOG_LEVEL_DBG=y +CONFIG_BT_VOCS_CLIENT_LOG_LEVEL_DBG=y +CONFIG_BT_AICS_LOG_LEVEL_DBG=y +CONFIG_BT_VOCS_LOG_LEVEL_DBG=y +CONFIG_BT_AUDIO_STREAM_LOG_LEVEL_DBG=y +CONFIG_BT_CSIP_SET_COORDINATOR_LOG_LEVEL_DBG=y diff --git a/tests/bluetooth/shell/log.conf b/tests/bluetooth/shell/log.conf new file mode 100644 index 00000000000..9724a6f9bd3 --- /dev/null +++ b/tests/bluetooth/shell/log.conf @@ -0,0 +1,66 @@ +# Increased stack due to settings API usage +CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048 + +CONFIG_TEST=y +CONFIG_TEST_LOGGING_DEFAULTS=n +CONFIG_BT=y +CONFIG_BT_CENTRAL=y +CONFIG_BT_PERIPHERAL=y +CONFIG_BT_PRIVACY=y +CONFIG_BT_SMP=y +CONFIG_BT_SIGNING=y +CONFIG_BT_FIXED_PASSKEY=y +CONFIG_BT_ATT_PREPARE_COUNT=2 +CONFIG_BT_GATT_CLIENT=y +CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y +CONFIG_BT_TINYCRYPT_ECC=y +CONFIG_BT_SHELL=y +CONFIG_BT_DEVICE_NAME="log test shell" +CONFIG_BT_DEVICE_NAME_DYNAMIC=y +CONFIG_BT_L2CAP_TX_BUF_COUNT=4 +CONFIG_BT_ID_MAX=2 +CONFIG_BT_EATT=y +CONFIG_BT_L2CAP_ECRED=y +CONFIG_BT_GATT_DYNAMIC_DB=y +CONFIG_BT_GATT_NOTIFY_MULTIPLE=y +CONFIG_BT_HRS=y +CONFIG_BT_FILTER_ACCEPT_LIST=y +CONFIG_BT_REMOTE_INFO=y +CONFIG_BT_REMOTE_VERSION=y +CONFIG_BT_GATT_AUTO_DISCOVER_CCC=y + +# Disable BT logging and enable general logging +CONFIG_BT_DEBUG_LOG=n +CONFIG_LOG=y + +CONFIG_BT_SETTINGS=y +CONFIG_FLASH=y +CONFIG_FLASH_PAGE_LAYOUT=y +CONFIG_FLASH_MAP=y +CONFIG_NVS=y +CONFIG_SETTINGS=y + +CONFIG_BT_EXT_ADV=y +CONFIG_BT_EXT_ADV_LEGACY_SUPPORT=y +CONFIG_BT_PER_ADV=y +CONFIG_BT_PER_ADV_SYNC=y + +CONFIG_BT_USER_DATA_LEN_UPDATE=y +CONFIG_BT_AUTO_DATA_LEN_UPDATE=y + +CONFIG_BT_USER_PHY_UPDATE=y +CONFIG_BT_AUTO_PHY_UPDATE=y + +CONFIG_BT_ISO_BROADCASTER=y +CONFIG_BT_ISO_SYNC_RECEIVER=y +CONFIG_BT_ISO_CENTRAL=y +CONFIG_BT_ISO_PERIPHERAL=y + +# Usage: +# `kernel log-level modulename severity` +# e.g., +# +# kernel log-level bt_hci_core 0 +# kernel log-level bt_l2cap 2 +# kernel log-level bt_att 4 +CONFIG_LOG_RUNTIME_FILTERING=y diff --git a/tests/bluetooth/shell/mesh.conf b/tests/bluetooth/shell/mesh.conf index 7b98c380183..c67416775e6 100644 --- a/tests/bluetooth/shell/mesh.conf +++ b/tests/bluetooth/shell/mesh.conf @@ -43,4 +43,4 @@ CONFIG_BT_MESH_MODEL_KEY_COUNT=2 CONFIG_BT_MESH_MODEL_GROUP_COUNT=2 CONFIG_BT_MESH_IV_UPDATE_TEST=y -CONFIG_BT_MESH_DEBUG=y +CONFIG_BT_MESH_LOG_LEVEL_DBG=y diff --git a/tests/bluetooth/shell/testcase.yaml b/tests/bluetooth/shell/testcase.yaml index 7550bc0626f..771f29bb693 100644 --- a/tests/bluetooth/shell/testcase.yaml +++ b/tests/bluetooth/shell/testcase.yaml @@ -29,6 +29,11 @@ tests: extra_args: CONFIG_BT_PRIVACY=n platform_allow: native_posix tags: bluetooth + bluetooth.shell.log_defaults: + build_only: true + platform_allow: native_posix + extra_args: CONF_FILE="log.conf" + tags: bluetooth # Bluetooth Audio Compile validation tests bluetooth.shell.audio: diff --git a/tests/bluetooth/tester/boards/qemu_cortex_m3.conf b/tests/bluetooth/tester/boards/qemu_cortex_m3.conf index c361f198cb1..c44cb743444 100644 --- a/tests/bluetooth/tester/boards/qemu_cortex_m3.conf +++ b/tests/bluetooth/tester/boards/qemu_cortex_m3.conf @@ -1,9 +1,9 @@ CONFIG_INIT_STACKS=y CONFIG_PRINTK=y CONFIG_BT_DEBUG_LOG=y -CONFIG_BT_DEBUG_HCI_CORE=y -CONFIG_BT_DEBUG_CONN=y -CONFIG_BT_DEBUG_L2CAP=y -CONFIG_BT_DEBUG_SMP=y -CONFIG_BT_DEBUG_ATT=y -CONFIG_BT_DEBUG_GATT=y +CONFIG_BT_HCI_CORE_LOG_LEVEL_DBG=y +CONFIG_BT_CONN_LOG_LEVEL_DBG=y +CONFIG_BT_L2CAP_LOG_LEVEL_DBG=y +CONFIG_BT_SMP_LOG_LEVEL_DBG=y +CONFIG_BT_ATT_LOG_LEVEL_DBG=y +CONFIG_BT_GATT_LOG_LEVEL_DBG=y