Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dummy for the node-temp #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node-temp/bin/*
.DS_Store
Binary file added node-temp/.DS_Store
Binary file not shown.
70 changes: 70 additions & 0 deletions node-temp/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Default Makefile, for host native GNRC-based networking

# name of your application
APPLICATION = gcoap

# If no BOARD is found in the environment, use this default:
BOARD ?= native

# This has to be the absolute path to the RIOT base directory:
RIOTBASE ?= $(CURDIR)/../..

BOARD_INSUFFICIENT_MEMORY := chronos msb-430 msb-430h nucleo32-f031 nucleo32-f042 \
nucleo32-l031 nucleo-f030 nucleo-f334 nucleo-l053 \
stm32f0discovery telosb weio wsn430-v1_3b wsn430-v1_4 z1

# Must read nordic_softdevice_ble package before nanocoap package. However,
# can't read it explicitly here because it is read later, as a dependency for
# the nrf52dk board.
BOARD_BLACKLIST := nrf52dk

## Uncomment to redefine port, for example use 61616 for RFC 6282 UDP compression.
#GCOAP_PORT = 5683
#CFLAGS += -DGCOAP_PORT=$(GCOAP_PORT)

## Uncomment to redefine request token length, max 8.
#GCOAP_TOKENLEN = 2
#CFLAGS += -DGCOAP_TOKENLEN=$(GCOAP_TOKENLEN)

FEATURES_REQUIRED = periph_i2c
USEPKG += nanocoap
# Required by nanocoap, but only due to issue #5959.
USEMODULE += posix

# 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
USEMODULE += auto_init_gnrc_netif
# Specify the mandatory networking modules
USEMODULE += gnrc_ipv6_router_default
USEMODULE += gnrc_sock_udp
USEMODULE += gcoap
# Additional networking modules that can be dropped if not needed
USEMODULE += gnrc_icmpv6_echo

# Required by gcoap example
USEMODULE += od
USEMODULE += fmt
# Add also the shell, some shell commands
USEMODULE += shell
USEMODULE += shell_commands
USEMODULE += ps
USEMODULE += tmp006
USEMODULE += xtimer

TEST_TMP006_I2C ?= I2C_DEV\(0\)
TEST_TMP006_ADDR ?= 0x41
TEST_TMP006_CONFIG_CR ?= TMP006_CONFIG_CR_DEF

# Comment this out to disable code in RIOT that does safety checking
# which is not needed in a production environment but helps in the
# development process:
CFLAGS += -DDEVELHELP
CFLAGS += -DTEST_TMP006_I2C=$(TEST_TMP006_I2C)
CFLAGS += -DTEST_TMP006_ADDR=$(TEST_TMP006_ADDR)
CFLAGS += -DTEST_TMP006_CONFIG_CR=$(TEST_TMP006_CONFIG_CR)

# Change this to 0 show compiler invocation lines by default:
QUIET ?= 1

include $(RIOTBASE)/Makefile.include
83 changes: 83 additions & 0 deletions node-temp/Makefile.slip
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Border router Makefile for GNRC and SLIP based networking
# Assumes use of SAMR21 board

# name of your application
APPLICATION = gcoap

# If no BOARD is found in the environment, use this default:
BOARD ?= samr21-xpro

# This has to be the absolute path to the RIOT base directory:
RIOTBASE ?= $(CURDIR)/../..

BOARD_INSUFFICIENT_MEMORY := chronos msb-430 msb-430h nucleo-f030 nucleo-f334 \
stm32f0discovery telosb weio wsn430-v1_3b wsn430-v1_4 \
z1

# Must read nordic_softdevice_ble package before nanocoap package. However,
# can't read it explicitly here because it is read later, as a dependency for
# the nrf52dk board.
BOARD_BLACKLIST := nrf52dk

# Redefine port, for example use 61616 for RFC 6282 UDP compression.
#GCOAP_PORT = 5683
#CFLAGS += -DGCOAP_PORT=$(GCOAP_PORT)

# Redefine request token length, max 8.
#GCOAP_TOKENLEN = 2
#CFLAGS += -DGCOAP_TOKENLEN=$(GCOAP_TOKENLEN)

# Border router requirements
ifeq (,$(SLIP_UART))
# set default (last available UART)
SLIP_UART="(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)

USEPKG += nanocoap
# Required by nanocoap, but only due to issue #5959.
USEMODULE += posix

# 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
USEMODULE += auto_init_gnrc_netif
# Specify the mandatory networking modules
USEMODULE += gnrc_sock_udp
USEMODULE += gcoap
# Add a routing protocol
USEMODULE += gnrc_rpl

# Border router requirements
# Include SLIP package for IP over Serial communication
USEMODULE += gnrc_slip
# Specify the mandatory networking modules for 6LoWPAN border router
USEMODULE += gnrc_sixlowpan_border_router_default
# Additional networking modules that can be dropped if not needed
USEMODULE += gnrc_icmpv6_echo

# Required by gcoap example
USEMODULE += od
USEMODULE += fmt
# Add also the shell, some shell commands
USEMODULE += shell
USEMODULE += shell_commands
USEMODULE += ps

# Comment this out to disable code in RIOT that does safety checking
# which is not needed in a production environment but helps in the
# development process:
CFLAGS += -DDEVELHELP

# Change this to 0 show compiler invocation lines by default:
QUIET ?= 1

