TCP(Transmission control protocol) is a connection-oriented protocol for transferring data reliably in either direction between a pair of users.

When TCP client send data to the server, it requires an acknowledgement in return. If an acknowledgement is not received, TCP automatically retransmit the data and waits for a longer period of time till timeout. After time out socket would be closed.

To open a connection, a packet is sent with SYN(synchronize) flag. To close a connection, a packet is sent with FIN(finish) flag. Urgent messages may also be sent by selecting the PSH(push) flag as a protocol parameter.

The TCP client application demonstrates how  Quessence acts as a TCP client and sends data on server socket using Quessence device.

Click here to download the source code for the TCP Client Socket Application

System Requirements

  1. Quessence
  2. 32/64-bit PC with minimum 2GB RAM and USB port for power, downloading and debugging software
  3. Windows 7/8/8.1/10 Operating System. It should have the Keil IDE and the CMSIS DAP drivers installed on it. Refer to installation section for download and installation steps.
  4. A windows machine (as a WiFi Station) with any TCP client application (This example uses iperf)

Configure the Application

Use an IDE to edit tcp_client.c file available in the path TCP_Client/Applications to make following changes

Macro Value Description
SSID
   “”
This macro refers to the SSID name of your Access point to connect.
CHANNEL_NO

 
This macro refers to particular channel used to scan by the device.If channel is 0 then it will scan all channels.
SECURITY_TYPE
    
This macro refers to the security type of Access point to connect.supports security types like OPEN,WEP,WPA,WPA2
PSK
   “”
This macro refers to the Pre-shared key of the connected Access point.
DEVICE_PORT
    
This macro is to configure port number given to the client (device).
SERVER_PORT
    
This macro is to configure port number of the remote server.
SERVER_IP_ADDRESS
    
This macro is to configure IP address of the remote server.
NUMBER_OF_PACKETS

 
This macro is to configure number of packets to send.
GLOBAL_BUFF_LEN
       8000
This macro is to configure Application memory length which is required by the driver
DHCP_MODE

 

To configure IP for configured station through dhcp set DHCP_MODE  to 1, else configure to 0

To configure static IP address

IP address to be configured to the device should be in long format and in little endian byte order.

Example: 1.To configure “192.168.10.101” as IP address,update the macro DEVICE_IP as 0x650AA8C0.

2. To configure “192.168.10.1” as Gateway,update the macro  GATEWAY as 0x010AA8C0.

3.To configure “255.255.255.0” as network mask,update the macro NETMASK as 0x00FFFFFF 

#define  DEVICE_IP    
#define  GATEWAY      
#define  NETMASK      

 

A sample configuration is shown in the below snapshot

Update the WLAN configuration file

Check the following macros of rsi_wlan_config.h file available in the path TCP_Client/Libraries/Wireless/include

 

Macro Value
CONCURRENT_MODE RSI_DISABLE
RSI_FEATURE_BIT_MAP FEAT_SECURITY_OPEN
RSI_TCP_IP_BYPASS RSI_DISABLE
RSI_TCP_IP_FEATURE_BIT_MAP (TCP_IP_FEAT_DHCPV4_CLIENT)
RSI_CUSTOM_FEATURE_BIT_MAP 0
RSI_BAND RSI_BAND_2P4GHZ

 

Execute the Application

  • Connect Quessence device to the Windows PC running Keil IDE.
  • Configure the macros in the files located at tcp_client.c and /rsi_wlan_config.h as mentioned above.

  • Open an TCP server socket using iperf (using command iperf_demo.exe -s -p -i 1 ) available in Tcp_client application folder by connecting the windows machine(wifi station) to the same AP which device is connecting..

  • On connecting windows machine (as a WiFi Station) to the same SSID, IP address is obtained. Enter this ip in the SERVER_IP_ADDRESS macro in tcp_client.c
  • Build and launch the application.
  • Execute the program, Quessence connects to an Access point . It will then connect to iperf server and send the number of packets pre-configured in NUMBER_OF_PACKETS.