1234567891011121314151617181920212223242526272829303132333435363738 |
- //
- // Created by zx on 23-4-11.
- //
- #ifndef NAVIGATION_TERMINATOR_EMQX_H
- #define NAVIGATION_TERMINATOR_EMQX_H
- #include <mutex>
- #include "paho_client.h"
- typedef void (*Callback)(const MqttMsg& msg,void* context);
- typedef struct{
- Callback func;
- void* contextx;
- }CallBackInfo;
- class Terminator_emqx {
- public:
- Terminator_emqx(std::string nodeId);
- ~Terminator_emqx();
- bool Connect(std::string ip,int port);
- bool AddCallback(std::string topic,Callback callback,void* context);
- void Publish(std::string topic,const MqttMsg& statu);
- protected:
- static void StatuArrivedCallback(std::string topic,int QOS,MqttMsg& msg,void* context);
- std::mutex mtx_;
- Paho_client* client_;
- bool connected_;
- std::string nodeId_;
- public:
- std::map<std::string,CallBackInfo> sub_topic_callbacks_;
- };
- #endif //NAVIGATION_TERMINATOR_EMQX_H
|