Bootcamp_Final

Dependencies:   lorawan1v1

Fork of LoRaWAN-grove-cayenne by wayne roberts

Revision:
3:fc23bbc14475
Parent:
2:da3c8d5b3f49
Child:
4:72b8fdc9878e
--- a/sensorDemoVT100.cpp	Mon Mar 05 16:51:20 2018 -0800
+++ b/sensorDemoVT100.cpp	Mon Mar 19 14:46:37 2018 -0700
@@ -162,7 +162,7 @@
 #endif
 
 #if defined(TARGET_FF_ARDUINO)
-DigitalIn d8(D8);
+InterruptIn d8(D8);
 DigitalOut extLed(D15);
 #endif /* TARGET_FF_ARDUINO */
 
@@ -397,6 +397,7 @@
     }
 }
 
+
 /*!
  * \brief   Prepares the payload of the frame
  *
@@ -1034,6 +1035,12 @@
     }
 }
 
+static void d8isr()
+{
+    c_ch = 0xff;
+    DeviceState = DEVICE_STATE_SEND;
+    buttonStartAt = LoRaMacReadTimer();
+}
 
 static const LoRaMacPrimitives_t LoRaMacPrimitives = {
     McpsConfirm,
@@ -1097,6 +1104,7 @@
                 cayenne_ack_ch = -1;
                 c_ch = 0xff;
                 d8.mode(PullDown);                
+                d8.rise(d8isr);
 
                 mibReq.Type = MIB_ADR;
                 mibReq.Param.AdrEnable = LORAWAN_ADR_ON;
@@ -1229,18 +1237,15 @@
                 break;
             }
             case DEVICE_STATE_TRIGGER:
+                /* wait button ISR */
                 sleep_manager_sleep_auto();
-                if (d8.read() == 1) {
-                    c_ch = 0xff;
-                    DeviceState = DEVICE_STATE_SEND;
-                    buttonStartAt = LoRaMacReadTimer();
-                }
                 break;
             default:
                 DeviceState = DEVICE_STATE_INIT;
                 break;
         } // ..switch( DeviceState )
 
+        LoRaMacUserContext();
     } // ..while( 1 )
 }
 #endif /* ENABLE_VT100 */