Objective
The objective of this post is to show you how to configure the options in Contiki OS. I tested this tutorial in Contiki 3.0 and Ubuntu 16.04.
Step 1: Create a project-conf.h file
I am going to use the example-broadcast.c of the RIME stack. So, go to the following folder:
/home/YOURUSER/contiki-3.0/examples/rime
and create a file named project-conf.h, this file will contain all the specific configurations of your nodes.
Step 2: Select your configurations and write them in the file project-conf.h
Open your file project-conf.h and change the defines you want. In this example i want to change the radio frequency channel to 20. Remember that the default radio channel is 26. Then, my project-conf.h looks like this:#define RF_CHANNEL 20 //RF_CHANNEL = Radio Fequency Channel
Step 3: Change your Makefile
Contiki only understands the changes you made in the project-conf.h file when you modify your Makefile. So, open your Makefile located in the rime folder:/home/YOURUSER/contiki-3.0/examples/rimeand add the line CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\". So, now your Makefile should look like this:
CONTIKI = ../.. all: example-abc example-mesh example-collect example-trickle example-polite \ example-rudolph1 example-rudolph2 example-rucb \ example-runicast example-unicast example-neighbors CONTIKI_WITH_RIME = 1 CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\" include $(CONTIKI)/Makefile.include
Step 4: Modify the contiki-conf.h of your platform
Next, you will need to modify the contiki-conf.h archive of your platform. In this case i am using a CM5000 sky node. Then, i must go to the folder /home/YOURUSER/Desktop/contiki-3.0/platform/sky, open the archive contiki-conf.h, and cut the following code located at the end of the file:
/* include the project config */ /* PROJECT_CONF_H might be defined in the project Makefile */ #ifdef PROJECT_CONF_H #include PROJECT_CONF_H #endif /* PROJECT_CONF_H */
Then, you must copy that code at the beginning of the archive. Finally, you contiki-conf.h archive would look like this:
/* -*- C -*- */ #ifndef CONTIKI_CONF_H #define CONTIKI_CONF_H /* include the project config */ /* PROJECT_CONF_H might be defined in the project Makefile */ #ifdef PROJECT_CONF_H #include PROJECT_CONF_H #endif /* PROJECT_CONF_H */
Step 5: Compile your code and load it in a node
The last step is to clean/compile your code and load it into a sensor node using the following commands:make clean make TARGET=sky example-broadcast.upload && make loginThen, you should see that the channel is set to 20:
Rime started with address 1.0 MAC 01:00:00:00:00:00:00:00 Contiki 3.0 started. Node id is set to 1. nullsec CSMA ContikiMAC, channel check rate 8 Hz, radio channel 20 Starting 'Broadcast example'
No comments:
Post a Comment