forked from xiaozhi/xiaozhi-esp32
fixbug: getting empty value
This commit is contained in:
@@ -39,7 +39,6 @@ bool MqttProtocol::StartMqttClient() {
|
||||
client_id_ = settings.GetString("client_id");
|
||||
username_ = settings.GetString("username");
|
||||
password_ = settings.GetString("password");
|
||||
subscribe_topic_ = settings.GetString("subscribe_topic");
|
||||
publish_topic_ = settings.GetString("publish_topic");
|
||||
|
||||
if (endpoint_.empty()) {
|
||||
@@ -92,9 +91,6 @@ bool MqttProtocol::StartMqttClient() {
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Connected to endpoint");
|
||||
if (!subscribe_topic_.empty()) {
|
||||
mqtt_->Subscribe(subscribe_topic_, 2);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ private:
|
||||
std::string client_id_;
|
||||
std::string username_;
|
||||
std::string password_;
|
||||
std::string subscribe_topic_;
|
||||
std::string publish_topic_;
|
||||
|
||||
std::mutex channel_mutex_;
|
||||
|
||||
@@ -31,7 +31,7 @@ std::string Settings::GetString(const std::string& key, const std::string& defau
|
||||
std::string value;
|
||||
value.resize(length);
|
||||
ESP_ERROR_CHECK(nvs_get_str(nvs_handle_, key.c_str(), value.data(), &length));
|
||||
while (value.back() == '\0') {
|
||||
while (!value.empty() && value.back() == '\0') {
|
||||
value.pop_back();
|
||||
}
|
||||
return value;
|
||||
|
||||
Reference in New Issue
Block a user