From 68e72f9275401c3cb7541259c692a704cbfc5e82 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Wed, 9 Sep 2020 23:57:44 -0400 Subject: fix: Switch to single AUTHORS file.* Closes #164 --- app/src/split/bluetooth/service.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'app/src/split/bluetooth/service.c') diff --git a/app/src/split/bluetooth/service.c b/app/src/split/bluetooth/service.c index e1d232a..0a5ddb7 100644 --- a/app/src/split/bluetooth/service.c +++ b/app/src/split/bluetooth/service.c @@ -1,3 +1,8 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ #include #include -- cgit v1.2.3 From 39f980a06dac1769e4f09abaf19d3ccbb4b34e67 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Tue, 8 Sep 2020 23:26:00 -0400 Subject: feat(bluetooth): Add back profiles, split fixes. * Add back in profiles, not using Zephyr BT identity infrastructure. * Restore additional `&bt` commands for profile operations. * Fix for split pairing and subscriptions, since Zephyr persists subscriptions across connects. * Remove keymap from peripheral builds, reduces firmware size, and avoids unneeded attempts to send HID data. --- app/src/split/bluetooth/service.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'app/src/split/bluetooth/service.c') diff --git a/app/src/split/bluetooth/service.c b/app/src/split/bluetooth/service.c index 0a5ddb7..c2f65d2 100644 --- a/app/src/split/bluetooth/service.c +++ b/app/src/split/bluetooth/service.c @@ -6,6 +6,11 @@ #include #include + +#include + +LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); + #include #include @@ -28,6 +33,7 @@ static ssize_t split_svc_num_of_positions(struct bt_conn *conn, const struct bt_ static void split_svc_pos_state_ccc(const struct bt_gatt_attr *attr, u16_t value) { + LOG_DBG("value %d", value); } -- cgit v1.2.3 From 191a2d755ad4761bd04a30a113e05119ad7aa61e Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Sun, 13 Sep 2020 22:53:24 -0400 Subject: chore: clang-format the codebase. * Use the LLVM style * Override indent width (8) and column limit (100) * Fixes #142. --- app/src/split/bluetooth/service.c | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) (limited to 'app/src/split/bluetooth/service.c') diff --git a/app/src/split/bluetooth/service.c b/app/src/split/bluetooth/service.c index c2f65d2..86af685 100644 --- a/app/src/split/bluetooth/service.c +++ b/app/src/split/bluetooth/service.c @@ -21,41 +21,36 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); static u8_t num_of_positions = ZMK_KEYMAP_LEN; static u8_t position_state[16]; -static ssize_t split_svc_pos_state(struct bt_conn *conn, const struct bt_gatt_attr *attrs, void *buf, u16_t len, u16_t offset) -{ - return bt_gatt_attr_read(conn, attrs, buf, len, offset, &position_state, sizeof(position_state)); +static ssize_t split_svc_pos_state(struct bt_conn *conn, const struct bt_gatt_attr *attrs, + void *buf, u16_t len, u16_t offset) { + return bt_gatt_attr_read(conn, attrs, buf, len, offset, &position_state, + sizeof(position_state)); } -static ssize_t split_svc_num_of_positions(struct bt_conn *conn, const struct bt_gatt_attr *attrs, void *buf, u16_t len, u16_t offset) -{ +static ssize_t split_svc_num_of_positions(struct bt_conn *conn, const struct bt_gatt_attr *attrs, + void *buf, u16_t len, u16_t offset) { return bt_gatt_attr_read(conn, attrs, buf, len, offset, attrs->user_data, sizeof(u8_t)); } -static void split_svc_pos_state_ccc(const struct bt_gatt_attr *attr, u16_t value) -{ +static void split_svc_pos_state_ccc(const struct bt_gatt_attr *attr, u16_t value) { LOG_DBG("value %d", value); } +BT_GATT_SERVICE_DEFINE( + split_svc, BT_GATT_PRIMARY_SERVICE(BT_UUID_DECLARE_128(ZMK_SPLIT_BT_SERVICE_UUID)), + BT_GATT_CHARACTERISTIC(BT_UUID_DECLARE_128(ZMK_SPLIT_BT_CHAR_POSITION_STATE_UUID), + BT_GATT_CHRC_READ | BT_GATT_CHRC_NOTIFY, BT_GATT_PERM_READ_ENCRYPT, + split_svc_pos_state, NULL, &position_state), + BT_GATT_CCC(split_svc_pos_state_ccc, BT_GATT_PERM_READ_ENCRYPT | BT_GATT_PERM_WRITE_ENCRYPT), + BT_GATT_DESCRIPTOR(BT_UUID_NUM_OF_DIGITALS, BT_GATT_PERM_READ, split_svc_num_of_positions, NULL, + &num_of_positions), ); -BT_GATT_SERVICE_DEFINE(split_svc, - BT_GATT_PRIMARY_SERVICE(BT_UUID_DECLARE_128(ZMK_SPLIT_BT_SERVICE_UUID)), - BT_GATT_CHARACTERISTIC(BT_UUID_DECLARE_128(ZMK_SPLIT_BT_CHAR_POSITION_STATE_UUID), BT_GATT_CHRC_READ | BT_GATT_CHRC_NOTIFY, - BT_GATT_PERM_READ_ENCRYPT, - split_svc_pos_state, NULL, &position_state), - BT_GATT_CCC(split_svc_pos_state_ccc, - BT_GATT_PERM_READ_ENCRYPT | BT_GATT_PERM_WRITE_ENCRYPT), - BT_GATT_DESCRIPTOR(BT_UUID_NUM_OF_DIGITALS, BT_GATT_PERM_READ, - split_svc_num_of_positions, NULL, &num_of_positions), -); - -int zmk_split_bt_position_pressed(u8_t position) -{ +int zmk_split_bt_position_pressed(u8_t position) { WRITE_BIT(position_state[position / 8], position % 8, true); return bt_gatt_notify(NULL, &split_svc.attrs[1], &position_state, sizeof(position_state)); } -int zmk_split_bt_position_released(u8_t position) -{ +int zmk_split_bt_position_released(u8_t position) { WRITE_BIT(position_state[position / 8], position % 8, false); return bt_gatt_notify(NULL, &split_svc.attrs[1], &position_state, sizeof(position_state)); } \ No newline at end of file -- cgit v1.2.3