1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

examples/gnrc_border_router: add example for WiFi <-> esp_now BR

This adds an example configuration to use the gnrc_border_router to route
between a regular WiFi network and an esp_now network.

All you need is an esp based board (esp8266, esp32).

Configure the access data for your WiFi network in `Makefile.esp.conf`,
then run

    make BOARD=esp32-wroom-32 USE_ETHOS=0 USE_ESP=1 flash term

to turn a e.g. `esp32-wroom-32` into a boarder router.

You can use other esp based boards as nodes in the network by flashing
e.g. the `gnrc_networking` example.
Be sure to add `CFLAGS += -DGNRC_IPV6_NIB_CONF_SLAAC=1` as otherwise
your esp_now node will not receive a link-local IP address.
This commit is contained in:
Benjamin Valentin 2020-03-03 23:38:33 +01:00
parent ed316309c8
commit 31245849fb
3 changed files with 34 additions and 10 deletions

View File

@ -7,6 +7,18 @@ BOARD ?= samr21-xpro
# This has to be the absolute path to the RIOT base directory: # This has to be the absolute path to the RIOT base directory:
RIOTBASE ?= $(CURDIR)/../.. RIOTBASE ?= $(CURDIR)/../..
# Default to using ethos for providing the uplink when not on native
UPLINK ?= ethos
# Check if the selected Uplink is valid
ifeq (,$(filter ethos slip wifi,$(UPLINK)))
$(error Supported uplinks are `ethos`, `slip` and `wifi`)
endif
# Set the SSID and password of your WiFi network here
WIFI_SSID ?= "Your_WiFi_name"
WIFI_PASS ?= "Your_secure_password"
# Include packages that pull up and auto-init the link layer. # Include packages that pull up and auto-init the link layer.
# NOTE: 6LoWPAN will be included if IEEE802.15.4 devices are present # NOTE: 6LoWPAN will be included if IEEE802.15.4 devices are present
USEMODULE += gnrc_netdev_default USEMODULE += gnrc_netdev_default
@ -24,8 +36,12 @@ USEMODULE += ps
# configure the node as a RPL DODAG root when receiving a prefix. # configure the node as a RPL DODAG root when receiving a prefix.
#USEMODULE += gnrc_rpl #USEMODULE += gnrc_rpl
# Optionally use DHCPv6 instead of UHCP # When using a WiFi uplink we should use DHCPv6
USE_DHCPV6 ?= 0 ifeq (wifi,$(UPLINK))
USE_DHCPV6 ?= 1
else
USE_DHCPV6 ?= 0
endif
ifeq (1,$(USE_DHCPV6)) ifeq (1,$(USE_DHCPV6))
# include DHCPv6 client for 6LoWPAN border router # include DHCPv6 client for 6LoWPAN border router
@ -35,10 +51,6 @@ else
USEMODULE += gnrc_uhcpc USEMODULE += gnrc_uhcpc
endif endif
# Optionally use SLIP instead of ethos when not on native
# (added to USEMODULE in Makefile.board.dep)
USE_SLIP ?= 0
# Use two network interfaces # Use two network interfaces
GNRC_NETIF_NUMOF := 2 GNRC_NETIF_NUMOF := 2
@ -60,14 +72,17 @@ IPV6_PREFIX ?= 2001:db8::/64
# communication and stdio over UART, but not on native, as native has a tap # communication and stdio over UART, but not on native, as native has a tap
# interface towards the host. # interface towards the host.
ifeq (,$(filter native,$(BOARD))) ifeq (,$(filter native,$(BOARD)))
ifeq (1,$(USE_SLIP)) ifeq (slip,$(UPLINK))
# SLIP baudrate and UART device can be configured from make command # SLIP baudrate and UART device can be configured from make command
SLIP_BAUDRATE ?= 115200 SLIP_BAUDRATE ?= 115200
include $(CURDIR)/Makefile.slip.conf include $(CURDIR)/Makefile.slip.conf
else else ifeq (ethos,$(UPLINK))
# ethos baudrate can be configured from make command # ethos baudrate can be configured from make command
ETHOS_BAUDRATE ?= 115200 ETHOS_BAUDRATE ?= 115200
include $(CURDIR)/Makefile.ethos.conf include $(CURDIR)/Makefile.ethos.conf
else ifeq (wifi,$(UPLINK))
# SSID and Password need to be configured
include $(CURDIR)/Makefile.wifi.conf
endif endif
else else
include $(CURDIR)/Makefile.native.conf include $(CURDIR)/Makefile.native.conf

View File

@ -1,9 +1,16 @@
# Put board specific dependencies here # Put board specific dependencies here
ifeq (,$(filter native,$(BOARD))) ifeq (,$(filter native,$(BOARD)))
ifeq (1,$(USE_SLIP)) ifeq (slip,$(UPLINK))
USEMODULE += slipdev_stdio USEMODULE += slipdev_stdio
else else ifeq (ethos,$(UPLINK))
USEMODULE += stdio_ethos USEMODULE += stdio_ethos
else ifeq (wifi,$(UPLINK))
ifneq (,$(filter esp32 esp8266,$(CPU)))
USEMODULE += esp_wifi
USEMODULE += esp_now
else
$(error Only esp32 and esp8266 are currently supported)
endif
endif endif
else else
USEMODULE += socket_zep USEMODULE += socket_zep

View File

@ -0,0 +1,2 @@
CFLAGS += -DESP_WIFI_SSID=\"$(WIFI_SSID)\"
CFLAGS += -DESP_WIFI_PASS=\"$(WIFI_PASS)\"