Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
feab701
Alert Pusher (#437)
je-foster Sep 15, 2023
64d045e
Tests run again (#438)
je-foster Oct 5, 2023
ad0920f
Simplify lint rules file.
Feb 7, 2024
6c445b8
Lint issues.
Mar 2, 2024
a493aea
AlertPusherTest now passes.
Mar 13, 2024
7ecd31f
DataLoggerTest now passes.
Mar 13, 2024
a8852f7
PHProbeTest.cpp now passes.
Mar 13, 2024
99876b9
SDTest.cpp now passes, along with all others!
Mar 13, 2024
15dfd99
The stdev seems to be different on my local runs from that on the Git…
Mar 13, 2024
01bf586
WIP on defer network when bubbler is on.
Mar 13, 2024
c60084a
Disable Arduino-CI tests (for now).
Mar 14, 2024
8268ece
Start on event log.
Mar 15, 2024
6a177c2
Newline at end of file.
Apr 24, 2024
d29cbf4
Formatting.
Apr 24, 2024
0362ef6
Merge branch 'main' into event_log
Jun 18, 2024
2e19029
Rename event log to remote log.
Jun 18, 2024
5895b60
Change formatting.
Jun 18, 2024
60f356e
Merge branch 'remote_log' into alerts
Jun 18, 2024
2df4fb9
Edits to get things to compile.
Jun 18, 2024
25672bf
More formatting (Arduino CI tests are disabled).
Jun 18, 2024
a8e9d20
More formatting changes.
Jun 18, 2024
8273a9b
Merge branch 'main' into alerts
Jun 19, 2024
a5ce38b
Merge branch 'main' into alerts
Jun 20, 2024
ac7a1d4
Merge branch 'main' into alerts
Jul 24, 2024
9697b3a
Formatting.
Jul 24, 2024
9c13e16
More formatting.
Jul 24, 2024
ae545b2
Revert code removed from PHProbe.cpp.
Jul 24, 2024
29283b7
Change code order to match main.
Jul 24, 2024
9967a97
Update ThermalProbeTest.cpp from main.
Jul 24, 2024
6565091
Move PORT from Ethernet_TC.h to AlertPusher.cpp.
Jul 24, 2024
646c13e
Bump versions.
Aug 14, 2024
9fd6dcf
Merge branch 'main' into alerts
Aug 14, 2024
08d5fbf
Update libraries; add `flutter.js.map` files to avoid client errors.
Oct 10, 2024
697c9bb
Merge branch 'main' into alerts
Oct 11, 2024
9b12ad7
Merge main into alerts.
Dec 24, 2024
b90b205
Change for deprecated Flutter function.
Dec 26, 2024
224bb29
Consolidate all the setup into the `instance()` method.
Dec 26, 2024
b038540
Merge branch 'december' into alerts.
Dec 26, 2024
2409e71
Update Flutter version.
Dec 26, 2024
3e77338
Add debugging to JSONBuilderTest.cpp to see how far it gets.
Dec 26, 2024
a633812
Further debugging of JSONBuilderTest. Don't expect float to be exactl…
Dec 26, 2024
25d2a02
Show test class in some tests.
Dec 26, 2024
4a786cd
Merge branch 'december' into alerts; fix SDTest.cpp and PHProbeTest.cpp.
Dec 26, 2024
9f72038
Fix formatting.
Dec 26, 2024
2cec546
More formatting.
Dec 26, 2024
71cf1f6
Work on RemoteLogPusherTest (it passed, but others fail now).
Dec 27, 2024
fd6791c
SDTest and PushingBoxTest now pass.
Dec 27, 2024
8fb7f2b
All tests pass locally.
Dec 27, 2024
be0bd3e
Enable device controller test.
Dec 27, 2024
2a134cd
Fix codacy issue (it found a bug!).
Dec 27, 2024
9636fd3
Fix Codacy issue (bug).
Dec 27, 2024
6066097
Switch default to hide loop delay for easier testing.
Dec 27, 2024
981577b
Formatting.
Dec 27, 2024
94b3618
Merge from december updates.
Dec 27, 2024
059a719
Merge branch 'main' into alerts. Test failures in:
Jan 8, 2025
1a313e3
Tests now pass.
Jan 9, 2025
026e8b3
Update Makefile to make it easier to compare with main.
Jan 9, 2025
dbf044b
Refactor Makefile.
Jan 14, 2025
6c43f5d
Use PHControl::instance()->loop()
Jan 14, 2025
ecaccea
Add files for RemoteLogPusher.
Jan 14, 2025
eb74837
Continuing small changes.
Jan 14, 2025
5784649
Most of the way back with tests passing.
Jan 14, 2025
93f53a8
Merge branches 'main' and 'january' into alerts
Jan 14, 2025
89b957a
- Update Makefile to match alerts.
Jan 14, 2025
e4cce23
Use tabs instead of spaces in Makefile.
Jan 14, 2025
9a3751e
A few more things from the alerts branch.
Jan 14, 2025
1510718
Update a few tests to match alerts.
Jan 15, 2025
a391002
Upgrade libraries.
Jan 15, 2025
4a3c413
Merge main into january.
Jan 15, 2025
f9b258d
Bring alerts branch closer to january branch.
Jan 15, 2025
1fdafdb
- Add RemoteLogPusher code.
Jan 15, 2025
64de97d
Import changes from january branch to alerts branch.
Jan 15, 2025
1829722
Restore some commented-out test code.
Jan 15, 2025
108e0ce
All tests pass with RemoteLogPusher!
Jan 15, 2025
7100abb
Merge branch 'january' into alerts
Jan 15, 2025
fd6af7f
Codacy issues.
Jan 15, 2025
e697dbb
Upgrade library versions.
Jan 17, 2025
78e1ce7
Merge branch 'main' into alerts
Jan 17, 2025
43525e5
* Update Flutter version
Jan 22, 2025
274f661
Merge branch 'main' into alerts
Jan 22, 2025
818a502
WIP: almost there! Only two failiing tests.
Jan 26, 2025
2e58432
Remove post-commit script.
Jan 26, 2025
d1aabf7
WIP: All tests pass.
Jan 26, 2025
9bdc379
no message
Jan 26, 2025
672460c
Still pass
Jan 26, 2025
0f7d920
Still pass.
Jan 26, 2025
f15e853
Tests pass!
Jan 26, 2025
18e219f
Merge branch 'alerts-tmp' into alerts
Jan 26, 2025
61edfc9
Fixes for formatting and failing tests.
Jan 26, 2025
41be7c3
Fix one of two failing tests.
Jan 26, 2025
0c399a5
Tests should pass now!
Jan 26, 2025
c6e8bcf
Merge branch 'upgrade-libraries' into alerts
Jan 26, 2025
21e8b2d
Merge branch 'main' into alerts
Jan 28, 2025
7c340cd
Restore code lost in last merge.
Jan 28, 2025
865d9ed
Remove tests of removed functionality.
Jan 28, 2025
329ff3c
Merge branch 'main' into alerts
Feb 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/device-client.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: install flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.27.2'
flutter-version: '3.27.3'
channel: 'stable'
- name: use cache
uses: actions/cache@v3
Expand Down Expand Up @@ -43,7 +43,7 @@ jobs:
- name: install flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.27.2'
flutter-version: '3.27.3'
channel: 'stable'
- name: use cache
uses: actions/cache@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/log_file_client.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
- name: install flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.27.2'
flutter-version: '3.27.3'
channel: 'stable'
- name: use cache
uses: actions/cache@v3
Expand Down Expand Up @@ -43,7 +43,7 @@
- name: install flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.27.2'
flutter-version: '3.27.3'
channel: 'stable'
- name: use cache
uses: actions/cache@v3
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/log_file_server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
- name: install flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.27.2'
flutter-version: '3.27.3'
channel: 'stable'
- name: use cache
uses: actions/cache@v3
Expand Down Expand Up @@ -42,7 +42,7 @@
- name: install flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.27.2'
flutter-version: '3.27.3'
channel: 'stable'
- name: use cache
uses: actions/cache@v3
Expand All @@ -60,7 +60,6 @@
mkdir -p test/logs
touch test/logs/empty.log
echo "123456789" > test/logs/ten.log
echo "This is data for line 1\nThis is data for line 2" > test/logs/deleteMe.log
dart run "bin/log_file_server.dart" "test/logs" &
dart test --concurrency=1
jobs
Expand Down
6 changes: 0 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@ GPP_TEST=g++ $(FLAGS) -L$(BIN) $(INCLUDE)
$(BIN)/PHCalibrationWarningTest.cpp.bin: $(BIN)/libarduino.so $(TEST)/PHCalibrationWarningTest.cpp $(HEADERS)
$(GPP_TEST) -o $(BIN)/PHCalibrationWarningTest.cpp.bin $(TEST)/PHCalibrationWarningTest.cpp -larduino

$(BIN)/RemoteLogPusherTest.cpp.bin: $(BIN)/libarduino.so $(TEST)/RemoteLogPusherTest.cpp $(HEADERS)
$(GPP_TEST) -o $(BIN)/RemoteLogPusherTest.cpp.bin $(TEST)/RemoteLogPusherTest.cpp -larduino

$(BIN)/BlinkTest.cpp.bin: $(BIN)/libarduino.so $(TEST)/BlinkTest.cpp $(HEADERS)
$(GPP_TEST) -o $(BIN)/BlinkTest.cpp.bin $(TEST)/BlinkTest.cpp -larduino

Expand Down Expand Up @@ -431,9 +428,6 @@ $(BIN)/TC_util.o: $(SRC)/model/TC_util.cpp $(HEADERS)
$(BIN)/TankController.o: $(SRC)/TankController.cpp $(HEADERS)
g++ -c $(FLAGS) $(INCLUDE) -o $(BIN)/TankController.o $(SRC)/TankController.cpp

$(BIN)/RemoteLogPusher.o: $(SRC)/model/RemoteLogPusher.cpp $(HEADERS)
g++ -c $(FLAGS) $(INCLUDE) -o $(BIN)/RemoteLogPusher.o $(SRC)/model/RemoteLogPusher.cpp

$(BIN)/DataLogger.o: $(SRC)/model/DataLogger.cpp $(HEADERS)
g++ -c $(FLAGS) $(INCLUDE) -o $(BIN)/DataLogger.o $(SRC)/model/DataLogger.cpp

Expand Down
1 change: 1 addition & 0 deletions examples/TankController/TankController.ino
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const char pushingBoxID[] = "";
// If it remains empty, the MAC address will be used. Keep in mind that
// the name should be unique across all devices, not just your devices.
// So "tank-1" is not a good name, but "Onthank-tank-1" is.
// The name will have ".log" added to it (so don't include it!).
const char remoteLogName[] = "";

// We query a web server for GMT time and then adjust for local time
Expand Down
2 changes: 1 addition & 1 deletion extras/device_client/lib/model/version.dart
Original file line number Diff line number Diff line change
@@ -1 +1 @@
const String gitVersion = 'v24.10.2-14-gf3+';
const String gitVersion = 'v24.10.2-105-g8+';
34 changes: 17 additions & 17 deletions extras/device_client/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ packages:
dependency: transitive
description:
name: _fe_analyzer_shared
sha256: "88399e291da5f7e889359681a8f64b18c5123e03576b01f32a6a276611e511c3"
sha256: "03f6da266a27a4538a69295ec142cb5717d7d4e5727b84658b63e1e1509bac9c"
url: "https://pub.dev"
source: hosted
version: "78.0.0"
version: "79.0.0"
_macros:
dependency: transitive
description: dart
Expand All @@ -18,10 +18,10 @@ packages:
dependency: transitive
description:
name: analyzer
sha256: "62899ef43d0b962b056ed2ebac6b47ec76ffd003d5f7c4e4dc870afe63188e33"
sha256: c9040fc56483c22a5e04a9f6a251313118b1a3c42423770623128fa484115643
url: "https://pub.dev"
source: hosted
version: "7.1.0"
version: "7.2.0"
args:
dependency: transitive
description:
Expand Down Expand Up @@ -313,10 +313,10 @@ packages:
dependency: "direct main"
description:
name: http_parser
sha256: "76d306a1c3afb33fe82e2bbacad62a61f409b5634c915fceb0d799de1a913360"
sha256: "178d74305e7866013777bab2c3d8726205dc5a4dd935297175b19a23a2e66571"
url: "https://pub.dev"
source: hosted
version: "4.1.1"
version: "4.1.2"
io:
dependency: transitive
description:
Expand Down Expand Up @@ -545,26 +545,26 @@ packages:
dependency: transitive
description:
name: pubspec_parse
sha256: "81876843eb50dc2e1e5b151792c9a985c5ed2536914115ed04e9c8528f6647b0"
sha256: "0560ba233314abbed0a48a2956f7f022cce7c3e1e73df540277da7544cad4082"
url: "https://pub.dev"
source: hosted
version: "1.4.0"
version: "1.5.0"
shared_preferences:
dependency: "direct main"
description:
name: shared_preferences
sha256: "3c7e73920c694a436afaf65ab60ce3453d91f84208d761fbd83fc21182134d93"
sha256: a752ce92ea7540fc35a0d19722816e04d0e72828a4200e83a98cf1a1eb524c9a
url: "https://pub.dev"
source: hosted
version: "2.3.4"
version: "2.3.5"
shared_preferences_android:
dependency: transitive
description:
name: shared_preferences_android
sha256: "02a7d8a9ef346c9af715811b01fbd8e27845ad2c41148eefd31321471b41863d"
sha256: "138b7bbbc7f59c56236e426c37afb8f78cbc57b094ac64c440e0bb90e380a4f5"
url: "https://pub.dev"
source: hosted
version: "2.4.0"
version: "2.4.2"
shared_preferences_foundation:
dependency: transitive
description:
Expand Down Expand Up @@ -774,18 +774,18 @@ packages:
dependency: transitive
description:
name: url_launcher_web
sha256: "772638d3b34c779ede05ba3d38af34657a05ac55b06279ea6edd409e323dca8e"
sha256: "3ba963161bd0fe395917ba881d320b9c4f6dd3c4a233da62ab18a5025c85f1e9"
url: "https://pub.dev"
source: hosted
version: "2.3.3"
version: "2.4.0"
url_launcher_windows:
dependency: transitive
description:
name: url_launcher_windows
sha256: "44cf3aabcedde30f2dba119a9dea3b0f2672fbe6fa96e85536251d678216b3c4"
sha256: "3284b6d2ac454cf34f114e1d3319866fdd1e19cdc329999057e44ffe936cfa77"
url: "https://pub.dev"
source: hosted
version: "3.1.3"
version: "3.1.4"
vector_math:
dependency: transitive
description:
Expand Down Expand Up @@ -860,4 +860,4 @@ packages:
version: "3.1.3"
sdks:
dart: ">=3.6.0 <4.0.0"
flutter: ">=3.24.0"
flutter: ">=3.27.0"
2 changes: 1 addition & 1 deletion extras/device_client/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: device_client
description: A web UI for the Open Acidification Tank Controller.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 24.10.2
version: 25.1.1

environment:
sdk: '>=3.3.0 <4.0.0'
Expand Down
49 changes: 49 additions & 0 deletions extras/docs/Network.drawio
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<mxfile host="Electron" agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/26.0.4 Chrome/128.0.6613.186 Electron/32.2.5 Safari/537.36" version="26.0.4">
<diagram name="Page-1" id="TVNFCbCHA6bo9ojTd-jz">
<mxGraphModel dx="717" dy="487" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1700" pageHeight="1100" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="mqZRchGrLW0FFxbzaa-a-2" value="oap-vm.cs" style="fontColor=#0066CC;verticalAlign=top;verticalLabelPosition=bottom;labelPosition=center;align=center;html=1;outlineConnect=0;fillColor=#CCCCCC;strokeColor=#6881B3;gradientColor=none;gradientDirection=north;strokeWidth=2;shape=mxgraph.networks.virtual_server;" vertex="1" parent="1">
<mxGeometry x="80" y="80" width="110" height="120" as="geometry" />
</mxCell>
<mxCell id="mqZRchGrLW0FFxbzaa-a-3" value="oap.cs (Traefik)" style="fontColor=#0066CC;verticalAlign=top;verticalLabelPosition=bottom;labelPosition=center;align=center;html=1;outlineConnect=0;fillColor=#CCCCCC;strokeColor=#6881B3;gradientColor=none;gradientDirection=north;strokeWidth=2;shape=mxgraph.networks.proxy_server;" vertex="1" parent="1">
<mxGeometry x="320" y="87.5" width="105" height="105" as="geometry" />
</mxCell>
<mxCell id="mqZRchGrLW0FFxbzaa-a-4" value="Tank Controller" style="fontColor=#0066CC;verticalAlign=top;verticalLabelPosition=bottom;labelPosition=center;align=center;html=1;outlineConnect=0;fillColor=#CCCCCC;strokeColor=#6881B3;gradientColor=none;gradientDirection=north;strokeWidth=2;shape=mxgraph.networks.desktop_pc;" vertex="1" parent="1">
<mxGeometry x="645" y="200" width="30" height="60" as="geometry" />
</mxCell>
<mxCell id="mqZRchGrLW0FFxbzaa-a-5" value="User Agent (Web)" style="fontColor=#0066CC;verticalAlign=top;verticalLabelPosition=bottom;labelPosition=center;align=center;html=1;outlineConnect=0;fillColor=#CCCCCC;strokeColor=#6881B3;gradientColor=none;gradientDirection=north;strokeWidth=2;shape=mxgraph.networks.pc;" vertex="1" parent="1">
<mxGeometry x="610" y="50" width="100" height="70" as="geometry" />
</mxCell>
<mxCell id="mqZRchGrLW0FFxbzaa-a-7" value="&lt;font style=&quot;font-size: 20px;&quot;&gt;A&lt;/font&gt;" style="html=1;outlineConnect=0;fillColor=#CCCCCC;strokeColor=#6881B3;gradientColor=none;gradientDirection=north;strokeWidth=2;shape=mxgraph.networks.comm_link_edge;html=1;rounded=0;" edge="1" parent="1" source="mqZRchGrLW0FFxbzaa-a-2" target="mqZRchGrLW0FFxbzaa-a-3">
<mxGeometry x="0.0769" width="100" height="100" relative="1" as="geometry">
<mxPoint x="490" y="470" as="sourcePoint" />
<mxPoint x="590" y="370" as="targetPoint" />
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="mqZRchGrLW0FFxbzaa-a-8" value="&lt;font style=&quot;font-size: 20px;&quot;&gt;B&lt;/font&gt;" style="html=1;outlineConnect=0;fillColor=#CCCCCC;strokeColor=#6881B3;gradientColor=none;gradientDirection=north;strokeWidth=2;shape=mxgraph.networks.comm_link_edge;html=1;rounded=0;" edge="1" parent="1" source="mqZRchGrLW0FFxbzaa-a-3" target="mqZRchGrLW0FFxbzaa-a-5">
<mxGeometry width="100" height="100" relative="1" as="geometry">
<mxPoint x="490" y="470" as="sourcePoint" />
<mxPoint x="590" y="370" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="mqZRchGrLW0FFxbzaa-a-9" value="&lt;font style=&quot;font-size: 20px;&quot;&gt;C&lt;/font&gt;" style="html=1;outlineConnect=0;fillColor=#CCCCCC;strokeColor=#6881B3;gradientColor=none;gradientDirection=north;strokeWidth=2;shape=mxgraph.networks.comm_link_edge;html=1;rounded=0;" edge="1" parent="1" source="mqZRchGrLW0FFxbzaa-a-3" target="mqZRchGrLW0FFxbzaa-a-4">
<mxGeometry width="100" height="100" relative="1" as="geometry">
<mxPoint x="490" y="480" as="sourcePoint" />
<mxPoint x="590" y="380" as="targetPoint" />
<Array as="points" />
</mxGeometry>
</mxCell>
<mxCell id="mqZRchGrLW0FFxbzaa-a-10" value="&lt;font style=&quot;font-size: 20px;&quot;&gt;D&lt;/font&gt;" style="html=1;outlineConnect=0;fillColor=#CCCCCC;strokeColor=#6881B3;gradientColor=none;gradientDirection=north;strokeWidth=2;shape=mxgraph.networks.comm_link_edge;html=1;rounded=0;" edge="1" parent="1" source="mqZRchGrLW0FFxbzaa-a-4" target="mqZRchGrLW0FFxbzaa-a-5">
<mxGeometry width="100" height="100" relative="1" as="geometry">
<mxPoint x="490" y="480" as="sourcePoint" />
<mxPoint x="590" y="380" as="targetPoint" />
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
4 changes: 4 additions & 0 deletions extras/docs/Network.drawio.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 55 additions & 0 deletions extras/docs/Network.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Architecture

## Machines

* **traefik** is a virtual machine that acts as the public-facing server for [oap.cs.wallawalla.edu](oap.cs.wallawalla.edu). It acts as a firewall and reverse-proxy, forwarding requests to oap-vm.
* **oap-vm** is a virtual machine in our CS Lab that supports various services for the Open Acidification Project (OAP).
* A **Tank Controller** is an Arduino-based device controller that monitors and manages temperature and pH for a tank (aquarium) used in ocean acidification research. It has a 4x4 keypad for input and a 16x2 LCD display for output. It has a serial port used to flash the program memory and communicate with a computer. It also has an Ethernet connection and can make and respond to HTTP requests (the system does not have adequate resources to support HTTPS).
* A **User Agent (Web Browser)** running on a separate machine that can connect to oap-vm or the tank controller.

## Applications

* The original application, **TankController**, is Arduino program that runs on the Tank Controller. It consists of a trivial "sketch" ([TankController.ino](../../examples/TankController/TankController.ino)), a primary library (TankController), and a number of other device-related libraries (see [libraries.md](libraries.md)).
* The second application, **device_client**, is a Flutter application that mimics the Tank Controller's keypad and LCD. It is a single-page application (SPA) served from http://oap.cs.wallawalla.edu. After the static files are loaded, it presents a GUI in which the user can enter the IP address of a Tank Controller and interact—using the web browser—with the Tank Controller as if the device were physically present. The fact that we use one browser to interact with multiple servers presents a couple complications.
* First, most browsers prevent "Cross-Origin Resource Sharing (CORS)" unless explicitly enabled. In particular, CORS is designed to prevent a malicious (primary) site from scraping content from a secondary site (say, a bank), and sending it to the user (making the user think it is interacting with the bank when it is actually interacting with the malicious site). A secondary site may, however, authorize a primary site to collect and display its data by adding `Access-Control-Allow-Origin: *` to a response header. The TankController does this, and thus solves the CORS issue.
* Second, if a page is served with HTTPS (typically indicated by a lock in the address bar), most browsers do not let JavaScript on the page make HTTP requests because this would violate the user's expectation of security in the content. This means that if any data is obtained using HTTP, the entire page must be loaded as HTTP (to adequately communicate "insecure" to the user). As mentioned above, the Tank Controller's Arduino processor does not have adequate resources to handle HTTPS, so the Flutter-generated files served from oap.cs.wallawalla.edu must be served using HTTP before making the HTTP requests to the Tank Controller.
* While the browser sees the device_client app as HTTP, it is actually served by oap-vm as HTTPS and sent on by traefik as HTTP.
* The third application, **log_file_server**, is a Dart server application that runs on oap-vm and accepts data from a Tank Controller and stores it on disk where it can be served by an Nginx web server on oap-vm. Because the Tank Controller does not support HTTPS (either as client or server), the data upload must be done using HTTP to oap.cs.wallawalla.edu (traefik) where it is converted to HTTPS and forwarded to oap-vm. This application also generates an abridged copy of the data to be used as thumbnails showing summary information for a group of Tank Controllers.
* The fourth application, **log_file_client**, is a Flutter SPA that takes the data saved by log_file_server (from the Tank Controllers), and presents it in a graphical format. Because it does not interact directly with a Tank Controller, it can be served from https://oap.cs.wallawalla.edu. In fact, the distinction between device_client and log_file_client is http vs. https.

## Communication

![Network Architecture Diagram](Network.drawio.svg)

* **A**: traefik communicates with oap-vm on an internal network using HTTPS using a self-signed certificate generated by oap-vm and recognized by traefik.
* **B**: The user requests device_client (http://oap.cs.wallawalla.edu) or log_file_client (https://oap.cs.wallawalla.edu) from traefik which forwards the requests to oap-vm.
* **C**: A Tank Controller can send data to log_file_server (using HTTP) to be saved on oap-vm.
* **D**: Using device_client, a user can interact directly with a live Tank Controller (using HTTP).

## Traefik and Nginx Configuration

Traefik receives several types of requests (on links B and C) that it passes on to oap-vm (on link A). Each is sent to oap-vm using HTTPS, so the request needs to be mapped to something that Nginx on oap-vm can recognize as distinct.

### HTTPS

1. GET https://oap.cs.wallawalla.edu/api/ requests are for recent lines from files saved by the log_file_server app (link B).
* Traefik forwards to https://oap.vm.cs.wallawalla.edu:443/
* Nginx forwards to http://localhost:8080 (log_file_server)
1. GET https://oap.cs.wallawalla.edu/logs/ requests are for files saved by the log_file_server app (link B).
* Traefik forwards to https://oap.vm.cs.wallawalla.edu:443/
* Nginx serves `/var/www/html` with `autoindex on`
1. GET https://oap.cs.wallawalla.edu/ requests are for the log_file_client app (link B).
* Traefik forwards to https://oap.vm.cs.wallawalla.edu:443/
* Nginx serves `/var/www/html/log_file_client/`

### HTTP

1. GET http://oap.cs.wallawalla.edu/ requests are for the device_client app (link B).
* Traefik forwards to https://oap.vm.cs.wallawalla.edu:444/
* Nginx serves `/var/www/html/device_client/`
1. HEAD http://oap.cs.wallawalla.edu/logs/ requests are for the size of log files (link C).
* Traefik forwards to https://oap.vm.cs.wallawalla.edu:444/logs/
* Nginx serves `/var/www/html/`
1. POST http://oap.cs.wallawalla.edu/api/ requests are to the log_file_server app (link C).
* Traefik forwards to https://oap.vm.cs.wallawalla.edu:444/api/
* Nginx forwards to http://localhost:8080 (log_file_server)
4 changes: 2 additions & 2 deletions extras/log_file_client/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,10 @@ packages:
dependency: transitive
description:
name: http_parser
sha256: "76d306a1c3afb33fe82e2bbacad62a61f409b5634c915fceb0d799de1a913360"
sha256: "178d74305e7866013777bab2c3d8726205dc5a4dd935297175b19a23a2e66571"
url: "https://pub.dev"
source: hosted
version: "4.1.1"
version: "4.1.2"
intl:
dependency: "direct main"
description:
Expand Down
2 changes: 1 addition & 1 deletion extras/log_file_client/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: log_file_client
description: "A new Flutter project."
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 24.10.2
version: 25.1.1

environment:
sdk: '>=3.3.1 <4.0.0'
Expand Down
Loading