initial commit
This commit is contained in:
commit
d575bd32cf
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
obj_*
|
||||
*~
|
7
S1/Makefile
Normal file
7
S1/Makefile
Normal file
@ -0,0 +1,7 @@
|
||||
CONTIKI_PROJECT = hello-world
|
||||
all: $(CONTIKI_PROJECT)
|
||||
|
||||
#UIP_CONF_IPV6=1
|
||||
|
||||
CONTIKI = ../..
|
||||
include $(CONTIKI)/Makefile.include
|
BIN
S1/contiki-sky.a
Normal file
BIN
S1/contiki-sky.a
Normal file
Binary file not shown.
2478
S1/contiki-sky.map
Normal file
2478
S1/contiki-sky.map
Normal file
File diff suppressed because it is too large
Load Diff
124
S1/cooja_helloworld.csc
Normal file
124
S1/cooja_helloworld.csc
Normal file
@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<simconf>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/mrm</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/mspsim</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/avrora</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/serial_socket</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/collect-view</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/powertracker</project>
|
||||
<simulation>
|
||||
<title>Hello World</title>
|
||||
<speedlimit>1.0</speedlimit>
|
||||
<randomseed>123456</randomseed>
|
||||
<motedelay_us>1000000</motedelay_us>
|
||||
<radiomedium>
|
||||
se.sics.cooja.radiomediums.UDGM
|
||||
<transmitting_range>50.0</transmitting_range>
|
||||
<interference_range>100.0</interference_range>
|
||||
<success_ratio_tx>1.0</success_ratio_tx>
|
||||
<success_ratio_rx>1.0</success_ratio_rx>
|
||||
</radiomedium>
|
||||
<events>
|
||||
<logoutput>40000</logoutput>
|
||||
</events>
|
||||
<motetype>
|
||||
se.sics.cooja.mspmote.SkyMoteType
|
||||
<identifier>sky1</identifier>
|
||||
<description>Sky Mote Type #sky1</description>
|
||||
<source EXPORT="discard">[CONTIKI_DIR]/surrey/S1/hello-world.c</source>
|
||||
<commands EXPORT="discard">make hello-world.sky TARGET=sky</commands>
|
||||
<firmware EXPORT="copy">[CONTIKI_DIR]/surrey/S1/hello-world.sky</firmware>
|
||||
<moteinterface>se.sics.cooja.interfaces.Position</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.RimeAddress</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.IPAddress</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.Mote2MoteRelations</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.MoteAttributes</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspClock</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspMoteID</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyButton</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyFlash</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyCoffeeFilesystem</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.Msp802154Radio</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspSerial</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyLED</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspDebugOutput</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyTemperature</moteinterface>
|
||||
</motetype>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
se.sics.cooja.interfaces.Position
|
||||
<x>29.99841204907099</x>
|
||||
<y>-115.95137024353158</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
se.sics.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>1</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
</simulation>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.SimControl
|
||||
<width>417</width>
|
||||
<z>0</z>
|
||||
<height>160</height>
|
||||
<location_x>400</location_x>
|
||||
<location_y>0</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.Visualizer
|
||||
<plugin_config>
|
||||
<skin>se.sics.cooja.plugins.skins.IDVisualizerSkin</skin>
|
||||
<viewport>0.9090909090909091 0.0 0.0 0.9090909090909091 153.72871631902638 172.41033658502872</viewport>
|
||||
</plugin_config>
|
||||
<width>393</width>
|
||||
<z>2</z>
|
||||
<height>430</height>
|
||||
<location_x>1</location_x>
|
||||
<location_y>1</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.TimeLine
|
||||
<plugin_config>
|
||||
<mote>0</mote>
|
||||
<showRadioRXTX />
|
||||
<showRadioHW />
|
||||
<showLEDs />
|
||||
<split>-1</split>
|
||||
<zoomfactor>500.0</zoomfactor>
|
||||
</plugin_config>
|
||||
<width>819</width>
|
||||
<z>3</z>
|
||||
<height>166</height>
|
||||
<location_x>0</location_x>
|
||||
<location_y>433</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.Notes
|
||||
<plugin_config>
|
||||
<notes>Enter notes here</notes>
|
||||
<decorations>true</decorations>
|
||||
</plugin_config>
|
||||
<width>6</width>
|
||||
<z>4</z>
|
||||
<height>160</height>
|
||||
<location_x>680</location_x>
|
||||
<location_y>0</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.MoteInterfaceViewer
|
||||
<mote_arg>0</mote_arg>
|
||||
<plugin_config>
|
||||
<interface>Serial port</interface>
|
||||
<scrollpos>0,0</scrollpos>
|
||||
</plugin_config>
|
||||
<width>422</width>
|
||||
<z>1</z>
|
||||
<height>265</height>
|
||||
<location_x>397</location_x>
|
||||
<location_y>162</location_y>
|
||||
</plugin>
|
||||
</simconf>
|
||||
|
56
S1/hello-world.c
Normal file
56
S1/hello-world.c
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 2006, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: hello-world.c,v 1.1 2006/10/02 21:46:46 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* A very simple Contiki application showing how Contiki programs look
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
|
||||
#include <stdio.h> /* For printf() */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(hello_world_process, "Hello world process");
|
||||
AUTOSTART_PROCESSES(&hello_world_process);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(hello_world_process, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
|
||||
printf("Hello, world 321\n");
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
BIN
S1/hello-world.sky
Normal file
BIN
S1/hello-world.sky
Normal file
Binary file not shown.
4
S1/symbols.c
Normal file
4
S1/symbols.c
Normal file
@ -0,0 +1,4 @@
|
||||
#include "symbols.h"
|
||||
|
||||
const int symbols_nelts = 0;
|
||||
const struct symbols symbols[] = {{0,0}};
|
3
S1/symbols.h
Normal file
3
S1/symbols.h
Normal file
@ -0,0 +1,3 @@
|
||||
#include "loader/symbols.h"
|
||||
|
||||
extern const struct symbols symbols[1];
|
7
S2/Makefile
Normal file
7
S2/Makefile
Normal file
@ -0,0 +1,7 @@
|
||||
CONTIKI_PROJECT = hello-world
|
||||
all: $(CONTIKI_PROJECT)
|
||||
|
||||
#UIP_CONF_IPV6=1
|
||||
|
||||
CONTIKI = ../..
|
||||
include $(CONTIKI)/Makefile.include
|
124
S2/cooja_helloworld.csc
Normal file
124
S2/cooja_helloworld.csc
Normal file
@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<simconf>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/mrm</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/mspsim</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/avrora</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/serial_socket</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/collect-view</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/powertracker</project>
|
||||
<simulation>
|
||||
<title>Hello World</title>
|
||||
<speedlimit>1.0</speedlimit>
|
||||
<randomseed>123456</randomseed>
|
||||
<motedelay_us>1000000</motedelay_us>
|
||||
<radiomedium>
|
||||
se.sics.cooja.radiomediums.UDGM
|
||||
<transmitting_range>50.0</transmitting_range>
|
||||
<interference_range>100.0</interference_range>
|
||||
<success_ratio_tx>1.0</success_ratio_tx>
|
||||
<success_ratio_rx>1.0</success_ratio_rx>
|
||||
</radiomedium>
|
||||
<events>
|
||||
<logoutput>40000</logoutput>
|
||||
</events>
|
||||
<motetype>
|
||||
se.sics.cooja.mspmote.SkyMoteType
|
||||
<identifier>sky1</identifier>
|
||||
<description>Sky Mote Type #sky1</description>
|
||||
<source EXPORT="discard">[CONTIKI_DIR]/surrey/S2/hello-world.c</source>
|
||||
<commands EXPORT="discard">make hello-world.sky TARGET=sky</commands>
|
||||
<firmware EXPORT="copy">[CONTIKI_DIR]/surrey/S2/hello-world.sky</firmware>
|
||||
<moteinterface>se.sics.cooja.interfaces.Position</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.RimeAddress</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.IPAddress</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.Mote2MoteRelations</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.MoteAttributes</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspClock</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspMoteID</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyButton</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyFlash</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyCoffeeFilesystem</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.Msp802154Radio</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspSerial</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyLED</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspDebugOutput</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyTemperature</moteinterface>
|
||||
</motetype>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
se.sics.cooja.interfaces.Position
|
||||
<x>29.99841204907099</x>
|
||||
<y>-115.95137024353158</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
se.sics.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>1</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
</simulation>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.SimControl
|
||||
<width>417</width>
|
||||
<z>0</z>
|
||||
<height>160</height>
|
||||
<location_x>400</location_x>
|
||||
<location_y>0</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.Visualizer
|
||||
<plugin_config>
|
||||
<skin>se.sics.cooja.plugins.skins.IDVisualizerSkin</skin>
|
||||
<viewport>0.9090909090909091 0.0 0.0 0.9090909090909091 153.72871631902638 172.41033658502872</viewport>
|
||||
</plugin_config>
|
||||
<width>393</width>
|
||||
<z>2</z>
|
||||
<height>430</height>
|
||||
<location_x>1</location_x>
|
||||
<location_y>1</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.TimeLine
|
||||
<plugin_config>
|
||||
<mote>0</mote>
|
||||
<showRadioRXTX />
|
||||
<showRadioHW />
|
||||
<showLEDs />
|
||||
<split>-1</split>
|
||||
<zoomfactor>500.0</zoomfactor>
|
||||
</plugin_config>
|
||||
<width>819</width>
|
||||
<z>3</z>
|
||||
<height>166</height>
|
||||
<location_x>0</location_x>
|
||||
<location_y>433</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.Notes
|
||||
<plugin_config>
|
||||
<notes>Enter notes here</notes>
|
||||
<decorations>true</decorations>
|
||||
</plugin_config>
|
||||
<width>6</width>
|
||||
<z>4</z>
|
||||
<height>160</height>
|
||||
<location_x>680</location_x>
|
||||
<location_y>0</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.MoteInterfaceViewer
|
||||
<mote_arg>0</mote_arg>
|
||||
<plugin_config>
|
||||
<interface>Serial port</interface>
|
||||
<scrollpos>0,0</scrollpos>
|
||||
</plugin_config>
|
||||
<width>422</width>
|
||||
<z>1</z>
|
||||
<height>265</height>
|
||||
<location_x>397</location_x>
|
||||
<location_y>162</location_y>
|
||||
</plugin>
|
||||
</simconf>
|
||||
|
56
S2/hello-world.c
Normal file
56
S2/hello-world.c
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 2006, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: hello-world.c,v 1.1 2006/10/02 21:46:46 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* A very simple Contiki application showing how Contiki programs look
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
|
||||
#include <stdio.h> /* For printf() */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(hello_world_process, "Hello world process");
|
||||
AUTOSTART_PROCESSES(&hello_world_process);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(hello_world_process, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
|
||||
printf("Hello, world\n");
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
7
S3/Makefile
Normal file
7
S3/Makefile
Normal file
@ -0,0 +1,7 @@
|
||||
CONTIKI_PROJECT = sensors
|
||||
all: $(CONTIKI_PROJECT)
|
||||
|
||||
#UIP_CONF_IPV6=1
|
||||
|
||||
CONTIKI = ../..
|
||||
include $(CONTIKI)/Makefile.include
|
125
S3/cooja_sensor.csc
Normal file
125
S3/cooja_sensor.csc
Normal file
@ -0,0 +1,125 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<simconf>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/mrm</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/mspsim</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/avrora</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/serial_socket</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/collect-view</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/powertracker</project>
|
||||
<simulation>
|
||||
<title>Sensor Reading</title>
|
||||
<speedlimit>1.0</speedlimit>
|
||||
<randomseed>123456</randomseed>
|
||||
<motedelay_us>1000000</motedelay_us>
|
||||
<radiomedium>
|
||||
se.sics.cooja.radiomediums.UDGM
|
||||
<transmitting_range>50.0</transmitting_range>
|
||||
<interference_range>100.0</interference_range>
|
||||
<success_ratio_tx>1.0</success_ratio_tx>
|
||||
<success_ratio_rx>1.0</success_ratio_rx>
|
||||
</radiomedium>
|
||||
<events>
|
||||
<logoutput>40000</logoutput>
|
||||
</events>
|
||||
<motetype>
|
||||
se.sics.cooja.mspmote.SkyMoteType
|
||||
<identifier>sky1</identifier>
|
||||
<description>Sky Mote Type #sky1</description>
|
||||
<source EXPORT="discard">[CONTIKI_DIR]/surrey/S3/sensor.c</source>
|
||||
<commands EXPORT="discard">make sensor.sky TARGET=sky</commands>
|
||||
<firmware EXPORT="copy">[CONTIKI_DIR]/surrey/S3/sensor.sky</firmware>
|
||||
<moteinterface>se.sics.cooja.interfaces.Position</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.RimeAddress</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.IPAddress</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.Mote2MoteRelations</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.MoteAttributes</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspClock</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspMoteID</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyButton</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyFlash</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyCoffeeFilesystem</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.Msp802154Radio</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspSerial</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyLED</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspDebugOutput</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyTemperature</moteinterface>
|
||||
</motetype>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
se.sics.cooja.interfaces.Position
|
||||
<x>4.880991957027561</x>
|
||||
<y>-110.74160922288071</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
se.sics.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>1</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
</simulation>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.SimControl
|
||||
<width>416</width>
|
||||
<z>0</z>
|
||||
<height>160</height>
|
||||
<location_x>400</location_x>
|
||||
<location_y>0</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.Visualizer
|
||||
<plugin_config>
|
||||
<skin>se.sics.cooja.plugins.skins.IDVisualizerSkin</skin>
|
||||
<viewport>0.9090909090909091 0.0 0.0 0.9090909090909091 183.5627345845204 172.67419020261883</viewport>
|
||||
</plugin_config>
|
||||
<width>400</width>
|
||||
<z>2</z>
|
||||
<height>241</height>
|
||||
<location_x>1</location_x>
|
||||
<location_y>1</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.TimeLine
|
||||
<plugin_config>
|
||||
<mote>0</mote>
|
||||
<showRadioRXTX />
|
||||
<showRadioHW />
|
||||
<showLEDs />
|
||||
<split>-1</split>
|
||||
<zoomfactor>500.0</zoomfactor>
|
||||
</plugin_config>
|
||||
<width>397</width>
|
||||
<z>4</z>
|
||||
<height>166</height>
|
||||
<location_x>0</location_x>
|
||||
<location_y>436</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.MoteInterfaceViewer
|
||||
<mote_arg>0</mote_arg>
|
||||
<plugin_config>
|
||||
<interface>Serial port</interface>
|
||||
<scrollpos>0,0</scrollpos>
|
||||
</plugin_config>
|
||||
<width>413</width>
|
||||
<z>3</z>
|
||||
<height>431</height>
|
||||
<location_x>406</location_x>
|
||||
<location_y>168</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.MoteInterfaceViewer
|
||||
<mote_arg>0</mote_arg>
|
||||
<plugin_config>
|
||||
<interface>Temperature and Light</interface>
|
||||
<scrollpos>0,0</scrollpos>
|
||||
</plugin_config>
|
||||
<width>397</width>
|
||||
<z>1</z>
|
||||
<height>179</height>
|
||||
<location_x>2</location_x>
|
||||
<location_y>247</location_y>
|
||||
</plugin>
|
||||
</simconf>
|
||||
|
57
S3/sensor.c
Normal file
57
S3/sensor.c
Normal file
@ -0,0 +1,57 @@
|
||||
#include "contiki.h"
|
||||
#include "dev/light-sensor.h"
|
||||
#include "dev/sht11-sensor.h"
|
||||
#include <stdio.h> /* For printf() */
|
||||
|
||||
float getTemperature(void)
|
||||
{
|
||||
int tempData;
|
||||
|
||||
// NOTE: You only need to use one of the following
|
||||
// If you run the code in Cooja Simulator, please remove the second one
|
||||
//tempData = sht11_sensor.value(SHT11_SENSOR_TEMP_SKYSIM); // For Cooja Sim
|
||||
tempData = sht11_sensor.value(SHT11_SENSOR_TEMP); // For XM1000 mote
|
||||
|
||||
float temp = tempData; // you need to implement the transfer function here
|
||||
return temp;
|
||||
}
|
||||
|
||||
float getLight(void)
|
||||
{
|
||||
int lightData = light_sensor.value(LIGHT_SENSOR_PHOTOSYNTHETIC);
|
||||
float light = lightData; // you need to implement the transfer function here
|
||||
return light;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(sensor_reading_process, "Sensor reading process");
|
||||
AUTOSTART_PROCESSES(&sensor_reading_process);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(sensor_reading_process, ev, data)
|
||||
{
|
||||
static struct etimer timer;
|
||||
PROCESS_BEGIN();
|
||||
etimer_set(&timer, CLOCK_CONF_SECOND/4); // you need to put the correct
|
||||
// timer setting here
|
||||
SENSORS_ACTIVATE(light_sensor);
|
||||
SENSORS_ACTIVATE(sht11_sensor);
|
||||
|
||||
static int counter = 0;
|
||||
while(1)
|
||||
{
|
||||
PROCESS_WAIT_EVENT_UNTIL(ev=PROCESS_EVENT_TIMER);
|
||||
|
||||
float temp = getTemperature();
|
||||
float light_lx = getLight();
|
||||
|
||||
printf("%d\n", ++counter); // you should also print the temperature
|
||||
// and light intensity here
|
||||
|
||||
etimer_reset(&timer);
|
||||
}
|
||||
PROCESS_END();
|
||||
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
5
S4/Makefile
Normal file
5
S4/Makefile
Normal file
@ -0,0 +1,5 @@
|
||||
CONTIKI_PROJECT = communication
|
||||
all: $(CONTIKI_PROJECT)
|
||||
#UIP_CONF_IPV6=1
|
||||
CONTIKI = ../..
|
||||
include $(CONTIKI)/Makefile.include
|
59
S4/client1.c
Normal file
59
S4/client1.c
Normal file
@ -0,0 +1,59 @@
|
||||
#include "contiki.h"
|
||||
#include "net/rime.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(example_unicast_process, "Example unicast");
|
||||
AUTOSTART_PROCESSES(&example_unicast_process);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
recv_uc(struct unicast_conn *c, const rimeaddr_t *from)
|
||||
{
|
||||
// Print the received message
|
||||
char *dataReceived = (char *)packetbuf_dataptr();
|
||||
dataReceived[packetbuf_datalen()] = 0;
|
||||
printf("A unicast received from %d.%d\n",from->u8[0],from->u8[1]);
|
||||
printf("The message is: '%s'\n",dataReceived);
|
||||
}
|
||||
static const struct unicast_callbacks unicast_callbacks = {recv_uc};
|
||||
static struct unicast_conn uc;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(example_unicast_process, ev, data)
|
||||
{
|
||||
PROCESS_EXITHANDLER(unicast_close(&uc);)
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
printf("I'm a client mote, my rime addr is: %d.%d\n",
|
||||
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1]);
|
||||
unicast_open(&uc, 146, &unicast_callbacks);
|
||||
|
||||
static int n = 1;
|
||||
|
||||
while(1) {
|
||||
static struct etimer et;
|
||||
rimeaddr_t addr;
|
||||
|
||||
etimer_set(&et, CLOCK_SECOND*5/7);
|
||||
|
||||
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
|
||||
|
||||
char message[100];
|
||||
sprintf(message,"Hello, I'm node %d.%d, This is message-%d",
|
||||
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],n++);
|
||||
|
||||
packetbuf_copyfrom(message, strlen(message));
|
||||
addr.u8[0] = 1; // this is the server rime address (part 1)
|
||||
addr.u8[1] = 0; // this is the server rime address (part 2)
|
||||
if(!rimeaddr_cmp(&addr, &rimeaddr_node_addr)) {
|
||||
unicast_send(&uc, &addr);
|
||||
printf("A packet is sent to %d.%d.\n", addr.u8[0],addr.u8[1]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
64
S4/client2.c
Normal file
64
S4/client2.c
Normal file
@ -0,0 +1,64 @@
|
||||
#include "contiki.h"
|
||||
#include "net/rime.h"
|
||||
#include "dev/light-sensor.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(example_unicast_process, "Example unicast");
|
||||
AUTOSTART_PROCESSES(&example_unicast_process);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
recv_uc(struct unicast_conn *c, const rimeaddr_t *from)
|
||||
{
|
||||
// Print the received message
|
||||
char *dataReceived = (char *)packetbuf_dataptr();
|
||||
dataReceived[packetbuf_datalen()] = 0;
|
||||
printf("A unicast received from %d.%d\n",from->u8[0],from->u8[1]);
|
||||
printf("The message is: '%s'\n",dataReceived);
|
||||
}
|
||||
static const struct unicast_callbacks unicast_callbacks = {recv_uc};
|
||||
static struct unicast_conn uc;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(example_unicast_process, ev, data)
|
||||
{
|
||||
PROCESS_EXITHANDLER(unicast_close(&uc);)
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
printf("I'm a client mote, my rime addr is: %d.%d\n",
|
||||
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1]);
|
||||
unicast_open(&uc, 146, &unicast_callbacks);
|
||||
|
||||
SENSORS_ACTIVATE(light_sensor);
|
||||
|
||||
while(1)
|
||||
{
|
||||
static struct etimer et;
|
||||
rimeaddr_t addr;
|
||||
|
||||
etimer_set(&et, CLOCK_SECOND*5/3);
|
||||
|
||||
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
|
||||
|
||||
int lightData = light_sensor.value(LIGHT_SENSOR_PHOTOSYNTHETIC);
|
||||
|
||||
char message[100];
|
||||
sprintf(message,"From %d.%d; Light (raw reading) = %d",
|
||||
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1], lightData);
|
||||
|
||||
packetbuf_copyfrom(message, strlen(message));
|
||||
addr.u8[0] = 1; // this is the server rime address (part 1)
|
||||
addr.u8[1] = 0; // this is the server rime address (part 2)
|
||||
if(!rimeaddr_cmp(&addr, &rimeaddr_node_addr))
|
||||
{
|
||||
unicast_send(&uc, &addr);
|
||||
printf("My light reading is sent to %d.%d.\n", addr.u8[0],addr.u8[1]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
202
S4/cooja_communication.csc
Normal file
202
S4/cooja_communication.csc
Normal file
@ -0,0 +1,202 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<simconf>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/mrm</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/mspsim</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/avrora</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/serial_socket</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/collect-view</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/powertracker</project>
|
||||
<simulation>
|
||||
<title>Communication</title>
|
||||
<speedlimit>0.1</speedlimit>
|
||||
<randomseed>123456</randomseed>
|
||||
<motedelay_us>1000000</motedelay_us>
|
||||
<radiomedium>
|
||||
se.sics.cooja.radiomediums.UDGM
|
||||
<transmitting_range>50.0</transmitting_range>
|
||||
<interference_range>100.0</interference_range>
|
||||
<success_ratio_tx>1.0</success_ratio_tx>
|
||||
<success_ratio_rx>1.0</success_ratio_rx>
|
||||
</radiomedium>
|
||||
<events>
|
||||
<logoutput>40000</logoutput>
|
||||
</events>
|
||||
<motetype>
|
||||
se.sics.cooja.mspmote.SkyMoteType
|
||||
<identifier>sky1</identifier>
|
||||
<description>Sky Mote Type #server</description>
|
||||
<source EXPORT="discard">[CONTIKI_DIR]/surrey/S4/server.c</source>
|
||||
<commands EXPORT="discard">make server.sky TARGET=sky</commands>
|
||||
<firmware EXPORT="copy">[CONTIKI_DIR]/surrey/S4/server.sky</firmware>
|
||||
<moteinterface>se.sics.cooja.interfaces.Position</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.RimeAddress</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.IPAddress</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.Mote2MoteRelations</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.MoteAttributes</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspClock</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspMoteID</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyButton</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyFlash</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyCoffeeFilesystem</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.Msp802154Radio</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspSerial</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyLED</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspDebugOutput</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyTemperature</moteinterface>
|
||||
</motetype>
|
||||
<motetype>
|
||||
se.sics.cooja.mspmote.SkyMoteType
|
||||
<identifier>sky2</identifier>
|
||||
<description>Sky Mote Type #client1</description>
|
||||
<source EXPORT="discard">[CONTIKI_DIR]/surrey/S4/client1.c</source>
|
||||
<commands EXPORT="discard">make client1.sky TARGET=sky</commands>
|
||||
<firmware EXPORT="copy">[CONTIKI_DIR]/surrey/S4/client1.sky</firmware>
|
||||
<moteinterface>se.sics.cooja.interfaces.Position</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.RimeAddress</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.IPAddress</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.Mote2MoteRelations</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.MoteAttributes</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspClock</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspMoteID</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyButton</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyFlash</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyCoffeeFilesystem</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.Msp802154Radio</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspSerial</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyLED</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspDebugOutput</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyTemperature</moteinterface>
|
||||
</motetype>
|
||||
<motetype>
|
||||
se.sics.cooja.mspmote.SkyMoteType
|
||||
<identifier>sky3</identifier>
|
||||
<description>Sky Mote Type #client2</description>
|
||||
<source EXPORT="discard">[CONTIKI_DIR]/surrey/S4/client2.c</source>
|
||||
<commands EXPORT="discard">make client2.sky TARGET=sky</commands>
|
||||
<firmware EXPORT="copy">[CONTIKI_DIR]/surrey/S4/client2.sky</firmware>
|
||||
<moteinterface>se.sics.cooja.interfaces.Position</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.RimeAddress</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.IPAddress</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.Mote2MoteRelations</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.MoteAttributes</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspClock</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspMoteID</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyButton</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyFlash</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyCoffeeFilesystem</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.Msp802154Radio</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspSerial</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyLED</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspDebugOutput</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyTemperature</moteinterface>
|
||||
</motetype>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
se.sics.cooja.interfaces.Position
|
||||
<x>61.33500937508643</x>
|
||||
<y>52.54588277697939</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
se.sics.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>1</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
se.sics.cooja.interfaces.Position
|
||||
<x>89.65134676297711</x>
|
||||
<y>53.129724784977135</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
se.sics.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>2</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky2</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
se.sics.cooja.interfaces.Position
|
||||
<x>33.31059299119462</x>
|
||||
<y>53.42164578897601</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
se.sics.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>3</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky3</motetype_identifier>
|
||||
</mote>
|
||||
</simulation>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.SimControl
|
||||
<width>307</width>
|
||||
<z>0</z>
|
||||
<height>215</height>
|
||||
<location_x>3</location_x>
|
||||
<location_y>166</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.Visualizer
|
||||
<plugin_config>
|
||||
<skin>se.sics.cooja.plugins.skins.IDVisualizerSkin</skin>
|
||||
<skin>se.sics.cooja.plugins.skins.AddressVisualizerSkin</skin>
|
||||
<skin>se.sics.cooja.plugins.skins.TrafficVisualizerSkin</skin>
|
||||
<viewport>3.4255842721199343 0.0 0.0 3.4255842721199343 -67.10824344562481 -139.00034960547833</viewport>
|
||||
</plugin_config>
|
||||
<width>281</width>
|
||||
<z>1</z>
|
||||
<height>159</height>
|
||||
<location_x>9</location_x>
|
||||
<location_y>-1</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.LogListener
|
||||
<plugin_config>
|
||||
<filter />
|
||||
<coloring />
|
||||
</plugin_config>
|
||||
<width>500</width>
|
||||
<z>3</z>
|
||||
<height>427</height>
|
||||
<location_x>312</location_x>
|
||||
<location_y>170</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.TimeLine
|
||||
<plugin_config>
|
||||
<mote>0</mote>
|
||||
<mote>1</mote>
|
||||
<mote>2</mote>
|
||||
<showRadioRXTX />
|
||||
<showRadioHW />
|
||||
<showLEDs />
|
||||
<split>-1</split>
|
||||
<zoomfactor>500.0</zoomfactor>
|
||||
</plugin_config>
|
||||
<width>522</width>
|
||||
<z>4</z>
|
||||
<height>166</height>
|
||||
<location_x>294</location_x>
|
||||
<location_y>-2</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.MoteInterfaceViewer
|
||||
<mote_arg>2</mote_arg>
|
||||
<plugin_config>
|
||||
<interface>Temperature and Light</interface>
|
||||
<scrollpos>0,0</scrollpos>
|
||||
</plugin_config>
|
||||
<width>305</width>
|
||||
<z>2</z>
|
||||
<height>199</height>
|
||||
<location_x>4</location_x>
|
||||
<location_y>395</location_y>
|
||||
</plugin>
|
||||
</simconf>
|
||||
|
57
S4/server.c
Normal file
57
S4/server.c
Normal file
@ -0,0 +1,57 @@
|
||||
#include "contiki.h"
|
||||
#include "net/rime.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
static struct unicast_conn uc;
|
||||
static int numPkts = 0;
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(example_unicast_process, "Example unicast");
|
||||
AUTOSTART_PROCESSES(&example_unicast_process);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
recv_uc(struct unicast_conn *c, const rimeaddr_t *from)
|
||||
{
|
||||
// Record number of packets received
|
||||
numPkts++;
|
||||
|
||||
// Print the received message
|
||||
char *dataReceived = (char *)packetbuf_dataptr();
|
||||
dataReceived[packetbuf_datalen()] = 0;
|
||||
printf("A unicast received from %d.%d\n",from->u8[0],from->u8[1]);
|
||||
printf("The message is:\n '%s'\n",dataReceived);
|
||||
|
||||
// Reply ACK
|
||||
rimeaddr_t addr;
|
||||
addr.u8[0] = from->u8[0];
|
||||
addr.u8[1] = from->u8[1];
|
||||
packetbuf_copyfrom("ACK",3);
|
||||
unicast_send(&uc, &addr);
|
||||
}
|
||||
static const struct unicast_callbacks unicast_callbacks = {recv_uc};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(example_unicast_process, ev, data)
|
||||
{
|
||||
PROCESS_EXITHANDLER(unicast_close(&uc);)
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
printf("I'm the server, my rime addr is: %d.%d\n",
|
||||
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1]);
|
||||
unicast_open(&uc, 146, &unicast_callbacks);
|
||||
|
||||
while(1)
|
||||
{
|
||||
static struct etimer et;
|
||||
|
||||
etimer_set(&et, CLOCK_SECOND);
|
||||
|
||||
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
|
||||
|
||||
printf("Total number of packets received = %d\n",numPkts);
|
||||
}
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
5
S5/Makefile
Normal file
5
S5/Makefile
Normal file
@ -0,0 +1,5 @@
|
||||
CONTIKI_PROJECT = firealarm
|
||||
all: $(CONTIKI_PROJECT)
|
||||
#UIP_CONF_IPV6=1
|
||||
CONTIKI = ../..
|
||||
include $(CONTIKI)/Makefile.include
|
135
S5/cooja-firealarm.csc
Normal file
135
S5/cooja-firealarm.csc
Normal file
@ -0,0 +1,135 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<simconf>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/mrm</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/mspsim</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/avrora</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/serial_socket</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/collect-view</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/powertracker</project>
|
||||
<simulation>
|
||||
<title>FireAlarm</title>
|
||||
<speedlimit>1.0</speedlimit>
|
||||
<randomseed>123456</randomseed>
|
||||
<motedelay_us>1000000</motedelay_us>
|
||||
<radiomedium>
|
||||
se.sics.cooja.radiomediums.UDGM
|
||||
<transmitting_range>50.0</transmitting_range>
|
||||
<interference_range>100.0</interference_range>
|
||||
<success_ratio_tx>1.0</success_ratio_tx>
|
||||
<success_ratio_rx>1.0</success_ratio_rx>
|
||||
</radiomedium>
|
||||
<events>
|
||||
<logoutput>40000</logoutput>
|
||||
</events>
|
||||
<motetype>
|
||||
se.sics.cooja.mspmote.SkyMoteType
|
||||
<identifier>sky1</identifier>
|
||||
<description>Sky Mote Type #sky1</description>
|
||||
<source EXPORT="discard">[CONTIKI_DIR]/surrey/S5/firealarm.c</source>
|
||||
<commands EXPORT="discard">make firealarm.sky TARGET=sky</commands>
|
||||
<firmware EXPORT="copy">[CONTIKI_DIR]/surrey/S5/firealarm.sky</firmware>
|
||||
<moteinterface>se.sics.cooja.interfaces.Position</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.RimeAddress</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.IPAddress</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.Mote2MoteRelations</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.MoteAttributes</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspClock</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspMoteID</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyButton</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyFlash</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyCoffeeFilesystem</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.Msp802154Radio</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspSerial</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyLED</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspDebugOutput</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyTemperature</moteinterface>
|
||||
</motetype>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
se.sics.cooja.interfaces.Position
|
||||
<x>95.71294705169161</x>
|
||||
<y>-39.772086367531145</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
se.sics.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>1</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
</simulation>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.SimControl
|
||||
<width>349</width>
|
||||
<z>0</z>
|
||||
<height>158</height>
|
||||
<location_x>467</location_x>
|
||||
<location_y>1</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.Visualizer
|
||||
<plugin_config>
|
||||
<skin>se.sics.cooja.plugins.skins.IDVisualizerSkin</skin>
|
||||
<viewport>0.9090909090909091 0.0 0.0 0.9090909090909091 102.98822995300763 78.15644215230104</viewport>
|
||||
</plugin_config>
|
||||
<width>461</width>
|
||||
<z>3</z>
|
||||
<height>234</height>
|
||||
<location_x>1</location_x>
|
||||
<location_y>1</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.MoteInterfaceViewer
|
||||
<mote_arg>0</mote_arg>
|
||||
<plugin_config>
|
||||
<interface>Sky LED</interface>
|
||||
<scrollpos>0,0</scrollpos>
|
||||
</plugin_config>
|
||||
<width>211</width>
|
||||
<z>4</z>
|
||||
<height>171</height>
|
||||
<location_x>3</location_x>
|
||||
<location_y>237</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.MoteInterfaceViewer
|
||||
<mote_arg>0</mote_arg>
|
||||
<plugin_config>
|
||||
<interface>Serial port</interface>
|
||||
<scrollpos>0,0</scrollpos>
|
||||
</plugin_config>
|
||||
<width>351</width>
|
||||
<z>5</z>
|
||||
<height>440</height>
|
||||
<location_x>467</location_x>
|
||||
<location_y>160</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.MoteInterfaceViewer
|
||||
<mote_arg>0</mote_arg>
|
||||
<plugin_config>
|
||||
<interface>Temperature and Light</interface>
|
||||
<scrollpos>0,0</scrollpos>
|
||||
</plugin_config>
|
||||
<width>459</width>
|
||||
<z>2</z>
|
||||
<height>172</height>
|
||||
<location_x>2</location_x>
|
||||
<location_y>416</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.MoteInterfaceViewer
|
||||
<mote_arg>0</mote_arg>
|
||||
<plugin_config>
|
||||
<interface>Button</interface>
|
||||
<scrollpos>0,0</scrollpos>
|
||||
</plugin_config>
|
||||
<width>245</width>
|
||||
<z>1</z>
|
||||
<height>173</height>
|
||||
<location_x>219</location_x>
|
||||
<location_y>240</location_y>
|
||||
</plugin>
|
||||
</simconf>
|
||||
|
47
S5/firealarm.c
Normal file
47
S5/firealarm.c
Normal file
@ -0,0 +1,47 @@
|
||||
#include "contiki.h"
|
||||
#include "dev/light-sensor.h"
|
||||
#include "dev/sht11-sensor.h"
|
||||
#include "dev/button-sensor.h" // For button
|
||||
#include "dev/leds.h" // For LED
|
||||
#include <stdio.h> /* For printf() */
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(fire_alarm_process, "Firealarm process");
|
||||
AUTOSTART_PROCESSES(&fire_alarm_process);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(fire_alarm_process, ev, data)
|
||||
{
|
||||
static struct etimer timer;
|
||||
PROCESS_BEGIN();
|
||||
etimer_set(&timer, CLOCK_CONF_SECOND/2);
|
||||
|
||||
SENSORS_ACTIVATE(light_sensor); // need this for temperature sensor in Simulation
|
||||
SENSORS_ACTIVATE(sht11_sensor);
|
||||
SENSORS_ACTIVATE(button_sensor); // activate button too
|
||||
leds_off(LEDS_ALL); // turn off all LEDs
|
||||
|
||||
static int counter = 0;
|
||||
while(1)
|
||||
{
|
||||
PROCESS_WAIT_EVENT(); // wait for an event
|
||||
|
||||
if (ev==PROCESS_EVENT_TIMER)
|
||||
{
|
||||
// timer event
|
||||
printf("%d\n",++counter);
|
||||
if (counter==10) leds_on(LEDS_ALL);
|
||||
|
||||
etimer_reset(&timer);
|
||||
}
|
||||
else if (ev==sensors_event && data==&button_sensor)
|
||||
{
|
||||
// button event
|
||||
counter = 0;
|
||||
leds_off(LEDS_ALL);
|
||||
printf("%d\n",counter);
|
||||
}
|
||||
}
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
6
S6/Makefile
Normal file
6
S6/Makefile
Normal file
@ -0,0 +1,6 @@
|
||||
CONTIKI_PROJECT = power
|
||||
APPS += powertrace
|
||||
all: $(CONTIKI_PROJECT)
|
||||
#UIP_CONF_IPV6=1
|
||||
CONTIKI = ../..
|
||||
include $(CONTIKI)/Makefile.include
|
163
S6/cooja_powertrace.csc
Normal file
163
S6/cooja_powertrace.csc
Normal file
@ -0,0 +1,163 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<simconf>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/mrm</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/mspsim</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/avrora</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/serial_socket</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/collect-view</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/powertracker</project>
|
||||
<simulation>
|
||||
<title>Powertrace</title>
|
||||
<speedlimit>1.0</speedlimit>
|
||||
<randomseed>123456</randomseed>
|
||||
<motedelay_us>1000000</motedelay_us>
|
||||
<radiomedium>
|
||||
se.sics.cooja.radiomediums.UDGM
|
||||
<transmitting_range>50.0</transmitting_range>
|
||||
<interference_range>100.0</interference_range>
|
||||
<success_ratio_tx>1.0</success_ratio_tx>
|
||||
<success_ratio_rx>1.0</success_ratio_rx>
|
||||
</radiomedium>
|
||||
<events>
|
||||
<logoutput>40000</logoutput>
|
||||
</events>
|
||||
<motetype>
|
||||
se.sics.cooja.mspmote.SkyMoteType
|
||||
<identifier>sky1</identifier>
|
||||
<description>Sky Mote Type #sky1</description>
|
||||
<source EXPORT="discard">[CONTIKI_DIR]/surrey/S6/test1.c</source>
|
||||
<commands EXPORT="discard">make test1.sky TARGET=sky</commands>
|
||||
<firmware EXPORT="copy">[CONTIKI_DIR]/surrey/S6/test1.sky</firmware>
|
||||
<moteinterface>se.sics.cooja.interfaces.Position</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.RimeAddress</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.IPAddress</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.Mote2MoteRelations</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.MoteAttributes</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspClock</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspMoteID</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyButton</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyFlash</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyCoffeeFilesystem</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.Msp802154Radio</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspSerial</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyLED</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspDebugOutput</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyTemperature</moteinterface>
|
||||
</motetype>
|
||||
<motetype>
|
||||
se.sics.cooja.mspmote.SkyMoteType
|
||||
<identifier>sky2</identifier>
|
||||
<description>Sky Mote Type #sky2</description>
|
||||
<source EXPORT="discard">[CONTIKI_DIR]/surrey/S6/test2.c</source>
|
||||
<commands EXPORT="discard">make test2.sky TARGET=sky</commands>
|
||||
<firmware EXPORT="copy">[CONTIKI_DIR]/surrey/S6/test2.sky</firmware>
|
||||
<moteinterface>se.sics.cooja.interfaces.Position</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.RimeAddress</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.IPAddress</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.Mote2MoteRelations</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.MoteAttributes</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspClock</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspMoteID</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyButton</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyFlash</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyCoffeeFilesystem</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.Msp802154Radio</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspSerial</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyLED</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspDebugOutput</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyTemperature</moteinterface>
|
||||
</motetype>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
se.sics.cooja.interfaces.Position
|
||||
<x>-62.31364313894892</x>
|
||||
<y>-37.398410120986085</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
se.sics.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>1</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
se.sics.cooja.interfaces.Position
|
||||
<x>-14.139911939661413</x>
|
||||
<y>-37.398410120986085</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
se.sics.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>2</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky2</motetype_identifier>
|
||||
</mote>
|
||||
</simulation>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.SimControl
|
||||
<width>525</width>
|
||||
<z>0</z>
|
||||
<height>160</height>
|
||||
<location_x>291</location_x>
|
||||
<location_y>0</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.Visualizer
|
||||
<plugin_config>
|
||||
<skin>se.sics.cooja.plugins.skins.IDVisualizerSkin</skin>
|
||||
<skin>se.sics.cooja.plugins.skins.LEDVisualizerSkin</skin>
|
||||
<viewport>1.515348680342196 0.0 0.0 1.515348680342196 177.42689689792078 109.67163142373249</viewport>
|
||||
</plugin_config>
|
||||
<width>284</width>
|
||||
<z>2</z>
|
||||
<height>243</height>
|
||||
<location_x>1</location_x>
|
||||
<location_y>1</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.LogListener
|
||||
<plugin_config>
|
||||
<filter />
|
||||
<coloring />
|
||||
</plugin_config>
|
||||
<width>533</width>
|
||||
<z>1</z>
|
||||
<height>434</height>
|
||||
<location_x>286</location_x>
|
||||
<location_y>160</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.TimeLine
|
||||
<plugin_config>
|
||||
<mote>0</mote>
|
||||
<mote>1</mote>
|
||||
<showRadioRXTX />
|
||||
<showRadioHW />
|
||||
<showLEDs />
|
||||
<split>-1</split>
|
||||
<zoomfactor>500.0</zoomfactor>
|
||||
</plugin_config>
|
||||
<width>279</width>
|
||||
<z>3</z>
|
||||
<height>201</height>
|
||||
<location_x>3</location_x>
|
||||
<location_y>249</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.MoteInterfaceViewer
|
||||
<mote_arg>1</mote_arg>
|
||||
<plugin_config>
|
||||
<interface>Sky LED</interface>
|
||||
<scrollpos>0,0</scrollpos>
|
||||
</plugin_config>
|
||||
<width>282</width>
|
||||
<z>4</z>
|
||||
<height>146</height>
|
||||
<location_x>-7</location_x>
|
||||
<location_y>456</location_y>
|
||||
</plugin>
|
||||
</simconf>
|
||||
|
34
S6/test1.c
Normal file
34
S6/test1.c
Normal file
@ -0,0 +1,34 @@
|
||||
#include "contiki.h"
|
||||
#include "random.h"
|
||||
#include "powertrace.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
PROCESS(power, "powertrace example");
|
||||
AUTOSTART_PROCESSES(&power);
|
||||
|
||||
PROCESS_THREAD(power, ev, data)
|
||||
{
|
||||
static struct etimer et;
|
||||
static float t;
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
/* Start powertracing */
|
||||
int n = 1; // 1 second reporting cycle
|
||||
|
||||
powertrace_start(CLOCK_SECOND * n);
|
||||
printf("Ticks per second: %u\n", RTIMER_SECOND);
|
||||
|
||||
while(1)
|
||||
{
|
||||
/* Delay 2-4 seconds and then perform some tasks */
|
||||
t = 2*((float)random_rand()/RANDOM_RAND_MAX) + 2;
|
||||
etimer_set(&et, CLOCK_SECOND*t);
|
||||
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
|
||||
|
||||
// Put your tasks here...
|
||||
}
|
||||
|
||||
PROCESS_END();
|
||||
}
|
73
S6/test2.c
Normal file
73
S6/test2.c
Normal file
@ -0,0 +1,73 @@
|
||||
#include "contiki.h"
|
||||
#include "random.h"
|
||||
#include "powertrace.h"
|
||||
#include "dev/leds.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
PROCESS(power, "powertrace example");
|
||||
AUTOSTART_PROCESSES(&power);
|
||||
|
||||
int d1(float f) // Integer part
|
||||
{
|
||||
return((int)f);
|
||||
}
|
||||
unsigned int d2(float f) // Fractional part
|
||||
{
|
||||
if (f>0)
|
||||
return(1000*(f-d1(f)));
|
||||
else
|
||||
return(1000*(d1(f)-f));
|
||||
}
|
||||
|
||||
|
||||
PROCESS_THREAD(power, ev, data)
|
||||
{
|
||||
static struct etimer et;
|
||||
static float t;
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
/* Start powertracing */
|
||||
int n = 1; // 1 second reporting cycle
|
||||
|
||||
powertrace_start(CLOCK_SECOND * n);
|
||||
printf("Ticks per second: %u\n", RTIMER_SECOND);
|
||||
|
||||
while(1)
|
||||
{
|
||||
/* Delay 2-4 seconds and then perform some tasks */
|
||||
t = 2*((float)random_rand()/RANDOM_RAND_MAX) + 2;
|
||||
etimer_set(&et, CLOCK_SECOND*t);
|
||||
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
|
||||
|
||||
// Put your tasks here...
|
||||
|
||||
// Task 1: Switching LED
|
||||
static int ledStatus = 0;
|
||||
switch(ledStatus) {
|
||||
case 0: leds_on(LEDS_RED);
|
||||
leds_off(LEDS_GREEN);
|
||||
leds_off(LEDS_BLUE);
|
||||
break;
|
||||
case 1: leds_off(LEDS_RED);
|
||||
leds_on(LEDS_GREEN);
|
||||
leds_off(LEDS_BLUE);
|
||||
break;
|
||||
case 2: leds_off(LEDS_RED);
|
||||
leds_off(LEDS_GREEN);
|
||||
leds_on(LEDS_BLUE);
|
||||
break;
|
||||
default:
|
||||
leds_on(LEDS_ALL);
|
||||
ledStatus = -1;
|
||||
}
|
||||
ledStatus++;
|
||||
|
||||
// Task 2: Squaring a floating point
|
||||
float sq = t*t;
|
||||
printf("floor(sq)=%d\n", (int)sq);
|
||||
}
|
||||
|
||||
PROCESS_END();
|
||||
}
|
5
S7/Makefile
Normal file
5
S7/Makefile
Normal file
@ -0,0 +1,5 @@
|
||||
CONTIKI_PROJECT = multithreading
|
||||
all: $(CONTIKI_PROJECT)
|
||||
#UIP_CONF_IPV6=1
|
||||
CONTIKI = ../..
|
||||
include $(CONTIKI)/Makefile.include
|
125
S7/cooja_multithreading.csc
Normal file
125
S7/cooja_multithreading.csc
Normal file
@ -0,0 +1,125 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<simconf>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/mrm</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/mspsim</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/avrora</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/serial_socket</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/collect-view</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/powertracker</project>
|
||||
<simulation>
|
||||
<title>Multithreading</title>
|
||||
<speedlimit>1.0</speedlimit>
|
||||
<randomseed>123456</randomseed>
|
||||
<motedelay_us>1000000</motedelay_us>
|
||||
<radiomedium>
|
||||
se.sics.cooja.radiomediums.UDGM
|
||||
<transmitting_range>50.0</transmitting_range>
|
||||
<interference_range>100.0</interference_range>
|
||||
<success_ratio_tx>1.0</success_ratio_tx>
|
||||
<success_ratio_rx>1.0</success_ratio_rx>
|
||||
</radiomedium>
|
||||
<events>
|
||||
<logoutput>40000</logoutput>
|
||||
</events>
|
||||
<motetype>
|
||||
se.sics.cooja.mspmote.SkyMoteType
|
||||
<identifier>sky1</identifier>
|
||||
<description>Sky Mote Type #sky1</description>
|
||||
<source EXPORT="discard">[CONTIKI_DIR]/surrey/S7/multithreading.c</source>
|
||||
<commands EXPORT="discard">make multithreading.sky TARGET=sky</commands>
|
||||
<firmware EXPORT="copy">[CONTIKI_DIR]/surrey/S7/multithreading.sky</firmware>
|
||||
<moteinterface>se.sics.cooja.interfaces.Position</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.RimeAddress</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.IPAddress</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.Mote2MoteRelations</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.MoteAttributes</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspClock</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspMoteID</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyButton</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyFlash</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyCoffeeFilesystem</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.Msp802154Radio</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspSerial</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyLED</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspDebugOutput</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyTemperature</moteinterface>
|
||||
</motetype>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
se.sics.cooja.interfaces.Position
|
||||
<x>-53.61682026487024</x>
|
||||
<y>-51.69139009016144</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
se.sics.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>1</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
</simulation>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.SimControl
|
||||
<width>508</width>
|
||||
<z>0</z>
|
||||
<height>160</height>
|
||||
<location_x>310</location_x>
|
||||
<location_y>0</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.Visualizer
|
||||
<plugin_config>
|
||||
<skin>se.sics.cooja.plugins.skins.IDVisualizerSkin</skin>
|
||||
<viewport>0.9090909090909091 0.0 0.0 0.9090909090909091 188.74256387715477 154.99217280923767</viewport>
|
||||
</plugin_config>
|
||||
<width>303</width>
|
||||
<z>2</z>
|
||||
<height>282</height>
|
||||
<location_x>1</location_x>
|
||||
<location_y>1</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.TimeLine
|
||||
<plugin_config>
|
||||
<mote>0</mote>
|
||||
<showRadioRXTX />
|
||||
<showRadioHW />
|
||||
<showLEDs />
|
||||
<split>-1</split>
|
||||
<zoomfactor>500.0</zoomfactor>
|
||||
</plugin_config>
|
||||
<width>814</width>
|
||||
<z>3</z>
|
||||
<height>122</height>
|
||||
<location_x>0</location_x>
|
||||
<location_y>480</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.MoteInterfaceViewer
|
||||
<mote_arg>0</mote_arg>
|
||||
<plugin_config>
|
||||
<interface>Serial port</interface>
|
||||
<scrollpos>0,0</scrollpos>
|
||||
</plugin_config>
|
||||
<width>508</width>
|
||||
<z>4</z>
|
||||
<height>315</height>
|
||||
<location_x>308</location_x>
|
||||
<location_y>165</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.MoteInterfaceViewer
|
||||
<mote_arg>0</mote_arg>
|
||||
<plugin_config>
|
||||
<interface>Temperature and Light</interface>
|
||||
<scrollpos>0,0</scrollpos>
|
||||
</plugin_config>
|
||||
<width>308</width>
|
||||
<z>1</z>
|
||||
<height>194</height>
|
||||
<location_x>-1</location_x>
|
||||
<location_y>284</location_y>
|
||||
</plugin>
|
||||
</simconf>
|
||||
|
94
S7/multithreading.c
Normal file
94
S7/multithreading.c
Normal file
@ -0,0 +1,94 @@
|
||||
#include "contiki.h"
|
||||
#include <stdio.h> /* For printf() */
|
||||
|
||||
#include "dev/sht11-sensor.h"
|
||||
#include "dev/light-sensor.h"
|
||||
|
||||
#define MAX_VALUES 4 // Number of values used in averaging process
|
||||
|
||||
static process_event_t event_data_ready; // Application specific event value
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* We declare the two processes */
|
||||
PROCESS(temp_process, "Temperature process");
|
||||
PROCESS(print_process, "Print process");
|
||||
|
||||
/* We require the processes to be started automatically */
|
||||
AUTOSTART_PROCESSES(&temp_process, &print_process);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Implementation of the first process */
|
||||
PROCESS_THREAD(temp_process, ev, data)
|
||||
{
|
||||
/* Variables are declared static to ensure their values are kept */
|
||||
/* between kernel calls. */
|
||||
static struct etimer timer;
|
||||
static int count = 0;
|
||||
|
||||
// Any process must start with this.
|
||||
PROCESS_BEGIN();
|
||||
|
||||
// Allocate the required event
|
||||
event_data_ready = process_alloc_event();
|
||||
|
||||
// Initialise the temperature sensor
|
||||
SENSORS_ACTIVATE(light_sensor); // need this for sky-mote emulation
|
||||
SENSORS_ACTIVATE(sht11_sensor);
|
||||
|
||||
// Initialise variables
|
||||
count = 0;
|
||||
|
||||
// Set the etimer module to generate a periodic event
|
||||
etimer_set(&timer, CLOCK_CONF_SECOND);
|
||||
|
||||
static int myData;
|
||||
while (1)
|
||||
{
|
||||
// Wait here for the timer to expire
|
||||
PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_TIMER);
|
||||
|
||||
// this is temperature process
|
||||
count++;
|
||||
//int tempVal = sht11_sensor.value(SHT11_SENSOR_TEMP_SKYSIM); // For Cooja Sim
|
||||
int tempVal = sht11_sensor.value(SHT11_SENSOR_TEMP); // For XM1000 mote
|
||||
printf("[temperature process] temp=%d\n", tempVal);
|
||||
|
||||
// Check if enough samples are collected
|
||||
if (count==MAX_VALUES)
|
||||
{
|
||||
// Transfer the last read raw temperature reading for passing
|
||||
myData = tempVal;
|
||||
|
||||
// Reset variables
|
||||
count = 0;
|
||||
|
||||
// Post an event to the print process
|
||||
// and pass a pointer to the last measure as data
|
||||
printf("[temperature process] passing value %d\n", myData);
|
||||
process_post(&print_process, event_data_ready, &myData);
|
||||
}
|
||||
|
||||
// Reset the timer so it will generate another event
|
||||
etimer_reset(&timer);
|
||||
}
|
||||
|
||||
// Any process must end with this, even if it is never reached.
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Implementation of the second process */
|
||||
PROCESS_THREAD(print_process, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
|
||||
while (1)
|
||||
{
|
||||
// Wait until we get a data_ready event
|
||||
PROCESS_WAIT_EVENT_UNTIL(ev == event_data_ready);
|
||||
|
||||
// Use 'data' variable to retrieve data and then display it
|
||||
int myData = *(int *)data; // cast to an integer pointer
|
||||
printf("[print process] data ready, received value = %d\n", myData);
|
||||
}
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
4
S8/Makefile
Normal file
4
S8/Makefile
Normal file
@ -0,0 +1,4 @@
|
||||
CONTIKI_PROJECT = calcution
|
||||
all: $(CONTIKI_PROJECT)
|
||||
CONTIKI = ../..
|
||||
include $(CONTIKI)/Makefile.include
|
45
S8/calculation.c
Normal file
45
S8/calculation.c
Normal file
@ -0,0 +1,45 @@
|
||||
#include "contiki.h"
|
||||
#include "dev/light-sensor.h"
|
||||
#include "dev/sht11-sensor.h"
|
||||
#include "dev/button-sensor.h"
|
||||
#include <stdio.h> // For printf()
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(calculation, "Calculation");
|
||||
AUTOSTART_PROCESSES(&calculation);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(calculation, ev, data)
|
||||
{
|
||||
static struct etimer timer;
|
||||
|
||||
PROCESS_BEGIN();
|
||||
etimer_set(&timer, CLOCK_CONF_SECOND);
|
||||
|
||||
SENSORS_ACTIVATE(light_sensor); // need this for temperature sensor in Simulation
|
||||
SENSORS_ACTIVATE(sht11_sensor);
|
||||
SENSORS_ACTIVATE(button_sensor); // activate button too
|
||||
|
||||
while(1)
|
||||
{
|
||||
PROCESS_WAIT_EVENT(); // wait for an event
|
||||
|
||||
if (ev==PROCESS_EVENT_TIMER)
|
||||
{
|
||||
int lightData = light_sensor.value(LIGHT_SENSOR_PHOTOSYNTHETIC);
|
||||
printf("Reading (raw light intensity) = %d\n", lightData);
|
||||
|
||||
etimer_reset(&timer);
|
||||
}
|
||||
else if (ev==sensors_event && data==&button_sensor)
|
||||
{
|
||||
// When a button is pressed, we should calculate the square root
|
||||
int lightData = light_sensor.value(LIGHT_SENSOR_PHOTOSYNTHETIC);
|
||||
printf("Reading (raw light intensity) = %d\n", lightData);
|
||||
|
||||
// Do your calculation here...
|
||||
printf("The square root of the last reading = ???\n");
|
||||
}
|
||||
}
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
138
S8/cooja_calculation.csc
Normal file
138
S8/cooja_calculation.csc
Normal file
@ -0,0 +1,138 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<simconf>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/mrm</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/mspsim</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/avrora</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/serial_socket</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/collect-view</project>
|
||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/powertracker</project>
|
||||
<simulation>
|
||||
<title>Calculation</title>
|
||||
<speedlimit>1.0</speedlimit>
|
||||
<randomseed>123456</randomseed>
|
||||
<motedelay_us>1000000</motedelay_us>
|
||||
<radiomedium>
|
||||
se.sics.cooja.radiomediums.UDGM
|
||||
<transmitting_range>50.0</transmitting_range>
|
||||
<interference_range>100.0</interference_range>
|
||||
<success_ratio_tx>1.0</success_ratio_tx>
|
||||
<success_ratio_rx>1.0</success_ratio_rx>
|
||||
</radiomedium>
|
||||
<events>
|
||||
<logoutput>40000</logoutput>
|
||||
</events>
|
||||
<motetype>
|
||||
se.sics.cooja.mspmote.SkyMoteType
|
||||
<identifier>sky1</identifier>
|
||||
<description>Sky Mote Type #sky1</description>
|
||||
<source EXPORT="discard">[CONTIKI_DIR]/surrey/S8/calculation.c</source>
|
||||
<commands EXPORT="discard">make calculation.sky TARGET=sky</commands>
|
||||
<firmware EXPORT="copy">[CONTIKI_DIR]/surrey/S8/calculation.sky</firmware>
|
||||
<moteinterface>se.sics.cooja.interfaces.Position</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.RimeAddress</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.IPAddress</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.Mote2MoteRelations</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.MoteAttributes</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspClock</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspMoteID</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyButton</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyFlash</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyCoffeeFilesystem</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.Msp802154Radio</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspSerial</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyLED</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspDebugOutput</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyTemperature</moteinterface>
|
||||
</motetype>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
se.sics.cooja.interfaces.Position
|
||||
<x>-7.515414031092613</x>
|
||||
<y>-43.82478351630446</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
se.sics.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>1</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
</simulation>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.SimControl
|
||||
<width>418</width>
|
||||
<z>0</z>
|
||||
<height>160</height>
|
||||
<location_x>400</location_x>
|
||||
<location_y>0</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.Visualizer
|
||||
<plugin_config>
|
||||
<skin>se.sics.cooja.plugins.skins.IDVisualizerSkin</skin>
|
||||
<viewport>0.9090909090909091 0.0 0.0 0.9090909090909091 192.83219457372056 91.84071228754951</viewport>
|
||||
</plugin_config>
|
||||
<width>400</width>
|
||||
<z>3</z>
|
||||
<height>177</height>
|
||||
<location_x>1</location_x>
|
||||
<location_y>1</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.TimeLine
|
||||
<plugin_config>
|
||||
<mote>0</mote>
|
||||
<showRadioRXTX />
|
||||
<showRadioHW />
|
||||
<showLEDs />
|
||||
<split>-1</split>
|
||||
<zoomfactor>500.0</zoomfactor>
|
||||
</plugin_config>
|
||||
<width>400</width>
|
||||
<z>4</z>
|
||||
<height>137</height>
|
||||
<location_x>0</location_x>
|
||||
<location_y>465</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.MoteInterfaceViewer
|
||||
<mote_arg>0</mote_arg>
|
||||
<plugin_config>
|
||||
<interface>Serial port</interface>
|
||||
<scrollpos>0,0</scrollpos>
|
||||
</plugin_config>
|
||||
<width>414</width>
|
||||
<z>5</z>
|
||||
<height>434</height>
|
||||
<location_x>403</location_x>
|
||||
<location_y>164</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.MoteInterfaceViewer
|
||||
<mote_arg>0</mote_arg>
|
||||
<plugin_config>
|
||||
<interface>Temperature and Light</interface>
|
||||
<scrollpos>0,0</scrollpos>
|
||||
</plugin_config>
|
||||
<width>396</width>
|
||||
<z>2</z>
|
||||
<height>163</height>
|
||||
<location_x>1</location_x>
|
||||
<location_y>182</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.MoteInterfaceViewer
|
||||
<mote_arg>0</mote_arg>
|
||||
<plugin_config>
|
||||
<interface>Button</interface>
|
||||
<scrollpos>0,0</scrollpos>
|
||||
</plugin_config>
|
||||
<width>395</width>
|
||||
<z>1</z>
|
||||
<height>115</height>
|
||||
<location_x>0</location_x>
|
||||
<location_y>345</location_y>
|
||||
</plugin>
|
||||
</simconf>
|
||||
|
Loading…
Reference in New Issue
Block a user