76
Contiki introduction Antonio Liñán Colina

Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

  • Upload
    vocong

  • View
    238

  • Download
    12

Embed Size (px)

Citation preview

Page 1: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

Contiki introduction

Antonio Liñán Colina

Page 2: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

https://www.arm.com/products/internet-of-things-solutions/mbed-IoT-device-platform.php

Page 3: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

RAMROM/FLASH

Processor

> 1MB RAM/ROM

Page 4: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

• Architectures: 8-bit, 16-bit, 32-bit• Open Source (source code openly

available)• IPv4/IPv6/Rime networking• Devices with < 8KB RAM• Typical applications < 50KB Flash• Vendor and platform independent• C language• Developed and contributed by Universities,

Research centers and industry contributors• +10 years development

Page 5: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:
Page 6: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

http://www.tado.com

http://www.lifx.comhttp://cetic.github.io/6lbr/

http://www.riva-lighting.de/

http://www.thingsquare.com

Page 7: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

www.contiki-os.org

https://github.com/contiki-os/contiki

Page 8: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

Install Contiki

Page 9: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

http://www.contiki-os.org/start.html

VMWare virtualized develop environment

“INSTANT CONTIKI” VIRTUAL MACHINE

Password is:user

Approx 2-3GbDownload size

Approx 8GbHard Drive

Page 10: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

VMWare image built specific for the workshop

“IOT IN FIVE DAYS” VIRTUAL MACHINE

https://sourceforge.net/projects/zolertia/files/VM/IoT%20Workshop%20VM.7z

Password is:user

Approx 2-3GbDownload size

Approx 8GbHard Drive

Page 11: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

CONFIGURE THE VIRTUAL MACHINE AS “BRIDGED”

Page 12: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

Install requirements (and extra goodies)

Installing Contiki from scratch (Linux)

Get a Contiki working copy:

sudo add-apt-repository ppa:wireshark-dev/stablesudo apt-get updatesudo apt-get install gcc-arm-none-eabi gdb-arm-none-eabisudo apt-get -y install build-essential automake gettextsudo apt-get -y install gcc-arm-none-eabi curl graphviz unzip wgetsudo apt-get -y install gcc gcc-msp430sudo apt-get -y install openjdk-7-jdk openjdk-7-jre antsudo apt-get –y install git git-core wireshark

git clone --recursive https:github.com/alignan/contikicd contikigit submodule –updategit checkout iot-workshop

Page 13: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

Install requirements (only the toolchain)

Installing Contiki from scratch (OSX)

Get a Contiki working copy:

# Install Homebrew - http://brew.sh/brew tap PX4/homebrew-px4brew update

# Install GCC Arm Toolchainbrew install gcc-arm-none-eabi-49

git clone --recursive https:github.com/alignan/contikicd contikigit submodule –updategit checkout iot-workshop

Page 14: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

Install requirements (only the toolchain)

Installing Contiki from scratch (Windows)

Get a Contiki working copy:

# Download ARM toolchainhttps://launchpad.net/gcc-arm-embedded/+download

# Download and install MINGWhttps://sourceforge.net/projects/mingw/files/latest/download

git clone --recursive https:github.com/alignan/contikicd contikigit submodule –updategit checkout iot-workshop

https://github.com/alignan/IPv6-WSN-book/blob/master/3.asc#windows-installation-re-mote-only

Page 15: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

Contiki structure

Page 16: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

MCU implementation: MSP430 (Z1), CC2538 (RE-Mote)

Devices implementation (radio, etc): CC2420 (Z1), CC1200 (RE-Mote)

Examples: IPv6, Zolertia-specific, sensors, etc.

Platform specific implementation (Z1, RE-Mote)

Tools (flashing, emulation, visualization)

Contiki core libraries: IPv4/IPv6, MAC, RDC, etc

Applications/Engines that may be used by other applications: MQTT, CoAP

Page 17: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

Specific Z1 applications

Specific sensors and actuators drivers

Makefiles (where the platform specifiesthe files to use and include)

Specific Contiki configurationContikiMain Application, Z1 initialization (booting) and application entry point

Specific platform configuration (pin-out, peripherals)

Page 18: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

Sensors and actuators ported

Specific Firefly platform files

Specific RE-Mote platform files

Makefiles (where the platform specifies the files to use and include)

Specific Contiki configuration

Main Application, initialization (booting) and application entry point

Page 19: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

Specific RE-Mote initialization

Specific RE-Mote Makefile

Page 20: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

Specific RE-Mote examples and demos

Specific Z1 examples and demos

IoT workshop content

Page 21: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:
Page 22: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

Zolertia RE-Mote

Page 23: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

Zolertia RE-Mote (Zoul inside)

• ARM Cortex-M3, 32MHz, 32KB RAM, 512KB FLASH

• Double Radio: ISM 2.4GHz & 863-925MHz, IEEE 802.15.4-2006/e/g

• Hardware encryption engine and acceleration

