REN - R12an0089eu0100 Synergy Wi Fi Esp Wroom 32 - APN - 20180213

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 46

Application Note

Renesas Synergy™ Platform R12AN0089EU0100


Rev.1.00
Wi-Fi Framework Application using ESP-WROOM-32 Feb 12, 2018

Introduction
This document enables the Renesas Synergy Wi-Fi Framework with support for Espressif ESP-WROOM-32 Wi-Fi
module, and provide an application example to demonstrate how to use a generic interface of Synergy Wi-Fi
Framework to configure and provision Wi-Fi modules and perform data transfer with ESP-WROOM-32 networking
stack. By following this approach, the application code is abstracted from the ESP-WROOM-32 driver by the
framework itself even though on-chip networking stack is used.
Document Scope
The following topics are covered in this document:
• Introduction to ESP-WROOM-32 PMOD Module
- Pin assignment and functionality
- Program the module with Espressif official support firmware version 1.0 (ESP-WROOM-32 AT Bin V1.0)
• Overview of the integration between Synergy Wi-Fi Framework and underlying ESP-WROOM-32 driver.
• API Reference: Wi-Fi Framework on ESP-WROOM-32
• Overview of the Wi-Fi Framework operation using on-chip networking stack
• Quick started for Wi-Fi Application example
- SK-S7G2
- TB-S5D5
- DK-S3A7
- TB-S3A6
Target Device and Required Hardware
• Renesas SynergyTM developer kit SK-S7G2 or TB-S5D5 or DK-S3A7 or TB-S3A6
• Renesas ESP-WROOM-32 PMOD module
• Wi-Fi Access Point or Wi-Fi Router
Required Resources
The example application targets Renesas Synergy S3A7 devices. To build and run the application, you need the
following resources.
1. e2 studio ISDE 5.4.0.023 (from Synergy Gallery→Development Tools→e2studio).
2. Synergy Software Package (SSP) 1.3.3 (from Synergy Gallery→Synergy Software Package→Download
Details).
3. Synergy ESP-WROOM-32 Driver Pack (from Synergy Gallery→Partner Showcase→ESP-WROOM-32).

Prerequisites
1. As the user of this application note, you are assumed to have some experience with the Synergy Wi-Fi Framework.
For example, before performing the procedure in this application note, you should follow the procedure in the Wi-
Fi Framework Module Guide (r11an0226eu0100-synergy-wi-fi-framework) to build and run the application
project. By doing so, you will become familiar with the Wi-Fi framework configuration and APIs, and experience
this generic interface for the application.
2. You are expected to go through the Release Note of ESP-WROOM-32 Add-on Component

R12AN0089EU0100 Rev.1.00 Page 1 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32
Contents

1. Introduction of ESP-WROOM-32 PMOD module ..................................................................... 3


1.1 Pin assignment and Schematic of ESP-WROOM-32 PMOD module ..................................................... 3
1.2 Program ESP-WROOM-32 PMOD module through ESP Flash Download Tool .................................... 5

2. Operational overview of Wi-Fi Framework using ESP-WROOM-32 on-chip stack ................. 10


2.1 ESP-WROOM-32 Module Operational Overview using Wi-Fi Framework API..................................... 10
2.2 ESP-WROOM-32 Module Operational Overview using Wi-Fi on-chip stack API ................................. 12
2.2.1 The general steps for IP configuration in Station mode are described in the flow chart that follows .. 12
2.2.2 The general steps for IP configuration in AP mode are described in the flow chart that follows ........ 13
2.3 ESP-WROOM-32 Module Operational Overview using BSD Socket API ............................................. 14
2.3.1 The general steps for using BSD Socket API to create a TCP client communication ........................ 14
2.3.2 The general steps for using BSD Socket API to create a TCP server communication....................... 15

3. API References ..................................................................................................................... 17


3.1 Wi-Fi Framework API on ESP-WROOM-32 Device Driver Interface .................................................... 17
3.1.1 Data structures .................................................................................................................................... 17
3.1.2 Structure reference .............................................................................................................................. 17
3.1.3 Functions ............................................................................................................................................. 17
3.2 Wi-Fi on-chip stack API on ESP-WROOM-32 Device Driver Interface ................................................. 18
3.2.1 Functions ............................................................................................................................................. 18
3.3 BSD Socket API on ESP-WROOM-32 Device Driver Interface ............................................................ 18
3.3.1 Data Structures.................................................................................................................................... 18
3.3.2 Structure reference .............................................................................................................................. 19
3.3.3 Functions ............................................................................................................................................. 19

4. Quick Start Guide for the Wi-Fi Application Example ............................................................. 22


4.1 Overview of the Application Project....................................................................................................... 22
4.1.1 Console Framework User Interface..................................................................................................... 22
4.1.2 Directory structure of Wi-Fi Framework application using ESP-WROOM-32 ..................................... 23
4.2 Component Configurations on Synergy Configurator ........................................................................... 23
4.2.1 Import a Synergy ESP-WROOM-32 Pack file to add Device Driver into SSP .................................... 23
4.2.2 Thread panel setup ............................................................................................................................. 24
4.2.3 Wi-Fi Device Driver Configuration ....................................................................................................... 26
4.3 Wi-Fi application using ESP-WROOM-32 on SK-S7G2........................................................................ 27
4.4 Wi-Fi application using ESP-WROOM-32 on TB-S5D5 ........................................................................ 29
4.5 Wi-Fi application using ESP-WROOM-32 on TB-S3A6 ........................................................................ 30
4.6 Wi-Fi application using ESP-WROOM-32 on DK-S3A7 ........................................................................ 32
4.7 Running the Application example with your PC .................................................................................... 33
4.7.1 Install the USB CDC Device Driver ..................................................................................................... 34
4.7.2 Open the serial terminal tool and check the available commands ...................................................... 35
4.7.3 Provision the ESP-WROOM-32 PMOD module .................................................................................. 35

R12AN0089EU0100 Rev.1.00 Page 2 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32
4.7.4 Check the available commands for TCP socket application ............................................................... 36
4.7.5 Create a TCP server socket connection ............................................................................................. 37
4.7.6 Create a TCP client socket connection ............................................................................................... 39
4.7.7 Close the sockets ................................................................................................................................ 41
4.7.8 Run a simple HTTP web server .......................................................................................................... 42

