From 7884300a9670c357236b2dcbee34df51a37317f6 Mon Sep 17 00:00:00 2001 From: niccellular <79813408+niccellular@users.noreply.github.com> Date: Wed, 11 Sep 2024 18:59:37 -0400 Subject: [PATCH] 1.0.33 tweak the logic when sending chunks, don't let the user get into a situation of sending multiple chunked CoTs in the future need to implement a queue or something --- app/build.gradle | 2 +- .../android/meshtastic/MeshtasticMapComponent.java | 13 ++++++++++++- .../android/meshtastic/MeshtasticReceiver.java | 8 +++----- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 1bd7993..0e3de4d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,7 +9,7 @@ buildscript { - ext.PLUGIN_VERSION = "1.0.32" + ext.PLUGIN_VERSION = "1.0.33" ext.ATAK_VERSION = "4.10.0" def takdevVersion = '2.+' diff --git a/app/src/main/java/com/atakmap/android/meshtastic/MeshtasticMapComponent.java b/app/src/main/java/com/atakmap/android/meshtastic/MeshtasticMapComponent.java index 6d7a539..1670135 100644 --- a/app/src/main/java/com/atakmap/android/meshtastic/MeshtasticMapComponent.java +++ b/app/src/main/java/com/atakmap/android/meshtastic/MeshtasticMapComponent.java @@ -641,7 +641,14 @@ else if (xpp.getAttributeName(i).equalsIgnoreCase("speed")) if (prefs.getBoolean("plugin_meshtastic_plichat_only", false)) { Log.d(TAG, "PLI/Chat Only"); return; + } else if (prefs.getBoolean("plugin_meshtastic_chunking", false)) { + Log.d(TAG, "Chunking in progress"); + return; } + + editor.putBoolean("plugin_meshtastic_chunking", true); + editor.apply(); + new Thread(() -> { Log.d(TAG, "Sending Chunks"); @@ -714,7 +721,7 @@ else if (xpp.getAttributeName(i).equalsIgnoreCase("speed")) mMeshService.send(dp[0]); while (prefs.getBoolean("plugin_meshtastic_chunk_ACK", false)) { try { - Thread.sleep(500); + Thread.sleep(250); if (prefs.getBoolean("plugin_meshtastic_chunk_ERR", false)) { Log.d(TAG, "Chunk ERR received, retransmitting message ID: " + i[0]); j = 0; @@ -739,6 +746,8 @@ else if (xpp.getAttributeName(i).equalsIgnoreCase("speed")) e.printStackTrace(); } } + editor.putBoolean("plugin_meshtastic_chunking", false); + editor.apply(); }).start(); } } @@ -784,6 +793,8 @@ public void onCreate(final Context context, Intent intent, MapView view) { prefs = PreferenceManager.getDefaultSharedPreferences(MapView.getMapView().getContext()); editor = prefs.edit(); editor.putBoolean("plugin_meshtastic_file_transfer", false); + editor.putBoolean("plugin_meshtastic_chunking", true); + editor.apply(); prefs.registerOnSharedPreferenceChangeListener(this); mr = new MeshtasticReceiver(); diff --git a/app/src/main/java/com/atakmap/android/meshtastic/MeshtasticReceiver.java b/app/src/main/java/com/atakmap/android/meshtastic/MeshtasticReceiver.java index bd16ca6..0328be0 100644 --- a/app/src/main/java/com/atakmap/android/meshtastic/MeshtasticReceiver.java +++ b/app/src/main/java/com/atakmap/android/meshtastic/MeshtasticReceiver.java @@ -163,22 +163,20 @@ public void onReceive(Context context, Intent intent) { MessageStatus status = intent.getParcelableExtra(MeshtasticMapComponent.EXTRA_STATUS); Log.d(TAG, "Message Status ID: " + id + " Status: " + status); if (prefs.getInt("plugin_meshtastic_switch_id", 0) == id && status == MessageStatus.DELIVERED) { - SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean("plugin_meshtastic_switch_ACK", false); editor.apply(); Log.d(TAG, "Got ACK from Switch"); } else if (prefs.getInt("plugin_meshtastic_chunk_id", 0) == id && status == MessageStatus.DELIVERED) { - SharedPreferences.Editor editor = prefs.edit(); // clear the ACK/ERR for the chunk editor.putBoolean("plugin_meshtastic_chunk_ACK", false); editor.putBoolean("plugin_meshtastic_chunk_ERR", false); editor.apply(); - Log.d(TAG, "Got ACK from Chunk"); + Log.d(TAG, "Got DELIVERED from Chunk"); } else if (prefs.getInt("plugin_meshtastic_chunk_id", 0) == id && status == MessageStatus.ERROR) { - Log.d(TAG, "Got ERROR from Chunk"); - editor.putBoolean("plugin_meshtastic_chunk_ACK", true); + editor.putBoolean("plugin_meshtastic_chunk_ACK", false); editor.putBoolean("plugin_meshtastic_chunk_ERR", true); editor.apply(); + Log.d(TAG, "Got ERROR from Chunk"); } break; case MeshtasticMapComponent.ACTION_RECEIVED_ATAK_FORWARDER: