14#include "dawn/porting/config.hxx"
15#include "dawn/proto/common.hxx"
37 static constexpr uint8_t FRAME_MIN_LEN = 6;
38 static constexpr size_t FRAME_MAX_PAYLOAD = 1024;
43 static constexpr size_t SEEK_CHUNK_CAP = FRAME_MAX_PAYLOAD -
SEEK_HDR_SIZE;
53 CMD_GET_IO_SEEK = 0x14,
54 CMD_SET_IO_SEEK = 0x15,
60 CMD_UNSUBSCRIBE = 0x31,
70 STATUS_INVALID_CMD = 0x01,
71 STATUS_INVALID_OBJ = 0x02,
72 STATUS_INVALID_CFG = 0x03,
73 STATUS_READ_ONLY = 0x04,
74 STATUS_WRITE_ONLY = 0x05,
75 STATUS_INVALID_FORMAT = 0x06,
83 IO_TYPE_READ_ONLY = 0x01,
84 IO_TYPE_WRITE_ONLY = 0x02,
85 IO_TYPE_READ_WRITE = 0x03,
117#ifdef CONFIG_DAWN_IO_NOTIFY
125 }
typedef SProtoSimpleNotify;
128 uint8_t rxbuffer[FRAME_MAX_PAYLOAD + FRAME_MIN_LEN];
130 std::vector<SProtoSimpleIOBind *> iobinds;
131 std::vector<SProtoSimpleData *> iobuffers;
133#ifdef CONFIG_DAWN_IO_NOTIFY
134 std::mutex subsMutex;
135 std::set<SObjectId::ObjectId> subscriptions;
136 std::vector<SProtoSimpleNotify *> notifyContexts;
183#ifdef CONFIG_DAWN_IO_NOTIFY
190 int setupNotifications();
196 void cleanupNotifications();
202 void destroyNotifications();
212 static int notifierCb(
void *priv,
io_ddata_t *data);
224 virtual int sendFrame(uint8_t cmd,
const uint8_t *payload,
size_t len) = 0;
236 void sendError(uint8_t error_code, uint8_t context);
249 void cmdGetIO(
const uint8_t *payload,
size_t len);
258 void cmdSetIO(
const uint8_t *payload,
size_t len);
267 void cmdGetIOSeek(
const uint8_t *payload,
size_t len);
275 void cmdSetIOSeek(
const uint8_t *payload,
size_t len);
284 void cmdGetCfg(
const uint8_t *payload,
size_t len);
293 void cmdSetCfg(
const uint8_t *payload,
size_t len);
302 void cmdGetInfo(
const uint8_t *payload,
size_t len);
310#ifdef CONFIG_DAWN_IO_NOTIFY
318 void cmdSubscribe(
const uint8_t *payload,
size_t len);
327 void cmdUnsubscribe(
const uint8_t *payload,
size_t len);
Descriptor wrapper for individual object configuration.
Base class for all I/O objects.
Base class for all protocol implementations.
Shared base for simple framed protocols.
CProtoSimpleBase(CDescObject &desc)
Constructor.
static uint8_t FRAME_SYNC
Frame structure constants.
void allocObject(SProtoSimpleIOBind *cfg)
Store an allocated IO binding.
uint16_t calculateCrc(const uint8_t *data, size_t len)
Calculate 16-bit CRC checksum.
int handleFrame(const uint8_t *frame, size_t len)
Process a received frame.
int createBuffers()
Allocate shared per-IO data buffers.
static size_t SEEK_HDR_SIZE
Seek response constants.
int destroyBuffers()
Destroy shared per-IO data buffers.
virtual int sendFrame(uint8_t cmd, const uint8_t *payload, size_t len)=0
Send a framed response via the derived transport.
Out-of-tree user-extension hooks for Dawn.
Internal I/O data mapping for simple protocol handlers.
Configuration for binding an I/O object to a simple protocol.
uint32_t ObjectId
ObjectID type - single 32-bit value.
Heap-allocated dynamic I/O data buffer.