• USB programing ready• Real-Time Clock and Calendar• Micro SD slot and RGB colors• Shutdown mode down to 150nA• USB 2.0 port for applications• Built-in LiPo battery charger to work with

energy harvesting and solar panels• On-board RF switch to use both radios over

the same RP-SMA connector• Pads to use an external 2.4GHz over U.Fl

connector, o solder a chip antenna

Page 24: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:
Page 25: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:
Page 26: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:
Page 27: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

01-basics

examples/zolertia/tutorial/01-basics

Page 28: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

sudo usermod -a -G dialout user

Fixes a problem related to being allowed to write to USB ports as the /dev/ttyUSB0 used to flash the nodes

For the change to take effect, you need to logout and log back inNot required if using the “IoT in five days” virtual image!

Page 29: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

VERIFY THE RE-MOTE IS CONNECTED

Page 30: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

examples/zolertia/tutorial/01-basics/01-hello-world.c

Page 31: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

examples/zolertia/tutorial/01-basics/Makefile

Page 32: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

To compile an application:

make TARGET=zoul 01-hello-world

The TARGET is used to tell the compiler which hardware platform itshould compile for. For the Z1 platform is “z1”, for the RE-Mote (and others zoul-based platforms) is “zoul”

You can save the TARGET so next time you don’t have to type it:

make TARGET=zoul savetarget

This will create a Makefile.target file. If no TARGET argument isadded in the compilation command line, the compiler will search a valid target in the Makefile.target file (if exists).

Page 33: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:
Page 34: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

To compile and program an application to a RE-Mote:

make 01-hello-world.upload

The upload argument tells the compiler to invoke the programming scripts required to program the compiled binary to the device.

If no specific PORT argument is given, it will program all the RE-Motes connected over USB.

make 01-hello-world.upload PORT=/dev/ttyUSB0

Page 35: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:
Page 36: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

Programming over the USB is posible as the “bootloader backdoor” is enabled as default in Contiki.

The CP2104 USB to serial converter creates the USB connection, when flashing the image to be programmed is transferred over USB from the Host to the on-board PIC-BSL microcontroller, which automatically puts the RE-Mote in “flashing mode” and transfers the image to the RE-Mote’s CC2538.

The script invoked by the compiler to program the RE-Mote is the cc2538-bsl, located in tools/cc2538-bsl. It is already included in Contiki.

https://github.com/JelmerT/cc2538-bsl

PIC-BSL

CP2104

CC2538

MicroUSBRE-Mote

Page 37: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

https://youtu.be/6vg4f7U_kF4

MANUALLY ENTER THE FLASHING MODE

Press and hold user button, then press and hold reset button… release the reset button and then release the user button

Page 38: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

To visualize the application output in a readable format, the following command is used:

make login

If no PORT is specified, it will open a connection to the first connected device it finds over USB.

make login PORT=/dev/ttyUSB0

Note you can execute one command after the other:

make 01-hello-world.upload PORT=/dev/ttyUSB0 && make login PORT=/dev/ttyUSB0

Page 39: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:
Page 40: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

The next command is similar to make login, but it appends an UNIX timestamp:

make serialview

If no PORT is specified, it will open a connection to the first connected device it finds over USB.

make serialview PORT=/dev/ttyUSB0

You can also list the connected devices:

make motelist

Page 41: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:
Page 42: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

Buttons and LEDs

Events and actions can be triggered by pressing the user button: senda message over the radio, take a sensor sample, start a process, etc.

The LEDs (light-emitting diodes) help us to understand what happensin the device, by using different colours and blinking sequences weknow when an event is happening, if there are any errors or whathappens in our application.

Page 43: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

examples/zolertia/tutorial/01-basics/02-led-and-button.c

Page 44: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

examples/zolertia/tutorial/01-basics/02-led-and-button.c

The application will wait (as it will be paused) until this event happens, saving processing cycles and energy

Page 45: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

examples/zolertia/tutorial/01-basics/02-led-and-button.c

Press and hold the button, the LED will be on

When the button is released, the LED will be off

Page 46: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

platforms/zoul/remote/board.h

Page 47: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

examples/zolertia/tutorial/01-basics/02-led-and-button.c

16 in binary is 00010000Same as (1 << 4) The LED on should be the Green:#define LEDS_GREEN (1 << 4) /**< LED1 (Green) -> PD4 */

Page 48: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

platforms/zoul/dev/button-sensor.h

Page 49: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

make clean

Always after making a change to the source code, clean the previously compiled objects

Page 50: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

examples/zolertia/tutorial/01-basics/02-led-and-button.c

What Color the LEDs will show?What number is printed when the LEDs are on?What will happen each time we press the button?

Page 51: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

examples/zolertia/tutorial/01-basics/02-led-and-button.c

Each time we press the button, the LED will toggle on and off showing a yellow-ish color

Page 52: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

examples/zolertia/tutorial/01-basics/02-led-and-button.c

