-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathEth_ESP8266.h
93 lines (79 loc) · 2.59 KB
/
Eth_ESP8266.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
/**
* @file Eth_ESP8266.h
*
* ESP8266 library
*
* @author Wu Pengfei (email:<[email protected]>)
* @date 2014/11/17
* @copyright
* Copyright (C) 2013-2014 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*/
#ifndef __ETH_ESP8266_H__
#define __ETH_ESP8266_H__
#include <Arduino.h>
#include <SoftwareSerial.h>
#include "IoTgo_config.h"
#include "Net_NetInterface.h"
#ifdef NET_USE_ESP8266
/* The way of encrypstion */
#define ESP8266_ENC_OPEN 0
#define ESP8266_ENC_WEP 1
#define ESP8266_ENC_WAP_PSK 2
#define ESP8266_ENC_WAP2_PSK 3
#define ESP8266_ENC_WAP_WAP2_PSK 4
/* Communication mode */
#define TCP_MODE 1
#define UDP_MODE 0
/* The type of initialized ESP8266 */
#define STA 1
#define AP 2
#define AP_STA 3
#define ESP8266SERIAL_TIMEOUT_DEFAULT (3000)
/**
* Provides TCP service for Application Layer of Network Protocol Stack.
*
* The implemetation is based on ESP8266 by sigle connection mode.
*
* @ingroup NetInterface
*/
class ESP8266: public NetInterface
{
public: /* Implementation of NetInterface */
virtual int32_t createTCPConnection(String host, uint32_t port);
virtual int32_t send(String data);
virtual int32_t recv(char *buffer, uint32_t length);
virtual int32_t releaseTCPConnection(void);
public: /* public methods */
bool connectWiFi(String ssid, String password);
bool disconnectWiFi(void);
private:
void begin(void);
bool Initialize(byte mode, String ssid, String pwd, byte chl = 1, byte ecn = 2);
boolean ipConfig(byte type, String addr, int32_t port, boolean a = 0, byte id = 0);
boolean Send(String str);
boolean Send(byte id, String str);
int32_t ReceiveMessage(char *buf);
bool confMode(byte a);
boolean confJAP(String ssid , String pwd);
boolean confSAP(String ssid , String pwd , byte chl , byte ecn);
String showMode(void);
String showAP(void);
String showJAP(void);
boolean quitAP(void);
String showSAP(void);
String showStatus(void);
String showMux(void);
boolean confMux(boolean a);
boolean newMux(byte type, String addr, int32_t port);
boolean newMux(byte id, byte type, String addr, int32_t port);
void closeMux(void);
void closeMux(byte id);
String showIP(void);
boolean confServer(byte mode, int32_t port);
};
#endif
#endif /* #ifndef __ETH_ESP8266_H__ */