Close
Recently, ModusToolbox added a new set of connectivity software libraries called AnyCloud. Together, they enable seamless development of Wi-Fi and BLE based connectivity projects with the PSoC 6 MCU and CYW43xx Wi-Fi + Bluetooth combo devices. AnyCloud is a framework for IoT application development that is not tied to a specific cloud provider or management tool.
In this blog post, we will see how to configure PSoC 6 MCU as a TCP client and a TCP server using the AnyCloud libraries.
TCP/IP protocol is a communication standard that defines how to establish and maintain a network conversation between two parties in a network. The TCP/IP protocol is based on client-server model. TCP is used for organizing data in a way that guarantees the integrity of data sent over the network, regardless of the amount. Hence, this protocol is used to transmit data from other higher-level protocols (such as HTTP, FTP etc.) that require all transmitted data to arrive.
Network communication using the TCP/IP protocol typically involves creation of a socket, through which information exchange takes place between two connected parties in a network. You can consider socket similar to a door having an address and a door number. Similarly, a socket has a unique combination of an address (IP address) and a number (port number).
This TCP client and server implementation makes use of two AnyCloud libraries – Secure Sockets and Wi-Fi Connection Manger libraries.
The Secure Sockets library significantly simplifies the task of creating a socket and managing the network communication. It abstracts out the popular network stack lwIP and the secure library MbedTLS, thus enabling you to establish a secure connection. AnyCloud also offers a Wi-Fi Connection Manager (WCM) which makes Wi-Fi connections easier and more reliable. WCM provides an easy-to-use API to scan and connect. It also manages and preserves the Wi-Fi connection in a background thread.
The basic steps involved in a TCP client operation are follows:
The basic steps involved in a TCP server operation are follows:
As part of the whole AnyCloud Solution, we have code examples demonstrating the basic steps required to set up a TCP client and a TCP server using the PSoC 6 MCU and CYW43xxx connectivity devices. You can try out these examples on Wi-Fi enabled kits such as
In the TCP client example, PSoC 6 MCU is configured as a TCP client, which establishes a connection with a remote TCP server and, based on the command received from the TCP server, turns the user LED ON or OFF. In the TCP server example, server establishes a connection with a TCP client. Once the connection completes successfully, the server allows the user to send LED ON/OFF command to the TCP client and the client responds by sending an acknowledgement message to the server.
To understand better on how to use the AnyCloud and the TCP client/server examples, you can start exploring the examples in the GitHub repository. To access the code examples:
You can follow the instructions given in the example README.md file to understand the operation. If you have more than two Wi-Fi enabled kits as listed previously, you can try out TCP server example on one kit and TCP client example on the other kit. Also feel free to explore the source code and let us know your thoughts!
For more AnyCloud examples, refer to Cypress GitHub repository.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.