MQTTClient.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifndef _MQTTCLIENT_H
  2. #define _MQTTCLIENT_H
  3. #include "stdint.h"
  4. #define MQTT_SENDBUF_LENGTH 10 * 1024
  5. #define MQTT_RECVBUF_LENTH 512
  6. extern uint8_t mqtt_sendBuf[MQTT_SENDBUF_LENGTH];
  7. extern uint8_t mqtt_recvbuffer[MQTT_RECVBUF_LENTH];
  8. extern uint8_t mqtt_publishQos1_status;
  9. extern uint16_t mqtt_publishQos1_packid;
  10. extern uint8_t mqtt_publishQos2_status;
  11. extern uint16_t mqtt_publishQos2_packid;
  12. extern uint8_t mqtt_subscribe_status;
  13. extern uint16_t mqtt_subscribe_packid;
  14. extern uint8_t mqtt_unsubscribe_status;
  15. extern uint16_t mqtt_unsubscribe_packid;
  16. extern uint8_t mqtt_pingreq_status;
  17. extern uint16_t mqtt_recvPublishQos1_packid;
  18. extern uint16_t mqtt_recvPublishQos2_packid;
  19. uint16_t mqtt_getPacketId(void);
  20. int mqtt_connectToMqttServer(int sock);
  21. int mqtt_subscribeTopic(int sock, char *topic, int qos);
  22. int mqtt_subscribeTopic_SUBACK(uint8_t *pbuf, int buflen);
  23. int mqtt_unSubscribeTopic(int sock, char *topic);
  24. int mqtt_unSubscribeTopic_UNSUBACK(uint8_t *pbuf, int buflen);
  25. int mqtt_publishMessage_qos0(int sock, char *topic, uint8_t *msg, int msg_len);
  26. int mqtt_publishMessage_qos1(int sock, char *topic, uint8_t *msg, int msg_len);
  27. int mqtt_publishMessage_qos1_PUBACK(uint8_t *pbuf, int buflen);
  28. int mqtt_publishMessage_qos2_PUBREL(int sock, uint16_t id);
  29. int mqtt_publishMessage_qos2(int sock, char *topic, uint8_t *msg, int msg_len);
  30. int mqtt_publishMessage_qos2_PUBREC(uint8_t *pbuf, int buflen);
  31. int mqtt_publishMessage_qos2_PUBCOMP(uint8_t *pbuf, int buflen);
  32. int mqtt_recvPublishMessage_qos1_PUBACK(int sock, uint16_t id);
  33. int mqtt_recvPublishMessage_qos2_PUBREC(int sock, uint16_t id);
  34. int mqtt_recvPublishMessage_qos2_PUBREL(int sock, uint8_t *pbuf, int buflen);
  35. int mqtt_recvPublishMessage_qos2_PUBCOMP(int sock, uint16_t id);
  36. int mqtt_pingReq(int sock);
  37. int mqtt_pingResponse(void);
  38. void mqtt_disconnectServer(int sock);
  39. #endif