-
Notifications
You must be signed in to change notification settings - Fork 0
/
circularBuffer.h
34 lines (29 loc) · 997 Bytes
/
circularBuffer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#ifndef __CIRCULAR_BUFFER_H__
#define __CIRCULAR_BUFFER_H__
#include <stdbool.h>
#include <time.h>
typedef struct {
time_t timestamp;
float bmp280_pressure;
int bmp280_temperature;
int htu21_temperature;
int htu21_humidity;
} tData;
typedef struct
{
int first;
int last;
int validItems;
tData *data;
int maxItems;
} circularQueue_t;
void queue_init(circularQueue_t *theQueue, tData data[], int maxItems);
bool queue_isEmpty(circularQueue_t *theQueue);
int queue_getNbItems(circularQueue_t *theQueue);
bool queue_putItem(circularQueue_t *theQueue, const tData *theItemValue);
bool queue_getItem(circularQueue_t *theQueue, tData *theItemValue);
bool queue_peekItem(circularQueue_t *theQueue, int index, tData *theItemValue);
void queue_print(circularQueue_t *theQueue);
char * queue_json(circularQueue_t *theQueue, char *buffer, int bufSize);
char * tData_json(tData * data, char* pBufferStart[], int *remainingSize);
#endif // __CIRCULAR_BUFFER_H__