Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
18156: pkg/opendsme: add initial support for IEEE 802.15.4 DSME time-slotted MAC r=miri64 a=jia200x



19691: drivers/bmx055: fix crazy use of FPU r=maribu a=maribu

### Contribution description

As the title says...


19694: tests/drivers/epd_bw_spi_disp_dev: fix accidental use of FPU r=maribu a=maribu



Co-authored-by: Jose Alamos <[email protected]>
Co-authored-by: Marian Buschsieweke <[email protected]>
  • Loading branch information
3 people authored May 31, 2023
4 parents 784692e + a6648a2 + 6ddf761 + 340b2b6 commit d572516
Show file tree
Hide file tree
Showing 31 changed files with 3,203 additions and 10 deletions.
2 changes: 1 addition & 1 deletion drivers/bmx055/bmx055.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ int bmx055_gyro_read(const bmx055_t *dev, int16_t *data)
uint16_t scale;

/* converting scale info into real scaling values */
scale = (GYRO_2000_DPS / pow(2, dev->p.gyro_scale));
scale = GYRO_2000_DPS >> dev->p.gyro_scale;

/* reading gyroscope data */
i2c_acquire(BUS);
Expand Down
51 changes: 51 additions & 0 deletions examples/opendsme/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# name of your application
APPLICATION = opendsme_example

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

# DSME uses beacon transmission, which are usually filtered out in current drivers.
# So far, nrf802154 is the only driver that supports beacons, which means openDSME
# will run only in nrf802154-based CPUs.
FEATURES_REQUIRED += cpu_nrf52

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

# Uncomment these lines if you want to use platform support from external
# repositories:
#RIOTCPU ?= $(CURDIR)/../../../thirdparty_cpu
#EXTERNAL_BOARD_DIRS ?= $(CURDIR)/../../../thirdparty_boards

# Uncomment this to enable scheduler statistics for ps:
#CFLAGS += -DSCHEDSTATISTICS

# If you want to use native with valgrind, you should recompile native
# with the target all-valgrind instead of all:
# make -B clean all-valgrind

# 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:
DEVELHELP ?= 1

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

USEMODULE += ps
USEMODULE += shell
USEMODULE += shell_cmds_default

USEPKG += opendsme
USEMODULE += auto_init_gnrc_netif
USEMODULE += l2util
USEMODULE += gnrc_pktdump
USEMODULE += gnrc_txtsnd

USEMODULE += netdev_default

# Some boards (e.g nrf52840dongle) require a higher CCA threshold to avoid
# false positives.
CFLAGS += -DCONFIG_IEEE802154_CCA_THRESH_DEFAULT=-30

include $(RIOTBASE)/Makefile.include
5 changes: 5 additions & 0 deletions examples/opendsme/Makefile.ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
BOARD_INSUFFICIENT_MEMORY := \
nrf52dk \
nrf52840dk \
nrf52840dongle \
#
95 changes: 95 additions & 0 deletions examples/opendsme/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# About openDSME

The IEEE 802.15.4 standard with its widespread usage in wireless sensor and
actuator networks was extended by several techniques that allow reliable data
transmission for critical applications, such as industrial plants. This
includes the Deterministic and Synchronous Multi-channel Extension (DSME) that
allows for distributed assignment of time slots on multiple channels.

openDSME is an open source implementation of the Deterministc and
Synchronous Multi-channel Extension.

## Features

- Topology agnostic (peer-to-peer, star, mesh, etc).
- By design, a DSME network can be extended just by adding more coordinators near the edge.
- Automatic resolution of beacon collision
- Frame transmission using either CSMA-CA or multi-channel GTS (guaranteed time slot)
- Built-in slot negotiation (dynamic allocation) and static allocation.

# Usage
1. A PAN coordinator device starts the DSME network via the GNRC network interface:
```
ifconfig <if_num> pan_coord
ifconfig <if_num> up
```

2. Child devices trigger scanning and join the DSME network:
```
ifconfig <if_num> up
```

3. On a fraction of second, `ifconfig` of the joining child device
should display "Link: up" and the L2 address should be visible

4. Devices may choose CSMA-CA or GTS transmissions. CSMA-CA transmissions are
selected by default. To switch to GTS transmissions, run:

```
ifconfig <if_num> gts
```

To switch back to CSMA-CA transmissions, run:
```
ifconfig <if_num> -gts
```
5. To transmit data, use the `txtsnd` command:
```
txtsnd <if_num> <target_L2_address> <message>
```
In case of GTS transmissions, the MAC will negotiate a slot with the target
device. On success, the message will be transmitted in the next occurrence of
the slot. As a result, the first GTS transmission will take longer than
subsequent transmissions.
Note that GTS expire if not used, which will require a new negotiation.
The expire timeout can be configured with `CONFIG_IEEE802154_DSME_GTS_EXPIRATION`
(by default 16 idle slot occurrences).

## Static GTS allocation
Although not supported by the standard, openDSME includes a mechanism to override
the dynamic allocation with static allocation. This is useful for experimentation
or quick prototypes.
To enable, compile openDSME with `CONFIG_IEEE802154_DSME_STATIC_GTS=1`. This can
be set via Kconfig or CFLAGS.

