29
29
extern " C" {
30
30
#include " lwip/init.h"
31
31
#include " lwip/err.h"
32
+ #include " lwip/pbuf.h"
32
33
};
33
34
34
35
class AsyncClient ;
@@ -37,14 +38,7 @@ class AsyncClient;
37
38
#define ASYNC_WRITE_FLAG_COPY 0x01 // will allocate new buffer to hold the data while sending (else will hold reference to the data given)
38
39
#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.
39
40
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
-
46
41
struct tcp_pcb ;
47
- struct pbuf ;
48
42
struct ip_addr ;
49
43
#if ASYNC_TCP_SSL_ENABLED
50
44
struct SSL_ ;
@@ -53,6 +47,13 @@ struct SSL_CTX_;
53
47
typedef struct SSL_CTX_ SSL_CTX;
54
48
#endif
55
49
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
+
56
57
class AsyncClient {
57
58
protected:
58
59
friend class AsyncTCPbuffer ;
@@ -67,6 +68,8 @@ class AsyncClient {
67
68
void * _error_cb_arg;
68
69
AcDataHandler _recv_cb;
69
70
void * _recv_cb_arg;
71
+ AcPacketHandler _pb_cb;
72
+ void * _pb_cb_arg;
70
73
AcTimeoutHandler _timeout_cb;
71
74
void * _timeout_cb_arg;
72
75
AcConnectHandler _poll_cb;
@@ -190,10 +193,13 @@ class AsyncClient {
190
193
void onDisconnect (AcConnectHandler cb, void * arg = 0 ); // disconnected
191
194
void onAck (AcAckHandler cb, void * arg = 0 ); // ack received
192
195
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
194
198
void onTimeout (AcTimeoutHandler cb, void * arg = 0 ); // ack timeout
195
199
void onPoll (AcConnectHandler cb, void * arg = 0 ); // every 125ms when connected
196
200
201
+ void ackPacket (struct pbuf * pb);
202
+
197
203
const char * errorToString (int8_t error);
198
204
const char * stateToString ();
199
205
0 commit comments