From 0c2a6c08c9cdaea572bc196c4988795f60b9e22f Mon Sep 17 00:00:00 2001 From: Luke Myers <19lmyers@gmail.com> Date: Sat, 30 Sep 2017 13:14:25 -0700 Subject: [PATCH] 2.0-beta2: add a delay to Bluetooth transmissions based on the AllianceStation --- app/build.gradle | 4 ++-- .../bluetooth/ClientConnectionThread.java | 6 ++++++ .../bluetooth/ServerConnectionTask.java | 2 +- .../schema/enumeration/AllianceStation.java | 20 +++++++++++------- app/src/main/res/values/strings.xml | 21 ++----------------- 5 files changed, 24 insertions(+), 29 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 4f7f5c4d..e9df1f01 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -32,8 +32,8 @@ android { applicationId "com.team980.thunderscout" minSdkVersion 16 targetSdkVersion 26 - versionCode 12 //Next public release: 13 - versionName "2.0-beta1" //2018 will be when I make the semantic change + versionCode 13 //Next public release: 14 + versionName "2.0-beta2" //2018 will be when I make the semantic change resConfigs "en" } diff --git a/app/src/main/java/com/team980/thunderscout/bluetooth/ClientConnectionThread.java b/app/src/main/java/com/team980/thunderscout/bluetooth/ClientConnectionThread.java index 55487471..bfdb8209 100644 --- a/app/src/main/java/com/team980/thunderscout/bluetooth/ClientConnectionThread.java +++ b/app/src/main/java/com/team980/thunderscout/bluetooth/ClientConnectionThread.java @@ -92,6 +92,12 @@ public ClientConnectionThread(BluetoothDevice device, ScoutData data, Context co } public void run() { + try { + Thread.sleep(scoutData.getAllianceStation().getDelay()); //Variable delay based on AllianceStation + } catch (InterruptedException e) { + FirebaseCrash.report(e); + } + // Cancel discovery because it will slow down the connection mBluetoothAdapter.cancelDiscovery(); diff --git a/app/src/main/java/com/team980/thunderscout/bluetooth/ServerConnectionTask.java b/app/src/main/java/com/team980/thunderscout/bluetooth/ServerConnectionTask.java index 7da30f2f..6dac9236 100644 --- a/app/src/main/java/com/team980/thunderscout/bluetooth/ServerConnectionTask.java +++ b/app/src/main/java/com/team980/thunderscout/bluetooth/ServerConnectionTask.java @@ -78,7 +78,7 @@ protected ScoutData doInBackground(Void[] params) { ObjectInputStream inputStream; try { - inputStream = new ObjectInputStream(mmSocket.getInputStream()); + inputStream = new ObjectInputStream(mmSocket.getInputStream()); //TODO fix the IOException caused by the missing socket... } catch (IOException e) { FirebaseCrash.report(e); notificationManager.showBtTransferError(mmSocket.getRemoteDevice().getName(), diff --git a/app/src/main/java/com/team980/thunderscout/schema/enumeration/AllianceStation.java b/app/src/main/java/com/team980/thunderscout/schema/enumeration/AllianceStation.java index d723058c..92ebbd1d 100644 --- a/app/src/main/java/com/team980/thunderscout/schema/enumeration/AllianceStation.java +++ b/app/src/main/java/com/team980/thunderscout/schema/enumeration/AllianceStation.java @@ -30,22 +30,24 @@ import com.team980.thunderscout.R; public enum AllianceStation { - RED_1(AllianceColor.RED, R.color.alliance_red_primary, R.id.match_red1), - RED_2(AllianceColor.RED, R.color.alliance_red_primary_dark, R.id.match_red2), - RED_3(AllianceColor.RED, R.color.alliance_red_primary, R.id.match_red3), + RED_1(AllianceColor.RED, R.color.alliance_red_primary, R.id.match_red1, 0), + RED_2(AllianceColor.RED, R.color.alliance_red_primary_dark, R.id.match_red2, 100), + RED_3(AllianceColor.RED, R.color.alliance_red_primary, R.id.match_red3, 200), - BLUE_1(AllianceColor.BLUE, R.color.alliance_blue_primary, R.id.match_blue1), - BLUE_2(AllianceColor.BLUE, R.color.alliance_blue_primary_dark, R.id.match_blue2), - BLUE_3(AllianceColor.BLUE, R.color.alliance_blue_primary, R.id.match_blue3); + BLUE_1(AllianceColor.BLUE, R.color.alliance_blue_primary, R.id.match_blue1, 300), + BLUE_2(AllianceColor.BLUE, R.color.alliance_blue_primary_dark, R.id.match_blue2, 400), + BLUE_3(AllianceColor.BLUE, R.color.alliance_blue_primary, R.id.match_blue3, 500); AllianceColor color; int colorStratified; int matchCellViewID; + long delayInMillis; - AllianceStation(AllianceColor color, int colorStratified, @IdRes int matchCellViewID) { + AllianceStation(AllianceColor color, int colorStratified, @IdRes int matchCellViewID, long delayInMillis) { this.color = color; this.colorStratified = colorStratified; this.matchCellViewID = matchCellViewID; + this.delayInMillis = delayInMillis; } public AllianceColor getColor() { @@ -61,6 +63,10 @@ public int getMatchCellViewID() { return matchCellViewID; } + public long getDelay() { //Client delay to prevent socket errors + return delayInMillis; + } + public enum AllianceColor { RED("Red Alliance", R.color.alliance_red_primary, R.color.alliance_red_primary_dark), BLUE("Blue Alliance", R.color.alliance_blue_primary, R.color.alliance_blue_primary_dark); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5af82e18..081b0554 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -26,26 +26,9 @@ ThunderScout - + - ThunderScout 2.0 redesigns the app\'s analytic features from the ground up to be more useful, relevant, and elegant. - \n - \nThe data analysis is now broken up into three tabs: Matches, Rankings, and Alliances. - \n - \nThe Matches tab displays a generated schedule of the event, allowing you to see at a glance all the data you have collected, or may be missing. - \n - \nThe Rankings tab ranks teams by an estimation of how many points they would score, on average, alone on the field based on your collected data. - \n - \nThe match and team breakdowns have been updated to highlight statistical performance and point estimations, and now take up less space. - \n - \nOther notable changes: - \n• A "gears dropped" field has been added to auto and teleop. - \n• The alliance field has been updated to reflect individual alliance stations. - \n• The Bluetooth Device selection preference now opens a system dialog. - \n• New squircle icon (now Adaptive on Android Oreo) - \n• And don\'t forget this very dialog, which is also accessible in the About menu! - \n - \nThere are a lot of other under-the-hood changes as well. + Beta 2 adds a variable delay to client-side Bluetooth transmissions based on the data\'s AllianceStation. This should improve Bluetooth reliability. \n \nKnown issues: \n• The match schedule currently does not show when multiple matches occupy the same slot.