To allocate slots statically, use the `gts` command:
```
gts <if_num> <neighbour_L2_address> <is_tx> <superframe_id> <slot_id> <channel_id>
```

For example, to allocate a pair of slots node 1 (`DE:AD`) and node
B (`BE:EF`), run:

In node 1 (`DE:AD`)
```
gts 3 BE:EF 1 0 0 0
```
In node 2 (`BE:EF`)
```
gts 3 DE:AD 0 0 0 0
```

The slot is located in the first slot (0) of the first superframe in the
multisuperframe (0) and uses the first channel (0). Node 1 allocates a TX slot
and node 2 an RX slot.
In contrast to standard GTS, static GTS do not expire.

To understand more about the superframe structure, check the openDSME
documentation in the RIOT documentation.

# Port limitations
- So far only GNRC link layer communication is supported (e.g `txtsnd`).
- Only PAN coordinator and child roles are supported. This is not an
openDSME limitation, but rather a missing configuration in the RIOT contrib.
- The current openDSME utilizes heap to allocate internal data structures.
- The scanning/joining procedure is hardcoded to join openDSME beacons.
40 changes: 40 additions & 0 deletions examples/opendsme/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (C) 2021 HAW Hamburg
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @file
* @brief OpenDSME example
*
* @author José I. Álamos <[email protected]>
*/

#include <stdio.h>
#include <string.h>
#include "opendsme/opendsme.h"

#include "net/gnrc.h"
#include "net/gnrc/pktdump.h"
#include "net/gnrc/netreg.h"

#include "shell.h"

#define MAIN_QUEUE_SIZE (8)
static msg_t _main_msg_queue[MAIN_QUEUE_SIZE];

int main(void)
{
msg_init_queue(_main_msg_queue, MAIN_QUEUE_SIZE);

gnrc_netreg_entry_t dump = GNRC_NETREG_ENTRY_INIT_PID(GNRC_NETREG_DEMUX_CTX_ALL,
gnrc_pktdump_pid);
gnrc_netreg_register(GNRC_NETTYPE_UNDEF, &dump);

char line_buf[SHELL_DEFAULT_BUFSIZE];
shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE);
return 0;
}
2 changes: 2 additions & 0 deletions makefiles/pseudomodules.inc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ PSEUDOMODULES += newlib_nano
PSEUDOMODULES += nice
## @}
PSEUDOMODULES += nrf24l01p_ng_diagnostics
PSEUDOMODULES += opendsme
PSEUDOMODULES += openthread
PSEUDOMODULES += picolibc
PSEUDOMODULES += picolibc_stdout_buffered
Expand Down Expand Up @@ -467,6 +468,7 @@ PSEUDOMODULES += shell_cmd_netstats_neighbor
PSEUDOMODULES += shell_cmd_nice
PSEUDOMODULES += shell_cmd_nimble_netif
PSEUDOMODULES += shell_cmd_nimble_statconn
PSEUDOMODULES += shell_cmd_opendsme
PSEUDOMODULES += shell_cmd_openwsn
PSEUDOMODULES += shell_cmd_pm
PSEUDOMODULES += shell_cmd_ps
Expand Down
46 changes: 46 additions & 0 deletions pkg/opendsme/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright (c) 2022 HAW Hamburg
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.
#

menuconfig KCONFIG_USEPKG_OPENDSME
bool "Configure openDSME"
help
Configure openDSME using Kconfig.

if KCONFIG_USEPKG_OPENDSME

config OPENDSME_MAX_NEIGHBOURS
int "Maximum number of DSME neighbours"
default 20

config OPENDSME_MAX_LOST_BEACONS
int "Maximum number of lost beacons before assuming the device desynchronized"
default 8
help
Sets the maximum number of lost beacons before the MAC triggers a
de-association procedure. Higher values are beneficial in noisy
environments, because the MAC will keep synchronization despite losing some
beacons. However, lower values are better for mobile nodes, because devices
may sinchronize faster to a new coordinator.

config OPENDSME_CAP_QUEUE_SIZE
int "DSME CAP queue size (for CSMA/CA transmissions)"
default 8
help
The CAP queue stores frames to be sent during the Contention Access Period
using CSMA-CA. Because the transmission delay of CSMA-CA is lower compared to
GTS transmissions, small values are preferred to reduce memory requirements.

config OPENDSME_CFP_QUEUE_SIZE
int "DSME CFP queue size (for GTS transmissions)"
default 22
help
The CFP queue stores frames to be sent during the Contention Free Period
using a dedicated GTS. In contrast to CSMA-CA transmissions, GTS transmission
take longer as a result of slot schedules. Therefore, the GTS queue should
have more capacity than the CAP queue (OPENDSME_CAP_QUEUE_SIZE).

endif # KCONFIG_USEPKG_OPENDSME
58 changes: 58 additions & 0 deletions pkg/opendsme/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
PKG_NAME=opendsme
PKG_URL=https://github.com/inetrg/openDSME.git
PKG_VERSION=b1969296d0fc9a1556ecbef7c0b01538dff3e10c
PKG_LICENSE=GPL

