diff --git a/examples/skald_ibeacon/Makefile b/examples/skald_ibeacon/Makefile new file mode 100644 index 0000000000..da517defcf --- /dev/null +++ b/examples/skald_ibeacon/Makefile @@ -0,0 +1,21 @@ +# name of your application +APPLICATION = skald_ibeacon + +# 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_ibeacon + +# 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_ibeacon/README.md b/examples/skald_ibeacon/README.md new file mode 100644 index 0000000000..37911394dd --- /dev/null +++ b/examples/skald_ibeacon/README.md @@ -0,0 +1,6 @@ +# Skald iBeacon Example + +This example demonstrates the usage of `Skald` for creating an Apple `iBeacon`. + +Simply compile and flash, and verify your newly created beacon with any type of +BLE scanner. diff --git a/examples/skald_ibeacon/main.c b/examples/skald_ibeacon/main.c new file mode 100644 index 0000000000..fe9ac9d104 --- /dev/null +++ b/examples/skald_ibeacon/main.c @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2017-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 Setting up an iBeacon using Skald + * + * @author Hauke Petersen + * + * @} + */ + +#include "log.h" + +#include "net/skald/ibeacon.h" + +/* configure the iBeacon */ +#define UUID { 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, \ + 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, } +#define MAJOR (0x0023) +#define MINOR (0x0017) +#define TXPOWER (0U) + +/* allocate a single advertising context */ +static skald_ctx_t _ctx; + +int main(void) +{ + LOG_INFO("Skald and the tail of the iBeacon\n"); + + /* this will configure the iBeacon and start advertising it */ + skald_uuid_t uuid = { UUID }; + skald_ibeacon_advertise(&_ctx, &uuid, MAJOR, MINOR, TXPOWER); + + return 0; +}