Skip to content

Commit

Permalink
feat(bt): Add tests to for unauth overwrite.
Browse files Browse the repository at this point in the history
* Two tests to ensure unauth overwrite does the right thing when
  hosts try to pair again without the profile cleared on the ZMK side.
  • Loading branch information
petejohanson committed Dec 18, 2023
1 parent 12d73ba commit 1b674ca
Show file tree
Hide file tree
Showing 10 changed files with 129 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./ble_test_central.exe -d=2 -disconnect_and_reconnect -clear_bond_on_disconnect
Original file line number Diff line number Diff line change
@@ -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}//p
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_BT_SMP_ALLOW_UNAUTH_OVERWRITE=y
CONFIG_ZMK_BLE_PASSKEY_ENTRY=y
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <behaviors.dtsi>
#include <dt-bindings/zmk/bt.h>
#include <dt-bindings/zmk/keys.h>
#include <dt-bindings/zmk/kscan_mock.h>

&kscan {
events =
<ZMK_MOCK_PRESS(0,0,10000)
ZMK_MOCK_RELEASE(0,0,2000)
ZMK_MOCK_PRESS(0,1,100)
ZMK_MOCK_RELEASE(0,1,1000)>;
};

/ {
keymap {
compatible = "zmk,keymap";
label = "Default keymap";

default_layer {
bindings = <
&kp A &kp B
&bt BT_SEL 0 &bt BT_SEL 1>;
};
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<wrn> bt_id: No static addresses stored in controller
<dbg> ble_central: _posix_zephyr_main: [Bluetooth initialized]
<dbg> ble_central: start_scan: [Scanning successfully started]
<dbg> ble_central: device_found: [DEVICE]: ED:3B:20:15:18:12 (random), AD evt type 0, AD data len 15, RSSI -59
<dbg> ble_central: eir_found: [AD]: 9 data_len 0
<dbg> ble_central: eir_found: [AD]: 25 data_len 2
<dbg> ble_central: eir_found: [AD]: 1 data_len 1
<dbg> ble_central: eir_found: [AD]: 2 data_len 4
<dbg> ble_central: connected: [Connected]: ED:3B:20:15:18:12 (random)
<dbg> ble_central: connected: [Setting the security for the connection]
<dbg> ble_central: pairing_complete: Pairing complete
<dbg> ble_central: disconnected: [Disconnected]: ED:3B:20:15:18:12 (random) (reason 0x16)
<dbg> ble_central: start_scan: [Scanning successfully started]
<dbg> ble_central: device_found: [DEVICE]: ED:3B:20:15:18:12 (random), AD evt type 0, AD data len 15, RSSI -59
<dbg> ble_central: eir_found: [AD]: 9 data_len 0
<dbg> ble_central: eir_found: [AD]: 25 data_len 2
<dbg> ble_central: eir_found: [AD]: 1 data_len 1
<dbg> ble_central: eir_found: [AD]: 2 data_len 4
<dbg> ble_central: connected: [Connected]: ED:3B:20:15:18:12 (random)
<dbg> ble_central: connected: [Setting the security for the connection]
<dbg> ble_central: pairing_complete: Pairing complete
<dbg> ble_central: discover_conn: [Discovery started for conn]
<dbg> ble_central: discover_func: [ATTRIBUTE] handle 23
<dbg> ble_central: discover_func: [ATTRIBUTE] handle 28
<dbg> ble_central: discover_func: [ATTRIBUTE] handle 30
<dbg> ble_central: discover_func: [SUBSCRIBED]
<dbg> ble_central: notify_func: payload
00 00 04 00 00 00 00 00 |........
<dbg> ble_central: notify_func: payload
00 00 00 00 00 00 00 00 |........
<dbg> ble_central: notify_func: payload
00 00 05 00 00 00 00 00 |........
<dbg> ble_central: notify_func: payload
00 00 00 00 00 00 00 00 |........
<dbg> ble_central: notify_func: payload
00 00 00 00 00 00 00 00 |........
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./ble_test_central.exe -d=2 -disconnect_and_reconnect -clear_bond_on_disconnect
Original file line number Diff line number Diff line change
@@ -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}//p
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_BT_SMP_ALLOW_UNAUTH_OVERWRITE=y
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <behaviors.dtsi>
#include <dt-bindings/zmk/bt.h>
#include <dt-bindings/zmk/keys.h>
#include <dt-bindings/zmk/kscan_mock.h>

&kscan {
events =
<ZMK_MOCK_PRESS(0,0,10000)
ZMK_MOCK_RELEASE(0,0,2000)
ZMK_MOCK_PRESS(0,1,100)
ZMK_MOCK_RELEASE(0,1,1000)>;
};

/ {
keymap {
compatible = "zmk,keymap";
label = "Default keymap";

default_layer {
bindings = <
&kp A &kp B
&bt BT_SEL 0 &bt BT_SEL 1>;
};
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<wrn> bt_id: No static addresses stored in controller
<dbg> ble_central: _posix_zephyr_main: [Bluetooth initialized]
<dbg> ble_central: start_scan: [Scanning successfully started]
<dbg> ble_central: device_found: [DEVICE]: ED:3B:20:15:18:12 (random), AD evt type 0, AD data len 15, RSSI -59
<dbg> ble_central: eir_found: [AD]: 9 data_len 0
<dbg> ble_central: eir_found: [AD]: 25 data_len 2
<dbg> ble_central: eir_found: [AD]: 1 data_len 1
<dbg> ble_central: eir_found: [AD]: 2 data_len 4
<dbg> ble_central: connected: [Connected]: ED:3B:20:15:18:12 (random)
<dbg> ble_central: connected: [Setting the security for the connection]
<dbg> ble_central: pairing_complete: Pairing complete
<dbg> ble_central: disconnected: [Disconnected]: ED:3B:20:15:18:12 (random) (reason 0x16)
<dbg> ble_central: start_scan: [Scanning successfully started]
<dbg> ble_central: device_found: [DEVICE]: ED:3B:20:15:18:12 (random), AD evt type 0, AD data len 15, RSSI -59
<dbg> ble_central: eir_found: [AD]: 9 data_len 0
<dbg> ble_central: eir_found: [AD]: 25 data_len 2
<dbg> ble_central: eir_found: [AD]: 1 data_len 1
<dbg> ble_central: eir_found: [AD]: 2 data_len 4
<dbg> ble_central: connected: [Connected]: ED:3B:20:15:18:12 (random)
<dbg> ble_central: connected: [Setting the security for the connection]
<dbg> ble_central: pairing_complete: Pairing complete
<dbg> ble_central: discover_conn: [Discovery started for conn]
<dbg> ble_central: discover_func: [ATTRIBUTE] handle 23
<dbg> ble_central: discover_func: [ATTRIBUTE] handle 28
<dbg> ble_central: discover_func: [ATTRIBUTE] handle 30
<dbg> ble_central: discover_func: [SUBSCRIBED]
<dbg> ble_central: notify_func: payload
00 00 04 00 00 00 00 00 |........
<dbg> ble_central: notify_func: payload
00 00 00 00 00 00 00 00 |........
<dbg> ble_central: notify_func: payload
00 00 05 00 00 00 00 00 |........
<dbg> ble_central: notify_func: payload
00 00 00 00 00 00 00 00 |........
<dbg> ble_central: notify_func: payload
00 00 00 00 00 00 00 00 |........

0 comments on commit 1b674ca

Please sign in to comment.