2020-10-05 19:42:31 +02:00
|
|
|
#ifndef WifiInboundHandler_h
|
|
|
|
#define WifiInboundHandler_h
|
|
|
|
|
2020-10-13 18:37:40 +02:00
|
|
|
#include "RingStream.h"
|
2020-10-26 14:31:51 +01:00
|
|
|
#include "WiThrottle.h"
|
2020-10-05 19:42:31 +02:00
|
|
|
#include "DIAG.h"
|
|
|
|
|
|
|
|
class WifiInboundHandler {
|
|
|
|
public:
|
|
|
|
static void setup(Stream * ESStream);
|
|
|
|
static void loop();
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
static WifiInboundHandler * singleton;
|
|
|
|
|
2020-10-13 18:37:40 +02:00
|
|
|
|
2021-01-27 17:58:42 +01:00
|
|
|
enum INBOUND_STATE : byte {
|
2020-10-05 19:42:31 +02:00
|
|
|
INBOUND_BUSY, // keep calling in loop()
|
|
|
|
INBOUND_IDLE // Nothing happening, outbound may xcall CIPSEND
|
|
|
|
};
|
|
|
|
|
2021-01-27 17:58:42 +01:00
|
|
|
enum LOOP_STATE : byte {
|
2020-10-05 19:42:31 +02:00
|
|
|
ANYTHING, // ready for +IPD, n CLOSED, n CONNECTED, busy etc...
|
|
|
|
SKIPTOEND, // skip to newline
|
|
|
|
|
|
|
|
// +IPD,client,length:data
|
|
|
|
IPD, // got +
|
|
|
|
IPD1, // got +I
|
|
|
|
IPD2, // got +IP
|
|
|
|
IPD3, // got +IPD
|
|
|
|
IPD4_CLIENT, // got +IPD, reading cient id
|
|
|
|
IPD5, // got +IPD,c
|
|
|
|
IPD6_LENGTH, // got +IPD,c, reading length
|
|
|
|
IPD_DATA, // got +IPD,c,ll,: collecting data
|
2020-10-26 13:59:40 +01:00
|
|
|
IPD_IGNORE_DATA, // got +IPD,c,ll,: ignoring the data that won't fit inblound Ring
|
2020-10-05 19:42:31 +02:00
|
|
|
|
|
|
|
GOT_CLIENT_ID, // clientid prefix to CONNECTED / CLOSED
|
2020-11-05 11:53:55 +01:00
|
|
|
GOT_CLIENT_ID2 // clientid prefix to CONNECTED / CLOSED
|
2020-10-05 19:42:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
WifiInboundHandler(Stream * ESStream);
|
|
|
|
void loop1();
|
|
|
|
INBOUND_STATE loop2();
|
2020-10-27 13:33:01 +01:00
|
|
|
void purgeCurrentCIPSEND();
|
2020-10-05 19:42:31 +02:00
|
|
|
Stream * wifiStream;
|
|
|
|
|
2020-10-26 13:59:40 +01:00
|
|
|
static const int INBOUND_RING = 512;
|
|
|
|
static const int OUTBOUND_RING = 2048;
|
2020-10-13 18:37:40 +02:00
|
|
|
|
|
|
|
RingStream * inboundRing;
|
|
|
|
RingStream * outboundRing;
|
|
|
|
|
2020-10-05 19:42:31 +02:00
|
|
|
LOOP_STATE loopState=ANYTHING;
|
|
|
|
int runningClientId; // latest client inbound processing data or CLOSE
|
|
|
|
int dataLength; // dataLength of +IPD
|
|
|
|
int clientPendingCIPSEND=-1;
|
2020-10-13 18:37:40 +02:00
|
|
|
int currentReplySize;
|
|
|
|
bool pendingCipsend;
|
2020-10-05 19:42:31 +02:00
|
|
|
};
|
|
|
|
#endif
|