Merge pull request #126 from andrzej-kaczmarek/phy-late-wfr-fix

nimble/phy: Fix late wfr setup
diff --git a/LICENSE b/LICENSE
index 8b36d82..08b9b21 100644
--- a/LICENSE
+++ b/LICENSE
@@ -200,250 +200,18 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 
-This product bundles crc16, which is available under the "3-clause BSD"
-license.  For details, see:
-    * util/crc/include/crc/crc16.h
-    * util/crc/src/crc16.c
-
 This product bundles queue.h 8.5, which is available under the "3-clause BSD"
-license.  For details, see kernel/os/include/os/queue.h
+license.  For details, see porting/nimble/include/os/queue.h
 
 This product partly derives from FreeBSD, which is available under the
 "3-clause BSD" license.  For details, see:
-    * kernel/os/include/os/os_time.h
-    * kernel/os/src/os_mbuf.c
-    * encoding/base64/src/base64.c
-    * time/datetime/src/datetime.c
+    * porting/nimble/src/os_mbuf.c
 
-This product bundles baselibc, which is available under the "3-clause BSD"
-license. Baselibc bundles tinyprintf and is based on klibc for details see:
-libc/baselibc/LICENSE
-
-This product bundles tinyprintf, which is available under the "3-clause BSD"
-license.  For details, see libc/baselibc/src/tinyprintf.c
-
-This product contains code based on klibc, which is available under the MIT
-license.  For details, see libc/baselibc/LICENSE
-
-This product bundles microjson, which is available under the "3-clause BSD"
-license.  For details, see encoding/json/
-
-This product bundles and partly derives from parts of the Nordic nRF52 SDK,
-which are available under a BSD style license.  Relevant files are:
-    * hw/bsp/nrf51dk/src/arch/cortex_m0/gcc_startup_nrf51.s
-    * hw/bsp/nrf51dk/src/arch/cortex_m0/gcc_startup_nrf51_split.s
-    * hw/bsp/nrf52840pdk/src/arch/cortex_m4/gcc_startup_nrf52840.s
-    * hw/bsp/nrf52840pdk/src/arch/cortex_m4/gcc_startup_nrf52_split.s
-    * hw/bsp/nrf52dk/src/arch/cortex_m4/gcc_startup_nrf52.s
-    * hw/bsp/nrf52dk/src/arch/cortex_m4/gcc_startup_nrf52_split.s
-    * hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/toolchain/system_nrf51.c
-    * hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/toolchain/system_nrf51.h
-    * hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/toolchain/system_nrf51422.c
-    * hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/toolchain/system_nrf52.c
-    * hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/toolchain/system_nrf52.h
-    * hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/toolchain/system_nrf52840.c
-    * hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/toolchain/system_nrf52840.h
-
-This product bundles Gary S. Brown's CRC32 implementation, which is available under the following license:
+This product bundles Gary S. Brown's CRC32 implementation, which is available
+under the following license:
     COPYRIGHT (C) 1986 Gary S. Brown.  You may use this program, or
     code or tables extracted from it, as desired without restriction.
 
