调试修改MQTT通讯解析

This commit is contained in:
lixiaoyuan
2025-09-16 19:38:46 +08:00
parent 9377e7f8e6
commit 393f68aec9
25 changed files with 943 additions and 1428 deletions

View File

@@ -8,22 +8,6 @@
class Station;
struct REGInfo
{
std::string key;
std::string datatype;
int bytes {0};
std::string remark;
int ratio {1};
REGInfo() {}
REGInfo(std::string key, std::string datatype, std::string remark)
: key(key), datatype(datatype), remark(remark)
{
if (datatype == "uint16" || datatype == "int16") { bytes = 1; }
else if (datatype == "uint32" || datatype == "int32") { bytes = 2; }
}
};
struct TopicInfo
{
@@ -41,8 +25,6 @@ using namespace std;
class MqttClient
{
public:
static void loadDataStruct(std::string filename);
int init(string addr, string clientId, string username, string password);
void destory();
@@ -51,13 +33,13 @@ public:
int polling();
void onConnectionLost(char* cause);
int onMessageArrived(char* topic, int len, MQTTAsync_message* msg);
void onDeliveryComplete(MQTTAsync_token token);
void onConnectSuccess(MQTTAsync_successData* resp);
void onConnectFaiure(MQTTAsync_failureData* resp);
void parseEMS_YX(std::shared_ptr<Station> station, njson& json, std::map<std::string, REGInfo>& mapRegInfo);
int onMessageArrived(char* topic, int len, MQTTAsync_message* msg);
void ParseArrivedMessage(njson& json, string clientId, string command, std::shared_ptr<Station> station);
public:
// MQTT clientId (使用station 的 code)