#include #include #include #define COMMS_MAXMSG 64 struct pktbuf { uint8_t *pkt; uint16_t pktlen; }; /* first arg is input buffer, second arg is what will be sent as reply */ typedef void (*process_msgfunc_t)(struct pktbuf, struct pktbuf *); enum comm_state { COMMS_WAIT_REQUEST = 1, COMMS_WAIT_CONFIRM, COMMS_PROCESS_MSGS, }; struct comms_state { strobe_s cs_state; enum comm_state cs_comm_state; strobe_s cs_start; /* special starting state cache */ process_msgfunc_t cs_procmsg; struct pktbuf cs_prevmsg; struct pktbuf cs_prevmsgresp; uint8_t cs_prevmsgbuf[COMMS_MAXMSG]; uint8_t cs_prevmsgrespbuf[COMMS_MAXMSG]; }; size_t _strobe_state_size(); void comms_init(struct comms_state *, process_msgfunc_t, struct pktbuf *); void comms_process(struct comms_state *, struct pktbuf, struct pktbuf *);