Network Component  
MDK Middleware for IPv4 and IPv6 Networking
 
Loading...
Searching...
No Matches
Network Examples

Many networking applications can be built with the Network Middleware Component. The following examples demonstrate the usage of the most popular services in the component.

  • The HTTP Server example shows the basic functionality of an embedded web server. It also contains information on the usage of the Common Gateway Interface (CGI) interface for web page interaction with the underlying hardware.
  • The HTTPS Server example shows the basic functionality of a secure web server using the mbed TLS software component.
  • The HTTP Upload example demonstrates how to access the SD card on a development board via a web interface.
  • In the FTP Server example you will learn to use a FTP server for file manipulation.
  • The Telnet Server example gives an example how to use Telnet to implement a User Callbacks for communication with your device.
  • Sending dynamic e-mail messages to a predefined email address is explained in the SMTP Client example.
  • The SNMP Agent example shows you how to use the Simple Network Management Protocol to control an embedded system.
  • The BSD Client/Server example shows you how to use BSD sockets for network communication.

Download these examples using the , select the related Board and Copy the example to your working directory.

Note
Depending on your target device or development board, you may not see all of these examples in Pack Installer.

HTTP Server

The HTTP Server example uses a fixed set of web pages stored in ROM, but is capable of exchanging information with the underlying hardware by using the CGI interface. The following picture shows an exemplary connection of the development board and a Computer.

HTTP server hardware setup

The Abstract.txt file contained in the Documentation group of the Project window gives you more information on the general setup and the available I/O of the development board.

Build the "HTTP Server" Project

Open the example project in MDK (the web page explains how to do this). The µVision Project window should display a similar project structure:

Compact Web Server Project Structure

Source Files

  • HTTP_Server.c contains the main C function that initializes the board hardware and the Network Component.
  • The HTTP_Server_CGI.c defines the functions for the scripting language for communication with the hardware.
  • Web.c is a compiled file that will be generated by the tool from all the web input files.
  • The Web files group contains all the HTML and CGI files that will be compiled into the Web.c` file. The files in this group determine the actual layout of the web page and the behaviour of the different refs using CGI.
  • A HTTP_Server_Multiuser.c file can be added using the feature. This file is used for specifying multiple users and access rights for these users.
  • Adding the HTTP_Server_Access.c file enables the server to accept or block connection requests from certain remote clients.
  • The user code template file HTTP_Server_Error.c contains the information that the web server is showing in case of errors (such as Error 404).

You may now build and download the example project to the evaluation board using the µVision commands:

  • Project - Build target
  • Flash - Download

After these steps, the project should start executing on your evaluation kit. In case of errors, refer to the Evaluation Board User's Guide for configuration information. If you want to know how the file converter works that is required to compile the web pages into a single C file, please visit the page.

Note
MDK Middleware 7.1.0 and above offers security extensions that can be used to convert the HTTP into a HTTPS server. Follow the instructions as described on page Converting the HTTP server to HTTPS.

Using the "HTTP Server" Project

Hardware Setup

The setup of the Evaluation Board hardware is described in the Abstract.txt file.

  • Verify all jumper settings on the target hardware.
  • Use an Ethernet cable to connect your development board to the local area network. The PC is assumed to be already in this LAN.

PC Software

The web server can be tested on any PC using any browser available. Simply, type in the Local Host Name that is defined in the Net_Config.h file. The default name is my_host. If you have a DCHP server in your network, you will be automatically connected. You need to log in. As for all network examples, use "admin" (without the quotes) for the user and no password (you can change the defaults in the Net_Config_HTTP_Server.h file). The following (or a similar) page will come up in your browser:

HTTP server web page

If you get an error message, please verify that all network, IP and other settings are correct.

HTTPS Server

The HTTPS Server example uses a fixed set of web pages stored in ROM, but is capable of exchanging information with the underlying hardware by using the CGI interface. The HTTPS server uses the ARM mbed TLS software component to enable Secure Communication. The following picture shows an exemplary connection of the development board and a Computer.

HTTPS server hardware setup

The Abstract.txt file contained in the Documentation group of the Project window gives you more information on the general setup and the available I/O of the development board.

Build the "HTTPs Server" Project

Open the example project in MDK (the web page explains how to do this). The µVision Project window should display a similar project structure:

Compact Secure Web Server Project Structure

Source Files

  • HTTP_Server.c contains the main C function that initializes the board hardware and the Network Component.
  • The HTTP_Server_CGI.c defines the functions for the scripting language for communication with the hardware.
  • Web.c is a compiled file that will be generated by the tool from all the web input files.
  • The Web files group contains all the HTML and CGI files that will be compiled into the Web.c` file. The files in this group determine the actual layout of the web page and the behavior of the different refs using CGI.
  • A HTTP_Server_Multiuser.c file can be added using the feature. This file is used for specifying multiple users and access rights for these users.
  • Adding the HTTP_Server_Access.c file enables the server to accept or block connection requests from certain remote clients.
  • The user code template file HTTP_Server_Error.c contains the information that the web server is showing in case of errors (such as Error 404).
  • The file Net_Security.c in the Network group contains the certificate for secure communication. If you want to change the default certificate, refer to Creating your own certificates and keys.

