Snorktracker
 All Data Structures Files Functions Variables Macros Pages
GsmPower.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2018 SFini
3 
4  This program is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
28 {
29 protected:
31 
32  int pinPower;
34 
35 public:
36  MyGsmPower(MyData &data, int pin);
37 
38  bool begin();
39 
40  void on();
41  void off();
42 };
43 
44 /* ******************************************** */
45 
48  : myData(data)
49  , pinPower(pin)
50  , powerOnStartSec(0)
51 {
52 }
53 
56 {
57  MyDbg(F("MyGsmPower::begin"));
58  pinMode(pinPower, INPUT);
59  return true;
60 }
61 
64 {
65  MyDbg(F("MyGsmPower::on"));
66  pinMode(pinPower, OUTPUT);
67  digitalWrite(pinPower, LOW);
68  myData.isPowerOn = true;
69  powerOnStartSec = millis() / 1000;
70  MyDelay(1000);
71 }
72 
75 {
76  MyDbg(F("MyGsmPower::off"));
77  pinMode(pinPower, INPUT);
78  digitalWrite(pinPower, HIGH);
79  myData.rtcData.powerOnTimeSec += millis() / 1000 - powerOnStartSec;
80  myData.isPowerOn = false;
81  powerOnStartSec = 0;
82 }
long powerOnStartSec
Timestamp of power on.
Definition: GsmPower.h:33
class MyData::RtcData rtcData
Data to store in the RTC memory.
int pinPower
esp8266 pin connected with pin 5 of the LM2596 modul.
Definition: GsmPower.h:32
Definition: Data.h:27
void MyDbg(String info, bool fromWebServer=false, bool newline=true)
Definition: Utils.h:94
long powerOnTimeSec
Time the sim808 is on power without current millis..
Definition: Data.h:38
void on()
Definition: GsmPower.h:63
MyGsmPower(MyData &data, int pin)
Definition: GsmPower.h:47
MyData & myData
Reference to the data.
Definition: GsmPower.h:30
void MyDelay(long millisDelay)
Definition: Utils.h:104
bool isPowerOn
Is the power of the sim808 switched on?
Definition: Data.h:66
bool begin()
Definition: GsmPower.h:55
void off()
Definition: GsmPower.h:74
MyData myData
The global collected data.
Definition: tracker.ino:58