Skip to content

Commit

Permalink
Fix SETPLACE command
Browse files Browse the repository at this point in the history
  • Loading branch information
not7cd committed Apr 11, 2019
1 parent 13fa07a commit b77e5e8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions 3rdparty/indi-starbook/command_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ namespace starbook {

ResponseCode CommandInterface::SetPlace(LnLat posn, int tz) {
std::ostringstream cmd;
if (tz > 24 || tz < -24)
throw std::domain_error("timezone should be between -24 and 24");
if (tz > 12 || tz < -12)
throw std::domain_error("timezone should be between -12 and 12");
cmd << "SETPLACE?" << posn
<< "&timezone="
<< std::setfill('0') << std::setw(2) << tz;
<< tz;
return SendOkCommand(cmd.str());
}

Expand Down
6 changes: 6 additions & 0 deletions 3rdparty/indi-starbook/indi_starbook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,13 @@ bool StarbookDriver::updateLocation(double latitude, double longitude, double el
LOGF_WARN("Can't update location in %s state", starbook::STATE_TO_STR.at(last_known_state).c_str());
return false;
}
if (TimeT[1].text == nullptr) {
LOG_WARN("Can't update location before time");
return false;
}

auto utc_offset = static_cast<int>(std::floor(std::strtof(TimeT[1].text, nullptr)));
LOGF_DEBUG("UTC offset for location: %i", utc_offset);
starbook::LnLat posn(latitude, longitude);
starbook::ResponseCode rc = cmd_interface->SetPlace(posn, utc_offset);
LogResponse("Updating location", rc);
Expand Down

0 comments on commit b77e5e8

Please sign in to comment.