You may now build and download the example project to the evaluation board using the µVision commands:

  • Project - Build target
  • Flash - Download

After these steps, the project should start executing on your evaluation kit. In case of errors, refer to the Evaluation Board User's Guide for configuration information. If you want to know how the file converter works that is required to compile the web pages into a single C file, please visit the page.

Using the "HTTPS Server" Project

Hardware Setup

The setup of the Evaluation Board hardware is described in the Abstract.txt file.

  • Verify all jumper settings on the target hardware.
  • Use an Ethernet cable to connect your development board to the local area network. The PC is assumed to be already in this LAN.

PC Software

The web server can be tested on any PC using any browser available. Simply, type in the Local Host Name that is defined in the Net_Config.h file. The default name is my_host. If you have a DCHP server in your network, you will be automatically connected. You need to log in. As for all network examples, use "admin" (without the quotes) for the user and no password (you can change the defaults in the Net_Config_HTTP_Server.h file). The following (or a similar) page will come up in your browser:

HTTPS server web page

If you get an error message, please verify that all network, IP and other settings are correct.

HTTP Upload

The HTTP Upload example gives a web based interface to the SD card that is attached to a development board. The user is able to list the contents of the memory card and to upload files to it. The following picture shows an exemplary connection of the development board and a Computer.

HTTP upload example hardware setup

The Abstract.txt file contained in the Documentation group of the Project window gives you more information on the general setup and the available I/O of the development board.

Build the "HTTP Upload" Project

Open the example project in MDK (the web page explains how to do this). The µVision Project window should display a similar project structure:

HTTP Upload Project Structure

