forked from spacehuhn/PacketMonitor32
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Buffer.h
41 lines (32 loc) · 865 Bytes
/
Buffer.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
35
36
37
38
39
40
41
#ifndef Buffer_h
#define Buffer_h
#include "Arduino.h"
#include "FS.h"
#include "SD_MMC.h"
#define BUF_SIZE 24 * 1024
#define SNAP_LEN 2324 // max len of each recieved packet
extern bool useSD;
class Buffer {
public:
Buffer();
void open(fs::FS* fs);
void close(fs::FS* fs);
void addPacket(uint8_t* buf, uint32_t len);
void save(fs::FS* fs);
void forceSave(fs::FS* fs);
private:
void write(int32_t n);
void write(uint32_t n);
void write(uint16_t n);
void write(uint8_t* buf, uint32_t len);
uint8_t* bufA;
uint8_t* bufB;
uint32_t bufSizeA = 0;
uint32_t bufSizeB = 0;
bool writing = false; // acceppting writes to buffer
bool useA = true; // writing to bufA or bufB
bool saving = false; // currently saving onto the SD card
String fileName = "/0.pcap";
File file;
};
#endif