mirror of
https://github.com/zmkfirmware/zmk.git
synced 2026-03-20 04:55:20 -05:00
feat(bluetooth): Initial nRF52 BSIM based test support.
Co-authored-by: Cem Aksoylar <caksoylar@users.noreply.github.com>
This commit is contained in:
committed by
Pete Johanson
parent
da15564d0e
commit
693530c2f1
10
app/tests/ble/central/CMakeLists.txt
Normal file
10
app/tests/ble/central/CMakeLists.txt
Normal file
@@ -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)
|
||||
9
app/tests/ble/central/prj.conf
Normal file
9
app/tests/ble/central/prj.conf
Normal file
@@ -0,0 +1,9 @@
|
||||
CONFIG_BT=y
|
||||
CONFIG_LOG=y
|
||||
CONFIG_BOOT_BANNER=n
|
||||
CONFIG_BT_LOG_LEVEL_WRN=y
|
||||
CONFIG_LOG_BACKEND_SHOW_COLOR=n
|
||||
CONFIG_BT_CENTRAL=y
|
||||
CONFIG_BT_SMP=y
|
||||
CONFIG_BT_SCAN_WITH_IDENTITY=y
|
||||
CONFIG_BT_GATT_CLIENT=y
|
||||
369
app/tests/ble/central/src/main.c
Normal file
369
app/tests/ble/central/src/main.c
Normal file
@@ -0,0 +1,369 @@
|
||||
/* 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 <zephyr/types.h>
|
||||
#include <stddef.h>
|
||||
#include <errno.h>
|
||||
#include <zephyr/kernel.h>
|
||||
|
||||
#include <zephyr/logging/log.h>
|
||||
|
||||
LOG_MODULE_REGISTER(ble_central, 4);
|
||||
|
||||
#include <zephyr/bluetooth/bluetooth.h>
|
||||
#include <zephyr/bluetooth/hci.h>
|
||||
#include <zephyr/bluetooth/conn.h>
|
||||
#include <zephyr/bluetooth/uuid.h>
|
||||
#include <zephyr/bluetooth/gatt.h>
|
||||
#include <zephyr/sys/byteorder.h>
|
||||
|
||||
#ifdef CONFIG_ARCH_POSIX
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/mman.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#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"},
|
||||
{.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);
|
||||
|
||||
#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) {
|
||||
LOG_DBG("[Security Change Failed]");
|
||||
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();
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
./ble_test_central.exe -d=2 -halt_after_bonding
|
||||
./ble_test_central.exe -d=3 -wait_on_start=1300
|
||||
@@ -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
|
||||
@@ -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(1,1,5000)
|
||||
ZMK_MOCK_RELEASE(1,1,200)
|
||||
ZMK_MOCK_PRESS(0,0,10)
|
||||
ZMK_MOCK_RELEASE(0,0,2000)>;
|
||||
};
|
||||
|
||||
/ {
|
||||
keymap {
|
||||
compatible = "zmk,keymap";
|
||||
label = "Default keymap";
|
||||
|
||||
default_layer {
|
||||
bindings = <
|
||||
&kp A &kp B
|
||||
&bt BT_SEL 0 &bt BT_CLR>;
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
profile 0 <wrn> bt_id: No static addresses stored in controller
|
||||
profile 0 <dbg> ble_central: _posix_zephyr_main: [Bluetooth initialized]
|
||||
profile 0 <dbg> ble_central: start_scan: [Scanning successfully started]
|
||||
profile 0 <dbg> ble_central: device_found: [DEVICE]: ED:3B:20:15:18:12 (random), AD evt type 0, AD data len 15, RSSI -59
|
||||
profile 0 <dbg> ble_central: eir_found: [AD]: 9 data_len 0
|
||||
profile 0 <dbg> ble_central: eir_found: [AD]: 25 data_len 2
|
||||
profile 0 <dbg> ble_central: eir_found: [AD]: 1 data_len 1
|
||||
profile 0 <dbg> ble_central: eir_found: [AD]: 2 data_len 4
|
||||
profile 0 <dbg> ble_central: connected: [Connected]: ED:3B:20:15:18:12 (random)
|
||||
profile 0 <dbg> ble_central: connected: [Setting the security for the connection]
|
||||
profile 0 <dbg> ble_central: pairing_complete: Pairing complete
|
||||
profile 1 <wrn> bt_id: No static addresses stored in controller
|
||||
profile 1 <dbg> ble_central: _posix_zephyr_main: [Bluetooth initialized]
|
||||
profile 1 <dbg> ble_central: start_scan: [Scanning successfully started]
|
||||
profile 1 <dbg> ble_central: device_found: [DEVICE]: ED:3B:20:15:18:12 (random), AD evt type 0, AD data len 15, RSSI -59
|
||||
profile 1 <dbg> ble_central: eir_found: [AD]: 9 data_len 0
|
||||
profile 1 <dbg> ble_central: eir_found: [AD]: 25 data_len 2
|
||||
profile 1 <dbg> ble_central: eir_found: [AD]: 1 data_len 1
|
||||
profile 1 <dbg> ble_central: eir_found: [AD]: 2 data_len 4
|
||||
profile 1 <dbg> ble_central: connected: [Connected]: ED:3B:20:15:18:12 (random)
|
||||
profile 1 <dbg> ble_central: connected: [Setting the security for the connection]
|
||||
profile 1 <dbg> ble_central: pairing_complete: Pairing complete
|
||||
profile 1 <dbg> ble_central: discover_conn: [Discovery started for conn]
|
||||
profile 1 <dbg> ble_central: discover_func: [ATTRIBUTE] handle 23
|
||||
profile 1 <dbg> ble_central: discover_func: [ATTRIBUTE] handle 28
|
||||
profile 1 <dbg> ble_central: discover_func: [ATTRIBUTE] handle 30
|
||||
profile 1 <dbg> ble_central: discover_func: [SUBSCRIBED]
|
||||
profile 1 <dbg> ble_central: notify_func: payload
|
||||
profile 1 00 00 04 00 00 00 00 00 |........
|
||||
profile 1 <dbg> ble_central: notify_func: payload
|
||||
profile 1 00 00 00 00 00 00 00 00 |........
|
||||
profile 1 <dbg> ble_central: notify_func: payload
|
||||
profile 1 00 00 00 00 00 00 00 00 |........
|
||||
@@ -0,0 +1,2 @@
|
||||
./ble_test_central.exe -d=2 -halt_after_bonding
|
||||
./ble_test_central.exe -d=3 -wait_on_start=1300
|
||||
@@ -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
|
||||
@@ -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(1,1,1000)
|
||||
ZMK_MOCK_RELEASE(1,1,2000)
|
||||
ZMK_MOCK_PRESS(0,0,100)
|
||||
ZMK_MOCK_RELEASE(0,0,1000)>;
|
||||
};
|
||||
|
||||
/ {
|
||||
keymap {
|
||||
compatible = "zmk,keymap";
|
||||
label = "Default keymap";
|
||||
|
||||
default_layer {
|
||||
bindings = <
|
||||
&kp A &kp B
|
||||
&bt BT_SEL 0 &bt BT_CLR>;
|
||||
};
|
||||
};
|
||||
};
|
||||
33
app/tests/ble/profiles/bond-to-cleared-profile/snapshot.log
Normal file
33
app/tests/ble/profiles/bond-to-cleared-profile/snapshot.log
Normal file
@@ -0,0 +1,33 @@
|
||||
profile 0 <wrn> bt_id: No static addresses stored in controller
|
||||
profile 0 <dbg> ble_central: _posix_zephyr_main: [Bluetooth initialized]
|
||||
profile 0 <dbg> ble_central: start_scan: [Scanning successfully started]
|
||||
profile 0 <dbg> ble_central: device_found: [DEVICE]: ED:3B:20:15:18:12 (random), AD evt type 0, AD data len 15, RSSI -59
|
||||
profile 0 <dbg> ble_central: eir_found: [AD]: 9 data_len 0
|
||||
profile 0 <dbg> ble_central: eir_found: [AD]: 25 data_len 2
|
||||
profile 0 <dbg> ble_central: eir_found: [AD]: 1 data_len 1
|
||||
profile 0 <dbg> ble_central: eir_found: [AD]: 2 data_len 4
|
||||
profile 0 <dbg> ble_central: connected: [Connected]: ED:3B:20:15:18:12 (random)
|
||||
profile 0 <dbg> ble_central: connected: [Setting the security for the connection]
|
||||
profile 0 <dbg> ble_central: pairing_complete: Pairing complete
|
||||
profile 1 <wrn> bt_id: No static addresses stored in controller
|
||||
profile 1 <dbg> ble_central: _posix_zephyr_main: [Bluetooth initialized]
|
||||
profile 1 <dbg> ble_central: start_scan: [Scanning successfully started]
|
||||
profile 1 <dbg> ble_central: device_found: [DEVICE]: ED:3B:20:15:18:12 (random), AD evt type 0, AD data len 15, RSSI -59
|
||||
profile 1 <dbg> ble_central: eir_found: [AD]: 9 data_len 0
|
||||
profile 1 <dbg> ble_central: eir_found: [AD]: 25 data_len 2
|
||||
profile 1 <dbg> ble_central: eir_found: [AD]: 1 data_len 1
|
||||
profile 1 <dbg> ble_central: eir_found: [AD]: 2 data_len 4
|
||||
profile 1 <dbg> ble_central: connected: [Connected]: ED:3B:20:15:18:12 (random)
|
||||
profile 1 <dbg> ble_central: connected: [Setting the security for the connection]
|
||||
profile 1 <dbg> ble_central: pairing_complete: Pairing complete
|
||||
profile 1 <dbg> ble_central: discover_conn: [Discovery started for conn]
|
||||
profile 1 <dbg> ble_central: discover_func: [ATTRIBUTE] handle 23
|
||||
profile 1 <dbg> ble_central: discover_func: [ATTRIBUTE] handle 28
|
||||
profile 1 <dbg> ble_central: discover_func: [ATTRIBUTE] handle 30
|
||||
profile 1 <dbg> ble_central: discover_func: [SUBSCRIBED]
|
||||
profile 1 <dbg> ble_central: notify_func: payload
|
||||
profile 1 00 00 04 00 00 00 00 00 |........
|
||||
profile 1 <dbg> ble_central: notify_func: payload
|
||||
profile 1 00 00 00 00 00 00 00 00 |........
|
||||
profile 1 <dbg> ble_central: notify_func: payload
|
||||
profile 1 00 00 00 00 00 00 00 00 |........
|
||||
@@ -0,0 +1 @@
|
||||
./ble_test_central.exe -d=2
|
||||
@@ -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
|
||||
@@ -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>;
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
<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: 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,0 +1,2 @@
|
||||
./ble_test_central.exe -d=2 -halt_after_bonding
|
||||
./ble_test_central.exe -d=3 -wait_on_start=1300
|
||||
@@ -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
|
||||
@@ -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>;
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
profile 0 <wrn> bt_id: No static addresses stored in controller
|
||||
profile 0 <dbg> ble_central: _posix_zephyr_main: [Bluetooth initialized]
|
||||
profile 0 <dbg> ble_central: start_scan: [Scanning successfully started]
|
||||
profile 0 <dbg> ble_central: device_found: [DEVICE]: ED:3B:20:15:18:12 (random), AD evt type 0, AD data len 15, RSSI -59
|
||||
profile 0 <dbg> ble_central: eir_found: [AD]: 9 data_len 0
|
||||
profile 0 <dbg> ble_central: eir_found: [AD]: 25 data_len 2
|
||||
profile 0 <dbg> ble_central: eir_found: [AD]: 1 data_len 1
|
||||
profile 0 <dbg> ble_central: eir_found: [AD]: 2 data_len 4
|
||||
profile 0 <dbg> ble_central: connected: [Connected]: ED:3B:20:15:18:12 (random)
|
||||
profile 0 <dbg> ble_central: connected: [Setting the security for the connection]
|
||||
profile 0 <dbg> ble_central: pairing_complete: Pairing complete
|
||||
profile 1 <wrn> bt_id: No static addresses stored in controller
|
||||
profile 1 <dbg> ble_central: _posix_zephyr_main: [Bluetooth initialized]
|
||||
profile 1 <dbg> ble_central: start_scan: [Scanning successfully started]
|
||||
profile 1 <dbg> ble_central: device_found: [DEVICE]: ED:3B:20:15:18:12 (random), AD evt type 0, AD data len 15, RSSI -59
|
||||
profile 1 <dbg> ble_central: eir_found: [AD]: 9 data_len 0
|
||||
profile 1 <dbg> ble_central: eir_found: [AD]: 25 data_len 2
|
||||
profile 1 <dbg> ble_central: eir_found: [AD]: 1 data_len 1
|
||||
profile 1 <dbg> ble_central: eir_found: [AD]: 2 data_len 4
|
||||
profile 1 <dbg> ble_central: connected: [Connected]: ED:3B:20:15:18:12 (random)
|
||||
profile 1 <dbg> ble_central: connected: [Setting the security for the connection]
|
||||
profile 1 <err> bt_smp: reason 0x8
|
||||
profile 1 <dbg> ble_central: security_changed: [Security Change Failed]
|
||||
@@ -0,0 +1,2 @@
|
||||
./ble_test_central.exe -d=2
|
||||
./ble_test_central.exe -d=3 -wait_on_start=1300
|
||||
@@ -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
|
||||
@@ -0,0 +1,27 @@
|
||||
#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,5000)
|
||||
ZMK_MOCK_RELEASE(0,0,200)
|
||||
ZMK_MOCK_PRESS(1,1,10)
|
||||
ZMK_MOCK_RELEASE(1,1,2000)
|
||||
ZMK_MOCK_PRESS(0,1,1000)
|
||||
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>;
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,42 @@
|
||||
profile 0 <wrn> bt_id: No static addresses stored in controller
|
||||
profile 0 <dbg> ble_central: _posix_zephyr_main: [Bluetooth initialized]
|
||||
profile 0 <dbg> ble_central: start_scan: [Scanning successfully started]
|
||||
profile 0 <dbg> ble_central: device_found: [DEVICE]: ED:3B:20:15:18:12 (random), AD evt type 0, AD data len 15, RSSI -59
|
||||
profile 0 <dbg> ble_central: eir_found: [AD]: 9 data_len 0
|
||||
profile 0 <dbg> ble_central: eir_found: [AD]: 25 data_len 2
|
||||
profile 0 <dbg> ble_central: eir_found: [AD]: 1 data_len 1
|
||||
profile 0 <dbg> ble_central: eir_found: [AD]: 2 data_len 4
|
||||
profile 0 <dbg> ble_central: connected: [Connected]: ED:3B:20:15:18:12 (random)
|
||||
profile 0 <dbg> ble_central: connected: [Setting the security for the connection]
|
||||
profile 0 <dbg> ble_central: pairing_complete: Pairing complete
|
||||
profile 0 <dbg> ble_central: discover_conn: [Discovery started for conn]
|
||||
profile 0 <dbg> ble_central: discover_func: [ATTRIBUTE] handle 23
|
||||
profile 1 <wrn> bt_id: No static addresses stored in controller
|
||||
profile 1 <dbg> ble_central: _posix_zephyr_main: [Bluetooth initialized]
|
||||
profile 1 <dbg> ble_central: start_scan: [Scanning successfully started]
|
||||
profile 0 <dbg> ble_central: discover_func: [ATTRIBUTE] handle 28
|
||||
profile 0 <dbg> ble_central: discover_func: [ATTRIBUTE] handle 30
|
||||
profile 0 <dbg> ble_central: discover_func: [SUBSCRIBED]
|
||||
profile 0 <dbg> ble_central: notify_func: payload
|
||||
profile 0 00 00 04 00 00 00 00 00 |........
|
||||
profile 0 <dbg> ble_central: notify_func: payload
|
||||
profile 0 00 00 00 00 00 00 00 00 |........
|
||||
profile 1 <dbg> ble_central: device_found: [DEVICE]: ED:3B:20:15:18:12 (random), AD evt type 0, AD data len 15, RSSI -59
|
||||
profile 1 <dbg> ble_central: eir_found: [AD]: 9 data_len 0
|
||||
profile 1 <dbg> ble_central: eir_found: [AD]: 25 data_len 2
|
||||
profile 1 <dbg> ble_central: eir_found: [AD]: 1 data_len 1
|
||||
profile 1 <dbg> ble_central: eir_found: [AD]: 2 data_len 4
|
||||
profile 1 <dbg> ble_central: connected: [Connected]: ED:3B:20:15:18:12 (random)
|
||||
profile 1 <dbg> ble_central: connected: [Setting the security for the connection]
|
||||
profile 1 <dbg> ble_central: pairing_complete: Pairing complete
|
||||
profile 1 <dbg> ble_central: discover_conn: [Discovery started for conn]
|
||||
profile 1 <dbg> ble_central: discover_func: [ATTRIBUTE] handle 23
|
||||
profile 1 <dbg> ble_central: discover_func: [ATTRIBUTE] handle 28
|
||||
profile 1 <dbg> ble_central: discover_func: [ATTRIBUTE] handle 30
|
||||
profile 1 <dbg> ble_central: discover_func: [SUBSCRIBED]
|
||||
profile 1 <dbg> ble_central: notify_func: payload
|
||||
profile 1 00 00 05 00 00 00 00 00 |........
|
||||
profile 1 <dbg> ble_central: notify_func: payload
|
||||
profile 1 00 00 00 00 00 00 00 00 |........
|
||||
profile 1 <dbg> ble_central: notify_func: payload
|
||||
profile 1 00 00 00 00 00 00 00 00 |........
|
||||
@@ -0,0 +1 @@
|
||||
./ble_test_central.exe -d=2 -disconnect_and_reconnect
|
||||
@@ -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
|
||||
@@ -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>;
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
<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: 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 |........
|
||||
Reference in New Issue
Block a user