pfodParser  3.61.0
The pfodParser library is handles commands sent from the Android pfodApp, pfodApp supports WiFi, BLE, Bluetooth and SMS connections
pfodESPBufferedClient.h
Go to the documentation of this file.
1 #ifndef pfodESPBufferedClient_h
2 #define pfodESPBufferedClient_h
13 #if defined (ESP32) || defined (ESP8266) || defined (ARDUINO_SAMD_NANO_33_IOT)
14 
15 #include "Stream.h"
16 #include "WiFiClient.h"
17 class pfodESPBufferedClient : public Stream {
18 
19  public:
20  pfodESPBufferedClient(); // default 1460 byte buffer and default send delay 10mS
21  pfodESPBufferedClient* connect(WiFiClient* _client);
22  virtual size_t write(uint8_t);
23  virtual size_t write(const uint8_t *buf, size_t size);
24  virtual int available();
25  virtual int availableForWrite();
26  virtual int read();
27  virtual int peek();
28  virtual void flush();
29  virtual void stop();
30  virtual uint8_t connected();
31  void setDebugStream(Print* out);
32  private:
33  WiFiClient* client;
34  void sendAfterDelay();
35  void forceSend();
36  size_t _write(uint8_t c);
37  static const unsigned long DEFAULT_SEND_DELAY_TIME = 10; // 10mS delay before sending buffer
38  //#define WIFICLIENT_MAX_PACKET_SIZE 1460
39  static const size_t DEFAULT_SEND_BUFFER_SIZE = 1460; //WIFICLIENT_MAX_PACKET_SIZE; // Max data size for standard TCP/IP packet
40  // at 57600 baud can read about 1152 bytes in 0.2sec so limit serial to <=57600 to prevent losing data
41  uint8_t sendBuffer[DEFAULT_SEND_BUFFER_SIZE]; //
42  size_t sendBufferIdx = 0;
43  unsigned long sendTimerStart = 0;
44  unsigned long sendDelayTime;
45  Print* debugOut;
46 };
47 
48 #endif
49 
50 #endif // pfodESPBufferedClient_h