sforkowany z mirror/meshtastic-firmware
set rtc from gps time
rodzic
67e0f5c184
commit
d9a875082c
1
TODO.md
1
TODO.md
|
@ -39,6 +39,7 @@ Items to complete before the first beta release.
|
|||
# Low power consumption tasks
|
||||
General ideas to hit the power draws our spreadsheet predicts. Do the easy ones before beta, the last 15% can be done after 1.0.
|
||||
|
||||
* (possibly bad idea - better to have lora radio always listen - check spreadsheet) have every node wake at the same tick and do their position syncs then go back to deep sleep
|
||||
* lower BT announce interval to save battery
|
||||
* change to use RXcontinuous mode and config to drop packets with bad CRC (see section 6.4 of datasheet) - I think this is already the case
|
||||
* have mesh service run in a thread that stays blocked until a packet arrives from the RF95
|
||||
|
|
27
src/GPS.cpp
27
src/GPS.cpp
|
@ -16,6 +16,15 @@ GPS::GPS() : PeriodicTask(30 * 1000)
|
|||
}
|
||||
|
||||
void GPS::setup()
|
||||
{
|
||||
readFromRTC();
|
||||
|
||||
#ifdef GPS_RX_PIN
|
||||
_serial_gps.begin(GPS_BAUDRATE, SERIAL_8N1, GPS_RX_PIN, GPS_TX_PIN);
|
||||
#endif
|
||||
}
|
||||
|
||||
void GPS::readFromRTC()
|
||||
{
|
||||
struct timeval tv; /* btw settimeofday() is helpfull here too*/
|
||||
|
||||
|
@ -27,10 +36,6 @@ void GPS::setup()
|
|||
timeStartMsec = now;
|
||||
zeroOffset = tv.tv_sec * 1000LL + tv.tv_usec / 1000LL;
|
||||
}
|
||||
|
||||
#ifdef GPS_RX_PIN
|
||||
_serial_gps.begin(GPS_BAUDRATE, SERIAL_8N1, GPS_RX_PIN, GPS_TX_PIN);
|
||||
#endif
|
||||
}
|
||||
|
||||
// for the time being we need to rapidly read from the serial port to prevent overruns
|
||||
|
@ -47,14 +52,18 @@ void GPS::loop()
|
|||
if (!timeSetFromGPS && time.isValid() && date.isValid())
|
||||
{
|
||||
timeSetFromGPS = true;
|
||||
timeStartMsec = millis();
|
||||
|
||||
struct timeval tv;
|
||||
|
||||
// FIXME, this is a shit not right version of the standard def of unix time!!!
|
||||
zeroOffset = 1000LL * (time.second() + time.minute() * 60 + time.hour() * 60 * 60 +
|
||||
24 * 60 * 60 * (date.month() * 31 + date.day() + 365 * (date.year() - 1970))) +
|
||||
time.centisecond() * 10;
|
||||
tv.tv_sec = time.second() + time.minute() * 60 + time.hour() * 60 * 60 +
|
||||
24 * 60 * 60 * (date.month() * 31 + date.day() + 365 * (date.year() - 1970));
|
||||
|
||||
DEBUG_MSG("Setting time zero %lld\n", zeroOffset);
|
||||
tv.tv_usec = time.centisecond() * (10 / 1000);
|
||||
|
||||
DEBUG_MSG("Setting RTC %ld secs\n", tv.tv_sec);
|
||||
settimeofday(&tv, NULL);
|
||||
readFromRTC();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -24,6 +24,9 @@ public:
|
|||
virtual void loop();
|
||||
|
||||
virtual void doTask();
|
||||
|
||||
private:
|
||||
void readFromRTC();
|
||||
};
|
||||
|
||||
extern GPS gps;
|
||||
|
|
|
@ -43,8 +43,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
// Select which board is being used. If the outside build environment has sent a choice, just use that
|
||||
#if !defined(T_BEAM_V10) && !defined(HELTEC_LORA32)
|
||||
//#define T_BEAM_V10 // AKA Rev1 (second board released)
|
||||
#define HELTEC_LORA32
|
||||
#define T_BEAM_V10 // AKA Rev1 (second board released)
|
||||
//#define HELTEC_LORA32
|
||||
|
||||
#define HW_VERSION_US // We encode the hardware freq range in the hw version string, so sw update can eventually install the correct build
|
||||
#endif
|
||||
|
|
Ładowanie…
Reference in New Issue