pull/369/head
Mike 2024-11-29 13:17:49 -08:00
rodzic 4829107122
commit 885341a3d7
2 zmienionych plików z 12 dodań i 7 usunięć

Wyświetl plik

@ -354,6 +354,8 @@ class AprsService extends Service {
def parsePacket(ts : Long, message : String, source : Int) { def parsePacket(ts : Long, message : String, source : Int) {
try { try {
var fap = Parser.parse(message) var fap = Parser.parse(message)
var digiPathCheck = fap.getDigiString()
if (fap.getType() == APRSTypes.T_THIRDPARTY) { if (fap.getType() == APRSTypes.T_THIRDPARTY) {
Log.d(TAG, "parsePacket: third-party packet from " + fap.getSourceCall()) Log.d(TAG, "parsePacket: third-party packet from " + fap.getSourceCall())
val inner = fap.getAprsInformation().toString() val inner = fap.getAprsInformation().toString()
@ -381,7 +383,8 @@ class AprsService extends Service {
fap.getAprsInformation() match { fap.getAprsInformation() match {
case pp : PositionPacket => addPosition(ts, fap, pp, pp.getPosition(), null) case pp : PositionPacket => addPosition(ts, fap, pp, pp.getPosition(), null)
case op : ObjectPacket => addPosition(ts, fap, op, op.getPosition(), op.getObjectName()) case op : ObjectPacket => addPosition(ts, fap, op, op.getPosition(), op.getObjectName())
case msg : MessagePacket => msgService.handleMessage(ts, fap, msg) case msg : MessagePacket => msgService.handleMessage(ts, fap, msg, digiPathCheck)
} }
} catch { } catch {
case e : Exception => case e : Exception =>

Wyświetl plik

@ -38,12 +38,17 @@ class MessageService(s : AprsService) {
) )
} }
def handleMessage(ts : Long, ap : APRSPacket, msg : MessagePacket) { def handleMessage(ts : Long, ap : APRSPacket, msg : MessagePacket, LastUsedDigi : String) {
val callssid = s.prefs.getCallSsid() val callssid = s.prefs.getCallSsid()
// Retrieve the ACK duplicate time setting from preferences (default is 0 seconds) // Retrieve the ACK duplicate time setting from preferences (default is 0 seconds)
val lastAckDupeTime = s.prefs.getStringInt("p.ackdupe", 0) * 1000 // Convert seconds to milliseconds val lastAckDupeTime = s.prefs.getStringInt("p.ackdupe", 0) * 1000 // Convert seconds to milliseconds
// Check if we have sent an ACK for the same source call and message number in the last `lastAckDupeTime` milliseconds
val currentTime = System.currentTimeMillis()
val messageNumber = msg.getMessageNumber() // Get the message number
val lastAckTime = lastAckTimestamps.get((ap.getSourceCall(), messageNumber))
if (msg.getTargetCallsign().equalsIgnoreCase(callssid)) { if (msg.getTargetCallsign().equalsIgnoreCase(callssid)) {
if (msg.isAck() || msg.isRej()) { if (msg.isAck() || msg.isRej()) {
val new_type = if (msg.isAck()) val new_type = if (msg.isAck())
@ -58,10 +63,6 @@ class MessageService(s : AprsService) {
// Only check for duplicate ACKs if the feature is enabled // Only check for duplicate ACKs if the feature is enabled
if (s.prefs.isAckDupeEnabled) { if (s.prefs.isAckDupeEnabled) {
// Check if we have sent an ACK for the same source call and message number in the last `lastAckDupeTime` milliseconds
val currentTime = System.currentTimeMillis()
val messageNumber = msg.getMessageNumber() // Get the message number
val lastAckTime = lastAckTimestamps.get((ap.getSourceCall(), messageNumber))
if (lastAckTime.exists(time => (currentTime - time) < lastAckDupeTime)) { if (lastAckTime.exists(time => (currentTime - time) < lastAckDupeTime)) {
Log.d(TAG, s"Duplicate msg, skipping ack for ${ap.getSourceCall()} messageNumber: $messageNumber") Log.d(TAG, s"Duplicate msg, skipping ack for ${ap.getSourceCall()} messageNumber: $messageNumber")
@ -71,7 +72,8 @@ class MessageService(s : AprsService) {
} }
// Proceed to send ACK if messageNumber is not empty // Proceed to send ACK if messageNumber is not empty
if (msg.getMessageNumber() != "" && !ap.getDigiString().contains(s.prefs.getCallSsid() + "*")) { if (msg.getMessageNumber() != "" && (!LastUsedDigi.split(",").contains(s.prefs.getCallSsid() + "*") && !ap.getDigiString().split(",").contains(s.prefs.getCallSsid() + "*"))) {
Log.d(TAG, s"DigiString: ${ap.getDigiString()}, LastUsedDigi: ${LastUsedDigi}, CallSSID: ${s.prefs.getCallSsid()}")
Log.d(TAG, s"Sending ACK: msgNumber = ${msg.getMessageNumber()}, digiString = ${ap.getDigiString()}, callsign = ${s.prefs.getCallSsid()}") Log.d(TAG, s"Sending ACK: msgNumber = ${msg.getMessageNumber()}, digiString = ${ap.getDigiString()}, callsign = ${s.prefs.getCallSsid()}")
// No recent ACK, we need to send an ACK // No recent ACK, we need to send an ACK