diff -uprN libindi.org/drivers/auxiliary/skysafari.cpp libindi/drivers/auxiliary/skysafari.cpp --- libindi.org/drivers/auxiliary/skysafari.cpp 2017-05-19 21:45:22.957186813 +0900 +++ libindi/drivers/auxiliary/skysafari.cpp 2017-05-19 21:53:30.035693243 +0900 @@ -432,6 +432,65 @@ void SkySafari::processCommand(std::stri // Try sending geographic coords if all is available sendGeographicCoords(); } + // set the number of hours added to local time to yield UTC + else if (cmd.compare(0, 2, "SG") == 0) + { + int ofs; + if (sscanf (cmd.c_str(), "SG%d", &ofs) == 1) + { + ofs = -ofs; + DEBUGF(INDI::Logger::DBG_DEBUG, "UTC Offset: %d",ofs); + + timeUTCOffset = ofs; + haveUTCoffset = true; + } + + // Always respond with valid + sendSkySafari("1"); + + // Try sending geographic coords if all is available + sendUTCtimedate(); + } + // set the local time + else if (cmd.compare(0, 2, "SL") == 0) + { + int hh, mm, ss; + if (sscanf (cmd.c_str(), "SL%d:%d:%d", &hh, &mm, &ss) == 3) + { + DEBUGF(INDI::Logger::DBG_DEBUG, "TIME : %02d:%02d:%02d",hh, mm, ss); + + timeHour = hh; + timeMin = mm; + timeSec = ss; + haveUTCtime = true; + } + + // Always respond with valid + sendSkySafari("1"); + + // Try sending geographic coords if all is available + sendUTCtimedate(); + } + // set the local date + else if (cmd.compare(0, 2, "SC") == 0) + { + int yyyy, mm, dd; + if (sscanf (cmd.c_str(), "SC%d/%d/%d", &mm, &dd, &yyyy) == 3) + { + DEBUGF(INDI::Logger::DBG_DEBUG, "DATE : %02d-%02d-%02d",yyyy, mm, dd); + + timeYear = yyyy; + timeMonth = mm; + timeDay = dd; + haveUTCdate = true; + } + + // Always respond with valid + sendSkySafari("1"); + + // Try sending geographic coords if all is available + sendUTCtimedate(); + } // Get RA else if (cmd == "GR") { @@ -697,6 +756,45 @@ bool SkySafari::sendSkySafari(const char return true; } +void SkySafari::sendUTCtimedate() +{ + ITextVectorProperty *timeUTC = skySafariClient->getTimeUTC(); + if (timeUTC && haveUTCoffset && haveUTCtime && haveUTCdate) + { + int yyyy = timeYear; + if (yyyy < 100) yyyy += 2000; + + // local to UTC + ln_zonedate zonedate; + ln_date utcdate; + zonedate.years = yyyy; + zonedate.months = timeMonth; + zonedate.days = timeDay; + zonedate.hours = timeHour; + zonedate.minutes = timeMin; + zonedate.seconds = timeSec; + zonedate.gmtoff = timeUTCOffset*3600.0; + + ln_zonedate_to_date(&zonedate, &utcdate); + + char bufDT[32]; + char bufOff[8]; + + snprintf(bufDT, 32, "%04d-%02d-%02dT%02d:%02d:%02d", utcdate.years, utcdate.months, utcdate.days, utcdate.hours, utcdate.minutes, (int)(utcdate.seconds)); + snprintf(bufOff, 8, "%4.2f", timeUTCOffset); + + IUSaveText(IUFindText(timeUTC, "UTC"), bufDT); + IUSaveText(IUFindText(timeUTC, "OFFSET"), bufOff); + + DEBUGF(INDI::Logger::DBG_DEBUG, "send to timedate. %s, %s", bufDT, bufOff); + + skySafariClient->setTimeUTC(); + + // Reset + haveUTCoffset = haveUTCtime = haveUTCdate = false; + } +} + // Had to get this from stackoverlow, why C++ STL lacks such basic functionality?!!! template void SkySafari::split(const std::string &s, char delim, Out result) { diff -uprN libindi.org/drivers/auxiliary/skysafari.h libindi/drivers/auxiliary/skysafari.h --- libindi.org/drivers/auxiliary/skysafari.h 2017-05-19 21:45:22.957186813 +0900 +++ libindi/drivers/auxiliary/skysafari.h 2017-05-19 12:44:21.671976416 +0900 @@ -69,6 +69,7 @@ private: bool sendSkySafari(const char *message); void sendGeographicCoords(); + void sendUTCtimedate(); template void split(const std::string &s, char delim, Out result); std::vector split(const std::string &s, char delim); @@ -94,9 +95,12 @@ private: int lsocket=-1, clientFD=-1; bool isSkySafariConnected=false, haveLatitude=false, haveLongitude=false; + bool haveUTCoffset=false, haveUTCtime=false, haveUTCdate=false; double siteLatitude=0, siteLongitude=0; double RA=0, DE=0; + double timeUTCOffset=0; + int timeYear=0, timeMonth=0, timeDay=0, timeHour=0, timeMin=0, timeSec=0; }; #endif diff -uprN libindi.org/drivers/auxiliary/skysafariclient.cpp libindi/drivers/auxiliary/skysafariclient.cpp --- libindi.org/drivers/auxiliary/skysafariclient.cpp 2017-05-19 21:45:22.957186813 +0900 +++ libindi/drivers/auxiliary/skysafariclient.cpp 2017-05-19 10:33:28.306057861 +0900 @@ -81,8 +81,11 @@ void SkySafariClient::newProperty(INDI:: motionNSSP = property->getSwitch(); else if (!strcmp(property->getName(), "TELESCOPE_MOTION_WE")) motionWESP = property->getSwitch(); + else if (!strcmp(property->getName(), "TIME_UTC")) + timeUTC = property->getText(); } + /************************************************************************************** ** ***************************************************************************************/ @@ -224,3 +227,17 @@ bool SkySafariClient::setMotionWE() return true; } + +/************************************************************************************** +** +***************************************************************************************/ +bool SkySafariClient::setTimeUTC() +{ + if (timeUTC == nullptr) + return false; + + sendNewText(timeUTC); + + return true; +} + diff -uprN libindi.org/drivers/auxiliary/skysafariclient.h libindi/drivers/auxiliary/skysafariclient.h --- libindi.org/drivers/auxiliary/skysafariclient.h 2017-05-19 21:45:22.957186813 +0900 +++ libindi/drivers/auxiliary/skysafariclient.h 2017-05-19 21:49:57.186345921 +0900 @@ -58,6 +58,9 @@ public: ISwitchVectorProperty * getMotionWE() { return motionWESP;} bool setMotionWE(); + ITextVectorProperty * getTimeUTC() { return timeUTC;} + bool setTimeUTC(); + bool parkMount(); IPState getMountParkState(); @@ -93,6 +96,7 @@ private: ISwitchVectorProperty *slewRateSP=nullptr; ISwitchVectorProperty *motionNSSP=nullptr; ISwitchVectorProperty *motionWESP=nullptr; + ITextVectorProperty *timeUTC=nullptr; GotoMode mode = TRACK; };