From 3796f76c56d42ca9b4fd36edae7f6bf6656009b9 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Mon, 29 Jun 2020 00:37:11 -0400 Subject: Initial exploration of split BLE service. * Service for split peripheral to report position state to split central. * Updated advertising info. * Behavior for split BT until we have a proper event system. --- app/src/ble.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'app/src/ble.c') diff --git a/app/src/ble.c b/app/src/ble.c index c0e81a9..94a23da 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -12,6 +12,7 @@ #include #include +#include static struct bt_conn *auth_passkey_entry_conn; static u8_t passkey_entries[6] = {0, 0, 0, 0, 0, 0}; @@ -121,9 +122,13 @@ static struct bt_conn_auth_cb zmk_ble_auth_cb_display = { static const struct bt_data zmk_ble_ad[] = { BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)), - BT_DATA_BYTES(BT_DATA_UUID16_ALL, + BT_DATA_BYTES(BT_DATA_UUID16_SOME, 0x12, 0x18, /* HID Service */ 0x0f, 0x18), /* Battery Service */ +#if IS_ENABLED(CONFIG_ZMK_SPLIT_BLE) + BT_DATA_BYTES(BT_DATA_UUID128_SOME, + ZMK_SPLIT_BT_SERVICE_UUID) +#endif }; static void zmk_ble_ready(int err) -- cgit v1.2.3 From a165db63586f37531d5050623bc5a7bc96793d49 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Wed, 1 Jul 2020 22:27:01 -0400 Subject: Initial work on split central support. --- app/src/ble.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/src/ble.c') diff --git a/app/src/ble.c b/app/src/ble.c index 94a23da..8b43cdd 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -12,7 +12,7 @@ #include #include -#include +#include static struct bt_conn *auth_passkey_entry_conn; static u8_t passkey_entries[6] = {0, 0, 0, 0, 0, 0}; -- cgit v1.2.3 From be537d06565a38f5fcca8d5a1d0a7b7350b35d51 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Thu, 2 Jul 2020 23:34:11 -0400 Subject: Lots of work on split peripheral/central logic. --- app/src/ble.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'app/src/ble.c') diff --git a/app/src/ble.c b/app/src/ble.c index 8b43cdd..3cbb14d 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -11,6 +11,11 @@ #include #include + +#include + +LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); + #include #include @@ -126,13 +131,14 @@ static const struct bt_data zmk_ble_ad[] = { 0x12, 0x18, /* HID Service */ 0x0f, 0x18), /* Battery Service */ #if IS_ENABLED(CONFIG_ZMK_SPLIT_BLE) - BT_DATA_BYTES(BT_DATA_UUID128_SOME, + BT_DATA_BYTES(BT_DATA_UUID128_ALL, ZMK_SPLIT_BT_SERVICE_UUID) #endif }; static void zmk_ble_ready(int err) { + LOG_DBG("ready? %d", err); if (err) { printk("Bluetooth init failed (err %d)\n", err); @@ -153,7 +159,7 @@ static int zmk_ble_init(struct device *_arg) { settings_load(); } - int err = bt_enable(zmk_ble_ready); + int err = bt_enable(NULL); if (err) { @@ -164,6 +170,8 @@ static int zmk_ble_init(struct device *_arg) bt_conn_cb_register(&conn_callbacks); bt_conn_auth_cb_register(&zmk_ble_auth_cb_display); + zmk_ble_ready(0); + return 0; } -- cgit v1.2.3 From 6701b7babc68cb8090a9d16105bd3876025aa0e8 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Thu, 16 Jul 2020 15:50:41 -0400 Subject: Working BT settings. --- app/src/ble.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'app/src/ble.c') diff --git a/app/src/ble.c b/app/src/ble.c index 3cbb14d..809575d 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -128,8 +128,11 @@ static struct bt_conn_auth_cb zmk_ble_auth_cb_display = { static const struct bt_data zmk_ble_ad[] = { BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)), BT_DATA_BYTES(BT_DATA_UUID16_SOME, +#if !IS_ENABLED(CONFIG_ZMK_SPLIT_BLE) 0x12, 0x18, /* HID Service */ - 0x0f, 0x18), /* Battery Service */ +#endif + 0x0f, 0x18 /* Battery Service */ + ), #if IS_ENABLED(CONFIG_ZMK_SPLIT_BLE) BT_DATA_BYTES(BT_DATA_UUID128_ALL, ZMK_SPLIT_BT_SERVICE_UUID) @@ -155,10 +158,6 @@ static void zmk_ble_ready(int err) static int zmk_ble_init(struct device *_arg) { - if (IS_ENABLED(CONFIG_SETTINGS)) - { - settings_load(); - } int err = bt_enable(NULL); if (err) @@ -167,6 +166,11 @@ static int zmk_ble_init(struct device *_arg) return err; } + if (IS_ENABLED(CONFIG_BT_SETTINGS)) + { + settings_load(); + } + bt_conn_cb_register(&conn_callbacks); bt_conn_auth_cb_register(&zmk_ble_auth_cb_display); -- cgit v1.2.3 From fd407c4876ddb3af8f0490051cd81620c545ebad Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Sun, 19 Jul 2020 22:40:49 -0400 Subject: Update connectin params once we're connected to. --- app/src/ble.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app/src/ble.c') diff --git a/app/src/ble.c b/app/src/ble.c index 809575d..af3c25d 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -37,6 +37,8 @@ static void connected(struct bt_conn *conn, u8_t err) printk("Connected %s\n", addr); + bt_conn_le_param_update(conn, BT_LE_CONN_PARAM(0x0006, 0x000c, 5, 400)); + if (bt_conn_set_security(conn, BT_SECURITY_L2)) { printk("Failed to set security\n"); -- cgit v1.2.3