- 新增docs/device_communication_protocol_v1.md文档,定义V1修订版协议 - CDC和BLE GATT均改为直接传输业务消息,去掉外层协议封装 - BLE改为使用NUS(Nordic UART Service)替代原有GATT服务 - 统一键盘位图为29字节格式,FunctionKeyEvent改为上报全键盘位图 - 顶层消息增加msg_id和reply_to字段用于请求响应匹配 - Ack和Error合并为统一Response消息类型 - CDC和NUS均增加统一外层帧格式:magic(2) + len(1) + protobuf - 添加Proto frame常量定义及长度验证逻辑 - 更新proto文件定义,包含DeviceMessage统一信封和ResponseCode枚举 - 重构hid_flowctrl_module.c中的上下文访问方式,统一使用ctx前缀
52 lines
969 B
C
52 lines
969 B
C
#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)) ||
|
|
(len > PROTO_MAX_FRAME_LEN)) {
|
|
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_ */
|