forked from lewisxhe/ArduinoBIGIOT
-
Notifications
You must be signed in to change notification settings - Fork 6
/
bigiot.h
79 lines (67 loc) · 1.54 KB
/
bigiot.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
#ifndef __BIGIOT_HPP
#define __BIGIOT_HPP
#include "WiFiClient.h"
#include <ArduinoJson.h>
#define BIGIOT_LOGINT_WELCOME 1
#define BIGIOT_LOGINT_CHECK_IN 2
#define BIGIOT_LOGINT_TOKEN 3
typedef enum
{
BIGIOT_LOST_CONNECTED = -1,
BIGIOT_INVALD_COMMAND = 0,
BIGIOT_STOP_COMMAND,
BIGIOT_PLAY_COMMAND,
BIGIOT_OFFON_COMMAND,
BIGIOT_MINUS_COMMAND,
BIGIOT_UP_COMMAND,
BIGIOT_PLUS_COMMAND,
BIGIOT_LEFT_COMMAND,
BIGIOT_PAUSE_COMMAND,
BIGIOT_RIGHT_COMMAND,
BIGIOT_BACKWARD_COMMAND,
BIGIOT_DOWN_COMMAND,
BIGIOT_FPRWARD_COMMAND,
} BIGIOT_command_t;
typedef enum
{
BIGIOT_EMAIL_M,
BIGIOT_QQ_M,
BIGIOT_WEIBO_M
} alarm_method_t;
typedef struct
{
String interfaceID;
String data;
} BIGIOT_Data_t;
typedef struct
{
String interfaceID;
String la;
String lo;
} BIGIOT_location_t;
class BigIOT : public WiFiClient
{
public:
BigIOT()
{
timeout = 0;
}
bool login(const char *devId, const char *apiKey, const char *userKey = "");
int waiting(void);
void update_data_stream(BIGIOT_Data_t *data, int len);
void update_location_data(BIGIOT_location_t *data);
void send_alarm_message(alarm_method_t manner, String mes);
private:
int login_parse(String pack);
int packet_parse(String pack);
String get_heatrate_pack(void);
String get_login_packet(String apiKey);
String get_logout_packet(void);
protected:
StaticJsonBuffer<1024> jsonBuffer;
uint64_t timeout;
String _dev;
String _key;
String _usrKey;
};
#endif /*__BIGIOT_HPP*/