include $(RIOTBASE)/pkg/pkg.mk

OPENDSME_MODULES = \
opendsme_dsmelayer \
opendsme_acklayer \
opendsme_associationmanager \
opendsme_beaconmanager \
opendsme_caplayer \
opendsme_gtsmanager \
opendsme_messagedispatcher \
opendsme_messages \
opendsme_datastructures \
opendsme_mcps_sap \
opendsme_mlme_sap \
opendsme_pib \
opendsme_adaption_layer \
opendsme_adaption_layer_scheduling \
#

CPPFLAGS += -Wno-deprecated-copy -Wno-unused-parameter -Wno-error

# dsmeLayer
DIR_DSME_LAYER = dsmeLayer
DIR_opendsme_dsmelayer = $(DIR_DSME_LAYER)
DIR_opendsme_acklayer = $(DIR_DSME_LAYER)/ackLayer
DIR_opendsme_associationmanager = $(DIR_DSME_LAYER)/associationManager
DIR_opendsme_beaconmanager = $(DIR_DSME_LAYER)/beaconManager
DIR_opendsme_caplayer = $(DIR_DSME_LAYER)/capLayer
DIR_opendsme_gtsmanager = $(DIR_DSME_LAYER)/gtsManager
DIR_opendsme_messagedispatcher = $(DIR_DSME_LAYER)/messageDispatcher
DIR_opendsme_messages = $(DIR_DSME_LAYER)/messages

# MAC Services

DIR_MAC_SERVICES = mac_services
DIR_opendsme_datastructures = $(DIR_MAC_SERVICES)/dataStructures
DIR_opendsme_mcps_sap = $(DIR_MAC_SERVICES)/mcps_sap
DIR_opendsme_mlme_sap = $(DIR_MAC_SERVICES)/mlme_sap
DIR_opendsme_pib = $(DIR_MAC_SERVICES)/pib

# DSME Adoption Layer
DIR_DSME_ADAPTION_LAYER = dsmeAdaptionLayer
DIR_opendsme_adaption_layer = $(DIR_DSME_ADAPTION_LAYER)
DIR_opendsme_adaption_layer_scheduling = $(DIR_DSME_ADAPTION_LAYER)/scheduling

.PHONY: opendsme_%

export SRCXXEXT=cc

all: $(OPENDSME_MODULES)

opendsme_%:
$(QQ)OPENDSME_MODULE=$@ "$(MAKE)" -C $(PKG_SOURCE_DIR)/$(DIR_$@) -f $(CURDIR)/Makefile.opendsme_module
40 changes: 40 additions & 0 deletions pkg/opendsme/Makefile.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FEATURES_REQUIRED += cpp

# Contrib code of openDSME
USEMODULE += opendsme_riot_contrib

# Internal openDSME modules
USEMODULE += opendsme_dsmelayer
USEMODULE += opendsme_acklayer
USEMODULE += opendsme_associationmanager
USEMODULE += opendsme_beaconmanager
USEMODULE += opendsme_caplayer
USEMODULE += opendsme_gtsmanager
USEMODULE += opendsme_messagedispatcher
USEMODULE += opendsme_messages
USEMODULE += opendsme_datastructures
USEMODULE += opendsme_mcps_sap
USEMODULE += opendsme_mlme_sap
USEMODULE += opendsme_pib

# openDSME adaption layer modules
USEMODULE += opendsme_adaption_layer
USEMODULE += opendsme_adaption_layer_scheduling

# required RIOT modules
USEMODULE += luid
USEMODULE += gnrc
USEMODULE += gnrc_netif
USEMODULE += ieee802154
USEMODULE += ztimer_usec

USEMODULE += cpp11-compat
CXXEXFLAGS += -Wno-unused-parameter -Wno-pedantic -Wno-missing-field-initializers -Wno-unused-but-set-variable -Wno-maybe-uninitialized -Wno-unused-variable -Wno-reorder -Wno-address -Wno-sign-compare -Wno-unused-function
FEATURES_REQUIRED += cpp # basic C++ support
FEATURES_REQUIRED += libstdcpp # libstdc++ support (for #include <cstdio>)


# Disable Auto-ACK (not supported by openDSME)
CFLAGS += -DCONFIG_IEEE802154_AUTO_ACK_DISABLE=1

USEMODULE += random
4 changes: 4 additions & 0 deletions pkg/opendsme/Makefile.include
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
INCLUDES += -I$(PKGDIRBASE)/opendsme
INCLUDES += -I$(RIOTBASE)/pkg/opendsme/include

DIRS += $(RIOTBASE)/pkg/opendsme/contrib
9 changes: 9 additions & 0 deletions pkg/opendsme/Makefile.opendsme_module
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MODULE = $(OPENDSME_MODULE)

ifeq (opendsme_adaption_layer_scheduling,$(OPENDSME_MODULE))
# Include TPS and StaticScheduling schedulers
NO_AUTO_SRC := 1
SRCXX += TPS.cc StaticScheduling.cc
endif

include $(RIOTBASE)/Makefile.base
Loading

0 comments on commit d572516

Please sign in to comment.