Buffer.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #ifndef Buffer_h
  2. #define Buffer_h
  3. #include "Arduino.h"
  4. #include "FS.h"
  5. #include "settings.h"
  6. //#include "SD_MMC.h"
  7. #define BUF_SIZE 3 * 1024 // Had to reduce buffer size to save RAM. GG @spacehuhn
  8. #define SNAP_LEN 2324 // max len of each recieved packet
  9. //extern bool useSD;
  10. extern Settings settings_obj;
  11. class Buffer {
  12. public:
  13. Buffer();
  14. void open(fs::FS* fs, String fn = "");
  15. void close(fs::FS* fs);
  16. void addPacket(uint8_t* buf, uint32_t len);
  17. void save(fs::FS* fs);
  18. void forceSave(fs::FS* fs);
  19. private:
  20. void write(int32_t n);
  21. void write(uint32_t n);
  22. void write(uint16_t n);
  23. void write(uint8_t* buf, uint32_t len);
  24. uint8_t* bufA;
  25. uint8_t* bufB;
  26. uint32_t bufSizeA = 0;
  27. uint32_t bufSizeB = 0;
  28. bool writing = false; // acceppting writes to buffer
  29. bool useA = true; // writing to bufA or bufB
  30. bool saving = false; // currently saving onto the SD card
  31. String fileName = "/0.pcap";
  32. File file;
  33. };
  34. #endif