Learning about Contiki

Programming TelosB/Sky with Contiki apps

Listing motes connected to the computer:

make motelist

Building an app (e.g. hello-world):

make TARGET=sky hello-world

Programing TelosB/Sky:

make TARGET=sky PORT=/dev/ttyUSB0 hello-world.upload

Launching serial console

Launching serial console:

make TARGET=sky PORT=/dev/ttyUSB0 login

Make tricks

Saving target – allows to omit TARGET=sky each time (saved per app):

make TARGET=sky savetarget

Combining commands – e.g. programing and then launching serial console:

make TARGET=sky PORT=/dev/ttyUSB0 hello-world.upload login

Apps with multiple source files

Add to Makefile:

PROJECT_SOURCEFILES += extra-file.c

Mote’s addresses

A single mote can have many network addresses, depending on its netstack. E.g.: Rime address, MAC address, Node id, …

They are printed on the serial console when a mote boots up, e.g.:

Rime started with address 70.31
MAC 46:1f:00:00:00:00:00:00 Contiki-3.0 started. Node id is not set.

Reciving messages from UART/serial console

A helpful snippet:

#include "dev/serial-line.h"
#include "dev/uart1.h"
// ...

PROCESS_THREAD(uart_process, ev, data)
// ...

uart1_set_input(serial_line_input_byte);
serial_line_init();
//...

if (ev == serial_line_event_message) {
      printf("received line: %s\n", (char *)data);
}