RedFlyClient.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef REDFLYCLIENT_h
  2. #define REDFLYCLIENT_h
  3. #include <inttypes.h>
  4. #if (defined(__AVR__) || defined(ARDUINO_ARCH_AVR))
  5. # include <avr/pgmspace.h>
  6. #endif
  7. #include "Print.h"
  8. #include "RedFly.h"
  9. #include "Server.h"
  10. class RedFlyClient : public Server
  11. {
  12. public:
  13. RedFlyClient(void);
  14. RedFlyClient(uint8_t socket);
  15. RedFlyClient(uint8_t *ip, uint16_t port);
  16. RedFlyClient(uint8_t *ip, uint16_t port, uint16_t lport);
  17. ~RedFlyClient(void);
  18. virtual void begin(void); //same as connect()
  19. virtual void beginUDP(void); //same as connect()
  20. virtual int connect(void);
  21. virtual int connectUDP(void);
  22. virtual int connect(uint8_t *ip, uint16_t port);
  23. virtual int connectUDP(uint8_t *ip, uint16_t port);
  24. virtual int connect(uint8_t *ip, uint16_t port, uint16_t lport);
  25. virtual int connectUDP(uint8_t *ip, uint16_t port, uint16_t lport);
  26. virtual int connect(char *host, uint16_t port);
  27. virtual int connectUDP(char *host, uint16_t port);
  28. int connectSocket(uint8_t p);
  29. virtual uint8_t connected(void);
  30. virtual void stop(void);
  31. uint8_t status(void);
  32. uint8_t getsocket(void);
  33. virtual int available(void);
  34. virtual int read(void);
  35. virtual int read(uint8_t *s, size_t sz);
  36. //virtual int peek(void); //not available
  37. virtual void flush(void);
  38. virtual size_t write(uint8_t b);
  39. virtual size_t write(const char *s);
  40. virtual size_t write(const uint8_t *s, size_t sz);
  41. virtual size_t print_P(PGM_P s);
  42. virtual size_t println_P(PGM_P s);
  43. virtual operator bool();
  44. using Print::write;
  45. private:
  46. uint8_t c_socket;
  47. uint8_t c_ip[4];
  48. uint16_t c_port;
  49. uint16_t c_lport;
  50. uint8_t proto, error;
  51. };
  52. #endif //REDFLYCLIENT_h