terminator_emqx.h 905 B

123456789101112131415161718192021222324252627282930313233343536
  1. //
  2. // Created by zx on 23-4-11.
  3. //
  4. #ifndef NAVIGATION_TERMINATOR_EMQX_H
  5. #define NAVIGATION_TERMINATOR_EMQX_H
  6. #include <mutex>
  7. #include "paho_client.h"
  8. typedef void (*NavStatuCallback)(const NavMessage::NavStatu& statu,void* context);
  9. class Terminator_emqx {
  10. public:
  11. Terminator_emqx(std::string nodeId,std::string pubTopic,std::string subTopic);
  12. ~Terminator_emqx();
  13. bool Connect(std::string ip,int port);
  14. void set_statu_arrived(NavStatuCallback callback,void* context);
  15. void SendNavCmd(const NavMessage::NavCmd& cmd);
  16. protected:
  17. NavStatuCallback StatuArrivedCallback_;
  18. static void StatuArrivedCallback(std::string topic,int QOS,MqttMsg& msg,void* context);
  19. std::mutex mtx_;
  20. Paho_client* client_;
  21. void* context_;
  22. std::string nodeId_;
  23. std::string pubTopic_;
  24. std::string subTopic_;
  25. public:
  26. MqttMsg msg_;
  27. };
  28. #endif //NAVIGATION_TERMINATOR_EMQX_H