5. References ............................................................................................................................ 43
1. Introduction of ESP-WROOM-32 PMOD module
The ESP-WROOM-32 PMOD module is designed by Renesas following the PMOD PIN configuration. For the detail
specifications of ESP-WROOM-32, you can the documentations on the Espressif website
(http://espressif.com/en/products/hardware/esp-wroom-32/overview)
1.1 Pin assignment and Schematic of ESP-WROOM-32 PMOD module
ESP-WROOM-32 PMOD module supports both UART and SPI interface on the PMOD connection, and provide GPIO
pin (SELECT pin in the schematic) to MCU to select the communication interface between UART and SPI. As the
Figure 1.1, the analog switch is used to switch the different communication interfaces, and the associated PMOD Pin
assignment is designed for UART mode and SPI mode as below Figure 1.2 and Figure 1.3.

Figure 1.1 Analog switch for interface select


• For UART mode, it’s supported by Synergy ESP-WROOM-32 driver as default, and used with an on-chip network
stack present on the Wi-Fi module. In the example project of this application note, the ESP-WROOM-32 PMOD
module is configured in UART mode. The pin configuration between ESP-WROOM-32 PMOD module and MCU
is described as below.
Table 1:
PMOD J1 connector ESP-WROOM-32 MCU peripheral
1 RTS (IO14) UART CTS
2 RXD (IO16) UART TXD
3 TXD (IO17) UART RXD
4 CTS (IO15) UART RTS
5 GND GND
6 VCC 3.3V VCC 3.3V

R12AN0089EU0100 Rev.1.00 Page 3 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32
7 INT Not use in UART mode
8 EN GPIO for reset control
9 SELECT GPIO for mode selection
10 GPIO (IO32) Not use in UART mode
11 GND GND
12 VCC 3.3V VCC 3.3V

Figure 1.2 PMOD Pin assignment in UART mode


• For SPI Mode, it supports higher throughput than UART mode, and uses the NetX networking stack on the
Synergy MCU. Currently, this mode is unsupported by Synergy ESP-WROOM-32 driver. You may see ESP-
WROOM-32 Release Note for the details.
Table 2:
PMOD J1 connector ESP-WROOM-32 MCU peripheral
1 SS (IO14) UART CTS
2 MOSI (IO16) UART TXD
3 MISO (IO17) UART RXD
4 SCK (IO15) UART RTS
5 GND GND
6 VCC 3.3V VCC 3.3V
7 INT IRQ
8 EN GPIO for reset control
9 SELECT GPIO for mode selection
10 GPIO (IO32) GPIO
11 GND GND
12 VCC 3.3V VCC 3.3V

R12AN0089EU0100 Rev.1.00 Page 4 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32

Figure 1.3 PMOD Pin assignment in SPI mode


Note: If you are using the Espressif’s ESP-WROOM-32 (not the PMOD module), you can refer to Table 1 and 2
to wire the module with Synergy MCU directly.

1.2 Program ESP-WROOM-32 PMOD module through ESP Flash Download Tool
ESP-WROOM-32 is an Espressif’s SoC module, which contains Wi-Fi and Bluetooth radio for IoT applications. The
default firmware of the ESP-WROOM-32 PMOD module should support the on-chip networking stack, and enables the
AT commands interface for external device to access. However, there is a programming interface on the PMOD module
if user needs to update the ESP firmware to the version, which is required by Synergy ESP-WROOM-32 Driver. This
section will go through the programming process of the ESP-WROOM-32 PMOD module step by step.
• Step 1: Download the required ESP firmware and ESP Flash Download Tool.
For the ESP-WROOM-32 add-on component release 1.3.3, it requires ESP-WROOM-32 supporting the firmware,
which is “ESP-WROOM-32 AT Bin V1.0”. Therefore, ensure that you download the correct firmware from Espressif
website. (http://espressif.com/en/products/hardware/esp32-devkitc/resources)
- Download the Flash Download Tool through the below place

Figure 1.4 Flash Download Tools for Windows PC


- Download the Bin files through the below place

R12AN0089EU0100 Rev.1.00 Page 5 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32

Figure 1.5 ESP-WROOM-32 AT Bin V1.0


• Step 2: Use USB to UART converter to connect the ESP-WROOM-32 PMOD module with PC
The ESP-WROOM-32 PMOD module provides a programming interface on connector J2. Referring to the Figure 1.6,
you can manually connect the TX/RX from your USB to UART convertor to the J2’s RXD0/TXD0, and remember to
use a jumper to short the J2’s Pin3 and Pin4.

Figure 1.6 programming interface on ESP-WROOM-32 PMOD module


Note 1: For the ESP-WROOM-32, the IO0 requires to be pull low to enter its bootloader for firmware update.
Note 2: The TXD0 and RXD0 on J2 provides a debug console when the IO0 is not pull low.

R12AN0089EU0100 Rev.1.00 Page 6 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32

• Step 3: Set SW1 on the PMOD such that Boot is ON and SPI is OFF.
• Start the ESP Flash Download Tool to download the Bin files.
As shown in Figure 1.7, run the ESP Flash Download Tool on your windows.

Figure 1.7 Flash Download Tool v 3.6.2.2


You will be able to see the image as same as Figure 1.8, select “Download for ESP32”.

Figure 1.8 select ESP32 Download Tool


As the Figure 1.9, the ESP32 Download Tool provides Download Path Configuration, Com Port Selection and
configuration of SPI Flash.
First, you can refer to the setting on Figure 1.9 to configure on module SPI Flash, or you can start the programming first
to get the detected information of on-board SPI Flash, which is highlighted in the below red box.

R12AN0089EU0100 Rev.1.00 Page 7 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32

Figure 1.9 ESP32 Flash Download Tool


Second, user needs to configure the Bin Files with memory offset. After you download the package of ESP-WROOM-
32 AT Bin V1.0, you will find the files under the location \esp-wroom32_at_v1.0\ESP-WROOM32_AT_V1.0\ESP-
WROOM32_AT_V1.0 as Figure 1.7.

Figure 1.7 files in the package of ESP-WROOM-32 AT Bin V1.0


Select the specified Bin files with the correct offset, which are described as below, to be programming through the tool.
- Bootloader.bin with memory offset 0x1000
- Partitions_at.bin with memory offset 0x8000
- Phy_init_data.bin with memory offset 0xf000
- At_customize.bin with memory offset 0x20000
- Esp-at.bin with memory offset 0x100000
- Server_cert.bin with memory offset 0x24000
- Server_key.bin with memory offset 0x26000

R12AN0089EU0100 Rev.1.00 Page 8 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32
- Server_ca.bin with memory offset 0x28000
- Ble_data.bin with memory offset 0x21000
Third, remember to click the S1 switch to reset the module before you click START button.

Figure 1.8 reset switch on ESP-WROOM-32 PMOD module


• Step 4: Use Tera Term to confirm that the firmware is programmed to the module successfully
After the programming is done, the Flash Download Tool will show the completed message. Since the PMOD module
is connected with PC, you can easily use Tera Term to check that Bin files is successfully programmed to the module
with correct offset.
First, close the Flash Download Tool
Second, use Tera Term to open the COM port
Third, take out the jumper, which shorts the IO0 with GND.
Fourth, click the S1 switch to reset the module
If the firmware is programmed, you will see that debug message is transmitted by same COM port, and the message
connect should be as same as below. In the message, module is initialized with the default settings.

Figure 1.9 receive debug message from ESP-WROOM-32

R12AN0089EU0100 Rev.1.00 Page 9 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32
2. Operational overview of Wi-Fi Framework using ESP-WROOM-32 on-chip stack
Figure 2.1 shows an overview of Synergy Wi-Fi Framework layered architecture. The Wi-Fi Framework includes the
enclosed 5 blocks in the middle of the architecture, which are Network Stack Abstraction Layer(NSAL), Wi-Fi
Framework API, Wi-Fi on-chip Stack API, BSD Socket API, and the Wi-Fi Device Driver Interface. For the ESP-
WROOM-32 Device Driver release on SSP 1.3.3 only supports making use of an on-chip networking stack as the Path2
of the architecture graph, so the operation description of Wi-Fi Framework using ESP-WROOM-32 module will focus
in the Wi-Fi on-chip stack API block and BSD Socket API block. For the implementation of Path 1, the Wi-Fi
Device Driver should be able to provide an instance to support the NSAL interface. In the meanwhile, it will also
require the firmware on ESP-WROOM-32 to bypass its on-chip stack, so currently this implementation is still under
development.

Figure 2.1 Wi-Fi framework organization, options, and stack implementations

2.1 ESP-WROOM-32 Module Operational Overview using Wi-Fi Framework API


This section describes the operational overview in a typical Wi-Fi application for initialization of the Wi-Fi module. In
order to call the Wi-Fi Framework API in the user application, the ESP-WROOM-32 Device driver component should
be added through the Synergy Configurator as the Figure 2.2. This component creates the instance of the Wi-Fi Device
Driver Interface for use of the following steps.

Figure 2.2 Synergy ESP-WROOM-32 Device Driver Component


The general steps for Wi-Fi module initialization are described in the flow chart that follows
1. After the component is added, generate the Project Content.

R12AN0089EU0100 Rev.1.00 Page 10 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32
2. When Wi-Fi on-chip stack API component or BSD Socket component is added on top of Wi-Fi Device component,
the user application should call the BSD Socket Interface open function or Wi-Fi on-chip stack open function.
Then, the Wi-Fi Framework open function is called internally to initialize and enable the Wi-Fi module.
3. User application calls Wi-Fi Framework scan function to get the available Access Points.
4. User application creates a Wi-Fi provision variable, and fill up the parameters following the Wi-Fi provisioning
structure.

Figure 2.3 Wi-Fi provisioning structure defined by sf_wifi_api.h


5. User application calls Wi-Fi Framework provisioningSet function to provision the Wi-Fi module.
6. Wi-Fi module is ready for data transfer on successful completion of the specified steps

Figure 2.4 Wi-Fi module initialization with on-chip networking stack support

R12AN0089EU0100 Rev.1.00 Page 11 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32
2.2 ESP-WROOM-32 Module Operational Overview using Wi-Fi on-chip stack API
This section describes the operational overview in using the Wi-Fi on-chip stack API to configure the IP address in
Station mode or AP mode. In order to call the Wi-Fi on-chip stack API in the user application, the on-chip stack on
Wi-Fi Framework component should be added through the Synergy Configurator as the Figure 2.4. This component
creates the instance of the Wi-Fi on-chip stack API Interface for use of the following steps.

Figure 2.5 Synergy on-chip stack on Wi-Fi Framework Component

2.2.1 The general steps for IP configuration in Station mode are described in the flow
chart that follows
1. After Wi-Fi module is provisioned in Station mode, user application creates an IP interface configuration variable
following the IP Interface configuration structure

Figure 2.6 Wi-Fi on-chip stack IP configuration structure defined by sf_wifi_onchip_stack_api.h


2. User application fills ip_addr_mode with SF_WIFI_IP_ADDR_DHCP or SF_WIFI_IP_ADDR_STATIC
depending on using DHCP or not. (if ip_addr_mode is configured as SF_WIFI_IP_ADDR_STATIC, the static
IP address, net mask and gateway should be filled up.)
3. User application calls Wi-Fi on-chip stack ipAddressCfg function to configure IP address.
4. If DHCP is enabled, user application fills ip_addr_mode with SF_WIFI_IP_ADDR_GET, and calls
ipAddressCfg function again to get the assigned IP address, net mask and gateway.

R12AN0089EU0100 Rev.1.00 Page 12 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32

Figure 2.7 Wi-Fi module IP configuration in Station mode with on-chip networking stack support

2.2.2 The general steps for IP configuration in AP mode are described in the flow chart
that follows
1. After Wi-Fi module is provisioned in AP mode, user application creates an IP interface configuration variable, and
fills ip_addr_mode with SF_WIFI_IP_ADDR_DHCP.
2. User application calls Wi-Fi on-chip stack ipAddressCfg function to enable the DHCP (It’s required by network
stack on ESP-WROOM-32 running on SoftAP mode)
3. User applications fills ip_addr_mode with SF_WIFI_IP_ADDR_GET, and calls ipAddressCfg function to get
the IP address of ESP-WROOM-32 SoftAP.
4. User application create a starting address of IP range that can be obtained by DHCP server following the IP address
structure
5. User application create an ending address of IP range that can be obtained by DHCP server following the IP
address structure

Figure 2.8 IP address structure defined by sf_wifi_api.h


6. User application calls Wi-Fi on-chip stack dhcpServerStart function and fills with the starting address and ending
address to configure the DHCP Server.

R12AN0089EU0100 Rev.1.00 Page 13 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32

Figure 2.9 Wi-Fi module IP configuration in AP mode with on-chip networking stack support
2.3 ESP-WROOM-32 Module Operational Overview using BSD Socket API
This section describes the operational overview in using the BSD Socket API to communicate with Wi-Fi module over
the sockets. In order to call the BSD Socket API in the user application, the BSD Socket using On-Chip Stack on Wi-Fi
Framework component should be added through the Synergy Configurator as shown in Figure 2.4. This component
creates the instance of the BSD Socket API Interface for use of the following steps

Figure 2.10 BSD Socket using On-Chip Stack on Wi-Fi Framework Component

2.3.1 The general steps for using BSD Socket API to create a TCP client communication
1. User application calls the BSD Socket API socket function to create a TCP socket and return a socket file
descriptor (Socket FD), which indicates this created socket
2. User application calls the BSD Socket API setsockopt function with the specified Socket FD and required option
name to set this socket to be kept alive.
3. User application calls the BSD Socket API connect function with the specified Socket FD and remote TCP server
information. The remote TCP server IP address and port should be filled up following the below structure.

R12AN0089EU0100 Rev.1.00 Page 14 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32

Figure 2.11 Socket IP address structure defined by sf_socket_api.h


4. Once the connection is established, user application calls the BSD Socket API getsockopt function with the
specified Socket FD and required option name to get the socket status from on-chip networking stack. The socket
status will be returned on the below structure, which is defined by ESP-WROOM-32 Device Driver Interface.

Figure 2.12 socket structure on ESP-WROOM-32 Device Driver


5. User application calls the BSD Socket API recv/send/recvfrom/sendto functions for the data transfer

Figure 2.13 establish TCP Client communication using BSD Socket API

2.3.2 The general steps for using BSD Socket API to create a TCP server
communication
1. User application calls the BSD Socket API socket function to create a TCP socket and return a socket file
descriptor (Socket FD), which indicates this created socket

R12AN0089EU0100 Rev.1.00 Page 15 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32
2. User application calls the BSD Socket API bind function to create a TCP server on specified port using on-chip
networking stack present on ESP-WROOM-32.
3. User application calls the BSD Socket API listen function with the specified number of maximum client
connections.
4. User application calls the BSD Socket API accept function to confirm the TCP client connection. Once the
connection is established, accept function returns a new socket file descriptor (Socket FD) and IP address
information of remote client
5. User application calls the BSD Socket API recv/send/recvfrom/sendto functions with the new socket file
descriptor for the data transfer

Figure 2.14 establish TCP Server communication using BSD Socket API

R12AN0089EU0100 Rev.1.00 Page 16 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32
3. API References
This section describes the supported Wi-Fi Framework APIs, Wi-Fi on-chip stack APIs and BSD Socket API on
ESP-WROOM-32 Device Driver
Note: This section will skip the definition of instances, control structure and configuration structure, which are
defined by Synergy Wi-Fi framework. User can refer to the Wi-Fi framework module guide for those
definitions.
3.1 Wi-Fi Framework API on ESP-WROOM-32 Device Driver Interface
RTOS-integrated Wi-Fi framework implementation of ESP-WROOM-32 Driver. The implementation includes the
following interfaces.
3.1.1 Data structures
• st_sf_wifi_on_esp_wroom_32_cfg with data fields
• uart_instance_t const * p_lower_lvl_uart: UART Interface used for Wi-Fi communications

• ioport_port_pin_t pin_enable; Port pin used as ESP-WROOM-32 chip enable

• ioport_port_pin_t pin_uart_rts; Port pin used as ESP-WROOM-32 RTS

• ioport_port_pin_t pin_uart_cts; Port pin used as ESP-WROOM-32 CTS

• ioport_port_pin_t pin_extra; Port pin used for controlling ESP-WROOM-32 GPIO

• uint16_t max_packet_window; Number of bytes of packet window size

• void * p_block_pool_mem; Memory used for block pool

• void * p_queue_mem; Memory used for the packet queue

3.1.2 Structure reference


• #include <sf_wifi_esp_wroom_32.h>
3.1.3 Functions
• ssp_err_t SF_WIFI_ESP_WROOM_32_Open(sf_wifi_ctrl_t * p_ctrl, sf_wifi_cfg_t
const * const p_cfg)
Initialize Wi-Fi module.
• ssp_err_t SF_WIFI_ESP_WROOM_32_Close(sf_wifi_ctrl_t * const p_ctrl)
Stop Wi-Fi module.
• ssp_err_t SF_WIFI_ESP_WROOM_32_ProvisioningSet(sf_wifi_ctrl_t * const p_ctrl,
sf_wifi_provisioning_t const * const p_wifi_provisioning)
Provisions the Wi-Fi module.
• ssp_err_t SF_WIFI_ESP_WROOM_32_ProvisioningGet(sf_wifi_ctrl_t * const p_ctrl,
sf_wifi_provisioning_t * const p_wifi_provisioning)
Reads the current Wi-Fi provisioning information of the Wi-Fi module.
• ssp_err_t SF_WIFI_ESP_WROOM_32_Scan(sf_wifi_ctrl_t * const p_ctrl,
sf_wifi_scan_t * const p_scan, uint8_t * const p_cnt)
Scan for available Aps.
• ssp_err_t SF_WIFI_ESP_WROOM_32_MACAddressGet(sf_wifi_ctrl_t * const p_ctrl,
uint8_t * const p_mac)
Get MAC address of Wi-Fi module
• ssp_err_t SF_WIFI_ESP_WROOM_32_MACAddressSet(sf_wifi_ctrl_t * const p_ctrl,
uint8_t const * const p_mac)
Set MAC address of Wi-Fi module
• ssp_err_t SF_WIFI_ESP_WROOM_32_VersionGet(ssp_version_t * const p_version)

R12AN0089EU0100 Rev.1.00 Page 17 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32
Get version of Wi-Fi device driver interface

3.2 Wi-Fi on-chip stack API on ESP-WROOM-32 Device Driver Interface


The implementation includes the following interfaces.
3.2.1 Functions
• ssp_err_t SF_WIFI_ESP_WROOM_32_ONCHIP_STACK_Open(sf_wifi_onchip_stack_ctrl_t
* p_ctrl, sf_wifi_onchip_stack_cfg_t const * const p_cfg)
Enable the driver link, and call Wi-Fi Framework Open API internally
• ssp_err_t SF_WIFI_ESP_WROOM_32_ONCHIP_STACK_Close(sf_wifi_onchip_stack_ctrl_t
* const p_ctrl)
Disable the driver link, and call Wi-Fi Framework Close API internally
• ssp_err_t SF_WIFI_ESP_WROOM_32_ONCHIP_STACK_IPAddressConfigure
(sf_wifi_onchip_stack_ctrl_t * const p_ctrl, sf_wifi_onchip_stack_ip_cfg_t *
const p_cfg)
Use on-chip networking stack to configure static IP address or get IP address through DHCP
• ssp_err_t SF_WIFI_ESP_WROOM_32_ONCHIP_STACK_DhcpServerStart
(sf_wifi_onchip_stack_ctrl_t * const p_ctrl, sf_wifi_ip_addr_t const * const
p_start_ip, sf_wifi_ip_addr_t const * const p_end_ip)
Starts DHCP Server on on-chip networking stack present on Wi-Fi module
• ssp_err_t SF_WIFI_ESP_WROOM_32_ONCHIP_STACK_DhcpServerStop
(sf_wifi_onchip_stack_ctrl_t * const p_ctrl)
Stop DHCP server on on-chip networking stack present on Wi-Fi module
• ssp_err_t SF_WIFI_ESP_WROOM_32_ONCHIP_STACK_VersionGet(ssp_version_t * const
p_version)
Get version of Wi-Fi on-chip stack Interface
3.3 BSD Socket API on ESP-WROOM-32 Device Driver Interface
The implementation includes the following interfaces.
3.3.1 Data Structures
• st_esp_wroom_32_socket
• int8_t link_id: ID of network connection(TCP/UDP/SSL). The maximum number of network
connection is 5, so the range of this parameter is 0~4.
• uint8_t * status: network connection status of specified link ID
• sf_wifi_socket_protocol_type_t protocol_type: network protocol type of specified link
ID. Enumeration of protocol type is listed as below.
- SOCK_STREAM: TCP
- SOCK_DGRM: UDP
- SOCK_SSL: SSL
• sf_wifi_socket_conn_type_t conn_type: network connection type of specified link ID.
Enumeration of connection type is listed as below.
- DISCONN: disconnect form network
- SERVER: server connection is established
- CLIENT: client connection is established
• struct sockaddr remote_ip_addr: IP address information of remote device of specified link ID

R12AN0089EU0100 Rev.1.00 Page 18 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32
• struct sockaddr local_ip_addr: IP address information of local device of specified link ID
• uint8_t error_code: error code log of specified link ID. This parameter can be read by BSD Socket
API getsockopt function.
• bool tcp_keep_alive: enable/disable TCP connection for keeping alive. When TCP connection is set
to keep alive, the detection time interval is 2 hours, which is set by on-chip networking stack
3.3.2 Structure reference
• #include <sf_wifi_esp_wroom_32_socket.h>
3.3.3 Functions
• ssp_err_t SF_WIFI_ESP_WROOM_32_SOCKET_Open(sf_socket_ctrl_t * p_ctrl,
sf_socket_cfg_t const * const p_cfg)
- Configure the parameters of ESP-WROOM-32 socket structure
- Update global variables for future use
- Call Wi-Fi on-chip stack API Open function internally
• ssp_err_t SF_WIFI_ESP_WROOM_32_SOCKET_Close(sf_socket_ctrl_t * const p_ctrl)
Disable the link of Wi-Fi on-chip stack instance, and call Wi-Fi on-chip stack API Close function internally
• ssp_err_t SF_WIFI_ESP_WROOM_32_SOCKET_VersionGet(ssp_version_t * const
p_version)
Get version of socket Interface
• int socket(int domain, int type, int protocol)
Create an endpoint for communication and returns a File Descriptor for the socket. This API takes three arguments:
Name Direction Description Options
domain In specifies the protocol 1. AF_INET6 (10): IPv6 (not supported)
family of the created 2. AF_INET (2): IPv4
socket. 3. AF_UNIX (1): Local socket (not supported)
type In Socket type 1. SOCK_STREAM: connection-oriented
sockets, which use TCP
2. SOCK_DGRAM: connectionless sockets,
which use UDP
3. SOCK_SSL: use SSL
protocol In Protocol type 1. IPPROTO_TCP (0)
2. IPPROTO_UDP (1)
3. IPPROTO_SSL (2)

• int close(int socket_fd)


Free a socket’s resources, and disconnect it from the remote host. This API only takes the File Descriptor.
• int bind(int socket_fd, const struct sockaddr * p_local_sock_addr, socklen_t
addrlen)
Bind a socket to a local port. This API takes three arguments:
Name Direction Description Option
socket_fd In Local socket File Descriptor 0~4
p_local_sock_addr In Pointer to a local socket address Follow socket internet address
structure (sockaddr)
addrlen In Size of socket address structure Sizeof(sockaddr)

• int listen(int sockfd, int backlog)


Set socket in listen mode for TCP client connection. This API takes two arguments

R12AN0089EU0100 Rev.1.00 Page 19 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32
Name Direction Description Option
sockfd In Local socket File Descriptor 0~4
backlog In Max number of connection 1~5
queue

• int connect(int sockfd, const struct sockaddr * p_serv_addr, socklen_t


addrlen)
Connect a socket to a TCP Server on a given port. This API takes three arguments
Name Direction Description Option
sockfd In Local socket File Descriptor 0~4
p_serv_addr In Pointer to a remote socket Follow socket internet address
address structure (sockaddr)
addrlen In Size of socket address structure Sizeof(sockaddr)

• int accept(int sockfd, struct sockaddr * p_cliaddr, socklen_t * p_addrlen)


Accept the stream-oriented connection request from the remote clients, and return a new File Descriptor for the
accepted connection. This API takes three arguments
Name Direction Description Option
sockfd In Local socket File Descriptor 0~4
p_cliaddr Out Pointer to a remote socket Follow socket internet address
address, which try to connect to structure (sockaddr)
server
p_addlen Out Size of socket address structure Sizeof(sockaddr)

• ssize_t send(int sockfd, const void * p_buf, size_t length, int flags)
Send data to remotes socket. This API takes four arguments.
Name Direction Description Option
sockfd In Local socket File Descriptor 0~4
p_buf In Pointer to data buffer
length In Transmit data length Maximum length is 2048
flags In timeout 0~0xFFFF

• ssize_t recv(int sockfd, void * p_buf, size_t length, int flags)


Receive data form a remote socket. This API takes four arguments.
Name Direction Description Option
sockfd In Local socket File Descriptor 0~4
p_buf Out Pointer to receive data buffer
length In Maximum length of data which Maximum length is 2048
can be received
flags In Time out 0~0xFFFF

• ssize_t sendto(int sockfd, const void * p_buf, size_t length, int flags,
const struct sockaddr * p_dest_addr, socklen_t addrlen)
Send data to a remote socket address. This API takes six arguments.

R12AN0089EU0100 Rev.1.00 Page 20 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32
Name Direction Description Option
sockfd In Local socket File Descriptor 0~4
p_buf In Pointer to transmit data buffer
length In Transmit data length Maximum length is 2048
flags In Time out 0~0xFFFF
p_dest_addr In Pointer to remote socket
address where to send data
addrlen In Length of socket address
structure

• ssize_t recvfrom(int sockfd, void * p_buf, size_t length, int flags, struct
sockaddr * p_src_addr, socklen_t * p_addrlen)
Receive data from a remote socket address. This API takes six arguments.
Name Direction Description Option
sockfd In Local socket File Descriptor 0~4
p_buf Out Pointer to receive data buffer
length In Maximum length of data which Maximum length is 2048
can be received
flags In Time out 0~0xFFFF
p_src_addr In Pointer to remote socket
address which has sent data
p_addrlen Out Length of socket address
structure

• int setsockopt(int sockfd, int level, int optname, const void * p_optval,
socklen_t optlen)
Set socket options. According to the ESP-WROOM-32 Device driver, the supported option name is
SO_KEEPALIVE.
Name Direction Description Option
sockfd In Local socket File Descriptor 0~4
level In Socket API level SOL_SOCKET
optname In Option to be set SO_KEEPALIVE
p_optval In Option value to be set True/False
socklen_t In Length of option value

• int getsockopt(int sockfd, int level, int optname, void * p_optval, socklen_t
* p_optlen)
Get socket options. According to the ESP-WROOM-32 Device driver, the supported option name are
SO_CONNSTATE, SO_TYPE, SO_ERROR. The description of each option name is listed as below.
SO_CONNSTATE: get connection status of specified Socket Descriptor File. Returning optval follows the socket
structure, which is defined by driver (sf_wifi_esp_wroom_32_socket.h)
SO_TYPE: get protocol type of specified Socket Description File. Returning optval follows the enumeration of
protocol type, which is defined by driver (sf_wifi_esp_wroom_32_socket.h)
SO_ERROR: get error code log of specified Socket Descriptor File. Returning optval follows the enumeration of
error code, which is defined by driver (sf_wifi_esp_wroom_32_socket.h)

R12AN0089EU0100 Rev.1.00 Page 21 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32
Name Direction Description Option
sockfd In Local socket File Descriptor 0~4
level In Socket API level SOL_SOCKET
optname In Option to be set SO_CONNSTATE, SO_TYPE
and SO_ERROR
p_optval Out Option value to be set Relative to the optname
socklen_t In Length of option value

4. Quick Start Guide for the Wi-Fi Application Example


The application project associated with this guide demonstrates the typical steps, which are described in Chapter 2. You
may import the example project regarding to which Synergy Kit you have, and view the configuration settings for the
ESP-WROOM-32 Device and SSP components. You can also read the code in the wifi_thread_entry.c file, used to
illustrate the Wi-Fi on-chip stack APIs and BSD Socket APIs in a complete design.
4.1 Overview of the Application Project
The application project is implemented on the Synergy SK-S7G2, TB-S5D5, DK-S3A7 and TB-S3A6 boards with ESP-
WROOM-32 PMOD module, and it contains a single thread to handle a Command Line Interface and the Wi-Fi
application. According to the commands receiving from the PC, the application project uses Wi-Fi on-chip stack API
and BSD Socket API to establish a network connection, multiple socket connections (Client/Server) and a simple HTTP
web page.
Note: In this application project, using the NetX networking stack is not supported, and the ESP-WROOM-32 Device
Driver only supports the communication with the ESP-WROOM-32 PMOD module through the SCI UART.

Figure 4.1 software architecture of Wi-Fi on-chip stack application


Before proceeding to exercise any of the software application projects, ensure your PMOD is programmed with the
firmware. After the firmware is programmed successfully, set the BOOT to OFF with SW1 on the PMOD.

4.1.1 Console Framework User Interface


The application project allows interactions with hardware through the Console framework on USB CDC. A COM port
terminal on the PC such as Tera Term, is required to send the user commands or read the message during the
demonstration. This Command Line Interface where you can
 Scan the available Wi-Fi Access Points

R12AN0089EU0100 Rev.1.00 Page 22 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32
 Select the Wi-Fi Access Points to connect
 Store a default SSID/Password of Wi-Fi Access Points in the Synergy MCU Data Flash
 Get the MAC Address of your ESP-WROOM-32 PMOD module
 Create a TCP socket connection with a specified remote TCP server
 Create a local TCP server on a specified port, and accept the connection request from remote TCP client
 Transmit message through TCP socket connection
 Echo the message through TCP socket connection
 Run a simple HTTP web server
In the coming section, we will go through the operation scenario step by step.
4.1.2 Directory structure of Wi-Fi Framework application using ESP-WROOM-32
Figure 4.2 shows the directory structure of the Wi-Fi framework application using the ESP-WROOM-32 module.

Figure 4.2 directory structure of Wi-Fi application project

4.2 Component Configurations on Synergy Configurator


This section describes the Thread panel setup and ESP-WROOM-32 Device Driver configuration in the Synergy
Configurator. To use with different Synergy MCU, below properties configuration will need to be adjusted with the
appropriate memory usage and interrupt priority setup.
4.2.1 Import a Synergy ESP-WROOM-32 Pack file to add Device Driver into SSP
Download the Synergy ESP-WROOM-32 Pack file and import the pack file into the Packs folder under your e2stuio
installation directory as shown in Figure 4.3.
Note: Highly recommend you to re-open the e2studio workbench after this action is done.

R12AN0089EU0100 Rev.1.00 Page 23 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32

Figure 4.3 Packs folder under e2studio installation directory


Open the e2sutio workbench, and create a new project. You should be able to see that there are three components,
which are added to the SSP. These three components generate the required Wi-Fi Framework instances to be used, and
Wi-Fi Device Driver.

Figure 4.4 Components of ESP-WROOM-32 Device Driver

4.2.2 Thread panel setup


As shown in Figure 4.5, create a new thread from the Thread panel and add a BSD Socket component, which is named
as “BSD Socket using On-Chip Stack on Wi-Fi Framework”. Some dependent configurations, which depends on the

R12AN0089EU0100 Rev.1.00 Page 24 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32
usage, still need to be done manually. If in a box with pink base there is the key[Optional], the required action is
possible but not necessary needed.

Figure 4.5 Add a BSD Socket Component


Once the specified BSD Socket component is added, it automatically inserts the required component such as the Wi-Fi
On-chip Stack component and Device Driver component. The Synergy ESP-WROOM-32 device driver uses UART to
communication with Wi-Fi module, and it supports either enabling or disabling the external RTS operation. If you
enable the external RTS operation, the DTC Driver for Reception should be taken out.

OR

Figure 4.6 framework architecture view on the Synergy Configurator


In the Synergy Configuration view, you can configure the properties of each SSP component. Click the SSP component,
which is in the Thread Panel, and check the Properties window as shown in the Figure 4.7.

R12AN0089EU0100 Rev.1.00 Page 25 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32

Figure 4.7 Properties window in Synergy Configuration view


In the properties window, you can easily configure the parameters of Wi-Fi Framework configuration structure, and it
will be generated with the instances for application use. we will introduce how to configure the properties of ESP-
WROOM-32 Device Driver through the Properties view in the next section.
4.2.3 Wi-Fi Device Driver Configuration
See section 3.1.1 for the configuration structure of ESP-WROOM-32 driver interface. Some of parameters in the
configuration structure, are available for user to configure through the Properties view as shown in Figure 4.8. These
property settings are highly depended on the application and hardware specification. For example, you will see the
configuration of these properties are slightly different in the application project on SK-S7G2, TB-S5D5, TB-S3A6 and
DK-S3A7.

Figure 4.8 Properties view of the ESP-WROOM-32 Device Driver component


The description of ESP-WROOM-32 driver properties in the Figure 4.8 is listed as below.

R12AN0089EU0100 Rev.1.00 Page 26 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32
- Network Mode: There are On-chip Stack Mode and Ethernet Forwarding Mode. Ethernet Forwarding Mode
supports NetX networking stack by bypassing the ESP-WROOM-32 on-chip stack. This mode will be
supported in the future release.
- UART RTSCTS: Enable the callback function for the RTS external pin control in the device driver. When
this property is enabled, the external RTS Operation of UART Driver should be also enabled.
- Maximum number of available APs in SCAN: This property can be set by user, but the value should not be
set over 20. The reason is that this parameter is affected by the size of memory allocation and the timeout.
Note: For using Synergy S3A6 or S124, set this value to be less than 10.
- Maximum number of packet in the block pool: This property represents the number of blocks in the block
pool. Wi-Fi device driver creates a block pool in the initialization, and dynamically allocate a block to store
the received/transmitted data during the TCP transparent transmission.
- Name: define a name for Wi-Fi device driver instance
- Chip Enable Pin: define a Pin for connecting with ESP-WROOM-32 PMOD EN Pin.
- WROOM32 RTS Pin: define a Pin for connecting with ESP-WROOM-32 PMOD RTS Pin.
- WROOM32 CTS Pin: define a Pin for connecting with ESP-WROOM-32 PMOD CTS Pin.
- WROOM32 GPIO Pin: define a Pin for connecting with ESP-WROOM-32 PMOD GPIO Pin.
- Packet window size: This property represents the size of each block in the block pool for storing the packet.
The maximum size is 2048 because the maximum length of packet is fixed as 2048 by ESP-WROOM-32 on-
chip stack.
4.3 Wi-Fi application using ESP-WROOM-32 on SK-S7G2
For the example project on SK-S7G2 in this App-note, the ESP-WROOM-32 PMOD module is connected with
PMODB of SK-S7G2. In the Synergy Configurator, the Pin configuration and Wi-Fi device driver configuration should
be associated with the hardware setup.

Figure 4.9 SK-S7G2 Board with ESP-WROOM-32 PMOD module connected


Select the g_sf_wifi0 ESP WROOM 32 Device Driver on sf_wifi_esp_wroom_32 block, and you will see the settings as
same as Figure 4.10. The properties that requires to be changed for hardware connection are marked in the red boxes.

R12AN0089EU0100 Rev.1.00 Page 27 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32

Figure 4.10 configuration of ESP-WROOM-32 Device Driver for SK-S7G2


According to the Pin assignment, the SCI channel 0 should be set for UART communication, and the CTS_RTS pin
should be configured if the external RTS operation is enabled.

Figure 4.11 Pin configuration of SCI channel 0 for ESP-WROOM-32 communication


Configure the P6_03 and P4_12 for the Chip Enable Pin and RTS Control Pin.

Figure 4.12 Pin configuration for Chip Enable Pin and RTS Pin

R12AN0089EU0100 Rev.1.00 Page 28 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32
4.4 Wi-Fi application using ESP-WROOM-32 on TB-S5D5
For the example project on TB-S5D5 in this App-note, the ESP-WROOM-32 PMOD module is connected with
PMODA of TB-S5D5. In the Synergy Configurator, the Pin configuration and Wi-Fi device driver configuration should
be associated with the hardware setup.

Figure 4.13 TB-S5D5 Board with ESP-WROOM-32 PMOD module connected


Select the g_sf_wifi0 ESP WROOM 32 Device Driver on sf_wifi_esp_wroom_32 block, and you will see the settings as
same as Figure 4.14. The properties that require to be changed for hardware connection are marked in the red boxes.

Figure 4.14 configuration of ESP-WROOM-32 Device Driver for TB-S5D5


According to the Pin assignment, the SCI channel 0 should be set for UART communication, and the CTS_RTS pin
should be configured if the external RTS operation is enabled.

R12AN0089EU0100 Rev.1.00 Page 29 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32

Figure 4.15 Pin configuration of SCI channel 0 for ESP-WROOM-32 communication


Configure the P1_07 and P1_02 for the Chip Enable Pin and RTS Control Pin.

Figure 4.16 Pin configuration for Chip Enable Pin and RTS Pin
4.5 Wi-Fi application using ESP-WROOM-32 on TB-S3A6
For the example project on TB-S3A6 in this App-note, the ESP-WROOM-32 PMOD module is connected with
PMODA of TB-S3A6. In the Synergy Configurator, the Pin configuration and Wi-Fi device driver configuration should
be associated with the hardware setup.

R12AN0089EU0100 Rev.1.00 Page 30 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32

Figure 4.17 TB-S3A6 Board with ESP-WROOM-32 PMOD module connected


Select the g_sf_wifi0 ESP WROOM 32 Device Driver on sf_wifi_esp_wroom_32 block, and you will see the settings as
same as Figure 4.18. The properties that requires to be changed for hardware connection are marked in the red boxes

Figure 4.18 configuration of ESP-WROOM-32 Device Driver for TB-S3A6


According to the Pin assignment, the SCI channel 0 should be set for UART communication, and the CTS_RTS pin
should be configured if the external RTS operation is enabled

Figure 4.19 Pin configuration of SCI channel 0 for ESP-WROOM-32 communication


Configure the P1_07 and P1_02 for the Chip Enable Pin and RTS Control Pin.

R12AN0089EU0100 Rev.1.00 Page 31 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32

Figure 4.20 Pin configuration for Chip Enable Pin and RTS Pin
4.6 Wi-Fi application using ESP-WROOM-32 on DK-S3A7
For the example project on DK-S3A7 in this App-note, the ESP-WROOM-32 PMOD module is connected with
PMODA of DK-S3A7. In the Synergy Configurator, the Pin configuration and Wi-Fi device driver configuration should
be associated with the hardware setup.

Figure 4.21 DK-S3A7 Board with ESP-WROOM-32 PMOD module connected


Select the g_sf_wifi0 ESP WROOM 32 Device Driver on sf_wifi_esp_wroom_32 block, and you will see the settings as
same as Figure 4.22. The properties that requires to be changed for hardware connection are marked in the red boxes

R12AN0089EU0100 Rev.1.00 Page 32 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32

Figure 4.22 configuration of ESP-WROOM-32 Device Driver for DK-S3A7


According to the Pin assignment, the SCI channel 3 should be set for UART communication, and the CTS_RTS pin
should be configured if the external RTS operation is enabled.

Figure 4.23 Pin configuration of SCI channel 3 for ESP-WROOM-32 communication


Configure the P7_05 and P4_10 for the Chip Enable Pin and RTS Control Pin.

Figure 4.24 Pin configuration for Chip Enable Pin and RTS Pin
4.7 Running the Application example with your PC
Review the following points before proceeding to the operation of this application project:

R12AN0089EU0100 Rev.1.00 Page 33 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32
- Make sure you have your PC connected to a Wi-Fi access point before running this application project.
- Have a TCP testing tool on your PC, such as Sokit-1.3
- Have a serial terminal tool on your PC, such as Tera Term
- Make sure that 3.3V is selected for PMOD on Synergy Kit. It’s important to select 3.3V for the Wi-Fi PMOD
module. Otherwise, the module might be damaged.
- Connect the micro USB cable from your PC to the USB Debug port on the Synergy Kit.
- Connect the micro USB cable from your PC to the USB device connector on the Synergy Kit. It’s used for
Command Line Interface.
- ESP-WROOM-32 PMOD module and the Synergy Kit choosen
4.7.1 Install the USB CDC Device Driver
The Command Line interface is implemented on USB CDC Device. This requires the USB CDC device driver being
installed on the PC.
For Windows 10, it’s not necessary to install the USB CDC device driver because the Class code of USB CDC device
descriptor is set as Miscellaneous, which allows Synergy Kit to be detected as a USB serial device by Win10. As shown
in Figure 4.25, Synergy kit USB device is detected as USB serial device in the Device Manager.

Figure 4.25 USB CDC port enumeration on Windows 10


For windows 7, user should modify the USBX Device Configuration of the application project. The Vendor ID, Product
ID and Class Code should be modified as same as the Figure 4.26.

Figure 4.26 USBX Device Configuration


Second, install the Renesas_USB_Driver_x64_for_USB_Boot_MCU_TypeB.exe. This installation file is included by
the Renesas Flash Programmer, which can be downloaded through the link https://www.renesas.com/en-
eu/software/D4000309.html

R12AN0089EU0100 Rev.1.00 Page 34 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32

4.7.2 Open the serial terminal tool and check the available commands
When you run the software, and confirm the COM port enumeration, open the Tera Term or other serial terminal tool.

Figure 4.27 connect to the COM port


On opening the Tera Term, type “?” and press the Enter key to review the available commands.

Figure 4.28 available commands on the Command Line Interface


There are four commands, which are provided through the Command Line Interface. The simple description of each
command is printed as shown in the Figure 4.28.
4.7.3 Provision the ESP-WROOM-32 PMOD module
For provisioning, you can either enter setup_prov command to set up SSID and Password of your AP, or enter scan
command and follow the below instruction to set up SSID and Password.
Note: If you want to setup a default Wi-Fi access, please use the setup_prov command, it will store the SSID/Password
into MCU’s data flash.
Enter scan command to get available APs. Once the scan is completed, the information of AP will be printed through
the Command Line Interface. Then, select which AP you want to connect, and enter # to complete. After that, following
the instructions to enter the password, and enter # to complete the input.

R12AN0089EU0100 Rev.1.00 Page 35 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32

Figure 4.29 SCAN and Input Password


Now, the SSID and Password are all set, enter the connect command to provision the Wi-Fi module.

Figure 4.30 connect to the Wi-Fi Access Point


If you are wondering what the MAC address of ESP-WROOM-32 module is, you can enter the get_mac command.
Then, you should be able to get the address through the Command Line Interface as shown in Figure 4.31.

Figure 4.31 get the MAC address of ESP-WROOM-32 PMOD module


4.7.4 Check the available commands for TCP socket application
After provisioning is done successfully, enter the bsd_socket command, which will switch the interface to another
command menu. In this menu, it provides the commands for running the TCP socket application.

R12AN0089EU0100 Rev.1.00 Page 36 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32

Figure 4.32 available commands for running TCP application


The detail descriptions of each command are listed as below.
- Tcp_server: user can enter this command to establish a local TCP server on specified port.
Usage: enter tcp_server <a space> <specified port> <a space> <Maximum client number which is allowed to
connect>
- Tcp_client: user can enter this command to create a socket to connect with a remote TCP server.
Usage: enter tcp_client <a space> <IP address of remote TCP server> <a space> <Port of remote TCP server>
- Socket_close: user can enter this command to close the specified socket connection. The socket Descriptor File is
required.
Usage: enter socket_close <a space> <Socket Descriptor File of the socket connection which you want to close>
- Echo: user can enter this command to echo the received data
Usage: enter echo <a space> <Socket Descriptor File which indicates the socket connection>
- Transmit: user can enter this command following the message, which you want to transmit.
Usage: enter transmit <a space> <transfer data>
- List: user can enter this command to get the status of current socket connections.
Usage: enter list
4.7.5 Create a TCP server socket connection
Following the usage of tcp_server command, create a TCP server on the Port 7, and only accept one TCP client
connection.

R12AN0089EU0100 Rev.1.00 Page 37 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32

Figure 4.33 create a local TCP server on Port 7


After the command is typed, use the TCP test tool to connect the Synergy TCP Server. Here, you will need to enter the
IP address of Synergy device and the Port 7 as shown in the Figure 4.34. Once you get the message to show that
connection is established, the Socket Descriptor File(SockFD) of this socket connection will be displayed on the
terminal as shown in the red box of Figure 4.33.

Figure 4.34 use TCP test tool to create a Client socket connection
Since the socket connection is established, user can transfer the data from Synergy device to the PC. Following the
usage of transmit command, transmit the message “hello PC client”, and you will need to use the Socket Descriptor
File(SockFD) here.

R12AN0089EU0100 Rev.1.00 Page 38 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32

Figure 4.35 transmit the message through the socket connection


After that, check the TCP test tool, and you should see the message.

Figure 4.36 receive the message through the socket connection on PC


4.7.6 Create a TCP client socket connection
Create a TCP server on the PC using the TCP test tool, so we know the IP address and Port of remote TCP server.

Figure 4.37 create a TCP Server on the PC


Following the usage of tcp_client command, user can create a TCP client socket on Synergy device and send the
request to the remote TCP server. Here, you will need to enter the IP address and Port of remote TCP server.

R12AN0089EU0100 Rev.1.00 Page 39 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32

Figure 4.38 create a TCP Client socket connection


Once the connection request is accepted by TCP Server on PC, you will get the message to show the Socket Descriptor
File (SockFD) on the terminal. Now, we can play with echo command.
Use the TCP test tool to transmit the message through the socket connection

Figure 4.39 accept the socket connection and send the message from PC
Back to the Command Line Interface, enter the echo command with the Socket Descriptor File (SockFD), which you
got from previous message.

Figure 4.40 echo the received data through the client socket connection

R12AN0089EU0100 Rev.1.00 Page 40 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32
In the TCP test tool, you should be able to that the same message is returned from Synergy TCP client

Figure 4.41 receive data from Synergy TCP Client


4.7.7 Close the sockets
By going through the section 4.7.5 and 4.7.6, you should already create 2 socket connections. In order to check the
status of socket connections, you can enter the list command to get the status. As shown in the Figure 4.42, the returned
messages show the information of current socket connections. If you want to terminate the socket connection, you can
enter the socket_close command following the Socket Descriptor File as shown in Figure 4.42.
For example, after I terminate the Server Socket, which is indicated by SockFD 0, the list command will only return the
connection status of the Client Socket.

Figure 4.42 terminate the socket connection


Back to the TCP test tool, you can also see that the client connection is terminated by TCP server.

Figure 4.43 TCP client socket on PC is terminated by Synergy

R12AN0089EU0100 Rev.1.00 Page 41 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32
4.7.8 Run a simple HTTP web server
This application project implements a simple HTTP web page by using the BSD Socket API. In the project, Wi-Fi
thread creates a local TCP server on Port 80 and wait for remote TCP client to connect. After the connection is establish
and receive the messages from client, Wi-Fi thread transmits the HTML strings to the client. The overall operation can
be executed by enter the http_server command through the Command Line Interface.
Restart the device, after provisioning and switching to the bsd socket interface, issue command http_server as shown
below.

Figure 4.44 run a simple HTTP web server on the Synergy Kit
Once you enter the http_server command, you will see the message, which shows “HTTP Server waiting on port 80”,
and the interface will be pended in this moment. Then, you open the browser on the PC, and enter the IP address of
Synergy device. In the meanwhile, Synergy device will accept the connection, and start to transmit the data. After the
web page is displayed as Figure 4.45, you should be able to see the message, which is highlighted in the red box of the
Figure 4.44.

Figure 4.45 a simple HTTP web page

R12AN0089EU0100 Rev.1.00 Page 42 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32
5. References
1. Synergy Project Import Guide attached as part of the Application.
2. User’s Manual of ESP-WROOM-32 PMOD module
3. Synergy Wi-Fi Framework Module Guide
4. ESP-WROOM-32 hardware datasheet

R12AN0089EU0100 Rev.1.00 Page 43 of 44


Feb 12, 2018
Renesas Synergy™ Platform Wi-Fi Framework Application using ESP-WROOM-32
Website and Support
Support: https://synergygallery.renesas.com/support
Technical Contact Details:
• America: https://renesas.zendesk.com/anonymous_requests/new
• Europe: https://www.renesas.com/en-eu/support/contact.html
• Japan: https://www.renesas.com/ja-jp/support/contact.html

All trademarks and registered trademarks are the property of their respective owners.

R12AN0089EU0100 Rev.1.00 Page 44 of 44


Feb 12, 2018
Revision History
Description
Rev. Date Page Summary
1.0 1/26/2018 42
Notice
1. Descriptions of circuits, software and other related information in this document are provided only to illustrate the operation of semiconductor products and application examples. You are fully responsible for
the incorporation or any other use of the circuits, software, and information in the design of your product or system. Renesas Electronics disclaims any and all liability for any losses and damages incurred by
you or third parties arising from the use of these circuits, software, or information.
2. Renesas Electronics hereby expressly disclaims any warranties against and liability for infringement or any other disputes involving patents, copyrights, or other intellectual property rights of third parties, by or
arising from the use of Renesas Electronics products or technical information described in this document, including but not limited to, the product data, drawing, chart, program, algorithm, application
examples.
3. No license, express, implied or otherwise, is granted hereby under any patents, copyrights or other intellectual property rights of Renesas Electronics or others.
4. You shall not alter, modify, copy, or otherwise misappropriate any Renesas Electronics product, whether in whole or in part. Renesas Electronics disclaims any and all liability for any losses or damages
incurred by you or third parties arising from such alteration, modification, copy or otherwise misappropriation of Renesas Electronics products.
5. Renesas Electronics products are classified according to the following two quality grades: "Standard" and "High Quality". The intended applications for each Renesas Electronics product depends on the
product’s quality grade, as indicated below.
"Standard": Computers; office equipment; communications equipment; test and measurement equipment; audio and visual equipment; home electronic appliances; machine tools; personal electronic
equipment; and industrial robots etc.
"High Quality": Transportation equipment (automobiles, trains, ships, etc.); traffic control (traffic lights); large-scale communication equipment; key financial terminal systems; safety control equipment; etc.
Renesas Electronics products are neither intended nor authorized for use in products or systems that may pose a direct threat to human life or bodily injury (artificial life support devices or systems, surgical
implantations etc.), or may cause serious property damages (space and undersea repeaters; nuclear power control systems; aircraft control systems; key plant systems; military equipment; etc.). Renesas
Electronics disclaims any and all liability for any damages or losses incurred by you or third parties arising from the use of any Renesas Electronics product for which the product is not intended by Renesas
Electronics.
6. When using the Renesas Electronics products, refer to the latest product information (data sheets, user’s manuals, application notes, "General Notes for Handling and Using Semiconductor Devices" in the
reliability handbook, etc.), and ensure that usage conditions are within the ranges specified by Renesas Electronics with respect to maximum ratings, operating power supply voltage range, heat radiation
characteristics, installation, etc. Renesas Electronics disclaims any and all liability for any malfunctions or failure or accident arising out of the use of Renesas Electronics products beyond such specified
ranges.
7. Although Renesas Electronics endeavors to improve the quality and reliability of Renesas Electronics products, semiconductor products have specific characteristics such as the occurrence of failure at a
certain rate and malfunctions under certain use conditions. Further, Renesas Electronics products are not subject to radiation resistance design. Please ensure to implement safety measures to guard them
against the possibility of bodily injury, injury or damage caused by fire, and social damage in the event of failure or malfunction of Renesas Electronics products, such as safety design for hardware and
software including but not limited to redundancy, fire control and malfunction prevention, appropriate treatment for aging degradation or any other appropriate measures by your own responsibility as warranty
for your products/system. Because the evaluation of microcomputer software alone is very difficult and not practical, please evaluate the safety of the final products or systems manufactured by you.
8. Please contact a Renesas Electronics sales office for details as to environmental matters such as the environmental compatibility of each Renesas Electronics product. Please investigate applicable laws and
regulations that regulate the inclusion or use of controlled substances, including without limitation, the EU RoHS Directive carefully and sufficiently and use Renesas Electronics products in compliance with all
these applicable laws and regulations. Renesas Electronics disclaims any and all liability for damages or losses occurring as a result of your noncompliance with applicable laws and regulations.
9. Renesas Electronics products and technologies shall not be used for or incorporated into any products or systems whose manufacture, use, or sale is prohibited under any applicable domestic or foreign laws
or regulations. You shall not use Renesas Electronics products or technologies for (1) any purpose relating to the development, design, manufacture, use, stockpiling, etc., of weapons of mass destruction,
such as nuclear weapons, chemical weapons, or biological weapons, or missiles (including unmanned aerial vehicles (UAVs)) for delivering such weapons, (2) any purpose relating to the development,
design, manufacture, or use of conventional weapons, or (3) any other purpose of disturbing international peace and security, and you shall not sell, export, lease, transfer, or release Renesas Electronics
products or technologies to any third party whether directly or indirectly with knowledge or reason to know that the third party or any other party will engage in the activities described above. When exporting,
selling, transferring, etc., Renesas Electronics products or technologies, you shall comply with any applicable export control laws and regulations promulgated and administered by the governments of the
countries asserting jurisdiction over the parties or transactions.
10. Please acknowledge and agree that you shall bear all the losses and damages which are incurred from the misuse or violation of the terms and conditions described in this document, including this notice,
and hold Renesas Electronics harmless, if such misuse or violation results from your resale or making Renesas Electronics products available any third party.
11. This document shall not be reprinted, reproduced or duplicated in any form, in whole or in part, without prior written consent of Renesas Electronics.
12. Please contact a Renesas Electronics sales office if you have any questions regarding the information contained in this document or Renesas Electronics products.
(Note 1) "Renesas Electronics" as used in this document means Renesas Electronics Corporation and also includes its majority-owned subsidiaries.
(Note 2) "Renesas Electronics product(s)" means any product developed or manufactured by or for Renesas Electronics.

(Rev.3.0-1 November 2016)

SALES OFFICES http://www.renesas.com


Refer to "http://www.renesas.com/" for the latest and detailed information.
Renesas Electronics America Inc.
2801 Scott Boulevard Santa Clara, CA 95050-2549, U.S.A.
Tel: +1-408-588-6000, Fax: +1-408-588-6130
Renesas Electronics Canada Limited
9251 Yonge Street, Suite 8309 Richmond Hill, Ontario Canada L4C 9T3
Tel: +1-905-237-2004
Renesas Electronics Europe Limited
Dukes Meadow, Millboard Road, Bourne End, Buckinghamshire, SL8 5FH, U.K
Tel: +44-1628-585-100, Fax: +44-1628-585-900
Renesas Electronics Europe GmbH
Arcadiastrasse 10, 40472 Düsseldorf, Germany
Tel: +49-211-6503-0, Fax: +49-211-6503-1327
Renesas Electronics (China) Co., Ltd.
Room 1709, Quantum Plaza, No.27 ZhiChunLu Haidian District, Beijing 100191, P.R.China
Tel: +86-10-8235-1155, Fax: +86-10-8235-7679
Renesas Electronics (Shanghai) Co., Ltd.
Unit 301, Tower A, Central Towers, 555 Langao Road, Putuo District, Shanghai, P. R. China 200333
Tel: +86-21-2226-0888, Fax: +86-21-2226-0999
Renesas Electronics Hong Kong Limited
Unit 1601-1611, 16/F., Tower 2, Grand Century Place, 193 Prince Edward Road West, Mongkok, Kowloon, Hong Kong
Tel: +852-2265-6688, Fax: +852 2886-9022
Renesas Electronics Taiwan Co., Ltd.
13F, No. 363, Fu Shing North Road, Taipei 10543, Taiwan
Tel: +886-2-8175-9600, Fax: +886 2-8175-9670
Renesas Electronics Singapore Pte. Ltd.
80 Bendemeer Road, Unit #06-02 Hyflux Innovation Centre, Singapore 339949
Tel: +65-6213-0200, Fax: +65-6213-0300
Renesas Electronics Malaysia Sdn.Bhd.
Unit 1207, Block B, Menara Amcorp, Amcorp Trade Centre, No. 18, Jln Persiaran Barat, 46050 Petaling Jaya, Selangor Darul Ehsan, Malaysia
Tel: +60-3-7955-9390, Fax: +60-3-7955-9510
Renesas Electronics India Pvt. Ltd.
No.777C, 100 Feet Road, HAL II Stage, Indiranagar, Bangalore, India
Tel: +91-80-67208700, Fax: +91-80-67208777
Renesas Electronics Korea Co., Ltd.
12F., 234 Teheran-ro, Gangnam-Gu, Seoul, 135-080, Korea
Tel: +82-2-558-3737, Fax: +82-2-558-5141

© 2017 Renesas Electronics Corporation. All rights reserved.


Colophon 6.0

You might also like