调试预制舱通讯协议修改数据解析

This commit is contained in:
lixiaoyuan
2025-09-18 20:12:46 +08:00
parent cec5cdc19a
commit 2ba4ab2781
28 changed files with 363415 additions and 662 deletions

View File

@@ -7,14 +7,13 @@
#include "common/JsonN.h"
class Station;
class Device;
struct TopicInfo
{
std::string name;
int deviceType {0};
int polling {0}; // 召测
int enabled {1};
TopicInfo() {};
TopicInfo(std::string name, int deviceType, int polling=0)
:name(name), deviceType(deviceType), polling(polling)
@@ -26,8 +25,6 @@ using namespace std;
class MqttClient
{
public:
static bool load(std::string filename);
int init(string addr, string clientId, string username, string password);
void destory();
@@ -42,8 +39,7 @@ public:
void onConnectFaiure(MQTTAsync_failureData* resp);
int onMessageArrived(char* topic, int len, MQTTAsync_message* msg);
void ParseArrivedMessage(njson& json, string command, std::shared_ptr<Station> station);
void ParseMessageCharge(njson& json, string command, std::shared_ptr<Station> station, std::shared_ptr<Device> device);
void ParseArrivedMessage(njson& json, string clientId, string command, std::shared_ptr<Station> station);
public:
// MQTT clientId (使用station 的 code)
@@ -55,7 +51,7 @@ public:
bool isConnected {false};
bool isSubscribed {false};
static std::map<std::string, TopicInfo> s_mapTopicInfo;
std::map<std::string, TopicInfo> mapTopicInfo;
};
@@ -75,3 +71,12 @@ public:
#define TOPIC_PCS_YC "up/json/预制舱01/PCS_YC"
#define TOPIC_PCS_YC "up/json/预制舱01/PCS_YC"
class MQTT
{
public:
public:
static string pack(std::string name);
};