From 0fc9947e0972d8e1ab1fb10b737d746b65d0e9c0 Mon Sep 17 00:00:00 2001 From: Peter Johanson Date: Tue, 20 Jun 2023 09:31:55 -0700 Subject: [PATCH] feat(bluetooth) Initial nRF52 BSIM based test support. --- .github/workflows/ble-test.yml | 78 ++++ .github/workflows/test.yml | 2 +- app/boards/native_posix_64.overlay | 10 + app/boards/nrf52_bsim.conf | 4 + app/boards/nrf52_bsim.overlay | 17 + app/run-ble-test.sh | 93 +++++ app/tests/ble/central/CMakeLists.txt | 10 + app/tests/ble/central/prj.conf | 8 + app/tests/ble/central/src/main.c | 370 ++++++++++++++++++ .../centrals.txt | 2 + .../events.patterns | 2 + .../nrf52_bsim.keymap | 25 ++ .../snapshot.log | 33 ++ .../bond-to-cleared-profile/centrals.txt | 2 + .../bond-to-cleared-profile/events.patterns | 2 + .../bond-to-cleared-profile/nrf52_bsim.keymap | 25 ++ .../bond-to-cleared-profile/snapshot.log | 33 ++ .../centrals.txt | 1 + .../events.patterns | 1 + .../nrf52_bsim.keymap | 25 ++ .../snapshot.log | 26 ++ .../dont-bond-to-taken-profile/centrals.txt | 2 + .../events.patterns | 2 + .../nrf52_bsim.keymap | 25 ++ .../dont-bond-to-taken-profile/snapshot.log | 22 ++ .../centrals.txt | 2 + .../events.patterns | 2 + .../nrf52_bsim.keymap | 27 ++ .../snapshot.log | 42 ++ .../centrals.txt | 1 + .../events.patterns | 1 + .../nrf52_bsim.keymap | 25 ++ .../snapshot.log | 35 ++ app/west.yml | 91 +++++ 34 files changed, 1045 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ble-test.yml create mode 100644 app/boards/nrf52_bsim.conf create mode 100644 app/boards/nrf52_bsim.overlay create mode 100755 app/run-ble-test.sh create mode 100644 app/tests/ble/central/CMakeLists.txt create mode 100644 app/tests/ble/central/prj.conf create mode 100644 app/tests/ble/central/src/main.c create mode 100644 app/tests/ble/profiles/bond-clear-then-bond-second-client/centrals.txt create mode 100644 app/tests/ble/profiles/bond-clear-then-bond-second-client/events.patterns create mode 100644 app/tests/ble/profiles/bond-clear-then-bond-second-client/nrf52_bsim.keymap create mode 100644 app/tests/ble/profiles/bond-clear-then-bond-second-client/snapshot.log create mode 100644 app/tests/ble/profiles/bond-to-cleared-profile/centrals.txt create mode 100644 app/tests/ble/profiles/bond-to-cleared-profile/events.patterns create mode 100644 app/tests/ble/profiles/bond-to-cleared-profile/nrf52_bsim.keymap create mode 100644 app/tests/ble/profiles/bond-to-cleared-profile/snapshot.log create mode 100644 app/tests/ble/profiles/connnect-and-output-to-selection/centrals.txt create mode 100644 app/tests/ble/profiles/connnect-and-output-to-selection/events.patterns create mode 100644 app/tests/ble/profiles/connnect-and-output-to-selection/nrf52_bsim.keymap create mode 100644 app/tests/ble/profiles/connnect-and-output-to-selection/snapshot.log create mode 100644 app/tests/ble/profiles/dont-bond-to-taken-profile/centrals.txt create mode 100644 app/tests/ble/profiles/dont-bond-to-taken-profile/events.patterns create mode 100644 app/tests/ble/profiles/dont-bond-to-taken-profile/nrf52_bsim.keymap create mode 100644 app/tests/ble/profiles/dont-bond-to-taken-profile/snapshot.log create mode 100644 app/tests/ble/profiles/first-and-second-profile-paired-then-send-data/centrals.txt create mode 100644 app/tests/ble/profiles/first-and-second-profile-paired-then-send-data/events.patterns create mode 100644 app/tests/ble/profiles/first-and-second-profile-paired-then-send-data/nrf52_bsim.keymap create mode 100644 app/tests/ble/profiles/first-and-second-profile-paired-then-send-data/snapshot.log create mode 100644 app/tests/ble/profiles/reconnect-then-output-to-selection/centrals.txt create mode 100644 app/tests/ble/profiles/reconnect-then-output-to-selection/events.patterns create mode 100644 app/tests/ble/profiles/reconnect-then-output-to-selection/nrf52_bsim.keymap create mode 100644 app/tests/ble/profiles/reconnect-then-output-to-selection/snapshot.log diff --git a/.github/workflows/ble-test.yml b/.github/workflows/ble-test.yml new file mode 100644 index 000000000000..3bc8a7180779 --- /dev/null +++ b/.github/workflows/ble-test.yml @@ -0,0 +1,78 @@ +name: BLE Tests + +on: + push: + paths: + - ".github/workflows/ble-test.yml" + - "app/tests/ble/**" + - "app/src/**" + - "app/run-ble-test.sh" + pull_request: + paths: + - ".github/workflows/ble-test.yml" + - "app/tests/ble/**" + - "app/src/**" + - "app/run-ble-test.sh" + +jobs: + collect-tests: + outputs: + test-dirs: ${{ steps.test-dirs.outputs.test-dirs }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Find test directories + id: test-dirs + run: | + cd app/tests/ble + export TESTS=$(ls -d * | grep -v central | jq -R -s -c 'split("\n")[:-1]') + echo "::set-output name=test-dirs::${TESTS}" + run-tests: + needs: collect-tests + strategy: + matrix: + test: ${{ fromJSON(needs.collect-tests.outputs.test-dirs) }} + runs-on: ubuntu-latest + container: + image: docker.io/zmkfirmware/zmk-build-arm:3.2 + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Cache west modules + uses: actions/cache@v3.0.2 + env: + cache-name: cache-zephyr-modules + with: + path: | + modules/ + tools/ + zephyr/ + bootloader/ + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('app/west.yml') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + timeout-minutes: 2 + continue-on-error: true + - name: Initialize workspace (west init) + run: west init -l app + - name: Enable babblesim group filter + run: west config manifest.group-filter -- +babblesim + - name: Update modules (west update) + run: west update + - name: Export Zephyr CMake package (west zephyr-export) + run: west zephyr-export + - name: Build BabbleSim components + working-directory: tools/bsim + run: make everything + - name: Test ${{ matrix.test }} + working-directory: app + run: BSIM_COMPONENTS_PATH="${GITHUB_WORKSPACE}/tools/bsim/components/" BSIM_OUT_PATH="${GITHUB_WORKSPACE}/tools/bsim/" ./run-ble-test.sh tests/ble/${{ matrix.test }} + - name: Archive artifacts + if: ${{ always() }} + uses: actions/upload-artifact@v2 + with: + name: "log-files" + path: app/build/**/*.log diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e8a9d2209e46..ec63081279b1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,7 +24,7 @@ jobs: id: test-dirs run: | cd app/tests/ - export TESTS=$(ls -d * | jq -R -s -c 'split("\n")[:-1]') + export TESTS=$(ls -d * | grep -v ble | jq -R -s -c 'split("\n")[:-1]') echo "::set-output name=test-dirs::${TESTS}" run-tests: needs: collect-tests diff --git a/app/boards/native_posix_64.overlay b/app/boards/native_posix_64.overlay index f8a8f700348a..74d6b7d87087 100644 --- a/app/boards/native_posix_64.overlay +++ b/app/boards/native_posix_64.overlay @@ -4,6 +4,7 @@ / { chosen { + zephyr,console = &uart0; zmk,kscan = &kscan; }; @@ -15,4 +16,13 @@ columns = <2>; exit-after; }; + + uart0: uart { + status = "okay"; + compatible = "zephyr,native-posix-uart"; + /* Dummy current-speed entry to comply with serial + * DTS binding + */ + current-speed = <0>; + }; }; diff --git a/app/boards/nrf52_bsim.conf b/app/boards/nrf52_bsim.conf new file mode 100644 index 000000000000..526f3bc7d7e2 --- /dev/null +++ b/app/boards/nrf52_bsim.conf @@ -0,0 +1,4 @@ +CONFIG_ZMK_BLE=y +CONFIG_LOG=y +CONFIG_LOG_BACKEND_SHOW_COLOR=n +CONFIG_ZMK_LOG_LEVEL_DBG=y diff --git a/app/boards/nrf52_bsim.overlay b/app/boards/nrf52_bsim.overlay new file mode 100644 index 000000000000..482b048604a6 --- /dev/null +++ b/app/boards/nrf52_bsim.overlay @@ -0,0 +1,17 @@ +#include +#include +#include + +/ { + chosen { + zmk,kscan = &kscan; + }; + + kscan: kscan { + compatible = "zmk,kscan-mock"; + label = "KSCAN_MOCK"; + + rows = <2>; + columns = <2>; + }; +}; diff --git a/app/run-ble-test.sh b/app/run-ble-test.sh new file mode 100755 index 000000000000..48ef6e27d2f3 --- /dev/null +++ b/app/run-ble-test.sh @@ -0,0 +1,93 @@ +#!/bin/bash + +# Copyright (c) 2023 The ZMK Contributors +# SPDX-License-Identifier: MIT + +if [ -z "$1" ]; then + echo "Usage: ./run-ble-test.sh " + exit 1 +fi + +path="$1" +if [ $path = "all" ]; then + path="tests" +fi + +if [ -z "$BLE_TESTS_NO_CENTRAL_BUILD" ]; then + if ! [ -e build/tests/ble/central ]; then + west build -d build/tests/ble/central -b nrf52_bsim tests/ble/central > /dev/null 2>&1 + else + west build -d build/tests/ble/central + fi + + cp build/tests/ble/central/zephyr/zephyr.exe "${BSIM_OUT_PATH}/bin/ble_test_central.exe" + + if ! [ -e build/tests/ble/private_central ]; then + west build -d build/tests/ble/private_central -b nrf52_bsim tests/ble/central -- -DCONFIG_BT_PRIVACY=y -DCONFIG_BT_SCAN_WITH_IDENTITY=n > /dev/null 2>&1 + else + west build -d build/tests/ble/private_central + fi + + cp build/tests/ble/private_central/zephyr/zephyr.exe "${BSIM_OUT_PATH}/bin/ble_test_private_central.exe" +fi + +testcases=$(find $path -name nrf52_bsim.keymap -exec dirname \{\} \;) +num_cases=$(echo "$testcases" | wc -l) +if [ $num_cases -gt 1 ] || [ "$testcases" != "${path%%/}" ]; then + echo "$testcases" + echo "" > ./build/tests/pass-fail.log + echo "$testcases" | BLE_TESTS_QUIET_OUTPUT=y BLE_TESTS_NO_CENTRAL_BUILD=y xargs -L 1 -P ${J:-4} ./run-ble-test.sh + err=$? + sort -k2 ./build/tests/pass-fail.log + exit $err +fi + +testcase="$path" +echo "Running $testcase:" + +west build -d build/$testcase -b nrf52_bsim -- -DZMK_CONFIG="$(pwd)/$testcase" > /dev/null 2>&1 +if [ $? -gt 0 ]; then + echo "FAILED: $testcase did not build" | tee -a ./build/tests/pass-fail.log + exit 1 +fi + +if [ -n "${BLE_TESTS_QUIET_OUTPUT}" ]; then + output_dev="/dev/null" +else + output_dev="/dev/stdout" +fi + +exe_name=${testcase//\//_} + +start_dir=$(pwd) +cp build/$testcase/zephyr/zmk.exe "${BSIM_OUT_PATH}/bin/${exe_name}" +pushd "${BSIM_OUT_PATH}/bin" 2>&1 > /dev/null +rm "${start_dir}/build/$testcase/output.log" +central_counts=`wc -l ${start_dir}/${testcase}/centrals.txt | cut -d' ' -f1` +./${exe_name} -d=0 -s=${exe_name} | tee -a "${start_dir}/build/$testcase/output.log" > "${output_dev}" & +./bs_device_handbrake -s=${exe_name} -d=1 -r=10 > "${output_dev}" & + +cat ${start_dir}/${testcase}/centrals.txt | +while IFS= read line +do + ${line} -s=${exe_name} | tee -a "${start_dir}/build/$testcase/output.log" > "${output_dev}" & +done + +./bs_2G4_phy_v1 -s=${exe_name} -D=`expr 2 + $central_counts` -sim_length=50e6 2>&1 > "${output_dev}" + +popd 2>&1 > /dev/null + +cat build/$testcase/output.log | sed -E -n -f $testcase/events.patterns > build/$testcase/filtered_output.log + +diff -auZ $testcase/snapshot.log build/$testcase/filtered_output.log +if [ $? -gt 0 ]; then + if [ -f $testcase/pending ]; then + echo "PENDING: $testcase" | tee -a ./build/tests/pass-fail.log + exit 0 + fi + echo "FAILED: $testcase" | tee -a ./build/tests/pass-fail.log + exit 1 +fi + +echo "PASS: $testcase" | tee -a ./build/tests/pass-fail.log +exit 0 diff --git a/app/tests/ble/central/CMakeLists.txt b/app/tests/ble/central/CMakeLists.txt new file mode 100644 index 000000000000..020bef3813cc --- /dev/null +++ b/app/tests/ble/central/CMakeLists.txt @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.20.0) +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(ble_test_central) + +FILE(GLOB app_sources src/*.c) +target_sources(app PRIVATE ${app_sources}) + +# zephyr_library_include_directories(${ZEPHYR_BASE}/samples/bluetooth) diff --git a/app/tests/ble/central/prj.conf b/app/tests/ble/central/prj.conf new file mode 100644 index 000000000000..3d8317749f54 --- /dev/null +++ b/app/tests/ble/central/prj.conf @@ -0,0 +1,8 @@ +CONFIG_BT=y +CONFIG_LOG=y +CONFIG_BOOT_BANNER=n +CONFIG_BT_LOG_LEVEL_WRN=y +CONFIG_BT_CENTRAL=y +CONFIG_BT_SMP=y +CONFIG_BT_SCAN_WITH_IDENTITY=y +CONFIG_BT_GATT_CLIENT=y diff --git a/app/tests/ble/central/src/main.c b/app/tests/ble/central/src/main.c new file mode 100644 index 000000000000..222fcb45d2a4 --- /dev/null +++ b/app/tests/ble/central/src/main.c @@ -0,0 +1,370 @@ +/* main.c - Application main entry point */ + +/* + * Copyright (c) 2015-2016 Intel Corporation + * Copyright (c) 2023 The ZMK Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include + +#include + +LOG_MODULE_REGISTER(ble_central, 4); + +#include +#include +#include +#include +#include +#include + +#ifdef CONFIG_ARCH_POSIX + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "cmdline.h" +#include "soc.h" + +static bool disconnect_and_reconnect = false; +static bool clear_bond_on_disconnect = false; +static bool halt_after_bonding = false; +static int32_t wait_on_start = 0; + +static void ble_central_native_posix_options(void) { + static struct args_struct_t options[] = { + {.is_switch = true, + .option = "disconnect_and_reconnect", + .type = 'b', + .dest = (void *)&disconnect_and_reconnect, + .descript = "Disconnect and reconnect after the initial connection"}, + {.is_switch = true, + .option = "halt_after_bonding", + .type = 'b', + .dest = (void *)&halt_after_bonding, + .descript = "Halt any further logic after bonding the first time"}, + {.is_switch = true, + .option = "clear_bond_on_disconnect", + .type = 'b', + .dest = (void *)&clear_bond_on_disconnect, + .descript = "Clear bonds on disconnect and reconnect"}, + {// .is_switch = true, + .option = "wait_on_start", + .name = "milliseconds", + .type = 'u', + .dest = (void *)&wait_on_start, + .descript = "Time in milliseconds to wait before starting the test process"}, + ARG_TABLE_ENDMARKER}; + + native_add_command_line_opts(options); +} + +NATIVE_TASK(ble_central_native_posix_options, PRE_BOOT_1, 1); +// NATIVE_TASK(flash_native_posix_cleanup, ON_EXIT, 1); + +#endif + +static void start_scan(void); + +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 uint8_t notify_func(struct bt_conn *conn, struct bt_gatt_subscribe_params *params, + const void *data, uint16_t length) { + if (!data) { + LOG_DBG("[UNSUBSCRIBED]"); + params->value_handle = 0U; + return BT_GATT_ITER_STOP; + } + + LOG_HEXDUMP_DBG(data, length, "payload"); + + return BT_GATT_ITER_CONTINUE; +} + +static uint8_t discover_func(struct bt_conn *conn, const struct bt_gatt_attr *attr, + struct bt_gatt_discover_params *params) { + int err; + + if (!attr) { + LOG_DBG("Discover complete"); + (void)memset(params, 0, sizeof(*params)); + return BT_GATT_ITER_STOP; + } + + LOG_DBG("[ATTRIBUTE] handle %u", attr->handle); + + if (!bt_uuid_cmp(discover_params.uuid, BT_UUID_HIDS)) { + memcpy(&uuid, BT_UUID_HIDS_REPORT, sizeof(uuid)); + discover_params.uuid = &uuid.uuid; + discover_params.start_handle = attr->handle + 1; + discover_params.type = BT_GATT_DISCOVER_CHARACTERISTIC; + + err = bt_gatt_discover(conn, &discover_params); + if (err) { + LOG_DBG("Discover failed (err %d)", err); + } + } else if (!bt_uuid_cmp(discover_params.uuid, BT_UUID_HIDS_REPORT)) { + 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; + 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 { + 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]"); + } + + return BT_GATT_ITER_STOP; + } + + return BT_GATT_ITER_STOP; +} + +static void reconnect(const bt_addr_le_t *addr) { + struct bt_le_conn_param *param; + int err = bt_le_scan_stop(); + if (err < 0) { + LOG_DBG("Stop LE scan failed (err %d)", err); + } + + param = BT_LE_CONN_PARAM_DEFAULT; + err = bt_conn_le_create(addr, BT_CONN_LE_CREATE_CONN, param, &default_conn); + if (err < 0) { + LOG_DBG("Create conn failed (err %d)", err); + start_scan(); + } +} + +static bool eir_found(struct bt_data *data, void *user_data) { + bt_addr_le_t *addr = user_data; + int i; + + LOG_DBG("[AD]: %u data_len %u", data->type, data->data_len); + + switch (data->type) { + case BT_DATA_UUID16_SOME: + case BT_DATA_UUID16_ALL: + if (data->data_len % sizeof(uint16_t) != 0U) { + LOG_DBG("AD malformed"); + return true; + } + + for (i = 0; i < data->data_len; i += sizeof(uint16_t)) { + struct bt_le_conn_param *param; + struct bt_uuid *uuid; + uint16_t u16; + int err; + + memcpy(&u16, &data->data[i], sizeof(u16)); + uuid = BT_UUID_DECLARE_16(sys_le16_to_cpu(u16)); + if (bt_uuid_cmp(uuid, BT_UUID_HIDS)) { + continue; + } + + err = bt_le_scan_stop(); + if (err) { + LOG_DBG("Stop LE scan failed (err %d)", err); + continue; + } + + param = BT_LE_CONN_PARAM_DEFAULT; + err = bt_conn_le_create(addr, BT_CONN_LE_CREATE_CONN, param, &default_conn); + if (err) { + LOG_DBG("Create conn failed (err %d)", err); + start_scan(); + } + + return false; + } + } + + return true; +} + +static void device_found(const bt_addr_le_t *addr, int8_t rssi, uint8_t type, + struct net_buf_simple *ad) { + char dev[BT_ADDR_LE_STR_LEN]; + + bt_addr_le_to_str(addr, dev, sizeof(dev)); + LOG_DBG("[DEVICE]: %s, AD evt type %u, AD data len %u, RSSI %i", dev, type, ad->len, rssi); + + /* We're only interested in connectable events */ + if (type == BT_GAP_ADV_TYPE_ADV_IND) { + bt_data_parse(ad, eir_found, (void *)addr); + } else if (type == BT_GAP_ADV_TYPE_ADV_DIRECT_IND) { + reconnect(addr); + } +} + +static void start_scan(void) { + int err; + + /* Use active scanning and disable duplicate filtering to handle any + * devices that might update their advertising data at runtime. */ + struct bt_le_scan_param scan_param = { + .type = BT_LE_SCAN_TYPE_ACTIVE, + .options = BT_LE_SCAN_OPT_NONE, + .interval = BT_GAP_SCAN_FAST_INTERVAL, + .window = BT_GAP_SCAN_FAST_WINDOW, + }; + + err = bt_le_scan_start(&scan_param, device_found); + if (err) { + LOG_DBG("Scanning failed to start (err %d)", err); + return; + } + + LOG_DBG("Scanning successfully started"); +} + +static void discover_conn(struct bt_conn *conn) { + int err; + + LOG_DBG("Discovery started for conn"); + memcpy(&uuid, BT_UUID_HIDS, sizeof(uuid)); + discover_params.uuid = &uuid.uuid; + discover_params.func = discover_func; + discover_params.start_handle = BT_ATT_FIRST_ATTRIBUTE_HANDLE; + discover_params.end_handle = BT_ATT_LAST_ATTRIBUTE_HANDLE; + discover_params.type = BT_GATT_DISCOVER_PRIMARY; + + err = bt_gatt_discover(default_conn, &discover_params); + if (err) { + LOG_DBG("Discover failed(err %d)", err); + return; + } +} + +static void connected(struct bt_conn *conn, uint8_t conn_err) { + char addr[BT_ADDR_LE_STR_LEN]; + + bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); + + if (conn_err) { + LOG_DBG("Failed to connect to %s (%u)", addr, conn_err); + + bt_conn_unref(default_conn); + default_conn = NULL; + + start_scan(); + return; + } + + LOG_DBG("Connected: %s", addr); + + if (conn == default_conn) { + if (bt_conn_get_security(conn) >= BT_SECURITY_L2) { + discover_conn(conn); + } else { + LOG_DBG("Setting the security for the connection"); + bt_conn_set_security(conn, BT_SECURITY_L2); + } + } +} + +static bool first_connect = true; +static void pairing_complete(struct bt_conn *conn, bool bonded) { LOG_DBG("Pairing complete"); } + +static void do_disconnect_of_active(struct k_work *work) { + bt_conn_disconnect(default_conn, BT_HCI_ERR_REMOTE_USER_TERM_CONN); + if (clear_bond_on_disconnect) { + bt_unpair(BT_ID_DEFAULT, bt_conn_get_dst(default_conn)); + } +} + +static K_WORK_DELAYABLE_DEFINE(disconnect_work, do_disconnect_of_active); + +static void security_changed(struct bt_conn *conn, bt_security_t level, enum bt_security_err err) { + if (err > BT_SECURITY_ERR_SUCCESS) { + exit(1); + } + + if (halt_after_bonding) { + exit(1); + } + + bool do_disconnect = first_connect && disconnect_and_reconnect; + first_connect = false; + if (do_disconnect) { + k_work_reschedule(&disconnect_work, K_MSEC(500)); + } else { + discover_conn(conn); + } +} + +static void disconnected(struct bt_conn *conn, uint8_t reason) { + char addr[BT_ADDR_LE_STR_LEN]; + + bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); + + LOG_DBG("Disconnected: %s (reason 0x%02x)", addr, reason); + + if (default_conn != conn) { + return; + } + + bt_conn_unref(default_conn); + default_conn = NULL; + + if (!halt_after_bonding) { + start_scan(); + } +} + +BT_CONN_CB_DEFINE(conn_callbacks) = { + .connected = connected, + .disconnected = disconnected, + .security_changed = security_changed, +}; + +struct bt_conn_auth_info_cb auth_info_cb = { + .pairing_complete = pairing_complete, +}; + +void main(void) { + int err; + + if (wait_on_start > 0) { + k_sleep(K_MSEC(wait_on_start)); + } + + err = bt_conn_auth_info_cb_register(&auth_info_cb); + + err = bt_enable(NULL); + + if (err) { + LOG_DBG("Bluetooth init failed (err %d)", err); + return; + } + + LOG_DBG("Bluetooth initialized"); + + start_scan(); +} diff --git a/app/tests/ble/profiles/bond-clear-then-bond-second-client/centrals.txt b/app/tests/ble/profiles/bond-clear-then-bond-second-client/centrals.txt new file mode 100644 index 000000000000..80601bad8bc6 --- /dev/null +++ b/app/tests/ble/profiles/bond-clear-then-bond-second-client/centrals.txt @@ -0,0 +1,2 @@ +./ble_test_central.exe -d=2 -halt_after_bonding +./ble_test_central.exe -d=3 -wait_on_start=1300 diff --git a/app/tests/ble/profiles/bond-clear-then-bond-second-client/events.patterns b/app/tests/ble/profiles/bond-clear-then-bond-second-client/events.patterns new file mode 100644 index 000000000000..dbfe5627ecf6 --- /dev/null +++ b/app/tests/ble/profiles/bond-clear-then-bond-second-client/events.patterns @@ -0,0 +1,2 @@ +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 +s/^d_03: @[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 1 /p diff --git a/app/tests/ble/profiles/bond-clear-then-bond-second-client/nrf52_bsim.keymap b/app/tests/ble/profiles/bond-clear-then-bond-second-client/nrf52_bsim.keymap new file mode 100644 index 000000000000..3ddf226fc860 --- /dev/null +++ b/app/tests/ble/profiles/bond-clear-then-bond-second-client/nrf52_bsim.keymap @@ -0,0 +1,25 @@ +#include +#include +#include +#include + +&kscan { + events = + ; +}; + +/ { + keymap { + compatible = "zmk,keymap"; + label = "Default keymap"; + + default_layer { + bindings = < + &kp A &kp B + &bt BT_SEL 0 &bt BT_CLR>; + }; + }; +}; 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 new file mode 100644 index 000000000000..4269fae5620f --- /dev/null +++ b/app/tests/ble/profiles/bond-clear-then-bond-second-client/snapshot.log @@ -0,0 +1,33 @@ +profile 0  bt_id: No static addresses stored in controller +profile 0  ble_central: _posix_zephyr_main: Bluetooth initialized +profile 0  ble_central: start_scan: Scanning successfully started +profile 0  ble_central: device_found: [DEVICE]: ED:3B:20:15:18:12 (random), AD evt type 0, AD data len 15, RSSI -59 +profile 0  ble_central: eir_found: [AD]: 9 data_len 0 +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: ED:3B:20:15:18:12 (random) +profile 0  ble_central: connected: Setting the security for the connection +profile 0  ble_central: pairing_complete: Pairing complete +profile 1  bt_id: No static addresses stored in controller +profile 1  ble_central: _posix_zephyr_main: Bluetooth initialized +profile 1  ble_central: start_scan: Scanning successfully started +profile 1  ble_central: device_found: [DEVICE]: ED:3B:20:15:18:12 (random), AD evt type 0, AD data len 15, RSSI -59 +profile 1  ble_central: eir_found: [AD]: 9 data_len 0 +profile 1  ble_central: eir_found: [AD]: 25 data_len 2 +profile 1  ble_central: eir_found: [AD]: 1 data_len 1 +profile 1  ble_central: eir_found: [AD]: 2 data_len 4 +profile 1  ble_central: connected: Connected: ED:3B:20:15:18:12 (random) +profile 1  ble_central: connected: Setting the security for the connection +profile 1  ble_central: pairing_complete: Pairing complete +profile 1  ble_central: discover_conn: Discovery started for conn +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: 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/centrals.txt b/app/tests/ble/profiles/bond-to-cleared-profile/centrals.txt new file mode 100644 index 000000000000..80601bad8bc6 --- /dev/null +++ b/app/tests/ble/profiles/bond-to-cleared-profile/centrals.txt @@ -0,0 +1,2 @@ +./ble_test_central.exe -d=2 -halt_after_bonding +./ble_test_central.exe -d=3 -wait_on_start=1300 diff --git a/app/tests/ble/profiles/bond-to-cleared-profile/events.patterns b/app/tests/ble/profiles/bond-to-cleared-profile/events.patterns new file mode 100644 index 000000000000..dbfe5627ecf6 --- /dev/null +++ b/app/tests/ble/profiles/bond-to-cleared-profile/events.patterns @@ -0,0 +1,2 @@ +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 +s/^d_03: @[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 1 /p diff --git a/app/tests/ble/profiles/bond-to-cleared-profile/nrf52_bsim.keymap b/app/tests/ble/profiles/bond-to-cleared-profile/nrf52_bsim.keymap new file mode 100644 index 000000000000..b13fe6f9dd88 --- /dev/null +++ b/app/tests/ble/profiles/bond-to-cleared-profile/nrf52_bsim.keymap @@ -0,0 +1,25 @@ +#include +#include +#include +#include + +&kscan { + events = + ; +}; + +/ { + keymap { + compatible = "zmk,keymap"; + label = "Default keymap"; + + default_layer { + bindings = < + &kp A &kp B + &bt BT_SEL 0 &bt BT_CLR>; + }; + }; +}; diff --git a/app/tests/ble/profiles/bond-to-cleared-profile/snapshot.log b/app/tests/ble/profiles/bond-to-cleared-profile/snapshot.log new file mode 100644 index 000000000000..4269fae5620f --- /dev/null +++ b/app/tests/ble/profiles/bond-to-cleared-profile/snapshot.log @@ -0,0 +1,33 @@ +profile 0  bt_id: No static addresses stored in controller +profile 0  ble_central: _posix_zephyr_main: Bluetooth initialized +profile 0  ble_central: start_scan: Scanning successfully started +profile 0  ble_central: device_found: [DEVICE]: ED:3B:20:15:18:12 (random), AD evt type 0, AD data len 15, RSSI -59 +profile 0  ble_central: eir_found: [AD]: 9 data_len 0 +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: ED:3B:20:15:18:12 (random) +profile 0  ble_central: connected: Setting the security for the connection +profile 0  ble_central: pairing_complete: Pairing complete +profile 1  bt_id: No static addresses stored in controller +profile 1  ble_central: _posix_zephyr_main: Bluetooth initialized +profile 1  ble_central: start_scan: Scanning successfully started +profile 1  ble_central: device_found: [DEVICE]: ED:3B:20:15:18:12 (random), AD evt type 0, AD data len 15, RSSI -59 +profile 1  ble_central: eir_found: [AD]: 9 data_len 0 +profile 1  ble_central: eir_found: [AD]: 25 data_len 2 +profile 1  ble_central: eir_found: [AD]: 1 data_len 1 +profile 1  ble_central: eir_found: [AD]: 2 data_len 4 +profile 1  ble_central: connected: Connected: ED:3B:20:15:18:12 (random) +profile 1  ble_central: connected: Setting the security for the connection +profile 1  ble_central: pairing_complete: Pairing complete +profile 1  ble_central: discover_conn: Discovery started for conn +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: 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/centrals.txt b/app/tests/ble/profiles/connnect-and-output-to-selection/centrals.txt new file mode 100644 index 000000000000..110e617d4b74 --- /dev/null +++ b/app/tests/ble/profiles/connnect-and-output-to-selection/centrals.txt @@ -0,0 +1 @@ +./ble_test_central.exe -d=2 diff --git a/app/tests/ble/profiles/connnect-and-output-to-selection/events.patterns b/app/tests/ble/profiles/connnect-and-output-to-selection/events.patterns new file mode 100644 index 000000000000..cca5a2d4ed3f --- /dev/null +++ b/app/tests/ble/profiles/connnect-and-output-to-selection/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}//p diff --git a/app/tests/ble/profiles/connnect-and-output-to-selection/nrf52_bsim.keymap b/app/tests/ble/profiles/connnect-and-output-to-selection/nrf52_bsim.keymap new file mode 100644 index 000000000000..789cec44337c --- /dev/null +++ b/app/tests/ble/profiles/connnect-and-output-to-selection/nrf52_bsim.keymap @@ -0,0 +1,25 @@ +#include +#include +#include +#include + +&kscan { + events = + ; +}; + +/ { + keymap { + compatible = "zmk,keymap"; + label = "Default keymap"; + + default_layer { + bindings = < + &kp A &kp B + &bt BT_SEL 0 &bt BT_SEL 1>; + }; + }; +}; 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 new file mode 100644 index 000000000000..f01b14ff5371 --- /dev/null +++ b/app/tests/ble/profiles/connnect-and-output-to-selection/snapshot.log @@ -0,0 +1,26 @@ + bt_id: No static addresses stored in controller + ble_central: _posix_zephyr_main: Bluetooth initialized + ble_central: start_scan: Scanning successfully started + ble_central: device_found: [DEVICE]: ED:3B:20:15:18:12 (random), AD evt type 0, AD data len 15, RSSI -59 + ble_central: eir_found: [AD]: 9 data_len 0 + ble_central: eir_found: [AD]: 25 data_len 2 + ble_central: eir_found: [AD]: 1 data_len 1 + ble_central: eir_found: [AD]: 2 data_len 4 + ble_central: connected: Connected: ED:3B:20:15:18:12 (random) + ble_central: connected: Setting the security for the connection + ble_central: pairing_complete: Pairing complete + ble_central: discover_conn: Discovery started for conn + ble_central: discover_func: [ATTRIBUTE] handle 23 + ble_central: discover_func: [ATTRIBUTE] handle 28 + ble_central: discover_func: [ATTRIBUTE] handle 30 + ble_central: discover_func: [SUBSCRIBED] + ble_central: notify_func: payload + 00 00 04 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 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/dont-bond-to-taken-profile/centrals.txt b/app/tests/ble/profiles/dont-bond-to-taken-profile/centrals.txt new file mode 100644 index 000000000000..80601bad8bc6 --- /dev/null +++ b/app/tests/ble/profiles/dont-bond-to-taken-profile/centrals.txt @@ -0,0 +1,2 @@ +./ble_test_central.exe -d=2 -halt_after_bonding +./ble_test_central.exe -d=3 -wait_on_start=1300 diff --git a/app/tests/ble/profiles/dont-bond-to-taken-profile/events.patterns b/app/tests/ble/profiles/dont-bond-to-taken-profile/events.patterns new file mode 100644 index 000000000000..dbfe5627ecf6 --- /dev/null +++ b/app/tests/ble/profiles/dont-bond-to-taken-profile/events.patterns @@ -0,0 +1,2 @@ +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 +s/^d_03: @[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 1 /p diff --git a/app/tests/ble/profiles/dont-bond-to-taken-profile/nrf52_bsim.keymap b/app/tests/ble/profiles/dont-bond-to-taken-profile/nrf52_bsim.keymap new file mode 100644 index 000000000000..789cec44337c --- /dev/null +++ b/app/tests/ble/profiles/dont-bond-to-taken-profile/nrf52_bsim.keymap @@ -0,0 +1,25 @@ +#include +#include +#include +#include + +&kscan { + events = + ; +}; + +/ { + keymap { + compatible = "zmk,keymap"; + label = "Default keymap"; + + default_layer { + bindings = < + &kp A &kp B + &bt BT_SEL 0 &bt BT_SEL 1>; + }; + }; +}; diff --git a/app/tests/ble/profiles/dont-bond-to-taken-profile/snapshot.log b/app/tests/ble/profiles/dont-bond-to-taken-profile/snapshot.log new file mode 100644 index 000000000000..a8d0187a2cb3 --- /dev/null +++ b/app/tests/ble/profiles/dont-bond-to-taken-profile/snapshot.log @@ -0,0 +1,22 @@ +profile 0  bt_id: No static addresses stored in controller +profile 0  ble_central: _posix_zephyr_main: Bluetooth initialized +profile 0  ble_central: start_scan: Scanning successfully started +profile 0  ble_central: device_found: [DEVICE]: ED:3B:20:15:18:12 (random), AD evt type 0, AD data len 15, RSSI -59 +profile 0  ble_central: eir_found: [AD]: 9 data_len 0 +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: ED:3B:20:15:18:12 (random) +profile 0  ble_central: connected: Setting the security for the connection +profile 0  ble_central: pairing_complete: Pairing complete +profile 1  bt_id: No static addresses stored in controller +profile 1  ble_central: _posix_zephyr_main: Bluetooth initialized +profile 1  ble_central: start_scan: Scanning successfully started +profile 1  ble_central: device_found: [DEVICE]: ED:3B:20:15:18:12 (random), AD evt type 0, AD data len 15, RSSI -59 +profile 1  ble_central: eir_found: [AD]: 9 data_len 0 +profile 1  ble_central: eir_found: [AD]: 25 data_len 2 +profile 1  ble_central: eir_found: [AD]: 1 data_len 1 +profile 1  ble_central: eir_found: [AD]: 2 data_len 4 +profile 1  ble_central: connected: Connected: ED:3B:20:15:18:12 (random) +profile 1  ble_central: connected: Setting the security for the connection +profile 1  bt_smp: reason 0x8 diff --git a/app/tests/ble/profiles/first-and-second-profile-paired-then-send-data/centrals.txt b/app/tests/ble/profiles/first-and-second-profile-paired-then-send-data/centrals.txt new file mode 100644 index 000000000000..e60cdec044b1 --- /dev/null +++ b/app/tests/ble/profiles/first-and-second-profile-paired-then-send-data/centrals.txt @@ -0,0 +1,2 @@ +./ble_test_central.exe -d=2 +./ble_test_central.exe -d=3 -wait_on_start=1300 diff --git a/app/tests/ble/profiles/first-and-second-profile-paired-then-send-data/events.patterns b/app/tests/ble/profiles/first-and-second-profile-paired-then-send-data/events.patterns new file mode 100644 index 000000000000..dbfe5627ecf6 --- /dev/null +++ b/app/tests/ble/profiles/first-and-second-profile-paired-then-send-data/events.patterns @@ -0,0 +1,2 @@ +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 +s/^d_03: @[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 1 /p diff --git a/app/tests/ble/profiles/first-and-second-profile-paired-then-send-data/nrf52_bsim.keymap b/app/tests/ble/profiles/first-and-second-profile-paired-then-send-data/nrf52_bsim.keymap new file mode 100644 index 000000000000..cc1420ee5ca9 --- /dev/null +++ b/app/tests/ble/profiles/first-and-second-profile-paired-then-send-data/nrf52_bsim.keymap @@ -0,0 +1,27 @@ +#include +#include +#include +#include + +&kscan { + events = + ; +}; + +/ { + keymap { + compatible = "zmk,keymap"; + label = "Default keymap"; + + default_layer { + bindings = < + &kp A &kp B + &bt BT_SEL 0 &bt BT_SEL 1>; + }; + }; +}; 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 new file mode 100644 index 000000000000..3e7e272913d8 --- /dev/null +++ b/app/tests/ble/profiles/first-and-second-profile-paired-then-send-data/snapshot.log @@ -0,0 +1,42 @@ +profile 0  bt_id: No static addresses stored in controller +profile 0  ble_central: _posix_zephyr_main: Bluetooth initialized +profile 0  ble_central: start_scan: Scanning successfully started +profile 0  ble_central: device_found: [DEVICE]: ED:3B:20:15:18:12 (random), AD evt type 0, AD data len 15, RSSI -59 +profile 0  ble_central: eir_found: [AD]: 9 data_len 0 +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: ED:3B:20:15:18:12 (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 1  bt_id: No static addresses stored in controller +profile 1  ble_central: _posix_zephyr_main: Bluetooth initialized +profile 1  ble_central: start_scan: Scanning successfully started +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 1  ble_central: device_found: [DEVICE]: ED:3B:20:15:18:12 (random), AD evt type 0, AD data len 15, RSSI -59 +profile 1  ble_central: eir_found: [AD]: 9 data_len 0 +profile 1  ble_central: eir_found: [AD]: 25 data_len 2 +profile 1  ble_central: eir_found: [AD]: 1 data_len 1 +profile 1  ble_central: eir_found: [AD]: 2 data_len 4 +profile 1  ble_central: connected: Connected: ED:3B:20:15:18:12 (random) +profile 1  ble_central: connected: Setting the security for the connection +profile 1  ble_central: pairing_complete: Pairing complete +profile 1  ble_central: discover_conn: Discovery started for conn +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: 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/reconnect-then-output-to-selection/centrals.txt b/app/tests/ble/profiles/reconnect-then-output-to-selection/centrals.txt new file mode 100644 index 000000000000..2478118532e1 --- /dev/null +++ b/app/tests/ble/profiles/reconnect-then-output-to-selection/centrals.txt @@ -0,0 +1 @@ +./ble_test_central.exe -d=2 -disconnect_and_reconnect diff --git a/app/tests/ble/profiles/reconnect-then-output-to-selection/events.patterns b/app/tests/ble/profiles/reconnect-then-output-to-selection/events.patterns new file mode 100644 index 000000000000..cca5a2d4ed3f --- /dev/null +++ b/app/tests/ble/profiles/reconnect-then-output-to-selection/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}//p diff --git a/app/tests/ble/profiles/reconnect-then-output-to-selection/nrf52_bsim.keymap b/app/tests/ble/profiles/reconnect-then-output-to-selection/nrf52_bsim.keymap new file mode 100644 index 000000000000..789cec44337c --- /dev/null +++ b/app/tests/ble/profiles/reconnect-then-output-to-selection/nrf52_bsim.keymap @@ -0,0 +1,25 @@ +#include +#include +#include +#include + +&kscan { + events = + ; +}; + +/ { + keymap { + compatible = "zmk,keymap"; + label = "Default keymap"; + + default_layer { + bindings = < + &kp A &kp B + &bt BT_SEL 0 &bt BT_SEL 1>; + }; + }; +}; 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 new file mode 100644 index 000000000000..28331f14e5a2 --- /dev/null +++ b/app/tests/ble/profiles/reconnect-then-output-to-selection/snapshot.log @@ -0,0 +1,35 @@ + bt_id: No static addresses stored in controller + ble_central: _posix_zephyr_main: Bluetooth initialized + ble_central: start_scan: Scanning successfully started + ble_central: device_found: [DEVICE]: ED:3B:20:15:18:12 (random), AD evt type 0, AD data len 15, RSSI -59 + ble_central: eir_found: [AD]: 9 data_len 0 + ble_central: eir_found: [AD]: 25 data_len 2 + ble_central: eir_found: [AD]: 1 data_len 1 + ble_central: eir_found: [AD]: 2 data_len 4 + ble_central: connected: Connected: ED:3B:20:15:18:12 (random) + ble_central: connected: Setting the security for the connection + ble_central: pairing_complete: Pairing complete + ble_central: disconnected: Disconnected: ED:3B:20:15:18:12 (random) (reason 0x16) + ble_central: start_scan: Scanning successfully started + ble_central: device_found: [DEVICE]: ED:3B:20:15:18:12 (random), AD evt type 0, AD data len 15, RSSI -59 + ble_central: eir_found: [AD]: 9 data_len 0 + ble_central: eir_found: [AD]: 25 data_len 2 + ble_central: eir_found: [AD]: 1 data_len 1 + ble_central: eir_found: [AD]: 2 data_len 4 + ble_central: connected: Connected: ED:3B:20:15:18:12 (random) + ble_central: connected: Setting the security for the connection + ble_central: discover_conn: Discovery started for conn + ble_central: discover_func: [ATTRIBUTE] handle 23 + ble_central: discover_func: [ATTRIBUTE] handle 28 + ble_central: discover_func: [ATTRIBUTE] handle 30 + ble_central: discover_func: [SUBSCRIBED] + ble_central: notify_func: payload + 00 00 04 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 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/west.yml b/app/west.yml index ffa36ca36e98..f72f2f398bcd 100644 --- a/app/west.yml +++ b/app/west.yml @@ -1,9 +1,17 @@ manifest: + defaults: + remote: upstream + remotes: - name: zephyrproject-rtos url-base: https://github.com/zephyrproject-rtos - name: zmkfirmware url-base: https://github.com/zmkfirmware + - name: upstream + url-base: https://github.com/zephyrproject-rtos + - name: babblesim + url-base: https://github.com/BabbleSim + group-filter: [-babblesim] projects: - name: zephyr remote: zmkfirmware @@ -30,5 +38,88 @@ manifest: - edtt - trusted-firmware-m - sof + - name: bsim + repo-path: babblesim-manifest + revision: 908ffde6298a937c6549dbfa843a62caab26bfc5 + path: tools/bsim + groups: + - babblesim + - name: babblesim_base + remote: babblesim + repo-path: base.git + path: tools/bsim/components + revision: 02838ca04c4562e68dc876196828d8121679e537 + groups: + - babblesim + - name: babblesim_ext_2G4_libPhyComv1 + remote: babblesim + repo-path: ext_2G4_libPhyComv1.git + path: tools/bsim/components/ext_2G4_libPhyComv1 + revision: 9018113a362fa6c9e8f4b9cab9e5a8f12cc46b94 + groups: + - babblesim + - name: babblesim_ext_2G4_phy_v1 + remote: babblesim + repo-path: ext_2G4_phy_v1.git + path: tools/bsim/components/ext_2G4_phy_v1 + revision: cf2d86e736efac4f12fad5093ed2da2c5b406156 + groups: + - babblesim + - name: babblesim_ext_2G4_channel_NtNcable + remote: babblesim + repo-path: ext_2G4_channel_NtNcable.git + path: tools/bsim/components/ext_2G4_channel_NtNcable + revision: 20a38c997f507b0aa53817aab3d73a462fff7af1 + groups: + - babblesim + - name: babblesim_ext_2G4_channel_multiatt + remote: babblesim + repo-path: ext_2G4_channel_multiatt.git + path: tools/bsim/components/ext_2G4_channel_multiatt + revision: e09bc2d14b1975f969ad19c6ed23eb20e5dc3d09 + groups: + - babblesim + - name: babblesim_ext_2G4_modem_magic + remote: babblesim + repo-path: ext_2G4_modem_magic.git + path: tools/bsim/components/ext_2G4_modem_magic + revision: cb70771794f0bf6f262aa474848611c68ae8f1ed + groups: + - babblesim + - name: babblesim_ext_2G4_modem_BLE_simple + remote: babblesim + repo-path: ext_2G4_modem_BLE_simple.git + path: tools/bsim/components/ext_2G4_modem_BLE_simple + revision: ce975a3259fd0dd761d371b60435242d54794bad + groups: + - babblesim + - name: babblesim_ext_2G4_device_burst_interferer + remote: babblesim + repo-path: ext_2G4_device_burst_interferer.git + path: tools/bsim/components/ext_2G4_device_burst_interferer + revision: 5b5339351d6e6a2368c686c734dc8b2fc65698fc + groups: + - babblesim + - name: babblesim_ext_2G4_device_WLAN_actmod + remote: babblesim + repo-path: ext_2G4_device_WLAN_actmod.git + path: tools/bsim/components/ext_2G4_device_WLAN_actmod + revision: 9cb6d8e72695f6b785e57443f0629a18069d6ce4 + groups: + - babblesim + - name: babblesim_ext_2G4_device_playback + remote: babblesim + repo-path: ext_2G4_device_playback.git + path: tools/bsim/components/ext_2G4_device_playback + revision: 85c645929cf1ce995d8537107d9dcbd12ed64036 + groups: + - babblesim + - name: babblesim_ext_libCryptov1 + remote: babblesim + repo-path: ext_libCryptov1.git + path: tools/bsim/components/ext_libCryptov1 + revision: eed6d7038e839153e340bd333bc43541cb90ba64 + groups: + - babblesim self: west-commands: scripts/west-commands.yml