Skip to content

Commit a3929fc

Browse files
committed
Version 2.3.0.3, 2025-04-10
- Extended the allowed time difference between clocks to full Linux Epoch
1 parent 49c0be1 commit a3929fc

2 files changed

Lines changed: 27 additions & 19 deletions

File tree

src/javapskmail/Main.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
public class Main {
3535

3636
//VK2ETA: Based on "jpskmail 1.7.b";
37-
static String version = "3.3.0.2";
37+
static String version = "3.3.0.3";
3838
static String application = "jPskmail " + version;// Used to preset an empty status
39-
static String versionDate = "20250407";
39+
static String versionDate = "20250410";
4040
static String host = "localhost";
4141
static int port = 7322; //ARQ IP port
4242
static String xmlPort = "7362"; //XML IP port

src/javapskmail/RMsgObject.java

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -570,18 +570,19 @@ public String createBufferNoCRC(boolean allCharsToLowerCase, boolean forStorage)
570570
if (this.sendMyTime) {
571571
//Time data to be sent must be generated just before sending the message to minimise Tx timing errors as messages
572572
// can stay in the Tx queue for a while (multiple messages, busy with a message reception, etc...)
573-
Long myTime = System.currentTimeMillis() / 1000; //UTC time by definition
574-
myTime = myTime - ((Long) (myTime / 1000000L) * 1000000L); //Keep the last 6 digits representing seconds
573+
Long myTime = System.currentTimeMillis() / 1000; //UTC time in seconds by definition
574+
//Changed from last 6 digits of epoch to full epoch value to allow clocks to be widely off (anywhere between 1970 to 2038 at minimum)
575+
//myTime = myTime - ((Long) (myTime / 1000000L) * 1000000L); //Keep the last 6 digits representing seconds
575576
//int TxDelay = 0;
576577
//String TxDelayStr = Main.configuration.getPreference("TXDELAY", "0");
577578
//int dcdSecs = Integer.parseInt(Main.configuration.getPreference("DCD", "0"));
578579
//if (TxDelayStr.length() > 0) {
579580
// TxDelay = Integer.parseInt(TxDelayStr);
580581
//}
581582
myTime += (3); //DCD and TxDelay not used for RadioMsg
582-
String myTimeStr = ("0000000" + myTime.toString());
583-
myTimeStr = myTimeStr.substring(myTimeStr.length() - 6);
584-
txBuffer += "tim:" + myTimeStr + "\n";
583+
//String myTimeStr = ("0000000" + myTime.toString());
584+
//myTimeStr = myTimeStr.substring(myTimeStr.length() - 6);
585+
txBuffer += "tim:" + myTime + "\n";
585586
}
586587
if (allCharsToLowerCase) {
587588
txBuffer = txBuffer.toLowerCase(Locale.US);
@@ -759,10 +760,12 @@ public static RMsgObject extractMsgObjectFromString(String dataString, boolean w
759760
mMessage.picture = Bitmap.decodeFile(filePath + pictureFn);
760761
}
761762
} else if (group1.equals("tim")) {
762-
//We have a time synchronisation data, store it
763-
if (group2.length() == 6) { //6 digits?
763+
//We have a time synchronisation data, store it.
764+
//Now allows for full epoch value to be sent
765+
if (group2.length() >= 1) { //at least one digit
766+
//All digits and nothing else?
764767
boolean formatOk = true;
765-
for (int i = 0; i < 6; i++) {
768+
for (int i = 0; i < group2.length(); i++) {
766769
if (group2.charAt(i) < '0' || group2.charAt(i) > '9') {
767770
formatOk = false;
768771
break; //end of exercise
@@ -773,16 +776,21 @@ public static RMsgObject extractMsgObjectFromString(String dataString, boolean w
773776
if (Main.lastRsidTime > 0L) {
774777
//We have a recent RSID received time, store the delta time and
775778
// the provisional time server call sign for later processing
776-
Long timeRef = Long.parseLong(group2);
777-
Long timeHere = Main.lastRsidTime / 1000 - ((Long) (Main.lastRsidTime / 1000000000L) * 1000000L); //Keep the last 6 digits representing seconds
778-
Long deltaTime = timeRef - timeHere;
779-
//Wrap around if we passed a 100000 seconds threshold
780-
if (Math.abs(deltaTime) > 99998L) {
781-
deltaTime = deltaTime < 0L ? deltaTime + 1000000L : deltaTime - 1000000L;
779+
try {
780+
Long timeRef = Long.parseLong(group2);
781+
//Long timeHere = Main.lastRsidTime / 1000 - ((Long) (Main.lastRsidTime / 1000000000L) * 1000000L); //Keep the last 6 digits representing seconds
782+
//Long deltaTime = timeRef - timeHere;
783+
Long deltaTime = timeRef - Main.lastRsidTime / 1000;
784+
//Wrap around if we passed a 100000 seconds threshold
785+
//if (Math.abs(deltaTime) > 99998L) {
786+
// deltaTime = deltaTime < 0L ? deltaTime + 1000000L : deltaTime - 1000000L;
787+
//}
788+
Main.deviceToRefTimeCorrection = deltaTime;
789+
Main.refTimeSource = mMessage.from;
790+
mMessage.sms = "*Time Reference Received*";
791+
} catch (NumberFormatException e) {
792+
//Discard. Should not happen, but to make sure
782793
}
783-
Main.deviceToRefTimeCorrection = deltaTime;
784-
Main.refTimeSource = mMessage.from;
785-
mMessage.sms = "*Time Reference Received*";
786794
}
787795
}
788796
}

0 commit comments

Comments
 (0)