init
Dependencies: aconno_I2C Lis2dh12 WatchdogTimer
Diff: main.cpp
- Revision:
- 2:fd554f01abdf
- Parent:
- 0:94b743e06998
- Child:
- 4:8d8e9bfa82e4
--- a/main.cpp Sat Oct 27 23:09:30 2018 +0000 +++ b/main.cpp Thu Nov 08 15:08:47 2018 +0000 @@ -2,6 +2,8 @@ #include "board.h" #include "modes.h" +//#include "ATCommand.h" + //LowPowerTicker ticker; //no impact on power consumption //------------------------------------------------------------------------------ @@ -11,14 +13,13 @@ static void loop(void); static void mode_mtu(void); static int selftest(void); -static void LEDon(int milliseconds); +static void LEDon(void); static void LEDoff(void); //------------------------------------------------------------------------------ //Var declarations- Local //------------------------------------------------------------------------------ int mode = 0; -string exceptions = ""; bool accel_healthy = false; //------------------------------------------------------------------------------ @@ -66,21 +67,24 @@ //------------------------------------------------------------------------------ //Peripherals //------------------------------------------------------------------------------ -Serial uart(USBTX, USBRX, 115200); -LIS3DH accelerometer(p23, p19, p24, p22, LIS3DH_DR_NR_LP_25HZ, LIS3DH_FS_8G); -BLE myble; + +//LIS3DH accelerometer(p23, p19, p24, p22, LIS3DH_DR_NR_LP_25HZ, LIS3DH_FS_8G); +//BLE myble; + +//Serial uart(p6, p8, 115200); +//ATSerial atserial(p6,p8,115200); -void gotosleep(long milliseconds) { - accelerometer.configureForSleep(); - Thread::wait(milliseconds); +void gotosleep(long sleep_milliseconds) { + //accelerometer.configureForSleep(); + ThisThread::sleep_for(sleep_milliseconds); //system_reset(); } -void LED1on(int milliseconds = 0) { +void LED1on(long flash_milliseconds = 0) { led1 = 0; - if (milliseconds > 0) { - Thread::wait(milliseconds); + if (flash_milliseconds > 0) { + ThisThread::sleep_for(flash_milliseconds); led1 = 1; } } @@ -95,36 +99,41 @@ } } +bool GSMon() { + //power on GSM + vreg_en = 1; + ThisThread::sleep_for(500); + gsm_pwkey = 0; + ThisThread::sleep_for(1500); + gsm_pwkey = 1; + LED1on(1000); +} void setup() { led1 = 1; + LED1on(50); + set_time(1256729737); + //accelerometer.configureForSleep(); + ThisThread::sleep_for(10000); + LIS3DH accelerometer(p23, p19, p24, p22, LIS3DH_DR_NR_LP_25HZ, LIS3DH_FS_8G); - accelerometer.configureForSleep(); + ThisThread::sleep_for(10000); + system_reset(); } void loop() { + LED1on(50); bool accel_awake; - //uart.printf("blah blah blah"); - //sleep_manager_lock_deep_sleep(); - //uart.printf("Deep sleep allowed: %i\r\n", sleep_manager_can_deep_sleep()); - /* - if (accelerometer.read_id() == 51){ - led1 = 0; - Thread::wait(20); - led1 = 1; - } else { - led1 = 1; - }; - */ + mode = MODE_SETUP; switch(mode) { case MODE_SETUP : - selftest(); + //selftest(); break; case MODE_INTERVAL : @@ -136,7 +145,7 @@ break; case MODE_MTU : - mode_mtu(); + //mode_mtu(); break; case MODE_DORMANT : @@ -148,14 +157,12 @@ } - - - gotosleep(60000); + gotosleep(10000); } - +/* void initMotion() { //CHECK FOR ANY MOTION if (!accelerometer.selfTest()) { @@ -242,11 +249,12 @@ } } +*/ - +/* int selftest() { int result = 0; @@ -265,4 +273,5 @@ }; return result; -} \ No newline at end of file +} +*/ \ No newline at end of file