This is an example code for using the TFTPServer library.

Dependencies:   TFTPServer

Fork of TFTPServerTest by Jaap Vermaas

A simple TFTP server built with the TFTPServer library

In this example a FAT formatted SD card is connected to the MBED board to provide a storage place for a TFTP server. This will allow us to upload files to or download files from the TFTP server (SD card) over an Ethernet connection as well as to use the files uploaded to the TFTP server in a program running on the MBED board.

Schematic

/media/uploads/hudakz/tftpserver01.png

We can use for example the SD Formatter utility to format an SD card for the FAT file system .

NOTE: In the commands below substitute 192.168.1.185 with the actual IP address of your TFTP server. It's printed to the serial terminal of the connected PC during the server start up.

To upload or download files from a MS Windows PC we can use the TFTP client utility as follows:

  • To upload for example the test.txt file to the TFTP server:
    • Open a command prompt in the folder the file is located in.
    • Type tftp 192.168.1.185 put test.txt /fs/test.txt and hit ENTER
  • To download for example the test.txt file from the TFTP server:
    • Open a command prompt in the destination folder.
    • Type tftp 192.168.1.185 get /fs/test.txt test.txt and hit ENTER

A similar built-in TFTP client is available also on MAC and Linux operating systems.

References:

Files at this revision

API Documentation at this revision

Comitter:
hudakz
Date:
Tue Mar 20 17:54:21 2018 +0000
Parent:
4:895c0ae49294
Commit message:
Updated.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Mar 20 17:32:28 2018 +0000
+++ b/main.cpp	Tue Mar 20 17:54:21 2018 +0000
@@ -35,7 +35,6 @@
 EthernetInterface   net;                // Ethernet interface
 TFTPServer*         server;             // Pointer to a TFTPServer
 int                 myPort = 69;        // TFPTServer port
-Timer               timer;              // For sending debug messages to the remote client every two seconds
 
 #define USE_DHCP
 
@@ -125,13 +124,10 @@
         pc.printf("\r\nSomething went wrong.\r\nThe TFTP server is not listening.\r\n");
         return 1;
     }
-    
 
     int     fileCount = 0;  // incoming files
     char    fileName[256];  // to display filenames
 
-    timer.start();
-
     while (1)
     {
         server->poll();