Skip to content

Commit 63f2aa8

Browse files
Fix auto-reconnect on windows localhost (#195)
Depends on BinghamtonRover/Networking#19 --------- Co-authored-by: Levi Lesches <levilesches@gmail.com>
1 parent a1f9b22 commit 63f2aa8

File tree

6 files changed

+51
-49
lines changed

6 files changed

+51
-49
lines changed

bin/science.dart

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import "dart:convert";
44
import "dart:io";
55

66
import "package:protobuf/protobuf.dart" as proto;
7-
import "package:burt_network/generated.dart";
7+
import "package:burt_network/protobuf.dart";
88

99
/// A cleaner name for any message generated by Protobuf.
1010
typedef Message = proto.GeneratedMessage;
1111

1212
/// Return true to keep this data in the dataset, or false to remove it.
13-
///
13+
///
1414
/// Not only are the sensors on the rover wonky, but the CAN bus can corrupt data along the way.
1515
/// This function can be used to remove any unwanted bad data.
1616
bool shouldKeepData(Timestamp timestamp, ScienceData data) {
@@ -21,25 +21,25 @@ bool shouldKeepData(Timestamp timestamp, ScienceData data) {
2121
if (data.humidity.isOutOfBounds(min: 0, max: 50)) return false;
2222
if (data.temperature.isOutOfBounds(min: 0, max: 100)) return false;
2323

24-
// Any other conditions should go here:
24+
// Any other conditions should go here:
2525
if (elapsed >= 30 * 60) return false;
2626

2727
return true; // if none of the above rules are broken, then keep this data
2828
}
2929

30-
/// Returns new data based on this one. To remove data, use [shouldKeepData] instead.
31-
///
30+
/// Returns new data based on this one. To remove data, use [shouldKeepData] instead.
31+
///
3232
/// You shouldn't need this unless you specifically need to change the *values* of the data. For example,
3333
/// if the CO2 sensor was consistently 100ppm off, you could use this function to add 100ppm to each data.
34-
///
35-
/// NOTE: Do not modify fields that are zero, because they are likely sent in another "packet". For
34+
///
35+
/// NOTE: Do not modify fields that are zero, because they are likely sent in another "packet". For
3636
/// example, if you want to modify CO2 but `data.co2 == 0`, this packet could be, eg, a methane packet
3737
/// and isn't meant to have any CO2 data.
3838
WrappedMessage modifyData(Timestamp timestamp, ScienceData data) { // ignore: prefer_expression_function_bodies
39-
// Example 1: Add 100 ppm to all CO2:
39+
// Example 1: Add 100 ppm to all CO2:
4040
// if (data.co2 != 0) data.co2 += 100;
41-
//
42-
// Example 2: Add one second to all the timestamps:
41+
//
42+
// Example 2: Add one second to all the timestamps:
4343
// timestamp += Duration(seconds: 1)
4444

4545
// Wrap the data and return it. Do not delete.
@@ -50,17 +50,17 @@ WrappedMessage modifyData(Timestamp timestamp, ScienceData data) { // ignore: p
5050
/// Use this to add new data to your dataset.
5151
List<WrappedMessage> newData = [
5252
// Adds methane=1 for every second from t=1 to t=100 seconds
53-
for (int t = 0; t < 100; t++)
53+
for (int t = 0; t < 100; t++)
5454
ScienceData(methane: 1).wrap(DateTime.now().add(Duration(seconds: t))),
5555
5656
// Adds some random methane in an increasing line between t=100 and t=200 seconds
57-
for (int t = 100; t < 200; t++)
57+
for (int t = 100; t < 200; t++)
5858
ScienceData(methane: t + random.nextDouble() * 20).wrap(DateTime.now().add(Duration(seconds: t))),
5959
6060
// Adds completely random data for t=0 to t=20 seconds, for all three samples
61-
for (int s = 0; s < 3; s++)
61+
for (int s = 0; s < 3; s++)
6262
for (int t = 0; t < 20; t++) ScienceData(
63-
// sample: s,
63+
// sample: s,
6464
temperature: t + s + (random.nextInt(10).toDouble()),
6565
methane: t + s + (random.nextInt(7).toDouble()),
6666
co2: t + s + (random.nextInt(5).toDouble()),

lib/data.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/// library should import any other library.
1111
library data;
1212

13-
export "package:burt_network/generated.dart";
13+
export "package:burt_network/protobuf.dart";
1414

1515
export "src/data/metrics/arm.dart";
1616
export "src/data/metrics/drive.dart";

lib/src/data/protobuf.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ extension DeviceUtils on Device {
136136
case Device.DRIVE: return "Drive";
137137
case Device.BASE_STATION: return "Base Station";
138138
case Device.ANTENNA: return "Antenna";
139+
case Device.RELAY: return "Relays";
139140
}
140141
// Do not use default or else you'll lose exhaustiveness checking.
141142
throw ArgumentError("Unrecognized device: $this");

lib/src/services/socket.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class DashboardSocket extends BurtSocket {
2424
double get frequency => models.settings.network.connectionTimeout;
2525

2626
/// Listens for incoming messages on a UDP socket and sends heartbeats to the [device].
27-
DashboardSocket({required super.device}) : super(port: null, quiet: true);
27+
DashboardSocket({required super.device}) : super(port: null, quiet: true, keepDestination: true);
2828

2929
@override
3030
Duration get heartbeatInterval => Duration(milliseconds: 1000 ~/ frequency);

pubspec.lock

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ packages:
2121
dependency: transitive
2222
description:
2323
name: async
24-
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
24+
sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63
2525
url: "https://pub.dev"
2626
source: hosted
27-
version: "2.11.0"
27+
version: "2.12.0"
2828
audio_session:
2929
dependency: transitive
3030
description:
@@ -37,19 +37,19 @@ packages:
3737
dependency: transitive
3838
description:
3939
name: boolean_selector
40-
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
40+
sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea"
4141
url: "https://pub.dev"
4242
source: hosted
43-
version: "2.1.1"
43+
version: "2.1.2"
4444
burt_network:
4545
dependency: "direct main"
4646
description:
47-
path: "."
48-
ref: "2.1.0"
49-
resolved-ref: "61c1952afe2210099ccde59220356db647dc79ae"
50-
url: "https://github.com/BinghamtonRover/Networking.git"
47+
path: burt_network
48+
ref: "2.5.0"
49+
resolved-ref: a52c8a984fcc4f6b022fa540c0ea13b55168ac22
50+
url: "https://github.com/BinghamtonRover/Rover-Code.git"
5151
source: git
52-
version: "2.1.0"
52+
version: "2.4.0"
5353
characters:
5454
dependency: transitive
5555
description:
@@ -78,18 +78,18 @@ packages:
7878
dependency: transitive
7979
description:
8080
name: clock
81-
sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
81+
sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b
8282
url: "https://pub.dev"
8383
source: hosted
84-
version: "1.1.1"
84+
version: "1.1.2"
8585
collection:
8686
dependency: "direct main"
8787
description:
8888
name: collection
89-
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
89+
sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf
9090
url: "https://pub.dev"
9191
source: hosted
92-
version: "1.18.0"
92+
version: "1.19.0"
9393
console:
9494
dependency: transitive
9595
description:
@@ -134,10 +134,10 @@ packages:
134134
dependency: transitive
135135
description:
136136
name: fake_async
137-
sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
137+
sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc"
138138
url: "https://pub.dev"
139139
source: hosted
140-
version: "1.3.1"
140+
version: "1.3.2"
141141
ffi:
142142
dependency: transitive
143143
description:
@@ -303,18 +303,18 @@ packages:
303303
dependency: transitive
304304
description:
305305
name: leak_tracker
306-
sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
306+
sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec
307307
url: "https://pub.dev"
308308
source: hosted
309-
version: "10.0.5"
309+
version: "10.0.8"
310310
leak_tracker_flutter_testing:
311311
dependency: transitive
312312
description:
313313
name: leak_tracker_flutter_testing
314-
sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
314+
sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573
315315
url: "https://pub.dev"
316316
source: hosted
317-
version: "3.0.5"
317+
version: "3.0.9"
318318
leak_tracker_testing:
319319
dependency: transitive
320320
description:
@@ -399,10 +399,10 @@ packages:
399399
dependency: transitive
400400
description:
401401
name: path
402-
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
402+
sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5"
403403
url: "https://pub.dev"
404404
source: hosted
405-
version: "1.9.0"
405+
version: "1.9.1"
406406
path_provider:
407407
dependency: "direct main"
408408
description:
@@ -519,7 +519,7 @@ packages:
519519
dependency: transitive
520520
description: flutter
521521
source: sdk
522-
version: "0.0.99"
522+
version: "0.0.0"
523523
source_span:
524524
dependency: transitive
525525
description:
@@ -540,10 +540,10 @@ packages:
540540
dependency: transitive
541541
description:
542542
name: stack_trace
543-
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
543+
sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377"
544544
url: "https://pub.dev"
545545
source: hosted
546-
version: "1.11.1"
546+
version: "1.12.0"
547547
stream_channel:
548548
dependency: transitive
549549
description:
@@ -556,10 +556,10 @@ packages:
556556
dependency: transitive
557557
description:
558558
name: string_scanner
559-
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
559+
sha256: "0bd04f5bb74fcd6ff0606a888a30e917af9bd52820b178eaa464beb11dca84b6"
560560
url: "https://pub.dev"
561561
source: hosted
562-
version: "1.2.0"
562+
version: "1.4.0"
563563
term_glyph:
564564
dependency: transitive
565565
description:
@@ -572,10 +572,10 @@ packages:
572572
dependency: transitive
573573
description:
574574
name: test_api
575-
sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
575+
sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c"
576576
url: "https://pub.dev"
577577
source: hosted
578-
version: "0.7.2"
578+
version: "0.7.3"
579579
typed_data:
580580
dependency: transitive
581581
description:
@@ -684,10 +684,10 @@ packages:
684684
dependency: transitive
685685
description:
686686
name: vm_service
687-
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
687+
sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14"
688688
url: "https://pub.dev"
689689
source: hosted
690-
version: "14.2.5"
690+
version: "14.3.1"
691691
web:
692692
dependency: transitive
693693
description:
@@ -729,5 +729,5 @@ packages:
729729
source: hosted
730730
version: "3.1.2"
731731
sdks:
732-
dart: ">=3.5.3 <4.0.0"
732+
dart: ">=3.6.0 <4.0.0"
733733
flutter: ">=3.24.0"

pubspec.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ dependencies:
1212
sdk: flutter
1313
burt_network:
1414
git:
15-
url: https://github.com/BinghamtonRover/Networking.git
16-
ref: 2.1.0
15+
url: https://github.com/BinghamtonRover/Rover-Code.git
16+
path: burt_network
17+
ref: 2.5.0
1718
file_picker: ^8.0.0+1
1819
fl_chart: ^0.69.0
1920
flutter_libserialport: ^0.4.0

0 commit comments

Comments
 (0)