-This product bundles parts of CMSIS-CORE, which is available under the
-"3-clause BSD" license.  Bundled files are:
-    * hw/cmsis-core/
-    * kernel/os/src/arch/cortex_m0/m0/HAL_CM0.s
-    * kernel/os/src/arch/cortex_m0/m0/SVC_Table.s
-    * kernel/os/src/arch/cortex_m4/m4/HAL_CM4.s
-    * kernel/os/src/arch/cortex_m4/m4/SVC_Table.s
-
-This product bundles additional files from CMSIS-CORE, but these files are
-missing licensing information.  The BSD license was subsequently added to
-these files in later releases.  These files are:
-    * hw/cmsis-core/src/cmsis_nvic.c
-    * hw/mcu/ambiq/apollo2/include/mcu/cmsis_nvic.h
-    * hw/mcu/nordic/nrf51xxx/include/mcu/cmsis_nvic.h
-    * hw/mcu/nordic/nrf52xxx/include/mcu/cmsis_nvic.h
-    * hw/mcu/nxp/MK64F12/include/mcu/cmsis_nvic.h
-    * hw/mcu/nxp/mkw41z/include/mcu/cmsis_nvic.h
-    * hw/mcu/stm/stm32f1xx/include/mcu/cmsis_nvic.h
-    * hw/mcu/stm/stm32f3xx/include/mcu/cmsis_nvic.h
-    * hw/mcu/stm/stm32f4xx/include/mcu/cmsis_nvic.h
-    * hw/mcu/stm/stm32f7xx/include/mcu/cmsis_nvic.h
-    * hw/mcu/stm/stm32l1xx/include/mcu/cmsis_nvic.h
-
-This product bundles parts of STM32CubeF4 1.5, which is available under the
-"3-clause BSD" license.  Bundled files are:
-    * hw/mcu/stm/stm32f4xx/src/ext
-    * hw/bsp/nucleo-f401re/src/arch/cortex_m4/startup_STM32F40x.s
-    * hw/bsp/nucleo-f401re/include/bsp/stm32f4xx_hal_conf.h
-    * hw/bsp/nucleo-f401re/src/system_stm32f4xx.c
-    * hw/bsp/olimex_stm32-e407_devboard/src/arch/cortex_m4/startup_STM32F40x.s
-    * hw/bsp/olimex_stm32-e407_devboard/include/bsp/stm32f4xx_hal_conf.h
-    * hw/bsp/olimex_stm32-e407_devboard/src/system_stm32f4xx.c
-    * hw/bsp/stm32f4discovery/src/arch/cortex_m4/startup_STM32F40x.s
-    * hw/bsp/stm32f4discovery/include/bsp/stm32f4xx_hal_conf.h
-    * hw/bsp/stm32f4discovery/src/system_stm32f4xx.c
-
-This product bundles parts of STM32CubeF7, which is available under the
-"3-clause BSD" license.  Bundled files are:
-    * hw/mcu/stm/stm32f7xx/src/ext
-    * hw/bsp/stm32f767-nucleo/include/bsp/stm32f7xx_hal_conf.h
-    * hw/bsp/stm32f767-nucleo/src/system_stm32f7xx.c
-    * hw/bsp/stm32f767-nucleo/src/arch/cortex_m7/startup_stm32f767xx.s
-
-This product bundles parts of mbed, which is available under the
-"3-clause BSD" license.  Bundled files are:
-    * hw/mcu/nordic/nrf51xxx/include/mcu/cortex_m0.h
-    * hw/mcu/nordic/nrf52xxx/include/mcu/cortex_m4.h
-    * hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/device/compiler_abstraction.h
-    * hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/device/nrf.h
-    * hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/device/nrf51.h
-    * hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/device/nrf52.h
-    * hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/device/nrf52840.h
-    * hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/device/nrf51_to_nrf52.h
-    * hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/device/nrf51_to_nrf52840.h
-    * hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/device/nrf52_to_nrf52840.h
-    * hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/device/nrf51_bitfields.h
-    * hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/device/nrf52_bitfields.h
-    * hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/device/nrf52840_bitfields.h
-    * hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/device/nrf52840_peripherals.h
-    * hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/device/nrf51_deprecated.h
-    * hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/toolchain/system_nrf51.c
-    * hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/toolchain/system_nrf51.h
-    * hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/toolchain/system_nrf51422.h
-    * hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/toolchain/system_nrf51422.c
-    * hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/toolchain/system_nrf52.c
-    * hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/toolchain/system_nrf52.h
-    * hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/toolchain/system_nrf52840.c
-    * hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/toolchain/system_nrf52840.h
-    * hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/device/nrf52_name_change.h
-
-This product bundles FATFS, which is available under a
-"1-clause BSD" style license.  Bundled files are:
-    * fs/fatfs/include/fatfs/diskio.h
-    * fs/fatfs/include/fatfs/ff.h
-    * fs/fatfs/include/fatfs/ffconf.h
-    * fs/fatfs/include/fatfs/integer.h
-    * fs/fatfs/src/ff.c
-    * fs/fatfs/src/option/unicode.c
-
-This product bundles part of linker scripts Nordic Semiconductor nRF5 devices, which is available under the
-"modified Tcl/Tk" license.  Bundled files are:
-    * hw/bsp/nrf52840pdk/split-nrf52840pdk.ld
-    * hw/bsp/nrf52840pdk/nrf52840pdk_no_boot.ld
-    * hw/bsp/bmd300eval/bmd300eval_no_boot.ld
-    * hw/bsp/nrf51dk-16kbram/nrf51dk-16kbram_no_boot.ld
-    * hw/bsp/nrf51dk/nrf51dk_no_boot.ld
-    * hw/bsp/nrf52dk/nrf52dk_no_boot.ld
-    * hw/mcu/nordic/nrf51xxx/nrf51.ld
-    * hw/mcu/nordic/nrf52xxx/nrf52.ld
-    * hw/mcu/ambiq/apollo2/apollo2.ld
-
-This product bundles part of NXP/FreeScale SDK, which is available
-under the "3-clause BSD" license. Bundled files are:
-    * hw/mcu/nxp/src/ext
-
-This product bundles part of NXP mkw41z, which is available under the
-"3-clause BSD" license.  Bundled files are:
-    * hw/mcu/nxp/mkw41z/include/mcu/MKW41Z4.h
-    * hw/mcu/nxp/mkw41z/include/mcu/MKW41Z4_features.h
-    * hw/mcu/nxp/mkw41z/include/mcu/fsl_device_registers.h
-    * hw/mcu/nxp/mkw41z/include/mcu/system_MKW41Z4.h
-    * hw/mcu/nxp/mkw41z/src/system_MKW41Z4.c
-    * hw/bsp/usbmkw41z/boot-mkw41z512.ld
-    * hw/bsp/usbmkw41z/mkw41z512.ld
-    * hw/bsp/usbmkw41z/no-boot-mkw41z512.ld
-    * hw/bsp/usbmkw41z/src/arch/cortex_m0/gcc_startup_mkw41z.s
-
-This product bundles part of mips architecture and ci40, which is available
-under the "3-clause BSD" license.  Bundled files are:
-    * kernel/os/src/arch/mips/asm/ctx.S
-    * kernel/os/src/arch/mips/asm/excpt_isr.S
-    * hw/bsp/ci40/uhi32.ld
-
-This product bundles LwIP, which is available under the "3-clause BSD"
-license. For details, and bundled files see:
-    * net/ip/lwip_base/COPYING
-    * net/ip/lwip_base
-
 This product bundles tinycrypt, which is available under the "3-clause BSD"
 license. For details, and bundled files see:
