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

net/skald: Expose configurations to Kconfig #14824

Merged
merged 4 commits into from
Aug 26, 2020
Merged
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
77 changes: 70 additions & 7 deletions sys/include/net/skald.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* # Design Decisions and Limitations
* - support for local addresses only (using `luid` to generate them)
* - advertising interval is configured during compile time, override by setting
* `CFLAGS+=-DSKALD_INTERVAL=xxx`
* `CFLAGS+=-DCONFIG_SKALD_INTERVAL=xxx`
* - advertising channels are configured during compile time, override by
* setting `CFLAGS+=-DSKALD_ADV_CHAN={37,39}`
*
Expand Down Expand Up @@ -55,17 +55,80 @@ extern "C" {
#endif

/**
* @brief Static advertising interval
* @defgroup net_skald_conf Skald compile configurations
* @ingroup config
* @{
*/
/**
* @brief Advertising interval in microseconds
*/
#ifndef CONFIG_SKALD_INTERVAL
#define CONFIG_SKALD_INTERVAL (1 * US_PER_SEC)
#endif

/**
* @brief Configure advertising channel 37
*
* Set CONFIG_ADV_CH_37_DISABLE to disable channel 37
*/
#ifdef DOXYGEN
#define CONFIG_ADV_CH_37_DISABLE
#endif

/**
* @brief Configure advertising channel 38
*
* Set CONFIG_ADV_CH_38_DISABLE to disable channel 38
*/
#ifdef DOXYGEN
#define CONFIG_ADV_CH_38_DISABLE
#endif

/**
* @brief Configure advertising channel 39
*
* Set CONFIG_ADV_CH_39_DISABLE to disable channel 39
*/
#ifdef DOXYGEN
#define CONFIG_ADV_CH_39_DISABLE
#endif
/** @} */

/**
* @brief Define advertising channel 37 if @ref CONFIG_ADV_CH_37_DISABLE is
* not set
*/
#if !defined(CONFIG_ADV_CH_37_DISABLE) || defined(DOXYGEN)
#define ADV_CH_37 37,
#else
#define ADV_CH_37
#endif

/**
* @brief Define advertising channel 38 if @ref CONFIG_ADV_CH_38_DISABLE is
* not set
*/
#if !defined(CONFIG_ADV_CH_38_DISABLE) || defined(DOXYGEN)
#define ADV_CH_38 38,
#else
#define ADV_CH_38
#endif

/**
* @brief Define advertising channel 39 if @ref CONFIG_ADV_CH_39_DISABLE is
* not set
*/
#ifndef SKALD_INTERVAL
#define SKALD_INTERVAL (1 * US_PER_SEC)
#if !defined(CONFIG_ADV_CH_39_DISABLE) || defined(DOXYGEN)
#define ADV_CH_39 39
#else
#define ADV_CH_39
#endif

/**
* @brief Static list of used advertising channels
* @brief List of advertising channels
*/
#ifndef SKALD_ADV_CHAN
#define SKALD_ADV_CHAN { 37, 38, 39 }
#define SKALD_ADV_CHAN { ADV_CH_37 ADV_CH_38 ADV_CH_39 }
#endif

/**
Expand Down Expand Up @@ -93,7 +156,7 @@ void skald_init(void);
/**
* @brief Start advertising the given packet
*
* The packet will be send out each advertising interval (see SKALD_INTERVAL) on
* The packet will be send out each advertising interval (see CONFIG_SKALD_INTERVAL) on
* each of the defined advertising channels (see SKALD_ADV_CHAN).
*
* @param[in,out] ctx start advertising this context
Expand Down
1 change: 1 addition & 0 deletions sys/net/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
menu "Networking"

rsource "application_layer/Kconfig"
rsource "ble/Kconfig"
rsource "credman/Kconfig"
rsource "gnrc/Kconfig"
rsource "sock/Kconfig"
Expand Down
7 changes: 7 additions & 0 deletions sys/net/ble/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright (c) 2020 Freie Universitaet 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.
#
rsource "skald/Kconfig"
31 changes: 31 additions & 0 deletions sys/net/ble/skald/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright (c) 2020 Freie Universitaet 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.
#
menuconfig KCONFIG_MODULE_SKALD
bool "Configure SKALD"
depends on MODULE_SKALD
help
Configure Skald, BLE advertising stack, using Kconfig.

if KCONFIG_MODULE_SKALD

config SKALD_INTERVAL
int "Advertising interval in microseconds"
default 1000000
help
Configure advertising interval in microseconds. Default value is 1
second which is 1000000 microseconds.

config ADV_CH_37_DISABLE
bool "Disable advertising on channel 37"

config ADV_CH_38_DISABLE
bool "Disable advertising on channel 38"

config ADV_CH_39_DISABLE
bool "Disable advertising on channel 39"

endif # KCONFIG_MODULE_SKALD
2 changes: 1 addition & 1 deletion sys/net/ble/skald/skald.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static void _stop_radio(void)

static void _sched_next(skald_ctx_t *ctx)
{
ctx->last += SKALD_INTERVAL;
ctx->last += CONFIG_SKALD_INTERVAL;
/* schedule next advertising event, adding a random jitter between
* 0ms and 10ms (see spec v5.0-vol6-b-4.4.2.2.1) */
ctx->last += random_uint32_range(JITTER_MIN, JITTER_MAX);
Expand Down