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:
50
inc/events/proto_tx_event.h
Normal file
50
inc/events/proto_tx_event.h
Normal file
@@ -0,0 +1,50 @@
|
||||
#ifndef BLINKY_PROTO_TX_EVENT_H_
|
||||
#define BLINKY_PROTO_TX_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_tx_event {
|
||||
struct app_event_header header;
|
||||
enum proto_transport transport;
|
||||
struct event_dyndata dyndata;
|
||||
};
|
||||
|
||||
APP_EVENT_TYPE_DYNDATA_DECLARE(proto_tx_event);
|
||||
|
||||
static inline int submit_proto_tx_event(enum proto_transport transport,
|
||||
const uint8_t *data, size_t len)
|
||||
{
|
||||
struct proto_tx_event *event;
|
||||
|
||||
if ((transport >= PROTO_TRANSPORT_COUNT) ||
|
||||
((data == NULL) && (len > 0U))) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
event = new_proto_tx_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_TX_EVENT_H_ */
|
||||
Reference in New Issue
Block a user