forked from Seeed-Studio/Seeed_Wio_GPS_Board
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMC20_Common.h
executable file
·203 lines (172 loc) · 5.74 KB
/
MC20_Common.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
/*
* GPSTracker_Arduino_Interface.h
* A library for SeeedStudio GPS Tracker
*
* Copyright (c) 2017 seeed technology inc.
* Website : www.seeed.cc
* Author : lawliet zou, lambor
* Create Time: April 2017
* Change Log :
*
* The MIT License (MIT)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef __MC20_COMMON_H__
#define __MC20_COMMON_H__
#include "MC20_Arduino_Interface.h"
/** GPSTracker class.
* used to realize GPSTracker communication
*/
enum Protocol {
CLOSED = 0,
TCP = 1,
UDP = 2,
};
class GPSTracker
{
public:
/** Create GPSTracker instance
* @param number default phone number during mobile communication
*/
GPSTracker();
/** get instance of GPSTracker class
*/
// static GPSTracker* getInstance() {
// return inst;
// };
/** initialize GPSTracker module including SIM card check & signal strength
* @return true if connected, false otherwise
*/
bool init(void);
/** check if GPSTracker module is powered on or not
* @returns
* true on success
* false on error
*/
bool Check_If_Power_On(void);
/** power Up GPSTracker module
* @param pin D13 is connectted to a power switch IC, the power is on when pin D13 pull up.
* @returns
*
*/
void Power_On(void);
/** power reset for SIM800 board
* @param pin (preconfigurated as OUTPUT)
* @returns
*
*/
void powerReset(void);
void io_init();
/** Wait for network register
*
*
* @returns
* true on success
* false on error
*/
bool waitForNetworkRegister(void);
/** send text SMS
* @param *number phone number which SMS will be send to
* @param *data message that will be send to
* @returns
* true on success
* false on error
*/
bool sendSMS(char* number, char* data);
/** read SMS, phone and date if getting a SMS message. It changes SMS status to READ
* @param messageIndex SIM position to read
* @param message buffer used to get SMS message
* @param length length of message buffer
* @param phone buffer used to get SMS's sender phone number
* @param datetime buffer used to get SMS's send datetime
* @returns
* true on success
* false on error
*/
bool readSMS(int messageIndex, char *message, int length, char *phone, char *datetime);
/** read SMS if getting a SMS message
* @param buffer buffer that get from GPSTracker module(when getting a SMS, GPSTracker module will return a buffer array)
* @param message buffer used to get SMS message
* @param check whether to check phone number(we may only want to read SMS from specified phone number)
* @returns
* true on success
* false on error
*/
bool readSMS(int messageIndex, char *message, int length);
/** delete SMS message on SIM card
* @param index the index number which SMS message will be delete
* index > 998, delete all message stored on SIM card
* @returns
* true on success
* false on error
*/
bool deleteSMS(int index);
/** call someone
* @param number the phone number which you want to call
* @returns
* true on success
* false on error
*/
bool callUp(char* number);
/** auto answer if coming a call
* @returns
*/
void answer(void);
/** hang up if coming a call
* @returns
* true on success
* false on error
*/
bool hangup(void);
/** get Signal Strength from SIM900 (see AT command: AT+CSQ) as integer
* @param
* @returns
* true on success
* false on error
*/
bool getSignalStrength(int *buffer);
int recv(char* buf, int len);
/** GSM power Mode
* @param
* 0, least consumption 1, 4
* 1, standard mode
* 4, shut down RF send and receive function
*/
bool GSM_work_mode(int mode);
/** Config GSM slow clock mode
* @param
* 0 Disable slow clock
* 1 Enable slow clock, and it is controlled by DTR
* 2 When there is no data on serial port in 5 seconds, module will enter Sleep Disable slow clock
*/
bool GSM_config_slow_clk(int mode);
/**
* Turn off module power buy AT commnad
*/
bool AT_PowerDown(void);
// private:
bool checkSIMStatus(void);
int PWR_KEY = 13; // Pulse power control
int PWR_BAT = 7; // BAT power
int RGB_PIN = 10; // RGB LED Pin
int VB_PIN = 12; // VCCB control pin
int DTR_PIN = 9;
};
#endif