esp8684 2.1.0.0
main.c File Reference

ESP8684 Click Example. More...

#include "board.h"
#include "log.h"
#include "esp8684.h"
#include "string.h"
#include "conversions.h"

Macros

#define PROCESS_BUFFER_SIZE   200
 
#define ESP8684_SSID   "MikroE Public"
 
#define ESP8684_PASSWORD   "mikroe.guest"
 
#define ESP8684_DATA   "MikroE ESP8684 Click"
 
#define REMOTE_IP   "77.46.162.162"
 
#define REMOTE_PORT   "51111"
 
#define TCP_LINK_ID   "0"
 
#define UDP_LINK_ID   "1"
 

Functions

void esp8684_clear_app_buf (void)
 ESP8684 clearing application buffer.
 
void esp8684_log_app_buf (void)
 ESP8684 log application buffer.
 
err_t esp8684_process (void)
 ESP8684 data reading function.
 
err_t esp8684_rsp_check (uint8_t *response)
 ESP8684 response check function.
 
void esp8684_error_check (err_t error_flag)
 ESP8684 error check function.
 
void esp8684_send_message (uint8_t *link_id, uint8_t *message)
 ESP8684 send message function.
 
void esp8684_con_device_to_network (void)
 ESP8684 connect device to the network.
 
void esp8684_send_data (void)
 ESP8684 send message to the host.
 
void application_init (void)
 
void application_task (void)
 
int main (void)
 

Variables

esp8684_t esp8684
 
log_t logger
 
uint8_t app_buf [PROCESS_BUFFER_SIZE] = { 0 }
 
int32_t app_buf_len = 0
 
err_t app_error_flag
 

Detailed Description

ESP8684 Click Example.

Description

This example connects to the desired WiFi network and then connects to the TCP/UDP server, writes then reads data to and from it.

The demo application is composed of two sections :

Application Init

Initializes driver and wifi communication, then connects to the desired WiFi network and sends data to the TCP/UDP server.

Application Task

Writes and reads data from TCP/UDP server, processes all incoming data and displays them on the USB UART.

Additional Function

  • void esp8684_clear_app_buf ( void )
  • void esp8684_log_app_buf ( void )
  • err_t esp8684_process ( void )
  • err_t esp8684_rsp_check ( uint8_t *response )
  • void esp8684_error_check( err_t error_flag )
  • void esp8684_send_message ( uint8_t *link_id, uint8_t *message )
  • void esp8684_con_device_to_network ( void )
  • void esp8684_send_data ( void )
Author
Stefan Ilic

Macro Definition Documentation

◆ ESP8684_DATA

#define ESP8684_DATA   "MikroE ESP8684 Click"

◆ ESP8684_PASSWORD

#define ESP8684_PASSWORD   "mikroe.guest"

◆ ESP8684_SSID

#define ESP8684_SSID   "MikroE Public"

◆ PROCESS_BUFFER_SIZE

#define PROCESS_BUFFER_SIZE   200

◆ REMOTE_IP

#define REMOTE_IP   "77.46.162.162"

◆ REMOTE_PORT

#define REMOTE_PORT   "51111"

◆ TCP_LINK_ID

#define TCP_LINK_ID   "0"

◆ UDP_LINK_ID

#define UDP_LINK_ID   "1"

Function Documentation

◆ application_init()

void application_init ( void )

< Logger config object.

< Click config object.

Logger initialization. Default baud rate: 115200 Default log level: LOG_LEVEL_DEBUG

Note
If USB_UART_RX and USB_UART_TX are defined as HAL_PIN_NC, you will need to define them manually for log to work. See LOG_MAP_USB_UART macro definition for detailed explanation.

◆ application_task()

void application_task ( void )

◆ esp8684_clear_app_buf()

void esp8684_clear_app_buf ( void )

ESP8684 clearing application buffer.

This function clears memory of application buffer and reset its length.

Returns
Nothing.
Note
None.

◆ esp8684_con_device_to_network()

void esp8684_con_device_to_network ( void )

ESP8684 connect device to the network.

This function is used to connect device to network.

Returns
Nothing.
Note
None.

◆ esp8684_error_check()

void esp8684_error_check ( err_t error_flag)

ESP8684 error check function.

This function checks if error has occurred.

Parameters
[in]error_flag: Data to be checked.
Returns
Nothing.
Note
None.

◆ esp8684_log_app_buf()

void esp8684_log_app_buf ( void )

ESP8684 log application buffer.

This function logs application buffer and reset its length.

Returns
Nothing.
Note
None.

◆ esp8684_process()

err_t esp8684_process ( void )

ESP8684 data reading function.

This function reads data from device and concatenates data to application buffer.

Returns
  • 0 - Read some data.
  • -1 - Nothing is read. See #err_t definition for detailed explanation.
Note
None.

◆ esp8684_rsp_check()

err_t esp8684_rsp_check ( uint8_t * response)

ESP8684 response check function.

This function checks the response of the sent command.

Parameters
[in]response: Expected response.
Returns
  • 0 - Responded as expected.
  • -1 - The response isn't the same.. See #err_t definition for detailed explanation.
Note
None.

◆ esp8684_send_data()

void esp8684_send_data ( void )

ESP8684 send message to the host.

This function is used to send messages to the host.

Returns
Nothing.
Note
None.

◆ esp8684_send_message()

void esp8684_send_message ( uint8_t * link_id,
uint8_t * message )

ESP8684 send message function.

This function is used to send messages to the host.

Parameters
[in]link_id: Host link id.
[in]message: Message to be sent.
Returns
Nothing.
Note
None.

◆ main()

int main ( void )

Variable Documentation

◆ app_buf

uint8_t app_buf[PROCESS_BUFFER_SIZE] = { 0 }

◆ app_buf_len

int32_t app_buf_len = 0

◆ app_error_flag

err_t app_error_flag

◆ esp8684

esp8684_t esp8684

◆ logger

log_t logger