-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEC20xlib.h
59 lines (51 loc) · 1.86 KB
/
EC20xlib.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
#ifndef EC20xlib_h
#define EC20xlib_h
#include <Arduino.h>
#include <iolte_base.h>
#ifndef TOPIC_MAX_LEN
#define TOPIC_MAX_LEN 128
#endif
#ifndef PAYLOAD_MAX_LEN
#define PAYLOAD_MAX_LEN 1024
#endif
#define USE_HTTP 1
#define USE_MQTT 1
#define USE_TCP 1
//#define EC20xconn Serial2
class EC20xlib : public IOLTE{
public:
EC20xlib(Stream &serial);
~EC20xlib();
byte begin();
int connect(char *ip, char *port,uint8_t connectID);
int disconnect(uint8_t connectID);
boolean connected();
byte ParseMsg(String data);
int postdata(char* buf, int buflen,uint8_t connectID);
byte connectMqttServer(char *clientID,char *ip,char *port,char *username,char *password,uint8_t keepalive,uint8_t will_qos,char *will,char *will_payload);
byte connectMqttServer(char *clientID,char *ip,char *port,char *username,char *password,uint8_t keepalive);
byte connectMqttServer(char *clientID,char *ip,char *port,char *username,char *password);
byte connectMqttServer(char *clientID,char *ip,char *port);
byte SubTopic(char *topic,uint8_t qos1);
byte PubTopic(char *topic,char* msg,uint8_t qos1);
byte UnSubTopic(char *topic,uint8_t qos1);
byte getMessage(char *topic,char* msg,uint8_t qos1);
void attachsubcallback(subcallbackFunction newFunction);
void attachtcpcallback(recallbackFunction newFunction);
void attacheventcallback(eventcallbackFunction newFunction);
void loop();
String Read_TimeClock();
int Read_Signal();
byte Read_CCID(char *DataBuf);
byte Read_IMEI(char *DataBuf);
private:
Stream* EC20xconn;
uint8_t resend_state;
char *ip;
char *port;
bool connected_state = false;
recallbackFunction getdatecallback = NULL;
subcallbackFunction subdatecallback = NULL;
eventcallbackFunction eventcallback = NULL;
};
#endif