From 5d720753432559aa0c9c2ddaad63cafb04096345 Mon Sep 17 00:00:00 2001 From: Lasse Rosenow Date: Wed, 22 Jan 2025 18:21:53 +0100 Subject: [PATCH] Switch to static ipv6 addresses for the riot coap example --- examples/riot/README.md | 54 ++----------- .../riot/coap_federated/receiver/Makefile | 15 +--- examples/riot/coap_federated/receiver/main.c | 4 +- examples/riot/coap_federated/sender/Makefile | 15 +--- examples/riot/coap_federated/sender/main.c | 4 +- .../coap_federated_lf/src/CoapFederatedLF.lf | 76 +++++++++---------- 6 files changed, 52 insertions(+), 116 deletions(-) diff --git a/examples/riot/README.md b/examples/riot/README.md index a81fb92a0..bf27eb9bc 100644 --- a/examples/riot/README.md +++ b/examples/riot/README.md @@ -35,62 +35,20 @@ First you need to create the `tap` interfaces so that the `sender` and `receiver sudo $RIOTBASE/dist/tools/tapsetup/tapsetup ``` -#### Get IPv6 address of receiver +#### Start the Sender -Enter the directory of the `sender` application: - -```shell -cd coap_federated/sender -``` - -Get the IP address of the `receiver` by specifying the `PORT=tap1` and `ONLY_PRINT_IP=1` environment variables: - -*If the program returns more than one IP-Address then select the one that starts with `fe80`*. - -```shell -make ONLY_PRINT_IP=1 BOARD=native PORT=tap1 all term -``` - -The resulting program will print out the IPv6 address of `tap1` and terminate. -This address must be used when starting the sender below. - - -#### Get IPv6 address of sender - -Enter the directory of the `receiver` application: - -```shell -cd coap_federated/receiver -``` - -Get the IP address of the `sender` by specifying the `PORT=tap0` and `ONLY_PRINT_IP=1` environment variables: - -*If the program returns more than one IP-Address then select the one that starts with `fe80`*. - -```shell -make ONLY_PRINT_IP=1 BOARD=native PORT=tap0 all term -``` - -The resulting program will print out the IPv6 address of `tap0` and terminate. -This address must be used when starting the receiver below. - -#### Start the applications - -##### Sender -Start the sender with `PORT=tap0`, make sure to replace `REMOTE_ADDRESS` with -the address of `tap1` that you found above. +Start the sender with `PORT=tap0`: ```shell cd sender -make REMOTE_ADDRESS=fe80::8cc3:33ff:febb:1b3 BOARD=native PORT=tap0 all term +make BOARD=native PORT=tap0 all term ``` -##### Receiver +#### Start the Receiver -Start the receiver with `PORT=tap1`, make sure to replace `REMOTE_ADDRESS` with -the address of `tap0` that you found above. +Start the receiver with `PORT=tap1`: ```shell cd receiver -make REMOTE_ADDRESS=fe80::44e5:1bff:fee4:dac8 BOARD=native PORT=tap1 all term +make BOARD=native PORT=tap1 all term ``` diff --git a/examples/riot/coap_federated/receiver/Makefile b/examples/riot/coap_federated/receiver/Makefile index 7a6d22cb2..f5e1288c1 100755 --- a/examples/riot/coap_federated/receiver/Makefile +++ b/examples/riot/coap_federated/receiver/Makefile @@ -29,17 +29,8 @@ CFLAGS += -DCONFIG_GCOAP_NO_RETRANS_BACKOFF=1 CFLAGS += -DCONFIG_COAP_ACK_TIMEOUT_MS=400 CFLAGS += -DCONFIG_COAP_MAX_RETRANSMIT=4 -# Check if ONLY_PRINT_IP is defined -# If ONLY_PRINT_IP is defined the REMOTE_ADDRESS is not needed -ifdef ONLY_PRINT_IP - # ONLY_PRINT_IP is defined => Set CFLAGS for it - CFLAGS += -DONLY_PRINT_IP=$(ONLY_PRINT_IP) -else ifdef REMOTE_ADDRESS - # REMOTE_ADDRESS is defined => Set CFLAGS for it - CFLAGS += -DREMOTE_ADDRESS=\"$(REMOTE_ADDRESS)\" -else - # Neither is defined - $(error Either define REMOTE_ADDRESS or set ONLY_PRINT_IP=1 to print the IP-Address of this device.) -endif +# Static IPv6 address +CFLAGS += -DCONFIG_GNRC_IPV6_STATIC_LLADDR='"fe80::cafe:cafe:cafe:2"' +CFLAGS += -DCONFIG_GNRC_IPV6_STATIC_LLADDR_IS_FIXED=1 include $(CURDIR)/../../../../make/riot/riot.mk diff --git a/examples/riot/coap_federated/receiver/main.c b/examples/riot/coap_federated/receiver/main.c index 8afb351b8..05af6cf80 100755 --- a/examples/riot/coap_federated/receiver/main.c +++ b/examples/riot/coap_federated/receiver/main.c @@ -1,9 +1,7 @@ #include "reactor-uc/platform/riot/coap_udp_ip_channel.h" #include "reactor-uc/reactor-uc.h" -#ifndef REMOTE_ADDRESS -#define REMOTE_ADDRESS "fe80::44e5:1bff:fee4:dac8" -#endif +#define REMOTE_ADDRESS "fe80::cafe:cafe:cafe:1" #define REMOTE_PROTOCOL_FAMILY AF_INET6 diff --git a/examples/riot/coap_federated/sender/Makefile b/examples/riot/coap_federated/sender/Makefile index ad03fccd1..9120d7d1c 100755 --- a/examples/riot/coap_federated/sender/Makefile +++ b/examples/riot/coap_federated/sender/Makefile @@ -29,17 +29,8 @@ CFLAGS += -DCONFIG_GCOAP_NO_RETRANS_BACKOFF=1 CFLAGS += -DCONFIG_COAP_ACK_TIMEOUT_MS=400 CFLAGS += -DCONFIG_COAP_MAX_RETRANSMIT=4 -# Check if ONLY_PRINT_IP is defined -# If ONLY_PRINT_IP is defined the REMOTE_ADDRESS is not needed -ifdef ONLY_PRINT_IP - # ONLY_PRINT_IP is defined => Set CFLAGS for it - CFLAGS += -DONLY_PRINT_IP=$(ONLY_PRINT_IP) -else ifdef REMOTE_ADDRESS - # REMOTE_ADDRESS is defined => Set CFLAGS for it - CFLAGS += -DREMOTE_ADDRESS=\"$(REMOTE_ADDRESS)\" -else - # Neither is defined - $(error Either define REMOTE_ADDRESS or set ONLY_PRINT_IP=1 to print the IP-Address of this device) -endif +# Static IPv6 address +CFLAGS += -DCONFIG_GNRC_IPV6_STATIC_LLADDR='"fe80::cafe:cafe:cafe:1"' +CFLAGS += -DCONFIG_GNRC_IPV6_STATIC_LLADDR_IS_FIXED=1 include $(CURDIR)/../../../../make/riot/riot.mk diff --git a/examples/riot/coap_federated/sender/main.c b/examples/riot/coap_federated/sender/main.c index 0f0a8ac15..4e90b7287 100755 --- a/examples/riot/coap_federated/sender/main.c +++ b/examples/riot/coap_federated/sender/main.c @@ -1,9 +1,7 @@ #include "reactor-uc/reactor-uc.h" #include "reactor-uc/platform/riot/coap_udp_ip_channel.h" -#ifndef REMOTE_ADDRESS -#define REMOTE_ADDRESS "fe80::8cc3:33ff:febb:1b3" -#endif +#define REMOTE_ADDRESS "fe80::cafe:cafe:cafe:2" #define REMOTE_PROTOCOL_FAMILY AF_INET6 diff --git a/examples/riot/coap_federated_lf/src/CoapFederatedLF.lf b/examples/riot/coap_federated_lf/src/CoapFederatedLF.lf index bb80be9e3..efd3c34f1 100644 --- a/examples/riot/coap_federated_lf/src/CoapFederatedLF.lf +++ b/examples/riot/coap_federated_lf/src/CoapFederatedLF.lf @@ -1,41 +1,41 @@ target uC { - platform: RIOT, - timeout: 1sec - } - - reactor Src(id: int = 0) { - output out: int - reaction(startup) -> out{= - printf("Hello from Src!\n"); - lf_set(out, self->id); - =} - } - - reactor Dst { - input in: int - state check: bool = false - reaction(startup) {= - printf("Hello from Dst!\n"); - =} - reaction(in) {= - printf("Received %d from Src\n", in->value); - validate(in->value == 42); - self->check = true; - env->request_shutdown(env); - =} - - reaction(shutdown) {= - validate(self->check); - =} - } - - federated reactor { - @interface_coap(name="if1", address="fe80::44e5:1bff:fee4:dac8") - r1 = new Src(id=42) + platform: RIOT, + timeout: 1sec +} - @interface_coap(name="if1", address="fe80::8cc3:33ff:febb:1b3") - r2 = new Dst() +reactor Src(id: int = 0) { + output out: int + reaction(startup) -> out{= + printf("Hello from Src!\n"); + lf_set(out, self->id); + =} +} - @link(left="if1", right="if1") - r1.out -> r2.in - } \ No newline at end of file +reactor Dst { + input in: int + state check: bool = false + reaction(startup) {= + printf("Hello from Dst!\n"); + =} + reaction(in) {= + printf("Received %d from Src\n", in->value); + validate(in->value == 42); + self->check = true; + env->request_shutdown(env); + =} + + reaction(shutdown) {= + validate(self->check); + =} +} + +federated reactor { + @interface_coap(name="if1", address="fe80::44e5:1bff:fee4:dac8") + r1 = new Src(id=42) + + @interface_coap(name="if1", address="fe80::8cc3:33ff:febb:1b3") + r2 = new Dst() + + @link(left="if1", right="if1") + r1.out -> r2.in +} \ No newline at end of file