|Description||This application note demonstrates TCP socket connections to resolve host names. It shows how to use the socket related commands of the CC3000.|
The coverage of this application note demonstrates TCP socket connections to resolved host names. It shows how to use the socket related commands of the CC3000.
Pre-requisite Application Note:
Before getting started, the following are required:
- The target module can also be a Diablo16 display
Visit www.4dsystems.com.au/products to see the latest display module products that use the Diablo16 processor.
- 4D Programming Cable / µUSB-PA5/uUSBPA5-II
for non-gen4 displays (uLCD-xxx)
- 4D Programming Cable & gen4-IB / 4D-UPA / gen4-PA
for gen4 displays (gen4-uLCD-xxx)
- micro-SD (µSD) memory card
- Workshop 4 IDE (installed according to the installation document)
When downloading an application note, a list of recommended application notes is shown. It is assumed that the user has read or has a working knowledge of the topics presented in these recommended application notes.
The CC3000 uses network sockets to communicate through the internet. It uses socket addresses that has a specified IP address and port number. For this project a Transmission Control Protocol (TCP) socket connection is utilized.
For instructions on how to launch Workshop 4, how to open a ViSi project, and how to change the target display, kindly refer to the section “Setup Procedure” of the application note
For instructions on how to create a new ViSi project, please refer to the section “Create a New Project” of the application note
In this project couple of objects were used to provide a simple user interface form for the CC3000. In this project the information related to a host se
These icons show the status of connecting to the network. The progress spinner is used to indicate that the processes under the connection icon is currently running or being executed.
In this part of the application note statements that were written in 4DGL will be shown. These statements are used to produce the functionality desired for this project application. Each of the sub-routines has a group of statements that are intended for a designated purpose only.
The statements presented here are called upon in the main function later in this document. It is best to present the purpose of each sub-routine for us to be able to easily understand the main program statements.
The starting part of this application project are very similar to the one used in the pre-requisite application notes indicated. Again, in this application project the IP address is being resolved using the statement shown below.
The first line in the statement uses the host name encoded in the space provided for the WEBSITE string. If the address resolving is done the IP address of the host will be saved to the array ‘result’.
The content of the array ‘result’ will then be converted from separate bytes into a string using the IP2STR function.
The need for converting the result IP address to string is a must due to socket related command which will be shown later. The function below denotes that the content of ‘result’ will be
Converted into a string that will be saved in IP_add array. After a successful retrieval of IP address and converting this to a string we now move to the connection preparation. Before any connection is made, make sure that a TCP socket is opened similar to the one below.
The opened socket will be saved on result. If the value of result is not -1 and less than 8, then the process have successfully opened the TCP socket. The next step is to connect the address to the socket. This command simply attempt to connect the IP_add to the socket with a port number of 80.
Again, the status of the command wSOCKET_CONNECT will be saved on the array result. If the value is 1 then it successfully connected to the host IP address.
Refer to the section "Connect the WiFi Module to the uLCD-35DT" of the application note
for the connection diagram of the WiFi module to the 4D display.
For instructions on how to save a ViSi project, how to connect the target display to the PC, how to select the program destination, and how to compile and download a program, please refer to the section “Run the Program” of the application note