-    * crypto/tinycrypt/LICENSE
-    * crypto/tinycrypt
-
-This product bundles parts of the Generic SX1276 driver from Semtech, which
-is available under the "3-clause BSD" license. For details, see:
-    * apps/loraping/src/main.c
-    * hw/drivers/lora/sx1276/LICENSE.txt
-
-This product bundles parts of SEGGER RTT, which is available under the
-"3-clause BSD" license. For details, see:
-    * hw/drivers/rtt
-
-This products bundle Adafruit's tsl2561 driver, which is available under the
-"3-clause BSD" license. For details, see:
-    * hw/drivers/sensors/tsl2561
-
-This products bundles Amiq Micro Apollo 2, which is available under the
-"3-clause BSD" license. Bundled files are:
-    * hw/mcu/ambiq/apollo2/include/mcu/apollo2.h
-    * hw/mcu/ambiq/apollo2/include/mcu/system_apollo2.h
-
-This product bundles processor headers for PIC32 by Microchip Technology
-Inc., which is available under the "3-clause BSD" license. Bundled files are:
-    * hw/mcu/microchip/pic32mx470f512h/include/mcu/p32mx470f512h.h
-    * hw/mcu/microchip/pic32mx470f512h/include/mcu/ppic32mx.h
-
-This product bundles MIPS processor low-level macros by Imagination
-Technologies Limited, which is available under the "3-clause BSD" license.
-Bundled files are included inside:
-    * hw/mips-hal/src/arch/mips
-
-This product bundles parts of LoRaWAN endpoint stack by Semtech, which is
-available under the "3-clause BSD" license. For details, see:
-    * net/lora/node/LICENSE.txt
-
-This product bundles Eclipse Paho's MQTT by IBM Corp. which is available
-under the Eclipse Public License 1.0. For details see:
-    * net/mqtt/eclipse/LICENSE.txt
-
-This product bundles SEGGER SystemView, which is available under the
-"3-clause BSD" license. For details, see:
-    * sys/sysview/vendor
-
-This product bundles normalizer.css, affix.js and scrollspy.js by Twitter
-which are available under the MIT license. Bundled files are:
-    * docs/_static/css/bootstrap-3.0.3.min.css
-    * docs/themes/mynewt/static/js/affix.js
-    * docs/themes/mynewt/static/js/scrollspy.js
-
-This product bundles tinycbor by Intel Corporation, which is available under
-the MIT license. For details see:
-    * encoding/tinycbor/include/tinycbor
-
-This product bundles FontAwesome by Dave Gandy, which is available under the
-SIL Open Font License 1.1. Bundled files are:
-    * docs/themes/mynewt/static/fonts/fontawesome-webfont.eot
-    * docs/themes/mynewt/static/fonts/fontawesome-webfont.svg
-    * docs/themes/mynewt/static/fonts/fontawesome-webfont.ttf
-    * docs/themes/mynewt/static/fonts/fontawesome-webfont.woff
-    * docs/themes/mynewt/static/fonts/FontAwesome.otf
-
-This product bundles Inconsolata by Raph Levien, which is available under the
-SIL Open Font License 1.1. Bundled files are:
-    * docs/themes/mynewt/static/fonts/Inconsolata-Bold.ttf
-    * docs/themes/mynewt/static/fonts/Inconsolata-Regular.ttf
-
-This product bundles Lato by Ɓukasz Dziedzic, which is available under the
-SIL Open Font License 1.1. Bundled files are:
-    * docs/themes/mynewt/static/fonts/Lato-Bold.ttf
-    * docs/themes/mynewt/static/fonts/Lato-Regular.ttf
-
-This product bundles RobotSlab by Christian Robertson, which is available
-under the Apache License v2.0. Bundled files are:
-    * docs/themes/mynewt/static/fonts/RobotoSlab-Bold.ttf
-    * docs/themes/mynewt/static/fonts/RobotoSlab-Regular.ttf
-
-This product bundles part of embARC BSP SDK by Synopsys, which is available
-under the "3-clause BSD" license. Bundled files are:
-    * hw/mcu/arc/src/ext/sdk
+    * ext/tinycrypt/LICENSE
diff --git a/apps/ext_advertiser/pkg.yml b/apps/ext_advertiser/pkg.yml
new file mode 100644
index 0000000..a743d20
--- /dev/null
+++ b/apps/ext_advertiser/pkg.yml
@@ -0,0 +1,41 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+pkg.name: apps/ext_advertiser
+pkg.type: app
+pkg.description: Extended Advertising sample application.
+pkg.author: "Szymon Janc"
+pkg.email: "szymon.janc@codecoup.pl"
+pkg.homepage: "http://mynewt.apache.org/"
+pkg.keywords:
+
+pkg.deps:
+    - nimble/controller
+    - nimble/host
+    - nimble/host/util
+    - nimble/host/services/gap
+    - nimble/host/services/gatt
+    - nimble/host/store/config
+    - nimble/transport/ram
+    - "@apache-mynewt-core/boot/bootutil"
+    - "@apache-mynewt-core/kernel/os"
+    - "@apache-mynewt-core/sys/console/full"
+    - "@apache-mynewt-core/sys/log/full"
+    - "@apache-mynewt-core/sys/stats/full"
+    - "@apache-mynewt-core/sys/sysinit"
+    - "@apache-mynewt-core/sys/id"
diff --git a/apps/ext_advertiser/src/main.c b/apps/ext_advertiser/src/main.c
new file mode 100644
index 0000000..6bbc23d
--- /dev/null
+++ b/apps/ext_advertiser/src/main.c
@@ -0,0 +1,464 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include "os/mynewt.h"
+#include "console/console.h"
+#include "config/config.h"
+#include "nimble/ble.h"
+#include "host/ble_hs.h"
+#include "host/util/util.h"
+
+#include"patterns.h"
+
+static uint8_t id_addr_type;
+
+static void start_legacy_duration(uint8_t pattern, bool configure);
+static void start_ext_max_events(uint8_t pattern, bool configure);
+
+static int
+start_ext_max_events_gap_event(struct ble_gap_event *event, void *arg)
+{
+    static uint8_t pattern = 1;
+
+    switch (event->type) {
+    case BLE_GAP_EVENT_ADV_COMPLETE:
+        break;
+    default:
+        assert(0);
+        return 0;
+    }
+
+    assert(event->adv_complete.instance == 4);
+    assert(event->adv_complete.reason == BLE_HS_ETIMEOUT);
+    assert(event->adv_complete.num_ext_adv_events == 10);
+
+    console_printf("instance %u terminated\n", event->adv_complete.instance);
+
+    pattern++;
+
+    start_ext_max_events(pattern, false);
+
+    return 0;
+}
+
+/* Starts advertising instance with 100 max events and changing adv data pattern
+ * and SID.
+ */
+static void
+start_ext_max_events(uint8_t pattern, bool configure)
+{
+    struct ble_gap_ext_adv_params params;
+    static uint8_t adv_data[600];
+    struct os_mbuf *data;
+    uint8_t instance = 4;
+    ble_addr_t addr;
+    int events = 10;
+    int rc;
+
+    if (configure) {
+        /* use defaults for non-set params */
+        memset (&params, 0, sizeof(params));
+
+        /* advertise using random addr */
+        params.own_addr_type = BLE_OWN_ADDR_RANDOM;
+
+        params.primary_phy = BLE_HCI_LE_PHY_1M;
+        params.secondary_phy = BLE_HCI_LE_PHY_1M;
+        params.tx_power = 127;
+        params.sid = pattern % 16;
+
+        /* allow larger interval, 400 * 0.625ms with 100 events will give up to
+         * ~2.5 seconds for instance
+         */
+        params.itvl_min = BLE_GAP_ADV_FAST_INTERVAL1_MIN;
+        params.itvl_max = 400;
+
+        /* configure instance 0 */
+        rc = ble_gap_ext_adv_configure(instance, &params, NULL,
+                                        start_ext_max_events_gap_event, NULL);
+        assert (rc == 0);
+
+        /* set random (NRPA) address for instance */
+        rc = ble_hs_id_gen_rnd(1, &addr);
+        assert (rc == 0);
+
+        rc = ble_gap_ext_adv_set_addr(instance, &addr );
+        assert (rc == 0);
+    }
+
+    /* in this case both advertising data and scan response is allowed, but
+     * both are limited to 31 bytes each
+     */
+
+    /* get mbuf for adv data */
+    data = os_msys_get_pkthdr(600, 0);
+    assert(data);
+
+    memset(adv_data, pattern, sizeof(adv_data));
+
+    /* fill mbuf with adv data */
+    rc = os_mbuf_append(data, adv_data, 600);
+    assert(rc == 0);
+
+   rc = ble_gap_ext_adv_set_data(instance, data);
+   assert (rc == 0);
+
+   /* start advertising */
+    rc = ble_gap_ext_adv_start(instance, 0, events);
+    assert (rc == 0);
+
+    console_printf("instance %u started (PDUs with max events %d)\n",
+                                                            instance, events);
+}
+
+static int
+start_legacy_duration_gap_event(struct ble_gap_event *event, void *arg)
+{
+    static uint8_t pattern = 1;
+
+    switch (event->type) {
+    case BLE_GAP_EVENT_ADV_COMPLETE:
+        break;
+    default:
+        assert(0);
+        return 0;
+    }
+
+    assert(event->adv_complete.instance == 3);
+    assert(event->adv_complete.reason == BLE_HS_ETIMEOUT);
+
+    console_printf("instance %u terminated\n", event->adv_complete.instance);
+
+    pattern++;
+
+    start_legacy_duration(pattern, false);
+
+    return 0;
+}
+
+/* Starts advertising instance with 5sec timeout and changing adv data pattern
+ * and SID.
+ */
+static void
+start_legacy_duration(uint8_t pattern, bool configure)
+{
+    struct ble_gap_ext_adv_params params;
+    uint8_t adv_data[31];
+    struct os_mbuf *data;
+    uint8_t instance = 3;
+    ble_addr_t addr;
+    int duration = 500; /* 5seconds, 10ms units */
+    int rc;
+
+    if (configure) {
+        /* use defaults for non-set params */
+        memset (&params, 0, sizeof(params));
+
+        /* enable advertising using legacy PDUs */
+        params.legacy_pdu = 1;
+
+        /* advertise using random addr */
+        params.own_addr_type = BLE_OWN_ADDR_RANDOM;
+
+        params.primary_phy = BLE_HCI_LE_PHY_1M;
+        params.secondary_phy = BLE_HCI_LE_PHY_1M;
+        params.tx_power = 127;
+        params.sid = pattern % 16;
+
+        /* configure instance 0 */
+        rc = ble_gap_ext_adv_configure(instance, &params, NULL,
+                                        start_legacy_duration_gap_event, NULL);
+        assert (rc == 0);
+
+        /* set random (NRPA) address for instance */
+        rc = ble_hs_id_gen_rnd(1, &addr);
+        assert (rc == 0);
+
+        rc = ble_gap_ext_adv_set_addr(instance, &addr );
+        assert (rc == 0);
+    }
+
+    /* in this case both advertising data and scan response is allowed, but
+     * both are limited to 31 bytes each
+     */
+
+    /* get mbuf for adv data */
+    data = os_msys_get_pkthdr(31, 0);
+    assert(data);
+
+    memset(adv_data, pattern, sizeof(adv_data));
+
+    /* fill mbuf with adv data */
+    rc = os_mbuf_append(data, adv_data, 31);
+    assert(rc == 0);
+
+   rc = ble_gap_ext_adv_set_data(instance, data);
+   assert (rc == 0);
+
+   /* start advertising */
+    rc = ble_gap_ext_adv_start(instance, duration, 0);
+    assert (rc == 0);
+
+    console_printf("instance %u started (legacy PDUs with duration %d)\n",
+                                                            instance, duration);
+}
+
+/* this is simple non-connectable scannable instance using legacy PUDs that
+ * runs forever
+ */
+static void
+start_scannable_legacy_ext(void)
+{
+    struct ble_gap_ext_adv_params params;
+    struct os_mbuf *data;
+    uint8_t instance = 2;
+    ble_addr_t addr;
+    int rc;
+
+    /* use defaults for non-set params */
+    memset (&params, 0, sizeof(params));
+
+    /* enable scannable advertising using legacy PDUs */
+    params.scannable = 1;
+    params.legacy_pdu = 1;
+
+    /* advertise using random addr */
+    params.own_addr_type = BLE_OWN_ADDR_RANDOM;
+
+    params.primary_phy = BLE_HCI_LE_PHY_1M;
+    params.secondary_phy = BLE_HCI_LE_PHY_1M;
+    params.tx_power = 127;
+    params.sid = 2;
+
+    /* configure instance 0 */
+    rc = ble_gap_ext_adv_configure(instance, &params, NULL, NULL, NULL);
+    assert (rc == 0);
+
+    /* set random (NRPA) address for instance */
+    rc = ble_hs_id_gen_rnd(1, &addr);
+    assert (rc == 0);
+
+    rc = ble_gap_ext_adv_set_addr(instance, &addr );
+    assert (rc == 0);
+
+    /* in this case both advertising data and scan response is allowed, but
+     * both are limited to 31 bytes each
+     */
+
+    /* get mbuf for adv data */
+    data = os_msys_get_pkthdr(31, 0);
+    assert(data);
+
+    /* fill mbuf with adv data */
+    rc = os_mbuf_append(data, ext_adv_pattern_1, 31);
+    assert(rc == 0);
+
+   rc = ble_gap_ext_adv_set_data(instance, data);
+   assert (rc == 0);
+
+    /* get mbuf for scan rsp data */
+    data = os_msys_get_pkthdr(31, 0);
+    assert(data);
+
+    /* fill mbuf with scan rsp data */
+    rc = os_mbuf_append(data, ext_adv_pattern_1 + 31, 31);
+    assert(rc == 0);
+
+   rc = ble_gap_ext_adv_rsp_set_data(instance, data);
+   assert (rc == 0);
+
+   /* start advertising */
+    rc = ble_gap_ext_adv_start(instance, 0, 0);
+    assert (rc == 0);
+
+    console_printf("instance %u started (scannable legacy PDUs)\n", instance);
+}
+
+static int
+scannable_ext_gap_event(struct ble_gap_event *event, void *arg)
+{
+    switch (event->type) {
+    default:
+        break;
+    }
+
+    return 0;
+}
+
+/* this is simple scannable instance that runs forever
+ * TODO Get scan request notifications.
+ */
+static void
+start_scannable_ext(void)
+{
+    struct ble_gap_ext_adv_params params;
+    struct os_mbuf *data;
+    uint8_t instance = 1;
+    ble_addr_t addr;
+    int rc;
+
+    /* use defaults for non-set params */
+    memset (&params, 0, sizeof(params));
+
+    /* enable scannable advertising */
+    params.scannable = 1;
+
+    /* enable scan request notification */
+    params.scan_req_notif = 1;
+
+    /* advertise using random addr */
+    params.own_addr_type = BLE_OWN_ADDR_RANDOM;
+
+    params.primary_phy = BLE_HCI_LE_PHY_1M;
+    params.secondary_phy = BLE_HCI_LE_PHY_1M;
+    params.tx_power = 127;
+    params.sid = 1;
+
+    /* configure instance 0 */
+    rc = ble_gap_ext_adv_configure(instance, &params, NULL,
+                                   scannable_ext_gap_event, NULL);
+    assert (rc == 0);
+
+    /* set random (NRPA) address for instance */
+    rc = ble_hs_id_gen_rnd(1, &addr);
+    assert (rc == 0);
+
+    rc = ble_gap_ext_adv_set_addr(instance, &addr );
+    assert (rc == 0);
+
+    /* in this case only scan response is allowed */
+
+    /* get mbuf for scan rsp data */
+    data = os_msys_get_pkthdr(sizeof(ext_adv_pattern_1), 0);
+    assert(data);
+
+    /* fill mbuf with scan rsp data */
+    rc = os_mbuf_append(data, ext_adv_pattern_1, sizeof(ext_adv_pattern_1));
+    assert(rc == 0);
+
+   rc = ble_gap_ext_adv_rsp_set_data(instance, data);
+   assert (rc == 0);
+
+   /* start advertising */
+    rc = ble_gap_ext_adv_start(instance, 0, 0);
+    assert (rc == 0);
+
+    console_printf("instance %u started (scannable)\n", instance);
+}
+
+/* this is simple non-connectable instance that runs forever */
+static void
+start_non_connectable_ext(void)
+{
+    struct ble_gap_ext_adv_params params;
+    struct os_mbuf *data;
+    uint8_t instance = 0;
+    int rc;
+
+    /* use defaults for non-set params */
+    memset (&params, 0, sizeof(params));
+
+    /* advertise using ID addr */
+    params.own_addr_type = id_addr_type;
+
+    params.primary_phy = BLE_HCI_LE_PHY_1M;
+    params.secondary_phy = BLE_HCI_LE_PHY_1M;
+    params.tx_power = 127;
+    params.sid = 0;
+
+    /* configure instance */
+    rc = ble_gap_ext_adv_configure(instance, &params, NULL, NULL, NULL);
+    assert (rc == 0);
+
+    /* in this case only advertisign data is allowed */
+
+    /* get mbuf for adv data */
+    data = os_msys_get_pkthdr(sizeof(ext_adv_pattern_1), 0);
+    assert(data);
+
+    /* fill mbuf with adv data */
+    rc = os_mbuf_append(data, ext_adv_pattern_1, sizeof(ext_adv_pattern_1));
+    assert(rc == 0);
+
+   rc = ble_gap_ext_adv_set_data(instance, data);
+   assert (rc == 0);
+
+   /* start advertising */
+    rc = ble_gap_ext_adv_start(instance, 0, 0);
+    assert (rc == 0);
+
+    console_printf("instance %u started (non-con non-scan)\n", instance);
+}
+
+static void
+on_sync(void)
+{
+    int rc;
+
+    console_printf("Synced, starting advertising\n");
+
+    /* Make sure we have proper identity address set (public preferred) */
+    rc = ble_hs_util_ensure_addr(0);
+    assert(rc == 0);
+
+    /* configure global address */
+    rc = ble_hs_id_infer_auto(0, &id_addr_type);
+    assert(rc == 0);
+
+    start_non_connectable_ext();
+
+    start_scannable_ext();
+
+    start_scannable_legacy_ext();
+
+    start_legacy_duration(0, true);
+
+    start_ext_max_events(0, true);
+}
+
+/*
+ * main
+ *
+ * The main task for the project. This function initializes the packages,
+ * then starts serving events from default event queue.
+ *
+ * @return int NOTE: this function should never return!
+ */
+int
+main(void)
+{
+    /* Initialize OS */
+    sysinit();
+
+    console_printf("Extended Advertising sample application\n");
+
+    /* Set sync callback */
+    ble_hs_cfg.sync_cb = on_sync;
+
+    /* As the last thing, process events from default event queue */
+    while (1) {
+        os_eventq_run(os_eventq_dflt_get());
+    }
+    return 0;
+}
diff --git a/apps/ext_advertiser/src/patterns.h b/apps/ext_advertiser/src/patterns.h
new file mode 100644
index 0000000..9485d0d
--- /dev/null
+++ b/apps/ext_advertiser/src/patterns.h
@@ -0,0 +1,186 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+static const uint8_t ext_adv_pattern_1[] = {
+        0x00, 0x02, 0x00, 0x04, 0x00, 0x06, 0x00, 0x08, 0x00, 0x0a,
+        0x00, 0x0c, 0x00, 0x0e, 0x00, 0x10, 0x00, 0x12, 0x00, 0x14,
+        0x00, 0x16, 0x00, 0x18, 0x00, 0x1a, 0x00, 0x1c, 0x00, 0x1e,
+        0x00, 0x20, 0x00, 0x22, 0x00, 0x24, 0x00, 0x26, 0x00, 0x28,
+        0x00, 0x2a, 0x00, 0x2c, 0x00, 0x2e, 0x00, 0x30, 0x00, 0x32,
+        0x00, 0x34, 0x00, 0x36, 0x00, 0x38, 0x00, 0x3a, 0x00, 0x3c,
+        0x00, 0x3e, 0x00, 0x40, 0x00, 0x42, 0x00, 0x44, 0x00, 0x46,
+        0x00, 0x48, 0x00, 0x4a, 0x00, 0x4c, 0x00, 0x4e, 0x00, 0x50,
+        0x00, 0x52, 0x00, 0x54, 0x00, 0x56, 0x00, 0x58, 0x00, 0x5a,
+        0x00, 0x5c, 0x00, 0x5e, 0x00, 0x60, 0x00, 0x62, 0x00, 0x64,
+        0x00, 0x66, 0x00, 0x68, 0x00, 0x6a, 0x00, 0x6c, 0x00, 0x6e,
+        0x00, 0x70, 0x00, 0x72, 0x00, 0x74, 0x00, 0x76, 0x00, 0x78,
+        0x00, 0x7a, 0x00, 0x7c, 0x00, 0x7e, 0x00, 0x80, 0x00, 0x82,
+        0x00, 0x84, 0x00, 0x86, 0x00, 0x88, 0x00, 0x8a, 0x00, 0x8c,
+        0x00, 0x8e, 0x00, 0x90, 0x00, 0x92, 0x00, 0x94, 0x00, 0x96,
+        0x00, 0x98, 0x00, 0x9a, 0x00, 0x9c, 0x00, 0x9e, 0x00, 0xa0,
+        0x00, 0xa2, 0x00, 0xa4, 0x00, 0xa6, 0x00, 0xa8, 0x00, 0xaa,
+        0x00, 0xac, 0x00, 0xae, 0x00, 0xb0, 0x00, 0xb2, 0x00, 0xb4,
+        0x00, 0xb6, 0x00, 0xb8, 0x00, 0xba, 0x00, 0xbc, 0x00, 0xbe,
+        0x00, 0xc0, 0x00, 0xc2, 0x00, 0xc4, 0x00, 0xc6, 0x00, 0xc8,
+        0x00, 0xca, 0x00, 0xcc, 0x00, 0xce, 0x00, 0xd0, 0x00, 0xd2,
+        0x00, 0xd4, 0x00, 0xd6, 0x00, 0xd8, 0x00, 0xda, 0x00, 0xdc,
+        0x00, 0xde, 0x00, 0xe0, 0x00, 0xe2, 0x00, 0xe4, 0x00, 0xe6,
+        0x00, 0xe8, 0x00, 0xea, 0x00, 0xec, 0x00, 0xee, 0x00, 0xf0,
+        0x00, 0xf2, 0x00, 0xf4, 0x00, 0xf6, 0x00, 0xf8, 0x00, 0xfa,
+        0x00, 0xfc, 0x00, 0xfe, 0x01, 0x01, 0x01, 0x03, 0x01, 0x05,
+        0x01, 0x07, 0x01, 0x09, 0x01, 0x0b, 0x01, 0x0d, 0x01, 0x0f,
+        0x01, 0x11, 0x01, 0x13, 0x01, 0x15, 0x01, 0x17, 0x01, 0x19,
+        0x01, 0x1b, 0x01, 0x1d, 0x01, 0x1f, 0x01, 0x21, 0x01, 0x23,
+        0x01, 0x25, 0x01, 0x27, 0x01, 0x29, 0x01, 0x2b, 0x01, 0x2d,
+        0x01, 0x2f, 0x01, 0x31, 0x01, 0x33, 0x01, 0x35, 0x01, 0x37,
+        0x01, 0x39, 0x01, 0x3b, 0x01, 0x3d, 0x01, 0x3f, 0x01, 0x41,
+        0x01, 0x43, 0x01, 0x45, 0x01, 0x47, 0x01, 0x49, 0x01, 0x4b,
+        0x01, 0x4d, 0x01, 0x4f, 0x01, 0x51, 0x01, 0x53, 0x01, 0x55,
+        0x01, 0x57, 0x01, 0x59, 0x01, 0x5b, 0x01, 0x5d, 0x01, 0x5f,
+        0x01, 0x61, 0x01, 0x63, 0x01, 0x65, 0x01, 0x67, 0x01, 0x69,
+        0x01, 0x6b, 0x01, 0x6d, 0x01, 0x6f, 0x01, 0x71, 0x01, 0x73,
+        0x01, 0x75, 0x01, 0x77, 0x01, 0x79, 0x01, 0x7b, 0x01, 0x7d,
+        0x01, 0x7f, 0x01, 0x81, 0x01, 0x83, 0x01, 0x85, 0x01, 0x87,
+        0x01, 0x89, 0x01, 0x8b, 0x01, 0x8d, 0x01, 0x8f, 0x01, 0x91,
+        0x01, 0x93, 0x01, 0x95, 0x01, 0x97, 0x01, 0x99, 0x01, 0x9b,
+        0x01, 0x9d, 0x01, 0x9f, 0x01, 0xa1, 0x01, 0xa3, 0x01, 0xa5,
+        0x01, 0xa7, 0x01, 0xa9, 0x01, 0xab, 0x01, 0xad, 0x01, 0xaf,
+        0x01, 0xb1, 0x01, 0xb3, 0x01, 0xb5, 0x01, 0xb7, 0x01, 0xb9,
+        0x01, 0xbb, 0x01, 0xbd, 0x01, 0xbf, 0x01, 0xc1, 0x01, 0xc3,
+        0x01, 0xc5, 0x01, 0xc7, 0x01, 0xc9, 0x01, 0xcb, 0x01, 0xcd,
+        0x01, 0xcf, 0x01, 0xd1, 0x01, 0xd3, 0x01, 0xd5, 0x01, 0xd7,
+        0x01, 0xd9, 0x01, 0xdb, 0x01, 0xdd, 0x01, 0xdf, 0x01, 0xe1,
+        0x01, 0xe3, 0x01, 0xe5, 0x01, 0xe7, 0x01, 0xe9, 0x01, 0xeb,
+        0x01, 0xed, 0x01, 0xef, 0x01, 0xf1, 0x01, 0xf3, 0x01, 0xf5,
+        0x01, 0xf7, 0x01, 0xf9, 0x01, 0xfb, 0x01, 0xfd, 0x02, 0x00,
+        0x02, 0x02, 0x02, 0x04, 0x02, 0x06, 0x02, 0x08, 0x02, 0x0a,
+        0x02, 0x0c, 0x02, 0x0e, 0x02, 0x10, 0x02, 0x12, 0x02, 0x14,
+        0x02, 0x16, 0x02, 0x18, 0x02, 0x1a, 0x02, 0x1c, 0x02, 0x1e,
+        0x02, 0x20, 0x02, 0x22, 0x02, 0x24, 0x02, 0x26, 0x02, 0x28,
+        0x02, 0x2a, 0x02, 0x2c, 0x02, 0x2e, 0x02, 0x30, 0x02, 0x32,
+        0x02, 0x34, 0x02, 0x36, 0x02, 0x38, 0x02, 0x3a, 0x02, 0x3c,
+        0x02, 0x3e, 0x02, 0x40, 0x02, 0x42, 0x02, 0x44, 0x02, 0x46,
+        0x02, 0x48, 0x02, 0x4a, 0x02, 0x4c, 0x02, 0x4e, 0x02, 0x50,
+        0x02, 0x52, 0x02, 0x54, 0x02, 0x56, 0x02, 0x58, 0x02, 0x5a,
+        0x02, 0x5c, 0x02, 0x5e, 0x02, 0x60, 0x02, 0x62, 0x02, 0x64,
+        0x02, 0x66, 0x02, 0x68, 0x02, 0x6a, 0x02, 0x6c, 0x02, 0x6e,
+        0x02, 0x70, 0x02, 0x72, 0x02, 0x74, 0x02, 0x76, 0x02, 0x78,
+        0x02, 0x7a, 0x02, 0x7c, 0x02, 0x7e, 0x02, 0x80, 0x02, 0x82,
+        0x02, 0x84, 0x02, 0x86, 0x02, 0x88, 0x02, 0x8a, 0x02, 0x8c,
+        0x02, 0x8e, 0x02, 0x90, 0x02, 0x92, 0x02, 0x94, 0x02, 0x96,
+        0x02, 0x98, 0x02, 0x9a, 0x02, 0x9c, 0x02, 0x9e, 0x02, 0xa0,
+        0x02, 0xa2, 0x02, 0xa4, 0x02, 0xa6, 0x02, 0xa8, 0x02, 0xaa,
+        0x02, 0xac, 0x02, 0xae, 0x02, 0xb0, 0x02, 0xb2, 0x02, 0xb4,
+        0x02, 0xb6, 0x02, 0xb8, 0x02, 0xba, 0x02, 0xbc, 0x02, 0xbe,
+        0x02, 0xc0, 0x02, 0xc2, 0x02, 0xc4, 0x02, 0xc6, 0x02, 0xc8,
+        0x02, 0xca, 0x02, 0xcc, 0x02, 0xce, 0x02, 0xd0, 0x02, 0xd2,
+        0x02, 0xd4, 0x02, 0xd6, 0x02, 0xd8, 0x02, 0xda, 0x02, 0xdc,
+        0x02, 0xde, 0x02, 0xe0, 0x02, 0xe2, 0x02, 0xe4, 0x02, 0xe6,
+        0x02, 0xe8, 0x02, 0xea, 0x02, 0xec, 0x02, 0xee, 0x02, 0xf0,
+        0x02, 0xf2, 0x02, 0xf4, 0x02, 0xf6, 0x02, 0xf8, 0x02, 0xfa,
+        0x02, 0xfc, 0x02, 0xfe, 0x03, 0x01, 0x03, 0x03, 0x03, 0x05,
+        0x03, 0x07, 0x03, 0x09, 0x03, 0x0b, 0x03, 0x0d, 0x03, 0x0f,
+        0x03, 0x11, 0x03, 0x13, 0x03, 0x15, 0x03, 0x17, 0x03, 0x19,
+        0x03, 0x1b, 0x03, 0x1d, 0x03, 0x1f, 0x03, 0x21, 0x03, 0x23,
+        0x03, 0x25, 0x03, 0x27, 0x03, 0x29, 0x03, 0x2b, 0x03, 0x2d,
+        0x03, 0x2f, 0x03, 0x31, 0x03, 0x33, 0x03, 0x35, 0x03, 0x37,
+        0x03, 0x39, 0x03, 0x3b, 0x03, 0x3d, 0x03, 0x3f, 0x03, 0x41,
+        0x03, 0x43, 0x03, 0x45, 0x03, 0x47, 0x03, 0x49, 0x03, 0x4b,
+        0x03, 0x4d, 0x03, 0x4f, 0x03, 0x51, 0x03, 0x53, 0x03, 0x55,
+        0x03, 0x57, 0x03, 0x59, 0x03, 0x5b, 0x03, 0x5d, 0x03, 0x5f,
+        0x03, 0x61, 0x03, 0x63, 0x03, 0x65, 0x03, 0x67, 0x03, 0x69,
+        0x03, 0x6b, 0x03, 0x6d, 0x03, 0x6f, 0x03, 0x71, 0x03, 0x73,
+        0x03, 0x75, 0x03, 0x77, 0x03, 0x79, 0x03, 0x7b, 0x03, 0x7d,
+        0x03, 0x7f, 0x03, 0x81, 0x03, 0x83, 0x03, 0x85, 0x03, 0x87,
+        0x03, 0x89, 0x03, 0x8b, 0x03, 0x8d, 0x03, 0x8f, 0x03, 0x91,
+        0x03, 0x93, 0x03, 0x95, 0x03, 0x97, 0x03, 0x99, 0x03, 0x9b,
+        0x03, 0x9d, 0x03, 0x9f, 0x03, 0xa1, 0x03, 0xa3, 0x03, 0xa5,
+        0x03, 0xa7, 0x03, 0xa9, 0x03, 0xab, 0x03, 0xad, 0x03, 0xaf,
+        0x03, 0xb1, 0x03, 0xb3, 0x03, 0xb5, 0x03, 0xb7, 0x03, 0xb9,
+        0x03, 0xbb, 0x03, 0xbd, 0x03, 0xbf, 0x03, 0xc1, 0x03, 0xc3,
+        0x03, 0xc5, 0x03, 0xc7, 0x03, 0xc9, 0x03, 0xcb, 0x03, 0xcd,
+        0x03, 0xcf, 0x03, 0xd1, 0x03, 0xd3, 0x03, 0xd5, 0x03, 0xd7,
+        0x03, 0xd9, 0x03, 0xdb, 0x03, 0xdd, 0x03, 0xdf, 0x03, 0xe1,
+        0x03, 0xe3, 0x03, 0xe5, 0x03, 0xe7, 0x03, 0xe9, 0x03, 0xeb,
+        0x03, 0xed, 0x03, 0xef, 0x03, 0xf1, 0x03, 0xf3, 0x03, 0xf5,
+        0x03, 0xf7, 0x03, 0xf9, 0x03, 0xfb, 0x03, 0xfd, 0x04, 0x00,
+        0x04, 0x02, 0x04, 0x04, 0x04, 0x06, 0x04, 0x08, 0x04, 0x0a,
+        0x04, 0x0c, 0x04, 0x0e, 0x04, 0x10, 0x04, 0x12, 0x04, 0x14,
+        0x04, 0x16, 0x04, 0x18, 0x04, 0x1a, 0x04, 0x1c, 0x04, 0x1e,
+        0x04, 0x20, 0x04, 0x22, 0x04, 0x24, 0x04, 0x26, 0x04, 0x28,
+        0x04, 0x2a, 0x04, 0x2c, 0x04, 0x2e, 0x04, 0x30, 0x04, 0x32,
+        0x04, 0x34, 0x04, 0x36, 0x04, 0x38, 0x04, 0x3a, 0x04, 0x3c,
+        0x04, 0x3e, 0x04, 0x40, 0x04, 0x42, 0x04, 0x44, 0x04, 0x46,
+        0x04, 0x48, 0x04, 0x4a, 0x04, 0x4c, 0x04, 0x4e, 0x04, 0x50,
+        0x04, 0x52, 0x04, 0x54, 0x04, 0x56, 0x04, 0x58, 0x04, 0x5a,
+        0x04, 0x5c, 0x04, 0x5e, 0x04, 0x60, 0x04, 0x62, 0x04, 0x64,
+        0x04, 0x66, 0x04, 0x68, 0x04, 0x6a, 0x04, 0x6c, 0x04, 0x6e,
+        0x04, 0x70, 0x04, 0x72, 0x04, 0x74, 0x04, 0x76, 0x04, 0x78,
+        0x04, 0x7a, 0x04, 0x7c, 0x04, 0x7e, 0x04, 0x80, 0x04, 0x82,
+        0x04, 0x84, 0x04, 0x86, 0x04, 0x88, 0x04, 0x8a, 0x04, 0x8c,
+        0x04, 0x8e, 0x04, 0x90, 0x04, 0x92, 0x04, 0x94, 0x04, 0x96,
+        0x04, 0x98, 0x04, 0x9a, 0x04, 0x9c, 0x04, 0x9e, 0x04, 0xa0,
+        0x04, 0xa2, 0x04, 0xa4, 0x04, 0xa6, 0x04, 0xa8, 0x04, 0xaa,
+        0x04, 0xac, 0x04, 0xae, 0x04, 0xb0, 0x04, 0xb2, 0x04, 0xb4,
+        0x04, 0xb6, 0x04, 0xb8, 0x04, 0xba, 0x04, 0xbc, 0x04, 0xbe,
+        0x04, 0xc0, 0x04, 0xc2, 0x04, 0xc4, 0x04, 0xc6, 0x04, 0xc8,
+        0x04, 0xca, 0x04, 0xcc, 0x04, 0xce, 0x04, 0xd0, 0x04, 0xd2,
+        0x04, 0xd4, 0x04, 0xd6, 0x04, 0xd8, 0x04, 0xda, 0x04, 0xdc,
+        0x04, 0xde, 0x04, 0xe0, 0x04, 0xe2, 0x04, 0xe4, 0x04, 0xe6,
+        0x04, 0xe8, 0x04, 0xea, 0x04, 0xec, 0x04, 0xee, 0x04, 0xf0,
+        0x04, 0xf2, 0x04, 0xf4, 0x04, 0xf6, 0x04, 0xf8, 0x04, 0xfa,
+        0x04, 0xfc, 0x04, 0xfe, 0x05, 0x01, 0x05, 0x03, 0x05, 0x05,
+        0x05, 0x07, 0x05, 0x09, 0x05, 0x0b, 0x05, 0x0d, 0x05, 0x0f,
+        0x05, 0x11, 0x05, 0x13, 0x05, 0x15, 0x05, 0x17, 0x05, 0x19,
+        0x05, 0x1b, 0x05, 0x1d, 0x05, 0x1f, 0x05, 0x21, 0x05, 0x23,
+        0x05, 0x25, 0x05, 0x27, 0x05, 0x29, 0x05, 0x2b, 0x05, 0x2d,
+        0x05, 0x2f, 0x05, 0x31, 0x05, 0x33, 0x05, 0x35, 0x05, 0x37,
+        0x05, 0x39, 0x05, 0x3b, 0x05, 0x3d, 0x05, 0x3f, 0x05, 0x41,
+        0x05, 0x43, 0x05, 0x45, 0x05, 0x47, 0x05, 0x49, 0x05, 0x4b,
+        0x05, 0x4d, 0x05, 0x4f, 0x05, 0x51, 0x05, 0x53, 0x05, 0x55,
+        0x05, 0x57, 0x05, 0x59, 0x05, 0x5b, 0x05, 0x5d, 0x05, 0x5f,
+        0x05, 0x61, 0x05, 0x63, 0x05, 0x65, 0x05, 0x67, 0x05, 0x69,
+        0x05, 0x6b, 0x05, 0x6d, 0x05, 0x6f, 0x05, 0x71, 0x05, 0x73,
+        0x05, 0x75, 0x05, 0x77, 0x05, 0x79, 0x05, 0x7b, 0x05, 0x7d,
+        0x05, 0x7f, 0x05, 0x81, 0x05, 0x83, 0x05, 0x85, 0x05, 0x87,
+        0x05, 0x89, 0x05, 0x8b, 0x05, 0x8d, 0x05, 0x8f, 0x05, 0x91,
+        0x05, 0x93, 0x05, 0x95, 0x05, 0x97, 0x05, 0x99, 0x05, 0x9b,
+        0x05, 0x9d, 0x05, 0x9f, 0x05, 0xa1, 0x05, 0xa3, 0x05, 0xa5,
+        0x05, 0xa7, 0x05, 0xa9, 0x05, 0xab, 0x05, 0xad, 0x05, 0xaf,
+        0x05, 0xb1, 0x05, 0xb3, 0x05, 0xb5, 0x05, 0xb7, 0x05, 0xb9,
+        0x05, 0xbb, 0x05, 0xbd, 0x05, 0xbf, 0x05, 0xc1, 0x05, 0xc3,
+        0x05, 0xc5, 0x05, 0xc7, 0x05, 0xc9, 0x05, 0xcb, 0x05, 0xcd,
+        0x05, 0xcf, 0x05, 0xd1, 0x05, 0xd3, 0x05, 0xd5, 0x05, 0xd7,
+        0x05, 0xd9, 0x05, 0xdb, 0x05, 0xdd, 0x05, 0xdf, 0x05, 0xe1,
+        0x05, 0xe3, 0x05, 0xe5, 0x05, 0xe7, 0x05, 0xe9, 0x05, 0xeb,
+        0x05, 0xed, 0x05, 0xef, 0x05, 0xf1, 0x05, 0xf3, 0x05, 0xf5,
+        0x05, 0xf7, 0x05, 0xf9, 0x05, 0xfb, 0x05, 0xfd, 0x06, 0x00,
+        0x06, 0x02, 0x06, 0x04, 0x06, 0x06, 0x06, 0x08, 0x06, 0x0a,
+        0x06, 0x0c, 0x06, 0x0e, 0x06, 0x10, 0x06, 0x12, 0x06, 0x14,
+        0x06, 0x16, 0x06, 0x18, 0x06, 0x1a, 0x06, 0x1c, 0x06, 0x1e,
+        0x06, 0x20, 0x06, 0x22, 0x06, 0x24, 0x06, 0x26, 0x06, 0x28,
+        0x06, 0x2a, 0x06, 0x2c, 0x06, 0x2e, 0x06, 0x30, 0x06, 0x32,
+        0x06, 0x34, 0x06, 0x36, 0x06, 0x38, 0x06, 0x3a, 0x06, 0x3c,
+        0x06, 0x3e, 0x06, 0x40, 0x06, 0x42, 0x06, 0x44, 0x06, 0x46,
+        0x06, 0x48, 0x06, 0x4a, 0x06, 0x4c, 0x06, 0x4e, 0x06, 0x50,
+        0x06, 0x52, 0x06, 0x54, 0x06, 0x56, 0x06, 0x58, 0x06, 0x5a,
+        0x06, 0x5c, 0x06, 0x5e, 0x06, 0x60, 0x06, 0x62, 0x06, 0x64,
+        0x06, 0x66, 0x06, 0x68, 0x06, 0x6a, 0x06, 0x6c, 0x06, 0x6e,
+        0x06, 0x70, 0x06, 0x72, 0x06, 0x74, 0x06, 0x76, 0x06, 0x78
+};
diff --git a/apps/ext_advertiser/syscfg.yml b/apps/ext_advertiser/syscfg.yml
new file mode 100644
index 0000000..0702ea7
--- /dev/null
+++ b/apps/ext_advertiser/syscfg.yml
@@ -0,0 +1,45 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+syscfg.vals:
+    # Disable not used GAP roles (we only do non-connectable
+    # advertising here)
+    BLE_ROLE_BROADCASTER: 1
+    BLE_ROLE_CENTRAL: 0
+    BLE_ROLE_OBSERVER: 0
+    BLE_ROLE_PERIPHERAL: 0
+
+    # Disable unused eddystone featdure.
+    BLE_EDDYSTONE: 0
+
+    # Enable Extended Advertising
+    BLE_EXT_ADV: 1
+
+    # Max advertising data size
+    BLE_EXT_ADV_MAX_SIZE: 1650
+
+    # Number of multi-advertising instances. Note that due
+    # to historical reasonds total number of advertising
+    # instances is BLE_MULTI_ADV_INSTANCES + 1 as instance
+    # 0 is always available
+    BLE_MULTI_ADV_INSTANCES: 4
+
+    # Controller uses msys pool for storing advertising data and scan responses.
+    # Since we advertise a lot of data (~4k in total) at the same time we need
+    # to increase block count.
+    MSYS_1_BLOCK_COUNT: 24