From cf6f87f25b239c1d6562faf7ca6a8d24fb5320ea Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Sat, 22 Sep 2018 08:53:49 +0300 Subject: [PATCH] Bluetooth: samples/peripheral_sc_only: Improve logging The periphreal_sc_only sample app wasn't very clearly logging information about pairing failures and could give the false impression that everything work when it doesn't. Enable some more logging Kconfig features and take advantage of the pairing complete & failed callbacks to give more information to the user. Signed-off-by: Johan Hedberg --- samples/bluetooth/peripheral_sc_only/prj.conf | 5 +++++ samples/bluetooth/peripheral_sc_only/src/main.c | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/samples/bluetooth/peripheral_sc_only/prj.conf b/samples/bluetooth/peripheral_sc_only/prj.conf index 4521db7d2ff..166454b23f2 100644 --- a/samples/bluetooth/peripheral_sc_only/prj.conf +++ b/samples/bluetooth/peripheral_sc_only/prj.conf @@ -1,4 +1,9 @@ +# Uncomment the following two options to get thread stack usage logs +#CONFIG_INIT_STACKS=y +#CONFIG_THREAD_STACK_INFO=y + CONFIG_BT=y +CONFIG_BT_DEBUG_LOG=y CONFIG_BT_PERIPHERAL=y CONFIG_BT_SMP=y CONFIG_BT_SMP_SC_ONLY=y diff --git a/samples/bluetooth/peripheral_sc_only/src/main.c b/samples/bluetooth/peripheral_sc_only/src/main.c index 177b9a18408..9c817b2cbdc 100644 --- a/samples/bluetooth/peripheral_sc_only/src/main.c +++ b/samples/bluetooth/peripheral_sc_only/src/main.c @@ -97,10 +97,23 @@ static void auth_cancel(struct bt_conn *conn) printk("Pairing cancelled: %s\n", addr); } +static void pairing_complete(struct bt_conn *conn, bool bonded) +{ + printk("Pairing Complete\n"); +} + +static void pairing_failed(struct bt_conn *conn) +{ + printk("Pairing Failed. Disconnecting.\n"); + bt_conn_disconnect(conn, BT_HCI_ERR_AUTHENTICATION_FAIL); +} + static struct bt_conn_auth_cb auth_cb_display = { .passkey_display = auth_passkey_display, .passkey_entry = NULL, .cancel = auth_cancel, + .pairing_complete = pairing_complete, + .pairing_failed = pairing_failed, }; void main(void)