SingingCat 0
application
packetbuffer.h
1#ifndef PACKETBUFFER_H
2#define PACKETBUFFER_H 1
3
4#define PACKETBUFFER_CC1101 1
5
6#define PACKETBUF_SIZE 270
7typedef struct cnw_packetbuf {
8 long recvstarted; // when did we start receiving? (for timeout)
9 int bytesinbuf; // how many valid bytes in buf atm?
10 char isvalid;
11 byte buf[PACKETBUF_SIZE];
13
14void packet_buf_init(const int num);
15void packet_init();
16// add a byte to the buffer
17// returns NEW length of buf or -1 on error (e.g. overflow)
18// if overflow - will reset itself!
19int packet_put_byte(const int num, const byte b);
20// returns 1 if there's a valid packet
21int packet_isvalid(const int num);
22void packet_mark_valid(const int num);
23// get pointer to the buffer of bytes (all bytes, not just payload)!)
24byte *packet_getbuf(const int num);
25int packet_getbytesinbuf(const int num);
26
27#endif
void packet_init()
initialize (reset, clear) all buffers
Definition: packetbuffer.c:52
int packet_put_byte(const int num, const byte b)
add a byte to a buffer
Definition: packetbuffer.c:78
void packet_mark_valid(const int num)
mark this buffer as containing a valid packet
Definition: packetbuffer.c:108
int packet_getbytesinbuf(const int num)
count bytes in the buffer
Definition: packetbuffer.c:158
byte * packet_getbuf(const int num)
get pointer to the contents of the buffer
Definition: packetbuffer.c:143
int packet_isvalid(const int num)
initialize (reset, clear) a given buffer
Definition: packetbuffer.c:125
void packet_buf_init(const int num)
initialize (reset, clear) a given buffer
Definition: packetbuffer.c:37