mirror of https://github.com/zmkfirmware/zmk.git
Compare commits
5 Commits
20a30eba30
...
5cb065e050
| Author | SHA1 | Date |
|---|---|---|
|
|
5cb065e050 | |
|
|
ad7fbfef92 | |
|
|
45568337d5 | |
|
|
ebf4391e0f | |
|
|
8ecb8a6404 |
|
|
@ -96,6 +96,7 @@ target_sources_ifdef(CONFIG_ZMK_BATTERY_REPORTING app PRIVATE src/battery.c)
|
|||
target_sources_ifdef(CONFIG_ZMK_HID_INDICATORS app PRIVATE src/events/hid_indicators_changed.c)
|
||||
|
||||
target_sources_ifdef(CONFIG_ZMK_SPLIT app PRIVATE src/events/split_peripheral_status_changed.c)
|
||||
target_sources_ifdef(CONFIG_ZMK_SPLIT app PRIVATE src/events/split_transport_changed.c)
|
||||
add_subdirectory_ifdef(CONFIG_ZMK_SPLIT src/split)
|
||||
|
||||
target_sources_ifdef(CONFIG_USB_DEVICE_STACK app PRIVATE src/usb.c)
|
||||
|
|
|
|||
|
|
@ -25,6 +25,9 @@ config USB_DEVICE_PID
|
|||
config USB_DEVICE_MANUFACTURER
|
||||
default "ZMK Project"
|
||||
|
||||
config BT_DEVICE_APPEARANCE
|
||||
default 961
|
||||
|
||||
config BT_DIS_PNP_VID
|
||||
default 0x1D50
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Copyright (c) 2025 The ZMK Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zmk/event_manager.h>
|
||||
#include <zmk/split/transport/types.h>
|
||||
|
||||
struct zmk_split_transport_changed {
|
||||
uint32_t addr;
|
||||
struct zmk_split_transport_status status;
|
||||
};
|
||||
|
||||
ZMK_EVENT_DECLARE(zmk_split_transport_changed)
|
||||
|
|
@ -46,3 +46,7 @@ int zmk_split_central_update_hid_indicator(zmk_hid_indicators_t indicators);
|
|||
int zmk_split_central_get_peripheral_battery_level(uint8_t source, uint8_t *level);
|
||||
|
||||
#endif // IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_CENTRAL_BATTERY_LEVEL_FETCHING)
|
||||
|
||||
bool zmk_split_transport_get_available(uint32_t addr);
|
||||
|
||||
uint32_t zmk_split_get_transport_addr_at_index(uint8_t index);
|
||||
|
|
@ -9,3 +9,7 @@
|
|||
#include <zmk/split/transport/types.h>
|
||||
|
||||
int zmk_split_peripheral_report_event(const struct zmk_split_transport_peripheral_event *event);
|
||||
|
||||
bool zmk_split_transport_get_available(uint32_t addr);
|
||||
|
||||
uint32_t zmk_split_get_transport_addr_at_index(uint8_t index);
|
||||
|
|
@ -65,13 +65,15 @@ static uint8_t active_profile;
|
|||
|
||||
#define DEVICE_NAME CONFIG_BT_DEVICE_NAME
|
||||
#define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1)
|
||||
#define DEVICE_APPEARANCE \
|
||||
(uint8_t) CONFIG_BT_DEVICE_APPEARANCE, (uint8_t)(CONFIG_BT_DEVICE_APPEARANCE >> 8)
|
||||
|
||||
BUILD_ASSERT(
|
||||
DEVICE_NAME_LEN <= CONFIG_BT_DEVICE_NAME_MAX,
|
||||
"ERROR: BLE device name is too long. Max length: " STRINGIFY(CONFIG_BT_DEVICE_NAME_MAX));
|
||||
|
||||
static struct bt_data zmk_ble_ad[] = {
|
||||
BT_DATA_BYTES(BT_DATA_GAP_APPEARANCE, 0xC1, 0x03),
|
||||
BT_DATA_BYTES(BT_DATA_GAP_APPEARANCE, DEVICE_APPEARANCE),
|
||||
BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
|
||||
BT_DATA_BYTES(BT_DATA_UUID16_SOME, 0x12, 0x18, /* HID Service */
|
||||
0x0f, 0x18 /* Battery Service */
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
* Copyright (c) 2025 The ZMK Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zmk/events/split_transport_changed.h>
|
||||
|
||||
ZMK_EVENT_IMPL(zmk_split_transport_changed);
|
||||
|
|
@ -19,6 +19,8 @@
|
|||
#include <zmk/events/position_state_changed.h>
|
||||
#include <zmk/events/sensor_event.h>
|
||||
|
||||
#include <zmk/events/split_transport_changed.h>
|
||||
|
||||
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
|
||||
|
||||
const struct zmk_split_transport_central *active_transport;
|
||||
|
|
@ -198,6 +200,8 @@ static int select_first_available_transport(void) {
|
|||
|
||||
static int transport_status_changed_cb(const struct zmk_split_transport_central *central,
|
||||
struct zmk_split_transport_status status) {
|
||||
raise_zmk_split_transport_changed(
|
||||
(struct zmk_split_transport_changed){.addr = (uint32_t)central, .status = status});
|
||||
if (central == active_transport) {
|
||||
LOG_DBG("Central at %p changed status: enabled %d, available %d, connections %d", central,
|
||||
status.enabled, status.available, status.connections);
|
||||
|
|
@ -212,6 +216,26 @@ static int transport_status_changed_cb(const struct zmk_split_transport_central
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool zmk_split_transport_get_available(uint32_t addr) {
|
||||
STRUCT_SECTION_FOREACH(zmk_split_transport_central, t) {
|
||||
if ((uint32_t)t == addr) {
|
||||
return t->api->get_status().available;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t zmk_split_get_transport_addr_at_index(uint8_t index) {
|
||||
struct zmk_split_transport_central *t;
|
||||
ptrdiff_t count;
|
||||
STRUCT_SECTION_COUNT(zmk_split_transport_central, &count);
|
||||
if ((ptrdiff_t)index > count)
|
||||
return 0;
|
||||
STRUCT_SECTION_GET(zmk_split_transport_central, index, &t);
|
||||
return (uint32_t)t;
|
||||
}
|
||||
|
||||
static int central_init(void) {
|
||||
STRUCT_SECTION_FOREACH(zmk_split_transport_central, t) {
|
||||
if (!t->api->set_status_callback) {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@
|
|||
#include <zmk/events/sensor_event.h>
|
||||
#include <zmk/events/battery_state_changed.h>
|
||||
|
||||
#include <zmk/events/split_transport_changed.h>
|
||||
|
||||
#if IS_ENABLED(CONFIG_ZMK_SPLIT_PERIPHERAL_HID_INDICATORS)
|
||||
#include <zmk/events/hid_indicators_changed.h>
|
||||
#endif
|
||||
|
|
@ -55,13 +57,14 @@ int zmk_split_transport_peripheral_command_handler(
|
|||
if (err) {
|
||||
LOG_ERR("Failed to invoke behavior %s: %d", binding.behavior_dev, err);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
case ZMK_SPLIT_TRANSPORT_CENTRAL_CMD_TYPE_SET_PHYSICAL_LAYOUT: {
|
||||
zmk_physical_layouts_select(cmd.data.set_physical_layout.layout_idx);
|
||||
return zmk_physical_layouts_select(cmd.data.set_physical_layout.layout_idx);
|
||||
}
|
||||
#if IS_ENABLED(CONFIG_ZMK_SPLIT_PERIPHERAL_HID_INDICATORS)
|
||||
case ZMK_SPLIT_TRANSPORT_CENTRAL_CMD_TYPE_SET_HID_INDICATORS: {
|
||||
raise_zmk_hid_indicators_changed((struct zmk_hid_indicators_changed){
|
||||
return raise_zmk_hid_indicators_changed((struct zmk_hid_indicators_changed){
|
||||
.indicators = cmd.data.set_hid_indicators.indicators});
|
||||
}
|
||||
#endif
|
||||
|
|
@ -115,6 +118,8 @@ static int select_first_available_transport(void) {
|
|||
|
||||
static int transport_status_changed_cb(const struct zmk_split_transport_peripheral *p,
|
||||
struct zmk_split_transport_status status) {
|
||||
raise_zmk_split_transport_changed(
|
||||
(struct zmk_split_transport_changed){.addr = (uint32_t)p, .status = status});
|
||||
if (p == active_transport) {
|
||||
LOG_DBG("Peripheral at %p changed status: enabled %d, available %d, connections %d", p,
|
||||
status.enabled, status.available, status.connections);
|
||||
|
|
@ -130,6 +135,26 @@ static int transport_status_changed_cb(const struct zmk_split_transport_peripher
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool zmk_split_transport_get_available(uint32_t addr) {
|
||||
STRUCT_SECTION_FOREACH(zmk_split_transport_peripheral, t) {
|
||||
if ((uint32_t)t == addr) {
|
||||
return t->api->get_status().available;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t zmk_split_get_transport_addr_at_index(uint8_t index) {
|
||||
struct zmk_split_transport_peripheral *t;
|
||||
ptrdiff_t count;
|
||||
STRUCT_SECTION_COUNT(zmk_split_transport_peripheral, &count);
|
||||
if ((ptrdiff_t)index > count)
|
||||
return 0;
|
||||
STRUCT_SECTION_GET(zmk_split_transport_peripheral, index, &t);
|
||||
return (uint32_t)t;
|
||||
}
|
||||
|
||||
static int peripheral_init(void) {
|
||||
STRUCT_SECTION_FOREACH(zmk_split_transport_peripheral, t) {
|
||||
if (!t->api->set_status_callback) {
|
||||
|
|
|
|||
|
|
@ -16,3 +16,4 @@ See [Configuration Overview](index.md) for instructions on how to change these s
|
|||
| `CONFIG_ZMK_BLE_EXPERIMENTAL_FEATURES` | bool | Aggregate config that enables both `CONFIG_ZMK_BLE_EXPERIMENTAL_CONN` and `CONFIG_ZMK_BLE_EXPERIMENTAL_SEC`. | n |
|
||||
| `CONFIG_ZMK_BLE_PASSKEY_ENTRY` | bool | Enable passkey entry during pairing for enhanced security. (Note: After enabling this, you will need to re-pair all previously paired hosts.) | n |
|
||||
| `CONFIG_BT_GATT_ENFORCE_SUBSCRIPTION` | bool | Low level setting for GATT subscriptions. Set to `n` to work around an annoying Windows bug with battery notifications. | y |
|
||||
| `CONFIG_BT_DEVICE_APPEARANCE` | int | Bluetooth device [appearance value](https://bluetooth.com/specifications/assigned-numbers) (should be converted from hexadecimal to decimal). | 961 |
|
||||
|
|
|
|||
Loading…
Reference in New Issue