embedded-software
reusable software modules for embedded systems
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ESP8266 WiFi

Macros

#define MODE_STATION   1
 
#define MODE_SOFTAP   2
 
#define MODE_SOFTAP_STATION   3
 

Functions

void ESP8266_ConnectNetwork (char *network_ssid, char *network_pass, uint8_t flash_settings)
 
void ESP8266_SetMode (uint8_t mode, uint8_t flash_settings)
 
void ESP8266_Reset (void)
 
void ESP8266_HTTP_GET (char *hostname, int port, char *uri, char *payload) int ESP8266_CalcLength(const char *s)
 

Detailed Description

@ brief Simplex communication with ESP8266 WiFi module using AT commands UART must be initialized and configured to use backchannel before using functions from this module.

ESP8266_UART must be defined in project_settings.h

Created on: March 18, 2019 Author: Stephen Glass

Example psuedo code: (Note the task scheduelr may need to be used to add delays between sending commands to ESP8266 because the device still needs to process it) void main() { UART_Init(); ESP8266_Reset(); ESP8266_SetMode(MODE_STATION, 0); ESP8266_ConnectNetwork("Rowan_IoT", "", 0); ESP8266_HTTP_GET("127.0.0.1", 80, "/api/callback.php", "?data=10"); }

Macro Definition Documentation

#define MODE_SOFTAP   2
#define MODE_SOFTAP_STATION   3
#define MODE_STATION   1

Function Documentation

void ESP8266_ConnectNetwork ( char *  network_ssid,
char *  network_pass,
uint8_t  flash_settings 
)

Configure the WiFi network

Parameters
network_ssidname of the network SSID
network_passpassword of the network
flash_settingsflash the settings to the esp8266 (0, no; 1, flash) Setting to flash will automatically connect every time ESP8266 is powered on
void ESP8266_HTTP_GET ( char *  hostname,
int  port,
char *  uri,
char *  payload 
) const

Performs a HTTP GET request on a specified URL with payload

Parameters
hostnamehostname in format of IP address or URL (e.g 127.0.0.1, localhost)
portport of the HTTP server (default 80 on most servers)
uriuri of the server (e.g: /api/test.php)
payloadpayload to send (e.g: ?data=1&id=5) Helper function to calculate length of string
sstring to calculate length
void ESP8266_Reset ( void  )

Resets the ESP8266

void ESP8266_SetMode ( uint8_t  mode,
uint8_t  flash_settings 
)

Set the mode of the ESP8266

Parameters
modemode to set
flash_settingsflash the setting to esp8266 (0, no; 1, flash) Setting to flash will automatically enable this mode every time ESP8266 is powered on