wireless communication with ESP8266
More...
|
|
#define | ESP8266_ENCRYPT_MODE_OPEN 0 |
| | Encryption modes.
|
| |
|
#define | ESP8266_ENCRYPT_MODE_WEP 1 |
| |
|
#define | ESP8266_ENCRYPT_MODE_WPA_PSK 2 |
| |
|
#define | ESP8266_ENCRYPT_MODE_WPA2_PSK 3 |
| |
|
#define | ESP8266_ENCRYPT_MODE_WPA_WPA2_PSK 4 |
| |
|
#define | ESP8266_WIFI_MODE_CLIENT 1 |
| | ESP8266 modes Client, AP, AP/Client.
|
| |
|
#define | ESP8266_WIFI_MODE_AP 2 |
| |
|
#define | ESP8266_WIFI_MODE_AP_AND_CLIENT 3 |
| |
|
| int | ESP8266_Init (int rx_echo, int tx_echo) |
| | Initializes ESP8266. More...
|
| |
| int | ESP8266_Connect (int verbose) |
| | Connects ESP8266. More...
|
| |
| int | ESP8266_StartServer (uint16_t port, uint16_t timeout) |
| | Start server. More...
|
| |
| int | ESP8266_StopServer (void) |
| | Stop server. More...
|
| |
| int | ESP8266_Reset (void) |
| | Reset the esp8266. More...
|
| |
| int | ESP8266_Restore (void) |
| | Restore default settings. More...
|
| |
| int | ESP8266_GetVersionNumber (void) |
| | Version number. More...
|
| |
| int | ESP8266_GetMACAddress (void) |
| | MAC address. More...
|
| |
| int | ESP8266_SetWifiMode (uint8_t mode) |
| | Set mode. More...
|
| |
| int | ESP8266_SetConnectionMux (uint8_t enabled) |
| | Set mode. More...
|
| |
| int | ESP8266_ListAccessPoints (void) |
| | Access Points. More...
|
| |
| int | ESP8266_JoinAccessPoint (const char *ssid, const char *password) |
| | Join AP. More...
|
| |
| int | ESP8266_QuitAccessPoint (void) |
| | Quit AP. More...
|
| |
| int | ESP8266_ConfigureAccessPoint (const char *ssid, const char *password, uint8_t channel, uint8_t encryptMode) |
| | Configure AP. More...
|
| |
| int | ESP8266_GetIPAddress (void) |
| | Get IP address. More...
|
| |
| int | ESP8266_SetSSLClientConfiguration (int verifyClient, int verifyServer) |
| | Set SSL. More...
|
| |
| int | ESP8266_SetSSLBufferSize (uint16_t bufferSize) |
| | SSL buffer size. More...
|
| |
| int | ESP8266_MakeTCPConnection (char *IPaddress, uint16_t port, uint16_t keepalive, int ssl) |
| | Make connection. More...
|
| |
| int | ESP8266_Send (const char *fetch) |
| | Send TCP. More...
|
| |
| int | ESP8266_SendBuffered (const char *fetch) |
| | Send buffered TCP. More...
|
| |
| int | ESP8266_SendBufferedStatus (void) |
| | Check status. More...
|
| |
| int | ESP8266_Receive (char *fetch, uint32_t max) |
| | Receive TCP. More...
|
| |
| int | ESP8266_CloseTCPConnection (void) |
| | Close TCP socket. More...
|
| |
| int | ESP8266_SetDataTransmissionMode (uint8_t mode) |
| | Set transmission mode. More...
|
| |
| int | ESP8266_GetStatus (void) |
| | Get status. More...
|
| |
| int | ESP8266_EnableServer (uint16_t port) |
| | Enable server. More...
|
| |
| int | ESP8266_SetServerTimeout (uint16_t timeout) |
| | Set server timeout. More...
|
| |
| int | ESP8266_WaitForConnection (void) |
| | Wait for connection. More...
|
| |
| int | ESP8266_DisableServer (void) |
| | Disable server. More...
|
| |
| void | ESP8266_StartReceiveSearch (char *search) |
| | Set search string. More...
|
| |
| char * | ESP8266_GetReceiveBuffer (void) |
| | Get search string. More...
|
| |
wireless communication with ESP8266
Interface of ESP8266 to the MSPM0G3507 LaunchPad
| Pin | ESP8266 | MSPM0 | Motor board version 7.1 or 7.2 |
| 1 | URxD | PB17 | UART2 out of MSPM0, into ESP8266 115200 baud |
| 2 | GPIO0 | | +3.3V for normal operation (ground to flash) |
| 3 | GPIO2 | PB19 | GPIO, high/float on startup, has internal pullup, can be used for I/O |
| 4 | GND | Gnd | GND (70mA) |
| 5 | UTxD | PB18 | UART out of ESP8266, UART2 into MSPM0 115200 baud |
| 6 | Ch_PD | | chip select, 10k resistor to 3.3V |
| 7 | Reset | PA25 | MSPM0 GPIO output, can issue output low to cause hardware reset |
| 8 | Vcc | | regulated 3.3V supply with at least 70mA |
◆ ESP8266_CloseTCPConnection()
| int ESP8266_CloseTCPConnection |
( |
void |
| ) |
|
◆ ESP8266_ConfigureAccessPoint()
| int ESP8266_ConfigureAccessPoint |
( |
const char * |
ssid, |
|
|
const char * |
password, |
|
|
uint8_t |
channel, |
|
|
uint8_t |
encryptMode |
|
) |
| |
Configure AP.
Configures esp8266 wifi soft access point settings. Use this function only when in AP mode (and not in client mode)
- ESP8266_ENCRYPT_MODE_OPEN 0
- ESP8266_ENCRYPT_MODE_WEP 1
- ESP8266_ENCRYPT_MODE_WPA_PSK 2
- ESP8266_ENCRYPT_MODE_WPA2_PSK 3
- ESP8266_ENCRYPT_MODE_WPA_WPA2_PSK 4
- Parameters
-
| ssid | name of the AP |
| password | password of the AP |
| channel | channel of the AP |
| encryptMode | mode of the AP, 0 to 4 |
- Returns
- 1 on success, 0 on failure
- Note
- Has not been tested on the MSPM0
◆ ESP8266_Connect()
| int ESP8266_Connect |
( |
int |
verbose | ) |
|
Connects ESP8266.
Connect the ESP8266-01 to the Wifi hotspot. Bring interface up and connect to Wifi.
- Parameters
-
| verbose | true to enable debug output |
- Returns
- 1 on success, 0 on failure
- Note
- specify SSID_NAME and PASSKEY at top of esp8266.c
◆ ESP8266_DisableServer()
| int ESP8266_DisableServer |
( |
void |
| ) |
|
Disable server.
Disables tcp server
- Parameters
-
- Returns
- 1 on success, 0 on failure
- Note
- This has not been tested on the MSPM0
◆ ESP8266_EnableServer()
| int ESP8266_EnableServer |
( |
uint16_t |
port | ) |
|
Enable server.
Enables tcp server on specified port.
- Parameters
-
| port | number of the server port |
- Returns
- 1 on success, 0 on failure
- Note
- This has not been tested on the MSPM0
◆ ESP8266_GetIPAddress()
| int ESP8266_GetIPAddress |
( |
void |
| ) |
|
Get IP address.
Get local IP address. See the results in the debug stream.
- Parameters
-
| none | is the password of the AP |
- Returns
- 1 on success, 0 on failure
- Note
- This is called within ESP8266_Connect
◆ ESP8266_GetMACAddress()
| int ESP8266_GetMACAddress |
( |
void |
| ) |
|
MAC address.
Get MAC address. See the results in the debug stream
- Parameters
-
- Returns
- 1 on success, 0 on failure
◆ ESP8266_GetReceiveBuffer()
| char* ESP8266_GetReceiveBuffer |
( |
void |
| ) |
|
◆ ESP8266_GetStatus()
| int ESP8266_GetStatus |
( |
void |
| ) |
|
Get status.
Get network connection status. See the results in the debug stream.
- Parameters
-
| none | is the password of the AP |
- Returns
- 1 on success, 0 on failure
◆ ESP8266_GetVersionNumber()
| int ESP8266_GetVersionNumber |
( |
void |
| ) |
|
Version number.
Get Version Number. See the results in the debug stream
- Parameters
-
- Returns
- 1 on success, 0 on failure
◆ ESP8266_Init()
| int ESP8266_Init |
( |
int |
rx_echo, |
|
|
int |
tx_echo |
|
) |
| |
Initializes ESP8266.
Initialize the ESP8266-01. Configure UART2 for 115200bps operation.
- Parameters
-
| rx_echo | 1 for receive echo to UART0 |
| tx_echo | 1 for transmit echo to UART0 |
- Returns
- 1 for success, 0 for failure (no ESP detected)
- Note
- A common reason for this to fail is if the ESP8266 has been programmed with alternate code (different from original)
-
see ESP8266 files in datasheets folder
◆ ESP8266_JoinAccessPoint()
| int ESP8266_JoinAccessPoint |
( |
const char * |
ssid, |
|
|
const char * |
password |
|
) |
| |
Join AP.
Joins a wifi access point using specified ssid and password
- Parameters
-
| ssid | is the name of the AP |
| password | is the password of the AP |
- Returns
- 1 on success, 0 on failure
- Note
- This is called within ESP8266_Connect
◆ ESP8266_ListAccessPoints()
| int ESP8266_ListAccessPoints |
( |
void |
| ) |
|
Access Points.
Lists available wifi access points
- Parameters
-
- Returns
- 1 on success, 0 on failure
◆ ESP8266_MakeTCPConnection()
| int ESP8266_MakeTCPConnection |
( |
char * |
IPaddress, |
|
|
uint16_t |
port, |
|
|
uint16_t |
keepalive, |
|
|
int |
ssl |
|
) |
| |
Make connection.
Establish TCP or SSL connection. Connect a socket in this client with a socket in the server. For the ECE445L RTOS server, one must immediately send the TCP, and this socket will automatically close. The ESP only seems to have limited SSL support, does not work with all servers
- Parameters
-
| IPaddress | IP address or web page as a string |
| port | as a number |
| keepalive | keepalive time (0 if none) |
| ssl | 0 for TCP, 1 for SSL |
- Returns
- 1 on success, 0 on failure
- Note
- Only TCP has been tested (not SSL)
◆ ESP8266_QuitAccessPoint()
| int ESP8266_QuitAccessPoint |
( |
void |
| ) |
|
Quit AP.
Disconnects from currently connected wifi access point
- Parameters
-
- Returns
- 1 on success, 0 on failure
◆ ESP8266_Receive()
| int ESP8266_Receive |
( |
char * |
fetch, |
|
|
uint32_t |
max |
|
) |
| |
◆ ESP8266_Reset()
| int ESP8266_Reset |
( |
void |
| ) |
|
Reset the esp8266.
Soft resets the esp8266 module.
- Parameters
-
- Returns
- 1 on success, 0 on failure
- Note
- A common reason for this to fail is if the ESP8266 has been programmed with alternate code (different from original)
◆ ESP8266_Restore()
| int ESP8266_Restore |
( |
void |
| ) |
|
Restore default settings.
Restore the ESP8266 module to default values.
- Parameters
-
- Returns
- 1 on success, 0 on failure
◆ ESP8266_Send()
| int ESP8266_Send |
( |
const char * |
fetch | ) |
|
◆ ESP8266_SendBuffered()
| int ESP8266_SendBuffered |
( |
const char * |
fetch | ) |
|
Send buffered TCP.
Send a string to server using ESP TCP-send buffer. Used when implementing a server
- Parameters
-
| fetch | payload as an ASCII string to send |
- Returns
- 1 on success, 0 on failure
- Note
- This has not been tested on the MSPM0
◆ ESP8266_SendBufferedStatus()
| int ESP8266_SendBufferedStatus |
( |
void |
| ) |
|
Check status.
Check status of last buffered segment. This is part of the server code
- Parameters
-
- Returns
- 1 on success, 0 on failure
- Note
- This has not been tested on the MSPM0
◆ ESP8266_SetConnectionMux()
| int ESP8266_SetConnectionMux |
( |
uint8_t |
enabled | ) |
|
Set mode.
Enables the esp8266 connection mux, required for starting tcp server
- Parameters
-
| enabled | 0 (single) or 1 (multiple) |
- Returns
- 1 on success, 0 on failure
- Note
- Has not been tested on the MSPM0
◆ ESP8266_SetDataTransmissionMode()
| int ESP8266_SetDataTransmissionMode |
( |
uint8_t |
mode | ) |
|
Set transmission mode.
Set data transmission passthrough mode
- Parameters
-
| mode | 0 not data mode, 1 data mode; return "Link is builded" |
- Returns
- 1 on success, 0 on failure
- Note
- This has not been tested on the MSPM0
◆ ESP8266_SetServerTimeout()
| int ESP8266_SetServerTimeout |
( |
uint16_t |
timeout | ) |
|
Set server timeout.
Set connection timeout for tcp server, 0-28800 seconds
- Parameters
-
- Returns
- 1 on success, 0 on failure
- Note
- This has not been tested on the MSPM0
◆ ESP8266_SetSSLBufferSize()
| int ESP8266_SetSSLBufferSize |
( |
uint16_t |
bufferSize | ) |
|
SSL buffer size.
Set SSL buffer size
- Parameters
-
| bufferSize | buffer size between 2048 and 4096 |
- Returns
- 1 on success, 0 on failure
- Note
- This function has not been tested on the MSPM0
◆ ESP8266_SetSSLClientConfiguration()
| int ESP8266_SetSSLClientConfiguration |
( |
int |
verifyClient, |
|
|
int |
verifyServer |
|
) |
| |
Set SSL.
Set SSL client configuration. Requires certificates to be flashed into the ESP firmware
- Parameters
-
| verifyClient | enable/disable client certificate checks |
| verifyServer | enable/disable server certificate checks |
- Returns
- 1 on success, 0 on failure
- Note
- This function has not been tested on the MSPM0
◆ ESP8266_SetWifiMode()
| int ESP8266_SetWifiMode |
( |
uint8_t |
mode | ) |
|
Set mode.
Configures the esp8266 to operate as a wifi client, access point, or both
- ESP8266_WIFI_MODE_CLIENT 1
- ESP8266_WIFI_MODE_AP 2
- ESP8266_WIFI_MODE_AP_AND_CLIENT 3
- Parameters
-
- Returns
- 1 on success, 0 on failure
- Note
- Only client mode been tested on the MSPM0
◆ ESP8266_StartReceiveSearch()
| void ESP8266_StartReceiveSearch |
( |
char * |
search | ) |
|
Set search string.
Set a search string to find response from server. The incoming data stream from the server is searched for "status=". After match, it will collect ASCII characters while greater than or equal to 'A'. It will stop collecting ASCII character is less than 'A'. if rxecho is active, receive data is also streamed to ReceiveBuffer For the ECE445M RTOS server,
- ESP8266_MakeTCPConnection();
- ESP8266_StartReceiveSearch();
- ESP8266_Send();
- This socket will automatically close.
- s = ESP8266_GetReceiveBuffer(); // pointer to search string
- Parameters
-
| search | is the ASCII string to search for |
- Returns
- 1 on success, 0 on failure
◆ ESP8266_StartServer()
| int ESP8266_StartServer |
( |
uint16_t |
port, |
|
|
uint16_t |
timeout |
|
) |
| |
Start server.
Start server on specific port.
- Parameters
-
| port | is the server port number |
| timeout | is the server timeout, 0-28800 seconds |
- Returns
- 1 on success, 0 on failure
- Note
- This has not been tested on the MSPM0
◆ ESP8266_StopServer()
| int ESP8266_StopServer |
( |
void |
| ) |
|
Stop server.
Stop server and set to single-client mode.
- Parameters
-
- Returns
- 1 on success, 0 on failure
- Note
- This has not been tested on the MSPM0
◆ ESP8266_WaitForConnection()
| int ESP8266_WaitForConnection |
( |
void |
| ) |
|
Wait for connection.
Wait for incoming connection on server
- Parameters
-
- Returns
- 1 on success, 0 on failure
- Note
- This has not been tested on the MSPM0