diff --git a/examples/rpl-udp/Makefile b/examples/rpl-udp/Makefile
index ecca51ed1..0a4d4d4e5 100644
--- a/examples/rpl-udp/Makefile
+++ b/examples/rpl-udp/Makefile
@@ -1,11 +1,4 @@
all: udp-client udp-server udp-client-packet-debug
+
CONTIKI=../..
-
-ifdef SERVER_REPLY
-CFLAGS+=-DSERVER_REPLY=$(SERVER_REPLY)
-endif
-ifdef PERIOD
-CFLAGS+=-DPERIOD=$(PERIOD)
-endif
-
include $(CONTIKI)/Makefile.include
diff --git a/examples/rpl-udp/project-conf.h b/examples/rpl-udp/project-conf.h
new file mode 100644
index 000000000..4575084e9
--- /dev/null
+++ b/examples/rpl-udp/project-conf.h
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+
+#ifndef PROJECT_CONF_H_
+#define PROJECT_CONF_H_
+
+/* Hardcoded global IPv6 address of the server.
+ * Must match link-local */
+#define INIT_SERVER_IPADDR(ipaddr) \
+ uip_ip6addr(&ipaddr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0x0212, 0x7401, 0x0001, 0x0101)
+
+#endif /* PROJECT_CONF_H_ */
diff --git a/examples/rpl-udp/rpl-udp-packet-debug.csc b/examples/rpl-udp/rpl-udp-packet-debug.csc
index 187c6cded..2349934e6 100644
--- a/examples/rpl-udp/rpl-udp-packet-debug.csc
+++ b/examples/rpl-udp/rpl-udp-packet-debug.csc
@@ -7,7 +7,7 @@
[APPS_DIR]/collect-view
[APPS_DIR]/powertracker
- Data collection network using IPv6 and RPL
+ RPL-UDP Example -- Packet Debug
generated
5000000
@@ -25,7 +25,7 @@
sky1
Sky Mote Type #sky1
[CONTIKI_DIR]/examples/rpl-udp/udp-server.c
- make clean udp-server.sky TARGET=sky DEFINES=TEST_MORE_ROUTES=1
+ make clean udp-server.sky TARGET=sky
[CONTIKI_DIR]/examples/rpl-udp/udp-server.sky
org.contikios.cooja.interfaces.Position
org.contikios.cooja.interfaces.RimeAddress
@@ -48,7 +48,7 @@
sky2
Sky Mote Type #sky2
[CONTIKI_DIR]/examples/rpl-udp/udp-client-packet-debug.c
- make clean packet-debug.sky TARGET=sky
+ make clean udp-client-packet-debug.sky TARGET=sky
[CONTIKI_DIR]/examples/rpl-udp/udp-client-packet-debug.sky
org.contikios.cooja.interfaces.Position
org.contikios.cooja.interfaces.RimeAddress
@@ -70,8 +70,8 @@
org.contikios.cooja.interfaces.Position
- 48.435974731198804
- -66.16503914182063
+ 30.051578821079996
+ -64.69428746901113
0.0
@@ -88,8 +88,8 @@
org.contikios.cooja.interfaces.Position
- 4.049356309774755
- 98.28771308774003
+ 21.31366587648077
+ -34.91404431659299
0.0
@@ -106,8 +106,8 @@
org.contikios.cooja.interfaces.Position
- 127.9689727848476
- 91.71883780610729
+ 57.165216906562264
+ -34.02362118358309
0.0
@@ -124,8 +124,8 @@
org.contikios.cooja.interfaces.Position
- 57.897299848739024
- 92.47229665488265
+ 75.1786320042507
+ -60.441618586411096
0.0
@@ -142,8 +142,8 @@
org.contikios.cooja.interfaces.Position
- 47.34887596588397
- -30.341495695501195
+ 59.11488934836
+ -7.544844766953879
0.0
@@ -160,8 +160,8 @@
org.contikios.cooja.interfaces.Position
- 47.13486576528276
- 32.944481932122315
+ 91.720430365082
+ -22.736406051209734
0.0
@@ -178,8 +178,8 @@
org.contikios.cooja.interfaces.Position
- -11.42091423859419
- 17.879870626121914
+ 92.90372351580778
+ 2.532304558933846
0.0
@@ -196,8 +196,8 @@
org.contikios.cooja.interfaces.Position
- 118.92746659954325
- 57.05973076244069
+ 120.28246466847423
+ 19.133402903417824
0.0
@@ -210,425 +210,11 @@
sky2
-
-
-
- org.contikios.cooja.interfaces.Position
- 53.68872892015448
- 59.887319605093715
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 9
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- 16.45706316609417
- 23.9075414163248
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 10
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- -18.9555027263478
- 75.14274313304935
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 11
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- 29.265863595275306
- 85.6911670159044
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 12
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- -39.298891643282545
- -3.9704359883635574
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 13
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- 66.93880603404335
- -42.39683727590697
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 14
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- 94.81678343873172
- 26.921376811426246
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 15
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- -43.06618588715935
- 30.68867105530305
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 16
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- -34.02467970185502
- -24.313824905298304
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 17
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- -28.750467760427494
- 48.01822457713635
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 18
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- 124.95513738974614
- 20.140247172447996
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 19
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- 15.703604317318808
- -47.6710492173345
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 20
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- -40.05235049205791
- 92.47229665488265
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 21
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- 121.18784314586934
- -24.313824905298304
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 22
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- 88.03565379975346
- -44.657213822233054
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 23
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- 24.745110502623138
- -1.7100594420374744
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 24
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- 94.06332458995635
- -2.4635182908128352
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 25
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- -4.639784599615941
- -9.998106778566445
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 26
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- -13.681290784920272
- -50.684884612435944
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 27
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- 103.10483077526068
- 96.99304974753483
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 28
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- 8.922474678340558
- 59.320107308766765
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 29
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- 58.650758697514384
- 2.8106936506146916
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 30
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- 90.59867707439
- 67.97632874312737
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 31
-
- sky2
-
org.contikios.cooja.plugins.SimControl
- 259
- 3
+ 249
+ 4
184
3
15
@@ -639,11 +225,11 @@
org.contikios.cooja.plugins.skins.IDVisualizerSkin
org.contikios.cooja.plugins.skins.UDGMVisualizerSkin
org.contikios.cooja.plugins.skins.AttributeVisualizerSkin
- 2.349818846983307 0.0 0.0 2.349818846983307 150.19773526533348 176.95275613586946
+ 1.3598488697820064 0.0 0.0 1.3598488697820064 6.142207908179105 118.20877091196155
- 520
- 2
- 523
+ 234
+ 1
+ 227
14
210
@@ -654,58 +240,46 @@
- 937
+ 1011
0
- 213
- 265
- 16
+ 556
+ 759
+ 7
- org.contikios.cooja.plugins.ScriptRunner
+ org.contikios.cooja.plugins.TimeLine
-
- true
+ 0
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+
+
+
+ 681.712557066089
- 651
- 1
- 550
- 547
- 181
+ 1804
+ 3
+ 352
+ 0
+ 567
+
+
+ org.contikios.cooja.plugins.RadioLogger
+
+ 150
+
+ false
+ false
+
+ 500
+ 2
+ 546
+ 259
+ 12
-
diff --git a/examples/rpl-udp/rpl-udp.csc b/examples/rpl-udp/rpl-udp.csc
index 6aa1730b9..f2a217a7b 100644
--- a/examples/rpl-udp/rpl-udp.csc
+++ b/examples/rpl-udp/rpl-udp.csc
@@ -7,7 +7,7 @@
[APPS_DIR]/collect-view
[APPS_DIR]/powertracker
- Data collection network using IPv6 and RPL
+ RPL-UDP Example
generated
5000000
@@ -25,7 +25,7 @@
sky1
Sky Mote Type #sky1
[CONTIKI_DIR]/examples/rpl-udp/udp-server.c
- make clean udp-server.sky TARGET=sky DEFINES=TEST_MORE_ROUTES=1
+ make clean udp-server.sky TARGET=sky
[CONTIKI_DIR]/examples/rpl-udp/udp-server.sky
org.contikios.cooja.interfaces.Position
org.contikios.cooja.interfaces.RimeAddress
@@ -70,8 +70,8 @@
org.contikios.cooja.interfaces.Position
- 48.435974731198804
- -66.16503914182063
+ 30.051578821079996
+ -64.69428746901113
0.0
@@ -88,8 +88,8 @@
org.contikios.cooja.interfaces.Position
- 4.049356309774755
- 98.28771308774003
+ 21.31366587648077
+ -34.91404431659299
0.0
@@ -106,8 +106,8 @@
org.contikios.cooja.interfaces.Position
- 127.9689727848476
- 91.71883780610729
+ 57.165216906562264
+ -34.02362118358309
0.0
@@ -124,8 +124,8 @@
org.contikios.cooja.interfaces.Position
- 57.897299848739024
- 92.47229665488265
+ 75.1786320042507
+ -60.441618586411096
0.0
@@ -142,8 +142,8 @@
org.contikios.cooja.interfaces.Position
- 47.34887596588397
- -30.341495695501195
+ 59.11488934836
+ -7.544844766953879
0.0
@@ -160,8 +160,8 @@
org.contikios.cooja.interfaces.Position
- 47.13486576528276
- 32.944481932122315
+ 91.720430365082
+ -22.736406051209734
0.0
@@ -178,8 +178,8 @@
org.contikios.cooja.interfaces.Position
- -11.42091423859419
- 17.879870626121914
+ 92.90372351580778
+ 2.532304558933846
0.0
@@ -196,8 +196,8 @@
org.contikios.cooja.interfaces.Position
- 118.92746659954325
- 57.05973076244069
+ 120.28246466847423
+ 19.133402903417824
0.0
@@ -210,425 +210,11 @@
sky2
-
-
-
- org.contikios.cooja.interfaces.Position
- 53.68872892015448
- 59.887319605093715
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 9
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- 16.45706316609417
- 23.9075414163248
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 10
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- -18.9555027263478
- 75.14274313304935
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 11
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- 29.265863595275306
- 85.6911670159044
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 12
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- -39.298891643282545
- -3.9704359883635574
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 13
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- 66.93880603404335
- -42.39683727590697
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 14
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- 94.81678343873172
- 26.921376811426246
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 15
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- -43.06618588715935
- 30.68867105530305
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 16
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- -34.02467970185502
- -24.313824905298304
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 17
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- -28.750467760427494
- 48.01822457713635
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 18
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- 124.95513738974614
- 20.140247172447996
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 19
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- 15.703604317318808
- -47.6710492173345
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 20
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- -40.05235049205791
- 92.47229665488265
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 21
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- 121.18784314586934
- -24.313824905298304
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 22
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- 88.03565379975346
- -44.657213822233054
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 23
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- 24.745110502623138
- -1.7100594420374744
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 24
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- 94.06332458995635
- -2.4635182908128352
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 25
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- -4.639784599615941
- -9.998106778566445
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 26
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- -13.681290784920272
- -50.684884612435944
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 27
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- 103.10483077526068
- 96.99304974753483
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 28
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- 8.922474678340558
- 59.320107308766765
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 29
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- 58.650758697514384
- 2.8106936506146916
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 30
-
- sky2
-
-
-
-
- org.contikios.cooja.interfaces.Position
- 90.59867707439
- 67.97632874312737
- 0.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspClock
- 1.0
-
-
- org.contikios.cooja.mspmote.interfaces.MspMoteID
- 31
-
- sky2
-
org.contikios.cooja.plugins.SimControl
- 259
- 3
+ 249
+ 4
184
3
15
@@ -639,11 +225,11 @@
org.contikios.cooja.plugins.skins.IDVisualizerSkin
org.contikios.cooja.plugins.skins.UDGMVisualizerSkin
org.contikios.cooja.plugins.skins.AttributeVisualizerSkin
- 2.349818846983307 0.0 0.0 2.349818846983307 150.19773526533348 176.95275613586946
+ 1.3598488697820064 0.0 0.0 1.3598488697820064 6.142207908179105 118.20877091196155
- 520
- 2
- 523
+ 234
+ 1
+ 227
14
210
@@ -654,58 +240,47 @@
- 937
+ 1011
0
- 213
- 265
- 16
+ 556
+ 759
+ 7
- org.contikios.cooja.plugins.ScriptRunner
+ org.contikios.cooja.plugins.TimeLine
-
- true
+ 0
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+
+
+
+ 681.712557066089
- 651
- 1
- 550
- 547
- 181
+ 1804
+ 3
+ 352
+ 0
+ 567
+
+
+ org.contikios.cooja.plugins.RadioLogger
+
+ 150
+
+ false
+ false
+
+ 500
+ 2
+ 546
+ 259
+ 12
diff --git a/examples/rpl-udp/udp-client-packet-debug.c b/examples/rpl-udp/udp-client-packet-debug.c
index 305ceb8ae..032075060 100644
--- a/examples/rpl-udp/udp-client-packet-debug.c
+++ b/examples/rpl-udp/udp-client-packet-debug.c
@@ -1,109 +1,43 @@
-/*
- * 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 "random.h"
+#include "net/netstack.h"
+#include "net/ipv6/simple-udp.h"
#include "net/ipv6/uipbuf.h"
-#include
-#include
-#include "dev/serial-line.h"
-#include "net/ipv6/uip-ds6-route.h"
+#include "sys/log.h"
+#define LOG_MODULE "App"
+#define LOG_LEVEL LOG_LEVEL_INFO
-#define UDP_CLIENT_PORT 8765
-#define UDP_SERVER_PORT 5678
+#define WITH_SERVER_REPLY 1
+#define UDP_CLIENT_PORT 8765
+#define UDP_SERVER_PORT 5678
+
+static struct simple_udp_connection udp_conn;
+
+#define START_INTERVAL (15 * CLOCK_SECOND)
+#define SEND_INTERVAL (60 * CLOCK_SECOND)
#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;
+static struct simple_udp_connection udp_conn;
+static uip_ipaddr_t server_ipaddr;
/*---------------------------------------------------------------------------*/
-PROCESS(udp_client_process, "UDP client process");
+PROCESS(udp_client_process, "UDP client -- packet debug");
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");
+ LOG_INFO("Incoming packet proto: %d from ", proto);
+ LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr);
+ LOG_INFO_("\n");
return NETSTACK_IP_PROCESS;
}
-
+/*---------------------------------------------------------------------------*/
static enum netstack_ip_action
ip_output(const linkaddr_t *localdest)
{
@@ -111,61 +45,64 @@ ip_output(const linkaddr_t *localdest)
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);
- }
+ LOG_INFO("Outgoing packet (%s) proto: %d to ", is_me ? "send" : "fwd ", proto);
+ LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr);
+ LOG_INFO_("\n");
return NETSTACK_IP_PROCESS;
}
-
+/*---------------------------------------------------------------------------*/
struct netstack_ip_packet_processor packet_processor = {
.process_input = ip_input,
.process_output = ip_output
};
-
+/*---------------------------------------------------------------------------*/
+static void
+udp_rx_callback(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 count = *(unsigned *)data;
+ LOG_INFO("Received response %u from ", count);
+ LOG_INFO_6ADDR(sender_addr);
+ LOG_INFO_("\n");
+}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(udp_client_process, ev, data)
{
- static struct etimer periodic;
- static struct ctimer backoff_timer;
+ static struct etimer periodic_timer;
+ static unsigned count;
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));
+ INIT_SERVER_IPADDR(server_ipaddr);
+ /* Initialize UDP connection */
+ simple_udp_register(&udp_conn, UDP_CLIENT_PORT, NULL,
+ UDP_SERVER_PORT, udp_rx_callback);
/* register packet processor */
netstack_ip_packet_processor_add(&packet_processor);
- etimer_set(&periodic, SEND_INTERVAL);
+ etimer_set(&periodic_timer, random_rand() % SEND_INTERVAL);
+ PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&periodic_timer));
+ etimer_set(&periodic_timer, SEND_INTERVAL);
while(1) {
- PROCESS_YIELD();
- if(ev == tcpip_event) {
- tcpip_handler();
+ PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&periodic_timer));
+
+ if(rpl_is_reachable()) {
+ LOG_INFO("Sending request %u to ", count);
+ LOG_INFO_6ADDR(&server_ipaddr);
+ LOG_INFO_("\n");
+ simple_udp_sendto(&udp_conn, &count, sizeof(count), &server_ipaddr);
+ count++;
+ } else {
+ LOG_INFO("Not reachable yet %p\n", rpl_get_any_dag());
}
- if(etimer_expired(&periodic)) {
- etimer_reset(&periodic);
- ctimer_set(&backoff_timer, SEND_TIME, send_packet, NULL);
- }
+ etimer_reset(&periodic_timer);
}
PROCESS_END();
diff --git a/examples/rpl-udp/udp-client.c b/examples/rpl-udp/udp-client.c
index 95612b7f8..c3dd7ba7e 100644
--- a/examples/rpl-udp/udp-client.c
+++ b/examples/rpl-udp/udp-client.c
@@ -1,247 +1,73 @@
-/*
- * 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
-#include
+#include "rpl.h"
+#include "random.h"
+#include "net/netstack.h"
+#include "net/ipv6/simple-udp.h"
-#include "dev/serial-line.h"
-#include "net/ipv6/uip-ds6-route.h"
-#include "rpl-dag-root.h"
+#include "sys/log.h"
+#define LOG_MODULE "App"
+#define LOG_LEVEL LOG_LEVEL_INFO
-#define UDP_CLIENT_PORT 8765
-#define UDP_SERVER_PORT 5678
+#define WITH_SERVER_REPLY 1
+#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
+static struct simple_udp_connection udp_conn;
#define START_INTERVAL (15 * CLOCK_SECOND)
-#define SEND_INTERVAL (PERIOD * CLOCK_SECOND)
-#define SEND_TIME (random_rand() % (SEND_INTERVAL))
-#define MAX_PAYLOAD_LEN 30
+#define SEND_INTERVAL (60 * CLOCK_SECOND)
-static struct uip_udp_conn *client_conn;
+static struct simple_udp_connection udp_conn;
static uip_ipaddr_t server_ipaddr;
/*---------------------------------------------------------------------------*/
-PROCESS(udp_client_process, "UDP client process");
+PROCESS(udp_client_process, "UDP client");
AUTOSTART_PROCESSES(&udp_client_process);
/*---------------------------------------------------------------------------*/
-static int seq_id;
-static int reply;
-
static void
-tcpip_handler(void)
+udp_rx_callback(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)
{
- 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
+ unsigned count = *(unsigned *)data;
+ LOG_INFO("Received response %u from ", count);
+ LOG_INFO_6ADDR(sender_addr);
+ LOG_INFO_("\n");
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(udp_client_process, ev, data)
{
- static struct etimer periodic;
- static struct ctimer backoff_timer;
+ static struct etimer periodic_timer;
+ static unsigned count;
PROCESS_BEGIN();
- PROCESS_PAUSE();
+ INIT_SERVER_IPADDR(server_ipaddr);
+ /* Initialize UDP connection */
+ simple_udp_register(&udp_conn, UDP_CLIENT_PORT, NULL,
+ UDP_SERVER_PORT, udp_rx_callback);
- 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);
+ etimer_set(&periodic_timer, random_rand() % SEND_INTERVAL);
+ PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&periodic_timer));
+ etimer_set(&periodic_timer, SEND_INTERVAL);
while(1) {
- PROCESS_YIELD();
- if(ev == tcpip_event) {
- tcpip_handler();
+ PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&periodic_timer));
+
+ if(rpl_is_reachable()) {
+ LOG_INFO("Sending request %u to ", count);
+ LOG_INFO_6ADDR(&server_ipaddr);
+ LOG_INFO_("\n");
+ simple_udp_sendto(&udp_conn, &count, sizeof(count), &server_ipaddr);
+ count++;
+ } else {
+ LOG_INFO("Not reachable yet %p\n", rpl_get_any_dag());
}
- 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);
- }
+ etimer_reset(&periodic_timer);
}
PROCESS_END();
diff --git a/examples/rpl-udp/udp-server.c b/examples/rpl-udp/udp-server.c
index 1ae29377d..95bf29f37 100644
--- a/examples/rpl-udp/udp-server.c
+++ b/examples/rpl-udp/udp-server.c
@@ -28,119 +28,78 @@
*/
#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
-#include
-#include
-#include
+#include "net/ipv6/simple-udp.h"
-#define DEBUG DEBUG_PRINT
-#include "net/ipv6/uip-debug.h"
-
-#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
+#include "sys/log.h"
+#define LOG_MODULE "App"
+#define LOG_LEVEL LOG_LEVEL_INFO
+#define WITH_SERVER_REPLY 1
#define UDP_CLIENT_PORT 8765
#define UDP_SERVER_PORT 5678
-#define UDP_EXAMPLE_ID 190
+static struct simple_udp_connection udp_conn;
-static struct uip_udp_conn *server_conn;
-
-PROCESS(udp_server_process, "UDP server process");
+PROCESS(udp_server_process, "UDP server");
AUTOSTART_PROCESSES(&udp_server_process);
/*---------------------------------------------------------------------------*/
static void
-tcpip_handler(void)
+udp_rx_callback(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)
{
- 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;
- }
- }
- }
+ unsigned count = *(unsigned *)data;
+ LOG_INFO("Received request %u from ", count);
+ LOG_INFO_6ADDR(sender_addr);
+ LOG_INFO_("\n");
+#if WITH_SERVER_REPLY
+ LOG_INFO("Sending reply %u to ", count);
+ LOG_INFO_6ADDR(sender_addr);
+ LOG_INFO_("\n");
+ simple_udp_sendto(&udp_conn, &count, sizeof(count), sender_addr);
+#endif /* WITH_SERVER_REPLY */
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(udp_server_process, ev, data)
{
uip_ipaddr_t ipaddr;
+ uip_ds6_addr_t *link_local_addr;
PROCESS_BEGIN();
- PROCESS_PAUSE();
+ /* Initialize Global address */
+ INIT_SERVER_IPADDR(ipaddr);
+ LOG_INFO("Global IPv6 address: ");
+ LOG_INFO_6ADDR(&ipaddr);
+ LOG_INFO_("\n");
- 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");
+ /* Get link-local address */
+ link_local_addr = uip_ds6_get_link_local(-1);
+ if(link_local_addr == NULL) {
+ LOG_ERR("No link-local address\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
- }
+ if(memcmp(((uint8_t*)&link_local_addr->ipaddr + 8),
+ ((uint8_t*)&ipaddr + 8), 8)) {
+ LOG_ERR("Global IPv6 address does not match link-local IPv6 address\n");
+ PROCESS_EXIT();
}
+ /* Initialize DAG root */
+ rpl_dag_root_init(&ipaddr, &ipaddr);
+ rpl_dag_root_init_dag_immediately();
+
+ /* Initialize UDP connection */
+ simple_udp_register(&udp_conn, UDP_SERVER_PORT, NULL,
+ UDP_CLIENT_PORT, udp_rx_callback);
+
PROCESS_END();
}
/*---------------------------------------------------------------------------*/