samples: hci_spi: Convert from SYS_LOG to new logger
Use the LOG_* macros instead of the deprecated SYS_LOG_* ones.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
diff --git a/samples/bluetooth/hci_spi/CMakeLists.txt b/samples/bluetooth/hci_spi/CMakeLists.txt
index 05febef..cb9d7e0 100644
--- a/samples/bluetooth/hci_spi/CMakeLists.txt
+++ b/samples/bluetooth/hci_spi/CMakeLists.txt
@@ -6,4 +6,3 @@
target_sources(app PRIVATE ${app_sources})
zephyr_library_include_directories($ENV{ZEPHYR_BASE}/samples/bluetooth)
-zephyr_library_include_directories($ENV{ZEPHYR_BASE}/subsys/bluetooth)
diff --git a/samples/bluetooth/hci_spi/prj.conf b/samples/bluetooth/hci_spi/prj.conf
index 92c24ba..dceaf30 100644
--- a/samples/bluetooth/hci_spi/prj.conf
+++ b/samples/bluetooth/hci_spi/prj.conf
@@ -7,7 +7,3 @@
CONFIG_BT_TINYCRYPT_ECC=n
CONFIG_BT_RX_BUF_COUNT=10
CONFIG_BT_RX_BUF_LEN=255
-
-# Debug; enable if needed.
-# CONFIG_SYS_LOG=y
-# CONFIG_SYS_LOG_DEFAULT_LEVEL=2
diff --git a/samples/bluetooth/hci_spi/src/main.c b/samples/bluetooth/hci_spi/src/main.c
index 2babfe6..34b5874 100644
--- a/samples/bluetooth/hci_spi/src/main.c
+++ b/samples/bluetooth/hci_spi/src/main.c
@@ -12,7 +12,7 @@
#include <zephyr.h>
#include <misc/byteorder.h>
-#include <logging/sys_log.h>
+#include <logging/log.h>
#include <misc/stack.h>
#include <device.h>
@@ -28,7 +28,7 @@
#include <bluetooth/hci_raw.h>
#define LOG_MODULE_NAME hci_spi
-#include "common/log.h"
+LOG_MODULE_REGISTER(LOG_MODULE_NAME);
#define HCI_CMD 0x01
#define HCI_ACL 0x02
@@ -113,8 +113,7 @@
txmsg[1] = SANITY_CHECK;
txmsg[2] = 0x00;
- SYS_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);
switch (bt_buf_get_type(buf)) {
case BT_BUF_ACL_IN:
@@ -124,13 +123,13 @@
net_buf_push_u8(buf, HCI_EVT);
break;
default:
- SYS_LOG_ERR("Unknown type %u", bt_buf_get_type(buf));
+ LOG_ERR("Unknown type %u", bt_buf_get_type(buf));
net_buf_unref(buf);
return -EINVAL;
}
if (buf->len > SPI_MAX_MSG_LEN) {
- SYS_LOG_ERR("TX message too long");
+ LOG_ERR("TX message too long");
net_buf_unref(buf);
return -EINVAL;
}
@@ -150,7 +149,7 @@
do {
ret = spi_transceive(spi_hci_dev, &spi_cfg, &tx_bufs, &rx_bufs);
if (ret < 0) {
- SYS_LOG_ERR("SPI transceive error: %d", ret);
+ LOG_ERR("SPI transceive error: %d", ret);
}
} while (rxmsg[STATUS_HEADER_READY] != SPI_READ);
@@ -159,7 +158,7 @@
ret = spi_write(spi_hci_dev, &spi_cfg, &tx_bufs);
if (ret < 0) {
- SYS_LOG_ERR("SPI transceive error: %d", ret);
+ LOG_ERR("SPI transceive error: %d", ret);
}
net_buf_unref(buf);
@@ -195,7 +194,7 @@
ret = spi_transceive(spi_hci_dev, &spi_cfg,
&tx_bufs, &rx_bufs);
if (ret < 0) {
- SYS_LOG_ERR("SPI transceive error: %d", ret);
+ LOG_ERR("SPI transceive error: %d", ret);
}
} while ((header_master[STATUS_HEADER_READY] != SPI_READ) &&
(header_master[STATUS_HEADER_READY] != SPI_WRITE));
@@ -216,7 +215,7 @@
ret = spi_transceive(spi_hci_dev, &spi_cfg,
&tx_bufs, &rx_bufs);
if (ret < 0) {
- SYS_LOG_ERR("SPI transceive error: %d", ret);
+ LOG_ERR("SPI transceive error: %d", ret);
continue;
}
@@ -232,7 +231,7 @@
net_buf_add_mem(buf, &rxmsg[4],
cmd_hdr.param_len);
} else {
- SYS_LOG_ERR("No available command buffers!");
+ LOG_ERR("No available command buffers!");
continue;
}
break;
@@ -247,21 +246,21 @@
net_buf_add_mem(buf, &rxmsg[5],
sys_le16_to_cpu(acl_hdr.len));
} else {
- SYS_LOG_ERR("No available ACL buffers!");
+ LOG_ERR("No available ACL buffers!");
continue;
}
break;
default:
- SYS_LOG_ERR("Unknown BT HCI buf type");
+ LOG_ERR("Unknown BT HCI buf type");
continue;
}
- SYS_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);
ret = bt_send(buf);
if (ret) {
- SYS_LOG_ERR("Unable to send (ret %d)", ret);
+ LOG_ERR("Unable to send (ret %d)", ret);
net_buf_unref(buf);
}
@@ -276,7 +275,7 @@
{
ARG_UNUSED(unused);
- SYS_LOG_DBG("");
+ LOG_DBG("");
spi_hci_dev = device_get_binding(SPI_HCI_DEV_NAME);
if (!spi_hci_dev) {
@@ -304,11 +303,11 @@
k_tid_t tx_id;
int err;
- SYS_LOG_DBG("Start");
+ LOG_DBG("Start");
err = bt_enable_raw(&rx_queue);
if (err) {
- SYS_LOG_ERR("bt_enable_raw: %d; aborting", err);
+ LOG_ERR("bt_enable_raw: %d; aborting", err);
return;
}
@@ -327,7 +326,7 @@
net_buf_add_le16(buf, EVT_BLUE_INITIALIZED);
err = spi_send(buf);
if (err) {
- SYS_LOG_ERR("can't send initialization event; aborting");
+ LOG_ERR("can't send initialization event; aborting");
k_thread_abort(tx_id);
return;
}
@@ -336,7 +335,7 @@
buf = net_buf_get(&rx_queue, K_FOREVER);
err = spi_send(buf);
if (err) {
- SYS_LOG_ERR("Failed to send");
+ LOG_ERR("Failed to send");
}
}
}