proto.h 739 B

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. * File: proto.h
  3. * Author: ThuHien
  4. *
  5. * Created on November 23, 2012, 8:57 AM
  6. */
  7. #ifndef _PROTO_H_
  8. #define _PROTO_H_
  9. #include "typedef.h"
  10. #include "ringbuf.h"
  11. typedef void(PROTO_PARSE_CALLBACK)();
  12. typedef struct{
  13. U8 *buf;
  14. U16 bufSize;
  15. U16 dataLen;
  16. U8 isEsc;
  17. U8 isBegin;
  18. PROTO_PARSE_CALLBACK* callback;
  19. }PROTO_PARSER;
  20. I8 PROTO_Init(PROTO_PARSER *parser, PROTO_PARSE_CALLBACK *completeCallback, U8 *buf, U16 bufSize);
  21. I8 PROTO_Parse(PROTO_PARSER *parser, U8 *buf, U16 len);
  22. I16 PROTO_Add(U8 *buf, const U8 *packet, I16 bufSize);
  23. I16 PROTO_AddRb(RINGBUF *rb, const U8 *packet, I16 len);
  24. I8 PROTO_ParseByte(PROTO_PARSER *parser, U8 value);
  25. I16 PROTO_ParseRb(RINGBUF *rb, U8 *bufOut, U16* len, U16 maxBufLen);
  26. #endif