From e437714c164f21096b814bbd72b32425ed03e7b9 Mon Sep 17 00:00:00 2001 From: Georg Lukas Date: Fri, 7 Oct 2011 03:07:09 +0200 Subject: [PATCH] abort messages after tx timeout --- src/MessageService.scala | 7 ++++++- src/StorageDatabase.scala | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/MessageService.scala b/src/MessageService.scala index a2b8707..6b6574a 100644 --- a/src/MessageService.scala +++ b/src/MessageService.scala @@ -83,7 +83,12 @@ class MessageService(s : AprsService) { val t_send = ts + getRetryDelayMS(retrycnt) - System.currentTimeMillis() Log.d(TAG, "pending message: %d/%d (%ds) ->%s '%s'".format(retrycnt, NUM_OF_RETRIES, t_send/1000, call, text)) - if (retrycnt < NUM_OF_RETRIES && t_send <= 0) { + if (retrycnt == NUM_OF_RETRIES && t_send <= 0) { + // this message timed out + s.db.updateMessageType(c.getLong(/* COLUMN_ID */ 0), TYPE_OUT_ABORTED) + s.sendBroadcast(new Intent(AprsService.MESSAGE)) + } else if (retrycnt < NUM_OF_RETRIES && t_send <= 0) { + // this message needs to be transmitted val msg = AprsPacket.formatMessage(callssid, s.appVersion(), call, text, msgid) val status = s.poster.update(msg) s.addPost(StorageDatabase.Post.TYPE_POST, status, msg.toString) diff --git a/src/StorageDatabase.scala b/src/StorageDatabase.scala index d648da2..1faf95b 100644 --- a/src/StorageDatabase.scala +++ b/src/StorageDatabase.scala @@ -386,7 +386,7 @@ class StorageDatabase(context : Context) extends def getPendingMessages(retries : Int) = { getReadableDatabase().query(Message.TABLE, Message.COLUMNS, - "type = 2 and retrycnt < ?", Array(retries.toString), + "type = 2 and retrycnt <= ?", Array(retries.toString), null, null, null, null) }