init
Dependencies: aconno_I2C Lis2dh12 WatchdogTimer
Diff: main.cpp
- Revision:
- 23:a3b0ccf75ca5
- Parent:
- 22:810425eb76e1
- Child:
- 24:c161db07557f
diff -r 810425eb76e1 -r a3b0ccf75ca5 main.cpp --- a/main.cpp Sat Dec 22 19:33:35 2018 +0000 +++ b/main.cpp Sun Dec 23 01:37:00 2018 +0000 @@ -13,6 +13,7 @@ static void buttonPress(void); static void buttonRelease(void); static void saveEventTimes(void); +static void event_location_tx(void); //------------------------------------------------------------------------------ //GLOBAL VARS / CLEARED ON SLEEP (IF USING SOFT REBOOT HACK) @@ -339,6 +340,9 @@ RET_motionState = true; RET_motionTriggeredInTXInterval = true; if (GLOBAL_debugLED) LED1blink(10,100); + if (RET_setting_activity_mode == 1) { + //RET_activityData + } } } if (RET_motionPendingOffState) { @@ -348,6 +352,9 @@ GLOBAL_motionStopFlagTriggered = true; RET_motionTotalActivityHours += (float(RET_motionStopTime - RET_motionStartTime) / 3600.0); if (GLOBAL_debugLED) LED1blink(5,500); + if (RET_setting_activity_mode == 1) { + + } } } } @@ -453,6 +460,7 @@ RET_imei = modem.getIMEI(); GLOBAL_imei = RET_imei; DEBUG("imei: %lld \n",RET_imei); + //char* modemModel = modem.getModemModel(); if (modem.registerOnNetwork(2,180000)) { int timetaken = (RET_RTCunixtime - GLOBAL_wakeTime); char bytestosend[160]; @@ -518,23 +526,21 @@ float temperature = getTemperature(); Modem modem(PN_UART_TX, PN_UART_RX, PN_UART_CTS, PN_UART_RTS, PN_GSM_PWR_KEY, PN_VREG_EN, PN_GSM_WAKE_DISABLE); if (modem.on()) { - int timetaken = (RET_RTCunixtime - GLOBAL_wakeTime); - char gpsString[70]; + char locString[70]; if (RET_setting_location_accuracy > 0) { - snprintf(gpsString,sizeof(gpsString),"%s",modem.getLocation(RET_setting_location_accuracy, RET_setting_location_timeout)); - DEBUG("\ngpsString:%s\n",gpsString); - } else { - DEBUG("localisation disabled\n"); + memcpy(locString, modem.getLocation(RET_setting_location_accuracy, RET_setting_location_timeout), 70); + //DEBUG("locString:%s-\n",locString); } //SEND DATA if (modem.registerOnNetwork(2,180000)) { - char bytestosend[160]; - snprintf(bytestosend,sizeof(bytestosend),"(%s,f:%d,t:%.2f,v:%.2f,z:OK,e:%d,c:1%s)\0",GLOBAL_defaultApi,FW_VERSION,temperature,GLOBAL_voltage,timetaken,gpsString); + int timetaken = (RET_RTCunixtime - GLOBAL_wakeTime); + char bytesToSend[160]; + snprintf(bytesToSend,sizeof(bytesToSend),"(%s,f:%d,t:%.2f,v:%.2f,z:OK,e:%d,c:1%s)\0",GLOBAL_defaultApi,FW_VERSION,temperature,GLOBAL_voltage,timetaken,locString); char result[180]; bool getSettings = true; - snprintf(result,sizeof(result),"%s",modem.USSDmessage(bytestosend, getSettings, 2, GLOBAL_defaultApi)); + snprintf(result,sizeof(result),"%s",modem.USSDmessage(bytesToSend, getSettings, 2, GLOBAL_defaultApi)); if (result != "err") { - DEBUG("\nfromserver: %s \n",result); + //DEBUG("\nfromserver: %s \n",result); if (getSettings) { saveSettings(result); } @@ -677,7 +683,7 @@ GLOBAL_wakeTime = RET_RTCunixtime; //MAIN LOGIC - DEBUG("STATE:%d, HAVESETTINGS:%d, RTC:%u, BOOTAT:%u, LOC:%u, LOC_FS:%u, ACT:%u \n", RET_state, RET_haveSettings, RET_RTCunixtime,RET_SetupRunAt,RET_eventTime_location_tx,RET_eventTime_location_failsafe_tx,RET_eventTime_activity_tx); + DEBUG("STATE:%d, HAVESETTINGS:%d, RTC:%u, BOOTAT:%u, LOC:%u, LOCFS:%u, ACT:%u \n", RET_state, RET_haveSettings, RET_RTCunixtime,RET_SetupRunAt,RET_eventTime_location_tx,RET_eventTime_location_failsafe_tx,RET_eventTime_activity_tx); mainStateEngine(); //PRE-SLEEP ACTIONS