feat(keyboard): 添加蓝牙HID支持和电池状态事件
- 添加BLE相关模块:ble_adv_ctrl_module、ble_adv_uuid16、ble_bas_module、 ble_hid_module - 新增电池状态事件(bat_state_event)用于监控电池电量、充电状态 - 在多个事件中添加HID_TRANSPORT_BLE支持,包括hid_led_event、 set_protocol_event等 - 更新配置文件prj.conf以启用蓝牙功能、HID服务和设置系统 - 修改电池模块以计算并报告电池SOC百分比 - 集成CAF设置加载器以管理蓝牙配对信息
This commit is contained in:
27
inc/events/bat_state_event.h
Normal file
27
inc/events/bat_state_event.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef BLINKY_BAT_STATE_EVENT_H_
|
||||
#define BLINKY_BAT_STATE_EVENT_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <app_event_manager.h>
|
||||
#include <app_event_manager_profiler_tracer.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct bat_state_event {
|
||||
struct app_event_header header;
|
||||
uint8_t soc;
|
||||
bool charging;
|
||||
bool full;
|
||||
};
|
||||
|
||||
APP_EVENT_TYPE_DECLARE(bat_state_event);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BLINKY_BAT_STATE_EVENT_H_ */
|
||||
@@ -4,12 +4,15 @@
|
||||
#include <app_event_manager.h>
|
||||
#include <app_event_manager_profiler_tracer.h>
|
||||
|
||||
#include "keyboard_core.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct hid_led_event {
|
||||
struct app_event_header header;
|
||||
enum hid_transport transport;
|
||||
uint8_t led_bm;
|
||||
};
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ extern "C" {
|
||||
|
||||
struct set_protocol_event {
|
||||
struct app_event_header header;
|
||||
enum hid_transport transport;
|
||||
enum keyboard_protocol_mode protocol_mode;
|
||||
};
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@ enum hid_queue_policy {
|
||||
|
||||
enum hid_transport {
|
||||
HID_TRANSPORT_USB,
|
||||
HID_TRANSPORT_BLE,
|
||||
HID_TRANSPORT_COUNT,
|
||||
};
|
||||
|
||||
enum keyboard_consumer_control {
|
||||
|
||||
15
inc/settings_loader_def.h
Normal file
15
inc/settings_loader_def.h
Normal file
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Settings must be loaded after HIDS has registered its dynamic GATT
|
||||
* service and after BLE state is initialized.
|
||||
*/
|
||||
|
||||
const struct {} settings_loader_def_include_once;
|
||||
|
||||
#include <caf/events/module_state_event.h>
|
||||
|
||||
static inline void get_req_modules(struct module_flags *mf)
|
||||
{
|
||||
module_flags_set_bit(mf, MODULE_IDX(main));
|
||||
module_flags_set_bit(mf, MODULE_IDX(ble_hid_module));
|
||||
module_flags_set_bit(mf, MODULE_IDX(ble_state));
|
||||
}
|
||||
Reference in New Issue
Block a user