We are waiting for ANY event to happen

Page 53: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

examples/zolertia/tutorial/01-basics/02-led-and-button.c

The press and hold option extends the possible alternatives the application would have to handle the user input

Page 54: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

Timers

Timers allow to execute actions periodically, like measuring a sensor periodically, waiting a few seconds before executing a function, sending hourly reports, etc.

Page 55: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

examples/zolertia/tutorial/01-basics/03-timers.c

Page 56: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

examples/zolertia/tutorial/01-basics/03-timers.c

The timer and stimer are computing-intensive, whereas the etimer, ctimer and rtimer generate events/callbacks only when the counter expires, saving processing cycles and energy

Page 57: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

examples/zolertia/tutorial/01-basics/03-timers.c

CLOCK_SECOND is a constant defined by each platform, specifies the number of ticks a second has according to the platform’s clock. If you want to specify a 5 seconds timer, then use (CLOCK_SECOND * 5), or likewise half a second would be the nearest integer to (CLOCK_SECOND / 2)

Page 58: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

core/sys/etimer.h

Each timer has its own API Aapplication Programming Interface) or commands, but mostly are alike:

Page 59: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

examples/zolertia/tutorial/01-basics/03-timers.c

Depending on the type of timers we need to use, include a given header and create a timer structure

Page 60: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

examples/zolertia/tutorial/01-basics/03-timers.c

RTIMER_NOW() is a macro returning the current tick count RTIMER_SECOND is a platform-defined constant, number of ticks/second

Page 61: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

examples/zolertia/tutorial/01-basics/03-timers.c

Page 62: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

examples/zolertia/tutorial/01-basics/03-timers.c

Print the value of CLOCK_SECOND and RTIMER_SECOND

Turn on only the red LED each time the “tick” counter variable is even, and the blue LED whenever is odd. Use only the ctimer from the example

Stop the timers whenever the user button is pressed

Restart the timer and set the tick variable value to zero when the user button is pressed again

Page 63: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

examples/zolertia/tutorial/01-basics/03-timers.c

Page 64: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

Processes

Contiki has two execution contexts: cooperative and preemptiveProcesses are cooperative and sequential, interrupts (button, sensorsevents) and the real-timer are preemptive.

examples/zolertia/tutorial/01-basics/04-processes.chttps://github.com/contiki-os/contiki/wiki/Processes

Page 65: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

examples/zolertia/tutorial/01-basics/04-processes.chttps://github.com/contiki-os/contiki/wiki/Processes

The process control block (RAM): contains run-time information about the process such as the name of the process, the state of the process, and a pointer to the process thread of the process.

The process thread (ROM): the code of the process

Page 66: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

core/sys/process.hhttps://github.com/contiki-os/contiki/wiki/Processes

Page 67: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

examples/zolertia/tutorial/01-basics/04-processes.chttps://github.com/contiki-os/contiki/wiki/Processes

Process A

Process B

process_post()

Event Queue

Page 68: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

examples/zolertia/tutorial/01-basics/04-processes.chttps://github.com/contiki-os/contiki/wiki/Processes

Process A

Process B

process_post_synch()

Page 69: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

examples/zolertia/tutorial/01-basics/04-processes.chttps://github.com/contiki-os/contiki/wiki/Processes

Process B

process_poll()

Interrupt or function

The only function that can be called from preemptive context

Page 70: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

examples/zolertia/tutorial/01-basics/04-processes.c

Process 2

Process 1 Process 3process_start()

Increment a counter and toggle green LED

process_post(&process1, …)

When counter is 10 or higher, request termination

1

2 Process 1 Process 3process_exit()

PROCESS_EVENT_EXITED

process_start()

Toggle red LED for 10 seconds and terminate process3

Page 71: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

examples/zolertia/tutorial/01-basics/04-processes.c

Page 72: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

examples/zolertia/tutorial/01-basics/04-processes.c

Page 73: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

examples/zolertia/tutorial/01-basics/04-processes.c

Page 74: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

Create two processes:

One that increments a counter and toggles a LED. When the counter reaches ten (10), it should print a message to the screen.

A second process that each time the user button is pressed, it will change the color of the LED to be toggled (i.e from Green to Blue, then Red, and repeat).

examples/zolertia/tutorial/01-basics/04-processes.c

Page 75: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

Conclusions

You should be able to:

• Create and compile a basic Contiki application• Program a Zolertia device• Implements timers, LEDs and buttons in your application• Understand how Contiki processes and protothreads are

implemented• Create processes and tasks interacting with each other• Identify connected devices, visualize the debug output in the

screen

Page 76: Contiki introduction - CEA-IoT · Contiki introduction Antonio Liñán Colina. ... • IPv4/IPv6/Rime networking ... Contiki has two execution contexts:

Antonio Liñán Colina

Twitter: @4Li6NaN

LinkedIn: Antonio Liñan Colina

github.com/alignan

hackster.io/alinan

[email protected]@gmail.com