forked from codezoo-ltd/CodeZoo_CATM1_Arduino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBG96.h
204 lines (162 loc) · 4.15 KB
/
BG96.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
204
/*
* A library for controlling BG96 LTE CAT.M1
*
* @Author Rooney.Jang [CodeZoo]
* @Date 01/09/2020
*
*/
#ifndef BG96_h
#define BG96_h
#include "Countdown.h"
class BG96 {
public:
/*
* A simplified constructor taking only a Stream ({Software/Hardware}Serial)
* object. The serial port should already be initialised when initialising
* this library.
*/
BG96(Stream &serial, Stream &debug, uint8_t pwr_pin, uint8_t status_pin);
/*
* Power on the module.
*/
int pwrON(void);
/*
* Power off the module.
*/
int pwrOFF(void);
/*
* Power status check the module.
*/
int isPwrON(void);
/*
* Initialization the module.
*/
int init(void);
/*
* Return current date & time.
*/
int getCCLK(char *szCCLK, int nBufferSize);
/*
* Request Manufacturer Revision.
*/
int getCGMR(char *szCGMR, int nBufferSize);
/*
* Request Product Serial Number (returns the IMEI).
*/
int getIMEI(char *szIMEI, int nBufferSize);
/*
* Request Change device functionality status. (0-1)
*/
int getCFUN(int *value);
/*
* Set Change device functionality. (0-1)
*/
int setCFUN(int value);
/*
* Request international mobile subscriber identity.
*/
int getCIMI(char *szCIMI, int nBufferSize);
/*
* PDP status check the module.
*/
int isActPDP(char *szPDP, int nBufferSize);
/*
* Activate a PDP Context
*/
int actPDP(void);
/*
* Deactivate a PDP Context
*/
int deActPDP(void);
/*
* EPS network registration status.
*/
int canConnect(void);
/*
* Get serving cellID information.
*/
int getServingCell(char *servingCell);
/*
* Get RSRP(Reference Signal Received Power) information.
*/
int getRSRP(int *rsrp);
/*
* Get SINR(Signal Interference plus Noise Ratio) information.
*/
int getSINR(int *sinr);
/*
* Get RSSI(Received Signal Strength Indicator) information.
*/
int getRSSI(int *rssi);
/*
* Get TX power.
*/
int getTxPower(int *txPower);
/*
* Create UDP/TCP Socket.
* service_type : 0(UDP) or 1(TCP)
* remote_address : IP_address or domain_name
* remote_port : (0-65535)
*/
int socketCreate(int service_type, char *remote_address, long remote_port);
/*
* Close UDP/TCP Socket.
*/
int socketClose(void);
/*
* Send UDP/TCP Socket.
*/
int socketSend(char *buffer, int size);
int socketSend(const char *str);
/*
* Receive UDP/TCP Socket.
*/
int socketRecv(char *buffer, int bufferSize, int *recvSize,
unsigned long timeout);
/*
* Activate a GPS
*/
int actGPS(void);
/*
* Deactivate a GPS
*/
int deActGPS(void);
/*
* Get GPS Location
*/
int getGPSLoc(char *buffer, int bufferSize);
/*
* Power Saving Mode Disable function. BG96 Default, 0(Disable)
*/
int disablePSM(void);
/*
* Reset the module.
*/
// void BG96_reset(void);
private:
int sendServicecmd(char *szCmd, char *szResponse, int nResponseBufSize,
int *recvSize, unsigned long ulWaitDelay = 2000);
int sendSckATcmd(char *szCmd, char *szResponse, int nResponseBufSize,
const char *szResponseFilter,
unsigned long ulWaitDelay = 2000);
int sendATcmd(char *szCmd, char *szResponse, int nResponseBufSize,
const char *szResponseFilter, unsigned long ulWaitDelay = 2000);
int sendATcmd(char *szCmd, char *aLine[], int nMaxLine,
unsigned long ulWaitDelay = 2000);
int readServiceResponseLine(char *szLine, int nLineBufSize, int *recvSize,
unsigned long ulDelay);
int readSckresponseLine(char *szLine, int nLineBufSize,
const char *szResponseFilter, unsigned long ulDelay);
int readATresponseLine(char *szLine, int nLineBufSize,
const char *szResponseFilter, unsigned long ulDelay);
int readATresponseLine(char *aLine[], int nMaxLine, unsigned long ulDelay);
void BG96_serial_clearbuf(void);
void BG96_trace(const __FlashStringHelper *szTrace, ...);
Stream &_serial;
Stream &_debug;
uint8_t _pwr_pin;
uint8_t _status_pin;
int _timeOut = 0;
int _nSocket = 0;
};
#endif