Skip to content

Commit 0c2a6c0

Browse files
committed
2.0-beta2: add a delay to Bluetooth transmissions based on the AllianceStation
1 parent 8df0643 commit 0c2a6c0

File tree

5 files changed

+24
-29
lines changed

5 files changed

+24
-29
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ android {
3232
applicationId "com.team980.thunderscout"
3333
minSdkVersion 16
3434
targetSdkVersion 26
35-
versionCode 12 //Next public release: 13
36-
versionName "2.0-beta1" //2018 will be when I make the semantic change
35+
versionCode 13 //Next public release: 14
36+
versionName "2.0-beta2" //2018 will be when I make the semantic change
3737
resConfigs "en"
3838
}
3939

app/src/main/java/com/team980/thunderscout/bluetooth/ClientConnectionThread.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ public ClientConnectionThread(BluetoothDevice device, ScoutData data, Context co
9292
}
9393

9494
public void run() {
95+
try {
96+
Thread.sleep(scoutData.getAllianceStation().getDelay()); //Variable delay based on AllianceStation
97+
} catch (InterruptedException e) {
98+
FirebaseCrash.report(e);
99+
}
100+
95101
// Cancel discovery because it will slow down the connection
96102
mBluetoothAdapter.cancelDiscovery();
97103

app/src/main/java/com/team980/thunderscout/bluetooth/ServerConnectionTask.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ protected ScoutData doInBackground(Void[] params) {
7878
ObjectInputStream inputStream;
7979

8080
try {
81-
inputStream = new ObjectInputStream(mmSocket.getInputStream());
81+
inputStream = new ObjectInputStream(mmSocket.getInputStream()); //TODO fix the IOException caused by the missing socket...
8282
} catch (IOException e) {
8383
FirebaseCrash.report(e);
8484
notificationManager.showBtTransferError(mmSocket.getRemoteDevice().getName(),

app/src/main/java/com/team980/thunderscout/schema/enumeration/AllianceStation.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,24 @@
3030
import com.team980.thunderscout.R;
3131

3232
public enum AllianceStation {
33-
RED_1(AllianceColor.RED, R.color.alliance_red_primary, R.id.match_red1),
34-
RED_2(AllianceColor.RED, R.color.alliance_red_primary_dark, R.id.match_red2),
35-
RED_3(AllianceColor.RED, R.color.alliance_red_primary, R.id.match_red3),
33+
RED_1(AllianceColor.RED, R.color.alliance_red_primary, R.id.match_red1, 0),
34+
RED_2(AllianceColor.RED, R.color.alliance_red_primary_dark, R.id.match_red2, 100),
35+
RED_3(AllianceColor.RED, R.color.alliance_red_primary, R.id.match_red3, 200),
3636

37-
BLUE_1(AllianceColor.BLUE, R.color.alliance_blue_primary, R.id.match_blue1),
38-
BLUE_2(AllianceColor.BLUE, R.color.alliance_blue_primary_dark, R.id.match_blue2),
39-
BLUE_3(AllianceColor.BLUE, R.color.alliance_blue_primary, R.id.match_blue3);
37+
BLUE_1(AllianceColor.BLUE, R.color.alliance_blue_primary, R.id.match_blue1, 300),
38+
BLUE_2(AllianceColor.BLUE, R.color.alliance_blue_primary_dark, R.id.match_blue2, 400),
39+
BLUE_3(AllianceColor.BLUE, R.color.alliance_blue_primary, R.id.match_blue3, 500);
4040

4141
AllianceColor color;
4242
int colorStratified;
4343
int matchCellViewID;
44+
long delayInMillis;
4445

45-
AllianceStation(AllianceColor color, int colorStratified, @IdRes int matchCellViewID) {
46+
AllianceStation(AllianceColor color, int colorStratified, @IdRes int matchCellViewID, long delayInMillis) {
4647
this.color = color;
4748
this.colorStratified = colorStratified;
4849
this.matchCellViewID = matchCellViewID;
50+
this.delayInMillis = delayInMillis;
4951
}
5052

5153
public AllianceColor getColor() {
@@ -61,6 +63,10 @@ public int getMatchCellViewID() {
6163
return matchCellViewID;
6264
}
6365

66+
public long getDelay() { //Client delay to prevent socket errors
67+
return delayInMillis;
68+
}
69+
6470
public enum AllianceColor {
6571
RED("Red Alliance", R.color.alliance_red_primary, R.color.alliance_red_primary_dark),
6672
BLUE("Blue Alliance", R.color.alliance_blue_primary, R.color.alliance_blue_primary_dark);

app/src/main/res/values/strings.xml

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,9 @@
2626
<string name="app_name">ThunderScout</string>
2727

2828
<!--- TODO These must be updated for every public release!-->
29-
<!--- TODO Last update: v12 -->
29+
<!--- TODO Last update: v13 -->
3030
<string name="update_notes">
31-
ThunderScout 2.0 redesigns the app\'s analytic features from the ground up to be more useful, relevant, and elegant.
32-
\n
33-
\nThe data analysis is now broken up into three tabs: Matches, Rankings, and Alliances.
34-
\n
35-
\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.
36-
\n
37-
\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.
38-
\n
39-
\nThe match and team breakdowns have been updated to highlight statistical performance and point estimations, and now take up less space.
40-
\n
41-
\nOther notable changes:
42-
\n&#8226; A "gears dropped" field has been added to auto and teleop.
43-
\n&#8226; The alliance field has been updated to reflect individual alliance stations.
44-
\n&#8226; The Bluetooth Device selection preference now opens a system dialog.
45-
\n&#8226; New squircle icon (now Adaptive on Android Oreo)
46-
\n&#8226; And don\'t forget this very dialog, which is also accessible in the About menu!
47-
\n
48-
\nThere are a lot of other under-the-hood changes as well.
31+
Beta 2 adds a variable delay to client-side Bluetooth transmissions based on the data\'s AllianceStation. This should improve Bluetooth reliability.
4932
\n
5033
\nKnown issues:
5134
\n&#8226; The match schedule currently does not show when multiple matches occupy the same slot.

0 commit comments

Comments
 (0)