2929extern " C" {
3030 #include " lwip/init.h"
3131 #include " lwip/err.h"
32+ #include " lwip/pbuf.h"
3233};
3334
3435class AsyncClient ;
@@ -37,14 +38,7 @@ class AsyncClient;
3738#define ASYNC_WRITE_FLAG_COPY 0x01 // will allocate new buffer to hold the data while sending (else will hold reference to the data given)
3839#define ASYNC_WRITE_FLAG_MORE 0x02 // will not send PSH flag, meaning that there should be more data to be sent before the application should react.
3940
40- typedef std::function<void (void *, AsyncClient*)> AcConnectHandler;
41- typedef std::function<void (void *, AsyncClient*, size_t len, uint32_t time)> AcAckHandler;
42- typedef std::function<void (void *, AsyncClient*, int8_t error)> AcErrorHandler;
43- typedef std::function<void (void *, AsyncClient*, void *data, size_t len)> AcDataHandler;
44- typedef std::function<void (void *, AsyncClient*, uint32_t time)> AcTimeoutHandler;
45-
4641struct tcp_pcb ;
47- struct pbuf ;
4842struct ip_addr ;
4943#if ASYNC_TCP_SSL_ENABLED
5044struct SSL_ ;
@@ -53,6 +47,13 @@ struct SSL_CTX_;
5347typedef struct SSL_CTX_ SSL_CTX;
5448#endif
5549
50+ typedef std::function<void (void *, AsyncClient*)> AcConnectHandler;
51+ typedef std::function<void (void *, AsyncClient*, size_t len, uint32_t time)> AcAckHandler;
52+ typedef std::function<void (void *, AsyncClient*, int8_t error)> AcErrorHandler;
53+ typedef std::function<void (void *, AsyncClient*, void *data, size_t len)> AcDataHandler;
54+ typedef std::function<void (void *, AsyncClient*, struct pbuf *pb)> AcPacketHandler;
55+ typedef std::function<void (void *, AsyncClient*, uint32_t time)> AcTimeoutHandler;
56+
5657class AsyncClient {
5758 protected:
5859 friend class AsyncTCPbuffer ;
@@ -67,6 +68,8 @@ class AsyncClient {
6768 void * _error_cb_arg;
6869 AcDataHandler _recv_cb;
6970 void * _recv_cb_arg;
71+ AcPacketHandler _pb_cb;
72+ void * _pb_cb_arg;
7073 AcTimeoutHandler _timeout_cb;
7174 void * _timeout_cb_arg;
7275 AcConnectHandler _poll_cb;
@@ -190,10 +193,13 @@ class AsyncClient {
190193 void onDisconnect (AcConnectHandler cb, void * arg = 0 ); // disconnected
191194 void onAck (AcAckHandler cb, void * arg = 0 ); // ack received
192195 void onError (AcErrorHandler cb, void * arg = 0 ); // unsuccessful connect or error
193- void onData (AcDataHandler cb, void * arg = 0 ); // data received
196+ void onData (AcDataHandler cb, void * arg = 0 ); // data received (called if onPacket is not used)
197+ void onPacket (AcPacketHandler cb, void * arg = 0 ); // data received
194198 void onTimeout (AcTimeoutHandler cb, void * arg = 0 ); // ack timeout
195199 void onPoll (AcConnectHandler cb, void * arg = 0 ); // every 125ms when connected
196200
201+ void ackPacket (struct pbuf * pb);
202+
197203 const char * errorToString (int8_t error);
198204 const char * stateToString ();
199205
0 commit comments