This commit is contained in:
cxh 2025-06-05 10:15:00 +08:00
parent dd9d15f48c
commit ec13c4d32b
2 changed files with 4 additions and 4 deletions

View File

@ -15,8 +15,8 @@ public:
void disconnect(); // 断开连接 void disconnect(); // 断开连接
// 让外部可以访问最新的 gear 和 speed // 让外部可以访问最新的 gear 和 speed
int getGear() const; int getGear();
double getSpeed() const; double getSpeed();
void checkTimeout(std::chrono::seconds timeout); void checkTimeout(std::chrono::seconds timeout);
private: private:

View File

@ -128,13 +128,13 @@ void MqttClient::checkTimeout(std::chrono::seconds timeout)
} }
} }
int MqttClient::getGear() const int MqttClient::getGear()
{ {
std::lock_guard<std::mutex> lock(dataMutex); std::lock_guard<std::mutex> lock(dataMutex);
return gear; return gear;
} }
double MqttClient::getSpeed() const double MqttClient::getSpeed()
{ {
std::lock_guard<std::mutex> lock(dataMutex); std::lock_guard<std::mutex> lock(dataMutex);
return speed; return speed;