LTE-M Leaf Library
hl7800_udp.h
Go to the documentation of this file.
1 
9 #ifndef HL7800_UDP_H
10 #define HL7800_UDP_H
11 
12 #include "Arduino.h"
13 #include "common.h"
14 #include <Udp.h>
15 #include "IPAddress.h"
16 
17 #define MAX_HOSTNAME_SIZE 20
18 
19 class HL7800Udp : public UDP {
20 public:
21 // HL7800Udp(); // Constructor
22  virtual uint8_t begin(uint16_t);
23  virtual void stop(); // Finish with the UDP socket
24  virtual int beginPacket(IPAddress ip, uint16_t port);
25  virtual int beginPacket(const char *host, uint16_t port);
26  virtual int endPacket();
27  virtual size_t write(uint8_t);
28  virtual size_t write(const uint8_t *buffer, size_t size);
29  virtual int parsePacket();
30  virtual int available();
31  virtual int read();
32  virtual int read(unsigned char* buffer, size_t len);
33  virtual int read(char* buffer, size_t len) { return read((unsigned char*)buffer, len); };
34  virtual int peek();
35  virtual void flush(); // Finish reading the current packet
36  virtual IPAddress remoteIP() { return _remoteIP; };
37  virtual uint16_t remotePort() { return _remotePort; };
38 
39 private:
40  char cmd[20];
41 // uint8_t _sock; // socket ID for Wiz5100
42  uint16_t _port; // local port to listen on
43  IPAddress _remoteIP; // remote IP address for the incoming packet whilst it's being processed
44  uint16_t _remotePort; // remote port for the incoming packet whilst it's being processed
45  uint16_t _offset; // offset into the packet being sent
46  uint16_t _remaining; // remaining bytes of incoming packet yet to be processed
47 
48  char _targetHost[MAX_HOSTNAME_SIZE];
49  IPAddress _targetIP;
50  uint16_t _targetPort;
51  bool _validHost;
52  bool _validIP;
53 
54 };
55 
56 #endif // HL7800_UDP_H
HL7800Udp::peek
virtual int peek()
Definition: hl7800_udp.cpp:375
HL7800Udp::read
virtual int read()
Definition: hl7800_udp.cpp:342
HL7800Udp::beginPacket
virtual int beginPacket(IPAddress ip, uint16_t port)
Definition: hl7800_udp.cpp:105
HL7800Udp::write
virtual size_t write(uint8_t)
Definition: hl7800_udp.cpp:175
HL7800Udp
Definition: hl7800_udp.h:19
HL7800Udp::stop
virtual void stop()
Definition: hl7800_udp.cpp:80
HL7800Udp::endPacket
virtual int endPacket()
Definition: hl7800_udp.cpp:151
HL7800Udp::flush
virtual void flush()
Definition: hl7800_udp.cpp:385
HL7800Udp::begin
virtual uint8_t begin(uint16_t)
Definition: hl7800_udp.cpp:38
HL7800Udp::available
virtual int available()
Definition: hl7800_udp.cpp:331