void ICACHE_FLASH_ATTR CMD_Init() { INFO("CMD: INIT\r\n"); RINGBUF_Init(&rxRb, rxBuf, sizeof(rxBuf)); PROTO_Init(&rxProto, protoCompletedCb, protoRxBuf, sizeof(protoRxBuf)); system_os_task(CMD_Task, CMD_TASK_PRIO, cmdRecvQueue, CMD_TASK_QUEUE_SIZE); system_os_post(CMD_TASK_PRIO, 0, 0); }
I16 PROTO_ParseRb(RINGBUF* rb, U8 *bufOut, U16* len, U16 maxBufLen) { U8 c; PROTO_PARSER proto; PROTO_Init(&proto, NULL, bufOut, maxBufLen); while(RINGBUF_Get(rb, &c) == 0){ if(PROTO_ParseByte(&proto, c) == 0){ *len = proto.dataLen; return 0; } } return -1; }