Merge pull request #123 from g-oikonomou/contrib/tidy-up-examples

Tidy-up the examples directory
This commit is contained in:
Simon Duquennoy 2017-10-31 18:59:09 +01:00 committed by GitHub
commit fc57dbbfaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
180 changed files with 1239 additions and 6887 deletions

View File

@ -25,7 +25,7 @@
org.contikios.cooja.contikimote.ContikiMoteType
<identifier>mtype660</identifier>
<description>RPL/TSCH Node</description>
<source>[CONTIKI_DIR]/examples/ipv6/rpl-tsch/node.c</source>
<source>[CONTIKI_DIR]/examples/6tisch/simple-node/node.c</source>
<commands>make TARGET=cooja clean
make TARGET=cooja node.cooja</commands>
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>

View File

@ -25,7 +25,7 @@ If the mode is 6ln (node)
* Following this the application triggers another 6P Add Request to 6dr
* After an interval, the application triggers a 6P Delete Request to 6dr
For the Cooja simulation, you may use the rpl-tsch-sixtop-z1.csc file in this folder.
For the Cooja simulation, you may use the rpl-tsch-sixtop-cooja.csc file in this folder.
Once you run the simulation, "Mote output" window of Cooja simulator displays the
following messages.

View File

@ -39,86 +39,50 @@
#include "contiki.h"
#include "node-id.h"
#include "net/rpl/rpl.h"
#include "rpl.h"
#include "rpl-dag-root.h"
#include "sys/log.h"
#include "net/ipv6/uip-ds6-route.h"
#include "net/mac/tsch/tsch.h"
#include "net/mac/tsch/tsch-log.h"
#include "net/mac/tsch/tsch-schedule.h"
#include "net/mac/tsch/sixtop/sixtop.h"
#include "net/rpl/rpl-private.h"
#include "net/ipv6/uip-debug.h"
#if UIP_CONF_IPV6_RPL_LITE == 0
#include "rpl-private.h"
#endif /* UIP_CONF_IPV6_RPL_LITE == 0 */
#include "sf-simple.h"
#define DEBUG DEBUG_PRINT
#include "net/ipv6/uip-debug.h"
/*---------------------------------------------------------------------------*/
PROCESS(node_process, "RPL Node");
AUTOSTART_PROCESSES(&node_process);
/*---------------------------------------------------------------------------*/
static void
net_init(uip_ipaddr_t *br_prefix)
{
uip_ipaddr_t global_ipaddr;
if(br_prefix) { /* We are RPL root. Will be set automatically
as TSCH pan coordinator via the tsch-rpl module */
memcpy(&global_ipaddr, br_prefix, 16);
uip_ds6_set_addr_iid(&global_ipaddr, &uip_lladdr);
uip_ds6_addr_add(&global_ipaddr, 0, ADDR_AUTOCONF);
rpl_set_root(RPL_DEFAULT_INSTANCE, &global_ipaddr);
rpl_set_prefix(rpl_get_any_dag(), br_prefix, 64);
rpl_repair_root(RPL_DEFAULT_INSTANCE);
}
NETSTACK_MAC.on();
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(node_process, ev, data)
{
int is_coordinator;
static int added_num_of_links = 0;
static struct etimer et;
struct tsch_neighbor *n;
PROCESS_BEGIN();
/* 3 possible roles:
* - role_6ln: simple node, will join any network, secured or not
* - role_6dr: DAG root, will advertise (unsecured) beacons
* - role_6dr_sec: DAG root, will advertise secured beacons
* */
static int is_coordinator = 0, added_num_of_links = 0;
static enum { role_6ln, role_6dr, role_6dr_sec } node_role;
node_role = role_6ln;
is_coordinator = 0;
/* Set node with MAC address c1:0c:00:00:00:00:01 as coordinator,
* convenient in cooja for regression tests using z1 nodes
* */
#ifdef CONTIKI_TARGET_Z1
extern unsigned char node_mac[8];
unsigned char coordinator_mac[8] = { 0xc1, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
if(memcmp(node_mac, coordinator_mac, 8) == 0) {
if(LLSEC802154_ENABLED) {
node_role = role_6dr_sec;
} else {
node_role = role_6dr;
}
} else {
node_role = role_6ln;
}
#if CONTIKI_TARGET_COOJA
is_coordinator = (node_id == 1);
#endif
tsch_set_pan_secured(LLSEC802154_ENABLED && (node_role == role_6dr_sec));
is_coordinator = node_role > role_6ln;
sixtop_add_sf(&sf_simple_driver);
if(is_coordinator) {
uip_ipaddr_t prefix;
uip_ip6addr(&prefix, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0);
net_init(&prefix);
} else {
net_init(NULL);
rpl_dag_root_init_dag_immediately();
}
NETSTACK_MAC.on();
sixtop_add_sf(&sf_simple_driver);
etimer_set(&et, CLOCK_SECOND * 30);
while(1) {
PROCESS_YIELD_UNTIL(etimer_expired(&et));
@ -127,8 +91,7 @@ PROCESS_THREAD(node_process, ev, data)
/* Get time-source neighbor */
n = tsch_queue_get_time_source();
if(node_id != 1) {
clock_delay(1000);
if(!is_coordinator) {
if((added_num_of_links == 1) || (added_num_of_links == 3)) {
printf("App : Add a link\n");
sf_simple_add_links(&n->addr, 1);

View File

@ -0,0 +1,157 @@
<?xml version="1.0" encoding="UTF-8"?>
<simconf>
<project EXPORT="discard">[APPS_DIR]/mrm</project>
<project EXPORT="discard">[APPS_DIR]/mspsim</project>
<project EXPORT="discard">[APPS_DIR]/avrora</project>
<project EXPORT="discard">[APPS_DIR]/serial_socket</project>
<project EXPORT="discard">[APPS_DIR]/collect-view</project>
<project EXPORT="discard">[APPS_DIR]/powertracker</project>
<simulation>
<title>sixtop example</title>
<randomseed>123456</randomseed>
<motedelay_us>1000000</motedelay_us>
<radiomedium>
org.contikios.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>
org.contikios.cooja.contikimote.ContikiMoteType
<identifier>mtype204</identifier>
<description>node</description>
<source>[CONTIKI_DIR]/examples/6tisch/sixtop/node-sixtop.c</source>
<commands>make node-sixtop.cooja TARGET=cooja</commands>
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.Battery</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiVib</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiMoteID</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRS232</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiBeeper</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiIPAddress</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRadio</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiButton</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiPIR</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiClock</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiLED</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiCFS</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiEEPROM</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface>
<symbols>false</symbols>
</motetype>
<mote>
<interface_config>
org.contikios.cooja.interfaces.Position
<x>11.419305725331853</x>
<y>88.17983927138442</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiMoteID
<id>1</id>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiRadio
<bitrate>250.0</bitrate>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiEEPROM
<eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom>
</interface_config>
<motetype_identifier>mtype204</motetype_identifier>
</mote>
<mote>
<interface_config>
org.contikios.cooja.interfaces.Position
<x>36.65377213719183</x>
<y>57.06132448464071</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiMoteID
<id>2</id>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiRadio
<bitrate>250.0</bitrate>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiEEPROM
<eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom>
</interface_config>
<motetype_identifier>mtype204</motetype_identifier>
</mote>
</simulation>
<plugin>
org.contikios.cooja.plugins.SimControl
<width>280</width>
<z>2</z>
<height>160</height>
<location_x>400</location_x>
<location_y>0</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.Visualizer
<plugin_config>
<moterelations>true</moterelations>
<skin>org.contikios.cooja.plugins.skins.IDVisualizerSkin</skin>
<skin>org.contikios.cooja.plugins.skins.GridVisualizerSkin</skin>
<skin>org.contikios.cooja.plugins.skins.TrafficVisualizerSkin</skin>
<skin>org.contikios.cooja.plugins.skins.UDGMVisualizerSkin</skin>
<viewport>4.580728081732807 0.0 0.0 4.580728081732807 74.39515112990499 -140.65513872038872</viewport>
</plugin_config>
<width>401</width>
<z>0</z>
<height>400</height>
<location_x>0</location_x>
<location_y>1</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.LogListener
<plugin_config>
<filter>sf-simple</filter>
<formatted_time />
<coloring />
</plugin_config>
<width>766</width>
<z>1</z>
<height>240</height>
<location_x>400</location_x>
<location_y>160</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.TimeLine
<plugin_config>
<mote>0</mote>
<mote>1</mote>
<showRadioRXTX />
<showRadioHW />
<showLEDs />
<zoomfactor>500.0</zoomfactor>
</plugin_config>
<width>1166</width>
<z>4</z>
<height>166</height>
<location_x>0</location_x>
<location_y>525</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.Notes
<plugin_config>
<notes>Enter notes here</notes>
<decorations>true</decorations>
</plugin_config>
<width>486</width>
<z>3</z>
<height>160</height>
<location_x>680</location_x>
<location_y>0</location_y>
</plugin>
</simconf>

View File

@ -198,7 +198,7 @@ add_response_sent_callback(void *arg, uint16_t arg_len,
(nbr = sixp_nbr_find(dest_addr)) != NULL) {
add_links_to_schedule(dest_addr, LINK_OPTION_RX,
cell_list, cell_list_len);
sixp_nbr_advance_grx(nbr);
sixp_nbr_advance_gen(nbr);
}
}
@ -222,7 +222,7 @@ delete_response_sent_callback(void *arg, uint16_t arg_len,
body, body_len) == 0 &&
(nbr = sixp_nbr_find(dest_addr)) != NULL) {
remove_links_to_schedule(cell_list, cell_list_len);
sixp_nbr_advance_grx(nbr);
sixp_nbr_advance_gen(nbr);
}
}
@ -429,7 +429,7 @@ response_input(sixp_pkt_rc_t rc,
PRINTF("\n");
add_links_to_schedule(peer_addr, LINK_OPTION_TX,
cell_list, cell_list_len);
sixp_nbr_advance_gtx(nbr);
sixp_nbr_advance_gen(nbr);
break;
case SIXP_PKT_CMD_DELETE:
if(sixp_pkt_get_cell_list(SIXP_PKT_TYPE_RESPONSE,
@ -443,9 +443,9 @@ response_input(sixp_pkt_rc_t rc,
print_cell_list(cell_list, cell_list_len);
PRINTF("\n");
remove_links_to_schedule(cell_list, cell_list_len);
sixp_nbr_advance_gtx(nbr);
sixp_nbr_advance_gen(nbr);
break;
case SIXP_PKT_CMD_STATUS:
case SIXP_PKT_CMD_COUNT:
case SIXP_PKT_CMD_LIST:
case SIXP_PKT_CMD_CLEAR:
default:

View File

@ -1,7 +1,7 @@
all: coap-example-server coap-example-client
# use target "plugtest-server" explicitly when required
CONTIKI=../../..
CONTIKI=../..
# automatically build RESTful resources
REST_RESOURCES_DIR = ./resources
@ -45,8 +45,8 @@ connect-router: $(CONTIKI)/tools/tunslip6
connect-router-cooja: $(CONTIKI)/tools/tunslip6
sudo $(CONTIKI)/tools/tunslip6 -a 127.0.0.1 -p 60001 fd00::1/64
connect-router-native: $(CONTIKI)/examples/ipv6/native-border-router/border-router.native
sudo $(CONTIKI)/exmples/ipv6/native-border-router/border-router.native -a 127.0.0.1 -p 60001 fd00::1/64
connect-router-native: $(CONTIKI)/examples/native-border-router/border-router.native
sudo $(CONTIKI)/examples/native-border-router/border-router.native -a 127.0.0.1 -p 60001 fd00::1/64
connect-minimal:
sudo ip address add fdfd::1/64 dev tap0

View File

@ -71,7 +71,7 @@ TMOTES HOWTO
2. Press reset button, get address, abort with Ctrl+C:
Line: "Tentative link-local IPv6 address fe80:0000:0000:0000:____:____:____:____"
cd ../ipv6/rpl-border-router/
cd ../rpl-border-router/
make TARGET=sky border-router.upload MOTE=1
make connect-router

View File

@ -48,9 +48,9 @@
org.contikios.cooja.mspmote.SkyMoteType
<identifier>server</identifier>
<description>Erbium Server</description>
<source EXPORT="discard">[CONTIKI_DIR]/examples/ipv6/coap-example/coap-example-server.c</source>
<source EXPORT="discard">[CONTIKI_DIR]/examples/coap-example/coap-example-server.c</source>
<commands EXPORT="discard">make coap-example-server.sky TARGET=sky</commands>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/ipv6/coap-example/coap-example-server.sky</firmware>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/coap-example/coap-example-server.sky</firmware>
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.IPAddress</moteinterface>
@ -71,9 +71,9 @@
org.contikios.cooja.mspmote.SkyMoteType
<identifier>client</identifier>
<description>Erbium Client</description>
<source EXPORT="discard">[CONTIKI_DIR]/examples/ipv6/coap-example/coap-example-client.c</source>
<source EXPORT="discard">[CONTIKI_DIR]/examples/coap-example/coap-example-client.c</source>
<commands EXPORT="discard">make coap-example-client.sky TARGET=sky</commands>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/ipv6/coap-example/coap-example-client.sky</firmware>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/coap-example/coap-example-client.sky</firmware>
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.IPAddress</moteinterface>

View File

@ -25,9 +25,9 @@
org.contikios.cooja.mspmote.SkyMoteType
<identifier>rplroot</identifier>
<description>Sky RPL Root</description>
<source EXPORT="discard">[CONTIKI_DIR]/examples/ipv6/rpl-border-router/border-router.c</source>
<source EXPORT="discard">[CONTIKI_DIR]/examples/rpl-border-router/border-router.c</source>
<commands EXPORT="discard">make border-router.sky TARGET=sky</commands>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/ipv6/rpl-border-router/border-router.sky</firmware>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/rpl-border-router/border-router.sky</firmware>
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.IPAddress</moteinterface>
@ -48,9 +48,9 @@
org.contikios.cooja.mspmote.SkyMoteType
<identifier>server</identifier>
<description>Erbium Server</description>
<source EXPORT="discard">[CONTIKI_DIR]/examples/ipv6/coap-example/coap-example-server.c</source>
<source EXPORT="discard">[CONTIKI_DIR]/examples/coap-example/coap-example-server.c</source>
<commands EXPORT="discard">make coap-example-server.sky TARGET=sky</commands>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/ipv6/coap-example/coap-example-server.sky</firmware>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/coap-example/coap-example-server.sky</firmware>
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.IPAddress</moteinterface>
@ -71,9 +71,9 @@
org.contikios.cooja.mspmote.SkyMoteType
<identifier>client</identifier>
<description>Erbium Client</description>
<source EXPORT="discard">[CONTIKI_DIR]/examples/ipv6/coap-example/coap-example-observe-client.c</source>
<source EXPORT="discard">[CONTIKI_DIR]/examples/coap-example/coap-example-observe-client.c</source>
<commands EXPORT="discard">make coap-example-observe-client.sky TARGET=sky</commands>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/ipv6/coap-example/coap-example-observe-client.sky</firmware>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/coap-example/coap-example-observe-client.sky</firmware>
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.IPAddress</moteinterface>

View File

@ -25,9 +25,9 @@
org.contikios.cooja.mspmote.SkyMoteType
<identifier>rplroot</identifier>
<description>Sky RPL Root</description>
<source EXPORT="discard">[CONTIKI_DIR]/examples/ipv6/rpl-border-router/border-router.c</source>
<source EXPORT="discard">[CONTIKI_DIR]/examples/rpl-border-router/border-router.c</source>
<commands EXPORT="discard">make border-router.sky TARGET=sky</commands>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/ipv6/rpl-border-router/border-router.sky</firmware>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/rpl-border-router/border-router.sky</firmware>
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.IPAddress</moteinterface>
@ -48,9 +48,9 @@
org.contikios.cooja.mspmote.SkyMoteType
<identifier>server</identifier>
<description>Erbium Server</description>
<source EXPORT="discard">[CONTIKI_DIR]/examples/ipv6/coap-example/coap-example-server.c</source>
<source EXPORT="discard">[CONTIKI_DIR]/examples/coap-example/coap-example-server.c</source>
<commands EXPORT="discard">make coap-example-server.sky TARGET=sky</commands>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/ipv6/coap-example/coap-example-server.sky</firmware>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/coap-example/coap-example-server.sky</firmware>
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.IPAddress</moteinterface>
@ -71,9 +71,9 @@
org.contikios.cooja.mspmote.SkyMoteType
<identifier>client</identifier>
<description>Erbium Client</description>
<source EXPORT="discard">[CONTIKI_DIR]/examples/ipv6/coap-example/coap-example-client.c</source>
<source EXPORT="discard">[CONTIKI_DIR]/examples/coap-example/coap-example-client.c</source>
<commands EXPORT="discard">make coap-example-client.sky TARGET=sky</commands>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/ipv6/coap-example/coap-example-client.sky</firmware>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/coap-example/coap-example-client.sky</firmware>
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.IPAddress</moteinterface>

View File

@ -25,9 +25,9 @@
org.contikios.cooja.mspmote.SkyMoteType
<identifier>rplroot</identifier>
<description>Sky RPL Root</description>
<source EXPORT="discard">[CONTIKI_DIR]/examples/ipv6/rpl-border-router/border-router.c</source>
<source EXPORT="discard">[CONTIKI_DIR]/examples/rpl-border-router/border-router.c</source>
<commands EXPORT="discard">make border-router.sky TARGET=sky</commands>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/ipv6/rpl-border-router/border-router.sky</firmware>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/rpl-border-router/border-router.sky</firmware>
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.IPAddress</moteinterface>
@ -48,9 +48,9 @@
org.contikios.cooja.mspmote.SkyMoteType
<identifier>server</identifier>
<description>Erbium Server</description>
<source EXPORT="discard">[CONTIKI_DIR]/examples/ipv6/coap-example/coap-example-server.c</source>
<source EXPORT="discard">[CONTIKI_DIR]/examples/coap-example/coap-example-server.c</source>
<commands EXPORT="discard">make coap-example-server.sky TARGET=sky</commands>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/ipv6/coap-example/coap-example-server.sky</firmware>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/coap-example/coap-example-server.sky</firmware>
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.IPAddress</moteinterface>

View File

@ -1,6 +0,0 @@
CONTIKI_PROJECT = extended-rf-api
all: $(CONTIKI_PROJECT)
CONTIKI = ../..
include $(CONTIKI)/Makefile.include

View File

@ -1,510 +0,0 @@
/*
* Copyright (c) 2014, George Oikonomou (george@contiki-os.org)
* 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 copyright holder 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 COPYRIGHT HOLDERS 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
* COPYRIGHT HOLDER 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.
*/
/**
* Example project demonstrating the extended RF API functionality
*/
#include "contiki.h"
#include "net/netstack.h"
#include "dev/radio.h"
#include <stdio.h>
#include <stdint.h>
#include <string.h>
/*---------------------------------------------------------------------------*/
struct rf_consts {
radio_value_t channel_min;
radio_value_t channel_max;
radio_value_t txpower_min;
radio_value_t txpower_max;
};
static struct rf_consts consts;
static radio_value_t value;
static uint8_t ext_addr[8];
/*---------------------------------------------------------------------------*/
PROCESS(extended_rf_api_process, "Extended RF API demo process");
AUTOSTART_PROCESSES(&extended_rf_api_process);
/*---------------------------------------------------------------------------*/
static void
print_64bit_addr(const uint8_t *addr)
{
unsigned int i;
for(i = 0; i < 7; i++) {
printf("%02x:", addr[i]);
}
printf("%02x (network order)\n", addr[7]);
}
/*---------------------------------------------------------------------------*/
static radio_result_t
get_object(radio_param_t param, void *dest, size_t size)
{
radio_result_t rv;
rv = NETSTACK_RADIO.get_object(param, dest, size);
switch(rv) {
case RADIO_RESULT_ERROR:
printf("Radio returned an error\n");
break;
case RADIO_RESULT_INVALID_VALUE:
printf("Value is invalid\n");
break;
case RADIO_RESULT_NOT_SUPPORTED:
printf("Param %u not supported\n", param);
break;
case RADIO_RESULT_OK:
break;
default:
printf("Unknown return value\n");
break;
}
return rv;
}
/*---------------------------------------------------------------------------*/
static radio_result_t
set_object(radio_param_t param, void *src, size_t size)
{
radio_result_t rv;
rv = NETSTACK_RADIO.set_object(param, src, size);
switch(rv) {
case RADIO_RESULT_ERROR:
printf("Radio returned an error\n");
break;
case RADIO_RESULT_INVALID_VALUE:
printf("Value is invalid\n");
break;
case RADIO_RESULT_NOT_SUPPORTED:
printf("Param %u not supported\n", param);
break;
case RADIO_RESULT_OK:
break;
default:
printf("Unknown return value\n");
break;
}
return rv;
}
/*---------------------------------------------------------------------------*/
static radio_result_t
get_param(radio_param_t param, radio_value_t *value)
{
radio_result_t rv;
rv = NETSTACK_RADIO.get_value(param, value);
switch(rv) {
case RADIO_RESULT_ERROR:
printf("Radio returned an error\n");
break;
case RADIO_RESULT_INVALID_VALUE:
printf("Value %d is invalid\n", *value);
break;
case RADIO_RESULT_NOT_SUPPORTED:
printf("Param %u not supported\n", param);
break;
case RADIO_RESULT_OK:
break;
default:
printf("Unknown return value\n");
break;
}
return rv;
}
/*---------------------------------------------------------------------------*/
static radio_result_t
set_param(radio_param_t param, radio_value_t value)
{
radio_result_t rv;
rv = NETSTACK_RADIO.set_value(param, value);
switch(rv) {
case RADIO_RESULT_ERROR:
printf("Radio returned an error\n");
break;
case RADIO_RESULT_INVALID_VALUE:
printf("Value %d is invalid\n", value);
break;
case RADIO_RESULT_NOT_SUPPORTED:
printf("Param %u not supported\n", param);
break;
case RADIO_RESULT_OK:
break;
default:
printf("Unknown return value\n");
break;
}
return rv;
}
/*---------------------------------------------------------------------------*/
static void
get_rf_consts(void)
{
printf("====================================\n");
printf("RF Constants\n");
printf("Min Channel : ");
if(get_param(RADIO_CONST_CHANNEL_MIN, &consts.channel_min) == RADIO_RESULT_OK) {
printf("%3d\n", consts.channel_min);
}
printf("Max Channel : ");
if(get_param(RADIO_CONST_CHANNEL_MAX, &consts.channel_max) == RADIO_RESULT_OK) {
printf("%3d\n", consts.channel_max);
}
printf("Min TX Power: ");
if(get_param(RADIO_CONST_TXPOWER_MIN, &consts.txpower_min) == RADIO_RESULT_OK) {
printf("%3d dBm\n", consts.txpower_min);
}
printf("Max TX Power: ");
if(get_param(RADIO_CONST_TXPOWER_MAX, &consts.txpower_max) == RADIO_RESULT_OK) {
printf("%3d dBm\n", consts.txpower_max);
}
}
/*---------------------------------------------------------------------------*/
static void
test_off_on(void)
{
printf("====================================\n");
printf("Power mode Test: Off, then On\n");
printf("Power mode is : ");
if(get_param(RADIO_PARAM_POWER_MODE, &value) == RADIO_RESULT_OK) {
if(value == RADIO_POWER_MODE_ON) {
printf("On\n");
} else if(value == RADIO_POWER_MODE_OFF) {
printf("Off\n");
}
}
printf("Turning Off : ");
value = RADIO_POWER_MODE_OFF;
set_param(RADIO_PARAM_POWER_MODE, value);
if(get_param(RADIO_PARAM_POWER_MODE, &value) == RADIO_RESULT_OK) {
if(value == RADIO_POWER_MODE_ON) {
printf("On\n");
} else if(value == RADIO_POWER_MODE_OFF) {
printf("Off\n");
}
}
printf("Turning On : ");
value = RADIO_POWER_MODE_ON;
set_param(RADIO_PARAM_POWER_MODE, value);
if(get_param(RADIO_PARAM_POWER_MODE, &value) == RADIO_RESULT_OK) {
if(value == RADIO_POWER_MODE_ON) {
printf("On\n");
} else if(value == RADIO_POWER_MODE_OFF) {
printf("Off\n");
}
}
}
/*---------------------------------------------------------------------------*/
static void
test_channels(void)
{
int i;
printf("====================================\n");
printf("Channel Test: [%u , %u]\n", consts.channel_min, consts.channel_max);
for(i = consts.channel_min; i <= consts.channel_max; i++) {
value = i;
printf("Switch to: %d, Now: ", value);
set_param(RADIO_PARAM_CHANNEL, value);
if(get_param(RADIO_PARAM_CHANNEL, &value) == RADIO_RESULT_OK) {
printf("%d\n", value);
}
}
}
/*---------------------------------------------------------------------------*/
static void
test_rx_modes(void)
{
int i;
printf("====================================\n");
printf("RX Modes Test: [0 , 3]\n");
for(i = 0; i <= 3; i++) {
value = i;
printf("Switch to: %d, Now: ", value);
set_param(RADIO_PARAM_RX_MODE, value);
if(get_param(RADIO_PARAM_RX_MODE, &value) == RADIO_RESULT_OK) {
printf("Address Filtering is ");
if(value & RADIO_RX_MODE_ADDRESS_FILTER) {
printf("On, ");
} else {
printf("Off, ");
}
printf("Auto ACK is ");
if(value & RADIO_RX_MODE_AUTOACK) {
printf("On, ");
} else {
printf("Off, ");
}
printf("(value=%d)\n", value);
}
}
}
/*---------------------------------------------------------------------------*/
static void
test_tx_powers(void)
{
int i;
printf("====================================\n");
printf("TX Power Test: [%d , %d]\n", consts.txpower_min, consts.txpower_max);
for(i = consts.txpower_min; i <= consts.txpower_max; i += 5) {
value = i;
printf("Switch to: %3d dBm, Now: ", value);
set_param(RADIO_PARAM_TXPOWER, value);
if(get_param(RADIO_PARAM_TXPOWER, &value) == RADIO_RESULT_OK) {
printf("%3d dBm\n", value);
}
}
}
/*---------------------------------------------------------------------------*/
static void
test_cca_thresholds(void)
{
printf("====================================\n");
printf("CCA Thres. Test: -105, then -81\n");
value = -105;
printf("Switch to: %4d dBm, Now: ", value);
set_param(RADIO_PARAM_CCA_THRESHOLD, value);
if(get_param(RADIO_PARAM_CCA_THRESHOLD, &value) == RADIO_RESULT_OK) {
printf("%4d dBm [0x%04x]\n", value, (uint16_t)value);
}
value = -81;
printf("Switch to: %4d dBm, Now: ", value);
set_param(RADIO_PARAM_CCA_THRESHOLD, value);
if(get_param(RADIO_PARAM_CCA_THRESHOLD, &value) == RADIO_RESULT_OK) {
printf("%4d dBm [0x%04x]\n", value, (uint16_t)value);
}
}
/*---------------------------------------------------------------------------*/
static void
test_pan_id(void)
{
radio_value_t new_val;
printf("====================================\n");
printf("PAN ID Test: Flip bytes and back\n");
printf("PAN ID is: ");
if(get_param(RADIO_PARAM_PAN_ID, &value) == RADIO_RESULT_OK) {
printf("0x%02x%02x\n", (value >> 8) & 0xFF, value & 0xFF);
}
new_val = (value >> 8) & 0xFF;
new_val |= (value & 0xFF) << 8;
printf("Switch to: 0x%02x%02x, Now: ", (new_val >> 8) & 0xFF, new_val & 0xFF);
set_param(RADIO_PARAM_PAN_ID, new_val);
if(get_param(RADIO_PARAM_PAN_ID, &value) == RADIO_RESULT_OK) {
printf("0x%02x%02x\n", (value >> 8) & 0xFF, value & 0xFF);
}
new_val = (value >> 8) & 0xFF;
new_val |= (value & 0xFF) << 8;
printf("Switch to: 0x%02x%02x, Now: ", (new_val >> 8) & 0xFF, new_val & 0xFF);
set_param(RADIO_PARAM_PAN_ID, new_val);
if(get_param(RADIO_PARAM_PAN_ID, &value) == RADIO_RESULT_OK) {
printf("0x%02x%02x\n", (value >> 8) & 0xFF, value & 0xFF);
}
}
/*---------------------------------------------------------------------------*/
static void
test_16bit_addr(void)
{
radio_value_t new_val;
printf("====================================\n");
printf("16-bit Address Test: Flip bytes and back\n");
printf("16-bit Address is: ");
if(get_param(RADIO_PARAM_16BIT_ADDR, &value) == RADIO_RESULT_OK) {
printf("0x%02x%02x\n", (value >> 8) & 0xFF, value & 0xFF);
}
new_val = (value >> 8) & 0xFF;
new_val |= (value & 0xFF) << 8;
printf("Switch to: 0x%02x%02x, Now: ", (new_val >> 8) & 0xFF, new_val & 0xFF);
set_param(RADIO_PARAM_16BIT_ADDR, new_val);
if(get_param(RADIO_PARAM_16BIT_ADDR, &value) == RADIO_RESULT_OK) {
printf("0x%02x%02x\n", (value >> 8) & 0xFF, value & 0xFF);
}
new_val = (value >> 8) & 0xFF;
new_val |= (value & 0xFF) << 8;
printf("Switch to: 0x%02x%02x, Now: ", (new_val >> 8) & 0xFF, new_val & 0xFF);
set_param(RADIO_PARAM_16BIT_ADDR, new_val);
if(get_param(RADIO_PARAM_16BIT_ADDR, &value) == RADIO_RESULT_OK) {
printf("0x%02x%02x\n", (value >> 8) & 0xFF, value & 0xFF);
}
}
/*---------------------------------------------------------------------------*/
static void
test_64bit_addr(void)
{
int i;
uint8_t new_val[8];
printf("====================================\n");
printf("64-bit Address Test: Invert byte order\n");
printf("64-bit Address is: ");
if(get_object(RADIO_PARAM_64BIT_ADDR, ext_addr, 8) == RADIO_RESULT_OK) {
print_64bit_addr(ext_addr);
}
for(i = 0; i <= 7; i++) {
new_val[7 - i] = ext_addr[i];
}
printf("Setting to : ");
print_64bit_addr(new_val);
printf("64-bit Address is: ");
set_object(RADIO_PARAM_64BIT_ADDR, new_val, 8);
if(get_object(RADIO_PARAM_64BIT_ADDR, ext_addr, 8) == RADIO_RESULT_OK) {
print_64bit_addr(ext_addr);
}
}
/*---------------------------------------------------------------------------*/
static void
print_rf_values(void)
{
printf("====================================\n");
printf("RF Values\n");
printf("Power: ");
if(get_param(RADIO_PARAM_POWER_MODE, &value) == RADIO_RESULT_OK) {
if(value == RADIO_POWER_MODE_ON) {
printf("On\n");
} else if(value == RADIO_POWER_MODE_OFF) {
printf("Off\n");
}
}
printf("Channel: ");
if(get_param(RADIO_PARAM_CHANNEL, &value) == RADIO_RESULT_OK) {
printf("%d\n", value);
}
printf("PAN ID: ");
if(get_param(RADIO_PARAM_PAN_ID, &value) == RADIO_RESULT_OK) {
printf("0x%02x%02x\n", (value >> 8) & 0xFF, value & 0xFF);
}
printf("16-bit Address: ");
if(get_param(RADIO_PARAM_16BIT_ADDR, &value) == RADIO_RESULT_OK) {
printf("0x%02x%02x\n", (value >> 8) & 0xFF, value & 0xFF);
}
printf("64-bit Address: ");
if(get_object(RADIO_PARAM_64BIT_ADDR, ext_addr, 8) == RADIO_RESULT_OK) {
print_64bit_addr(ext_addr);
}
printf("RX Mode: ");
if(get_param(RADIO_PARAM_RX_MODE, &value) == RADIO_RESULT_OK) {
printf("Address Filtering is ");
if(value & RADIO_RX_MODE_ADDRESS_FILTER) {
printf("On, ");
} else {
printf("Off, ");
}
printf("Auto ACK is ");
if(value & RADIO_RX_MODE_AUTOACK) {
printf("On, ");
} else {
printf("Off, ");
}
printf("(value=%d)\n", value);
}
printf("TX Mode: ");
if(get_param(RADIO_PARAM_TX_MODE, &value) == RADIO_RESULT_OK) {
printf("%d\n", value);
}
printf("TX Power: ");
if(get_param(RADIO_PARAM_TXPOWER, &value) == RADIO_RESULT_OK) {
printf("%d dBm [0x%04x]\n", value, (uint16_t)value);
}
printf("CCA Threshold: ");
if(get_param(RADIO_PARAM_CCA_THRESHOLD, &value) == RADIO_RESULT_OK) {
printf("%d dBm [0x%04x]\n", value, (uint16_t)value);
}
printf("RSSI: ");
if(get_param(RADIO_PARAM_RSSI, &value) == RADIO_RESULT_OK) {
printf("%d dBm [0x%04x]\n", value, (uint16_t)value);
}
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(extended_rf_api_process, ev, data)
{
PROCESS_BEGIN();
get_rf_consts();
print_rf_values();
test_off_on();
test_channels();
test_rx_modes();
test_tx_powers();
test_cca_thresholds();
test_pan_id();
test_16bit_addr();
test_64bit_addr();
printf("Done\n");
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View File

@ -1,6 +1,5 @@
all: http-example
all: http-example websocket-example
CONTIKI=../..
MODULES += os/net/app-layer/http-socket
MAKE_ROUTING = MAKE_ROUTING_RPL_CLASSIC
include $(CONTIKI)/Makefile.include

View File

@ -21,5 +21,5 @@ connect-router: $(CONTIKI)/tools/tunslip6
connect-router-cooja: $(CONTIKI)/tools/tunslip6
sudo $(CONTIKI)/tools/tunslip6 -a 127.0.0.1 -p 60001 aaaa::1/64
connect-router-native: $(CONTIKI)/examples/ipv6/native-border-router/border-router.native
sudo $(CONTIKI)/exmples/ipv6/native-border-router/border-router.native -a 127.0.0.1 -p 60001 aaaa::1/64
connect-router-native: $(CONTIKI)/examples/native-border-router/border-router.native
sudo $(CONTIKI)/examples/native-border-router/border-router.native -a 127.0.0.1 -p 60001 aaaa::1/64

View File

@ -48,10 +48,6 @@
#include "dev/serial-line.h"
#include "serial-protocol.h"
#if CONTIKI_TARGET_WISMOTE
#include "dev/uart1.h"
#endif
#define DEBUG DEBUG_PRINT
#include "net/ipv6/uip-debug.h"
@ -219,11 +215,6 @@ setup_network(void)
int i;
uint8_t state;
#if CONTIKI_TARGET_WISMOTE
uart1_set_input(serial_line_input_byte);
serial_line_init();
#endif
#if UIP_CONF_ROUTER
/**
* The choice of server address determines its 6LoWPAN header compression.

View File

@ -1,24 +0,0 @@
CONTIKI=../../..
PROJECT_SOURCEFILES += json-ws.c
ifdef WITH_COSM
CFLAGS += -DWITH_COSM=1
endif
ifdef WITH_UDP
CFLAGS += -DWITH_UDP=1
PROJECT_SOURCEFILES += json-ws-udp.c
endif
MODULES += os/lib/json os/net/app-layer/httpd-ws
ifeq ($(TARGET),)
-include Makefile.target
endif
ifneq ($(TARGET),)
all: websense-$(TARGET)
endif
include $(CONTIKI)/Makefile.include

View File

@ -1,109 +0,0 @@
JSON ws
=======
Short description on how to set-up a sensor network for global IPv6 addresses.
NOTE: this assumes that you do not have a native IPv6 connection.
You will need:
- PC with Ubuntu (Linux) - 11 or 12 versions
- A node for the RPL-Border-Router (examples/ipv6/rpl-border-router)
- A node for the json webservice (examples/ipv6/json-ws)
Set-up IPv6 tunnel and Border Router
------------------------------------
1. Ensure that you have gogo6c installed.
sudo apt-get install gogoc
2. Register an account at gogo6 and Freenet6 (http://www.gogo6.com).
The account at Freenet6 is needed by the gogo6c client.
3. Edit the gogoc.conf and set your own Freenet6 user and password by
changing the lines with "userid" and "passwd".
4. Start gogoc at command line
cd contiki/examples/ipv6/json-ws
sudo gogoc -f gogoc.conf -n
This will print your prefix - TSP_PREFIX. In my case
TSP_PREFIX=2001:05c0:1517:e400 (prefixlen is 56).
5. Connect one of the nodes to the PC (via USB or serial) and program
it with the RPL-border-router (assumes Z1 node).
cd contiki/examples/ipv6/rpl-border-router
make DEFINES=DEFINES=NETSTACK_RDC=nullrdc_driver,CSMA_CONF_802154_AUTOACK=1 TARGET=z1 border-router.upload
6. Run tunslip6 which will forward IP from the RPL network to the IPv6 tunnel
(and to the Internet).
cd contiki/examples/ipv6/rpl-border-router
make connect-router PREFIX=<TSP_PREFIX>::1/64
When you start this you should get a printout from the border-router
which give you the IPv6 address of it.
Server IPv6 addresses:
2001:05c0:1517:e400:c30c::10a
fe80::c30c:0:0:10a
7. Browse using Mozilla Firefox (or any other browser) to the IPv6 address
given by the border router. This will show you the list of other nodes
connected to the RPL network.
http://[2001:05c0:1517:e400:c30c::10a]/
NOTE: this is a global IPv6 address so it should also be reachable from
any machine on the Internet.
Configuration of COSM submission
--------------------------------
1. Register a COSM account at https://cosm.com/
Set-up a feed and create an API key for the feed.
2. Program the sensor node with (assumes Z1)
cd contiki/examples/ipv6/json-ws
make websense-z1.upload WITH_COSM=1 TARGET=z1
3. Check the IPv6 address of the node via the RPL-border router or by looking
at printouts when booting (make login TARGET=z1)
4. You need to configure the node to push data to the COSM feed and this can be
done in several ways. For convenience a Python script is included that
pushes the configuration to the nodes.
Edit the file 'setcosm.py' and replace "<your-key>" and "<your-feed>" with
your COSM API key and COSM feed id. You can then use this Python script to
configure your nodes.
This is an example that configures the node with IP address
2001:05c0:1517:e400:c30c::10b to push data to the COSM feed with stream 1:
cd contiki/examples/ipv6/json-ws
./setcosm.py [2001:05c0:1517:e400:c30c::10b] 1
Another way to configure the nodes is to use a REST add-on for the web
browser to post a COSM configuration to the node. "REST Client" for Mozilla
Firefox is an example of such add-on.
POST a JSON expression to your node with the following data: This assumes
that you have the feed with id 55180 and want to post to stream 1 in that
feed. The field 'appdata' should be set to the API key you created at the
COSM web site for the feed.
{
"host":"[2001:470:1f10:333::2]",
"port":80,
"path":"/v2/feeds/55180/datastreams/1",
"appdata":"<insert your COSM API key>",
"interval":120,
"proto":"cosm"
}
This will configure the node to periodically push temperature data every
other minute. You can use GET to retrieve the data to se that the node has
been successfully configured (the COSM API key will be visualized as a
number of stars).

View File

@ -1,351 +0,0 @@
#-----------------------------------------------------------------------------
# $Id: gogoc.conf.in,v 1.1 2009/11/20 16:53:12 jasminko Exp $
#-----------------------------------------------------------------------------
########################## READ ME! ################################
#
# Welcome to the gogoCLIENT configuration file.
# In order to use the client, you need to modify the 'userid', 'passwd' and
# 'server' parameters below depending on which of these situations applies:
#
# 1. If you created a Freenet6 account, enter your userid and password below.
# Change the server name to "broker.freenet6.net" and auth_method to 'any'.
# 2. If you would like to use Freenet6 without creating an account,
# do not make any modifications and close this file.
# 3. If this software was provided by your ISP, enter the userid, password and
# server name provided by your ISP below.
#
########################## BASIC CONFIGURATION ################################
#
# User Identification and Password:
# Specify your user name and password as provided by your ISP or Freenet6.
# If you plan to connect anonymously, leave these values empty.
# NOTE: Change auth_method option if you are using a username/password.
#
# userid=<your_userid>
# passwd=<your_password>
#
userid=<change to your userid>
passwd=<change to your password>
#
# gogoSERVER:
# Specify a gogoSERVER name or IP address (provided by your ISP or
# Freenet6). An optional port number can be added; the default port number
# is 3653.
#
# Examples:
# server=hostname # FQDN
# server=A.B.C.D # IPv4 address
# server=[X:X::X:X] # IPv6 address
# server=hostname:port_number
# server=A.B.C.D:port_number
# server=[X:X::X:X]:port_number
#
# Freenet6 account holders should enter authenticated.freenet6.net,
# otherwise use anonymous.freenet6.net.
# Your ISP may provide you with a different server name.
#
#server=anonymous.freenet6.net
#server=authenticated.freenet6.net
server=amsterdam.freenet6.net
#
# Authentication Method:
#
# auth_method=<{anonymous}|{any|passdss-3des-1|digest-md5|plain}>
#
# anonymous: Sends no username or password
#
# any: The most secure method will be used.
# passdss-3des-1: The password is sent encrypted.
# digest-md5: The password is sent encrypted.
# plain: Both username and password are sent as plain text.
#
# Recommended values:
# - any: If you are authenticating a username / password.
# - anonymous: If you are connecting anonymously.
#
#auth_method=anonymous
auth_method=any
########################## ROUTING CONFIGURATION ##############################
# Use these parameters when you wish the client to act as a router and provide
# IPv6 connectivity to IPv6-capable devices on your network.
#
# Local Host Type:
# Change this value to 'router' to enable IPv6 advertisements.
#
# host_type=<host|router>
#
host_type=router
#host
#
# Prefix Length:
# Length of the requested prefix. Valid values range between 0 and 64 when
# using V6*V4 tunnel modes, and between 0 and 32 when using V4V6 tunnel mode.
#
# prefixlen=<integer>
#
prefixlen=64
#
# Advertisement Interface Prefix:
# Name of the interface that will be configured to send router advertisements.
# This is an interface index on Windows (ex: 4) and a name on Linux
# and BSD (ex: eth1 or fxp1).
#
# if_prefix=<interface name>
#
if_prefix=tun0
#
# DNS Server:
# A DNS server list to which the reverse prefix will be delegated. Servers
# are separated by the colon(:) delimiter.
#
# Example: dns_server=ns1.domain:ns2.domain:ns3.domain
#
dns_server=
######################### ADVANCED CONFIGURATION ##############################
#
# gogoCLIENT Installation Directory:
# Directory where the gogoCLIENT will be installed. This value has been
# set during installation.
#
gogoc_dir=
#
# Auto-Retry Connect, Retry Delay and Max Retry Delay:
# When auto_retry_connect=yes, the gogoCLIENT will attempt to reconnect
# after a disconnection occurred. The time to wait is 'retry_delay' and that
# delay is doubled at every 3 failed consecutive reconnection attempt.
# However, the wait delay will never exceed retry_delay_max.
#
#
# auto_retry_connect=<yes|no>
# retry_delay=<integer: 0..3600>
# retry_delay_max=<integer: 0..3600>
#
# Recommended values: "yes", 30, 300
#
auto_retry_connect=yes
retry_delay=30
retry_delay_max=300
#
# Keepalive Feature and Message Interval:
# Indicates if and how often the client will send data to keep the tunnel
# active.
#
# keepalive=<yes|no>
# keepalive_interval=<integer>
#
# Recommended values: "yes" and 30
#
keepalive=yes
keepalive_interval=30
#
# Tunnel Encapsulation Mode:
# v6v4: IPv6-in-IPv4 tunnel.
# v6udpv4: IPv6-in-UDP-in-IPv4 tunnel (for clients behind a NAT).
# v6anyv4: Lets the broker choose the best mode for IPv6 tunnel.
# v4v6: IPv4-in-IPv6 tunnel.
#
# Recommended value: v6anyv4
#
tunnel_mode=v6anyv4
#
# Tunnel Interface Name:
# The interface name assigned to the tunnel. This value is O/S dependent.
#
# if_tunnel_v6v4 is the tunnel interface name for v6v4 encapsulation mode
# if_tunnel_v6udpv4 is the tunnel interface name for v6udpv4 encapsulate mode
# if_tunnel_v4v6 is the tunnel interface name for v4v6 encapsulation mode
#
# Default values are set during installation.
#
if_tunnel_v6v4=sit1
if_tunnel_v6udpv4=sit
if_tunnel_v4v6=sit0
#
# Local IP Address of the Client:
# Allows you to set a specific address as the local tunnel endpoint.
#
# client_v4=<auto|A.B.C.D (valid ipv4 address)>
# client_v6=<auto|X:X::X:X (valid ipv6 address)>
# auto: The gogoCLIENT will find the local IP address endpoint.
#
# Recommended value: auto
#
client_v4=auto
client_v6=auto
#
# Script Name:
# File name of the script to run to install the tunnel interface. The
# scripts are located in the template directory under the client
# installation directory.
#
# template=<checktunnel|freebsd|netbsd|openbsd|linux|windows|darwin|cisco|solaris>
#
# Default value is set during installation.
#
template=linux
#
# Proxy client:
# Indicates that this client will request a tunnel for another endpoint,
# such as a Cisco router.
#
# proxy_client=<yes|no>
#
# NOTE: NAT traversal is not possible in proxy mode.
#
proxy_client=no
############################ BROKER REDIRECTION ###############################
#
# Broker List File Name:
# The 'broker_list' directive specifies the filename where the broker
# list received during broker redirection will be saved.
#
# broker_list=<file_name>
#
broker_list=/var/lib/gogoc/tsp-broker-list.txt
#
# Last Server Used File Name:
# The 'last_server' directive specifies the filename where the address of
# the last broker to which a connection was successfully established will
# be saved.
#
# last_server=<file_name>
#
last_server=/var/lib/gogoc/tsp-last-server.txt
#
# Always Use Last Known Working Server:
# The value of the 'always_use_same_server' directive determines whether the
# client should always try to connect to the broker found in the
# 'last_server' directive filename.
#
# always_use_same_server=<yes|no>
#
always_use_same_server=no
#################################### LOGGING ##################################
#
# Log Verbosity Configuration:
# The format is 'log_<destination>=level', where possible values for
# 'destination' are:
#
# - console (logging to the console [AKA stdout])
# - stderr (logging to standard error)
# - file (logging to a file)
# - syslog (logging to syslog [Unix only])
#
# and 'level' is a digit between 0 and 3. A 'level' value of 0 disables
# logging to the destination, while values 1 to 3 request increasing levels
# of log verbosity and detail. If 'level' is not specified, a value of 1 is
# assumed.
#
# Example:
# log_file=3 (Maximal logging to a file)
# log_stderr=0 (Logging to standard error disabled)
# log_console= (Minimal logging to the console)
#
# - Default configuration on Windows platforms:
#
# log_console=0
# log_stderr=0
# log_file=1
#
# - Default configuration on Unix platforms:
#
# log_console=0
# log_stderr=1
# log_file=0
# log_syslog=0
#
log_console=3
log_stderr=0
#log_file=
#log_syslog=
#
# Log File Name:
# When logging to file is requested using the 'log_file' directive, the name
# and path of the file to use may be specified using this directive.
#
# log_filename=<file_name>
#
log_filename=/var/log/gogoc/gogoc.log
#
# Log File Rotation:
# When logging to file is requested using the 'log_file' directive, log file
# rotation may be enabled. When enabled, the contents of the log file will
# be moved to a backup file just before it reaches the maximum log file size
# specified via this directive.
#
# The name of the backup file is the name of the original log file with
# '.<timestamp>' inserted before the file extension. If the file does not
# have an extension, '.<timestamp>' is appended to the name of the original
# log file. The timestamp specifies when the rotation occurred.
#
# After the contents of the log file have been moved to the backup file, the
# original file is cleared, and logging resumes at the beginning of the file.
#
# log_rotation=<yes|no>
#
log_rotation=yes
#
# Log File Rotation Size:
# The 'log_rotation_size' directive specifies the maximum size a log file may
# reach before rotation occurs, if enabled. The value is expressed in
# kilobytes.
#
# log_rotation_size=<16|32|128|1024>
#
log_rotation_size=32
#
# Deletion of rotated log files:
# The 'log_rotation_delete' directive specifies that no log backup will be
# kept. When rotation occurs, the file is immediately wiped out and a new
# log file is started.
#
# log_rotation_delete=<yes|no>
#
log_rotation_delete=no
#
# Syslog Logging Facility [Unix Only]:
# When logging to syslog is requested using the 'log_syslog' directive, the
# facility to use may be specified using this directive.
#
# syslog_facility=<USER|LOCAL[0-7]>
#
syslog_facility=USER
# end of gogoc.conf
#------------------------------------------------------------------------------

View File

@ -1,151 +0,0 @@
/*
* Copyright (c) 2011-2012, 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.
*
*/
/**
* \file
* Code for sending the JSON data as a UDP packet
* Specify proto = "udp", port = <server-udp-port>
* host = <ipv6-server-address>
*
* \author
* Niclas Finne <nfi@sics.se>
* Joakim Eriksson <joakime@sics.se>
*/
#include "contiki.h"
#include "httpd-ws.h"
#include "jsontree.h"
#include "jsonparse.h"
#include "json-ws.h"
#include <stdio.h>
#include <string.h>
#define DEBUG DEBUG_FULL
#include "net/ipv6/uip-debug.h"
static struct uip_udp_conn *client_conn;
static uip_ipaddr_t server_ipaddr;
static uint16_t server_port;
#define SENDER_PORT 8181
/*---------------------------------------------------------------------------*/
int
json_ws_udp_setup(const char *host, uint16_t port)
{
server_port = port;
if(client_conn != NULL) {
/* this should be a macro uip_udp_conn_free() or something */
uip_udp_remove(client_conn);
client_conn = NULL;
}
uip_ipaddr_t *ipaddr;
/* First check if the host is an IP address. */
ipaddr = &server_ipaddr;
if(uiplib_ipaddrconv(host, &server_ipaddr) == 0) {
#if 0 && UIP_UDP
if(resolv_lookup(host, &ipaddr) != RESOLV_STATUS_CACHED) {
return 0;
}
#else /* UIP_UDP */
return 0;
#endif /* UIP_UDP */
}
/* new connection with remote host */
client_conn = udp_new(&server_ipaddr, UIP_HTONS(server_port), NULL);
udp_bind(client_conn, UIP_HTONS(SENDER_PORT));
PRINTF("Created a connection with the server ");
PRINT6ADDR(&client_conn->ripaddr);
PRINTF(" local/remote port %u/%u\n",
UIP_HTONS(client_conn->lport), UIP_HTONS(client_conn->rport));
return 1;
}
/*---------------------------------------------------------------------------*/
static char *udp_buf;
static int pos;
static int size;
static int
putchar_udp(int c)
{
if(udp_buf != NULL && pos <= size) {
udp_buf[pos++] = c;
return c;
}
return 0;
}
/*---------------------------------------------------------------------------*/
void
json_ws_udp_send(struct jsontree_value *tree, const char *path)
{
struct jsontree_context json;
/* maxsize = 70 bytes */
char buf[70];
udp_buf = buf;
/* reset state and set max-size */
/* NOTE: packet will be truncated at 70 bytes */
pos = 0;
size = sizeof(buf);
json.values[0] = (struct json_value *)tree;
jsontree_reset(&json);
find_json_path(&json, path);
json.path = json.depth;
json.putchar = putchar_udp;
while(jsontree_print_next(&json) && json.path <= json.depth);
printf("Real UDP size: %d\n", pos);
buf[pos] = 0;
uip_udp_packet_sendto(client_conn, &buf, pos,
&server_ipaddr, UIP_HTONS(server_port));
}
/*---------------------------------------------------------------------------*/
void
json_ws_udp_debug(char *string)
{
int len;
len = strlen(string);
uip_udp_packet_sendto(client_conn, string, len,
&server_ipaddr, UIP_HTONS(server_port));
}
/*---------------------------------------------------------------------------*/

View File

@ -1,521 +0,0 @@
/*
* Copyright (c) 2011-2012, 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.
*/
/**
* \file
* JSON webservice util
* \author
* Niclas Finne <nfi@sics.se>
* Joakim Eriksson <joakime@sics.se>
* Joel Hoglund <joel@sics.se>
*/
#include "contiki.h"
#if PLATFORM_HAS_LEDS
#include "dev/leds.h"
#endif
#include "httpd-ws.h"
#include "jsontree.h"
#include "jsonparse.h"
#include "json-ws.h"
#include <stdio.h>
#include <string.h>
#define DEBUG 0
#if DEBUG
#define PRINTF(...) printf(__VA_ARGS__)
#else
#define PRINTF(...)
#endif
#ifdef JSON_WS_CONF_CALLBACK_PROTO
#define CALLBACK_PROTO JSON_WS_CONF_CALLBACK_PROTO
#else
#define CALLBACK_PROTO "http"
#endif /* JSON_WS_CONF_CALLBACK_PROTO */
#ifdef JSON_WS_CONF_CALLBACK_PORT
#define CALLBACK_PORT JSON_WS_CONF_CALLBACK_PORT
#else
#define CALLBACK_PORT 8080;
#endif /* JSON_WS_CONF_CALLBACK_PORT */
/* Predefined startup-send interval */
#ifdef JSON_WS_CONF_CALLBACK_INTERVAL
#define SEND_INTERVAL JSON_WS_CONF_CALLBACK_INTERVAL
#else
#define SEND_INTERVAL 120
#endif
static const char http_content_type_json[] = "application/json";
/* Maximum 40 chars in host name?: 5 x 8 */
static char callback_host[40] = "[fd00::1]";
static uint16_t callback_port = CALLBACK_PORT;
static uint16_t callback_interval = SEND_INTERVAL;
static char callback_path[80] = "/debug/";
static char callback_appdata[80] = "";
static char callback_proto[8] = CALLBACK_PROTO;
static const char *callback_json_path = NULL;
static struct jsontree_object *tree;
static struct ctimer periodic_timer;
long json_time_offset = 0;
/* support for submitting to cosm */
#if WITH_COSM
extern struct jsontree_callback cosm_value_callback;
JSONTREE_OBJECT_EXT(cosm_tree,
JSONTREE_PAIR("current_value", &cosm_value_callback));
#endif /* WITH_COSM */
static void periodic(void *ptr);
/*---------------------------------------------------------------------------*/
static void
json_copy_string(struct jsonparse_state *parser, char *string, int len)
{
jsonparse_next(parser);
jsonparse_next(parser);
jsonparse_copy_value(parser, string, len);
}
/*---------------------------------------------------------------------------*/
static int
cfg_get(struct jsontree_context *js_ctx)
{
const char *path = jsontree_path_name(js_ctx, js_ctx->depth - 1);
if(strncmp(path, "host", 4) == 0) {
jsontree_write_string(js_ctx, callback_host);
} else if(strncmp(path, "port", 4) == 0) {
jsontree_write_int(js_ctx, callback_port);
} else if(strncmp(path, "interval", 8) == 0) {
jsontree_write_int(js_ctx, callback_interval);
} else if(strncmp(path, "path", 4) == 0) {
jsontree_write_string(js_ctx, callback_path);
} else if(strncmp(path, "appdata", 7) == 0) {
jsontree_write_string(js_ctx, callback_appdata[0] == '\0' ? "" : "***");
} else if(strncmp(path, "proto", 5) == 0) {
jsontree_write_string(js_ctx, callback_proto);
}
return 0;
}
static int
cfg_set(struct jsontree_context *js_ctx, struct jsonparse_state *parser)
{
int type;
int update = 0;
while((type = jsonparse_next(parser)) != 0) {
if(type == JSON_TYPE_PAIR_NAME) {
if(jsonparse_strcmp_value(parser, "host") == 0) {
json_copy_string(parser, callback_host, sizeof(callback_host));
update++;
} else if(jsonparse_strcmp_value(parser, "path") == 0) {
json_copy_string(parser, callback_path, sizeof(callback_path));
update++;
} else if(jsonparse_strcmp_value(parser, "appdata") == 0) {
json_copy_string(parser, callback_appdata, sizeof(callback_appdata));
update++;
} else if(jsonparse_strcmp_value(parser, "proto") == 0) {
json_copy_string(parser, callback_proto, sizeof(callback_proto));
update++;
} else if(jsonparse_strcmp_value(parser, "port") == 0) {
jsonparse_next(parser);
jsonparse_next(parser);
callback_port = jsonparse_get_value_as_int(parser);
if(callback_port == 0) {
callback_port = CALLBACK_PORT;
}
update++;
} else if(jsonparse_strcmp_value(parser, "interval") == 0) {
jsonparse_next(parser);
jsonparse_next(parser);
callback_interval = jsonparse_get_value_as_int(parser);
if(callback_interval == 0) {
callback_interval = SEND_INTERVAL;
}
update++;
}
}
}
if(update && callback_json_path != NULL) {
#if WITH_UDP
if(strncmp(callback_proto, "udp", 3) == 0) {
json_ws_udp_setup(callback_host, callback_port);
}
#endif
ctimer_set(&periodic_timer, CLOCK_SECOND * callback_interval,
periodic, NULL);
}
return 0;
}
static struct jsontree_callback cfg_callback =
JSONTREE_CALLBACK(cfg_get, cfg_set);
JSONTREE_OBJECT_EXT(json_subscribe_callback,
JSONTREE_PAIR("host", &cfg_callback),
JSONTREE_PAIR("port", &cfg_callback),
JSONTREE_PAIR("path", &cfg_callback),
JSONTREE_PAIR("appdata", &cfg_callback),
JSONTREE_PAIR("proto", &cfg_callback),
JSONTREE_PAIR("interval", &cfg_callback));
/*---------------------------------------------------------------------------*/
static int
time_get(struct jsontree_context *js_ctx)
{
/* unix time */
char buf[20];
unsigned long time = json_time_offset + clock_seconds();
snprintf(buf, 20, "%lu", time);
jsontree_write_atom(js_ctx, buf);
return 0;
}
static int
time_set(struct jsontree_context *js_ctx, struct jsonparse_state *parser)
{
int type;
unsigned long time;
while((type = jsonparse_next(parser)) != 0) {
if(type == JSON_TYPE_PAIR_NAME) {
if(jsonparse_strcmp_value(parser, "time") == 0) {
jsonparse_next(parser);
jsonparse_next(parser);
time = jsonparse_get_value_as_long(parser);
json_time_offset = time - clock_seconds();
}
}
}
return 0;
}
struct jsontree_callback json_time_callback =
JSONTREE_CALLBACK(time_get, time_set);
/*---------------------------------------------------------------------------*/
#if PLATFORM_HAS_LEDS
#include "dev/leds.h"
static int
ws_leds_get(struct jsontree_context *js_ctx)
{
char buf[4];
unsigned char leds = leds_get();
snprintf(buf, 4, "%u", leds);
jsontree_write_atom(js_ctx, buf);
return 0;
}
static int
ws_leds_set(struct jsontree_context *js_ctx, struct jsonparse_state *parser)
{
int type, old_leds, new_leds;
while((type = jsonparse_next(parser)) != 0) {
if(type == JSON_TYPE_PAIR_NAME) {
if(jsonparse_strcmp_value(parser, "leds") == 0) {
jsonparse_next(parser);
jsonparse_next(parser);
new_leds = jsonparse_get_value_as_int(parser);
old_leds = leds_get();
leds_on(~old_leds & new_leds);
leds_off(old_leds & ~new_leds);
}
}
}
return 0;
}
struct jsontree_callback json_leds_callback =
JSONTREE_CALLBACK(ws_leds_get, ws_leds_set);
#endif /* PLATFORM_HAS_LEDS */
/*---------------------------------------------------------------------------*/
static struct httpd_ws_state *json_putchar_context;
static int
json_putchar(int c)
{
if(json_putchar_context != NULL &&
json_putchar_context->outbuf_pos < HTTPD_OUTBUF_SIZE) {
json_putchar_context->outbuf[json_putchar_context->outbuf_pos++] = c;
return c;
}
return 0;
}
static int putchar_size = 0;
static int
json_putchar_count(int c)
{
putchar_size++;
return c;
}
/*---------------------------------------------------------------------------*/
static
PT_THREAD(send_values(struct httpd_ws_state *s))
{
json_putchar_context = s;
PSOCK_BEGIN(&s->sout);
s->json.putchar = json_putchar;
s->outbuf_pos = 0;
if(s->json.values[0] == NULL) {
/* Nothing to do */
} else if(s->request_type == HTTPD_WS_POST &&
s->state == HTTPD_WS_STATE_OUTPUT) {
/* Set value */
struct jsontree_value *v;
struct jsontree_callback *c;
while((v = jsontree_find_next(&s->json, JSON_TYPE_CALLBACK)) != NULL) {
c = (struct jsontree_callback *)v;
if(c->set != NULL) {
struct jsonparse_state js;
jsonparse_setup(&js, s->inputbuf, s->content_len);
c->set(&s->json, &js);
}
}
memcpy(s->outbuf, "{\"Status\":\"OK\"}", 15);
s->outbuf_pos = 15;
} else {
/* Get value */
while(jsontree_print_next(&s->json) && s->json.path <= s->json.depth) {
if(s->outbuf_pos >= UIP_TCP_MSS) {
SEND_STRING(&s->sout, s->outbuf, UIP_TCP_MSS);
s->outbuf_pos -= UIP_TCP_MSS;
if(s->outbuf_pos > 0) {
memcpy(s->outbuf, &s->outbuf[UIP_TCP_MSS], s->outbuf_pos);
}
}
}
}
if(s->outbuf_pos > 0) {
SEND_STRING(&s->sout, s->outbuf, s->outbuf_pos);
s->outbuf_pos = 0;
}
PSOCK_END(&s->sout);
}
/*---------------------------------------------------------------------------*/
struct jsontree_value *
find_json_path(struct jsontree_context *json, const char *path)
{
struct jsontree_value *v;
const char *start;
const char *end;
int len;
v = json->values[0];
start = path;
do {
end = strchr(start, '/');
if(end == start) {
break;
}
if(end != NULL) {
len = end - start;
end++;
} else {
len = strlen(start);
}
if(v->type != JSON_TYPE_OBJECT) {
v = NULL;
} else {
struct jsontree_object *o;
int i;
o = (struct jsontree_object *)v;
v = NULL;
for(i = 0; i < o->count; i++) {
if(strncmp(start, o->pairs[i].name, len) == 0) {
v = o->pairs[i].value;
json->index[json->depth] = i;
json->depth++;
json->values[json->depth] = v;
json->index[json->depth] = 0;
break;
}
}
}
start = end;
} while(end != NULL && *end != '\0' && v != NULL);
json->callback_state = 0;
return v;
}
/*---------------------------------------------------------------------------*/
static int
calculate_json_size(const char *path, struct jsontree_value *v)
{
/* check size of JSON expression */
struct jsontree_context json;
json.values[0] = (v == NULL) ? (struct jsontree_value *)tree : v;
jsontree_reset(&json);
if(path != NULL) {
find_json_path(&json, path);
}
json.path = json.depth;
json.putchar = json_putchar_count;
putchar_size = 0;
while(jsontree_print_next(&json) && json.path <= json.depth);
return putchar_size;
}
/*---------------------------------------------------------------------------*/
httpd_ws_script_t
httpd_ws_get_script(struct httpd_ws_state *s)
{
struct jsontree_value *v;
s->json.values[0] = v = (struct jsontree_value *)tree;
jsontree_reset(&s->json);
if(s->filename[1] == '\0') {
/* Default page: show full JSON tree. */
} else {
v = find_json_path(&s->json, &s->filename[1]);
}
if(v != NULL) {
s->json.path = s->json.depth;
s->content_type = http_content_type_json;
return send_values;
}
return NULL;
}
/*---------------------------------------------------------------------------*/
#if JSON_POST_EXTRA_HEADER || WITH_COSM
static int
output_headers(struct httpd_ws_state *s, char *buffer, int buffer_size,
int index)
{
if(index == 0) {
#ifdef JSON_POST_EXTRA_HEADER
return snprintf(buffer, buffer_size, "%s\r\n", JSON_POST_EXTRA_HEADER);
} else if(index == 1) {
#endif
#if WITH_COSM
if(strncmp(callback_proto, "cosm", 4) == 0 && callback_appdata[0] != '\0') {
return snprintf(buffer, buffer_size, "X-PachubeApiKey:%s\r\n",
callback_appdata);
}
#endif
}
return 0;
}
#endif /* JSON_POST_EXTRA_HEADER || WITH_COSM */
/*---------------------------------------------------------------------------*/
static void
periodic(void *ptr)
{
struct httpd_ws_state *s;
int callback_size;
if(callback_json_path != NULL && strlen(callback_host) > 2) {
ctimer_restart(&periodic_timer);
if(strncmp(callback_proto, "http", 4) == 0) {
callback_size = calculate_json_size(callback_json_path, NULL);
s = httpd_ws_request(HTTPD_WS_POST, callback_host, NULL, callback_port,
callback_path, http_content_type_json,
callback_size, send_values);
if(s != NULL) {
PRINTF("PERIODIC POST %s\n", callback_json_path);
#if JSON_POST_EXTRA_HEADER
s->output_extra_headers = output_headers;
#endif
s->json.values[0] = (struct jsontree_value *)tree;
jsontree_reset(&s->json);
find_json_path(&s->json, callback_json_path);
s->json.path = s->json.depth;
} else {
PRINTF("PERIODIC CALLBACK FAILED\n");
}
#if WITH_COSM
} else if(strncmp(callback_proto, "cosm", 4) == 0) {
callback_size = calculate_json_size(NULL, (struct jsontree_value *)
&cosm_tree);
/* printf("JSON Size:%d\n", callback_size); */
s = httpd_ws_request(HTTPD_WS_PUT, callback_host, "api.pachube.com",
callback_port, callback_path,
http_content_type_json, callback_size, send_values);
/* host = cosm host */
/* path => path to datastream / data point */
s->output_extra_headers = output_headers;
s->json.values[0] = (struct jsontree_value *)&cosm_tree;
jsontree_reset(&s->json);
s->json.path = 0;
PRINTF("PERIODIC cosm callback: %d\n", callback_size);
#endif /* WITH_COSM */
}
#if WITH_UDP
else {
callback_size = calculate_json_size(callback_json_path, NULL);
PRINTF("PERIODIC UDP size: %d\n", callback_size);
json_ws_udp_send(tree, callback_json_path);
}
#endif /* WITH_UDP */
} else {
printf("PERIODIC CALLBACK - nothing todo\n");
}
}
/*---------------------------------------------------------------------------*/
void
json_ws_init(struct jsontree_object *json)
{
PRINTF("JSON INIT (callback %s every %u seconds)\n",
CALLBACK_PROTO, SEND_INTERVAL);
tree = json;
ctimer_set(&periodic_timer, CLOCK_SECOND * SEND_INTERVAL, periodic, NULL);
process_start(&httpd_ws_process, NULL);
#if WITH_UDP
if(strncmp(callback_proto, "udp", 3) == 0) {
json_ws_udp_setup(callback_host, callback_port);
}
#endif /* WITH_UDP */
}
/*---------------------------------------------------------------------------*/
void
json_ws_set_callback(const char *path)
{
callback_json_path = path;
ctimer_restart(&periodic_timer);
}
/*---------------------------------------------------------------------------*/

View File

@ -1,58 +0,0 @@
/*
* Copyright (c) 2011-2012, 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.
*/
/**
* \file
* JSON webservice util
* \author
* Niclas Finne <nfi@sics.se>
* Joakim Eriksson <joakime@sics.se>
* Joel Hoglund <joel@sics.se>
*/
#ifndef JSON_WS_H_
#define JSON_WS_H_
#include "jsontree.h"
void json_ws_init(struct jsontree_object *json);
void json_ws_set_callback(const char *json_path);
int json_ws_udp_setup(const char *host, uint16_t port);
extern struct jsontree_object json_subscribe_callback;
extern struct jsontree_callback json_time_callback;
#if PLATFORM_HAS_LEDS
extern struct jsontree_callback json_leds_callback;
#endif
extern struct jsontree_object cosm_tree;
#endif /* JSON_WS_H_ */

View File

@ -1,30 +0,0 @@
#!/usr/bin/python
# python set time code
import httplib,sys
# edit the key and feed parameters to match your COSM account and feed
key = "<your-key>"
feed = "<your-feed>"
cosmaddr = "[2001:470:1f10:333::2]"
print "JSON-WS COSM configuration utility\n Currently set to COSM feed: %s Key: '%s'" % (feed, key)
if len(sys.argv) > 2:
host = sys.argv[1]
stream = sys.argv[2]
else:
print "Usage: ", sys.argv[0], "<host> <feed-id>"
sys.exit()
print "Setting cosm config at:", host, " feed:", feed, " stream:",stream
conn = httplib.HTTPConnection(host)
# NAT64 address =
#conn.request("POST","", '{"host":"[2001:778:0:ffff:64:0:d834:e97a]","port":80,"path":"/v2/feeds/55180/datastreams/1","interval":120}')
requestData = '{"host":"%s","port":80,"path":"/v2/feeds/%s/datastreams/%s","appdata":"%s","interval":120,"proto":"cosm"}' % (cosmaddr, feed, stream, key)
print "Posting to node: ", requestData
conn.request("POST","", requestData)
res = conn.getresponse()
print res.status, res.reason

View File

@ -1,130 +0,0 @@
/*
* Copyright (c) 2011-2012, 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.
*/
/**
* \file
* Websense for Sky mote
* \author
* Niclas Finne <nfi@sics.se>
* Joakim Eriksson <joakime@sics.se>
* Joel Hoglund <joel@sics.se>
*/
#include "contiki.h"
#include "dev/leds.h"
#include "dev/sht11/sht11-sensor.h"
#include "jsontree.h"
#include "json-ws.h"
#include <stdio.h>
#define DEBUG 0
#if DEBUG
#define PRINTF(...) printf(__VA_ARGS__)
#else
#define PRINTF(...)
#endif
PROCESS(websense_process, "Websense (sky)");
AUTOSTART_PROCESSES(&websense_process);
/*---------------------------------------------------------------------------*/
static CC_INLINE int
get_temp(void)
{
return ((sht11_sensor.value(SHT11_SENSOR_TEMP) / 10) - 396) / 10;
}
/*---------------------------------------------------------------------------*/
static int
output_temp(struct jsontree_context *path)
{
char buf[5];
snprintf(buf, sizeof(buf), "%3d", get_temp());
jsontree_write_atom(path, buf);
return 0;
}
static struct jsontree_callback temp_sensor_callback =
JSONTREE_CALLBACK(output_temp, NULL);
/*---------------------------------------------------------------------------*/
static struct jsontree_string desc = JSONTREE_STRING("Tmote Sky");
static struct jsontree_string temp_unit = JSONTREE_STRING("Celcius");
JSONTREE_OBJECT(node_tree,
JSONTREE_PAIR("node-type", &desc),
JSONTREE_PAIR("time", &json_time_callback));
JSONTREE_OBJECT(temp_sensor_tree,
JSONTREE_PAIR("unit", &temp_unit),
JSONTREE_PAIR("value", &temp_sensor_callback));
JSONTREE_OBJECT(rsc_tree,
JSONTREE_PAIR("temperature", &temp_sensor_tree),
JSONTREE_PAIR("leds", &json_leds_callback));
/* complete node tree */
JSONTREE_OBJECT(tree,
JSONTREE_PAIR("node", &node_tree),
JSONTREE_PAIR("rsc", &rsc_tree),
JSONTREE_PAIR("cfg", &json_subscribe_callback));
/*---------------------------------------------------------------------------*/
/* for cosm plugin */
#if WITH_COSM
/* set COSM value callback to be the temp sensor */
struct jsontree_callback cosm_value_callback =
JSONTREE_CALLBACK(output_temp, NULL);
#endif
PROCESS_THREAD(websense_process, ev, data)
{
static struct etimer timer;
PROCESS_BEGIN();
json_ws_init(&tree);
SENSORS_ACTIVATE(sht11_sensor);
json_ws_set_callback("rsc");
while(1) {
/* Alive indication with the LED */
etimer_set(&timer, CLOCK_SECOND * 5);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&timer));
leds_on(LEDS_RED);
etimer_set(&timer, CLOCK_SECOND / 8);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&timer));
leds_off(LEDS_RED);
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View File

@ -1,24 +0,0 @@
CONTIKI_PROJECT=border-router
all: $(CONTIKI_PROJECT)
MODULES += os/services/slip-cmd
CONTIKI=../../..
PROJECT_SOURCEFILES += border-router-cmds.c tun-bridge.c border-router-mac.c \
slip-config.c slip-dev.c
WITH_WEBSERVER=1
ifeq ($(WITH_WEBSERVER),1)
CFLAGS += -DWEBSERVER=1
PROJECT_SOURCEFILES += httpd-simple.c
else ifneq ($(WITH_WEBSERVER), 0)
MODULES += $(WITH_WEBSERVER)
CFLAGS += -DWEBSERVER=2
endif
MAKE_MAC = MAKE_MAC_OTHER
MAKE_NET = MAKE_NET_IPV6
include $(CONTIKI)/Makefile.include
connect-router: border-router.native
sudo ./border-router.native fd00::1/64

View File

@ -1,12 +0,0 @@
all: packet-debug ../rpl-udp/udp-server
CONTIKI=../../..
ifdef SERVER_REPLY
CFLAGS+=-DSERVER_REPLY=$(SERVER_REPLY)
endif
ifdef PERIOD
CFLAGS+=-DPERIOD=$(PERIOD)
endif
CONTIKI_WITH_IPV6 = 1
include $(CONTIKI)/Makefile.include

View File

@ -1,173 +0,0 @@
/*
* 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.
*
*
*/
#include "contiki.h"
#include "lib/random.h"
#include "sys/ctimer.h"
#include "net/ipv6/uip.h"
#include "net/ipv6/uip-ds6.h"
#include "net/ipv6/uip-udp-packet.h"
#include "sys/ctimer.h"
#include "rpl.h"
#include "net/ipv6/uipbuf.h"
#include <stdio.h>
#include <string.h>
#include "dev/serial-line.h"
#include "net/ipv6/uip-ds6-route.h"
#define UDP_CLIENT_PORT 8765
#define UDP_SERVER_PORT 5678
#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
#define DEBUG DEBUG_FULL
#include "net/ipv6/uip-debug.h"
#ifndef PERIOD
#define PERIOD 60
#endif
#define START_INTERVAL (15 * CLOCK_SECOND)
#define SEND_INTERVAL (PERIOD * CLOCK_SECOND)
#define SEND_TIME (random_rand() % (SEND_INTERVAL))
#define MAX_PAYLOAD_LEN 30
static struct uip_udp_conn *client_conn;
/*---------------------------------------------------------------------------*/
PROCESS(udp_client_process, "UDP client process");
AUTOSTART_PROCESSES(&udp_client_process);
/*---------------------------------------------------------------------------*/
static int seq_id;
static int reply;
static void
tcpip_handler(void)
{
if(uip_newdata()) {
reply++;
}
}
/*---------------------------------------------------------------------------*/
static void
send_packet(void *ptr)
{
char buf[MAX_PAYLOAD_LEN];
rpl_dag_t *dag;
seq_id++;
sprintf(buf, "Hello %d from the client", seq_id);
dag = rpl_get_any_dag();
if(dag != NULL) {
uip_udp_packet_sendto(client_conn, buf, strlen(buf),
&dag->dag_id, UIP_HTONS(UDP_SERVER_PORT));
} else {
PRINTF("Have not joined any DAG yet - could not send\n");
}
}
/*---------------------------------------------------------------------------*/
static enum netstack_ip_action
ip_input(void)
{
uint8_t proto = 0;
uipbuf_get_last_header(uip_buf, uip_len, &proto);
PRINTF("Incoming packet proto: %d from ", proto);
PRINT6ADDR(&UIP_IP_BUF->srcipaddr);
PRINTF("\n");
return NETSTACK_IP_PROCESS;
}
static enum netstack_ip_action
ip_output(const linkaddr_t *localdest)
{
uint8_t proto;
uint8_t is_me = 0;
uipbuf_get_last_header(uip_buf, uip_len, &proto);
is_me = uip_ds6_is_my_addr(&UIP_IP_BUF->srcipaddr);
PRINTF("%s packet proto: %d to ", is_me ? "Send" : "Fwd ", proto);
PRINT6ADDR(&UIP_IP_BUF->destipaddr);
PRINTF("\n");
if(is_me && proto == UIP_PROTO_UDP) {
/* fake server-ip address here - just to emulate the UDP-example */
PRINTF("DATA send to %d 'Hello %d'\n", 1, seq_id);
}
return NETSTACK_IP_PROCESS;
}
struct netstack_ip_packet_processor packet_processor = {
.process_input = ip_input,
.process_output = ip_output
};
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(udp_client_process, ev, data)
{
static struct etimer periodic;
static struct ctimer backoff_timer;
PROCESS_BEGIN();
PROCESS_PAUSE();
PRINTF("UDP client process started nbr:%d routes:%d\n",
NBR_TABLE_CONF_MAX_NEIGHBORS, NETSTACK_MAX_ROUTE_ENTRIES);
/* new connection with remote host */
client_conn = udp_new(NULL, UIP_HTONS(UDP_SERVER_PORT), NULL);
if(client_conn == NULL) {
PRINTF("No UDP connection available, exiting the process!\n");
PROCESS_EXIT();
}
udp_bind(client_conn, UIP_HTONS(UDP_CLIENT_PORT));
PRINTF("Created a connection with the server ");
PRINT6ADDR(&client_conn->ripaddr);
PRINTF(" local/remote port %u/%u\n",
UIP_HTONS(client_conn->lport), UIP_HTONS(client_conn->rport));
/* register packet processor */
netstack_ip_packet_processor_add(&packet_processor);
etimer_set(&periodic, SEND_INTERVAL);
while(1) {
PROCESS_YIELD();
if(ev == tcpip_event) {
tcpip_handler();
}
if(etimer_expired(&periodic)) {
etimer_reset(&periodic);
ctimer_set(&backoff_timer, SEND_TIME, send_packet, NULL);
}
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View File

@ -1,711 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<simconf>
<project EXPORT="discard">[APPS_DIR]/mrm</project>
<project EXPORT="discard">[APPS_DIR]/mspsim</project>
<project EXPORT="discard">[APPS_DIR]/avrora</project>
<project EXPORT="discard">[APPS_DIR]/serial_socket</project>
<project EXPORT="discard">[APPS_DIR]/collect-view</project>
<project EXPORT="discard">[APPS_DIR]/powertracker</project>
<simulation>
<title>Data collection network using IPv6 and RPL</title>
<randomseed>generated</randomseed>
<motedelay_us>5000000</motedelay_us>
<radiomedium>
org.contikios.cooja.radiomediums.UDGM
<transmitting_range>50.0</transmitting_range>
<interference_range>50.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>
org.contikios.cooja.mspmote.SkyMoteType
<identifier>sky1</identifier>
<description>Sky Mote Type #sky1</description>
<source EXPORT="discard">[CONTIKI_DIR]/examples/ipv6/rpl-udp/udp-server.c</source>
<commands EXPORT="discard">make clean udp-server.sky TARGET=sky DEFINES=TEST_MORE_ROUTES=1</commands>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/ipv6/rpl-udp/udp-server.sky</firmware>
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.IPAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspClock</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspMoteID</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyButton</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyFlash</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyCoffeeFilesystem</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.Msp802154Radio</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspSerial</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyLED</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspDebugOutput</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyTemperature</moteinterface>
</motetype>
<motetype>
org.contikios.cooja.mspmote.SkyMoteType
<identifier>sky2</identifier>
<description>Sky Mote Type #sky2</description>
<source EXPORT="discard">[CONTIKI_DIR]/examples/ipv6/packet-processing/packet-debug.c</source>
<commands EXPORT="discard">make clean packet-debug.sky TARGET=sky</commands>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/ipv6/packet-processing/packet-debug.sky</firmware>
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.IPAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspClock</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspMoteID</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyButton</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyFlash</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyCoffeeFilesystem</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.Msp802154Radio</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspSerial</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyLED</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspDebugOutput</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyTemperature</moteinterface>
</motetype>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>48.435974731198804</x>
<y>-66.16503914182063</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>1</id>
</interface_config>
<motetype_identifier>sky1</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>4.049356309774755</x>
<y>98.28771308774003</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>2</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>127.9689727848476</x>
<y>91.71883780610729</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>3</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>57.897299848739024</x>
<y>92.47229665488265</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>4</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>47.34887596588397</x>
<y>-30.341495695501195</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>5</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>47.13486576528276</x>
<y>32.944481932122315</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>6</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-11.42091423859419</x>
<y>17.879870626121914</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>7</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>118.92746659954325</x>
<y>57.05973076244069</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>8</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>53.68872892015448</x>
<y>59.887319605093715</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>9</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>16.45706316609417</x>
<y>23.9075414163248</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>10</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-18.9555027263478</x>
<y>75.14274313304935</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>11</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>29.265863595275306</x>
<y>85.6911670159044</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>12</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-39.298891643282545</x>
<y>-3.9704359883635574</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>13</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>66.93880603404335</x>
<y>-42.39683727590697</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>14</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>94.81678343873172</x>
<y>26.921376811426246</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>15</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-43.06618588715935</x>
<y>30.68867105530305</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>16</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-34.02467970185502</x>
<y>-24.313824905298304</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>17</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-28.750467760427494</x>
<y>48.01822457713635</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>18</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>124.95513738974614</x>
<y>20.140247172447996</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>19</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>15.703604317318808</x>
<y>-47.6710492173345</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>20</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-40.05235049205791</x>
<y>92.47229665488265</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>21</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>121.18784314586934</x>
<y>-24.313824905298304</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>22</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>88.03565379975346</x>
<y>-44.657213822233054</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>23</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>24.745110502623138</x>
<y>-1.7100594420374744</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>24</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>94.06332458995635</x>
<y>-2.4635182908128352</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>25</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-4.639784599615941</x>
<y>-9.998106778566445</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>26</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-13.681290784920272</x>
<y>-50.684884612435944</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>27</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>103.10483077526068</x>
<y>96.99304974753483</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>28</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>8.922474678340558</x>
<y>59.320107308766765</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>29</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>58.650758697514384</x>
<y>2.8106936506146916</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>30</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>90.59867707439</x>
<y>67.97632874312737</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>31</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
</simulation>
<plugin>
org.contikios.cooja.plugins.SimControl
<width>259</width>
<z>3</z>
<height>184</height>
<location_x>3</location_x>
<location_y>15</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.Visualizer
<plugin_config>
<skin>org.contikios.cooja.plugins.skins.IDVisualizerSkin</skin>
<skin>org.contikios.cooja.plugins.skins.UDGMVisualizerSkin</skin>
<skin>org.contikios.cooja.plugins.skins.AttributeVisualizerSkin</skin>
<viewport>2.349818846983307 0.0 0.0 2.349818846983307 150.19773526533348 176.95275613586946</viewport>
</plugin_config>
<width>520</width>
<z>2</z>
<height>523</height>
<location_x>14</location_x>
<location_y>210</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.LogListener
<plugin_config>
<filter />
<formatted_time />
<coloring />
</plugin_config>
<width>937</width>
<z>0</z>
<height>213</height>
<location_x>265</location_x>
<location_y>16</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.ScriptRunner
<plugin_config>
<script>TIMEOUT(12000000, log.log("Total PRR " + totalPRR + "\n"));
packetsReceived= new Array();
packetsSent = new Array();
serverID = 1;
nodeCount = 31;
totalPRR = 0;
for(i = 0; i &lt;= nodeCount; i++) {
packetsReceived[i] = 0;
packetsSent[i] = 0;
}
while(1) {
YIELD();
msgArray = msg.split(' ');
if(msgArray[0].equals("DATA")) {
if(msgArray.length == 9) {
// Received packet
senderID = parseInt(msgArray[8]);
packetsReceived[senderID]++;
log.log("SenderID " + senderID + " PRR " + packetsReceived[senderID] / packetsSent[senderID] + "\n");
totalReceived = totalSent = 0;
for(i = serverID + 1; i &lt;= nodeCount; i++) {
totalReceived += packetsReceived[i];
totalSent += packetsSent[i];
}
totalPRR = totalReceived / totalSent;
log.log("Total PRR " + totalPRR + " recv " + totalReceived + " sent " + totalSent + "\n");
} else if(msgArray.length == 6) {
// Sent packet
packetsSent[id]++;
}
}
}</script>
<active>true</active>
</plugin_config>
<width>651</width>
<z>1</z>
<height>550</height>
<location_x>547</location_x>
<location_y>181</location_y>
</plugin>
</simconf>

View File

@ -1,39 +0,0 @@
CONTIKI_PROJECT=border-router
all: $(CONTIKI_PROJECT)
CONTIKI=../../..
PROJECT_SOURCEFILES += slip-bridge.c
#Simple built-in webserver is the default.
#Override with make WITH_WEBSERVER=0 for no webserver.
#WITH_WEBSERVER=module-path will use the module if it can be found
#make clean before changing webservers!
#Note /apps/webserver contains a 2500 byte style sheet which is a severe test
#of the slip connection. Large MSS together with low baud rates without flow
#control will overrun the transmit buffer when the style sheet is requested.
WITH_WEBSERVER=1
ifeq ($(WITH_WEBSERVER),1)
CFLAGS += -DWEBSERVER=1
PROJECT_SOURCEFILES += httpd-simple.c
else ifneq ($(WITH_WEBSERVER), 0)
MODULES += $(WITH_WEBSERVER)
CFLAGS += -DWEBSERVER=2
endif
ifeq ($(PREFIX),)
PREFIX = fd00::1/64
endif
include $(CONTIKI)/Makefile.include
$(CONTIKI)/tools/tunslip6: $(CONTIKI)/tools/tunslip6.c
(cd $(CONTIKI)/tools && $(MAKE) tunslip6)
connect-router: $(CONTIKI)/tools/tunslip6
sudo $(CONTIKI)/tools/tunslip6 $(PREFIX)
connect-router-cooja: $(CONTIKI)/tools/tunslip6
sudo $(CONTIKI)/tools/tunslip6 -a 127.0.0.1 $(PREFIX)

View File

@ -1,7 +0,0 @@
all: node
CONTIKI=../../..
# Set MAKE_MAC = MAKE_MAC_TSCH to run TSCH instead
MAKE_MAC = MAKE_MAC_CSMA
include $(CONTIKI)/Makefile.include

View File

@ -1,170 +0,0 @@
/*
* 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.
*
*/
#include "contiki.h"
#include "lib/random.h"
#include "sys/ctimer.h"
#include "net/ipv6/uip.h"
#include "net/ipv6/uip-ds6.h"
#include "net/ipv6/uip-udp-packet.h"
#include "rpl.h"
#include "rpl-dag-root.h"
#include "node-id.h"
#include "simple-udp.h"
#include "sys/ctimer.h"
#include <stdio.h>
#include <string.h>
#include "dev/serial-line.h"
#include "net/ipv6/uip-ds6-route.h"
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "App"
#define LOG_LEVEL LOG_LEVEL_INFO
#define UDP_PORT 8765
#define START_INTERVAL (5 * CLOCK_SECOND)
#define SEND_INTERVAL (30 * CLOCK_SECOND)
static struct simple_udp_connection udp_conn;
static uip_ipaddr_t node_ipaddr;
static uip_ipaddr_t root_ipaddr;
static uip_ipaddr_t destination_ipaddr;
/*---------------------------------------------------------------------------*/
PROCESS(node_process, "RPL Simple Process");
AUTOSTART_PROCESSES(&node_process);
/*---------------------------------------------------------------------------*/
static void
receiver(struct simple_udp_connection *c,
const uip_ipaddr_t *sender_addr,
uint16_t sender_port,
const uip_ipaddr_t *receiver_addr,
uint16_t receiver_port,
const uint8_t *data,
uint16_t datalen)
{
unsigned seq_id;
memcpy(&seq_id, data, sizeof(int));
if(uip_ip6addr_cmp(&destination_ipaddr, &node_ipaddr)) {
LOG_INFO("received request %u from ", seq_id);
LOG_INFO_6ADDR(sender_addr);
LOG_INFO_("\n");
LOG_INFO("sending reply %u to ", seq_id);
LOG_INFO_6ADDR(sender_addr);
LOG_INFO_("\n");
simple_udp_sendto(&udp_conn, &seq_id, sizeof(seq_id), sender_addr);
} else {
static unsigned reply_count = 0;
reply_count++;
LOG_INFO("received reply %u (%u/%u) from ", seq_id, reply_count, seq_id);
LOG_INFO_6ADDR(sender_addr);
LOG_INFO_("\n");
}
}
/*---------------------------------------------------------------------------*/
static void
send_packet(void *ptr)
{
if(rpl_is_reachable()) {
static unsigned seq_id = 0;
LOG_INFO("sending request %u to ", ++seq_id);
LOG_INFO_6ADDR(&destination_ipaddr);
LOG_INFO_("\n");
simple_udp_sendto(&udp_conn, &seq_id, sizeof(seq_id), &destination_ipaddr);
} else {
LOG_INFO("not connected yet\n");
}
}
/*---------------------------------------------------------------------------*/
static void
get_global_address(void)
{
int i;
uint8_t state;
for(i = 0; i < UIP_DS6_ADDR_NB; i++) {
state = uip_ds6_if.addr_list[i].state;
if(uip_ds6_if.addr_list[i].isused &&
state == ADDR_PREFERRED &&
!uip_is_addr_linklocal(&uip_ds6_if.addr_list[i].ipaddr)) {
uip_ip6addr_copy(&node_ipaddr, &uip_ds6_if.addr_list[i].ipaddr);
}
}
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(node_process, ev, data)
{
static struct etimer periodic;
static struct ctimer backoff_timer;
PROCESS_BEGIN();
/* Hardcoded IPv6 addresses */
uip_ip6addr(&root_ipaddr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0x0212, 0x7401, 0x0001, 0x0101);
uip_ip6addr(&destination_ipaddr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0x0212, 0x7401, 0x0001, 0x0101);
rpl_dag_root_init(NULL, NULL);
get_global_address();
/* Configure root */
if(uip_ip6addr_cmp(&root_ipaddr, &node_ipaddr)) {
rpl_dag_root_init_dag_immediately();
}
/* New connection with remote host */
simple_udp_register(&udp_conn, UDP_PORT, NULL, UDP_PORT, receiver);
/* Wait for START_INTERVAL */
etimer_set(&periodic, START_INTERVAL);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&periodic));
#if MAC_CONF_WITH_TSCH
NETSTACK_MAC.on();
#endif /* MAC_CONF_WITH_TSCH */
if(!uip_ip6addr_cmp(&destination_ipaddr, &node_ipaddr)) {
/* Send data periodically */
etimer_set(&periodic, SEND_INTERVAL);
while(1) {
PROCESS_YIELD();
if(etimer_expired(&periodic)) {
etimer_reset(&periodic);
ctimer_set(&backoff_timer, random_rand() % (SEND_INTERVAL), send_packet, NULL);
}
}
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View File

@ -1,52 +0,0 @@
/*
* Copyright (c) 2015, 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.
*/
#ifndef PROJECT_CONF_H_
#define PROJECT_CONF_H_
/* Network size and PAN-ID */
#define NBR_TABLE_CONF_MAX_NEIGHBORS 25
#define NETSTACK_MAX_ROUTE_ENTRIES 25
#define IEEE802154_CONF_PANID 0xf123
/* Save some space */
#define SICSLOWPAN_CONF_FRAG 0
/* Do not start TSCH at init, wait for NETSTACK_MAC.on() */
#define TSCH_CONF_AUTOSTART 0
/* 6TiSCH minimal schedule length.
* Larger values result in less frequent active slots: reduces capacity and saves energy. */
#define TSCH_SCHEDULE_CONF_DEFAULT_LENGTH 3
#define TSCH_SCHEDULE_CONF_MAX_LINKS 4
#endif

View File

@ -1,148 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<simconf>
<project EXPORT="discard">[APPS_DIR]/mrm</project>
<project EXPORT="discard">[APPS_DIR]/mspsim</project>
<project EXPORT="discard">[APPS_DIR]/avrora</project>
<project EXPORT="discard">[APPS_DIR]/serial_socket</project>
<project EXPORT="discard">[APPS_DIR]/collect-view</project>
<project EXPORT="discard">[APPS_DIR]/powertracker</project>
<simulation>
<title>Simple RPL Example</title>
<randomseed>generated</randomseed>
<motedelay_us>5000000</motedelay_us>
<radiomedium>
org.contikios.cooja.radiomediums.UDGM
<transmitting_range>50.0</transmitting_range>
<interference_range>50.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>
org.contikios.cooja.mspmote.SkyMoteType
<identifier>sky2</identifier>
<description>Sky Mote Type #sky2</description>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/ipv6/rpl-simple/node.sky</firmware>
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.IPAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspClock</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspMoteID</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyButton</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyFlash</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyCoffeeFilesystem</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.Msp802154Radio</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspSerial</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyLED</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspDebugOutput</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyTemperature</moteinterface>
</motetype>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>48.435974731198804</x>
<y>-66.16503914182063</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>1</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>28.87281458333398</x>
<y>-21.744318674852618</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>2</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
</simulation>
<plugin>
org.contikios.cooja.plugins.SimControl
<width>185</width>
<z>2</z>
<height>154</height>
<location_x>1651</location_x>
<location_y>778</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.Visualizer
<plugin_config>
<skin>org.contikios.cooja.plugins.skins.IDVisualizerSkin</skin>
<skin>org.contikios.cooja.plugins.skins.UDGMVisualizerSkin</skin>
<skin>org.contikios.cooja.plugins.skins.AttributeVisualizerSkin</skin>
<viewport>1.260147830790386 0.0 0.0 1.260147830790386 105.5104655860535 140.74330745981246</viewport>
</plugin_config>
<width>258</width>
<z>1</z>
<height>309</height>
<location_x>1573</location_x>
<location_y>11</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.LogListener
<plugin_config>
<filter />
<formatted_time />
<coloring />
</plugin_config>
<width>854</width>
<z>3</z>
<height>919</height>
<location_x>5</location_x>
<location_y>2</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.TimeLine
<plugin_config>
<mote>0</mote>
<mote>1</mote>
<showRadioRXTX />
<showRadioHW />
<showLEDs />
<zoomfactor>2736.9736958636</zoomfactor>
</plugin_config>
<width>1858</width>
<z>4</z>
<height>223</height>
<location_x>0</location_x>
<location_y>931</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.RadioLogger
<plugin_config>
<split>477</split>
<formatted_time />
<showdups>false</showdups>
<hidenodests>false</hidenodests>
<analyzers name="6lowpan" />
</plugin_config>
<width>874</width>
<z>0</z>
<height>917</height>
<location_x>857</location_x>
<location_y>10</location_y>
</plugin>
</simconf>

View File

@ -1,160 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<simconf>
<project EXPORT="discard">[APPS_DIR]/mrm</project>
<project EXPORT="discard">[APPS_DIR]/mspsim</project>
<project EXPORT="discard">[APPS_DIR]/avrora</project>
<project EXPORT="discard">[APPS_DIR]/serial_socket</project>
<project EXPORT="discard">[APPS_DIR]/collect-view</project>
<project EXPORT="discard">[APPS_DIR]/powertracker</project>
<simulation>
<title>My simulation</title>
<randomseed>123456</randomseed>
<motedelay_us>1000000</motedelay_us>
<radiomedium>
org.contikios.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>
org.contikios.cooja.mspmote.Z1MoteType
<identifier>z11</identifier>
<description>Z1 Mote Type #z11</description>
<source EXPORT="discard">[CONTIKI_DIR]/examples/ipv6/rpl-tsch-sixtop/node-sixtop.c</source>
<commands EXPORT="discard">make node-sixtop.z1 TARGET=z1</commands>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/ipv6/rpl-tsch-sixtop/node-sixtop.z1</firmware>
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.IPAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspClock</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspMoteID</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspButton</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.Msp802154Radio</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspDefaultSerial</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspLED</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspDebugOutput</moteinterface>
</motetype>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>3.827476552301217</x>
<y>2.167129170680247</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>1</id>
</interface_config>
<motetype_identifier>z11</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>30.278379737463556</x>
<y>17.799585117738026</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>2</id>
</interface_config>
<motetype_identifier>z11</motetype_identifier>
</mote>
</simulation>
<plugin>
org.contikios.cooja.plugins.SimControl
<width>280</width>
<z>0</z>
<height>160</height>
<location_x>400</location_x>
<location_y>0</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.Visualizer
<plugin_config>
<moterelations>true</moterelations>
<skin>org.contikios.cooja.plugins.skins.IDVisualizerSkin</skin>
<skin>org.contikios.cooja.plugins.skins.GridVisualizerSkin</skin>
<skin>org.contikios.cooja.plugins.skins.TrafficVisualizerSkin</skin>
<skin>org.contikios.cooja.plugins.skins.UDGMVisualizerSkin</skin>
<viewport>4.027583163598053 0.0 0.0 4.027583163598053 133.5292942712438 14.03198741893021</viewport>
</plugin_config>
<width>400</width>
<z>3</z>
<height>160</height>
<location_x>1</location_x>
<location_y>1</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.LogListener
<plugin_config>
<filter>TSCH-sch</filter>
<formatted_time />
<coloring />
</plugin_config>
<width>854</width>
<z>1</z>
<height>342</height>
<location_x>0</location_x>
<location_y>161</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.TimeLine
<plugin_config>
<mote>0</mote>
<mote>1</mote>
<showRadioRXTX />
<showRadioHW />
<showLEDs />
<zoomfactor>500.0</zoomfactor>
</plugin_config>
<width>1366</width>
<z>5</z>
<height>166</height>
<location_x>0</location_x>
<location_y>503</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.Notes
<plugin_config>
<notes>Enter notes here</notes>
<decorations>true</decorations>
</plugin_config>
<width>686</width>
<z>4</z>
<height>160</height>
<location_x>680</location_x>
<location_y>0</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.RadioLogger
<plugin_config>
<split>150</split>
<formatted_time />
<showdups>false</showdups>
<hidenodests>false</hidenodests>
</plugin_config>
<width>508</width>
<z>2</z>
<height>343</height>
<location_x>854</location_x>
<location_y>160</location_y>
</plugin>
</simconf>

View File

@ -1,11 +0,0 @@
all: udp-client udp-server
CONTIKI=../../..
ifdef SERVER_REPLY
CFLAGS+=-DSERVER_REPLY=$(SERVER_REPLY)
endif
ifdef PERIOD
CFLAGS+=-DPERIOD=$(PERIOD)
endif
include $(CONTIKI)/Makefile.include

View File

@ -1 +0,0 @@
TARGET = sky

View File

@ -1,584 +0,0 @@
<?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/mobility</project>
<simulation>
<title>Data collection network using IPv6 and RPL</title>
<delaytime>0</delaytime>
<randomseed>generated</randomseed>
<motedelay_us>5000000</motedelay_us>
<radiomedium>
org.contikios.cooja.radiomediums.UDGM
<transmitting_range>50.0</transmitting_range>
<interference_range>50.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>
org.contikios.cooja.mspmote.SkyMoteType
<identifier>sky1</identifier>
<description>Sky Mote Type #sky1</description>
<source EXPORT="discard">[CONTIKI_DIR]/examples/ipv6/rpl-udp/udp-server.c</source>
<commands EXPORT="discard">make udp-server.sky TARGET=sky WITH_COMPOWER=1</commands>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/ipv6/rpl-udp/udp-server.sky</firmware>
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.IPAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspClock</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspMoteID</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyButton</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyFlash</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyCoffeeFilesystem</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.Msp802154Radio</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspSerial</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyLED</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspDebugOutput</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyTemperature</moteinterface>
</motetype>
<motetype>
org.contikios.cooja.mspmote.SkyMoteType
<identifier>sky2</identifier>
<description>Sky Mote Type #sky2</description>
<source EXPORT="discard">[CONTIKI_DIR]/examples/ipv6/rpl-udp/udp-client.c</source>
<commands EXPORT="discard">make udp-client.sky TARGET=sky WITH_COMPOWER=1</commands>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/ipv6/rpl-udp/udp-client.sky</firmware>
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.IPAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspClock</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspMoteID</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyButton</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyFlash</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyCoffeeFilesystem</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.Msp802154Radio</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspSerial</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyLED</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspDebugOutput</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyTemperature</moteinterface>
</motetype>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>48.435974731198804</x>
<y>-66.16503914182063</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>1</id>
</interface_config>
<motetype_identifier>sky1</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>4.049356309774755</x>
<y>98.28771308774003</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>2</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>127.9689727848476</x>
<y>91.71883780610729</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>3</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>57.897299848739024</x>
<y>92.47229665488265</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>4</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>47.34887596588397</x>
<y>-30.341495695501195</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>5</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>47.13486576528276</x>
<y>32.944481932122315</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>6</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-11.42091423859419</x>
<y>17.879870626121914</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>7</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>118.92746659954325</x>
<y>57.05973076244069</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>8</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>53.68872892015448</x>
<y>59.887319605093715</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>9</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>16.45706316609417</x>
<y>23.9075414163248</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>10</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-18.9555027263478</x>
<y>75.14274313304935</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>11</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>29.265863595275306</x>
<y>85.6911670159044</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>12</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-39.298891643282545</x>
<y>-3.9704359883635574</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>13</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>66.93880603404335</x>
<y>-42.39683727590697</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>14</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>94.81678343873172</x>
<y>26.921376811426246</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>15</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-43.06618588715935</x>
<y>30.68867105530305</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>16</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-34.02467970185502</x>
<y>-24.313824905298304</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>17</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-28.750467760427494</x>
<y>48.01822457713635</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>18</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>124.95513738974614</x>
<y>20.140247172447996</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>19</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>15.703604317318808</x>
<y>-47.6710492173345</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>20</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-40.05235049205791</x>
<y>92.47229665488265</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>21</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>121.18784314586934</x>
<y>-24.313824905298304</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>22</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>88.03565379975346</x>
<y>-44.657213822233054</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>23</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>24.745110502623138</x>
<y>-1.7100594420374744</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>24</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>94.06332458995635</x>
<y>-2.4635182908128352</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>25</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-4.639784599615941</x>
<y>-9.998106778566445</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>26</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-13.681290784920272</x>
<y>-50.684884612435944</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>27</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>103.10483077526068</x>
<y>96.99304974753483</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>28</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>8.922474678340558</x>
<y>59.320107308766765</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>29</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>58.650758697514384</x>
<y>2.8106936506146916</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>30</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>90.59867707439</x>
<y>67.97632874312737</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>31</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
</simulation>
<plugin>
org.contikios.cooja.plugins.SimControl
<width>259</width>
<z>1</z>
<height>184</height>
<location_x>0</location_x>
<location_y>0</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.Visualizer
<plugin_config>
<skin>org.contikios.cooja.plugins.skins.IDVisualizerSkin</skin>
<skin>org.contikios.cooja.plugins.skins.UDGMVisualizerSkin</skin>
<skin>org.contikios.cooja.plugins.skins.AttributeVisualizerSkin</skin>
<viewport>2.349818846983307 0.0 0.0 2.349818846983307 150.19773526533348 176.95275613586946</viewport>
</plugin_config>
<width>520</width>
<z>3</z>
<height>523</height>
<location_x>269</location_x>
<location_y>14</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.LogListener
<plugin_config>
<filter />
</plugin_config>
<width>937</width>
<z>0</z>
<height>213</height>
<location_x>21</location_x>
<location_y>464</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.ScriptRunner
<plugin_config>
<script>TIMEOUT(12000000, log.log("Total PRR " + totalPRR + "\n"));
packetsReceived= new Array();
packetsSent = new Array();
serverID = 1;
nodeCount = 31;
totalPRR = 0;
for(i = 0; i &lt;= nodeCount; i++) {
packetsReceived[i] = 0;
packetsSent[i] = 0;
}
while(1) {
YIELD();
msgArray = msg.split(' ');
if(msgArray[0].equals("DATA")) {
if(msgArray.length == 9) {
// Received packet
senderID = parseInt(msgArray[8]);
packetsReceived[senderID]++;
log.log("SenderID " + senderID + " PRR " + packetsReceived[senderID] / packetsSent[senderID] + "\n");
totalReceived = totalSent = 0;
for(i = serverID + 1; i &lt;= nodeCount; i++) {
totalReceived += packetsReceived[i];
totalSent += packetsSent[i];
}
totalPRR = totalReceived / totalSent;
log.log("Total PRR " + totalPRR + " recv " + totalReceived + " sent " + totalSent + "\n");
} else if(msgArray.length == 6) {
// Sent packet
packetsSent[id]++;
}
}
}</script>
<active>true</active>
</plugin_config>
<width>600</width>
<z>2</z>
<height>700</height>
<location_x>665</location_x>
<location_y>6</location_y>
</plugin>
</simconf>

View File

@ -1,729 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<simconf>
<project EXPORT="discard">[APPS_DIR]/mrm</project>
<project EXPORT="discard">[APPS_DIR]/mspsim</project>
<project EXPORT="discard">[APPS_DIR]/avrora</project>
<project EXPORT="discard">[APPS_DIR]/serial_socket</project>
<project EXPORT="discard">[APPS_DIR]/collect-view</project>
<project EXPORT="discard">[APPS_DIR]/powertracker</project>
<simulation>
<title>RPL up and downstream scaleability test network using IPv6 and RPL</title>
<randomseed>generated</randomseed>
<motedelay_us>5000000</motedelay_us>
<radiomedium>
org.contikios.cooja.radiomediums.UDGM
<transmitting_range>50.0</transmitting_range>
<interference_range>50.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>
org.contikios.cooja.mspmote.SkyMoteType
<identifier>sky1</identifier>
<description>Sky Mote Type #sky1</description>
<source EXPORT="discard">[CONTIKI_DIR]/examples/ipv6/rpl-udp/udp-server.c</source>
<commands EXPORT="discard">make SERVER_REPLY=1 clean udp-server.sky TARGET=sky DEFINES=TEST_MORE_ROUTES=1</commands>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/ipv6/rpl-udp/udp-server.sky</firmware>
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.IPAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspClock</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspMoteID</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyButton</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyFlash</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyCoffeeFilesystem</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.Msp802154Radio</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspSerial</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyLED</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspDebugOutput</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyTemperature</moteinterface>
</motetype>
<motetype>
org.contikios.cooja.mspmote.SkyMoteType
<identifier>sky2</identifier>
<description>Sky Mote Type #sky2</description>
<source EXPORT="discard">[CONTIKI_DIR]/examples/ipv6/rpl-udp/udp-client.c</source>
<commands EXPORT="discard">make SERVER_REPLY=1 clean udp-client.sky TARGET=sky</commands>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/ipv6/rpl-udp/udp-client.sky</firmware>
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.IPAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspClock</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspMoteID</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyButton</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyFlash</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyCoffeeFilesystem</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.Msp802154Radio</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspSerial</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyLED</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspDebugOutput</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyTemperature</moteinterface>
</motetype>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>48.435974731198804</x>
<y>-66.16503914182063</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>1</id>
</interface_config>
<motetype_identifier>sky1</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-39.78380986481406</x>
<y>-48.10655064098382</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>2</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>127.9689727848476</x>
<y>91.71883780610729</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>3</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>154.92605604103275</x>
<y>40.97896551774433</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>4</id>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspSerial
<history>r~;</history>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>47.34887596588397</x>
<y>-30.341495695501195</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>5</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>47.13486576528276</x>
<y>32.944481932122315</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>6</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-11.42091423859419</x>
<y>17.879870626121914</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>7</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>118.92746659954325</x>
<y>57.05973076244069</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>8</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>53.68872892015448</x>
<y>59.887319605093715</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>9</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>16.45706316609417</x>
<y>23.9075414163248</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>10</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-13.423161364506493</x>
<y>-38.483037144768275</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>11</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-9.034961217472201</x>
<y>44.411389162165406</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>12</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-39.298891643282545</x>
<y>-3.9704359883635574</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>13</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>66.93880603404335</x>
<y>-42.39683727590697</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>14</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>94.81678343873172</x>
<y>26.921376811426246</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>15</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-43.06618588715935</x>
<y>30.68867105530305</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>16</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-34.02467970185502</x>
<y>-24.313824905298304</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>17</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-28.750467760427494</x>
<y>48.01822457713635</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>18</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>124.95513738974614</x>
<y>20.140247172447996</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>19</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>15.703604317318808</x>
<y>-47.6710492173345</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>20</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>154.43072661267115</x>
<y>-3.279765376986134</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>21</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>121.18784314586934</x>
<y>-24.313824905298304</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>22</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>88.4612185198951</x>
<y>-49.763990463932714</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>23</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>24.745110502623138</x>
<y>-1.7100594420374744</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>24</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>94.06332458995635</x>
<y>-2.4635182908128352</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>25</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-4.639784599615941</x>
<y>-9.998106778566445</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>26</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>2.4901685804620115</x>
<y>-60.89843789583528</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>27</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>103.10483077526068</x>
<y>96.99304974753483</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>28</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>8.922474678340558</x>
<y>59.320107308766765</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>29</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>58.650758697514384</x>
<y>2.8106936506146916</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>30</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>90.59867707439</x>
<y>67.97632874312737</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>31</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
</simulation>
<plugin>
org.contikios.cooja.plugins.SimControl
<width>289</width>
<z>1</z>
<height>184</height>
<location_x>31</location_x>
<location_y>41</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.Visualizer
<plugin_config>
<skin>org.contikios.cooja.plugins.skins.IDVisualizerSkin</skin>
<skin>org.contikios.cooja.plugins.skins.UDGMVisualizerSkin</skin>
<skin>org.contikios.cooja.plugins.skins.AttributeVisualizerSkin</skin>
<viewport>2.349818846983307 0.0 0.0 2.349818846983307 187.19773526533345 190.95275613586946</viewport>
</plugin_config>
<width>659</width>
<z>3</z>
<height>523</height>
<location_x>296</location_x>
<location_y>11</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.LogListener
<plugin_config>
<filter />
<formatted_time />
<coloring />
</plugin_config>
<width>937</width>
<z>4</z>
<height>349</height>
<location_x>21</location_x>
<location_y>464</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.ScriptRunner
<plugin_config>
<script>TIMEOUT(12000000, log.log("Total PRR " + totalPRR + "\n"));
packetsReceived= new Array();
packetsSent = new Array();
serverID = 1;
nodeCount = 31;
totalPRR = 0;
for(i = 0; i &lt;= nodeCount; i++) {
packetsReceived[i] = 0;
packetsSent[i] = 0;
}
while(1) {
YIELD();
msgArray = msg.split(' ');
if(msgArray[0].equals("#A")) {
if(msgArray[1].charAt(0) == 'r') {
// Received packet
senderID = id;
arr2 = msgArray[1].split(',')[0].slice(2).split('/');
recv = parseInt(arr2[0]);
sent = parseInt(arr2[1]);
log.log("Sent:" + sent + " Recv:" + recv + "\n");
packetsSent[senderID] = sent;
packetsReceived[senderID] = recv;
log.log("SenderID " + senderID + " PRR " + packetsReceived[senderID] / packetsSent[senderID] + "\n");
totalReceived = totalSent = 0;
for(i = serverID + 1; i &lt;= nodeCount; i++) {
totalReceived += packetsReceived[i];
totalSent += packetsSent[i];
}
totalPRR = totalReceived / totalSent;
log.log("Total PRR " + totalPRR + " recv " + totalReceived + " sent " + totalSent + "\n");
}
}
}</script>
<active>true</active>
</plugin_config>
<width>600</width>
<z>0</z>
<height>700</height>
<location_x>946</location_x>
<location_y>6</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.MoteInterfaceViewer
<mote_arg>3</mote_arg>
<plugin_config>
<interface>Serial port</interface>
<scrollpos>0,0</scrollpos>
</plugin_config>
<width>350</width>
<z>2</z>
<height>300</height>
<location_x>976</location_x>
<location_y>36</location_y>
</plugin>
</simconf>

View File

@ -1,711 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<simconf>
<project EXPORT="discard">[APPS_DIR]/mrm</project>
<project EXPORT="discard">[APPS_DIR]/mspsim</project>
<project EXPORT="discard">[APPS_DIR]/avrora</project>
<project EXPORT="discard">[APPS_DIR]/serial_socket</project>
<project EXPORT="discard">[APPS_DIR]/collect-view</project>
<project EXPORT="discard">[APPS_DIR]/powertracker</project>
<simulation>
<title>Data collection network using IPv6 and RPL</title>
<randomseed>generated</randomseed>
<motedelay_us>5000000</motedelay_us>
<radiomedium>
org.contikios.cooja.radiomediums.UDGM
<transmitting_range>50.0</transmitting_range>
<interference_range>50.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>
org.contikios.cooja.mspmote.SkyMoteType
<identifier>sky1</identifier>
<description>Sky Mote Type #sky1</description>
<source EXPORT="discard">[CONTIKI_DIR]/examples/ipv6/rpl-udp/udp-server.c</source>
<commands EXPORT="discard">make clean udp-server.sky TARGET=sky DEFINES=TEST_MORE_ROUTES=1</commands>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/ipv6/rpl-udp/udp-server.sky</firmware>
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.IPAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspClock</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspMoteID</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyButton</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyFlash</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyCoffeeFilesystem</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.Msp802154Radio</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspSerial</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyLED</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspDebugOutput</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyTemperature</moteinterface>
</motetype>
<motetype>
org.contikios.cooja.mspmote.SkyMoteType
<identifier>sky2</identifier>
<description>Sky Mote Type #sky2</description>
<source EXPORT="discard">[CONTIKI_DIR]/examples/ipv6/rpl-udp/udp-client.c</source>
<commands EXPORT="discard">make clean udp-client.sky TARGET=sky</commands>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/ipv6/rpl-udp/udp-client.sky</firmware>
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.IPAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspClock</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspMoteID</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyButton</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyFlash</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyCoffeeFilesystem</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.Msp802154Radio</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspSerial</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyLED</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspDebugOutput</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyTemperature</moteinterface>
</motetype>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>48.435974731198804</x>
<y>-66.16503914182063</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>1</id>
</interface_config>
<motetype_identifier>sky1</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>4.049356309774755</x>
<y>98.28771308774003</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>2</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>127.9689727848476</x>
<y>91.71883780610729</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>3</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>57.897299848739024</x>
<y>92.47229665488265</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>4</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>47.34887596588397</x>
<y>-30.341495695501195</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>5</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>47.13486576528276</x>
<y>32.944481932122315</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>6</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-11.42091423859419</x>
<y>17.879870626121914</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>7</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>118.92746659954325</x>
<y>57.05973076244069</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>8</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>53.68872892015448</x>
<y>59.887319605093715</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>9</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>16.45706316609417</x>
<y>23.9075414163248</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>10</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-18.9555027263478</x>
<y>75.14274313304935</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>11</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>29.265863595275306</x>
<y>85.6911670159044</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>12</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-39.298891643282545</x>
<y>-3.9704359883635574</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>13</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>66.93880603404335</x>
<y>-42.39683727590697</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>14</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>94.81678343873172</x>
<y>26.921376811426246</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>15</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-43.06618588715935</x>
<y>30.68867105530305</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>16</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-34.02467970185502</x>
<y>-24.313824905298304</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>17</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-28.750467760427494</x>
<y>48.01822457713635</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>18</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>124.95513738974614</x>
<y>20.140247172447996</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>19</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>15.703604317318808</x>
<y>-47.6710492173345</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>20</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-40.05235049205791</x>
<y>92.47229665488265</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>21</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>121.18784314586934</x>
<y>-24.313824905298304</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>22</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>88.03565379975346</x>
<y>-44.657213822233054</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>23</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>24.745110502623138</x>
<y>-1.7100594420374744</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>24</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>94.06332458995635</x>
<y>-2.4635182908128352</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>25</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-4.639784599615941</x>
<y>-9.998106778566445</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>26</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-13.681290784920272</x>
<y>-50.684884612435944</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>27</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>103.10483077526068</x>
<y>96.99304974753483</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>28</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>8.922474678340558</x>
<y>59.320107308766765</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>29</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>58.650758697514384</x>
<y>2.8106936506146916</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>30</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>90.59867707439</x>
<y>67.97632874312737</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>31</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
</simulation>
<plugin>
org.contikios.cooja.plugins.SimControl
<width>259</width>
<z>3</z>
<height>184</height>
<location_x>3</location_x>
<location_y>15</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.Visualizer
<plugin_config>
<skin>org.contikios.cooja.plugins.skins.IDVisualizerSkin</skin>
<skin>org.contikios.cooja.plugins.skins.UDGMVisualizerSkin</skin>
<skin>org.contikios.cooja.plugins.skins.AttributeVisualizerSkin</skin>
<viewport>2.349818846983307 0.0 0.0 2.349818846983307 150.19773526533348 176.95275613586946</viewport>
</plugin_config>
<width>520</width>
<z>2</z>
<height>523</height>
<location_x>14</location_x>
<location_y>210</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.LogListener
<plugin_config>
<filter />
<formatted_time />
<coloring />
</plugin_config>
<width>937</width>
<z>0</z>
<height>213</height>
<location_x>265</location_x>
<location_y>16</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.ScriptRunner
<plugin_config>
<script>TIMEOUT(12000000, log.log("Total PRR " + totalPRR + "\n"));
packetsReceived= new Array();
packetsSent = new Array();
serverID = 1;
nodeCount = 31;
totalPRR = 0;
for(i = 0; i &lt;= nodeCount; i++) {
packetsReceived[i] = 0;
packetsSent[i] = 0;
}
while(1) {
YIELD();
msgArray = msg.split(' ');
if(msgArray[0].equals("DATA")) {
if(msgArray.length == 9) {
// Received packet
senderID = parseInt(msgArray[8]);
packetsReceived[senderID]++;
log.log("SenderID " + senderID + " PRR " + packetsReceived[senderID] / packetsSent[senderID] + "\n");
totalReceived = totalSent = 0;
for(i = serverID + 1; i &lt;= nodeCount; i++) {
totalReceived += packetsReceived[i];
totalSent += packetsSent[i];
}
totalPRR = totalReceived / totalSent;
log.log("Total PRR " + totalPRR + " recv " + totalReceived + " sent " + totalSent + "\n");
} else if(msgArray.length == 6) {
// Sent packet
packetsSent[id]++;
}
}
}</script>
<active>true</active>
</plugin_config>
<width>651</width>
<z>1</z>
<height>550</height>
<location_x>547</location_x>
<location_y>181</location_y>
</plugin>
</simconf>

View File

@ -1,249 +0,0 @@
/*
* 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.
*
*/
#include "contiki.h"
#include "lib/random.h"
#include "sys/ctimer.h"
#include "net/ipv6/uip.h"
#include "net/ipv6/uip-ds6.h"
#include "net/ipv6/uip-udp-packet.h"
#include "sys/ctimer.h"
#include <stdio.h>
#include <string.h>
#include "dev/serial-line.h"
#include "net/ipv6/uip-ds6-route.h"
#include "rpl-dag-root.h"
#define UDP_CLIENT_PORT 8765
#define UDP_SERVER_PORT 5678
#define UDP_EXAMPLE_ID 190
#define DEBUG DEBUG_FULL
#include "net/ipv6/uip-debug.h"
#ifndef PERIOD
#define PERIOD 60
#endif
#define START_INTERVAL (15 * CLOCK_SECOND)
#define SEND_INTERVAL (PERIOD * CLOCK_SECOND)
#define SEND_TIME (random_rand() % (SEND_INTERVAL))
#define MAX_PAYLOAD_LEN 30
static struct uip_udp_conn *client_conn;
static uip_ipaddr_t server_ipaddr;
/*---------------------------------------------------------------------------*/
PROCESS(udp_client_process, "UDP client process");
AUTOSTART_PROCESSES(&udp_client_process);
/*---------------------------------------------------------------------------*/
static int seq_id;
static int reply;
static void
tcpip_handler(void)
{
char *str;
if(uip_newdata()) {
str = uip_appdata;
str[uip_datalen()] = '\0';
reply++;
printf("DATA recv '%s' (s:%d, r:%d)\n", str, seq_id, reply);
}
}
/*---------------------------------------------------------------------------*/
static void
send_packet(void *ptr)
{
char buf[MAX_PAYLOAD_LEN];
#ifdef SERVER_REPLY
uint8_t num_used = 0;
uip_ds6_nbr_t *nbr;
nbr = nbr_table_head(ds6_neighbors);
while(nbr != NULL) {
nbr = nbr_table_next(ds6_neighbors, nbr);
num_used++;
}
if(seq_id > 0) {
ANNOTATE("#A r=%d/%d,color=%s,n=%d %d\n", reply, seq_id,
reply == seq_id ? "GREEN" : "RED", uip_ds6_route_num_routes(), num_used);
}
#endif /* SERVER_REPLY */
seq_id++;
PRINTF("DATA send to %d 'Hello %d'\n",
server_ipaddr.u8[sizeof(server_ipaddr.u8) - 1], seq_id);
sprintf(buf, "Hello %d from the client", seq_id);
uip_udp_packet_sendto(client_conn, buf, strlen(buf),
&server_ipaddr, UIP_HTONS(UDP_SERVER_PORT));
}
/*---------------------------------------------------------------------------*/
static void
print_local_addresses(void)
{
int i;
uint8_t state;
PRINTF("Client IPv6 addresses: ");
for(i = 0; i < UIP_DS6_ADDR_NB; i++) {
state = uip_ds6_if.addr_list[i].state;
if(uip_ds6_if.addr_list[i].isused &&
(state == ADDR_TENTATIVE || state == ADDR_PREFERRED)) {
PRINT6ADDR(&uip_ds6_if.addr_list[i].ipaddr);
PRINTF("\n");
/* hack to make address "final" */
if (state == ADDR_TENTATIVE) {
uip_ds6_if.addr_list[i].state = ADDR_PREFERRED;
}
}
}
}
/*---------------------------------------------------------------------------*/
static void
set_global_address(void)
{
uip_ipaddr_t ipaddr;
uip_ip6addr(&ipaddr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0);
uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);
/* The choice of server address determines its 6LoWPAN header compression.
* (Our address will be compressed Mode 3 since it is derived from our
* link-local address)
* Obviously the choice made here must also be selected in udp-server.c.
*
* For correct Wireshark decoding using a sniffer, add the /64 prefix to the
* 6LowPAN protocol preferences,
* e.g. set Context 0 to fd00::. At present Wireshark copies Context/128 and
* then overwrites it.
* (Setting Context 0 to fd00::1111:2222:3333:4444 will report a 16 bit
* compressed address of fd00::1111:22ff:fe33:xxxx)
*
* Note the IPCMV6 checksum verification depends on the correct uncompressed
* addresses.
*/
#if 0
/* Mode 1 - 64 bits inline */
uip_ip6addr(&server_ipaddr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 1);
#elif 1
/* Mode 2 - 16 bits inline */
uip_ip6addr(&server_ipaddr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0x00ff, 0xfe00, 1);
#else
/* Mode 3 - derived from server link-local (MAC) address */
uip_ip6addr(&server_ipaddr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0x0250, 0xc2ff, 0xfea8, 0xcd1a); //redbee-econotag
#endif
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(udp_client_process, ev, data)
{
static struct etimer periodic;
static struct ctimer backoff_timer;
PROCESS_BEGIN();
PROCESS_PAUSE();
set_global_address();
PRINTF("UDP client process started nbr:%d routes:%d\n",
NBR_TABLE_CONF_MAX_NEIGHBORS, NETSTACK_MAX_ROUTE_ENTRIES);
print_local_addresses();
/* new connection with remote host */
client_conn = udp_new(NULL, UIP_HTONS(UDP_SERVER_PORT), NULL);
if(client_conn == NULL) {
PRINTF("No UDP connection available, exiting the process!\n");
PROCESS_EXIT();
}
udp_bind(client_conn, UIP_HTONS(UDP_CLIENT_PORT));
PRINTF("Created a connection with the server ");
PRINT6ADDR(&client_conn->ripaddr);
PRINTF(" local/remote port %u/%u\n",
UIP_HTONS(client_conn->lport), UIP_HTONS(client_conn->rport));
etimer_set(&periodic, SEND_INTERVAL);
while(1) {
PROCESS_YIELD();
if(ev == tcpip_event) {
tcpip_handler();
}
if(ev == serial_line_event_message && data != NULL) {
char *str;
str = data;
if(str[0] == 'r') {
uip_ds6_route_t *r;
uip_ipaddr_t *nexthop;
uip_ds6_defrt_t *defrt;
uip_ipaddr_t *ipaddr;
defrt = NULL;
if((ipaddr = uip_ds6_defrt_choose()) != NULL) {
defrt = uip_ds6_defrt_lookup(ipaddr);
}
if(defrt != NULL) {
PRINTF("DefRT: :: -> %02d", defrt->ipaddr.u8[15]);
PRINTF(" lt:%lu inf:%d\n", stimer_remaining(&defrt->lifetime),
defrt->isinfinite);
} else {
PRINTF("DefRT: :: -> NULL\n");
}
for(r = uip_ds6_route_head();
r != NULL;
r = uip_ds6_route_next(r)) {
nexthop = uip_ds6_route_nexthop(r);
PRINTF("Route: %02d -> %02d", r->ipaddr.u8[15], nexthop->u8[15]);
/* PRINT6ADDR(&r->ipaddr); */
/* PRINTF(" -> "); */
/* PRINT6ADDR(nexthop); */
PRINTF(" lt:%lu\n", r->state.lifetime);
}
}
}
if(etimer_expired(&periodic)) {
etimer_reset(&periodic);
ctimer_set(&backoff_timer, SEND_TIME, send_packet, NULL);
}
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View File

@ -1,146 +0,0 @@
/*
* 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.
*
*/
#include "contiki.h"
#include "contiki-lib.h"
#include "contiki-net.h"
#include "net/ipv6/uip.h"
#include "rpl.h"
#include "rpl-dag-root.h"
#include "net/netstack.h"
#include "dev/button-sensor.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define DEBUG DEBUG_PRINT
#include "net/ipv6/uip-debug.h"
#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
#define UDP_CLIENT_PORT 8765
#define UDP_SERVER_PORT 5678
#define UDP_EXAMPLE_ID 190
static struct uip_udp_conn *server_conn;
PROCESS(udp_server_process, "UDP server process");
AUTOSTART_PROCESSES(&udp_server_process);
/*---------------------------------------------------------------------------*/
static void
tcpip_handler(void)
{
char *appdata;
if(uip_newdata()) {
appdata = (char *)uip_appdata;
appdata[uip_datalen()] = 0;
PRINTF("DATA recv '%s' from ", appdata);
PRINTF("%d",
UIP_IP_BUF->srcipaddr.u8[sizeof(UIP_IP_BUF->srcipaddr.u8) - 1]);
PRINTF("\n");
#if SERVER_REPLY
PRINTF("DATA sending reply\n");
uip_ipaddr_copy(&server_conn->ripaddr, &UIP_IP_BUF->srcipaddr);
uip_udp_packet_send(server_conn, "Reply", sizeof("Reply"));
uip_create_unspecified(&server_conn->ripaddr);
#endif
}
}
/*---------------------------------------------------------------------------*/
static void
print_local_addresses(void)
{
int i;
uint8_t state;
PRINTF("Server IPv6 addresses: ");
for(i = 0; i < UIP_DS6_ADDR_NB; i++) {
state = uip_ds6_if.addr_list[i].state;
if(state == ADDR_TENTATIVE || state == ADDR_PREFERRED) {
PRINT6ADDR(&uip_ds6_if.addr_list[i].ipaddr);
PRINTF("\n");
/* hack to make address "final" */
if (state == ADDR_TENTATIVE) {
uip_ds6_if.addr_list[i].state = ADDR_PREFERRED;
}
}
}
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(udp_server_process, ev, data)
{
uip_ipaddr_t ipaddr;
PROCESS_BEGIN();
PROCESS_PAUSE();
SENSORS_ACTIVATE(button_sensor);
PRINTF("UDP server started. nbr:%d routes:%d\n",
NBR_TABLE_CONF_MAX_NEIGHBORS, NETSTACK_MAX_ROUTE_ENTRIES);
uip_ip6addr(&ipaddr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0x00ff, 0xfe00, 1);
rpl_dag_root_init_dag_immediately();
print_local_addresses();
server_conn = udp_new(NULL, UIP_HTONS(UDP_CLIENT_PORT), NULL);
if(server_conn == NULL) {
PRINTF("No UDP connection available, exiting the process!\n");
PROCESS_EXIT();
}
udp_bind(server_conn, UIP_HTONS(UDP_SERVER_PORT));
PRINTF("Created a server connection with remote address ");
PRINT6ADDR(&server_conn->ripaddr);
PRINTF(" local/remote port %u/%u\n", UIP_HTONS(server_conn->lport),
UIP_HTONS(server_conn->rport));
while(1) {
PROCESS_YIELD();
if(ev == tcpip_event) {
tcpip_handler();
} else if (ev == sensors_event && data == &button_sensor) {
PRINTF("Initiaing global repair\n");
#if UIP_CONF_IPV6_RPL_LITE
rpl_global_repair();
#else
rpl_repair_root(RPL_DEFAULT_INSTANCE);
#endif
}
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View File

@ -1,5 +0,0 @@
all: udp-server udp-client
CONTIKI = ../../..
CFLAGS += -DUIP_CONF_ND6_SEND_NS=1
include $(CONTIKI)/Makefile.include

View File

@ -1 +0,0 @@
TARGET = minimal-net

View File

@ -1,196 +0,0 @@
/*
* 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.
*
*/
#include "contiki.h"
#include "contiki-lib.h"
#include "contiki-net.h"
#include "net/ipv6/resolv.h"
#include <string.h>
#include <stdbool.h>
#define DEBUG DEBUG_PRINT
#include "net/ipv6/uip-debug.h"
#define SEND_INTERVAL 15 * CLOCK_SECOND
#define MAX_PAYLOAD_LEN 40
static struct uip_udp_conn *client_conn;
/*---------------------------------------------------------------------------*/
PROCESS(udp_client_process, "UDP client process");
AUTOSTART_PROCESSES(&resolv_process,&udp_client_process);
/*---------------------------------------------------------------------------*/
static void
tcpip_handler(void)
{
char *str;
if(uip_newdata()) {
str = uip_appdata;
str[uip_datalen()] = '\0';
printf("Response from the server: '%s'\n", str);
}
}
/*---------------------------------------------------------------------------*/
static char buf[MAX_PAYLOAD_LEN];
static void
timeout_handler(void)
{
static int seq_id;
printf("Client sending to: ");
PRINT6ADDR(&client_conn->ripaddr);
sprintf(buf, "Hello %d from the client", ++seq_id);
printf(" (msg: %s)\n", buf);
#if SEND_TOO_LARGE_PACKET_TO_TEST_FRAGMENTATION
uip_udp_packet_send(client_conn, buf, UIP_APPDATA_SIZE);
#else /* SEND_TOO_LARGE_PACKET_TO_TEST_FRAGMENTATION */
uip_udp_packet_send(client_conn, buf, strlen(buf));
#endif /* SEND_TOO_LARGE_PACKET_TO_TEST_FRAGMENTATION */
}
/*---------------------------------------------------------------------------*/
static void
print_local_addresses(void)
{
int i;
uint8_t state;
PRINTF("Client IPv6 addresses: ");
for(i = 0; i < UIP_DS6_ADDR_NB; i++) {
state = uip_ds6_if.addr_list[i].state;
if(uip_ds6_if.addr_list[i].isused &&
(state == ADDR_TENTATIVE || state == ADDR_PREFERRED)) {
PRINT6ADDR(&uip_ds6_if.addr_list[i].ipaddr);
PRINTF("\n");
}
}
}
/*---------------------------------------------------------------------------*/
#if UIP_CONF_ROUTER
static void
set_global_address(void)
{
uip_ipaddr_t ipaddr;
uip_ip6addr(&ipaddr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0);
uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);
}
#endif /* UIP_CONF_ROUTER */
/*---------------------------------------------------------------------------*/
static resolv_status_t
set_connection_address(uip_ipaddr_t *ipaddr)
{
#ifndef UDP_CONNECTION_ADDR
#if RESOLV_CONF_SUPPORTS_MDNS
#define UDP_CONNECTION_ADDR contiki-udp-server.local
#elif UIP_CONF_ROUTER
#define UDP_CONNECTION_ADDR fd00:0:0:0:0212:7404:0004:0404
#else
#define UDP_CONNECTION_ADDR fe80:0:0:0:6466:6666:6666:6666
#endif
#endif /* !UDP_CONNECTION_ADDR */
#define _QUOTEME(x) #x
#define QUOTEME(x) _QUOTEME(x)
resolv_status_t status = RESOLV_STATUS_ERROR;
if(uiplib_ipaddrconv(QUOTEME(UDP_CONNECTION_ADDR), ipaddr) == 0) {
uip_ipaddr_t *resolved_addr = NULL;
status = resolv_lookup(QUOTEME(UDP_CONNECTION_ADDR),&resolved_addr);
if(status == RESOLV_STATUS_UNCACHED || status == RESOLV_STATUS_EXPIRED) {
PRINTF("Attempting to look up %s\n",QUOTEME(UDP_CONNECTION_ADDR));
resolv_query(QUOTEME(UDP_CONNECTION_ADDR));
status = RESOLV_STATUS_RESOLVING;
} else if(status == RESOLV_STATUS_CACHED && resolved_addr != NULL) {
PRINTF("Lookup of \"%s\" succeded!\n",QUOTEME(UDP_CONNECTION_ADDR));
} else if(status == RESOLV_STATUS_RESOLVING) {
PRINTF("Still looking up \"%s\"...\n",QUOTEME(UDP_CONNECTION_ADDR));
} else {
PRINTF("Lookup of \"%s\" failed. status = %d\n",QUOTEME(UDP_CONNECTION_ADDR),status);
}
if(resolved_addr)
uip_ipaddr_copy(ipaddr, resolved_addr);
} else {
status = RESOLV_STATUS_CACHED;
}
return status;
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(udp_client_process, ev, data)
{
static struct etimer et;
uip_ipaddr_t ipaddr;
PROCESS_BEGIN();
PRINTF("UDP client process started\n");
#if UIP_CONF_ROUTER
set_global_address();
#endif
print_local_addresses();
static resolv_status_t status = RESOLV_STATUS_UNCACHED;
while(status != RESOLV_STATUS_CACHED) {
status = set_connection_address(&ipaddr);
if(status == RESOLV_STATUS_RESOLVING) {
PROCESS_WAIT_EVENT_UNTIL(ev == resolv_event_found);
} else if(status != RESOLV_STATUS_CACHED) {
PRINTF("Can't get connection address.\n");
PROCESS_YIELD();
}
}
/* new connection with remote host */
client_conn = udp_new(&ipaddr, UIP_HTONS(3000), NULL);
udp_bind(client_conn, UIP_HTONS(3001));
PRINTF("Created a connection with the server ");
PRINT6ADDR(&client_conn->ripaddr);
PRINTF(" local/remote port %u/%u\n",
UIP_HTONS(client_conn->lport), UIP_HTONS(client_conn->rport));
etimer_set(&et, SEND_INTERVAL);
while(1) {
PROCESS_YIELD();
if(etimer_expired(&et)) {
timeout_handler();
etimer_restart(&et);
} else if(ev == tcpip_event) {
tcpip_handler();
}
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View File

@ -1,121 +0,0 @@
/*
* 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.
*
*/
#include "contiki.h"
#include "contiki-lib.h"
#include "contiki-net.h"
#include <string.h>
#define DEBUG DEBUG_PRINT
#include "net/ipv6/uip-debug.h"
#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
#define MAX_PAYLOAD_LEN 120
static struct uip_udp_conn *server_conn;
PROCESS(udp_server_process, "UDP server process");
AUTOSTART_PROCESSES(&resolv_process,&udp_server_process);
/*---------------------------------------------------------------------------*/
static void
tcpip_handler(void)
{
static int seq_id;
char buf[MAX_PAYLOAD_LEN];
if(uip_newdata()) {
((char *)uip_appdata)[uip_datalen()] = 0;
PRINTF("Server received: '%s' from ", (char *)uip_appdata);
PRINT6ADDR(&UIP_IP_BUF->srcipaddr);
PRINTF("\n");
uip_ipaddr_copy(&server_conn->ripaddr, &UIP_IP_BUF->srcipaddr);
PRINTF("Responding with message: ");
sprintf(buf, "Hello from the server! (%d)", ++seq_id);
PRINTF("%s\n", buf);
uip_udp_packet_send(server_conn, buf, strlen(buf));
/* Restore server connection to allow data from any node */
memset(&server_conn->ripaddr, 0, sizeof(server_conn->ripaddr));
}
}
/*---------------------------------------------------------------------------*/
static void
print_local_addresses(void)
{
int i;
uint8_t state;
PRINTF("Server IPv6 addresses: ");
for(i = 0; i < UIP_DS6_ADDR_NB; i++) {
state = uip_ds6_if.addr_list[i].state;
if(uip_ds6_if.addr_list[i].isused &&
(state == ADDR_TENTATIVE || state == ADDR_PREFERRED)) {
PRINT6ADDR(&uip_ds6_if.addr_list[i].ipaddr);
PRINTF("\n");
}
}
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(udp_server_process, ev, data)
{
#if UIP_CONF_ROUTER
uip_ipaddr_t ipaddr;
#endif /* UIP_CONF_ROUTER */
PROCESS_BEGIN();
PRINTF("UDP server started\n");
#if RESOLV_CONF_SUPPORTS_MDNS
resolv_set_hostname("contiki-udp-server");
#endif
#if UIP_CONF_ROUTER
uip_ip6addr(&ipaddr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0);
uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);
#endif /* UIP_CONF_ROUTER */
print_local_addresses();
server_conn = udp_new(NULL, UIP_HTONS(3001), NULL);
udp_bind(server_conn, UIP_HTONS(3000));
while(1) {
PROCESS_YIELD();
if(ev == tcpip_event) {
tcpip_handler();
}
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View File

@ -1,5 +1,5 @@
CONTIKI_PROJECT = logging
all: $(CONTIKI_PROJECT)
CONTIKI = ../..
CONTIKI = ../../..
include $(CONTIKI)/Makefile.include

View File

@ -45,6 +45,7 @@
#define LOG_CONF_LEVEL_TCPIP LOG_LEVEL_DBG
#define LOG_CONF_LEVEL_MAC LOG_LEVEL_DBG
#define LOG_CONF_LEVEL_FRAMER LOG_LEVEL_DBG
#define LOG_CONF_LEVEL_6TOP LOG_LEVEL_DBG
/* Enable cooja annotations */
#define LOG_CONF_WITH_ANNOTATE 1

View File

@ -1,5 +1,5 @@
CONTIKI_PROJECT = all-timers
all: $(CONTIKI_PROJECT)
CONTIKI = ../..
CONTIKI = ../../..
include $(CONTIKI)/Makefile.include

View File

@ -36,96 +36,73 @@
#include "sys/timer.h"
#include "sys/rtimer.h"
PROCESS(process1, "ETimer x Timer x STimer Process");
PROCESS(process2, "CTimer Process 2");
PROCESS(process3, "RTimer Process 3");
AUTOSTART_PROCESSES(&process1, &process2, &process3);
PROCESS(timer_process, "ETimer x Timer x STimer Process");
AUTOSTART_PROCESSES(&timer_process);
static int counter_etimer;
static int counter_timer;
static int counter_stimer;
static int counter_ctimer;
static int counter_rtimer;
static struct timer timer_timer;
static struct stimer timer_stimer;
static struct ctimer timer_ctimer;
static struct rtimer timer_rtimer;
static rtimer_clock_t timeout_rtimer = RTIMER_SECOND / 2;
void
do_timeout1()
{
counter_etimer++;
if(timer_expired(&timer_timer)) {
counter_timer++;
}
if(stimer_expired(&timer_stimer)) {
counter_stimer++;
}
printf("\nProcess 1: %s", counter_timer == counter_etimer
&& counter_timer == counter_stimer ? "SUCCESS" : "FAIL");
}
/*---------------------------------------------------------------------------*/
void
do_timeout2()
ctimer_callback(void *ptr)
{
/* rearm the ctimer */
ctimer_reset(&timer_ctimer);
printf("\nProcess 2: CTimer callback called");
counter_ctimer++;
printf("CTimer callback called\n");
}
/*---------------------------------------------------------------------------*/
void
do_timeout3(struct rtimer *timer, void *ptr)
rtimer_callback(struct rtimer *timer, void *ptr)
{
counter_rtimer++;
printf("\nProcess 3: RTimer callback called");
/* Normally avoid printing from rtimer - rather do a process poll */
printf("RTimer callback called\n");
/* Re-arm rtimer */
rtimer_set(&timer_rtimer, RTIMER_NOW() + timeout_rtimer, 0, do_timeout3,
NULL);
rtimer_set(&timer_rtimer, RTIMER_NOW() + RTIMER_SECOND / 2, 0,
rtimer_callback, NULL);
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(process1, ev, data)
/*
* This Process will count timer expires on one e-timer (that drives the
* events to the process), one timer, and one stimer.
*
*/
PROCESS_THREAD(timer_process, ev, data)
{
static struct etimer timer_etimer;
PROCESS_BEGIN();
ctimer_set(&timer_ctimer, CLOCK_SECOND, ctimer_callback, NULL);
rtimer_set(&timer_rtimer, RTIMER_NOW() + CLOCK_SECOND / 2, 0,
rtimer_callback, NULL);
while(1) {
/* set all the timers */
timer_set(&timer_timer, 3 * CLOCK_SECOND);
stimer_set(&timer_stimer, 3);
etimer_set(&timer_etimer, 3 * CLOCK_SECOND);
PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_TIMER);
do_timeout1();
counter_etimer++;
if(timer_expired(&timer_timer)) {
counter_timer++;
}
if(stimer_expired(&timer_stimer)) {
counter_stimer++;
}
printf("Timer process: %s\n", counter_timer == counter_etimer
&& counter_timer == counter_stimer ? "SUCCESS" : "FAIL");
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(process2, ev, data)
{
PROCESS_BEGIN();
while(1) {
ctimer_set(&timer_ctimer, 5 * CLOCK_SECOND, do_timeout2, NULL);
PROCESS_YIELD();
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(process3, ev, data)
{
PROCESS_BEGIN();
while(1) {
rtimer_set(&timer_rtimer, RTIMER_NOW() + timeout_rtimer, 0,
do_timeout3, NULL);
PROCESS_YIELD();
}
PROCESS_END();
}

View File

@ -2,6 +2,6 @@ CONTIKI_PROJECT = trickle-library
all: $(CONTIKI_PROJECT)
CONTIKI = ../..
CONTIKI = ../../..
include $(CONTIKI)/Makefile.include

Some files were not shown because too many files have changed in this diff Show More