/
esp8266.h
168 lines (147 loc) · 3.64 KB
/
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
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
/**
* @file esp8266.h
* @brief esp8266 command driver library
* @author Michael Burmeister
* @version 1.2
* @date November 29, 2023
*/
#define HTTP 0xF7
#define WS 0xF6
/**
* @brief Open connection to ESP8266 unit
* @param rx receive pin
* @param tx transmit pin
* @param baud baud rate of ESP8266 unit
*
*/
void esp8266_Open(int rx, int tx, int baud) __fromfile("libesp8266/esp8266.c");
/**
* @brief Open connection to target
* @param url target name or address
* @param port target port number (80)
* @return handle or error
*/
int esp8266_Connect(char *url, short port);
/**
* @brief Send request data
* @param handle return from connection
* @param request pointer to request data
* @return status
*/
int esp8266_Send(char handle, char *request);
/**
* @brief Send HTTP request
* @param handle return from connection
* @param request pointer to request data
* @param opt request options
* @return status
*/
int esp8266_Http(char handle, char *request, short opt);
/**
* @brief Set header for http request
* @param header data
*/
void esp8266_setHeader(char *header);
/**
* @brief Send binary data request
* @param handle return from connection
* @param data pointer to data to send
* @param size number of characters to send
* @return status
*/
int esp8266_SendBin(char handle, char *data, int size);
/**
* @brief Receive requested data
* @param handle returned from connection
* @param data pointer to returned data
* @param size of data
* @return status
*/
int esp8266_Recv(char handle, char *data, int size);
/**
* @brief Send UDP Packet
* @param url remote locator
* @param port remote port number to connect
* @return status
*/
int esp8266_UDP(char *url, short port);
/**
* @brief Close open connection
* @param handle return from connection
*/
void esp8266_Close(char handle);
/**
* @brief Join network access point
* @param sid network access point name
* @param pwd password for connection
* @return status
*/
int esp8266_Join(char *sid, char pwd);
/**
* @brief Set environment value
* @param env enviroment parameter
* @param value environment value to set
* @return status
*/
int esp8266_Set(char *env, char *value);
/**
* @brief Check environment value
* @param env
* @return environment value
* @details environment values: version, module-name,
* wifi-mode, wifi-ssd, station-ipaddr, station-macaddr,
* softap-ipaddr, softap-macaddr, cmd-start-char,
* cmd-enable, cmd-events, loader-baud-rate, baud-rate,
* stop-bits, dbg-baud-rate, dbg-stop-bits, reset-pin,
* connected-led-pin, rx-pullup, pin-gpio0...15
*/
char *esp8266_Check(char *env);
/**
* @brief Poll connection status
* @param mask of handles to check
* @return status
*/
int esp8266_Poll(int mask);
/**
* @brief Set Listen URI
* @param protocol to listen for (HTTP, WS)
* @param uri to match
* @return status
*/
int esp8266_Listen(char *protocol, char *uri);
/**
* @brief Reply to request
* @param handle returned by connection
* @param data return data
* @return status
*/
int esp8266_Reply(char handle, char *data);
/**
* @brief Wait for incoming connection
* @param type character pointer to the return type
* @return handle
*/
int esp8266_Wait(char *type);
/**
* @brief Path from connection request
* @return path pointer to path data
*/
char *esp8266_Path(char handle);
/**
* @brief Get argument values
* @param handle of connection
* @param name of argument
* @return value
*/
char *esp8266_arg(char handle, char *name);
/**
* @brief Drop WiFi connection
* @return status
*/
int esp8266_Drop(void);
/**
* @brief Special print
* @param data to print
* @param size of data
*/
void esp8266_Print(char *data, int size);