ROM Comm / Mbed 2 deprecated espar_mini_control_CAN

Dependencies:   mbed mbed-STM32F103C8T6

Revision:
10:a82e51837e2b
Parent:
9:6126b83608be
Child:
11:b571de4666c9
--- a/heatcontrol.cpp	Thu Jun 11 21:57:29 2020 +0000
+++ b/heatcontrol.cpp	Fri Jun 12 23:28:43 2020 +0000
@@ -74,7 +74,7 @@
 // external timer variables to use for timing (ie 1 minute, etc.)
 extern volatile unsigned char idletimer;
 extern void DebugWrite(const char* str);
-struct sHeatVars heaterState[2];
+struct sHeatVars heaterState[HEATERSTATECOUNT];
 
 char otherControllerDetected = 0;
 /******************************************************
@@ -1707,18 +1707,22 @@
     {
        
         // start blank
-
-        if (((canMsg.id == 0x07A0)))
+        if ((canMsg.id == 0x0055)) {
+            // sub our own
+            DebugWrite("SUBSTITUTE ALTITUDE CMD\r\n");
+            sendAltitudeMode(s);
+        }
+        if ((canMsg.id == 0x07A0) || (canMsg.id == 0x060D) || (canMsg.id == 0x0057) )
         {
-            otherControllerDetected = 30;
+            otherControllerDetected = 300;
             DebugWrite("\r\n****OTHER CONTROLLER ON NETWORK*****\r\n");
         }
         if (((canMsg.id != 0x0625) && (canMsg.id != 0x02C4)) && (canMsg.id != 0x02C6) && (canMsg.id != 0x0626) && (canMsg.id != 0x02D0)
                 && (canMsg.id != 0x02CE))
         {
-            //
-            //DebugWrite("0-");
-            //  printCAN(&canMsg);
+            
+            DebugWrite("0-");
+            printCAN(&canMsg);
         }
         else if ((canMsg.id == 0x0625) || (canMsg.id == 0x0626))
         {
@@ -1726,18 +1730,10 @@
             {
                 heaterToUpdate = &(heaterState[0]);
             }
-            else if ((canMsg.id == 0x0625) && (heaterState[1].bustype == HEATERTYPECAN) && (heaterState[1].heaternum == 1))
-            {
-                heaterToUpdate = &(heaterState[1]);
-            }
             else if ((canMsg.id == 0x0626) && (heaterState[0].bustype == HEATERTYPECAN) && (heaterState[0].heaternum == 2))
             {
                 heaterToUpdate = &(heaterState[0]);
             }
-            else if ((canMsg.id == 0x0626) && (heaterState[1].bustype == HEATERTYPECAN) && (heaterState[1].heaternum == 2))
-            {
-                heaterToUpdate = &(heaterState[1]);
-            }
             heaterToUpdate->heaterDetected = 60; // preserve for a min.
             // unpack and document
             NM_Heater_1_t heaterInfo;
@@ -1808,10 +1804,6 @@
                 {
                     heaterToUpdate = &(heaterState[0]);
                 }
-                else if ((heaterState[1].bustype == HEATERTYPECAN) && (heaterState[1].heaternum == 1))
-                {
-                    heaterToUpdate = &(heaterState[1]);
-                }
                 else
                 {
                     DebugWrite("Unable to update 0x02C6\r\n");
@@ -1823,10 +1815,6 @@
                 {
                     heaterToUpdate = &(heaterState[0]);
                 }
-                else if ((heaterState[1].bustype == HEATERTYPECAN) && (heaterState[1].heaternum == 2))
-                {
-                    heaterToUpdate = &(heaterState[1]);
-                }
                 else
                 {
                     DebugWrite("Unable to update 0x02D0\r\n");
@@ -1893,10 +1881,6 @@
             {
                 heaterToUpdate = &(heaterState[0]);
             }
-            else if ((heaterState[1].bustype == HEATERTYPECAN) && (heaterState[1].heaternum == heater))
-            {
-                heaterToUpdate = &(heaterState[1]);
-            }
             else
             {
                 DebugWrite("Unable to update 0x02C6\r\n");
@@ -2016,11 +2000,12 @@
     //DebugWrite("Listen Only\r\n");
 
     readCAN(s);
-    if ((otherControllerDetected > 0) && s->tasksequence > 1)
+    if ((otherControllerDetected > 0))
     {
         s->tasksequence = 0;
         s->heatOn = HEATCALLOFF;
-        //return;
+        
+        return; // don't send anything.
     }
 #ifdef LISTENONLY
     return;