init
Dependencies: aconno_I2C Lis2dh12 WatchdogTimer
Diff: main.cpp
- Revision:
- 35:d9421d57d116
- Parent:
- 34:4493c9f6d707
- Child:
- 36:8e359069192b
--- a/main.cpp Sun Jan 13 23:40:56 2019 +0000 +++ b/main.cpp Sun Jan 13 23:48:41 2019 +0000 @@ -41,7 +41,7 @@ bool GLOBAL_accel_healthy = false; bool GLOBAL_motionStopFlagTriggered = false; bool GLOBAL_debugLED = true; -bool GLOBAL_needToConfigureLis3dh = true; +bool GLOBAL_needToConfigureLis3dh = false; bool GLOBAL_registeredOnNetwork = false; bool GLOBAL_modemOn = false; bool GLOBAL_LEDSequenceinProgress = false; @@ -410,6 +410,62 @@ memset(GLOBAL_exceptionString,0x00,sizeof(GLOBAL_exceptionString)); if (DEBUG_ON) {memset(GLOBAL_debug_buffer,0x00,sizeof(GLOBAL_debug_buffer));} } +void factoryReset() { + //IDENTITY + //RET_imei = 0; + //STATE + RET_haveSettings = 0; + RET_state = STATE_SETUP; + RET_state_prev = RET_state; + RET_RTCunixtime = 0; + RET_SetupRunAt = 0; + RET_SettingsGotAt = 0; + //SETTINGS + RET_setting_firmware = 0; + RET_setting_minimumupdate_hrs = 0; + RET_setting_location_mode = DEFAULT_LOCATION_MODE; + RET_setting_location_accuracy = DEFAULT_LOCATION_ACCURACY; + RET_setting_location_tx_interval_mins = DEFAULT_LOCATION_TX_INTERVAL_MINS; + RET_setting_location_tx_failsafe_hrs = DEFAULT_LOCATION_TX_FAILSAFE_HRS; + RET_setting_location_timeout = DEFAULT_LOCATION_TIMEOUT; + RET_setting_activity_tx_interval_hrs = 0; + RET_setting_environmental_tx_interval_mins = 0; + RET_setting_motion_g = DEFAULT_MOTION_G; + RET_setting_motion_start_seconds = DEFAULT_MOTION_START_SECONDS; + RET_setting_motion_stop_seconds = DEFAULT_MOTION_STOP_SECONDS; + RET_setting_impact_g = 0; + RET_setting_impact_alert = 0; + RET_setting_connection_timeout = DEFAULT_CONNECTION_TIMEOUT; + RET_setting_beacon_interval_seconds = DEFAULT_BEACON_INTERVAL_SECONDS; + RET_setting_beacon_scan = 0; + RET_buttonPressCount = 0; + RET_buttonPressTime = 0; + RET_buttonHoldTime = 0; + //MOTION STATE + RET_motionTriggered = 0; + RET_motionTriggeredInTXInterval = 0; + RET_motionStartTime = 0; + RET_motionStopTime = 0; + RET_motionPendingOnState = 0; + RET_motionPendingOffState = 0; + RET_motionState = 0; + RET_motionTotalActivityHours = 0.0; + RET_motionFrameStart = 0; + memset(RET_activityData,0x00,sizeof(RET_activityData)); + //IMPACT + RET_impactTriggered = 0; + //EVENT HANDLING + RET_eventTime_location_log = 0; + RET_eventTime_location_tx = 0; + RET_eventTime_location_failsafe_tx = 0; + RET_eventTime_environmental_log = 0; + RET_eventTime_environmental_tx = 0; + RET_eventTime_activity_tx = 0; + RET_eventTime_wakeFromDormant = 0; + + //PERIPHERAL RESET + lis3dh_configureForSleep(DEFAULT_MOTION_G,DEFAULT_IMPACT_G); +} bool selfTest() { int test_count = 0; @@ -925,6 +981,7 @@ //CHECK FOR FIRST BOOT if (RET_coldBoot == 1) { + factoryReset(); LED1errorCode(6,2); }