What is a Contiki application?

A Contiki application is implemented as a collection of processes and “proto-threads”.

For each application, you can view:

  • file.c : implements the process
  • file.h : exports process reference

For each example, you can view a file.c which executes the “autostart process”. The Makefile is present in examples folder.

WebServer

Properties

You can find the following files in your contiki source tree:

  • Examples folder: contiki/examples/webserver
  • Applications folder: contiki/apps/webserver
  • File process: contiki/apps/webserver/webserver.c

Objectives

The aim is to install the Web server application from Contiki onto the WiSMote. This Web server will be accessible from a Web browser. This example will demonstrate:

  • Flashing the WiSMote via the JTAG interface
  • Contiki Web Server via HTTP protocol
  • SLIP communication with your WiSMote via the usb cable

Deployment

Preparation

Flash the WiSMote with “webserver-example” (located in Contiki/examples), for example with the “MSP-JTAG-TINY” Olimex programmer. This requires the following software:

Network settings

  • IP Address: 192.168.1.2.
  • Default Gateway: 192.168.1.1
  • Mask network: 255.255.255.0

Client configuration

The communication between the PC and wismote is realized through the SLIP protocol (baud rate: 57600b/s).

SLIP is a Serial Line Protocol which encapsulates the IP protocol. You can use the tunslip tool in Contiki to create and bind virtual IP interfaces (tun) to the serial port. This tool creates a SLIP tunnel between a “physical” serial port and a “virtual” network interface (tun).

This virtual interface will be used like a real network interface: traffic forwarding, Wireshark analysis, etc. While the “tun” interface driver is available out-of-the-box under Linux, it requires the installation of a kernel extension for Mac OS X (see the TunTap project) and is not yet officially supported. Windows also lacks a tun/tap driver by default and we don't support it yet.

See also http://vtun.sourceforge.net/tun/index.html

Compilation

The compilation of tunslip is trivia:

gcc tunslip.c -o tunslip

Execution

Use the following command, according to your system parameters, to launch tunslip: tunslip -s SerialPort -B BaudRate IPAddress NetMask

Warning: you must be root to run it.

For example, with a WiSMote visible as ttyUSB0:

tunslip -s /dev/ttyUSB0 -B 57600 192.168.1.1 255.255.255.0

Results

Connect to the WiSMote at http://192.168.1.2/ from your web browser, so as to check that the web server is running.

SHT15UDP

Properties

You can find the following files in your contiki browser:

  • Folder examples : contiki/examples/sht15UDP
  • Folder application: contiki/apps/sht15UDP
  • File process: contiki/apps/sht15UDP/sht15UDP.c

Objectives

The WiSMote reads humidity and temperature data for SHT15 sensor, and sends them via UDP to a server. The UDP server is a Java application which receives data, and converts it in order to print it to a terminal-based interface. Translation rules are mentioned in the sht15 datasheet. With this example, you can test:

  • Flashing of WiSMote via JTAG interface
  • WiSMote communication with SHT15 sensor
  • WiSMote → computer communication via UDP
  • Reception and management of data by the Java application (UDP server)

Deployment

Preparation

Connect the SHT15 sensor to the WiSMote. The source code is configured for the following wiring:

  • Data - P6.4
  • SCK - P6.5
  • PWR - P6.2

Flash the WiSMote with the example “sht15UDP” using the “MSP-JTAG-TINY” Olimex programmer and the following tools:

  • MSPdebug under Linux: MSPDebug - only MSP-JTAG-TINY v1 is supported for now.
  • Olimex official tools and drivers under Windows: Olimex software

Network configuration

The communication between the PC and WiSMote is realized through the SLIP protocol (baud rate: 57600b/s).

SLIP is a Serial Line Protocol which encapsulates the IP protocol. You can use the tunslip tool in Contiki to create and bind virtual IP interfaces (tun) to the serial port. This tool creates a SLIP tunnel between a “physical” serial port and a “virtual” network interface (tun).

This virtual interface will be used like a real network interface: traffic forwarding, Wireshark analysis, etc. While the “tun” interface driver is available out-of-the-box under Linux, it requires the installation of a kernel extension for Mac OS X (see the TunTap project) and is not yet supported officially. Windows also lacks a tun/tap driver by default and we don't support it yet.

See also http://vtun.sourceforge.net/tun/index.html

The compilation of tunslip is trivial:

gcc tunslip.c -o tunslip

Execution

Use the following command, according to your system parameters, to launch tunslip: tunslip -s SerialPort -B BaudRate IPAddress NetMask

Warning: you must be root to run it.

For example, with a WiSMote visible as ttyUSB0:

tunslip -s /dev/ttyUSB0 -B 57600 192.168.1.1 255.255.255.0

Results

Wireshark

The WiSMote sends data via UDP. Wireshark can sniff the data on the tun interface.

Java application

A Java application has been developed to receive data on a UDP socket, convert them to Celsius degrees and display them on the terminal interface.

FIXME You want to create a virtual interface with IP address “192.168.1.1”, because this adress (probably) doesn't exist for your system. In order to receive UDP data, it is mandatory to attribute this address to the virtual interface (TUN). For exemple, I have a free interface in the command “ifconfig -a”. The name is vboxnet. You want to configure it.

sudo ifconfig vboxnet0 192.168.1.1

Now, execute “SHT15UDP.java”.

javac SHT15UDP.java java SHT15UDP

Wireshark capture
Wireshark capture

Terminal output of the Java application
Terminal output of the Java application

 
development/sample_code.txt · Last modified: 2012/05/07 09:28 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki