mirror of
https://github.com/esphome/esphome.git
synced 2024-12-25 15:04:54 +01:00
fix some gnss isues
This commit is contained in:
parent
0b4d2cbe07
commit
67fb79a6e7
3 changed files with 82 additions and 88 deletions
|
@ -57,7 +57,7 @@ AtCommandResult ModemComponent::send_at(const std::string &cmd, uint32_t timeout
|
|||
if (this->modem_ready()) {
|
||||
ESP_LOGV(TAG, "Sending command: %s", cmd.c_str());
|
||||
status = this->dce->at(cmd, at_command_result.result, timeout);
|
||||
ESP_LOGV(TAG, "Result for command %s: %s (status %s)", cmd.c_str(), at_command_result.result.c_str(),
|
||||
ESP_LOGD(TAG, "Result for command %s: %s (status %s)", cmd.c_str(), at_command_result.result.c_str(),
|
||||
command_result_to_string(status).c_str());
|
||||
}
|
||||
if (status == command_result::OK) {
|
||||
|
@ -694,7 +694,7 @@ void ModemComponent::poweron_() {
|
|||
if (this->modem_ready()) {
|
||||
ESP_LOGV(TAG, "Modem is already ON");
|
||||
} else {
|
||||
ESP_LOGW(TAG, "No 'power_pin' defined: Not able to poweron the modem");
|
||||
ESP_LOGE(TAG, "No 'power_pin' defined: Not able to poweron the modem");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,6 +79,7 @@ std::map<std::string, std::string> get_gnssinfo_tokens(const std::string &gnss_i
|
|||
|
||||
if (data.find(",,,,,,") != std::string::npos) {
|
||||
ESP_LOGW(TAG, "No GNSS location available");
|
||||
return gnss_data; // empty
|
||||
}
|
||||
|
||||
std::vector<std::string> parts;
|
||||
|
@ -90,10 +91,6 @@ std::map<std::string, std::string> get_gnssinfo_tokens(const std::string &gnss_i
|
|||
}
|
||||
|
||||
switch (parts.size()) {
|
||||
case 15:
|
||||
parts.emplace_back("");
|
||||
// NOLINTNEXTLINE(bugprone-branch-clone)
|
||||
// fall through
|
||||
case 16:
|
||||
gnss_data["mode"] = parts[0];
|
||||
gnss_data["sat_used_count"] = parts[1];
|
||||
|
@ -114,10 +111,6 @@ std::map<std::string, std::string> get_gnssinfo_tokens(const std::string &gnss_i
|
|||
gnss_data["lon_lat_format"] = "DDMM.MM"; // decimal degrees, float minutes
|
||||
break;
|
||||
|
||||
case 17:
|
||||
parts.emplace_back("");
|
||||
// NOLINTNEXTLINE(bugprone-branch-clone)
|
||||
// fall through
|
||||
case 18:
|
||||
gnss_data["mode"] = parts[0];
|
||||
gnss_data["sat_used_count"] = parts[1];
|
||||
|
@ -154,10 +147,12 @@ std::map<std::string, std::string> get_gnssinfo_tokens(const std::string &gnss_i
|
|||
|
||||
void ModemSensor::update_gnss_sensors_() {
|
||||
if (this->gnss_latitude_sensor_ || this->gnss_longitude_sensor_ || this->gnss_altitude_sensor_) {
|
||||
std::map<std::string, std::string> parts;
|
||||
auto at_command_result = global_modem_component->send_at("AT+CGNSSINFO");
|
||||
if (at_command_result) {
|
||||
std::string gnss_info = at_command_result.result;
|
||||
std::map<std::string, std::string> parts = get_gnssinfo_tokens(gnss_info);
|
||||
parts = get_gnssinfo_tokens(gnss_info);
|
||||
}
|
||||
|
||||
float lat = NAN;
|
||||
float lon = NAN;
|
||||
|
@ -236,7 +231,6 @@ void ModemSensor::update_gnss_sensors_() {
|
|||
this->gnss_accuracy_sensor_->publish_state(hdop * 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace modem
|
||||
} // namespace esphome
|
||||
|
|
|
@ -32,7 +32,7 @@ using namespace esp_modem;
|
|||
static const char *const TAG = "modem.switch";
|
||||
|
||||
optional<bool> GnssSwitch::get_modem_gnss_state() {
|
||||
optional<bool> gnss_state;
|
||||
optional<bool> gnss_state = nullopt;
|
||||
auto at_command_result = global_modem_component->send_at(this->command_ + "?");
|
||||
if (at_command_result) {
|
||||
std::string modem_state = at_command_result.result;
|
||||
|
|
Loading…
Reference in a new issue