include $(RIOTBASE)/Makefile.include
67 changes: 67 additions & 0 deletions node-temp/README-slip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
`Makefile.slip` assumes use of a SAMR21 Xplained Pro. This file describes how we use the board as a border router. See the [SLIP instructions][1] for the gnrc_border_router example for more background.

## Background -- Building
Build commands, for reference:

make clean BOARD="samr21-xpro"

# Use -f only for border router!
make -f Makefile.slip BOARD="samr21-xpro"

../../dist/tools/usb-serial/list-ttys.sh
# Use -f only for border router!
make -f Makefile.slip flash BOARD="samr21-xpro" SERIAL="???"

make term BOARD="samr21-xpro" PORT="/dev/ttyACM???"

## USB serial port
The USB serial port requires a USB-TTL converter cable with 3.3 V output.

Pin connections for SAMR21 board:

* PA23 (RX) -- TXD wire
* PA22 (TX) -- RXD wire
* GND -- GND wire

## Network configuration
We will define two networks:

1. `bbbb` Between Border Router (BR) and Ubuntu host over TUN
2. `aaaa` Between RIOT router node and BR over 6LoWPAN

We include two approaches to configuration below, automated via RPL, and manual via fib.

First, define a TUN interface on an Ubuntu host with tunslip, in the `dist/tools/tunslip` directory. In the example below, the tun interface is host 1.

cd ../../dist/tools/tunslip/
sudo ./tunslip6 -s ttyUSB0 -t tun0 bbbb::1/64
sudo ip -6 route add aaaa::/64 dev tun0

### RPL-based configuration

Configure the interface to the `bbbb` network on the BR from the RIOT terminal. The example commands below assume SLIP is on interface 8.

# Set address for SLIP interface
ifconfig 8 add unicast bbbb::2/64
# Add the Ubuntu host to the neighbor cache
ncache add 8 bbbb::1

Next configure the interface for the `aaaa` network on the BR. Strictly speaking, it is not necessary to define this address. However, it is convenient for typing, because RIOT automatically creates a more verbose address based on the MAC address for the interface.

ifconfig 7 add unicast aaaa::1/64
rpl init 7

Next, configure the interface on the `aaaa` network on the RIOT router mote.

ifconfig 7 add unicast aaaa::2/64
rpl init 7

Finally, set the BR as the RPL DAG root.

rpl root 1 aaaa::1

Ping the TUN interface from the router mote, via the BR:

ping6 bbbb::1

[1]: https://github.com/RIOT-OS/RIOT/tree/master/examples/gnrc_border_router "SLIP instructions"
69 changes: 69 additions & 0 deletions node-temp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# gcoap Example

This application provides command line access to gcoap, a high-level API for CoAP messaging. See the [CoAP spec][1] for background, and the Modules>Networking>CoAP topic in the source documentation for detailed usage instructions and implementation notes.

We support two setup options for this example:

### Native networking
Build with the standard `Makefile`. Follow the setup [instructions][2] for the gnrc_networking example.

### SLIP-based border router

Build with `Makefile.slip`. Follow the setup instructions in README-slip.md, which are based on the [SLIP instructions][3] for the gnrc_border_router example. We also plan to provide or reference the ethos/UHCP instructions, but we don't have it working yet.

## Current Status
gcoap includes server and client capability. Available features include:

* Server and Client provide helper functions for writing the response/request. See the CoAP topic in the source documentation for details. See the gcoap example for sample implementations.
* Server allows an application to register a 'listener', which includes an array of endpoint paths and function callbacks used to write a response.
* Server listens on a port at startup; defaults to 5683.
* Client operates asynchronously; sends request and then handles response in a user provided callback. Also executes callback on timeout.
* Client generates token; length defined at compile time.
* Message Type: Supports non-confirmable (NON) messaging.
* Options: Supports Content-Format for response payload.


## Example Use
This example uses gcoap as a server on RIOT native. Then we send a request from a libcoap example client on the Linux host.

### Verify setup from RIOT terminal

> coap info

Expected response:

CoAP server is listening on port 5683
CLI requests sent: 0
CoAP open requests: 0

### Query from libcoap example client
gcoap does not provide any output to the CoAP terminal when it handles a request. We recommend use of Wireshark to see the request and response. You also can add some debug output in the endpoint function callback.

./coap-client -N -m get -p 5683 coap://[fe80::1843:8eff:fe40:4eaa%tap0]/.well-known/core

Example response:

v:1 t:NON c:GET i:0daa {} [ ]
</cli/stats>

The response shows the endpoint registered by the gcoap CLI example.

### Send query to libcoap example server
Start the libcoap example server with the command below.

./coap-server

Enter the query below in the RIOT CLI.

> coap get fe80::d8b8:65ff:feee:121b 5683 /.well-known/core

CLI output:

gcoap_cli: sending msg ID 743, 75 bytes
> gcoap: response Success, code 2.05, 105 bytes
</>;title="General Info";ct=0,</time>;if="clock";rt="Ticks";title="Internal Clock";ct=0;obs,</async>;ct=0


[1]: https://tools.ietf.org/html/rfc7252 "CoAP spec"
[2]: https://github.com/RIOT-OS/RIOT/tree/master/examples/gnrc_networking "instructions"
[3]: https://github.com/RIOT-OS/RIOT/tree/master/examples/gnrc_border_router "SLIP instructions"
Loading