From 8dddb1d9d77d1727a6e2116d12fe5f8de98d0aba Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Mon, 13 Jan 2025 13:15:16 -0700 Subject: [PATCH] Testing: split input test (#2762) test(pointing): Add mock input device. New mock input device to generate input events for tests. test(split): Add peripheral input test. Test event propagation from peripheral input devices. fix(split): Proper scoping for local within switch. Minor compile fix. chore: Fix up test snapshots after logging changes. Adjust the test snapshots after logging changes to the central. fix(kscan): Don't fire last mock event twice. Fix a bug where the kscan mock would raise the last mock event twice before halting processing. --- app/module/drivers/CMakeLists.txt | 1 + app/module/drivers/Kconfig | 1 + app/module/drivers/input/CMakeLists.txt | 6 ++ app/module/drivers/input/Kconfig | 9 ++ app/module/drivers/input/input_mock.c | 87 +++++++++++++++++++ app/module/drivers/kscan/kscan_mock.c | 6 ++ .../dts/bindings/input/zmk,input-mock.yaml | 21 +++++ app/src/split/bluetooth/central.c | 3 +- app/tests/ble/central/src/main.c | 73 ++++++++++++++-- .../snapshot.log | 5 +- .../bond-to-cleared-profile/snapshot.log | 5 +- .../snapshot.log | 5 +- .../snapshot.log | 8 +- .../snapshot.log | 5 +- .../snapshot.log | 5 +- app/tests/ble/split/basic/snapshot.log | 3 + .../split/multiple-peripherals/snapshot.log | 3 + .../ble/split/peripheral-encoder/snapshot.log | 3 + .../split/peripheral-input/events.patterns | 1 + .../split/peripheral-input/nrf52_bsim.conf | 2 + .../split/peripheral-input/nrf52_bsim.keymap | 27 ++++++ .../split/peripheral-input/peripheral.overlay | 31 +++++++ .../ble/split/peripheral-input/shared.dtsi | 16 ++++ .../ble/split/peripheral-input/siblings.txt | 2 + .../ble/split/peripheral-input/snapshot.log | 25 ++++++ 25 files changed, 332 insertions(+), 21 deletions(-) create mode 100644 app/module/drivers/input/CMakeLists.txt create mode 100644 app/module/drivers/input/Kconfig create mode 100644 app/module/drivers/input/input_mock.c create mode 100644 app/module/dts/bindings/input/zmk,input-mock.yaml create mode 100644 app/tests/ble/split/peripheral-input/events.patterns create mode 100644 app/tests/ble/split/peripheral-input/nrf52_bsim.conf create mode 100644 app/tests/ble/split/peripheral-input/nrf52_bsim.keymap create mode 100644 app/tests/ble/split/peripheral-input/peripheral.overlay create mode 100644 app/tests/ble/split/peripheral-input/shared.dtsi create mode 100644 app/tests/ble/split/peripheral-input/siblings.txt create mode 100644 app/tests/ble/split/peripheral-input/snapshot.log diff --git a/app/module/drivers/CMakeLists.txt b/app/module/drivers/CMakeLists.txt index 5281c3dcb..a3a15c651 100644 --- a/app/module/drivers/CMakeLists.txt +++ b/app/module/drivers/CMakeLists.txt @@ -5,3 +5,4 @@ add_subdirectory_ifdef(CONFIG_GPIO gpio) add_subdirectory_ifdef(CONFIG_KSCAN kscan) add_subdirectory_ifdef(CONFIG_SENSOR sensor) add_subdirectory_ifdef(CONFIG_DISPLAY display) +add_subdirectory_ifdef(CONFIG_INPUT input) diff --git a/app/module/drivers/Kconfig b/app/module/drivers/Kconfig index c57ed3347..db3f49a55 100644 --- a/app/module/drivers/Kconfig +++ b/app/module/drivers/Kconfig @@ -5,3 +5,4 @@ rsource "gpio/Kconfig" rsource "kscan/Kconfig" rsource "sensor/Kconfig" rsource "display/Kconfig" +rsource "input/Kconfig" diff --git a/app/module/drivers/input/CMakeLists.txt b/app/module/drivers/input/CMakeLists.txt new file mode 100644 index 000000000..f8f5b2319 --- /dev/null +++ b/app/module/drivers/input/CMakeLists.txt @@ -0,0 +1,6 @@ +# Copyright (c) 2020-2023 The ZMK Contributors +# SPDX-License-Identifier: MIT + +zephyr_library_amend() + +zephyr_library_sources_ifdef(CONFIG_ZMK_INPUT_MOCK input_mock.c) diff --git a/app/module/drivers/input/Kconfig b/app/module/drivers/input/Kconfig new file mode 100644 index 000000000..248805d14 --- /dev/null +++ b/app/module/drivers/input/Kconfig @@ -0,0 +1,9 @@ + +if INPUT + +config ZMK_INPUT_MOCK + bool "Input Mock" + default y + depends on DT_HAS_ZMK_INPUT_MOCK_ENABLED + +endif \ No newline at end of file diff --git a/app/module/drivers/input/input_mock.c b/app/module/drivers/input/input_mock.c new file mode 100644 index 000000000..6bcab5f8f --- /dev/null +++ b/app/module/drivers/input/input_mock.c @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2024 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#define DT_DRV_COMPAT zmk_input_mock + +#include +#include +#include +#include +#include + +LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); + +struct input_mock_config { + uint16_t startup_delay; + uint16_t event_period; + bool exit_after; + const uint32_t *events; + size_t events_len; +}; + +struct input_mock_data { + size_t event_index; + struct k_work_delayable work; + const struct device *dev; +}; + +static void input_mock_work_cb(struct k_work *work) { + struct k_work_delayable *dwork = CONTAINER_OF(work, struct k_work_delayable, work); + struct input_mock_data *data = CONTAINER_OF(dwork, struct input_mock_data, work); + + const struct device *dev = data->dev; + + const struct input_mock_config *cfg = dev->config; + + data->event_index++; + + size_t base_idx = data->event_index * 4; + + if (base_idx >= cfg->events_len) { + if (cfg->exit_after) { + exit(0); + } else { + return; + } + } + + input_report(dev, cfg->events[base_idx], cfg->events[base_idx + 1], cfg->events[base_idx + 2], + cfg->events[base_idx + 3], K_NO_WAIT); + + k_work_schedule(&data->work, K_MSEC(cfg->event_period)); +} + +int input_mock_init(const struct device *dev) { + struct input_mock_data *drv_data = dev->data; + const struct input_mock_config *drv_cfg = dev->config; + + drv_data->dev = dev; + drv_data->event_index = -1; + + k_work_init_delayable(&drv_data->work, input_mock_work_cb); + + k_work_schedule(&drv_data->work, K_MSEC(drv_cfg->startup_delay)); + + return 0; +} + +#define GET_EVENT(n, inst) \ + {} + +#define INPUT_MOCK_INST(n) \ + struct input_mock_data input_mock_data_##n = {}; \ + const uint32_t mock_data_##n[] = DT_INST_PROP(n, events); \ + const struct input_mock_config input_mock_cfg_##n = { \ + .events = mock_data_##n, \ + .events_len = DT_INST_PROP_LEN(n, events), \ + .startup_delay = DT_INST_PROP(n, event_startup_delay), \ + .event_period = DT_INST_PROP(n, event_period), \ + .exit_after = DT_INST_PROP(n, exit_after), \ + }; \ + DEVICE_DT_INST_DEFINE(n, input_mock_init, NULL, &input_mock_data_##n, &input_mock_cfg_##n, \ + POST_KERNEL, CONFIG_INPUT_INIT_PRIORITY, NULL); + +DT_INST_FOREACH_STATUS_OKAY(INPUT_MOCK_INST) diff --git a/app/module/drivers/kscan/kscan_mock.c b/app/module/drivers/kscan/kscan_mock.c index 1ffb937e8..f4c9dceda 100644 --- a/app/module/drivers/kscan/kscan_mock.c +++ b/app/module/drivers/kscan/kscan_mock.c @@ -65,6 +65,12 @@ static int kscan_mock_configure(const struct device *dev, kscan_callback_t callb struct k_work_delayable *d_work = k_work_delayable_from_work(work); \ struct kscan_mock_data *data = CONTAINER_OF(d_work, struct kscan_mock_data, work); \ const struct kscan_mock_config_##n *cfg = data->dev->config; \ + if (data->event_index >= DT_INST_PROP_LEN(n, events)) { \ + if (cfg->exit_after) \ + exit(0); \ + else \ + return; \ + } \ uint32_t ev = cfg->events[data->event_index]; \ LOG_DBG("ev %u row %d column %d state %d\n", ev, ZMK_MOCK_ROW(ev), ZMK_MOCK_COL(ev), \ ZMK_MOCK_IS_PRESS(ev)); \ diff --git a/app/module/dts/bindings/input/zmk,input-mock.yaml b/app/module/dts/bindings/input/zmk,input-mock.yaml new file mode 100644 index 000000000..a7efe4254 --- /dev/null +++ b/app/module/dts/bindings/input/zmk,input-mock.yaml @@ -0,0 +1,21 @@ +# Copyright (c) 2024 The ZMK Contributors +# SPDX-License-Identifier: MIT + +description: | + Allows defining a mock input driver that simulates periodic input events. + +compatible: "zmk,input-mock" + +properties: + event-startup-delay: + type: int + default: 0 + description: Milliseconds to delay before starting generating the events + event-period: + type: int + description: Milliseconds between each generated event + events: + type: array + description: List of tuples of (type, code, value, sync) + exit-after: + type: boolean diff --git a/app/src/split/bluetooth/central.c b/app/src/split/bluetooth/central.c index 4c354b36b..dcebfb0cc 100644 --- a/app/src/split/bluetooth/central.c +++ b/app/src/split/bluetooth/central.c @@ -582,7 +582,7 @@ static uint8_t split_central_chrc_discovery_func(struct bt_conn *conn, LOG_DBG("[ATTRIBUTE] handle %u", attr->handle); switch (params->type) { - case BT_GATT_DISCOVER_CHARACTERISTIC: + case BT_GATT_DISCOVER_CHARACTERISTIC: { const struct bt_uuid *chrc_uuid = ((struct bt_gatt_chrc *)attr->user_data)->uuid; if (bt_uuid_cmp(chrc_uuid, BT_UUID_DECLARE_128(ZMK_SPLIT_BT_CHAR_POSITION_STATE_UUID)) == @@ -665,6 +665,7 @@ static uint8_t split_central_chrc_discovery_func(struct bt_conn *conn, #endif /* IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_CENTRAL_BATTERY_LEVEL_FETCHING) */ } break; + } case BT_GATT_DISCOVER_STD_CHAR_DESC: #if IS_ENABLED(CONFIG_ZMK_INPUT_SPLIT) if (bt_uuid_cmp(slot->discover_params.uuid, BT_UUID_GATT_CCC) == 0) { diff --git a/app/tests/ble/central/src/main.c b/app/tests/ble/central/src/main.c index 3c5c08887..f33d50e0e 100644 --- a/app/tests/ble/central/src/main.c +++ b/app/tests/ble/central/src/main.c @@ -45,6 +45,7 @@ static bool skip_set_security_on_connect = false; static bool skip_discovery_on_connect = false; static bool read_directly_on_discovery = false; static bool write_hid_indicators_on_discovery = false; +static bool subscribe_to_pointer_report = false; static int32_t wait_on_start = 0; static void ble_central_native_posix_options(void) { @@ -74,6 +75,11 @@ static void ble_central_native_posix_options(void) { .type = 'b', .dest = (void *)&read_hid_report_on_connect, .descript = "Read the peripheral HID report after connecting"}, + {.is_switch = true, + .option = "subscribe_to_pointer_report", + .type = 'b', + .dest = (void *)&subscribe_to_pointer_report, + .descript = "Subscribe to peripheral mouse HID report after connecting"}, {.is_switch = true, .option = "skip_discovery_on_connect", .type = 'b', @@ -110,6 +116,8 @@ static struct bt_conn *default_conn; static struct bt_uuid_16 uuid = BT_UUID_INIT_16(0); static struct bt_gatt_discover_params discover_params; static struct bt_gatt_subscribe_params subscribe_params; +static struct bt_gatt_subscribe_params consumer_subscribe_params; +static struct bt_gatt_subscribe_params pointer_subscribe_params; static uint8_t notify_func(struct bt_conn *conn, struct bt_gatt_subscribe_params *params, const void *data, uint16_t length) { @@ -167,6 +175,28 @@ static uint8_t discover_func(struct bt_conn *conn, const struct bt_gatt_attr *at discover_params.type = BT_GATT_DISCOVER_DESCRIPTOR; subscribe_params.value_handle = bt_gatt_attr_value_handle(attr); + err = bt_gatt_discover(conn, &discover_params); + if (err) { + LOG_DBG("[Discover failed] (err %d)", err); + } + } else if (!consumer_subscribe_params.value_handle) { + memcpy(&uuid, BT_UUID_GATT_CCC, sizeof(uuid)); + discover_params.uuid = &uuid.uuid; + discover_params.start_handle = attr->handle + 2; + discover_params.type = BT_GATT_DISCOVER_DESCRIPTOR; + consumer_subscribe_params.value_handle = bt_gatt_attr_value_handle(attr); + + err = bt_gatt_discover(conn, &discover_params); + if (err) { + LOG_DBG("[Discover failed] (err %d)", err); + } + } else if (subscribe_to_pointer_report && !pointer_subscribe_params.value_handle) { + memcpy(&uuid, BT_UUID_GATT_CCC, sizeof(uuid)); + discover_params.uuid = &uuid.uuid; + discover_params.start_handle = attr->handle + 2; + discover_params.type = BT_GATT_DISCOVER_DESCRIPTOR; + pointer_subscribe_params.value_handle = bt_gatt_attr_value_handle(attr); + err = bt_gatt_discover(conn, &discover_params); if (err) { LOG_DBG("[Discover failed] (err %d)", err); @@ -182,18 +212,45 @@ static uint8_t discover_func(struct bt_conn *conn, const struct bt_gatt_attr *at return BT_GATT_ITER_CONTINUE; } } else if (discover_params.type == BT_GATT_DISCOVER_DESCRIPTOR) { - subscribe_params.notify = notify_func; - subscribe_params.value = BT_GATT_CCC_NOTIFY; - subscribe_params.ccc_handle = attr->handle; + if (!subscribe_params.ccc_handle) { - err = bt_gatt_subscribe(conn, &subscribe_params); - if (err && err != -EALREADY) { - LOG_DBG("[Subscribe failed] (err %d)", err); + subscribe_params.notify = notify_func; + subscribe_params.value = BT_GATT_CCC_NOTIFY; + subscribe_params.ccc_handle = attr->handle; + + err = bt_gatt_subscribe(conn, &subscribe_params); + if (err && err != -EALREADY) { + LOG_DBG("[Subscribe failed] (err %d)", err); + } else { + LOG_DBG("[SUBSCRIBED]"); + } + } else if (!consumer_subscribe_params.ccc_handle) { + + consumer_subscribe_params.notify = notify_func; + consumer_subscribe_params.value = BT_GATT_CCC_NOTIFY; + consumer_subscribe_params.ccc_handle = attr->handle; + + err = bt_gatt_subscribe(conn, &consumer_subscribe_params); + if (err && err != -EALREADY) { + LOG_DBG("[Subscribe failed] (err %d)", err); + } else { + LOG_DBG("[CONSUMER SUBSCRIBED]"); + } } else { - LOG_DBG("[SUBSCRIBED]"); + pointer_subscribe_params.notify = notify_func; + pointer_subscribe_params.value = BT_GATT_CCC_NOTIFY; + pointer_subscribe_params.ccc_handle = attr->handle; + + err = bt_gatt_subscribe(conn, &pointer_subscribe_params); + if (err && err != -EALREADY) { + LOG_DBG("[Subscribe failed] (err %d)", err); + } else { + LOG_DBG("[MOUSE SUBSCRIBED]"); + } } - find_next_hids_report = write_hid_indicators_on_discovery; + find_next_hids_report = !consumer_subscribe_params.ccc_handle || + write_hid_indicators_on_discovery || subscribe_to_pointer_report; } if (find_next_hids_report) { diff --git a/app/tests/ble/profiles/bond-clear-then-bond-second-client/snapshot.log b/app/tests/ble/profiles/bond-clear-then-bond-second-client/snapshot.log index c7a0884d4..ce5e9e331 100644 --- a/app/tests/ble/profiles/bond-clear-then-bond-second-client/snapshot.log +++ b/app/tests/ble/profiles/bond-clear-then-bond-second-client/snapshot.log @@ -23,9 +23,10 @@ profile 1 ble_central: discover_func: [ATTRIBUTE] handle 23 profile 1 ble_central: discover_func: [ATTRIBUTE] handle 28 profile 1 ble_central: discover_func: [ATTRIBUTE] handle 30 profile 1 ble_central: discover_func: [SUBSCRIBED] +profile 1 ble_central: discover_func: [ATTRIBUTE] handle 32 +profile 1 ble_central: discover_func: [ATTRIBUTE] handle 34 +profile 1 ble_central: discover_func: [CONSUMER SUBSCRIBED] profile 1 ble_central: notify_func: payload profile 1 00 00 04 00 00 00 00 00 |........ profile 1 ble_central: notify_func: payload profile 1 00 00 00 00 00 00 00 00 |........ -profile 1 ble_central: notify_func: payload -profile 1 00 00 00 00 00 00 00 00 |........ diff --git a/app/tests/ble/profiles/bond-to-cleared-profile/snapshot.log b/app/tests/ble/profiles/bond-to-cleared-profile/snapshot.log index c7a0884d4..ce5e9e331 100644 --- a/app/tests/ble/profiles/bond-to-cleared-profile/snapshot.log +++ b/app/tests/ble/profiles/bond-to-cleared-profile/snapshot.log @@ -23,9 +23,10 @@ profile 1 ble_central: discover_func: [ATTRIBUTE] handle 23 profile 1 ble_central: discover_func: [ATTRIBUTE] handle 28 profile 1 ble_central: discover_func: [ATTRIBUTE] handle 30 profile 1 ble_central: discover_func: [SUBSCRIBED] +profile 1 ble_central: discover_func: [ATTRIBUTE] handle 32 +profile 1 ble_central: discover_func: [ATTRIBUTE] handle 34 +profile 1 ble_central: discover_func: [CONSUMER SUBSCRIBED] profile 1 ble_central: notify_func: payload profile 1 00 00 04 00 00 00 00 00 |........ profile 1 ble_central: notify_func: payload profile 1 00 00 00 00 00 00 00 00 |........ -profile 1 ble_central: notify_func: payload -profile 1 00 00 00 00 00 00 00 00 |........ diff --git a/app/tests/ble/profiles/connnect-and-output-to-selection/snapshot.log b/app/tests/ble/profiles/connnect-and-output-to-selection/snapshot.log index 61f3e09e1..2c83ae2e5 100644 --- a/app/tests/ble/profiles/connnect-and-output-to-selection/snapshot.log +++ b/app/tests/ble/profiles/connnect-and-output-to-selection/snapshot.log @@ -13,6 +13,9 @@ ble_central: discover_func: [ATTRIBUTE] handle 28 ble_central: discover_func: [ATTRIBUTE] handle 30 ble_central: discover_func: [SUBSCRIBED] + ble_central: discover_func: [ATTRIBUTE] handle 32 + ble_central: discover_func: [ATTRIBUTE] handle 34 + ble_central: discover_func: [CONSUMER SUBSCRIBED] ble_central: notify_func: payload 00 00 04 00 00 00 00 00 |........ ble_central: notify_func: payload @@ -21,5 +24,3 @@ 00 00 05 00 00 00 00 00 |........ ble_central: notify_func: payload 00 00 00 00 00 00 00 00 |........ - ble_central: notify_func: payload - 00 00 00 00 00 00 00 00 |........ diff --git a/app/tests/ble/profiles/first-and-second-profile-paired-then-send-data/snapshot.log b/app/tests/ble/profiles/first-and-second-profile-paired-then-send-data/snapshot.log index bc345b0bf..4a58305a8 100644 --- a/app/tests/ble/profiles/first-and-second-profile-paired-then-send-data/snapshot.log +++ b/app/tests/ble/profiles/first-and-second-profile-paired-then-send-data/snapshot.log @@ -16,6 +16,9 @@ profile 0 ble_central: discover_func: [ATTRIBUTE] handle 23 profile 0 ble_central: discover_func: [ATTRIBUTE] handle 28 profile 0 ble_central: discover_func: [ATTRIBUTE] handle 30 profile 0 ble_central: discover_func: [SUBSCRIBED] +profile 0 ble_central: discover_func: [ATTRIBUTE] handle 32 +profile 0 ble_central: discover_func: [ATTRIBUTE] handle 34 +profile 0 ble_central: discover_func: [CONSUMER SUBSCRIBED] profile 0 ble_central: notify_func: payload profile 0 00 00 04 00 00 00 00 00 |........ profile 0 ble_central: notify_func: payload @@ -32,9 +35,10 @@ profile 1 ble_central: discover_func: [ATTRIBUTE] handle 23 profile 1 ble_central: discover_func: [ATTRIBUTE] handle 28 profile 1 ble_central: discover_func: [ATTRIBUTE] handle 30 profile 1 ble_central: discover_func: [SUBSCRIBED] +profile 1 ble_central: discover_func: [ATTRIBUTE] handle 32 +profile 1 ble_central: discover_func: [ATTRIBUTE] handle 34 +profile 1 ble_central: discover_func: [CONSUMER SUBSCRIBED] profile 1 ble_central: notify_func: payload profile 1 00 00 05 00 00 00 00 00 |........ profile 1 ble_central: notify_func: payload profile 1 00 00 00 00 00 00 00 00 |........ -profile 1 ble_central: notify_func: payload -profile 1 00 00 00 00 00 00 00 00 |........ diff --git a/app/tests/ble/profiles/overwrite-enabled-reconnect-without-bond-then-output-to-selection/snapshot.log b/app/tests/ble/profiles/overwrite-enabled-reconnect-without-bond-then-output-to-selection/snapshot.log index e54d70923..afa4f676e 100644 --- a/app/tests/ble/profiles/overwrite-enabled-reconnect-without-bond-then-output-to-selection/snapshot.log +++ b/app/tests/ble/profiles/overwrite-enabled-reconnect-without-bond-then-output-to-selection/snapshot.log @@ -22,6 +22,9 @@ ble_central: discover_func: [ATTRIBUTE] handle 28 ble_central: discover_func: [ATTRIBUTE] handle 30 ble_central: discover_func: [SUBSCRIBED] + ble_central: discover_func: [ATTRIBUTE] handle 32 + ble_central: discover_func: [ATTRIBUTE] handle 34 + ble_central: discover_func: [CONSUMER SUBSCRIBED] ble_central: notify_func: payload 00 00 04 00 00 00 00 00 |........ ble_central: notify_func: payload @@ -30,5 +33,3 @@ 00 00 05 00 00 00 00 00 |........ ble_central: notify_func: payload 00 00 00 00 00 00 00 00 |........ - ble_central: notify_func: payload - 00 00 00 00 00 00 00 00 |........ diff --git a/app/tests/ble/profiles/reconnect-then-output-to-selection/snapshot.log b/app/tests/ble/profiles/reconnect-then-output-to-selection/snapshot.log index c6f2d9145..b12db556b 100644 --- a/app/tests/ble/profiles/reconnect-then-output-to-selection/snapshot.log +++ b/app/tests/ble/profiles/reconnect-then-output-to-selection/snapshot.log @@ -21,6 +21,9 @@ ble_central: discover_func: [ATTRIBUTE] handle 28 ble_central: discover_func: [ATTRIBUTE] handle 30 ble_central: discover_func: [SUBSCRIBED] + ble_central: discover_func: [ATTRIBUTE] handle 32 + ble_central: discover_func: [ATTRIBUTE] handle 34 + ble_central: discover_func: [CONSUMER SUBSCRIBED] ble_central: notify_func: payload 00 00 04 00 00 00 00 00 |........ ble_central: notify_func: payload @@ -29,5 +32,3 @@ 00 00 05 00 00 00 00 00 |........ ble_central: notify_func: payload 00 00 00 00 00 00 00 00 |........ - ble_central: notify_func: payload - 00 00 00 00 00 00 00 00 |........ diff --git a/app/tests/ble/split/basic/snapshot.log b/app/tests/ble/split/basic/snapshot.log index c3804f64a..545a0f365 100644 --- a/app/tests/ble/split/basic/snapshot.log +++ b/app/tests/ble/split/basic/snapshot.log @@ -13,6 +13,9 @@ profile 0 ble_central: discover_func: [ATTRIBUTE] handle 23 profile 0 ble_central: discover_func: [ATTRIBUTE] handle 28 profile 0 ble_central: discover_func: [ATTRIBUTE] handle 30 profile 0 ble_central: discover_func: [SUBSCRIBED] +profile 0 ble_central: discover_func: [ATTRIBUTE] handle 32 +profile 0 ble_central: discover_func: [ATTRIBUTE] handle 34 +profile 0 ble_central: discover_func: [CONSUMER SUBSCRIBED] profile 0 ble_central: notify_func: payload profile 0 00 00 04 00 00 00 00 00 |........ profile 0 ble_central: notify_func: payload diff --git a/app/tests/ble/split/multiple-peripherals/snapshot.log b/app/tests/ble/split/multiple-peripherals/snapshot.log index 58de7954e..7c19d59c4 100644 --- a/app/tests/ble/split/multiple-peripherals/snapshot.log +++ b/app/tests/ble/split/multiple-peripherals/snapshot.log @@ -13,6 +13,9 @@ profile 0 ble_central: discover_func: [ATTRIBUTE] handle 23 profile 0 ble_central: discover_func: [ATTRIBUTE] handle 28 profile 0 ble_central: discover_func: [ATTRIBUTE] handle 30 profile 0 ble_central: discover_func: [SUBSCRIBED] +profile 0 ble_central: discover_func: [ATTRIBUTE] handle 32 +profile 0 ble_central: discover_func: [ATTRIBUTE] handle 34 +profile 0 ble_central: discover_func: [CONSUMER SUBSCRIBED] profile 0 ble_central: notify_func: payload profile 0 00 00 05 00 00 00 00 00 |........ profile 0 ble_central: notify_func: payload diff --git a/app/tests/ble/split/peripheral-encoder/snapshot.log b/app/tests/ble/split/peripheral-encoder/snapshot.log index c3804f64a..545a0f365 100644 --- a/app/tests/ble/split/peripheral-encoder/snapshot.log +++ b/app/tests/ble/split/peripheral-encoder/snapshot.log @@ -13,6 +13,9 @@ profile 0 ble_central: discover_func: [ATTRIBUTE] handle 23 profile 0 ble_central: discover_func: [ATTRIBUTE] handle 28 profile 0 ble_central: discover_func: [ATTRIBUTE] handle 30 profile 0 ble_central: discover_func: [SUBSCRIBED] +profile 0 ble_central: discover_func: [ATTRIBUTE] handle 32 +profile 0 ble_central: discover_func: [ATTRIBUTE] handle 34 +profile 0 ble_central: discover_func: [CONSUMER SUBSCRIBED] profile 0 ble_central: notify_func: payload profile 0 00 00 04 00 00 00 00 00 |........ profile 0 ble_central: notify_func: payload diff --git a/app/tests/ble/split/peripheral-input/events.patterns b/app/tests/ble/split/peripheral-input/events.patterns new file mode 100644 index 000000000..f8cf363c2 --- /dev/null +++ b/app/tests/ble/split/peripheral-input/events.patterns @@ -0,0 +1 @@ +s/^d_02: @[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9][0-9][0-9][0-9] .{19}/profile 0 /p diff --git a/app/tests/ble/split/peripheral-input/nrf52_bsim.conf b/app/tests/ble/split/peripheral-input/nrf52_bsim.conf new file mode 100644 index 000000000..08e4ff087 --- /dev/null +++ b/app/tests/ble/split/peripheral-input/nrf52_bsim.conf @@ -0,0 +1,2 @@ +CONFIG_ZMK_SPLIT=y +CONFIG_ZMK_POINTING=y \ No newline at end of file diff --git a/app/tests/ble/split/peripheral-input/nrf52_bsim.keymap b/app/tests/ble/split/peripheral-input/nrf52_bsim.keymap new file mode 100644 index 000000000..d1a0f3eac --- /dev/null +++ b/app/tests/ble/split/peripheral-input/nrf52_bsim.keymap @@ -0,0 +1,27 @@ +#include +#include +#include + +#include "shared.dtsi" + +&kscan { + /delete-property/ exit-after; + events = <>; +}; + +&split_listener { + status = "okay"; +}; +/ { + keymap { + compatible = "zmk,keymap"; + + default_layer { + bindings = < + &kp A &kp B + &bt BT_SEL 0 &bt BT_CLR>; + + sensor-bindings = <&inc_dec_kp A B>; + }; + }; +}; diff --git a/app/tests/ble/split/peripheral-input/peripheral.overlay b/app/tests/ble/split/peripheral-input/peripheral.overlay new file mode 100644 index 000000000..3c571a4fc --- /dev/null +++ b/app/tests/ble/split/peripheral-input/peripheral.overlay @@ -0,0 +1,31 @@ + +#include +#include + +#include "shared.dtsi" + +&kscan { + events = <>; + + /delete-property/ exit-after; +}; + +/ { + mock_input: mock_input { + compatible = "zmk,input-mock"; + status = "okay"; + event-startup-delay = <4000>; + event-period = <2000>; + events + = + , + , + , + ; + exit-after; + }; +}; + +&split_input { + device = <&mock_input>; +}; diff --git a/app/tests/ble/split/peripheral-input/shared.dtsi b/app/tests/ble/split/peripheral-input/shared.dtsi new file mode 100644 index 000000000..3a31a28f6 --- /dev/null +++ b/app/tests/ble/split/peripheral-input/shared.dtsi @@ -0,0 +1,16 @@ +/ { + splits { + #address-cells = <1>; + #size-cells = <0>; + split_input: split_input@0 { + compatible = "zmk,input-split"; + reg = <0>; + }; + }; + + split_listener: split_listener { + compatible = "zmk,input-listener"; + status = "disabled"; + device = <&split_input>; + }; +}; \ No newline at end of file diff --git a/app/tests/ble/split/peripheral-input/siblings.txt b/app/tests/ble/split/peripheral-input/siblings.txt new file mode 100644 index 000000000..16ee60971 --- /dev/null +++ b/app/tests/ble/split/peripheral-input/siblings.txt @@ -0,0 +1,2 @@ +./ble_test_central.exe -d=2 -subscribe_to_pointer_report +./tests_ble_split_peripheral-input_peripheral.exe -d=3 diff --git a/app/tests/ble/split/peripheral-input/snapshot.log b/app/tests/ble/split/peripheral-input/snapshot.log new file mode 100644 index 000000000..eaf0675de --- /dev/null +++ b/app/tests/ble/split/peripheral-input/snapshot.log @@ -0,0 +1,25 @@ +profile 0 bt_id: No static addresses stored in controller +profile 0 ble_central: main: [Bluetooth initialized] +profile 0 ble_central: start_scan: [Scanning successfully started] +profile 0 ble_central: device_found: [DEVICE]: FD:9E:B2:48:47:39 (random), AD evt type 0, AD data len 15, RSSI -56 +profile 0 ble_central: eir_found: [AD]: 25 data_len 2 +profile 0 ble_central: eir_found: [AD]: 1 data_len 1 +profile 0 ble_central: eir_found: [AD]: 2 data_len 4 +profile 0 ble_central: connected: [Connected]: FD:9E:B2:48:47:39 (random) +profile 0 ble_central: connected: [Setting the security for the connection] +profile 0 ble_central: pairing_complete: Pairing complete +profile 0 ble_central: discover_conn: [Discovery started for conn] +profile 0 ble_central: discover_func: [ATTRIBUTE] handle 23 +profile 0 ble_central: discover_func: [ATTRIBUTE] handle 28 +profile 0 ble_central: discover_func: [ATTRIBUTE] handle 30 +profile 0 ble_central: discover_func: [SUBSCRIBED] +profile 0 ble_central: discover_func: [ATTRIBUTE] handle 32 +profile 0 ble_central: discover_func: [ATTRIBUTE] handle 34 +profile 0 ble_central: discover_func: [CONSUMER SUBSCRIBED] +profile 0 ble_central: discover_func: [ATTRIBUTE] handle 36 +profile 0 ble_central: discover_func: [ATTRIBUTE] handle 38 +profile 0 ble_central: discover_func: [MOUSE SUBSCRIBED] +profile 0 ble_central: notify_func: payload +profile 0 00 64 00 64 00 00 00 00 00 |.d.d.... . +profile 0 ble_central: notify_func: payload +profile 0 00 28 00 32 00 00 00 00 00 |.(.2.... .