Firmware SDK
|
Driver for ESP8266 WiFi module. More...
Data Structures | |
struct | twr_esp8266_config |
struct | twr_esp8266_t |
Typedefs | |
typedef struct twr_esp8266_t | twr_esp8266_t |
ESP8266 instance. | |
Enumerations | |
enum | twr_esp8266_event_t { TWR_ESP8266_EVENT_READY = 0 , TWR_ESP8266_EVENT_ERROR = 1 , TWR_ESP8266_EVENT_WIFI_CONNECT_SUCCESS = 2 , TWR_ESP8266_EVENT_WIFI_CONNECT_ERROR = 3 , TWR_ESP8266_EVENT_SOCKET_CONNECT_SUCCESS = 4 , TWR_ESP8266_EVENT_SOCKET_CONNECT_ERROR = 5 , TWR_ESP8266_EVENT_SOCKET_SEND_SUCCESS = 6 , TWR_ESP8266_EVENT_SOCKET_SEND_ERROR = 7 , TWR_ESP8266_EVENT_DATA_RECEIVED = 8 , TWR_ESP8266_EVENT_AP_AVAILABILITY_RESULT = 9 , TWR_ESP8266_EVENT_DISCONNECTED = 10 } |
Callback events. More... | |
enum | twr_esp8266_state_t { TWR_ESP8266_STATE_READY = 0 , TWR_ESP8266_STATE_ERROR = 1 , TWR_ESP8266_STATE_INITIALIZE = 2 , TWR_ESP8266_STATE_IDLE = 3 , TWR_ESP8266_STATE_RECEIVE = 4 , TWR_ESP8266_STATE_INITIALIZE_COMMAND_SEND = 5 , TWR_ESP8266_STATE_INITIALIZE_COMMAND_RESPONSE = 6 , TWR_ESP8266_STATE_WIFI_CONNECT_COMMAND = 7 , TWR_ESP8266_STATE_SOCKET_CONNECT_COMMAND = 8 , TWR_ESP8266_STATE_SOCKET_SEND_COMMAND = 9 , TWR_ESP8266_STATE_SOCKET_SEND_DATA = 10 , TWR_ESP8266_STATE_WIFI_CONNECT_RESPONSE = 11 , TWR_ESP8266_STATE_SOCKET_CONNECT_RESPONSE = 12 , TWR_ESP8266_STATE_SOCKET_SEND_RESPONSE = 13 , TWR_ESP8266_STATE_WIFI_CONNECT_ERROR = 14 , TWR_ESP8266_STATE_SOCKET_CONNECT_ERROR = 15 , TWR_ESP8266_STATE_SOCKET_SEND_ERROR = 16 , TWR_ESP8266_STATE_SOCKET_RECEIVE = 17 , TWR_ESP8266_STATE_DISCONNECTED = 18 , TWR_ESP8266_STATE_SNTP_CONFIG_COMMAND = 19 , TWR_ESP8266_STATE_SNTP_CONFIG_RESPONSE = 20 , TWR_ESP8266_STATE_SNTP_TIME_COMMAND = 21 , TWR_ESP8266_STATE_SNTP_TIME_RESPONSE = 22 , TWR_ESP8266_STATE_AP_AVAILABILITY_OPT_COMMAND = 23 , TWR_ESP8266_STATE_AP_AVAILABILITY_OPT_RESPONSE = 24 , TWR_ESP8266_STATE_AP_AVAILABILITY_COMMAND = 25 , TWR_ESP8266_STATE_AP_AVAILABILITY_RESPONSE = 26 } |
enum | twr_esp8266_config_mode_t { TWR_ESP8266_CONFIG_MODE_STATION = 0 , TWR_ESP8266_CONFIG_MODE_AP = 1 } |
Functions | |
void | twr_esp8266_init (twr_esp8266_t *self, twr_uart_channel_t uart_channel) |
Initialize ESP8266. More... | |
void | twr_esp8266_set_event_handler (twr_esp8266_t *self, void(*event_handler)(twr_esp8266_t *, twr_esp8266_event_t, void *), void *event_param) |
Set callback function. More... | |
void | twr_esp8266_set_station_mode (twr_esp8266_t *self, char *ssid, char *password) |
Set station mode. More... | |
void | twr_esp8266_set_sntp (twr_esp8266_t *self, int timezone) |
Enable SNTP and set time zone. More... | |
void | twr_esp8266_set_sntp_with_servers (twr_esp8266_t *self, int timezone, char *sntp_server1, char *sntp_server2, char *sntp_server3) |
Enable SNTP and set configuration. More... | |
bool | twr_esp8266_is_ready (twr_esp8266_t *self) |
Check if modem is ready for commands. More... | |
bool | twr_esp8266_connect (twr_esp8266_t *self) |
Enable ESP8266 and connect to WiFi. More... | |
bool | twr_esp8266_disconnect (twr_esp8266_t *self) |
Disable ESP8266 and disconnect. More... | |
bool | twr_esp8266_tcp_connect (twr_esp8266_t *self, const char *host, uint16_t port) |
Establish TCP Connection. More... | |
bool | twr_esp8266_udp_connect (twr_esp8266_t *self, const char *host, uint16_t port) |
Establish UDP Connection. More... | |
bool | twr_esp8266_ssl_connect (twr_esp8266_t *self, const char *host, uint16_t port) |
Establish SSL Connection. More... | |
bool | twr_esp8266_send_data (twr_esp8266_t *self, const void *buffer, size_t length) |
Send data. More... | |
uint32_t | twr_esp8266_get_received_message_length (twr_esp8266_t *self) |
Get length of the received message. More... | |
uint32_t | twr_esp8266_get_received_message_data (twr_esp8266_t *self, uint8_t *buffer, uint32_t buffer_size) |
Get received message data. More... | |
bool | twr_esp8266_check_ap_availability (twr_esp8266_t *self) |
Check AP availability. More... | |
void | twr_esp8266_get_ap_availability (twr_esp8266_t *self, bool *available, int *rssi) |
Get AP availability result. More... | |
void | twr_esp8266_get_ssid (twr_esp8266_t *self, char *ssid) |
Get SSID. More... | |
void | twr_esp8266_set_ssid (twr_esp8266_t *self, char *ssid) |
Set SSID. More... | |
void | twr_esp8266_get_password (twr_esp8266_t *self, char *password) |
Get password. More... | |
void | twr_esp8266_set_password (twr_esp8266_t *self, char *password) |
Set password. More... | |
Driver for ESP8266 WiFi module.
enum twr_esp8266_event_t |
Callback events.
Enumerator | |
---|---|
TWR_ESP8266_EVENT_READY | Ready event. |
TWR_ESP8266_EVENT_ERROR | Error event. |
Definition at line 23 of file twr_esp8266.h.
bool twr_esp8266_check_ap_availability | ( | twr_esp8266_t * | self | ) |
Check AP availability.
[in] | self | Instance |
Definition at line 979 of file twr_esp8266.c.
bool twr_esp8266_connect | ( | twr_esp8266_t * | self | ) |
Enable ESP8266 and connect to WiFi.
[in] | self | Instance |
Definition at line 156 of file twr_esp8266.c.
bool twr_esp8266_disconnect | ( | twr_esp8266_t * | self | ) |
Disable ESP8266 and disconnect.
[in] | self | Instance |
Definition at line 174 of file twr_esp8266.c.
void twr_esp8266_get_ap_availability | ( | twr_esp8266_t * | self, |
bool * | available, | ||
int * | rssi | ||
) |
Get AP availability result.
[in] | self | Instance |
[in] | available | If AP is available |
[in] | rssi | RSSI |
Definition at line 996 of file twr_esp8266.c.
void twr_esp8266_get_password | ( | twr_esp8266_t * | self, |
char * | password | ||
) |
Get password.
[in] | self | Instance |
[in] | password | Pointer to at least 64 character string |
Definition at line 1012 of file twr_esp8266.c.
uint32_t twr_esp8266_get_received_message_data | ( | twr_esp8266_t * | self, |
uint8_t * | buffer, | ||
uint32_t | buffer_size | ||
) |
Get received message data.
[in] | self | Instance |
[in] | buffer | Destination buffer for received data |
[in] | buffer_size | Size of the destination buffer |
Definition at line 795 of file twr_esp8266.c.
uint32_t twr_esp8266_get_received_message_length | ( | twr_esp8266_t * | self | ) |
Get length of the received message.
[in] | self | Instance |
Definition at line 790 of file twr_esp8266.c.
void twr_esp8266_get_ssid | ( | twr_esp8266_t * | self, |
char * | ssid | ||
) |
Get SSID.
[in] | self | Instance |
[in] | ssid | Pointer to at least 64 character string |
Definition at line 1002 of file twr_esp8266.c.
void twr_esp8266_init | ( | twr_esp8266_t * | self, |
twr_uart_channel_t | uart_channel | ||
) |
Initialize ESP8266.
[in] | self | Instance |
[in] | uart_channel | UART channel where TX and RX signals are connected |
Definition at line 37 of file twr_esp8266.c.
bool twr_esp8266_is_ready | ( | twr_esp8266_t * | self | ) |
Check if modem is ready for commands.
[in] | self | Instance |
Definition at line 146 of file twr_esp8266.c.
Referenced by twr_esp8266_send_data().
bool twr_esp8266_send_data | ( | twr_esp8266_t * | self, |
const void * | buffer, | ||
size_t | length | ||
) |
Send data.
[in] | self | Instance |
[in] | buffer | Pointer to data to be transmitted |
[in] | length | Length of data to be transmitted in bytes |
Definition at line 225 of file twr_esp8266.c.
void twr_esp8266_set_event_handler | ( | twr_esp8266_t * | self, |
void(*)(twr_esp8266_t *, twr_esp8266_event_t, void *) | event_handler, | ||
void * | event_param | ||
) |
Set callback function.
[in] | self | Instance |
[in] | event_handler | Function address |
[in] | event_param | Optional event parameter (can be NULL) |
Definition at line 98 of file twr_esp8266.c.
void twr_esp8266_set_password | ( | twr_esp8266_t * | self, |
char * | password | ||
) |
Set password.
[in] | self | Instance |
[in] | password | Pointer to 64 character string |
Definition at line 1017 of file twr_esp8266.c.
void twr_esp8266_set_sntp | ( | twr_esp8266_t * | self, |
int | timezone | ||
) |
Enable SNTP and set time zone.
[in] | self | Instance |
[in] | timezone | Time zone, from -11 to 13 |
Definition at line 111 of file twr_esp8266.c.
void twr_esp8266_set_sntp_with_servers | ( | twr_esp8266_t * | self, |
int | timezone, | ||
char * | sntp_server1, | ||
char * | sntp_server2, | ||
char * | sntp_server3 | ||
) |
Enable SNTP and set configuration.
[in] | self | Instance |
[in] | timezone | Time zone, from -11 to 13 |
[in] | sntp_server1 | First SNTP server |
[in] | sntp_server2 | Second SNTP server |
[in] | sntp_server3 | Third SNTP server |
Definition at line 116 of file twr_esp8266.c.
Referenced by twr_esp8266_set_sntp().
void twr_esp8266_set_ssid | ( | twr_esp8266_t * | self, |
char * | ssid | ||
) |
Set SSID.
[in] | self | Instance |
[in] | ssid | Pointer to 64 character string |
Definition at line 1007 of file twr_esp8266.c.
void twr_esp8266_set_station_mode | ( | twr_esp8266_t * | self, |
char * | ssid, | ||
char * | password | ||
) |
Set station mode.
[in] | self | Instance |
[in] | ssid | SSID |
[in] | password | Password |
Definition at line 104 of file twr_esp8266.c.
bool twr_esp8266_ssl_connect | ( | twr_esp8266_t * | self, |
const char * | host, | ||
uint16_t | port | ||
) |
Establish SSL Connection.
[in] | self | Instance |
[in] | host | Remote host |
[in] | port | Remote port |
Definition at line 220 of file twr_esp8266.c.
bool twr_esp8266_tcp_connect | ( | twr_esp8266_t * | self, |
const char * | host, | ||
uint16_t | port | ||
) |
Establish TCP Connection.
[in] | self | Instance |
[in] | host | Remote host |
[in] | port | Remote port |
Definition at line 210 of file twr_esp8266.c.
bool twr_esp8266_udp_connect | ( | twr_esp8266_t * | self, |
const char * | host, | ||
uint16_t | port | ||
) |
Establish UDP Connection.
[in] | self | Instance |
[in] | host | Remote host |
[in] | port | Remote port |
Definition at line 215 of file twr_esp8266.c.