MQTTInterface.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * MQTTInterface.h
  3. *
  4. * Created on: 2020. 4. 29.
  5. * Author: https://github.com/eziya
  6. */
  7. #ifndef __MQTT_INTERFACE_H_
  8. #define __MQTT_INTERFACE_H_
  9. #include "cmsis_os.h"
  10. #define MQTT_LWIP_SOCKET //Use SOCKET API
  11. //#define MQTT_LWIP_NETCONN //Use NETCONN API
  12. typedef struct Timer Timer;
  13. struct Timer {
  14. unsigned long systick_period;
  15. unsigned long end_time;
  16. };
  17. typedef struct Network Network;
  18. struct Network
  19. {
  20. #ifdef MQTT_LWIP_SOCKET
  21. int socket;
  22. #elif defined(MQTT_LWIP_NETCONN)
  23. struct netconn *conn;
  24. struct netbuf *buf;
  25. int offset;
  26. #endif
  27. int (*mqttread) (Network*, unsigned char*, int, int);
  28. int (*mqttwrite) (Network*, unsigned char*, int, int);
  29. void (*disconnect) (Network*);
  30. };
  31. void InitTimer(Timer*);
  32. char TimerIsExpired(Timer*);
  33. void TimerCountdownMS(Timer*, unsigned int);
  34. void TimerCountdown(Timer*, unsigned int);
  35. int TimerLeftMS(Timer*);
  36. int net_read(Network*, unsigned char*, int, int);
  37. int net_write(Network*, unsigned char*, int, int);
  38. void net_disconnect(Network*);
  39. void NewNetwork(Network*);
  40. int ConnectNetwork(Network*, char*, int);
  41. #endif