mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #15326 from aabadie/pr/pkg/softdevice_remove
pkg/nordic-softdevice: remove deprecated package
This commit is contained in:
commit
35b6ccedf3
@ -8,4 +8,4 @@ config BOARD_COMMON_NRF52
|
||||
bool
|
||||
select HAS_PERIPH_RTT
|
||||
select HAS_PERIPH_TIMER
|
||||
select HAS_RIOTBOOT if !USEPKG_NORDIC_SOFTDEVICE_BLE
|
||||
select HAS_RIOTBOOT
|
||||
|
@ -3,11 +3,4 @@ CPU = nrf52
|
||||
# Put defined MCU peripherals here (in alphabetical order)
|
||||
FEATURES_PROVIDED += periph_rtt
|
||||
FEATURES_PROVIDED += periph_timer
|
||||
ifeq (,$(filter nordic_softdevice_ble,$(USEPKG)))
|
||||
FEATURES_PROVIDED += riotboot
|
||||
endif
|
||||
|
||||
ifneq (,$(findstring nrf52832, $(CPU_MODEL)))
|
||||
# Nordic SoftDevice support in RIOT is verified for all nrf52832-based boards
|
||||
FEATURES_PROVIDED += ble_nordic_softdevice
|
||||
endif
|
||||
FEATURES_PROVIDED += riotboot
|
||||
|
@ -19,19 +19,6 @@ PROGRAMMER ?= jlink
|
||||
ifeq (jlink,$(PROGRAMMER))
|
||||
# setup JLink for flashing
|
||||
JLINK_DEVICE = nrf52
|
||||
|
||||
# special options when using SoftDevice
|
||||
ifneq (,$(filter nordic_softdevice_ble,$(USEPKG)))
|
||||
JLINK_PRE_FLASH = loadfile $(BINDIR)/softdevice.hex
|
||||
FLASH_ADDR = 0x1f000
|
||||
LINKER_SCRIPT ?= $(RIOTCPU)/$(CPU)/ldscripts/$(CPU_MODEL)_sd.ld
|
||||
# murdock: softdevice.hex file is used for flashing
|
||||
# It must be taken into account for the test input hash and
|
||||
# be sent to the separated testing boards
|
||||
TEST_EXTRA_FILES += $(BINDIR)/softdevice.hex
|
||||
# Files in TEST_EXTRA_FILES need to have an explicit target
|
||||
$(BINDIR)/softdevice.hex: | $(ELFFILE)
|
||||
endif
|
||||
include $(RIOTMAKE)/tools/jlink.inc.mk
|
||||
else ifeq (openocd,$(PROGRAMMER))
|
||||
ifneq (,$(filter $(BOARD),ruuvitag thingy52))
|
||||
@ -41,26 +28,6 @@ else ifeq (openocd,$(PROGRAMMER))
|
||||
# setup OpenOCD for flashing. Version 0.10 of OpenOCD doesn't contain support
|
||||
# for nrf52dk and nrf52840dk boards. To use OpenOCD with these a version
|
||||
# build from source (master > 2018, August the 13rd) is required.
|
||||
ifneq (,$(filter nordic_softdevice_ble,$(USEPKG)))
|
||||
LINKER_SCRIPT ?= $(RIOTCPU)/$(CPU)/ldscripts/$(CPU_MODEL)_sd.ld
|
||||
|
||||
OPENOCD_PRE_FLASH_CMDS += -c 'flash write_image erase "$(BINDIR)/softdevice.hex"'
|
||||
OPENOCD_PRE_VERIFY_CMDS += -c 'verify_image "$(BINDIR)/softdevice.hex"'
|
||||
|
||||
# Cannot use the 'ELFFILE' here
|
||||
# The segments are 0x10000 aligned so padding bytes are copied and verified
|
||||
#
|
||||
# Using 'LINKFLAGS += -Wl,--nmagic' prevents it but would require
|
||||
# dedicated testing/review
|
||||
FLASHFILE ?= $(HEXFILE)
|
||||
|
||||
# murdock: softdevice.hex file is used for flashing
|
||||
# It must be taken into account for the test input hash and
|
||||
# be sent to the separated testing boards
|
||||
TEST_EXTRA_FILES += $(BINDIR)/softdevice.hex
|
||||
# Files in TEST_EXTRA_FILES need to have an explicit target
|
||||
$(BINDIR)/softdevice.hex: | $(ELFFILE)
|
||||
endif
|
||||
DEBUG_ADAPTER ?= jlink
|
||||
OPENOCD_CONFIG = $(RIOTBOARD)/common/nrf52/dist/openocd.cfg
|
||||
include $(RIOTMAKE)/tools/openocd.inc.mk
|
||||
|
@ -1,5 +1,5 @@
|
||||
ifneq (,$(filter gnrc_netdev_default,$(USEMODULE)))
|
||||
ifeq (,$(filter nordic_softdevice_ble nrfmin,$(USEMODULE) $(USEPKG)))
|
||||
ifeq (,$(filter nrfmin,$(USEMODULE)))
|
||||
USEMODULE += nimble_netif
|
||||
endif
|
||||
endif
|
||||
|
@ -42,7 +42,6 @@ config CPU_MODEL_NRF52832XXAA
|
||||
bool
|
||||
select CPU_FAM_NRF52
|
||||
select CPU_CORE_CORTEX_M4F
|
||||
select HAS_BLE_NORDIC_SOFTDEVICE
|
||||
|
||||
config CPU_MODEL_NRF52833XXAA
|
||||
bool
|
||||
|
@ -34,11 +34,6 @@ static bool ftpan_32(void);
|
||||
static bool ftpan_37(void);
|
||||
static bool ftpan_36(void);
|
||||
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
#include "softdevice_handler.h"
|
||||
uint8_t _ble_evt_buffer[BLE_STACK_EVT_MSG_BUF_SIZE];
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Initialize the CPU, set IRQ priorities
|
||||
*/
|
||||
@ -73,18 +68,8 @@ void cpu_init(void)
|
||||
NRF_NVMC->ICACHECNF = (NVMC_ICACHECNF_CACHEEN_Msk);
|
||||
#endif
|
||||
|
||||
/* softdevice needs to be enabled from ISR context */
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
softdevice_handler_init(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, &_ble_evt_buffer,
|
||||
BLE_STACK_EVT_MSG_BUF_SIZE, NULL);
|
||||
|
||||
/* fixup swi0 (used as softdevice PendSV trampoline) */
|
||||
NVIC_EnableIRQ(SWI0_EGU0_IRQn);
|
||||
NVIC_SetPriority(SWI0_EGU0_IRQn, 6);
|
||||
#else
|
||||
/* call cortexm default initialization */
|
||||
cortexm_init();
|
||||
#endif
|
||||
|
||||
/* enable wake up on events for __WFE CPU sleep */
|
||||
SCB->SCR |= SCB_SCR_SEVONPEND_Msk;
|
||||
|
@ -112,19 +112,6 @@ extern "C" {
|
||||
#define FLASHPAGE_RAW_ALIGNMENT (4U)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief SoftDevice settings
|
||||
* @{
|
||||
*/
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
#ifndef DONT_OVERRIDE_NVIC
|
||||
#include "nrf_soc.h"
|
||||
#undef NVIC_SetPriority
|
||||
#define NVIC_SetPriority sd_nvic_SetPriority
|
||||
#endif /* DONT_OVERRIDE_NVIC */
|
||||
#endif /* SOFTDEVICE_PRESENT */
|
||||
/** @} */
|
||||
|
||||
#ifdef CPU_MODEL_NRF52840XXAA
|
||||
/**
|
||||
* @name OpenWSN timing constants
|
||||
|
@ -53,21 +53,7 @@ WEAK_DEFAULT void isr_wdt(void);
|
||||
WEAK_DEFAULT void isr_rtc1(void);
|
||||
WEAK_DEFAULT void isr_qdec(void);
|
||||
WEAK_DEFAULT void isr_lpcomp(void);
|
||||
|
||||
#ifndef SOFTDEVICE_PRESENT
|
||||
WEAK_DEFAULT void isr_swi0(void);
|
||||
#else
|
||||
/* For unknown reasons, setting PendSV pending within
|
||||
* the softdevice ISRs leads to a crash. This workaround
|
||||
* uses swi0 as trampoline.
|
||||
*/
|
||||
extern void thread_yield_higher(void);
|
||||
void isr_swi0(void)
|
||||
{
|
||||
thread_yield_higher();
|
||||
}
|
||||
#endif
|
||||
|
||||
WEAK_DEFAULT void isr_swi1(void);
|
||||
WEAK_DEFAULT void isr_swi2(void);
|
||||
WEAK_DEFAULT void isr_swi3(void);
|
||||
@ -84,10 +70,6 @@ WEAK_DEFAULT void isr_spi2(void);
|
||||
WEAK_DEFAULT void isr_rtc2(void);
|
||||
WEAK_DEFAULT void isr_i2s(void);
|
||||
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
extern void SWI2_EGU2_IRQHandler(void);
|
||||
#endif
|
||||
|
||||
/* CPU specific interrupt vector table */
|
||||
ISR_VECTOR(1) const isr_t vector_cpu[CPU_IRQ_NUMOF] = {
|
||||
isr_power_clock, /* power_clock */
|
||||
|
@ -54,21 +54,7 @@ WEAK_DEFAULT void isr_wdt(void);
|
||||
WEAK_DEFAULT void isr_rtc1(void);
|
||||
WEAK_DEFAULT void isr_qdec(void);
|
||||
WEAK_DEFAULT void isr_lpcomp(void);
|
||||
|
||||
#ifndef SOFTDEVICE_PRESENT
|
||||
WEAK_DEFAULT void isr_swi0(void);
|
||||
#else
|
||||
/* For unknown reasons, setting PendSV pending within
|
||||
* the softdevice ISRs leads to a crash. This workaround
|
||||
* uses swi0 as trampoline.
|
||||
*/
|
||||
extern void thread_yield_higher(void);
|
||||
void isr_swi0(void)
|
||||
{
|
||||
thread_yield_higher();
|
||||
}
|
||||
#endif
|
||||
|
||||
WEAK_DEFAULT void isr_swi1(void);
|
||||
WEAK_DEFAULT void isr_swi2(void);
|
||||
WEAK_DEFAULT void isr_swi3(void);
|
||||
@ -85,10 +71,6 @@ WEAK_DEFAULT void isr_spi2(void);
|
||||
WEAK_DEFAULT void isr_rtc2(void);
|
||||
WEAK_DEFAULT void isr_i2s(void);
|
||||
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
extern void SWI2_EGU2_IRQHandler(void);
|
||||
#endif
|
||||
|
||||
/* CPU specific interrupt vector table */
|
||||
ISR_VECTOR(1) const isr_t vector_cpu[CPU_IRQ_NUMOF] = {
|
||||
isr_power_clock, /* power_clock */
|
||||
|
@ -55,21 +55,7 @@ WEAK_DEFAULT void isr_wdt(void);
|
||||
WEAK_DEFAULT void isr_rtc1(void);
|
||||
WEAK_DEFAULT void isr_qdec(void);
|
||||
WEAK_DEFAULT void isr_lpcomp(void);
|
||||
|
||||
#ifndef SOFTDEVICE_PRESENT
|
||||
WEAK_DEFAULT void isr_swi0(void);
|
||||
#else
|
||||
/* For unknown reasons, setting PendSV pending within
|
||||
* the softdevice ISRs leads to a crash. This workaround
|
||||
* uses swi0 as trampoline.
|
||||
*/
|
||||
extern void thread_yield_higher(void);
|
||||
void isr_swi0(void)
|
||||
{
|
||||
thread_yield_higher();
|
||||
}
|
||||
#endif
|
||||
|
||||
WEAK_DEFAULT void isr_swi1(void);
|
||||
WEAK_DEFAULT void isr_swi2(void);
|
||||
WEAK_DEFAULT void isr_swi3(void);
|
||||
@ -86,10 +72,6 @@ WEAK_DEFAULT void isr_spi2(void);
|
||||
WEAK_DEFAULT void isr_rtc2(void);
|
||||
WEAK_DEFAULT void isr_i2s(void);
|
||||
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
extern void SWI2_EGU2_IRQHandler(void);
|
||||
#endif
|
||||
|
||||
/* CPU specific interrupt vector table */
|
||||
ISR_VECTOR(1) const isr_t vector_cpu[CPU_IRQ_NUMOF] = {
|
||||
isr_power_clock, /* power_clock */
|
||||
|
@ -54,21 +54,7 @@ WEAK_DEFAULT void isr_wdt(void);
|
||||
WEAK_DEFAULT void isr_rtc1(void);
|
||||
WEAK_DEFAULT void isr_qdec(void);
|
||||
WEAK_DEFAULT void isr_lpcomp(void);
|
||||
|
||||
#ifndef SOFTDEVICE_PRESENT
|
||||
WEAK_DEFAULT void isr_swi0(void);
|
||||
#else
|
||||
/* For unknown reasons, setting PendSV pending within
|
||||
* the softdevice ISRs leads to a crash. This workaround
|
||||
* uses swi0 as trampoline.
|
||||
*/
|
||||
extern void thread_yield_higher(void);
|
||||
void isr_swi0(void)
|
||||
{
|
||||
thread_yield_higher();
|
||||
}
|
||||
#endif
|
||||
|
||||
WEAK_DEFAULT void isr_swi1(void);
|
||||
WEAK_DEFAULT void isr_swi2(void);
|
||||
WEAK_DEFAULT void isr_swi3(void);
|
||||
@ -92,10 +78,6 @@ WEAK_DEFAULT void isr_cryptocell(void);
|
||||
WEAK_DEFAULT void isr_spi3(void);
|
||||
WEAK_DEFAULT void isr_pwm3(void);
|
||||
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
extern void SWI2_EGU2_IRQHandler(void);
|
||||
#endif
|
||||
|
||||
/* CPU specific interrupt vector table */
|
||||
ISR_VECTOR(1)
|
||||
const isr_t vector_cpu[CPU_IRQ_NUMOF] = {
|
||||
@ -121,11 +103,7 @@ const isr_t vector_cpu[CPU_IRQ_NUMOF] = {
|
||||
isr_lpcomp, /* lpcomp */
|
||||
isr_swi0, /* swi0 */
|
||||
isr_swi1, /* swi1 */
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
SWI2_EGU2_IRQHandler, /* softdevice swi handler */
|
||||
#else
|
||||
isr_swi2, /* swi2 */
|
||||
#endif
|
||||
isr_swi3, /* swi3 */
|
||||
isr_swi4, /* swi4 */
|
||||
isr_swi5, /* swi5 */
|
||||
|
@ -53,21 +53,7 @@ WEAK_DEFAULT void isr_wdt(void);
|
||||
WEAK_DEFAULT void isr_rtc1(void);
|
||||
WEAK_DEFAULT void isr_qdec(void);
|
||||
WEAK_DEFAULT void isr_lpcomp(void);
|
||||
|
||||
#ifndef SOFTDEVICE_PRESENT
|
||||
WEAK_DEFAULT void isr_swi0(void);
|
||||
#else
|
||||
/* For unknown reasons, setting PendSV pending within
|
||||
* the softdevice ISRs leads to a crash. This workaround
|
||||
* uses swi0 as trampoline.
|
||||
*/
|
||||
extern void thread_yield_higher(void);
|
||||
void isr_swi0(void)
|
||||
{
|
||||
thread_yield_higher();
|
||||
}
|
||||
#endif
|
||||
|
||||
WEAK_DEFAULT void isr_swi1(void);
|
||||
WEAK_DEFAULT void isr_swi2(void);
|
||||
WEAK_DEFAULT void isr_swi3(void);
|
||||
@ -85,10 +71,6 @@ WEAK_DEFAULT void isr_rtc2(void);
|
||||
WEAK_DEFAULT void isr_i2s(void);
|
||||
WEAK_DEFAULT void isr_fpu(void);
|
||||
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
extern void SWI2_EGU2_IRQHandler(void);
|
||||
#endif
|
||||
|
||||
/* CPU specific interrupt vector table */
|
||||
ISR_VECTOR(1)
|
||||
const isr_t vector_cpu[CPU_IRQ_NUMOF] = {
|
||||
@ -114,11 +96,7 @@ const isr_t vector_cpu[CPU_IRQ_NUMOF] = {
|
||||
isr_lpcomp, /* lpcomp */
|
||||
isr_swi0, /* swi0 */
|
||||
isr_swi1, /* swi1 */
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
SWI2_EGU2_IRQHandler, /* softdevice swi handler */
|
||||
#else
|
||||
isr_swi2, /* swi2 */
|
||||
#endif
|
||||
isr_swi3, /* swi3 */
|
||||
isr_swi4, /* swi4 */
|
||||
isr_swi5, /* swi5 */
|
||||
|
@ -53,21 +53,7 @@ WEAK_DEFAULT void isr_wdt(void);
|
||||
WEAK_DEFAULT void isr_rtc1(void);
|
||||
WEAK_DEFAULT void isr_qdec(void);
|
||||
WEAK_DEFAULT void isr_lpcomp(void);
|
||||
|
||||
#ifndef SOFTDEVICE_PRESENT
|
||||
WEAK_DEFAULT void isr_swi0(void);
|
||||
#else
|
||||
/* For unknown reasons, setting PendSV pending within
|
||||
* the softdevice ISRs leads to a crash. This workaround
|
||||
* uses swi0 as trampoline.
|
||||
*/
|
||||
extern void thread_yield_higher(void);
|
||||
void isr_swi0(void)
|
||||
{
|
||||
thread_yield_higher();
|
||||
}
|
||||
#endif
|
||||
|
||||
WEAK_DEFAULT void isr_swi1(void);
|
||||
WEAK_DEFAULT void isr_swi2(void);
|
||||
WEAK_DEFAULT void isr_swi3(void);
|
||||
@ -91,10 +77,6 @@ WEAK_DEFAULT void isr_cryptocell(void);
|
||||
WEAK_DEFAULT void isr_spi3(void);
|
||||
WEAK_DEFAULT void isr_pwm3(void);
|
||||
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
extern void SWI2_EGU2_IRQHandler(void);
|
||||
#endif
|
||||
|
||||
/* CPU specific interrupt vector table */
|
||||
ISR_VECTOR(1)
|
||||
const isr_t vector_cpu[CPU_IRQ_NUMOF] = {
|
||||
@ -120,11 +102,7 @@ const isr_t vector_cpu[CPU_IRQ_NUMOF] = {
|
||||
isr_lpcomp, /* lpcomp */
|
||||
isr_swi0, /* swi0 */
|
||||
isr_swi1, /* swi1 */
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
SWI2_EGU2_IRQHandler, /* softdevice swi handler */
|
||||
#else
|
||||
isr_swi2, /* swi2 */
|
||||
#endif
|
||||
isr_swi3, /* swi3 */
|
||||
isr_swi4, /* swi4 */
|
||||
isr_swi5, /* swi5 */
|
||||
|
@ -53,21 +53,7 @@ WEAK_DEFAULT void isr_wdt(void);
|
||||
WEAK_DEFAULT void isr_rtc1(void);
|
||||
WEAK_DEFAULT void isr_qdec(void);
|
||||
WEAK_DEFAULT void isr_lpcomp(void);
|
||||
|
||||
#ifndef SOFTDEVICE_PRESENT
|
||||
WEAK_DEFAULT void isr_swi0(void);
|
||||
#else
|
||||
/* For unknown reasons, setting PendSV pending within
|
||||
* the softdevice ISRs leads to a crash. This workaround
|
||||
* uses swi0 as trampoline.
|
||||
*/
|
||||
extern void thread_yield_higher(void);
|
||||
void isr_swi0(void)
|
||||
{
|
||||
thread_yield_higher();
|
||||
}
|
||||
#endif
|
||||
|
||||
WEAK_DEFAULT void isr_swi1(void);
|
||||
WEAK_DEFAULT void isr_swi2(void);
|
||||
WEAK_DEFAULT void isr_swi3(void);
|
||||
@ -91,10 +77,6 @@ WEAK_DEFAULT void isr_cryptocell(void);
|
||||
WEAK_DEFAULT void isr_spi3(void);
|
||||
WEAK_DEFAULT void isr_pwm3(void);
|
||||
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
extern void SWI2_EGU2_IRQHandler(void);
|
||||
#endif
|
||||
|
||||
/* CPU specific interrupt vector table */
|
||||
ISR_VECTOR(1)
|
||||
const isr_t vector_cpu[CPU_IRQ_NUMOF] = {
|
||||
@ -120,11 +102,7 @@ const isr_t vector_cpu[CPU_IRQ_NUMOF] = {
|
||||
isr_lpcomp, /* lpcomp */
|
||||
isr_swi0, /* swi0 */
|
||||
isr_swi1, /* swi1 */
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
SWI2_EGU2_IRQHandler, /* softdevice swi handler */
|
||||
#else
|
||||
isr_swi2, /* swi2 */
|
||||
#endif
|
||||
isr_swi3, /* swi3 */
|
||||
isr_swi4, /* swi4 */
|
||||
isr_swi5, /* swi5 */
|
||||
|
@ -42,10 +42,4 @@ config HAS_RADIO_NRFMIN
|
||||
Indicates that a radio compatible with the nRF minimal radio driver is
|
||||
present.
|
||||
|
||||
config HAS_BLE_NORDIC_SOFTDEVICE
|
||||
bool
|
||||
help
|
||||
Indicates that Nordic SoftDevice support in RIOT has been verified on the
|
||||
current platform.
|
||||
|
||||
source "$(RIOTCPU)/cortexm_common/Kconfig"
|
||||
|
@ -24,9 +24,7 @@
|
||||
|
||||
#include "cpu.h"
|
||||
#include "periph/hwrng.h"
|
||||
#ifndef MODULE_NORDIC_SOFTDEVICE_BLE
|
||||
#include "assert.h"
|
||||
#endif
|
||||
|
||||
void hwrng_init(void)
|
||||
{
|
||||
@ -34,11 +32,6 @@ void hwrng_init(void)
|
||||
NRF_RNG->CONFIG = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* The hardware peripheral is used by the SoftDevice. When the SoftDevice is
|
||||
* enabled, it shall only be accessed through the SoftDevice API
|
||||
*/
|
||||
#ifndef MODULE_NORDIC_SOFTDEVICE_BLE
|
||||
void hwrng_read(void *buf, unsigned int num)
|
||||
{
|
||||
unsigned int count = 0;
|
||||
@ -71,24 +64,3 @@ void hwrng_read(void *buf, unsigned int num)
|
||||
NRF_RNG->POWER = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void hwrng_read(void *buf, unsigned int num)
|
||||
{
|
||||
uint32_t ret;
|
||||
uint8_t avail;
|
||||
|
||||
assert(num <= 0xff);
|
||||
|
||||
/* this is not the most efficient, but this way we can assure that there are
|
||||
* enough bytes of random data available */
|
||||
do {
|
||||
sd_rand_application_bytes_available_get(&avail);
|
||||
} while (avail < (uint8_t)num);
|
||||
|
||||
ret = sd_rand_application_vector_get((uint8_t *)buf, (uint8_t)num);
|
||||
assert(ret == NRF_SUCCESS);
|
||||
(void)ret;
|
||||
}
|
||||
#endif /* MODULE_NORDIC_SOFTDEVICE_BLE */
|
||||
|
@ -1,56 +0,0 @@
|
||||
PKG_NAME = nordic_softdevice_ble
|
||||
PKG_VERSION = 3288530
|
||||
PKG_FILE = nrf5_iot_sdk_$(PKG_VERSION).zip
|
||||
PKG_URL = https://developer.nordicsemi.com/nRF5_IoT_SDK/nRF5_IoT_SDK_v0.9.x/$(PKG_FILE)
|
||||
PKG_MD5 = 291c875df69c51e22491e6112128bd9c
|
||||
PKG_LICENSE = nordic-bsd
|
||||
|
||||
PKG_DIR = $(CURDIR)
|
||||
PKG_BUILD_DIR = $(BINDIR)/pkg/$(PKG_NAME)
|
||||
PKG_SOURCE_DIR = $(PKGDIRBASE)/$(PKG_NAME)
|
||||
PKG_SRCDIR = $(PKG_SOURCE_DIR)/src
|
||||
|
||||
SOFTDEVICE := components/softdevice/s1xx_iot/s1xx-iot-prototype3_nrf52_softdevice.hex
|
||||
BLE_6LOWPAN_LIB := components/iot/ble_6lowpan/lib/ble_6lowpan.a
|
||||
|
||||
SOFTDEVICE_MODULES = $(filter softdevice_handler ble_common ble_ipsp,$(USEMODULE))
|
||||
|
||||
.PHONY: all prepare clean distclean $(SOFTDEVICE_MODULES)
|
||||
|
||||
all: $(BINDIR)/ble_6lowpan.a $(BINDIR)/softdevice.hex $(SOFTDEVICE_MODULES)
|
||||
|
||||
prepare: $(PKG_SRCDIR)/.extracted
|
||||
|
||||
softdevice_handler:
|
||||
"$(MAKE)" -C $(PKG_SRCDIR)/components/softdevice/common/softdevice_handler -f $(RIOTBASE)/Makefile.base
|
||||
|
||||
ble_common:
|
||||
"$(MAKE)" -C $(PKG_SRCDIR)/components/ble/common -f $(CURDIR)/ble_common.mk
|
||||
|
||||
ble_ipsp:
|
||||
"$(MAKE)" -C $(PKG_SRCDIR)/components/iot/ble_ipsp -f $(RIOTBASE)/Makefile.base
|
||||
|
||||
$(BINDIR)/ble_6lowpan.a: $(PKG_SRCDIR)/.extracted
|
||||
cp $(PKG_SRCDIR)/$(BLE_6LOWPAN_LIB) $@
|
||||
|
||||
# softdevice.hex has the `[0x8bc, 0x3000[` addresses not set.
|
||||
# However, it requires that the value at `0x2000` is 0xFFFFFFFF
|
||||
# We just put all the undefined memory to 0xff as it is the rom reset value anyway.
|
||||
$(BINDIR)/softdevice.hex: $(PKG_SRCDIR)/.extracted
|
||||
$(Q)$(OBJCOPY) $(OFLAGS) -Oihex --gap-fill 0xff $(PKG_SRCDIR)/$(SOFTDEVICE) $@
|
||||
|
||||
$(PKG_SRCDIR)/.extracted: $(PKG_SOURCE_DIR)/$(PKG_FILE)
|
||||
rm -rf $(@D)
|
||||
mkdir -p $(@D)
|
||||
$(Q)cd $(@D) && $(UNZIP_HERE) $(PKG_SOURCE_DIR)/$(PKG_FILE)
|
||||
touch $@
|
||||
|
||||
$(PKG_SOURCE_DIR)/$(PKG_FILE):
|
||||
@mkdir -p $(@D)
|
||||
$(Q)$(DLCACHE) $(PKG_URL) $(PKG_MD5) $@
|
||||
|
||||
clean::
|
||||
rm -rf $(PKG_SOURCE_DIR)/
|
||||
|
||||
distclean::
|
||||
rm -rf $(PKG_BUILD_DIR)/
|
@ -1,18 +0,0 @@
|
||||
FEATURES_REQUIRED += ble_nordic_softdevice
|
||||
USEMODULE += softdevice_handler
|
||||
USEMODULE += ble_common
|
||||
USEMODULE += ble_6lowpan
|
||||
USEMODULE += gnrc_sixlowpan
|
||||
USEMODULE += gnrc_sixlowpan_iphc
|
||||
USEMODULE += gnrc_ipv6_nib_6ln
|
||||
USEMODULE += gnrc_ipv6_default
|
||||
|
||||
# prevent application from being a router
|
||||
# TODO: maybe find a nicer solution in future build system update
|
||||
_ROUTER_MODULES = gnrc_ipv6_router% gnrc_rpl netstats_rpl auto_init_gnrc_rpl
|
||||
ifneq (,$(filter $(_ROUTER_MODULES),$(USEMODULE)))
|
||||
$(warning nordic_softdevice_ble: Disabling router modules:\
|
||||
$(filter $(_ROUTER_MODULES),$(USEMODULE)))
|
||||
endif
|
||||
|
||||
USEMODULE := $(filter-out $(_ROUTER_MODULES),$(USEMODULE))
|
@ -1,33 +0,0 @@
|
||||
NORDIC_SRCS := $(PKGDIRBASE)/nordic_softdevice_ble/src
|
||||
|
||||
INCLUDES += \
|
||||
-I$(RIOTBASE)/pkg/nordic_softdevice_ble/src \
|
||||
-I$(NORDIC_SRCS)/components/ble/common \
|
||||
-I$(NORDIC_SRCS)/components/device \
|
||||
-I$(NORDIC_SRCS)/components/iot/ble_6lowpan \
|
||||
-I$(NORDIC_SRCS)/components/iot/ble_ipsp \
|
||||
-I$(NORDIC_SRCS)/components/iot/common \
|
||||
-I$(NORDIC_SRCS)/components/libraries/scheduler \
|
||||
-I$(NORDIC_SRCS)/components/libraries/util \
|
||||
-I$(NORDIC_SRCS)/components/softdevice/common/softdevice_handler \
|
||||
-I$(NORDIC_SRCS)/components/softdevice/s1xx_iot/headers \
|
||||
-I$(NORDIC_SRCS)/components/softdevice/s1xx_iot/headers/nrf52 \
|
||||
-I$(NORDIC_SRCS)/components/toolchain
|
||||
|
||||
CFLAGS += -DNRF52 \
|
||||
-DBLE_STACK_SUPPORT_REQD \
|
||||
-DISR_STACKSIZE=8192 \
|
||||
-DSOFTDEVICE_PRESENT \
|
||||
-DS132
|
||||
|
||||
CFLAGS += -Wno-pedantic -Wno-unused-parameter -Wno-sign-compare
|
||||
|
||||
# Nordic's ble_6lowpan.a is compiled with hard-float
|
||||
# so set this, otherwise linking fails
|
||||
CFLAGS_FPU := -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
||||
ARCHIVES += $(BINDIR)/ble_6lowpan.a
|
||||
|
||||
DIRS += $(RIOTBASE)/pkg/nordic_softdevice_ble/src
|
||||
|
||||
# LLVM ARM assembler has massive problems digesting this
|
||||
TOOLCHAINS_BLACKLIST += llvm
|
@ -1,104 +0,0 @@
|
||||
This README contains information how to establish an IPv6 connection between
|
||||
Linux BLE router and an IPSP enabled BLE device.
|
||||
|
||||
Prerequisites
|
||||
=============
|
||||
In general, any device capable of running Linux operating system, can be used
|
||||
as a BLE router provided the following conditions are met:
|
||||
|
||||
* Linux Kernel >3.18 and <=4.12 is used
|
||||
* The nRF IoT SDK version used in this package does not yet support the
|
||||
`BLE_6LOWPAN_LEGACY_MODE` flag, which would remove the upper version bound.
|
||||
See [the package documentation](https://riot-os.org/api/group__pkg__nordic-softdevice-ble.html)
|
||||
for further directions.
|
||||
* bluez, libcap-ng0, radvd tools are present.
|
||||
|
||||
If a built-in Bluetooth device is not available then Bluetooth 4.0 compatible
|
||||
USB dongle can be used.
|
||||
|
||||
The following procedures have been tested on Ubuntu 15.10 and Ubuntu 16.04.
|
||||
|
||||
Establishing an IPv6 connection
|
||||
===============================
|
||||
Use the following procedure to establish a connection between an nRF52 device
|
||||
and Linux router:
|
||||
|
||||
First enable 6LoWPAN module. This is necessary only once per session:
|
||||
|
||||
# Log in as a root user.
|
||||
sudo su
|
||||
|
||||
# Mount debugfs file system.
|
||||
mount -t debugfs none /sys/kernel/debug
|
||||
|
||||
# Load 6LoWPAN module.
|
||||
modprobe bluetooth_6lowpan
|
||||
|
||||
# Enable the bluetooth 6lowpan module.
|
||||
echo 1 > /sys/kernel/debug/bluetooth/6lowpan_enable
|
||||
|
||||
# Look for available HCI devices.
|
||||
hciconfig
|
||||
|
||||
# Reset HCI device - for example hci0 device.
|
||||
hciconfig hci0 reset
|
||||
|
||||
# Read 00:AA:BB:XX:YY:ZZ address of the nRF5x device.
|
||||
hcitool lescan
|
||||
|
||||
If you see device name and address in lescan output then you can connect to the
|
||||
device:
|
||||
|
||||
echo "connect 00:AA:BB:XX:YY:ZZ 1" > /sys/kernel/debug/bluetooth/6lowpan_control
|
||||
|
||||
If above is successful then LED1 will stop blinking and LED2 will switch on.
|
||||
You can then check the connection using the following commands:
|
||||
|
||||
# Check if bt0 interface is present and up
|
||||
ifconfig
|
||||
|
||||
# Try to ping the device using its link-local address, for example, on bt0 interface.
|
||||
ping6 fe80::2aa:bbff:fexx:yyzz%bt0
|
||||
|
||||
If you'd like to learn more about the procedure please refer to
|
||||
[Connecting devices to the router].
|
||||
|
||||
Distributing routable IPv6 prefix
|
||||
=================================
|
||||
In Linux, Router Advertisement Daemon (RADVD) can be used to distribute prefixes
|
||||
in the network, hance configure routable IPv6 address.
|
||||
|
||||
To configure RADVD create `/etc/radvd.conf` file and paste the following contents:
|
||||
|
||||
interface bt0
|
||||
{
|
||||
AdvSendAdvert on;
|
||||
prefix 2001:db8::/64
|
||||
{
|
||||
AdvOnLink off;
|
||||
AdvAutonomous on;
|
||||
AdvRouterAddr on;
|
||||
};
|
||||
};
|
||||
|
||||
Next, start RADVD daemon:
|
||||
|
||||
# Set IPv6 forwarding (must be present).
|
||||
sudo echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
|
||||
# Run radvd daemon.
|
||||
sudo service radvd restart
|
||||
|
||||
If successful then all devices connected to the host will receive
|
||||
a routable `2001:db8` prefix.
|
||||
|
||||
This can be verified by sending echo request to the full address:
|
||||
|
||||
ping6 -I bt0 2001:db8::2aa:bbff:fexx:yyzz
|
||||
|
||||
where `aa:bbff:fexx:yyzz` is device Bluetooth address.
|
||||
|
||||
If you'd like to learn more about the procedure please refer to
|
||||
[Distributing a global IPv6 prefix].
|
||||
|
||||
* [Connecting devices to the router]: http://developer.nordicsemi.com/nRF5_IoT_SDK/doc/0.9.0/html/a00089.html
|
||||
* [Distributing a global IPv6 prefix]: http://developer.nordicsemi.com/nRF5_IoT_SDK/doc/0.9.0/html/a00090.html
|
@ -1,5 +0,0 @@
|
||||
MODULE = ble_common
|
||||
|
||||
SRC = ble_advdata.c
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
@ -1,54 +0,0 @@
|
||||
/**
|
||||
* @defgroup pkg_nordic-softdevice-ble Nordic Softdevice BLE
|
||||
* @ingroup pkg
|
||||
* @ingroup net
|
||||
* @brief Provides a RIOT adaption for Nordic Softdevice BLE library
|
||||
* @deprecated Will be removed after the 2020.10 release. Use nimble for BLE
|
||||
* support instead.
|
||||
|
||||
# Overview
|
||||
|
||||
This package provides necessary Makefiles and glue code to use the Nordic S132
|
||||
SoftDevice as Bluetooth BLE transport for RIOT's 6lowpan stack.
|
||||
|
||||
# Usage
|
||||
|
||||
"gnrc_netdev_default" has a dependency to "nordic_softdevice_ble", so all
|
||||
examples automatically download the SDK and compile / link / flash all needed
|
||||
code.
|
||||
|
||||
If you want to manually set up included modules, add "USEPKG +=
|
||||
nordic_softdevice_ble" to your application's Makefile.
|
||||
|
||||
See README-BLE-6LoWPAN.md for instructions on how to set up 6lowpan over BLE on
|
||||
Linux.
|
||||
|
||||
# Known issues
|
||||
|
||||
- floating point ABI mismatch
|
||||
|
||||
The Nordic binaries are compiled using hard float ABI, which RIOT currently
|
||||
doesn't support (RIOT's context switching code doesn't preserve the floating
|
||||
point registers). If the softdevice is compiled in, RIOT will be compiled with
|
||||
hard float ABI in order for the linking to succeed. This works for some
|
||||
application, but will lead to serious and hard-to-find bugs for code using
|
||||
floating point instructions.
|
||||
|
||||
Hopefully, either the RIOT community adds hard-float support, or Nordic
|
||||
releases a soft-float version of the used binaries.
|
||||
|
||||
- Outdated
|
||||
|
||||
This package uses version 0.9 of the nRF IoT SDK, which has been integrated
|
||||
into the nRF5 SDK v14.1.0 in its 1.0 version, and the nRF5 SDK has since been
|
||||
released in several new versions.
|
||||
|
||||
A noteworthy shortcoming due to the old version is that the IPSP
|
||||
implementation only interoperates with Linux kernels up to 4.12.
|
||||
|
||||
Unless the [efforts to update the softedevice
|
||||
integration](https://github.com/RIOT-OS/RIOT/pull/9473) are rekindled, this
|
||||
module should not be used in new projects, and @ref pkg_nimble should be used
|
||||
instead.
|
||||
|
||||
*/
|
@ -1,2 +0,0 @@
|
||||
MODULE = nordic_softdevice_ble
|
||||
include $(RIOTBASE)/Makefile.base
|
@ -1,9 +0,0 @@
|
||||
#include "app_error.h"
|
||||
|
||||
#define ENABLE_DEBUG 0
|
||||
#include "debug.h"
|
||||
|
||||
void app_error_handler(uint32_t error_code, uint32_t line_num, const uint8_t *p_file_name)
|
||||
{
|
||||
puts("nordic softdevice app_error_handler()");
|
||||
}
|
@ -1,240 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Nordic Semiconductor
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* @addtogroup cpu
|
||||
* @{
|
||||
*
|
||||
* @addtogroup nrf52832
|
||||
* @{
|
||||
*
|
||||
* @addtogroup nrf52832-ble Bluetooth Low Energy drivers
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* Basic BLE functions.
|
||||
* @author
|
||||
* Wojciech Bober <wojciech.bober@nordicsemi.no>
|
||||
* Kaspar Schleiser <kaspar@schleiser.de>
|
||||
*
|
||||
*/
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
//#include "boards.h"
|
||||
//#include "nordic_common.h"
|
||||
//#include "nrf_delay.h"
|
||||
#include "nrf_sdm.h"
|
||||
#include "ble_advdata.h"
|
||||
#include "ble_srv_common.h"
|
||||
#include "ble_ipsp.h"
|
||||
#include "softdevice_handler.h"
|
||||
#include "app_error.h"
|
||||
#include "iot_defines.h"
|
||||
#include "ble-core.h"
|
||||
|
||||
#define ENABLE_DEBUG 0
|
||||
#include "debug.h"
|
||||
|
||||
#define IS_SRVC_CHANGED_CHARACT_PRESENT 1
|
||||
#define APP_ADV_TIMEOUT 0 /**< Time for which the device must be advertising in non-connectable mode (in seconds). 0 disables timeout. */
|
||||
#define APP_ADV_ADV_INTERVAL MSEC_TO_UNITS(333, UNIT_0_625_MS) /**< The advertising interval. This value can vary between 100ms to 10.24s). */
|
||||
|
||||
static ble_gap_adv_params_t m_adv_params; /**< Parameters to be passed to the stack when starting advertising. */
|
||||
|
||||
static void
|
||||
ble_evt_dispatch(ble_evt_t * p_ble_evt);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Initialize and enable the BLE stack.
|
||||
*/
|
||||
void
|
||||
ble_stack_init(void)
|
||||
{
|
||||
uint32_t err_code;
|
||||
|
||||
// Enable BLE stack.
|
||||
ble_enable_params_t ble_enable_params;
|
||||
memset(&ble_enable_params, 0, sizeof(ble_enable_params));
|
||||
ble_enable_params.gatts_enable_params.attr_tab_size =
|
||||
BLE_GATTS_ATTR_TAB_SIZE_DEFAULT;
|
||||
ble_enable_params.gatts_enable_params.service_changed =
|
||||
IS_SRVC_CHANGED_CHARACT_PRESENT;
|
||||
err_code = sd_ble_enable(&ble_enable_params);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
// Register with the SoftDevice handler module for BLE events.
|
||||
err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
// Setup address
|
||||
ble_gap_addr_t ble_addr;
|
||||
err_code = sd_ble_gap_address_get(&ble_addr);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
ble_addr.addr[5] = 0x00;
|
||||
ble_addr.addr_type = BLE_GAP_ADDR_TYPE_PUBLIC;
|
||||
|
||||
err_code = sd_ble_gap_address_set(BLE_GAP_ADDR_CYCLE_MODE_NONE, &ble_addr);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Return device EUI64 MAC address
|
||||
* @param addr pointer to a buffer to store the address
|
||||
*/
|
||||
#include "ble-mac.h"
|
||||
void
|
||||
ble_get_mac(uint8_t addr[6])
|
||||
{
|
||||
uint32_t err_code;
|
||||
ble_gap_addr_t ble_addr;
|
||||
|
||||
err_code = sd_ble_gap_address_get(&ble_addr);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
ble_eui48(addr, ble_addr.addr,
|
||||
ble_addr.addr_type == BLE_GAP_ADDR_TYPE_PUBLIC);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Initialize BLE advertising data.
|
||||
* @param name Human readable device name that will be advertised
|
||||
*/
|
||||
void
|
||||
ble_advertising_init(const char *name)
|
||||
{
|
||||
uint32_t err_code;
|
||||
ble_advdata_t advdata;
|
||||
uint8_t flags = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED;
|
||||
ble_gap_conn_sec_mode_t sec_mode;
|
||||
|
||||
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
|
||||
|
||||
err_code = sd_ble_gap_device_name_set(&sec_mode, (const uint8_t *)name,
|
||||
strlen(name));
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
ble_uuid_t adv_uuids[] = {{BLE_UUID_IPSP_SERVICE, BLE_UUID_TYPE_BLE}};
|
||||
|
||||
// Build and set advertising data.
|
||||
memset(&advdata, 0, sizeof(advdata));
|
||||
|
||||
advdata.name_type = BLE_ADVDATA_FULL_NAME;
|
||||
advdata.flags = flags;
|
||||
advdata.uuids_complete.uuid_cnt = ARRAY_SIZE(adv_uuids);
|
||||
advdata.uuids_complete.p_uuids = adv_uuids;
|
||||
|
||||
err_code = ble_advdata_set(&advdata, NULL);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
// Initialize advertising parameters (used when starting advertising).
|
||||
memset(&m_adv_params, 0, sizeof(m_adv_params));
|
||||
|
||||
m_adv_params.type = BLE_GAP_ADV_TYPE_ADV_IND;
|
||||
m_adv_params.p_peer_addr = NULL; // Undirected advertisement.
|
||||
m_adv_params.fp = BLE_GAP_ADV_FP_ANY;
|
||||
m_adv_params.interval = APP_ADV_ADV_INTERVAL;
|
||||
m_adv_params.timeout = APP_ADV_TIMEOUT;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Start BLE advertising.
|
||||
*/
|
||||
void
|
||||
ble_advertising_start(void)
|
||||
{
|
||||
uint32_t err_code;
|
||||
|
||||
err_code = sd_ble_gap_adv_start(&m_adv_params);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
DEBUG("ble-core: advertising started\n");
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Print GAP address.
|
||||
* @param addr a pointer to address
|
||||
*/
|
||||
void
|
||||
ble_gap_addr_print(const ble_gap_addr_t *addr)
|
||||
{
|
||||
unsigned int i;
|
||||
for(i = 0; i < sizeof(addr->addr); i++) {
|
||||
if (i > 0) {
|
||||
DEBUG(":");
|
||||
}
|
||||
DEBUG("%02x", addr->addr[i]);
|
||||
}
|
||||
DEBUG(" (%d)\n", addr->addr_type);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Function for handling the Application's BLE Stack events.
|
||||
* @param[in] p_ble_evt Bluetooth stack event.
|
||||
*/
|
||||
static void
|
||||
on_ble_evt(ble_evt_t *p_ble_evt)
|
||||
{
|
||||
switch(p_ble_evt->header.evt_id) {
|
||||
case BLE_GAP_EVT_CONNECTED:
|
||||
DEBUG("ble-core: connected [handle:%d, peer: ", p_ble_evt->evt.gap_evt.conn_handle);
|
||||
ble_gap_addr_print(&(p_ble_evt->evt.gap_evt.params.connected.peer_addr));
|
||||
DEBUG("]\n");
|
||||
sd_ble_gap_rssi_start(p_ble_evt->evt.gap_evt.conn_handle,
|
||||
BLE_GAP_RSSI_THRESHOLD_INVALID,
|
||||
0);
|
||||
break;
|
||||
|
||||
case BLE_GAP_EVT_DISCONNECTED:
|
||||
DEBUG("ble-core: disconnected [handle:%d]\n", p_ble_evt->evt.gap_evt.conn_handle);
|
||||
ble_advertising_start();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief SoftDevice BLE event callback.
|
||||
* @param[in] p_ble_evt Bluetooth stack event.
|
||||
*/
|
||||
static void
|
||||
ble_evt_dispatch(ble_evt_t *p_ble_evt)
|
||||
{
|
||||
ble_ipsp_evt_handler(p_ble_evt);
|
||||
on_ble_evt(p_ble_evt);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
* @}
|
||||
*/
|
@ -1,89 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Nordic Semiconductor
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* @addtogroup cpu
|
||||
* @{
|
||||
*
|
||||
* @addtogroup nrf52832
|
||||
* @{
|
||||
*
|
||||
* @addtogroup nrf52832-ble Bluetooth Low Energy drivers
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
*
|
||||
* @brief Basic BLE functions.
|
||||
*
|
||||
* @author Wojciech Bober <wojciech.bober@nordicsemi.no>
|
||||
*/
|
||||
#ifndef BLE_CORE_H
|
||||
#define BLE_CORE_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Initialize and enable the BLE stack.
|
||||
*/
|
||||
void ble_stack_init(void);
|
||||
|
||||
/**
|
||||
* @brief Initialize BLE advertising data.
|
||||
*
|
||||
* @param name Human readable device name that will be advertised
|
||||
*/
|
||||
void ble_advertising_init(const char *name);
|
||||
|
||||
/**
|
||||
* @brief Start BLE advertising.
|
||||
*/
|
||||
void ble_advertising_start(void);
|
||||
|
||||
/**
|
||||
* @brief Return device MAC address
|
||||
*
|
||||
* @param addr pointer to a buffer to store the address
|
||||
*/
|
||||
void ble_get_mac(uint8_t addr[6]);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BLE_CORE_H */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
* @}
|
||||
*/
|
@ -1,306 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Nordic Semiconductor
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#define DONT_OVERRIDE_NVIC
|
||||
|
||||
#include "ble-core.h"
|
||||
#include "ble_ipsp.h"
|
||||
#include "ble_gap.h"
|
||||
|
||||
#include "ble-mac.h"
|
||||
|
||||
#define ENABLE_DEBUG 0
|
||||
#include "debug.h"
|
||||
|
||||
#if defined(MODULE_OD) && ENABLE_DEBUG
|
||||
#include "od.h"
|
||||
#endif
|
||||
|
||||
#ifndef BLE_MAC_MAX_INTERFACE_NUM
|
||||
#define BLE_MAC_MAX_INTERFACE_NUM (1U) /**< Maximum number of interfaces, i.e.,
|
||||
connection to master devices */
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
uint8_t peer_addr[BLE_L2_ADDR_LEN];
|
||||
ble_ipsp_handle_t handle;
|
||||
} ble_mac_interface_t;
|
||||
|
||||
static ble_mac_interface_t interfaces[BLE_MAC_MAX_INTERFACE_NUM];
|
||||
|
||||
volatile int ble_mac_busy_tx;
|
||||
volatile int ble_mac_busy_rx;
|
||||
|
||||
static ble_mac_inbuf_t inbuf;
|
||||
static ble_mac_callback_t _callback;
|
||||
|
||||
/**
|
||||
* @brief Lookup interface by IPSP connection.
|
||||
*
|
||||
* @param[in] handle a pointer to IPSP handle.
|
||||
* @return a pointer to interface structure
|
||||
* @return NULL if no interface has been found for a given handle
|
||||
*/
|
||||
static ble_mac_interface_t *ble_mac_interface_lookup(ble_ipsp_handle_t *handle)
|
||||
{
|
||||
if (handle == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
for (int i = 0; i < BLE_MAC_MAX_INTERFACE_NUM; i++) {
|
||||
if (interfaces[i].handle.conn_handle == handle->conn_handle &&
|
||||
interfaces[i].handle.cid == handle->cid) {
|
||||
return &interfaces[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Add IPSP connection to the interface table.
|
||||
*
|
||||
* This function binds IPSP connection with peer address.
|
||||
*
|
||||
* @param[in] peer a pointer to eui64 address
|
||||
* @param[in] handle a pointer to IPSP handle
|
||||
*
|
||||
* @return a pointer to an interface structure on success
|
||||
* @return NULL if interface table is full
|
||||
*/
|
||||
static ble_mac_interface_t *ble_mac_interface_add(uint8_t peer[BLE_L2_ADDR_LEN],
|
||||
ble_ipsp_handle_t *handle)
|
||||
{
|
||||
DEBUG("ble_mac_interface_add()\n");
|
||||
for (int i = 0; i < BLE_MAC_MAX_INTERFACE_NUM; i++) {
|
||||
if (interfaces[i].handle.conn_handle == 0 && interfaces[i].handle.cid == 0) {
|
||||
memcpy(&interfaces[i].handle, handle, sizeof(ble_ipsp_handle_t));
|
||||
memcpy(&interfaces[i].peer_addr, peer, BLE_L2_ADDR_LEN);
|
||||
|
||||
/* notify handler thread */
|
||||
/* msg_t m = { .type = BLE_IFACE_ADDED, .content.ptr = &interfaces[i] }; */
|
||||
/* msg_send(&m, gnrc_nordic_ble_6lowpan_pid); */
|
||||
|
||||
return &interfaces[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Remove interface from the interface table.
|
||||
* @param[in] interface a pointer to interface
|
||||
*/
|
||||
static void ble_mac_interface_delete(ble_mac_interface_t *interface)
|
||||
{
|
||||
DEBUG("ble_mac_interface_delete()\n");
|
||||
memset(interface, 0, sizeof(ble_mac_interface_t));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Lookup IPSP handle by peer address.
|
||||
*
|
||||
* @param[in] addr a pointer to eui64 address.
|
||||
* @retval a pointer to IPSP handle on success
|
||||
* @retval NULL if an IPSP handle for given address haven't been found
|
||||
*/
|
||||
static ble_ipsp_handle_t *_find_handle(const uint8_t *addr)
|
||||
{
|
||||
for (int i = 0; i < BLE_MAC_MAX_INTERFACE_NUM; i++) {
|
||||
if (memcmp(interfaces[i].peer_addr, addr, BLE_L2_ADDR_LEN) == 0) {
|
||||
return &interfaces[i].handle;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Send packet on a given IPSP handle.
|
||||
*
|
||||
* @param[in] handle a pointer to IPSP handle.
|
||||
* @return 1 on success, 0 otherwise
|
||||
*/
|
||||
static int _send_to_peer(ble_ipsp_handle_t *handle, void *data, size_t len)
|
||||
{
|
||||
DEBUG("ble-mac: sending packet[GAP handle:%d CID:0x%04X]\n",
|
||||
handle->conn_handle, handle->cid);
|
||||
return ble_ipsp_send(handle, data, len);
|
||||
}
|
||||
|
||||
static int _is_broadcast(uint8_t dest[BLE_L2_ADDR_LEN])
|
||||
{
|
||||
uint32_t *_dest = (uint32_t*)dest;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
if (_dest[i]) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ble_mac_send(uint8_t dest[BLE_L2_ADDR_LEN], void *data, size_t len)
|
||||
{
|
||||
DEBUG("ble_mac_send(): sending pkt with len %u\n", (unsigned)len);
|
||||
|
||||
#if defined(MODULE_OD) && ENABLE_DEBUG
|
||||
od_hex_dump(dest, BLE_L2_ADDR_LEN, OD_WIDTH_DEFAULT);
|
||||
od_hex_dump(data, len, OD_WIDTH_DEFAULT);
|
||||
#endif
|
||||
|
||||
ble_ipsp_handle_t *handle;
|
||||
int ret = -1;
|
||||
|
||||
if ((!dest) || _is_broadcast(dest)) {
|
||||
DEBUG("broadcast\n");
|
||||
for (int i = 0; i < BLE_MAC_MAX_INTERFACE_NUM; i++) {
|
||||
if (interfaces[i].handle.cid != 0 && interfaces[i].handle.conn_handle != 0) {
|
||||
ret = _send_to_peer(&interfaces[i].handle, data, len);
|
||||
DEBUG("ret=%i\n", ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((handle = _find_handle(dest)) != NULL) {
|
||||
DEBUG("unicast\n");
|
||||
ret = _send_to_peer(handle, data, len);
|
||||
}
|
||||
else {
|
||||
DEBUG("ble-mac: no connection found for peer\n");
|
||||
}
|
||||
|
||||
if (ret == NRF_SUCCESS) {
|
||||
ble_mac_busy_tx = 1;
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
DEBUG("ble-mac: send error: %i\n", ret);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t ble_mac_ipsp_evt_handler_irq(ble_ipsp_handle_t *p_handle, ble_ipsp_evt_t *p_evt)
|
||||
{
|
||||
uint32_t retval = NRF_SUCCESS;
|
||||
|
||||
ble_mac_interface_t *p_instance = ble_mac_interface_lookup(p_handle);
|
||||
|
||||
if (p_handle) {
|
||||
DEBUG("ble-mac: IPSP event [handle:%d CID 0x%04X]\n", p_handle->conn_handle, p_handle->cid);
|
||||
}
|
||||
|
||||
switch (p_evt->evt_id) {
|
||||
case BLE_IPSP_EVT_CHANNEL_CONNECTED: {
|
||||
uint8_t peer_addr[BLE_L2_ADDR_LEN];
|
||||
|
||||
DEBUG("ble-mac: channel connected\n");
|
||||
ble_eui48(peer_addr,
|
||||
p_evt->evt_param->params.ch_conn_request.peer_addr.addr,
|
||||
p_evt->evt_param->params.ch_conn_request.peer_addr.addr_type ==
|
||||
BLE_GAP_ADDR_TYPE_PUBLIC);
|
||||
p_instance = ble_mac_interface_add(peer_addr, p_handle);
|
||||
|
||||
if (p_instance != NULL) {
|
||||
DEBUG("ble-mac: added new IPSP interface\n");
|
||||
}
|
||||
else {
|
||||
DEBUG("ble-mac: cannot add new interface. Table is full\n");
|
||||
ble_ipsp_disconnect(p_handle);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case BLE_IPSP_EVT_CHANNEL_DISCONNECTED: {
|
||||
DEBUG("ble-mac: channel disconnected\n");
|
||||
if (p_instance != NULL) {
|
||||
DEBUG("ble-mac: removed IPSP interface\n");
|
||||
ble_mac_interface_delete(p_instance);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case BLE_IPSP_EVT_CHANNEL_DATA_RX: {
|
||||
DEBUG("ble-mac: data received\n");
|
||||
if (p_instance != NULL) {
|
||||
if (ble_mac_busy_rx) {
|
||||
DEBUG("ble-mac: packet dropped as input buffer is busy\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if (p_evt->evt_param->params.ch_rx.len > BLE_SIXLOWPAN_MTU) {
|
||||
DEBUG("ble-mac: packet buffer is too small!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
ble_mac_busy_rx = 1;
|
||||
|
||||
inbuf.len = p_evt->evt_param->params.ch_rx.len;
|
||||
memcpy(inbuf.payload, p_evt->evt_param->params.ch_rx.p_data, inbuf.len);
|
||||
memcpy(inbuf.src, p_instance->peer_addr, BLE_L2_ADDR_LEN);
|
||||
sd_ble_gap_rssi_get(p_handle->conn_handle, &inbuf.rssi);
|
||||
|
||||
_callback(BLE_EVENT_RX_DONE, &inbuf);
|
||||
}
|
||||
else {
|
||||
DEBUG("ble-mac: got data to unknown interface!\n");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case BLE_IPSP_EVT_CHANNEL_DATA_TX_COMPLETE: {
|
||||
DEBUG("ble-mac: data transmitted\n");
|
||||
ble_mac_busy_tx = 0;
|
||||
//_callback(BLE_EVENT_TX_DONE, NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (sched_context_switch_request) {
|
||||
NVIC_SetPendingIRQ( SWI0_EGU0_IRQn );
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
void ble_mac_init(ble_mac_callback_t callback)
|
||||
{
|
||||
assert(callback);
|
||||
|
||||
uint32_t res;
|
||||
ble_ipsp_init_t ipsp_init_params = {
|
||||
.evt_handler = ble_mac_ipsp_evt_handler_irq
|
||||
};
|
||||
|
||||
_callback = callback;
|
||||
|
||||
res = ble_ipsp_init(&ipsp_init_params);
|
||||
DEBUG("ble_ipsp_init() res = %" PRIu32 "\n", res);
|
||||
(void)res;
|
||||
}
|
@ -1,130 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Nordic Semiconductor
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup pkg_nordic-softdevice-ble
|
||||
* @brief Public API and definitions of Nordic Softdevice BLE
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
*/
|
||||
|
||||
|
||||
#ifndef BLE_MAC_H
|
||||
#define BLE_MAC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
BLE_EVENT_RX_DONE = 20000,
|
||||
} ble_mac_event_enum_t;
|
||||
|
||||
#define BLE_IFACE_ADDED (10000)
|
||||
|
||||
#define BLE_SIXLOWPAN_MTU (1280U)
|
||||
#define BLE_L2_ADDR_LEN (6U)
|
||||
|
||||
#ifndef IPV6_IID_FLIP_VALUE
|
||||
#define IPV6_IID_FLIP_VALUE (0x02)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Get BLE EUI64 from EUI48
|
||||
*
|
||||
* @param[out] eui48 The output EUI48 (big-endian,
|
||||
* 6 bytes long)
|
||||
* @param[in] ble_addr The input BLE address (little-endian,
|
||||
* 6 bytes long)
|
||||
* @param[in] _public True if public interface, false otherwise
|
||||
*/
|
||||
static inline void ble_eui48(uint8_t *eui48, const uint8_t *ble_addr, int _public)
|
||||
{
|
||||
eui48[0] = ble_addr[5];
|
||||
eui48[1] = ble_addr[4];
|
||||
eui48[2] = ble_addr[3];
|
||||
eui48[3] = ble_addr[2];
|
||||
eui48[4] = ble_addr[1];
|
||||
eui48[5] = ble_addr[0];
|
||||
if (_public) {
|
||||
eui48[0] &= ~(IPV6_IID_FLIP_VALUE);
|
||||
}
|
||||
else {
|
||||
eui48[0] |= IPV6_IID_FLIP_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Structure handling a received BLE mac packet
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t payload[BLE_SIXLOWPAN_MTU]; /**< Payload of the packet */
|
||||
uint8_t src[BLE_L2_ADDR_LEN]; /**< Source address of the packet */
|
||||
uint16_t len; /**< Length of the packet */
|
||||
int8_t rssi; /**< RSSI of the received packet */
|
||||
} ble_mac_inbuf_t;
|
||||
|
||||
/**
|
||||
* @brief Mac event callback function definition
|
||||
*/
|
||||
typedef void (*ble_mac_callback_t)(ble_mac_event_enum_t event, void*arg);
|
||||
|
||||
/**
|
||||
* @brief Initialize the BLE mac
|
||||
*
|
||||
* @param[in] callback The callback function triggered on mac event
|
||||
*/
|
||||
void ble_mac_init(ble_mac_callback_t callback);
|
||||
|
||||
/**
|
||||
* @brief Send a BLE message
|
||||
*
|
||||
* @param[in] dest The destination address
|
||||
* @param[in] data The data to send
|
||||
* @param[in] len The length of the data to send
|
||||
*
|
||||
* @return 0 if send is successful
|
||||
* @return <0 if send failed
|
||||
*/
|
||||
int ble_mac_send(uint8_t dest[BLE_L2_ADDR_LEN], void *data,
|
||||
size_t len);
|
||||
|
||||
extern volatile int ble_mac_busy_tx; /**< Flag is set to 1 when the driver
|
||||
is busy transmitting a packet. */
|
||||
extern volatile int ble_mac_busy_rx; /**< Flag is set to 1 when there is a
|
||||
received packet pending. */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BLE_MAC_H */
|
||||
/** @} */
|
@ -1,283 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Nordic Semiconductor
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @{
|
||||
* @ingroup net
|
||||
* @file
|
||||
* @brief Glue for Nordic's SoftDevice BLE 6lowpan blob to netapi
|
||||
*
|
||||
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
||||
* @author Martine Lenders <m.lenders@fu-berlin.de>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "msg.h"
|
||||
#include "thread.h"
|
||||
|
||||
#include "net/eui48.h"
|
||||
#include "net/gnrc.h"
|
||||
#include "net/gnrc/netif.h"
|
||||
#include "net/gnrc/nettype.h"
|
||||
|
||||
#include "ble-core.h"
|
||||
#include "softdevice_handler.h"
|
||||
|
||||
#include "ble-mac.h"
|
||||
|
||||
#define ENABLE_DEBUG 0
|
||||
#include "debug.h"
|
||||
|
||||
#if defined(MODULE_OD) && ENABLE_DEBUG
|
||||
#include "od.h"
|
||||
#endif
|
||||
|
||||
#define BLE_PRIO (GNRC_NETIF_PRIO)
|
||||
|
||||
/* XXX: netdev required by gnrc_netif, but not implemented fully for
|
||||
* nordic_softdevice_ble for legacy reasons */
|
||||
|
||||
static char _stack[(THREAD_STACKSIZE_DEFAULT + DEBUG_EXTRA_STACKSIZE)];
|
||||
|
||||
static gnrc_netif_t *_ble_netif = NULL;
|
||||
static gnrc_netif_t _netif;
|
||||
|
||||
static uint8_t _sendbuf[BLE_SIXLOWPAN_MTU];
|
||||
|
||||
static void _ble_mac_callback(ble_mac_event_enum_t event, void* arg)
|
||||
{
|
||||
msg_t m = { .type=event, .content.ptr=arg };
|
||||
|
||||
if ((_ble_netif == NULL) || !msg_send_int(&m, _ble_netif->pid)) {
|
||||
puts("_ble_mac_callback(): possibly lost interrupt");
|
||||
}
|
||||
}
|
||||
|
||||
static void _handle_raw_sixlowpan(ble_mac_inbuf_t *inbuf)
|
||||
{
|
||||
gnrc_pktsnip_t *pkt = gnrc_pktbuf_add(NULL, inbuf->payload,
|
||||
inbuf->len,
|
||||
GNRC_NETTYPE_SIXLOWPAN);
|
||||
|
||||
if(!pkt) {
|
||||
DEBUG("_handle_raw_sixlowpan(): no space left in packet buffer.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* create netif header */
|
||||
gnrc_pktsnip_t *netif_hdr;
|
||||
netif_hdr = gnrc_pktbuf_add(NULL, NULL,
|
||||
sizeof(gnrc_netif_hdr_t) + (2 * sizeof(eui64_t)),
|
||||
GNRC_NETTYPE_NETIF);
|
||||
|
||||
if (netif_hdr == NULL) {
|
||||
DEBUG("_handle_raw_sixlowpan(): no space left in packet buffer.\n");
|
||||
gnrc_pktbuf_release(pkt);
|
||||
return;
|
||||
}
|
||||
|
||||
gnrc_netif_hdr_init(netif_hdr->data, BLE_L2_ADDR_LEN, BLE_L2_ADDR_LEN);
|
||||
gnrc_netif_hdr_set_src_addr(netif_hdr->data, inbuf->src, BLE_L2_ADDR_LEN);
|
||||
gnrc_netif_hdr_set_dst_addr(netif_hdr->data, _ble_netif->l2addr, BLE_L2_ADDR_LEN);
|
||||
gnrc_netif_hdr_set_netif(netif_hdr->data, _ble_netif);
|
||||
|
||||
DEBUG("_handle_raw_sixlowpan(): received packet from %02x:%02x:%02x:%02x:%02x:%02x "
|
||||
"of length %d\n",
|
||||
inbuf->src[0], inbuf->src[1], inbuf->src[2],
|
||||
inbuf->src[3], inbuf->src[4], inbuf->src[5], inbuf->len);
|
||||
#if defined(MODULE_OD) && ENABLE_DEBUG
|
||||
od_hex_dump(inbuf->payload, inbuf->len, OD_WIDTH_DEFAULT);
|
||||
#endif
|
||||
|
||||
pkt = gnrc_pkt_append(pkt, netif_hdr);
|
||||
|
||||
/* throw away packet if no one is interested */
|
||||
if (!gnrc_netapi_dispatch_receive(pkt->type, GNRC_NETREG_DEMUX_CTX_ALL, pkt)) {
|
||||
DEBUG("_handle_raw_sixlowpan: unable to forward packet of type %i\n", pkt->type);
|
||||
gnrc_pktbuf_release(pkt);
|
||||
}
|
||||
}
|
||||
|
||||
static int _send(gnrc_pktsnip_t *pkt)
|
||||
{
|
||||
if (pkt == NULL) {
|
||||
DEBUG("_send_ble: pkt was NULL\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
gnrc_netif_hdr_t *netif_hdr;
|
||||
gnrc_pktsnip_t *payload = pkt->next;
|
||||
uint8_t *dst;
|
||||
|
||||
if (ble_mac_busy_tx) {
|
||||
DEBUG("_send(): ble_mac_busy_tx\n");
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
uint8_t *buf = _sendbuf;
|
||||
unsigned len = 0;
|
||||
|
||||
if (pkt->type != GNRC_NETTYPE_NETIF) {
|
||||
DEBUG("_send_ble: first header is not generic netif header\n");
|
||||
return -EBADMSG;
|
||||
}
|
||||
|
||||
netif_hdr = pkt->data;
|
||||
|
||||
/* prepare destination address */
|
||||
if (netif_hdr->flags &
|
||||
(GNRC_NETIF_HDR_FLAGS_BROADCAST | GNRC_NETIF_HDR_FLAGS_MULTICAST)) {
|
||||
dst = NULL;
|
||||
}
|
||||
else {
|
||||
dst = gnrc_netif_hdr_get_dst_addr(netif_hdr);
|
||||
}
|
||||
|
||||
/* prepare packet for sending */
|
||||
while (payload) {
|
||||
memcpy(buf, payload->data, payload->size);
|
||||
len += payload->size;
|
||||
buf += payload->size;
|
||||
payload = payload->next;
|
||||
}
|
||||
|
||||
gnrc_pktbuf_release(pkt);
|
||||
|
||||
if (ble_mac_send(dst, _sendbuf, len) == -1) {
|
||||
return -EBADMSG;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _netdev_init(netdev_t *dev)
|
||||
{
|
||||
_ble_netif = dev->context;
|
||||
ble_stack_init();
|
||||
ble_mac_init(_ble_mac_callback);
|
||||
_ble_netif->l2addr_len = BLE_L2_ADDR_LEN;
|
||||
ble_get_mac(_ble_netif->l2addr);
|
||||
ble_advertising_init("RIOT BLE");
|
||||
ble_advertising_start();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _netdev_get(netdev_t *netdev, netopt_t opt,
|
||||
void *v, size_t max_len)
|
||||
{
|
||||
int res = -ENOTSUP;
|
||||
uint8_t *value = v;
|
||||
|
||||
(void)netdev;
|
||||
switch (opt) {
|
||||
case NETOPT_ADDRESS:
|
||||
assert(max_len >= BLE_L2_ADDR_LEN);
|
||||
memcpy(value, _ble_netif->l2addr, BLE_L2_ADDR_LEN);
|
||||
res = BLE_L2_ADDR_LEN;
|
||||
break;
|
||||
case NETOPT_ADDR_LEN:
|
||||
case NETOPT_SRC_LEN:
|
||||
assert(max_len == sizeof(uint16_t));
|
||||
*((uint16_t *)value) = BLE_L2_ADDR_LEN;
|
||||
res = sizeof(uint16_t);
|
||||
break;
|
||||
case NETOPT_PROTO:
|
||||
assert(max_len == sizeof(gnrc_nettype_t));
|
||||
*((gnrc_nettype_t *)value) = GNRC_NETTYPE_SIXLOWPAN;
|
||||
res = sizeof(gnrc_nettype_t);
|
||||
break;
|
||||
case NETOPT_DEVICE_TYPE:
|
||||
assert(max_len == sizeof(uint16_t));
|
||||
*((uint16_t *)value) = NETDEV_TYPE_BLE;
|
||||
res = sizeof(uint16_t);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static int _netif_send(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt)
|
||||
{
|
||||
(void)netif;
|
||||
assert(netif == _ble_netif);
|
||||
return _send(pkt);
|
||||
}
|
||||
|
||||
static gnrc_pktsnip_t *_netif_recv(gnrc_netif_t *netif)
|
||||
{
|
||||
(void)netif;
|
||||
/* not supported */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void _netif_msg_handler(gnrc_netif_t *netif, msg_t *msg)
|
||||
{
|
||||
switch (msg->type) {
|
||||
case BLE_EVENT_RX_DONE:
|
||||
{
|
||||
DEBUG("ble rx:\n");
|
||||
_handle_raw_sixlowpan(msg->content.ptr);
|
||||
ble_mac_busy_rx = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static const gnrc_netif_ops_t _ble_ops = {
|
||||
.init = gnrc_netif_default_init,
|
||||
.send = _netif_send,
|
||||
.recv = _netif_recv,
|
||||
.get = gnrc_netif_get_from_netdev,
|
||||
.set = gnrc_netif_set_from_netdev,
|
||||
.msg_handler = _netif_msg_handler,
|
||||
};
|
||||
|
||||
static const netdev_driver_t _ble_netdev_driver = {
|
||||
.send = NULL,
|
||||
.recv = NULL,
|
||||
.init = _netdev_init,
|
||||
.isr = NULL,
|
||||
.get = _netdev_get,
|
||||
.set = netdev_set_notsup,
|
||||
};
|
||||
|
||||
static netdev_t _ble_dummy_dev = {
|
||||
.driver = &_ble_netdev_driver,
|
||||
};
|
||||
|
||||
void gnrc_nordic_ble_6lowpan_init(void)
|
||||
{
|
||||
gnrc_netif_create(&_netif, _stack, sizeof(_stack), BLE_PRIO,
|
||||
"ble", &_ble_dummy_dev, &_ble_ops);
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Nordic Semiconductor
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
#ifndef GNRC_NORDIC_BLE_6LOWPAN_H
|
||||
#define GNRC_NORDIC_BLE_6LOWPAN_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void gnrc_nordic_ble_6lowpan_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* GNRC_NORDIC_BLE_6LOWPAN_H */
|
@ -40,7 +40,7 @@ netopt_t gnrc_netif_get_l2addr_opt(const gnrc_netif_t *netif)
|
||||
|
||||
switch (netif->device_type) {
|
||||
#if defined(MODULE_NETDEV_IEEE802154) || defined(MODULE_XBEE) || \
|
||||
defined(MODULE_NORDIC_SOFTDEVICE_BLE) || defined(MODULE_NIMBLE_NETIF)
|
||||
defined(MODULE_NIMBLE_NETIF)
|
||||
case NETDEV_TYPE_IEEE802154:
|
||||
case NETDEV_TYPE_BLE: {
|
||||
netdev_t *dev = netif->dev;
|
||||
@ -180,7 +180,7 @@ void gnrc_netif_ipv6_init_mtu(gnrc_netif_t *netif)
|
||||
#endif
|
||||
break;
|
||||
#endif
|
||||
#if defined(MODULE_NORDIC_SOFTDEVICE_BLE) || defined(MODULE_NIMBLE_NETIF)
|
||||
#if defined(MODULE_NIMBLE_NETIF)
|
||||
case NETDEV_TYPE_BLE:
|
||||
netif->ipv6.mtu = IPV6_MIN_MTU;
|
||||
#ifdef MODULE_GNRC_SIXLOWPAN_IPHC
|
||||
|
@ -139,11 +139,6 @@ void gnrc_netif_init_devs(void)
|
||||
auto_init_socket_zep();
|
||||
}
|
||||
|
||||
if (IS_USED(MODULE_NORDIC_SOFTDEVICE_BLE)) {
|
||||
extern void gnrc_nordic_ble_6lowpan_init(void);
|
||||
gnrc_nordic_ble_6lowpan_init();
|
||||
}
|
||||
|
||||
if (IS_USED(MODULE_NRFMIN)) {
|
||||
extern void gnrc_nrfmin_init(void);
|
||||
gnrc_nrfmin_init();
|
||||
|
@ -41,7 +41,7 @@ int l2util_eui64_from_addr(int dev_type, const uint8_t *addr, size_t addr_len,
|
||||
{
|
||||
switch (dev_type) {
|
||||
#if defined(MODULE_NETDEV_ETH) || defined(MODULE_ESP_NOW) || \
|
||||
defined(MODULE_NORDIC_SOFTDEVICE_BLE) || defined(MODULE_NIMBLE_NETIF)
|
||||
defined(MODULE_NIMBLE_NETIF)
|
||||
case NETDEV_TYPE_ETHERNET:
|
||||
case NETDEV_TYPE_ESP_NOW:
|
||||
case NETDEV_TYPE_BLE:
|
||||
@ -53,7 +53,7 @@ int l2util_eui64_from_addr(int dev_type, const uint8_t *addr, size_t addr_len,
|
||||
return -EINVAL;
|
||||
}
|
||||
#endif /* defined(MODULE_NETDEV_ETH) || defined(MODULE_ESP_NOW) \
|
||||
defined(MODULE_NORDIC_SOFTDEVICE_BLE) || defined(MODULE_NIMBLE_NETIF) */
|
||||
defined(MODULE_NIMBLE_NETIF) */
|
||||
#if defined(MODULE_NETDEV_IEEE802154) || defined(MODULE_XBEE)
|
||||
case NETDEV_TYPE_IEEE802154:
|
||||
switch (addr_len) {
|
||||
@ -119,11 +119,11 @@ int l2util_ipv6_iid_from_addr(int dev_type,
|
||||
return -EINVAL;
|
||||
}
|
||||
#endif /* defined(MODULE_CC110X) || defined(MODULE_NRFMIN) */
|
||||
#if defined(MODULE_NORDIC_SOFTDEVICE_BLE) || defined(MODULE_NIMBLE_NETIF)
|
||||
#if defined(MODULE_NIMBLE_NETIF)
|
||||
case NETDEV_TYPE_BLE:
|
||||
/* for BLE we don't flip the universal/local flag... */
|
||||
return l2util_eui64_from_addr(dev_type, addr, addr_len, iid);
|
||||
#endif /* defined(MODULE_NORDIC_SOFTDEVICE_BLE) || defined(MODULE_NIMBLE_NETIF) */
|
||||
#endif /* defined(MODULE_NIMBLE_NETIF) */
|
||||
default: {
|
||||
int res = l2util_eui64_from_addr(dev_type, addr, addr_len, iid);
|
||||
if (res == sizeof(eui64_t)) {
|
||||
@ -144,7 +144,7 @@ int l2util_ipv6_iid_to_addr(int dev_type, const eui64_t *iid, uint8_t *addr)
|
||||
eui48_from_ipv6_iid((eui48_t *)addr, iid);
|
||||
return sizeof(eui48_t);
|
||||
#endif /* defined(MODULE_NETDEV_ETH) || defined(MODULE_ESP_NOW) */
|
||||
#if defined(MODULE_NORDIC_SOFTDEVICE_BLE) || defined(MODULE_NIMBLE_NETIF)
|
||||
#if defined(MODULE_NIMBLE_NETIF)
|
||||
case NETDEV_TYPE_BLE:
|
||||
addr[0] = iid->uint8[0];
|
||||
addr[1] = iid->uint8[1];
|
||||
@ -153,7 +153,7 @@ int l2util_ipv6_iid_to_addr(int dev_type, const eui64_t *iid, uint8_t *addr)
|
||||
addr[4] = iid->uint8[6];
|
||||
addr[5] = iid->uint8[7];
|
||||
return sizeof(eui48_t);
|
||||
#endif /* defined(MODULE_NORDIC_SOFTDEVICE_BLE) || defined(MODULE_NIMBLE_NETIF) */
|
||||
#endif /* defined(MODULE_NIMBLE_NETIF) */
|
||||
#if defined(MODULE_NETDEV_IEEE802154) || defined(MODULE_XBEE)
|
||||
case NETDEV_TYPE_IEEE802154:
|
||||
/* assume address was based on EUI-64
|
||||
@ -196,7 +196,7 @@ int l2util_ndp_addr_len_from_l2ao(int dev_type,
|
||||
return sizeof(uint8_t);
|
||||
#endif /* MODULE_CC110X */
|
||||
#if defined(MODULE_NETDEV_ETH) || defined(MODULE_ESP_NOW) || \
|
||||
defined(MODULE_NORDIC_SOFTDEVICE_BLE) || defined(MODULE_NIMBLE_NETIF)
|
||||
defined(MODULE_NIMBLE_NETIF)
|
||||
case NETDEV_TYPE_ETHERNET:
|
||||
case NETDEV_TYPE_ESP_NOW:
|
||||
case NETDEV_TYPE_BLE:
|
||||
@ -208,7 +208,7 @@ int l2util_ndp_addr_len_from_l2ao(int dev_type,
|
||||
return -EINVAL;
|
||||
}
|
||||
#endif /* defined(MODULE_NETDEV_ETH) || defined(MODULE_ESP_NOW) \
|
||||
defined(MODULE_NORDIC_SOFTDEVICE_BLE) || defined(MODULE_NIMBLE_NETIF) */
|
||||
defined(MODULE_NIMBLE_NETIF) */
|
||||
#ifdef MODULE_NRFMIN
|
||||
case NETDEV_TYPE_NRFMIN:
|
||||
(void)opt;
|
||||
|
@ -12,7 +12,6 @@ CHECKED_IFDEF_PATHS = cc110x \
|
||||
netdev_eth \
|
||||
netdev_ieee802154 \
|
||||
xbee \
|
||||
nordic_softdevice_ble \
|
||||
nrfmin \
|
||||
nimble_netif
|
||||
|
||||
|
@ -1,20 +0,0 @@
|
||||
BOARD ?= nrf52dk
|
||||
include ../Makefile.tests_common
|
||||
|
||||
# Use the Nordic SoftDevice
|
||||
USEPKG += nordic_softdevice_ble
|
||||
|
||||
# use a minimal GNRC configuration
|
||||
USEMODULE += gnrc_netdev_default
|
||||
USEMODULE += auto_init_gnrc_netif
|
||||
USEMODULE += gnrc_ipv6
|
||||
USEMODULE += gnrc_icmpv6_echo
|
||||
# also add the shell with some basic shell commands
|
||||
USEMODULE += shell
|
||||
USEMODULE += shell_commands
|
||||
USEMODULE += ps
|
||||
|
||||
# softdevice currently broken on CI
|
||||
TEST_ON_CI_BLACKLIST += all
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
@ -1,13 +0,0 @@
|
||||
# Nordic SoftDevice Test Application
|
||||
The main purpose of this test application is to ensure the inclusion of the
|
||||
Nordic SoftDevice package in RIOTs build test.
|
||||
|
||||
In addition, this example includes a minimal GNRC configuration and the
|
||||
corresponding shell commands, so it can be used for some simple tests of
|
||||
network functionality. Please refer to `pkg/nordic_softdevice_ble/README.md`
|
||||
and `pkg/nordic_softdevice_ble/README-BLE-6LoWPAN.md` for more information on
|
||||
how to setup an IPv6 connection to your device.
|
||||
|
||||
For more features, you can use the SoftDevice with RIOTs `gnrc_networking`
|
||||
example application. Simply build `gnrc_networking` for a SoftDevice-capable
|
||||
device, e.g. `USEPKG=nordic_softdevice_ble BOARD=nrf52dk make ...`.
|
@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Freie Universität Berlin
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup tests
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief This test application ensures that the Nordic SoftDevice
|
||||
* integration is included in the build test
|
||||
*
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "shell.h"
|
||||
#include "msg.h"
|
||||
|
||||
#define MAIN_QUEUE_SIZE (8)
|
||||
static msg_t _main_msg_queue[MAIN_QUEUE_SIZE];
|
||||
|
||||
int main(void)
|
||||
{
|
||||
/* we need a message queue for the thread running the shell in order to
|
||||
* receive potentially fast incoming networking packets */
|
||||
msg_init_queue(_main_msg_queue, MAIN_QUEUE_SIZE);
|
||||
puts("Test for the RIOT integration of the Nordic SoftDevice");
|
||||
|
||||
/* start shell */
|
||||
puts("All up, running the shell now");
|
||||
char line_buf[SHELL_DEFAULT_BUFSIZE];
|
||||
shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE);
|
||||
|
||||
/* should be never reached */
|
||||
return 0;
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import time
|
||||
from testrunner import run
|
||||
|
||||
|
||||
def testfunc(child):
|
||||
child.expect_exact(">")
|
||||
time.sleep(1) # Wait 1s to let some time for the interface to be fully ready
|
||||
child.sendline("ifconfig")
|
||||
child.expect(r"Iface\s+(\d+)\s+HWaddr:")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(run(testfunc))
|
Loading…
Reference in New Issue
Block a user