feat(ble): 添加BLE NUS模块替换原有的BLE串口功能

- 将ble_serial_module替换为ble_nus_module以使用标准的BLE NUS服务
- 移除不再使用的cdc_wrapper_module和相关事件处理
- 更新协议传输层抽象,支持USB CDC和BLE NUS两种传输方式
- 创建统一的proto_rx_event和proto_tx_event替代专用的串行通信事件
- 添加proto_common.h定义传输类型枚举
- 修改protocol_module接口以支持多传输方式
- 在prj.conf中启用CONFIG_BT_ZEPHYR_NUS配置选项
This commit is contained in:
2026-04-15 10:23:12 +08:00
parent c4b205b8a1
commit bc42a4dd63
25 changed files with 538 additions and 1499 deletions

View File

@@ -0,0 +1,50 @@
#ifndef BLINKY_PROTO_RX_EVENT_H_
#define BLINKY_PROTO_RX_EVENT_H_
#include <errno.h>
#include <stddef.h>
#include <string.h>
#include <app_event_manager.h>
#include <app_event_manager_profiler_tracer.h>
#include "proto_common.h"
#ifdef __cplusplus
extern "C" {
#endif
struct proto_rx_event {
struct app_event_header header;
enum proto_transport transport;
struct event_dyndata dyndata;
};
APP_EVENT_TYPE_DYNDATA_DECLARE(proto_rx_event);
static inline int submit_proto_rx_event(enum proto_transport transport,
const uint8_t *data, size_t len)
{
struct proto_rx_event *event;
if ((transport >= PROTO_TRANSPORT_COUNT) ||
((data == NULL) && (len > 0U))) {
return -EINVAL;
}
event = new_proto_rx_event(len);
event->transport = transport;
if (len > 0U) {
memcpy(event->dyndata.data, data, len);
}
APP_EVENT_SUBMIT(event);
return 0;
}
#ifdef __cplusplus
}
#endif
#endif /* BLINKY_PROTO_RX_EVENT_H_ */