Source Files

  • HTTP_Upload.c contains the main C function that initializes the board hardware and the Network Component.
  • The HTTP_Server_CGI.c defines the functions for the scripting language for communication with the hardware.
  • Web.c is a compiled file that will be generated by the tool from all the web input files.
  • The Web files group contains all the HTML and CGI files that will be compiled into the Web.c` file. The files in this group determine the actual layout of the web page and the behaviour of the different refs using CGI.

You may now build and download the example project to the evaluation board using the µVision commands:

  • Project - Build target
  • Flash - Download

After these steps, the project should start executing on your evaluation kit. In case of errors, refer to the Evaluation Board User's Guide for configuration information.

Using the "HTTP Upload" Project

Hardware Setup

The setup of the Evaluation Board hardware is described in the Abstract.txt file.

  • Verify all jumper settings on the target hardware.
  • Use an Ethernet cable to connect your development board to the local area network. The PC is assumed to be already in this LAN.

PC Software

The web server can be tested on any PC using any browser available. Simply, type in the Local Host Name that is defined in the Net_Config.h file. If you have a DCHP server in your network, you will be automatically connected. You need to log in. As for all network examples, use "admin" (without the quotes) for the user and no password (you can change the defaults in the Net_Config_HTTP_Server.h file). The following (or a similar) page will come up in your browser:

HTTP upload web page

If you get an error message, please verify that all network, IP and other settings are correct.

FTP Server

This tutorial creates a FTP server that allows you to manage files from any machine using a FTP client. The following picture shows an exemplary connection of the development board and a Computer.

FTP server hardware setup

Build the "FTP Server" Project

Open the example project in MDK (the web page explains how to do this). The µVision Project window should display a similar project structure:

FTP Server Project Structure

Source Files

  • FTP_Server.c contains the main C function that initializes the board hardware and the Network Component.
  • A FTP_Server_Multiuser.c file can be added using the feature. This file is used for specifying multiple users and access rights for these users.
  • Adding the FTP_Server_Access.c file enables the server to accept or block connection requests from certain remote clients.
  • The user code template file FTP_Server_Event.c contains a routine that notifies the user application about certain events happening on the FTP server (such as file/directory manipulation events).

You may now build and download the example project to the evaluation board using the µVision commands:

  • Project - Build target
  • Flash - Download

After these steps, the project should start executing on your evaluation kit. In case of errors, refer to the Evaluation Board User's Guide for configuration information.

Using the "FTP Server" Project

Hardware Setup

The setup of the Evaluation Board hardware is described in the Abstract.txt file.

  • Verify all jumper settings on the target hardware.
  • Use an Ethernet cable to connect your development board to the local area network. The PC is assumed to be already a member of this LAN.
  • If your hardware supports it, insert a SD card into the SD card slot. This will be the data storage that you will have access to. Hardware that does not have a SD card interface will most probably use a RAM disk for FTP demonstration.

PC Software

To connect to the FTP server, all you need is a FTP client. On a Windows PC you can use the Command Prompt. Simply type ftp my_host (or the respective hostname that you have chosen in the Net_Config.h file). If you have a DCHP server in your network, it will automatically connect to the FTP server. You will be asked for a username and password combination. As for all network examples, this is "admin" (without the quotes) for the user and no password (you can change the defaults in the Net_Config_FTP_Server.h file). After a successful log in, you should see something like this:

FTP server command line interface

Telnet Server

Often, it is necessary to have a Command Line Interface (CLI) for interaction with the device. This example shows how to use the Telnet server for this purpose. The following picture shows an exemplary connection of the development board and a Computer.

Telnet example hardware setup

Build the "Telnet" Project

Open the example project in MDK (the web page explains how to do this). The µVision Project window should display a similar project structure:

Telnet Client Project Structure

Source Files

  • Telnet_Server.c contains the main C function that initializes the board hardware and the Network Component.
  • The Telnet_Server_UIF.c defines the functions for the user interface and all the available CLI commands.
  • A Telnet_Server_Multiuser.c file can be added using the feature. This file is used for specifying multiple users and access rights for these users.
  • Adding the Telnet_Server_Access.c file enables the server to accept or block connection requests from certain remote clients.

You may now build and download the example project to the evaluation board using the µVision commands:

  • Project - Build target
  • Flash - Download

After these steps, the project should start executing on your evaluation kit. In case of errors, refer to the Evaluation Board User's Guide for configuration information.

Using the "Telnet" Project

Hardware Setup

The setup of the Evaluation Board hardware is described in the Abstract.txt file.

  • Verify all jumper settings on the target hardware.
  • Use an Ethernet cable to connect your development board to the local area network. The PC is assumed to be already a member of this LAN.

PC Software

For opening a Telnet session, you need a Telnet client. As this is not an integral part of Windows any more, please look for an alternative on the Internet. PuTTY has a good feature set and is easy to install and use. When you connect to your board using a Telnet client, please enter my_host (or the respective hostname that you have chosen in the Net_Config.h file) in the hostname field and use the standard Telnet port 23. You will be asked for log-in credentials. Like for all other tutorials, the default is admin for the username without any password (you can change the defaults in the Net_Config_Telnet_Server.h file). Using the help command, you can see the list of available CLI commands:

Telnet Command Line Interface

SMTP Client

SMTP is used for sending e-mail notifications from an embedded system to various recipients. This example shows how to setup a SMTP client for this purpose. The following picture shows an exemplary connection of the development board and a Computer.

SMTP client hardware setup

Build the "SMTP Client" Project

Open the example project in MDK (the web page explains how to do this). The µVision Project window should display a similar project structure:

SMTP Client Project Structure

Source Files

  • SMTP_Client.c contains the main C function that initializes the board hardware, the Network Component and provides the IP address of SMTP server.
  • The SMTP_Client_UIF.c defines the sender's and recipient's e-mail addresses and the subject. Optionally, you can specify a SMTP username and password.

You may now build and download the example project to the evaluation board using the µVision commands:

  • Project - Build target
  • Flash - Download

After these steps, the project should start executing on your evaluation kit. In case of errors, refer to the Evaluation Board User's Guide for configuration information.

Using the "SMTP Client" Project

Hardware Setup

The setup of the Evaluation Board hardware is described in the Abstract.txt file.

  • Verify all jumper settings on the target hardware.
  • Use an Ethernet cable to connect your development board to the local area network. The PC is assumed to be already a member of this LAN.

PC Software

If you have entered your personal e-mail address as the recipient's address, you only need to open your mail program and check your inbox.

SNMP Agent

The Simple Network Management Protocol (SNMP) is mainly used in network management systems to monitor network-attached devices for conditions that warrant administrative attention. It is the most popular network management protocol in the TCP/IP protocol suite. The SNMP Agent example shows how to use SNMP to control an embedded system. The following picture shows an exemplary connection of the development board and a Computer.

SNMP agent hardware setup

Build the "SNMP Agent" Project

Open the example project in MDK (the web page explains how to do this). The µVision Project window should display a similar project structure:

SNMP Agent Project Structure

Source Files

  • SNMP_Agent.c contains the main C function that initializes the board hardware and the Network Component.
  • The SNMP_Agent_MIB.c contains the mib_data_table. Change this to the application's needs.

You may now build and download the example project to the evaluation board using the µVision commands:

  • Project - Build target
  • Flash - Download

After these steps, the project should start executing on your evaluation kit. In case of errors, refer to the Evaluation Board User's Guide for configuration information.

Using the "SNMP Agent" Project

Hardware Setup

The setup of the Evaluation Board hardware is described in the Abstract.txt file.

  • Verify all jumper settings on the target hardware.
  • Use an Ethernet cable to connect your development board to the local area network. The PC is assumed to be already a member of this LAN.

PC Software

To test this example, run the Windows application 'SNMPTest.exe' from C:\Keil\ARM\Utilities\SNMPTest\Release and type in the IP address of your Embedded SNMP Agent and click 'Connect'. When connected, you can change the LCD text on the target, control the on-board LED diodes and monitor the state of on-board push-buttons.

SNMP Test Application

BSD Client/Server

BSD sockets are often used for network communication as they are providing a well-defined API for exchanging data over the network. In general, they are relying on TCP and UDP socket communication. The BSD server and client examples are used to demonstrate BSD compliant communication. To make it work, you need to setup two development boards within the same network: a BSD server and a BSD client. An exemplary setup could look like this:

BSD example hardware setup

Build the "BSD" Projects

Open the two example projects in MDK (the web page explains how to do this). The µVision Project window should display a similar project structure:

Structure of the BSD Projects

Source Files

  • BSD_Client.c contains the main C function that initializes the board hardware and the Network Component for the BSD client. It also contains the actual code that is used to communicate with the BSD server.
  • BSD_Server.c contains the main C function that initializes the board hardware and the Network Component for the BSD server. The server is waiting for a connection from a BSD client.

You may now build and download the example projects to the evaluation boards using the µVision commands:

  • Project - Build target
  • Flash - Download

After these steps, the projects should start executing on your evaluation kit. In case of errors, refer to the Evaluation Board User's Guide for configuration information.

Using the "BSD" Projects

Hardware Setup

The setup of the Evaluation Board hardware is described in the Abstract.txt file.

  • Verify all jumper settings on the target hardware.
  • Use an Ethernet cable to connect your development board to the local area network. The PC is assumed to be already a member of this LAN.

PC Software

To test the BSD Server example stand-alone, run the Windows application 'LEDSwitch.exe' from C:\Keil\ARM\Utilities\LEDSwitch\Release and type in the IP address of your development board (IPv4 and IPv6 addresses are accepted). When connected, you can control the on-board LEDs.

LED Switch Application