Firmware SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
bc_esp8266

Driver for ESP8266 WiFi module. More...

Data Structures

struct  bc_esp8266_config
 
struct  bc_esp8266_t
 

Typedefs

typedef struct bc_esp8266_t bc_esp8266_t
 ESP8266 instance.
 

Enumerations

enum  bc_esp8266_event_t {
  BC_ESP8266_EVENT_READY = 0,
  BC_ESP8266_EVENT_ERROR = 1,
  BC_ESP8266_EVENT_WIFI_CONNECT_SUCCESS = 2,
  BC_ESP8266_EVENT_WIFI_CONNECT_ERROR = 3,
  BC_ESP8266_EVENT_SOCKET_CONNECT_SUCCESS = 4,
  BC_ESP8266_EVENT_SOCKET_CONNECT_ERROR = 5,
  BC_ESP8266_EVENT_SOCKET_SEND_SUCCESS = 6,
  BC_ESP8266_EVENT_SOCKET_SEND_ERROR = 7,
  BC_ESP8266_EVENT_DATA_RECEIVED = 8,
  BC_ESP8266_EVENT_AP_AVAILABILITY_RESULT = 9,
  BC_ESP8266_EVENT_DISCONNECTED = 10
}
 Callback events. More...
 
enum  bc_esp8266_state_t {
  BC_ESP8266_STATE_READY = 0,
  BC_ESP8266_STATE_ERROR = 1,
  BC_ESP8266_STATE_INITIALIZE = 2,
  BC_ESP8266_STATE_IDLE = 3,
  BC_ESP8266_STATE_RECEIVE = 4,
  BC_ESP8266_STATE_INITIALIZE_COMMAND_SEND = 5,
  BC_ESP8266_STATE_INITIALIZE_COMMAND_RESPONSE = 6,
  BC_ESP8266_STATE_WIFI_CONNECT_COMMAND = 7,
  BC_ESP8266_STATE_SOCKET_CONNECT_COMMAND = 8,
  BC_ESP8266_STATE_SOCKET_SEND_COMMAND = 9,
  BC_ESP8266_STATE_SOCKET_SEND_DATA = 10,
  BC_ESP8266_STATE_WIFI_CONNECT_RESPONSE = 11,
  BC_ESP8266_STATE_SOCKET_CONNECT_RESPONSE = 12,
  BC_ESP8266_STATE_SOCKET_SEND_RESPONSE = 13,
  BC_ESP8266_STATE_WIFI_CONNECT_ERROR = 14,
  BC_ESP8266_STATE_SOCKET_CONNECT_ERROR = 15,
  BC_ESP8266_STATE_SOCKET_SEND_ERROR = 16,
  BC_ESP8266_STATE_SOCKET_RECEIVE = 17,
  BC_ESP8266_STATE_DISCONNECTED = 18,
  BC_ESP8266_STATE_SNTP_CONFIG_COMMAND = 19,
  BC_ESP8266_STATE_SNTP_CONFIG_RESPONSE = 20,
  BC_ESP8266_STATE_SNTP_TIME_COMMAND = 21,
  BC_ESP8266_STATE_SNTP_TIME_RESPONSE = 22,
  BC_ESP8266_STATE_AP_AVAILABILITY_OPT_COMMAND = 23,
  BC_ESP8266_STATE_AP_AVAILABILITY_OPT_RESPONSE = 24,
  BC_ESP8266_STATE_AP_AVAILABILITY_COMMAND = 25,
  BC_ESP8266_STATE_AP_AVAILABILITY_RESPONSE = 26
}
 
enum  bc_esp8266_config_mode_t {
  BC_ESP8266_CONFIG_MODE_STATION = 0,
  BC_ESP8266_CONFIG_MODE_AP = 1
}
 

Functions

void bc_esp8266_init (bc_esp8266_t *self, bc_uart_channel_t uart_channel)
 Initialize ESP8266. More...
 
void bc_esp8266_set_event_handler (bc_esp8266_t *self, void(*event_handler)(bc_esp8266_t *, bc_esp8266_event_t, void *), void *event_param)
 Set callback function. More...
 
void bc_esp8266_set_station_mode (bc_esp8266_t *self, char *ssid, char *password)
 Set station mode. More...
 
void bc_esp8266_set_sntp (bc_esp8266_t *self, int timezone)
 Enable SNTP and set time zone. More...
 
