In the main loop, I discovered some kind of an "indent-problem". Code of a block
if ..{} ... else { ... } foo
went to
if ..{} ... else { ...; foo }
$ diff LightAPRS-W-pico-balloon.ino.orig LightAPRS-W-pico-balloon-fix.ino
303,311c303,311
< freeMem();
< Serial.flush();
< //If two minutes time slot is close, sleep less than default.
< if (timeStatus() == timeSet && ((minute() % 10 == 2) || (minute() % 10 == 6))){
< sleepSeconds(60 - second());
< } else {
< sleepSeconds(BeaconWait);
< }
<
---
> }
>
> freeMem();
> Serial.flush();
> //If two minutes time slot is close, sleep less than default.
> if (timeStatus() == timeSet && ((minute() % 10 == 2) || (minute() % 10 == 6))){
> sleepSeconds(60 - second());
> } else {
> sleepSeconds(BeaconWait);
freeMem() and Serial.flush had moved to the aprs-section (instead of applying for both, aprs and wspr).
Thus, the timeslot-check (minute 2 and 6) for aprs is inside the aprs routine after we sent the packet.
That also means, if we had a WSPR transmission in the loop (and so we are not in the aprs block), we do no sleep at all.
You could see the problem better in the following part, where I deleted most of the code in between tha {}:
void loop() {
if (readBatt() > BattMin) {
...
if ((gps.location.age() < 1000 || gps.location.isUpdated()) && gps.location.isValid()) {
if (gps.satellites.isValid() && gps.satellites.value() >= 3) {
Serial.println(F("Before WSPR Check"));
// preparations for HF starts one minute before TX time at minute 3, 7, 13, 17, 23, 27, 33, 37, 43, 47, 53 or 57. No APRS TX during this period...
if (readBatt() > WsprBattMin && timeStatus() == timeSet && ((minute() % 10 == 3) || (minute() % 10 == 7)) ) {
...
[WSPR transmission here]
HFSent = true;
} else {
//APRS frequency isn't the same for the whole world. (for pico balloon only)
...
..
if (isAirborneAPRSAllowed()) {
sendLocation();
}
freeMem();
Serial.flush();
//If two minutes time slot is close, sleep less than default.
if (timeStatus() == timeSet && ((minute() % 10 == 2) || (minute() % 10 == 6))){
sleepSeconds(60 - second());
} else {
sleepSeconds(BeaconWait);
}
}
} else {
#if defined(DEVMODE)
Serial.println(F("Not enough sattelites"));
#endif
}
}
} else {
sleepSeconds(BattWait);
}
In the main loop, I discovered some kind of an "indent-problem". Code of a block if ..{} ... else { ... } foo went to if ..{} ... else { ...; foo }
freeMem() and Serial.flush had moved to the aprs-section (instead of applying for both, aprs and wspr). Thus, the timeslot-check (minute 2 and 6) for aprs is inside the aprs routine after we sent the packet.
That also means, if we had a WSPR transmission in the loop (and so we are not in the aprs block), we do no sleep at all.
You could see the problem better in the following part, where I deleted most of the code in between tha {}: