From 3c29674a9dc0960ec115a9a545884f153d537246 Mon Sep 17 00:00:00 2001 From: Peter Johanson Date: Mon, 6 Jan 2025 11:58:26 -0700 Subject: [PATCH] test(split): Add a peripheral sensor split test Test BLE split logic for peripheral sensors (encoders). --- .../split/peripheral-encoder/events.patterns | 1 + .../split/peripheral-encoder/nrf52_bsim.conf | 2 ++ .../peripheral-encoder/nrf52_bsim.keymap | 23 +++++++++++++++++++ .../peripheral-encoder/peripheral.overlay | 16 +++++++++++++ .../ble/split/peripheral-encoder/shared.dtsi | 12 ++++++++++ .../ble/split/peripheral-encoder/siblings.txt | 2 ++ .../ble/split/peripheral-encoder/snapshot.log | 23 +++++++++++++++++++ 7 files changed, 79 insertions(+) create mode 100644 app/tests/ble/split/peripheral-encoder/events.patterns create mode 100644 app/tests/ble/split/peripheral-encoder/nrf52_bsim.conf create mode 100644 app/tests/ble/split/peripheral-encoder/nrf52_bsim.keymap create mode 100644 app/tests/ble/split/peripheral-encoder/peripheral.overlay create mode 100644 app/tests/ble/split/peripheral-encoder/shared.dtsi create mode 100644 app/tests/ble/split/peripheral-encoder/siblings.txt create mode 100644 app/tests/ble/split/peripheral-encoder/snapshot.log diff --git a/app/tests/ble/split/peripheral-encoder/events.patterns b/app/tests/ble/split/peripheral-encoder/events.patterns new file mode 100644 index 00000000000..f8cf363c2e0 --- /dev/null +++ b/app/tests/ble/split/peripheral-encoder/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-encoder/nrf52_bsim.conf b/app/tests/ble/split/peripheral-encoder/nrf52_bsim.conf new file mode 100644 index 00000000000..ba7e6a1cc88 --- /dev/null +++ b/app/tests/ble/split/peripheral-encoder/nrf52_bsim.conf @@ -0,0 +1,2 @@ +CONFIG_ZMK_SPLIT=y +CONFIG_SENSOR=y \ No newline at end of file diff --git a/app/tests/ble/split/peripheral-encoder/nrf52_bsim.keymap b/app/tests/ble/split/peripheral-encoder/nrf52_bsim.keymap new file mode 100644 index 00000000000..635b2a259f1 --- /dev/null +++ b/app/tests/ble/split/peripheral-encoder/nrf52_bsim.keymap @@ -0,0 +1,23 @@ +#include +#include +#include + +#include "shared.dtsi" + +&kscan { + /delete-property/ exit-after; + events = <>; +}; +/ { + 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-encoder/peripheral.overlay b/app/tests/ble/split/peripheral-encoder/peripheral.overlay new file mode 100644 index 00000000000..8859efc0430 --- /dev/null +++ b/app/tests/ble/split/peripheral-encoder/peripheral.overlay @@ -0,0 +1,16 @@ + +#include + +#include "shared.dtsi" +&kscan { + events = + <>; + /delete-property/ exit-after; +}; + +&mock_encoder { + status = "okay"; + event-startup-delay = <2000>; + event-period = <2000>; + events = <18 (-18)>; +}; diff --git a/app/tests/ble/split/peripheral-encoder/shared.dtsi b/app/tests/ble/split/peripheral-encoder/shared.dtsi new file mode 100644 index 00000000000..7ae4eded446 --- /dev/null +++ b/app/tests/ble/split/peripheral-encoder/shared.dtsi @@ -0,0 +1,12 @@ +/ { + mock_encoder: mock_encoder { + compatible = "zmk,sensor-encoder-mock"; + status = "disabled"; + }; + + sensors: sensors { + compatible = "zmk,keymap-sensors"; + sensors = <&mock_encoder>; + triggers-per-rotation = <20>; + }; +}; \ No newline at end of file diff --git a/app/tests/ble/split/peripheral-encoder/siblings.txt b/app/tests/ble/split/peripheral-encoder/siblings.txt new file mode 100644 index 00000000000..52dfbb78839 --- /dev/null +++ b/app/tests/ble/split/peripheral-encoder/siblings.txt @@ -0,0 +1,2 @@ +./ble_test_central.exe -d=2 +./tests_ble_split_peripheral-encoder_peripheral.exe -d=3 diff --git a/app/tests/ble/split/peripheral-encoder/snapshot.log b/app/tests/ble/split/peripheral-encoder/snapshot.log new file mode 100644 index 00000000000..c3804f64afb --- /dev/null +++ b/app/tests/ble/split/peripheral-encoder/snapshot.log @@ -0,0 +1,23 @@ +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: notify_func: payload +profile 0 00 00 04 00 00 00 00 00 |........ +profile 0 ble_central: notify_func: payload +profile 0 00 00 00 00 00 00 00 00 |........ +profile 0 ble_central: notify_func: payload +profile 0 00 00 05 00 00 00 00 00 |........ +profile 0 ble_central: notify_func: payload +profile 0 00 00 00 00 00 00 00 00 |........