diff --git a/examples/skald_eddystone/Makefile b/examples/skald_eddystone/Makefile new file mode 100644 index 0000000000..a452cae292 --- /dev/null +++ b/examples/skald_eddystone/Makefile @@ -0,0 +1,21 @@ +# name of your application +APPLICATION = skald_eddystone + +# If no BOARD is found in the environment, use this default: +BOARD ?= nrf52dk + +# This has to be the absolute path to the RIOT base directory: +RIOTBASE ?= $(CURDIR)/../.. + +# include Skald +USEMODULE += skald_eddystone + +# Comment this out to disable code in RIOT that does safety checking +# which is not needed in a production environment but helps in the +# development process: +# CFLAGS += -DDEVELHELP + +# Change this to 0 show compiler invocation lines by default: +QUIET ?= 1 + +include $(RIOTBASE)/Makefile.include diff --git a/examples/skald_eddystone/README.md b/examples/skald_eddystone/README.md new file mode 100644 index 0000000000..fa0d8f8f6a --- /dev/null +++ b/examples/skald_eddystone/README.md @@ -0,0 +1,8 @@ +# Skald iBeacon Example + +This example demonstrates the usage of `Skald` for creating an Google +`Eddystone` beacon, advertising an`Eddystone-URI` and an `Eddystone-URL` +concurrently. + +Simply compile and flash, and verify your newly created beacon with any type of +BLE scanner. diff --git a/examples/skald_eddystone/main.c b/examples/skald_eddystone/main.c new file mode 100644 index 0000000000..2892cc85bd --- /dev/null +++ b/examples/skald_eddystone/main.c @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2018 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 examples + * @{ + * + * @file + * @brief BLE Eddystone beacon example using Skald + * + * @author Hauke Petersen + * + * @} + */ + +#include "log.h" + +#include "net/skald/eddystone.h" + +/* example of an Eddystone URI: + * - namespace (ASCII): 'supercool!' + * - instance (ASCII): `_RIOT_` */ +#define URI_NAMESPACE { 0x73, 0x75, 0x70, 0x65, 0x72, \ + 0x63, 0x6f, 0x6f, 0x6c, 0x21 } +#define URI_INSTANCE { 0x5f, 0x52, 0x49, 0x4f, 0x54, 0x5f } + +/* advertise this short URL, points to https://www.riot-os.org */ +#define URL "bit.ly/2Ep11dm" +/* calibrated TX power value */ +#define TX_PWR (0U) + + +/* allocate two advertising contexts, one for Eddystone-URL and one for + * Eddystone-URI */ +static skald_ctx_t _ctx_uid; +static skald_ctx_t _ctx_url; + +int main(void) +{ + LOG_INFO("Skald and the tail of Eddystone\n"); + + /* advertise the defined URI */ + skald_eddystone_uid_t uid = { URI_NAMESPACE, URI_INSTANCE }; + skald_eddystone_uid_adv(&_ctx_uid, &uid, TX_PWR); + + /* also advertise the defined short-URL */ + skald_eddystone_url_adv(&_ctx_url, EDDYSTONE_URL_HTTPS, URL, TX_PWR); + + return 0; +}