void bc_esp8266_set_sntp_with_servers (bc_esp8266_t *self, int timezone, char *sntp_server1, char *sntp_server2, char *sntp_server3)
 Enable SNTP and set configuration. More...
 
bool bc_esp8266_is_ready (bc_esp8266_t *self)
 Check if modem is ready for commands. More...
 
bool bc_esp8266_connect (bc_esp8266_t *self)
 Enable ESP8266 and connect to WiFi. More...
 
bool bc_esp8266_disconnect (bc_esp8266_t *self)
 Disable ESP8266 and disconnect. More...
 
bool bc_esp8266_tcp_connect (bc_esp8266_t *self, const char *host, uint16_t port)
 Establish TCP Connection. More...
 
bool bc_esp8266_udp_connect (bc_esp8266_t *self, const char *host, uint16_t port)
 Establish UDP Connection. More...
 
bool bc_esp8266_ssl_connect (bc_esp8266_t *self, const char *host, uint16_t port)
 Establish SSL Connection. More...
 
bool bc_esp8266_send_data (bc_esp8266_t *self, const void *buffer, size_t length)
 Send data. More...
 
uint32_t bc_esp8266_get_received_message_length (bc_esp8266_t *self)
 Get length of the received message. More...
 
uint32_t bc_esp8266_get_received_message_data (bc_esp8266_t *self, uint8_t *buffer, uint32_t buffer_size)
 Get received message data. More...
 
bool bc_esp8266_check_ap_availability (bc_esp8266_t *self)
 Check AP availability. More...
 
void bc_esp8266_get_ap_availability (bc_esp8266_t *self, bool *available, int *rssi)
 Get AP availability result. More...
 
void bc_esp8266_get_ssid (bc_esp8266_t *self, char *ssid)
 Get SSID. More...
 
void bc_esp8266_set_ssid (bc_esp8266_t *self, char *ssid)
 Set SSID. More...
 
void bc_esp8266_get_password (bc_esp8266_t *self, char *password)
 Get password. More...
 
void bc_esp8266_set_password (bc_esp8266_t *self, char *password)
 Set password. More...
 

Detailed Description

Driver for ESP8266 WiFi module.

Enumeration Type Documentation

Callback events.

Enumerator
BC_ESP8266_EVENT_READY 

Ready event.

BC_ESP8266_EVENT_ERROR 

Error event.

Definition at line 23 of file bc_esp8266.h.

Function Documentation

bool bc_esp8266_check_ap_availability ( bc_esp8266_t self)

Check AP availability.

Parameters
[in]selfInstance
Returns
true If command was accepted for processing
false If command was denied for processing

Definition at line 979 of file bc_esp8266.c.

Here is the call graph for this function:

bool bc_esp8266_connect ( bc_esp8266_t self)

Enable ESP8266 and connect to WiFi.

Parameters
[in]selfInstance
Returns
true If command was accepted for processing
false If command was denied for processing

Definition at line 156 of file bc_esp8266.c.

Here is the call graph for this function:

bool bc_esp8266_disconnect ( bc_esp8266_t self)

Disable ESP8266 and disconnect.

Parameters
[in]selfInstance
Returns
true If command was accepted for processing
false If command was denied for processing

Definition at line 174 of file bc_esp8266.c.

void bc_esp8266_get_ap_availability ( bc_esp8266_t self,
bool *  available,
int *  rssi 
)

Get AP availability result.

Parameters
[in]selfInstance
[in]availableIf AP is available
[in]rssiRSSI

Definition at line 996 of file bc_esp8266.c.

void bc_esp8266_get_password ( bc_esp8266_t self,
char *  password 
)

Get password.

Parameters
[in]selfInstance
[in]passwordPointer to at least 64 character string

Definition at line 1012 of file bc_esp8266.c.

uint32_t bc_esp8266_get_received_message_data ( bc_esp8266_t self,
uint8_t *  buffer,
uint32_t  buffer_size 
)

Get received message data.

Parameters
[in]selfInstance
[in]bufferDestination buffer for received data
[in]buffer_sizeSize of the destination buffer
Returns
Length of the received message. Zero if the destination buffer is not big enough.

Definition at line 795 of file bc_esp8266.c.

uint32_t bc_esp8266_get_received_message_length ( bc_esp8266_t self)

Get length of the received message.

Parameters
[in]selfInstance
Returns
length

