UCSD-E4E / smartfin-fw2

Smartfin FW 2
GNU General Public License v3.0
1 stars 0 forks source link

Have wet/dry sensor kick device out of upload mode while connecting to cellular network #27

Open SUPScientist opened 3 years ago

SUPScientist commented 3 years ago

While current firmware is attempting to connect to a cellular network, submersion in water (tripping of wet/dry sensor) does not immediately trigger a new session. It would be a valuable addition to have submersion in water always trigger init/log surf session states (i.e., interrupt an upload attempt). The upload attempt can occur later.

Use case: fin is in log surf session state. Board is turned over or fin is otherwise kept dry for enough time to transition to upload state. Surfer re-enters water prior to fin establishing cellular connection and therefore stays in upload state even though user might expect that it is once again logging data.

ntlhui commented 2 years ago

Testing against 59c05d8 with 3G fin (no antenna)

Steps:

  1. Reset fin
  2. Enter CLI mode
  3. Create files
  4. Enter upload mode
  5. Short W/D sensor
ntlhui commented 2 years ago

W/D sensor does not work during STATE_UPLOAD

ntlhui commented 2 years ago

W/D sensor is not responsive enough.

Recommended patch:

diff --git a/src/dataUpload.cpp b/src/dataUpload.cpp
index a79e84b..f1f0a43 100644
--- a/src/dataUpload.cpp
+++ b/src/dataUpload.cpp
@@ -58,7 +58,7 @@ STATES_e DataUpload::run(void)
         startConnectTime = millis();
         while(1)
         {
-            if(pSystemDesc->pWaterSensor->getCurrentStatus())
+            if(pSystemDesc->pWaterSensor->getCurrentReading())
             {
                 return STATE_SESSION_INIT;
             }
@@ -100,7 +100,7 @@ STATES_e DataUpload::run(void)
         }

         // connected, but maybe we went into the water
-        if(pSystemDesc->pWaterSensor->getLastStatus() == WATER_SENSOR_HIGH_STATE)
+        if(pSystemDesc->pWaterSensor->getLastReading() == WATER_SENSOR_HIGH_STATE)
         {
             SF_OSAL_printf("In the water!\n");
             return STATE_SESSION_INIT;
ntlhui commented 1 year ago

Blocking on results of #25