Home  Contents

Using MTD16 with TCP/IP

TCP/IP Application Notes

ABSTRACT

An example that shows how to pass MTD16 encoded messages between a TCP/IP client and server.

INTRODUCTION

This is an example application that implements a TCP server and client. The server and client pass MTD16 encoded messages between each other.

To keep the hardware requirements for running the example simple, the client and server code is included in one applications. Both 'halves' pass data using the localhost IP address (127.0.0.1). Of course, it is also feasible to run the parts on a separate hardware each.

DESCRIPTION

The sample code shows how to encode and decode MTD16 messages. You see how to set up a jump table to dispatch received messages. Link testing by regularily sending ping messages is implemented.

SAMPLE PROJECT

You can download the example project MTD16Demo or browse the project contents online.

The main lua file initializes the TFT display for debug messages and runs the mainloop.

The files client.lua and server.lua implement the client and server side respectively.

In the file tags.lua is the mapping between numeric codes used by the binary MTD16 protocol and symbolic names. This allows for easier development and debugging. When splitting server and client into separate applications, both applications need a copy of the same tags file, so they share the same message encoding.