Definition at line 790 of file bc_esp8266.c.

void bc_esp8266_get_ssid ( bc_esp8266_t self,
char *  ssid 
)

Get SSID.

Parameters
[in]selfInstance
[in]ssidPointer to at least 64 character string

Definition at line 1002 of file bc_esp8266.c.

void bc_esp8266_init ( bc_esp8266_t self,
bc_uart_channel_t  uart_channel 
)

Initialize ESP8266.

Parameters
[in]selfInstance
[in]uart_channelUART channel where TX and RX signals are connected

Definition at line 37 of file bc_esp8266.c.

Here is the call graph for this function:

bool bc_esp8266_is_ready ( bc_esp8266_t self)

Check if modem is ready for commands.

Parameters
[in]selfInstance
Returns
true If ready
false If not ready

Definition at line 146 of file bc_esp8266.c.

Referenced by bc_esp8266_send_data().

Here is the caller graph for this function:

bool bc_esp8266_send_data ( bc_esp8266_t self,
const void *  buffer,
size_t  length 
)

Send data.

Parameters
[in]selfInstance
[in]bufferPointer to data to be transmitted
[in]lengthLength of data to be transmitted in bytes
Returns
true If command was accepted for processing
false If command was denied for processing

Definition at line 225 of file bc_esp8266.c.

Here is the call graph for this function:

void bc_esp8266_set_event_handler ( bc_esp8266_t self,
void(*)(bc_esp8266_t *, bc_esp8266_event_t, void *)  event_handler,
void *  event_param 
)

Set callback function.

Parameters
[in]selfInstance
[in]event_handlerFunction address
[in]event_paramOptional event parameter (can be NULL)

Definition at line 98 of file bc_esp8266.c.

void bc_esp8266_set_password ( bc_esp8266_t self,
char *  password 
)

Set password.

Parameters
[in]selfInstance
[in]passwordPointer to 64 character string

Definition at line 1017 of file bc_esp8266.c.

void bc_esp8266_set_sntp ( bc_esp8266_t self,
int  timezone 
)

Enable SNTP and set time zone.

Parameters
[in]selfInstance
[in]timezoneTime zone, from -11 to 13

Definition at line 111 of file bc_esp8266.c.

Here is the call graph for this function:

void bc_esp8266_set_sntp_with_servers ( bc_esp8266_t self,
int  timezone,
char *  sntp_server1,
char *  sntp_server2,
char *  sntp_server3 
)

Enable SNTP and set configuration.

Parameters
[in]selfInstance
[in]timezoneTime zone, from -11 to 13
[in]sntp_server1First SNTP server
[in]sntp_server2Second SNTP server
[in]sntp_server3Third SNTP server

Definition at line 116 of file bc_esp8266.c.

Referenced by bc_esp8266_set_sntp().

Here is the caller graph for this function:

void bc_esp8266_set_ssid ( bc_esp8266_t self,
char *  ssid 
)

Set SSID.

Parameters
[in]selfInstance
[in]ssidPointer to 64 character string

Definition at line 1007 of file bc_esp8266.c.

void bc_esp8266_set_station_mode ( bc_esp8266_t self,
char *  ssid,
char *  password 
)

Set station mode.

Parameters
[in]selfInstance
[in]ssidSSID
[in]passwordPassword

Definition at line 104 of file bc_esp8266.c.

bool bc_esp8266_ssl_connect ( bc_esp8266_t self,
const char *  host,
uint16_t  port 
)

Establish SSL Connection.

Parameters
[in]selfInstance
[in]hostRemote host
[in]portRemote port
Returns
true If command was accepted for processing
false If command was denied for processing

Definition at line 220 of file bc_esp8266.c.

bool bc_esp8266_tcp_connect ( bc_esp8266_t self,
const char *  host,
uint16_t  port 
)

Establish TCP Connection.

Parameters
[in]selfInstance
[in]hostRemote host
[in]portRemote port
Returns
true If command was accepted for processing
false If command was denied for processing

Definition at line 210 of file bc_esp8266.c.

bool bc_esp8266_udp_connect ( bc_esp8266_t self,
const char *  host,
uint16_t  port 
)

Establish UDP Connection.

Parameters
[in]selfInstance
[in]hostRemote host
[in]portRemote port
Returns
true If command was accepted for processing
false If command was denied for processing

Definition at line 215 of file bc_esp8266.c.