feat: 添加蓝牙多槽位绑定支持模块
- 新增 ble_bond_multi_module.c 实现多槽位蓝牙绑定管理功能 - 添加 ble_bond_multi_event 事件系统支持槽位状态广播 - 在 CMakeLists.txt 中注册新模块和事件源文件 - 更新 Kconfig 配置添加 BLINKY_BLE_BOND_MULTI 选项 - 修改 prj.conf 配置支持 4 个配对设备和 5 个身份标识 - 关闭默认 CAF ble_bond 模块使用自定义实现 - 更新 ui_settings_controller.h 接口支持槽位元数据设置 - 在 display_module.c 中添加事件订阅刷新UI显示 - 编写详细的设计文档 ble_multi_slot_design.md
This commit is contained in:
@@ -94,7 +94,6 @@ struct keyboard_core_module_ctx {
|
||||
uint8_t function_usage_mask[KEYBOARD_PROTOCOL_BITMAP_BYTES];
|
||||
enum keyboard_protocol_mode transport_protocol_modes[HID_TRANSPORT_COUNT];
|
||||
enum hid_transport_policy current_transport;
|
||||
bool mode_valid;
|
||||
bool settings_active;
|
||||
};
|
||||
|
||||
@@ -146,8 +145,7 @@ static enum keyboard_protocol_mode active_protocol_mode_get(void)
|
||||
{
|
||||
enum hid_transport transport;
|
||||
|
||||
if (ctx.mode_valid &&
|
||||
policy_to_transport(ctx.current_transport, &transport)) {
|
||||
if (policy_to_transport(ctx.current_transport, &transport)) {
|
||||
return ctx.transport_protocol_modes[transport];
|
||||
}
|
||||
|
||||
@@ -358,7 +356,7 @@ static void submit_consumer_fifo_frame(uint16_t usage_id)
|
||||
enum keyboard_protocol_mode protocol_mode = active_protocol_mode_get();
|
||||
enum mode_switch_mode mode;
|
||||
|
||||
if (!module_lifecycle_is_running(&ctx.lc) || !ctx.mode_valid ||
|
||||
if (!module_lifecycle_is_running(&ctx.lc) ||
|
||||
ctx.settings_active ||
|
||||
!transport_policy_to_mode(ctx.current_transport, &mode) ||
|
||||
(protocol_mode == KEYBOARD_PROTOCOL_MODE_BOOT)) {
|
||||
@@ -406,8 +404,7 @@ static void emit_keys_report(bool force)
|
||||
enum keyboard_protocol_mode protocol_mode = active_protocol_mode_get();
|
||||
enum mode_switch_mode mode;
|
||||
|
||||
if (!ctx.mode_valid ||
|
||||
!transport_policy_to_mode(ctx.current_transport, &mode)) {
|
||||
if (!transport_policy_to_mode(ctx.current_transport, &mode)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -445,8 +442,7 @@ static void emit_consumer_report(bool force)
|
||||
enum keyboard_protocol_mode protocol_mode = active_protocol_mode_get();
|
||||
enum mode_switch_mode mode;
|
||||
|
||||
if (!ctx.mode_valid ||
|
||||
!transport_policy_to_mode(ctx.current_transport, &mode) ||
|
||||
if (!transport_policy_to_mode(ctx.current_transport, &mode) ||
|
||||
ctx.settings_active ||
|
||||
(protocol_mode == KEYBOARD_PROTOCOL_MODE_BOOT)) {
|
||||
return;
|
||||
@@ -522,8 +518,8 @@ static int do_init(void)
|
||||
keyboard_state_clear();
|
||||
reports_cache_invalidate();
|
||||
function_usage_mask_clear();
|
||||
ctx.mode_valid = false;
|
||||
ctx.settings_active = false;
|
||||
ctx.current_transport = HID_TRANSPORT_POLICY_USB;
|
||||
ctx.transport_protocol_modes[HID_TRANSPORT_USB] =
|
||||
KEYBOARD_PROTOCOL_MODE_REPORT;
|
||||
ctx.transport_protocol_modes[HID_TRANSPORT_BLE] =
|
||||
@@ -547,14 +543,13 @@ static int do_stop(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ctx.mode_valid) {
|
||||
if (ctx.current_transport != HID_TRANSPORT_POLICY_NONE) {
|
||||
emit_release_reports(ctx.current_transport);
|
||||
}
|
||||
emit_function_state_event();
|
||||
|
||||
keyboard_state_clear();
|
||||
reports_cache_invalidate();
|
||||
ctx.mode_valid = false;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -625,8 +620,8 @@ static bool handle_transport_policy_event(
|
||||
return false;
|
||||
}
|
||||
|
||||
transport_changed =
|
||||
ctx.mode_valid && (ctx.current_transport != event->hid_transport);
|
||||
transport_changed = (ctx.current_transport != HID_TRANSPORT_POLICY_NONE) &&
|
||||
(ctx.current_transport != event->hid_transport);
|
||||
if (transport_changed) {
|
||||
emit_release_reports(ctx.current_transport);
|
||||
emit_function_state_event();
|
||||
@@ -635,9 +630,8 @@ static bool handle_transport_policy_event(
|
||||
}
|
||||
|
||||
ctx.current_transport = event->hid_transport;
|
||||
ctx.mode_valid = (ctx.current_transport != HID_TRANSPORT_POLICY_NONE);
|
||||
|
||||
if (ctx.mode_valid) {
|
||||
if (ctx.current_transport != HID_TRANSPORT_POLICY_NONE) {
|
||||
emit_all_reports(true);
|
||||
}
|
||||
|
||||
@@ -646,7 +640,8 @@ static bool handle_transport_policy_event(
|
||||
|
||||
static bool handle_encoder_event(const struct encoder_event *event)
|
||||
{
|
||||
if (!module_lifecycle_is_running(&ctx.lc) || !ctx.mode_valid) {
|
||||
if (!module_lifecycle_is_running(&ctx.lc) ||
|
||||
(ctx.current_transport == HID_TRANSPORT_POLICY_NONE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -701,7 +696,7 @@ static bool app_event_handler(const struct app_event_header *aeh)
|
||||
ctx.transport_protocol_modes[event->transport] =
|
||||
event->protocol_mode;
|
||||
|
||||
if (module_lifecycle_is_running(&ctx.lc) && ctx.mode_valid &&
|
||||
if (module_lifecycle_is_running(&ctx.lc) &&
|
||||
policy_to_transport(ctx.current_transport, &active_transport) &&
|
||||
(active_transport == event->transport)) {
|
||||
reports_cache_invalidate();
|
||||
@@ -731,7 +726,7 @@ static bool app_event_handler(const struct app_event_header *aeh)
|
||||
|
||||
ctx.settings_active = event->active;
|
||||
if (ctx.settings_active) {
|
||||
if (ctx.mode_valid) {
|
||||
if (ctx.current_transport != HID_TRANSPORT_POLICY_NONE) {
|
||||
emit_release_reports(ctx.current_transport);
|
||||
}
|
||||
emit_function_state_event();
|
||||
|
||||
Reference in New Issue
Block a user