mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #13545 from benpicco/esp-now-br
examples/gnrc_border_router: add example for WiFi ⇆ esp_now border router
This commit is contained in:
commit
16f55475bf
@ -7,6 +7,18 @@ BOARD ?= samr21-xpro
|
||||
# This has to be the absolute path to the RIOT base directory:
|
||||
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.
|
||||
# NOTE: 6LoWPAN will be included if IEEE802.15.4 devices are present
|
||||
USEMODULE += gnrc_netdev_default
|
||||
@ -24,8 +36,12 @@ USEMODULE += ps
|
||||
# configure the node as a RPL DODAG root when receiving a prefix.
|
||||
#USEMODULE += gnrc_rpl
|
||||
|
||||
# Optionally use DHCPv6 instead of UHCP
|
||||
USE_DHCPV6 ?= 0
|
||||
# When using a WiFi uplink we should use DHCPv6
|
||||
ifeq (wifi,$(UPLINK))
|
||||
USE_DHCPV6 ?= 1
|
||||
else
|
||||
USE_DHCPV6 ?= 0
|
||||
endif
|
||||
|
||||
ifeq (1,$(USE_DHCPV6))
|
||||
# include DHCPv6 client for 6LoWPAN border router
|
||||
@ -35,10 +51,6 @@ else
|
||||
USEMODULE += gnrc_uhcpc
|
||||
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
|
||||
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
|
||||
# interface towards the host.
|
||||
ifeq (,$(filter native,$(BOARD)))
|
||||
ifeq (1,$(USE_SLIP))
|
||||
ifeq (slip,$(UPLINK))
|
||||
# SLIP baudrate and UART device can be configured from make command
|
||||
SLIP_BAUDRATE ?= 115200
|
||||
include $(CURDIR)/Makefile.slip.conf
|
||||
else
|
||||
else ifeq (ethos,$(UPLINK))
|
||||
# ethos baudrate can be configured from make command
|
||||
ETHOS_BAUDRATE ?= 115200
|
||||
include $(CURDIR)/Makefile.ethos.conf
|
||||
else ifeq (wifi,$(UPLINK))
|
||||
# SSID and Password need to be configured
|
||||
include $(CURDIR)/Makefile.wifi.conf
|
||||
endif
|
||||
else
|
||||
include $(CURDIR)/Makefile.native.conf
|
||||
|
@ -1,9 +1,16 @@
|
||||
# Put board specific dependencies here
|
||||
ifeq (,$(filter native,$(BOARD)))
|
||||
ifeq (1,$(USE_SLIP))
|
||||
ifeq (slip,$(UPLINK))
|
||||
USEMODULE += slipdev_stdio
|
||||
else
|
||||
else ifeq (ethos,$(UPLINK))
|
||||
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
|
||||
else
|
||||
USEMODULE += socket_zep
|
||||
|
2
examples/gnrc_border_router/Makefile.wifi.conf
Normal file
2
examples/gnrc_border_router/Makefile.wifi.conf
Normal file
@ -0,0 +1,2 @@
|
||||
CFLAGS += -DESP_WIFI_SSID=\"$(WIFI_SSID)\"
|
||||
CFLAGS += -DESP_WIFI_PASS=\"$(WIFI_PASS)\"
|
@ -8,6 +8,40 @@ and routes on the BR.
|
||||
|
||||
The script `start_network.sh` enables a *ready-to-use* BR in only one command.
|
||||
|
||||
## Uplink
|
||||
|
||||
The border router will route packets between a 6Lo network (PAN) and a 'normal'
|
||||
IPv6 network (i.e. the Internet).
|
||||
|
||||
This requires the border router to have two interfaces: A downstream interface
|
||||
to run 6LoWPAN on and an IPv6 uplink.
|
||||
|
||||
This example comes with support for three uplink types pre-configured:
|
||||
|
||||
- [`ethos`](https://doc.riot-os.org/group__drivers__ethos.html) (default)
|
||||
- [`slip`](https://tools.ietf.org/html/rfc1055)
|
||||
- `wifi`
|
||||
|
||||
For `native` the host-facing [`netdev_tap`](https://doc.riot-os.org/netdev__tap_8h.html) device
|
||||
is configured, providing connectivity via a TAP interface to the RIOT instance.
|
||||
|
||||
To select an uplink, set the UPLINK environment variable. For instance, use `UPLINK=slip`
|
||||
for a SLIP uplink.
|
||||
|
||||
`ethos` and `slip` will make use of the existing serial interface that is used for the
|
||||
RIOT shell to provide an upstream interface. Your computer will act as the upstream
|
||||
router, stdio is multiplexed over the same line.
|
||||
|
||||
The `wifi` uplink will connect to an existing WiFi (IEEE 802.11) network.
|
||||
The network must provide a DHCPv6 server that supports prefix delegation (IA_PD) when
|
||||
`USE_DHCPV6=1` is set (default).
|
||||
|
||||
Use `WIFI_SSID="SSID" WIFI_PASS="password"` in your `make` command to set your WiFi's
|
||||
credentials. You can alternatively edit the `Makefile`.
|
||||
|
||||
Currently, `wifi` requires an esp8266 or esp32 for the border router and will default
|
||||
to using `esp_now` for the downstream interface.
|
||||
|
||||
## Requirements
|
||||
This functionality works only on Linux machines.
|
||||
Mac OSX support will be added in the future (lack of native `tap` interface).
|
||||
@ -41,21 +75,8 @@ Linux might not recognize the interface as connected.
|
||||
[KEA]: https://kea.isc.org/
|
||||
|
||||
## Setup
|
||||
First, you need to compile `ethos`.
|
||||
Go to `/dist/tools/ethos` and type:
|
||||
|
||||
```bash
|
||||
make clean all
|
||||
```
|
||||
|
||||
Then, you need to compile UHCP.
|
||||
This tool is found in `/dist/tools/uhcpd`. So, as for `ethos`:
|
||||
|
||||
```bash
|
||||
make clean all
|
||||
```
|
||||
|
||||
Afterwards, proceed to compile and flash `gnrc_border_router` to your board:
|
||||
To compile and flash `gnrc_border_router` to your board:
|
||||
|
||||
```bash
|
||||
make clean all flash
|
||||
@ -69,18 +90,19 @@ USE_DHCPV6=1 make clean all flash
|
||||
```
|
||||
|
||||
## Usage
|
||||
Start the `start_network.sh` script by doing on `dist/tools/ethos`:
|
||||
The `start_network.sh` script needed for `ethos` and `slip` is automatically run
|
||||
if you type
|
||||
|
||||
```bash
|
||||
sudo sh start_network.sh /dev/ttyACMx tap0 2001:db8::/64
|
||||
make term
|
||||
```
|
||||
|
||||
This will execute the needed commands to setup a `tap` interface
|
||||
and configure the BR.
|
||||
This will execute the needed commands to setup a `tap` (`ethos`) or `tun` (`slip`)
|
||||
interface and configure the BR.
|
||||
Notice that this will also configure `2001:db8::/64` as a prefix.
|
||||
This prefix should be announced to other motes through the wireless interface.
|
||||
|
||||
As said previously, `ethos` allows to send IP packets and shell commands.
|
||||
As said previously, `ethos` and `slipdev` allow to send IP packets and shell commands.
|
||||
This is done through the same serial interface.
|
||||
By typing `help` you will get the list of available shell commands.
|
||||
|
||||
@ -208,7 +230,7 @@ standard [1]. The example application in this folder assumes as a default to be
|
||||
run on an Atmel SAM R21 Xplained Pro evaluation board using an external UART
|
||||
adapter for the second serial interface. However, it is feasible to run the
|
||||
example on any RIOT supported platform that offers either more than one UART or
|
||||
be equipped with an IPv6 capable network device. In this case only the Makefile
|
||||
be equipped with an IPv6 capable network device. In this case only the Makefile.board.dep
|
||||
of this application has to be slightly modified, e.g. by replacing the line
|
||||
```
|
||||
USEMODULE += ethos
|
||||
@ -218,32 +240,14 @@ with something like
|
||||
USEMODULE += encx24j600
|
||||
```
|
||||
and specify the target platform as `BOARD = myplatform`.
|
||||
In order to use the border router over SLIP, please check the `periph_conf.h`
|
||||
of the corresponding board and look out for the `UART_NUMOF` parameter. Its
|
||||
value has to be bigger than 1.
|
||||
|
||||
Be sure that you have replaced on your `Makefile` the lines to use SLIP.
|
||||
You should have something like this:
|
||||
|
||||
```make
|
||||
ifeq (,$(SLIP_UART))
|
||||
# set default (last available UART)
|
||||
SLIP_UART="UART_DEV(UART_NUMOF-1)"
|
||||
endif
|
||||
ifeq (,$(SLIP_BAUDRATE))
|
||||
# set default
|
||||
SLIP_BAUDRATE=115200
|
||||
endif
|
||||
|
||||
GNRC_NETIF_NUMOF := 2
|
||||
INCLUDES += -I$(CURDIR)
|
||||
CFLAGS += -DSLIP_UART=$(SLIP_UART)
|
||||
CFLAGS += -DSLIP_BAUDRATE=$(SLIP_BAUDRATE)
|
||||
# Include SLIP package for IP over Serial communication
|
||||
USEMODULE += slipdev
|
||||
UPLINK ?= slip
|
||||
```
|
||||
|
||||
|
||||
## Configuration
|
||||
|
||||
In order to connect a RIOT 6LoWPAN border router over SLIP you run a small
|
||||
@ -288,4 +292,3 @@ for further help.
|
||||
[1] https://tools.ietf.org/html/rfc1055
|
||||
|
||||
[2] https://github.com/contiki-os/contiki/blob/master/tools/tunslip.c
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user