Facebook Pixel

AN-00131 ViSi TCP Socket Connections

Description This application note demonstrates TCP socket connections to resolve host names. It shows how to use the socket related commands of the CC3000.
Supported Processor DIABLO16
Supported Environment ViSi
Difficulty Difficult

 

File Downloads
Files

Description

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:

ViSi Connecting the CC3000 to an AP
Visi Resolving Remote Address

 

Before getting started, the following are required:

Visit www.4dsystems.com.au/products to see the latest display module products that use the Diablo16 processor.

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.

 

Application Overview

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.

 

Setup Procedure

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

 

ViSi Getting Started - First Project for Picaso and Diablo16

 

Create a New Project

For instructions on how to create a new ViSi project, please refer to the section “Create a New Project” of the application note

 

ViSi Getting Started - First Project for Picaso and Diablo16

 

Design of the Project

Layout of the Project

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

The GUI string inputs and output display locations

 

Connection Status and

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.

 

The ViSi-based CC3000 Program

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 TCP Socket Connection 

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[0]. If the value of result[0] 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.

 

Run the Program

Refer to the section "Connect the WiFi Module to the uLCD-35DT" of the application note

 

ViSi Connecting the CC3000 to an AP

 

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

 

ViSi Getting Started - First Project for Picaso and Diablo16

Share: