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,
116#ifdef CONFIG_DAWN_IO_NOTIFY
124 }
typedef SProtoSimpleNotify;
127 uint8_t rxbuffer[FRAME_MAX_PAYLOAD + FRAME_MIN_LEN];
129 std::vector<SProtoSimpleIOBind *> iobinds;
130 std::vector<SProtoSimpleData *> iobuffers;
132#ifdef CONFIG_DAWN_IO_NOTIFY
133 std::mutex subsMutex;
134 std::set<SObjectId::ObjectId> subscriptions;
135 std::vector<SProtoSimpleNotify *> notifyContexts;
182#ifdef CONFIG_DAWN_IO_NOTIFY
189 int setupNotifications();
195 void cleanupNotifications();
201 void destroyNotifications();
211 static int notifierCb(
void *priv,
io_ddata_t *data);
223 virtual int sendFrame(uint8_t cmd,
const uint8_t *payload,
size_t len) = 0;
235 void sendError(uint8_t error_code, uint8_t context);
248 void cmdGetIO(
const uint8_t *payload,
size_t len);
257 void cmdSetIO(
const uint8_t *payload,
size_t len);
266 void cmdGetIOSeek(
const uint8_t *payload,
size_t len);
274 void cmdSetIOSeek(
const uint8_t *payload,
size_t len);
283 void cmdGetCfg(
const uint8_t *payload,
size_t len);
292 void cmdSetCfg(
const uint8_t *payload,
size_t len);
301 void cmdGetInfo(
const uint8_t *payload,
size_t len);
309#ifdef CONFIG_DAWN_IO_NOTIFY
317 void cmdSubscribe(
const uint8_t *payload,
size_t len);
326 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.