2026-04-15 10:23:12 +08:00
|
|
|
#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) ||
|
2026-04-24 10:54:14 +08:00
|
|
|
((data == NULL) && (len > 0U)) ||
|
|
|
|
|
(len > PROTO_MAX_FRAME_LEN)) {
|
2026-04-15 10:23:12 +08:00
|
|
|
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_ */
|