Friday, March 21, 2014

Contiki OS 2.7 Cooja Serial Device with serial2pty

Create a virtual serial device for Cooja motes under /dev/pts/[id]

1. Download
https://github.com/cmorty/cooja-serial2pty
2. Update code with new Cooja class names (if not updated) in Serial2Pty.java

- Change package org.contikios.cooja to se.sics.cooja
import se.sics.cooja.*;
import se.sics.cooja.interfaces.SerialPort;
- Change class Cooja to GUI

A modified code can be found here: https://github.com/sonhan/cooja-serial2pty

3. Build
copy to /contiki/cooja/apps/serial2pty
ant jar
cooja > Settings -> Cooja Extensions... > Select the serial2pty app

4. Test
- Restart Cooja if needed
- Right click on the mote > Mote tools for Test Node > Serial 2 Pty > it shows the serial device (e.g., /dev/pts/10
- Open a Terminal:

#cd contiki
#sudo make login TARGET=sky MOTES=/dev/pts/10 (for a simulated Sky mote)

Thursday, March 6, 2014

Contiki OS: RPL Network Setup 2

One mote can be used as a wireless interface (IEEE 802.15.4), host machine as Border Router to  bridge the wireless IPv6 network (e.g., LLN) to outside network, and the Internet.

InstantContiki 2.7 or any machine with Contiki-2.7 and TI MSP430 toolchain (See here)

1. slip-radio (mote 1 as an IEEE 802.15.4 interface)
#cd contiki-2.7/examples/ipv6/slip-radio
#make TARGET=sky
#sudo make TARGET=sky slip-radio.upload

2. UDP servers or any IPv6 service (motes 2..n)
#cd contiki-2.7/examples/ipv6/rpl-udp
#make TARGET=sky
#sudo make TARGET=sky udp-server.upload

3. Host machine (Linux)
 #cd contiki-2.7/examples/ipv6/native-border-router
#make [TARGET=native]
#sudo ./border-router.native -L -v6 aaaa::1/64
*default: -s ttyUSB0 (serial device) -B 115200 (baud rate) -t tun0 (name of interface)

Cooja:  sudo ./border-router.native -a 127.0.0.1 -v6 aaaa::1/64
(enable Serial  Socket Server in the Cooja node used as the wireless interface)

[Contiki 2.7 Release Error] border-router.c:161:28: error: expected ‘)’ before ‘;’ token. 
Just delete the ';'

4. Test
ping6 aaaa::212:7400:13cb:44 (mote 1, wireless interface)
ping6 aaaa::212:7400:13ca:fee4 (mote 2)
ping6 aaaa::212:7400:13cb:34fa (mote 3)

Firefox: http://[aaaa::212:7400:13cb:44]