You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/03/15 01:36:08 UTC

[01/42] incubator-mynewt-core git commit: Reflect repository name change in yml files. Types in packages. Move projects -> apps.

Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/master 3104b4952 -> 3020b32d6


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/project/bletiny/src/periph.c
----------------------------------------------------------------------
diff --git a/project/bletiny/src/periph.c b/project/bletiny/src/periph.c
deleted file mode 100644
index d0f97e5..0000000
--- a/project/bletiny/src/periph.c
+++ /dev/null
@@ -1,344 +0,0 @@
-/**
- * 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 "bsp/bsp.h"
-#include "console/console.h"
-#include "host/ble_hs.h"
-#include "bletiny_priv.h"
-
-#define CHR_F_FULL_ACCESS       (BLE_GATT_CHR_F_READ                |   \
-                                 BLE_GATT_CHR_F_WRITE_NO_RSP        |   \
-                                 BLE_GATT_CHR_F_WRITE               |   \
-                                 BLE_GATT_CHR_F_NOTIFY              |   \
-                                 BLE_GATT_CHR_F_INDICATE)
-
-#define PERIPH_SVC_ALERT_UUID               0x1811
-#define PERIPH_CHR_SUP_NEW_ALERT_CAT_UUID   0x2A47
-#define PERIPH_CHR_NEW_ALERT                0x2A46
-#define PERIPH_CHR_SUP_UNR_ALERT_CAT_UUID   0x2A48
-#define PERIPH_CHR_UNR_ALERT_STAT_UUID      0x2A45
-#define PERIPH_CHR_ALERT_NOT_CTRL_PT        0x2A44
-
-static int
-periph_chr_access_gap(uint16_t conn_handle, uint16_t attr_handle, uint8_t op,
-                      union ble_gatt_access_ctxt *ctxt, void *arg);
-static int
-periph_chr_access_gatt(uint16_t conn_handle, uint16_t attr_handle, uint8_t op,
-                       union ble_gatt_access_ctxt *ctxt, void *arg);
-static int
-periph_chr_access_alert(uint16_t conn_handle, uint16_t attr_handle, uint8_t op,
-                        union ble_gatt_access_ctxt *ctxt, void *arg);
-
-static const struct ble_gatt_svc_def periph_svcs[] = {
-    [0] = {
-        /*** Service: GAP. */
-        .type = BLE_GATT_SVC_TYPE_PRIMARY,
-        .uuid128 = BLE_UUID16(BLE_GAP_SVC_UUID16),
-        .characteristics = (struct ble_gatt_chr_def[]) { {
-            /*** Characteristic: Device Name. */
-            .uuid128 = BLE_UUID16(BLE_GAP_CHR_UUID16_DEVICE_NAME),
-            .access_cb = periph_chr_access_gap,
-            .flags = BLE_GATT_CHR_F_READ,
-        }, {
-            /*** Characteristic: Appearance. */
-            .uuid128 = BLE_UUID16(BLE_GAP_CHR_UUID16_APPEARANCE),
-            .access_cb = periph_chr_access_gap,
-            .flags = BLE_GATT_CHR_F_READ,
-        }, {
-            /*** Characteristic: Peripheral Privacy Flag. */
-            .uuid128 = BLE_UUID16(BLE_GAP_CHR_UUID16_PERIPH_PRIV_FLAG),
-            .access_cb = periph_chr_access_gap,
-            .flags = BLE_GATT_CHR_F_READ,
-        }, {
-            /*** Characteristic: Reconnection Address. */
-            .uuid128 = BLE_UUID16(BLE_GAP_CHR_UUID16_RECONNECT_ADDR),
-            .access_cb = periph_chr_access_gap,
-            .flags = BLE_GATT_CHR_F_WRITE,
-        }, {
-            /*** Characteristic: Peripheral Preferred Connection Parameters. */
-            .uuid128 = BLE_UUID16(BLE_GAP_CHR_UUID16_PERIPH_PREF_CONN_PARAMS),
-            .access_cb = periph_chr_access_gap,
-            .flags = BLE_GATT_CHR_F_READ,
-        }, {
-            0, /* No more characteristics in this service. */
-        } },
-    },
-
-    [1] = {
-        /*** Service: GATT */
-        .type = BLE_GATT_SVC_TYPE_PRIMARY,
-        .uuid128 = BLE_UUID16(BLE_GATT_SVC_UUID16),
-        .characteristics = (struct ble_gatt_chr_def[]) { {
-            .uuid128 = BLE_UUID16(BLE_GATT_CHR_SERVICE_CHANGED_UUID16),
-            .access_cb = periph_chr_access_gatt,
-            .flags = BLE_GATT_CHR_F_INDICATE,
-        }, {
-            0, /* No more characteristics in this service. */
-        } },
-    },
-
-    [2] = {
-        /*** Alert Notification Service. */
-        .type = BLE_GATT_SVC_TYPE_PRIMARY,
-        .uuid128 = BLE_UUID16(PERIPH_SVC_ALERT_UUID),
-        .characteristics = (struct ble_gatt_chr_def[]) { {
-            .uuid128 = BLE_UUID16(PERIPH_CHR_SUP_NEW_ALERT_CAT_UUID),
-            .access_cb = periph_chr_access_alert,
-            .flags = BLE_GATT_CHR_F_READ,
-        }, {
-            .uuid128 = BLE_UUID16(PERIPH_CHR_NEW_ALERT),
-            .access_cb = periph_chr_access_alert,
-            .flags = BLE_GATT_CHR_F_NOTIFY,
-        }, {
-            .uuid128 = BLE_UUID16(PERIPH_CHR_SUP_UNR_ALERT_CAT_UUID),
-            .access_cb = periph_chr_access_alert,
-            .flags = BLE_GATT_CHR_F_READ,
-        }, {
-            .uuid128 = BLE_UUID16(PERIPH_CHR_UNR_ALERT_STAT_UUID),
-            .access_cb = periph_chr_access_alert,
-            .flags = BLE_GATT_CHR_F_NOTIFY,
-        }, {
-            .uuid128 = BLE_UUID16(PERIPH_CHR_ALERT_NOT_CTRL_PT),
-            .access_cb = periph_chr_access_alert,
-            .flags = BLE_GATT_CHR_F_WRITE,
-        }, {
-            0, /* No more characteristics in this service. */
-        } },
-    },
-
-    {
-        0, /* No more services. */
-    },
-};
-
-static int
-periph_chr_write(uint8_t op, union ble_gatt_access_ctxt *ctxt,
-                 uint16_t min_len, uint16_t max_len, void *dst, uint16_t *len)
-{
-    assert(op == BLE_GATT_ACCESS_OP_WRITE_CHR);
-    if (ctxt->chr_access.len < min_len ||
-        ctxt->chr_access.len > max_len) {
-        return BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN;
-    }
-    memcpy(dst, ctxt->chr_access.data, ctxt->chr_access.len);
-    if (len != NULL) {
-        *len = ctxt->chr_access.len;
-    }
-
-    return 0;
-}
-
-static int
-periph_chr_access_gap(uint16_t conn_handle, uint16_t attr_handle, uint8_t op,
-                      union ble_gatt_access_ctxt *ctxt, void *arg)
-{
-    uint16_t uuid16;
-
-    uuid16 = ble_uuid_128_to_16(ctxt->chr_access.chr->uuid128);
-    assert(uuid16 != 0);
-
-    switch (uuid16) {
-    case BLE_GAP_CHR_UUID16_DEVICE_NAME:
-        assert(op == BLE_GATT_ACCESS_OP_READ_CHR);
-        ctxt->chr_access.data = (void *)bletiny_device_name;
-        ctxt->chr_access.len = strlen(bletiny_device_name);
-        break;
-
-    case BLE_GAP_CHR_UUID16_APPEARANCE:
-        assert(op == BLE_GATT_ACCESS_OP_READ_CHR);
-        ctxt->chr_access.data = (void *)&bletiny_appearance;
-        ctxt->chr_access.len = sizeof bletiny_appearance;
-        break;
-
-    case BLE_GAP_CHR_UUID16_PERIPH_PRIV_FLAG:
-        assert(op == BLE_GATT_ACCESS_OP_READ_CHR);
-        ctxt->chr_access.data = (void *)&bletiny_privacy_flag;
-        ctxt->chr_access.len = sizeof bletiny_privacy_flag;
-        break;
-
-    case BLE_GAP_CHR_UUID16_RECONNECT_ADDR:
-        assert(op == BLE_GATT_ACCESS_OP_WRITE_CHR);
-        if (ctxt->chr_access.len != sizeof bletiny_reconnect_addr) {
-            return BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN;
-        }
-        memcpy(bletiny_reconnect_addr, ctxt->chr_access.data,
-               sizeof bletiny_reconnect_addr);
-        break;
-
-    case BLE_GAP_CHR_UUID16_PERIPH_PREF_CONN_PARAMS:
-        assert(op == BLE_GATT_ACCESS_OP_READ_CHR);
-        ctxt->chr_access.data = (void *)&bletiny_pref_conn_params;
-        ctxt->chr_access.len = sizeof bletiny_pref_conn_params;
-        break;
-
-    default:
-        assert(0);
-        break;
-    }
-
-    return 0;
-}
-
-static int
-periph_chr_access_gatt(uint16_t conn_handle, uint16_t attr_handle, uint8_t op,
-                       union ble_gatt_access_ctxt *ctxt, void *arg)
-{
-    uint16_t uuid16;
-
-    uuid16 = ble_uuid_128_to_16(ctxt->chr_access.chr->uuid128);
-    assert(uuid16 != 0);
-
-    switch (uuid16) {
-    case BLE_GATT_CHR_SERVICE_CHANGED_UUID16:
-        if (op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
-            if (ctxt->chr_access.len != sizeof bletiny_gatt_service_changed) {
-                return BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN;
-            }
-            memcpy(bletiny_gatt_service_changed, ctxt->chr_access.data,
-                   sizeof bletiny_gatt_service_changed);
-        } else if (op == BLE_GATT_ACCESS_OP_READ_CHR) {
-            ctxt->chr_access.data = (void *)&bletiny_gatt_service_changed;
-            ctxt->chr_access.len = sizeof bletiny_gatt_service_changed;
-        }
-        break;
-
-    default:
-        assert(0);
-        break;
-    }
-
-    return 0;
-}
-
-#define PERIPH_NEW_ALERT_VAL_MAX_LEN    64
-
-static const uint8_t periph_new_alert_cat = 0x01; /* Simple alert. */
-static uint8_t periph_new_alert_val[PERIPH_NEW_ALERT_VAL_MAX_LEN];
-static uint16_t periph_new_alert_val_len;
-static const uint8_t periph_unr_alert_cat = 0x01; /* Simple alert. */
-static uint16_t periph_unr_alert_stat;
-static uint16_t periph_alert_not_ctrl_pt;
-
-static int
-periph_chr_access_alert(uint16_t conn_handle, uint16_t attr_handle, uint8_t op,
-                        union ble_gatt_access_ctxt *ctxt, void *arg)
-{
-    uint16_t uuid16;
-    int rc;
-
-    uuid16 = ble_uuid_128_to_16(ctxt->chr_access.chr->uuid128);
-    assert(uuid16 != 0);
-
-    switch (uuid16) {
-    case PERIPH_CHR_SUP_NEW_ALERT_CAT_UUID:
-        assert(op == BLE_GATT_ACCESS_OP_READ_CHR);
-        ctxt->chr_access.data = (void *)&periph_new_alert_cat;
-        ctxt->chr_access.len = sizeof periph_new_alert_cat;
-        return 0;
-
-    case PERIPH_CHR_NEW_ALERT:
-        if (op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
-            rc = periph_chr_write(op, ctxt, 0, sizeof periph_new_alert_val,
-                                  periph_new_alert_val,
-                                  &periph_new_alert_val_len);
-            return rc;
-        } else if (op == BLE_GATT_ACCESS_OP_READ_CHR) {
-            ctxt->chr_access.data = (void *)&periph_new_alert_val;
-            ctxt->chr_access.len = sizeof periph_new_alert_val;
-            return 0;
-        }
-
-    case PERIPH_CHR_SUP_UNR_ALERT_CAT_UUID:
-        assert(op == BLE_GATT_ACCESS_OP_READ_CHR);
-        ctxt->chr_access.data = (void *)&periph_unr_alert_cat;
-        ctxt->chr_access.len = sizeof periph_unr_alert_cat;
-        return 0;
-
-    case PERIPH_CHR_UNR_ALERT_STAT_UUID:
-        if (op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
-            rc = periph_chr_write(op, ctxt, 2, 2, &periph_unr_alert_stat, NULL);
-        } else {
-            ctxt->chr_access.data = (void *)&periph_unr_alert_stat;
-            ctxt->chr_access.len = sizeof periph_unr_alert_stat;
-            rc = 0;
-        }
-        return rc;
-
-    case PERIPH_CHR_ALERT_NOT_CTRL_PT:
-        if (op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
-            rc = periph_chr_write(op, ctxt, 2, 2, &periph_alert_not_ctrl_pt,
-                                  NULL);
-        } else {
-            rc = BLE_ATT_ERR_UNLIKELY;
-        }
-        return rc;
-
-    default:
-        assert(0);
-        return BLE_ATT_ERR_UNLIKELY;
-    }
-}
-
-static void
-periph_register_cb(uint8_t op, union ble_gatt_register_ctxt *ctxt, void *arg)
-{
-    uint16_t uuid16;
-
-    switch (op) {
-    case BLE_GATT_REGISTER_OP_SVC:
-        uuid16 = ble_uuid_128_to_16(ctxt->svc_reg.svc->uuid128);
-        assert(uuid16 != 0);
-        BLETINY_LOG(DEBUG, "registered service 0x%04x with handle=%d\n",
-                    uuid16, ctxt->svc_reg.handle);
-        break;
-
-    case BLE_GATT_REGISTER_OP_CHR:
-        uuid16 = ble_uuid_128_to_16(ctxt->chr_reg.chr->uuid128);
-        assert(uuid16 != 0);
-        BLETINY_LOG(DEBUG, "registering characteristic 0x%04x with "
-                           "def_handle=%d val_handle=%d\n",
-                    uuid16, ctxt->chr_reg.def_handle,
-                    ctxt->chr_reg.val_handle);
-        break;
-
-    case BLE_GATT_REGISTER_OP_DSC:
-        uuid16 = ble_uuid_128_to_16(ctxt->dsc_reg.dsc->uuid128);
-        assert(uuid16 != 0);
-        BLETINY_LOG(DEBUG, "registering descriptor 0x%04x with handle=%d "
-                           "chr_handle=%d\n",
-                    uuid16, ctxt->dsc_reg.dsc_handle,
-                    ctxt->dsc_reg.chr_def_handle);
-        break;
-
-    default:
-        assert(0);
-        break;
-    }
-}
-
-void
-periph_init(void)
-{
-    int rc;
-
-    rc = ble_gatts_register_svcs(periph_svcs, periph_register_cb, NULL);
-    assert(rc == 0);
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/project/blinky/pkg.yml
----------------------------------------------------------------------
diff --git a/project/blinky/pkg.yml b/project/blinky/pkg.yml
deleted file mode 100644
index cf5eb0c..0000000
--- a/project/blinky/pkg.yml
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-# 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: project/blinky
-pkg.vers: 0.8.0
-pkg.description: Basic example application which blinks an LED.
-pkg.author: Marko Kiiskila <ma...@runtime.io>
-pkg.homepage: http://mynewt.apache.org/os/get_acclimated/project2/
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
-pkg.keywords:
-
-pkg.deps:
-    - libs/console/full
-    - libs/newtmgr
-    - libs/os
-    - libs/shell
-    - sys/config
-    - sys/log
-    - sys/stats

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/project/blinky/src/main.c
----------------------------------------------------------------------
diff --git a/project/blinky/src/main.c b/project/blinky/src/main.c
deleted file mode 100755
index 5c46883..0000000
--- a/project/blinky/src/main.c
+++ /dev/null
@@ -1,200 +0,0 @@
-/**
- * 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 "os/os.h"
-#include "bsp/bsp.h"
-#include "hal/hal_gpio.h"
-#include "console/console.h"
-#include "shell/shell.h"
-#include "log/log.h"
-#include "stats/stats.h"
-#include "config/config.h"
-#include <assert.h>
-#include <string.h>
-#ifdef ARCH_sim
-#include <mcu/mcu_sim.h>
-#endif
-
-/* Init all tasks */
-volatile int tasks_initialized;
-int init_tasks(void);
-
-/* Task 1 */
-#define TASK1_PRIO (1)
-#define TASK1_STACK_SIZE    OS_STACK_ALIGN(1024)
-struct os_task task1;
-os_stack_t stack1[TASK1_STACK_SIZE];
-static volatile int g_task1_loops;
-
-/* Task 2 */
-#define TASK2_PRIO (2)
-#define TASK2_STACK_SIZE    OS_STACK_ALIGN(1024)
-struct os_task task2;
-os_stack_t stack2[TASK2_STACK_SIZE];
-
-#define SHELL_TASK_PRIO (3)
-#define SHELL_MAX_INPUT_LEN     (256)
-#define SHELL_TASK_STACK_SIZE (OS_STACK_ALIGN(1024))
-os_stack_t shell_stack[SHELL_TASK_STACK_SIZE];
-
-struct log_handler log_console_handler;
-struct log my_log;
-
-static volatile int g_task2_loops;
-
-/* Global test semaphore */
-struct os_sem g_test_sem;
-
-/* For LED toggling */
-int g_led_pin;
-
-#define DEFAULT_MBUF_MPOOL_BUF_LEN (256)
-#define DEFAULT_MBUF_MPOOL_NBUFS (5)
-
-uint8_t default_mbuf_mpool_data[DEFAULT_MBUF_MPOOL_BUF_LEN *
-    DEFAULT_MBUF_MPOOL_NBUFS];
-
-struct os_mbuf_pool default_mbuf_pool;
-struct os_mempool default_mbuf_mpool;
-
-
-void
-task1_handler(void *arg)
-{
-    struct os_task *t;
-
-    /* Set the led pin for the E407 devboard */
-    g_led_pin = LED_BLINK_PIN;
-    hal_gpio_init_out(g_led_pin, 1);
-
-    while (1) {
-        t = os_sched_get_current_task();
-        assert(t->t_func == task1_handler);
-
-        ++g_task1_loops;
-
-        /* Wait one second */
-        os_time_delay(1000);
-
-        /* Toggle the LED */
-        hal_gpio_toggle(g_led_pin);
-
-        /* Release semaphore to task 2 */
-        os_sem_release(&g_test_sem);
-    }
-}
-
-void
-task2_handler(void *arg)
-{
-    struct os_task *t;
-
-    while (1) {
-        /* just for debug; task 2 should be the running task */
-        t = os_sched_get_current_task();
-        assert(t->t_func == task2_handler);
-
-        /* Increment # of times we went through task loop */
-        ++g_task2_loops;
-
-        /* Wait for semaphore from ISR */
-        os_sem_pend(&g_test_sem, OS_TIMEOUT_NEVER);
-    }
-}
-
-/**
- * init_tasks
- *
- * Called by main.c after os_init(). This function performs initializations
- * that are required before tasks are running.
- *
- * @return int 0 success; error otherwise.
- */
-int
-init_tasks(void)
-{
-    /* Initialize global test semaphore */
-    os_sem_init(&g_test_sem, 0);
-
-    os_task_init(&task1, "task1", task1_handler, NULL,
-            TASK1_PRIO, OS_WAIT_FOREVER, stack1, TASK1_STACK_SIZE);
-
-    os_task_init(&task2, "task2", task2_handler, NULL,
-            TASK2_PRIO, OS_WAIT_FOREVER, stack2, TASK2_STACK_SIZE);
-
-    tasks_initialized = 1;
-    return 0;
-}
-
-/**
- * main
- *
- * The main function for the project. This function initializes the os, calls
- * init_tasks to initialize tasks (and possibly other objects), then starts the
- * OS. We should not return from os start.
- *
- * @return int NOTE: this function should never return!
- */
-int
-main(int argc, char **argv)
-{
-    int rc;
-
-#ifdef ARCH_sim
-    mcu_sim_parse_args(argc, argv);
-#endif
-
-    conf_init();
-
-    log_init();
-    log_console_handler_init(&log_console_handler);
-    log_register("log", &my_log, &log_console_handler);
-
-    LOG_DEBUG(&my_log, LOG_MODULE_DEFAULT, "bla");
-    LOG_DEBUG(&my_log, LOG_MODULE_DEFAULT, "bab");
-
-    os_init();
-
-    rc = os_mempool_init(&default_mbuf_mpool, DEFAULT_MBUF_MPOOL_NBUFS,
-            DEFAULT_MBUF_MPOOL_BUF_LEN, default_mbuf_mpool_data,
-            "default_mbuf_data");
-    assert(rc == 0);
-
-    rc = os_mbuf_pool_init(&default_mbuf_pool, &default_mbuf_mpool,
-            DEFAULT_MBUF_MPOOL_BUF_LEN, DEFAULT_MBUF_MPOOL_NBUFS);
-    assert(rc == 0);
-
-    rc = os_msys_register(&default_mbuf_pool);
-    assert(rc == 0);
-
-    shell_task_init(SHELL_TASK_PRIO, shell_stack, SHELL_TASK_STACK_SIZE,
-                    SHELL_MAX_INPUT_LEN);
-
-    (void) console_init(shell_console_rx_cb);
-
-    stats_module_init();
-
-    rc = init_tasks();
-    os_start();
-
-    /* os start should never return. If it does, this should be an error */
-    assert(0);
-
-    return rc;
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/project/boot/pkg.yml
----------------------------------------------------------------------
diff --git a/project/boot/pkg.yml b/project/boot/pkg.yml
deleted file mode 100644
index 0c5d424..0000000
--- a/project/boot/pkg.yml
+++ /dev/null
@@ -1,37 +0,0 @@
-#
-# 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: project/boot
-pkg.vers: 0.8.0
-pkg.description: Boot loader application.
-pkg.author: Christopher Collins <ch...@apache.org>
-pkg.homepage: http://mynewt.apache.org/os/modules/bootloader/bootloader/
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
-pkg.keywords:
-    - loader
-
-pkg.identities: bootloader
-pkg.deps:
-    - fs/nffs
-    - libs/baselibc
-    - libs/bootutil
-    - libs/console/stub
-    - libs/mbedtls
-    - libs/os
-    - libs/util

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/project/boot/src/boot.c
----------------------------------------------------------------------
diff --git a/project/boot/src/boot.c b/project/boot/src/boot.c
deleted file mode 100755
index 1eff268..0000000
--- a/project/boot/src/boot.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/**
- * 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 <stddef.h>
-#include <inttypes.h>
-#include <hal/flash_map.h>
-#include <os/os.h>
-#include <bsp/bsp.h>
-#include <hal/hal_system.h>
-#include <hal/hal_flash.h>
-#include <log/log.h>
-#include "nffs/nffs.h"
-#include "bootutil/image.h"
-#include "bootutil/loader.h"
-
-/* we currently need extra nffs_area_descriptors for booting since the 
- * boot code uses these to keep track of which block to write and copy.*/
-#define BOOT_AREA_DESC_MAX  (256)
-#define AREA_DESC_MAX       (BOOT_AREA_DESC_MAX + NFFS_AREA_MAX)
-
-int
-main(void)
-{
-    struct nffs_area_desc descs[AREA_DESC_MAX];
-    /** Contains indices of the areas which can contain image data. */
-    uint8_t img_areas[AREA_DESC_MAX];
-    /** Areas representing the beginning of image slots. */
-    uint8_t img_starts[2];
-    int cnt;
-    int total;
-    struct boot_rsp rsp;
-    int rc;
-    struct boot_req req = {
-        .br_area_descs = descs,
-        .br_image_areas = img_areas,
-        .br_slot_areas = img_starts,
-    };
-
-    os_init();
-
-    rc = hal_flash_init();
-    assert(rc == 0);    
-    
-    cnt = BOOT_AREA_DESC_MAX;
-    rc = flash_area_to_nffs_desc(FLASH_AREA_IMAGE_0, &cnt, descs);
-    img_starts[0] = 0;
-    total = cnt;
-
-    cnt = BOOT_AREA_DESC_MAX - total;
-    assert(cnt >= 0);
-    rc = flash_area_to_nffs_desc(FLASH_AREA_IMAGE_1, &cnt, &descs[total]);
-    assert(rc == 0);
-    img_starts[1] = total;
-    total += cnt;
-    
-    cnt = BOOT_AREA_DESC_MAX - total;
-    assert(cnt >= 0);
-    rc = flash_area_to_nffs_desc(FLASH_AREA_IMAGE_SCRATCH, &cnt, &descs[total]);
-    assert(rc == 0);
-    req.br_scratch_area_idx = total;
-    total += cnt;
-
-    req.br_num_image_areas = total;
-
-    for (cnt = 0; cnt < total; cnt++) {
-        img_areas[cnt] = cnt;
-    }
-
-    cnt = BOOT_AREA_DESC_MAX - total;
-    
-    /* make sure we have enough left to initialize the NFFS with the 
-     * right number of maximum areas otherwise the file-system will not
-     * be readable */
-    assert(cnt >= NFFS_AREA_MAX);
-    rc = flash_area_to_nffs_desc(FLASH_AREA_NFFS, &cnt, &descs[total]);
-    assert(rc == 0);
-    req.br_nffs_area_idx = total;
-    total += cnt;
-
-    nffs_config.nc_num_inodes = 50;
-    nffs_config.nc_num_blocks = 50;
-    nffs_config.nc_num_cache_blocks = 32;
-
-    log_init();
-    
-    rc = boot_go(&req, &rsp);
-    assert(rc == 0);
-
-    system_start((void *)(rsp.br_image_addr + rsp.br_hdr->ih_hdr_size));
-
-    return 0;
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/project/ffs2native/pkg.yml
----------------------------------------------------------------------
diff --git a/project/ffs2native/pkg.yml b/project/ffs2native/pkg.yml
deleted file mode 100644
index 087ac67..0000000
--- a/project/ffs2native/pkg.yml
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# 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: project/ffs2native
-pkg.vers: 0.8.0
-pkg.description: Support application for debugging the Newtron Flash File System.
-pkg.author: Christopher Collins <cc...@apache.org>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
-pkg.keywords:
-
-pkg.deps:
-    - fs/nffs
-    - hw/hal
-    - libs/console/full
-    - libs/os

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/project/ffs2native/src/main.c
----------------------------------------------------------------------
diff --git a/project/ffs2native/src/main.c b/project/ffs2native/src/main.c
deleted file mode 100644
index 9192f14..0000000
--- a/project/ffs2native/src/main.c
+++ /dev/null
@@ -1,366 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * XXX
- * This is a hack of a tool which prints the structure of an nffs file system.
- * It needs to be rewritten properly.
- */
-
-#include <assert.h>
-#include <stdio.h>
-#include <inttypes.h>
-#include <unistd.h>
-#include <dirent.h>
-#include <strings.h>
-#include "../src/nffs_priv.h"
-#include <os/queue.h>
-#include <fs/fs.h>
-#include <bsp/bsp.h>
-#include <nffs/nffs.h>
-#include <hal/hal_flash.h>
-#include <hal/flash_map.h>
-#ifdef ARCH_sim
-#include <mcu/mcu_sim.h>
-#endif
-
-static const char *copy_in_dir;
-static const char *progname;
-
-#define MAX_AREAS	16
-static struct nffs_area_desc area_descs[MAX_AREAS];
-
-static void usage(int rc);
-
-static void
-copyfs(FILE *fp)
-{
-    uint32_t dst_addr;
-    int rc;
-    int c;
-
-    dst_addr = area_descs[0].nad_offset;
-    while (1) {
-        c = getc(fp);
-        if (c == EOF) {
-            return;
-        }
-
-        rc = hal_flash_write(area_descs[0].nad_flash_id, dst_addr, &c, 1);
-        assert(rc == 0);
-
-        dst_addr++;
-    }
-}
-
-static void
-print_inode_entry(struct nffs_inode_entry *inode_entry, int indent)
-{
-    struct nffs_inode inode;
-    char name[NFFS_FILENAME_MAX_LEN + 1];
-    uint32_t area_offset;
-    uint8_t area_idx;
-    int rc;
-
-    rc = nffs_inode_from_entry(&inode, inode_entry);
-    assert(rc == 0);
-
-    nffs_flash_loc_expand(inode_entry->nie_hash_entry.nhe_flash_loc,
-                         &area_idx, &area_offset);
-
-    rc = nffs_flash_read(area_idx,
-                         area_offset + sizeof (struct nffs_disk_inode),
-                         name, inode.ni_filename_len);
-    assert(rc == 0);
-
-    name[inode.ni_filename_len] = '\0';
-
-    printf("%*s%s\n", indent, "", name[0] == '\0' ? "/" : name);
-}
-
-static void
-process_inode_entry(struct nffs_inode_entry *inode_entry, int indent)
-{
-    struct nffs_inode_entry *child;
-
-    print_inode_entry(inode_entry, indent);
-
-    if (nffs_hash_id_is_dir(inode_entry->nie_hash_entry.nhe_id)) {
-        SLIST_FOREACH(child, &inode_entry->nie_child_list, nie_sibling_next) {
-            process_inode_entry(child, indent + 2);
-        }
-    }
-}
-
-static int
-print_nffs_inode(int idx, uint32_t off)
-{
-    struct nffs_disk_inode ndi;
-    char filename[128];
-    int len;
-    int rc;
-
-    rc = nffs_flash_read(idx, off, &ndi, sizeof(ndi));
-    assert(rc == 0);
-
-    memset(filename, 0, sizeof(filename));
-    len = min(sizeof(filename) - 1, ndi.ndi_filename_len);
-    rc = nffs_flash_read(idx, off + sizeof(ndi), filename, len);
-    printf("      %x-%d inode %d/%d %s\n",
-      off, ndi.ndi_filename_len, ndi.ndi_id, ndi.ndi_seq, filename);
-    return sizeof(ndi) + ndi.ndi_filename_len;
-}
-
-static int
-print_nffs_block(int idx, uint32_t off)
-{
-    struct nffs_disk_block ndb;
-    int rc;
-
-    rc = nffs_flash_read(idx, off, &ndb, sizeof(ndb));
-    assert(rc == 0);
-
-    printf("      %x-%d block %u/%u belongs to %u\n",
-      off, ndb.ndb_data_len, ndb.ndb_id, ndb.ndb_seq, ndb.ndb_inode_id);
-    return sizeof(ndb) + ndb.ndb_data_len;
-}
-
-static int
-print_nffs_object(int idx, uint32_t off)
-{
-    uint32_t magic;
-    int rc;
-
-    rc = nffs_flash_read(idx, off, &magic, sizeof(magic));
-    assert(rc == 0);
-
-    switch (magic) {
-    case NFFS_INODE_MAGIC:
-        return print_nffs_inode(idx, off);
-
-    case NFFS_BLOCK_MAGIC:
-        return print_nffs_block(idx, off);
-        break;
-
-    case 0xffffffff:
-        assert(0);
-        return 0;
-
-    default:
-        printf("      %x Corruption\n", off);
-        return 1;
-    }
-}
-
-static void
-print_nffs_area(int idx)
-{
-    struct nffs_area *area;
-    struct nffs_disk_area darea;
-    int off;
-    int rc;
-
-    area = &nffs_areas[idx];
-    rc = nffs_flash_read(idx, 0, &darea, sizeof(darea));
-    assert(rc == 0);
-    if (!nffs_area_magic_is_set(&darea)) {
-        printf("Area header corrupt!\n");
-        return;
-    }
-    off = sizeof (struct nffs_disk_area);
-    while (off < area->na_cur) {
-        off += print_nffs_object(idx, off);
-    }
-}
-
-static void
-print_nffs_areas(void)
-{
-    int i;
-    struct nffs_area *area;
-
-    for (i = 0; i < nffs_num_areas; i++) {
-        if (nffs_scratch_area_idx == i) {
-            printf(" sc ");
-        } else {
-            printf("    ");
-        }
-
-        area = &nffs_areas[i];
-        printf("%d: cur:%d id:%d 0x%x-0x%x\n",
-          i, area->na_cur, area->na_id,
-          area->na_offset, area->na_offset + area->na_length);
-        print_nffs_area(i);
-    }
-}
-
-static void
-printfs(void)
-{
-    printf("\n\nNFFS contents:\n");
-    process_inode_entry(nffs_root_dir, 0);
-    printf("\nNFFS areas:\n");
-    print_nffs_areas();
-}
-
-static int
-copy_in_file(char *src, char *dst)
-{
-    struct fs_file *nf;
-    FILE *fp;
-    int rc;
-    char data[2048];
-    int ret = 0;
-
-    rc = fs_open(dst, FS_ACCESS_WRITE, &nf);
-    assert(rc == 0);
-
-    fp = fopen(src, "r");
-    if (!fp) {
-        perror("fopen()");
-        assert(0);
-    }
-    while ((rc = fread(data, 1, sizeof(data), fp))) {
-        rc = fs_write(nf, data, rc);
-        if (rc) {
-            ret = rc;
-            break;
-        }
-    }
-    rc = fs_close(nf);
-    assert(rc == 0);
-    fclose(fp);
-    return ret;
-}
-
-void
-copy_in_directory(const char *src, const char *dst)
-{
-    DIR *dr;
-    struct dirent *entry;
-    char src_name[1024];
-    char dst_name[1024];
-    int rc;
-
-    dr = opendir(src);
-    if (!dr) {
-        perror("opendir");
-        usage(1);
-    }
-    while ((entry = readdir(dr))) {
-        snprintf(src_name, sizeof(src_name), "%s/%s", src, entry->d_name);
-        snprintf(dst_name, sizeof(dst_name), "%s/%s", dst, entry->d_name);
-        if (entry->d_type == DT_DIR &&
-          strcmp(entry->d_name, ".") && strcmp(entry->d_name, "..")) {
-            rc = fs_mkdir(dst_name);
-            copy_in_directory(src_name, dst_name);
-            assert(rc == 0);
-        } else if (entry->d_type == DT_REG) {
-            printf("Copying %s\n", dst_name);
-            rc = copy_in_file(src_name, dst_name);
-            if (rc) {
-                printf("  error code %d ", rc);
-                switch (rc) {
-                case FS_ENOMEM:
-                    printf("out of memory\n");
-                    break;
-                case FS_EFULL:
-                    printf("disk is full\n");
-                    break;
-                default:
-                    printf("\n");
-                }
-                break;
-            }
-        } else {
-            printf("Skipping %s\n", src_name);
-        }
-    }
-    closedir(dr);
-}
-
-static void
-usage(int rc)
-{
-    printf("%s [-c]|[-d dir][-f flash_file]\n", progname);
-    printf("  Tool for operating on simulator flash image file\n");
-    printf("   -c: ...\n");
-    printf("   -d: use dir as root for NFFS portion and create flash image\n");
-    printf("   -f: flash_file is the name of the flash image file\n");
-    exit(rc);
-}
-
-int
-main(int argc, char **argv)
-{
-    FILE *fp;
-    int rc;
-    int ch;
-    int cnt;
-
-    progname = argv[0];
-
-    while ((ch = getopt(argc, argv, "c:d:f:")) != -1) {
-        switch (ch) {
-        case 'c':
-            fp = fopen(optarg, "rb");
-            assert(fp != NULL);
-            copyfs(fp);
-            fclose(fp);
-            break;
-        case 'd':
-            copy_in_dir = optarg;
-            break;
-        case 'f':
-            native_flash_file = optarg;
-            break;
-        case '?':
-        default:
-            usage(0);
-        }
-    }
-
-    os_init();
-    rc = flash_area_to_nffs_desc(FLASH_AREA_NFFS, &cnt, area_descs);
-    assert(rc == 0);
-
-    rc = hal_flash_init();
-    assert(rc == 0);
-
-    rc = nffs_init();
-    assert(rc == 0);
-
-    if (copy_in_dir) {
-        /*
-         * Build filesystem from contents of directory
-         */
-        rc = nffs_format(area_descs);
-        assert(rc == 0);
-        copy_in_directory(copy_in_dir, "");
-    } else {
-        rc = nffs_detect(area_descs);
-        if (rc) {
-            printf("nffs_detect() failed\n");
-            exit(0);
-        }
-    }
-    printfs();
-
-    return 0;
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/project/luatest/pkg.yml
----------------------------------------------------------------------
diff --git a/project/luatest/pkg.yml b/project/luatest/pkg.yml
deleted file mode 100644
index b1e8158..0000000
--- a/project/luatest/pkg.yml
+++ /dev/null
@@ -1,32 +0,0 @@
-# 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: luatest
-pkg.vers: 0.8.0
-pkg.description: Simple project for testing Lua scripting.
-pkg.author: Marko Kiiskila <ma...@runtime.io>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
-pkg.keywords:
-
-pkg.deps:
-     - fs/nffs
-     - libs/os
-     - libs/elua/elua_base
-     - libs/console/full
-     - libs/shell
-

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/project/luatest/src/main.c
----------------------------------------------------------------------
diff --git a/project/luatest/src/main.c b/project/luatest/src/main.c
deleted file mode 100755
index 76dd13f..0000000
--- a/project/luatest/src/main.c
+++ /dev/null
@@ -1,115 +0,0 @@
-/**
- * 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 <os/os.h>
-#include <bsp/bsp.h>
-#include <hal/hal_flash.h>
-#include <console/console.h>
-#include <shell/shell.h>
-#include <elua_base/elua.h>
-#include <fs/fs.h>
-#include <nffs/nffs.h>
-#include <hal/flash_map.h>
-#ifdef ARCH_sim
-#include <mcu/mcu_sim.h>
-#endif
-
-/* Init all tasks */
-int init_tasks(void);
-
-/* Shell */
-#define SHELL_TASK_PRIO      (8)
-#define SHELL_MAX_INPUT_LEN     (256)
-#define SHELL_TASK_STACK_SIZE (OS_STACK_ALIGN(2048))
-static os_stack_t shell_stack[SHELL_TASK_STACK_SIZE];
-
-static void
-create_script_file(void)
-{
-    char filename[] = "/foobar";
-    char script[] = "print \"eat my shorts\"\n";
-    struct fs_file *nf;
-    int rc;
-
-    rc = fs_open(filename, FS_ACCESS_READ, &nf);
-    if (rc) {
-        rc = fs_open(filename, FS_ACCESS_WRITE, &nf);
-        assert(rc == 0);
-        rc = fs_write(nf, script, strlen(script));
-        assert(rc == 0);
-    }
-    fs_close(nf);
-}
-
-/**
- * main
- *
- * The main function for the project. This function initializes the os, calls
- * init_tasks to initialize tasks (and possibly other objects), then starts the
- * OS. We should not return from os start.
- *
- * @return int NOTE: this function should never return!
- */
-int
-main(int argc, char **argv)
-{
-    int rc;
-    struct nffs_area_desc descs[NFFS_AREA_MAX];
-    int cnt;
-
-#ifdef ARCH_sim
-    mcu_sim_parse_args(argc, argv);
-#endif
-
-    rc = hal_flash_init();
-    assert(rc == 0);
-
-    /* Initialize OS */
-    os_init();
-
-    /* Init tasks */
-    shell_task_init(SHELL_TASK_PRIO, shell_stack, SHELL_TASK_STACK_SIZE,
-                         SHELL_MAX_INPUT_LEN);
-    console_init(shell_console_rx_cb);
-
-    nffs_init();
-
-    cnt = NFFS_AREA_MAX;
-    rc = flash_area_to_nffs_desc(FLASH_AREA_NFFS, &cnt, descs);
-    assert(rc == 0);
-
-    if (nffs_detect(descs) == FS_ECORRUPT) {
-        rc = nffs_format(descs);
-        assert(rc == 0);
-    }
-
-    lua_init();
-    create_script_file();
-
-    /* Start the OS */
-    os_start();
-
-    /* os start should never return. If it does, this should be an error */
-    assert(0);
-
-    return rc;
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/project/slinky/pkg.yml
----------------------------------------------------------------------
diff --git a/project/slinky/pkg.yml b/project/slinky/pkg.yml
deleted file mode 100644
index 63d48c3..0000000
--- a/project/slinky/pkg.yml
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-# 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: project/slinky
-pkg.vers: 0.8.0
-pkg.description: Example application which uses a variety of mynewt features.
-pkg.author: Marko Kiiskila <ma...@runtime.io>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
-pkg.keywords:
-
-pkg.deps:
-    - fs/nffs
-    - libs/baselibc
-    - libs/console/full
-    - libs/flash_test    
-    - libs/imgmgr
-    - libs/newtmgr
-    - libs/os
-    - libs/shell
-    - libs/util
-    - sys/config
-    - sys/log
-    - sys/stats

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/project/slinky/src/main.c
----------------------------------------------------------------------
diff --git a/project/slinky/src/main.c b/project/slinky/src/main.c
deleted file mode 100755
index edaad80..0000000
--- a/project/slinky/src/main.c
+++ /dev/null
@@ -1,296 +0,0 @@
-/**
- * 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 <os/os.h>
-#include <bsp/bsp.h>
-#include <hal/hal_gpio.h>
-#include <hal/hal_flash.h>
-#include <console/console.h>
-#include <shell/shell.h>
-#include <log/log.h>
-#include <stats/stats.h>
-#include <config/config.h>
-#include <hal/flash_map.h>
-#include <fs/fs.h>
-#include <nffs/nffs.h>
-#include <newtmgr/newtmgr.h>
-#include <imgmgr/imgmgr.h>
-#include <assert.h>
-#include <string.h>
-#include <json/json.h>
-#include <flash_test/flash_test.h>
-
-#ifdef ARCH_sim
-#include <mcu/mcu_sim.h>
-#endif
-
-/* Init all tasks */
-volatile int tasks_initialized;
-int init_tasks(void);
-
-/* Task 1 */
-#define TASK1_PRIO (1)
-#define TASK1_STACK_SIZE    OS_STACK_ALIGN(128)
-struct os_task task1;
-os_stack_t stack1[TASK1_STACK_SIZE];
-static volatile int g_task1_loops;
-
-/* Task 2 */
-#define TASK2_PRIO (2)
-#define TASK2_STACK_SIZE    OS_STACK_ALIGN(128)
-struct os_task task2;
-os_stack_t stack2[TASK2_STACK_SIZE];
-
-#define SHELL_TASK_PRIO (3)
-#define SHELL_MAX_INPUT_LEN     (256)
-#define SHELL_TASK_STACK_SIZE (OS_STACK_ALIGN(384))
-os_stack_t shell_stack[SHELL_TASK_STACK_SIZE];
-
-#define NEWTMGR_TASK_PRIO (4)
-#define NEWTMGR_TASK_STACK_SIZE (OS_STACK_ALIGN(512))
-os_stack_t newtmgr_stack[NEWTMGR_TASK_STACK_SIZE];
-
-struct log_handler log_console_handler;
-struct log my_log;
-
-static volatile int g_task2_loops;
-
-/* Global test semaphore */
-struct os_sem g_test_sem;
-
-/* For LED toggling */
-int g_led_pin;
-
-#define DEFAULT_MBUF_MPOOL_BUF_LEN (256)
-#define DEFAULT_MBUF_MPOOL_NBUFS (10)
-
-uint8_t default_mbuf_mpool_data[DEFAULT_MBUF_MPOOL_BUF_LEN *
-    DEFAULT_MBUF_MPOOL_NBUFS];
-
-struct os_mbuf_pool default_mbuf_pool;
-struct os_mempool default_mbuf_mpool;
-
-static char *test_conf_get(int argc, char **argv, char *val, int max_len);
-static int test_conf_set(int argc, char **argv, char *val);
-static int test_conf_commit(void);
-
-static struct conf_handler test_conf_handler = {
-    .ch_name = "test",
-    .ch_get = test_conf_get,
-    .ch_set = test_conf_set,
-    .ch_commit = test_conf_commit
-};
-
-static uint8_t test8;
-static uint8_t test8_shadow;
-static char test_str[32];
-
-static char *
-test_conf_get(int argc, char **argv, char *buf, int max_len)
-{
-    if (argc == 1) {
-        if (!strcmp(argv[0], "8")) {
-            return conf_str_from_value(CONF_INT8, &test8, buf, max_len);
-        } else if (!strcmp(argv[0], "str")) {
-            return test_str;
-        }
-    }
-    return NULL;
-}
-
-static int
-test_conf_set(int argc, char **argv, char *val)
-{
-    if (argc == 1) {
-        if (!strcmp(argv[0], "8")) {
-            return CONF_VALUE_SET(val, CONF_INT8, test8_shadow);
-        } else if (!strcmp(argv[0], "str")) {
-            return CONF_VALUE_SET(val, CONF_STRING, test_str);
-        }
-    }
-    return OS_ENOENT;
-}
-
-static int
-test_conf_commit(void)
-{
-    test8 = test8_shadow;
-
-    return 0;
-}
-
-void
-task1_handler(void *arg)
-{
-    struct os_task *t;
-
-    /* Set the led pin for the E407 devboard */
-    g_led_pin = LED_BLINK_PIN;
-    hal_gpio_init_out(g_led_pin, 1);
-
-    while (1) {
-        t = os_sched_get_current_task();
-        assert(t->t_func == task1_handler);
-
-        ++g_task1_loops;
-
-        /* Wait one second */
-        os_time_delay(1000);
-
-        /* Toggle the LED */
-        hal_gpio_toggle(g_led_pin);
-
-        /* Release semaphore to task 2 */
-        os_sem_release(&g_test_sem);
-    }
-}
-
-void
-task2_handler(void *arg)
-{
-    struct os_task *t;
-
-    while (1) {
-        /* just for debug; task 2 should be the running task */
-        t = os_sched_get_current_task();
-        assert(t->t_func == task2_handler);
-
-        /* Increment # of times we went through task loop */
-        ++g_task2_loops;
-
-        /* Wait for semaphore from ISR */
-        os_sem_pend(&g_test_sem, OS_TIMEOUT_NEVER);
-    }
-}
-
-/**
- * init_tasks
- *
- * Called by main.c after os_init(). This function performs initializations
- * that are required before tasks are running.
- *
- * @return int 0 success; error otherwise.
- */
-int
-init_tasks(void)
-{
-    /* Initialize global test semaphore */
-    os_sem_init(&g_test_sem, 0);
-
-    os_task_init(&task1, "task1", task1_handler, NULL,
-            TASK1_PRIO, OS_WAIT_FOREVER, stack1, TASK1_STACK_SIZE);
-
-    os_task_init(&task2, "task2", task2_handler, NULL,
-            TASK2_PRIO, OS_WAIT_FOREVER, stack2, TASK2_STACK_SIZE);
-
-    tasks_initialized = 1;
-    return 0;
-}
-
-
-/**
- * main
- *
- * The main function for the project. This function initializes the os, calls
- * init_tasks to initialize tasks (and possibly other objects), then starts the
- * OS. We should not return from os start.
- *
- * @return int NOTE: this function should never return!
- */
-int
-main(int argc, char **argv)
-{
-    int rc;
-    int cnt;
-
-    /* NFFS_AREA_MAX is defined in the BSP-specified bsp.h header file. */
-    struct nffs_area_desc descs[NFFS_AREA_MAX];
-
-#ifdef ARCH_sim
-    mcu_sim_parse_args(argc, argv);
-#endif
-
-    conf_init();
-    rc = conf_register(&test_conf_handler);
-    assert(rc == 0);
-
-
-    log_init();
-
-    log_console_handler_init(&log_console_handler);
-    log_register("log", &my_log, &log_console_handler);
-
-    LOG_DEBUG(&my_log, LOG_MODULE_DEFAULT, "bla");
-    LOG_DEBUG(&my_log, LOG_MODULE_DEFAULT, "bab");
-
-    os_init();
-
-    rc = os_mempool_init(&default_mbuf_mpool, DEFAULT_MBUF_MPOOL_NBUFS, 
-            DEFAULT_MBUF_MPOOL_BUF_LEN, default_mbuf_mpool_data, 
-            "default_mbuf_data");
-    assert(rc == 0);
-
-    rc = os_mbuf_pool_init(&default_mbuf_pool, &default_mbuf_mpool, 
-            DEFAULT_MBUF_MPOOL_BUF_LEN, DEFAULT_MBUF_MPOOL_NBUFS);
-    assert(rc == 0);
-
-    rc = os_msys_register(&default_mbuf_pool);
-    assert(rc == 0);
-
-    rc = hal_flash_init();
-    assert(rc == 0);
-
-    /* Initialize nffs's internal state. */
-    rc = nffs_init();
-    assert(rc == 0);
-
-    /* Convert the set of flash blocks we intend to use for nffs into an array
-     * of nffs area descriptors.
-     */
-    cnt = NFFS_AREA_MAX;
-    rc = flash_area_to_nffs_desc(FLASH_AREA_NFFS, &cnt, descs);
-    assert(rc == 0);
-
-    /* Attempt to restore an existing nffs file system from flash. */
-    if (nffs_detect(descs) == FS_ECORRUPT) {
-        /* No valid nffs instance detected; format a new one. */
-        rc = nffs_format(descs);
-        assert(rc == 0);
-    }
-
-    shell_task_init(SHELL_TASK_PRIO, shell_stack, SHELL_TASK_STACK_SIZE,
-                    SHELL_MAX_INPUT_LEN);
-
-    (void) console_init(shell_console_rx_cb);
-
-    nmgr_task_init(NEWTMGR_TASK_PRIO, newtmgr_stack, NEWTMGR_TASK_STACK_SIZE);
-    imgmgr_module_init();
-
-    stats_module_init();
-
-    flash_test_init();
-    
-    rc = init_tasks();
-    os_start();
-
-    /* os start should never return. If it does, this should be an error */
-    assert(0);
-
-    return rc;
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/project/test/pkg.yml
----------------------------------------------------------------------
diff --git a/project/test/pkg.yml b/project/test/pkg.yml
deleted file mode 100644
index 1c48c94..0000000
--- a/project/test/pkg.yml
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-# 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: project/test
-pkg.vers: 0.8.0
-pkg.description: Automated test suite for mynewt core functionality.
-pkg.author: Christopher Collins <cc...@apache.org>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
-pkg.keywords:
-
-pkg.deps:
-    - fs/nffs
-    - libs/bootutil
-    - libs/console/full
-    - libs/mbedtls
-    - libs/os
-    - libs/testreport
-    - libs/testutil
-    - libs/util
-    - sys/config
-
-pkg.identities:
-    - test

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/project/test/src/test.c
----------------------------------------------------------------------
diff --git a/project/test/src/test.c b/project/test/src/test.c
deleted file mode 100644
index 57c6418..0000000
--- a/project/test/src/test.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * 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 <stddef.h>
-#include "os/os_test.h"
-#include "nffs/nffs_test.h"
-#include "bootutil/bootutil_test.h"
-#include "testutil/testutil.h"
-#include "mbedtls/mbedtls_test.h"
-#include "config/config_test.h"
-
-extern int util_test_all(void);
-
-int
-main(void)
-{
-    tu_config.tc_print_results = 1;
-    tu_init();
-
-    os_test_all();
-    nffs_test_all();
-    boot_test_all();
-    util_test_all();
-    mbedtls_test_all();
-    config_test_all();
-
-    return 0;
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/sys/config/pkg.yml
----------------------------------------------------------------------
diff --git a/sys/config/pkg.yml b/sys/config/pkg.yml
index a58d1f1..ff8d87c 100644
--- a/sys/config/pkg.yml
+++ b/sys/config/pkg.yml
@@ -22,7 +22,7 @@ pkg.vers: 0.8.0
 pkg.description: Configuration management for embedded systems.
 pkg.author: Marko Kiiskila <ma...@apache.org>
 pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
 pkg.keywords:
 
 pkg.deps:
@@ -30,7 +30,7 @@ pkg.deps:
     - libs/testutil
 pkg.deps.SHELL:
     - libs/shell
-pkg.req_caps.SHELL:
+pkg.req_apis.SHELL:
     - console
 pkg.cflags.SHELL: -DSHELL_PRESENT
 pkg.deps.NEWTMGR:

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/sys/log/pkg.yml
----------------------------------------------------------------------
diff --git a/sys/log/pkg.yml b/sys/log/pkg.yml
index 905287e..f7a44e9 100644
--- a/sys/log/pkg.yml
+++ b/sys/log/pkg.yml
@@ -22,7 +22,7 @@ pkg.vers: 0.8.0
 pkg.description: Logging utilities for embedded systems.
 pkg.author: Sterling Hughes <st...@apache.org>
 pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
 pkg.keywords:
     - logging
 
@@ -34,7 +34,7 @@ pkg.deps.SHELL:
     - libs/shell
 pkg.deps.NEWTMGR:
     - libs/newtmgr
-pkg.req_caps.SHELL:
+pkg.req_apis.SHELL:
     - console
 pkg.cflags.SHELL: -DSHELL_PRESENT
 pkg.cflags.NEWTMGR: -DNEWTMGR_PRESENT

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/sys/stats/pkg.yml
----------------------------------------------------------------------
diff --git a/sys/stats/pkg.yml b/sys/stats/pkg.yml
index 541933e..9a6276d 100644
--- a/sys/stats/pkg.yml
+++ b/sys/stats/pkg.yml
@@ -22,7 +22,7 @@ pkg.vers: 0.8.0
 pkg.description: Statistic tracking utilities for embedded systems.
 pkg.author: Sterling Hughes <st...@apache.org>
 pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
 pkg.keywords:
     - statistics
 
@@ -34,7 +34,7 @@ pkg.deps.SHELL:
     - libs/shell
 pkg.deps.NEWTMGR:
     - libs/newtmgr
-pkg.req_caps.SHELL:
+pkg.req_apis.SHELL:
     - console
 pkg.cflags.SHELL: -DSHELL_PRESENT
 pkg.cflags.NEWTMGR: -DNEWTMGR_PRESENT 


[18/42] incubator-mynewt-core git commit: Remove pkg.feature TEST.

Posted by cc...@apache.org.
Remove pkg.feature TEST.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/ffb1317e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/ffb1317e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/ffb1317e

Branch: refs/heads/master
Commit: ffb1317e7e476a0c83347d6ece2e39c76835cdab
Parents: 6d634b4
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Mar 10 14:14:37 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Mar 10 14:14:37 2016 -0800

----------------------------------------------------------------------
 libs/flash_test/pkg.yml | 2 --
 1 file changed, 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ffb1317e/libs/flash_test/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/flash_test/pkg.yml b/libs/flash_test/pkg.yml
index 569f72f..1903f2c 100644
--- a/libs/flash_test/pkg.yml
+++ b/libs/flash_test/pkg.yml
@@ -31,5 +31,3 @@ pkg.deps:
     - libs/baselibc
 pkg.req_apis:
     - console
-pkg.features:
-    - TEST


[24/42] incubator-mynewt-core git commit: Revert changes to the stack sizes since they will have a detrimental effect on low memory embedded platforms.

Posted by cc...@apache.org.
Revert changes to the stack sizes since they will have a detrimental effect
on low memory embedded platforms.

Scale up the stack size in sim-specific OS_STACK_ALIGN() to ensure that there
is sufficient space on sim targets.

Fix uart_poller so it computes the stack size via the OS_STACK_ALIGN() macro.

Requested by: mkiiskila@github


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/2d2a07ad
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/2d2a07ad
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/2d2a07ad

Branch: refs/heads/master
Commit: 2d2a07ad88de8dc8f5bba4bc78a7ade0f07e41d0
Parents: adbc585
Author: Neel Natu <ne...@nahannisys.com>
Authored: Fri Mar 11 11:24:50 2016 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Fri Mar 11 12:16:13 2016 -0800

----------------------------------------------------------------------
 apps/slinky/src/main.c                   |  8 ++++----
 hw/mcu/native/src/hal_uart.c             |  2 +-
 libs/os/include/os/arch/sim/os/os_arch.h | 14 +++++++++++++-
 3 files changed, 18 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2d2a07ad/apps/slinky/src/main.c
----------------------------------------------------------------------
diff --git a/apps/slinky/src/main.c b/apps/slinky/src/main.c
index 4534097..edaad80 100755
--- a/apps/slinky/src/main.c
+++ b/apps/slinky/src/main.c
@@ -45,24 +45,24 @@ int init_tasks(void);
 
 /* Task 1 */
 #define TASK1_PRIO (1)
-#define TASK1_STACK_SIZE    OS_STACK_ALIGN(1024)
+#define TASK1_STACK_SIZE    OS_STACK_ALIGN(128)
 struct os_task task1;
 os_stack_t stack1[TASK1_STACK_SIZE];
 static volatile int g_task1_loops;
 
 /* Task 2 */
 #define TASK2_PRIO (2)
-#define TASK2_STACK_SIZE    OS_STACK_ALIGN(1024)
+#define TASK2_STACK_SIZE    OS_STACK_ALIGN(128)
 struct os_task task2;
 os_stack_t stack2[TASK2_STACK_SIZE];
 
 #define SHELL_TASK_PRIO (3)
 #define SHELL_MAX_INPUT_LEN     (256)
-#define SHELL_TASK_STACK_SIZE (OS_STACK_ALIGN(1024))
+#define SHELL_TASK_STACK_SIZE (OS_STACK_ALIGN(384))
 os_stack_t shell_stack[SHELL_TASK_STACK_SIZE];
 
 #define NEWTMGR_TASK_PRIO (4)
-#define NEWTMGR_TASK_STACK_SIZE (OS_STACK_ALIGN(1024))
+#define NEWTMGR_TASK_STACK_SIZE (OS_STACK_ALIGN(512))
 os_stack_t newtmgr_stack[NEWTMGR_TASK_STACK_SIZE];
 
 struct log_handler log_console_handler;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2d2a07ad/hw/mcu/native/src/hal_uart.c
----------------------------------------------------------------------
diff --git a/hw/mcu/native/src/hal_uart.c b/hw/mcu/native/src/hal_uart.c
index e2bfc6d..dae24c7 100644
--- a/hw/mcu/native/src/hal_uart.c
+++ b/hw/mcu/native/src/hal_uart.c
@@ -35,7 +35,7 @@
 #include <string.h>
 
 #define UART_MAX_BYTES_PER_POLL	64
-#define UART_POLLER_STACK_SZ	(1024)
+#define UART_POLLER_STACK_SZ	OS_STACK_ALIGN(1024)
 #define UART_POLLER_PRIO	0
 
 struct uart {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2d2a07ad/libs/os/include/os/arch/sim/os/os_arch.h
----------------------------------------------------------------------
diff --git a/libs/os/include/os/arch/sim/os/os_arch.h b/libs/os/include/os/arch/sim/os/os_arch.h
index cfe737f..59096f8 100644
--- a/libs/os/include/os/arch/sim/os/os_arch.h
+++ b/libs/os/include/os/arch/sim/os/os_arch.h
@@ -40,8 +40,20 @@ typedef unsigned int os_stack_t;
 #define OS_SANITY_STACK_SIZE (1024)
 #define OS_IDLE_STACK_SIZE (1024)
 
+/*
+ * The 'sim' architecture-specific code does not have as much control on
+ * stack usage as the real embedded architectures.
+ *
+ * For e.g. the space occupied by the signal handler frame on the task
+ * stack is entirely dependent on the host OS.
+ *
+ * Deal with this by scaling the stack size by a factor of 16. The scaling
+ * factor can be arbitrarily large because the stacks are allocated from
+ * BSS and thus don't add to either the executable size or resident
+ * memory.
+ */
 #define OS_STACK_ALIGN(__nmemb) \
-    (OS_ALIGN((__nmemb), OS_STACK_ALIGNMENT))
+    (OS_ALIGN(((__nmemb) * 16), OS_STACK_ALIGNMENT))
 
 /* Enter a critical section, save processor state, and block interrupts */
 #define OS_ENTER_CRITICAL(__os_sr) (__os_sr = os_arch_save_sr())


[32/42] incubator-mynewt-core git commit: Delete unittest target from core; it is in blinky.

Posted by cc...@apache.org.
Delete unittest target from core; it is in blinky.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/9eb699db
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/9eb699db
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/9eb699db

Branch: refs/heads/master
Commit: 9eb699db967d250f09a23928b123fdd86788ed9c
Parents: 473f5a8
Author: Christopher Collins <cc...@apache.org>
Authored: Fri Mar 11 15:20:34 2016 -0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Fri Mar 11 15:20:34 2016 -0800

----------------------------------------------------------------------
 targets/unittest/pkg.yml    | 7 -------
 targets/unittest/target.yml | 3 ---
 2 files changed, 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9eb699db/targets/unittest/pkg.yml
----------------------------------------------------------------------
diff --git a/targets/unittest/pkg.yml b/targets/unittest/pkg.yml
deleted file mode 100644
index 806f690..0000000
--- a/targets/unittest/pkg.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-### Package: targets/unittest
-pkg.name: "targets/unittest"
-pkg.type: "target"
-pkg.description: "Used for unit tests by the \"newt test\" command."
-pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
-pkg.homepage: "http://mynewt.apache.org/"
-pkg.repository: "local"

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9eb699db/targets/unittest/target.yml
----------------------------------------------------------------------
diff --git a/targets/unittest/target.yml b/targets/unittest/target.yml
deleted file mode 100644
index fd88167..0000000
--- a/targets/unittest/target.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-### Target: targets/unittest
-target.bsp: "hw/bsp/native"
-target.build_profile: "debug"


[40/42] incubator-mynewt-core git commit: MYNEWT-96: Moved LL configuration items out of controller code into nimble_opt.h. This also caused the LL init API to change which is why the main C modules were modified in some of the apps

Posted by cc...@apache.org.
MYNEWT-96: Moved LL configuration items out of controller code into nimble_opt.h. This also caused the LL init API to change which is why the main C modules were modified in some of the apps


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/27a3fd47
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/27a3fd47
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/27a3fd47

Branch: refs/heads/master
Commit: 27a3fd47f30bb45d042ca734f1d875fa8b827cfa
Parents: fc3116a
Author: wes3 <wi...@micosa.io>
Authored: Mon Mar 14 16:31:45 2016 -0700
Committer: wes3 <wi...@micosa.io>
Committed: Mon Mar 14 16:32:03 2016 -0700

----------------------------------------------------------------------
 apps/bleprph/src/main.c                         |  2 +-
 apps/bletest/src/main.c                         | 32 ++++---
 apps/bletiny/src/main.c                         |  3 +-
 .../controller/include/controller/ble_ll.h      | 29 +++----
 .../controller/include/controller/ble_ll_hci.h  | 11 ---
 .../controller/include/controller/ble_ll_scan.h | 18 ----
 .../include/controller/ble_ll_whitelist.h       |  2 -
 net/nimble/controller/src/ble_ll.c              |  6 +-
 net/nimble/controller/src/ble_ll_conn.c         | 48 +++++------
 net/nimble/controller/src/ble_ll_conn_hci.c     | 10 +--
 net/nimble/controller/src/ble_ll_ctrl.c         |  3 +-
 net/nimble/controller/src/ble_ll_hci.c          |  7 +-
 net/nimble/controller/src/ble_ll_scan.c         | 19 ++++-
 net/nimble/controller/src/ble_ll_whitelist.c    | 12 +--
 net/nimble/include/nimble/nimble_opt.h          | 89 +++++++++++++++++++-
 15 files changed, 181 insertions(+), 110 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/27a3fd47/apps/bleprph/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bleprph/src/main.c b/apps/bleprph/src/main.c
index a67d4e1..b9e2d6d 100755
--- a/apps/bleprph/src/main.c
+++ b/apps/bleprph/src/main.c
@@ -269,7 +269,7 @@ main(void)
                  bleprph_stack, BLEPRPH_STACK_SIZE);
 
     /* Initialize the BLE LL */
-    rc = ble_ll_init(BLE_LL_TASK_PRI);
+    rc = ble_ll_init(BLE_LL_TASK_PRI, MBUF_NUM_MBUFS, BLE_MBUF_PAYLOAD_SIZE);
     assert(rc == 0);
 
     /* Initialize the BLE host. */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/27a3fd47/apps/bletest/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bletest/src/main.c b/apps/bletest/src/main.c
index aa0578b..fe017d0 100755
--- a/apps/bletest/src/main.c
+++ b/apps/bletest/src/main.c
@@ -111,7 +111,11 @@ os_membuf_t g_mbuf_buffer[MBUF_MEMPOOL_SIZE];
 #define BLETEST_CFG_MAX_CE_LEN          (BLETEST_CFG_CONN_ITVL)
 #define BLETEST_CFG_CONN_PEER_ADDR_TYPE (BLE_HCI_CONN_PEER_ADDR_PUBLIC)
 #define BLETEST_CFG_CONN_OWN_ADDR_TYPE  (BLE_HCI_ADV_OWN_ADDR_PUBLIC)
-#define BLETEST_CFG_CONCURRENT_CONNS    (16)
+#define BLETEST_CFG_CONCURRENT_CONNS    (1)
+
+/* Test configurations. One of these should be set to 1 */
+#define BLETEST_CONCURRENT_CONN_TEST    (1)
+#define BLETEST_THROUGHPUT_TEST         (0)
 
 /* BLETEST variables */
 #undef BLETEST_ADV_PKT_NUM
@@ -511,13 +515,17 @@ static void
 bletest_execute_advertiser(void)
 {
     int i;
+#if (BLETEST_CONCURRENT_CONN_TEST == 1)
     int j;
+#endif
     int rc;
-    //os_sr_t sr;
     uint16_t handle;
     uint16_t pktlen;
-    //uint16_t completed_pkts;
     struct os_mbuf *om;
+#if (BLETEST_THROUGHPUT_TEST == 1)
+    os_sr_t sr;
+    uint16_t completed_pkts;
+#endif
 
     /* See if we should start advertising again */
     if (g_bletest_current_conns < BLETEST_CFG_CONCURRENT_CONNS) {
@@ -526,7 +534,7 @@ bletest_execute_advertiser(void)
             /* Set LED to slower blink rate */
             g_bletest_led_rate = OS_TICKS_PER_SEC;
 
-#if 0
+#if (BLETEST_THROUGHPUT_TEST == 1)
             /* Set next os time to 10 seconds after 1st connection */
             if (g_next_os_time == 0) {
                 g_next_os_time = os_time_get() + (10 * OS_TICKS_PER_SEC);
@@ -577,6 +585,8 @@ bletest_execute_advertiser(void)
         }
     }
 #endif
+
+#if (BLETEST_CONCURRENT_CONN_TEST == 1)
     /* See if it is time to hand a data packet to the connection */
     if ((int32_t)(os_time_get() - g_next_os_time) >= 0) {
         if (g_bletest_current_conns) {
@@ -622,8 +632,9 @@ bletest_execute_advertiser(void)
         }
         g_next_os_time = os_time_get() + OS_TICKS_PER_SEC/4;
     }
+#endif
 
-#if 0 /* XXX: throughput test */
+#if (BLETEST_THROUGHPUT_TEST == 1)
     /* Nothing to do if no connections */
     if (!g_bletest_current_conns) {
         return;
@@ -641,7 +652,7 @@ bletest_execute_advertiser(void)
         assert(g_bletest_outstanding_pkts >= completed_pkts);
         g_bletest_outstanding_pkts -= completed_pkts;
 
-        while (g_bletest_outstanding_pkts < 8) {
+        while (g_bletest_outstanding_pkts < 20) {
             om = bletest_get_packet();
             if (om) {
                 /* set payload length */
@@ -659,8 +670,8 @@ bletest_execute_advertiser(void)
                 om->om_len += 4;
 
                 /* Fill with incrementing pattern (starting from 1) */
-                for (j = 0; j < pktlen; ++j) {
-                    om->om_data[8 + j] = (uint8_t)(j + 1);
+                for (i = 0; i < pktlen; ++i) {
+                    om->om_data[8 + i] = (uint8_t)(i + 1);
                 }
 
                 /* Add length */
@@ -783,9 +794,8 @@ bletest_task_handler(void *arg)
     /* Wait some time before starting */
     os_time_delay(OS_TICKS_PER_SEC);
 
-    /* Init bletest variables */
+    /* Init state */
     g_bletest_state = 0;
-    g_next_os_time = os_time_get();
 
     /* Begin advertising if we are an advertiser */
 #if (BLETEST_CFG_ROLE == BLETEST_ROLE_ADVERTISER)
@@ -833,7 +843,7 @@ init_tasks(void)
     assert(rc == 0);
 
     /* Initialize the BLE LL */
-    rc = ble_ll_init(BLE_LL_TASK_PRI);
+    rc = ble_ll_init(BLE_LL_TASK_PRI, MBUF_NUM_MBUFS, BLE_MBUF_PAYLOAD_SIZE);
     assert(rc == 0);
 
     return 0;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/27a3fd47/apps/bletiny/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bletiny/src/main.c b/apps/bletiny/src/main.c
index 99cfca6..7e92e0e 100755
--- a/apps/bletiny/src/main.c
+++ b/apps/bletiny/src/main.c
@@ -1444,7 +1444,8 @@ main(void)
     assert(rc == 0);
 
     /* Initialize the BLE LL */
-    ble_ll_init(BLE_LL_TASK_PRI);
+    rc = ble_ll_init(BLE_LL_TASK_PRI, MBUF_NUM_MBUFS, BLE_MBUF_PAYLOAD_SIZE);
+    assert(rc == 0);
 
     rc = cmd_init();
     assert(rc == 0);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/27a3fd47/net/nimble/controller/include/controller/ble_ll.h
----------------------------------------------------------------------
diff --git a/net/nimble/controller/include/controller/ble_ll.h b/net/nimble/controller/include/controller/ble_ll.h
index 8c04be5..d520427 100644
--- a/net/nimble/controller/include/controller/ble_ll.h
+++ b/net/nimble/controller/include/controller/ble_ll.h
@@ -25,7 +25,6 @@
 
 /* Controller revision. */
 #define BLE_LL_SUB_VERS_NR      (0x0000)
-#define BLE_LL_MFRG_ID          (0xFFFF)    /* XXX: replace with real one */
 
 /* 
  * The amount of time that we will wait to hear the start of a receive
@@ -54,6 +53,14 @@ struct ble_ll_obj
     /* Supported features */
     uint8_t ll_supp_features;
 
+    /* Number of ACL data packets supported */
+    uint8_t ll_num_acl_pkts;
+    uint8_t _pad;
+
+    /* ACL data packet size */
+    uint16_t ll_acl_pkt_size;
+    uint16_t _pad16;
+
     /* Task event queue */
     struct os_eventq ll_evq;
 
@@ -132,25 +139,14 @@ extern STATS_SECT_DECL(ble_ll_stats) ble_ll_stats;
 #define BLE_LL_FEAT_EXT_SCAN_FILT   (0x80)
 
 /* LL timing */
-#define BLE_LL_IFS              (150)       /* usecs */
-#define BLE_CLOCK_DRIFT_ACTIVE  (50)        /* +/- ppm */
-#define BLE_CLOCK_DRIFT_SLEEP   (500)       /* +/- ppm */
-
-/* 
- * Link Layer processing delay. This number is simply made up for now. We
- * use it to insure that we have enough time to do some processing before
- * the LL needs to do something. I made it one IFS time for now. It is used:
- *  -> When determining how much time we leave before the end of a connection
- *  event.
- */
-#define BLE_LL_PROC_DELAY       (150)
+#define BLE_LL_IFS                  (150)       /* usecs */
 
 /* 
  * BLE LL device address. Note that element 0 of the array is the LSB and
  * is sent over the air first. Byte 5 is the MSB and is the last one sent over
  * the air.
  */
-#define BLE_DEV_ADDR_LEN    (6)     /* bytes */
+#define BLE_DEV_ADDR_LEN            (6)     /* bytes */
 
 struct ble_dev_addr
 {
@@ -227,8 +223,6 @@ struct ble_dev_addr
 #define BLE_ADV_PDU_HDR_TXADD_RAND          (0x40)
 #define BLE_ADV_PDU_HDR_RXADD_RAND          (0x80)
 
-/* Max length */
-#define BLE_LL_MAX_ADV_PYLD                 (37)
 /*
  * Data Channel format
  * 
@@ -287,7 +281,8 @@ struct ble_dev_addr
 
 /*--- External API ---*/
 /* Initialize the Link Layer */
-int ble_ll_init(uint8_t ll_task_prio);
+int
+ble_ll_init(uint8_t ll_task_prio, uint8_t num_acl_pkts, uint16_t acl_pkt_size);
 
 /* Reset the Link Layer */
 int ble_ll_reset(void);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/27a3fd47/net/nimble/controller/include/controller/ble_ll_hci.h
----------------------------------------------------------------------
diff --git a/net/nimble/controller/include/controller/ble_ll_hci.h b/net/nimble/controller/include/controller/ble_ll_hci.h
index 60b2956..3e1558f 100644
--- a/net/nimble/controller/include/controller/ble_ll_hci.h
+++ b/net/nimble/controller/include/controller/ble_ll_hci.h
@@ -20,23 +20,12 @@
 #ifndef H_BLE_LL_HCI_
 #define H_BLE_LL_HCI_
 
-/* Define the number of data packets that the controller can store */
-#define BLE_LL_CFG_NUM_ACL_DATA_PKTS    (4)
-#define BLE_LL_CFG_ACL_DATA_PKT_LEN     (251)
-
 /* 
  * This determines the number of outstanding commands allowed from the
  * host to the controller.
  */
 #define BLE_LL_CFG_NUM_HCI_CMD_PKTS     (1)
 
-/* 
- * Determines the maximum rate at which the controller will send the
- * number of completed packets event to the host. This number is in
- * milliseconds.
- */
-#define BLE_LL_CFG_NUM_COMP_PKT_RATE    (2000)  /* msecs */
-
 /* Initialize LL HCI */
 void ble_ll_hci_init(void);
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/27a3fd47/net/nimble/controller/include/controller/ble_ll_scan.h
----------------------------------------------------------------------
diff --git a/net/nimble/controller/include/controller/ble_ll_scan.h b/net/nimble/controller/include/controller/ble_ll_scan.h
index 5e3632b..6967a1a 100644
--- a/net/nimble/controller/include/controller/ble_ll_scan.h
+++ b/net/nimble/controller/include/controller/ble_ll_scan.h
@@ -23,21 +23,6 @@
 #include "controller/ble_ll_sched.h"
 #include "hal/hal_cputime.h"
 
-/* 
- * Configuration items for the number of duplicate advertisers and the
- * number of advertisers from which we have heard a scan response 
- */
-#define BLE_LL_SCAN_CFG_NUM_DUP_ADVS         (8)
-#define BLE_LL_SCAN_CFG_NUM_SCAN_RSP_ADVS    (8)
-
-/* Dont allow more than 255 of these entries */
-#if BLE_LL_SCAN_CFG_NUM_DUP_ADVS > 255
-    #error "Cannot have more than 255 duplicate entries!"
-#endif
-#if BLE_LL_SCAN_CFG_NUM_SCAN_RSP_ADVS > 255
-    #error "Cannot have more than 255 scan response entries!"
-#endif
-
 /*
  * SCAN_REQ 
  *      -> ScanA    (6 bytes)
@@ -50,7 +35,6 @@
  * state. The advertising address is the intended recipient of this frame.
  */
 #define BLE_SCAN_REQ_LEN                (12)
-#define BLE_SCAN_REQ_TXTIME_USECS       (176)
 
 /*
  * SCAN_RSP
@@ -64,8 +48,6 @@
  * scanning state. 
  */
 #define BLE_SCAN_RSP_DATA_MAX_LEN       (31)
-#define BLE_SCAN_RSP_MIN_LEN            (6)
-#define BLE_SCAN_RSP_MAX_LEN            (6 + BLE_SCAN_RSP_DATA_MAX_LEN)
 
 /* Scanning state machine (used when initiating as well) */
 struct ble_ll_scan_sm

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/27a3fd47/net/nimble/controller/include/controller/ble_ll_whitelist.h
----------------------------------------------------------------------
diff --git a/net/nimble/controller/include/controller/ble_ll_whitelist.h b/net/nimble/controller/include/controller/ble_ll_whitelist.h
index e460ba3..f8f4331 100644
--- a/net/nimble/controller/include/controller/ble_ll_whitelist.h
+++ b/net/nimble/controller/include/controller/ble_ll_whitelist.h
@@ -20,8 +20,6 @@
 #ifndef H_BLE_LL_WHITELIST_
 #define H_BLE_LL_WHITELIST_
 
-#define BLE_LL_CFG_WHITELIST_SIZE   (8)
-
 /* Clear the whitelist */
 int ble_ll_whitelist_clear(void);
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/27a3fd47/net/nimble/controller/src/ble_ll.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll.c b/net/nimble/controller/src/ble_ll.c
index 54bf2d1..36ec6ab 100644
--- a/net/nimble/controller/src/ble_ll.c
+++ b/net/nimble/controller/src/ble_ll.c
@@ -953,7 +953,7 @@ ble_ll_reset(void)
  * @return int 
  */
 int
-ble_ll_init(uint8_t ll_task_prio)
+ble_ll_init(uint8_t ll_task_prio, uint8_t num_acl_pkts, uint16_t acl_pkt_size)
 {
     int rc;
     uint8_t features;
@@ -962,6 +962,10 @@ ble_ll_init(uint8_t ll_task_prio)
     /* Get pointer to global data object */
     lldata = &g_ble_ll_data;
 
+    /* Set acl pkt size and number */
+    lldata->ll_num_acl_pkts = num_acl_pkts;
+    lldata->ll_acl_pkt_size = acl_pkt_size;
+
     /* Initialize eventq */
     os_eventq_init(&lldata->ll_evq);
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/27a3fd47/net/nimble/controller/src/ble_ll_conn.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_conn.c b/net/nimble/controller/src/ble_ll_conn.c
index e3a38d0..79a0450 100644
--- a/net/nimble/controller/src/ble_ll_conn.c
+++ b/net/nimble/controller/src/ble_ll_conn.c
@@ -36,6 +36,10 @@
 #include "hal/hal_cputime.h"
 #include "hal/hal_gpio.h"
 
+#if (BLETEST_THROUGHPUT_TEST == 1)
+extern void bletest_completed_pkt(uint16_t handle);
+#endif
+
 /* XXX TODO
  * 1) I think if we are initiating and we already have a connection with
  * a device that we will still try and connect to it. Fix this.
@@ -109,23 +113,11 @@ extern int ble_hs_rx_data(struct os_mbuf *om);
  */
 #define BLE_LL_WFR_USECS                    (BLE_LL_IFS + 40 + 32)
 
-/* Configuration parameters */
-#define BLE_LL_CFG_CONN_TX_WIN_SIZE         (1)
-#define BLE_LL_CFG_CONN_TX_WIN_OFF          (0)
-#define BLE_LL_CFG_CONN_MASTER_SCA          (BLE_MASTER_SCA_51_75_PPM << 5)
-#define BLE_LL_CFG_CONN_OUR_SCA             (60)    /* in ppm */
-#define BLE_LL_CFG_CONN_INIT_SLOTS          (2)
-
 /* We cannot have more than 254 connections given our current implementation */
 #if (NIMBLE_OPT_MAX_CONNECTIONS >= 255)
     #error "Maximum # of connections is 254"
 #endif
 
-/* LL configuration definitions */
-#define BLE_LL_CFG_SUPP_MAX_RX_BYTES        (251)
-#define BLE_LL_CFG_SUPP_MAX_TX_BYTES        (251)
-#define BLE_LL_CFG_CONN_INIT_MAX_TX_BYTES   (251)
-
 /* Sleep clock accuracy table (in ppm) */
 static const uint16_t g_ble_sca_ppm_tbl[8] =
 {
@@ -359,7 +351,7 @@ ble_ll_conn_calc_window_widening(struct ble_ll_conn_sm *connsm)
     if (time_since_last_anchor > 0) {
         delta_msec = cputime_ticks_to_usecs(time_since_last_anchor) / 1000;
         total_sca_ppm = g_ble_sca_ppm_tbl[connsm->master_sca] + 
-                        BLE_LL_CFG_CONN_OUR_SCA;
+            NIMBLE_OPT_LL_OUR_SCA;
         window_widening = (total_sca_ppm * delta_msec) / 1000;
     }
 
@@ -1021,9 +1013,9 @@ ble_ll_conn_master_init(struct ble_ll_conn_sm *connsm,
     connsm->conn_role = BLE_LL_CONN_ROLE_MASTER;
 
     /* Set default ce parameters */
-    connsm->tx_win_size = BLE_LL_CFG_CONN_TX_WIN_SIZE;
-    connsm->tx_win_off = BLE_LL_CFG_CONN_TX_WIN_OFF;
-    connsm->master_sca = BLE_LL_CFG_CONN_MASTER_SCA;
+    connsm->tx_win_size = BLE_LL_CONN_TX_WIN_MIN;
+    connsm->tx_win_off = 0;
+    connsm->master_sca = NIMBLE_OPT_LL_MASTER_SCA;
 
     /* Hop increment is a random value between 5 and 16. */
     connsm->hop_inc = (rand() % 12) + 5;
@@ -1425,7 +1417,7 @@ ble_ll_conn_next_event(struct ble_ll_conn_sm *connsm)
      * Calculate ce end time. For a slave, we need to add window widening and
      * the transmit window if we still have one.
      */
-    itvl = BLE_LL_CFG_CONN_INIT_SLOTS * BLE_LL_SCHED_USECS_PER_SLOT;
+    itvl = NIMBLE_OPT_LL_CONN_INIT_SLOTS * BLE_LL_SCHED_USECS_PER_SLOT;
     if (connsm->conn_role == BLE_LL_CONN_ROLE_SLAVE) {
         cur_ww = ble_ll_conn_calc_window_widening(connsm);
         max_ww = (connsm->conn_itvl * (BLE_LL_CONN_ITVL_USECS/2)) - BLE_LL_IFS;
@@ -1489,8 +1481,8 @@ ble_ll_conn_created(struct ble_ll_conn_sm *connsm, uint32_t endtime)
             connsm->tx_win_size * BLE_LL_CONN_TX_WIN_USECS;
         usecs = 1250 + (connsm->tx_win_off * BLE_LL_CONN_TX_WIN_USECS);
         connsm->anchor_point = endtime + cputime_usecs_to_ticks(usecs);
-        usecs = connsm->slave_cur_tx_win_usecs + (BLE_LL_CFG_CONN_INIT_SLOTS *
-                                                  BLE_LL_SCHED_USECS_PER_SLOT);
+        usecs = connsm->slave_cur_tx_win_usecs + 
+            (NIMBLE_OPT_LL_CONN_INIT_SLOTS * BLE_LL_SCHED_USECS_PER_SLOT);
         connsm->ce_end_time = connsm->anchor_point + 
             cputime_usecs_to_ticks(usecs);
         connsm->slave_cur_window_widening = 0;
@@ -1859,7 +1851,7 @@ ble_ll_init_rx_isr_end(struct os_mbuf *rxpdu, uint8_t crcok)
         /* Attempt to schedule new connection. Possible that this might fail */
         if (!ble_ll_sched_master_new(g_ble_ll_conn_create_sm, 
                                      ble_hdr->end_cputime,
-                                     BLE_LL_CFG_CONN_INIT_SLOTS)) {
+                                     NIMBLE_OPT_LL_CONN_INIT_SLOTS)) {
             /* Setup to transmit the connect request */
             rc = ble_ll_conn_request_send(addr_type, adv_addr, 
                                           g_ble_ll_conn_create_sm->tx_win_off);
@@ -2206,6 +2198,10 @@ ble_ll_conn_rx_isr_end(struct os_mbuf *rxpdu, uint32_t aa)
 
                         /* If l2cap pdu, increment # of completed packets */
                         if (ble_ll_conn_is_l2cap_pdu(txhdr)) {
+#if (BLETEST_THROUGHPUT_TEST == 1)
+                            bletest_completed_pkt(connsm->conn_handle);
+#endif
+
                             ++connsm->completed_pkts;
                         }
                         os_mbuf_free_chain(txpdu);
@@ -2545,17 +2541,17 @@ ble_ll_conn_module_reset(void)
 
     /* Configure the global LL parameters */
     conn_params = &g_ble_ll_conn_params;
-    maxbytes = BLE_LL_CFG_SUPP_MAX_RX_BYTES + BLE_LL_DATA_MIC_LEN;
+    maxbytes = NIMBLE_OPT_LL_SUPP_MAX_RX_BYTES + BLE_LL_DATA_MIC_LEN;
     conn_params->supp_max_rx_time = BLE_TX_DUR_USECS_M(maxbytes);
-    conn_params->supp_max_rx_octets = BLE_LL_CFG_SUPP_MAX_RX_BYTES;
+    conn_params->supp_max_rx_octets = NIMBLE_OPT_LL_SUPP_MAX_RX_BYTES;
 
-    maxbytes = BLE_LL_CFG_SUPP_MAX_TX_BYTES + BLE_LL_DATA_MIC_LEN;
+    maxbytes = NIMBLE_OPT_LL_SUPP_MAX_TX_BYTES + BLE_LL_DATA_MIC_LEN;
     conn_params->supp_max_tx_time = BLE_TX_DUR_USECS_M(maxbytes);
-    conn_params->supp_max_tx_octets = BLE_LL_CFG_SUPP_MAX_TX_BYTES;
+    conn_params->supp_max_tx_octets = NIMBLE_OPT_LL_SUPP_MAX_TX_BYTES;
 
-    maxbytes = BLE_LL_CFG_CONN_INIT_MAX_TX_BYTES + BLE_LL_DATA_MIC_LEN;
+    maxbytes = NIMBLE_OPT_LL_CONN_INIT_MAX_TX_BYTES + BLE_LL_DATA_MIC_LEN;
     conn_params->conn_init_max_tx_time = BLE_TX_DUR_USECS_M(maxbytes);
-    conn_params->conn_init_max_tx_octets = BLE_LL_CFG_CONN_INIT_MAX_TX_BYTES;
+    conn_params->conn_init_max_tx_octets = NIMBLE_OPT_LL_CONN_INIT_MAX_TX_BYTES;
 
     /* Mask in all channels by default */
     conn_params->num_used_chans = BLE_PHY_NUM_DATA_CHANS;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/27a3fd47/net/nimble/controller/src/ble_ll_conn_hci.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_conn_hci.c b/net/nimble/controller/src/ble_ll_conn_hci.c
index 4b86403..9b9cefd 100644
--- a/net/nimble/controller/src/ble_ll_conn_hci.c
+++ b/net/nimble/controller/src/ble_ll_conn_hci.c
@@ -23,6 +23,7 @@
 #include "bsp/bsp.h"
 #include "os/os.h"
 #include "nimble/ble.h"
+#include "nimble/nimble_opt.h"
 #include "nimble/hci_common.h"
 #include "controller/ble_ll.h"
 #include "controller/ble_ll_hci.h"
@@ -37,9 +38,6 @@
  */
 static uint32_t g_ble_ll_next_num_comp_pkt_evt;
 
-#define BLE_LL_NUM_COMP_PKT_RATE    \
-    ((BLE_LL_CFG_NUM_COMP_PKT_RATE * OS_TICKS_PER_SEC) / 1000)
-
 /**
  * Called to check that the connection parameters are within range 
  * 
@@ -133,7 +131,7 @@ ble_ll_conn_req_pdu_make(struct ble_ll_conn_sm *connsm)
     htole16(dptr + 12, connsm->slave_latency);
     htole16(dptr + 14, connsm->supervision_tmo);
     memcpy(dptr + 16, &connsm->chanmap, BLE_LL_CONN_CHMAP_LEN);
-    dptr[21] = connsm->hop_inc | connsm->master_sca;
+    dptr[21] = connsm->hop_inc | (connsm->master_sca << 5);
 }
 
 /**
@@ -191,7 +189,7 @@ ble_ll_conn_num_comp_pkts_event_send(void)
 
     /* Check rate limit */
     if ((uint32_t)(g_ble_ll_next_num_comp_pkt_evt - os_time_get()) < 
-        BLE_LL_NUM_COMP_PKT_RATE) {
+         NIMBLE_OPT_NUM_COMP_PKT_RATE) {
         return;
     }
 
@@ -258,7 +256,7 @@ ble_ll_conn_num_comp_pkts_event_send(void)
 
     if (event_sent) {
         g_ble_ll_next_num_comp_pkt_evt = os_time_get() + 
-            BLE_LL_NUM_COMP_PKT_RATE;
+            NIMBLE_OPT_NUM_COMP_PKT_RATE;
     }
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/27a3fd47/net/nimble/controller/src/ble_ll_ctrl.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_ctrl.c b/net/nimble/controller/src/ble_ll_ctrl.c
index 2322a6b..a9ace70 100644
--- a/net/nimble/controller/src/ble_ll_ctrl.c
+++ b/net/nimble/controller/src/ble_ll_ctrl.c
@@ -20,6 +20,7 @@
 #include <assert.h>
 #include <string.h>
 #include "nimble/ble.h"
+#include "nimble/nimble_opt.h"
 #include "nimble/hci_common.h"
 #include "controller/ble_ll.h"
 #include "controller/ble_ll_hci.h"
@@ -378,7 +379,7 @@ ble_ll_ctrl_version_ind_make(struct ble_ll_conn_sm *connsm, uint8_t *pyld)
 
     /* Fill out response */
     pyld[0] = BLE_HCI_VER_BCS_4_2;
-    htole16(pyld + 1, BLE_LL_MFRG_ID);
+    htole16(pyld + 1, NIMBLE_OPT_LL_MFRG_ID);
     htole16(pyld + 3, BLE_LL_SUB_VERS_NR);
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/27a3fd47/net/nimble/controller/src/ble_ll_hci.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_hci.c b/net/nimble/controller/src/ble_ll_hci.c
index 5d8eebf..9d38ba1 100644
--- a/net/nimble/controller/src/ble_ll_hci.c
+++ b/net/nimble/controller/src/ble_ll_hci.c
@@ -21,6 +21,7 @@
 #include <string.h>
 #include "os/os.h"
 #include "nimble/ble.h"
+#include "nimble/nimble_opt.h"
 #include "nimble/hci_common.h"
 #include "nimble/hci_transport.h"
 #include "controller/ble_ll_adv.h"
@@ -109,7 +110,7 @@ ble_ll_hci_rd_local_version(uint8_t *rspbuf, uint8_t *rsplen)
 
     hci_rev = 0;
     lmp_subver = 0;
-    mfrg = BLE_LL_MFRG_ID;
+    mfrg = NIMBLE_OPT_LL_MFRG_ID;
 
     /* Place the data packet length and number of packets in the buffer */
     rspbuf[0] = BLE_HCI_VER_BCS_4_2;
@@ -153,8 +154,8 @@ static int
 ble_ll_hci_le_read_bufsize(uint8_t *rspbuf, uint8_t *rsplen)
 {    
     /* Place the data packet length and number of packets in the buffer */
-    htole16(rspbuf, BLE_LL_CFG_ACL_DATA_PKT_LEN);
-    rspbuf[2] = BLE_LL_CFG_NUM_ACL_DATA_PKTS;
+    htole16(rspbuf, g_ble_ll_data.ll_acl_pkt_size);
+    rspbuf[2] = g_ble_ll_data.ll_num_acl_pkts;
     *rsplen = BLE_HCI_RD_BUF_SIZE_RSPLEN;
     return BLE_ERR_SUCCESS;
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/27a3fd47/net/nimble/controller/src/ble_ll_scan.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_scan.c b/net/nimble/controller/src/ble_ll_scan.c
index 9d74333..663ed99 100644
--- a/net/nimble/controller/src/ble_ll_scan.c
+++ b/net/nimble/controller/src/ble_ll_scan.c
@@ -23,6 +23,7 @@
 #include "bsp/bsp.h"
 #include "os/os.h"
 #include "nimble/ble.h"
+#include "nimble/nimble_opt.h"
 #include "nimble/hci_common.h"
 #include "controller/ble_phy.h"
 #include "controller/ble_ll.h"
@@ -45,6 +46,14 @@
  * receive a scan response from? Implement this.
  */
 
+/* Dont allow more than 255 of these entries */
+#if NIMBLE_OPT_LL_NUM_SCAN_DUP_ADVS > 255
+    #error "Cannot have more than 255 duplicate entries!"
+#endif
+#if NIMBLE_OPT_LL_NUM_SCAN_RSP_ADVS > 255
+    #error "Cannot have more than 255 scan response entries!"
+#endif
+
 /* The scanning state machine global object */
 struct ble_ll_scan_sm g_ble_ll_scan_sm;
 
@@ -66,11 +75,13 @@ struct ble_ll_scan_advertisers
 
 /* Contains list of advertisers that we have heard scan responses from */
 static uint8_t g_ble_ll_scan_num_rsp_advs;
-struct ble_ll_scan_advertisers g_ble_ll_scan_rsp_advs[BLE_LL_SCAN_CFG_NUM_SCAN_RSP_ADVS];
+struct ble_ll_scan_advertisers 
+g_ble_ll_scan_rsp_advs[NIMBLE_OPT_LL_NUM_SCAN_RSP_ADVS];
 
 /* Used to filter duplicate advertising events to host */
 static uint8_t g_ble_ll_scan_num_dup_advs;
-struct ble_ll_scan_advertisers g_ble_ll_scan_dup_advs[BLE_LL_SCAN_CFG_NUM_DUP_ADVS];
+struct ble_ll_scan_advertisers 
+g_ble_ll_scan_dup_advs[NIMBLE_OPT_LL_NUM_SCAN_DUP_ADVS];
 
 /* See Vol 6 Part B Section 4.4.3.2. Active scanning backoff */
 static void
@@ -240,7 +251,7 @@ ble_ll_scan_add_dup_adv(uint8_t *addr, uint8_t txadd)
     if (!adv) {
         /* XXX: for now, if we dont have room, just leave */
         num_advs = g_ble_ll_scan_num_dup_advs;
-        if (num_advs == BLE_LL_SCAN_CFG_NUM_DUP_ADVS) {
+        if (num_advs == NIMBLE_OPT_LL_NUM_SCAN_DUP_ADVS) {
             return;
         }
 
@@ -307,7 +318,7 @@ ble_ll_scan_add_scan_rsp_adv(uint8_t *addr, uint8_t txadd)
 
     /* XXX: for now, if we dont have room, just leave */
     num_advs = g_ble_ll_scan_num_rsp_advs;
-    if (num_advs == BLE_LL_SCAN_CFG_NUM_SCAN_RSP_ADVS) {
+    if (num_advs == NIMBLE_OPT_LL_NUM_SCAN_RSP_ADVS) {
         return;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/27a3fd47/net/nimble/controller/src/ble_ll_whitelist.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_whitelist.c b/net/nimble/controller/src/ble_ll_whitelist.c
index 168a8c8..e5cce12 100644
--- a/net/nimble/controller/src/ble_ll_whitelist.c
+++ b/net/nimble/controller/src/ble_ll_whitelist.c
@@ -35,7 +35,7 @@ struct ble_ll_whitelist_entry
     uint8_t wl_dev_addr[BLE_DEV_ADDR_LEN];
 };
 
-struct ble_ll_whitelist_entry g_ble_ll_whitelist[BLE_LL_CFG_WHITELIST_SIZE];
+struct ble_ll_whitelist_entry g_ble_ll_whitelist[NIMBLE_OPT_LL_WHITELIST_SIZE];
 #endif
 
 static int
@@ -79,7 +79,7 @@ ble_ll_whitelist_clear(void)
 
     /* Set the number of entries to 0 */
     wl = &g_ble_ll_whitelist[0];
-    for (i = 0; i < BLE_LL_CFG_WHITELIST_SIZE; ++i) {
+    for (i = 0; i < NIMBLE_OPT_LL_WHITELIST_SIZE; ++i) {
         wl->wl_valid = 0;
         ++wl;
     }
@@ -102,7 +102,7 @@ ble_ll_whitelist_read_size(uint8_t *rspbuf, uint8_t *rsplen)
 #ifdef BLE_USES_HW_WHITELIST
     rspbuf[0] = ble_hw_whitelist_size();
 #else
-    rspbuf[0] = BLE_LL_CFG_WHITELIST_SIZE;
+    rspbuf[0] = NIMBLE_OPT_LL_WHITELIST_SIZE;
 #endif
     *rsplen = 1;
     return BLE_ERR_SUCCESS;
@@ -126,7 +126,7 @@ ble_ll_is_on_whitelist(uint8_t *addr, uint8_t addr_type)
     struct ble_ll_whitelist_entry *wl;
 
     wl = &g_ble_ll_whitelist[0];
-    for (i = 0; i < BLE_LL_CFG_WHITELIST_SIZE; ++i) {
+    for (i = 0; i < NIMBLE_OPT_LL_WHITELIST_SIZE; ++i) {
         if ((wl->wl_valid) && (wl->wl_addr_type == addr_type) &&
             (!memcmp(&wl->wl_dev_addr[0], addr, BLE_DEV_ADDR_LEN))) {
             return i + 1;
@@ -183,7 +183,7 @@ ble_ll_whitelist_add(uint8_t *addr, uint8_t addr_type)
     rc = BLE_ERR_SUCCESS;
     if (!ble_ll_is_on_whitelist(addr, addr_type)) {
         wl = &g_ble_ll_whitelist[0];
-        for (i = 0; i < BLE_LL_CFG_WHITELIST_SIZE; ++i) {
+        for (i = 0; i < NIMBLE_OPT_LL_WHITELIST_SIZE; ++i) {
             if (wl->wl_valid == 0) {
                 memcpy(&wl->wl_dev_addr[0], addr, BLE_DEV_ADDR_LEN);
                 wl->wl_addr_type = addr_type;
@@ -193,7 +193,7 @@ ble_ll_whitelist_add(uint8_t *addr, uint8_t addr_type)
             ++wl;
         }
 
-        if (i == BLE_LL_CFG_WHITELIST_SIZE) {
+        if (i == NIMBLE_OPT_LL_WHITELIST_SIZE) {
             rc = BLE_ERR_MEM_CAPACITY;
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/27a3fd47/net/nimble/include/nimble/nimble_opt.h
----------------------------------------------------------------------
diff --git a/net/nimble/include/nimble/nimble_opt.h b/net/nimble/include/nimble/nimble_opt.h
index 3ab8b27..4a8467a 100644
--- a/net/nimble/include/nimble/nimble_opt.h
+++ b/net/nimble/include/nimble/nimble_opt.h
@@ -182,9 +182,94 @@
 #define NIMBLE_OPT_ATT_SVR_INDICATE             1
 #endif
 
-/** CONTROLLER: transmit power level */
+/*** CONTROLLER ***/
+
+/* 
+ * Sleep clock accuracy (sca). This is the amount of drift in the system during 
+ * when the device is sleeping (in parts per million).
+ *
+ * NOTE: the master sca is an enumerated value based on the sca. Rather than
+ * have a piece of code calculate this value, the developer must set this
+ * value based on the value of the SCA using the following table:
+ * 
+ *  SCA between 251 and 500 ppm (inclusive); master sca = 0
+ *  SCA between 151 and 250 ppm (inclusive); master sca = 1
+ *  SCA between 101 and 150 ppm (inclusive); master sca = 2
+ *  SCA between 76 and 100 ppm (inclusive); master sca = 3
+ *  SCA between 51 and 75 ppm (inclusive); master sca = 4
+ *  SCA between 31 and 50 ppm (inclusive); master sca = 5
+ *  SCA between 21 and 30 ppm (inclusive); master sca = 6
+ *  SCA between 0 and 20 ppm (inclusive); master sca = 7
+ * 
+ *  For example:
+ *      if your clock drift is 101 ppm, your master should be set to 2.
+ *      if your clock drift is 20, your master sca should be set to 7.
+ * 
+ *  The values provided below are merely meant to be an example and should
+ *  be replaced by values appropriate for your platform.
+ */
+#ifndef NIMBLE_OPT_LL_OUR_SCA
+#define NIMBLE_OPT_LL_OUR_SCA                   (60)    /* in ppm */
+#endif
+
+#ifndef NIMBLE_OPT_LL_MASTER_SCA
+#define NIMBLE_OPT_LL_MASTER_SCA                (4)
+#endif
+
+/* transmit power level */
 #ifndef NIMBLE_OPT_LL_TX_PWR_DBM
-#define NIMBLE_OPT_LL_TX_PWR_DBM                0
+#define NIMBLE_OPT_LL_TX_PWR_DBM                (0)
+#endif
+
+/* 
+ * Determines the maximum rate at which the controller will send the
+ * number of completed packets event to the host. Rate is in os time ticks
+ */
+#ifndef NIMBLE_OPT_NUM_COMP_PKT_RATE
+#define NIMBLE_OPT_NUM_COMP_PKT_RATE    ((2000 * OS_TICKS_PER_SEC) / 1000)
+#endif
+
+/* Manufacturer ID. Should be set to unique ID per manufacturer */
+#ifndef NIMBLE_OPT_LL_MFRG_ID
+#define NIMBLE_OPT_LL_MFRG_ID                   (0xFFFF)
+#endif
+
+/* 
+ * Configuration items for the number of duplicate advertisers and the
+ * number of advertisers from which we have heard a scan response.
+ */
+#ifndef NIMBLE_OPT_LL_NUM_SCAN_DUP_ADVS
+#define NIMBLE_OPT_LL_NUM_SCAN_DUP_ADVS         (8)
+#endif
+
+#ifndef NIMBLE_OPT_LL_NUM_SCAN_RSP_ADVS
+#define NIMBLE_OPT_LL_NUM_SCAN_RSP_ADVS         (8)
+#endif
+
+/* Size of the LL whitelist */
+#ifndef NIMBLE_OPT_LL_WHITELIST_SIZE
+#define NIMBLE_OPT_LL_WHITELIST_SIZE            (8)
+#endif
+
+/* 
+ * Data length management definitions for connections. These define the maximum
+ * size of the PDU's that will be sent and/or received in a connection. 
+ */
+#ifndef NIMBLE_OPT_LL_SUPP_MAX_RX_BYTES
+#define NIMBLE_OPT_LL_SUPP_MAX_RX_BYTES        (251)
+#endif
+
+#ifndef NIMBLE_OPT_LL_SUPP_MAX_TX_BYTES
+#define NIMBLE_OPT_LL_SUPP_MAX_TX_BYTES        (251)
+#endif
+
+#ifndef NIMBLE_OPT_LL_CONN_INIT_MAX_TX_BYTES
+#define NIMBLE_OPT_LL_CONN_INIT_MAX_TX_BYTES   (251)
+#endif
+
+/* The number of slots that will be allocated to each connection */
+#ifndef NIMBLE_OPT_LL_CONN_INIT_SLOTS
+#define NIMBLE_OPT_LL_CONN_INIT_SLOTS          (2)
 #endif
 
 /* Include automatically-generated settings. */


[25/42] incubator-mynewt-core git commit: Mac OS X and Linux use different conventions for names of C functions.

Posted by cc...@apache.org.
Mac OS X and Linux use different conventions for names of C functions.

OS X adds a "_" prefix to all C function names whereas Linux uses the name
unchanged.

sigsetjmp() is a macro on Linux and the real function name is __sigsetjmp().


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/adbc585f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/adbc585f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/adbc585f

Branch: refs/heads/master
Commit: adbc585f797c561f79f0c235de2dba4633f6fcfa
Parents: a92a45e
Author: Neel Natu <ne...@nahannisys.com>
Authored: Thu Mar 10 22:59:18 2016 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Fri Mar 11 12:16:13 2016 -0800

----------------------------------------------------------------------
 libs/os/src/arch/sim/os_arch_stack_frame.s | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/adbc585f/libs/os/src/arch/sim/os_arch_stack_frame.s
----------------------------------------------------------------------
diff --git a/libs/os/src/arch/sim/os_arch_stack_frame.s b/libs/os/src/arch/sim/os_arch_stack_frame.s
index 709ca29..a09654d 100644
--- a/libs/os/src/arch/sim/os_arch_stack_frame.s
+++ b/libs/os/src/arch/sim/os_arch_stack_frame.s
@@ -1,12 +1,23 @@
+#if defined MN_LINUX
+#define sigsetjmp   __sigsetjmp
+#define CNAME(x)    x
+#elif defined MN_OSX
+#define sigsetjmp   sigsetjmp
+#define CNAME(x)    _ ## x
+#else
+#error "unsupported platform"
+#endif
+
     .text
     .code32
     .p2align 4, 0x90    /* align on 16-byte boundary and fill with NOPs */
 
+    .globl CNAME(os_arch_frame_init)
     .globl _os_arch_frame_init
     /*
      * void os_arch_frame_init(struct stack_frame *sf)
      */
-_os_arch_frame_init:
+CNAME(os_arch_frame_init):
     push    %ebp                    /* function prologue for backtrace */
     mov     %esp,%ebp
     push    %esi                    /* save %esi before using it as a tmpreg */
@@ -51,7 +62,7 @@ _os_arch_frame_init:
     leal    0x4(%esi),%eax          /* %eax = &sf->sf_jb */
     movl    %eax,0x0(%esp)
     movl    $0, 0x4(%esp)
-    call    _sigsetjmp              /* sigsetjmp(sf->sf_jb, 0) */
+    call    CNAME(sigsetjmp)        /* sigsetjmp(sf->sf_jb, 0) */
     test    %eax,%eax
     jne     1f
     movl    0x0(%esi),%esp          /* switch back to the main() stack */
@@ -65,7 +76,7 @@ _os_arch_frame_init:
     movl    %esp,%ebp               /* handcrafted prologue for backtrace */
     push    %eax                    /* rc */
     push    %esi                    /* sf */
-    call    _os_arch_task_start     /* os_arch_task_start(sf, rc) */
+    call    CNAME(os_arch_task_start) /* os_arch_task_start(sf, rc) */
     /* never returns */
 2:
     nop


[20/42] incubator-mynewt-core git commit: No arch in target variables.

Posted by cc...@apache.org.
No arch in target variables.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/f7ac6fed
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/f7ac6fed
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/f7ac6fed

Branch: refs/heads/master
Commit: f7ac6fedccddc5d78e13225e5e74fcc15940f788
Parents: 2e6f78e
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Mar 10 15:45:47 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Mar 10 15:45:47 2016 -0800

----------------------------------------------------------------------
 targets/unittest/pkg.yml    | 6 ++----
 targets/unittest/target.yml | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f7ac6fed/targets/unittest/pkg.yml
----------------------------------------------------------------------
diff --git a/targets/unittest/pkg.yml b/targets/unittest/pkg.yml
index 338ba99..806f690 100644
--- a/targets/unittest/pkg.yml
+++ b/targets/unittest/pkg.yml
@@ -1,9 +1,7 @@
-### Target: slinky_sim
+### Package: targets/unittest
 pkg.name: "targets/unittest"
 pkg.type: "target"
-pkg.vers: "0.8.0"
 pkg.description: "Used for unit tests by the \"newt test\" command."
 pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
 pkg.homepage: "http://mynewt.apache.org/"
-pkg.repository:
-pkg.keywords:
+pkg.repository: "local"

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f7ac6fed/targets/unittest/target.yml
----------------------------------------------------------------------
diff --git a/targets/unittest/target.yml b/targets/unittest/target.yml
index 9e7e56e..fd88167 100644
--- a/targets/unittest/target.yml
+++ b/targets/unittest/target.yml
@@ -1,4 +1,3 @@
-### Target: unittest
-target.arch: "sim"
+### Target: targets/unittest
 target.bsp: "hw/bsp/native"
 target.build_profile: "debug"


[14/42] incubator-mynewt-core git commit: initialize native_uart_file to satisfy linker

Posted by cc...@apache.org.
initialize native_uart_file to satisfy linker


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/c1338807
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/c1338807
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/c1338807

Branch: refs/heads/master
Commit: c1338807125c182d2d6b524141fc84e8352c0cb6
Parents: 9c705a7
Author: Sterling Hughes <st...@apache.org>
Authored: Thu Mar 10 11:06:45 2016 -0800
Committer: Sterling Hughes <st...@apache.org>
Committed: Thu Mar 10 11:06:45 2016 -0800

----------------------------------------------------------------------
 hw/mcu/native/src/hal_uart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c1338807/hw/mcu/native/src/hal_uart.c
----------------------------------------------------------------------
diff --git a/hw/mcu/native/src/hal_uart.c b/hw/mcu/native/src/hal_uart.c
index ff5101b..e2bfc6d 100644
--- a/hw/mcu/native/src/hal_uart.c
+++ b/hw/mcu/native/src/hal_uart.c
@@ -53,7 +53,7 @@ struct uart {
  * XXXX should try to use O_ASYNC/SIGIO for byte arrival notification,
  * so we wouldn't need an OS for pseudo ttys.
  */
-char *native_uart_log_file;
+char *native_uart_log_file = NULL;
 static int uart_log_fd = -1;
 
 static struct uart uarts[UART_CNT];


[35/42] incubator-mynewt-core git commit: Replace some common fields in pkg.yml.

Posted by cc...@apache.org.
Replace some common fields in pkg.yml.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/2fb63deb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/2fb63deb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/2fb63deb

Branch: refs/heads/master
Commit: 2fb63deb4653b80737d267a63a655d1f9e33754b
Parents: f7c9270
Author: Christopher Collins <cc...@apache.org>
Authored: Mon Mar 14 14:10:24 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Mon Mar 14 14:24:24 2016 -0700

----------------------------------------------------------------------
 apps/bletest/pkg.yml                      |  7 ++-----
 apps/bletiny/pkg.yml                      |  7 ++-----
 apps/blinky/pkg.yml                       |  7 ++-----
 apps/boot/pkg.yml                         |  7 ++-----
 apps/ffs2native/pkg.yml                   |  7 ++-----
 apps/luatest/pkg.yml                      |  7 ++-----
 apps/slinky/pkg.yml                       |  7 ++-----
 apps/test/pkg.yml                         |  7 ++-----
 compiler/arm-none-eabi-m0/pkg.yml         |  7 ++-----
 compiler/arm-none-eabi-m4/pkg.yml         |  7 ++-----
 compiler/sim/pkg.yml                      |  7 ++-----
 fs/fs/pkg.yml                             |  6 ++----
 fs/nffs/pkg.yml                           |  6 ++----
 hw/bsp/native/pkg.yml                     |  7 ++-----
 hw/bsp/nrf51dk-16kbram/pkg.yml            |  7 ++-----
 hw/bsp/nrf51dk/pkg.yml                    |  7 ++-----
 hw/bsp/nrf52pdk/pkg.yml                   |  7 ++-----
 hw/bsp/olimex_stm32-e407_devboard/pkg.yml |  7 ++-----
 hw/hal/pkg.yml                            |  6 ++----
 hw/mcu/native/pkg.yml                     |  6 ++----
 hw/mcu/nordic/nrf51xxx/pkg.yml            |  6 ++----
 hw/mcu/nordic/nrf52xxx/pkg.yml            |  6 ++----
 hw/mcu/stm/stm32f4xx/pkg.yml              |  6 ++----
 libs/baselibc/pkg.yml                     |  6 ++----
 libs/bootutil/pkg.yml                     |  6 ++----
 libs/cmsis-core/pkg.yml                   |  6 ++----
 libs/console/full/pkg.yml                 |  6 ++----
 libs/console/stub/pkg.yml                 |  6 ++----
 libs/elua/elua_base/pkg.yml               | 10 ++++------
 libs/flash_test/pkg.yml                   |  4 +---
 libs/imgmgr/pkg.yml                       |  6 ++----
 libs/json/pkg.yml                         |  6 ++----
 libs/mbedtls/pkg.yml                      |  6 ++----
 libs/newtmgr/pkg.yml                      |  6 ++----
 libs/os/pkg.yml                           |  6 ++----
 libs/shell/pkg.yml                        |  6 ++----
 libs/testreport/pkg.yml                   |  6 ++----
 libs/testutil/pkg.yml                     |  6 ++----
 libs/util/pkg.yml                         |  6 ++----
 net/nimble/controller/pkg.yml             |  6 ++----
 net/nimble/drivers/native/pkg.yml         |  6 ++----
 net/nimble/drivers/nrf51/pkg.yml          |  6 ++----
 net/nimble/drivers/nrf52/pkg.yml          |  6 ++----
 net/nimble/host/pkg.yml                   |  6 ++----
 net/nimble/pkg.yml                        |  6 ++----
 sys/config/pkg.yml                        |  6 ++----
 sys/log/pkg.yml                           |  6 ++----
 sys/stats/pkg.yml                         |  6 ++----
 48 files changed, 97 insertions(+), 209 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/apps/bletest/pkg.yml
----------------------------------------------------------------------
diff --git a/apps/bletest/pkg.yml b/apps/bletest/pkg.yml
index 918f7f4..88142b8 100644
--- a/apps/bletest/pkg.yml
+++ b/apps/bletest/pkg.yml
@@ -19,12 +19,9 @@
 
 pkg.name: apps/bletest
 pkg.type: app
-pkg.vers: 0.8.0
 pkg.description: Test project for the nimble BLE controller.
-pkg.author: wes3 <wi...@runtime.io>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
-pkg.type: app
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
 
 pkg.deps: 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/apps/bletiny/pkg.yml
----------------------------------------------------------------------
diff --git a/apps/bletiny/pkg.yml b/apps/bletiny/pkg.yml
index 851461d..55f0a58 100644
--- a/apps/bletiny/pkg.yml
+++ b/apps/bletiny/pkg.yml
@@ -17,12 +17,9 @@
 #
 pkg.name: apps/bletiny
 pkg.type: app
-pkg.vers: 0.8.0
 pkg.description: Shell application exposing the nimble GAP and GATT.
-pkg.author: Christopher Collins <cc...@apache.org>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
-pkg.type: app
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
 
 pkg.deps: 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/apps/blinky/pkg.yml
----------------------------------------------------------------------
diff --git a/apps/blinky/pkg.yml b/apps/blinky/pkg.yml
index 44bf925..64bbace 100644
--- a/apps/blinky/pkg.yml
+++ b/apps/blinky/pkg.yml
@@ -19,12 +19,9 @@
 
 pkg.name: apps/blinky
 pkg.type: app
-pkg.vers: 0.8.0
 pkg.description: Basic example application which blinks an LED.
-pkg.author: Marko Kiiskila <ma...@runtime.io>
-pkg.homepage: http://mynewt.apache.org/os/get_acclimated/project2/
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
-pkg.type: app
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
 
 pkg.deps:

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/apps/boot/pkg.yml
----------------------------------------------------------------------
diff --git a/apps/boot/pkg.yml b/apps/boot/pkg.yml
index 3041abb..e45d2a0 100644
--- a/apps/boot/pkg.yml
+++ b/apps/boot/pkg.yml
@@ -19,12 +19,9 @@
 
 pkg.name: apps/boot
 pkg.type: app
-pkg.vers: 0.8.0
 pkg.description: Boot loader application.
-pkg.author: Christopher Collins <ch...@apache.org>
-pkg.homepage: http://mynewt.apache.org/os/modules/bootloader/bootloader/
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
-pkg.type: app
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
     - loader
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/apps/ffs2native/pkg.yml
----------------------------------------------------------------------
diff --git a/apps/ffs2native/pkg.yml b/apps/ffs2native/pkg.yml
index abb9800..0644425 100644
--- a/apps/ffs2native/pkg.yml
+++ b/apps/ffs2native/pkg.yml
@@ -19,12 +19,9 @@
 
 pkg.name: apps/ffs2native
 pkg.type: app
-pkg.vers: 0.8.0
 pkg.description: Support application for debugging the Newtron Flash File System.
-pkg.author: Christopher Collins <cc...@apache.org>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
-pkg.type: app
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
 
 pkg.deps:

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/apps/luatest/pkg.yml
----------------------------------------------------------------------
diff --git a/apps/luatest/pkg.yml b/apps/luatest/pkg.yml
index 7d83b97..b56be6b 100644
--- a/apps/luatest/pkg.yml
+++ b/apps/luatest/pkg.yml
@@ -17,12 +17,9 @@
 #
 pkg.name: apps/luatest
 pkg.type: app
-pkg.vers: 0.8.0
 pkg.description: Simple project for testing Lua scripting.
-pkg.author: Marko Kiiskila <ma...@runtime.io>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
-pkg.type: app
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
 
 pkg.deps:

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/apps/slinky/pkg.yml
----------------------------------------------------------------------
diff --git a/apps/slinky/pkg.yml b/apps/slinky/pkg.yml
index d286ade..931fe97 100644
--- a/apps/slinky/pkg.yml
+++ b/apps/slinky/pkg.yml
@@ -19,12 +19,9 @@
 
 pkg.name: apps/slinky
 pkg.type: app
-pkg.vers: 0.8.0
 pkg.description: Example application which uses a variety of mynewt features.
-pkg.author: Marko Kiiskila <ma...@runtime.io>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
-pkg.type: app
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
 
 pkg.deps:

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/apps/test/pkg.yml
----------------------------------------------------------------------
diff --git a/apps/test/pkg.yml b/apps/test/pkg.yml
index c6a42af..7e05e28 100644
--- a/apps/test/pkg.yml
+++ b/apps/test/pkg.yml
@@ -19,12 +19,9 @@
 
 pkg.name: apps/test
 pkg.type: app
-pkg.vers: 0.8.0
 pkg.description: Automated test suite for mynewt core functionality.
-pkg.author: Christopher Collins <cc...@apache.org>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
-pkg.type: app
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
 
 pkg.features:

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/compiler/arm-none-eabi-m0/pkg.yml
----------------------------------------------------------------------
diff --git a/compiler/arm-none-eabi-m0/pkg.yml b/compiler/arm-none-eabi-m0/pkg.yml
index f920944..d0d3a39 100644
--- a/compiler/arm-none-eabi-m0/pkg.yml
+++ b/compiler/arm-none-eabi-m0/pkg.yml
@@ -19,12 +19,9 @@
 
 pkg.name: compiler/arm-none-eabi-m0
 pkg.type: compiler
-pkg.vers: 0.8.0
 pkg.description: Compiler definition for ARM Cortex-M0 gcc cross compiler.
-pkg.author: wes3 <wi...@runtime.io>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
-pkg.type: compiler
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
     - arm
     - compiler

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/compiler/arm-none-eabi-m4/pkg.yml
----------------------------------------------------------------------
diff --git a/compiler/arm-none-eabi-m4/pkg.yml b/compiler/arm-none-eabi-m4/pkg.yml
index c04b1b3..626ffbb 100644
--- a/compiler/arm-none-eabi-m4/pkg.yml
+++ b/compiler/arm-none-eabi-m4/pkg.yml
@@ -19,12 +19,9 @@
 
 pkg.name: compiler/arm-none-eabi-m4
 pkg.type: compiler
-pkg.vers: 0.8.0
 pkg.description: Compiler definition for ARM Cortex-M4 gcc cross compiler.
-pkg.author: sterling <st...@runtime.io>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
-pkg.type: compiler
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
     - arm
     - compiler

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/compiler/sim/pkg.yml
----------------------------------------------------------------------
diff --git a/compiler/sim/pkg.yml b/compiler/sim/pkg.yml
index b0ec2be..99858eb 100644
--- a/compiler/sim/pkg.yml
+++ b/compiler/sim/pkg.yml
@@ -19,12 +19,9 @@
 
 pkg.name: compiler/sim
 pkg.type: compiler
-pkg.vers: 0.8.0
 pkg.description: Compiler definition for native gcc compiler.
-pkg.author: sterling <st...@runtime.io>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
-pkg.type: compiler
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
     - sim
     - compiler

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/fs/fs/pkg.yml
----------------------------------------------------------------------
diff --git a/fs/fs/pkg.yml b/fs/fs/pkg.yml
index 22c6cff..64909cb 100644
--- a/fs/fs/pkg.yml
+++ b/fs/fs/pkg.yml
@@ -18,11 +18,9 @@
 #
 
 pkg.name: fs/fs
-pkg.vers: 0.8.0
 pkg.description: File system abstrction.
-pkg.author: Marko Kiiskila <ma...@apache.org>
-pkg.homepage: http://mynewt.apache.org/os/modules/filesystem/
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
     - file
     - filesystem

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/fs/nffs/pkg.yml
----------------------------------------------------------------------
diff --git a/fs/nffs/pkg.yml b/fs/nffs/pkg.yml
index ff7c694..61e07e0 100644
--- a/fs/nffs/pkg.yml
+++ b/fs/nffs/pkg.yml
@@ -18,11 +18,9 @@
 #
 
 pkg.name: fs/nffs
-pkg.vers: 0.8.0
 pkg.description: Newtron Flash File System.
-pkg.author: Christopher Collins <cc...@apache.org>
-pkg.homepage: http://mynewt.apache.org/os/modules/nffs/
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
     - file
     - filesystem

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/hw/bsp/native/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/native/pkg.yml b/hw/bsp/native/pkg.yml
index c3ade4d..54a1ccd 100644
--- a/hw/bsp/native/pkg.yml
+++ b/hw/bsp/native/pkg.yml
@@ -19,12 +19,9 @@
 
 pkg.name: hw/bsp/native
 pkg.type: bsp
-pkg.vers: 0.8.0
 pkg.description: BSP definition for native (amd64) applications.
-pkg.author: Christopher Collins <cc...@apache.org>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
-pkg.type: bsp
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
     - native
     - bsp

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/hw/bsp/nrf51dk-16kbram/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf51dk-16kbram/pkg.yml b/hw/bsp/nrf51dk-16kbram/pkg.yml
index 76fea72..486156f 100644
--- a/hw/bsp/nrf51dk-16kbram/pkg.yml
+++ b/hw/bsp/nrf51dk-16kbram/pkg.yml
@@ -19,12 +19,9 @@
 
 pkg.name: hw/bsp/nrf51dk-16kbram
 pkg.type: bsp
-pkg.vers: 0.8.0
 pkg.description: BSP definition for a Nordic nRF51 DK SoC with 16kB RAM.
-pkg.author: Christopher Collins <ch...@apache.org>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
-pkg.type: bsp
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
     - nrf51
     - nrf51dk

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/hw/bsp/nrf51dk/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf51dk/pkg.yml b/hw/bsp/nrf51dk/pkg.yml
index 0bbd67d..396732d 100644
--- a/hw/bsp/nrf51dk/pkg.yml
+++ b/hw/bsp/nrf51dk/pkg.yml
@@ -19,12 +19,9 @@
 
 pkg.name: hw/bsp/nrf51dk
 pkg.type: bsp
-pkg.vers: 0.8.0
 pkg.description: BSP definition for the Nordic nRF51 DK SoC.
-pkg.author: wes3 <wi...@runtime.io>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
-pkg.type: bsp
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
     - nrf51
     - nrf51dk

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/hw/bsp/nrf52pdk/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf52pdk/pkg.yml b/hw/bsp/nrf52pdk/pkg.yml
index b048144..ffad3de 100644
--- a/hw/bsp/nrf52pdk/pkg.yml
+++ b/hw/bsp/nrf52pdk/pkg.yml
@@ -19,12 +19,9 @@
 
 pkg.name: hw/bsp/nrf52pdk
 pkg.type: bsp
-pkg.vers: 0.8.0
 pkg.description: BSP definition for the Nordic nRF52 Preview DK SoC.
-pkg.author: wes3 <wi...@runtime.io>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
-pkg.type: bsp
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
     - nrf52
     - nrf52dk

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/hw/bsp/olimex_stm32-e407_devboard/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/olimex_stm32-e407_devboard/pkg.yml b/hw/bsp/olimex_stm32-e407_devboard/pkg.yml
index 96e4222..cb8b2ec 100644
--- a/hw/bsp/olimex_stm32-e407_devboard/pkg.yml
+++ b/hw/bsp/olimex_stm32-e407_devboard/pkg.yml
@@ -19,12 +19,9 @@
 
 pkg.name: hw/bsp/olimex_stm32-e407_devboard
 pkg.type: bsp
-pkg.vers: 0.8.0
 pkg.description: BSP definition for the Olimex STM32-E407 board.
-pkg.author: Sterling Hughes <st...@apache.org>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
-pkg.type: bsp
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
     - olimex
     - stm32

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/hw/hal/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/hal/pkg.yml b/hw/hal/pkg.yml
index a92e9e4..f350040 100644
--- a/hw/hal/pkg.yml
+++ b/hw/hal/pkg.yml
@@ -18,11 +18,9 @@
 #
 
 pkg.name: hw/hal
-pkg.vers: 0.8.0 
 pkg.description: Hardware Abstraction Layer.
-pkg.author: wes3 <wi...@runtime.io>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
 
 pkg.deps: libs/os

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/hw/mcu/native/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/mcu/native/pkg.yml b/hw/mcu/native/pkg.yml
index 83b2ce1..ab74052 100644
--- a/hw/mcu/native/pkg.yml
+++ b/hw/mcu/native/pkg.yml
@@ -18,11 +18,9 @@
 #
 
 pkg.name: hw/mcu/native
-pkg.vers: 0.8.0
 pkg.description: MCU definition native applications.
-pkg.author: Christopher Collins <ch...@apache.org>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
     - native
     - x86

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/hw/mcu/nordic/nrf51xxx/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/nrf51xxx/pkg.yml b/hw/mcu/nordic/nrf51xxx/pkg.yml
index d200472..6957250 100644
--- a/hw/mcu/nordic/nrf51xxx/pkg.yml
+++ b/hw/mcu/nordic/nrf51xxx/pkg.yml
@@ -18,11 +18,9 @@
 #
 
 pkg.name: hw/mcu/nordic/nrf51xxx
-pkg.vers: 0.8.0
 pkg.description: MCU definition for Nordic nRF51 ARM Cortex-M0 chips.
-pkg.author: wes3 <wi...@runtime.io>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
     - nrf51
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/hw/mcu/nordic/nrf52xxx/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/nrf52xxx/pkg.yml b/hw/mcu/nordic/nrf52xxx/pkg.yml
index 780b308..2d54cf1 100644
--- a/hw/mcu/nordic/nrf52xxx/pkg.yml
+++ b/hw/mcu/nordic/nrf52xxx/pkg.yml
@@ -18,11 +18,9 @@
 #
 
 pkg.name: hw/mcu/nordic/nrf52xxx
-pkg.vers: 0.8.0
 pkg.description: MCU definition for Nordic nRF52 ARM Cortex-M4 chips.
-pkg.author: wes3 <wi...@runtime.io>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
     - nrf52
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/hw/mcu/stm/stm32f4xx/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/mcu/stm/stm32f4xx/pkg.yml b/hw/mcu/stm/stm32f4xx/pkg.yml
index 843110a..3202f12 100644
--- a/hw/mcu/stm/stm32f4xx/pkg.yml
+++ b/hw/mcu/stm/stm32f4xx/pkg.yml
@@ -18,11 +18,9 @@
 #
 
 pkg.name: hw/mcu/stm/stm32f4xx
-pkg.vers: 0.8.0
 pkg.description: MCU definition for STM32F4 ARM Cortex-M4 chips.
-pkg.author: wes3 <wi...@runtime.io>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
     - stm32
     - stm32f4

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/libs/baselibc/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/baselibc/pkg.yml b/libs/baselibc/pkg.yml
index 1b242da..0aa4d10 100644
--- a/libs/baselibc/pkg.yml
+++ b/libs/baselibc/pkg.yml
@@ -18,11 +18,9 @@
 #
 
 pkg.name: libs/baselibc
-pkg.vers: 0.8.0
 pkg.description: Simple libc for embedded systems.
-pkg.author: Petteri Aimonen
-pkg.homepage: https://github.com/PetteriAimonen/Baselibc
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
     - libc
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/libs/bootutil/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/bootutil/pkg.yml b/libs/bootutil/pkg.yml
index 5424dd2..7d1f6ba 100644
--- a/libs/bootutil/pkg.yml
+++ b/libs/bootutil/pkg.yml
@@ -18,11 +18,9 @@
 #
 
 pkg.name: libs/bootutil
-pkg.vers: 0.8.0
 pkg.description: The bootutil library performs most of the functions of a boot loader.
-pkg.author: Christopher Collins <cc...@apache.org>
-pkg.homepage: http://mynewt.apache.org/os/modules/bootloader/bootloader/
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
     - boot
     - bootloader

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/libs/cmsis-core/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/cmsis-core/pkg.yml b/libs/cmsis-core/pkg.yml
index 9cd9aef..ed3928d 100644
--- a/libs/cmsis-core/pkg.yml
+++ b/libs/cmsis-core/pkg.yml
@@ -18,11 +18,9 @@
 #
 
 pkg.name: libs/cmsis-core
-pkg.vers: 0.8.0
 pkg.description: CMSIS-CORE abstraction layer for Cortex-M processors.
-pkg.author: Keil
-pkg.homepage: http://www.keil.com/pack/doc/CMSIS/Core/html/index.html
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
     - cmsis
     - core

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/libs/console/full/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/console/full/pkg.yml b/libs/console/full/pkg.yml
index 68830ab..77c0b71 100644
--- a/libs/console/full/pkg.yml
+++ b/libs/console/full/pkg.yml
@@ -18,11 +18,9 @@
 #
 
 pkg.name: libs/console/full
-pkg.vers: 0.8.0
 pkg.description: Text-based IO interface.
-pkg.author: Marko Kiiskila <ma...@runtime.io>
-pkg.homepage: http://mynewt.apache.org/os/modules/console/console/
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
 
 pkg.deps:

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/libs/console/stub/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/console/stub/pkg.yml b/libs/console/stub/pkg.yml
index cf9da84..c5e530c 100644
--- a/libs/console/stub/pkg.yml
+++ b/libs/console/stub/pkg.yml
@@ -18,11 +18,9 @@
 #
 
 pkg.name: libs/console/stub
-pkg.vers: 0.8.0 
 pkg.description: Stub for text-based IO interface.
-pkg.author: Marko Kiiskila <ma...@runtime.io>
-pkg.homepage: http://mynewt.apache.org/os/modules/console/console/
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
 
 pkg.deps:

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/libs/elua/elua_base/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/elua/elua_base/pkg.yml b/libs/elua/elua_base/pkg.yml
index ffb48a1..5180159 100644
--- a/libs/elua/elua_base/pkg.yml
+++ b/libs/elua/elua_base/pkg.yml
@@ -18,13 +18,11 @@
 #
 
 pkg.name: libs/elua/elua_base
-pkg.vers: 0.8.0
 pkg.description: Lua interpreter for embedded systems.
-pkg.author: 
-    - Bogdan Marinescu
-    - Dado Sutter
-pkg.homepage: http://www.eluaproject.net/
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.author:
+    - "Bogdan Marinescu"
+    - "Dado Sutter"
+pkg.homepage: "http://www.eluaproject.net/"
 pkg.keywords:
     - lua
     - scripting

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/libs/flash_test/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/flash_test/pkg.yml b/libs/flash_test/pkg.yml
index 1903f2c..aa8510d 100644
--- a/libs/flash_test/pkg.yml
+++ b/libs/flash_test/pkg.yml
@@ -18,10 +18,8 @@
 #
 
 pkg.name: libs/flash_test
-pkg.vers: 0.8.0
 pkg.description: flash HAL tester
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
 
 pkg.deps:

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/libs/imgmgr/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/imgmgr/pkg.yml b/libs/imgmgr/pkg.yml
index fd22888..0c66744 100644
--- a/libs/imgmgr/pkg.yml
+++ b/libs/imgmgr/pkg.yml
@@ -18,11 +18,9 @@
 #
 
 pkg.name: libs/imgmgr
-pkg.vers: 0.8.0
 pkg.description: Library for image uploading.
-pkg.author: Marko Kiiskila <ma...@runtime.io>
-pkg.homepage: http://mynewt.apache.org/os/modules/imgmgr/imgmgr/
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
 
 pkg.deps:

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/libs/json/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/json/pkg.yml b/libs/json/pkg.yml
index a9e45a9..4944622 100644
--- a/libs/json/pkg.yml
+++ b/libs/json/pkg.yml
@@ -18,11 +18,9 @@
 #
 
 pkg.name: libs/json 
-pkg.vers: 0.8.0
 pkg.description: JSON encoding / decoding library.
-pkg.author: Sterling Hughes <st...@apache.org>
-pkg.homepage: http://mynewt.apache.org/os/modules/json/json/
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
 
 pkg.cflags.float_user: -DFLOAT_SUPPORT

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/libs/mbedtls/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/mbedtls/pkg.yml b/libs/mbedtls/pkg.yml
index 2c7b3b3..f1dd880 100644
--- a/libs/mbedtls/pkg.yml
+++ b/libs/mbedtls/pkg.yml
@@ -18,11 +18,9 @@
 #
 
 pkg.name: libs/mbedtls
-pkg.vers: 0.8.0
 pkg.description: SSL / TLS library for embedded systems.
-pkg.author: ARM
-pkg.homepage: https://tls.mbed.org/
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
     - ssl
     - tls

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/libs/newtmgr/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/newtmgr/pkg.yml b/libs/newtmgr/pkg.yml
index fc7c0db..ad0305d 100644
--- a/libs/newtmgr/pkg.yml
+++ b/libs/newtmgr/pkg.yml
@@ -18,11 +18,9 @@
 #
 
 pkg.name: libs/newtmgr
-pkg.vers: 0.8.0
 pkg.description: Server-side newtmgr functionality.
-pkg.author: Sterling Hughes <st...@apache.org>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
 
 pkg.deps:

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/libs/os/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/os/pkg.yml b/libs/os/pkg.yml
index 269d052..98eeb3c 100644
--- a/libs/os/pkg.yml
+++ b/libs/os/pkg.yml
@@ -18,11 +18,9 @@
 #
 
 pkg.name: libs/os
-pkg.vers: 0.8.0
 pkg.description: Mynewt operating system core.
-pkg.author: wes3 <wi...@runtime.io>
-pkg.homepage: http://mynewt.apache.org/os/core_os/mynewt_os/
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
 
 pkg.deps:

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/libs/shell/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/shell/pkg.yml b/libs/shell/pkg.yml
index 005577f..dcfc484 100644
--- a/libs/shell/pkg.yml
+++ b/libs/shell/pkg.yml
@@ -18,11 +18,9 @@
 #
 
 pkg.name: libs/shell 
-pkg.vers: 0.8.0
 pkg.description: Command processor for console-based applications.
-pkg.author: Sterling Hughes <st...@apache.org>
-pkg.homepage: http://mynewt.apache.org/os/modules/shell/shell/
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
 
 pkg.deps:

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/libs/testreport/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/testreport/pkg.yml b/libs/testreport/pkg.yml
index 84b82ad..502d2c5 100644
--- a/libs/testreport/pkg.yml
+++ b/libs/testreport/pkg.yml
@@ -18,11 +18,9 @@
 #
 
 pkg.name: libs/testreport
-pkg.vers: 0.8.0
 pkg.description: Library for recording unit test results to flash.
-pkg.author: Christopher Collins <cc...@apache.org>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
     - unit
     - test

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/libs/testutil/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/testutil/pkg.yml b/libs/testutil/pkg.yml
index d1fe7ca..605065e 100644
--- a/libs/testutil/pkg.yml
+++ b/libs/testutil/pkg.yml
@@ -18,11 +18,9 @@
 #
 
 pkg.name: libs/testutil
-pkg.vers: 0.8.0
 pkg.description: Support library for implementing unit tests.
-pkg.author: Christopher Collins <cc...@apache.org>
-pkg.homepage: http://mynewt.apache.org/os/modules/testutil/testutil/
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
     - unit
     - test

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/libs/util/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/util/pkg.yml b/libs/util/pkg.yml
index f61c089..3b37b11 100644
--- a/libs/util/pkg.yml
+++ b/libs/util/pkg.yml
@@ -18,11 +18,9 @@
 #
 
 pkg.name: libs/util
-pkg.vers: 0.8.0
 pkg.description: Library containing miscellaneous utilities.
-pkg.author: Sterling Hughes <st...@apache.org>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
     - base64
     - circular buffer

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/net/nimble/controller/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/controller/pkg.yml b/net/nimble/controller/pkg.yml
index c521aec..f9c3eae 100644
--- a/net/nimble/controller/pkg.yml
+++ b/net/nimble/controller/pkg.yml
@@ -18,11 +18,9 @@
 #
 
 pkg.name: net/nimble/controller
-pkg.vers: 0.8.0
 pkg.description: Controller side of the nimble Bluetooth Smart stack.
-pkg.author: wes3 <wi...@runtime.io>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
     - ble
     - bluetooth

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/net/nimble/drivers/native/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/drivers/native/pkg.yml b/net/nimble/drivers/native/pkg.yml
index 272d2dd..7233638 100644
--- a/net/nimble/drivers/native/pkg.yml
+++ b/net/nimble/drivers/native/pkg.yml
@@ -18,11 +18,9 @@
 #
 
 pkg.name: net/nimble/drivers/native
-pkg.vers: 0.8.0
 pkg.description: BLE driver for simulations.
-pkg.author: wes3 <wi...@runtime.io>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
     - ble
     - bluetooth

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/net/nimble/drivers/nrf51/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/drivers/nrf51/pkg.yml b/net/nimble/drivers/nrf51/pkg.yml
index 1ebfaec..7116f5f 100644
--- a/net/nimble/drivers/nrf51/pkg.yml
+++ b/net/nimble/drivers/nrf51/pkg.yml
@@ -18,11 +18,9 @@
 #
 
 pkg.name: net/nimble/drivers/nrf51
-pkg.vers: 0.8.0
 pkg.description: BLE driver for nRF51 systems.
-pkg.author: wes3 <wi...@runtime.io>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
     - ble
     - bluetooth

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/net/nimble/drivers/nrf52/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/drivers/nrf52/pkg.yml b/net/nimble/drivers/nrf52/pkg.yml
index e4255bb..a087f05 100644
--- a/net/nimble/drivers/nrf52/pkg.yml
+++ b/net/nimble/drivers/nrf52/pkg.yml
@@ -18,11 +18,9 @@
 #
 
 pkg.name: net/nimble/drivers/nrf52
-pkg.vers: 0.8.0
 pkg.description: BLE driver for nRF52 systems.
-pkg.author: wes3 <wi...@runtime.io>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
     - ble
     - bluetooth

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/net/nimble/host/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/host/pkg.yml b/net/nimble/host/pkg.yml
index 27c82cb..e689cad 100644
--- a/net/nimble/host/pkg.yml
+++ b/net/nimble/host/pkg.yml
@@ -18,11 +18,9 @@
 #
 
 pkg.name: net/nimble/host
-pkg.vers: 0.8.0
 pkg.description: Host side of the nimble Bluetooth Smart stack.
-pkg.author: Christopher Collins <cc...@apache.org>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
     - ble
     - bluetooth

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/net/nimble/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/pkg.yml b/net/nimble/pkg.yml
index 70c31b8..ec9a473 100644
--- a/net/nimble/pkg.yml
+++ b/net/nimble/pkg.yml
@@ -18,11 +18,9 @@
 #
 
 pkg.name: net/nimble
-pkg.vers: 0.8.0
 pkg.description: Generic functionality for the nimble Bluetooth Smart stack; used by both the controller and the host.
-pkg.author: wes3 <wi...@runtime.io>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
     - ble
     - bluetooth

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/sys/config/pkg.yml
----------------------------------------------------------------------
diff --git a/sys/config/pkg.yml b/sys/config/pkg.yml
index ff8d87c..b0d7a84 100644
--- a/sys/config/pkg.yml
+++ b/sys/config/pkg.yml
@@ -18,11 +18,9 @@
 #
 
 pkg.name: sys/config
-pkg.vers: 0.8.0
 pkg.description: Configuration management for embedded systems.
-pkg.author: Marko Kiiskila <ma...@apache.org>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
 
 pkg.deps:

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/sys/log/pkg.yml
----------------------------------------------------------------------
diff --git a/sys/log/pkg.yml b/sys/log/pkg.yml
index f7a44e9..1d40b43 100644
--- a/sys/log/pkg.yml
+++ b/sys/log/pkg.yml
@@ -18,11 +18,9 @@
 #
 
 pkg.name: sys/log
-pkg.vers: 0.8.0
 pkg.description: Logging utilities for embedded systems.
-pkg.author: Sterling Hughes <st...@apache.org>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
     - logging
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2fb63deb/sys/stats/pkg.yml
----------------------------------------------------------------------
diff --git a/sys/stats/pkg.yml b/sys/stats/pkg.yml
index 9a6276d..309dbd6 100644
--- a/sys/stats/pkg.yml
+++ b/sys/stats/pkg.yml
@@ -18,11 +18,9 @@
 #
 
 pkg.name: sys/stats
-pkg.vers: 0.8.0
 pkg.description: Statistic tracking utilities for embedded systems.
-pkg.author: Sterling Hughes <st...@apache.org>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
     - statistics
 



[08/42] incubator-mynewt-core git commit: Fix error with names.

Posted by cc...@apache.org.
Fix error with names.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/e880b3c7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/e880b3c7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/e880b3c7

Branch: refs/heads/master
Commit: e880b3c7dd79c8d6bbd5b2c3ab4b40b30230c1b8
Parents: 3b71741
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Wed Mar 9 16:04:49 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Wed Mar 9 16:05:51 2016 -0800

----------------------------------------------------------------------
 fs/fs/pkg.yml      | 2 +-
 libs/shell/pkg.yml | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e880b3c7/fs/fs/pkg.yml
----------------------------------------------------------------------
diff --git a/fs/fs/pkg.yml b/fs/fs/pkg.yml
index f1e0fcd..22c6cff 100644
--- a/fs/fs/pkg.yml
+++ b/fs/fs/pkg.yml
@@ -30,7 +30,7 @@ pkg.keywords:
 
 pkg.deps.SHELL:
     - libs/shell
-pkg.reqs.SHELL:
+pkg.req_apis.SHELL:
     - console
 pkg.cflags.SHELL: -DSHELL_PRESENT
 pkg.features:

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e880b3c7/libs/shell/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/shell/pkg.yml b/libs/shell/pkg.yml
index 8600f68..005577f 100644
--- a/libs/shell/pkg.yml
+++ b/libs/shell/pkg.yml
@@ -28,7 +28,7 @@ pkg.keywords:
 pkg.deps:
     - libs/os
     - libs/util
-pkg.apis:
+pkg.req_apis:
     - console
 pkg.features:
     - SHELL 


[16/42] incubator-mynewt-core git commit: pkg.features: TEST needs to be present for standalone test app.

Posted by cc...@apache.org.
pkg.features: TEST needs to be present for standalone test app.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/b307127a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/b307127a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/b307127a

Branch: refs/heads/master
Commit: b307127ac53afd8b4f7e360d84e3762e8ae8fa0c
Parents: 3aad560
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Mar 10 11:16:22 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Mar 10 11:16:22 2016 -0800

----------------------------------------------------------------------
 apps/test/pkg.yml | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b307127a/apps/test/pkg.yml
----------------------------------------------------------------------
diff --git a/apps/test/pkg.yml b/apps/test/pkg.yml
index d442071..4da07d0 100644
--- a/apps/test/pkg.yml
+++ b/apps/test/pkg.yml
@@ -26,6 +26,8 @@ pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
 pkg.type: app
 pkg.keywords:
 
+pkg.features:
+    - TEST
 pkg.deps:
     - fs/nffs
     - libs/bootutil


[33/42] incubator-mynewt-core git commit: No jira ticket for this commit. Modifying some of how the nimble stack gets initialized and also trying to move configuration options out of the controller code into nimble_opt.h

Posted by cc...@apache.org.
No jira ticket for this commit. Modifying some of how the nimble stack gets initialized and also trying to move configuration options out of the controller code into nimble_opt.h


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/ec4830c9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/ec4830c9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/ec4830c9

Branch: refs/heads/master
Commit: ec4830c93bdd3fd2e10e15535fb1424e70fd56fd
Parents: 9eb699d
Author: wes3 <wi...@micosa.io>
Authored: Fri Mar 11 16:22:21 2016 -0800
Committer: wes3 <wi...@micosa.io>
Committed: Fri Mar 11 16:22:34 2016 -0800

----------------------------------------------------------------------
 apps/bleprph/src/main.c                           | 11 ++++++-----
 apps/bletest/src/main.c                           |  8 ++++----
 apps/bletiny/src/main.c                           |  5 +++--
 net/nimble/controller/include/controller/ble_ll.h |  2 +-
 net/nimble/controller/src/ble_ll.c                | 14 ++++----------
 net/nimble/controller/src/ble_ll_adv.c            | 12 ++----------
 net/nimble/controller/src/ble_ll_hci.c            |  4 ++--
 net/nimble/controller/src/ble_ll_scan.c           | 13 ++++---------
 net/nimble/include/nimble/nimble_opt.h            |  5 +++++
 9 files changed, 31 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ec4830c9/apps/bleprph/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bleprph/src/main.c b/apps/bleprph/src/main.c
index 8824428..a67d4e1 100755
--- a/apps/bleprph/src/main.c
+++ b/apps/bleprph/src/main.c
@@ -56,12 +56,13 @@ struct os_mempool bleprph_mbuf_mpool;
 static struct log_handler bleprph_log_console_handler;
 struct log bleprph_log;
 
-/** Priority of the nimble host task. */
-#define BLEPRPH_BLE_HS_PRIO          (1)
+/** Priority of the nimble host and controller tasks. */
+#define BLE_LL_TASK_PRI             (OS_TASK_PRI_HIGHEST)
+#define BLEPRPH_BLE_HS_PRIO         (1)
 
 /** bleprph task settings. */
-#define BLEPRPH_STACK_SIZE             (OS_STACK_ALIGN(200))
-#define BLEPRPH_TASK_PRIO              (BLEPRPH_BLE_HS_PRIO + 1)
+#define BLEPRPH_STACK_SIZE          (OS_STACK_ALIGN(200))
+#define BLEPRPH_TASK_PRIO           (BLEPRPH_BLE_HS_PRIO + 1)
 
 struct os_eventq bleprph_evq;
 struct os_task bleprph_task;
@@ -268,7 +269,7 @@ main(void)
                  bleprph_stack, BLEPRPH_STACK_SIZE);
 
     /* Initialize the BLE LL */
-    rc = ble_ll_init();
+    rc = ble_ll_init(BLE_LL_TASK_PRI);
     assert(rc == 0);
 
     /* Initialize the BLE host. */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ec4830c9/apps/bletest/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bletest/src/main.c b/apps/bletest/src/main.c
index 8fdc06f..aa0578b 100755
--- a/apps/bletest/src/main.c
+++ b/apps/bletest/src/main.c
@@ -46,7 +46,7 @@
 #include "controller/ble_ll_adv.h"
 
 /* Task priorities */
-/* NOTE: highest priority task (0) reserved for controller LL task */
+#define BLE_LL_TASK_PRI     (OS_TASK_PRI_HIGHEST)
 #define HOST_TASK_PRIO      (OS_TASK_PRI_HIGHEST + 1)
 #define BLETEST_TASK_PRIO   (HOST_TASK_PRIO + 1)
 #define SHELL_TASK_PRIO     (BLETEST_TASK_PRIO + 1)
@@ -90,8 +90,8 @@ os_membuf_t g_mbuf_buffer[MBUF_MEMPOOL_SIZE];
 #define BLETEST_ROLE_ADVERTISER         (0)
 #define BLETEST_ROLE_SCANNER            (1)
 #define BLETEST_ROLE_INITIATOR          (2)
-#define BLETEST_CFG_ROLE                (BLETEST_ROLE_INITIATOR)
-//#define BLETEST_CFG_ROLE                (BLETEST_ROLE_ADVERTISER)
+//#define BLETEST_CFG_ROLE                (BLETEST_ROLE_INITIATOR)
+#define BLETEST_CFG_ROLE                (BLETEST_ROLE_ADVERTISER)
 //#define BLETEST_CFG_ROLE                (BLETEST_ROLE_SCANNER)
 #define BLETEST_CFG_ADV_OWN_ADDR_TYPE   (BLE_HCI_ADV_OWN_ADDR_PUBLIC)
 #define BLETEST_CFG_ADV_PEER_ADDR_TYPE  (BLE_HCI_ADV_PEER_ADDR_PUBLIC)
@@ -833,7 +833,7 @@ init_tasks(void)
     assert(rc == 0);
 
     /* Initialize the BLE LL */
-    rc = ble_ll_init();
+    rc = ble_ll_init(BLE_LL_TASK_PRI);
     assert(rc == 0);
 
     return 0;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ec4830c9/apps/bletiny/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bletiny/src/main.c b/apps/bletiny/src/main.c
index cf482ad..99cfca6 100755
--- a/apps/bletiny/src/main.c
+++ b/apps/bletiny/src/main.c
@@ -47,7 +47,8 @@
 
 #define BSWAP16(x)  ((uint16_t)(((x) << 8) | (((x) & 0xff00) >> 8)))
 
-/* Task 1 */
+/* Nimble task priorities */
+#define BLE_LL_TASK_PRI         (OS_TASK_PRI_HIGHEST)
 #define HOST_TASK_PRIO          (1)
 
 #define SHELL_TASK_PRIO         (3)
@@ -1443,7 +1444,7 @@ main(void)
     assert(rc == 0);
 
     /* Initialize the BLE LL */
-    ble_ll_init();
+    ble_ll_init(BLE_LL_TASK_PRI);
 
     rc = cmd_init();
     assert(rc == 0);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ec4830c9/net/nimble/controller/include/controller/ble_ll.h
----------------------------------------------------------------------
diff --git a/net/nimble/controller/include/controller/ble_ll.h b/net/nimble/controller/include/controller/ble_ll.h
index 8c4d479..8c04be5 100644
--- a/net/nimble/controller/include/controller/ble_ll.h
+++ b/net/nimble/controller/include/controller/ble_ll.h
@@ -287,7 +287,7 @@ struct ble_dev_addr
 
 /*--- External API ---*/
 /* Initialize the Link Layer */
-int ble_ll_init(void);
+int ble_ll_init(uint8_t ll_task_prio);
 
 /* Reset the Link Layer */
 int ble_ll_reset(void);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ec4830c9/net/nimble/controller/src/ble_ll.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll.c b/net/nimble/controller/src/ble_ll.c
index bddc365..54bf2d1 100644
--- a/net/nimble/controller/src/ble_ll.c
+++ b/net/nimble/controller/src/ble_ll.c
@@ -24,6 +24,7 @@
 #include "stats/stats.h"
 #include "bsp/bsp.h"
 #include "nimble/ble.h"
+#include "nimble/nimble_opt.h"
 #include "nimble/hci_common.h"
 #include "controller/ble_phy.h"
 #include "controller/ble_ll.h"
@@ -44,12 +45,6 @@
  * 4) Should look into always disabled the wfr interrupt if we receive the
  * start of a frame. Need to look at the various states to see if this is the
  * right thing to do.
- * 
- * 5) Make sure there is no way we can start a wfr timer and then have
- * whatever event end and not stop the timer. We want to make sure the timer
- * cant fire off unless we are sure that it will fire off when the device is
- * in standby state. At least in standby we are sure no erroneous action will
- * be taken
  */
 
 /* Configuration for supported features */
@@ -98,7 +93,6 @@ STATS_NAME_START(ble_ll_stats)
 STATS_NAME_END(ble_ll_stats)
 
 /* The BLE LL task data structure */
-#define BLE_LL_TASK_PRI     (OS_TASK_PRI_HIGHEST)
 #define BLE_LL_STACK_SIZE   (64)
 struct os_task g_ble_ll_task;
 os_stack_t g_ble_ll_stack[BLE_LL_STACK_SIZE];
@@ -747,7 +741,7 @@ ble_ll_task(void *arg)
     ble_phy_init();
 
     /* Set output power to 1mW (0 dBm) */
-    ble_phy_txpwr_set(0);
+    ble_phy_txpwr_set(NIMBLE_OPT_LL_TX_PWR_DBM);
 
     /* Tell the host that we are ready to receive packets */
     ble_ll_hci_send_noop();
@@ -959,7 +953,7 @@ ble_ll_reset(void)
  * @return int 
  */
 int
-ble_ll_init(void)
+ble_ll_init(uint8_t ll_task_prio)
 {
     int rc;
     uint8_t features;
@@ -1016,7 +1010,7 @@ ble_ll_init(void)
     lldata->ll_supp_features = features;
 
     /* Initialize the LL task */
-    os_task_init(&g_ble_ll_task, "ble_ll", ble_ll_task, NULL, BLE_LL_TASK_PRI, 
+    os_task_init(&g_ble_ll_task, "ble_ll", ble_ll_task, NULL, ll_task_prio, 
                  OS_WAIT_FOREVER, g_ble_ll_stack, BLE_LL_STACK_SIZE);
 
     rc = stats_init_and_reg(STATS_HDR(ble_ll_stats), 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ec4830c9/net/nimble/controller/src/ble_ll_adv.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_adv.c b/net/nimble/controller/src/ble_ll_adv.c
index 352cfb1..59d3eb1 100644
--- a/net/nimble/controller/src/ble_ll_adv.c
+++ b/net/nimble/controller/src/ble_ll_adv.c
@@ -22,6 +22,7 @@
 #include "os/os.h"
 #include "bsp/bsp.h"
 #include "nimble/ble.h"
+#include "nimble/nimble_opt.h"
 #include "nimble/hci_common.h"
 #include "controller/ble_phy.h"
 #include "controller/ble_ll.h"
@@ -33,15 +34,6 @@
 #include "hal/hal_cputime.h"
 #include "hal/hal_gpio.h"
 
-/* 
- * Advertising configuration parameters. These are parameters that I have
- * fixed for now but could be considered "configuration" parameters for either
- * the device or the stack.
- */
-#define BLE_LL_CFG_ADV_PDU_ITVL_HD_USECS    (1250)  /* usecs */
-#define BLE_LL_CFG_ADV_PDU_ITVL_LD_USECS    (10000) /* usecs */
-#define BLE_LL_CFG_ADV_TXPWR                (0)     /* dBm */
-
 /* XXX: TODO
  * 1) Need to look at advertising and scan request PDUs. Do I allocate these
  * once? Do I use a different pool for smaller ones? Do I statically declare
@@ -707,7 +699,7 @@ ble_ll_adv_scheduled(uint32_t sch_start)
 int
 ble_ll_adv_read_txpwr(uint8_t *rspbuf, uint8_t *rsplen)
 {
-    rspbuf[0] = BLE_LL_CFG_ADV_TXPWR;
+    rspbuf[0] = NIMBLE_OPT_LL_TX_PWR_DBM;
     *rsplen = 1;
     return BLE_ERR_SUCCESS;
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ec4830c9/net/nimble/controller/src/ble_ll_hci.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_hci.c b/net/nimble/controller/src/ble_ll_hci.c
index 0e97fdf..5d8eebf 100644
--- a/net/nimble/controller/src/ble_ll_hci.c
+++ b/net/nimble/controller/src/ble_ll_hci.c
@@ -31,8 +31,8 @@
 #include "ble_ll_conn_priv.h"
 
 /* LE event mask */
-uint8_t g_ble_ll_hci_le_event_mask[BLE_HCI_SET_LE_EVENT_MASK_LEN];
-uint8_t g_ble_ll_hci_event_mask[BLE_HCI_SET_EVENT_MASK_LEN];
+static uint8_t g_ble_ll_hci_le_event_mask[BLE_HCI_SET_LE_EVENT_MASK_LEN];
+static uint8_t g_ble_ll_hci_event_mask[BLE_HCI_SET_EVENT_MASK_LEN];
 
 /**
  * ll hci get num cmd pkts 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ec4830c9/net/nimble/controller/src/ble_ll_scan.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_scan.c b/net/nimble/controller/src/ble_ll_scan.c
index 1f6704f..9d74333 100644
--- a/net/nimble/controller/src/ble_ll_scan.c
+++ b/net/nimble/controller/src/ble_ll_scan.c
@@ -36,16 +36,11 @@
 
 /* 
  * XXX:
- * 1) Do I need to know if the address is random or public? Or
- * is there no chance that a public address will match a random
- * address? This applies to checking for advertisers that we have heard a scan 
- * response from or sent an advertising report for.
- * 
- * 2) I think I can guarantee that we dont process things out of order if
+ * 1) I think I can guarantee that we dont process things out of order if
  * I send an event when a scan request is sent. The scan_rsp_pending flag
  * code might be made simpler.
  * 
- * 3) Interleave sending scan requests to different advertisers? I guess I need 
+ * 2) Interleave sending scan requests to different advertisers? I guess I need 
  * a list of advertisers to which I sent a scan request and have yet to
  * receive a scan response from? Implement this.
  */
@@ -70,11 +65,11 @@ struct ble_ll_scan_advertisers
 #define BLE_LL_SC_ADV_F_ADV_RPT_SENT    (0x08)
 
 /* Contains list of advertisers that we have heard scan responses from */
-uint8_t g_ble_ll_scan_num_rsp_advs;
+static uint8_t g_ble_ll_scan_num_rsp_advs;
 struct ble_ll_scan_advertisers g_ble_ll_scan_rsp_advs[BLE_LL_SCAN_CFG_NUM_SCAN_RSP_ADVS];
 
 /* Used to filter duplicate advertising events to host */
-uint8_t g_ble_ll_scan_num_dup_advs;
+static uint8_t g_ble_ll_scan_num_dup_advs;
 struct ble_ll_scan_advertisers g_ble_ll_scan_dup_advs[BLE_LL_SCAN_CFG_NUM_DUP_ADVS];
 
 /* See Vol 6 Part B Section 4.4.3.2. Active scanning backoff */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ec4830c9/net/nimble/include/nimble/nimble_opt.h
----------------------------------------------------------------------
diff --git a/net/nimble/include/nimble/nimble_opt.h b/net/nimble/include/nimble/nimble_opt.h
index cd45bbf..3ab8b27 100644
--- a/net/nimble/include/nimble/nimble_opt.h
+++ b/net/nimble/include/nimble/nimble_opt.h
@@ -182,6 +182,11 @@
 #define NIMBLE_OPT_ATT_SVR_INDICATE             1
 #endif
 
+/** CONTROLLER: transmit power level */
+#ifndef NIMBLE_OPT_LL_TX_PWR_DBM
+#define NIMBLE_OPT_LL_TX_PWR_DBM                0
+#endif
+
 /* Include automatically-generated settings. */
 #include "nimble/nimble_opt_auto.h"
 


[26/42] incubator-mynewt-core git commit: Add assembler path.

Posted by cc...@apache.org.
Add assembler path.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/06bf5d16
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/06bf5d16
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/06bf5d16

Branch: refs/heads/master
Commit: 06bf5d16833ae42a946f5ce73c51f0b12b122ef9
Parents: b0db6dd
Author: Neel Natu <ne...@nahannisys.com>
Authored: Thu Mar 10 21:47:25 2016 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Fri Mar 11 12:16:13 2016 -0800

----------------------------------------------------------------------
 compiler/sim/linux-compiler.yml | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/06bf5d16/compiler/sim/linux-compiler.yml
----------------------------------------------------------------------
diff --git a/compiler/sim/linux-compiler.yml b/compiler/sim/linux-compiler.yml
index 4b70e33..c1618ef 100644
--- a/compiler/sim/linux-compiler.yml
+++ b/compiler/sim/linux-compiler.yml
@@ -18,6 +18,7 @@
 #
 
 compiler.path.cc: "gcc"
+compiler.path.as: "gcc -x assembler-with-cpp"
 compiler.path.archive: "ar"
 compiler.path.objdump: "objdump"
 compiler.path.objsize: "size"


[13/42] incubator-mynewt-core git commit: Add pkg.arch to BSP.

Posted by cc...@apache.org.
Add pkg.arch to BSP.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/64b0daec
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/64b0daec
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/64b0daec

Branch: refs/heads/master
Commit: 64b0daecda40e9536082b85e2d65f2989cbbbb4f
Parents: 9c705a7
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Mar 10 09:02:12 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Mar 10 09:02:12 2016 -0800

----------------------------------------------------------------------
 hw/bsp/native/pkg.yml                     | 1 +
 hw/bsp/nrf51dk-16kbram/pkg.yml            | 1 +
 hw/bsp/nrf51dk/pkg.yml                    | 1 +
 hw/bsp/nrf52pdk/pkg.yml                   | 1 +
 hw/bsp/olimex_stm32-e407_devboard/pkg.yml | 1 +
 5 files changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/64b0daec/hw/bsp/native/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/native/pkg.yml b/hw/bsp/native/pkg.yml
index 47cf4fa..fe8346b 100644
--- a/hw/bsp/native/pkg.yml
+++ b/hw/bsp/native/pkg.yml
@@ -28,6 +28,7 @@ pkg.keywords:
     - native
     - bsp
 
+pkg.arch: sim
 pkg.compiler: compiler/sim
 pkg.deps: 
     - hw/mcu/native

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/64b0daec/hw/bsp/nrf51dk-16kbram/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf51dk-16kbram/pkg.yml b/hw/bsp/nrf51dk-16kbram/pkg.yml
index b0aab54..4d26cf2 100644
--- a/hw/bsp/nrf51dk-16kbram/pkg.yml
+++ b/hw/bsp/nrf51dk-16kbram/pkg.yml
@@ -28,6 +28,7 @@ pkg.keywords:
     - nrf51
     - nrf51dk
 
+pkg.arch: cortex_m0
 pkg.compiler: compiler/arm-none-eabi-m0
 pkg.linkerscript: "nrf51dk-16kbram.ld"
 pkg.linkerscript.bootloader.OVERWRITE: "boot-nrf51dk-16kbram.ld"

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/64b0daec/hw/bsp/nrf51dk/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf51dk/pkg.yml b/hw/bsp/nrf51dk/pkg.yml
index 056b976..a6d888c 100644
--- a/hw/bsp/nrf51dk/pkg.yml
+++ b/hw/bsp/nrf51dk/pkg.yml
@@ -28,6 +28,7 @@ pkg.keywords:
     - nrf51
     - nrf51dk
 
+pkg.arch: cortex_m0
 pkg.compiler: compiler/arm-none-eabi-m0
 pkg.linkerscript: "nrf51dk.ld" 
 pkg.linkerscript.bootloader.OVERWRITE: "boot-nrf51dk.ld"

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/64b0daec/hw/bsp/nrf52pdk/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf52pdk/pkg.yml b/hw/bsp/nrf52pdk/pkg.yml
index b136084..9f68182 100644
--- a/hw/bsp/nrf52pdk/pkg.yml
+++ b/hw/bsp/nrf52pdk/pkg.yml
@@ -28,6 +28,7 @@ pkg.keywords:
     - nrf52
     - nrf52dk
 
+pkg.arch: cortex_m4
 pkg.compiler: compiler/arm-none-eabi-m4
 pkg.linkerscript: "nrf52pdk.ld"
 pkg.linkerscript.bootloader.OVERWRITE: "boot-nrf52pdk.ld"

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/64b0daec/hw/bsp/olimex_stm32-e407_devboard/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/olimex_stm32-e407_devboard/pkg.yml b/hw/bsp/olimex_stm32-e407_devboard/pkg.yml
index 885693e..3d37b94 100644
--- a/hw/bsp/olimex_stm32-e407_devboard/pkg.yml
+++ b/hw/bsp/olimex_stm32-e407_devboard/pkg.yml
@@ -29,6 +29,7 @@ pkg.keywords:
     - stm32
     - e407
 
+pkg.arch: cortex_m4
 pkg.compiler: compiler/arm-none-eabi-m4
 pkg.linkerscript: "olimex_stm32-e407_devboard.ld" 
 pkg.linkerscript.bootloader.OVERWRITE: "boot-olimex_stm32-e407_devboard.ld"


[19/42] incubator-mynewt-core git commit: Clean up.

Posted by cc...@apache.org.
Clean up.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/2e6f78ef
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/2e6f78ef
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/2e6f78ef

Branch: refs/heads/master
Commit: 2e6f78ef3dcd514f27e51b41558bbd7c62bbc361
Parents: ffb1317
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Mar 10 15:45:30 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Mar 10 15:45:30 2016 -0800

----------------------------------------------------------------------
 project.yml | 6 ------
 1 file changed, 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2e6f78ef/project.yml
----------------------------------------------------------------------
diff --git a/project.yml b/project.yml
index 5c30981..1adfca7 100644
--- a/project.yml
+++ b/project.yml
@@ -18,9 +18,3 @@
 #
 
 project.name: "apache-mynewt-core"
-
-repository.apache-mynewt-core:
-    type: github
-    vers: 0-latest
-    user: sterlinghughes
-    repo: incubator-mynewt-core


[02/42] incubator-mynewt-core git commit: Reflect repository name change in yml files. Types in packages. Move projects -> apps.

Posted by cc...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/project/bletiny/src/cmd.c
----------------------------------------------------------------------
diff --git a/project/bletiny/src/cmd.c b/project/bletiny/src/cmd.c
deleted file mode 100644
index ce66a8e..0000000
--- a/project/bletiny/src/cmd.c
+++ /dev/null
@@ -1,1479 +0,0 @@
-/**
- * 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 <errno.h>
-#include <string.h>
-#include "bsp/bsp.h"
-#include "console/console.h"
-#include "shell/shell.h"
-
-#include "nimble/ble.h"
-#include "nimble/hci_common.h"
-#include "host/ble_gap.h"
-#include "host/ble_hs_adv.h"
-#include "../src/ble_l2cap_priv.h"
-
-#include "bletiny_priv.h"
-
-#define CMD_BUF_SZ      256
-
-static int cmd_b_exec(int argc, char **argv);
-static struct shell_cmd cmd_b = {
-    .sc_cmd = "b",
-    .sc_cmd_func = cmd_b_exec
-};
-
-static bssnz_t uint8_t cmd_buf[CMD_BUF_SZ];
-
-/*****************************************************************************
- * $misc                                                                     *
- *****************************************************************************/
-
-static int
-cmd_exec(const struct cmd_entry *cmds, int argc, char **argv)
-{
-    const struct cmd_entry *cmd;
-    int rc;
-
-    if (argc <= 1) {
-        return parse_err_too_few_args(argv[0]);
-    }
-
-    cmd = parse_cmd_find(cmds, argv[1]);
-    if (cmd == NULL) {
-        BLETINY_LOG(ERROR, "Error: unknown %s command: %s\n",
-                    argv[0], argv[1]);
-        return -1;
-    }
-
-    rc = cmd->cb(argc - 1, argv + 1);
-    if (rc != 0) {
-        return rc;
-    }
-
-    return 0;
-}
-
-static void
-cmd_print_dsc(struct bletiny_dsc *dsc)
-{
-    BLETINY_LOG(INFO, "            dsc_handle=%d uuid=", dsc->dsc.handle);
-    print_uuid(dsc->dsc.uuid128);
-    BLETINY_LOG(INFO, "\n");
-}
-
-static void
-cmd_print_chr(struct bletiny_chr *chr)
-{
-    struct bletiny_dsc *dsc;
-
-    BLETINY_LOG(INFO, "        def_handle=%d val_handle=%d properties=0x%02x "
-                      "uuid=", chr->chr.decl_handle, chr->chr.value_handle,
-                chr->chr.properties);
-    print_uuid(chr->chr.uuid128);
-    BLETINY_LOG(INFO, "\n");
-
-    SLIST_FOREACH(dsc, &chr->dscs, next) {
-        cmd_print_dsc(dsc);
-    }
-}
-
-static void
-cmd_print_svc(struct bletiny_svc *svc, int print_chrs)
-{
-    struct bletiny_chr *chr;
-
-    BLETINY_LOG(INFO, "    start=%d end=%d uuid=", svc->svc.start_handle,
-                svc->svc.end_handle);
-    print_uuid(svc->svc.uuid128);
-    BLETINY_LOG(INFO, "\n");
-
-    if (print_chrs) {
-        SLIST_FOREACH(chr, &svc->chrs, next) {
-            cmd_print_chr(chr);
-        }
-    }
-}
-
-static int
-cmd_parse_conn_start_end(uint16_t *out_conn, uint16_t *out_start,
-                         uint16_t *out_end)
-{
-    int rc;
-
-    *out_conn = parse_arg_uint16("conn", &rc);
-    if (rc != 0) {
-        return rc;
-    }
-
-    *out_start = parse_arg_uint16("start", &rc);
-    if (rc != 0) {
-        return rc;
-    }
-
-    *out_end = parse_arg_uint16("end", &rc);
-    if (rc != 0) {
-        return rc;
-    }
-
-    return 0;
-}
-
-/*****************************************************************************
- * $advertise                                                                *
- *****************************************************************************/
-
-static struct kv_pair cmd_adv_conn_modes[] = {
-    { "non", BLE_GAP_CONN_MODE_NON },
-    { "und", BLE_GAP_CONN_MODE_UND },
-    { "dir", BLE_GAP_CONN_MODE_DIR },
-    { NULL }
-};
-
-static struct kv_pair cmd_adv_disc_modes[] = {
-    { "non", BLE_GAP_DISC_MODE_NON },
-    { "ltd", BLE_GAP_DISC_MODE_LTD },
-    { "gen", BLE_GAP_DISC_MODE_GEN },
-    { NULL }
-};
-
-static struct kv_pair cmd_adv_addr_types[] = {
-    { "public", BLE_ADDR_TYPE_PUBLIC },
-    { "random", BLE_ADDR_TYPE_RANDOM },
-    { NULL }
-};
-
-static struct kv_pair cmd_adv_filt_types[] = {
-    { "none", BLE_HCI_ADV_FILT_NONE },
-    { "scan", BLE_HCI_ADV_FILT_SCAN },
-    { "conn", BLE_HCI_ADV_FILT_CONN },
-    { "both", BLE_HCI_ADV_FILT_BOTH },
-};
-
-static int
-cmd_adv(int argc, char **argv)
-{
-    struct hci_adv_params params = {
-        .adv_itvl_min = 0,
-        .adv_itvl_max = 0,
-        .adv_type = BLE_HCI_ADV_TYPE_ADV_IND,
-        .own_addr_type = BLE_HCI_ADV_OWN_ADDR_PUBLIC,
-        .peer_addr_type = BLE_HCI_ADV_PEER_ADDR_PUBLIC,
-        .adv_channel_map = BLE_HCI_ADV_CHANMASK_DEF,
-        .adv_filter_policy = BLE_HCI_ADV_FILT_DEF,
-    };
-    uint8_t peer_addr[6];
-    uint8_t u8;
-    int addr_type;
-    int conn;
-    int disc;
-    int rc;
-
-    if (argc > 1 && strcmp(argv[1], "stop") == 0) {
-        rc = bletiny_adv_stop();
-        if (rc != 0) {
-            BLETINY_LOG(INFO, "advertise stop fail: %d\n", rc);
-            return rc;
-        }
-
-        return 0;
-    }
-
-    conn = parse_arg_kv("conn", cmd_adv_conn_modes);
-    if (conn == -1) {
-        BLETINY_LOG(ERROR, "invalid 'conn' parameter\n");
-        return -1;
-    }
-
-    disc = parse_arg_kv("disc", cmd_adv_disc_modes);
-    if (disc == -1) {
-        BLETINY_LOG(ERROR, "missing 'disc' parameter\n");
-        return -1;
-    }
-
-    if (conn == BLE_GAP_CONN_MODE_DIR) {
-        addr_type = parse_arg_kv("addr_type", cmd_adv_addr_types);
-        if (addr_type == -1) {
-            return -1;
-        }
-
-        rc = parse_arg_mac("addr", peer_addr);
-        if (rc != 0) {
-            return rc;
-        }
-    } else {
-        addr_type = 0;
-        memset(peer_addr, 0, sizeof peer_addr);
-    }
-
-    u8 = parse_arg_long_bounds("chan_map", 0, 0xff, &rc);
-    if (rc == 0) {
-        params.adv_channel_map = u8;
-    } else if (rc != ENOENT) {
-        return rc;
-    }
-
-    if (parse_arg_find("filt") != NULL) {
-        params.adv_filter_policy = parse_arg_kv("filt", cmd_adv_filt_types);
-        if (params.adv_filter_policy == -1) {
-            return EINVAL;
-        }
-    }
-
-    rc = bletiny_adv_start(disc, conn, peer_addr, addr_type, &params);
-    if (rc != 0) {
-        BLETINY_LOG(INFO, "advertise fail: %d\n", rc);
-        return rc;
-    }
-
-    return 0;
-}
-
-/*****************************************************************************
- * $connect                                                                  *
- *****************************************************************************/
-
-static struct kv_pair cmd_conn_addr_types[] = {
-    { "public",         BLE_HCI_CONN_PEER_ADDR_PUBLIC },
-    { "random",         BLE_HCI_CONN_PEER_ADDR_RANDOM },
-    { "public_ident",   BLE_HCI_CONN_PEER_ADDR_PUBLIC_IDENT },
-    { "random_ident",   BLE_HCI_CONN_PEER_ADDR_RANDOM_IDENT },
-    { "wl",             BLE_GAP_ADDR_TYPE_WL },
-    { NULL }
-};
-
-static int
-cmd_conn(int argc, char **argv)
-{
-    struct ble_gap_crt_params params;
-    uint8_t peer_addr[6];
-    int addr_type;
-    int rc;
-
-    if (argc > 1 && strcmp(argv[1], "cancel") == 0) {
-        rc = bletiny_conn_cancel();
-        if (rc != 0) {
-            BLETINY_LOG(INFO, "connection cancel fail: %d\n", rc);
-            return rc;
-        }
-
-        return 0;
-    }
-
-    addr_type = parse_arg_kv("addr_type", cmd_conn_addr_types);
-    if (addr_type == -1) {
-        return -1;
-    }
-
-    if (addr_type != BLE_GAP_ADDR_TYPE_WL) {
-        rc = parse_arg_mac("addr", peer_addr);
-        if (rc != 0) {
-            return rc;
-        }
-    } else {
-        memset(peer_addr, 0, sizeof peer_addr);
-    }
-
-    params.scan_itvl = parse_arg_uint16_dflt("scan_itvl", 0x0010, &rc);
-    if (rc != 0) {
-        return rc;
-    }
-
-    params.scan_window = parse_arg_uint16_dflt("scan_window", 0x0010, &rc);
-    if (rc != 0) {
-        return rc;
-    }
-
-    params.itvl_min = parse_arg_uint16_dflt(
-        "itvl_min", BLE_GAP_INITIAL_CONN_ITVL_MIN, &rc);
-    if (rc != 0) {
-        return rc;
-    }
-
-    params.itvl_max = parse_arg_uint16_dflt(
-        "itvl_max", BLE_GAP_INITIAL_CONN_ITVL_MAX, &rc);
-    if (rc != 0) {
-        return rc;
-    }
-
-    params.latency = parse_arg_uint16_dflt("latency", 0, &rc);
-    if (rc != 0) {
-        return rc;
-    }
-
-    params.supervision_timeout = parse_arg_uint16_dflt("timeout", 0x0100, &rc);
-    if (rc != 0) {
-        return rc;
-    }
-
-    params.min_ce_len = parse_arg_uint16_dflt("min_ce_len", 0x0010, &rc);
-    if (rc != 0) {
-        return rc;
-    }
-
-    params.max_ce_len = parse_arg_uint16_dflt("max_ce_len", 0x0300, &rc);
-    if (rc != 0) {
-        return rc;
-    }
-
-    rc = bletiny_conn_initiate(addr_type, peer_addr, &params);
-    if (rc != 0) {
-        return rc;
-    }
-
-    return 0;
-}
-
-/*****************************************************************************
- * $connect                                                                  *
- *****************************************************************************/
-
-static int
-cmd_chrup(int argc, char **argv)
-{
-    uint16_t attr_handle;
-    int rc;
-
-    attr_handle = parse_arg_long("attr", &rc);
-    if (rc != 0) {
-        return rc;
-    }
-
-    bletiny_chrup(attr_handle);
-
-    return 0;
-}
-
-/*****************************************************************************
- * $discover                                                                 *
- *****************************************************************************/
-
-static int
-cmd_disc_chr(int argc, char **argv)
-{
-    uint16_t start_handle;
-    uint16_t conn_handle;
-    uint16_t end_handle;
-    uint8_t uuid128[16];
-    int rc;
-
-    rc = cmd_parse_conn_start_end(&conn_handle, &start_handle, &end_handle);
-    if (rc != 0) {
-        return rc;
-    }
-
-    rc = parse_arg_uuid("uuid", uuid128);
-    if (rc == 0) {
-        rc = bletiny_disc_chrs_by_uuid(conn_handle, start_handle, end_handle,
-                                        uuid128);
-    } else if (rc == ENOENT) {
-        rc = bletiny_disc_all_chrs(conn_handle, start_handle, end_handle);
-    } else  {
-        return rc;
-    }
-    if (rc != 0) {
-        BLETINY_LOG(INFO, "error discovering characteristics; rc=%d\n", rc);
-        return rc;
-    }
-
-    return 0;
-}
-
-static int
-cmd_disc_dsc(int argc, char **argv)
-{
-    uint16_t start_handle;
-    uint16_t conn_handle;
-    uint16_t end_handle;
-    int rc;
-
-    rc = cmd_parse_conn_start_end(&conn_handle, &start_handle, &end_handle);
-    if (rc != 0) {
-        return rc;
-    }
-
-    rc = bletiny_disc_all_dscs(conn_handle, start_handle, end_handle);
-    if (rc != 0) {
-        BLETINY_LOG(INFO, "error discovering descriptors; rc=%d\n", rc);
-        return rc;
-    }
-
-    return 0;
-}
-
-static int
-cmd_disc_svc(int argc, char **argv)
-{
-    uint8_t uuid128[16];
-    int conn_handle;
-    int rc;
-
-    conn_handle = parse_arg_uint16("conn", &rc);
-    if (rc != 0) {
-        return rc;
-    }
-
-    rc = parse_arg_uuid("uuid", uuid128);
-    if (rc == 0) {
-        rc = bletiny_disc_svc_by_uuid(conn_handle, uuid128);
-    } else if (rc == ENOENT) {
-        rc = bletiny_disc_svcs(conn_handle);
-    } else  {
-        return rc;
-    }
-
-    if (rc != 0) {
-        BLETINY_LOG(INFO, "error discovering services; rc=%d\n", rc);
-        return rc;
-    }
-
-    return 0;
-}
-
-static struct cmd_entry cmd_disc_entries[] = {
-    { "chr", cmd_disc_chr },
-    { "dsc", cmd_disc_dsc },
-    { "svc", cmd_disc_svc },
-    { NULL, NULL }
-};
-
-static int
-cmd_disc(int argc, char **argv)
-{
-    int rc;
-
-    rc = cmd_exec(cmd_disc_entries, argc, argv);
-    if (rc != 0) {
-        return rc;
-    }
-
-    return 0;
-}
-
-/*****************************************************************************
- * $find                                                                     *
- *****************************************************************************/
-
-static int
-cmd_find_inc_svcs(int argc, char **argv)
-{
-    uint16_t start_handle;
-    uint16_t conn_handle;
-    uint16_t end_handle;
-    int rc;
-
-    rc = cmd_parse_conn_start_end(&conn_handle, &start_handle, &end_handle);
-    if (rc != 0) {
-        return rc;
-    }
-
-    rc = bletiny_find_inc_svcs(conn_handle, start_handle, end_handle);
-    if (rc != 0) {
-        BLETINY_LOG(INFO, "error finding included services; rc=%d\n", rc);
-        return rc;
-    }
-
-    return 0;
-}
-
-static const struct cmd_entry cmd_find_entries[] = {
-    { "inc_svcs", cmd_find_inc_svcs },
-    { NULL, NULL }
-};
-
-static int
-cmd_find(int argc, char **argv)
-{
-    int rc;
-
-    rc = cmd_exec(cmd_find_entries, argc, argv);
-    if (rc != 0) {
-        return rc;
-    }
-
-    return 0;
-}
-
-/*****************************************************************************
- * $l2cap                                                                    *
- *****************************************************************************/
-
-static int
-cmd_l2cap_update(int argc, char **argv)
-{
-    struct ble_l2cap_sig_update_params params;
-    uint16_t conn_handle;
-    int rc;
-
-    conn_handle = parse_arg_uint16("conn", &rc);
-    if (rc != 0) {
-        return rc;
-    }
-
-    params.itvl_min = parse_arg_uint16_dflt(
-        "itvl_min", BLE_GAP_INITIAL_CONN_ITVL_MIN, &rc);
-    if (rc != 0) {
-        return rc;
-    }
-
-    params.itvl_max = parse_arg_uint16_dflt(
-        "itvl_max", BLE_GAP_INITIAL_CONN_ITVL_MAX, &rc);
-    if (rc != 0) {
-        return rc;
-    }
-
-    params.slave_latency = parse_arg_uint16_dflt("latency", 0, &rc);
-    if (rc != 0) {
-        return rc;
-    }
-
-    params.timeout_multiplier = parse_arg_uint16_dflt("timeout", 0x0100, &rc);
-    if (rc != 0) {
-        return rc;
-    }
-
-    rc = bletiny_l2cap_update(conn_handle, &params);
-    if (rc != 0) {
-        BLETINY_LOG(INFO, "error txing l2cap update; rc=%d\n", rc);
-        return rc;
-    }
-
-    return 0;
-}
-
-static const struct cmd_entry cmd_l2cap_entries[] = {
-    { "update", cmd_l2cap_update },
-    { NULL, NULL }
-};
-
-static int
-cmd_l2cap(int argc, char **argv)
-{
-    int rc;
-
-    rc = cmd_exec(cmd_l2cap_entries, argc, argv);
-    if (rc != 0) {
-        return rc;
-    }
-
-    return 0;
-}
-
-/*****************************************************************************
- * $mtu                                                                      *
- *****************************************************************************/
-
-static int
-cmd_mtu(int argc, char **argv)
-{
-    uint16_t conn_handle;
-    int rc;
-
-    conn_handle = parse_arg_uint16("conn", &rc);
-    if (rc != 0) {
-        return rc;
-    }
-
-    rc = bletiny_exchange_mtu(conn_handle);
-    if (rc != 0) {
-        BLETINY_LOG(INFO, "error exchanging mtu; rc=%d\n", rc);
-        return rc;
-    }
-
-    return 0;
-}
-
-/*****************************************************************************
- * $read                                                                     *
- *****************************************************************************/
-
-#define CMD_READ_MAX_ATTRS  8
-
-static int
-cmd_read(int argc, char **argv)
-{
-    static uint16_t attr_handles[CMD_READ_MAX_ATTRS];
-    uint16_t conn_handle;
-    uint16_t start;
-    uint16_t end;
-    uint8_t uuid128[16];
-    uint8_t num_attr_handles;
-    int is_uuid;
-    int is_long;
-    int rc;
-
-    conn_handle = parse_arg_uint16("conn", &rc);
-    if (rc != 0) {
-        return rc;
-    }
-
-    is_long = parse_arg_long("long", &rc);
-    if (rc == ENOENT) {
-        is_long = 0;
-    } else if (rc != 0) {
-        return rc;
-    }
-
-    for (num_attr_handles = 0;
-         num_attr_handles < CMD_READ_MAX_ATTRS;
-         num_attr_handles++) {
-
-        attr_handles[num_attr_handles] = parse_arg_uint16("attr", &rc);
-        if (rc == ENOENT) {
-            break;
-        } else if (rc != 0) {
-            return rc;
-        }
-    }
-
-    rc = parse_arg_uuid("uuid", uuid128);
-    if (rc == ENOENT) {
-        is_uuid = 0;
-    } else if (rc == 0) {
-        is_uuid = 1;
-    } else {
-        return rc;
-    }
-
-    start = parse_arg_uint16("start", &rc);
-    if (rc == ENOENT) {
-        start = 0;
-    } else if (rc != 0) {
-        return rc;
-    }
-
-    end = parse_arg_uint16("end", &rc);
-    if (rc == ENOENT) {
-        end = 0;
-    } else if (rc != 0) {
-        return rc;
-    }
-
-    if (num_attr_handles == 1) {
-        if (is_long) {
-            rc = bletiny_read_long(conn_handle, attr_handles[0]);
-        } else {
-            rc = bletiny_read(conn_handle, attr_handles[0]);
-        }
-    } else if (num_attr_handles > 1) {
-        rc = bletiny_read_mult(conn_handle, attr_handles, num_attr_handles);
-    } else if (is_uuid) {
-        if (start == 0 || end == 0) {
-            rc = EINVAL;
-        } else {
-            rc = bletiny_read_by_uuid(conn_handle, start, end, uuid128);
-        }
-    } else {
-        rc = EINVAL;
-    }
-
-    if (rc != 0) {
-        BLETINY_LOG(INFO, "error reading characteristic; rc=%d\n", rc);
-        return rc;
-    }
-
-    return 0;
-}
-
-/*****************************************************************************
- * $scan                                                                     *
- *****************************************************************************/
-
-static struct kv_pair cmd_scan_disc_modes[] = {
-    { "ltd", BLE_GAP_DISC_MODE_LTD },
-    { "gen", BLE_GAP_DISC_MODE_GEN },
-    { NULL }
-};
-
-static struct kv_pair cmd_scan_types[] = {
-    { "passive", BLE_HCI_SCAN_TYPE_PASSIVE },
-    { "active", BLE_HCI_SCAN_TYPE_ACTIVE },
-    { NULL }
-};
-
-static struct kv_pair cmd_scan_filt_policies[] = {
-    { "no_wl", BLE_HCI_SCAN_FILT_NO_WL },
-    { "use_wl", BLE_HCI_SCAN_FILT_USE_WL },
-    { "no_wl_inita", BLE_HCI_SCAN_FILT_NO_WL_INITA },
-    { "use_wl_inita", BLE_HCI_SCAN_FILT_USE_WL_INITA },
-    { NULL }
-};
-
-static int
-cmd_scan(int argc, char **argv)
-{
-    uint32_t dur;
-    int disc;
-    int type;
-    int filt;
-    int rc;
-
-    dur = parse_arg_uint16("dur", &rc);
-    if (rc != 0) {
-        return rc;
-    }
-
-    disc = parse_arg_kv("disc", cmd_scan_disc_modes);
-    if (disc == -1) {
-        return EINVAL;
-    }
-
-    type = parse_arg_kv("type", cmd_scan_types);
-    if (type == -1) {
-        return EINVAL;
-    }
-
-    filt = parse_arg_kv("filt", cmd_scan_filt_policies);
-    if (disc == -1) {
-        return EINVAL;
-    }
-
-    rc = bletiny_scan(dur, disc, type, filt);
-    if (rc != 0) {
-        BLETINY_LOG(INFO, "error scanning; rc=%d\n", rc);
-        return rc;
-    }
-
-    return 0;
-}
-
-/*****************************************************************************
- * $show                                                                     *
- *****************************************************************************/
-
-static int
-cmd_show_addr(int argc, char **argv)
-{
-    bletiny_lock();
-
-    BLETINY_LOG(INFO, "myaddr=");
-    print_addr(g_dev_addr);
-    BLETINY_LOG(INFO, "\n");
-
-    bletiny_unlock();
-
-    return 0;
-}
-
-static int
-cmd_show_chr(int argc, char **argv)
-{
-    struct bletiny_conn *conn;
-    struct bletiny_svc *svc;
-    int i;
-
-    bletiny_lock();
-
-    for (i = 0; i < bletiny_num_conns; i++) {
-        conn = bletiny_conns + i;
-
-        BLETINY_LOG(INFO, "CONNECTION: handle=%d addr=", conn->handle);
-        print_addr(conn->addr);
-        BLETINY_LOG(INFO, "\n");
-
-        SLIST_FOREACH(svc, &conn->svcs, next) {
-            cmd_print_svc(svc, 1);
-        }
-    }
-
-    bletiny_unlock();
-
-    return 0;
-}
-
-static int
-cmd_show_conn(int argc, char **argv)
-{
-    struct bletiny_conn *conn;
-    int i;
-
-    bletiny_lock();
-
-    for (i = 0; i < bletiny_num_conns; i++) {
-        conn = bletiny_conns + i;
-
-        BLETINY_LOG(INFO, "handle=%d addr=", conn->handle);
-        print_addr(conn->addr);
-        BLETINY_LOG(INFO, " addr_type=%d\n", conn->addr_type);
-    }
-
-    bletiny_unlock();
-
-    return 0;
-}
-
-static int
-cmd_show_rssi(int argc, char **argv)
-{
-    uint16_t conn_handle;
-    int rc;
-
-    conn_handle = parse_arg_uint16("conn", &rc);
-    if (rc != 0) {
-        return rc;
-    }
-
-    rc = bletiny_show_rssi(conn_handle);
-    if (rc != 0) {
-        return rc;
-    }
-
-    return 0;
-}
-
-static int
-cmd_show_svc(int argc, char **argv)
-{
-    struct bletiny_conn *conn;
-    struct bletiny_svc *svc;
-    int i;
-
-    bletiny_lock();
-
-    for (i = 0; i < bletiny_num_conns; i++) {
-        conn = bletiny_conns + i;
-
-        BLETINY_LOG(INFO, "CONNECTION: handle=%d addr=", conn->handle);
-        print_addr(conn->addr);
-        BLETINY_LOG(INFO, "\n");
-
-        SLIST_FOREACH(svc, &conn->svcs, next) {
-            cmd_print_svc(svc, 0);
-        }
-    }
-
-    bletiny_unlock();
-
-    return 0;
-}
-
-static struct cmd_entry cmd_show_entries[] = {
-    { "addr", cmd_show_addr },
-    { "chr", cmd_show_chr },
-    { "conn", cmd_show_conn },
-    { "rssi", cmd_show_rssi },
-    { "svc", cmd_show_svc },
-    { NULL, NULL }
-};
-
-static int
-cmd_show(int argc, char **argv)
-{
-    int rc;
-
-    rc = cmd_exec(cmd_show_entries, argc, argv);
-    if (rc != 0) {
-        return rc;
-    }
-
-    return 0;
-}
-
-/*****************************************************************************
- * $set                                                                      *
- *****************************************************************************/
-
-#define CMD_ADV_DATA_MAX_UUIDS16                8
-#define CMD_ADV_DATA_MAX_UUIDS32                8
-#define CMD_ADV_DATA_MAX_UUIDS128               8
-#define CMD_ADV_DATA_MAX_PUBLIC_TGT_ADDRS       8
-#define CMD_ADV_DATA_SVC_DATA_UUID16_MAX_LEN    32
-#define CMD_ADV_DATA_SVC_DATA_UUID32_MAX_LEN    32
-#define CMD_ADV_DATA_SVC_DATA_UUID128_MAX_LEN   32
-#define CMD_ADV_DATA_URI_MAX_LEN                32
-#define CMD_ADV_DATA_MFG_DATA_MAX_LEN           32
-
-static int
-cmd_set_adv_data(void)
-{
-    static bssnz_t uint16_t uuids16[CMD_ADV_DATA_MAX_UUIDS16];
-    static bssnz_t uint32_t uuids32[CMD_ADV_DATA_MAX_UUIDS32];
-    static bssnz_t uint8_t uuids128[CMD_ADV_DATA_MAX_UUIDS128][16];
-    static bssnz_t uint8_t
-        public_tgt_addrs[CMD_ADV_DATA_MAX_PUBLIC_TGT_ADDRS]
-                        [BLE_HS_ADV_PUBLIC_TGT_ADDR_ENTRY_LEN];
-    static bssnz_t uint8_t device_class[BLE_HS_ADV_DEVICE_CLASS_LEN];
-    static bssnz_t uint8_t slave_itvl_range[BLE_HS_ADV_SLAVE_ITVL_RANGE_LEN];
-    static bssnz_t uint8_t
-        svc_data_uuid16[CMD_ADV_DATA_SVC_DATA_UUID16_MAX_LEN];
-    static bssnz_t uint8_t
-        svc_data_uuid32[CMD_ADV_DATA_SVC_DATA_UUID32_MAX_LEN];
-    static bssnz_t uint8_t
-        svc_data_uuid128[CMD_ADV_DATA_SVC_DATA_UUID128_MAX_LEN];
-    static bssnz_t uint8_t le_addr[BLE_HS_ADV_LE_ADDR_LEN];
-    static bssnz_t uint8_t uri[CMD_ADV_DATA_URI_MAX_LEN];
-    static bssnz_t uint8_t mfg_data[CMD_ADV_DATA_MFG_DATA_MAX_LEN];
-    struct ble_hs_adv_fields adv_fields;
-    uint32_t uuid32;
-    uint16_t uuid16;
-    uint8_t uuid128[16];
-    uint8_t public_tgt_addr[BLE_HS_ADV_PUBLIC_TGT_ADDR_ENTRY_LEN];
-    int svc_data_uuid16_len;
-    int svc_data_uuid32_len;
-    int svc_data_uuid128_len;
-    int uri_len;
-    int mfg_data_len;
-    int tmp;
-    int rc;
-
-    memset(&adv_fields, 0, sizeof adv_fields);
-
-    while (1) {
-        uuid16 = parse_arg_uint16("uuid16", &rc);
-        if (rc == 0) {
-            if (adv_fields.num_uuids16 >= CMD_ADV_DATA_MAX_UUIDS16) {
-                return EINVAL;
-            }
-            uuids16[adv_fields.num_uuids16] = uuid16;
-            adv_fields.num_uuids16++;
-        } else if (rc == ENOENT) {
-            break;
-        } else {
-            return rc;
-        }
-    }
-    if (adv_fields.num_uuids16 > 0) {
-        adv_fields.uuids16 = uuids16;
-    }
-
-    tmp = parse_arg_long("uuids16_is_complete", &rc);
-    if (rc == 0) {
-        adv_fields.uuids16_is_complete = !!tmp;
-    } else if (rc != ENOENT) {
-        return rc;
-    }
-
-    while (1) {
-        uuid32 = parse_arg_uint32("uuid32", &rc);
-        if (rc == 0) {
-            if (adv_fields.num_uuids32 >= CMD_ADV_DATA_MAX_UUIDS32) {
-                return EINVAL;
-            }
-            uuids32[adv_fields.num_uuids32] = uuid32;
-            adv_fields.num_uuids32++;
-        } else if (rc == ENOENT) {
-            break;
-        } else {
-            return rc;
-        }
-    }
-    if (adv_fields.num_uuids32 > 0) {
-        adv_fields.uuids32 = uuids32;
-    }
-
-    tmp = parse_arg_long("uuids32_is_complete", &rc);
-    if (rc == 0) {
-        adv_fields.uuids32_is_complete = !!tmp;
-    } else if (rc != ENOENT) {
-        return rc;
-    }
-
-    while (1) {
-        rc = parse_arg_byte_stream_exact_length("uuid128", uuid128, 16);
-        if (rc == 0) {
-            if (adv_fields.num_uuids128 >= CMD_ADV_DATA_MAX_UUIDS128) {
-                return EINVAL;
-            }
-            memcpy(uuids128[adv_fields.num_uuids128], uuid128, 16);
-            adv_fields.num_uuids128++;
-        } else if (rc == ENOENT) {
-            break;
-        } else {
-            return rc;
-        }
-    }
-    if (adv_fields.num_uuids128 > 0) {
-        adv_fields.uuids128 = uuids128;
-    }
-
-    tmp = parse_arg_long("uuids128_is_complete", &rc);
-    if (rc == 0) {
-        adv_fields.uuids128_is_complete = !!tmp;
-    } else if (rc != ENOENT) {
-        return rc;
-    }
-
-    adv_fields.name = (uint8_t *)parse_arg_find("name");
-    if (adv_fields.name != NULL) {
-        adv_fields.name_len = strlen((char *)adv_fields.name);
-    }
-
-    tmp = parse_arg_long_bounds("tx_pwr_lvl", 0, 0xff, &rc);
-    if (rc == 0) {
-        adv_fields.tx_pwr_lvl = tmp;
-        adv_fields.tx_pwr_lvl_is_present = 1;
-    } else if (rc != ENOENT) {
-        return rc;
-    }
-
-    rc = parse_arg_byte_stream_exact_length("device_class", device_class,
-                                            BLE_HS_ADV_DEVICE_CLASS_LEN);
-    if (rc == 0) {
-        adv_fields.device_class = device_class;
-    } else if (rc != ENOENT) {
-        return rc;
-    }
-
-    rc = parse_arg_byte_stream_exact_length("slave_itvl_range",
-                                            slave_itvl_range,
-                                            BLE_HS_ADV_SLAVE_ITVL_RANGE_LEN);
-    if (rc == 0) {
-        adv_fields.slave_itvl_range = slave_itvl_range;
-    } else if (rc != ENOENT) {
-        return rc;
-    }
-
-    rc = parse_arg_byte_stream("svc_data_uuid16",
-                               CMD_ADV_DATA_SVC_DATA_UUID16_MAX_LEN,
-                               svc_data_uuid16, &svc_data_uuid16_len);
-    if (rc == 0) {
-        adv_fields.svc_data_uuid16 = svc_data_uuid16;
-        adv_fields.svc_data_uuid16_len = svc_data_uuid16_len;
-    } else if (rc != ENOENT) {
-        return rc;
-    }
-
-    while (1) {
-        rc = parse_arg_byte_stream_exact_length(
-            "public_tgt_addr", public_tgt_addr,
-            BLE_HS_ADV_PUBLIC_TGT_ADDR_ENTRY_LEN);
-        if (rc == 0) {
-            if (adv_fields.num_public_tgt_addrs >=
-                CMD_ADV_DATA_MAX_PUBLIC_TGT_ADDRS) {
-
-                return EINVAL;
-            }
-            memcpy(public_tgt_addrs[adv_fields.num_public_tgt_addrs],
-                   public_tgt_addr, BLE_HS_ADV_PUBLIC_TGT_ADDR_ENTRY_LEN);
-            adv_fields.num_public_tgt_addrs++;
-        } else if (rc == ENOENT) {
-            break;
-        } else {
-            return rc;
-        }
-    }
-    if (adv_fields.num_public_tgt_addrs > 0) {
-        adv_fields.public_tgt_addr = (void *)public_tgt_addrs;
-    }
-
-    adv_fields.appearance = parse_arg_uint16("appearance", &rc);
-    if (rc == 0) {
-        adv_fields.appearance_is_present = 1;
-    } else if (rc != ENOENT) {
-        return rc;
-    }
-
-    adv_fields.adv_itvl = parse_arg_uint16("adv_itvl", &rc);
-    if (rc == 0) {
-        adv_fields.adv_itvl_is_present = 1;
-    } else if (rc != ENOENT) {
-        return rc;
-    }
-
-    rc = parse_arg_byte_stream_exact_length("le_addr", le_addr,
-                                            BLE_HS_ADV_LE_ADDR_LEN);
-    if (rc == 0) {
-        adv_fields.le_addr = le_addr;
-    } else if (rc != ENOENT) {
-        return rc;
-    }
-
-    adv_fields.le_role = parse_arg_long_bounds("le_role", 0, 0xff, &rc);
-    if (rc == 0) {
-        adv_fields.le_role_is_present = 1;
-    } else if (rc != ENOENT) {
-        return rc;
-    }
-
-    rc = parse_arg_byte_stream("svc_data_uuid32",
-                               CMD_ADV_DATA_SVC_DATA_UUID32_MAX_LEN,
-                               svc_data_uuid32, &svc_data_uuid32_len);
-    if (rc == 0) {
-        adv_fields.svc_data_uuid32 = svc_data_uuid32;
-        adv_fields.svc_data_uuid32_len = svc_data_uuid32_len;
-    } else if (rc != ENOENT) {
-        return rc;
-    }
-
-    rc = parse_arg_byte_stream("svc_data_uuid128",
-                               CMD_ADV_DATA_SVC_DATA_UUID128_MAX_LEN,
-                               svc_data_uuid128, &svc_data_uuid128_len);
-    if (rc == 0) {
-        adv_fields.svc_data_uuid128 = svc_data_uuid128;
-        adv_fields.svc_data_uuid128_len = svc_data_uuid128_len;
-    } else if (rc != ENOENT) {
-        return rc;
-    }
-
-    rc = parse_arg_byte_stream("uri", CMD_ADV_DATA_URI_MAX_LEN, uri, &uri_len);
-    if (rc == 0) {
-        adv_fields.uri = uri;
-        adv_fields.uri_len = uri_len;
-    } else if (rc != ENOENT) {
-        return rc;
-    }
-
-    rc = parse_arg_byte_stream("mfg_data", CMD_ADV_DATA_MFG_DATA_MAX_LEN,
-                               mfg_data, &mfg_data_len);
-    if (rc == 0) {
-        adv_fields.mfg_data = mfg_data;
-        adv_fields.mfg_data_len = mfg_data_len;
-    } else if (rc != ENOENT) {
-        return rc;
-    }
-
-    rc = bletiny_set_adv_data(&adv_fields);
-    if (rc != 0) {
-        BLETINY_LOG(INFO, "error setting advertisement data; rc=%d\n", rc);
-        return rc;
-    }
-
-    return 0;
-}
-
-static int
-cmd_set(int argc, char **argv)
-{
-    uint16_t mtu;
-    uint8_t addr[6];
-    int good;
-    int rc;
-
-    if (argc > 1 && strcmp(argv[1], "adv_data") == 0) {
-        rc = cmd_set_adv_data();
-        return rc;
-    }
-
-    good = 0;
-
-    rc = parse_arg_mac("addr", addr);
-    if (rc == 0) {
-        good = 1;
-        memcpy(g_dev_addr, addr, 6);
-    } else if (rc != ENOENT) {
-        return rc;
-    }
-
-    mtu = parse_arg_uint16("mtu", &rc);
-    if (rc == 0) {
-        rc = ble_att_set_preferred_mtu(mtu);
-        if (rc == 0) {
-            good = 1;
-        }
-    } else if (rc != ENOENT) {
-        return rc;
-    }
-
-    if (!good) {
-        BLETINY_LOG(ERROR, "Error: no valid settings specified\n");
-        return -1;
-    }
-
-    return 0;
-}
-
-/*****************************************************************************
- * $terminate                                                                *
- *****************************************************************************/
-
-static int
-cmd_term(int argc, char **argv)
-{
-    uint16_t conn_handle;
-    int rc;
-
-    conn_handle = parse_arg_uint16("conn", &rc);
-    if (rc != 0) {
-        return rc;
-    }
-
-    rc = bletiny_term_conn(conn_handle);
-    if (rc != 0) {
-        BLETINY_LOG(INFO, "error terminating connection; rc=%d\n", rc);
-        return rc;
-    }
-
-    return 0;
-}
-
-/*****************************************************************************
- * $update connection parameters                                             *
- *****************************************************************************/
-
-static int
-cmd_update(int argc, char **argv)
-{
-    struct ble_gap_upd_params params;
-    uint16_t conn_handle;
-    int rc;
-
-    conn_handle = parse_arg_uint16("conn", &rc);
-    if (rc != 0) {
-        return rc;
-    }
-
-    params.itvl_min = parse_arg_uint16_dflt(
-        "itvl_min", BLE_GAP_INITIAL_CONN_ITVL_MIN, &rc);
-    if (rc != 0) {
-        return rc;
-    }
-
-    params.itvl_max = parse_arg_uint16_dflt(
-        "itvl_max", BLE_GAP_INITIAL_CONN_ITVL_MAX, &rc);
-    if (rc != 0) {
-        return rc;
-    }
-
-    params.latency = parse_arg_uint16_dflt("latency", 0, &rc);
-    if (rc != 0) {
-        return rc;
-    }
-
-    params.supervision_timeout = parse_arg_uint16_dflt("timeout", 0x0100, &rc);
-    if (rc != 0) {
-        return rc;
-    }
-
-    params.min_ce_len = parse_arg_uint16_dflt("min_ce_len", 0x0010, &rc);
-    if (rc != 0) {
-        return rc;
-    }
-
-    params.max_ce_len = parse_arg_uint16_dflt("max_ce_len", 0x0300, &rc);
-    if (rc != 0) {
-        return rc;
-    }
-
-    rc = bletiny_update_conn(conn_handle, &params);
-    if (rc != 0) {
-        BLETINY_LOG(INFO, "error updating connection; rc=%d\n", rc);
-        return rc;
-    }
-
-    return 0;
-}
-
-/*****************************************************************************
- * $white list                                                               *
- *****************************************************************************/
-
-static struct kv_pair cmd_wl_addr_types[] = {
-    { "public",         BLE_HCI_CONN_PEER_ADDR_PUBLIC },
-    { "random",         BLE_HCI_CONN_PEER_ADDR_RANDOM },
-    { NULL }
-};
-
-#define CMD_WL_MAX_SZ   8
-
-static int
-cmd_wl(int argc, char **argv)
-{
-    static struct ble_gap_white_entry white_list[CMD_WL_MAX_SZ];
-    uint8_t addr_type;
-    uint8_t addr[6];
-    int wl_cnt;
-    int rc;
-
-    wl_cnt = 0;
-    while (1) {
-        if (wl_cnt >= CMD_WL_MAX_SZ) {
-            return EINVAL;
-        }
-
-        rc = parse_arg_mac("addr", addr);
-        if (rc == ENOENT) {
-            break;
-        } else if (rc != 0) {
-            return rc;
-        }
-
-        addr_type = parse_arg_kv("addr_type", cmd_wl_addr_types);
-        if (addr_type == -1) {
-            return EINVAL;
-        }
-
-        memcpy(white_list[wl_cnt].addr, addr, 6);
-        white_list[wl_cnt].addr_type = addr_type;
-        wl_cnt++;
-    }
-
-    if (wl_cnt == 0) {
-        return EINVAL;
-    }
-
-    bletiny_wl_set(white_list, wl_cnt);
-
-    return 0;
-}
-
-/*****************************************************************************
- * $write                                                                    *
- *****************************************************************************/
-
-#define CMD_WRITE_MAX_ATTRS 16
-
-static int
-cmd_write(int argc, char **argv)
-{
-    static struct ble_gatt_attr attrs[CMD_WRITE_MAX_ATTRS];
-    uint16_t attr_handle;
-    uint16_t conn_handle;
-    int total_attr_len;
-    int num_attrs;
-    int attr_len;
-    int is_long;
-    int no_rsp;
-    int rc;
-
-    conn_handle = parse_arg_uint16("conn", &rc);
-    if (rc != 0) {
-        return rc;
-    }
-
-    no_rsp = parse_arg_long("no_rsp", &rc);
-    if (rc == ENOENT) {
-        no_rsp = 0;
-    } else if (rc != 0) {
-        return rc;
-    }
-
-    is_long = parse_arg_long("long", &rc);
-    if (rc == ENOENT) {
-        is_long = 0;
-    } else if (rc != 0) {
-        return rc;
-    }
-
-    total_attr_len = 0;
-    num_attrs = 0;
-    while (1) {
-        attr_handle = parse_arg_long("attr", &rc);
-        if (rc == ENOENT) {
-            break;
-        } else if (rc != 0) {
-            return rc;
-        }
-
-        rc = parse_arg_byte_stream("value", sizeof cmd_buf - total_attr_len,
-                                   cmd_buf + total_attr_len, &attr_len);
-        if (rc == ENOENT) {
-            break;
-        } else if (rc != 0) {
-            return rc;
-        }
-
-        if (num_attrs >= CMD_WRITE_MAX_ATTRS) {
-            return EINVAL;
-        }
-
-        attrs[num_attrs].handle = attr_handle;
-        attrs[num_attrs].offset = 0;
-        attrs[num_attrs].value_len = attr_len;
-        attrs[num_attrs].value = cmd_buf + total_attr_len;
-
-        total_attr_len += attr_len;
-        num_attrs++;
-    }
-
-    if (no_rsp) {
-        if (num_attrs != 1) {
-            return EINVAL;
-        }
-        rc = bletiny_write_no_rsp(conn_handle, attrs[0].handle,
-                                   attrs[0].value, attrs[0].value_len);
-    } else if (is_long) {
-        if (num_attrs != 1) {
-            return EINVAL;
-        }
-        rc = bletiny_write_long(conn_handle, attrs[0].handle,
-                                 attrs[0].value, attrs[0].value_len);
-    } else if (num_attrs > 1) {
-        rc = bletiny_write_reliable(conn_handle, attrs, num_attrs);
-    } else if (num_attrs == 1) {
-        rc = bletiny_write(conn_handle, attrs[0].handle,
-                            attrs[0].value, attrs[0].value_len);
-    } else {
-        return EINVAL;
-    }
-
-    if (rc != 0) {
-        BLETINY_LOG(INFO, "error writing characteristic; rc=%d\n", rc);
-        return rc;
-    }
-
-    return 0;
-}
-
-/*****************************************************************************
- * $init                                                                     *
- *****************************************************************************/
-
-static struct cmd_entry cmd_b_entries[] = {
-    { "adv",        cmd_adv },
-    { "conn",       cmd_conn },
-    { "chrup",      cmd_chrup },
-    { "disc",       cmd_disc },
-    { "find",       cmd_find },
-    { "l2cap",      cmd_l2cap },
-    { "mtu",        cmd_mtu },
-    { "read",       cmd_read },
-    { "scan",       cmd_scan },
-    { "show",       cmd_show },
-    { "set",        cmd_set },
-    { "term",       cmd_term },
-    { "update",     cmd_update },
-    { "wl",         cmd_wl },
-    { "write",      cmd_write },
-    { NULL, NULL }
-};
-
-static int
-cmd_b_exec(int argc, char **argv)
-{
-    int rc;
-
-    rc = parse_arg_all(argc - 1, argv + 1);
-    if (rc != 0) {
-        goto done;
-    }
-
-    rc = cmd_exec(cmd_b_entries, argc, argv);
-    if (rc != 0) {
-        BLETINY_LOG(ERROR, "error\n");
-        goto done;
-    }
-
-    rc = 0;
-
-done:
-    return rc;
-}
-
-int
-cmd_init(void)
-{
-    int rc;
-
-    rc = shell_cmd_register(&cmd_b);
-    if (rc != 0) {
-        return rc;
-    }
-
-    return 0;
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/project/bletiny/src/main.c
----------------------------------------------------------------------
diff --git a/project/bletiny/src/main.c b/project/bletiny/src/main.c
deleted file mode 100755
index cf482ad..0000000
--- a/project/bletiny/src/main.c
+++ /dev/null
@@ -1,1467 +0,0 @@
-/**
- * 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 "bsp/bsp.h"
-#include "log/log.h"
-#include "stats/stats.h"
-#include "os/os.h"
-#include "bsp/bsp.h"
-#include "hal/hal_gpio.h"
-#include "hal/hal_cputime.h"
-#include "console/console.h"
-#include "shell/shell.h"
-#include "bletiny_priv.h"
-
-/* BLE */
-#include "nimble/ble.h"
-#include "nimble/nimble_opt.h"
-#include "host/host_hci.h"
-#include "host/ble_hs.h"
-#include "host/ble_hs_adv.h"
-#include "host/ble_uuid.h"
-#include "host/ble_att.h"
-#include "host/ble_gap.h"
-#include "host/ble_gatt.h"
-#include "controller/ble_ll.h"
-#include "../src/ble_hs_conn.h"
-#include "../src/ble_hci_sched.h"
-
-#define BSWAP16(x)  ((uint16_t)(((x) << 8) | (((x) & 0xff00) >> 8)))
-
-/* Task 1 */
-#define HOST_TASK_PRIO          (1)
-
-#define SHELL_TASK_PRIO         (3)
-#define SHELL_MAX_INPUT_LEN     (64)
-#define SHELL_TASK_STACK_SIZE   (OS_STACK_ALIGN(216))
-static bssnz_t os_stack_t shell_stack[SHELL_TASK_STACK_SIZE];
-
-static struct os_mutex bletiny_mutex;
-
-/* Our global device address (public) */
-uint8_t g_dev_addr[BLE_DEV_ADDR_LEN];
-
-/* Our random address (in case we need it) */
-uint8_t g_random_addr[BLE_DEV_ADDR_LEN];
-
-/* A buffer for host advertising data */
-uint8_t g_host_adv_data[BLE_HCI_MAX_ADV_DATA_LEN];
-uint8_t g_host_adv_len;
-
-static uint8_t bletiny_addr[6] = {0x03, 0x02, 0x01, 0x50, 0x13, 0x00};
-
-/* Create a mbuf pool of BLE mbufs */
-#define MBUF_NUM_MBUFS      (7)
-#define MBUF_BUF_SIZE       OS_ALIGN(BLE_MBUF_PAYLOAD_SIZE, 4)
-#define MBUF_MEMBLOCK_SIZE  (MBUF_BUF_SIZE + BLE_MBUF_MEMBLOCK_OVERHEAD)
-#define MBUF_MEMPOOL_SIZE   OS_MEMPOOL_SIZE(MBUF_NUM_MBUFS, MBUF_MEMBLOCK_SIZE)
-
-os_membuf_t default_mbuf_mpool_data[MBUF_MEMPOOL_SIZE];
-
-struct os_mbuf_pool default_mbuf_pool;
-struct os_mempool default_mbuf_mpool;
-
-/* BLETINY variables */
-#define BLETINY_STACK_SIZE             (OS_STACK_ALIGN(200))
-#define BLETINY_TASK_PRIO              (HOST_TASK_PRIO + 1)
-
-#if NIMBLE_OPT_ROLE_CENTRAL
-#define BLETINY_MAX_SVCS               32
-#define BLETINY_MAX_CHRS               64
-#define BLETINY_MAX_DSCS               64
-#else
-#define BLETINY_MAX_SVCS               1
-#define BLETINY_MAX_CHRS               1
-#define BLETINY_MAX_DSCS               1
-#endif
-
-struct os_eventq g_bletiny_evq;
-struct os_task bletiny_task;
-bssnz_t os_stack_t bletiny_stack[BLETINY_STACK_SIZE];
-
-static struct log_handler bletiny_log_console_handler;
-struct log bletiny_log;
-
-struct bletiny_conn ble_shell_conns[NIMBLE_OPT_MAX_CONNECTIONS];
-int bletiny_num_conns;
-
-void
-bletest_inc_adv_pkt_num(void) { }
-
-bssnz_t struct bletiny_conn bletiny_conns[NIMBLE_OPT_MAX_CONNECTIONS];
-int bletiny_num_conns;
-
-static void *bletiny_svc_mem;
-static struct os_mempool bletiny_svc_pool;
-
-static void *bletiny_chr_mem;
-static struct os_mempool bletiny_chr_pool;
-
-static void *bletiny_dsc_mem;
-static struct os_mempool bletiny_dsc_pool;
-
-const char *bletiny_device_name = "nimble-bletiny";
-const uint16_t bletiny_appearance = BSWAP16(BLE_GAP_APPEARANCE_GEN_COMPUTER);
-const uint8_t bletiny_privacy_flag = 0;
-uint8_t bletiny_reconnect_addr[6];
-uint8_t bletiny_pref_conn_params[8];
-uint8_t bletiny_gatt_service_changed[4];
-
-#define XSTR(s) STR(s)
-#define STR(s) #s
-
-#ifdef DEVICE_NAME
-#define BLETINY_AUTO_DEVICE_NAME    XSTR(DEVICE_NAME)
-#else
-#define BLETINY_AUTO_DEVICE_NAME    NULL
-#endif
-
-void
-bletiny_lock(void)
-{
-    int rc;
-
-    rc = os_mutex_pend(&bletiny_mutex, 0xffffffff);
-    assert(rc == 0 || rc == OS_NOT_STARTED);
-}
-
-void
-bletiny_unlock(void)
-{
-    int rc;
-
-    rc = os_mutex_release(&bletiny_mutex);
-    assert(rc == 0 || rc == OS_NOT_STARTED);
-}
-
-static void
-bletiny_print_error(char *msg, uint16_t conn_handle,
-                    struct ble_gatt_error *error)
-{
-    BLETINY_LOG(INFO, "%s: conn_handle=%d status=%d att_handle=%d\n",
-                msg, conn_handle, error->status, error->att_handle);
-}
-
-static void
-bletiny_print_bytes(uint8_t *bytes, int len)
-{
-    int i;
-
-    for (i = 0; i < len; i++) {
-        BLETINY_LOG(INFO, "%s0x%02x", i != 0 ? ":" : "", bytes[i]);
-    }
-}
-
-static void
-bletiny_print_conn_desc(struct ble_gap_conn_desc *desc)
-{
-    BLETINY_LOG(INFO, "handle=%d peer_addr_type=%d peer_addr=",
-                desc->conn_handle, desc->peer_addr_type);
-    bletiny_print_bytes(desc->peer_addr, 6);
-    BLETINY_LOG(INFO, " conn_itvl=%d conn_latency=%d supervision_timeout=%d",
-                desc->conn_itvl, desc->conn_latency,
-                desc->supervision_timeout);
-}
-
-static void
-bletiny_print_adv_fields(struct ble_hs_adv_fields *fields)
-{
-    uint32_t u32;
-    uint16_t u16;
-    uint8_t *u8p;
-    int i;
-
-    if (fields->flags_is_present) {
-        BLETINY_LOG(INFO, "    flags=0x%02x\n", fields->flags);
-    }
-
-    if (fields->uuids16 != NULL) {
-        BLETINY_LOG(INFO, "    uuids16(%scomplete)=",
-                    fields->uuids16_is_complete ? "" : "in");
-        u8p = fields->uuids16;
-        for (i = 0; i < fields->num_uuids16; i++) {
-            memcpy(&u16, u8p + i * 2, 2);
-            BLETINY_LOG(INFO, "0x%04x ", u16);
-        }
-        BLETINY_LOG(INFO, "\n");
-    }
-
-    if (fields->uuids32 != NULL) {
-        BLETINY_LOG(INFO, "    uuids32(%scomplete)=",
-                    fields->uuids32_is_complete ? "" : "in");
-        u8p = fields->uuids32;
-        for (i = 0; i < fields->num_uuids32; i++) {
-            memcpy(&u32, u8p + i * 4, 4);
-            BLETINY_LOG(INFO, "0x%08x ", (unsigned)u32);
-        }
-        BLETINY_LOG(INFO, "\n");
-    }
-
-    if (fields->uuids128 != NULL) {
-        BLETINY_LOG(INFO, "    uuids128(%scomplete)=",
-                    fields->uuids128_is_complete ? "" : "in");
-        u8p = fields->uuids128;
-        for (i = 0; i < fields->num_uuids128; i++) {
-            print_uuid(u8p);
-            BLETINY_LOG(INFO, " ");
-            u8p += 16;
-        }
-        BLETINY_LOG(INFO, "\n");
-    }
-
-    if (fields->name != NULL) {
-        BLETINY_LOG(INFO, "    name(%scomplete)=",
-                    fields->name_is_complete ? "" : "in");
-        BLETINY_LOG(INFO, "%*s\n", fields->name_len, fields->name);
-    }
-
-    if (fields->tx_pwr_lvl_is_present) {
-        BLETINY_LOG(INFO, "    tx_pwr_lvl=%d\n", fields->tx_pwr_lvl);
-    }
-
-    if (fields->device_class != NULL) {
-        BLETINY_LOG(INFO, "    device_class=");
-        bletiny_print_bytes(fields->device_class,
-                             BLE_HS_ADV_DEVICE_CLASS_LEN);
-        BLETINY_LOG(INFO, "\n");
-    }
-
-    if (fields->slave_itvl_range != NULL) {
-        BLETINY_LOG(INFO, "    slave_itvl_range=");
-        bletiny_print_bytes(fields->slave_itvl_range,
-                             BLE_HS_ADV_SLAVE_ITVL_RANGE_LEN);
-        BLETINY_LOG(INFO, "\n");
-    }
-
-    if (fields->svc_data_uuid16 != NULL) {
-        BLETINY_LOG(INFO, "    svc_data_uuid16=");
-        bletiny_print_bytes(fields->svc_data_uuid16,
-                             fields->svc_data_uuid16_len);
-        BLETINY_LOG(INFO, "\n");
-    }
-
-    if (fields->public_tgt_addr != NULL) {
-        BLETINY_LOG(INFO, "    public_tgt_addr=");
-        u8p = fields->public_tgt_addr;
-        for (i = 0; i < fields->num_public_tgt_addrs; i++) {
-            print_addr(u8p);
-            u8p += BLE_HS_ADV_PUBLIC_TGT_ADDR_ENTRY_LEN;
-        }
-        BLETINY_LOG(INFO, "\n");
-    }
-
-    if (fields->appearance_is_present) {
-        BLETINY_LOG(INFO, "    appearance=0x%04x\n", fields->appearance);
-    }
-
-    if (fields->adv_itvl_is_present) {
-        BLETINY_LOG(INFO, "    adv_itvl=0x%04x\n", fields->adv_itvl);
-    }
-
-    if (fields->le_addr != NULL) {
-        BLETINY_LOG(INFO, "    le_addr=");
-        bletiny_print_bytes(fields->le_addr, BLE_HS_ADV_LE_ADDR_LEN);
-        BLETINY_LOG(INFO, "\n");
-    }
-
-    if (fields->le_role_is_present) {
-        BLETINY_LOG(INFO, "    le_role=0x%02x\n", fields->le_role);
-    }
-
-    if (fields->svc_data_uuid32 != NULL) {
-        BLETINY_LOG(INFO, "    svc_data_uuid32=");
-        bletiny_print_bytes(fields->svc_data_uuid32,
-                             fields->svc_data_uuid32_len);
-        BLETINY_LOG(INFO, "\n");
-    }
-
-    if (fields->svc_data_uuid128 != NULL) {
-        BLETINY_LOG(INFO, "    svc_data_uuid128=");
-        bletiny_print_bytes(fields->svc_data_uuid128,
-                             fields->svc_data_uuid128_len);
-        BLETINY_LOG(INFO, "\n");
-    }
-
-    if (fields->uri != NULL) {
-        BLETINY_LOG(INFO, "    uri=");
-        bletiny_print_bytes(fields->uri, fields->uri_len);
-        BLETINY_LOG(INFO, "\n");
-    }
-
-    if (fields->mfg_data != NULL) {
-        BLETINY_LOG(INFO, "    mfg_data=");
-        bletiny_print_bytes(fields->mfg_data, fields->mfg_data_len);
-        BLETINY_LOG(INFO, "\n");
-    }
-}
-
-static int
-bletiny_conn_find_idx(uint16_t handle)
-{
-    int i;
-
-    for (i = 0; i < bletiny_num_conns; i++) {
-        if (bletiny_conns[i].handle == handle) {
-            return i;
-        }
-    }
-
-    return -1;
-}
-
-static struct bletiny_conn *
-bletiny_conn_find(uint16_t handle)
-{
-    int idx;
-
-    idx = bletiny_conn_find_idx(handle);
-    if (idx == -1) {
-        return NULL;
-    } else {
-        return bletiny_conns + idx;
-    }
-}
-
-static struct bletiny_conn *
-bletiny_conn_add(struct ble_gap_conn_desc *desc)
-{
-    struct bletiny_conn *conn;
-
-    assert(bletiny_num_conns < NIMBLE_OPT_MAX_CONNECTIONS);
-
-    conn = bletiny_conns + bletiny_num_conns;
-    bletiny_num_conns++;
-
-    conn->handle = desc->conn_handle;
-    conn->addr_type = desc->peer_addr_type;
-    memcpy(conn->addr, desc->peer_addr, 6);
-    SLIST_INIT(&conn->svcs);
-
-    return conn;
-}
-
-static void
-bletiny_conn_delete_idx(int idx)
-{
-    struct bletiny_conn *conn;
-    struct bletiny_svc *svc;
-
-    assert(idx >= 0 && idx < bletiny_num_conns);
-
-    conn = bletiny_conns + idx;
-    while ((svc = SLIST_FIRST(&conn->svcs)) != NULL) {
-        SLIST_REMOVE_HEAD(&conn->svcs, next);
-        os_memblock_put(&bletiny_svc_pool, svc);
-    }
-
-    bletiny_num_conns--;
-
-    /* This '#if' is not strictly necessary.  It is here to prevent a spurious
-     * warning from being reported.
-     */
-#if NIMBLE_OPT_MAX_CONNECTIONS > 1
-    int i;
-    for (i = idx; i < bletiny_num_conns; i++) {
-        bletiny_conns[i - 1] = bletiny_conns[i];
-    }
-#endif
-}
-
-static struct bletiny_svc *
-bletiny_svc_find_prev(struct bletiny_conn *conn, uint16_t svc_start_handle)
-{
-    struct bletiny_svc *prev;
-    struct bletiny_svc *svc;
-
-    prev = NULL;
-    SLIST_FOREACH(svc, &conn->svcs, next) {
-        if (svc->svc.start_handle >= svc_start_handle) {
-            break;
-        }
-
-        prev = svc;
-    }
-
-    return prev;
-}
-
-static struct bletiny_svc *
-bletiny_svc_find(struct bletiny_conn *conn, uint16_t svc_start_handle,
-                  struct bletiny_svc **out_prev)
-{
-    struct bletiny_svc *prev;
-    struct bletiny_svc *svc;
-
-    prev = bletiny_svc_find_prev(conn, svc_start_handle);
-    if (prev == NULL) {
-        svc = SLIST_FIRST(&conn->svcs);
-    } else {
-        svc = SLIST_NEXT(prev, next);
-    }
-
-    if (svc != NULL && svc->svc.start_handle != svc_start_handle) {
-        svc = NULL;
-    }
-
-    if (out_prev != NULL) {
-        *out_prev = prev;
-    }
-    return svc;
-}
-
-static struct bletiny_svc *
-bletiny_svc_find_range(struct bletiny_conn *conn, uint16_t attr_handle)
-{
-    struct bletiny_svc *svc;
-
-    SLIST_FOREACH(svc, &conn->svcs, next) {
-        if (svc->svc.start_handle <= attr_handle &&
-            svc->svc.end_handle >= attr_handle) {
-
-            return svc;
-        }
-    }
-
-    return NULL;
-}
-
-static struct bletiny_svc *
-bletiny_svc_add(uint16_t conn_handle, struct ble_gatt_service *gatt_svc)
-{
-    struct bletiny_conn *conn;
-    struct bletiny_svc *prev;
-    struct bletiny_svc *svc;
-
-    conn = bletiny_conn_find(conn_handle);
-    if (conn == NULL) {
-        BLETINY_LOG(INFO,
-                    "RECEIVED SERVICE FOR UNKNOWN CONNECTION; HANDLE=%d\n",
-                    conn_handle);
-        return NULL;
-    }
-
-    svc = bletiny_svc_find(conn, gatt_svc->start_handle, &prev);
-    if (svc != NULL) {
-        /* Service already discovered. */
-        return svc;
-    }
-
-    svc = os_memblock_get(&bletiny_svc_pool);
-    if (svc == NULL) {
-        BLETINY_LOG(INFO, "OOM WHILE DISCOVERING SERVICE\n");
-        return NULL;
-    }
-    memset(svc, 0, sizeof *svc);
-
-    svc->svc = *gatt_svc;
-    SLIST_INIT(&svc->chrs);
-
-    if (prev == NULL) {
-        SLIST_INSERT_HEAD(&conn->svcs, svc, next);
-    } else {
-        SLIST_INSERT_AFTER(prev, svc, next);
-    }
-
-    return svc;
-}
-
-static struct bletiny_chr *
-bletiny_chr_find_prev(struct bletiny_svc *svc, uint16_t chr_def_handle)
-{
-    struct bletiny_chr *prev;
-    struct bletiny_chr *chr;
-
-    prev = NULL;
-    SLIST_FOREACH(chr, &svc->chrs, next) {
-        if (chr->chr.decl_handle >= chr_def_handle) {
-            break;
-        }
-
-        prev = chr;
-    }
-
-    return prev;
-}
-
-static struct bletiny_chr *
-bletiny_chr_find(struct bletiny_svc *svc, uint16_t chr_def_handle,
-                  struct bletiny_chr **out_prev)
-{
-    struct bletiny_chr *prev;
-    struct bletiny_chr *chr;
-
-    prev = bletiny_chr_find_prev(svc, chr_def_handle);
-    if (prev == NULL) {
-        chr = SLIST_FIRST(&svc->chrs);
-    } else {
-        chr = SLIST_NEXT(prev, next);
-    }
-
-    if (chr != NULL && chr->chr.decl_handle != chr_def_handle) {
-        chr = NULL;
-    }
-
-    if (out_prev != NULL) {
-        *out_prev = prev;
-    }
-    return chr;
-}
-
-
-static struct bletiny_chr *
-bletiny_chr_add(uint16_t conn_handle,  uint16_t svc_start_handle,
-                 struct ble_gatt_chr *gatt_chr)
-{
-    struct bletiny_conn *conn;
-    struct bletiny_chr *prev;
-    struct bletiny_chr *chr;
-    struct bletiny_svc *svc;
-
-    conn = bletiny_conn_find(conn_handle);
-    if (conn == NULL) {
-        BLETINY_LOG(INFO,
-                    "RECEIVED SERVICE FOR UNKNOWN CONNECTION; HANDLE=%d\n",
-                    conn_handle);
-        return NULL;
-    }
-
-    svc = bletiny_svc_find(conn, svc_start_handle, NULL);
-    if (svc == NULL) {
-        BLETINY_LOG(INFO,
-                    "CAN'T FIND SERVICE FOR DISCOVERED CHR; HANDLE=%d\n",
-                    conn_handle);
-        return NULL;
-    }
-
-    chr = bletiny_chr_find(svc, gatt_chr->decl_handle, &prev);
-    if (chr != NULL) {
-        /* Characteristic already discovered. */
-        return chr;
-    }
-
-    chr = os_memblock_get(&bletiny_chr_pool);
-    if (chr == NULL) {
-        BLETINY_LOG(INFO, "OOM WHILE DISCOVERING CHARACTERISTIC\n");
-        return NULL;
-    }
-    memset(chr, 0, sizeof *chr);
-
-    chr->chr = *gatt_chr;
-
-    if (prev == NULL) {
-        SLIST_INSERT_HEAD(&svc->chrs, chr, next);
-    } else {
-        SLIST_NEXT(prev, next) = chr;
-    }
-
-    return chr;
-}
-
-static struct bletiny_dsc *
-bletiny_dsc_find_prev(struct bletiny_chr *chr, uint16_t dsc_handle)
-{
-    struct bletiny_dsc *prev;
-    struct bletiny_dsc *dsc;
-
-    prev = NULL;
-    SLIST_FOREACH(dsc, &chr->dscs, next) {
-        if (dsc->dsc.handle >= dsc_handle) {
-            break;
-        }
-
-        prev = dsc;
-    }
-
-    return prev;
-}
-
-static struct bletiny_dsc *
-bletiny_dsc_find(struct bletiny_chr *chr, uint16_t dsc_handle,
-                  struct bletiny_dsc **out_prev)
-{
-    struct bletiny_dsc *prev;
-    struct bletiny_dsc *dsc;
-
-    prev = bletiny_dsc_find_prev(chr, dsc_handle);
-    if (prev == NULL) {
-        dsc = SLIST_FIRST(&chr->dscs);
-    } else {
-        dsc = SLIST_NEXT(prev, next);
-    }
-
-    if (dsc != NULL && dsc->dsc.handle != dsc_handle) {
-        dsc = NULL;
-    }
-
-    if (out_prev != NULL) {
-        *out_prev = prev;
-    }
-    return dsc;
-}
-
-static struct bletiny_dsc *
-bletiny_dsc_add(uint16_t conn_handle, uint16_t chr_def_handle,
-                 struct ble_gatt_dsc *gatt_dsc)
-{
-    struct bletiny_conn *conn;
-    struct bletiny_dsc *prev;
-    struct bletiny_dsc *dsc;
-    struct bletiny_svc *svc;
-    struct bletiny_chr *chr;
-
-    conn = bletiny_conn_find(conn_handle);
-    if (conn == NULL) {
-        BLETINY_LOG(INFO,
-                    "RECEIVED SERVICE FOR UNKNOWN CONNECTION; HANDLE=%d\n",
-                    conn_handle);
-        return NULL;
-    }
-
-    svc = bletiny_svc_find_range(conn, chr_def_handle);
-    if (svc == NULL) {
-        BLETINY_LOG(INFO,
-                    "CAN'T FIND SERVICE FOR DISCOVERED DSC; HANDLE=%d\n",
-                    conn_handle);
-        return NULL;
-    }
-
-    chr = bletiny_chr_find(svc, chr_def_handle, NULL);
-    if (chr == NULL) {
-        BLETINY_LOG(INFO, "CAN'T FIND CHARACTERISTIC FOR DISCOVERED DSC; "
-                    "HANDLE=%d\n", conn_handle);
-        return NULL;
-    }
-
-    dsc = bletiny_dsc_find(chr, gatt_dsc->handle, &prev);
-    if (dsc != NULL) {
-        /* Descriptor already discovered. */
-        return dsc;
-    }
-
-    dsc = os_memblock_get(&bletiny_dsc_pool);
-    if (dsc == NULL) {
-        BLETINY_LOG(INFO, "OOM WHILE DISCOVERING DESCRIPTOR\n");
-        return NULL;
-    }
-    memset(dsc, 0, sizeof *dsc);
-
-    dsc->dsc = *gatt_dsc;
-
-    if (prev == NULL) {
-        SLIST_INSERT_HEAD(&chr->dscs, dsc, next);
-    } else {
-        SLIST_NEXT(prev, next) = dsc;
-    }
-
-    return dsc;
-}
-
-static void
-bletiny_start_auto_advertise(void)
-{
-#if 0
-    struct ble_hs_adv_fields fields;
-    int rc;
-
-    if (BLETINY_AUTO_DEVICE_NAME != NULL) {
-        memset(&fields, 0, sizeof fields);
-
-        fields.name = (uint8_t *)BLETINY_AUTO_DEVICE_NAME;
-        fields.name_len = strlen(BLETINY_AUTO_DEVICE_NAME);
-        fields.name_is_complete = 1;
-        rc = bletiny_set_adv_data(&fields);
-        if (rc != 0) {
-            return;
-        }
-
-        rc = bletiny_adv_start(BLE_GAP_DISC_MODE_GEN, BLE_GAP_CONN_MODE_UND,
-                               NULL, 0, NULL);
-        if (rc != 0) {
-            return;
-        }
-    }
-#endif
-}
-
-static int
-bletiny_on_mtu(uint16_t conn_handle, struct ble_gatt_error *error,
-                uint16_t mtu, void *arg)
-{
-    if (error != NULL) {
-        bletiny_print_error("ERROR EXCHANGING MTU", conn_handle, error);
-    } else {
-        BLETINY_LOG(INFO, "mtu exchange complete: conn_handle=%d mtu=%d\n",
-                    conn_handle, mtu);
-    }
-
-    return 0;
-}
-
-static int
-bletiny_on_disc_s(uint16_t conn_handle, struct ble_gatt_error *error,
-                   struct ble_gatt_service *service, void *arg)
-{
-    bletiny_lock();
-
-    if (error != NULL) {
-        bletiny_print_error("ERROR DISCOVERING SERVICE", conn_handle, error);
-    } else if (service != NULL) {
-        bletiny_svc_add(conn_handle, service);
-    } else {
-        BLETINY_LOG(INFO, "service discovery successful\n");
-    }
-
-    bletiny_unlock();
-
-    return 0;
-}
-
-static int
-bletiny_on_disc_c(uint16_t conn_handle, struct ble_gatt_error *error,
-                   struct ble_gatt_chr *chr, void *arg)
-{
-    intptr_t svc_start_handle;
-
-    svc_start_handle = (intptr_t)arg;
-
-    if (error != NULL) {
-        bletiny_print_error("ERROR DISCOVERING CHARACTERISTIC", conn_handle,
-                             error);
-    } else if (chr != NULL) {
-        bletiny_lock();
-        bletiny_chr_add(conn_handle, svc_start_handle, chr);
-        bletiny_unlock();
-    } else {
-        BLETINY_LOG(INFO, "characteristic discovery successful\n");
-    }
-
-    return 0;
-}
-
-static int
-bletiny_on_disc_d(uint16_t conn_handle, struct ble_gatt_error *error,
-                   uint16_t chr_def_handle, struct ble_gatt_dsc *dsc,
-                   void *arg)
-{
-    bletiny_lock();
-
-    if (error != NULL) {
-        bletiny_print_error("ERROR DISCOVERING DESCRIPTOR", conn_handle,
-                             error);
-    } else if (dsc != NULL) {
-        bletiny_dsc_add(conn_handle, chr_def_handle, dsc);
-    } else {
-        BLETINY_LOG(INFO, "descriptor discovery successful\n");
-    }
-
-    bletiny_unlock();
-
-    return 0;
-}
-
-static int
-bletiny_on_read(uint16_t conn_handle, struct ble_gatt_error *error,
-                 struct ble_gatt_attr *attr, void *arg)
-{
-    if (error != NULL) {
-        bletiny_print_error("ERROR READING CHARACTERISTIC", conn_handle,
-                             error);
-    } else if (attr != NULL) {
-        BLETINY_LOG(INFO, "characteristic read; conn_handle=%d "
-                    "attr_handle=%d len=%d value=", conn_handle,
-                    attr->handle, attr->value_len);
-        bletiny_print_bytes(attr->value, attr->value_len);
-        BLETINY_LOG(INFO, "\n");
-    } else {
-        BLETINY_LOG(INFO, "characteristic read complete\n");
-    }
-
-    return 0;
-}
-
-static int
-bletiny_on_read_mult(uint16_t conn_handle, struct ble_gatt_error *error,
-                      uint16_t *attr_handles, uint8_t num_attr_handles,
-                      uint8_t *attr_data, uint16_t attr_data_len, void *arg)
-{
-    int i;
-
-    if (error != NULL) {
-        bletiny_print_error("ERROR READING CHARACTERISTICS", conn_handle,
-                             error);
-    } else {
-        BLETINY_LOG(INFO,
-                    "multiple characteristic read complete; conn_handle=%d "
-                    "attr_handles=", conn_handle);
-        for (i = 0; i < num_attr_handles; i++) {
-            BLETINY_LOG(INFO, "%s%d", i != 0 ? "," : "", attr_handles[i]);
-        }
-
-        BLETINY_LOG(INFO, " len=%d value=", attr_data_len);
-        bletiny_print_bytes(attr_data, attr_data_len);
-        BLETINY_LOG(INFO, "\n");
-    }
-
-    return 0;
-
-}
-
-static int
-bletiny_on_write(uint16_t conn_handle, struct ble_gatt_error *error,
-                  struct ble_gatt_attr *attr, void *arg)
-{
-    if (error != NULL) {
-        bletiny_print_error("ERROR WRITING CHARACTERISTIC", conn_handle,
-                             error);
-    } else {
-        BLETINY_LOG(INFO, "characteristic write complete; conn_handle=%d "
-                    "attr_handle=%d len=%d value=", conn_handle,
-                    attr->handle, attr->value_len);
-        bletiny_print_bytes(attr->value, attr->value_len);
-        BLETINY_LOG(INFO, "\n");
-    }
-
-    return 0;
-}
-
-static int
-bletiny_on_write_reliable(uint16_t conn_handle, struct ble_gatt_error *error,
-                           struct ble_gatt_attr *attrs, uint8_t num_attrs,
-                           void *arg)
-{
-    int i;
-
-    if (error != NULL) {
-        bletiny_print_error("ERROR WRITING CHARACTERISTICS RELIABLY",
-                             conn_handle, error);
-    } else {
-        BLETINY_LOG(INFO, "characteristic write reliable complete; "
-                    "conn_handle=%d", conn_handle);
-
-        for (i = 0; i < num_attrs; i++) {
-            BLETINY_LOG(INFO, " attr_handle=%d len=%d value=", attrs[i].handle,
-                        attrs[i].value_len);
-            bletiny_print_bytes(attrs[i].value, attrs[i].value_len);
-        }
-        BLETINY_LOG(INFO, "\n");
-    }
-
-    return 0;
-}
-
-static int
-bletiny_on_notify(uint16_t conn_handle, uint16_t attr_handle,
-                   uint8_t *attr_val, uint16_t attr_len, void *arg)
-{
-    BLETINY_LOG(INFO, "received notification from conn_handle=%d attr=%d "
-                "len=%d value=", conn_handle, attr_handle, attr_len);
-
-    bletiny_print_bytes(attr_val, attr_len);
-    BLETINY_LOG(INFO, "\n");
-
-    return 0;
-}
-
-static int
-bletiny_on_connect(int event, int status, struct ble_gap_conn_ctxt *ctxt,
-                    void *arg)
-{
-    int conn_idx;
-
-    bletiny_lock();
-
-    switch (event) {
-    case BLE_GAP_EVENT_CONN:
-        BLETINY_LOG(INFO, "connection %s; status=%d ",
-                    status == 0 ? "up" : "down", status);
-        bletiny_print_conn_desc(ctxt->desc);
-        BLETINY_LOG(INFO, "\n");
-
-        if (status == 0) {
-            bletiny_conn_add(ctxt->desc);
-        } else {
-            if (ctxt->desc->conn_handle == BLE_HS_CONN_HANDLE_NONE) {
-                if (status == BLE_HS_HCI_ERR(BLE_ERR_UNK_CONN_ID)) {
-                    BLETINY_LOG(INFO, "connection procedure cancelled.\n");
-                }
-            } else {
-                conn_idx = bletiny_conn_find_idx(ctxt->desc->conn_handle);
-                if (conn_idx == -1) {
-                    BLETINY_LOG(INFO, "UNKNOWN CONNECTION\n");
-                } else {
-                    bletiny_conn_delete_idx(conn_idx);
-                }
-
-                bletiny_start_auto_advertise();
-            }
-        }
-
-        break;
-
-    case BLE_GAP_EVENT_CONN_UPDATED:
-        BLETINY_LOG(INFO, "connection updated; status=%d ", status);
-        bletiny_print_conn_desc(ctxt->desc);
-        BLETINY_LOG(INFO, "\n");
-        break;
-
-    case BLE_GAP_EVENT_CONN_UPDATE_REQ:
-        BLETINY_LOG(INFO, "connection update request; status=%d ", status);
-        *ctxt->self_params = *ctxt->peer_params;
-        break;
-    }
-
-    bletiny_unlock();
-
-    return 0;
-}
-
-static void
-bletiny_on_l2cap_update(int status, void *arg)
-{
-    BLETINY_LOG(INFO, "l2cap update complete; status=%d\n", status);
-}
-
-static void
-bletiny_on_wl_set(int status, void *arg)
-{
-    BLETINY_LOG(INFO, "white list set status=%d\n", status);
-}
-
-static void
-bletiny_on_scan(int event, int status, struct ble_gap_disc_desc *desc,
-                 void *arg)
-{
-    switch (event) {
-    case BLE_GAP_EVENT_DISC_SUCCESS:
-        BLETINY_LOG(INFO, "received advertisement; event_type=%d addr_type=%d "
-                    "addr=", desc->event_type, desc->addr_type);
-        bletiny_print_bytes(desc->addr, 6);
-        BLETINY_LOG(INFO, " length_data=%d rssi=%d data=", desc->length_data,
-                    desc->rssi);
-        bletiny_print_bytes(desc->data, desc->length_data);
-        BLETINY_LOG(INFO, " fields:\n");
-        bletiny_print_adv_fields(desc->fields);
-        BLETINY_LOG(INFO, "\n");
-        break;
-
-    case BLE_GAP_EVENT_DISC_FINISHED:
-        BLETINY_LOG(INFO, "scanning finished; status=%d\n", status);
-        break;
-
-    default:
-        assert(0);
-        break;
-    }
-}
-
-static void
-bletiny_on_rx_rssi(struct ble_hci_ack *ack, void *unused)
-{
-    struct hci_read_rssi_ack_params params;
-
-    if (ack->bha_params_len != BLE_HCI_READ_RSSI_ACK_PARAM_LEN) {
-        BLETINY_LOG(INFO, "invalid rssi response; len=%d\n",
-                    ack->bha_params_len);
-        return;
-    }
-
-    params.status = ack->bha_params[0];
-    params.connection_handle = le16toh(ack->bha_params + 1);
-    params.rssi = ack->bha_params[3];
-
-    BLETINY_LOG(INFO, "rssi response received; status=%d conn=%d rssi=%d\n",
-                params.status, params.connection_handle, params.rssi);
-}
-
-int
-bletiny_exchange_mtu(uint16_t conn_handle)
-{
-    int rc;
-
-    rc = ble_gattc_exchange_mtu(conn_handle, bletiny_on_mtu, NULL);
-    return rc;
-}
-
-int
-bletiny_disc_all_chrs(uint16_t conn_handle, uint16_t start_handle,
-                       uint16_t end_handle)
-{
-    intptr_t svc_start_handle;
-    int rc;
-
-    svc_start_handle = start_handle;
-    rc = ble_gattc_disc_all_chrs(conn_handle, start_handle, end_handle,
-                                 bletiny_on_disc_c, (void *)svc_start_handle);
-    return rc;
-}
-
-int
-bletiny_disc_chrs_by_uuid(uint16_t conn_handle, uint16_t start_handle,
-                           uint16_t end_handle, uint8_t *uuid128)
-{
-    intptr_t svc_start_handle;
-    int rc;
-
-    svc_start_handle = start_handle;
-    rc = ble_gattc_disc_chrs_by_uuid(conn_handle, start_handle, end_handle,
-                                     uuid128, bletiny_on_disc_c,
-                                     &svc_start_handle);
-    return rc;
-}
-
-int
-bletiny_disc_svcs(uint16_t conn_handle)
-{
-    int rc;
-
-    rc = ble_gattc_disc_all_svcs(conn_handle, bletiny_on_disc_s, NULL);
-    return rc;
-}
-
-int
-bletiny_disc_svc_by_uuid(uint16_t conn_handle, uint8_t *uuid128)
-{
-    int rc;
-
-    rc = ble_gattc_disc_svc_by_uuid(conn_handle, uuid128,
-                                    bletiny_on_disc_s, NULL);
-    return rc;
-}
-
-int
-bletiny_disc_all_dscs(uint16_t conn_handle, uint16_t chr_def_handle,
-                       uint16_t chr_end_handle)
-{
-    int rc;
-
-    rc = ble_gattc_disc_all_dscs(conn_handle, chr_def_handle, chr_end_handle,
-                                 bletiny_on_disc_d, NULL);
-    return rc;
-}
-
-int
-bletiny_find_inc_svcs(uint16_t conn_handle, uint16_t start_handle,
-                       uint16_t end_handle)
-{
-    int rc;
-
-    rc = ble_gattc_find_inc_svcs(conn_handle, start_handle, end_handle,
-                                 bletiny_on_disc_s, NULL);
-    return rc;
-}
-
-int
-bletiny_read(uint16_t conn_handle, uint16_t attr_handle)
-{
-    int rc;
-
-    rc = ble_gattc_read(conn_handle, attr_handle, bletiny_on_read, NULL);
-    return rc;
-}
-
-int
-bletiny_read_long(uint16_t conn_handle, uint16_t attr_handle)
-{
-    int rc;
-
-    rc = ble_gattc_read_long(conn_handle, attr_handle, bletiny_on_read, NULL);
-    return rc;
-}
-
-int
-bletiny_read_by_uuid(uint16_t conn_handle, uint16_t start_handle,
-                      uint16_t end_handle, uint8_t *uuid128)
-{
-    int rc;
-
-    rc = ble_gattc_read_by_uuid(conn_handle, start_handle, end_handle, uuid128,
-                                bletiny_on_read, NULL);
-    return rc;
-}
-
-int
-bletiny_read_mult(uint16_t conn_handle, uint16_t *attr_handles,
-                   int num_attr_handles)
-{
-    int rc;
-
-    rc = ble_gattc_read_mult(conn_handle, attr_handles, num_attr_handles,
-                             bletiny_on_read_mult, NULL);
-    return rc;
-}
-
-int
-bletiny_write(uint16_t conn_handle, uint16_t attr_handle, void *value,
-               uint16_t value_len)
-{
-    int rc;
-
-    if (conn_handle == BLE_HS_CONN_HANDLE_NONE) {
-        rc = ble_att_svr_write_local(attr_handle, value, value_len);
-    } else {
-        rc = ble_gattc_write(conn_handle, attr_handle, value, value_len,
-                             bletiny_on_write, NULL);
-    }
-
-    return rc;
-}
-
-int
-bletiny_write_no_rsp(uint16_t conn_handle, uint16_t attr_handle, void *value,
-                      uint16_t value_len)
-{
-    int rc;
-
-    rc = ble_gattc_write_no_rsp(conn_handle, attr_handle, value, value_len,
-                                bletiny_on_write, NULL);
-    return rc;
-}
-
-int
-bletiny_write_long(uint16_t conn_handle, uint16_t attr_handle, void *value,
-                    uint16_t value_len)
-{
-    int rc;
-
-    rc = ble_gattc_write_long(conn_handle, attr_handle, value, value_len,
-                              bletiny_on_write, NULL);
-    return rc;
-}
-
-int
-bletiny_write_reliable(uint16_t conn_handle, struct ble_gatt_attr *attrs,
-                        int num_attrs)
-{
-    int rc;
-
-    rc = ble_gattc_write_reliable(conn_handle, attrs, num_attrs,
-                                  bletiny_on_write_reliable, NULL);
-    return rc;
-}
-
-int
-bletiny_adv_stop(void)
-{
-    int rc;
-
-    rc = ble_gap_adv_stop();
-    return rc;
-}
-
-int
-bletiny_adv_start(int disc, int conn, uint8_t *peer_addr, int addr_type,
-                  struct hci_adv_params *params)
-{
-    int rc;
-
-    rc = ble_gap_adv_start(disc, conn, peer_addr, addr_type, params,
-                           bletiny_on_connect, NULL);
-    return rc;
-}
-
-int
-bletiny_conn_initiate(int addr_type, uint8_t *peer_addr,
-                       struct ble_gap_crt_params *params)
-{
-    int rc;
-
-    rc = ble_gap_conn_initiate(addr_type, peer_addr, NULL, bletiny_on_connect,
-                               params);
-    return rc;
-}
-
-int
-bletiny_conn_cancel(void)
-{
-    int rc;
-
-    rc = ble_gap_cancel();
-    return rc;
-}
-
-int
-bletiny_term_conn(uint16_t conn_handle)
-{
-    int rc;
-
-    rc = ble_gap_terminate(conn_handle);
-    return rc;
-}
-
-int
-bletiny_wl_set(struct ble_gap_white_entry *white_list, int white_list_count)
-{
-    int rc;
-
-    rc = ble_gap_wl_set(white_list, white_list_count, bletiny_on_wl_set,
-                        NULL);
-    return rc;
-}
-
-int
-bletiny_scan(uint32_t dur_ms, uint8_t disc_mode, uint8_t scan_type,
-              uint8_t filter_policy)
-{
-    int rc;
-
-    rc = ble_gap_disc(dur_ms, disc_mode, scan_type, filter_policy,
-                      bletiny_on_scan, NULL);
-    return rc;
-}
-
-int
-bletiny_set_adv_data(struct ble_hs_adv_fields *adv_fields)
-{
-    int rc;
-
-    rc = ble_gap_adv_set_fields(adv_fields);
-    return rc;
-}
-
-int
-bletiny_update_conn(uint16_t conn_handle, struct ble_gap_upd_params *params)
-{
-    int rc;
-
-    rc = ble_gap_update_params(conn_handle, params);
-    return rc;
-}
-
-void
-bletiny_chrup(uint16_t attr_handle)
-{
-    ble_gatts_chr_updated(attr_handle);
-}
-
-int
-bletiny_l2cap_update(uint16_t conn_handle,
-                     struct ble_l2cap_sig_update_params *params)
-{
-    int rc;
-
-    rc = ble_l2cap_sig_update(conn_handle, params, bletiny_on_l2cap_update,
-                              NULL);
-    return rc;
-}
-
-static int
-bletiny_tx_rssi_req(void *arg)
-{
-    intptr_t conn_handle;
-    int rc;
-
-    conn_handle = (intptr_t)arg;
-
-    ble_hci_sched_set_ack_cb(bletiny_on_rx_rssi, NULL);
-
-    rc = host_hci_cmd_read_rssi(conn_handle);
-    if (rc != 0) {
-        BLETINY_LOG(ERROR, "failure to send rssi hci cmd; rc=%d\n", rc);
-        return rc;
-    }
-
-    return 0;
-}
-
-int
-bletiny_show_rssi(uint16_t conn_handle)
-{
-    int rc;
-
-    rc = ble_hci_sched_enqueue(bletiny_tx_rssi_req,
-                               (void *)(intptr_t)conn_handle, NULL);
-    if (rc != 0) {
-        BLETINY_LOG(ERROR, "failure to enqueue rssi hci cmd; rc=%d\n", rc);
-        return rc;
-    }
-
-    return 0;
-
-}
-
-/**
- * BLE test task
- *
- * @param arg
- */
-static void
-bletiny_task_handler(void *arg)
-{
-    struct os_event *ev;
-    struct os_callout_func *cf;
-
-    periph_init();
-
-    ble_att_set_notify_cb(bletiny_on_notify, NULL);
-
-    /* Initialize eventq */
-    os_eventq_init(&g_bletiny_evq);
-
-    bletiny_start_auto_advertise();
-
-    while (1) {
-        ev = os_eventq_get(&g_bletiny_evq);
-        switch (ev->ev_type) {
-        case OS_EVENT_T_TIMER:
-            cf = (struct os_callout_func *)ev;
-            assert(cf->cf_func);
-            cf->cf_func(cf->cf_arg);
-            break;
-        default:
-            assert(0);
-            break;
-        }
-    }
-}
-
-/**
- * main
- *
- * The main function for the project. This function initializes the os, calls
- * init_tasks to initialize tasks (and possibly other objects), then starts the
- * OS. We should not return from os start.
- *
- * @return int NOTE: this function should never return!
- */
-int
-main(void)
-{
-    struct ble_hs_cfg cfg;
-    uint32_t seed;
-    int rc;
-    int i;
-
-    /* Initialize OS */
-    os_init();
-
-    /* Set cputime to count at 1 usec increments */
-    rc = cputime_init(1000000);
-    assert(rc == 0);
-
-    /* Dummy device address */
-    memcpy(g_dev_addr, bletiny_addr, 6);
-
-    /*
-     * Seed random number generator with least significant bytes of device
-     * address.
-     */
-    seed = 0;
-    for (i = 0; i < 4; ++i) {
-        seed |= g_dev_addr[i];
-        seed <<= 8;
-    }
-    srand(seed);
-
-    bletiny_svc_mem = malloc(
-        OS_MEMPOOL_BYTES(BLETINY_MAX_SVCS, sizeof (struct bletiny_svc)));
-    assert(bletiny_svc_mem != NULL);
-
-    rc = os_mempool_init(&bletiny_svc_pool, BLETINY_MAX_SVCS,
-                         sizeof (struct bletiny_svc), bletiny_svc_mem,
-                         "bletiny_svc_pool");
-    assert(rc == 0);
-
-    bletiny_chr_mem = malloc(
-        OS_MEMPOOL_BYTES(BLETINY_MAX_CHRS, sizeof (struct bletiny_chr)));
-    assert(bletiny_chr_mem != NULL);
-
-    rc = os_mempool_init(&bletiny_chr_pool, BLETINY_MAX_CHRS,
-                         sizeof (struct bletiny_chr), bletiny_chr_mem,
-                         "bletiny_chr_pool");
-    assert(rc == 0);
-
-    bletiny_dsc_mem = malloc(
-        OS_MEMPOOL_BYTES(BLETINY_MAX_DSCS, sizeof (struct bletiny_dsc)));
-    assert(bletiny_dsc_mem != NULL);
-
-    rc = os_mempool_init(&bletiny_dsc_pool, BLETINY_MAX_DSCS,
-                         sizeof (struct bletiny_dsc), bletiny_dsc_mem,
-                         "bletiny_dsc_pool");
-    assert(rc == 0);
-
-    rc = os_mempool_init(&default_mbuf_mpool, MBUF_NUM_MBUFS, 
-                         MBUF_MEMBLOCK_SIZE, default_mbuf_mpool_data, 
-                         "default_mbuf_data");
-    assert(rc == 0);
-
-    rc = os_mbuf_pool_init(&default_mbuf_pool, &default_mbuf_mpool,
-                           MBUF_MEMBLOCK_SIZE, MBUF_NUM_MBUFS);
-    assert(rc == 0);
-
-    rc = os_msys_register(&default_mbuf_pool);
-    assert(rc == 0);
-
-    log_init();
-    log_console_handler_init(&bletiny_log_console_handler);
-    log_register("bletiny", &bletiny_log, &bletiny_log_console_handler);
-
-    os_task_init(&bletiny_task, "bletiny", bletiny_task_handler,
-                 NULL, BLETINY_TASK_PRIO, OS_WAIT_FOREVER,
-                 bletiny_stack, BLETINY_STACK_SIZE);
-
-    rc = shell_task_init(SHELL_TASK_PRIO, shell_stack, SHELL_TASK_STACK_SIZE,
-                         SHELL_MAX_INPUT_LEN);
-    assert(rc == 0);
-
-    /* Init the console */
-    rc = console_init(shell_console_rx_cb);
-    assert(rc == 0);
-
-    rc = stats_module_init();
-    assert(rc == 0);
-
-    /* Initialize the BLE host. */
-    cfg = ble_hs_cfg_dflt;
-    cfg.max_hci_bufs = 3;
-    cfg.max_attrs = 32;
-    cfg.max_services = 4;
-    cfg.max_client_configs = 6;
-    cfg.max_gattc_procs = 2;
-    cfg.max_l2cap_chans = 3;
-    cfg.max_l2cap_sig_procs = 2;
-
-    rc = ble_hs_init(HOST_TASK_PRIO, &cfg);
-    assert(rc == 0);
-
-    /* Initialize the BLE LL */
-    ble_ll_init();
-
-    rc = cmd_init();
-    assert(rc == 0);
-
-    /* Initialize the preferred parameters. */
-    htole16(bletiny_pref_conn_params + 0, BLE_GAP_INITIAL_CONN_ITVL_MIN);
-    htole16(bletiny_pref_conn_params + 2, BLE_GAP_INITIAL_CONN_ITVL_MAX);
-    htole16(bletiny_pref_conn_params + 4, 0);
-    htole16(bletiny_pref_conn_params + 6, BSWAP16(0x100));
-
-    rc = os_mutex_init(&bletiny_mutex);
-    assert(rc == 0);
-
-    /* Start the OS */
-    os_start();
-
-    /* os start should never return. If it does, this should be an error */
-    assert(0);
-
-    return 0;
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/project/bletiny/src/parse.c
----------------------------------------------------------------------
diff --git a/project/bletiny/src/parse.c b/project/bletiny/src/parse.c
deleted file mode 100644
index 8051a88..0000000
--- a/project/bletiny/src/parse.c
+++ /dev/null
@@ -1,435 +0,0 @@
-/**
- * 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 <string.h>
-#include <stdlib.h>
-#include <limits.h>
-#include <stdarg.h>
-#include <errno.h>
-#include <assert.h>
-#include "console/console.h"
-#include "host/ble_uuid.h"
-#include "bletiny_priv.h"
-
-#define CMD_MAX_ARGS        16
-
-static char *cmd_args[CMD_MAX_ARGS][2];
-static int cmd_num_args;
-
-void
-print_addr(void *addr)
-{
-    uint8_t *u8p;
-
-    u8p = addr;
-    BLETINY_LOG(INFO, "%02x:%02x:%02x:%02x:%02x:%02x",
-                u8p[5], u8p[4], u8p[3], u8p[2], u8p[1], u8p[0]);
-}
-
-void
-print_uuid(void *uuid128)
-{
-    uint16_t uuid16;
-    uint8_t *u8p;
-
-    uuid16 = ble_uuid_128_to_16(uuid128);
-    if (uuid16 != 0) {
-        BLETINY_LOG(INFO, "0x%04x", uuid16);
-        return;
-    }
-
-    u8p = uuid128;
-
-    /* 00001101-0000-1000-8000-00805f9b34fb */
-    BLETINY_LOG(INFO, "%02x%02x%02x%02x-", u8p[15], u8p[14], u8p[13],
-                u8p[12]);
-    BLETINY_LOG(INFO, "%02x%02x-%02x%02x-", u8p[11], u8p[10], u8p[9], u8p[8]);
-    BLETINY_LOG(INFO, "%02x%02x%02x%02x%02x%02x%02x%02x",
-                u8p[7], u8p[6], u8p[5], u8p[4],
-                u8p[3], u8p[2], u8p[1], u8p[0]);
-}
-
-int
-parse_err_too_few_args(char *cmd_name)
-{
-    BLETINY_LOG(ERROR, "Error: too few arguments for command \"%s\"\n",
-                cmd_name);
-    return -1;
-}
-
-const struct cmd_entry *
-parse_cmd_find(const struct cmd_entry *cmds, char *name)
-{
-    const struct cmd_entry *cmd;
-    int i;
-
-    for (i = 0; cmds[i].name != NULL; i++) {
-        cmd = cmds + i;
-        if (strcmp(name, cmd->name) == 0) {
-            return cmd;
-        }
-    }
-
-    return NULL;
-}
-
-struct kv_pair *
-parse_kv_find(struct kv_pair *kvs, char *name)
-{
-    struct kv_pair *kv;
-    int i;
-
-    for (i = 0; kvs[i].key != NULL; i++) {
-        kv = kvs + i;
-        if (strcmp(name, kv->key) == 0) {
-            return kv;
-        }
-    }
-
-    return NULL;
-}
-
-char *
-parse_arg_find(char *key)
-{
-    int i;
-
-    for (i = 0; i < cmd_num_args; i++) {
-        if (strcmp(cmd_args[i][0], key) == 0) {
-            /* Erase parameter. */
-            cmd_args[i][0][0] = '\0';
-
-            return cmd_args[i][1];
-        }
-    }
-
-    return NULL;
-}
-
-long
-parse_arg_long_bounds(char *name, long min, long max, int *out_status)
-{
-    char *endptr;
-    char *sval;
-    long lval;
-
-    sval = parse_arg_find(name);
-    if (sval == NULL) {
-        *out_status = ENOENT;
-        return 0;
-    }
-
-    lval = strtol(sval, &endptr, 0);
-    if (sval[0] != '\0' && *endptr == '\0' &&
-        lval >= min && lval <= max) {
-
-        *out_status = 0;
-        return lval;
-    }
-
-    *out_status = EINVAL;
-    return 0;
-}
-
-long
-parse_arg_long(char *name, int *out_status)
-{
-    return parse_arg_long_bounds(name, LONG_MIN, LONG_MAX, out_status);
-}
-
-uint16_t
-parse_arg_uint16(char *name, int *out_status)
-{
-    return parse_arg_long_bounds(name, 0, UINT16_MAX, out_status);
-}
-
-uint32_t
-parse_arg_uint32(char *name, int *out_status)
-{
-    return parse_arg_long_bounds(name, 0, UINT32_MAX, out_status);
-}
-
-uint16_t
-parse_arg_uint16_dflt(char *name, uint16_t dflt, int *out_status)
-{
-    uint16_t val;
-    int rc;
-
-    val = parse_arg_uint16(name, &rc);
-    if (rc == ENOENT) {
-        val = dflt;
-        rc = 0;
-    }
-
-    *out_status = rc;
-    return val;
-}
-
-int
-parse_arg_kv(char *name, struct kv_pair *kvs)
-{
-    struct kv_pair *kv;
-    char *sval;
-
-    sval = parse_arg_find(name);
-    if (sval == NULL) {
-        return ENOENT;
-    }
-
-    kv = parse_kv_find(kvs, sval);
-    if (kv == NULL) {
-        return EINVAL;
-    }
-
-    return kv->val;
-}
-
-static int
-parse_arg_byte_stream_no_delim(char *sval, int max_len, uint8_t *dst,
-                               int *out_len)
-{
-    unsigned long ul;
-    char *endptr;
-    char buf[3];
-    int i;
-
-    buf[2] = '\0';
-    i = 0;
-    while (1) {
-        if (sval[i * 2] == '\0') {
-            *out_len = i;
-            return 0;
-        }
-
-        if (i >= max_len) {
-            return EINVAL;
-        }
-
-        buf[0] = sval[i * 2 + 0];
-        buf[1] = sval[i * 2 + 1];
-
-        ul = strtoul(buf, &endptr, 16);
-        if (*sval == '\0' || *endptr != '\0') {
-            return EINVAL;
-        }
-
-        assert(ul <= UINT8_MAX);
-        dst[i] = ul;
-
-        i++;
-    }
-}
-
-static int
-parse_arg_byte_stream_delim(char *sval, char *delims, int max_len,
-                            uint8_t *dst, int *out_len)
-{
-    unsigned long ul;
-    char *endptr;
-    char *token;
-    int i;
-
-    i = 0;
-    for (token = strtok(sval, delims);
-         token != NULL;
-         token = strtok(NULL, delims)) {
-
-        if (i >= max_len) {
-            return EINVAL;
-        }
-
-        ul = strtoul(token, &endptr, 16);
-        if (sval[0] == '\0' || *endptr != '\0' || ul > UINT8_MAX) {
-            return -1;
-        }
-
-        dst[i] = ul;
-        i++;
-    }
-
-    *out_len = i;
-
-    return 0;
-}
-
-int
-parse_arg_byte_stream(char *name, int max_len, uint8_t *dst, int *out_len)
-{
-    int total_len;
-    char *sval;
-
-    sval = parse_arg_find(name);
-    if (sval == NULL) {
-        return ENOENT;
-    }
-
-    total_len = strlen(sval);
-    if (strcspn(sval, ":-") == total_len) {
-        return parse_arg_byte_stream_no_delim(sval, max_len, dst, out_len);
-    } else {
-        return parse_arg_byte_stream_delim(sval, ":-", max_len, dst, out_len);
-    }
-}
-
-int
-parse_arg_byte_stream_exact_length(char *name, uint8_t *dst, int len)
-{
-    int actual_len;
-    int rc;
-
-    rc = parse_arg_byte_stream(name, 6, dst, &actual_len);
-    if (rc != 0) {
-        return rc;
-    }
-
-    if (actual_len != len) {
-        return EINVAL;
-    }
-
-    return 0;
-}
-
-static void
-parse_reverse_bytes(uint8_t *bytes, int len)
-{
-    uint8_t tmp;
-    int i;
-
-    for (i = 0; i < len / 2; i++) {
-        tmp = bytes[i];
-        bytes[i] = bytes[len - i - 1];
-        bytes[len - i - 1] = tmp;
-    }
-}
-
-int
-parse_arg_mac(char *name, uint8_t *dst)
-{
-    int rc;
-
-    rc = parse_arg_byte_stream_exact_length(name, dst, 6);
-    if (rc != 0) {
-        return rc;
-    }
-
-    parse_reverse_bytes(dst, 6);
-
-    return 0;
-}
-
-int
-parse_arg_uuid(char *str, uint8_t *dst_uuid128)
-{
-    uint16_t uuid16;
-    char *tok;
-    int rc;
-
-    uuid16 = parse_arg_uint16(str, &rc);
-    switch (rc) {
-    case ENOENT:
-        return ENOENT;
-
-    case 0:
-        rc = ble_uuid_16_to_128(uuid16, dst_uuid128);
-        if (rc != 0) {
-            return EINVAL;
-        } else {
-            return 0;
-        }
-
-    default:
-        /* e7add801-b042-4876-aae1112855353cc1 */
-        if (strlen(str) == 35) {
-            tok = strtok(str, "-");
-            if (tok == NULL) {
-                return EINVAL;
-            }
-            rc = parse_arg_byte_stream_exact_length(tok, dst_uuid128 + 0, 4);
-            if (rc != 0) {
-                return rc;
-            }
-
-            tok = strtok(NULL, "-");
-            if (tok == NULL) {
-                return EINVAL;
-            }
-            rc = parse_arg_byte_stream_exact_length(tok, dst_uuid128 + 4, 2);
-            if (rc != 0) {
-                return rc;
-            }
-
-            tok = strtok(NULL, "-");
-            if (tok == NULL) {
-                return EINVAL;
-            }
-            rc = parse_arg_byte_stream_exact_length(tok, dst_uuid128 + 6, 2);
-            if (rc != 0) {
-                return rc;
-            }
-
-            tok = strtok(NULL, "-");
-            if (tok == NULL) {
-                return EINVAL;
-            }
-            rc = parse_arg_byte_stream_exact_length(tok, dst_uuid128 + 8, 8);
-            if (rc != 0) {
-                return rc;
-            }
-
-            return 0;
-        }
-
-        rc = parse_arg_byte_stream_exact_length(str, dst_uuid128, 16);
-        return rc;
-    }
-}
-
-int
-parse_arg_all(int argc, char **argv)
-{
-    char *key;
-    char *val;
-    int i;
-
-    cmd_num_args = 0;
-
-    for (i = 0; i < argc; i++) {
-        key = strtok(argv[i], "=");
-        val = strtok(NULL, "=");
-
-        if (key != NULL && val != NULL) {
-            if (strlen(key) == 0) {
-                BLETINY_LOG(ERROR, "Error: invalid argument: %s\n", argv[i]);
-                return -1;
-            }
-
-            if (cmd_num_args >= CMD_MAX_ARGS) {
-                BLETINY_LOG(ERROR, "Error: too many arguments");
-                return -1;
-            }
-
-            cmd_args[cmd_num_args][0] = key;
-            cmd_args[cmd_num_args][1] = val;
-            cmd_num_args++;
-        }
-    }
-
-    return 0;
-}
-



[12/42] incubator-mynewt-core git commit: pkg-list is gone with new newt

Posted by cc...@apache.org.
pkg-list is gone with new newt


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/9c705a78
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/9c705a78
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/9c705a78

Branch: refs/heads/master
Commit: 9c705a78cd6304ae6a5a6b5398d5dd7ddd02cdd8
Parents: 9faa5da
Author: Sterling Hughes <st...@apache.org>
Authored: Thu Mar 10 07:53:58 2016 -0800
Committer: Sterling Hughes <st...@apache.org>
Committed: Thu Mar 10 07:53:58 2016 -0800

----------------------------------------------------------------------
 pkg-list.yml | 384 ------------------------------------------------------
 1 file changed, 384 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9c705a78/pkg-list.yml
----------------------------------------------------------------------
diff --git a/pkg-list.yml b/pkg-list.yml
deleted file mode 100644
index f3cae7e..0000000
--- a/pkg-list.yml
+++ /dev/null
@@ -1,384 +0,0 @@
-#
-# 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.
-#
-
-name: larva
-url: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
-pkgs:
-    bletest:
-        vers: 0.8.0
-        hash: 325d6ff98eb71341c4f3e47bce3c37a74ea819b4
-        deps:
-            - net/nimble/controller@none#stable
-            - net/nimble/host@none#stable
-            - libs/os@none#stable
-            - libs/console/full@none#stable
-            - libs/baselibc@none#stable
-            - libs/shell@none#stable
-            - libs/imgmgr@none#stable
-            - libs/newtmgr@none#stable
-            - sys/config@none#stable
-            - sys/log@none#stable
-            - sys/stats@none#stable
-    libs/console/stub:
-        vers: 0.8.0
-        hash: d41aedc5941495ca9320cc013f68ee73d4e349ab
-        apis:
-            - console@none#stable
-    libs/os:
-        vers: 0.8.0
-        hash: 999a3419d9959d3c39b11dcc67d79c7888b4b765
-        deps:
-            - libs/testutil@none#stable
-        req_apis:
-            - console@none#stable
-    project/blinky:
-        vers: 0.8.0
-        hash: 8be3527ec83fad088e4d9bf87eb0ecaf35842900
-        deps:
-            - libs/console/full@none#stable
-            - libs/newtmgr@none#stable
-            - libs/os@none#stable
-            - libs/shell@none#stable
-            - sys/config@none#stable
-            - sys/log@none#stable
-            - sys/stats@none#stable
-    project/boot:
-        vers: 0.8.0
-        hash: 3a38b2fcb865c466060cd3354b1b8b10b68b24c2
-        deps:
-            - fs/nffs@none#stable
-            - libs/baselibc@none#stable
-            - libs/bootutil@none#stable
-            - libs/console/stub@none#stable
-            - libs/mbedtls@none#stable
-            - libs/os@none#stable
-            - libs/util@none#stable
-    net/nimble/drivers/native:
-        vers: 0.8.0
-        hash: 513cc71e129320e3e2d80a9cdfc748db6c83fbb4
-        deps:
-            - net/nimble/controller@none#stable
-        apis:
-            - ble_driver@none#stable
-    fs/fs:
-        vers: 0.8.0
-        hash: 6eb8e611b9b7da5be034502b53183c779a115e91
-    compiler/arm-none-eabi-m0:
-        vers: 0.8.0
-        hash: f01309d64a6e2672c1128ee5f62f33dccf483773
-    hw/bsp/native:
-        vers: 0.0.0
-        hash: 5fcbfe71744ff13621e4d126919bd7ab3fd68f0f
-        deps:
-            - hw/mcu/native@none#stable
-    libs/elua/elua_base:
-        vers: 0.8.0
-        hash: 0f4bff75e83236ad27c49ba9a161d50b76c648fb
-        deps:
-            - fs/fs@none#stable
-        req_apis:
-            - console@none#stable
-    libs/util:
-        vers: 0.8.0
-        hash: 090ddff6afe551379588ed9afe813bf10f45d271
-        deps:
-            - hw/hal@none#stable
-            - libs/os@none#stable
-            - libs/testutil@none#stable
-    libs/testreport:
-        vers: 0.8.0
-        hash: 8911630551f233ec26203e1ab230a76d184d5d3a
-        deps:
-            - fs/nffs@none#stable
-            - libs/testutil@none#stable
-    libs/cmsis-core:
-        vers: 0.8.0
-        hash: c6aad09920627ca3300992b53d666fc34771d575
-    sys/stats:
-        vers: 0.8.0
-        hash: cba5a8bb1ddcdff13c3a61bcff2539e1c0271d73
-        deps:
-            - libs/os@none#stable
-            - libs/util@none#stable
-            - libs/testutil@none#stable
-    hw/mcu/nordic/nrf52xxx:
-        vers: 0.0.0
-        hash: 68beecaad8f55ddbb340e80e53ba316e346c11dc
-        deps:
-            - hw/hal@none#stable
-            - libs/cmsis-core@none#stable
-            - compiler/arm-none-eabi-m4@none#stable
-    bletiny:
-        vers: 0.8.0
-        hash: 246c029f74244a70ce3037c598aaa481af45ad36
-        deps:
-            - libs/os@none#stable
-            - sys/log@none#stable
-            - net/nimble/controller@none#stable
-            - net/nimble/host@none#stable
-            - libs/console/full@none#stable
-            - libs/shell@none#stable
-            - libs/baselibc@none#stable
-    hw/mcu/stm/stm32f3xx:
-        vers: 0.0.0
-        hash: ca97cded47b4b4d4a3aa76dd6c8969e874f3e673
-        deps:
-            - hw/hal@none#stable
-            - libs/cmsis-core@none#stable
-            - compiler/arm-none-eabi-m4@none#stable
-    project/slinky:
-        vers: 0.8.0
-        hash: 5dbdf0f12815ad722ea8f747d298d25bf7065062
-        deps:
-            - libs/console/full@none#stable
-            - libs/imgmgr@none#stable
-            - libs/newtmgr@none#stable
-            - libs/os@none#stable
-            - libs/shell@none#stable
-            - libs/util@none#stable
-            - sys/config@none#stable
-            - sys/log@none#stable
-            - sys/stats@none#stable
-            - libs/baselibc@none#stable
-            - libs/flash_test@none#stable
-    hw/hal:
-        vers: 0.8.0
-        hash: bb85a7cd2c561bf80a87b613353a4446cb487431
-        deps:
-            - libs/os@none#stable
-    net/nimble:
-        vers: 0.8.0
-        hash: 8977b8da604d9779d51baf4aacabef5af2771bf7
-        deps:
-            - libs/os@none#stable
-    project/ffs2native:
-        vers: 0.8.0
-        hash: 8a53de11192076317745eea6b67f9b45a3a0738e
-        deps:
-            - fs/nffs@none#stable
-            - hw/hal@none#stable
-            - libs/console/full@none#stable
-            - libs/os@none#stable
-    compiler/sim:
-        vers: 0.8.0
-        hash: 06c06f86b544cffd78c54bfdc0cd0695490ba493
-    libs/mbedtls:
-        vers: 0.8.0
-        hash: 60433696c8affac24e8cfa7f5cde129d9dda4df5
-        deps:
-            - libs/testutil@none#stable
-    libs/shell:
-        vers: 0.8.0
-        hash: c8e4058dfccc96afa85553d789b0595761d32de1
-        deps:
-            - libs/os@none#stable
-            - libs/util@none#stable
-    hw/bsp/stm32f3discovery:
-        vers: 0.0.0
-        hash: c0a5233355d5ec1f7146d9e886628c43f54b9c22
-        deps:
-            - hw/mcu/stm/stm32f3xx@none#stable
-    hw/bsp/arduino_zero:
-        vers: 0.0.0
-        hash: b18682812929391068160a104728d6fb491ae218
-        deps:
-            - hw/mcu/atmel/samd21xx@none#stable
-            - libs/cmsis-core@none#stable
-    sys/config:
-        vers: 0.8.0
-        hash: b0791ff2f0785815f2c80d63ab249d8e541ce2a2
-        deps:
-            - libs/util@none#stable
-            - libs/testutil@none#stable
-    hw/bsp/olimex_stm32-e407_devboard:
-        vers: 0.0.0
-        hash: 143ede450dede56c43a0071c7e4b06f716fbbb93
-        deps:
-            - hw/mcu/stm/stm32f4xx@none#stable
-    libs/json:
-        vers: 0.8.0
-        hash: 18ab42710fad7a8434ba96b127e2976881506d1c
-    net/nimble/drivers/nrf51:
-        vers: 0.8.0
-        hash: 97739c2be0d90766414a382de6f51090563e9cad
-        deps:
-            - net/nimble@none#stable
-            - net/nimble/controller@none#stable
-        apis:
-            - ble_driver@none#stable
-    compiler/arm-none-eabi-m4:
-        vers: 0.8.0
-        hash: 8655fa5d74093f3f80db45fcb82bde7b0c7fa0e8
-    libs/console/full:
-        vers: 0.8.0
-        hash: 274362e34db9347764078c80c528037212b4f496
-        deps:
-            - hw/hal@none#stable
-            - libs/os@none#stable
-        apis:
-            - console@none#stable
-    hw/mcu/stm/stm32f4xx:
-        vers: 0.0.0
-        hash: b7a31f8eff452f6ef9bb653a0ad7622370aaeaad
-        deps:
-            - hw/hal@none#stable
-            - libs/cmsis-core@none#stable
-            - compiler/arm-none-eabi-m4@none#stable
-    sys/log:
-        vers: 0.8.0
-        hash: 85e3c7bb087f518b20cca97599c84f4c7fdafa58
-        deps:
-            - libs/os@none#stable
-            - libs/util@none#stable
-            - libs/testutil@none#stable
-    hw/bsp/nrf52pdk:
-        vers: 0.0.0
-        hash: befbe4e4ae4c5c370af7664139f658fb08292bf1
-        deps:
-            - hw/mcu/nordic/nrf52xxx@none#stable
-    libs/newtmgr:
-        vers: 0.8.0
-        hash: 03a11f10ea9e4e5b21acbd0c034d2024c7dea22b
-        deps:
-            - libs/os@none#stable
-            - libs/json@none#stable
-            - libs/util@none#stable
-            - libs/testutil@none#stable
-            - libs/shell@none#stable
-    luatest:
-        vers: 0.8.0
-        hash: 342cf211141bee0337d2f7da2b8b1eb46f6ab4b8
-        deps:
-            - fs/nffs@none#stable
-            - libs/os@none#stable
-            - libs/elua/elua_base@none#stable
-            - libs/console/full@none#stable
-            - libs/shell@none#stable
-    fs/nffs:
-        vers: 0.8.0
-        hash: 8af35aa4fcb4830294bc90c287c697953fa329c5
-        deps:
-            - sys/log@none#stable
-            - fs/fs@none#stable
-            - libs/os@none#stable
-            - libs/testutil@none#stable
-            - hw/hal@none#stable
-    net/nimble/controller:
-        vers: 0.8.0
-        hash: 9cc5ce3af39ecf51fec6a5329d369e64c0b17ebc
-        deps:
-            - libs/os@none#stable
-            - sys/stats@none#stable
-            - net/nimble@none#stable
-    net/nimble/host:
-        vers: 0.8.0
-        hash: 1b0650626ba590df2631327ed9722d70e7cd27ee
-        deps:
-            - sys/log@none#stable
-            - sys/stats@none#stable
-            - libs/os@none#stable
-            - libs/util@none#stable
-            - net/nimble@none#stable
-        req_apis:
-            - console@none#stable
-    libs/imgmgr:
-        vers: 0.8.0
-        hash: ce0f94539cefa2ac5f18c56f0d24ce1169fe1cd5
-        deps:
-            - libs/newtmgr@none#stable
-            - libs/bootutil@none#stable
-    hw/mcu/native:
-        vers: 0.0.0
-        hash: 37ee2b63f3226f70e3e748d8e6ce56b54b745122
-        deps:
-            - hw/hal@none#stable
-            - compiler/sim@none#stable
-    hw/mcu/atmel/samd21xx:
-        vers: 0.0.0
-        hash: 46d1c78c23346555847b91d13a32ebd821d5b8bb
-        deps:
-            - hw/hal@none#stable
-            - libs/cmsis-core@none#stable
-            - compiler/arm-none-eabi-m4@none#stable
-    libs/baselibc:
-        vers: 0.8.0
-        hash: bb46b003c472b16309bd9fbed81f5c4c62bd4aa5
-        req_apis:
-            - console@none#stable
-    net/nimble/drivers/nrf52:
-        vers: 0.8.0
-        hash: 30701b65eedf693670a3f56367d6728fdac26f6f
-        deps:
-            - net/nimble@none#stable
-            - net/nimble/controller@none#stable
-        apis:
-            - ble_driver@none#stable
-    hw/mcu/nordic/nrf51xxx:
-        vers: 0.0.0
-        hash: 6681e65a49a2e393e9e168534fc4134ee8d33dce
-        deps:
-            - hw/hal@none#stable
-            - libs/cmsis-core@none#stable
-            - compiler/arm-none-eabi-m0@none#stable
-    hw/bsp/nrf51dk:
-        vers: 0.0.0
-        hash: 6a83e0c206b3f9bc644701f477508f8130e69631
-        deps:
-            - hw/mcu/nordic/nrf51xxx@none#stable
-    project/test:
-        vers: 0.8.0
-        hash: 61f2e0b5226af06d94263324966c34b174db615d
-        deps:
-            - fs/nffs@none#stable
-            - libs/bootutil@none#stable
-            - libs/console/full@none#stable
-            - libs/mbedtls@none#stable
-            - libs/os@none#stable
-            - libs/testreport@none#stable
-            - libs/testutil@none#stable
-            - libs/util@none#stable
-            - sys/config@none#stable
-    hw/bsp/nrf51dk-16kbram:
-        vers: 0.0.0
-        hash: 06994cccca7723cc62552345db2554bd3aa733ee
-        deps:
-            - hw/mcu/nordic/nrf51xxx@none#stable
-    libs/flash_test:
-        vers: 0.1.0
-        hash: fb60fc85b335de1b4585e0799af9680d6acce698
-        deps:
-            - libs/os@none#stable
-            - libs/util@none#stable
-            - hw/hal@none#stable
-            - libs/baselibc@none#stable
-    libs/testutil:
-        vers: 0.8.0
-        hash: b8185d12fe46b4e153e693f79c23338c98d37757
-        deps:
-            - hw/hal@none#stable
-            - libs/os@none#stable
-    libs/bootutil:
-        vers: 0.8.0
-        hash: cf63c7b6e78fb1b7ff97f491aa7839d87ffa1f10
-        deps:
-            - fs/nffs@none#stable
-            - libs/os@none#stable
-            - libs/testutil@none#stable
-            - libs/mbedtls@none#stable
-            - hw/hal@none#stable


[09/42] incubator-mynewt-core git commit: Remove duplicate requirement for console.

Posted by cc...@apache.org.
Remove duplicate requirement for console.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/3b717412
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/3b717412
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/3b717412

Branch: refs/heads/master
Commit: 3b7174129d0fe542ef208d3f5dbb3efdc637ba06
Parents: 4d1854d
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Wed Mar 9 15:46:34 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Wed Mar 9 16:05:51 2016 -0800

----------------------------------------------------------------------
 libs/os/pkg.yml | 2 --
 1 file changed, 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3b717412/libs/os/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/os/pkg.yml b/libs/os/pkg.yml
index bf7fa7d..0fccae3 100644
--- a/libs/os/pkg.yml
+++ b/libs/os/pkg.yml
@@ -34,8 +34,6 @@ pkg.req_apis:
 pkg.deps.SHELL:
     - libs/shell 
 pkg.cflags.SHELL: -DSHELL_PRESENT 
-pkg.reqs.SHELL:
-    - console
 
 # Satisfy capability dependencies for the self-contained test executable.
 pkg.deps.selftest: libs/console/stub


[28/42] incubator-mynewt-core git commit: Use the presence of SIGALRM in the signal mask to detect whether the task is inside a critical section. Previously this was done by comparing the entire 'omask' with 'allsigs'. This was dubious for a couple of re

Posted by cc...@apache.org.
Use the presence of SIGALRM in the signal mask to detect whether the task
is inside a critical section. Previously this was done by comparing the
entire 'omask' with 'allsigs'. This was dubious for a couple of reasons:
- the compiler is free to add pad bytes between structure members and
  not initialize them.
- the OS is required to initialize only those signals that are actually
  implemented.

Since we enable/disable all signals in 'allsigs' simultaneously, testing
the presence of any one signal is sufficient to test all of them.

Set the SA_RESTART flag when registering a signal handler otherwise a
'write()' to the uart can fail with errno set to EINTR causing the
'uart_poller' task to assert.

Initialize signals in 'os_arch_os_init()' so critical sections start
functioning before they are used during task initialization.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/a92a45eb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/a92a45eb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/a92a45eb

Branch: refs/heads/master
Commit: a92a45eb5862a5b077e37c23a29a203a7c434cca
Parents: 66bad70
Author: Neel Natu <ne...@nahannisys.com>
Authored: Thu Mar 10 22:55:36 2016 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Fri Mar 11 12:16:13 2016 -0800

----------------------------------------------------------------------
 libs/os/src/arch/sim/os_arch_sim.c | 31 ++++++++++++++++++++++++++-----
 1 file changed, 26 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a92a45eb/libs/os/src/arch/sim/os_arch_sim.c
----------------------------------------------------------------------
diff --git a/libs/os/src/arch/sim/os_arch_sim.c b/libs/os/src/arch/sim/os_arch_sim.c
index a0a06d9..1daa94a 100644
--- a/libs/os/src/arch/sim/os_arch_sim.c
+++ b/libs/os/src/arch/sim/os_arch_sim.c
@@ -138,7 +138,11 @@ os_arch_save_sr(void)
     error = sigprocmask(SIG_BLOCK, &allsigs, &omask);
     assert(error == 0);
 
-    return (omask == allsigs);
+    /*
+     * If any one of the signals in 'allsigs' is present in 'omask' then
+     * we are already inside a critical section.
+     */
+    return (sigismember(&omask, SIGALRM));
 }
 
 void
@@ -167,7 +171,11 @@ os_arch_in_critical(void)
     error = sigprocmask(SIG_SETMASK, NULL, &omask);
     assert(error == 0);
 
-    return (omask == allsigs);
+    /*
+     * If any one of the signals in 'allsigs' is present in 'omask' then
+     * we are already inside a critical section.
+     */
+    return (sigismember(&omask, SIGALRM));
 }
 
 void
@@ -205,9 +213,17 @@ signals_init(void)
         memset(&sa, 0, sizeof sa);
         sa.sa_handler = signals[i].handler;
         sa.sa_mask = allsigs;
+        sa.sa_flags = SA_RESTART;
         error = sigaction(signals[i].num, &sa, NULL);
         assert(error == 0);
     }
+
+    /*
+     * We use SIGALRM as a proxy for 'allsigs' to check if we are inside
+     * a critical section (for e.g. see os_arch_in_critical()). Make sure
+     * that SIGALRM is indeed present in 'allsigs'.
+     */
+    assert(sigismember(&allsigs, SIGALRM));
 }
 
 static void
@@ -297,6 +313,14 @@ os_arch_os_init(void)
     TAILQ_INIT(&g_os_run_list);
     TAILQ_INIT(&g_os_sleep_list);
 
+    /*
+     * Setup all interrupt handlers.
+     *
+     * This must be done early because task initialization uses critical
+     * sections which function correctly only when 'allsigs' is initialized.
+     */
+    signals_init();
+
     os_init_idle_task();
     os_sanity_task_init(1);
 
@@ -312,9 +336,6 @@ os_arch_os_start(void)
     struct os_task *t;
     os_sr_t sr;
 
-    /* Setup all interrupt handlers */
-    signals_init();
-
     /*
      * Disable interrupts before enabling any interrupt sources. Pending
      * interrupts will be recognized when the first task starts executing.


[05/42] incubator-mynewt-core git commit: Reflect repository name change in yml files. Types in packages. Move projects -> apps.

Posted by cc...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/apps/bletiny/src/cmd.c
----------------------------------------------------------------------
diff --git a/apps/bletiny/src/cmd.c b/apps/bletiny/src/cmd.c
new file mode 100644
index 0000000..ce66a8e
--- /dev/null
+++ b/apps/bletiny/src/cmd.c
@@ -0,0 +1,1479 @@
+/**
+ * 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 <errno.h>
+#include <string.h>
+#include "bsp/bsp.h"
+#include "console/console.h"
+#include "shell/shell.h"
+
+#include "nimble/ble.h"
+#include "nimble/hci_common.h"
+#include "host/ble_gap.h"
+#include "host/ble_hs_adv.h"
+#include "../src/ble_l2cap_priv.h"
+
+#include "bletiny_priv.h"
+
+#define CMD_BUF_SZ      256
+
+static int cmd_b_exec(int argc, char **argv);
+static struct shell_cmd cmd_b = {
+    .sc_cmd = "b",
+    .sc_cmd_func = cmd_b_exec
+};
+
+static bssnz_t uint8_t cmd_buf[CMD_BUF_SZ];
+
+/*****************************************************************************
+ * $misc                                                                     *
+ *****************************************************************************/
+
+static int
+cmd_exec(const struct cmd_entry *cmds, int argc, char **argv)
+{
+    const struct cmd_entry *cmd;
+    int rc;
+
+    if (argc <= 1) {
+        return parse_err_too_few_args(argv[0]);
+    }
+
+    cmd = parse_cmd_find(cmds, argv[1]);
+    if (cmd == NULL) {
+        BLETINY_LOG(ERROR, "Error: unknown %s command: %s\n",
+                    argv[0], argv[1]);
+        return -1;
+    }
+
+    rc = cmd->cb(argc - 1, argv + 1);
+    if (rc != 0) {
+        return rc;
+    }
+
+    return 0;
+}
+
+static void
+cmd_print_dsc(struct bletiny_dsc *dsc)
+{
+    BLETINY_LOG(INFO, "            dsc_handle=%d uuid=", dsc->dsc.handle);
+    print_uuid(dsc->dsc.uuid128);
+    BLETINY_LOG(INFO, "\n");
+}
+
+static void
+cmd_print_chr(struct bletiny_chr *chr)
+{
+    struct bletiny_dsc *dsc;
+
+    BLETINY_LOG(INFO, "        def_handle=%d val_handle=%d properties=0x%02x "
+                      "uuid=", chr->chr.decl_handle, chr->chr.value_handle,
+                chr->chr.properties);
+    print_uuid(chr->chr.uuid128);
+    BLETINY_LOG(INFO, "\n");
+
+    SLIST_FOREACH(dsc, &chr->dscs, next) {
+        cmd_print_dsc(dsc);
+    }
+}
+
+static void
+cmd_print_svc(struct bletiny_svc *svc, int print_chrs)
+{
+    struct bletiny_chr *chr;
+
+    BLETINY_LOG(INFO, "    start=%d end=%d uuid=", svc->svc.start_handle,
+                svc->svc.end_handle);
+    print_uuid(svc->svc.uuid128);
+    BLETINY_LOG(INFO, "\n");
+
+    if (print_chrs) {
+        SLIST_FOREACH(chr, &svc->chrs, next) {
+            cmd_print_chr(chr);
+        }
+    }
+}
+
+static int
+cmd_parse_conn_start_end(uint16_t *out_conn, uint16_t *out_start,
+                         uint16_t *out_end)
+{
+    int rc;
+
+    *out_conn = parse_arg_uint16("conn", &rc);
+    if (rc != 0) {
+        return rc;
+    }
+
+    *out_start = parse_arg_uint16("start", &rc);
+    if (rc != 0) {
+        return rc;
+    }
+
+    *out_end = parse_arg_uint16("end", &rc);
+    if (rc != 0) {
+        return rc;
+    }
+
+    return 0;
+}
+
+/*****************************************************************************
+ * $advertise                                                                *
+ *****************************************************************************/
+
+static struct kv_pair cmd_adv_conn_modes[] = {
+    { "non", BLE_GAP_CONN_MODE_NON },
+    { "und", BLE_GAP_CONN_MODE_UND },
+    { "dir", BLE_GAP_CONN_MODE_DIR },
+    { NULL }
+};
+
+static struct kv_pair cmd_adv_disc_modes[] = {
+    { "non", BLE_GAP_DISC_MODE_NON },
+    { "ltd", BLE_GAP_DISC_MODE_LTD },
+    { "gen", BLE_GAP_DISC_MODE_GEN },
+    { NULL }
+};
+
+static struct kv_pair cmd_adv_addr_types[] = {
+    { "public", BLE_ADDR_TYPE_PUBLIC },
+    { "random", BLE_ADDR_TYPE_RANDOM },
+    { NULL }
+};
+
+static struct kv_pair cmd_adv_filt_types[] = {
+    { "none", BLE_HCI_ADV_FILT_NONE },
+    { "scan", BLE_HCI_ADV_FILT_SCAN },
+    { "conn", BLE_HCI_ADV_FILT_CONN },
+    { "both", BLE_HCI_ADV_FILT_BOTH },
+};
+
+static int
+cmd_adv(int argc, char **argv)
+{
+    struct hci_adv_params params = {
+        .adv_itvl_min = 0,
+        .adv_itvl_max = 0,
+        .adv_type = BLE_HCI_ADV_TYPE_ADV_IND,
+        .own_addr_type = BLE_HCI_ADV_OWN_ADDR_PUBLIC,
+        .peer_addr_type = BLE_HCI_ADV_PEER_ADDR_PUBLIC,
+        .adv_channel_map = BLE_HCI_ADV_CHANMASK_DEF,
+        .adv_filter_policy = BLE_HCI_ADV_FILT_DEF,
+    };
+    uint8_t peer_addr[6];
+    uint8_t u8;
+    int addr_type;
+    int conn;
+    int disc;
+    int rc;
+
+    if (argc > 1 && strcmp(argv[1], "stop") == 0) {
+        rc = bletiny_adv_stop();
+        if (rc != 0) {
+            BLETINY_LOG(INFO, "advertise stop fail: %d\n", rc);
+            return rc;
+        }
+
+        return 0;
+    }
+
+    conn = parse_arg_kv("conn", cmd_adv_conn_modes);
+    if (conn == -1) {
+        BLETINY_LOG(ERROR, "invalid 'conn' parameter\n");
+        return -1;
+    }
+
+    disc = parse_arg_kv("disc", cmd_adv_disc_modes);
+    if (disc == -1) {
+        BLETINY_LOG(ERROR, "missing 'disc' parameter\n");
+        return -1;
+    }
+
+    if (conn == BLE_GAP_CONN_MODE_DIR) {
+        addr_type = parse_arg_kv("addr_type", cmd_adv_addr_types);
+        if (addr_type == -1) {
+            return -1;
+        }
+
+        rc = parse_arg_mac("addr", peer_addr);
+        if (rc != 0) {
+            return rc;
+        }
+    } else {
+        addr_type = 0;
+        memset(peer_addr, 0, sizeof peer_addr);
+    }
+
+    u8 = parse_arg_long_bounds("chan_map", 0, 0xff, &rc);
+    if (rc == 0) {
+        params.adv_channel_map = u8;
+    } else if (rc != ENOENT) {
+        return rc;
+    }
+
+    if (parse_arg_find("filt") != NULL) {
+        params.adv_filter_policy = parse_arg_kv("filt", cmd_adv_filt_types);
+        if (params.adv_filter_policy == -1) {
+            return EINVAL;
+        }
+    }
+
+    rc = bletiny_adv_start(disc, conn, peer_addr, addr_type, &params);
+    if (rc != 0) {
+        BLETINY_LOG(INFO, "advertise fail: %d\n", rc);
+        return rc;
+    }
+
+    return 0;
+}
+
+/*****************************************************************************
+ * $connect                                                                  *
+ *****************************************************************************/
+
+static struct kv_pair cmd_conn_addr_types[] = {
+    { "public",         BLE_HCI_CONN_PEER_ADDR_PUBLIC },
+    { "random",         BLE_HCI_CONN_PEER_ADDR_RANDOM },
+    { "public_ident",   BLE_HCI_CONN_PEER_ADDR_PUBLIC_IDENT },
+    { "random_ident",   BLE_HCI_CONN_PEER_ADDR_RANDOM_IDENT },
+    { "wl",             BLE_GAP_ADDR_TYPE_WL },
+    { NULL }
+};
+
+static int
+cmd_conn(int argc, char **argv)
+{
+    struct ble_gap_crt_params params;
+    uint8_t peer_addr[6];
+    int addr_type;
+    int rc;
+
+    if (argc > 1 && strcmp(argv[1], "cancel") == 0) {
+        rc = bletiny_conn_cancel();
+        if (rc != 0) {
+            BLETINY_LOG(INFO, "connection cancel fail: %d\n", rc);
+            return rc;
+        }
+
+        return 0;
+    }
+
+    addr_type = parse_arg_kv("addr_type", cmd_conn_addr_types);
+    if (addr_type == -1) {
+        return -1;
+    }
+
+    if (addr_type != BLE_GAP_ADDR_TYPE_WL) {
+        rc = parse_arg_mac("addr", peer_addr);
+        if (rc != 0) {
+            return rc;
+        }
+    } else {
+        memset(peer_addr, 0, sizeof peer_addr);
+    }
+
+    params.scan_itvl = parse_arg_uint16_dflt("scan_itvl", 0x0010, &rc);
+    if (rc != 0) {
+        return rc;
+    }
+
+    params.scan_window = parse_arg_uint16_dflt("scan_window", 0x0010, &rc);
+    if (rc != 0) {
+        return rc;
+    }
+
+    params.itvl_min = parse_arg_uint16_dflt(
+        "itvl_min", BLE_GAP_INITIAL_CONN_ITVL_MIN, &rc);
+    if (rc != 0) {
+        return rc;
+    }
+
+    params.itvl_max = parse_arg_uint16_dflt(
+        "itvl_max", BLE_GAP_INITIAL_CONN_ITVL_MAX, &rc);
+    if (rc != 0) {
+        return rc;
+    }
+
+    params.latency = parse_arg_uint16_dflt("latency", 0, &rc);
+    if (rc != 0) {
+        return rc;
+    }
+
+    params.supervision_timeout = parse_arg_uint16_dflt("timeout", 0x0100, &rc);
+    if (rc != 0) {
+        return rc;
+    }
+
+    params.min_ce_len = parse_arg_uint16_dflt("min_ce_len", 0x0010, &rc);
+    if (rc != 0) {
+        return rc;
+    }
+
+    params.max_ce_len = parse_arg_uint16_dflt("max_ce_len", 0x0300, &rc);
+    if (rc != 0) {
+        return rc;
+    }
+
+    rc = bletiny_conn_initiate(addr_type, peer_addr, &params);
+    if (rc != 0) {
+        return rc;
+    }
+
+    return 0;
+}
+
+/*****************************************************************************
+ * $connect                                                                  *
+ *****************************************************************************/
+
+static int
+cmd_chrup(int argc, char **argv)
+{
+    uint16_t attr_handle;
+    int rc;
+
+    attr_handle = parse_arg_long("attr", &rc);
+    if (rc != 0) {
+        return rc;
+    }
+
+    bletiny_chrup(attr_handle);
+
+    return 0;
+}
+
+/*****************************************************************************
+ * $discover                                                                 *
+ *****************************************************************************/
+
+static int
+cmd_disc_chr(int argc, char **argv)
+{
+    uint16_t start_handle;
+    uint16_t conn_handle;
+    uint16_t end_handle;
+    uint8_t uuid128[16];
+    int rc;
+
+    rc = cmd_parse_conn_start_end(&conn_handle, &start_handle, &end_handle);
+    if (rc != 0) {
+        return rc;
+    }
+
+    rc = parse_arg_uuid("uuid", uuid128);
+    if (rc == 0) {
+        rc = bletiny_disc_chrs_by_uuid(conn_handle, start_handle, end_handle,
+                                        uuid128);
+    } else if (rc == ENOENT) {
+        rc = bletiny_disc_all_chrs(conn_handle, start_handle, end_handle);
+    } else  {
+        return rc;
+    }
+    if (rc != 0) {
+        BLETINY_LOG(INFO, "error discovering characteristics; rc=%d\n", rc);
+        return rc;
+    }
+
+    return 0;
+}
+
+static int
+cmd_disc_dsc(int argc, char **argv)
+{
+    uint16_t start_handle;
+    uint16_t conn_handle;
+    uint16_t end_handle;
+    int rc;
+
+    rc = cmd_parse_conn_start_end(&conn_handle, &start_handle, &end_handle);
+    if (rc != 0) {
+        return rc;
+    }
+
+    rc = bletiny_disc_all_dscs(conn_handle, start_handle, end_handle);
+    if (rc != 0) {
+        BLETINY_LOG(INFO, "error discovering descriptors; rc=%d\n", rc);
+        return rc;
+    }
+
+    return 0;
+}
+
+static int
+cmd_disc_svc(int argc, char **argv)
+{
+    uint8_t uuid128[16];
+    int conn_handle;
+    int rc;
+
+    conn_handle = parse_arg_uint16("conn", &rc);
+    if (rc != 0) {
+        return rc;
+    }
+
+    rc = parse_arg_uuid("uuid", uuid128);
+    if (rc == 0) {
+        rc = bletiny_disc_svc_by_uuid(conn_handle, uuid128);
+    } else if (rc == ENOENT) {
+        rc = bletiny_disc_svcs(conn_handle);
+    } else  {
+        return rc;
+    }
+
+    if (rc != 0) {
+        BLETINY_LOG(INFO, "error discovering services; rc=%d\n", rc);
+        return rc;
+    }
+
+    return 0;
+}
+
+static struct cmd_entry cmd_disc_entries[] = {
+    { "chr", cmd_disc_chr },
+    { "dsc", cmd_disc_dsc },
+    { "svc", cmd_disc_svc },
+    { NULL, NULL }
+};
+
+static int
+cmd_disc(int argc, char **argv)
+{
+    int rc;
+
+    rc = cmd_exec(cmd_disc_entries, argc, argv);
+    if (rc != 0) {
+        return rc;
+    }
+
+    return 0;
+}
+
+/*****************************************************************************
+ * $find                                                                     *
+ *****************************************************************************/
+
+static int
+cmd_find_inc_svcs(int argc, char **argv)
+{
+    uint16_t start_handle;
+    uint16_t conn_handle;
+    uint16_t end_handle;
+    int rc;
+
+    rc = cmd_parse_conn_start_end(&conn_handle, &start_handle, &end_handle);
+    if (rc != 0) {
+        return rc;
+    }
+
+    rc = bletiny_find_inc_svcs(conn_handle, start_handle, end_handle);
+    if (rc != 0) {
+        BLETINY_LOG(INFO, "error finding included services; rc=%d\n", rc);
+        return rc;
+    }
+
+    return 0;
+}
+
+static const struct cmd_entry cmd_find_entries[] = {
+    { "inc_svcs", cmd_find_inc_svcs },
+    { NULL, NULL }
+};
+
+static int
+cmd_find(int argc, char **argv)
+{
+    int rc;
+
+    rc = cmd_exec(cmd_find_entries, argc, argv);
+    if (rc != 0) {
+        return rc;
+    }
+
+    return 0;
+}
+
+/*****************************************************************************
+ * $l2cap                                                                    *
+ *****************************************************************************/
+
+static int
+cmd_l2cap_update(int argc, char **argv)
+{
+    struct ble_l2cap_sig_update_params params;
+    uint16_t conn_handle;
+    int rc;
+
+    conn_handle = parse_arg_uint16("conn", &rc);
+    if (rc != 0) {
+        return rc;
+    }
+
+    params.itvl_min = parse_arg_uint16_dflt(
+        "itvl_min", BLE_GAP_INITIAL_CONN_ITVL_MIN, &rc);
+    if (rc != 0) {
+        return rc;
+    }
+
+    params.itvl_max = parse_arg_uint16_dflt(
+        "itvl_max", BLE_GAP_INITIAL_CONN_ITVL_MAX, &rc);
+    if (rc != 0) {
+        return rc;
+    }
+
+    params.slave_latency = parse_arg_uint16_dflt("latency", 0, &rc);
+    if (rc != 0) {
+        return rc;
+    }
+
+    params.timeout_multiplier = parse_arg_uint16_dflt("timeout", 0x0100, &rc);
+    if (rc != 0) {
+        return rc;
+    }
+
+    rc = bletiny_l2cap_update(conn_handle, &params);
+    if (rc != 0) {
+        BLETINY_LOG(INFO, "error txing l2cap update; rc=%d\n", rc);
+        return rc;
+    }
+
+    return 0;
+}
+
+static const struct cmd_entry cmd_l2cap_entries[] = {
+    { "update", cmd_l2cap_update },
+    { NULL, NULL }
+};
+
+static int
+cmd_l2cap(int argc, char **argv)
+{
+    int rc;
+
+    rc = cmd_exec(cmd_l2cap_entries, argc, argv);
+    if (rc != 0) {
+        return rc;
+    }
+
+    return 0;
+}
+
+/*****************************************************************************
+ * $mtu                                                                      *
+ *****************************************************************************/
+
+static int
+cmd_mtu(int argc, char **argv)
+{
+    uint16_t conn_handle;
+    int rc;
+
+    conn_handle = parse_arg_uint16("conn", &rc);
+    if (rc != 0) {
+        return rc;
+    }
+
+    rc = bletiny_exchange_mtu(conn_handle);
+    if (rc != 0) {
+        BLETINY_LOG(INFO, "error exchanging mtu; rc=%d\n", rc);
+        return rc;
+    }
+
+    return 0;
+}
+
+/*****************************************************************************
+ * $read                                                                     *
+ *****************************************************************************/
+
+#define CMD_READ_MAX_ATTRS  8
+
+static int
+cmd_read(int argc, char **argv)
+{
+    static uint16_t attr_handles[CMD_READ_MAX_ATTRS];
+    uint16_t conn_handle;
+    uint16_t start;
+    uint16_t end;
+    uint8_t uuid128[16];
+    uint8_t num_attr_handles;
+    int is_uuid;
+    int is_long;
+    int rc;
+
+    conn_handle = parse_arg_uint16("conn", &rc);
+    if (rc != 0) {
+        return rc;
+    }
+
+    is_long = parse_arg_long("long", &rc);
+    if (rc == ENOENT) {
+        is_long = 0;
+    } else if (rc != 0) {
+        return rc;
+    }
+
+    for (num_attr_handles = 0;
+         num_attr_handles < CMD_READ_MAX_ATTRS;
+         num_attr_handles++) {
+
+        attr_handles[num_attr_handles] = parse_arg_uint16("attr", &rc);
+        if (rc == ENOENT) {
+            break;
+        } else if (rc != 0) {
+            return rc;
+        }
+    }
+
+    rc = parse_arg_uuid("uuid", uuid128);
+    if (rc == ENOENT) {
+        is_uuid = 0;
+    } else if (rc == 0) {
+        is_uuid = 1;
+    } else {
+        return rc;
+    }
+
+    start = parse_arg_uint16("start", &rc);
+    if (rc == ENOENT) {
+        start = 0;
+    } else if (rc != 0) {
+        return rc;
+    }
+
+    end = parse_arg_uint16("end", &rc);
+    if (rc == ENOENT) {
+        end = 0;
+    } else if (rc != 0) {
+        return rc;
+    }
+
+    if (num_attr_handles == 1) {
+        if (is_long) {
+            rc = bletiny_read_long(conn_handle, attr_handles[0]);
+        } else {
+            rc = bletiny_read(conn_handle, attr_handles[0]);
+        }
+    } else if (num_attr_handles > 1) {
+        rc = bletiny_read_mult(conn_handle, attr_handles, num_attr_handles);
+    } else if (is_uuid) {
+        if (start == 0 || end == 0) {
+            rc = EINVAL;
+        } else {
+            rc = bletiny_read_by_uuid(conn_handle, start, end, uuid128);
+        }
+    } else {
+        rc = EINVAL;
+    }
+
+    if (rc != 0) {
+        BLETINY_LOG(INFO, "error reading characteristic; rc=%d\n", rc);
+        return rc;
+    }
+
+    return 0;
+}
+
+/*****************************************************************************
+ * $scan                                                                     *
+ *****************************************************************************/
+
+static struct kv_pair cmd_scan_disc_modes[] = {
+    { "ltd", BLE_GAP_DISC_MODE_LTD },
+    { "gen", BLE_GAP_DISC_MODE_GEN },
+    { NULL }
+};
+
+static struct kv_pair cmd_scan_types[] = {
+    { "passive", BLE_HCI_SCAN_TYPE_PASSIVE },
+    { "active", BLE_HCI_SCAN_TYPE_ACTIVE },
+    { NULL }
+};
+
+static struct kv_pair cmd_scan_filt_policies[] = {
+    { "no_wl", BLE_HCI_SCAN_FILT_NO_WL },
+    { "use_wl", BLE_HCI_SCAN_FILT_USE_WL },
+    { "no_wl_inita", BLE_HCI_SCAN_FILT_NO_WL_INITA },
+    { "use_wl_inita", BLE_HCI_SCAN_FILT_USE_WL_INITA },
+    { NULL }
+};
+
+static int
+cmd_scan(int argc, char **argv)
+{
+    uint32_t dur;
+    int disc;
+    int type;
+    int filt;
+    int rc;
+
+    dur = parse_arg_uint16("dur", &rc);
+    if (rc != 0) {
+        return rc;
+    }
+
+    disc = parse_arg_kv("disc", cmd_scan_disc_modes);
+    if (disc == -1) {
+        return EINVAL;
+    }
+
+    type = parse_arg_kv("type", cmd_scan_types);
+    if (type == -1) {
+        return EINVAL;
+    }
+
+    filt = parse_arg_kv("filt", cmd_scan_filt_policies);
+    if (disc == -1) {
+        return EINVAL;
+    }
+
+    rc = bletiny_scan(dur, disc, type, filt);
+    if (rc != 0) {
+        BLETINY_LOG(INFO, "error scanning; rc=%d\n", rc);
+        return rc;
+    }
+
+    return 0;
+}
+
+/*****************************************************************************
+ * $show                                                                     *
+ *****************************************************************************/
+
+static int
+cmd_show_addr(int argc, char **argv)
+{
+    bletiny_lock();
+
+    BLETINY_LOG(INFO, "myaddr=");
+    print_addr(g_dev_addr);
+    BLETINY_LOG(INFO, "\n");
+
+    bletiny_unlock();
+
+    return 0;
+}
+
+static int
+cmd_show_chr(int argc, char **argv)
+{
+    struct bletiny_conn *conn;
+    struct bletiny_svc *svc;
+    int i;
+
+    bletiny_lock();
+
+    for (i = 0; i < bletiny_num_conns; i++) {
+        conn = bletiny_conns + i;
+
+        BLETINY_LOG(INFO, "CONNECTION: handle=%d addr=", conn->handle);
+        print_addr(conn->addr);
+        BLETINY_LOG(INFO, "\n");
+
+        SLIST_FOREACH(svc, &conn->svcs, next) {
+            cmd_print_svc(svc, 1);
+        }
+    }
+
+    bletiny_unlock();
+
+    return 0;
+}
+
+static int
+cmd_show_conn(int argc, char **argv)
+{
+    struct bletiny_conn *conn;
+    int i;
+
+    bletiny_lock();
+
+    for (i = 0; i < bletiny_num_conns; i++) {
+        conn = bletiny_conns + i;
+
+        BLETINY_LOG(INFO, "handle=%d addr=", conn->handle);
+        print_addr(conn->addr);
+        BLETINY_LOG(INFO, " addr_type=%d\n", conn->addr_type);
+    }
+
+    bletiny_unlock();
+
+    return 0;
+}
+
+static int
+cmd_show_rssi(int argc, char **argv)
+{
+    uint16_t conn_handle;
+    int rc;
+
+    conn_handle = parse_arg_uint16("conn", &rc);
+    if (rc != 0) {
+        return rc;
+    }
+
+    rc = bletiny_show_rssi(conn_handle);
+    if (rc != 0) {
+        return rc;
+    }
+
+    return 0;
+}
+
+static int
+cmd_show_svc(int argc, char **argv)
+{
+    struct bletiny_conn *conn;
+    struct bletiny_svc *svc;
+    int i;
+
+    bletiny_lock();
+
+    for (i = 0; i < bletiny_num_conns; i++) {
+        conn = bletiny_conns + i;
+
+        BLETINY_LOG(INFO, "CONNECTION: handle=%d addr=", conn->handle);
+        print_addr(conn->addr);
+        BLETINY_LOG(INFO, "\n");
+
+        SLIST_FOREACH(svc, &conn->svcs, next) {
+            cmd_print_svc(svc, 0);
+        }
+    }
+
+    bletiny_unlock();
+
+    return 0;
+}
+
+static struct cmd_entry cmd_show_entries[] = {
+    { "addr", cmd_show_addr },
+    { "chr", cmd_show_chr },
+    { "conn", cmd_show_conn },
+    { "rssi", cmd_show_rssi },
+    { "svc", cmd_show_svc },
+    { NULL, NULL }
+};
+
+static int
+cmd_show(int argc, char **argv)
+{
+    int rc;
+
+    rc = cmd_exec(cmd_show_entries, argc, argv);
+    if (rc != 0) {
+        return rc;
+    }
+
+    return 0;
+}
+
+/*****************************************************************************
+ * $set                                                                      *
+ *****************************************************************************/
+
+#define CMD_ADV_DATA_MAX_UUIDS16                8
+#define CMD_ADV_DATA_MAX_UUIDS32                8
+#define CMD_ADV_DATA_MAX_UUIDS128               8
+#define CMD_ADV_DATA_MAX_PUBLIC_TGT_ADDRS       8
+#define CMD_ADV_DATA_SVC_DATA_UUID16_MAX_LEN    32
+#define CMD_ADV_DATA_SVC_DATA_UUID32_MAX_LEN    32
+#define CMD_ADV_DATA_SVC_DATA_UUID128_MAX_LEN   32
+#define CMD_ADV_DATA_URI_MAX_LEN                32
+#define CMD_ADV_DATA_MFG_DATA_MAX_LEN           32
+
+static int
+cmd_set_adv_data(void)
+{
+    static bssnz_t uint16_t uuids16[CMD_ADV_DATA_MAX_UUIDS16];
+    static bssnz_t uint32_t uuids32[CMD_ADV_DATA_MAX_UUIDS32];
+    static bssnz_t uint8_t uuids128[CMD_ADV_DATA_MAX_UUIDS128][16];
+    static bssnz_t uint8_t
+        public_tgt_addrs[CMD_ADV_DATA_MAX_PUBLIC_TGT_ADDRS]
+                        [BLE_HS_ADV_PUBLIC_TGT_ADDR_ENTRY_LEN];
+    static bssnz_t uint8_t device_class[BLE_HS_ADV_DEVICE_CLASS_LEN];
+    static bssnz_t uint8_t slave_itvl_range[BLE_HS_ADV_SLAVE_ITVL_RANGE_LEN];
+    static bssnz_t uint8_t
+        svc_data_uuid16[CMD_ADV_DATA_SVC_DATA_UUID16_MAX_LEN];
+    static bssnz_t uint8_t
+        svc_data_uuid32[CMD_ADV_DATA_SVC_DATA_UUID32_MAX_LEN];
+    static bssnz_t uint8_t
+        svc_data_uuid128[CMD_ADV_DATA_SVC_DATA_UUID128_MAX_LEN];
+    static bssnz_t uint8_t le_addr[BLE_HS_ADV_LE_ADDR_LEN];
+    static bssnz_t uint8_t uri[CMD_ADV_DATA_URI_MAX_LEN];
+    static bssnz_t uint8_t mfg_data[CMD_ADV_DATA_MFG_DATA_MAX_LEN];
+    struct ble_hs_adv_fields adv_fields;
+    uint32_t uuid32;
+    uint16_t uuid16;
+    uint8_t uuid128[16];
+    uint8_t public_tgt_addr[BLE_HS_ADV_PUBLIC_TGT_ADDR_ENTRY_LEN];
+    int svc_data_uuid16_len;
+    int svc_data_uuid32_len;
+    int svc_data_uuid128_len;
+    int uri_len;
+    int mfg_data_len;
+    int tmp;
+    int rc;
+
+    memset(&adv_fields, 0, sizeof adv_fields);
+
+    while (1) {
+        uuid16 = parse_arg_uint16("uuid16", &rc);
+        if (rc == 0) {
+            if (adv_fields.num_uuids16 >= CMD_ADV_DATA_MAX_UUIDS16) {
+                return EINVAL;
+            }
+            uuids16[adv_fields.num_uuids16] = uuid16;
+            adv_fields.num_uuids16++;
+        } else if (rc == ENOENT) {
+            break;
+        } else {
+            return rc;
+        }
+    }
+    if (adv_fields.num_uuids16 > 0) {
+        adv_fields.uuids16 = uuids16;
+    }
+
+    tmp = parse_arg_long("uuids16_is_complete", &rc);
+    if (rc == 0) {
+        adv_fields.uuids16_is_complete = !!tmp;
+    } else if (rc != ENOENT) {
+        return rc;
+    }
+
+    while (1) {
+        uuid32 = parse_arg_uint32("uuid32", &rc);
+        if (rc == 0) {
+            if (adv_fields.num_uuids32 >= CMD_ADV_DATA_MAX_UUIDS32) {
+                return EINVAL;
+            }
+            uuids32[adv_fields.num_uuids32] = uuid32;
+            adv_fields.num_uuids32++;
+        } else if (rc == ENOENT) {
+            break;
+        } else {
+            return rc;
+        }
+    }
+    if (adv_fields.num_uuids32 > 0) {
+        adv_fields.uuids32 = uuids32;
+    }
+
+    tmp = parse_arg_long("uuids32_is_complete", &rc);
+    if (rc == 0) {
+        adv_fields.uuids32_is_complete = !!tmp;
+    } else if (rc != ENOENT) {
+        return rc;
+    }
+
+    while (1) {
+        rc = parse_arg_byte_stream_exact_length("uuid128", uuid128, 16);
+        if (rc == 0) {
+            if (adv_fields.num_uuids128 >= CMD_ADV_DATA_MAX_UUIDS128) {
+                return EINVAL;
+            }
+            memcpy(uuids128[adv_fields.num_uuids128], uuid128, 16);
+            adv_fields.num_uuids128++;
+        } else if (rc == ENOENT) {
+            break;
+        } else {
+            return rc;
+        }
+    }
+    if (adv_fields.num_uuids128 > 0) {
+        adv_fields.uuids128 = uuids128;
+    }
+
+    tmp = parse_arg_long("uuids128_is_complete", &rc);
+    if (rc == 0) {
+        adv_fields.uuids128_is_complete = !!tmp;
+    } else if (rc != ENOENT) {
+        return rc;
+    }
+
+    adv_fields.name = (uint8_t *)parse_arg_find("name");
+    if (adv_fields.name != NULL) {
+        adv_fields.name_len = strlen((char *)adv_fields.name);
+    }
+
+    tmp = parse_arg_long_bounds("tx_pwr_lvl", 0, 0xff, &rc);
+    if (rc == 0) {
+        adv_fields.tx_pwr_lvl = tmp;
+        adv_fields.tx_pwr_lvl_is_present = 1;
+    } else if (rc != ENOENT) {
+        return rc;
+    }
+
+    rc = parse_arg_byte_stream_exact_length("device_class", device_class,
+                                            BLE_HS_ADV_DEVICE_CLASS_LEN);
+    if (rc == 0) {
+        adv_fields.device_class = device_class;
+    } else if (rc != ENOENT) {
+        return rc;
+    }
+
+    rc = parse_arg_byte_stream_exact_length("slave_itvl_range",
+                                            slave_itvl_range,
+                                            BLE_HS_ADV_SLAVE_ITVL_RANGE_LEN);
+    if (rc == 0) {
+        adv_fields.slave_itvl_range = slave_itvl_range;
+    } else if (rc != ENOENT) {
+        return rc;
+    }
+
+    rc = parse_arg_byte_stream("svc_data_uuid16",
+                               CMD_ADV_DATA_SVC_DATA_UUID16_MAX_LEN,
+                               svc_data_uuid16, &svc_data_uuid16_len);
+    if (rc == 0) {
+        adv_fields.svc_data_uuid16 = svc_data_uuid16;
+        adv_fields.svc_data_uuid16_len = svc_data_uuid16_len;
+    } else if (rc != ENOENT) {
+        return rc;
+    }
+
+    while (1) {
+        rc = parse_arg_byte_stream_exact_length(
+            "public_tgt_addr", public_tgt_addr,
+            BLE_HS_ADV_PUBLIC_TGT_ADDR_ENTRY_LEN);
+        if (rc == 0) {
+            if (adv_fields.num_public_tgt_addrs >=
+                CMD_ADV_DATA_MAX_PUBLIC_TGT_ADDRS) {
+
+                return EINVAL;
+            }
+            memcpy(public_tgt_addrs[adv_fields.num_public_tgt_addrs],
+                   public_tgt_addr, BLE_HS_ADV_PUBLIC_TGT_ADDR_ENTRY_LEN);
+            adv_fields.num_public_tgt_addrs++;
+        } else if (rc == ENOENT) {
+            break;
+        } else {
+            return rc;
+        }
+    }
+    if (adv_fields.num_public_tgt_addrs > 0) {
+        adv_fields.public_tgt_addr = (void *)public_tgt_addrs;
+    }
+
+    adv_fields.appearance = parse_arg_uint16("appearance", &rc);
+    if (rc == 0) {
+        adv_fields.appearance_is_present = 1;
+    } else if (rc != ENOENT) {
+        return rc;
+    }
+
+    adv_fields.adv_itvl = parse_arg_uint16("adv_itvl", &rc);
+    if (rc == 0) {
+        adv_fields.adv_itvl_is_present = 1;
+    } else if (rc != ENOENT) {
+        return rc;
+    }
+
+    rc = parse_arg_byte_stream_exact_length("le_addr", le_addr,
+                                            BLE_HS_ADV_LE_ADDR_LEN);
+    if (rc == 0) {
+        adv_fields.le_addr = le_addr;
+    } else if (rc != ENOENT) {
+        return rc;
+    }
+
+    adv_fields.le_role = parse_arg_long_bounds("le_role", 0, 0xff, &rc);
+    if (rc == 0) {
+        adv_fields.le_role_is_present = 1;
+    } else if (rc != ENOENT) {
+        return rc;
+    }
+
+    rc = parse_arg_byte_stream("svc_data_uuid32",
+                               CMD_ADV_DATA_SVC_DATA_UUID32_MAX_LEN,
+                               svc_data_uuid32, &svc_data_uuid32_len);
+    if (rc == 0) {
+        adv_fields.svc_data_uuid32 = svc_data_uuid32;
+        adv_fields.svc_data_uuid32_len = svc_data_uuid32_len;
+    } else if (rc != ENOENT) {
+        return rc;
+    }
+
+    rc = parse_arg_byte_stream("svc_data_uuid128",
+                               CMD_ADV_DATA_SVC_DATA_UUID128_MAX_LEN,
+                               svc_data_uuid128, &svc_data_uuid128_len);
+    if (rc == 0) {
+        adv_fields.svc_data_uuid128 = svc_data_uuid128;
+        adv_fields.svc_data_uuid128_len = svc_data_uuid128_len;
+    } else if (rc != ENOENT) {
+        return rc;
+    }
+
+    rc = parse_arg_byte_stream("uri", CMD_ADV_DATA_URI_MAX_LEN, uri, &uri_len);
+    if (rc == 0) {
+        adv_fields.uri = uri;
+        adv_fields.uri_len = uri_len;
+    } else if (rc != ENOENT) {
+        return rc;
+    }
+
+    rc = parse_arg_byte_stream("mfg_data", CMD_ADV_DATA_MFG_DATA_MAX_LEN,
+                               mfg_data, &mfg_data_len);
+    if (rc == 0) {
+        adv_fields.mfg_data = mfg_data;
+        adv_fields.mfg_data_len = mfg_data_len;
+    } else if (rc != ENOENT) {
+        return rc;
+    }
+
+    rc = bletiny_set_adv_data(&adv_fields);
+    if (rc != 0) {
+        BLETINY_LOG(INFO, "error setting advertisement data; rc=%d\n", rc);
+        return rc;
+    }
+
+    return 0;
+}
+
+static int
+cmd_set(int argc, char **argv)
+{
+    uint16_t mtu;
+    uint8_t addr[6];
+    int good;
+    int rc;
+
+    if (argc > 1 && strcmp(argv[1], "adv_data") == 0) {
+        rc = cmd_set_adv_data();
+        return rc;
+    }
+
+    good = 0;
+
+    rc = parse_arg_mac("addr", addr);
+    if (rc == 0) {
+        good = 1;
+        memcpy(g_dev_addr, addr, 6);
+    } else if (rc != ENOENT) {
+        return rc;
+    }
+
+    mtu = parse_arg_uint16("mtu", &rc);
+    if (rc == 0) {
+        rc = ble_att_set_preferred_mtu(mtu);
+        if (rc == 0) {
+            good = 1;
+        }
+    } else if (rc != ENOENT) {
+        return rc;
+    }
+
+    if (!good) {
+        BLETINY_LOG(ERROR, "Error: no valid settings specified\n");
+        return -1;
+    }
+
+    return 0;
+}
+
+/*****************************************************************************
+ * $terminate                                                                *
+ *****************************************************************************/
+
+static int
+cmd_term(int argc, char **argv)
+{
+    uint16_t conn_handle;
+    int rc;
+
+    conn_handle = parse_arg_uint16("conn", &rc);
+    if (rc != 0) {
+        return rc;
+    }
+
+    rc = bletiny_term_conn(conn_handle);
+    if (rc != 0) {
+        BLETINY_LOG(INFO, "error terminating connection; rc=%d\n", rc);
+        return rc;
+    }
+
+    return 0;
+}
+
+/*****************************************************************************
+ * $update connection parameters                                             *
+ *****************************************************************************/
+
+static int
+cmd_update(int argc, char **argv)
+{
+    struct ble_gap_upd_params params;
+    uint16_t conn_handle;
+    int rc;
+
+    conn_handle = parse_arg_uint16("conn", &rc);
+    if (rc != 0) {
+        return rc;
+    }
+
+    params.itvl_min = parse_arg_uint16_dflt(
+        "itvl_min", BLE_GAP_INITIAL_CONN_ITVL_MIN, &rc);
+    if (rc != 0) {
+        return rc;
+    }
+
+    params.itvl_max = parse_arg_uint16_dflt(
+        "itvl_max", BLE_GAP_INITIAL_CONN_ITVL_MAX, &rc);
+    if (rc != 0) {
+        return rc;
+    }
+
+    params.latency = parse_arg_uint16_dflt("latency", 0, &rc);
+    if (rc != 0) {
+        return rc;
+    }
+
+    params.supervision_timeout = parse_arg_uint16_dflt("timeout", 0x0100, &rc);
+    if (rc != 0) {
+        return rc;
+    }
+
+    params.min_ce_len = parse_arg_uint16_dflt("min_ce_len", 0x0010, &rc);
+    if (rc != 0) {
+        return rc;
+    }
+
+    params.max_ce_len = parse_arg_uint16_dflt("max_ce_len", 0x0300, &rc);
+    if (rc != 0) {
+        return rc;
+    }
+
+    rc = bletiny_update_conn(conn_handle, &params);
+    if (rc != 0) {
+        BLETINY_LOG(INFO, "error updating connection; rc=%d\n", rc);
+        return rc;
+    }
+
+    return 0;
+}
+
+/*****************************************************************************
+ * $white list                                                               *
+ *****************************************************************************/
+
+static struct kv_pair cmd_wl_addr_types[] = {
+    { "public",         BLE_HCI_CONN_PEER_ADDR_PUBLIC },
+    { "random",         BLE_HCI_CONN_PEER_ADDR_RANDOM },
+    { NULL }
+};
+
+#define CMD_WL_MAX_SZ   8
+
+static int
+cmd_wl(int argc, char **argv)
+{
+    static struct ble_gap_white_entry white_list[CMD_WL_MAX_SZ];
+    uint8_t addr_type;
+    uint8_t addr[6];
+    int wl_cnt;
+    int rc;
+
+    wl_cnt = 0;
+    while (1) {
+        if (wl_cnt >= CMD_WL_MAX_SZ) {
+            return EINVAL;
+        }
+
+        rc = parse_arg_mac("addr", addr);
+        if (rc == ENOENT) {
+            break;
+        } else if (rc != 0) {
+            return rc;
+        }
+
+        addr_type = parse_arg_kv("addr_type", cmd_wl_addr_types);
+        if (addr_type == -1) {
+            return EINVAL;
+        }
+
+        memcpy(white_list[wl_cnt].addr, addr, 6);
+        white_list[wl_cnt].addr_type = addr_type;
+        wl_cnt++;
+    }
+
+    if (wl_cnt == 0) {
+        return EINVAL;
+    }
+
+    bletiny_wl_set(white_list, wl_cnt);
+
+    return 0;
+}
+
+/*****************************************************************************
+ * $write                                                                    *
+ *****************************************************************************/
+
+#define CMD_WRITE_MAX_ATTRS 16
+
+static int
+cmd_write(int argc, char **argv)
+{
+    static struct ble_gatt_attr attrs[CMD_WRITE_MAX_ATTRS];
+    uint16_t attr_handle;
+    uint16_t conn_handle;
+    int total_attr_len;
+    int num_attrs;
+    int attr_len;
+    int is_long;
+    int no_rsp;
+    int rc;
+
+    conn_handle = parse_arg_uint16("conn", &rc);
+    if (rc != 0) {
+        return rc;
+    }
+
+    no_rsp = parse_arg_long("no_rsp", &rc);
+    if (rc == ENOENT) {
+        no_rsp = 0;
+    } else if (rc != 0) {
+        return rc;
+    }
+
+    is_long = parse_arg_long("long", &rc);
+    if (rc == ENOENT) {
+        is_long = 0;
+    } else if (rc != 0) {
+        return rc;
+    }
+
+    total_attr_len = 0;
+    num_attrs = 0;
+    while (1) {
+        attr_handle = parse_arg_long("attr", &rc);
+        if (rc == ENOENT) {
+            break;
+        } else if (rc != 0) {
+            return rc;
+        }
+
+        rc = parse_arg_byte_stream("value", sizeof cmd_buf - total_attr_len,
+                                   cmd_buf + total_attr_len, &attr_len);
+        if (rc == ENOENT) {
+            break;
+        } else if (rc != 0) {
+            return rc;
+        }
+
+        if (num_attrs >= CMD_WRITE_MAX_ATTRS) {
+            return EINVAL;
+        }
+
+        attrs[num_attrs].handle = attr_handle;
+        attrs[num_attrs].offset = 0;
+        attrs[num_attrs].value_len = attr_len;
+        attrs[num_attrs].value = cmd_buf + total_attr_len;
+
+        total_attr_len += attr_len;
+        num_attrs++;
+    }
+
+    if (no_rsp) {
+        if (num_attrs != 1) {
+            return EINVAL;
+        }
+        rc = bletiny_write_no_rsp(conn_handle, attrs[0].handle,
+                                   attrs[0].value, attrs[0].value_len);
+    } else if (is_long) {
+        if (num_attrs != 1) {
+            return EINVAL;
+        }
+        rc = bletiny_write_long(conn_handle, attrs[0].handle,
+                                 attrs[0].value, attrs[0].value_len);
+    } else if (num_attrs > 1) {
+        rc = bletiny_write_reliable(conn_handle, attrs, num_attrs);
+    } else if (num_attrs == 1) {
+        rc = bletiny_write(conn_handle, attrs[0].handle,
+                            attrs[0].value, attrs[0].value_len);
+    } else {
+        return EINVAL;
+    }
+
+    if (rc != 0) {
+        BLETINY_LOG(INFO, "error writing characteristic; rc=%d\n", rc);
+        return rc;
+    }
+
+    return 0;
+}
+
+/*****************************************************************************
+ * $init                                                                     *
+ *****************************************************************************/
+
+static struct cmd_entry cmd_b_entries[] = {
+    { "adv",        cmd_adv },
+    { "conn",       cmd_conn },
+    { "chrup",      cmd_chrup },
+    { "disc",       cmd_disc },
+    { "find",       cmd_find },
+    { "l2cap",      cmd_l2cap },
+    { "mtu",        cmd_mtu },
+    { "read",       cmd_read },
+    { "scan",       cmd_scan },
+    { "show",       cmd_show },
+    { "set",        cmd_set },
+    { "term",       cmd_term },
+    { "update",     cmd_update },
+    { "wl",         cmd_wl },
+    { "write",      cmd_write },
+    { NULL, NULL }
+};
+
+static int
+cmd_b_exec(int argc, char **argv)
+{
+    int rc;
+
+    rc = parse_arg_all(argc - 1, argv + 1);
+    if (rc != 0) {
+        goto done;
+    }
+
+    rc = cmd_exec(cmd_b_entries, argc, argv);
+    if (rc != 0) {
+        BLETINY_LOG(ERROR, "error\n");
+        goto done;
+    }
+
+    rc = 0;
+
+done:
+    return rc;
+}
+
+int
+cmd_init(void)
+{
+    int rc;
+
+    rc = shell_cmd_register(&cmd_b);
+    if (rc != 0) {
+        return rc;
+    }
+
+    return 0;
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/apps/bletiny/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bletiny/src/main.c b/apps/bletiny/src/main.c
new file mode 100755
index 0000000..cf482ad
--- /dev/null
+++ b/apps/bletiny/src/main.c
@@ -0,0 +1,1467 @@
+/**
+ * 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 "bsp/bsp.h"
+#include "log/log.h"
+#include "stats/stats.h"
+#include "os/os.h"
+#include "bsp/bsp.h"
+#include "hal/hal_gpio.h"
+#include "hal/hal_cputime.h"
+#include "console/console.h"
+#include "shell/shell.h"
+#include "bletiny_priv.h"
+
+/* BLE */
+#include "nimble/ble.h"
+#include "nimble/nimble_opt.h"
+#include "host/host_hci.h"
+#include "host/ble_hs.h"
+#include "host/ble_hs_adv.h"
+#include "host/ble_uuid.h"
+#include "host/ble_att.h"
+#include "host/ble_gap.h"
+#include "host/ble_gatt.h"
+#include "controller/ble_ll.h"
+#include "../src/ble_hs_conn.h"
+#include "../src/ble_hci_sched.h"
+
+#define BSWAP16(x)  ((uint16_t)(((x) << 8) | (((x) & 0xff00) >> 8)))
+
+/* Task 1 */
+#define HOST_TASK_PRIO          (1)
+
+#define SHELL_TASK_PRIO         (3)
+#define SHELL_MAX_INPUT_LEN     (64)
+#define SHELL_TASK_STACK_SIZE   (OS_STACK_ALIGN(216))
+static bssnz_t os_stack_t shell_stack[SHELL_TASK_STACK_SIZE];
+
+static struct os_mutex bletiny_mutex;
+
+/* Our global device address (public) */
+uint8_t g_dev_addr[BLE_DEV_ADDR_LEN];
+
+/* Our random address (in case we need it) */
+uint8_t g_random_addr[BLE_DEV_ADDR_LEN];
+
+/* A buffer for host advertising data */
+uint8_t g_host_adv_data[BLE_HCI_MAX_ADV_DATA_LEN];
+uint8_t g_host_adv_len;
+
+static uint8_t bletiny_addr[6] = {0x03, 0x02, 0x01, 0x50, 0x13, 0x00};
+
+/* Create a mbuf pool of BLE mbufs */
+#define MBUF_NUM_MBUFS      (7)
+#define MBUF_BUF_SIZE       OS_ALIGN(BLE_MBUF_PAYLOAD_SIZE, 4)
+#define MBUF_MEMBLOCK_SIZE  (MBUF_BUF_SIZE + BLE_MBUF_MEMBLOCK_OVERHEAD)
+#define MBUF_MEMPOOL_SIZE   OS_MEMPOOL_SIZE(MBUF_NUM_MBUFS, MBUF_MEMBLOCK_SIZE)
+
+os_membuf_t default_mbuf_mpool_data[MBUF_MEMPOOL_SIZE];
+
+struct os_mbuf_pool default_mbuf_pool;
+struct os_mempool default_mbuf_mpool;
+
+/* BLETINY variables */
+#define BLETINY_STACK_SIZE             (OS_STACK_ALIGN(200))
+#define BLETINY_TASK_PRIO              (HOST_TASK_PRIO + 1)
+
+#if NIMBLE_OPT_ROLE_CENTRAL
+#define BLETINY_MAX_SVCS               32
+#define BLETINY_MAX_CHRS               64
+#define BLETINY_MAX_DSCS               64
+#else
+#define BLETINY_MAX_SVCS               1
+#define BLETINY_MAX_CHRS               1
+#define BLETINY_MAX_DSCS               1
+#endif
+
+struct os_eventq g_bletiny_evq;
+struct os_task bletiny_task;
+bssnz_t os_stack_t bletiny_stack[BLETINY_STACK_SIZE];
+
+static struct log_handler bletiny_log_console_handler;
+struct log bletiny_log;
+
+struct bletiny_conn ble_shell_conns[NIMBLE_OPT_MAX_CONNECTIONS];
+int bletiny_num_conns;
+
+void
+bletest_inc_adv_pkt_num(void) { }
+
+bssnz_t struct bletiny_conn bletiny_conns[NIMBLE_OPT_MAX_CONNECTIONS];
+int bletiny_num_conns;
+
+static void *bletiny_svc_mem;
+static struct os_mempool bletiny_svc_pool;
+
+static void *bletiny_chr_mem;
+static struct os_mempool bletiny_chr_pool;
+
+static void *bletiny_dsc_mem;
+static struct os_mempool bletiny_dsc_pool;
+
+const char *bletiny_device_name = "nimble-bletiny";
+const uint16_t bletiny_appearance = BSWAP16(BLE_GAP_APPEARANCE_GEN_COMPUTER);
+const uint8_t bletiny_privacy_flag = 0;
+uint8_t bletiny_reconnect_addr[6];
+uint8_t bletiny_pref_conn_params[8];
+uint8_t bletiny_gatt_service_changed[4];
+
+#define XSTR(s) STR(s)
+#define STR(s) #s
+
+#ifdef DEVICE_NAME
+#define BLETINY_AUTO_DEVICE_NAME    XSTR(DEVICE_NAME)
+#else
+#define BLETINY_AUTO_DEVICE_NAME    NULL
+#endif
+
+void
+bletiny_lock(void)
+{
+    int rc;
+
+    rc = os_mutex_pend(&bletiny_mutex, 0xffffffff);
+    assert(rc == 0 || rc == OS_NOT_STARTED);
+}
+
+void
+bletiny_unlock(void)
+{
+    int rc;
+
+    rc = os_mutex_release(&bletiny_mutex);
+    assert(rc == 0 || rc == OS_NOT_STARTED);
+}
+
+static void
+bletiny_print_error(char *msg, uint16_t conn_handle,
+                    struct ble_gatt_error *error)
+{
+    BLETINY_LOG(INFO, "%s: conn_handle=%d status=%d att_handle=%d\n",
+                msg, conn_handle, error->status, error->att_handle);
+}
+
+static void
+bletiny_print_bytes(uint8_t *bytes, int len)
+{
+    int i;
+
+    for (i = 0; i < len; i++) {
+        BLETINY_LOG(INFO, "%s0x%02x", i != 0 ? ":" : "", bytes[i]);
+    }
+}
+
+static void
+bletiny_print_conn_desc(struct ble_gap_conn_desc *desc)
+{
+    BLETINY_LOG(INFO, "handle=%d peer_addr_type=%d peer_addr=",
+                desc->conn_handle, desc->peer_addr_type);
+    bletiny_print_bytes(desc->peer_addr, 6);
+    BLETINY_LOG(INFO, " conn_itvl=%d conn_latency=%d supervision_timeout=%d",
+                desc->conn_itvl, desc->conn_latency,
+                desc->supervision_timeout);
+}
+
+static void
+bletiny_print_adv_fields(struct ble_hs_adv_fields *fields)
+{
+    uint32_t u32;
+    uint16_t u16;
+    uint8_t *u8p;
+    int i;
+
+    if (fields->flags_is_present) {
+        BLETINY_LOG(INFO, "    flags=0x%02x\n", fields->flags);
+    }
+
+    if (fields->uuids16 != NULL) {
+        BLETINY_LOG(INFO, "    uuids16(%scomplete)=",
+                    fields->uuids16_is_complete ? "" : "in");
+        u8p = fields->uuids16;
+        for (i = 0; i < fields->num_uuids16; i++) {
+            memcpy(&u16, u8p + i * 2, 2);
+            BLETINY_LOG(INFO, "0x%04x ", u16);
+        }
+        BLETINY_LOG(INFO, "\n");
+    }
+
+    if (fields->uuids32 != NULL) {
+        BLETINY_LOG(INFO, "    uuids32(%scomplete)=",
+                    fields->uuids32_is_complete ? "" : "in");
+        u8p = fields->uuids32;
+        for (i = 0; i < fields->num_uuids32; i++) {
+            memcpy(&u32, u8p + i * 4, 4);
+            BLETINY_LOG(INFO, "0x%08x ", (unsigned)u32);
+        }
+        BLETINY_LOG(INFO, "\n");
+    }
+
+    if (fields->uuids128 != NULL) {
+        BLETINY_LOG(INFO, "    uuids128(%scomplete)=",
+                    fields->uuids128_is_complete ? "" : "in");
+        u8p = fields->uuids128;
+        for (i = 0; i < fields->num_uuids128; i++) {
+            print_uuid(u8p);
+            BLETINY_LOG(INFO, " ");
+            u8p += 16;
+        }
+        BLETINY_LOG(INFO, "\n");
+    }
+
+    if (fields->name != NULL) {
+        BLETINY_LOG(INFO, "    name(%scomplete)=",
+                    fields->name_is_complete ? "" : "in");
+        BLETINY_LOG(INFO, "%*s\n", fields->name_len, fields->name);
+    }
+
+    if (fields->tx_pwr_lvl_is_present) {
+        BLETINY_LOG(INFO, "    tx_pwr_lvl=%d\n", fields->tx_pwr_lvl);
+    }
+
+    if (fields->device_class != NULL) {
+        BLETINY_LOG(INFO, "    device_class=");
+        bletiny_print_bytes(fields->device_class,
+                             BLE_HS_ADV_DEVICE_CLASS_LEN);
+        BLETINY_LOG(INFO, "\n");
+    }
+
+    if (fields->slave_itvl_range != NULL) {
+        BLETINY_LOG(INFO, "    slave_itvl_range=");
+        bletiny_print_bytes(fields->slave_itvl_range,
+                             BLE_HS_ADV_SLAVE_ITVL_RANGE_LEN);
+        BLETINY_LOG(INFO, "\n");
+    }
+
+    if (fields->svc_data_uuid16 != NULL) {
+        BLETINY_LOG(INFO, "    svc_data_uuid16=");
+        bletiny_print_bytes(fields->svc_data_uuid16,
+                             fields->svc_data_uuid16_len);
+        BLETINY_LOG(INFO, "\n");
+    }
+
+    if (fields->public_tgt_addr != NULL) {
+        BLETINY_LOG(INFO, "    public_tgt_addr=");
+        u8p = fields->public_tgt_addr;
+        for (i = 0; i < fields->num_public_tgt_addrs; i++) {
+            print_addr(u8p);
+            u8p += BLE_HS_ADV_PUBLIC_TGT_ADDR_ENTRY_LEN;
+        }
+        BLETINY_LOG(INFO, "\n");
+    }
+
+    if (fields->appearance_is_present) {
+        BLETINY_LOG(INFO, "    appearance=0x%04x\n", fields->appearance);
+    }
+
+    if (fields->adv_itvl_is_present) {
+        BLETINY_LOG(INFO, "    adv_itvl=0x%04x\n", fields->adv_itvl);
+    }
+
+    if (fields->le_addr != NULL) {
+        BLETINY_LOG(INFO, "    le_addr=");
+        bletiny_print_bytes(fields->le_addr, BLE_HS_ADV_LE_ADDR_LEN);
+        BLETINY_LOG(INFO, "\n");
+    }
+
+    if (fields->le_role_is_present) {
+        BLETINY_LOG(INFO, "    le_role=0x%02x\n", fields->le_role);
+    }
+
+    if (fields->svc_data_uuid32 != NULL) {
+        BLETINY_LOG(INFO, "    svc_data_uuid32=");
+        bletiny_print_bytes(fields->svc_data_uuid32,
+                             fields->svc_data_uuid32_len);
+        BLETINY_LOG(INFO, "\n");
+    }
+
+    if (fields->svc_data_uuid128 != NULL) {
+        BLETINY_LOG(INFO, "    svc_data_uuid128=");
+        bletiny_print_bytes(fields->svc_data_uuid128,
+                             fields->svc_data_uuid128_len);
+        BLETINY_LOG(INFO, "\n");
+    }
+
+    if (fields->uri != NULL) {
+        BLETINY_LOG(INFO, "    uri=");
+        bletiny_print_bytes(fields->uri, fields->uri_len);
+        BLETINY_LOG(INFO, "\n");
+    }
+
+    if (fields->mfg_data != NULL) {
+        BLETINY_LOG(INFO, "    mfg_data=");
+        bletiny_print_bytes(fields->mfg_data, fields->mfg_data_len);
+        BLETINY_LOG(INFO, "\n");
+    }
+}
+
+static int
+bletiny_conn_find_idx(uint16_t handle)
+{
+    int i;
+
+    for (i = 0; i < bletiny_num_conns; i++) {
+        if (bletiny_conns[i].handle == handle) {
+            return i;
+        }
+    }
+
+    return -1;
+}
+
+static struct bletiny_conn *
+bletiny_conn_find(uint16_t handle)
+{
+    int idx;
+
+    idx = bletiny_conn_find_idx(handle);
+    if (idx == -1) {
+        return NULL;
+    } else {
+        return bletiny_conns + idx;
+    }
+}
+
+static struct bletiny_conn *
+bletiny_conn_add(struct ble_gap_conn_desc *desc)
+{
+    struct bletiny_conn *conn;
+
+    assert(bletiny_num_conns < NIMBLE_OPT_MAX_CONNECTIONS);
+
+    conn = bletiny_conns + bletiny_num_conns;
+    bletiny_num_conns++;
+
+    conn->handle = desc->conn_handle;
+    conn->addr_type = desc->peer_addr_type;
+    memcpy(conn->addr, desc->peer_addr, 6);
+    SLIST_INIT(&conn->svcs);
+
+    return conn;
+}
+
+static void
+bletiny_conn_delete_idx(int idx)
+{
+    struct bletiny_conn *conn;
+    struct bletiny_svc *svc;
+
+    assert(idx >= 0 && idx < bletiny_num_conns);
+
+    conn = bletiny_conns + idx;
+    while ((svc = SLIST_FIRST(&conn->svcs)) != NULL) {
+        SLIST_REMOVE_HEAD(&conn->svcs, next);
+        os_memblock_put(&bletiny_svc_pool, svc);
+    }
+
+    bletiny_num_conns--;
+
+    /* This '#if' is not strictly necessary.  It is here to prevent a spurious
+     * warning from being reported.
+     */
+#if NIMBLE_OPT_MAX_CONNECTIONS > 1
+    int i;
+    for (i = idx; i < bletiny_num_conns; i++) {
+        bletiny_conns[i - 1] = bletiny_conns[i];
+    }
+#endif
+}
+
+static struct bletiny_svc *
+bletiny_svc_find_prev(struct bletiny_conn *conn, uint16_t svc_start_handle)
+{
+    struct bletiny_svc *prev;
+    struct bletiny_svc *svc;
+
+    prev = NULL;
+    SLIST_FOREACH(svc, &conn->svcs, next) {
+        if (svc->svc.start_handle >= svc_start_handle) {
+            break;
+        }
+
+        prev = svc;
+    }
+
+    return prev;
+}
+
+static struct bletiny_svc *
+bletiny_svc_find(struct bletiny_conn *conn, uint16_t svc_start_handle,
+                  struct bletiny_svc **out_prev)
+{
+    struct bletiny_svc *prev;
+    struct bletiny_svc *svc;
+
+    prev = bletiny_svc_find_prev(conn, svc_start_handle);
+    if (prev == NULL) {
+        svc = SLIST_FIRST(&conn->svcs);
+    } else {
+        svc = SLIST_NEXT(prev, next);
+    }
+
+    if (svc != NULL && svc->svc.start_handle != svc_start_handle) {
+        svc = NULL;
+    }
+
+    if (out_prev != NULL) {
+        *out_prev = prev;
+    }
+    return svc;
+}
+
+static struct bletiny_svc *
+bletiny_svc_find_range(struct bletiny_conn *conn, uint16_t attr_handle)
+{
+    struct bletiny_svc *svc;
+
+    SLIST_FOREACH(svc, &conn->svcs, next) {
+        if (svc->svc.start_handle <= attr_handle &&
+            svc->svc.end_handle >= attr_handle) {
+
+            return svc;
+        }
+    }
+
+    return NULL;
+}
+
+static struct bletiny_svc *
+bletiny_svc_add(uint16_t conn_handle, struct ble_gatt_service *gatt_svc)
+{
+    struct bletiny_conn *conn;
+    struct bletiny_svc *prev;
+    struct bletiny_svc *svc;
+
+    conn = bletiny_conn_find(conn_handle);
+    if (conn == NULL) {
+        BLETINY_LOG(INFO,
+                    "RECEIVED SERVICE FOR UNKNOWN CONNECTION; HANDLE=%d\n",
+                    conn_handle);
+        return NULL;
+    }
+
+    svc = bletiny_svc_find(conn, gatt_svc->start_handle, &prev);
+    if (svc != NULL) {
+        /* Service already discovered. */
+        return svc;
+    }
+
+    svc = os_memblock_get(&bletiny_svc_pool);
+    if (svc == NULL) {
+        BLETINY_LOG(INFO, "OOM WHILE DISCOVERING SERVICE\n");
+        return NULL;
+    }
+    memset(svc, 0, sizeof *svc);
+
+    svc->svc = *gatt_svc;
+    SLIST_INIT(&svc->chrs);
+
+    if (prev == NULL) {
+        SLIST_INSERT_HEAD(&conn->svcs, svc, next);
+    } else {
+        SLIST_INSERT_AFTER(prev, svc, next);
+    }
+
+    return svc;
+}
+
+static struct bletiny_chr *
+bletiny_chr_find_prev(struct bletiny_svc *svc, uint16_t chr_def_handle)
+{
+    struct bletiny_chr *prev;
+    struct bletiny_chr *chr;
+
+    prev = NULL;
+    SLIST_FOREACH(chr, &svc->chrs, next) {
+        if (chr->chr.decl_handle >= chr_def_handle) {
+            break;
+        }
+
+        prev = chr;
+    }
+
+    return prev;
+}
+
+static struct bletiny_chr *
+bletiny_chr_find(struct bletiny_svc *svc, uint16_t chr_def_handle,
+                  struct bletiny_chr **out_prev)
+{
+    struct bletiny_chr *prev;
+    struct bletiny_chr *chr;
+
+    prev = bletiny_chr_find_prev(svc, chr_def_handle);
+    if (prev == NULL) {
+        chr = SLIST_FIRST(&svc->chrs);
+    } else {
+        chr = SLIST_NEXT(prev, next);
+    }
+
+    if (chr != NULL && chr->chr.decl_handle != chr_def_handle) {
+        chr = NULL;
+    }
+
+    if (out_prev != NULL) {
+        *out_prev = prev;
+    }
+    return chr;
+}
+
+
+static struct bletiny_chr *
+bletiny_chr_add(uint16_t conn_handle,  uint16_t svc_start_handle,
+                 struct ble_gatt_chr *gatt_chr)
+{
+    struct bletiny_conn *conn;
+    struct bletiny_chr *prev;
+    struct bletiny_chr *chr;
+    struct bletiny_svc *svc;
+
+    conn = bletiny_conn_find(conn_handle);
+    if (conn == NULL) {
+        BLETINY_LOG(INFO,
+                    "RECEIVED SERVICE FOR UNKNOWN CONNECTION; HANDLE=%d\n",
+                    conn_handle);
+        return NULL;
+    }
+
+    svc = bletiny_svc_find(conn, svc_start_handle, NULL);
+    if (svc == NULL) {
+        BLETINY_LOG(INFO,
+                    "CAN'T FIND SERVICE FOR DISCOVERED CHR; HANDLE=%d\n",
+                    conn_handle);
+        return NULL;
+    }
+
+    chr = bletiny_chr_find(svc, gatt_chr->decl_handle, &prev);
+    if (chr != NULL) {
+        /* Characteristic already discovered. */
+        return chr;
+    }
+
+    chr = os_memblock_get(&bletiny_chr_pool);
+    if (chr == NULL) {
+        BLETINY_LOG(INFO, "OOM WHILE DISCOVERING CHARACTERISTIC\n");
+        return NULL;
+    }
+    memset(chr, 0, sizeof *chr);
+
+    chr->chr = *gatt_chr;
+
+    if (prev == NULL) {
+        SLIST_INSERT_HEAD(&svc->chrs, chr, next);
+    } else {
+        SLIST_NEXT(prev, next) = chr;
+    }
+
+    return chr;
+}
+
+static struct bletiny_dsc *
+bletiny_dsc_find_prev(struct bletiny_chr *chr, uint16_t dsc_handle)
+{
+    struct bletiny_dsc *prev;
+    struct bletiny_dsc *dsc;
+
+    prev = NULL;
+    SLIST_FOREACH(dsc, &chr->dscs, next) {
+        if (dsc->dsc.handle >= dsc_handle) {
+            break;
+        }
+
+        prev = dsc;
+    }
+
+    return prev;
+}
+
+static struct bletiny_dsc *
+bletiny_dsc_find(struct bletiny_chr *chr, uint16_t dsc_handle,
+                  struct bletiny_dsc **out_prev)
+{
+    struct bletiny_dsc *prev;
+    struct bletiny_dsc *dsc;
+
+    prev = bletiny_dsc_find_prev(chr, dsc_handle);
+    if (prev == NULL) {
+        dsc = SLIST_FIRST(&chr->dscs);
+    } else {
+        dsc = SLIST_NEXT(prev, next);
+    }
+
+    if (dsc != NULL && dsc->dsc.handle != dsc_handle) {
+        dsc = NULL;
+    }
+
+    if (out_prev != NULL) {
+        *out_prev = prev;
+    }
+    return dsc;
+}
+
+static struct bletiny_dsc *
+bletiny_dsc_add(uint16_t conn_handle, uint16_t chr_def_handle,
+                 struct ble_gatt_dsc *gatt_dsc)
+{
+    struct bletiny_conn *conn;
+    struct bletiny_dsc *prev;
+    struct bletiny_dsc *dsc;
+    struct bletiny_svc *svc;
+    struct bletiny_chr *chr;
+
+    conn = bletiny_conn_find(conn_handle);
+    if (conn == NULL) {
+        BLETINY_LOG(INFO,
+                    "RECEIVED SERVICE FOR UNKNOWN CONNECTION; HANDLE=%d\n",
+                    conn_handle);
+        return NULL;
+    }
+
+    svc = bletiny_svc_find_range(conn, chr_def_handle);
+    if (svc == NULL) {
+        BLETINY_LOG(INFO,
+                    "CAN'T FIND SERVICE FOR DISCOVERED DSC; HANDLE=%d\n",
+                    conn_handle);
+        return NULL;
+    }
+
+    chr = bletiny_chr_find(svc, chr_def_handle, NULL);
+    if (chr == NULL) {
+        BLETINY_LOG(INFO, "CAN'T FIND CHARACTERISTIC FOR DISCOVERED DSC; "
+                    "HANDLE=%d\n", conn_handle);
+        return NULL;
+    }
+
+    dsc = bletiny_dsc_find(chr, gatt_dsc->handle, &prev);
+    if (dsc != NULL) {
+        /* Descriptor already discovered. */
+        return dsc;
+    }
+
+    dsc = os_memblock_get(&bletiny_dsc_pool);
+    if (dsc == NULL) {
+        BLETINY_LOG(INFO, "OOM WHILE DISCOVERING DESCRIPTOR\n");
+        return NULL;
+    }
+    memset(dsc, 0, sizeof *dsc);
+
+    dsc->dsc = *gatt_dsc;
+
+    if (prev == NULL) {
+        SLIST_INSERT_HEAD(&chr->dscs, dsc, next);
+    } else {
+        SLIST_NEXT(prev, next) = dsc;
+    }
+
+    return dsc;
+}
+
+static void
+bletiny_start_auto_advertise(void)
+{
+#if 0
+    struct ble_hs_adv_fields fields;
+    int rc;
+
+    if (BLETINY_AUTO_DEVICE_NAME != NULL) {
+        memset(&fields, 0, sizeof fields);
+
+        fields.name = (uint8_t *)BLETINY_AUTO_DEVICE_NAME;
+        fields.name_len = strlen(BLETINY_AUTO_DEVICE_NAME);
+        fields.name_is_complete = 1;
+        rc = bletiny_set_adv_data(&fields);
+        if (rc != 0) {
+            return;
+        }
+
+        rc = bletiny_adv_start(BLE_GAP_DISC_MODE_GEN, BLE_GAP_CONN_MODE_UND,
+                               NULL, 0, NULL);
+        if (rc != 0) {
+            return;
+        }
+    }
+#endif
+}
+
+static int
+bletiny_on_mtu(uint16_t conn_handle, struct ble_gatt_error *error,
+                uint16_t mtu, void *arg)
+{
+    if (error != NULL) {
+        bletiny_print_error("ERROR EXCHANGING MTU", conn_handle, error);
+    } else {
+        BLETINY_LOG(INFO, "mtu exchange complete: conn_handle=%d mtu=%d\n",
+                    conn_handle, mtu);
+    }
+
+    return 0;
+}
+
+static int
+bletiny_on_disc_s(uint16_t conn_handle, struct ble_gatt_error *error,
+                   struct ble_gatt_service *service, void *arg)
+{
+    bletiny_lock();
+
+    if (error != NULL) {
+        bletiny_print_error("ERROR DISCOVERING SERVICE", conn_handle, error);
+    } else if (service != NULL) {
+        bletiny_svc_add(conn_handle, service);
+    } else {
+        BLETINY_LOG(INFO, "service discovery successful\n");
+    }
+
+    bletiny_unlock();
+
+    return 0;
+}
+
+static int
+bletiny_on_disc_c(uint16_t conn_handle, struct ble_gatt_error *error,
+                   struct ble_gatt_chr *chr, void *arg)
+{
+    intptr_t svc_start_handle;
+
+    svc_start_handle = (intptr_t)arg;
+
+    if (error != NULL) {
+        bletiny_print_error("ERROR DISCOVERING CHARACTERISTIC", conn_handle,
+                             error);
+    } else if (chr != NULL) {
+        bletiny_lock();
+        bletiny_chr_add(conn_handle, svc_start_handle, chr);
+        bletiny_unlock();
+    } else {
+        BLETINY_LOG(INFO, "characteristic discovery successful\n");
+    }
+
+    return 0;
+}
+
+static int
+bletiny_on_disc_d(uint16_t conn_handle, struct ble_gatt_error *error,
+                   uint16_t chr_def_handle, struct ble_gatt_dsc *dsc,
+                   void *arg)
+{
+    bletiny_lock();
+
+    if (error != NULL) {
+        bletiny_print_error("ERROR DISCOVERING DESCRIPTOR", conn_handle,
+                             error);
+    } else if (dsc != NULL) {
+        bletiny_dsc_add(conn_handle, chr_def_handle, dsc);
+    } else {
+        BLETINY_LOG(INFO, "descriptor discovery successful\n");
+    }
+
+    bletiny_unlock();
+
+    return 0;
+}
+
+static int
+bletiny_on_read(uint16_t conn_handle, struct ble_gatt_error *error,
+                 struct ble_gatt_attr *attr, void *arg)
+{
+    if (error != NULL) {
+        bletiny_print_error("ERROR READING CHARACTERISTIC", conn_handle,
+                             error);
+    } else if (attr != NULL) {
+        BLETINY_LOG(INFO, "characteristic read; conn_handle=%d "
+                    "attr_handle=%d len=%d value=", conn_handle,
+                    attr->handle, attr->value_len);
+        bletiny_print_bytes(attr->value, attr->value_len);
+        BLETINY_LOG(INFO, "\n");
+    } else {
+        BLETINY_LOG(INFO, "characteristic read complete\n");
+    }
+
+    return 0;
+}
+
+static int
+bletiny_on_read_mult(uint16_t conn_handle, struct ble_gatt_error *error,
+                      uint16_t *attr_handles, uint8_t num_attr_handles,
+                      uint8_t *attr_data, uint16_t attr_data_len, void *arg)
+{
+    int i;
+
+    if (error != NULL) {
+        bletiny_print_error("ERROR READING CHARACTERISTICS", conn_handle,
+                             error);
+    } else {
+        BLETINY_LOG(INFO,
+                    "multiple characteristic read complete; conn_handle=%d "
+                    "attr_handles=", conn_handle);
+        for (i = 0; i < num_attr_handles; i++) {
+            BLETINY_LOG(INFO, "%s%d", i != 0 ? "," : "", attr_handles[i]);
+        }
+
+        BLETINY_LOG(INFO, " len=%d value=", attr_data_len);
+        bletiny_print_bytes(attr_data, attr_data_len);
+        BLETINY_LOG(INFO, "\n");
+    }
+
+    return 0;
+
+}
+
+static int
+bletiny_on_write(uint16_t conn_handle, struct ble_gatt_error *error,
+                  struct ble_gatt_attr *attr, void *arg)
+{
+    if (error != NULL) {
+        bletiny_print_error("ERROR WRITING CHARACTERISTIC", conn_handle,
+                             error);
+    } else {
+        BLETINY_LOG(INFO, "characteristic write complete; conn_handle=%d "
+                    "attr_handle=%d len=%d value=", conn_handle,
+                    attr->handle, attr->value_len);
+        bletiny_print_bytes(attr->value, attr->value_len);
+        BLETINY_LOG(INFO, "\n");
+    }
+
+    return 0;
+}
+
+static int
+bletiny_on_write_reliable(uint16_t conn_handle, struct ble_gatt_error *error,
+                           struct ble_gatt_attr *attrs, uint8_t num_attrs,
+                           void *arg)
+{
+    int i;
+
+    if (error != NULL) {
+        bletiny_print_error("ERROR WRITING CHARACTERISTICS RELIABLY",
+                             conn_handle, error);
+    } else {
+        BLETINY_LOG(INFO, "characteristic write reliable complete; "
+                    "conn_handle=%d", conn_handle);
+
+        for (i = 0; i < num_attrs; i++) {
+            BLETINY_LOG(INFO, " attr_handle=%d len=%d value=", attrs[i].handle,
+                        attrs[i].value_len);
+            bletiny_print_bytes(attrs[i].value, attrs[i].value_len);
+        }
+        BLETINY_LOG(INFO, "\n");
+    }
+
+    return 0;
+}
+
+static int
+bletiny_on_notify(uint16_t conn_handle, uint16_t attr_handle,
+                   uint8_t *attr_val, uint16_t attr_len, void *arg)
+{
+    BLETINY_LOG(INFO, "received notification from conn_handle=%d attr=%d "
+                "len=%d value=", conn_handle, attr_handle, attr_len);
+
+    bletiny_print_bytes(attr_val, attr_len);
+    BLETINY_LOG(INFO, "\n");
+
+    return 0;
+}
+
+static int
+bletiny_on_connect(int event, int status, struct ble_gap_conn_ctxt *ctxt,
+                    void *arg)
+{
+    int conn_idx;
+
+    bletiny_lock();
+
+    switch (event) {
+    case BLE_GAP_EVENT_CONN:
+        BLETINY_LOG(INFO, "connection %s; status=%d ",
+                    status == 0 ? "up" : "down", status);
+        bletiny_print_conn_desc(ctxt->desc);
+        BLETINY_LOG(INFO, "\n");
+
+        if (status == 0) {
+            bletiny_conn_add(ctxt->desc);
+        } else {
+            if (ctxt->desc->conn_handle == BLE_HS_CONN_HANDLE_NONE) {
+                if (status == BLE_HS_HCI_ERR(BLE_ERR_UNK_CONN_ID)) {
+                    BLETINY_LOG(INFO, "connection procedure cancelled.\n");
+                }
+            } else {
+                conn_idx = bletiny_conn_find_idx(ctxt->desc->conn_handle);
+                if (conn_idx == -1) {
+                    BLETINY_LOG(INFO, "UNKNOWN CONNECTION\n");
+                } else {
+                    bletiny_conn_delete_idx(conn_idx);
+                }
+
+                bletiny_start_auto_advertise();
+            }
+        }
+
+        break;
+
+    case BLE_GAP_EVENT_CONN_UPDATED:
+        BLETINY_LOG(INFO, "connection updated; status=%d ", status);
+        bletiny_print_conn_desc(ctxt->desc);
+        BLETINY_LOG(INFO, "\n");
+        break;
+
+    case BLE_GAP_EVENT_CONN_UPDATE_REQ:
+        BLETINY_LOG(INFO, "connection update request; status=%d ", status);
+        *ctxt->self_params = *ctxt->peer_params;
+        break;
+    }
+
+    bletiny_unlock();
+
+    return 0;
+}
+
+static void
+bletiny_on_l2cap_update(int status, void *arg)
+{
+    BLETINY_LOG(INFO, "l2cap update complete; status=%d\n", status);
+}
+
+static void
+bletiny_on_wl_set(int status, void *arg)
+{
+    BLETINY_LOG(INFO, "white list set status=%d\n", status);
+}
+
+static void
+bletiny_on_scan(int event, int status, struct ble_gap_disc_desc *desc,
+                 void *arg)
+{
+    switch (event) {
+    case BLE_GAP_EVENT_DISC_SUCCESS:
+        BLETINY_LOG(INFO, "received advertisement; event_type=%d addr_type=%d "
+                    "addr=", desc->event_type, desc->addr_type);
+        bletiny_print_bytes(desc->addr, 6);
+        BLETINY_LOG(INFO, " length_data=%d rssi=%d data=", desc->length_data,
+                    desc->rssi);
+        bletiny_print_bytes(desc->data, desc->length_data);
+        BLETINY_LOG(INFO, " fields:\n");
+        bletiny_print_adv_fields(desc->fields);
+        BLETINY_LOG(INFO, "\n");
+        break;
+
+    case BLE_GAP_EVENT_DISC_FINISHED:
+        BLETINY_LOG(INFO, "scanning finished; status=%d\n", status);
+        break;
+
+    default:
+        assert(0);
+        break;
+    }
+}
+
+static void
+bletiny_on_rx_rssi(struct ble_hci_ack *ack, void *unused)
+{
+    struct hci_read_rssi_ack_params params;
+
+    if (ack->bha_params_len != BLE_HCI_READ_RSSI_ACK_PARAM_LEN) {
+        BLETINY_LOG(INFO, "invalid rssi response; len=%d\n",
+                    ack->bha_params_len);
+        return;
+    }
+
+    params.status = ack->bha_params[0];
+    params.connection_handle = le16toh(ack->bha_params + 1);
+    params.rssi = ack->bha_params[3];
+
+    BLETINY_LOG(INFO, "rssi response received; status=%d conn=%d rssi=%d\n",
+                params.status, params.connection_handle, params.rssi);
+}
+
+int
+bletiny_exchange_mtu(uint16_t conn_handle)
+{
+    int rc;
+
+    rc = ble_gattc_exchange_mtu(conn_handle, bletiny_on_mtu, NULL);
+    return rc;
+}
+
+int
+bletiny_disc_all_chrs(uint16_t conn_handle, uint16_t start_handle,
+                       uint16_t end_handle)
+{
+    intptr_t svc_start_handle;
+    int rc;
+
+    svc_start_handle = start_handle;
+    rc = ble_gattc_disc_all_chrs(conn_handle, start_handle, end_handle,
+                                 bletiny_on_disc_c, (void *)svc_start_handle);
+    return rc;
+}
+
+int
+bletiny_disc_chrs_by_uuid(uint16_t conn_handle, uint16_t start_handle,
+                           uint16_t end_handle, uint8_t *uuid128)
+{
+    intptr_t svc_start_handle;
+    int rc;
+
+    svc_start_handle = start_handle;
+    rc = ble_gattc_disc_chrs_by_uuid(conn_handle, start_handle, end_handle,
+                                     uuid128, bletiny_on_disc_c,
+                                     &svc_start_handle);
+    return rc;
+}
+
+int
+bletiny_disc_svcs(uint16_t conn_handle)
+{
+    int rc;
+
+    rc = ble_gattc_disc_all_svcs(conn_handle, bletiny_on_disc_s, NULL);
+    return rc;
+}
+
+int
+bletiny_disc_svc_by_uuid(uint16_t conn_handle, uint8_t *uuid128)
+{
+    int rc;
+
+    rc = ble_gattc_disc_svc_by_uuid(conn_handle, uuid128,
+                                    bletiny_on_disc_s, NULL);
+    return rc;
+}
+
+int
+bletiny_disc_all_dscs(uint16_t conn_handle, uint16_t chr_def_handle,
+                       uint16_t chr_end_handle)
+{
+    int rc;
+
+    rc = ble_gattc_disc_all_dscs(conn_handle, chr_def_handle, chr_end_handle,
+                                 bletiny_on_disc_d, NULL);
+    return rc;
+}
+
+int
+bletiny_find_inc_svcs(uint16_t conn_handle, uint16_t start_handle,
+                       uint16_t end_handle)
+{
+    int rc;
+
+    rc = ble_gattc_find_inc_svcs(conn_handle, start_handle, end_handle,
+                                 bletiny_on_disc_s, NULL);
+    return rc;
+}
+
+int
+bletiny_read(uint16_t conn_handle, uint16_t attr_handle)
+{
+    int rc;
+
+    rc = ble_gattc_read(conn_handle, attr_handle, bletiny_on_read, NULL);
+    return rc;
+}
+
+int
+bletiny_read_long(uint16_t conn_handle, uint16_t attr_handle)
+{
+    int rc;
+
+    rc = ble_gattc_read_long(conn_handle, attr_handle, bletiny_on_read, NULL);
+    return rc;
+}
+
+int
+bletiny_read_by_uuid(uint16_t conn_handle, uint16_t start_handle,
+                      uint16_t end_handle, uint8_t *uuid128)
+{
+    int rc;
+
+    rc = ble_gattc_read_by_uuid(conn_handle, start_handle, end_handle, uuid128,
+                                bletiny_on_read, NULL);
+    return rc;
+}
+
+int
+bletiny_read_mult(uint16_t conn_handle, uint16_t *attr_handles,
+                   int num_attr_handles)
+{
+    int rc;
+
+    rc = ble_gattc_read_mult(conn_handle, attr_handles, num_attr_handles,
+                             bletiny_on_read_mult, NULL);
+    return rc;
+}
+
+int
+bletiny_write(uint16_t conn_handle, uint16_t attr_handle, void *value,
+               uint16_t value_len)
+{
+    int rc;
+
+    if (conn_handle == BLE_HS_CONN_HANDLE_NONE) {
+        rc = ble_att_svr_write_local(attr_handle, value, value_len);
+    } else {
+        rc = ble_gattc_write(conn_handle, attr_handle, value, value_len,
+                             bletiny_on_write, NULL);
+    }
+
+    return rc;
+}
+
+int
+bletiny_write_no_rsp(uint16_t conn_handle, uint16_t attr_handle, void *value,
+                      uint16_t value_len)
+{
+    int rc;
+
+    rc = ble_gattc_write_no_rsp(conn_handle, attr_handle, value, value_len,
+                                bletiny_on_write, NULL);
+    return rc;
+}
+
+int
+bletiny_write_long(uint16_t conn_handle, uint16_t attr_handle, void *value,
+                    uint16_t value_len)
+{
+    int rc;
+
+    rc = ble_gattc_write_long(conn_handle, attr_handle, value, value_len,
+                              bletiny_on_write, NULL);
+    return rc;
+}
+
+int
+bletiny_write_reliable(uint16_t conn_handle, struct ble_gatt_attr *attrs,
+                        int num_attrs)
+{
+    int rc;
+
+    rc = ble_gattc_write_reliable(conn_handle, attrs, num_attrs,
+                                  bletiny_on_write_reliable, NULL);
+    return rc;
+}
+
+int
+bletiny_adv_stop(void)
+{
+    int rc;
+
+    rc = ble_gap_adv_stop();
+    return rc;
+}
+
+int
+bletiny_adv_start(int disc, int conn, uint8_t *peer_addr, int addr_type,
+                  struct hci_adv_params *params)
+{
+    int rc;
+
+    rc = ble_gap_adv_start(disc, conn, peer_addr, addr_type, params,
+                           bletiny_on_connect, NULL);
+    return rc;
+}
+
+int
+bletiny_conn_initiate(int addr_type, uint8_t *peer_addr,
+                       struct ble_gap_crt_params *params)
+{
+    int rc;
+
+    rc = ble_gap_conn_initiate(addr_type, peer_addr, NULL, bletiny_on_connect,
+                               params);
+    return rc;
+}
+
+int
+bletiny_conn_cancel(void)
+{
+    int rc;
+
+    rc = ble_gap_cancel();
+    return rc;
+}
+
+int
+bletiny_term_conn(uint16_t conn_handle)
+{
+    int rc;
+
+    rc = ble_gap_terminate(conn_handle);
+    return rc;
+}
+
+int
+bletiny_wl_set(struct ble_gap_white_entry *white_list, int white_list_count)
+{
+    int rc;
+
+    rc = ble_gap_wl_set(white_list, white_list_count, bletiny_on_wl_set,
+                        NULL);
+    return rc;
+}
+
+int
+bletiny_scan(uint32_t dur_ms, uint8_t disc_mode, uint8_t scan_type,
+              uint8_t filter_policy)
+{
+    int rc;
+
+    rc = ble_gap_disc(dur_ms, disc_mode, scan_type, filter_policy,
+                      bletiny_on_scan, NULL);
+    return rc;
+}
+
+int
+bletiny_set_adv_data(struct ble_hs_adv_fields *adv_fields)
+{
+    int rc;
+
+    rc = ble_gap_adv_set_fields(adv_fields);
+    return rc;
+}
+
+int
+bletiny_update_conn(uint16_t conn_handle, struct ble_gap_upd_params *params)
+{
+    int rc;
+
+    rc = ble_gap_update_params(conn_handle, params);
+    return rc;
+}
+
+void
+bletiny_chrup(uint16_t attr_handle)
+{
+    ble_gatts_chr_updated(attr_handle);
+}
+
+int
+bletiny_l2cap_update(uint16_t conn_handle,
+                     struct ble_l2cap_sig_update_params *params)
+{
+    int rc;
+
+    rc = ble_l2cap_sig_update(conn_handle, params, bletiny_on_l2cap_update,
+                              NULL);
+    return rc;
+}
+
+static int
+bletiny_tx_rssi_req(void *arg)
+{
+    intptr_t conn_handle;
+    int rc;
+
+    conn_handle = (intptr_t)arg;
+
+    ble_hci_sched_set_ack_cb(bletiny_on_rx_rssi, NULL);
+
+    rc = host_hci_cmd_read_rssi(conn_handle);
+    if (rc != 0) {
+        BLETINY_LOG(ERROR, "failure to send rssi hci cmd; rc=%d\n", rc);
+        return rc;
+    }
+
+    return 0;
+}
+
+int
+bletiny_show_rssi(uint16_t conn_handle)
+{
+    int rc;
+
+    rc = ble_hci_sched_enqueue(bletiny_tx_rssi_req,
+                               (void *)(intptr_t)conn_handle, NULL);
+    if (rc != 0) {
+        BLETINY_LOG(ERROR, "failure to enqueue rssi hci cmd; rc=%d\n", rc);
+        return rc;
+    }
+
+    return 0;
+
+}
+
+/**
+ * BLE test task
+ *
+ * @param arg
+ */
+static void
+bletiny_task_handler(void *arg)
+{
+    struct os_event *ev;
+    struct os_callout_func *cf;
+
+    periph_init();
+
+    ble_att_set_notify_cb(bletiny_on_notify, NULL);
+
+    /* Initialize eventq */
+    os_eventq_init(&g_bletiny_evq);
+
+    bletiny_start_auto_advertise();
+
+    while (1) {
+        ev = os_eventq_get(&g_bletiny_evq);
+        switch (ev->ev_type) {
+        case OS_EVENT_T_TIMER:
+            cf = (struct os_callout_func *)ev;
+            assert(cf->cf_func);
+            cf->cf_func(cf->cf_arg);
+            break;
+        default:
+            assert(0);
+            break;
+        }
+    }
+}
+
+/**
+ * main
+ *
+ * The main function for the project. This function initializes the os, calls
+ * init_tasks to initialize tasks (and possibly other objects), then starts the
+ * OS. We should not return from os start.
+ *
+ * @return int NOTE: this function should never return!
+ */
+int
+main(void)
+{
+    struct ble_hs_cfg cfg;
+    uint32_t seed;
+    int rc;
+    int i;
+
+    /* Initialize OS */
+    os_init();
+
+    /* Set cputime to count at 1 usec increments */
+    rc = cputime_init(1000000);
+    assert(rc == 0);
+
+    /* Dummy device address */
+    memcpy(g_dev_addr, bletiny_addr, 6);
+
+    /*
+     * Seed random number generator with least significant bytes of device
+     * address.
+     */
+    seed = 0;
+    for (i = 0; i < 4; ++i) {
+        seed |= g_dev_addr[i];
+        seed <<= 8;
+    }
+    srand(seed);
+
+    bletiny_svc_mem = malloc(
+        OS_MEMPOOL_BYTES(BLETINY_MAX_SVCS, sizeof (struct bletiny_svc)));
+    assert(bletiny_svc_mem != NULL);
+
+    rc = os_mempool_init(&bletiny_svc_pool, BLETINY_MAX_SVCS,
+                         sizeof (struct bletiny_svc), bletiny_svc_mem,
+                         "bletiny_svc_pool");
+    assert(rc == 0);
+
+    bletiny_chr_mem = malloc(
+        OS_MEMPOOL_BYTES(BLETINY_MAX_CHRS, sizeof (struct bletiny_chr)));
+    assert(bletiny_chr_mem != NULL);
+
+    rc = os_mempool_init(&bletiny_chr_pool, BLETINY_MAX_CHRS,
+                         sizeof (struct bletiny_chr), bletiny_chr_mem,
+                         "bletiny_chr_pool");
+    assert(rc == 0);
+
+    bletiny_dsc_mem = malloc(
+        OS_MEMPOOL_BYTES(BLETINY_MAX_DSCS, sizeof (struct bletiny_dsc)));
+    assert(bletiny_dsc_mem != NULL);
+
+    rc = os_mempool_init(&bletiny_dsc_pool, BLETINY_MAX_DSCS,
+                         sizeof (struct bletiny_dsc), bletiny_dsc_mem,
+                         "bletiny_dsc_pool");
+    assert(rc == 0);
+
+    rc = os_mempool_init(&default_mbuf_mpool, MBUF_NUM_MBUFS, 
+                         MBUF_MEMBLOCK_SIZE, default_mbuf_mpool_data, 
+                         "default_mbuf_data");
+    assert(rc == 0);
+
+    rc = os_mbuf_pool_init(&default_mbuf_pool, &default_mbuf_mpool,
+                           MBUF_MEMBLOCK_SIZE, MBUF_NUM_MBUFS);
+    assert(rc == 0);
+
+    rc = os_msys_register(&default_mbuf_pool);
+    assert(rc == 0);
+
+    log_init();
+    log_console_handler_init(&bletiny_log_console_handler);
+    log_register("bletiny", &bletiny_log, &bletiny_log_console_handler);
+
+    os_task_init(&bletiny_task, "bletiny", bletiny_task_handler,
+                 NULL, BLETINY_TASK_PRIO, OS_WAIT_FOREVER,
+                 bletiny_stack, BLETINY_STACK_SIZE);
+
+    rc = shell_task_init(SHELL_TASK_PRIO, shell_stack, SHELL_TASK_STACK_SIZE,
+                         SHELL_MAX_INPUT_LEN);
+    assert(rc == 0);
+
+    /* Init the console */
+    rc = console_init(shell_console_rx_cb);
+    assert(rc == 0);
+
+    rc = stats_module_init();
+    assert(rc == 0);
+
+    /* Initialize the BLE host. */
+    cfg = ble_hs_cfg_dflt;
+    cfg.max_hci_bufs = 3;
+    cfg.max_attrs = 32;
+    cfg.max_services = 4;
+    cfg.max_client_configs = 6;
+    cfg.max_gattc_procs = 2;
+    cfg.max_l2cap_chans = 3;
+    cfg.max_l2cap_sig_procs = 2;
+
+    rc = ble_hs_init(HOST_TASK_PRIO, &cfg);
+    assert(rc == 0);
+
+    /* Initialize the BLE LL */
+    ble_ll_init();
+
+    rc = cmd_init();
+    assert(rc == 0);
+
+    /* Initialize the preferred parameters. */
+    htole16(bletiny_pref_conn_params + 0, BLE_GAP_INITIAL_CONN_ITVL_MIN);
+    htole16(bletiny_pref_conn_params + 2, BLE_GAP_INITIAL_CONN_ITVL_MAX);
+    htole16(bletiny_pref_conn_params + 4, 0);
+    htole16(bletiny_pref_conn_params + 6, BSWAP16(0x100));
+
+    rc = os_mutex_init(&bletiny_mutex);
+    assert(rc == 0);
+
+    /* Start the OS */
+    os_start();
+
+    /* os start should never return. If it does, this should be an error */
+    assert(0);
+
+    return 0;
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/apps/bletiny/src/parse.c
----------------------------------------------------------------------
diff --git a/apps/bletiny/src/parse.c b/apps/bletiny/src/parse.c
new file mode 100644
index 0000000..8051a88
--- /dev/null
+++ b/apps/bletiny/src/parse.c
@@ -0,0 +1,435 @@
+/**
+ * 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 <string.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <errno.h>
+#include <assert.h>
+#include "console/console.h"
+#include "host/ble_uuid.h"
+#include "bletiny_priv.h"
+
+#define CMD_MAX_ARGS        16
+
+static char *cmd_args[CMD_MAX_ARGS][2];
+static int cmd_num_args;
+
+void
+print_addr(void *addr)
+{
+    uint8_t *u8p;
+
+    u8p = addr;
+    BLETINY_LOG(INFO, "%02x:%02x:%02x:%02x:%02x:%02x",
+                u8p[5], u8p[4], u8p[3], u8p[2], u8p[1], u8p[0]);
+}
+
+void
+print_uuid(void *uuid128)
+{
+    uint16_t uuid16;
+    uint8_t *u8p;
+
+    uuid16 = ble_uuid_128_to_16(uuid128);
+    if (uuid16 != 0) {
+        BLETINY_LOG(INFO, "0x%04x", uuid16);
+        return;
+    }
+
+    u8p = uuid128;
+
+    /* 00001101-0000-1000-8000-00805f9b34fb */
+    BLETINY_LOG(INFO, "%02x%02x%02x%02x-", u8p[15], u8p[14], u8p[13],
+                u8p[12]);
+    BLETINY_LOG(INFO, "%02x%02x-%02x%02x-", u8p[11], u8p[10], u8p[9], u8p[8]);
+    BLETINY_LOG(INFO, "%02x%02x%02x%02x%02x%02x%02x%02x",
+                u8p[7], u8p[6], u8p[5], u8p[4],
+                u8p[3], u8p[2], u8p[1], u8p[0]);
+}
+
+int
+parse_err_too_few_args(char *cmd_name)
+{
+    BLETINY_LOG(ERROR, "Error: too few arguments for command \"%s\"\n",
+                cmd_name);
+    return -1;
+}
+
+const struct cmd_entry *
+parse_cmd_find(const struct cmd_entry *cmds, char *name)
+{
+    const struct cmd_entry *cmd;
+    int i;
+
+    for (i = 0; cmds[i].name != NULL; i++) {
+        cmd = cmds + i;
+        if (strcmp(name, cmd->name) == 0) {
+            return cmd;
+        }
+    }
+
+    return NULL;
+}
+
+struct kv_pair *
+parse_kv_find(struct kv_pair *kvs, char *name)
+{
+    struct kv_pair *kv;
+    int i;
+
+    for (i = 0; kvs[i].key != NULL; i++) {
+        kv = kvs + i;
+        if (strcmp(name, kv->key) == 0) {
+            return kv;
+        }
+    }
+
+    return NULL;
+}
+
+char *
+parse_arg_find(char *key)
+{
+    int i;
+
+    for (i = 0; i < cmd_num_args; i++) {
+        if (strcmp(cmd_args[i][0], key) == 0) {
+            /* Erase parameter. */
+            cmd_args[i][0][0] = '\0';
+
+            return cmd_args[i][1];
+        }
+    }
+
+    return NULL;
+}
+
+long
+parse_arg_long_bounds(char *name, long min, long max, int *out_status)
+{
+    char *endptr;
+    char *sval;
+    long lval;
+
+    sval = parse_arg_find(name);
+    if (sval == NULL) {
+        *out_status = ENOENT;
+        return 0;
+    }
+
+    lval = strtol(sval, &endptr, 0);
+    if (sval[0] != '\0' && *endptr == '\0' &&
+        lval >= min && lval <= max) {
+
+        *out_status = 0;
+        return lval;
+    }
+
+    *out_status = EINVAL;
+    return 0;
+}
+
+long
+parse_arg_long(char *name, int *out_status)
+{
+    return parse_arg_long_bounds(name, LONG_MIN, LONG_MAX, out_status);
+}
+
+uint16_t
+parse_arg_uint16(char *name, int *out_status)
+{
+    return parse_arg_long_bounds(name, 0, UINT16_MAX, out_status);
+}
+
+uint32_t
+parse_arg_uint32(char *name, int *out_status)
+{
+    return parse_arg_long_bounds(name, 0, UINT32_MAX, out_status);
+}
+
+uint16_t
+parse_arg_uint16_dflt(char *name, uint16_t dflt, int *out_status)
+{
+    uint16_t val;
+    int rc;
+
+    val = parse_arg_uint16(name, &rc);
+    if (rc == ENOENT) {
+        val = dflt;
+        rc = 0;
+    }
+
+    *out_status = rc;
+    return val;
+}
+
+int
+parse_arg_kv(char *name, struct kv_pair *kvs)
+{
+    struct kv_pair *kv;
+    char *sval;
+
+    sval = parse_arg_find(name);
+    if (sval == NULL) {
+        return ENOENT;
+    }
+
+    kv = parse_kv_find(kvs, sval);
+    if (kv == NULL) {
+        return EINVAL;
+    }
+
+    return kv->val;
+}
+
+static int
+parse_arg_byte_stream_no_delim(char *sval, int max_len, uint8_t *dst,
+                               int *out_len)
+{
+    unsigned long ul;
+    char *endptr;
+    char buf[3];
+    int i;
+
+    buf[2] = '\0';
+    i = 0;
+    while (1) {
+        if (sval[i * 2] == '\0') {
+            *out_len = i;
+            return 0;
+        }
+
+        if (i >= max_len) {
+            return EINVAL;
+        }
+
+        buf[0] = sval[i * 2 + 0];
+        buf[1] = sval[i * 2 + 1];
+
+        ul = strtoul(buf, &endptr, 16);
+        if (*sval == '\0' || *endptr != '\0') {
+            return EINVAL;
+        }
+
+        assert(ul <= UINT8_MAX);
+        dst[i] = ul;
+
+        i++;
+    }
+}
+
+static int
+parse_arg_byte_stream_delim(char *sval, char *delims, int max_len,
+                            uint8_t *dst, int *out_len)
+{
+    unsigned long ul;
+    char *endptr;
+    char *token;
+    int i;
+
+    i = 0;
+    for (token = strtok(sval, delims);
+         token != NULL;
+         token = strtok(NULL, delims)) {
+
+        if (i >= max_len) {
+            return EINVAL;
+        }
+
+        ul = strtoul(token, &endptr, 16);
+        if (sval[0] == '\0' || *endptr != '\0' || ul > UINT8_MAX) {
+            return -1;
+        }
+
+        dst[i] = ul;
+        i++;
+    }
+
+    *out_len = i;
+
+    return 0;
+}
+
+int
+parse_arg_byte_stream(char *name, int max_len, uint8_t *dst, int *out_len)
+{
+    int total_len;
+    char *sval;
+
+    sval = parse_arg_find(name);
+    if (sval == NULL) {
+        return ENOENT;
+    }
+
+    total_len = strlen(sval);
+    if (strcspn(sval, ":-") == total_len) {
+        return parse_arg_byte_stream_no_delim(sval, max_len, dst, out_len);
+    } else {
+        return parse_arg_byte_stream_delim(sval, ":-", max_len, dst, out_len);
+    }
+}
+
+int
+parse_arg_byte_stream_exact_length(char *name, uint8_t *dst, int len)
+{
+    int actual_len;
+    int rc;
+
+    rc = parse_arg_byte_stream(name, 6, dst, &actual_len);
+    if (rc != 0) {
+        return rc;
+    }
+
+    if (actual_len != len) {
+        return EINVAL;
+    }
+
+    return 0;
+}
+
+static void
+parse_reverse_bytes(uint8_t *bytes, int len)
+{
+    uint8_t tmp;
+    int i;
+
+    for (i = 0; i < len / 2; i++) {
+        tmp = bytes[i];
+        bytes[i] = bytes[len - i - 1];
+        bytes[len - i - 1] = tmp;
+    }
+}
+
+int
+parse_arg_mac(char *name, uint8_t *dst)
+{
+    int rc;
+
+    rc = parse_arg_byte_stream_exact_length(name, dst, 6);
+    if (rc != 0) {
+        return rc;
+    }
+
+    parse_reverse_bytes(dst, 6);
+
+    return 0;
+}
+
+int
+parse_arg_uuid(char *str, uint8_t *dst_uuid128)
+{
+    uint16_t uuid16;
+    char *tok;
+    int rc;
+
+    uuid16 = parse_arg_uint16(str, &rc);
+    switch (rc) {
+    case ENOENT:
+        return ENOENT;
+
+    case 0:
+        rc = ble_uuid_16_to_128(uuid16, dst_uuid128);
+        if (rc != 0) {
+            return EINVAL;
+        } else {
+            return 0;
+        }
+
+    default:
+        /* e7add801-b042-4876-aae1112855353cc1 */
+        if (strlen(str) == 35) {
+            tok = strtok(str, "-");
+            if (tok == NULL) {
+                return EINVAL;
+            }
+            rc = parse_arg_byte_stream_exact_length(tok, dst_uuid128 + 0, 4);
+            if (rc != 0) {
+                return rc;
+            }
+
+            tok = strtok(NULL, "-");
+            if (tok == NULL) {
+                return EINVAL;
+            }
+            rc = parse_arg_byte_stream_exact_length(tok, dst_uuid128 + 4, 2);
+            if (rc != 0) {
+                return rc;
+            }
+
+            tok = strtok(NULL, "-");
+            if (tok == NULL) {
+                return EINVAL;
+            }
+            rc = parse_arg_byte_stream_exact_length(tok, dst_uuid128 + 6, 2);
+            if (rc != 0) {
+                return rc;
+            }
+
+            tok = strtok(NULL, "-");
+            if (tok == NULL) {
+                return EINVAL;
+            }
+            rc = parse_arg_byte_stream_exact_length(tok, dst_uuid128 + 8, 8);
+            if (rc != 0) {
+                return rc;
+            }
+
+            return 0;
+        }
+
+        rc = parse_arg_byte_stream_exact_length(str, dst_uuid128, 16);
+        return rc;
+    }
+}
+
+int
+parse_arg_all(int argc, char **argv)
+{
+    char *key;
+    char *val;
+    int i;
+
+    cmd_num_args = 0;
+
+    for (i = 0; i < argc; i++) {
+        key = strtok(argv[i], "=");
+        val = strtok(NULL, "=");
+
+        if (key != NULL && val != NULL) {
+            if (strlen(key) == 0) {
+                BLETINY_LOG(ERROR, "Error: invalid argument: %s\n", argv[i]);
+                return -1;
+            }
+
+            if (cmd_num_args >= CMD_MAX_ARGS) {
+                BLETINY_LOG(ERROR, "Error: too many arguments");
+                return -1;
+            }
+
+            cmd_args[cmd_num_args][0] = key;
+            cmd_args[cmd_num_args][1] = val;
+            cmd_num_args++;
+        }
+    }
+
+    return 0;
+}
+



[15/42] incubator-mynewt-core git commit: Merge branch 'develop' of https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core into develop

Posted by cc...@apache.org.
Merge branch 'develop' of https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core into develop


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/3aad5609
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/3aad5609
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/3aad5609

Branch: refs/heads/master
Commit: 3aad560940c8f2230b01528423b062a0e222d3c0
Parents: c133880 64b0dae
Author: Sterling Hughes <st...@apache.org>
Authored: Thu Mar 10 11:06:56 2016 -0800
Committer: Sterling Hughes <st...@apache.org>
Committed: Thu Mar 10 11:06:56 2016 -0800

----------------------------------------------------------------------
 hw/bsp/native/pkg.yml                     | 1 +
 hw/bsp/nrf51dk-16kbram/pkg.yml            | 1 +
 hw/bsp/nrf51dk/pkg.yml                    | 1 +
 hw/bsp/nrf52pdk/pkg.yml                   | 1 +
 hw/bsp/olimex_stm32-e407_devboard/pkg.yml | 1 +
 5 files changed, 5 insertions(+)
----------------------------------------------------------------------



[29/42] incubator-mynewt-core git commit: Undef byte swapping macros that exist in some envs.

Posted by cc...@apache.org.
Undef byte swapping macros that exist in some envs.

This allows the nimble unit tests to compile in sim on my linux machine.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/05ce86e7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/05ce86e7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/05ce86e7

Branch: refs/heads/master
Commit: 05ce86e74ca37058c2cdc9f70e2a1f57f1b0f2ca
Parents: 2d2a07a
Author: ccollins at iori.nightmare.heaven <cc...@iori.nightmare-heaven.no-ip.biz>
Authored: Wed Mar 9 09:57:25 2016 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Fri Mar 11 12:16:14 2016 -0800

----------------------------------------------------------------------
 net/nimble/include/nimble/ble.h | 6 ++++++
 1 file changed, 6 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/05ce86e7/net/nimble/include/nimble/ble.h
----------------------------------------------------------------------
diff --git a/net/nimble/include/nimble/ble.h b/net/nimble/include/nimble/ble.h
index e9a1e93..babb3ac 100644
--- a/net/nimble/include/nimble/ble.h
+++ b/net/nimble/include/nimble/ble.h
@@ -109,6 +109,12 @@ struct ble_mbuf_hdr
 extern uint8_t g_dev_addr[BLE_DEV_ADDR_LEN];
 extern uint8_t g_random_addr[BLE_DEV_ADDR_LEN];
 
+#undef htole16
+#undef htole32
+#undef htole64
+#undef le16toh
+#undef le32toh
+#undef le64toh
 void htole16(void *buf, uint16_t x);
 void htole32(void *buf, uint32_t x);
 void htole64(void *buf, uint64_t x);


[22/42] incubator-mynewt-core git commit: Rename baselibc test directory so that newt ignores it.

Posted by cc...@apache.org.
Rename baselibc test directory so that newt ignores it.

These tests are part of the original baselibc library, so they aren't
compatible with the "newt test" command.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/cfc3383e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/cfc3383e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/cfc3383e

Branch: refs/heads/master
Commit: cfc3383e886a96b624c46c3eea2ac99b7d4d1e1f
Parents: 3af4ca4
Author: Christopher Collins <cc...@gmail.com>
Authored: Thu Mar 10 19:29:42 2016 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Thu Mar 10 19:29:42 2016 -0800

----------------------------------------------------------------------
 libs/baselibc/src/baselibc_test/printf_tests.c | 22 ++++++++++++++
 libs/baselibc/src/baselibc_test/tests_glue.c   | 33 +++++++++++++++++++++
 libs/baselibc/src/baselibc_test/unittests.h    | 14 +++++++++
 libs/baselibc/src/test/printf_tests.c          | 22 --------------
 libs/baselibc/src/test/tests_glue.c            | 33 ---------------------
 libs/baselibc/src/test/unittests.h             | 14 ---------
 6 files changed, 69 insertions(+), 69 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/cfc3383e/libs/baselibc/src/baselibc_test/printf_tests.c
----------------------------------------------------------------------
diff --git a/libs/baselibc/src/baselibc_test/printf_tests.c b/libs/baselibc/src/baselibc_test/printf_tests.c
new file mode 100644
index 0000000..f9f380f
--- /dev/null
+++ b/libs/baselibc/src/baselibc_test/printf_tests.c
@@ -0,0 +1,22 @@
+#include "unittests.h"
+
+int main()
+{
+    int status = 0;
+    
+    {
+        COMMENT("Testing basic snprintf functionality");
+        char buf[20];
+        
+        snprintf(buf, sizeof(buf), "%08d", 55);
+        TEST(strcmp(buf, "00000055") == 0);
+        
+        TEST(snprintf(buf, sizeof(buf), "01234567890123456789") == 20);
+        TEST(strcmp(buf, "0123456789012345678") == 0);
+    }
+        
+    if (status != 0)
+        fprintf(stdout, "\n\nSome tests FAILED!\n");
+
+    return status;
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/cfc3383e/libs/baselibc/src/baselibc_test/tests_glue.c
----------------------------------------------------------------------
diff --git a/libs/baselibc/src/baselibc_test/tests_glue.c b/libs/baselibc/src/baselibc_test/tests_glue.c
new file mode 100644
index 0000000..b18a689
--- /dev/null
+++ b/libs/baselibc/src/baselibc_test/tests_glue.c
@@ -0,0 +1,33 @@
+#include <stdio.h>
+
+#if defined(linux)
+/* Connects the baselibc stdio to normal POSIX stdio */
+size_t write(int fd, const void *buf, size_t count);
+
+static size_t stdio_write(FILE *instance, const char *bp, size_t n)
+{
+    if (instance == stdout)
+        return write(1, bp, n);
+    else
+        return write(2, bp, n);
+}
+#else
+#error No suitable write() implementation.
+#endif
+
+
+static struct File_methods stdio_methods = {
+        &stdio_write, NULL
+};
+
+static struct File _stdout = {
+        &stdio_methods
+};
+
+static struct File _stderr = {
+        &stdio_methods
+};
+
+FILE* const stdout = &_stdout;
+FILE* const stderr = &_stderr;
+

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/cfc3383e/libs/baselibc/src/baselibc_test/unittests.h
----------------------------------------------------------------------
diff --git a/libs/baselibc/src/baselibc_test/unittests.h b/libs/baselibc/src/baselibc_test/unittests.h
new file mode 100644
index 0000000..c2b470a
--- /dev/null
+++ b/libs/baselibc/src/baselibc_test/unittests.h
@@ -0,0 +1,14 @@
+#include <stdio.h>
+
+#define COMMENT(x) printf("\n----" x "----\n");
+#define STR(x) #x
+#define STR2(x) STR(x)
+#define TEST(x) \
+    if (!(x)) { \
+        fprintf(stderr, "\033[31;1mFAILED:\033[22;39m " __FILE__ ":" STR2(__LINE__) " " #x "\n"); \
+        status = 1; \
+    } else { \
+        printf("\033[32;1mOK:\033[22;39m " #x "\n"); \
+    }
+
+

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/cfc3383e/libs/baselibc/src/test/printf_tests.c
----------------------------------------------------------------------
diff --git a/libs/baselibc/src/test/printf_tests.c b/libs/baselibc/src/test/printf_tests.c
deleted file mode 100644
index f9f380f..0000000
--- a/libs/baselibc/src/test/printf_tests.c
+++ /dev/null
@@ -1,22 +0,0 @@
-#include "unittests.h"
-
-int main()
-{
-    int status = 0;
-    
-    {
-        COMMENT("Testing basic snprintf functionality");
-        char buf[20];
-        
-        snprintf(buf, sizeof(buf), "%08d", 55);
-        TEST(strcmp(buf, "00000055") == 0);
-        
-        TEST(snprintf(buf, sizeof(buf), "01234567890123456789") == 20);
-        TEST(strcmp(buf, "0123456789012345678") == 0);
-    }
-        
-    if (status != 0)
-        fprintf(stdout, "\n\nSome tests FAILED!\n");
-
-    return status;
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/cfc3383e/libs/baselibc/src/test/tests_glue.c
----------------------------------------------------------------------
diff --git a/libs/baselibc/src/test/tests_glue.c b/libs/baselibc/src/test/tests_glue.c
deleted file mode 100644
index b18a689..0000000
--- a/libs/baselibc/src/test/tests_glue.c
+++ /dev/null
@@ -1,33 +0,0 @@
-#include <stdio.h>
-
-#if defined(linux)
-/* Connects the baselibc stdio to normal POSIX stdio */
-size_t write(int fd, const void *buf, size_t count);
-
-static size_t stdio_write(FILE *instance, const char *bp, size_t n)
-{
-    if (instance == stdout)
-        return write(1, bp, n);
-    else
-        return write(2, bp, n);
-}
-#else
-#error No suitable write() implementation.
-#endif
-
-
-static struct File_methods stdio_methods = {
-        &stdio_write, NULL
-};
-
-static struct File _stdout = {
-        &stdio_methods
-};
-
-static struct File _stderr = {
-        &stdio_methods
-};
-
-FILE* const stdout = &_stdout;
-FILE* const stderr = &_stderr;
-

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/cfc3383e/libs/baselibc/src/test/unittests.h
----------------------------------------------------------------------
diff --git a/libs/baselibc/src/test/unittests.h b/libs/baselibc/src/test/unittests.h
deleted file mode 100644
index c2b470a..0000000
--- a/libs/baselibc/src/test/unittests.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <stdio.h>
-
-#define COMMENT(x) printf("\n----" x "----\n");
-#define STR(x) #x
-#define STR2(x) STR(x)
-#define TEST(x) \
-    if (!(x)) { \
-        fprintf(stderr, "\033[31;1mFAILED:\033[22;39m " __FILE__ ":" STR2(__LINE__) " " #x "\n"); \
-        status = 1; \
-    } else { \
-        printf("\033[32;1mOK:\033[22;39m " #x "\n"); \
-    }
-
-


[31/42] incubator-mynewt-core git commit: Closes pull request #16

Posted by cc...@apache.org.
Closes pull request #16

This indicates that Neel's linux fix has been merged to develop.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/473f5a83
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/473f5a83
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/473f5a83

Branch: refs/heads/master
Commit: 473f5a83c3e08f58ab2e4ca6108bb65dd920fabf
Parents: f51c77b
Author: Christopher Collins <cc...@gmail.com>
Authored: Fri Mar 11 12:26:06 2016 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Fri Mar 11 12:26:06 2016 -0800

----------------------------------------------------------------------

----------------------------------------------------------------------



[10/42] incubator-mynewt-core git commit: Capitalize unit test feature names.

Posted by cc...@apache.org.
Capitalize unit test feature names.

test -> TEST
selftest -> SELFTEST

It seems the convention is to use all caps for feature names.  These two
were the only two features that didn't follow that convention.

Also, the SELFTEST feature now adds this cflag: -DMYNEWT_SELFTEST

It used to be: -DPKG_TEST.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/36afc70c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/36afc70c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/36afc70c

Branch: refs/heads/master
Commit: 36afc70c580bbe2c71c4d21bb6cc39c0a82fb72c
Parents: e880b3c
Author: Christopher Collins <cc...@gmail.com>
Authored: Wed Mar 9 18:40:21 2016 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Wed Mar 9 18:40:21 2016 -0800

----------------------------------------------------------------------
 apps/test/pkg.yml                         | 3 ---
 fs/nffs/src/test/arch/sim/nffs_test.c     | 2 +-
 hw/hal/src/test/flash_map_test.c          | 2 +-
 libs/bootutil/src/test/boot_test.c        | 2 +-
 libs/mbedtls/pkg.yml                      | 2 +-
 libs/mbedtls/src/test/mbedtls_test.c      | 2 +-
 libs/os/pkg.yml                           | 2 +-
 libs/os/src/test/os_test.c                | 2 +-
 libs/testutil/include/testutil/testutil.h | 2 +-
 libs/testutil/pkg.yml                     | 2 ++
 libs/util/src/test/util_test.c            | 2 +-
 net/nimble/host/pkg.yml                   | 6 +++---
 net/nimble/host/src/test/ble_hs_test.c    | 2 +-
 sys/config/src/test/conf_test.c           | 2 +-
 14 files changed, 16 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/36afc70c/apps/test/pkg.yml
----------------------------------------------------------------------
diff --git a/apps/test/pkg.yml b/apps/test/pkg.yml
index f375073..d442071 100644
--- a/apps/test/pkg.yml
+++ b/apps/test/pkg.yml
@@ -36,6 +36,3 @@ pkg.deps:
     - libs/testutil
     - libs/util
     - sys/config
-
-pkg.features:
-    - test

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/36afc70c/fs/nffs/src/test/arch/sim/nffs_test.c
----------------------------------------------------------------------
diff --git a/fs/nffs/src/test/arch/sim/nffs_test.c b/fs/nffs/src/test/arch/sim/nffs_test.c
index 8fdb080..5e2d462 100644
--- a/fs/nffs/src/test/arch/sim/nffs_test.c
+++ b/fs/nffs/src/test/arch/sim/nffs_test.c
@@ -2489,7 +2489,7 @@ nffs_test_all(void)
     return tu_any_failed;
 }
 
-#ifdef PKG_TEST
+#ifdef MYNEWT_SELFTEST
 
 int
 main(void)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/36afc70c/hw/hal/src/test/flash_map_test.c
----------------------------------------------------------------------
diff --git a/hw/hal/src/test/flash_map_test.c b/hw/hal/src/test/flash_map_test.c
index b733f16..c9df88c 100644
--- a/hw/hal/src/test/flash_map_test.c
+++ b/hw/hal/src/test/flash_map_test.c
@@ -153,7 +153,7 @@ TEST_SUITE(flash_map_test_suite)
     flash_map_test_case_2();
 }
 
-#ifdef PKG_TEST
+#ifdef MYNEWT_SELFTEST
 
 int
 main(int argc, char **argv)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/36afc70c/libs/bootutil/src/test/boot_test.c
----------------------------------------------------------------------
diff --git a/libs/bootutil/src/test/boot_test.c b/libs/bootutil/src/test/boot_test.c
index e0242b8..b6814eb 100644
--- a/libs/bootutil/src/test/boot_test.c
+++ b/libs/bootutil/src/test/boot_test.c
@@ -1147,7 +1147,7 @@ boot_test_all(void)
     return tu_any_failed;
 }
 
-#ifdef PKG_TEST
+#ifdef MYNEWT_SELFTEST
 
 int
 main(void)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/36afc70c/libs/mbedtls/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/mbedtls/pkg.yml b/libs/mbedtls/pkg.yml
index a36d9af..2c7b3b3 100644
--- a/libs/mbedtls/pkg.yml
+++ b/libs/mbedtls/pkg.yml
@@ -30,4 +30,4 @@ pkg.keywords:
 pkg.cflags: -DMBEDTLS_USER_CONFIG_FILE=\"mbedtls/config_mynewt.h\"
 pkg.deps:
     - libs/testutil
-pkg.cflags.test: -DTEST
+pkg.cflags.TEST: -DTEST

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/36afc70c/libs/mbedtls/src/test/mbedtls_test.c
----------------------------------------------------------------------
diff --git a/libs/mbedtls/src/test/mbedtls_test.c b/libs/mbedtls/src/test/mbedtls_test.c
index e30200a..dee9040 100644
--- a/libs/mbedtls/src/test/mbedtls_test.c
+++ b/libs/mbedtls/src/test/mbedtls_test.c
@@ -212,7 +212,7 @@ TEST_SUITE(mbedtls_test_all)
     xtea_test();
 }
 
-#ifdef PKG_TEST
+#ifdef MYNEWT_SELFTEST
 int
 main(int argc, char **argv)
 {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/36afc70c/libs/os/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/os/pkg.yml b/libs/os/pkg.yml
index 0fccae3..269d052 100644
--- a/libs/os/pkg.yml
+++ b/libs/os/pkg.yml
@@ -36,4 +36,4 @@ pkg.deps.SHELL:
 pkg.cflags.SHELL: -DSHELL_PRESENT 
 
 # Satisfy capability dependencies for the self-contained test executable.
-pkg.deps.selftest: libs/console/stub
+pkg.deps.SELFTEST: libs/console/stub

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/36afc70c/libs/os/src/test/os_test.c
----------------------------------------------------------------------
diff --git a/libs/os/src/test/os_test.c b/libs/os/src/test/os_test.c
index e4cff6a..0f180bb 100644
--- a/libs/os/src/test/os_test.c
+++ b/libs/os/src/test/os_test.c
@@ -34,7 +34,7 @@ os_test_all(void)
     return tu_case_failed;
 }
 
-#ifdef PKG_TEST
+#ifdef MYNEWT_SELFTEST
 
 int
 main(int argc, char **argv)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/36afc70c/libs/testutil/include/testutil/testutil.h
----------------------------------------------------------------------
diff --git a/libs/testutil/include/testutil/testutil.h b/libs/testutil/include/testutil/testutil.h
index f3243f4..2868cdd 100644
--- a/libs/testutil/include/testutil/testutil.h
+++ b/libs/testutil/include/testutil/testutil.h
@@ -153,7 +153,7 @@ extern jmp_buf tu_case_jb;
 #define TEST_PASS(...)                                                        \
     tu_case_pass_manual(__FILE__, __LINE__, __VA_ARGS__);
 
-#ifdef TEST
+#ifdef MYNEWT_UNIT_TEST
 #define ASSERT_IF_TEST(expr) assert(expr)
 #else
 #define ASSERT_IF_TEST(expr)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/36afc70c/libs/testutil/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/testutil/pkg.yml b/libs/testutil/pkg.yml
index 070b149..d1fe7ca 100644
--- a/libs/testutil/pkg.yml
+++ b/libs/testutil/pkg.yml
@@ -30,3 +30,5 @@ pkg.keywords:
 pkg.deps:
     - hw/hal
     - libs/os
+
+pkg.cflags.TEST: "-DMYNEWT_UNIT_TEST"

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/36afc70c/libs/util/src/test/util_test.c
----------------------------------------------------------------------
diff --git a/libs/util/src/test/util_test.c b/libs/util/src/test/util_test.c
index 11b820c..c236ab5 100644
--- a/libs/util/src/test/util_test.c
+++ b/libs/util/src/test/util_test.c
@@ -29,7 +29,7 @@ util_test_all(void)
     return tu_case_failed;
 }
 
-#ifdef PKG_TEST
+#ifdef MYNEWT_SELFTEST
 
 int
 main(int argc, char **argv)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/36afc70c/net/nimble/host/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/host/pkg.yml b/net/nimble/host/pkg.yml
index 5e07071..27c82cb 100644
--- a/net/nimble/host/pkg.yml
+++ b/net/nimble/host/pkg.yml
@@ -37,6 +37,6 @@ pkg.req_apis:
     - console
 
 # Satisfy capability dependencies for the self-contained test executable.
-pkg.deps.selftest: libs/console/stub
-pkg.cflags.selftest: -DPHONY_TRANSPORT
-pkg.cflags.test: -DBLE_HS_DEBUG
+pkg.deps.SELFTEST: libs/console/stub
+pkg.cflags.SELFTEST: -DPHONY_TRANSPORT
+pkg.cflags.TEST: -DBLE_HS_DEBUG

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/36afc70c/net/nimble/host/src/test/ble_hs_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_hs_test.c b/net/nimble/host/src/test/ble_hs_test.c
index 16f83de..aa837b0 100644
--- a/net/nimble/host/src/test/ble_hs_test.c
+++ b/net/nimble/host/src/test/ble_hs_test.c
@@ -42,7 +42,7 @@ ble_hs_test_hci_txed(uint8_t *cmdbuf)
     ble_hs_test_util_prev_hci_tx = cmdbuf;
 }
 
-#ifdef PKG_TEST
+#ifdef MYNEWT_SELFTEST
 
 int
 main(void)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/36afc70c/sys/config/src/test/conf_test.c
----------------------------------------------------------------------
diff --git a/sys/config/src/test/conf_test.c b/sys/config/src/test/conf_test.c
index fd8828c..427cac0 100644
--- a/sys/config/src/test/conf_test.c
+++ b/sys/config/src/test/conf_test.c
@@ -187,7 +187,7 @@ TEST_SUITE(config_test_all)
     config_test_commit();
 }
 
-#ifdef PKG_TEST
+#ifdef MYNEWT_SELFTEST
 
 int
 main(int argc, char **argv)


[17/42] incubator-mynewt-core git commit: Add necessary type field to packages.

Posted by cc...@apache.org.
Add necessary type field to packages.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/6d634b47
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/6d634b47
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/6d634b47

Branch: refs/heads/master
Commit: 6d634b473948618ef5958ffb5f244c53894065d6
Parents: b307127
Author: Christopher Collins <cc...@gmail.com>
Authored: Thu Mar 10 11:29:56 2016 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Thu Mar 10 11:29:56 2016 -0800

----------------------------------------------------------------------
 apps/bletest/pkg.yml                      | 1 +
 apps/bletiny/pkg.yml                      | 1 +
 apps/blinky/pkg.yml                       | 1 +
 apps/boot/pkg.yml                         | 1 +
 apps/ffs2native/pkg.yml                   | 1 +
 apps/luatest/pkg.yml                      | 1 +
 apps/slinky/pkg.yml                       | 1 +
 apps/test/pkg.yml                         | 1 +
 compiler/arm-none-eabi-m0/pkg.yml         | 1 +
 compiler/arm-none-eabi-m4/pkg.yml         | 1 +
 compiler/sim/pkg.yml                      | 1 +
 hw/bsp/native/pkg.yml                     | 1 +
 hw/bsp/nrf51dk-16kbram/pkg.yml            | 1 +
 hw/bsp/nrf51dk/pkg.yml                    | 1 +
 hw/bsp/nrf52pdk/pkg.yml                   | 1 +
 hw/bsp/olimex_stm32-e407_devboard/pkg.yml | 1 +
 16 files changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6d634b47/apps/bletest/pkg.yml
----------------------------------------------------------------------
diff --git a/apps/bletest/pkg.yml b/apps/bletest/pkg.yml
index b7e098b..918f7f4 100644
--- a/apps/bletest/pkg.yml
+++ b/apps/bletest/pkg.yml
@@ -18,6 +18,7 @@
 #
 
 pkg.name: apps/bletest
+pkg.type: app
 pkg.vers: 0.8.0
 pkg.description: Test project for the nimble BLE controller.
 pkg.author: wes3 <wi...@runtime.io>

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6d634b47/apps/bletiny/pkg.yml
----------------------------------------------------------------------
diff --git a/apps/bletiny/pkg.yml b/apps/bletiny/pkg.yml
index 1956484..851461d 100644
--- a/apps/bletiny/pkg.yml
+++ b/apps/bletiny/pkg.yml
@@ -16,6 +16,7 @@
 # under the License.
 #
 pkg.name: apps/bletiny
+pkg.type: app
 pkg.vers: 0.8.0
 pkg.description: Shell application exposing the nimble GAP and GATT.
 pkg.author: Christopher Collins <cc...@apache.org>

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6d634b47/apps/blinky/pkg.yml
----------------------------------------------------------------------
diff --git a/apps/blinky/pkg.yml b/apps/blinky/pkg.yml
index 5a4a97f..44bf925 100644
--- a/apps/blinky/pkg.yml
+++ b/apps/blinky/pkg.yml
@@ -18,6 +18,7 @@
 #
 
 pkg.name: apps/blinky
+pkg.type: app
 pkg.vers: 0.8.0
 pkg.description: Basic example application which blinks an LED.
 pkg.author: Marko Kiiskila <ma...@runtime.io>

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6d634b47/apps/boot/pkg.yml
----------------------------------------------------------------------
diff --git a/apps/boot/pkg.yml b/apps/boot/pkg.yml
index 71c29ca..3041abb 100644
--- a/apps/boot/pkg.yml
+++ b/apps/boot/pkg.yml
@@ -18,6 +18,7 @@
 #
 
 pkg.name: apps/boot
+pkg.type: app
 pkg.vers: 0.8.0
 pkg.description: Boot loader application.
 pkg.author: Christopher Collins <ch...@apache.org>

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6d634b47/apps/ffs2native/pkg.yml
----------------------------------------------------------------------
diff --git a/apps/ffs2native/pkg.yml b/apps/ffs2native/pkg.yml
index 718b0ac..abb9800 100644
--- a/apps/ffs2native/pkg.yml
+++ b/apps/ffs2native/pkg.yml
@@ -18,6 +18,7 @@
 #
 
 pkg.name: apps/ffs2native
+pkg.type: app
 pkg.vers: 0.8.0
 pkg.description: Support application for debugging the Newtron Flash File System.
 pkg.author: Christopher Collins <cc...@apache.org>

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6d634b47/apps/luatest/pkg.yml
----------------------------------------------------------------------
diff --git a/apps/luatest/pkg.yml b/apps/luatest/pkg.yml
index 3fefaa8..7d83b97 100644
--- a/apps/luatest/pkg.yml
+++ b/apps/luatest/pkg.yml
@@ -16,6 +16,7 @@
 # under the License.
 #
 pkg.name: apps/luatest
+pkg.type: app
 pkg.vers: 0.8.0
 pkg.description: Simple project for testing Lua scripting.
 pkg.author: Marko Kiiskila <ma...@runtime.io>

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6d634b47/apps/slinky/pkg.yml
----------------------------------------------------------------------
diff --git a/apps/slinky/pkg.yml b/apps/slinky/pkg.yml
index d5f792a..d286ade 100644
--- a/apps/slinky/pkg.yml
+++ b/apps/slinky/pkg.yml
@@ -18,6 +18,7 @@
 #
 
 pkg.name: apps/slinky
+pkg.type: app
 pkg.vers: 0.8.0
 pkg.description: Example application which uses a variety of mynewt features.
 pkg.author: Marko Kiiskila <ma...@runtime.io>

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6d634b47/apps/test/pkg.yml
----------------------------------------------------------------------
diff --git a/apps/test/pkg.yml b/apps/test/pkg.yml
index 4da07d0..c6a42af 100644
--- a/apps/test/pkg.yml
+++ b/apps/test/pkg.yml
@@ -18,6 +18,7 @@
 #
 
 pkg.name: apps/test
+pkg.type: app
 pkg.vers: 0.8.0
 pkg.description: Automated test suite for mynewt core functionality.
 pkg.author: Christopher Collins <cc...@apache.org>

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6d634b47/compiler/arm-none-eabi-m0/pkg.yml
----------------------------------------------------------------------
diff --git a/compiler/arm-none-eabi-m0/pkg.yml b/compiler/arm-none-eabi-m0/pkg.yml
index 36972c5..f920944 100644
--- a/compiler/arm-none-eabi-m0/pkg.yml
+++ b/compiler/arm-none-eabi-m0/pkg.yml
@@ -18,6 +18,7 @@
 #
 
 pkg.name: compiler/arm-none-eabi-m0
+pkg.type: compiler
 pkg.vers: 0.8.0
 pkg.description: Compiler definition for ARM Cortex-M0 gcc cross compiler.
 pkg.author: wes3 <wi...@runtime.io>

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6d634b47/compiler/arm-none-eabi-m4/pkg.yml
----------------------------------------------------------------------
diff --git a/compiler/arm-none-eabi-m4/pkg.yml b/compiler/arm-none-eabi-m4/pkg.yml
index 6b33971..c04b1b3 100644
--- a/compiler/arm-none-eabi-m4/pkg.yml
+++ b/compiler/arm-none-eabi-m4/pkg.yml
@@ -18,6 +18,7 @@
 #
 
 pkg.name: compiler/arm-none-eabi-m4
+pkg.type: compiler
 pkg.vers: 0.8.0
 pkg.description: Compiler definition for ARM Cortex-M4 gcc cross compiler.
 pkg.author: sterling <st...@runtime.io>

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6d634b47/compiler/sim/pkg.yml
----------------------------------------------------------------------
diff --git a/compiler/sim/pkg.yml b/compiler/sim/pkg.yml
index 6078cc2..b0ec2be 100644
--- a/compiler/sim/pkg.yml
+++ b/compiler/sim/pkg.yml
@@ -18,6 +18,7 @@
 #
 
 pkg.name: compiler/sim
+pkg.type: compiler
 pkg.vers: 0.8.0
 pkg.description: Compiler definition for native gcc compiler.
 pkg.author: sterling <st...@runtime.io>

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6d634b47/hw/bsp/native/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/native/pkg.yml b/hw/bsp/native/pkg.yml
index fe8346b..c3ade4d 100644
--- a/hw/bsp/native/pkg.yml
+++ b/hw/bsp/native/pkg.yml
@@ -18,6 +18,7 @@
 #
 
 pkg.name: hw/bsp/native
+pkg.type: bsp
 pkg.vers: 0.8.0
 pkg.description: BSP definition for native (amd64) applications.
 pkg.author: Christopher Collins <cc...@apache.org>

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6d634b47/hw/bsp/nrf51dk-16kbram/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf51dk-16kbram/pkg.yml b/hw/bsp/nrf51dk-16kbram/pkg.yml
index 4d26cf2..76fea72 100644
--- a/hw/bsp/nrf51dk-16kbram/pkg.yml
+++ b/hw/bsp/nrf51dk-16kbram/pkg.yml
@@ -18,6 +18,7 @@
 #
 
 pkg.name: hw/bsp/nrf51dk-16kbram
+pkg.type: bsp
 pkg.vers: 0.8.0
 pkg.description: BSP definition for a Nordic nRF51 DK SoC with 16kB RAM.
 pkg.author: Christopher Collins <ch...@apache.org>

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6d634b47/hw/bsp/nrf51dk/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf51dk/pkg.yml b/hw/bsp/nrf51dk/pkg.yml
index a6d888c..0bbd67d 100644
--- a/hw/bsp/nrf51dk/pkg.yml
+++ b/hw/bsp/nrf51dk/pkg.yml
@@ -18,6 +18,7 @@
 #
 
 pkg.name: hw/bsp/nrf51dk
+pkg.type: bsp
 pkg.vers: 0.8.0
 pkg.description: BSP definition for the Nordic nRF51 DK SoC.
 pkg.author: wes3 <wi...@runtime.io>

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6d634b47/hw/bsp/nrf52pdk/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf52pdk/pkg.yml b/hw/bsp/nrf52pdk/pkg.yml
index 9f68182..b048144 100644
--- a/hw/bsp/nrf52pdk/pkg.yml
+++ b/hw/bsp/nrf52pdk/pkg.yml
@@ -18,6 +18,7 @@
 #
 
 pkg.name: hw/bsp/nrf52pdk
+pkg.type: bsp
 pkg.vers: 0.8.0
 pkg.description: BSP definition for the Nordic nRF52 Preview DK SoC.
 pkg.author: wes3 <wi...@runtime.io>

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6d634b47/hw/bsp/olimex_stm32-e407_devboard/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/olimex_stm32-e407_devboard/pkg.yml b/hw/bsp/olimex_stm32-e407_devboard/pkg.yml
index 3d37b94..96e4222 100644
--- a/hw/bsp/olimex_stm32-e407_devboard/pkg.yml
+++ b/hw/bsp/olimex_stm32-e407_devboard/pkg.yml
@@ -18,6 +18,7 @@
 #
 
 pkg.name: hw/bsp/olimex_stm32-e407_devboard
+pkg.type: bsp
 pkg.vers: 0.8.0
 pkg.description: BSP definition for the Olimex STM32-E407 board.
 pkg.author: Sterling Hughes <st...@apache.org>


[03/42] incubator-mynewt-core git commit: Reflect repository name change in yml files. Types in packages. Move projects -> apps.

Posted by cc...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/libs/console/stub/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/console/stub/pkg.yml b/libs/console/stub/pkg.yml
index 6a73d9c..cf9da84 100644
--- a/libs/console/stub/pkg.yml
+++ b/libs/console/stub/pkg.yml
@@ -22,8 +22,8 @@ pkg.vers: 0.8.0
 pkg.description: Stub for text-based IO interface.
 pkg.author: Marko Kiiskila <ma...@runtime.io>
 pkg.homepage: http://mynewt.apache.org/os/modules/console/console/
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
 pkg.keywords:
 
 pkg.deps:
-pkg.caps: console
+pkg.apis: console

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/libs/elua/elua_base/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/elua/elua_base/pkg.yml b/libs/elua/elua_base/pkg.yml
index 6388961..ffb48a1 100644
--- a/libs/elua/elua_base/pkg.yml
+++ b/libs/elua/elua_base/pkg.yml
@@ -24,14 +24,14 @@ pkg.author:
     - Bogdan Marinescu
     - Dado Sutter
 pkg.homepage: http://www.eluaproject.net/
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
 pkg.keywords:
     - lua
     - scripting
     - interpreter
 
 pkg.cflags: -DLUA_OPTIMIZE_MEMORY=2 -DLUA_CROSS_COMPILER -DLUA_USE_MKSTEMP -DLUA_NUMBER_INTEGRAL -DMYNEWT
-pkg.req_caps:
+pkg.req_apis:
     - console
 pkg.deps:
     - fs/fs

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/libs/flash_test/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/flash_test/pkg.yml b/libs/flash_test/pkg.yml
index c830455..569f72f 100644
--- a/libs/flash_test/pkg.yml
+++ b/libs/flash_test/pkg.yml
@@ -19,12 +19,17 @@
 
 pkg.name: libs/flash_test
 pkg.vers: 0.8.0
+pkg.description: flash HAL tester
+pkg.homepage:
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.keywords:
+
 pkg.deps:
     - libs/os
     - libs/util
     - hw/hal
     - libs/baselibc
-pkg.reqs:
+pkg.req_apis:
     - console
-pkg.identities:
+pkg.features:
     - TEST

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/libs/imgmgr/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/imgmgr/pkg.yml b/libs/imgmgr/pkg.yml
index f1a3a8c..fd22888 100644
--- a/libs/imgmgr/pkg.yml
+++ b/libs/imgmgr/pkg.yml
@@ -22,7 +22,7 @@ pkg.vers: 0.8.0
 pkg.description: Library for image uploading.
 pkg.author: Marko Kiiskila <ma...@runtime.io>
 pkg.homepage: http://mynewt.apache.org/os/modules/imgmgr/imgmgr/
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
 pkg.keywords:
 
 pkg.deps:

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/libs/json/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/json/pkg.yml b/libs/json/pkg.yml
index cf2032a..a9e45a9 100644
--- a/libs/json/pkg.yml
+++ b/libs/json/pkg.yml
@@ -22,7 +22,7 @@ pkg.vers: 0.8.0
 pkg.description: JSON encoding / decoding library.
 pkg.author: Sterling Hughes <st...@apache.org>
 pkg.homepage: http://mynewt.apache.org/os/modules/json/json/
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
 pkg.keywords:
 
 pkg.cflags.float_user: -DFLOAT_SUPPORT

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/libs/mbedtls/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/mbedtls/pkg.yml b/libs/mbedtls/pkg.yml
index d877198..a36d9af 100644
--- a/libs/mbedtls/pkg.yml
+++ b/libs/mbedtls/pkg.yml
@@ -22,7 +22,7 @@ pkg.vers: 0.8.0
 pkg.description: SSL / TLS library for embedded systems.
 pkg.author: ARM
 pkg.homepage: https://tls.mbed.org/
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
 pkg.keywords:
     - ssl
     - tls

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/libs/newtmgr/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/newtmgr/pkg.yml b/libs/newtmgr/pkg.yml
index 83c25e6..fc7c0db 100644
--- a/libs/newtmgr/pkg.yml
+++ b/libs/newtmgr/pkg.yml
@@ -22,7 +22,7 @@ pkg.vers: 0.8.0
 pkg.description: Server-side newtmgr functionality.
 pkg.author: Sterling Hughes <st...@apache.org>
 pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
 pkg.keywords:
 
 pkg.deps:
@@ -32,5 +32,5 @@ pkg.deps:
     - libs/testutil
     - libs/shell
 
-pkg.identities:
+pkg.features:
     - NEWTMGR 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/libs/os/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/os/pkg.yml b/libs/os/pkg.yml
index 6cf0627..bf7fa7d 100644
--- a/libs/os/pkg.yml
+++ b/libs/os/pkg.yml
@@ -22,13 +22,13 @@ pkg.vers: 0.8.0
 pkg.description: Mynewt operating system core.
 pkg.author: wes3 <wi...@runtime.io>
 pkg.homepage: http://mynewt.apache.org/os/core_os/mynewt_os/
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
 pkg.keywords:
 
 pkg.deps:
     - libs/testutil
     - libs/util
-pkg.req_caps:
+pkg.req_apis:
     - console
 
 pkg.deps.SHELL:

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/libs/shell/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/shell/pkg.yml b/libs/shell/pkg.yml
index 389f162..8600f68 100644
--- a/libs/shell/pkg.yml
+++ b/libs/shell/pkg.yml
@@ -22,13 +22,13 @@ pkg.vers: 0.8.0
 pkg.description: Command processor for console-based applications.
 pkg.author: Sterling Hughes <st...@apache.org>
 pkg.homepage: http://mynewt.apache.org/os/modules/shell/shell/
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
 pkg.keywords:
 
 pkg.deps:
     - libs/os
     - libs/util
-pkg.reqs:
+pkg.apis:
     - console
-pkg.identities:
+pkg.features:
     - SHELL 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/libs/testreport/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/testreport/pkg.yml b/libs/testreport/pkg.yml
index c0ca116..84b82ad 100644
--- a/libs/testreport/pkg.yml
+++ b/libs/testreport/pkg.yml
@@ -22,7 +22,7 @@ pkg.vers: 0.8.0
 pkg.description: Library for recording unit test results to flash.
 pkg.author: Christopher Collins <cc...@apache.org>
 pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
 pkg.keywords:
     - unit
     - test

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/libs/testutil/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/testutil/pkg.yml b/libs/testutil/pkg.yml
index 1d899d5..070b149 100644
--- a/libs/testutil/pkg.yml
+++ b/libs/testutil/pkg.yml
@@ -22,7 +22,7 @@ pkg.vers: 0.8.0
 pkg.description: Support library for implementing unit tests.
 pkg.author: Christopher Collins <cc...@apache.org>
 pkg.homepage: http://mynewt.apache.org/os/modules/testutil/testutil/
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
 pkg.keywords:
     - unit
     - test

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/libs/util/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/util/pkg.yml b/libs/util/pkg.yml
index 3ef5276..f61c089 100644
--- a/libs/util/pkg.yml
+++ b/libs/util/pkg.yml
@@ -22,7 +22,7 @@ pkg.vers: 0.8.0
 pkg.description: Library containing miscellaneous utilities.
 pkg.author: Sterling Hughes <st...@apache.org>
 pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
 pkg.keywords:
     - base64
     - circular buffer

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/net/nimble/controller/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/controller/pkg.yml b/net/nimble/controller/pkg.yml
index 379a7ba..c521aec 100644
--- a/net/nimble/controller/pkg.yml
+++ b/net/nimble/controller/pkg.yml
@@ -22,7 +22,7 @@ pkg.vers: 0.8.0
 pkg.description: Controller side of the nimble Bluetooth Smart stack.
 pkg.author: wes3 <wi...@runtime.io>
 pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
 pkg.keywords:
     - ble
     - bluetooth
@@ -31,5 +31,5 @@ pkg.deps:
     - libs/os
     - sys/stats
     - net/nimble
-pkg.identities:
+pkg.features:
     - BLE_DEVICE

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/net/nimble/drivers/native/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/drivers/native/pkg.yml b/net/nimble/drivers/native/pkg.yml
index f0a6d3a..272d2dd 100644
--- a/net/nimble/drivers/native/pkg.yml
+++ b/net/nimble/drivers/native/pkg.yml
@@ -22,11 +22,11 @@ pkg.vers: 0.8.0
 pkg.description: BLE driver for simulations.
 pkg.author: wes3 <wi...@runtime.io>
 pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
 pkg.keywords:
     - ble
     - bluetooth
 
-pkg.caps: ble_driver
+pkg.apis: ble_driver
 pkg.deps:
     - net/nimble/controller

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/net/nimble/drivers/nrf51/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/drivers/nrf51/pkg.yml b/net/nimble/drivers/nrf51/pkg.yml
index 78ad311..1ebfaec 100644
--- a/net/nimble/drivers/nrf51/pkg.yml
+++ b/net/nimble/drivers/nrf51/pkg.yml
@@ -22,12 +22,12 @@ pkg.vers: 0.8.0
 pkg.description: BLE driver for nRF51 systems.
 pkg.author: wes3 <wi...@runtime.io>
 pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
 pkg.keywords:
     - ble
     - bluetooth
 
-pkg.caps: ble_driver
+pkg.apis: ble_driver
 pkg.deps:
     - net/nimble
     - net/nimble/controller

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/net/nimble/drivers/nrf52/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/drivers/nrf52/pkg.yml b/net/nimble/drivers/nrf52/pkg.yml
index f9f2a8b..e4255bb 100644
--- a/net/nimble/drivers/nrf52/pkg.yml
+++ b/net/nimble/drivers/nrf52/pkg.yml
@@ -22,12 +22,12 @@ pkg.vers: 0.8.0
 pkg.description: BLE driver for nRF52 systems.
 pkg.author: wes3 <wi...@runtime.io>
 pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
 pkg.keywords:
     - ble
     - bluetooth
 
-pkg.caps: ble_driver
+pkg.apis: ble_driver
 pkg.deps:
     - net/nimble
     - net/nimble/controller

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/net/nimble/host/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/host/pkg.yml b/net/nimble/host/pkg.yml
index a4610be..5e07071 100644
--- a/net/nimble/host/pkg.yml
+++ b/net/nimble/host/pkg.yml
@@ -22,7 +22,7 @@ pkg.vers: 0.8.0
 pkg.description: Host side of the nimble Bluetooth Smart stack.
 pkg.author: Christopher Collins <cc...@apache.org>
 pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
 pkg.keywords:
     - ble
     - bluetooth
@@ -33,7 +33,7 @@ pkg.deps:
     - libs/os
     - libs/util
     - net/nimble
-pkg.req_caps:
+pkg.req_apis:
     - console
 
 # Satisfy capability dependencies for the self-contained test executable.

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/net/nimble/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/pkg.yml b/net/nimble/pkg.yml
index e5e2b90..70c31b8 100644
--- a/net/nimble/pkg.yml
+++ b/net/nimble/pkg.yml
@@ -22,7 +22,7 @@ pkg.vers: 0.8.0
 pkg.description: Generic functionality for the nimble Bluetooth Smart stack; used by both the controller and the host.
 pkg.author: wes3 <wi...@runtime.io>
 pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
 pkg.keywords:
     - ble
     - bluetooth

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/pkg-list.yml
----------------------------------------------------------------------
diff --git a/pkg-list.yml b/pkg-list.yml
index 3edb569..f3cae7e 100644
--- a/pkg-list.yml
+++ b/pkg-list.yml
@@ -38,14 +38,14 @@ pkgs:
     libs/console/stub:
         vers: 0.8.0
         hash: d41aedc5941495ca9320cc013f68ee73d4e349ab
-        caps:
+        apis:
             - console@none#stable
     libs/os:
         vers: 0.8.0
         hash: 999a3419d9959d3c39b11dcc67d79c7888b4b765
         deps:
             - libs/testutil@none#stable
-        req_caps:
+        req_apis:
             - console@none#stable
     project/blinky:
         vers: 0.8.0
@@ -74,7 +74,7 @@ pkgs:
         hash: 513cc71e129320e3e2d80a9cdfc748db6c83fbb4
         deps:
             - net/nimble/controller@none#stable
-        caps:
+        apis:
             - ble_driver@none#stable
     fs/fs:
         vers: 0.8.0
@@ -92,7 +92,7 @@ pkgs:
         hash: 0f4bff75e83236ad27c49ba9a161d50b76c648fb
         deps:
             - fs/fs@none#stable
-        req_caps:
+        req_apis:
             - console@none#stable
     libs/util:
         vers: 0.8.0
@@ -220,7 +220,7 @@ pkgs:
         deps:
             - net/nimble@none#stable
             - net/nimble/controller@none#stable
-        caps:
+        apis:
             - ble_driver@none#stable
     compiler/arm-none-eabi-m4:
         vers: 0.8.0
@@ -231,7 +231,7 @@ pkgs:
         deps:
             - hw/hal@none#stable
             - libs/os@none#stable
-        caps:
+        apis:
             - console@none#stable
     hw/mcu/stm/stm32f4xx:
         vers: 0.0.0
@@ -295,7 +295,7 @@ pkgs:
             - libs/os@none#stable
             - libs/util@none#stable
             - net/nimble@none#stable
-        req_caps:
+        req_apis:
             - console@none#stable
     libs/imgmgr:
         vers: 0.8.0
@@ -319,7 +319,7 @@ pkgs:
     libs/baselibc:
         vers: 0.8.0
         hash: bb46b003c472b16309bd9fbed81f5c4c62bd4aa5
-        req_caps:
+        req_apis:
             - console@none#stable
     net/nimble/drivers/nrf52:
         vers: 0.8.0
@@ -327,7 +327,7 @@ pkgs:
         deps:
             - net/nimble@none#stable
             - net/nimble/controller@none#stable
-        caps:
+        apis:
             - ble_driver@none#stable
     hw/mcu/nordic/nrf51xxx:
         vers: 0.0.0

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/project.yml
----------------------------------------------------------------------
diff --git a/project.yml b/project.yml
new file mode 100644
index 0000000..5c30981
--- /dev/null
+++ b/project.yml
@@ -0,0 +1,26 @@
+#
+# 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.
+#
+
+project.name: "apache-mynewt-core"
+
+repository.apache-mynewt-core:
+    type: github
+    vers: 0-latest
+    user: sterlinghughes
+    repo: incubator-mynewt-core

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/project/bleprph/src/bleprph.h
----------------------------------------------------------------------
diff --git a/project/bleprph/src/bleprph.h b/project/bleprph/src/bleprph.h
deleted file mode 100644
index e903fe0..0000000
--- a/project/bleprph/src/bleprph.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * 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.
- */
-
-#ifndef H_BLEPRPH_
-#define H_BLEPRPH_
-
-#include "log/log.h"
-
-void gatt_svr_init(void);
-
-extern struct log bleprph_log;
-
-extern const char *bleprph_device_name;
-extern const uint16_t bleprph_appearance;
-extern const uint8_t bleprph_privacy_flag;
-extern uint8_t bleprph_reconnect_addr[6];
-extern uint8_t bleprph_pref_conn_params[8];
-extern uint8_t bleprph_gatt_service_changed[4];
-
-/* bleprph uses the first "peruser" log module. */
-#define BLEPRPH_LOG_MODULE  (LOG_MODULE_PERUSER + 0)
-
-/* Convenience macro for logging to the bleprph module. */
-#define BLEPRPH_LOG(lvl, ...) \
-    LOG_ ## lvl(&bleprph_log, BLEPRPH_LOG_MODULE, __VA_ARGS__)
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/project/bleprph/src/gatt_svr.c
----------------------------------------------------------------------
diff --git a/project/bleprph/src/gatt_svr.c b/project/bleprph/src/gatt_svr.c
deleted file mode 100644
index 27a1433..0000000
--- a/project/bleprph/src/gatt_svr.c
+++ /dev/null
@@ -1,342 +0,0 @@
-/**
- * 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 "bsp/bsp.h"
-#include "console/console.h"
-#include "host/ble_hs.h"
-#include "bleprph.h"
-
-#define GATT_SVR_SVC_ALERT_UUID               0x1811
-#define GATT_SVR_CHR_SUP_NEW_ALERT_CAT_UUID   0x2A47
-#define GATT_SVR_CHR_NEW_ALERT                0x2A46
-#define GATT_SVR_CHR_SUP_UNR_ALERT_CAT_UUID   0x2A48
-#define GATT_SVR_CHR_UNR_ALERT_STAT_UUID      0x2A45
-#define GATT_SVR_CHR_ALERT_NOT_CTRL_PT        0x2A44
-
-static int
-gatt_svr_chr_access_gap(uint16_t conn_handle, uint16_t attr_handle, uint8_t op,
-                        union ble_gatt_access_ctxt *ctxt, void *arg);
-static int
-gatt_svr_chr_access_gatt(uint16_t conn_handle, uint16_t attr_handle, uint8_t op,
-                         union ble_gatt_access_ctxt *ctxt, void *arg);
-static int
-gatt_svr_chr_access_alert(uint16_t conn_handle, uint16_t attr_handle,
-                          uint8_t op, union ble_gatt_access_ctxt *ctxt,
-                          void *arg);
-
-static const struct ble_gatt_svc_def gatt_svr_svcs[] = {
-    {
-        /*** Service: GAP. */
-        .type = BLE_GATT_SVC_TYPE_PRIMARY,
-        .uuid128 = BLE_UUID16(BLE_GAP_SVC_UUID16),
-        .characteristics = (struct ble_gatt_chr_def[]) { {
-            /*** Characteristic: Device Name. */
-            .uuid128 = BLE_UUID16(BLE_GAP_CHR_UUID16_DEVICE_NAME),
-            .access_cb = gatt_svr_chr_access_gap,
-            .flags = BLE_GATT_CHR_F_READ,
-        }, {
-            /*** Characteristic: Appearance. */
-            .uuid128 = BLE_UUID16(BLE_GAP_CHR_UUID16_APPEARANCE),
-            .access_cb = gatt_svr_chr_access_gap,
-            .flags = BLE_GATT_CHR_F_READ,
-        }, {
-            /*** Characteristic: Peripheral Privacy Flag. */
-            .uuid128 = BLE_UUID16(BLE_GAP_CHR_UUID16_PERIPH_PRIV_FLAG),
-            .access_cb = gatt_svr_chr_access_gap,
-            .flags = BLE_GATT_CHR_F_READ,
-        }, {
-            /*** Characteristic: Reconnection Address. */
-            .uuid128 = BLE_UUID16(BLE_GAP_CHR_UUID16_RECONNECT_ADDR),
-            .access_cb = gatt_svr_chr_access_gap,
-            .flags = BLE_GATT_CHR_F_WRITE,
-        }, {
-            /*** Characteristic: Peripheral Preferred Connection Parameters. */
-            .uuid128 = BLE_UUID16(BLE_GAP_CHR_UUID16_PERIPH_PREF_CONN_PARAMS),
-            .access_cb = gatt_svr_chr_access_gap,
-            .flags = BLE_GATT_CHR_F_READ,
-        }, {
-            0, /* No more characteristics in this service. */
-        } },
-    },
-
-    {
-        /*** Service: GATT */
-        .type = BLE_GATT_SVC_TYPE_PRIMARY,
-        .uuid128 = BLE_UUID16(BLE_GATT_SVC_UUID16),
-        .characteristics = (struct ble_gatt_chr_def[]) { {
-            .uuid128 = BLE_UUID16(BLE_GATT_CHR_SERVICE_CHANGED_UUID16),
-            .access_cb = gatt_svr_chr_access_gatt,
-            .flags = BLE_GATT_CHR_F_INDICATE,
-        }, {
-            0, /* No more characteristics in this service. */
-        } },
-    },
-
-    {
-        /*** Alert Notification Service. */
-        .type = BLE_GATT_SVC_TYPE_PRIMARY,
-        .uuid128 = BLE_UUID16(GATT_SVR_SVC_ALERT_UUID),
-        .characteristics = (struct ble_gatt_chr_def[]) { {
-            .uuid128 = BLE_UUID16(GATT_SVR_CHR_SUP_NEW_ALERT_CAT_UUID),
-            .access_cb = gatt_svr_chr_access_alert,
-            .flags = BLE_GATT_CHR_F_READ,
-        }, {
-            .uuid128 = BLE_UUID16(GATT_SVR_CHR_NEW_ALERT),
-            .access_cb = gatt_svr_chr_access_alert,
-            .flags = BLE_GATT_CHR_F_NOTIFY,
-        }, {
-            .uuid128 = BLE_UUID16(GATT_SVR_CHR_SUP_UNR_ALERT_CAT_UUID),
-            .access_cb = gatt_svr_chr_access_alert,
-            .flags = BLE_GATT_CHR_F_READ,
-        }, {
-            .uuid128 = BLE_UUID16(GATT_SVR_CHR_UNR_ALERT_STAT_UUID),
-            .access_cb = gatt_svr_chr_access_alert,
-            .flags = BLE_GATT_CHR_F_NOTIFY,
-        }, {
-            .uuid128 = BLE_UUID16(GATT_SVR_CHR_ALERT_NOT_CTRL_PT),
-            .access_cb = gatt_svr_chr_access_alert,
-            .flags = BLE_GATT_CHR_F_WRITE,
-        }, {
-            0, /* No more characteristics in this service. */
-        } },
-    },
-
-    {
-        0, /* No more services. */
-    },
-};
-
-static int
-gatt_svr_chr_write(uint8_t op, union ble_gatt_access_ctxt *ctxt,
-                   uint16_t min_len, uint16_t max_len, void *dst,
-                   uint16_t *len)
-{
-    assert(op == BLE_GATT_ACCESS_OP_WRITE_CHR);
-    if (ctxt->chr_access.len < min_len ||
-        ctxt->chr_access.len > max_len) {
-        return BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN;
-    }
-    memcpy(dst, ctxt->chr_access.data, ctxt->chr_access.len);
-    if (len != NULL) {
-        *len = ctxt->chr_access.len;
-    }
-
-    return 0;
-}
-
-static int
-gatt_svr_chr_access_gap(uint16_t conn_handle, uint16_t attr_handle, uint8_t op,
-                        union ble_gatt_access_ctxt *ctxt, void *arg)
-{
-    uint16_t uuid16;
-
-    uuid16 = ble_uuid_128_to_16(ctxt->chr_access.chr->uuid128);
-    assert(uuid16 != 0);
-
-    switch (uuid16) {
-    case BLE_GAP_CHR_UUID16_DEVICE_NAME:
-        assert(op == BLE_GATT_ACCESS_OP_READ_CHR);
-        ctxt->chr_access.data = (void *)bleprph_device_name;
-        ctxt->chr_access.len = strlen(bleprph_device_name);
-        break;
-
-    case BLE_GAP_CHR_UUID16_APPEARANCE:
-        assert(op == BLE_GATT_ACCESS_OP_READ_CHR);
-        ctxt->chr_access.data = (void *)&bleprph_appearance;
-        ctxt->chr_access.len = sizeof bleprph_appearance;
-        break;
-
-    case BLE_GAP_CHR_UUID16_PERIPH_PRIV_FLAG:
-        assert(op == BLE_GATT_ACCESS_OP_READ_CHR);
-        ctxt->chr_access.data = (void *)&bleprph_privacy_flag;
-        ctxt->chr_access.len = sizeof bleprph_privacy_flag;
-        break;
-
-    case BLE_GAP_CHR_UUID16_RECONNECT_ADDR:
-        assert(op == BLE_GATT_ACCESS_OP_WRITE_CHR);
-        if (ctxt->chr_access.len != sizeof bleprph_reconnect_addr) {
-            return BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN;
-        }
-        memcpy(bleprph_reconnect_addr, ctxt->chr_access.data,
-               sizeof bleprph_reconnect_addr);
-        break;
-
-    case BLE_GAP_CHR_UUID16_PERIPH_PREF_CONN_PARAMS:
-        assert(op == BLE_GATT_ACCESS_OP_READ_CHR);
-        ctxt->chr_access.data = (void *)&bleprph_pref_conn_params;
-        ctxt->chr_access.len = sizeof bleprph_pref_conn_params;
-        break;
-
-    default:
-        assert(0);
-        break;
-    }
-
-    return 0;
-}
-
-static int
-gatt_svr_chr_access_gatt(uint16_t conn_handle, uint16_t attr_handle, uint8_t op,
-                         union ble_gatt_access_ctxt *ctxt, void *arg)
-{
-    uint16_t uuid16;
-
-    uuid16 = ble_uuid_128_to_16(ctxt->chr_access.chr->uuid128);
-    assert(uuid16 != 0);
-
-    switch (uuid16) {
-    case BLE_GATT_CHR_SERVICE_CHANGED_UUID16:
-        if (op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
-            if (ctxt->chr_access.len != sizeof bleprph_gatt_service_changed) {
-                return BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN;
-            }
-            memcpy(bleprph_gatt_service_changed, ctxt->chr_access.data,
-                   sizeof bleprph_gatt_service_changed);
-        } else if (op == BLE_GATT_ACCESS_OP_READ_CHR) {
-            ctxt->chr_access.data = (void *)&bleprph_gatt_service_changed;
-            ctxt->chr_access.len = sizeof bleprph_gatt_service_changed;
-        }
-        break;
-
-    default:
-        assert(0);
-        break;
-    }
-
-    return 0;
-}
-
-#define GATT_SVR_NEW_ALERT_VAL_MAX_LEN    64
-
-static const uint8_t gatt_svr_new_alert_cat = 0x01; /* Simple alert. */
-static uint8_t gatt_svr_new_alert_val[GATT_SVR_NEW_ALERT_VAL_MAX_LEN];
-static uint16_t gatt_svr_new_alert_val_len;
-static const uint8_t gatt_svr_unr_alert_cat = 0x01; /* Simple alert. */
-static uint16_t gatt_svr_unr_alert_stat;
-static uint16_t gatt_svr_alert_not_ctrl_pt;
-
-static int
-gatt_svr_chr_access_alert(uint16_t conn_handle, uint16_t attr_handle,
-                          uint8_t op, union ble_gatt_access_ctxt *ctxt,
-                          void *arg)
-{
-    uint16_t uuid16;
-    int rc;
-
-    uuid16 = ble_uuid_128_to_16(ctxt->chr_access.chr->uuid128);
-    assert(uuid16 != 0);
-
-    switch (uuid16) {
-    case GATT_SVR_CHR_SUP_NEW_ALERT_CAT_UUID:
-        assert(op == BLE_GATT_ACCESS_OP_READ_CHR);
-        ctxt->chr_access.data = (void *)&gatt_svr_new_alert_cat;
-        ctxt->chr_access.len = sizeof gatt_svr_new_alert_cat;
-        return 0;
-
-    case GATT_SVR_CHR_NEW_ALERT:
-        if (op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
-            rc = gatt_svr_chr_write(op, ctxt, 0, sizeof gatt_svr_new_alert_val,
-                                  gatt_svr_new_alert_val,
-                                  &gatt_svr_new_alert_val_len);
-            return rc;
-        } else if (op == BLE_GATT_ACCESS_OP_READ_CHR) {
-            ctxt->chr_access.data = (void *)&gatt_svr_new_alert_val;
-            ctxt->chr_access.len = sizeof gatt_svr_new_alert_val;
-            return 0;
-        }
-
-    case GATT_SVR_CHR_SUP_UNR_ALERT_CAT_UUID:
-        assert(op == BLE_GATT_ACCESS_OP_READ_CHR);
-        ctxt->chr_access.data = (void *)&gatt_svr_unr_alert_cat;
-        ctxt->chr_access.len = sizeof gatt_svr_unr_alert_cat;
-        return 0;
-
-    case GATT_SVR_CHR_UNR_ALERT_STAT_UUID:
-        if (op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
-            rc = gatt_svr_chr_write(op, ctxt, 2, 2, &gatt_svr_unr_alert_stat,
-                                    NULL);
-        } else {
-            ctxt->chr_access.data = (void *)&gatt_svr_unr_alert_stat;
-            ctxt->chr_access.len = sizeof gatt_svr_unr_alert_stat;
-            rc = 0;
-        }
-        return rc;
-
-    case GATT_SVR_CHR_ALERT_NOT_CTRL_PT:
-        if (op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
-            rc = gatt_svr_chr_write(op, ctxt, 2, 2,
-                                    &gatt_svr_alert_not_ctrl_pt, NULL);
-        } else {
-            rc = BLE_ATT_ERR_UNLIKELY;
-        }
-        return rc;
-
-    default:
-        assert(0);
-        return BLE_ATT_ERR_UNLIKELY;
-    }
-}
-
-static void
-gatt_svr_register_cb(uint8_t op, union ble_gatt_register_ctxt *ctxt, void *arg)
-{
-    uint16_t uuid16;
-
-    switch (op) {
-    case BLE_GATT_REGISTER_OP_SVC:
-        uuid16 = ble_uuid_128_to_16(ctxt->svc_reg.svc->uuid128);
-        assert(uuid16 != 0);
-        BLEPRPH_LOG(DEBUG, "registered service 0x%04x with handle=%d\n",
-                    uuid16, ctxt->svc_reg.handle);
-        break;
-
-    case BLE_GATT_REGISTER_OP_CHR:
-        uuid16 = ble_uuid_128_to_16(ctxt->chr_reg.chr->uuid128);
-        assert(uuid16 != 0);
-        BLEPRPH_LOG(DEBUG, "registering characteristic 0x%04x with "
-                           "def_handle=%d val_handle=%d\n",
-                    uuid16, ctxt->chr_reg.def_handle,
-                    ctxt->chr_reg.val_handle);
-        break;
-
-    case BLE_GATT_REGISTER_OP_DSC:
-        uuid16 = ble_uuid_128_to_16(ctxt->dsc_reg.dsc->uuid128);
-        assert(uuid16 != 0);
-        BLEPRPH_LOG(DEBUG, "registering descriptor 0x%04x with handle=%d "
-                           "chr_handle=%d\n",
-                    uuid16, ctxt->dsc_reg.dsc_handle,
-                    ctxt->dsc_reg.chr_def_handle);
-        break;
-
-    default:
-        assert(0);
-        break;
-    }
-}
-
-void
-gatt_svr_init(void)
-{
-    int rc;
-
-    rc = ble_gatts_register_svcs(gatt_svr_svcs, gatt_svr_register_cb, NULL);
-    assert(rc == 0);
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/project/bleprph/src/main.c
----------------------------------------------------------------------
diff --git a/project/bleprph/src/main.c b/project/bleprph/src/main.c
deleted file mode 100755
index 8824428..0000000
--- a/project/bleprph/src/main.c
+++ /dev/null
@@ -1,299 +0,0 @@
-/**
- * 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 "bsp/bsp.h"
-#include "os/os.h"
-#include "bsp/bsp.h"
-#include "hal/hal_gpio.h"
-#include "hal/hal_cputime.h"
-#include "console/console.h"
-
-/* BLE */
-#include "nimble/ble.h"
-#include "host/host_hci.h"
-#include "host/ble_hs.h"
-#include "host/ble_hs_adv.h"
-#include "host/ble_uuid.h"
-#include "host/ble_att.h"
-#include "host/ble_gap.h"
-#include "host/ble_gatt.h"
-#include "controller/ble_ll.h"
-
-#include "bleprph.h"
-
-#define BSWAP16(x)  ((uint16_t)(((x) << 8) | (((x) & 0xff00) >> 8)))
-
-/** Mbuf settings. */
-#define MBUF_NUM_MBUFS      (8)
-#define MBUF_BUF_SIZE       OS_ALIGN(BLE_MBUF_PAYLOAD_SIZE, 4)
-#define MBUF_MEMBLOCK_SIZE  (MBUF_BUF_SIZE + BLE_MBUF_MEMBLOCK_OVERHEAD)
-#define MBUF_MEMPOOL_SIZE   OS_MEMPOOL_SIZE(MBUF_NUM_MBUFS, MBUF_MEMBLOCK_SIZE)
-
-static os_membuf_t bleprph_mbuf_mpool_data[MBUF_MEMPOOL_SIZE];
-struct os_mbuf_pool bleprph_mbuf_pool;
-struct os_mempool bleprph_mbuf_mpool;
-
-/** Log data. */
-static struct log_handler bleprph_log_console_handler;
-struct log bleprph_log;
-
-/** Priority of the nimble host task. */
-#define BLEPRPH_BLE_HS_PRIO          (1)
-
-/** bleprph task settings. */
-#define BLEPRPH_STACK_SIZE             (OS_STACK_ALIGN(200))
-#define BLEPRPH_TASK_PRIO              (BLEPRPH_BLE_HS_PRIO + 1)
-
-struct os_eventq bleprph_evq;
-struct os_task bleprph_task;
-bssnz_t os_stack_t bleprph_stack[BLEPRPH_STACK_SIZE];
-
-/** Our global device address (public) */
-uint8_t g_dev_addr[BLE_DEV_ADDR_LEN] = {0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a};
-
-/** Our random address (in case we need it) */
-uint8_t g_random_addr[BLE_DEV_ADDR_LEN];
-
-/** Device name - included in advertisements and exposed by GAP service. */
-const char *bleprph_device_name = "nimble-bleprph";
-
-/** Device properties - exposed by GAP service. */
-const uint16_t bleprph_appearance = BSWAP16(BLE_GAP_APPEARANCE_GEN_COMPUTER);
-const uint8_t bleprph_privacy_flag = 0;
-uint8_t bleprph_reconnect_addr[6];
-uint8_t bleprph_pref_conn_params[8];
-uint8_t bleprph_gatt_service_changed[4];
-
-static int bleprph_on_connect(int event, int status,
-                              struct ble_gap_conn_ctxt *ctxt, void *arg);
-
-/**
- * Utility function to log an array of bytes.
- */
-static void
-bleprph_print_bytes(uint8_t *bytes, int len)
-{
-    int i;
-
-    for (i = 0; i < len; i++) {
-        BLEPRPH_LOG(INFO, "%s0x%02x", i != 0 ? ":" : "", bytes[i]);
-    }
-}
-
-/**
- * Logs information about a connection to the console.
- */
-static void
-bleprph_print_conn_desc(struct ble_gap_conn_desc *desc)
-{
-    BLEPRPH_LOG(INFO, "handle=%d peer_addr_type=%d peer_addr=",
-                desc->conn_handle, desc->peer_addr_type);
-    bleprph_print_bytes(desc->peer_addr, 6);
-    BLEPRPH_LOG(INFO, " conn_itvl=%d conn_latency=%d supervision_timeout=%d",
-                desc->conn_itvl, desc->conn_latency,
-                desc->supervision_timeout);
-}
-
-/**
- * Enables advertising with the following parameters:
- *     o General discoverable mode.
- *     o Undirected connectable mode.
- */
-static void
-bleprph_advertise(void)
-{
-    struct ble_hs_adv_fields fields;
-    int rc;
-
-    /* Set the advertisement data included in our advertisements. */
-    memset(&fields, 0, sizeof fields);
-    fields.name = (uint8_t *)bleprph_device_name;
-    fields.name_len = strlen(bleprph_device_name);
-    fields.name_is_complete = 1;
-    rc = ble_gap_adv_set_fields(&fields);
-    if (rc != 0) {
-        BLEPRPH_LOG(ERROR, "error setting advertisement data; rc=%d\n", rc);
-        return;
-    }
-
-    /* Begin advertising. */
-    rc = ble_gap_adv_start(BLE_GAP_DISC_MODE_GEN, BLE_GAP_CONN_MODE_UND,
-                           NULL, 0, NULL, bleprph_on_connect, NULL);
-    if (rc != 0) {
-        BLEPRPH_LOG(ERROR, "error enabling advertisement; rc=%d\n", rc);
-        return;
-    }
-}
-
-static int
-bleprph_on_connect(int event, int status, struct ble_gap_conn_ctxt *ctxt,
-                   void *arg)
-{
-    switch (event) {
-    case BLE_GAP_EVENT_CONN:
-        BLEPRPH_LOG(INFO, "connection %s; status=%d ",
-                    status == 0 ? "up" : "down", status);
-        bleprph_print_conn_desc(ctxt->desc);
-        BLEPRPH_LOG(INFO, "\n");
-
-        if (status != 0) {
-            /* Connection terminated; resume advertising. */
-            bleprph_advertise();
-        }
-        break;
-
-    case BLE_GAP_EVENT_CONN_UPDATED:
-        BLEPRPH_LOG(INFO, "connection updated; status=%d ", status);
-        bleprph_print_conn_desc(ctxt->desc);
-        BLEPRPH_LOG(INFO, "\n");
-        break;
-
-    case BLE_GAP_EVENT_CONN_UPDATE_REQ:
-        BLEPRPH_LOG(INFO, "connection update request; status=%d ", status);
-        *ctxt->self_params = *ctxt->peer_params;
-        break;
-    }
-
-    return 0;
-}
-
-/**
- * Event loop for the main bleprph task.
- */
-static void
-bleprph_task_handler(void *unused)
-{
-    struct os_event *ev;
-    struct os_callout_func *cf;
-
-    /* Register GATT attributes (services, characteristics, and
-     * descriptors).
-     */
-    gatt_svr_init();
-
-    /* Initialize eventq */
-    os_eventq_init(&bleprph_evq);
-
-    /* Begin advertising. */
-    bleprph_advertise();
-
-    while (1) {
-        ev = os_eventq_get(&bleprph_evq);
-        switch (ev->ev_type) {
-        case OS_EVENT_T_TIMER:
-            cf = (struct os_callout_func *)ev;
-            assert(cf->cf_func);
-            cf->cf_func(cf->cf_arg);
-            break;
-        default:
-            assert(0);
-            break;
-        }
-    }
-}
-
-/**
- * main
- *
- * The main function for the project. This function initializes the os, calls
- * init_tasks to initialize tasks (and possibly other objects), then starts the
- * OS. We should not return from os start.
- *
- * @return int NOTE: this function should never return!
- */
-int
-main(void)
-{
-    struct ble_hs_cfg cfg;
-    uint32_t seed;
-    int rc;
-    int i;
-
-    /* Initialize OS */
-    os_init();
-
-    /* Set cputime to count at 1 usec increments */
-    rc = cputime_init(1000000);
-    assert(rc == 0);
-
-    /* Seed random number generator with least significant bytes of device
-     * address.
-     */
-    seed = 0;
-    for (i = 0; i < 4; ++i) {
-        seed |= g_dev_addr[i];
-        seed <<= 8;
-    }
-    srand(seed);
-
-    /* Initialize msys mbufs. */
-    rc = os_mempool_init(&bleprph_mbuf_mpool, MBUF_NUM_MBUFS, 
-                         MBUF_MEMBLOCK_SIZE, bleprph_mbuf_mpool_data, 
-                         "bleprph_mbuf_data");
-    assert(rc == 0);
-
-    rc = os_mbuf_pool_init(&bleprph_mbuf_pool, &bleprph_mbuf_mpool,
-                           MBUF_MEMBLOCK_SIZE, MBUF_NUM_MBUFS);
-    assert(rc == 0);
-
-    rc = os_msys_register(&bleprph_mbuf_pool);
-    assert(rc == 0);
-
-    /* Initialize the logging system. */
-    log_init();
-    log_console_handler_init(&bleprph_log_console_handler);
-    log_register("bleprph", &bleprph_log, &bleprph_log_console_handler);
-
-    os_task_init(&bleprph_task, "bleprph", bleprph_task_handler,
-                 NULL, BLEPRPH_TASK_PRIO, OS_WAIT_FOREVER,
-                 bleprph_stack, BLEPRPH_STACK_SIZE);
-
-    /* Initialize the BLE LL */
-    rc = ble_ll_init();
-    assert(rc == 0);
-
-    /* Initialize the BLE host. */
-    cfg = ble_hs_cfg_dflt;
-    cfg.max_hci_bufs = 3;
-    cfg.max_connections = 1;
-    cfg.max_attrs = 32;
-    cfg.max_services = 4;
-    cfg.max_client_configs = 6;
-    cfg.max_gattc_procs = 2;
-    cfg.max_l2cap_chans = 3;
-    cfg.max_l2cap_sig_procs = 2;
-
-    rc = ble_hs_init(BLEPRPH_BLE_HS_PRIO, &cfg);
-    assert(rc == 0);
-
-    /* Initialize the console (for log output). */
-    rc = console_init(NULL);
-    assert(rc == 0);
-
-    /* Start the OS */
-    os_start();
-
-    /* os start should never return. If it does, this should be an error */
-    assert(0);
-
-    return 0;
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/project/bletest/pkg.yml
----------------------------------------------------------------------
diff --git a/project/bletest/pkg.yml b/project/bletest/pkg.yml
deleted file mode 100644
index de3fdaa..0000000
--- a/project/bletest/pkg.yml
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-# 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: bletest
-pkg.vers: 0.8.0
-pkg.description: Test project for the nimble BLE controller.
-pkg.author: wes3 <wi...@runtime.io>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
-pkg.keywords:
-
-pkg.deps: 
-    - net/nimble/controller
-    - net/nimble/host
-    - libs/os 
-    - libs/console/full
-    - libs/baselibc
-    - libs/shell
-    - libs/imgmgr
-    - libs/newtmgr
-    - sys/config
-    - sys/log
-    - sys/stats
-pkg.cflags: -DBLETEST

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/project/bletest/src/main.c
----------------------------------------------------------------------
diff --git a/project/bletest/src/main.c b/project/bletest/src/main.c
deleted file mode 100755
index d004aa9..0000000
--- a/project/bletest/src/main.c
+++ /dev/null
@@ -1,969 +0,0 @@
-/**
- * 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 "os/os.h"
-#include "bsp/bsp.h"
-#include "hal/hal_gpio.h"
-#include "hal/hal_cputime.h"
-#include "hal/hal_flash.h"
-#include "console/console.h"
-#include "shell/shell.h"
-#include "stats/stats.h"
-#include "hal/flash_map.h"
-#include "fs/fs.h"
-#include "nffs/nffs.h"
-#include "newtmgr/newtmgr.h"
-#include "imgmgr/imgmgr.h"
-
-/* BLE */
-#include "nimble/ble.h"
-#include "nimble/hci_transport.h"
-#include "nimble/hci_common.h"
-#include "host/host_hci.h"
-#include "host/ble_hs.h"
-#include "controller/ble_ll.h"
-#include "controller/ble_ll_hci.h"
-#include "controller/ble_ll_conn.h"
-#include "controller/ble_ll_scan.h"
-#include "controller/ble_ll_adv.h"
-
-/* Task priorities */
-/* NOTE: highest priority task (0) reserved for controller LL task */
-#define HOST_TASK_PRIO      (OS_TASK_PRI_HIGHEST + 1)
-#define BLETEST_TASK_PRIO   (HOST_TASK_PRIO + 1)
-#define SHELL_TASK_PRIO     (BLETEST_TASK_PRIO + 1)
-#define NEWTMGR_TASK_PRIO   (SHELL_TASK_PRIO + 1)
-
-/* Shell task stack */
-#define SHELL_TASK_STACK_SIZE (OS_STACK_ALIGN(256))
-os_stack_t shell_stack[SHELL_TASK_STACK_SIZE];
-
-/* Newt manager task stack */
-#define NEWTMGR_TASK_STACK_SIZE (OS_STACK_ALIGN(448))
-os_stack_t newtmgr_stack[NEWTMGR_TASK_STACK_SIZE];
-
-/* Shell maximum input line length */
-#define SHELL_MAX_INPUT_LEN     (256)
-
-/* For LED toggling */
-int g_led_pin;
-
-/* Our global device address (public) */
-uint8_t g_dev_addr[BLE_DEV_ADDR_LEN];
-
-/* Our random address (in case we need it) */
-uint8_t g_random_addr[BLE_DEV_ADDR_LEN];
-
-/* A buffer for host advertising data */
-uint8_t g_host_adv_data[BLE_HCI_MAX_ADV_DATA_LEN];
-uint8_t g_host_adv_len;
-
-/* Create a mbuf pool of BLE mbufs */
-#define MBUF_NUM_MBUFS      (42)
-#define MBUF_BUF_SIZE       OS_ALIGN(BLE_MBUF_PAYLOAD_SIZE, 4)
-#define MBUF_MEMBLOCK_SIZE  (MBUF_BUF_SIZE + BLE_MBUF_MEMBLOCK_OVERHEAD)
-#define MBUF_MEMPOOL_SIZE   OS_MEMPOOL_SIZE(MBUF_NUM_MBUFS, MBUF_MEMBLOCK_SIZE)
-
-struct os_mbuf_pool g_mbuf_pool; 
-struct os_mempool g_mbuf_mempool;
-os_membuf_t g_mbuf_buffer[MBUF_MEMPOOL_SIZE];
-
-/* Some application configurations */
-#define BLETEST_ROLE_ADVERTISER         (0)
-#define BLETEST_ROLE_SCANNER            (1)
-#define BLETEST_ROLE_INITIATOR          (2)
-#define BLETEST_CFG_ROLE                (BLETEST_ROLE_INITIATOR)
-//#define BLETEST_CFG_ROLE                (BLETEST_ROLE_ADVERTISER)
-//#define BLETEST_CFG_ROLE                (BLETEST_ROLE_SCANNER)
-#define BLETEST_CFG_ADV_OWN_ADDR_TYPE   (BLE_HCI_ADV_OWN_ADDR_PUBLIC)
-#define BLETEST_CFG_ADV_PEER_ADDR_TYPE  (BLE_HCI_ADV_PEER_ADDR_PUBLIC)
-#define BLETEST_CFG_FILT_DUP_ADV        (0)
-#define BLETEST_CFG_ADV_ITVL            (600000 / BLE_HCI_ADV_ITVL)
-#define BLETEST_CFG_ADV_TYPE            BLE_HCI_ADV_TYPE_ADV_IND
-#define BLETEST_CFG_ADV_FILT_POLICY     (BLE_HCI_ADV_FILT_NONE)
-#define BLETEST_CFG_SCAN_ITVL           (700000 / BLE_HCI_SCAN_ITVL)
-#define BLETEST_CFG_SCAN_WINDOW         (700000 / BLE_HCI_SCAN_ITVL)
-#define BLETEST_CFG_SCAN_TYPE           (BLE_HCI_SCAN_TYPE_ACTIVE)
-#define BLETEST_CFG_SCAN_FILT_POLICY    (BLE_HCI_SCAN_FILT_NO_WL)
-#define BLETEST_CFG_CONN_ITVL           (128)  /* in 1.25 msec increments */           
-#define BLETEST_CFG_SLAVE_LATENCY       (0)
-#define BLETEST_CFG_INIT_FILTER_POLICY  (BLE_HCI_CONN_FILT_NO_WL)
-#define BLETEST_CFG_CONN_SPVN_TMO       (1000)  /* 20 seconds */
-#define BLETEST_CFG_MIN_CE_LEN          (6)    
-#define BLETEST_CFG_MAX_CE_LEN          (BLETEST_CFG_CONN_ITVL)
-#define BLETEST_CFG_CONN_PEER_ADDR_TYPE (BLE_HCI_CONN_PEER_ADDR_PUBLIC)
-#define BLETEST_CFG_CONN_OWN_ADDR_TYPE  (BLE_HCI_ADV_OWN_ADDR_RANDOM)
-#define BLETEST_CFG_CONCURRENT_CONNS    (1)
-
-/* BLETEST variables */
-#undef BLETEST_ADV_PKT_NUM
-#define BLETEST_PKT_SIZE                (251)
-#define BLETEST_STACK_SIZE              (256)
-uint32_t g_next_os_time;
-int g_bletest_state;
-struct os_eventq g_bletest_evq;
-struct os_callout_func g_bletest_timer;
-struct os_task bletest_task;
-bssnz_t os_stack_t bletest_stack[BLETEST_STACK_SIZE];
-uint32_t g_bletest_conn_end;
-int g_bletest_start_update;
-uint32_t g_bletest_conn_upd_time;
-uint8_t g_bletest_current_conns;
-uint8_t g_bletest_cur_peer_addr[BLE_DEV_ADDR_LEN];
-uint8_t g_last_handle_used;
-uint8_t g_bletest_led_state;
-uint32_t g_bletest_led_rate;
-uint32_t g_bletest_next_led_time;
-
-#ifdef BLETEST_ADV_PKT_NUM
-void
-bletest_inc_adv_pkt_num(void)
-{
-    int rc;
-    uint8_t *dptr;
-    uint8_t digit;
-
-    if (g_host_adv_len != 0) {
-        dptr = &g_host_adv_data[18];
-        while (dptr >= &g_host_adv_data[13]) {
-            digit = *dptr;
-            ++digit;
-            if (digit == 58) {
-                digit = 48;
-                *dptr = digit;
-                --dptr;
-            } else {
-                *dptr = digit;
-                break;
-            }
-        }
-
-        rc = host_hci_cmd_le_set_adv_data(g_host_adv_data, g_host_adv_len);
-        assert(rc == 0);
-        host_hci_outstanding_opcode = 0;
-    }
-}
-#endif
-
-void
-bletest_send_conn_update(uint16_t handle)
-{
-    int rc;
-    struct hci_conn_update hcu;
-
-    hcu.conn_latency = 4;
-    hcu.supervision_timeout = 2000; 
-    hcu.conn_itvl_min = 1000;
-    hcu.conn_itvl_max = 1000;
-    hcu.handle = handle;
-    hcu.min_ce_len = 4;
-    hcu.max_ce_len = 4;
-
-    rc = host_hci_cmd_le_conn_update(&hcu);
-    assert(rc == 0);
-    host_hci_outstanding_opcode = 0;
-}
-
-/**
- * Sets the advertising data to be sent in advertising pdu's which contain
- * advertising data.
- *
- * @param dptr
- * @return uint8_t
- */
-uint8_t
-bletest_set_adv_data(uint8_t *dptr)
-{
-    uint8_t len;
-
-    /* Place flags in first */
-    dptr[0] = 2;
-    dptr[1] = 0x01;     /* Flags identifier */
-    dptr[2] = 0x06;
-    dptr += 3;
-    len = 3;
-
-    /* Add local name */
-    dptr[0] = 15;   /* Length of this data, not including the length */
-    dptr[1] = 0x09;
-    dptr[2] = 'r';
-    dptr[3] = 'u';
-    dptr[4] = 'n';
-    dptr[5] = 't';
-    dptr[6] = 'i';
-    dptr[7] = 'm';
-    dptr[8] = 'e';
-    dptr[9] = '-';
-    dptr[10] = '0';
-    dptr[11] = '0';
-    dptr[12] = '0';
-    dptr[13] = '0';
-    dptr[14] = '0';
-    dptr[15] = '0';
-    dptr += 16;
-    len += 16;
-
-    /* Add local device address */
-    dptr[0] = 0x08;
-    dptr[1] = 0x1B;
-    dptr[2] = 0x00;
-    memcpy(dptr + 3, g_dev_addr, BLE_DEV_ADDR_LEN);
-    len += 9;
-
-    g_host_adv_len = len;
-
-    return len;
-}
-
-#if (BLETEST_CFG_ROLE == BLETEST_ROLE_ADVERTISER)
-void
-bletest_init_advertising(void)
-{
-    int rc;
-    uint8_t adv_len;
-    uint8_t rand_addr[BLE_DEV_ADDR_LEN];
-    struct hci_adv_params adv;
-
-    /* Just zero out advertising */
-    memset(&adv, 0, sizeof(struct hci_adv_params));
-
-    /* Set advertising parameters */
-    adv.adv_type = BLETEST_CFG_ADV_TYPE;
-    adv.adv_channel_map = 0x07;
-    adv.adv_filter_policy = BLETEST_CFG_ADV_FILT_POLICY;
-    adv.own_addr_type = BLETEST_CFG_ADV_OWN_ADDR_TYPE;
-    adv.peer_addr_type = BLETEST_CFG_ADV_PEER_ADDR_TYPE;
-    if ((adv.adv_type == BLE_HCI_ADV_TYPE_ADV_DIRECT_IND_HD) ||
-        (adv.adv_type == BLE_HCI_ADV_TYPE_ADV_DIRECT_IND_LD)) {
-        memcpy(adv.peer_addr, g_bletest_cur_peer_addr, BLE_DEV_ADDR_LEN);
-        if (adv.peer_addr_type == BLE_HCI_ADV_PEER_ADDR_RANDOM) {
-            adv.peer_addr[5] |= 0xc0;
-        }
-        adv_len = 0;
-    } else {
-        adv_len = bletest_set_adv_data(&g_host_adv_data[0]);
-    }
-
-    console_printf("Trying to connect to %x.%x.%x.%x.%x.%x\n",
-                   adv.peer_addr[0], adv.peer_addr[1], adv.peer_addr[2],
-                   adv.peer_addr[3], adv.peer_addr[4], adv.peer_addr[5]);
-
-    if (adv.adv_type == BLE_HCI_ADV_TYPE_ADV_DIRECT_IND_HD) {
-        adv.adv_itvl_min = 0;
-        adv.adv_itvl_max = 0;
-    } else {
-        adv.adv_itvl_min = BLETEST_CFG_ADV_ITVL;
-        adv.adv_itvl_max = BLETEST_CFG_ADV_ITVL; /* Advertising interval */
-    }
-
-    /* Set the advertising parameters */
-    rc = host_hci_cmd_le_set_adv_params(&adv);
-    assert(rc == 0);
-    host_hci_outstanding_opcode = 0;
-
-    /* If we are using a random address, we need to set it */
-    if (adv.own_addr_type == BLE_HCI_ADV_OWN_ADDR_RANDOM) {
-        memcpy(rand_addr, g_dev_addr, BLE_DEV_ADDR_LEN);
-        rand_addr[5] |= 0xc0;
-        rc = host_hci_cmd_le_set_rand_addr(rand_addr);
-        assert(rc == 0);
-        host_hci_outstanding_opcode = 0;
-    }
-
-    /* Set advertising data */
-    if (adv_len != 0) {
-        rc = host_hci_cmd_le_set_adv_data(&g_host_adv_data[0], adv_len);
-        assert(rc == 0);
-        host_hci_outstanding_opcode = 0;
-
-        /* Set scan response data */
-        rc = host_hci_cmd_le_set_scan_rsp_data(&g_host_adv_data[0], adv_len);
-        assert(rc == 0);
-        host_hci_outstanding_opcode = 0;
-    }
-}
-#endif
-
-#if (BLETEST_CFG_ROLE == BLETEST_ROLE_SCANNER)
-void
-bletest_init_scanner(void)
-{
-    int rc;
-    uint8_t dev_addr[BLE_DEV_ADDR_LEN];
-    uint8_t filter_policy;
-
-    /* Set scanning parameters */
-    rc = host_hci_cmd_le_set_scan_params(BLETEST_CFG_SCAN_TYPE,
-                                         BLETEST_CFG_SCAN_ITVL,
-                                         BLETEST_CFG_SCAN_WINDOW,
-                                         BLE_HCI_ADV_OWN_ADDR_PUBLIC,
-                                         BLETEST_CFG_SCAN_FILT_POLICY);
-    assert(rc == 0);
-    host_hci_outstanding_opcode = 0;
-
-    filter_policy = BLETEST_CFG_SCAN_FILT_POLICY;
-    if (filter_policy & 1) {
-        /* Add some whitelist addresses */
-        dev_addr[0] = 0x00;
-        dev_addr[1] = 0x00;
-        dev_addr[2] = 0x00;
-        dev_addr[3] = 0x88;
-        dev_addr[4] = 0x88;
-        dev_addr[5] = 0x08;
-        rc = host_hci_cmd_le_add_to_whitelist(dev_addr, BLE_ADDR_TYPE_PUBLIC);
-        assert(rc == 0);
-        host_hci_outstanding_opcode = 0;
-    }
-}
-
-void
-bletest_execute_scanner(void)
-{
-    int rc;
-
-    /* Enable scanning */
-    if ((int32_t)(os_time_get() - g_next_os_time) >= 0) {
-        if (g_bletest_state) {
-            rc = host_hci_cmd_le_set_scan_enable(0, BLETEST_CFG_FILT_DUP_ADV);
-            assert(rc == 0);
-            host_hci_outstanding_opcode = 0;
-            g_bletest_state = 0;
-        } else {
-            rc = host_hci_cmd_le_set_scan_enable(1, BLETEST_CFG_FILT_DUP_ADV);
-            assert(rc == 0);
-            host_hci_outstanding_opcode = 0;
-            g_bletest_state = 1;
-        }
-        g_next_os_time += (OS_TICKS_PER_SEC * 60);
-    }
-}
-#endif
-
-#if (BLETEST_CFG_ROLE == BLETEST_ROLE_INITIATOR)
-void
-bletest_init_initiator(void)
-{
-    int rc;
-    uint8_t rand_addr[BLE_DEV_ADDR_LEN];
-    struct hci_create_conn cc;
-    struct hci_create_conn *hcc;
-
-    /* Enable initiating */
-    hcc = &cc;
-    hcc->conn_itvl_max = BLETEST_CFG_CONN_ITVL;
-    hcc->conn_itvl_min = BLETEST_CFG_CONN_ITVL;
-    hcc->conn_latency = BLETEST_CFG_SLAVE_LATENCY;
-    hcc->filter_policy = BLETEST_CFG_INIT_FILTER_POLICY;
-    hcc->supervision_timeout = BLETEST_CFG_CONN_SPVN_TMO;
-    hcc->scan_itvl = BLETEST_CFG_SCAN_ITVL;
-    hcc->scan_window = BLETEST_CFG_SCAN_WINDOW;
-    hcc->peer_addr_type = BLETEST_CFG_CONN_PEER_ADDR_TYPE;
-    memcpy(hcc->peer_addr, g_bletest_cur_peer_addr, BLE_DEV_ADDR_LEN);
-    if (hcc->peer_addr_type == BLE_HCI_CONN_PEER_ADDR_RANDOM) {
-        hcc->peer_addr[5] |= 0xc0;
-    }
-    hcc->own_addr_type = BLETEST_CFG_CONN_OWN_ADDR_TYPE;
-    hcc->min_ce_len = BLETEST_CFG_MIN_CE_LEN;
-    hcc->max_ce_len = BLETEST_CFG_MAX_CE_LEN;
-
-    console_printf("Trying to connect to %x.%x.%x.%x.%x.%x\n",
-                   hcc->peer_addr[0], hcc->peer_addr[1], hcc->peer_addr[2],
-                   hcc->peer_addr[3], hcc->peer_addr[4], hcc->peer_addr[5]);
-
-    /* If we are using a random address, we need to set it */
-    if (hcc->own_addr_type == BLE_HCI_ADV_OWN_ADDR_RANDOM) {
-        memcpy(rand_addr, g_dev_addr, BLE_DEV_ADDR_LEN);
-        rand_addr[5] |= 0xc0;
-        rc = host_hci_cmd_le_set_rand_addr(rand_addr);
-        assert(rc == 0);
-        host_hci_outstanding_opcode = 0;
-    }
-
-    rc = host_hci_cmd_le_create_connection(hcc);
-    assert(rc == 0);
-    host_hci_outstanding_opcode = 0;
-}
-
-void
-bletest_execute_initiator(void)
-{
-    int i;
-    int rc;
-    uint16_t handle;
-    uint8_t new_chan_map[5];
-
-    /* 
-     * Determine if there is an active connection for the current handle
-     * we are trying to create. If so, start looking for the next one
-     */
-    if (g_bletest_current_conns < BLETEST_CFG_CONCURRENT_CONNS) {
-        handle = g_bletest_current_conns + 1;
-        if (ble_ll_conn_find_active_conn(handle)) {
-            /* Set LED to slower blink rate */
-            g_bletest_led_rate = OS_TICKS_PER_SEC;
-
-            /* Ask for version information */
-            rc = host_hci_cmd_rd_rem_version(handle);
-            host_hci_outstanding_opcode = 0;
-
-            /* Scanning better be stopped! */
-            assert(ble_ll_scan_enabled() == 0);
-
-            /* Add to current connections */
-            if (!rc) {
-                ++g_bletest_current_conns;
-
-                /* Move to next connection */
-                if (g_bletest_current_conns < BLETEST_CFG_CONCURRENT_CONNS) {
-                    /* restart initiating */
-                    g_bletest_cur_peer_addr[5] += 1;
-                    g_dev_addr[5] += 1;
-                    bletest_init_initiator();
-                }
-            }
-        }
-    } else {
-        if ((int32_t)(os_time_get() - g_next_os_time) >= 0) {
-            if ((g_bletest_state == 1) || (g_bletest_state == 3)) {
-                for (i = 0; i < g_bletest_current_conns; ++i) {
-                    if (ble_ll_conn_find_active_conn(i + 1)) {
-                        host_hci_cmd_le_rd_chanmap(i+1);
-                        host_hci_outstanding_opcode = 0;
-                    }   
-                }
-            } else if (g_bletest_state == 2) {
-                new_chan_map[0] = 0;
-                new_chan_map[1] = 0x3;
-                new_chan_map[2] = 0;
-                new_chan_map[3] = 0;
-                new_chan_map[4] = 0;
-                host_hci_cmd_le_set_host_chan_class(new_chan_map);
-                host_hci_outstanding_opcode = 0;
-            } else {
-                for (i = 0; i < g_bletest_current_conns; ++i) {
-                    if (ble_ll_conn_find_active_conn(i + 1)) {
-                        host_hci_cmd_read_rssi(i+1);
-                        host_hci_outstanding_opcode = 0;
-                    }   
-                }
-            }
-            ++g_bletest_state;
-            g_next_os_time = os_time_get() + OS_TICKS_PER_SEC * 5;
-        }
-    }
-}
-#endif
-
-#if (BLETEST_CFG_ROLE == BLETEST_ROLE_ADVERTISER)
-/* 
- * Test wrapper to get packets. Only get a packet if we have more than half
- * left
- */ 
-static struct os_mbuf *
-bletest_get_packet(void)
-{
-    struct os_mbuf *om;
-
-    om = NULL;
-    if (g_mbuf_pool.omp_pool->mp_num_free >= 5) {
-        om = os_msys_get_pkthdr(BLE_MBUF_PAYLOAD_SIZE, 
-                                sizeof(struct ble_mbuf_hdr));
-    }
-    return om;
-}
-
-#if 0
-void
-bletest_execute(void)
-{
-    int rc;
-
-    int i;
-    uint16_t pktlen;
-    uint16_t handle;
-    struct os_mbuf *om;
-    struct ble_ll_conn_sm *connsm;
-
-    handle = 1;
-    if ((int32_t)(os_time_get() - g_next_os_time) >= 0) {
-        if (g_bletest_state == 0) {
-            rc = host_hci_cmd_le_set_adv_enable(1);
-            host_hci_outstanding_opcode = 0;
-            assert(rc == 0);
-            g_bletest_state = 1;
-        } else if (g_bletest_state == 1) {
-            /* See if handle 1 has been created. If so, send packets */
-            connsm = ble_ll_conn_find_active_conn(handle);
-            if (connsm) {
-                /* Set connection end time */
-                g_bletest_conn_end = os_time_get() + 
-                    (OS_TICKS_PER_SEC * (60 * 15));
-                g_bletest_state = 2;
-            }
-        } else if (g_bletest_state == 2) {
-            if ((int32_t)(os_time_get() - g_bletest_conn_end) >= 0) {
-                g_bletest_state = 3;
-                host_hci_cmd_disconnect(handle, BLE_ERR_REM_USER_CONN_TERM);
-            } else {
-                om = bletest_get_packet();
-                if (om) {
-                    /* set payload length */
-                    pktlen = BLETEST_PKT_SIZE;
-                    om->om_len = BLETEST_PKT_SIZE + 4;
-
-                    /* Put the HCI header in the mbuf */
-                    htole16(om->om_data, handle);
-                    htole16(om->om_data + 2, om->om_len);
-
-                    /* Place L2CAP header in packet */
-                    htole16(om->om_data + 4, pktlen);
-                    om->om_data[6] = 0;
-                    om->om_data[7] = 0;
-
-                    /* Fill with incrementing pattern (starting from 1) */
-                    for (i = 0; i < pktlen; ++i) {
-                        om->om_data[8 + i] = (uint8_t)(i + 1);
-                    }
-
-                    /* Add length */
-                    om->om_len += 4;
-                    OS_MBUF_PKTHDR(om)->omp_len = om->om_len;
-                    ble_hci_transport_host_acl_data_send(om);
-                }
-                g_next_os_time += OS_TICKS_PER_SEC / 10;
-                return;
-            }
-        } else if (g_bletest_state == 3) {
-            /* We should be waiting for disconnect */
-            connsm = ble_ll_conn_find_active_conn(handle);
-            if (!connsm) {
-                /* Set to 0 if you want to restart advertising */
-                //g_bletest_state = 0;
-                g_bletest_state = 4;
-            }
-        }
-        g_next_os_time += OS_TICKS_PER_SEC;
-    }
-}
-#else
-static void
-bletest_execute_advertiser(void)
-{
-    int i,j;
-    int rc;
-    uint16_t handle;
-    uint16_t pktlen;
-    struct os_mbuf *om;
-
-    /* See if we should start advertising again */
-    if (g_bletest_current_conns < BLETEST_CFG_CONCURRENT_CONNS) {
-        handle = g_bletest_current_conns + 1;
-        if (ble_ll_conn_find_active_conn(handle)) {
-            /* Set LED to slower blink rate */
-            g_bletest_led_rate = OS_TICKS_PER_SEC;
-
-            /* advertising better be stopped! */
-            assert(ble_ll_adv_enabled() == 0);
-
-            /* Send the remote used features command */
-            rc = host_hci_cmd_le_read_rem_used_feat(handle);
-            host_hci_outstanding_opcode = 0;
-            if (rc) {
-                return;
-            }
-
-            /* Send the remote read version command */
-            rc = host_hci_cmd_rd_rem_version(handle);
-            host_hci_outstanding_opcode = 0;
-            if (rc) {
-                return;
-            }
-
-            /* set conn update time */
-            g_bletest_conn_upd_time = os_time_get() + (OS_TICKS_PER_SEC * 5);
-            g_bletest_start_update = 1;
-
-            /* Add to current connections */
-            ++g_bletest_current_conns;
-
-            /* Move to next connection */
-            if (g_bletest_current_conns < BLETEST_CFG_CONCURRENT_CONNS) {
-                /* restart initiating */
-                g_bletest_cur_peer_addr[5] += 1;
-                g_dev_addr[5] += 1;
-                bletest_init_advertising();
-                rc = host_hci_cmd_le_set_adv_enable(1);
-                host_hci_outstanding_opcode = 0;
-            }
-        }
-    }
-#if 0
-    if (g_bletest_start_update) {
-        if ((int32_t)(os_time_get() - g_bletest_conn_upd_time) >= 0) {
-            bletest_send_conn_update(1);
-            g_bletest_start_update = 0;
-        }
-    }
-#endif
-    /* See if it is time to hand a data packet to the connection */
-    if ((int32_t)(os_time_get() - g_next_os_time) >= 0) {
-        if (g_bletest_current_conns) {
-            for (i = 0; i < g_bletest_current_conns; ++i) {
-                if ((g_last_handle_used == 0) || 
-                    (g_last_handle_used > g_bletest_current_conns)) {
-                    g_last_handle_used = 1;
-                }
-                handle = g_last_handle_used;
-                if (ble_ll_conn_find_active_conn(handle)) {
-                    om = bletest_get_packet();
-                    if (om) {
-                        /* set payload length */
-                        pktlen = BLETEST_PKT_SIZE;
-                        om->om_len = BLETEST_PKT_SIZE + 4;
-
-                        /* Put the HCI header in the mbuf */
-                        htole16(om->om_data, handle);
-                        htole16(om->om_data + 2, om->om_len);
-
-                        /* Place L2CAP header in packet */
-                        htole16(om->om_data + 4, pktlen);
-                        om->om_data[6] = 0;
-                        om->om_data[7] = 0;
-                        om->om_len += 4;
-
-                        /* Fill with incrementing pattern (starting from 1) */
-                        for (j = 0; j < pktlen; ++j) {
-                            om->om_data[8 + j] = (uint8_t)(j + 1);
-                        }
-
-                        /* Add length */
-                        OS_MBUF_PKTHDR(om)->omp_len = om->om_len;
-                        ble_hci_transport_host_acl_data_send(om);
-
-                        /* Increment last handle used */
-                        ++g_last_handle_used;
-                    }
-                } else {
-                    ++g_last_handle_used;
-                }
-            }
-        }
-        g_next_os_time = os_time_get() + OS_TICKS_PER_SEC;
-    }
-}
-#endif
-#endif
-
-/**
- * Main bletest function. Called by the task timer every 50 msecs.
- * 
- */
-void
-bletest_execute(void)
-{
-    /* Toggle LED at set rate */
-    if ((int32_t)(os_time_get() - g_bletest_next_led_time) >= 0) {
-        hal_gpio_toggle(LED_BLINK_PIN);
-        g_bletest_next_led_time = os_time_get() + g_bletest_led_rate;
-    }
-#if (BLETEST_CFG_ROLE == BLETEST_ROLE_ADVERTISER)
-    bletest_execute_advertiser();
-#endif
-#if (BLETEST_CFG_ROLE == BLETEST_ROLE_SCANNER)
-    bletest_execute_scanner();
-#endif
-#if (BLETEST_CFG_ROLE == BLETEST_ROLE_INITIATOR)
-    bletest_execute_initiator();
-#endif
-}
-
-/**
- * Callback when BLE test timer expires. 
- * 
- * @param arg 
- */
-void
-bletest_timer_cb(void *arg)
-{
-    /* Call the bletest code */
-    bletest_execute();
-
-    /* Re-start the timer (run every 50 msecs) */
-    os_callout_reset(&g_bletest_timer.cf_c, OS_TICKS_PER_SEC / 20);
-}
-
-/**
- * BLE test task 
- * 
- * @param arg 
- */
-void
-bletest_task_handler(void *arg)
-{
-    int rc;
-    uint64_t event_mask;
-    struct os_event *ev;
-    struct os_callout_func *cf;
-
-    /* Set LED blink rate */
-    g_bletest_led_rate = OS_TICKS_PER_SEC / 20;
-
-    /* Wait one second before starting test task */
-    os_time_delay(OS_TICKS_PER_SEC);
-
-    /* Initialize eventq */
-    os_eventq_init(&g_bletest_evq);
-
-    /* Initialize the host timer */
-    os_callout_func_init(&g_bletest_timer, &g_bletest_evq, bletest_timer_cb,
-                         NULL);
-
-    /* Send the reset command first */
-    rc = host_hci_cmd_send(BLE_HCI_OGF_CTLR_BASEBAND, BLE_HCI_OCF_CB_RESET,
-                           0, NULL);
-    assert(rc == 0);
-    host_hci_outstanding_opcode = 0;
-
-#if (BLETEST_CFG_ROLE == BLETEST_ROLE_ADVERTISER)
-    /* Initialize the advertiser */
-    console_printf("Starting BLE test task as advertiser\n");
-    bletest_init_advertising();
-#endif
-
-#if (BLETEST_CFG_ROLE == BLETEST_ROLE_SCANNER)
-    /* Initialize the scanner */
-    console_printf("Starting BLE test task as scanner\n");
-    bletest_init_scanner();
-#endif
-
-#if (BLETEST_CFG_ROLE == BLETEST_ROLE_INITIATOR)
-    /* Initialize the scanner */
-    console_printf("Starting BLE test task as initiator\n");
-    bletest_init_initiator();
-#endif
-
-    /* Set the event mask we want to display */
-    event_mask = 0x7FF;
-    rc = host_hci_cmd_le_set_event_mask(event_mask);
-    assert(rc == 0);
-    host_hci_outstanding_opcode = 0;
-
-    /* Turn on all events */
-    event_mask = 0xffffffffffffffff;
-    rc = host_hci_cmd_set_event_mask(event_mask);
-    assert(rc == 0);
-    host_hci_outstanding_opcode = 0;
-
-    /* Turn on all events */
-    rc = host_hci_cmd_rd_local_version();
-    assert(rc == 0);
-    host_hci_outstanding_opcode = 0;
-
-    /* Wait some time before starting */
-    os_time_delay(OS_TICKS_PER_SEC);
-
-    /* Init bletest variables */
-    g_bletest_state = 0;
-    g_next_os_time = os_time_get();
-
-    /* Begin advertising if we are an advertiser */
-#if (BLETEST_CFG_ROLE == BLETEST_ROLE_ADVERTISER)
-    rc = host_hci_cmd_le_set_adv_enable(1);
-    assert(rc == 0);
-    host_hci_outstanding_opcode = 0;
-#endif
-
-    bletest_timer_cb(NULL);
-
-    while (1) {
-        ev = os_eventq_get(&g_bletest_evq);
-        switch (ev->ev_type) {
-        case OS_EVENT_T_TIMER:
-            cf = (struct os_callout_func *)ev;
-            assert(cf->cf_func);
-            cf->cf_func(cf->cf_arg);
-            break;
-        default:
-            assert(0);
-            break;
-        }
-    }
-}
-
-/**
- * init_tasks
- *  
- * Called by main.c after os_init(). This function performs initializations 
- * that are required before tasks are running. 
- *  
- * @return int 0 success; error otherwise.
- */
-static int
-init_tasks(void)
-{
-    int rc;
-
-    os_task_init(&bletest_task, "bletest", bletest_task_handler, NULL, 
-                 BLETEST_TASK_PRIO, OS_WAIT_FOREVER, bletest_stack, 
-                 BLETEST_STACK_SIZE);
-
-    /* Initialize host HCI */
-    rc = ble_hs_init(HOST_TASK_PRIO, NULL);
-    assert(rc == 0);
-
-    /* Initialize the BLE LL */
-    rc = ble_ll_init();
-    assert(rc == 0);
-
-    return 0;
-}
-
-/**
- * main
- *  
- * The main function for the project. This function initializes the os, calls 
- * init_tasks to initialize tasks (and possibly other objects), then starts the 
- * OS. We should not return from os start. 
- *  
- * @return int NOTE: this function should never return!
- */
-int
-main(void)
-{
-    int i;
-    int rc;
-    uint32_t seed;
-#if 0
-    int cnt;
-    struct nffs_area_desc descs[NFFS_AREA_MAX];
-#endif
-
-    /* Initialize OS */
-    os_init();
-
-    /* Set cputime to count at 1 usec increments */
-    rc = cputime_init(1000000);
-    assert(rc == 0);
-
-    rc = os_mempool_init(&g_mbuf_mempool, MBUF_NUM_MBUFS, 
-            MBUF_MEMBLOCK_SIZE, &g_mbuf_buffer[0], "mbuf_pool");
-    assert(rc == 0);
-
-    rc = os_mbuf_pool_init(&g_mbuf_pool, &g_mbuf_mempool, MBUF_MEMBLOCK_SIZE, 
-                           MBUF_NUM_MBUFS);
-    assert(rc == 0);
-
-    rc = os_msys_register(&g_mbuf_pool);
-    assert(rc == 0);
-
-    /* Dummy device address */
-#if BLETEST_CFG_ROLE == BLETEST_ROLE_ADVERTISER
-    g_dev_addr[0] = 0x00;
-    g_dev_addr[1] = 0x00;
-    g_dev_addr[2] = 0x00;
-    g_dev_addr[3] = 0x88;
-    g_dev_addr[4] = 0x88;
-    g_dev_addr[5] = 0x08;
-
-    g_bletest_cur_peer_addr[0] = 0x00;
-    g_bletest_cur_peer_addr[1] = 0x00;
-    g_bletest_cur_peer_addr[2] = 0x00;
-    g_bletest_cur_peer_addr[3] = 0x99;
-    g_bletest_cur_peer_addr[4] = 0x99;
-    g_bletest_cur_peer_addr[5] = 0x09;
-#else
-    g_dev_addr[0] = 0x00;
-    g_dev_addr[1] = 0x00;
-    g_dev_addr[2] = 0x00;
-    g_dev_addr[3] = 0x99;
-    g_dev_addr[4] = 0x99;
-    g_dev_addr[5] = 0x09;
-
-    g_bletest_cur_peer_addr[0] = 0x00;
-    g_bletest_cur_peer_addr[1] = 0x00;
-    g_bletest_cur_peer_addr[2] = 0x00;
-    g_bletest_cur_peer_addr[3] = 0x88;
-    g_bletest_cur_peer_addr[4] = 0x88;
-    g_bletest_cur_peer_addr[5] = 0x08;
-#endif
-
-    /* 
-     * Seed random number generator with least significant bytes of device
-     * address.
-     */ 
-    seed = 0;
-    for (i = 0; i < 4; ++i) {
-        seed |= g_dev_addr[i];
-        seed <<= 8;
-    }
-    srand(seed);
-
-    /* Set the led pin as an output */
-    g_led_pin = LED_BLINK_PIN;
-    hal_gpio_init_out(g_led_pin, 1);
-
-    /* Init the console */
-    rc = console_init(shell_console_rx_cb);
-    assert(rc == 0);
-
-#if 0
-    rc = hal_flash_init();
-    assert(rc == 0);
-
-    nffs_config.nc_num_inodes = 32;
-    nffs_config.nc_num_blocks = 64;
-    nffs_config.nc_num_files = 2;
-    nffs_config.nc_num_dirs = 2;
-    rc = nffs_init();
-    assert(rc == 0);
-
-    cnt = NFFS_AREA_MAX;
-    rc = flash_area_to_nffs_desc(FLASH_AREA_NFFS, &cnt, descs);
-    assert(rc == 0);
-    if (nffs_detect(descs) == FS_ECORRUPT) {
-        rc = nffs_format(descs);
-        assert(rc == 0);
-    }
-#endif
-
-    shell_task_init(SHELL_TASK_PRIO, shell_stack, SHELL_TASK_STACK_SIZE,
-                         SHELL_MAX_INPUT_LEN);
-
-    nmgr_task_init(NEWTMGR_TASK_PRIO, newtmgr_stack, NEWTMGR_TASK_STACK_SIZE);
-#if 0
-    imgmgr_module_init();
-#endif
-
-    /* Init statistics module */
-    stats_module_init();
-
-    /* Init tasks */
-    init_tasks();
-
-    /* Start the OS */
-    os_start();
-
-    /* os start should never return. If it does, this should be an error */
-    assert(0);
-
-    return rc;
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/project/bletiny/pkg.yml
----------------------------------------------------------------------
diff --git a/project/bletiny/pkg.yml b/project/bletiny/pkg.yml
deleted file mode 100644
index 32d25f7..0000000
--- a/project/bletiny/pkg.yml
+++ /dev/null
@@ -1,33 +0,0 @@
-# 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: bletiny
-pkg.vers: 0.8.0
-pkg.description: Shell application exposing the nimble GAP and GATT.
-pkg.author: Christopher Collins <cc...@apache.org>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
-pkg.keywords:
-
-pkg.deps: 
-    - libs/os 
-    - sys/log
-    - net/nimble/controller
-    - net/nimble/host
-    - libs/console/full
-    - libs/shell
-    - libs/baselibc

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/project/bletiny/src/bletiny_priv.h
----------------------------------------------------------------------
diff --git a/project/bletiny/src/bletiny_priv.h b/project/bletiny/src/bletiny_priv.h
deleted file mode 100644
index e32251b..0000000
--- a/project/bletiny/src/bletiny_priv.h
+++ /dev/null
@@ -1,169 +0,0 @@
-/**
- * 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.
- */
-
-#ifndef H_BLETINY_PRIV_
-#define H_BLETINY_PRIV_
-
-#include <inttypes.h>
-#include "nimble/nimble_opt.h"
-#include "log/log.h"
-#include "os/queue.h"
-
-#include "host/ble_gatt.h"
-struct ble_gap_white_entry;
-struct ble_hs_adv_fields;
-struct ble_gap_upd_params;
-struct ble_gap_crt_params;
-struct hci_adv_params;
-struct ble_l2cap_sig_update_req;
-struct ble_l2cap_sig_update_params;
-
-typedef int cmd_fn(int argc, char **argv);
-struct cmd_entry {
-    char *name;
-    cmd_fn *cb;
-};
-
-struct kv_pair {
-    char *key;
-    int val;
-};
-
-struct bletiny_dsc {
-    SLIST_ENTRY(bletiny_dsc) next;
-    struct ble_gatt_dsc dsc;
-};
-SLIST_HEAD(bletiny_dsc_list, bletiny_dsc);
-
-struct bletiny_chr {
-    SLIST_ENTRY(bletiny_chr) next;
-    struct ble_gatt_chr chr;
-
-    struct bletiny_dsc_list dscs;
-};
-SLIST_HEAD(bletiny_chr_list, bletiny_chr);
-
-struct bletiny_svc {
-    SLIST_ENTRY(bletiny_svc) next;
-    struct ble_gatt_service svc;
-
-    struct bletiny_chr_list chrs;
-};
-
-SLIST_HEAD(bletiny_svc_list, bletiny_svc);
-
-struct bletiny_conn {
-    uint16_t handle;
-    uint8_t addr_type;
-    uint8_t addr[6];
-
-    struct bletiny_svc_list svcs;
-};
-
-extern struct bletiny_conn bletiny_conns[NIMBLE_OPT_MAX_CONNECTIONS];
-extern int bletiny_num_conns;
-
-extern const char *bletiny_device_name;
-extern const uint16_t bletiny_appearance;
-extern const uint8_t bletiny_privacy_flag;
-extern uint8_t bletiny_reconnect_addr[6];
-extern uint8_t bletiny_pref_conn_params[8];
-extern uint8_t bletiny_gatt_service_changed[4];
-
-extern struct nmgr_transport nm_ble_transport;
-extern uint16_t nm_attr_val_handle;
-
-extern struct log bletiny_log;
-
-void print_addr(void *addr);
-void print_uuid(void *uuid128);
-const struct cmd_entry *parse_cmd_find(const struct cmd_entry *cmds,
-                                       char *name);
-struct kv_pair *parse_kv_find(struct kv_pair *kvs, char *name);
-char *parse_arg_find(char *key);
-long parse_arg_long_bounds(char *name, long min, long max, int *out_status);
-long parse_arg_long(char *name, int *staus);
-uint16_t parse_arg_uint16(char *name, int *status);
-uint16_t parse_arg_uint16_dflt(char *name, uint16_t dflt, int *out_status);
-uint32_t parse_arg_uint32(char *name, int *out_status);
-int parse_arg_kv(char *name, struct kv_pair *kvs);
-int parse_arg_byte_stream(char *name, int max_len, uint8_t *dst, int *out_len);
-int parse_arg_byte_stream_exact_length(char *name, uint8_t *dst, int len);
-int parse_arg_mac(char *name, uint8_t *dst);
-int parse_arg_uuid(char *name, uint8_t *dst_uuid128);
-int parse_err_too_few_args(char *cmd_name);
-int parse_arg_all(int argc, char **argv);
-int cmd_init(void);
-void periph_init(void);
-int nm_chr_access(uint16_t conn_handle, uint16_t attr_handle,
-                  uint8_t op, union ble_gatt_access_ctxt *ctxt,
-                  void *arg);
-int nm_rx_rsp(uint8_t *attr_val, uint16_t attr_len);
-void nm_init(void);
-void bletiny_lock(void);
-void bletiny_unlock(void);
-int bletiny_exchange_mtu(uint16_t conn_handle);
-int bletiny_disc_svcs(uint16_t conn_handle);
-int bletiny_disc_svc_by_uuid(uint16_t conn_handle, uint8_t *uuid128);
-int bletiny_disc_all_chrs(uint16_t conn_handle, uint16_t start_handle,
-                           uint16_t end_handle);
-int bletiny_disc_chrs_by_uuid(uint16_t conn_handle, uint16_t start_handle,
-                               uint16_t end_handle, uint8_t *uuid128);
-int bletiny_disc_all_dscs(uint16_t conn_handle, uint16_t chr_val_handle,
-                           uint16_t chr_end_handle);
-int bletiny_find_inc_svcs(uint16_t conn_handle, uint16_t start_handle,
-                           uint16_t end_handle);
-int bletiny_read(uint16_t conn_handle, uint16_t attr_handle);
-int bletiny_read_long(uint16_t conn_handle, uint16_t attr_handle);
-int bletiny_read_by_uuid(uint16_t conn_handle, uint16_t start_handle,
-                          uint16_t end_handle, uint8_t *uuid128);
-int bletiny_read_mult(uint16_t conn_handle, uint16_t *attr_handles,
-                       int num_attr_handles);
-int bletiny_write(uint16_t conn_handle, uint16_t attr_handle, void *value,
-                   uint16_t value_len);
-int bletiny_write_no_rsp(uint16_t conn_handle, uint16_t attr_handle,
-                          void *value, uint16_t value_len);
-int bletiny_write_long(uint16_t conn_handle, uint16_t attr_handle,
-                        void *value, uint16_t value_len);
-int bletiny_write_reliable(uint16_t conn_handle, struct ble_gatt_attr *attrs,
-                            int num_attrs);
-int bletiny_adv_start(int disc, int conn, uint8_t *peer_addr, int addr_type,
-                       struct hci_adv_params *params);
-int bletiny_adv_stop(void);
-int bletiny_conn_initiate(int addr_type, uint8_t *peer_addr,
-                           struct ble_gap_crt_params *params);
-int bletiny_conn_cancel(void);
-int bletiny_term_conn(uint16_t conn_handle);
-int bletiny_wl_set(struct ble_gap_white_entry *white_list,
-                    int white_list_count);
-int bletiny_scan(uint32_t dur_ms, uint8_t disc_mode, uint8_t scan_type,
-                  uint8_t filter_policy);
-int bletiny_set_adv_data(struct ble_hs_adv_fields *adv_fields);
-int bletiny_update_conn(uint16_t conn_handle,
-                         struct ble_gap_upd_params *params);
-void bletiny_chrup(uint16_t attr_handle);
-int bletiny_l2cap_update(uint16_t conn_handle,
-                          struct ble_l2cap_sig_update_params *params);
-int bletiny_show_rssi(uint16_t conn_handle);
-
-#define BLETINY_LOG_MODULE  (LOG_MODULE_PERUSER + 0)
-#define BLETINY_LOG(lvl, ...) \
-    LOG_ ## lvl(&bletiny_log, BLETINY_LOG_MODULE, __VA_ARGS__)
-
-#endif


[37/42] incubator-mynewt-core git commit: update readme.

Posted by cc...@apache.org.
update readme.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/fa7e1694
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/fa7e1694
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/fa7e1694

Branch: refs/heads/master
Commit: fa7e1694d764c2ed73744cca2e844af0ba594dc8
Parents: 0eb30d5
Author: Sterling Hughes <st...@apache.org>
Authored: Mon Mar 14 15:11:26 2016 -0700
Committer: Sterling Hughes <st...@apache.org>
Committed: Mon Mar 14 15:11:26 2016 -0700

----------------------------------------------------------------------
 README.md | 105 ++++++++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 81 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fa7e1694/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index e1ab9d3..7a3e4fc 100644
--- a/README.md
+++ b/README.md
@@ -19,27 +19,30 @@
 #
 -->
 
-# Apache Mynewt Repository 
+# Apache Mynewt Core 
 
-# Overview
+## Overview
 
-This is the main Apache Mynewt development repository.  It contains the
-major packages that make up the Apache Mynewt Operating System.  For
-instructions on getting Apache Mynewt up and running, see the Getting
-Started page at: http://mynewt.apache.org/os/get_started/project1/
+This repository represents the core of the Apache Mynewt repository.
+It contains the major packages that make up the Apache Mynewt Operating 
+System.  For instructions on getting Apache Mynewt up & running, please 
+see our [Getting Started Guide.](http://mynewt.apache.org/os/get_started/project1/)
 
-The packages that make up Apache Mynewt are contained in the following
-directories:
+## Browsing 
 
-- libs: Contains the core of the RTOS (libs/os) and a number of helper 
-libraries for building applications.  Including a console (libs/console), 
+If you are browsing around the source tree, and want to see some of the 
+major functional chunks, here are a few pointers: 
+
+- libs: Contains the core of the RTOS ([libs/os](https://github.com/apache/incubator-mynewt-core/tree/master/libs/os) 
+and a number of helper libraries for building applications.  Including a 
+console (libs/console), 
 shell (libs/shell), and newtmgr, which supports software upgrade and 
 remote fetching of logs and statistics (libs/newtmgr).  
 
-- net: Contains the networking packages.  Right now, net/ just contains
-the nimble package.  Nimble is a full Bluetooth host and controller 
-implmentation, that is written from the ground up for the Apache Mynewt
-Operating System.   
+- net: Contains the networking packages.  Right now, net/ contains
+the nimble package.  [Nimble](https://github.com/apache/incubator-mynewt-core/tree/master/net/nimble)
+is a full Bluetooth host and controller implementation, that is written 
+from the ground up for the Apache Mynewt Operating System.   
 
 - hw: Contains the HW specific support packages.  Board Support Packages 
 are located in hw/bsp, and the MCU specific definitions they rely on 
@@ -53,21 +56,79 @@ File System.)  The Newtron file system is a FS that has been built from
 the ground-up in Apache Mynewt, designed to be optimized for small 
 (64KB-32MB) flashes.
 
-In addition to the package directories, there is a special type of package
-called a project, which defines an embedded build project (it has a 
-main() function.)  In the Apache Mynewt development repository there are a 
-set of standard projects, which can be used as examples to fasten your
-own project:
+## Sample Applications
+
+In addition to some of the core packages, there are also some sample 
+applications that show how to instantiate the Apache Mynewt system.  These
+sample applications are located in the ```apps/``` directory.  They 
+include: 
 
 * boot: Project to build the bootloader for test platforms. 
 * blinky: The minimal packages to build the OS, and blink a
   LED!  
 * slinky: A slightly more complex project that includes the 
-  console and shell libraries.  
+  console and shell libraries. 
+* bletiny: A stripped down interface to the Apache Mynewt Bluetooth stack.
 * test: Test project which can be compiled either with the simulator, or 
   on a per-architecture basis.  Test will run all the package's unit 
   tests. 
 
+# Contributing 
+
+Anybody who works with Apache Mynewt can be a contributing member of the 
+community that develops and deploys it.  The process of releasing an operating 
+system for microcontrollers is never done: and we welcome your contributions
+to that effort.
+
+## Pull Requests
+
+Apache Mynewt welcomes pull request via Github.  Discussions are done on Github,
+but depending on the topic, can also be relayed to the official Apache Mynewt
+developer mailing list dev@mynewt.incubator.apache.org.
+
+If you are suggesting a new feature, please email the developer list directly,
+with a description of the feature you are planning to work on.  
+
+We do not merge pull requests directly on Github, all PRs will be pulled and 
+pushed through http://git.apache.org/.
+
+## Filing Bugs
+
+Bugs can be filed on the 
+[Apache Mynewt Bug Tracker](https://issues.apache.org/jira/browse/MYNEWT).
+
+Where possible, please include a self-contained reproduction case!
+
+## Feature Requests
+
+Feature requests should also be filed on the 
+[Apache Mynewt Bug Tracker](https://issues.apache.org/jira/browse/MYNEWT).  
+Please introduce it as a ticket type "Wish." 
+
+## Writing Tests
+
+We love getting newt tests!  Apache Mynewt is a huge undertaking, and improving
+code coverage is a win for every Apache Mynewt user.  
+
+## Writing Documentation
+
+Contributing to documentation (in addition to writing tests), is a great way 
+to get involved with the Apache Mynewt project.
+
+Pull requests to the apache-mynewt-site repository on Github are the best 
+way to submit documentation.  For more information on contributing to the 
+documentation, the [FAQ](http://mynewt.apache.org/faq/answers/) has some 
+more information.
+
+## Getting Help
+
+If you are having trouble contributing to Apache Mynewt, or just want to talk 
+to a human about what you're working on, you can contact us via the 
+[developers mailing list](mailto:dev@mynewt.incubator.apache.org).  
+
+Although not a formal channel, you can also find a number of core developers
+on the #mynewt channel on Freenode.
+
 # License 
 
 The code in this repository is all under either the Apache 2 license, or a 
@@ -94,7 +155,3 @@ Regulations, Section 740.13) for both object code and source code.
 The following provides more details on the included cryptographic software: 
 https://tls.mbed.org/supported-ssl-ciphersuites.
 
-# Contact 
-
-For any questions on the larva repository, please contact the Apache Mynewt developer's 
-list (dev@mynewt.incubator.apache.org).  


[21/42] incubator-mynewt-core git commit: testutil: flush stdout after each test result.

Posted by cc...@apache.org.
testutil: flush stdout after each test result.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/3af4ca4f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/3af4ca4f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/3af4ca4f

Branch: refs/heads/master
Commit: 3af4ca4fc71e019f3d73576bc08a1db3e64c9c9d
Parents: f7ac6fe
Author: Christopher Collins <cc...@gmail.com>
Authored: Thu Mar 10 16:58:51 2016 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Thu Mar 10 16:59:17 2016 -0800

----------------------------------------------------------------------
 libs/testutil/src/case.c | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3af4ca4f/libs/testutil/src/case.c
----------------------------------------------------------------------
diff --git a/libs/testutil/src/case.c b/libs/testutil/src/case.c
index a2d78ef..bea6efa 100644
--- a/libs/testutil/src/case.c
+++ b/libs/testutil/src/case.c
@@ -111,6 +111,7 @@ tu_case_write_fail_buf(void)
 
     if (tu_config.tc_print_results) {
         printf("[FAIL] %s/%s %s", tu_suite_name, tu_case_name, tu_case_buf);
+        fflush(stdout);
     }
 
     if (tu_config.tc_case_fail_cb != NULL) {
@@ -145,6 +146,7 @@ tu_case_write_pass_buf(void)
         if (tu_case_buf_len > 0) {
             printf("%s", tu_case_buf);
         }
+        fflush(stdout);
     }
 
     tu_case_reported = 1;


[23/42] incubator-mynewt-core git commit: Rename baselibc test .c files.

Posted by cc...@apache.org.
Rename baselibc test .c files.

The main() functions defined in these files caused linker errors.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/b0db6dde
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/b0db6dde
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/b0db6dde

Branch: refs/heads/master
Commit: b0db6dde6202c38ab6f159f59f3e2bc2e43dd28f
Parents: cfc3383
Author: Christopher Collins <cc...@gmail.com>
Authored: Fri Mar 11 11:34:44 2016 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Fri Mar 11 11:34:44 2016 -0800

----------------------------------------------------------------------
 libs/baselibc/src/baselibc_test/printf_tests.c  | 22 -------------
 .../baselibc_test/printf_tests.c.donotcompile   | 22 +++++++++++++
 libs/baselibc/src/baselibc_test/tests_glue.c    | 33 --------------------
 .../src/baselibc_test/tests_glue.c.donotcompile | 33 ++++++++++++++++++++
 4 files changed, 55 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b0db6dde/libs/baselibc/src/baselibc_test/printf_tests.c
----------------------------------------------------------------------
diff --git a/libs/baselibc/src/baselibc_test/printf_tests.c b/libs/baselibc/src/baselibc_test/printf_tests.c
deleted file mode 100644
index f9f380f..0000000
--- a/libs/baselibc/src/baselibc_test/printf_tests.c
+++ /dev/null
@@ -1,22 +0,0 @@
-#include "unittests.h"
-
-int main()
-{
-    int status = 0;
-    
-    {
-        COMMENT("Testing basic snprintf functionality");
-        char buf[20];
-        
-        snprintf(buf, sizeof(buf), "%08d", 55);
-        TEST(strcmp(buf, "00000055") == 0);
-        
-        TEST(snprintf(buf, sizeof(buf), "01234567890123456789") == 20);
-        TEST(strcmp(buf, "0123456789012345678") == 0);
-    }
-        
-    if (status != 0)
-        fprintf(stdout, "\n\nSome tests FAILED!\n");
-
-    return status;
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b0db6dde/libs/baselibc/src/baselibc_test/printf_tests.c.donotcompile
----------------------------------------------------------------------
diff --git a/libs/baselibc/src/baselibc_test/printf_tests.c.donotcompile b/libs/baselibc/src/baselibc_test/printf_tests.c.donotcompile
new file mode 100644
index 0000000..f9f380f
--- /dev/null
+++ b/libs/baselibc/src/baselibc_test/printf_tests.c.donotcompile
@@ -0,0 +1,22 @@
+#include "unittests.h"
+
+int main()
+{
+    int status = 0;
+    
+    {
+        COMMENT("Testing basic snprintf functionality");
+        char buf[20];
+        
+        snprintf(buf, sizeof(buf), "%08d", 55);
+        TEST(strcmp(buf, "00000055") == 0);
+        
+        TEST(snprintf(buf, sizeof(buf), "01234567890123456789") == 20);
+        TEST(strcmp(buf, "0123456789012345678") == 0);
+    }
+        
+    if (status != 0)
+        fprintf(stdout, "\n\nSome tests FAILED!\n");
+
+    return status;
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b0db6dde/libs/baselibc/src/baselibc_test/tests_glue.c
----------------------------------------------------------------------
diff --git a/libs/baselibc/src/baselibc_test/tests_glue.c b/libs/baselibc/src/baselibc_test/tests_glue.c
deleted file mode 100644
index b18a689..0000000
--- a/libs/baselibc/src/baselibc_test/tests_glue.c
+++ /dev/null
@@ -1,33 +0,0 @@
-#include <stdio.h>
-
-#if defined(linux)
-/* Connects the baselibc stdio to normal POSIX stdio */
-size_t write(int fd, const void *buf, size_t count);
-
-static size_t stdio_write(FILE *instance, const char *bp, size_t n)
-{
-    if (instance == stdout)
-        return write(1, bp, n);
-    else
-        return write(2, bp, n);
-}
-#else
-#error No suitable write() implementation.
-#endif
-
-
-static struct File_methods stdio_methods = {
-        &stdio_write, NULL
-};
-
-static struct File _stdout = {
-        &stdio_methods
-};
-
-static struct File _stderr = {
-        &stdio_methods
-};
-
-FILE* const stdout = &_stdout;
-FILE* const stderr = &_stderr;
-

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b0db6dde/libs/baselibc/src/baselibc_test/tests_glue.c.donotcompile
----------------------------------------------------------------------
diff --git a/libs/baselibc/src/baselibc_test/tests_glue.c.donotcompile b/libs/baselibc/src/baselibc_test/tests_glue.c.donotcompile
new file mode 100644
index 0000000..b18a689
--- /dev/null
+++ b/libs/baselibc/src/baselibc_test/tests_glue.c.donotcompile
@@ -0,0 +1,33 @@
+#include <stdio.h>
+
+#if defined(linux)
+/* Connects the baselibc stdio to normal POSIX stdio */
+size_t write(int fd, const void *buf, size_t count);
+
+static size_t stdio_write(FILE *instance, const char *bp, size_t n)
+{
+    if (instance == stdout)
+        return write(1, bp, n);
+    else
+        return write(2, bp, n);
+}
+#else
+#error No suitable write() implementation.
+#endif
+
+
+static struct File_methods stdio_methods = {
+        &stdio_write, NULL
+};
+
+static struct File _stdout = {
+        &stdio_methods
+};
+
+static struct File _stderr = {
+        &stdio_methods
+};
+
+FILE* const stdout = &_stdout;
+FILE* const stderr = &_stderr;
+


[38/42] incubator-mynewt-core git commit: bit more of an update of the README

Posted by cc...@apache.org.
bit more of an update of the README


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/edd5b1f7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/edd5b1f7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/edd5b1f7

Branch: refs/heads/master
Commit: edd5b1f7cc1f109a768049522d72026c9d02fa5e
Parents: fa7e169
Author: Sterling Hughes <st...@apache.org>
Authored: Mon Mar 14 15:51:03 2016 -0700
Committer: Sterling Hughes <st...@apache.org>
Committed: Mon Mar 14 15:51:03 2016 -0700

----------------------------------------------------------------------
 README.md | 69 ++++++++++++++++++++++++++++++++++------------------------
 1 file changed, 41 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/edd5b1f7/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 7a3e4fc..7c5202e 100644
--- a/README.md
+++ b/README.md
@@ -35,9 +35,10 @@ major functional chunks, here are a few pointers:
 
 - libs: Contains the core of the RTOS ([libs/os](https://github.com/apache/incubator-mynewt-core/tree/master/libs/os) 
 and a number of helper libraries for building applications.  Including a 
-console (libs/console), 
-shell (libs/shell), and newtmgr, which supports software upgrade and 
-remote fetching of logs and statistics (libs/newtmgr).  
+console ([libs/console](https://github.com/apache/incubator-mynewt-core/tree/master/libs/console))), 
+shell ([libs/shell](https://github.com/apache/incubator-mynewt-core/tree/master/libs/shell))), and 
+[libs/newtmgr](https://github.com/apache/incubator-mynewt-core/tree/master/libs/newtmgr)), which 
+supports software upgrade and remote fetching of logs and statistics.
 
 - net: Contains the networking packages.  Right now, net/ contains
 the nimble package.  [Nimble](https://github.com/apache/incubator-mynewt-core/tree/master/net/nimble)
@@ -45,13 +46,16 @@ is a full Bluetooth host and controller implementation, that is written
 from the ground up for the Apache Mynewt Operating System.   
 
 - hw: Contains the HW specific support packages.  Board Support Packages 
-are located in hw/bsp, and the MCU specific definitions they rely on 
-are located in hw/mcu.  Finally, there is a HAL (Hardware Abstraction 
-Layer) stored in hw/hal, even though the implementation of various 
-HALs are stored in the MCU specific definitions.  
-
-- fs: Contains the FS package (fs/fs), which is the high-level Apache Mynewt 
-file system API.   A specific implementation of that FS, is NFFS (Newtron
+are located in [hw/bsp](https://github.com/apache/incubator-mynewt-core/tree/master/hw/bsp), 
+and the MCU specific definitions they rely on are located in 
+[hw/mcu](https://github.com/apache/incubator-mynewt-core/tree/master/hw/mcu).  
+Finally, there is a HAL (Hardware Abstraction Layer) stored in 
+[hw/hal](https://github.com/apache/incubator-mynewt-core/tree/master/hw/hal), even 
+though the implementation of various HALs are stored in the MCU specific definitions.  
+
+- fs: Contains the FS package ([fs/fs](https://github.com/apache/incubator-mynewt-core/tree/master/fs/fs))), 
+which is the high-level Apache Mynewt file system API.   A specific implementation of that FS, is 
+[NFFS](https://github.com/apache/incubator-mynewt-core/tree/master/fs/nffs) (Newtron
 File System.)  The Newtron file system is a FS that has been built from 
 the ground-up in Apache Mynewt, designed to be optimized for small 
 (64KB-32MB) flashes.
@@ -63,15 +67,30 @@ applications that show how to instantiate the Apache Mynewt system.  These
 sample applications are located in the ```apps/``` directory.  They 
 include: 
 
-* boot: Project to build the bootloader for test platforms. 
-* blinky: The minimal packages to build the OS, and blink a
-  LED!  
-* slinky: A slightly more complex project that includes the 
-  console and shell libraries. 
-* bletiny: A stripped down interface to the Apache Mynewt Bluetooth stack.
-* test: Test project which can be compiled either with the simulator, or 
-  on a per-architecture basis.  Test will run all the package's unit 
-  tests. 
+* [boot](https://github.com/apache/incubator-mynewt-core/tree/master/apps/boot): 
+  Project to build the bootloader for test platforms. 
+* [blinky](https://github.com/apache/incubator-mynewt-core/tree/master/apps/blinky): The 
+  minimal packages to build the OS, and blink a LED!  
+* [slinky](https://github.com/apache/incubator-mynewt-core/tree/master/apps/slinky): A 
+  slightly more complex project that includes the console and shell libraries. 
+* [bletiny](https://github.com/apache/incubator-mynewt-core/tree/master/apps/bletiny): A 
+  stripped down interface to the Apache Mynewt Bluetooth stack.
+* [test](https://github.com/apache/incubator-mynewt-core/tree/master/apps/test): Test 
+  project which can be compiled either with the simulator, or on a per-architecture basis.  
+  Test will run all the package's unit tests. 
+
+
+# Getting Help
+
+If you are having trouble using or contributing to Apache Mynewt, or just want to talk 
+to a human about what you're working on, you can contact us via the 
+[developers mailing list](mailto:dev@mynewt.incubator.apache.org).  
+
+Although not a formal channel, you can also find a number of core developers
+on the #mynewt channel on Freenode.
+
+Also, be sure to checkout the [Frequently Asked Questions](https://mynewt.apache.org/faq/answers)
+for some help troubleshooting first.
 
 # Contributing 
 
@@ -80,6 +99,9 @@ community that develops and deploys it.  The process of releasing an operating
 system for microcontrollers is never done: and we welcome your contributions
 to that effort.
 
+More information can be found at the Community section of the Apache Mynewt 
+website, located [here](https://mynewt.apache.org/community).  
+
 ## Pull Requests
 
 Apache Mynewt welcomes pull request via Github.  Discussions are done on Github,
@@ -120,15 +142,6 @@ way to submit documentation.  For more information on contributing to the
 documentation, the [FAQ](http://mynewt.apache.org/faq/answers/) has some 
 more information.
 
-## Getting Help
-
-If you are having trouble contributing to Apache Mynewt, or just want to talk 
-to a human about what you're working on, you can contact us via the 
-[developers mailing list](mailto:dev@mynewt.incubator.apache.org).  
-
-Although not a formal channel, you can also find a number of core developers
-on the #mynewt channel on Freenode.
-
 # License 
 
 The code in this repository is all under either the Apache 2 license, or a 


[11/42] incubator-mynewt-core git commit: Add unittest target for "newt test" command.

Posted by cc...@apache.org.
Add unittest target for "newt test" command.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/9faa5dac
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/9faa5dac
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/9faa5dac

Branch: refs/heads/master
Commit: 9faa5dacbe6d4f3e74463636acb17538b57839bc
Parents: 36afc70
Author: Christopher Collins <cc...@gmail.com>
Authored: Wed Mar 9 21:33:12 2016 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Wed Mar 9 21:33:12 2016 -0800

----------------------------------------------------------------------
 targets/unittest/pkg.yml    | 9 +++++++++
 targets/unittest/target.yml | 4 ++++
 2 files changed, 13 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9faa5dac/targets/unittest/pkg.yml
----------------------------------------------------------------------
diff --git a/targets/unittest/pkg.yml b/targets/unittest/pkg.yml
new file mode 100644
index 0000000..338ba99
--- /dev/null
+++ b/targets/unittest/pkg.yml
@@ -0,0 +1,9 @@
+### Target: slinky_sim
+pkg.name: "targets/unittest"
+pkg.type: "target"
+pkg.vers: "0.8.0"
+pkg.description: "Used for unit tests by the \"newt test\" command."
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
+pkg.repository:
+pkg.keywords:

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9faa5dac/targets/unittest/target.yml
----------------------------------------------------------------------
diff --git a/targets/unittest/target.yml b/targets/unittest/target.yml
new file mode 100644
index 0000000..9e7e56e
--- /dev/null
+++ b/targets/unittest/target.yml
@@ -0,0 +1,4 @@
+### Target: unittest
+target.arch: "sim"
+target.bsp: "hw/bsp/native"
+target.build_profile: "debug"


[34/42] incubator-mynewt-core git commit: Combine OS-specific compiler.yml files.

Posted by cc...@apache.org.
Combine OS-specific compiler.yml files.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/f7c92701
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/f7c92701
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/f7c92701

Branch: refs/heads/master
Commit: f7c927012ba5fa1da24575afe21c9c298256c939
Parents: ec4830c
Author: Christopher Collins <cc...@apache.org>
Authored: Mon Mar 14 14:10:11 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Mon Mar 14 14:24:24 2016 -0700

----------------------------------------------------------------------
 compiler/sim/compiler.yml       | 34 +++++++++++++++++++++++++---------
 compiler/sim/linux-compiler.yml | 35 -----------------------------------
 compiler/sim/osx-compiler.yml   | 31 -------------------------------
 3 files changed, 25 insertions(+), 75 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f7c92701/compiler/sim/compiler.yml
----------------------------------------------------------------------
diff --git a/compiler/sim/compiler.yml b/compiler/sim/compiler.yml
index 9c03ab5..eaeccec 100644
--- a/compiler/sim/compiler.yml
+++ b/compiler/sim/compiler.yml
@@ -6,7 +6,7 @@
 # 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,
@@ -16,17 +16,33 @@
 # specific language governing permissions and limitations
 # under the License.
 #
-compiler.path.cc: "/usr/local/bin/gcc-5" 
-compiler.path.as: "/usr/local/bin/gcc-5 -x assembler-with-cpp"
-compiler.path.archive: "ar"
-compiler.path.objdump: "gobjdump"
-compiler.path.objsize: "objsize"
-compiler.path.objcopy: "gobjcopy"
 
+# Default.
+compiler.path.cc: "gcc"
+compiler.path.as: "gcc -x assembler-with-cpp"
+compiler.path.archive: "ar"
+compiler.path.objdump: "objdump"
+compiler.path.objsize: "size"
+compiler.path.objcopy: "objcopy"
 compiler.flags.base: >
-    -m32 -Wall -Werror -ggdb -DMN_OSX
+    -m32 -Wall -Werror -ggdb
+compiler.ld.resolve_circular_deps: true
 
 compiler.flags.default: [compiler.flags.base, -O1]
 compiler.flags.debug: [compiler.flags.base, -O0]
-
 compiler.ld.mapfile: false
+
+# Linux.
+compiler.flags.base.LINUX: >
+    -DMN_LINUX
+compiler.ld.flags.LINUX: -lutil
+
+# OS X.
+compiler.path.cc.DARWIN.OVERWRITE: "/usr/local/bin/gcc-5"
+compiler.path.as.DARWIN.OVERWRITE: "/usr/local/bin/gcc-5 -x assembler-with-cpp"
+compiler.path.objdump.DARWIN.OVERWRITE: "gobjdump"
+compiler.path.objsize.DARWIN.OVERWRITE: "objsize"
+compiler.path.objcopy.DARWIN.OVERWRITE: "gobjcopy"
+compiler.flags.base.DARWIN: >
+    -DMN_OSX
+compiler.ld.resolve_circular_deps.DARWIN.OVERWRITE: false

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f7c92701/compiler/sim/linux-compiler.yml
----------------------------------------------------------------------
diff --git a/compiler/sim/linux-compiler.yml b/compiler/sim/linux-compiler.yml
deleted file mode 100644
index c1618ef..0000000
--- a/compiler/sim/linux-compiler.yml
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-# 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.
-#
-
-compiler.path.cc: "gcc"
-compiler.path.as: "gcc -x assembler-with-cpp"
-compiler.path.archive: "ar"
-compiler.path.objdump: "objdump"
-compiler.path.objsize: "size"
-compiler.path.objcopy: "objcopy"
-
-compiler.flags.base: >
-    -m32 -Wall -Werror -ggdb -O0 -DMN_LINUX
-
-compiler.flags.default: [compiler.flags.base]
-compiler.flags.debug: [compiler.flags.base, -ggdb -O0]
-
-compiler.ld.mapfile: false
-compiler.ld.resolve_circular_deps: true
-compiler.ld.flags: -lutil

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f7c92701/compiler/sim/osx-compiler.yml
----------------------------------------------------------------------
diff --git a/compiler/sim/osx-compiler.yml b/compiler/sim/osx-compiler.yml
deleted file mode 100644
index 93dece4..0000000
--- a/compiler/sim/osx-compiler.yml
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# 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.
-#
-compiler.path.cc: "/usr/local/bin/gcc-5" 
-compiler.path.archive: "ar"
-compiler.path.objdump: "gobjdump"
-compiler.path.objsize: "objsize"
-compiler.path.objcopy: "gobjcopy"
-
-compiler.flags.base: >
-    -m32 -Wall -Werror -ggdb -O0 -DMN_OSX
-
-compiler.flags.default: [compiler.flags.base]
-compiler.flags.debug: [compiler.flags.base, -ggdb -O0]
-
-compiler.ld.mapfile: false


[07/42] incubator-mynewt-core git commit: MYNEWT-84: extend connection events beyond originally scheduled connection event

Posted by cc...@apache.org.
MYNEWT-84: extend connection events beyond originally scheduled connection event


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/4d1854dc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/4d1854dc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/4d1854dc

Branch: refs/heads/master
Commit: 4d1854dca59a5ceb3b03ef6da159876c1d2f568c
Parents: a601f78
Author: wes3 <wi...@micosa.io>
Authored: Wed Mar 9 15:50:46 2016 -0800
Committer: wes3 <wi...@micosa.io>
Committed: Wed Mar 9 15:55:32 2016 -0800

----------------------------------------------------------------------
 apps/bletest/src/main.c                         | 169 ++++++++---------
 .../controller/include/controller/ble_ll_conn.h |   1 +
 .../include/controller/ble_ll_sched.h           |  19 ++
 net/nimble/controller/src/ble_ll_conn.c         | 181 ++++++++++++++-----
 net/nimble/controller/src/ble_ll_ctrl.c         |   3 -
 net/nimble/controller/src/ble_ll_sched.c        |  53 +++++-
 net/nimble/drivers/nrf52/src/ble_phy.c          |   4 +-
 7 files changed, 287 insertions(+), 143 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4d1854dc/apps/bletest/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bletest/src/main.c b/apps/bletest/src/main.c
index d004aa9..8fdc06f 100755
--- a/apps/bletest/src/main.c
+++ b/apps/bletest/src/main.c
@@ -110,12 +110,12 @@ os_membuf_t g_mbuf_buffer[MBUF_MEMPOOL_SIZE];
 #define BLETEST_CFG_MIN_CE_LEN          (6)    
 #define BLETEST_CFG_MAX_CE_LEN          (BLETEST_CFG_CONN_ITVL)
 #define BLETEST_CFG_CONN_PEER_ADDR_TYPE (BLE_HCI_CONN_PEER_ADDR_PUBLIC)
-#define BLETEST_CFG_CONN_OWN_ADDR_TYPE  (BLE_HCI_ADV_OWN_ADDR_RANDOM)
-#define BLETEST_CFG_CONCURRENT_CONNS    (1)
+#define BLETEST_CFG_CONN_OWN_ADDR_TYPE  (BLE_HCI_ADV_OWN_ADDR_PUBLIC)
+#define BLETEST_CFG_CONCURRENT_CONNS    (16)
 
 /* BLETEST variables */
 #undef BLETEST_ADV_PKT_NUM
-#define BLETEST_PKT_SIZE                (251)
+#define BLETEST_PKT_SIZE                (247)
 #define BLETEST_STACK_SIZE              (256)
 uint32_t g_next_os_time;
 int g_bletest_state;
@@ -132,6 +132,23 @@ uint8_t g_last_handle_used;
 uint8_t g_bletest_led_state;
 uint32_t g_bletest_led_rate;
 uint32_t g_bletest_next_led_time;
+uint16_t g_bletest_handle;
+uint16_t g_bletest_completed_pkts;
+uint16_t g_bletest_outstanding_pkts;
+
+#if (BLETEST_THROUGHPUT_TEST == 1)
+void
+bletest_completed_pkt(uint16_t handle)
+{
+    os_sr_t sr;
+
+    OS_ENTER_CRITICAL(sr);
+    if (handle == g_bletest_handle) {
+        ++g_bletest_completed_pkts;
+    }
+    OS_EXIT_CRITICAL(sr);
+}
+#endif
 
 #ifdef BLETEST_ADV_PKT_NUM
 void
@@ -490,87 +507,16 @@ bletest_get_packet(void)
     return om;
 }
 
-#if 0
-void
-bletest_execute(void)
-{
-    int rc;
-
-    int i;
-    uint16_t pktlen;
-    uint16_t handle;
-    struct os_mbuf *om;
-    struct ble_ll_conn_sm *connsm;
-
-    handle = 1;
-    if ((int32_t)(os_time_get() - g_next_os_time) >= 0) {
-        if (g_bletest_state == 0) {
-            rc = host_hci_cmd_le_set_adv_enable(1);
-            host_hci_outstanding_opcode = 0;
-            assert(rc == 0);
-            g_bletest_state = 1;
-        } else if (g_bletest_state == 1) {
-            /* See if handle 1 has been created. If so, send packets */
-            connsm = ble_ll_conn_find_active_conn(handle);
-            if (connsm) {
-                /* Set connection end time */
-                g_bletest_conn_end = os_time_get() + 
-                    (OS_TICKS_PER_SEC * (60 * 15));
-                g_bletest_state = 2;
-            }
-        } else if (g_bletest_state == 2) {
-            if ((int32_t)(os_time_get() - g_bletest_conn_end) >= 0) {
-                g_bletest_state = 3;
-                host_hci_cmd_disconnect(handle, BLE_ERR_REM_USER_CONN_TERM);
-            } else {
-                om = bletest_get_packet();
-                if (om) {
-                    /* set payload length */
-                    pktlen = BLETEST_PKT_SIZE;
-                    om->om_len = BLETEST_PKT_SIZE + 4;
-
-                    /* Put the HCI header in the mbuf */
-                    htole16(om->om_data, handle);
-                    htole16(om->om_data + 2, om->om_len);
-
-                    /* Place L2CAP header in packet */
-                    htole16(om->om_data + 4, pktlen);
-                    om->om_data[6] = 0;
-                    om->om_data[7] = 0;
-
-                    /* Fill with incrementing pattern (starting from 1) */
-                    for (i = 0; i < pktlen; ++i) {
-                        om->om_data[8 + i] = (uint8_t)(i + 1);
-                    }
-
-                    /* Add length */
-                    om->om_len += 4;
-                    OS_MBUF_PKTHDR(om)->omp_len = om->om_len;
-                    ble_hci_transport_host_acl_data_send(om);
-                }
-                g_next_os_time += OS_TICKS_PER_SEC / 10;
-                return;
-            }
-        } else if (g_bletest_state == 3) {
-            /* We should be waiting for disconnect */
-            connsm = ble_ll_conn_find_active_conn(handle);
-            if (!connsm) {
-                /* Set to 0 if you want to restart advertising */
-                //g_bletest_state = 0;
-                g_bletest_state = 4;
-            }
-        }
-        g_next_os_time += OS_TICKS_PER_SEC;
-    }
-}
-#else
 static void
 bletest_execute_advertiser(void)
 {
-    int i,j;
+    int i;
+    int j;
     int rc;
+    //os_sr_t sr;
     uint16_t handle;
     uint16_t pktlen;
+    //uint16_t completed_pkts;
     struct os_mbuf *om;
 
     /* See if we should start advertising again */
@@ -580,6 +526,14 @@ bletest_execute_advertiser(void)
             /* Set LED to slower blink rate */
             g_bletest_led_rate = OS_TICKS_PER_SEC;
 
+#if 0
+            /* Set next os time to 10 seconds after 1st connection */
+            if (g_next_os_time == 0) {
+                g_next_os_time = os_time_get() + (10 * OS_TICKS_PER_SEC);
+                g_bletest_handle = handle;
+            }
+#endif
+
             /* advertising better be stopped! */
             assert(ble_ll_adv_enabled() == 0);
 
@@ -666,11 +620,60 @@ bletest_execute_advertiser(void)
                 }
             }
         }
-        g_next_os_time = os_time_get() + OS_TICKS_PER_SEC;
+        g_next_os_time = os_time_get() + OS_TICKS_PER_SEC/4;
     }
+
+#if 0 /* XXX: throughput test */
+    /* Nothing to do if no connections */
+    if (!g_bletest_current_conns) {
+        return;
+    }
+
+    /* See if it is time to start throughput testing */
+    if ((int32_t)(os_time_get() - g_next_os_time) >= 0) {
+
+        /* Keep window full */
+        OS_ENTER_CRITICAL(sr);
+        completed_pkts = g_bletest_completed_pkts;
+        g_bletest_completed_pkts = 0;
+        OS_EXIT_CRITICAL(sr);
+
+        assert(g_bletest_outstanding_pkts >= completed_pkts);
+        g_bletest_outstanding_pkts -= completed_pkts;
+
+        while (g_bletest_outstanding_pkts < 8) {
+            om = bletest_get_packet();
+            if (om) {
+                /* set payload length */
+                pktlen = BLETEST_PKT_SIZE;
+                om->om_len = BLETEST_PKT_SIZE + 4;
+
+                /* Put the HCI header in the mbuf */
+                htole16(om->om_data, g_bletest_handle);
+                htole16(om->om_data + 2, om->om_len);
+
+                /* Place L2CAP header in packet */
+                htole16(om->om_data + 4, pktlen);
+                om->om_data[6] = 0;
+                om->om_data[7] = 0;
+                om->om_len += 4;
+
+                /* Fill with incrementing pattern (starting from 1) */
+                for (j = 0; j < pktlen; ++j) {
+                    om->om_data[8 + j] = (uint8_t)(j + 1);
+                }
+
+                /* Add length */
+                OS_MBUF_PKTHDR(om)->omp_len = om->om_len;
+                ble_hci_transport_host_acl_data_send(om);
+
+                ++g_bletest_outstanding_pkts;
+            }
+        }
+    }
+#endif /* XXX: throughput test */
 }
-#endif
-#endif
+#endif 
 
 /**
  * Main bletest function. Called by the task timer every 50 msecs.
@@ -706,8 +709,8 @@ bletest_timer_cb(void *arg)
     /* Call the bletest code */
     bletest_execute();
 
-    /* Re-start the timer (run every 50 msecs) */
-    os_callout_reset(&g_bletest_timer.cf_c, OS_TICKS_PER_SEC / 20);
+    /* Re-start the timer (run every 10 msecs) */
+    os_callout_reset(&g_bletest_timer.cf_c, OS_TICKS_PER_SEC / 100);
 }
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4d1854dc/net/nimble/controller/include/controller/ble_ll_conn.h
----------------------------------------------------------------------
diff --git a/net/nimble/controller/include/controller/ble_ll_conn.h b/net/nimble/controller/include/controller/ble_ll_conn.h
index b1bceca..7670ac0 100644
--- a/net/nimble/controller/include/controller/ble_ll_conn.h
+++ b/net/nimble/controller/include/controller/ble_ll_conn.h
@@ -147,6 +147,7 @@ struct ble_ll_conn_sm
 
     uint32_t access_addr;
     uint32_t crcinit;               /* only low 24 bits used */
+    /* XXX: do we need ce_end_time? Cant this be sched end time? */
     uint32_t ce_end_time;   /* cputime at which connection event should end */
     uint32_t terminate_timeout;
     uint32_t last_scheduled;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4d1854dc/net/nimble/controller/include/controller/ble_ll_sched.h
----------------------------------------------------------------------
diff --git a/net/nimble/controller/include/controller/ble_ll_sched.h b/net/nimble/controller/include/controller/ble_ll_sched.h
index 7fe2b06..00a2c6b 100644
--- a/net/nimble/controller/include/controller/ble_ll_sched.h
+++ b/net/nimble/controller/include/controller/ble_ll_sched.h
@@ -23,6 +23,13 @@
 /* Time per BLE scheduler slot */
 #define BLE_LL_SCHED_USECS_PER_SLOT (1250)
 
+/* 
+ * This is the number of slots needed to transmit and receive a maximum
+ * size PDU, including an IFS time before each. The actual time is
+ * 2120 usecs for tx/rx and 150 for IFS = 4540 usecs.
+ */ 
+#define BLE_LL_SCHED_MAX_TXRX_SLOT  (4 * BLE_LL_SCHED_USECS_PER_SLOT)
+
 /* BLE scheduler errors */
 #define BLE_LL_SCHED_ERR_OVERLAP    (1)
 
@@ -79,6 +86,18 @@ int ble_ll_sched_adv_reschedule(struct ble_ll_sched_item *sch);
 /* Reschedule a connection that had previously been scheduled or that is over */
 int ble_ll_sched_conn_reschedule(struct ble_ll_conn_sm * connsm);
 
+/**
+ * Called to determine when the next scheduled event will occur. 
+ *  
+ * If there are not scheduled events this function returns 0; otherwise it 
+ * returns 1 and *next_event_time is set to the start time of the next event. 
+ * 
+ * @param next_event_time cputime at which next scheduled event will occur
+ * 
+ * @return int 0: No events are scheduled 1: there is an upcoming event 
+ */
+int ble_ll_sched_next_time(uint32_t *next_event_time);
+
 /* Stop the scheduler */
 void ble_ll_sched_stop(void);
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4d1854dc/net/nimble/controller/src/ble_ll_conn.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_conn.c b/net/nimble/controller/src/ble_ll_conn.c
index 36c63e3..e3a38d0 100644
--- a/net/nimble/controller/src/ble_ll_conn.c
+++ b/net/nimble/controller/src/ble_ll_conn.c
@@ -36,34 +36,54 @@
 #include "hal/hal_cputime.h"
 #include "hal/hal_gpio.h"
 
-/* 
- * XXX: looks like the current code will allow the 1st packet in a
- * connection to extend past the end of the allocated connection end
- * time. That is not good. Need to deal with that. Need to extend connection
- * end time.
- */
-
 /* XXX TODO
- * 1) Add set channel map command and implement channel change procedure.
- * 2) I think if we are initiating and we already have a connection with
+ * 1) I think if we are initiating and we already have a connection with
  * a device that we will still try and connect to it. Fix this.
- * 3) Make sure we check incoming data packets for size and all that. You
+ *  -> This is true. There are a couple things to do
+ *      i) When a connection create is issued, if we already are connected
+ *      deny it. BLE ERROR = 0x0B (ACL connection exists).
+ *      ii) If we receive an advertisement while initiating and want to send
+ *      a connect request to the device, make sure we dont have it.
+ *      iii) I think I need to do something like this: I am initiating and
+ *      advertising. Suppose the device I want to connect to sends me a connect
+ *      request because I am advertising? What happens to connection? Deal
+ *      with this!
+ * 
+ * 2) Make sure we check incoming data packets for size and all that. You
  * know, supported octets and all that. For both rx and tx.
- * 4) Make sure we are setting the schedule end time properly for both slave
+ * 
+ * 3) Make sure we are setting the schedule end time properly for both slave
  * and master. We should just set this to the end of the connection event.
  * We might want to guarantee a IFS time as well since the next event needs
  * to be scheduled prior to the start of the event to account for the time it
  * takes to get a frame ready (which is pretty much the IFS time).
- * 5) Do we need to check the terminate timeout inside the connection event?
- * I think we do.
+ * 
+ * 4) looks like the current code will allow the 1st packet in a
+ * connection to extend past the end of the allocated connection end
+ * time. That is not good. Need to deal with that. Need to extend connection
+ * end time.
+ * 
  * 6) Use error code 0x3E correctly! Connection failed to establish. If you
  * read the LE connection complete event, it says that if the connection
  * fails to be established that the connection complete event gets sent to
- * the host that issued the create connection.
+ * the host that issued the create connection. Need to resolve this.
+ * 
  * 7) How does peer address get set if we are using whitelist? Look at filter
  * policy and make sure you are doing this correctly.
+ * 
  * 8) Right now I use a fixed definition for required slots. CHange this.
+ * 
  * 9) Use output compare for transmit.
+ * 
+ * 10) See what connection state machine elements are purely master and
+ * purely slave. We can make a union of them.
+ * 
+ * 11) Need to trim elements from the connection state machine.
+ * 
+ * 12) When a slave receives a data packet in a connection it has to send a
+ * response. Well, it should. If this packet will overrun the next scheduled
+ * event, what should we do? Transmit anyway? Not transmit? For now, we just
+ * transmit.
  */
 
 /* 
@@ -79,12 +99,6 @@
 extern int ble_hs_rx_data(struct os_mbuf *om);
 
 /* 
- * XXX: Possible improvements
- * 1) See what connection state machine elements are purely master and
- * purely slave. We can make a union of them.
- */
-
-/* 
  * The amount of time that we will wait to hear the start of a receive
  * packet after we have transmitted a packet. This time is at least
  * an IFS time plus the time to receive the preamble and access address. We
@@ -580,6 +594,39 @@ ble_ll_conn_wait_txend(void *arg)
 }
 
 /**
+ * Returns the cputime of the next scheduled item on the scheduler list or 
+ * when the current connection will start its next interval (whichever is 
+ * earlier). This API is called when determining at what time we should end 
+ * the current connection event. The current connection event must end before 
+ * the next scheduled item. However, the current connection itself is not 
+ * in the scheduler list! Thus, we need to calculate the time at which the 
+ * next connection will start and not overrun it. 
+ * 
+ * @param connsm 
+ * 
+ * @return uint32_t 
+ */
+static uint32_t
+ble_ll_conn_get_next_sched_time(struct ble_ll_conn_sm *connsm)
+{
+    uint32_t itvl;
+    uint32_t ce_end;
+    uint32_t next_sched_time;
+
+    /* Calculate time at which next connection event will start */
+    itvl = connsm->conn_itvl * BLE_LL_CONN_ITVL_USECS;
+    ce_end = connsm->anchor_point + cputime_usecs_to_ticks(itvl);
+
+    if (ble_ll_sched_next_time(&next_sched_time)) {
+        if (CPUTIME_LT(next_sched_time, ce_end)) {
+            ce_end = next_sched_time;
+        }
+    }
+
+    return ce_end;
+}
+
+/**
  * Called when we want to send a data channel pdu inside a connection event. 
  *  
  * Context: interrupt 
@@ -597,7 +644,9 @@ ble_ll_conn_tx_data_pdu(struct ble_ll_conn_sm *connsm, int beg_transition)
     uint8_t hdr_byte;
     uint8_t end_transition;
     uint8_t cur_txlen;
+    uint8_t next_txlen;
     uint8_t rem_bytes;
+    uint32_t next_event_time;
     uint32_t ticks;
     struct os_mbuf *m;
     struct ble_mbuf_hdr *ble_hdr;
@@ -607,11 +656,7 @@ ble_ll_conn_tx_data_pdu(struct ble_ll_conn_sm *connsm, int beg_transition)
 
     /*
      * Get packet off transmit queue. If not available, send empty PDU. Set
-     * the more data bit as well. For a slave, we will set it regardless of
-     * connection event end timing (master will deal with that for us or the
-     * connection event will be terminated locally). For a master, we only
-     * set the MD bit if we have enough time to send the current PDU, get
-     * a response and send the next packet and get a response.
+     * the more data bit as well. 
      */
     md = 0;
     tx_empty_pdu = 0;
@@ -655,32 +700,60 @@ ble_ll_conn_tx_data_pdu(struct ble_ll_conn_sm *connsm, int beg_transition)
             ble_hdr->txinfo.pyld_len = cur_txlen;
         }
 
+        /* 
+         * Set the more data data flag if we have more data to send and we
+         * have not been asked to terminate
+         */ 
         if ((nextpkthdr || 
              ((ble_hdr->txinfo.offset + cur_txlen) < pkthdr->omp_len)) && 
              !connsm->csmflags.cfbit.terminate_ind_rxd) {
-            md = 1;
-            if (connsm->conn_role == BLE_LL_CONN_ROLE_MASTER) {
-                /* 
-                 * Dont bother to set the MD bit if we cannot do the following:
-                 *  -> wait IFS, send the current frame.
-                 *  -> wait IFS, receive a mininim size frame.
-                 *  -> wait IFS, send a mininim size frame.
-                 *  -> wait IFS, receive a mininim size frame.
-                 */
-                /* 
-                 * XXX: this calculation is based on using the current time
-                 * and assuming the transmission will occur an IFS time from
-                 * now. This is not the most accurate especially if we have
-                 * received a frame and we are replying to it.
-                 */ 
-                ticks = (BLE_LL_IFS * 4) + (3 * BLE_LL_CONN_SUPP_TIME_MIN) +
-                    BLE_TX_DUR_USECS_M(cur_txlen);
-                ticks = cputime_usecs_to_ticks(ticks);
-                if ((cputime_get32() + ticks) >= connsm->ce_end_time) {
-                    md = 0;
+            /* Get next event time */
+            next_event_time = ble_ll_conn_get_next_sched_time(connsm);
+
+            /* 
+             * Dont bother to set the MD bit if we cannot do the following:
+             *  -> wait IFS, send the current frame.
+             *  -> wait IFS, receive a maximum size frame.
+             *  -> wait IFS, send the next frame.
+             *  -> wait IFS, receive a maximum size frame.
+             * 
+             *  For slave:
+             *  -> wait IFS, send current frame.
+             *  -> wait IFS, receive maximum size frame.
+             *  -> wait IFS, send next frame.
+             */
+            if ((ble_hdr->txinfo.offset + cur_txlen) < pkthdr->omp_len) {
+                next_txlen = pkthdr->omp_len - 
+                    (ble_hdr->txinfo.offset + cur_txlen);
+            } else {
+                if (nextpkthdr->omp_len > connsm->eff_max_tx_octets) {
+                    next_txlen = connsm->eff_max_tx_octets;
+                } else {
+                    next_txlen = nextpkthdr->omp_len;
                 }
             }
-        }
+
+            /* 
+             * XXX: this calculation is based on using the current time
+             * and assuming the transmission will occur an IFS time from
+             * now. This is not the most accurate especially if we have
+             * received a frame and we are replying to it.
+             */ 
+            ticks = (BLE_LL_IFS * 3) + connsm->eff_max_rx_time +
+                    BLE_TX_DUR_USECS_M(next_txlen) + 
+                    BLE_TX_DUR_USECS_M(cur_txlen);
+
+            if (connsm->conn_role == BLE_LL_CONN_ROLE_MASTER) {
+                ticks += (BLE_LL_IFS + connsm->eff_max_rx_time); 
+            }
+
+            ticks = cputime_usecs_to_ticks(ticks);
+            if ((cputime_get32() + ticks) >= next_event_time) {
+                md = 0;
+            } else {
+                md = 1;
+            }
+         }
     } else {
         /* Send empty pdu. Need to reset some items since we re-use it. */
         m = (struct os_mbuf *)&connsm->conn_empty_pdu;
@@ -718,6 +791,13 @@ ble_ll_conn_tx_data_pdu(struct ble_ll_conn_sm *connsm, int beg_transition)
      * connection event. We will end the connection event if we have
      * received a valid frame with the more data bit set to 0 and we dont
      * have more data.
+     * 
+     * XXX: for a slave, we dont check to see if we can:
+     *  -> wait IFS, rx frame from master (either big or small).
+     *  -> wait IFS, send empty pdu or next pdu.
+     * 
+     *  We could do this. Now, we just keep going and hope that we dont
+     *  overrun next scheduled item.
      */
     if ((connsm->csmflags.cfbit.terminate_ind_rxd) ||
         ((connsm->conn_role == BLE_LL_CONN_ROLE_SLAVE) && (md == 0) &&
@@ -873,12 +953,17 @@ ble_ll_conn_can_send_next_pdu(struct ble_ll_conn_sm *connsm, uint32_t begtime)
     int rc;
     uint8_t rem_bytes;
     uint32_t ticks;
+    uint32_t next_sched_time;
     struct os_mbuf *txpdu;
     struct os_mbuf_pkthdr *pkthdr;
     struct ble_mbuf_hdr *txhdr;
 
     rc = 1;
     if (connsm->conn_role == BLE_LL_CONN_ROLE_MASTER) {
+        /* Get next scheduled item time */
+        next_sched_time = ble_ll_conn_get_next_sched_time(connsm);
+
+        /* Check if there is a packet on the queue. */
         pkthdr = STAILQ_FIRST(&connsm->conn_txq);
         if (pkthdr) {
             txpdu = OS_MBUF_PKTHDR_TO_MBUF(pkthdr);
@@ -892,9 +977,9 @@ ble_ll_conn_can_send_next_pdu(struct ble_ll_conn_sm *connsm, uint32_t begtime)
             /* We will send empty pdu (just a LL header) */
             ticks = BLE_TX_DUR_USECS_M(0);
         }
-        ticks += (BLE_LL_IFS * 2) + BLE_LL_CONN_SUPP_TIME_MIN;
+        ticks += (BLE_LL_IFS * 2) + connsm->eff_max_rx_time;
         ticks = cputime_usecs_to_ticks(ticks);
-        if ((begtime + ticks) >= connsm->ce_end_time) {
+        if ((begtime + ticks) >= next_sched_time) {
             rc = 0;
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4d1854dc/net/nimble/controller/src/ble_ll_ctrl.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_ctrl.c b/net/nimble/controller/src/ble_ll_ctrl.c
index ec77808..2322a6b 100644
--- a/net/nimble/controller/src/ble_ll_ctrl.c
+++ b/net/nimble/controller/src/ble_ll_ctrl.c
@@ -72,9 +72,6 @@ const uint8_t g_ble_ll_ctrl_pkt_lengths[BLE_LL_CTRL_OPCODES] =
     11, 7, 1, 22, 12, 0, 0, 1, 8, 8, 0, 0, 5, 1, 8, 23, 23, 2, 0, 0, 8, 8
 };
 
-/* XXX: Improvements
- * 1) We can inititalize the procedure timer once per connection state machine
- */
 static int
 ble_ll_ctrl_chk_supp_bytes(uint16_t bytes)
 {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4d1854dc/net/nimble/controller/src/ble_ll_sched.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_sched.c b/net/nimble/controller/src/ble_ll_sched.c
index dae0947..11601d8 100644
--- a/net/nimble/controller/src/ble_ll_sched.c
+++ b/net/nimble/controller/src/ble_ll_sched.c
@@ -241,6 +241,7 @@ ble_ll_sched_master_new(struct ble_ll_conn_sm *connsm, uint32_t adv_rxend,
 {
     int rc;
     os_sr_t sr;
+    uint32_t tps;
     uint32_t initial_start;
     uint32_t earliest_start;
     uint32_t earliest_end;
@@ -282,11 +283,18 @@ ble_ll_sched_master_new(struct ble_ll_conn_sm *connsm, uint32_t adv_rxend,
      * earliest start so we can end the connection reasonably.
      */
     if (ble_ll_state_get() == BLE_LL_STATE_CONNECTION) {
+        tps = cputime_usecs_to_ticks(BLE_LL_SCHED_USECS_PER_SLOT);
         ce_end_time = ble_ll_conn_get_ce_end_time();
-        if ((int32_t)(ce_end_time - sch->start_time) >= 0) {
-            earliest_start = ce_end_time;
-            earliest_end = earliest_start + dur;
+        while ((int32_t)(ce_end_time - cputime_get32()) < 0) {
+            ce_end_time += tps;
         }
+
+        /* Start at next slot boundary past earliest */
+        while ((int32_t)(ce_end_time - earliest_start) < 0) {
+            ce_end_time += tps;
+        }
+        earliest_start = ce_end_time;
+        earliest_end = earliest_start + dur;
     }
     initial_start = earliest_start;
 
@@ -430,6 +438,7 @@ ble_ll_sched_adv_new(struct ble_ll_sched_item *sch)
 {
     int rc;
     os_sr_t sr;
+    int32_t ticks;
     uint32_t ce_end_time;
     uint32_t adv_start;
     uint32_t duration;
@@ -445,12 +454,13 @@ ble_ll_sched_adv_new(struct ble_ll_sched_item *sch)
      * earliest start so we can end the connection reasonably.
      */
     if (ble_ll_state_get() == BLE_LL_STATE_CONNECTION) {
-        sch->start_time += cputime_usecs_to_ticks(BLE_LL_SCHED_USECS_PER_SLOT);
+        ticks = (int32_t)cputime_usecs_to_ticks(BLE_LL_SCHED_MAX_TXRX_SLOT);
         ce_end_time = ble_ll_conn_get_ce_end_time();
-        if ((int32_t)(ce_end_time - sch->start_time) >= 0) {
-            sch->start_time = ce_end_time;
+        if ((int32_t)(ce_end_time - sch->start_time) < ticks) {
+            ce_end_time += ticks;
         }
-        sch->end_time = sch->start_time + duration;
+        sch->start_time = ce_end_time;
+        sch->end_time = ce_end_time + duration;
     }
 
     entry = ble_ll_sched_insert_if_empty(sch);
@@ -670,6 +680,35 @@ ble_ll_sched_run(void *arg)
 }
 
 /**
+ * Called to determine when the next scheduled event will occur. 
+ *  
+ * If there are not scheduled events this function returns 0; otherwise it 
+ * returns 1 and *next_event_time is set to the start time of the next event. 
+ * 
+ * @param next_event_time 
+ * 
+ * @return int 0: No events are scheduled 1: there is an upcoming event 
+ */
+int
+ble_ll_sched_next_time(uint32_t *next_event_time)
+{
+    int rc;
+    os_sr_t sr;
+    struct ble_ll_sched_item *first;
+
+    rc = 0;
+    OS_ENTER_CRITICAL(sr);
+    first = TAILQ_FIRST(&g_ble_ll_sched_q);
+    if (first) {
+        *next_event_time = first->start_time;
+        rc = 1;
+    }
+    OS_EXIT_CRITICAL(sr);
+
+    return rc;
+}
+
+/**
  * Stop the scheduler
  *  
  * Context: Link Layer task 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4d1854dc/net/nimble/drivers/nrf52/src/ble_phy.c
----------------------------------------------------------------------
diff --git a/net/nimble/drivers/nrf52/src/ble_phy.c b/net/nimble/drivers/nrf52/src/ble_phy.c
index 1f6e101..58befeb 100644
--- a/net/nimble/drivers/nrf52/src/ble_phy.c
+++ b/net/nimble/drivers/nrf52/src/ble_phy.c
@@ -179,8 +179,8 @@ ble_phy_isr(void)
         /* Better be in TX state! */
         assert(g_ble_phy_data.phy_state == BLE_PHY_STATE_TX);
 
-        ble_ll_log(BLE_LL_LOG_ID_PHY_TXEND, g_ble_phy_txrx_buf[1], 0, 
-                   NRF_TIMER0->CC[2]);
+        ble_ll_log(BLE_LL_LOG_ID_PHY_TXEND, (g_ble_phy_txrx_buf[0] >> 8) & 0xFF, 
+                   0, NRF_TIMER0->CC[2]);
 
         /* Clear events and clear interrupt on disabled event */
         NRF_RADIO->EVENTS_DISABLED = 0;


[41/42] incubator-mynewt-core git commit: add release notes

Posted by cc...@apache.org.
add release notes


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/c4d8d396
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/c4d8d396
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/c4d8d396

Branch: refs/heads/master
Commit: c4d8d396ab6838b47a8fffcff544435b9519775d
Parents: 27a3fd4
Author: Sterling Hughes <st...@apache.org>
Authored: Mon Mar 14 16:36:10 2016 -0700
Committer: Sterling Hughes <st...@apache.org>
Committed: Mon Mar 14 16:36:19 2016 -0700

----------------------------------------------------------------------
 RELEASE_NOTES.md | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c4d8d396/RELEASE_NOTES.md
----------------------------------------------------------------------
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
new file mode 100644
index 0000000..5c791db
--- /dev/null
+++ b/RELEASE_NOTES.md
@@ -0,0 +1,36 @@
+# RELEASE NOTES
+
+14 Mar 2016 - Apache Mynewt V0.8 Beta 2 
+
+For full release notes, please visit the 
+[Apache Mynewt Wiki](https://cwiki.apache.org/confluence/display/MYNEWT/Release+Notes).
+For information about bugs fixed in beta 2, please view the 
+[Issue Tracker Summary](https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12319221&version=12334805)
+
+This is the second source release of Apache Mynewt Core.  For more 
+information on Apache Mynewt, please visit the 
+[Apache Mynewt Website](https://mynewt.apache.org/).  
+
+As an early beta release of Apache Mynewt, all the normal caveats apply:
+
+  * APIs and commands may change
+
+  * There are definitely bugs hiding around many corners
+
+However, we believe this release of Apache Mynewt represents the going forward 
+architecture and layout of the Apache Mynewt Operating System.  Further, we have 
+been running Apache Mynewt stably on real hardware for over 6+ mos, without 
+any issues.  So, people who are interested in playing around, and trying Mynewt,
+are encouraged to download and begin to evaluate it.
+
+A full roadmap for Apache Mynewt is available on the [website](http://mynewt.apache.org/about/).
+In addition, a detailed view of what is being worked on, and all open feature 
+requests are in 
+[JIRA](https://issues.apache.org/jira/browse/MYNEWT/?selectedTab=com.atlassian.jira.jira-projects-plugin:roadmap-panel).
+
+More information is available in the [README](/README.md) file in this directory.
+
+The next release of Apache Mynewt is scheduled for April 22nd, 2016.  If building 
+an Operating System for Microcontrollers sounds fun to you, get in touch by sending
+a mail to the [Apache Mynewt Developer's list](mailto:dev@mynewt.incubator.apache.org).
+


[39/42] incubator-mynewt-core git commit: remove empty readmes, fixup readmes with content. some of these may be re-added, but shouldn't be in the release empty. top-level readme suffices

Posted by cc...@apache.org.
remove empty readmes, fixup readmes with content.  some of these may be re-added, but shouldn't be in the release empty.  top-level readme suffices


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/fc3116a9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/fc3116a9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/fc3116a9

Branch: refs/heads/master
Commit: fc3116a91eeb2c7d0efd2bb7cbf2b75ee41d86f5
Parents: edd5b1f
Author: Sterling Hughes <st...@apache.org>
Authored: Mon Mar 14 15:55:06 2016 -0700
Committer: Sterling Hughes <st...@apache.org>
Committed: Mon Mar 14 15:55:06 2016 -0700

----------------------------------------------------------------------
 fs/nffs/README.md       | 22 ----------------------
 hw/bsp/native/README.md | 22 ----------------------
 hw/hal/README.MD        | 22 ----------------------
 hw/mcu/README.md        | 22 ----------------------
 libs/bootutil/README.md | 22 ----------------------
 libs/console/README.md  | 24 ++++++++++++------------
 libs/os/README.md       | 24 ------------------------
 libs/testutil/README.md | 22 ----------------------
 net/nimble/README.md    | 22 ----------------------
 9 files changed, 12 insertions(+), 190 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fc3116a9/fs/nffs/README.md
----------------------------------------------------------------------
diff --git a/fs/nffs/README.md b/fs/nffs/README.md
deleted file mode 100644
index 052a125..0000000
--- a/fs/nffs/README.md
+++ /dev/null
@@ -1,22 +0,0 @@
-<!--
-#
-# 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.
-#
--->
-
-# ffs

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fc3116a9/hw/bsp/native/README.md
----------------------------------------------------------------------
diff --git a/hw/bsp/native/README.md b/hw/bsp/native/README.md
deleted file mode 100644
index 48ec416..0000000
--- a/hw/bsp/native/README.md
+++ /dev/null
@@ -1,22 +0,0 @@
-<!--
-#
-# 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.
-#
--->
-
-# Native BSP 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fc3116a9/hw/hal/README.MD
----------------------------------------------------------------------
diff --git a/hw/hal/README.MD b/hw/hal/README.MD
deleted file mode 100644
index 88f5cbe..0000000
--- a/hw/hal/README.MD
+++ /dev/null
@@ -1,22 +0,0 @@
-<!--
-#
-# 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.
-#
--->
-
-# hal

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fc3116a9/hw/mcu/README.md
----------------------------------------------------------------------
diff --git a/hw/mcu/README.md b/hw/mcu/README.md
deleted file mode 100644
index 2f670c1..0000000
--- a/hw/mcu/README.md
+++ /dev/null
@@ -1,22 +0,0 @@
-<!--
-#
-# 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.
-#
--->
-
-# mcu

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fc3116a9/libs/bootutil/README.md
----------------------------------------------------------------------
diff --git a/libs/bootutil/README.md b/libs/bootutil/README.md
deleted file mode 100644
index ab95114..0000000
--- a/libs/bootutil/README.md
+++ /dev/null
@@ -1,22 +0,0 @@
-<!--
-#
-# 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.
-#
--->
-
-# bootutil

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fc3116a9/libs/console/README.md
----------------------------------------------------------------------
diff --git a/libs/console/README.md b/libs/console/README.md
index f57e6c8..4ef8bd7 100644
--- a/libs/console/README.md
+++ b/libs/console/README.md
@@ -19,15 +19,15 @@
 #
 -->
 
-# console
-#
-# There are two versions of this library;
-#  full - contains actual implemetation
-#  stub - has stubs for the API
-#
-# You can write of a library which uses console_printf(), and builder of a
-# project can select which one they'll use.
-# For the library/egg, list in the pkg.yml console as the required capability.
-# Project builder will then include either libs/console/full or
-# libs/console/stub as their choice.
-#
+# Console
+
+There are two versions of this library;
+  * full - contains actual implemetation
+  * stub - has stubs for the API
+
+You can write a package which uses ```console_printf()```, and builder of a
+project can select which one they'll use.
+For the package, list in the pkg.yml console as the required capability.
+Project builder will then include either libs/console/full or
+libs/console/stub as their choice.
+

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fc3116a9/libs/os/README.md
----------------------------------------------------------------------
diff --git a/libs/os/README.md b/libs/os/README.md
deleted file mode 100644
index 6a9e7b5..0000000
--- a/libs/os/README.md
+++ /dev/null
@@ -1,24 +0,0 @@
-<!--
-#
-# 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.
-#
--->
-
-# Mynewt OS 
-
-This is documentation on Mynewt OS 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fc3116a9/libs/testutil/README.md
----------------------------------------------------------------------
diff --git a/libs/testutil/README.md b/libs/testutil/README.md
deleted file mode 100644
index 62bac30..0000000
--- a/libs/testutil/README.md
+++ /dev/null
@@ -1,22 +0,0 @@
-<!--
-#
-# 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.
-#
--->
-
-# testutil

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fc3116a9/net/nimble/README.md
----------------------------------------------------------------------
diff --git a/net/nimble/README.md b/net/nimble/README.md
deleted file mode 100644
index 17a5eb5..0000000
--- a/net/nimble/README.md
+++ /dev/null
@@ -1,22 +0,0 @@
-<!--
-#
-# 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.
-#
--->
-
-# nimble


[42/42] incubator-mynewt-core git commit: Merge branch 'develop' for 0.8.0 B2

Posted by cc...@apache.org.
Merge branch 'develop' for 0.8.0 B2


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/3020b32d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/3020b32d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/3020b32d

Branch: refs/heads/master
Commit: 3020b32d67ff2c04da69bed9d76df43bf9bbed70
Parents: 3104b49 c4d8d39
Author: Christopher Collins <cc...@apache.org>
Authored: Mon Mar 14 17:27:00 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Mon Mar 14 17:27:00 2016 -0700

----------------------------------------------------------------------
 README.md                                       |  152 +-
 RELEASE_NOTES.md                                |   36 +
 app.yml                                         |   20 -
 apps/bleprph/src/bleprph.h                      |   43 +
 apps/bleprph/src/gatt_svr.c                     |  342 ++++
 apps/bleprph/src/main.c                         |  300 ++++
 apps/bletest/pkg.yml                            |   39 +
 apps/bletest/src/main.c                         |  982 ++++++++++++
 apps/bletiny/pkg.yml                            |   32 +
 apps/bletiny/src/bletiny_priv.h                 |  169 ++
 apps/bletiny/src/cmd.c                          | 1479 ++++++++++++++++++
 apps/bletiny/src/main.c                         | 1469 +++++++++++++++++
 apps/bletiny/src/parse.c                        |  435 ++++++
 apps/bletiny/src/periph.c                       |  344 ++++
 apps/blinky/pkg.yml                             |   34 +
 apps/blinky/src/main.c                          |  200 +++
 apps/boot/pkg.yml                               |   36 +
 apps/boot/src/boot.c                            |  110 ++
 apps/ffs2native/pkg.yml                         |   31 +
 apps/ffs2native/src/main.c                      |  366 +++++
 apps/luatest/pkg.yml                            |   31 +
 apps/luatest/src/main.c                         |  115 ++
 apps/slinky/pkg.yml                             |   39 +
 apps/slinky/src/main.c                          |  296 ++++
 apps/test/pkg.yml                               |   38 +
 apps/test/src/test.c                            |   44 +
 compiler/arm-none-eabi-m0/compiler.yml          |   33 +
 compiler/arm-none-eabi-m0/pkg.yml               |   22 +-
 compiler/arm-none-eabi-m4/compiler.yml          |   33 +
 compiler/arm-none-eabi-m4/pkg.yml               |   22 +-
 compiler/sim/compiler.yml                       |   48 +
 compiler/sim/linux-compiler.yml                 |   46 -
 compiler/sim/osx-compiler.yml                   |   43 -
 compiler/sim/pkg.yml                            |   21 +-
 fs/fs/pkg.yml                                   |   10 +-
 fs/nffs/README.md                               |   22 -
 fs/nffs/pkg.yml                                 |    8 +-
 fs/nffs/src/test/arch/sim/nffs_test.c           |    2 +-
 hw/bsp/native/README.md                         |   22 -
 hw/bsp/native/native_debug.sh                   |    7 +-
 hw/bsp/native/pkg.yml                           |    9 +-
 hw/bsp/nrf51dk-16kbram/nrf51dk-16kbram_debug.sh |   11 +-
 .../nrf51dk-16kbram/nrf51dk-16kbram_download.sh |   12 +-
 hw/bsp/nrf51dk-16kbram/pkg.yml                  |    9 +-
 hw/bsp/nrf51dk/nrf51dk_debug.sh                 |   11 +-
 hw/bsp/nrf51dk/nrf51dk_download.sh              |   14 +-
 hw/bsp/nrf51dk/pkg.yml                          |    9 +-
 hw/bsp/nrf52pdk/nrf52pdk_debug.sh               |    9 +-
 hw/bsp/nrf52pdk/nrf52pdk_download.sh            |   11 +-
 hw/bsp/nrf52pdk/pkg.yml                         |    9 +-
 .../olimex_stm32-e407_devboard_debug.sh         |   11 +-
 .../olimex_stm32-e407_devboard_download.sh      |   17 +-
 hw/bsp/olimex_stm32-e407_devboard/pkg.yml       |    9 +-
 hw/hal/README.MD                                |   22 -
 hw/hal/pkg.yml                                  |    6 +-
 hw/hal/src/test/flash_map_test.c                |    2 +-
 hw/mcu/README.md                                |   22 -
 hw/mcu/native/pkg.yml                           |    6 +-
 hw/mcu/native/src/hal_uart.c                    |    4 +-
 hw/mcu/nordic/nrf51xxx/pkg.yml                  |    6 +-
 hw/mcu/nordic/nrf52xxx/pkg.yml                  |    6 +-
 hw/mcu/stm/stm32f4xx/pkg.yml                    |    6 +-
 libs/baselibc/pkg.yml                           |   10 +-
 .../baselibc_test/printf_tests.c.donotcompile   |   22 +
 .../src/baselibc_test/tests_glue.c.donotcompile |   33 +
 libs/baselibc/src/baselibc_test/unittests.h     |   14 +
 libs/baselibc/src/test/printf_tests.c           |   22 -
 libs/baselibc/src/test/tests_glue.c             |   33 -
 libs/baselibc/src/test/unittests.h              |   14 -
 libs/bootutil/README.md                         |   22 -
 libs/bootutil/pkg.yml                           |    6 +-
 libs/bootutil/src/test/boot_test.c              |    2 +-
 libs/cmsis-core/pkg.yml                         |    6 +-
 libs/console/README.md                          |   24 +-
 libs/console/full/pkg.yml                       |    8 +-
 libs/console/stub/pkg.yml                       |    8 +-
 libs/elua/elua_base/pkg.yml                     |   12 +-
 libs/flash_test/pkg.yml                         |    9 +-
 libs/imgmgr/pkg.yml                             |    6 +-
 libs/json/pkg.yml                               |    6 +-
 libs/mbedtls/pkg.yml                            |    8 +-
 libs/mbedtls/src/test/mbedtls_test.c            |    2 +-
 libs/newtmgr/pkg.yml                            |    8 +-
 libs/os/README.md                               |   24 -
 libs/os/include/os/arch/sim/os/os_arch.h        |   14 +-
 libs/os/pkg.yml                                 |   12 +-
 libs/os/src/arch/sim/os_arch_sim.c              |   32 +-
 libs/os/src/arch/sim/os_arch_stack_frame.s      |   17 +-
 libs/os/src/os_priv.h                           |    1 +
 libs/os/src/test/os_test.c                      |    2 +-
 libs/shell/pkg.yml                              |   10 +-
 libs/testreport/pkg.yml                         |    6 +-
 libs/testutil/README.md                         |   22 -
 libs/testutil/include/testutil/testutil.h       |    2 +-
 libs/testutil/pkg.yml                           |    8 +-
 libs/testutil/src/case.c                        |    2 +
 libs/testutil/src/testutil.c                    |    3 +
 libs/util/pkg.yml                               |    6 +-
 libs/util/src/test/util_test.c                  |    2 +-
 net/nimble/README.md                            |   22 -
 .../controller/include/controller/ble_ll.h      |   29 +-
 .../controller/include/controller/ble_ll_conn.h |    1 +
 .../controller/include/controller/ble_ll_hci.h  |   11 -
 .../controller/include/controller/ble_ll_scan.h |   18 -
 .../include/controller/ble_ll_sched.h           |   19 +
 .../include/controller/ble_ll_whitelist.h       |    2 -
 net/nimble/controller/pkg.yml                   |    8 +-
 net/nimble/controller/src/ble_ll.c              |   18 +-
 net/nimble/controller/src/ble_ll_adv.c          |   12 +-
 net/nimble/controller/src/ble_ll_conn.c         |  227 ++-
 net/nimble/controller/src/ble_ll_conn_hci.c     |   10 +-
 net/nimble/controller/src/ble_ll_ctrl.c         |    6 +-
 net/nimble/controller/src/ble_ll_hci.c          |   11 +-
 net/nimble/controller/src/ble_ll_scan.c         |   32 +-
 net/nimble/controller/src/ble_ll_sched.c        |   53 +-
 net/nimble/controller/src/ble_ll_whitelist.c    |   12 +-
 net/nimble/drivers/native/pkg.yml               |    8 +-
 net/nimble/drivers/nrf51/pkg.yml                |    8 +-
 net/nimble/drivers/nrf52/pkg.yml                |    8 +-
 net/nimble/drivers/nrf52/src/ble_phy.c          |    4 +-
 net/nimble/host/pkg.yml                         |   14 +-
 net/nimble/host/src/test/ble_hs_test.c          |    2 +-
 net/nimble/host/src/test/ble_hs_test_util.c     |    2 +
 net/nimble/host/src/test/ble_os_test.c          |    6 -
 net/nimble/include/nimble/nimble_opt.h          |   90 ++
 net/nimble/pkg.yml                              |    6 +-
 project.yml                                     |   20 +
 project/bleprph/src/bleprph.h                   |   43 -
 project/bleprph/src/gatt_svr.c                  |  342 ----
 project/bleprph/src/main.c                      |  299 ----
 project/bletest/pkg.yml                         |   40 -
 project/bletest/src/main.c                      |  969 ------------
 project/bletiny/pkg.yml                         |   33 -
 project/bletiny/src/bletiny_priv.h              |  169 --
 project/bletiny/src/cmd.c                       | 1479 ------------------
 project/bletiny/src/main.c                      | 1467 -----------------
 project/bletiny/src/parse.c                     |  435 ------
 project/bletiny/src/periph.c                    |  344 ----
 project/blinky/pkg.yml                          |   35 -
 project/blinky/src/main.c                       |  200 ---
 project/boot/pkg.yml                            |   37 -
 project/boot/src/boot.c                         |  110 --
 project/ffs2native/pkg.yml                      |   32 -
 project/ffs2native/src/main.c                   |  366 -----
 project/luatest/pkg.yml                         |   32 -
 project/luatest/src/main.c                      |  115 --
 project/slinky/pkg.yml                          |   40 -
 project/slinky/src/main.c                       |  296 ----
 project/test/pkg.yml                            |   40 -
 project/test/src/test.c                         |   44 -
 sys/config/pkg.yml                              |    8 +-
 sys/config/src/test/conf_test.c                 |    2 +-
 sys/log/pkg.yml                                 |    8 +-
 sys/stats/pkg.yml                               |    8 +-
 154 files changed, 7969 insertions(+), 7863 deletions(-)
----------------------------------------------------------------------



[36/42] incubator-mynewt-core git commit: Restore author/homepage tags for third party libs.

Posted by cc...@apache.org.
Restore author/homepage tags for third party libs.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/0eb30d5e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/0eb30d5e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/0eb30d5e

Branch: refs/heads/master
Commit: 0eb30d5e1bd7537367f658691fddc27a62845b72
Parents: 2fb63de
Author: Christopher Collins <cc...@apache.org>
Authored: Mon Mar 14 14:43:33 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Mon Mar 14 14:43:33 2016 -0700

----------------------------------------------------------------------
 libs/baselibc/pkg.yml   | 4 ++--
 libs/cmsis-core/pkg.yml | 4 ++--
 libs/mbedtls/pkg.yml    | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/0eb30d5e/libs/baselibc/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/baselibc/pkg.yml b/libs/baselibc/pkg.yml
index 0aa4d10..4ab0857 100644
--- a/libs/baselibc/pkg.yml
+++ b/libs/baselibc/pkg.yml
@@ -19,8 +19,8 @@
 
 pkg.name: libs/baselibc
 pkg.description: Simple libc for embedded systems.
-pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
-pkg.homepage: "http://mynewt.apache.org/"
+pkg.author: "Petteri Aimonen"
+pkg.homepage: "https://github.com/PetteriAimonen/Baselibc"
 pkg.keywords:
     - libc
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/0eb30d5e/libs/cmsis-core/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/cmsis-core/pkg.yml b/libs/cmsis-core/pkg.yml
index ed3928d..6370df6 100644
--- a/libs/cmsis-core/pkg.yml
+++ b/libs/cmsis-core/pkg.yml
@@ -19,8 +19,8 @@
 
 pkg.name: libs/cmsis-core
 pkg.description: CMSIS-CORE abstraction layer for Cortex-M processors.
-pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
-pkg.homepage: "http://mynewt.apache.org/"
+pkg.author: "Keil"
+pkg.homepage: "http://www.keil.com/pack/doc/CMSIS/Core/html/index.html"
 pkg.keywords:
     - cmsis
     - core

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/0eb30d5e/libs/mbedtls/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/mbedtls/pkg.yml b/libs/mbedtls/pkg.yml
index f1dd880..6d364b6 100644
--- a/libs/mbedtls/pkg.yml
+++ b/libs/mbedtls/pkg.yml
@@ -19,8 +19,8 @@
 
 pkg.name: libs/mbedtls
 pkg.description: SSL / TLS library for embedded systems.
-pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
-pkg.homepage: "http://mynewt.apache.org/"
+pkg.author: "ARM"
+pkg.homepage: "https://tls.mbed.org/"
 pkg.keywords:
     - ssl
     - tls


[27/42] incubator-mynewt-core git commit: The stack usage for task1, task2, shell and newtmgr tasks is 204, 196, 632 and 192 dwords respectively. Prior to this change the stack size for these tasks was 128, 128, 384 and 512 words respectively. It was eas

Posted by cc...@apache.org.
The stack usage for task1, task2, shell and newtmgr tasks is 204, 196, 632 and
192 dwords respectively. Prior to this change the stack size for these tasks
was 128, 128, 384 and 512 words respectively. It was easy to induce a segfault
on Linux by executing the "tasks" command at the shell prompt.

Bump up the stack sizes of task1, task2, shell and newtmgr tasks to 1024 dwords.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/66bad700
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/66bad700
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/66bad700

Branch: refs/heads/master
Commit: 66bad700e7fba9b54fa5b232adcfc451a53bed4b
Parents: 06bf5d1
Author: Neel Natu <ne...@nahannisys.com>
Authored: Thu Mar 10 22:41:25 2016 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Fri Mar 11 12:16:13 2016 -0800

----------------------------------------------------------------------
 apps/slinky/src/main.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/66bad700/apps/slinky/src/main.c
----------------------------------------------------------------------
diff --git a/apps/slinky/src/main.c b/apps/slinky/src/main.c
index edaad80..4534097 100755
--- a/apps/slinky/src/main.c
+++ b/apps/slinky/src/main.c
@@ -45,24 +45,24 @@ int init_tasks(void);
 
 /* Task 1 */
 #define TASK1_PRIO (1)
-#define TASK1_STACK_SIZE    OS_STACK_ALIGN(128)
+#define TASK1_STACK_SIZE    OS_STACK_ALIGN(1024)
 struct os_task task1;
 os_stack_t stack1[TASK1_STACK_SIZE];
 static volatile int g_task1_loops;
 
 /* Task 2 */
 #define TASK2_PRIO (2)
-#define TASK2_STACK_SIZE    OS_STACK_ALIGN(128)
+#define TASK2_STACK_SIZE    OS_STACK_ALIGN(1024)
 struct os_task task2;
 os_stack_t stack2[TASK2_STACK_SIZE];
 
 #define SHELL_TASK_PRIO (3)
 #define SHELL_MAX_INPUT_LEN     (256)
-#define SHELL_TASK_STACK_SIZE (OS_STACK_ALIGN(384))
+#define SHELL_TASK_STACK_SIZE (OS_STACK_ALIGN(1024))
 os_stack_t shell_stack[SHELL_TASK_STACK_SIZE];
 
 #define NEWTMGR_TASK_PRIO (4)
-#define NEWTMGR_TASK_STACK_SIZE (OS_STACK_ALIGN(512))
+#define NEWTMGR_TASK_STACK_SIZE (OS_STACK_ALIGN(1024))
 os_stack_t newtmgr_stack[NEWTMGR_TASK_STACK_SIZE];
 
 struct log_handler log_console_handler;


[06/42] incubator-mynewt-core git commit: Reflect repository name change in yml files. Types in packages. Move projects -> apps.

Posted by cc...@apache.org.
Reflect repository name change in yml files.
Types in packages.
Move projects -> apps.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/a601f78b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/a601f78b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/a601f78b

Branch: refs/heads/master
Commit: a601f78b38a1974979ede2fb843b2d60eeda01c9
Parents: 963ff4d
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Wed Mar 9 12:24:07 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Wed Mar 9 12:24:07 2016 -0800

----------------------------------------------------------------------
 app.yml                                         |   20 -
 apps/bleprph/src/bleprph.h                      |   43 +
 apps/bleprph/src/gatt_svr.c                     |  342 ++++
 apps/bleprph/src/main.c                         |  299 ++++
 apps/bletest/pkg.yml                            |   41 +
 apps/bletest/src/main.c                         |  969 ++++++++++++
 apps/bletiny/pkg.yml                            |   34 +
 apps/bletiny/src/bletiny_priv.h                 |  169 ++
 apps/bletiny/src/cmd.c                          | 1479 ++++++++++++++++++
 apps/bletiny/src/main.c                         | 1467 +++++++++++++++++
 apps/bletiny/src/parse.c                        |  435 ++++++
 apps/bletiny/src/periph.c                       |  344 ++++
 apps/blinky/pkg.yml                             |   36 +
 apps/blinky/src/main.c                          |  200 +++
 apps/boot/pkg.yml                               |   38 +
 apps/boot/src/boot.c                            |  110 ++
 apps/ffs2native/pkg.yml                         |   33 +
 apps/ffs2native/src/main.c                      |  366 +++++
 apps/luatest/pkg.yml                            |   33 +
 apps/luatest/src/main.c                         |  115 ++
 apps/slinky/pkg.yml                             |   41 +
 apps/slinky/src/main.c                          |  296 ++++
 apps/test/pkg.yml                               |   41 +
 apps/test/src/test.c                            |   44 +
 compiler/arm-none-eabi-m0/compiler.yml          |   33 +
 compiler/arm-none-eabi-m0/pkg.yml               |   18 +-
 compiler/arm-none-eabi-m4/compiler.yml          |   33 +
 compiler/arm-none-eabi-m4/pkg.yml               |   18 +-
 compiler/sim/compiler.yml                       |   32 +
 compiler/sim/linux-compiler.yml                 |   12 -
 compiler/sim/osx-compiler.yml                   |   12 -
 compiler/sim/pkg.yml                            |   17 +-
 fs/fs/pkg.yml                                   |    4 +-
 fs/nffs/pkg.yml                                 |    4 +-
 hw/bsp/native/native_debug.sh                   |    7 +-
 hw/bsp/native/pkg.yml                           |    4 +-
 hw/bsp/nrf51dk-16kbram/nrf51dk-16kbram_debug.sh |   11 +-
 .../nrf51dk-16kbram/nrf51dk-16kbram_download.sh |   12 +-
 hw/bsp/nrf51dk-16kbram/pkg.yml                  |    4 +-
 hw/bsp/nrf51dk/nrf51dk_debug.sh                 |   11 +-
 hw/bsp/nrf51dk/nrf51dk_download.sh              |   14 +-
 hw/bsp/nrf51dk/pkg.yml                          |    4 +-
 hw/bsp/nrf52pdk/nrf52pdk_debug.sh               |    9 +-
 hw/bsp/nrf52pdk/nrf52pdk_download.sh            |   11 +-
 hw/bsp/nrf52pdk/pkg.yml                         |    4 +-
 .../olimex_stm32-e407_devboard_debug.sh         |   11 +-
 .../olimex_stm32-e407_devboard_download.sh      |   17 +-
 hw/bsp/olimex_stm32-e407_devboard/pkg.yml       |    4 +-
 hw/hal/pkg.yml                                  |    2 +-
 hw/mcu/native/pkg.yml                           |    2 +-
 hw/mcu/nordic/nrf51xxx/pkg.yml                  |    2 +-
 hw/mcu/nordic/nrf52xxx/pkg.yml                  |    2 +-
 hw/mcu/stm/stm32f4xx/pkg.yml                    |    2 +-
 libs/baselibc/pkg.yml                           |    6 +-
 libs/bootutil/pkg.yml                           |    2 +-
 libs/cmsis-core/pkg.yml                         |    2 +-
 libs/console/full/pkg.yml                       |    4 +-
 libs/console/stub/pkg.yml                       |    4 +-
 libs/elua/elua_base/pkg.yml                     |    4 +-
 libs/flash_test/pkg.yml                         |    9 +-
 libs/imgmgr/pkg.yml                             |    2 +-
 libs/json/pkg.yml                               |    2 +-
 libs/mbedtls/pkg.yml                            |    2 +-
 libs/newtmgr/pkg.yml                            |    4 +-
 libs/os/pkg.yml                                 |    4 +-
 libs/shell/pkg.yml                              |    6 +-
 libs/testreport/pkg.yml                         |    2 +-
 libs/testutil/pkg.yml                           |    2 +-
 libs/util/pkg.yml                               |    2 +-
 net/nimble/controller/pkg.yml                   |    4 +-
 net/nimble/drivers/native/pkg.yml               |    4 +-
 net/nimble/drivers/nrf51/pkg.yml                |    4 +-
 net/nimble/drivers/nrf52/pkg.yml                |    4 +-
 net/nimble/host/pkg.yml                         |    4 +-
 net/nimble/pkg.yml                              |    2 +-
 pkg-list.yml                                    |   18 +-
 project.yml                                     |   26 +
 project/bleprph/src/bleprph.h                   |   43 -
 project/bleprph/src/gatt_svr.c                  |  342 ----
 project/bleprph/src/main.c                      |  299 ----
 project/bletest/pkg.yml                         |   40 -
 project/bletest/src/main.c                      |  969 ------------
 project/bletiny/pkg.yml                         |   33 -
 project/bletiny/src/bletiny_priv.h              |  169 --
 project/bletiny/src/cmd.c                       | 1479 ------------------
 project/bletiny/src/main.c                      | 1467 -----------------
 project/bletiny/src/parse.c                     |  435 ------
 project/bletiny/src/periph.c                    |  344 ----
 project/blinky/pkg.yml                          |   35 -
 project/blinky/src/main.c                       |  200 ---
 project/boot/pkg.yml                            |   37 -
 project/boot/src/boot.c                         |  110 --
 project/ffs2native/pkg.yml                      |   32 -
 project/ffs2native/src/main.c                   |  366 -----
 project/luatest/pkg.yml                         |   32 -
 project/luatest/src/main.c                      |  115 --
 project/slinky/pkg.yml                          |   40 -
 project/slinky/src/main.c                       |  296 ----
 project/test/pkg.yml                            |   40 -
 project/test/src/test.c                         |   44 -
 sys/config/pkg.yml                              |    4 +-
 sys/log/pkg.yml                                 |    4 +-
 sys/stats/pkg.yml                               |    4 +-
 103 files changed, 7245 insertions(+), 7168 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/app.yml
----------------------------------------------------------------------
diff --git a/app.yml b/app.yml
deleted file mode 100644
index 7e81eba..0000000
--- a/app.yml
+++ /dev/null
@@ -1,20 +0,0 @@
-#
-# 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.
-#
-
-app.name: "larva"

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/apps/bleprph/src/bleprph.h
----------------------------------------------------------------------
diff --git a/apps/bleprph/src/bleprph.h b/apps/bleprph/src/bleprph.h
new file mode 100644
index 0000000..e903fe0
--- /dev/null
+++ b/apps/bleprph/src/bleprph.h
@@ -0,0 +1,43 @@
+/**
+ * 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.
+ */
+
+#ifndef H_BLEPRPH_
+#define H_BLEPRPH_
+
+#include "log/log.h"
+
+void gatt_svr_init(void);
+
+extern struct log bleprph_log;
+
+extern const char *bleprph_device_name;
+extern const uint16_t bleprph_appearance;
+extern const uint8_t bleprph_privacy_flag;
+extern uint8_t bleprph_reconnect_addr[6];
+extern uint8_t bleprph_pref_conn_params[8];
+extern uint8_t bleprph_gatt_service_changed[4];
+
+/* bleprph uses the first "peruser" log module. */
+#define BLEPRPH_LOG_MODULE  (LOG_MODULE_PERUSER + 0)
+
+/* Convenience macro for logging to the bleprph module. */
+#define BLEPRPH_LOG(lvl, ...) \
+    LOG_ ## lvl(&bleprph_log, BLEPRPH_LOG_MODULE, __VA_ARGS__)
+
+#endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/apps/bleprph/src/gatt_svr.c
----------------------------------------------------------------------
diff --git a/apps/bleprph/src/gatt_svr.c b/apps/bleprph/src/gatt_svr.c
new file mode 100644
index 0000000..27a1433
--- /dev/null
+++ b/apps/bleprph/src/gatt_svr.c
@@ -0,0 +1,342 @@
+/**
+ * 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 "bsp/bsp.h"
+#include "console/console.h"
+#include "host/ble_hs.h"
+#include "bleprph.h"
+
+#define GATT_SVR_SVC_ALERT_UUID               0x1811
+#define GATT_SVR_CHR_SUP_NEW_ALERT_CAT_UUID   0x2A47
+#define GATT_SVR_CHR_NEW_ALERT                0x2A46
+#define GATT_SVR_CHR_SUP_UNR_ALERT_CAT_UUID   0x2A48
+#define GATT_SVR_CHR_UNR_ALERT_STAT_UUID      0x2A45
+#define GATT_SVR_CHR_ALERT_NOT_CTRL_PT        0x2A44
+
+static int
+gatt_svr_chr_access_gap(uint16_t conn_handle, uint16_t attr_handle, uint8_t op,
+                        union ble_gatt_access_ctxt *ctxt, void *arg);
+static int
+gatt_svr_chr_access_gatt(uint16_t conn_handle, uint16_t attr_handle, uint8_t op,
+                         union ble_gatt_access_ctxt *ctxt, void *arg);
+static int
+gatt_svr_chr_access_alert(uint16_t conn_handle, uint16_t attr_handle,
+                          uint8_t op, union ble_gatt_access_ctxt *ctxt,
+                          void *arg);
+
+static const struct ble_gatt_svc_def gatt_svr_svcs[] = {
+    {
+        /*** Service: GAP. */
+        .type = BLE_GATT_SVC_TYPE_PRIMARY,
+        .uuid128 = BLE_UUID16(BLE_GAP_SVC_UUID16),
+        .characteristics = (struct ble_gatt_chr_def[]) { {
+            /*** Characteristic: Device Name. */
+            .uuid128 = BLE_UUID16(BLE_GAP_CHR_UUID16_DEVICE_NAME),
+            .access_cb = gatt_svr_chr_access_gap,
+            .flags = BLE_GATT_CHR_F_READ,
+        }, {
+            /*** Characteristic: Appearance. */
+            .uuid128 = BLE_UUID16(BLE_GAP_CHR_UUID16_APPEARANCE),
+            .access_cb = gatt_svr_chr_access_gap,
+            .flags = BLE_GATT_CHR_F_READ,
+        }, {
+            /*** Characteristic: Peripheral Privacy Flag. */
+            .uuid128 = BLE_UUID16(BLE_GAP_CHR_UUID16_PERIPH_PRIV_FLAG),
+            .access_cb = gatt_svr_chr_access_gap,
+            .flags = BLE_GATT_CHR_F_READ,
+        }, {
+            /*** Characteristic: Reconnection Address. */
+            .uuid128 = BLE_UUID16(BLE_GAP_CHR_UUID16_RECONNECT_ADDR),
+            .access_cb = gatt_svr_chr_access_gap,
+            .flags = BLE_GATT_CHR_F_WRITE,
+        }, {
+            /*** Characteristic: Peripheral Preferred Connection Parameters. */
+            .uuid128 = BLE_UUID16(BLE_GAP_CHR_UUID16_PERIPH_PREF_CONN_PARAMS),
+            .access_cb = gatt_svr_chr_access_gap,
+            .flags = BLE_GATT_CHR_F_READ,
+        }, {
+            0, /* No more characteristics in this service. */
+        } },
+    },
+
+    {
+        /*** Service: GATT */
+        .type = BLE_GATT_SVC_TYPE_PRIMARY,
+        .uuid128 = BLE_UUID16(BLE_GATT_SVC_UUID16),
+        .characteristics = (struct ble_gatt_chr_def[]) { {
+            .uuid128 = BLE_UUID16(BLE_GATT_CHR_SERVICE_CHANGED_UUID16),
+            .access_cb = gatt_svr_chr_access_gatt,
+            .flags = BLE_GATT_CHR_F_INDICATE,
+        }, {
+            0, /* No more characteristics in this service. */
+        } },
+    },
+
+    {
+        /*** Alert Notification Service. */
+        .type = BLE_GATT_SVC_TYPE_PRIMARY,
+        .uuid128 = BLE_UUID16(GATT_SVR_SVC_ALERT_UUID),
+        .characteristics = (struct ble_gatt_chr_def[]) { {
+            .uuid128 = BLE_UUID16(GATT_SVR_CHR_SUP_NEW_ALERT_CAT_UUID),
+            .access_cb = gatt_svr_chr_access_alert,
+            .flags = BLE_GATT_CHR_F_READ,
+        }, {
+            .uuid128 = BLE_UUID16(GATT_SVR_CHR_NEW_ALERT),
+            .access_cb = gatt_svr_chr_access_alert,
+            .flags = BLE_GATT_CHR_F_NOTIFY,
+        }, {
+            .uuid128 = BLE_UUID16(GATT_SVR_CHR_SUP_UNR_ALERT_CAT_UUID),
+            .access_cb = gatt_svr_chr_access_alert,
+            .flags = BLE_GATT_CHR_F_READ,
+        }, {
+            .uuid128 = BLE_UUID16(GATT_SVR_CHR_UNR_ALERT_STAT_UUID),
+            .access_cb = gatt_svr_chr_access_alert,
+            .flags = BLE_GATT_CHR_F_NOTIFY,
+        }, {
+            .uuid128 = BLE_UUID16(GATT_SVR_CHR_ALERT_NOT_CTRL_PT),
+            .access_cb = gatt_svr_chr_access_alert,
+            .flags = BLE_GATT_CHR_F_WRITE,
+        }, {
+            0, /* No more characteristics in this service. */
+        } },
+    },
+
+    {
+        0, /* No more services. */
+    },
+};
+
+static int
+gatt_svr_chr_write(uint8_t op, union ble_gatt_access_ctxt *ctxt,
+                   uint16_t min_len, uint16_t max_len, void *dst,
+                   uint16_t *len)
+{
+    assert(op == BLE_GATT_ACCESS_OP_WRITE_CHR);
+    if (ctxt->chr_access.len < min_len ||
+        ctxt->chr_access.len > max_len) {
+        return BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN;
+    }
+    memcpy(dst, ctxt->chr_access.data, ctxt->chr_access.len);
+    if (len != NULL) {
+        *len = ctxt->chr_access.len;
+    }
+
+    return 0;
+}
+
+static int
+gatt_svr_chr_access_gap(uint16_t conn_handle, uint16_t attr_handle, uint8_t op,
+                        union ble_gatt_access_ctxt *ctxt, void *arg)
+{
+    uint16_t uuid16;
+
+    uuid16 = ble_uuid_128_to_16(ctxt->chr_access.chr->uuid128);
+    assert(uuid16 != 0);
+
+    switch (uuid16) {
+    case BLE_GAP_CHR_UUID16_DEVICE_NAME:
+        assert(op == BLE_GATT_ACCESS_OP_READ_CHR);
+        ctxt->chr_access.data = (void *)bleprph_device_name;
+        ctxt->chr_access.len = strlen(bleprph_device_name);
+        break;
+
+    case BLE_GAP_CHR_UUID16_APPEARANCE:
+        assert(op == BLE_GATT_ACCESS_OP_READ_CHR);
+        ctxt->chr_access.data = (void *)&bleprph_appearance;
+        ctxt->chr_access.len = sizeof bleprph_appearance;
+        break;
+
+    case BLE_GAP_CHR_UUID16_PERIPH_PRIV_FLAG:
+        assert(op == BLE_GATT_ACCESS_OP_READ_CHR);
+        ctxt->chr_access.data = (void *)&bleprph_privacy_flag;
+        ctxt->chr_access.len = sizeof bleprph_privacy_flag;
+        break;
+
+    case BLE_GAP_CHR_UUID16_RECONNECT_ADDR:
+        assert(op == BLE_GATT_ACCESS_OP_WRITE_CHR);
+        if (ctxt->chr_access.len != sizeof bleprph_reconnect_addr) {
+            return BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN;
+        }
+        memcpy(bleprph_reconnect_addr, ctxt->chr_access.data,
+               sizeof bleprph_reconnect_addr);
+        break;
+
+    case BLE_GAP_CHR_UUID16_PERIPH_PREF_CONN_PARAMS:
+        assert(op == BLE_GATT_ACCESS_OP_READ_CHR);
+        ctxt->chr_access.data = (void *)&bleprph_pref_conn_params;
+        ctxt->chr_access.len = sizeof bleprph_pref_conn_params;
+        break;
+
+    default:
+        assert(0);
+        break;
+    }
+
+    return 0;
+}
+
+static int
+gatt_svr_chr_access_gatt(uint16_t conn_handle, uint16_t attr_handle, uint8_t op,
+                         union ble_gatt_access_ctxt *ctxt, void *arg)
+{
+    uint16_t uuid16;
+
+    uuid16 = ble_uuid_128_to_16(ctxt->chr_access.chr->uuid128);
+    assert(uuid16 != 0);
+
+    switch (uuid16) {
+    case BLE_GATT_CHR_SERVICE_CHANGED_UUID16:
+        if (op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
+            if (ctxt->chr_access.len != sizeof bleprph_gatt_service_changed) {
+                return BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN;
+            }
+            memcpy(bleprph_gatt_service_changed, ctxt->chr_access.data,
+                   sizeof bleprph_gatt_service_changed);
+        } else if (op == BLE_GATT_ACCESS_OP_READ_CHR) {
+            ctxt->chr_access.data = (void *)&bleprph_gatt_service_changed;
+            ctxt->chr_access.len = sizeof bleprph_gatt_service_changed;
+        }
+        break;
+
+    default:
+        assert(0);
+        break;
+    }
+
+    return 0;
+}
+
+#define GATT_SVR_NEW_ALERT_VAL_MAX_LEN    64
+
+static const uint8_t gatt_svr_new_alert_cat = 0x01; /* Simple alert. */
+static uint8_t gatt_svr_new_alert_val[GATT_SVR_NEW_ALERT_VAL_MAX_LEN];
+static uint16_t gatt_svr_new_alert_val_len;
+static const uint8_t gatt_svr_unr_alert_cat = 0x01; /* Simple alert. */
+static uint16_t gatt_svr_unr_alert_stat;
+static uint16_t gatt_svr_alert_not_ctrl_pt;
+
+static int
+gatt_svr_chr_access_alert(uint16_t conn_handle, uint16_t attr_handle,
+                          uint8_t op, union ble_gatt_access_ctxt *ctxt,
+                          void *arg)
+{
+    uint16_t uuid16;
+    int rc;
+
+    uuid16 = ble_uuid_128_to_16(ctxt->chr_access.chr->uuid128);
+    assert(uuid16 != 0);
+
+    switch (uuid16) {
+    case GATT_SVR_CHR_SUP_NEW_ALERT_CAT_UUID:
+        assert(op == BLE_GATT_ACCESS_OP_READ_CHR);
+        ctxt->chr_access.data = (void *)&gatt_svr_new_alert_cat;
+        ctxt->chr_access.len = sizeof gatt_svr_new_alert_cat;
+        return 0;
+
+    case GATT_SVR_CHR_NEW_ALERT:
+        if (op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
+            rc = gatt_svr_chr_write(op, ctxt, 0, sizeof gatt_svr_new_alert_val,
+                                  gatt_svr_new_alert_val,
+                                  &gatt_svr_new_alert_val_len);
+            return rc;
+        } else if (op == BLE_GATT_ACCESS_OP_READ_CHR) {
+            ctxt->chr_access.data = (void *)&gatt_svr_new_alert_val;
+            ctxt->chr_access.len = sizeof gatt_svr_new_alert_val;
+            return 0;
+        }
+
+    case GATT_SVR_CHR_SUP_UNR_ALERT_CAT_UUID:
+        assert(op == BLE_GATT_ACCESS_OP_READ_CHR);
+        ctxt->chr_access.data = (void *)&gatt_svr_unr_alert_cat;
+        ctxt->chr_access.len = sizeof gatt_svr_unr_alert_cat;
+        return 0;
+
+    case GATT_SVR_CHR_UNR_ALERT_STAT_UUID:
+        if (op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
+            rc = gatt_svr_chr_write(op, ctxt, 2, 2, &gatt_svr_unr_alert_stat,
+                                    NULL);
+        } else {
+            ctxt->chr_access.data = (void *)&gatt_svr_unr_alert_stat;
+            ctxt->chr_access.len = sizeof gatt_svr_unr_alert_stat;
+            rc = 0;
+        }
+        return rc;
+
+    case GATT_SVR_CHR_ALERT_NOT_CTRL_PT:
+        if (op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
+            rc = gatt_svr_chr_write(op, ctxt, 2, 2,
+                                    &gatt_svr_alert_not_ctrl_pt, NULL);
+        } else {
+            rc = BLE_ATT_ERR_UNLIKELY;
+        }
+        return rc;
+
+    default:
+        assert(0);
+        return BLE_ATT_ERR_UNLIKELY;
+    }
+}
+
+static void
+gatt_svr_register_cb(uint8_t op, union ble_gatt_register_ctxt *ctxt, void *arg)
+{
+    uint16_t uuid16;
+
+    switch (op) {
+    case BLE_GATT_REGISTER_OP_SVC:
+        uuid16 = ble_uuid_128_to_16(ctxt->svc_reg.svc->uuid128);
+        assert(uuid16 != 0);
+        BLEPRPH_LOG(DEBUG, "registered service 0x%04x with handle=%d\n",
+                    uuid16, ctxt->svc_reg.handle);
+        break;
+
+    case BLE_GATT_REGISTER_OP_CHR:
+        uuid16 = ble_uuid_128_to_16(ctxt->chr_reg.chr->uuid128);
+        assert(uuid16 != 0);
+        BLEPRPH_LOG(DEBUG, "registering characteristic 0x%04x with "
+                           "def_handle=%d val_handle=%d\n",
+                    uuid16, ctxt->chr_reg.def_handle,
+                    ctxt->chr_reg.val_handle);
+        break;
+
+    case BLE_GATT_REGISTER_OP_DSC:
+        uuid16 = ble_uuid_128_to_16(ctxt->dsc_reg.dsc->uuid128);
+        assert(uuid16 != 0);
+        BLEPRPH_LOG(DEBUG, "registering descriptor 0x%04x with handle=%d "
+                           "chr_handle=%d\n",
+                    uuid16, ctxt->dsc_reg.dsc_handle,
+                    ctxt->dsc_reg.chr_def_handle);
+        break;
+
+    default:
+        assert(0);
+        break;
+    }
+}
+
+void
+gatt_svr_init(void)
+{
+    int rc;
+
+    rc = ble_gatts_register_svcs(gatt_svr_svcs, gatt_svr_register_cb, NULL);
+    assert(rc == 0);
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/apps/bleprph/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bleprph/src/main.c b/apps/bleprph/src/main.c
new file mode 100755
index 0000000..8824428
--- /dev/null
+++ b/apps/bleprph/src/main.c
@@ -0,0 +1,299 @@
+/**
+ * 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 "bsp/bsp.h"
+#include "os/os.h"
+#include "bsp/bsp.h"
+#include "hal/hal_gpio.h"
+#include "hal/hal_cputime.h"
+#include "console/console.h"
+
+/* BLE */
+#include "nimble/ble.h"
+#include "host/host_hci.h"
+#include "host/ble_hs.h"
+#include "host/ble_hs_adv.h"
+#include "host/ble_uuid.h"
+#include "host/ble_att.h"
+#include "host/ble_gap.h"
+#include "host/ble_gatt.h"
+#include "controller/ble_ll.h"
+
+#include "bleprph.h"
+
+#define BSWAP16(x)  ((uint16_t)(((x) << 8) | (((x) & 0xff00) >> 8)))
+
+/** Mbuf settings. */
+#define MBUF_NUM_MBUFS      (8)
+#define MBUF_BUF_SIZE       OS_ALIGN(BLE_MBUF_PAYLOAD_SIZE, 4)
+#define MBUF_MEMBLOCK_SIZE  (MBUF_BUF_SIZE + BLE_MBUF_MEMBLOCK_OVERHEAD)
+#define MBUF_MEMPOOL_SIZE   OS_MEMPOOL_SIZE(MBUF_NUM_MBUFS, MBUF_MEMBLOCK_SIZE)
+
+static os_membuf_t bleprph_mbuf_mpool_data[MBUF_MEMPOOL_SIZE];
+struct os_mbuf_pool bleprph_mbuf_pool;
+struct os_mempool bleprph_mbuf_mpool;
+
+/** Log data. */
+static struct log_handler bleprph_log_console_handler;
+struct log bleprph_log;
+
+/** Priority of the nimble host task. */
+#define BLEPRPH_BLE_HS_PRIO          (1)
+
+/** bleprph task settings. */
+#define BLEPRPH_STACK_SIZE             (OS_STACK_ALIGN(200))
+#define BLEPRPH_TASK_PRIO              (BLEPRPH_BLE_HS_PRIO + 1)
+
+struct os_eventq bleprph_evq;
+struct os_task bleprph_task;
+bssnz_t os_stack_t bleprph_stack[BLEPRPH_STACK_SIZE];
+
+/** Our global device address (public) */
+uint8_t g_dev_addr[BLE_DEV_ADDR_LEN] = {0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a};
+
+/** Our random address (in case we need it) */
+uint8_t g_random_addr[BLE_DEV_ADDR_LEN];
+
+/** Device name - included in advertisements and exposed by GAP service. */
+const char *bleprph_device_name = "nimble-bleprph";
+
+/** Device properties - exposed by GAP service. */
+const uint16_t bleprph_appearance = BSWAP16(BLE_GAP_APPEARANCE_GEN_COMPUTER);
+const uint8_t bleprph_privacy_flag = 0;
+uint8_t bleprph_reconnect_addr[6];
+uint8_t bleprph_pref_conn_params[8];
+uint8_t bleprph_gatt_service_changed[4];
+
+static int bleprph_on_connect(int event, int status,
+                              struct ble_gap_conn_ctxt *ctxt, void *arg);
+
+/**
+ * Utility function to log an array of bytes.
+ */
+static void
+bleprph_print_bytes(uint8_t *bytes, int len)
+{
+    int i;
+
+    for (i = 0; i < len; i++) {
+        BLEPRPH_LOG(INFO, "%s0x%02x", i != 0 ? ":" : "", bytes[i]);
+    }
+}
+
+/**
+ * Logs information about a connection to the console.
+ */
+static void
+bleprph_print_conn_desc(struct ble_gap_conn_desc *desc)
+{
+    BLEPRPH_LOG(INFO, "handle=%d peer_addr_type=%d peer_addr=",
+                desc->conn_handle, desc->peer_addr_type);
+    bleprph_print_bytes(desc->peer_addr, 6);
+    BLEPRPH_LOG(INFO, " conn_itvl=%d conn_latency=%d supervision_timeout=%d",
+                desc->conn_itvl, desc->conn_latency,
+                desc->supervision_timeout);
+}
+
+/**
+ * Enables advertising with the following parameters:
+ *     o General discoverable mode.
+ *     o Undirected connectable mode.
+ */
+static void
+bleprph_advertise(void)
+{
+    struct ble_hs_adv_fields fields;
+    int rc;
+
+    /* Set the advertisement data included in our advertisements. */
+    memset(&fields, 0, sizeof fields);
+    fields.name = (uint8_t *)bleprph_device_name;
+    fields.name_len = strlen(bleprph_device_name);
+    fields.name_is_complete = 1;
+    rc = ble_gap_adv_set_fields(&fields);
+    if (rc != 0) {
+        BLEPRPH_LOG(ERROR, "error setting advertisement data; rc=%d\n", rc);
+        return;
+    }
+
+    /* Begin advertising. */
+    rc = ble_gap_adv_start(BLE_GAP_DISC_MODE_GEN, BLE_GAP_CONN_MODE_UND,
+                           NULL, 0, NULL, bleprph_on_connect, NULL);
+    if (rc != 0) {
+        BLEPRPH_LOG(ERROR, "error enabling advertisement; rc=%d\n", rc);
+        return;
+    }
+}
+
+static int
+bleprph_on_connect(int event, int status, struct ble_gap_conn_ctxt *ctxt,
+                   void *arg)
+{
+    switch (event) {
+    case BLE_GAP_EVENT_CONN:
+        BLEPRPH_LOG(INFO, "connection %s; status=%d ",
+                    status == 0 ? "up" : "down", status);
+        bleprph_print_conn_desc(ctxt->desc);
+        BLEPRPH_LOG(INFO, "\n");
+
+        if (status != 0) {
+            /* Connection terminated; resume advertising. */
+            bleprph_advertise();
+        }
+        break;
+
+    case BLE_GAP_EVENT_CONN_UPDATED:
+        BLEPRPH_LOG(INFO, "connection updated; status=%d ", status);
+        bleprph_print_conn_desc(ctxt->desc);
+        BLEPRPH_LOG(INFO, "\n");
+        break;
+
+    case BLE_GAP_EVENT_CONN_UPDATE_REQ:
+        BLEPRPH_LOG(INFO, "connection update request; status=%d ", status);
+        *ctxt->self_params = *ctxt->peer_params;
+        break;
+    }
+
+    return 0;
+}
+
+/**
+ * Event loop for the main bleprph task.
+ */
+static void
+bleprph_task_handler(void *unused)
+{
+    struct os_event *ev;
+    struct os_callout_func *cf;
+
+    /* Register GATT attributes (services, characteristics, and
+     * descriptors).
+     */
+    gatt_svr_init();
+
+    /* Initialize eventq */
+    os_eventq_init(&bleprph_evq);
+
+    /* Begin advertising. */
+    bleprph_advertise();
+
+    while (1) {
+        ev = os_eventq_get(&bleprph_evq);
+        switch (ev->ev_type) {
+        case OS_EVENT_T_TIMER:
+            cf = (struct os_callout_func *)ev;
+            assert(cf->cf_func);
+            cf->cf_func(cf->cf_arg);
+            break;
+        default:
+            assert(0);
+            break;
+        }
+    }
+}
+
+/**
+ * main
+ *
+ * The main function for the project. This function initializes the os, calls
+ * init_tasks to initialize tasks (and possibly other objects), then starts the
+ * OS. We should not return from os start.
+ *
+ * @return int NOTE: this function should never return!
+ */
+int
+main(void)
+{
+    struct ble_hs_cfg cfg;
+    uint32_t seed;
+    int rc;
+    int i;
+
+    /* Initialize OS */
+    os_init();
+
+    /* Set cputime to count at 1 usec increments */
+    rc = cputime_init(1000000);
+    assert(rc == 0);
+
+    /* Seed random number generator with least significant bytes of device
+     * address.
+     */
+    seed = 0;
+    for (i = 0; i < 4; ++i) {
+        seed |= g_dev_addr[i];
+        seed <<= 8;
+    }
+    srand(seed);
+
+    /* Initialize msys mbufs. */
+    rc = os_mempool_init(&bleprph_mbuf_mpool, MBUF_NUM_MBUFS, 
+                         MBUF_MEMBLOCK_SIZE, bleprph_mbuf_mpool_data, 
+                         "bleprph_mbuf_data");
+    assert(rc == 0);
+
+    rc = os_mbuf_pool_init(&bleprph_mbuf_pool, &bleprph_mbuf_mpool,
+                           MBUF_MEMBLOCK_SIZE, MBUF_NUM_MBUFS);
+    assert(rc == 0);
+
+    rc = os_msys_register(&bleprph_mbuf_pool);
+    assert(rc == 0);
+
+    /* Initialize the logging system. */
+    log_init();
+    log_console_handler_init(&bleprph_log_console_handler);
+    log_register("bleprph", &bleprph_log, &bleprph_log_console_handler);
+
+    os_task_init(&bleprph_task, "bleprph", bleprph_task_handler,
+                 NULL, BLEPRPH_TASK_PRIO, OS_WAIT_FOREVER,
+                 bleprph_stack, BLEPRPH_STACK_SIZE);
+
+    /* Initialize the BLE LL */
+    rc = ble_ll_init();
+    assert(rc == 0);
+
+    /* Initialize the BLE host. */
+    cfg = ble_hs_cfg_dflt;
+    cfg.max_hci_bufs = 3;
+    cfg.max_connections = 1;
+    cfg.max_attrs = 32;
+    cfg.max_services = 4;
+    cfg.max_client_configs = 6;
+    cfg.max_gattc_procs = 2;
+    cfg.max_l2cap_chans = 3;
+    cfg.max_l2cap_sig_procs = 2;
+
+    rc = ble_hs_init(BLEPRPH_BLE_HS_PRIO, &cfg);
+    assert(rc == 0);
+
+    /* Initialize the console (for log output). */
+    rc = console_init(NULL);
+    assert(rc == 0);
+
+    /* Start the OS */
+    os_start();
+
+    /* os start should never return. If it does, this should be an error */
+    assert(0);
+
+    return 0;
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/apps/bletest/pkg.yml
----------------------------------------------------------------------
diff --git a/apps/bletest/pkg.yml b/apps/bletest/pkg.yml
new file mode 100644
index 0000000..b7e098b
--- /dev/null
+++ b/apps/bletest/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/bletest
+pkg.vers: 0.8.0
+pkg.description: Test project for the nimble BLE controller.
+pkg.author: wes3 <wi...@runtime.io>
+pkg.homepage:
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.type: app
+pkg.keywords:
+
+pkg.deps: 
+    - net/nimble/controller
+    - net/nimble/host
+    - libs/os 
+    - libs/console/full
+    - libs/baselibc
+    - libs/shell
+    - libs/imgmgr
+    - libs/newtmgr
+    - sys/config
+    - sys/log
+    - sys/stats
+pkg.cflags: -DBLETEST

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/apps/bletest/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bletest/src/main.c b/apps/bletest/src/main.c
new file mode 100755
index 0000000..d004aa9
--- /dev/null
+++ b/apps/bletest/src/main.c
@@ -0,0 +1,969 @@
+/**
+ * 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 "os/os.h"
+#include "bsp/bsp.h"
+#include "hal/hal_gpio.h"
+#include "hal/hal_cputime.h"
+#include "hal/hal_flash.h"
+#include "console/console.h"
+#include "shell/shell.h"
+#include "stats/stats.h"
+#include "hal/flash_map.h"
+#include "fs/fs.h"
+#include "nffs/nffs.h"
+#include "newtmgr/newtmgr.h"
+#include "imgmgr/imgmgr.h"
+
+/* BLE */
+#include "nimble/ble.h"
+#include "nimble/hci_transport.h"
+#include "nimble/hci_common.h"
+#include "host/host_hci.h"
+#include "host/ble_hs.h"
+#include "controller/ble_ll.h"
+#include "controller/ble_ll_hci.h"
+#include "controller/ble_ll_conn.h"
+#include "controller/ble_ll_scan.h"
+#include "controller/ble_ll_adv.h"
+
+/* Task priorities */
+/* NOTE: highest priority task (0) reserved for controller LL task */
+#define HOST_TASK_PRIO      (OS_TASK_PRI_HIGHEST + 1)
+#define BLETEST_TASK_PRIO   (HOST_TASK_PRIO + 1)
+#define SHELL_TASK_PRIO     (BLETEST_TASK_PRIO + 1)
+#define NEWTMGR_TASK_PRIO   (SHELL_TASK_PRIO + 1)
+
+/* Shell task stack */
+#define SHELL_TASK_STACK_SIZE (OS_STACK_ALIGN(256))
+os_stack_t shell_stack[SHELL_TASK_STACK_SIZE];
+
+/* Newt manager task stack */
+#define NEWTMGR_TASK_STACK_SIZE (OS_STACK_ALIGN(448))
+os_stack_t newtmgr_stack[NEWTMGR_TASK_STACK_SIZE];
+
+/* Shell maximum input line length */
+#define SHELL_MAX_INPUT_LEN     (256)
+
+/* For LED toggling */
+int g_led_pin;
+
+/* Our global device address (public) */
+uint8_t g_dev_addr[BLE_DEV_ADDR_LEN];
+
+/* Our random address (in case we need it) */
+uint8_t g_random_addr[BLE_DEV_ADDR_LEN];
+
+/* A buffer for host advertising data */
+uint8_t g_host_adv_data[BLE_HCI_MAX_ADV_DATA_LEN];
+uint8_t g_host_adv_len;
+
+/* Create a mbuf pool of BLE mbufs */
+#define MBUF_NUM_MBUFS      (42)
+#define MBUF_BUF_SIZE       OS_ALIGN(BLE_MBUF_PAYLOAD_SIZE, 4)
+#define MBUF_MEMBLOCK_SIZE  (MBUF_BUF_SIZE + BLE_MBUF_MEMBLOCK_OVERHEAD)
+#define MBUF_MEMPOOL_SIZE   OS_MEMPOOL_SIZE(MBUF_NUM_MBUFS, MBUF_MEMBLOCK_SIZE)
+
+struct os_mbuf_pool g_mbuf_pool; 
+struct os_mempool g_mbuf_mempool;
+os_membuf_t g_mbuf_buffer[MBUF_MEMPOOL_SIZE];
+
+/* Some application configurations */
+#define BLETEST_ROLE_ADVERTISER         (0)
+#define BLETEST_ROLE_SCANNER            (1)
+#define BLETEST_ROLE_INITIATOR          (2)
+#define BLETEST_CFG_ROLE                (BLETEST_ROLE_INITIATOR)
+//#define BLETEST_CFG_ROLE                (BLETEST_ROLE_ADVERTISER)
+//#define BLETEST_CFG_ROLE                (BLETEST_ROLE_SCANNER)
+#define BLETEST_CFG_ADV_OWN_ADDR_TYPE   (BLE_HCI_ADV_OWN_ADDR_PUBLIC)
+#define BLETEST_CFG_ADV_PEER_ADDR_TYPE  (BLE_HCI_ADV_PEER_ADDR_PUBLIC)
+#define BLETEST_CFG_FILT_DUP_ADV        (0)
+#define BLETEST_CFG_ADV_ITVL            (600000 / BLE_HCI_ADV_ITVL)
+#define BLETEST_CFG_ADV_TYPE            BLE_HCI_ADV_TYPE_ADV_IND
+#define BLETEST_CFG_ADV_FILT_POLICY     (BLE_HCI_ADV_FILT_NONE)
+#define BLETEST_CFG_SCAN_ITVL           (700000 / BLE_HCI_SCAN_ITVL)
+#define BLETEST_CFG_SCAN_WINDOW         (700000 / BLE_HCI_SCAN_ITVL)
+#define BLETEST_CFG_SCAN_TYPE           (BLE_HCI_SCAN_TYPE_ACTIVE)
+#define BLETEST_CFG_SCAN_FILT_POLICY    (BLE_HCI_SCAN_FILT_NO_WL)
+#define BLETEST_CFG_CONN_ITVL           (128)  /* in 1.25 msec increments */           
+#define BLETEST_CFG_SLAVE_LATENCY       (0)
+#define BLETEST_CFG_INIT_FILTER_POLICY  (BLE_HCI_CONN_FILT_NO_WL)
+#define BLETEST_CFG_CONN_SPVN_TMO       (1000)  /* 20 seconds */
+#define BLETEST_CFG_MIN_CE_LEN          (6)    
+#define BLETEST_CFG_MAX_CE_LEN          (BLETEST_CFG_CONN_ITVL)
+#define BLETEST_CFG_CONN_PEER_ADDR_TYPE (BLE_HCI_CONN_PEER_ADDR_PUBLIC)
+#define BLETEST_CFG_CONN_OWN_ADDR_TYPE  (BLE_HCI_ADV_OWN_ADDR_RANDOM)
+#define BLETEST_CFG_CONCURRENT_CONNS    (1)
+
+/* BLETEST variables */
+#undef BLETEST_ADV_PKT_NUM
+#define BLETEST_PKT_SIZE                (251)
+#define BLETEST_STACK_SIZE              (256)
+uint32_t g_next_os_time;
+int g_bletest_state;
+struct os_eventq g_bletest_evq;
+struct os_callout_func g_bletest_timer;
+struct os_task bletest_task;
+bssnz_t os_stack_t bletest_stack[BLETEST_STACK_SIZE];
+uint32_t g_bletest_conn_end;
+int g_bletest_start_update;
+uint32_t g_bletest_conn_upd_time;
+uint8_t g_bletest_current_conns;
+uint8_t g_bletest_cur_peer_addr[BLE_DEV_ADDR_LEN];
+uint8_t g_last_handle_used;
+uint8_t g_bletest_led_state;
+uint32_t g_bletest_led_rate;
+uint32_t g_bletest_next_led_time;
+
+#ifdef BLETEST_ADV_PKT_NUM
+void
+bletest_inc_adv_pkt_num(void)
+{
+    int rc;
+    uint8_t *dptr;
+    uint8_t digit;
+
+    if (g_host_adv_len != 0) {
+        dptr = &g_host_adv_data[18];
+        while (dptr >= &g_host_adv_data[13]) {
+            digit = *dptr;
+            ++digit;
+            if (digit == 58) {
+                digit = 48;
+                *dptr = digit;
+                --dptr;
+            } else {
+                *dptr = digit;
+                break;
+            }
+        }
+
+        rc = host_hci_cmd_le_set_adv_data(g_host_adv_data, g_host_adv_len);
+        assert(rc == 0);
+        host_hci_outstanding_opcode = 0;
+    }
+}
+#endif
+
+void
+bletest_send_conn_update(uint16_t handle)
+{
+    int rc;
+    struct hci_conn_update hcu;
+
+    hcu.conn_latency = 4;
+    hcu.supervision_timeout = 2000; 
+    hcu.conn_itvl_min = 1000;
+    hcu.conn_itvl_max = 1000;
+    hcu.handle = handle;
+    hcu.min_ce_len = 4;
+    hcu.max_ce_len = 4;
+
+    rc = host_hci_cmd_le_conn_update(&hcu);
+    assert(rc == 0);
+    host_hci_outstanding_opcode = 0;
+}
+
+/**
+ * Sets the advertising data to be sent in advertising pdu's which contain
+ * advertising data.
+ *
+ * @param dptr
+ * @return uint8_t
+ */
+uint8_t
+bletest_set_adv_data(uint8_t *dptr)
+{
+    uint8_t len;
+
+    /* Place flags in first */
+    dptr[0] = 2;
+    dptr[1] = 0x01;     /* Flags identifier */
+    dptr[2] = 0x06;
+    dptr += 3;
+    len = 3;
+
+    /* Add local name */
+    dptr[0] = 15;   /* Length of this data, not including the length */
+    dptr[1] = 0x09;
+    dptr[2] = 'r';
+    dptr[3] = 'u';
+    dptr[4] = 'n';
+    dptr[5] = 't';
+    dptr[6] = 'i';
+    dptr[7] = 'm';
+    dptr[8] = 'e';
+    dptr[9] = '-';
+    dptr[10] = '0';
+    dptr[11] = '0';
+    dptr[12] = '0';
+    dptr[13] = '0';
+    dptr[14] = '0';
+    dptr[15] = '0';
+    dptr += 16;
+    len += 16;
+
+    /* Add local device address */
+    dptr[0] = 0x08;
+    dptr[1] = 0x1B;
+    dptr[2] = 0x00;
+    memcpy(dptr + 3, g_dev_addr, BLE_DEV_ADDR_LEN);
+    len += 9;
+
+    g_host_adv_len = len;
+
+    return len;
+}
+
+#if (BLETEST_CFG_ROLE == BLETEST_ROLE_ADVERTISER)
+void
+bletest_init_advertising(void)
+{
+    int rc;
+    uint8_t adv_len;
+    uint8_t rand_addr[BLE_DEV_ADDR_LEN];
+    struct hci_adv_params adv;
+
+    /* Just zero out advertising */
+    memset(&adv, 0, sizeof(struct hci_adv_params));
+
+    /* Set advertising parameters */
+    adv.adv_type = BLETEST_CFG_ADV_TYPE;
+    adv.adv_channel_map = 0x07;
+    adv.adv_filter_policy = BLETEST_CFG_ADV_FILT_POLICY;
+    adv.own_addr_type = BLETEST_CFG_ADV_OWN_ADDR_TYPE;
+    adv.peer_addr_type = BLETEST_CFG_ADV_PEER_ADDR_TYPE;
+    if ((adv.adv_type == BLE_HCI_ADV_TYPE_ADV_DIRECT_IND_HD) ||
+        (adv.adv_type == BLE_HCI_ADV_TYPE_ADV_DIRECT_IND_LD)) {
+        memcpy(adv.peer_addr, g_bletest_cur_peer_addr, BLE_DEV_ADDR_LEN);
+        if (adv.peer_addr_type == BLE_HCI_ADV_PEER_ADDR_RANDOM) {
+            adv.peer_addr[5] |= 0xc0;
+        }
+        adv_len = 0;
+    } else {
+        adv_len = bletest_set_adv_data(&g_host_adv_data[0]);
+    }
+
+    console_printf("Trying to connect to %x.%x.%x.%x.%x.%x\n",
+                   adv.peer_addr[0], adv.peer_addr[1], adv.peer_addr[2],
+                   adv.peer_addr[3], adv.peer_addr[4], adv.peer_addr[5]);
+
+    if (adv.adv_type == BLE_HCI_ADV_TYPE_ADV_DIRECT_IND_HD) {
+        adv.adv_itvl_min = 0;
+        adv.adv_itvl_max = 0;
+    } else {
+        adv.adv_itvl_min = BLETEST_CFG_ADV_ITVL;
+        adv.adv_itvl_max = BLETEST_CFG_ADV_ITVL; /* Advertising interval */
+    }
+
+    /* Set the advertising parameters */
+    rc = host_hci_cmd_le_set_adv_params(&adv);
+    assert(rc == 0);
+    host_hci_outstanding_opcode = 0;
+
+    /* If we are using a random address, we need to set it */
+    if (adv.own_addr_type == BLE_HCI_ADV_OWN_ADDR_RANDOM) {
+        memcpy(rand_addr, g_dev_addr, BLE_DEV_ADDR_LEN);
+        rand_addr[5] |= 0xc0;
+        rc = host_hci_cmd_le_set_rand_addr(rand_addr);
+        assert(rc == 0);
+        host_hci_outstanding_opcode = 0;
+    }
+
+    /* Set advertising data */
+    if (adv_len != 0) {
+        rc = host_hci_cmd_le_set_adv_data(&g_host_adv_data[0], adv_len);
+        assert(rc == 0);
+        host_hci_outstanding_opcode = 0;
+
+        /* Set scan response data */
+        rc = host_hci_cmd_le_set_scan_rsp_data(&g_host_adv_data[0], adv_len);
+        assert(rc == 0);
+        host_hci_outstanding_opcode = 0;
+    }
+}
+#endif
+
+#if (BLETEST_CFG_ROLE == BLETEST_ROLE_SCANNER)
+void
+bletest_init_scanner(void)
+{
+    int rc;
+    uint8_t dev_addr[BLE_DEV_ADDR_LEN];
+    uint8_t filter_policy;
+
+    /* Set scanning parameters */
+    rc = host_hci_cmd_le_set_scan_params(BLETEST_CFG_SCAN_TYPE,
+                                         BLETEST_CFG_SCAN_ITVL,
+                                         BLETEST_CFG_SCAN_WINDOW,
+                                         BLE_HCI_ADV_OWN_ADDR_PUBLIC,
+                                         BLETEST_CFG_SCAN_FILT_POLICY);
+    assert(rc == 0);
+    host_hci_outstanding_opcode = 0;
+
+    filter_policy = BLETEST_CFG_SCAN_FILT_POLICY;
+    if (filter_policy & 1) {
+        /* Add some whitelist addresses */
+        dev_addr[0] = 0x00;
+        dev_addr[1] = 0x00;
+        dev_addr[2] = 0x00;
+        dev_addr[3] = 0x88;
+        dev_addr[4] = 0x88;
+        dev_addr[5] = 0x08;
+        rc = host_hci_cmd_le_add_to_whitelist(dev_addr, BLE_ADDR_TYPE_PUBLIC);
+        assert(rc == 0);
+        host_hci_outstanding_opcode = 0;
+    }
+}
+
+void
+bletest_execute_scanner(void)
+{
+    int rc;
+
+    /* Enable scanning */
+    if ((int32_t)(os_time_get() - g_next_os_time) >= 0) {
+        if (g_bletest_state) {
+            rc = host_hci_cmd_le_set_scan_enable(0, BLETEST_CFG_FILT_DUP_ADV);
+            assert(rc == 0);
+            host_hci_outstanding_opcode = 0;
+            g_bletest_state = 0;
+        } else {
+            rc = host_hci_cmd_le_set_scan_enable(1, BLETEST_CFG_FILT_DUP_ADV);
+            assert(rc == 0);
+            host_hci_outstanding_opcode = 0;
+            g_bletest_state = 1;
+        }
+        g_next_os_time += (OS_TICKS_PER_SEC * 60);
+    }
+}
+#endif
+
+#if (BLETEST_CFG_ROLE == BLETEST_ROLE_INITIATOR)
+void
+bletest_init_initiator(void)
+{
+    int rc;
+    uint8_t rand_addr[BLE_DEV_ADDR_LEN];
+    struct hci_create_conn cc;
+    struct hci_create_conn *hcc;
+
+    /* Enable initiating */
+    hcc = &cc;
+    hcc->conn_itvl_max = BLETEST_CFG_CONN_ITVL;
+    hcc->conn_itvl_min = BLETEST_CFG_CONN_ITVL;
+    hcc->conn_latency = BLETEST_CFG_SLAVE_LATENCY;
+    hcc->filter_policy = BLETEST_CFG_INIT_FILTER_POLICY;
+    hcc->supervision_timeout = BLETEST_CFG_CONN_SPVN_TMO;
+    hcc->scan_itvl = BLETEST_CFG_SCAN_ITVL;
+    hcc->scan_window = BLETEST_CFG_SCAN_WINDOW;
+    hcc->peer_addr_type = BLETEST_CFG_CONN_PEER_ADDR_TYPE;
+    memcpy(hcc->peer_addr, g_bletest_cur_peer_addr, BLE_DEV_ADDR_LEN);
+    if (hcc->peer_addr_type == BLE_HCI_CONN_PEER_ADDR_RANDOM) {
+        hcc->peer_addr[5] |= 0xc0;
+    }
+    hcc->own_addr_type = BLETEST_CFG_CONN_OWN_ADDR_TYPE;
+    hcc->min_ce_len = BLETEST_CFG_MIN_CE_LEN;
+    hcc->max_ce_len = BLETEST_CFG_MAX_CE_LEN;
+
+    console_printf("Trying to connect to %x.%x.%x.%x.%x.%x\n",
+                   hcc->peer_addr[0], hcc->peer_addr[1], hcc->peer_addr[2],
+                   hcc->peer_addr[3], hcc->peer_addr[4], hcc->peer_addr[5]);
+
+    /* If we are using a random address, we need to set it */
+    if (hcc->own_addr_type == BLE_HCI_ADV_OWN_ADDR_RANDOM) {
+        memcpy(rand_addr, g_dev_addr, BLE_DEV_ADDR_LEN);
+        rand_addr[5] |= 0xc0;
+        rc = host_hci_cmd_le_set_rand_addr(rand_addr);
+        assert(rc == 0);
+        host_hci_outstanding_opcode = 0;
+    }
+
+    rc = host_hci_cmd_le_create_connection(hcc);
+    assert(rc == 0);
+    host_hci_outstanding_opcode = 0;
+}
+
+void
+bletest_execute_initiator(void)
+{
+    int i;
+    int rc;
+    uint16_t handle;
+    uint8_t new_chan_map[5];
+
+    /* 
+     * Determine if there is an active connection for the current handle
+     * we are trying to create. If so, start looking for the next one
+     */
+    if (g_bletest_current_conns < BLETEST_CFG_CONCURRENT_CONNS) {
+        handle = g_bletest_current_conns + 1;
+        if (ble_ll_conn_find_active_conn(handle)) {
+            /* Set LED to slower blink rate */
+            g_bletest_led_rate = OS_TICKS_PER_SEC;
+
+            /* Ask for version information */
+            rc = host_hci_cmd_rd_rem_version(handle);
+            host_hci_outstanding_opcode = 0;
+
+            /* Scanning better be stopped! */
+            assert(ble_ll_scan_enabled() == 0);
+
+            /* Add to current connections */
+            if (!rc) {
+                ++g_bletest_current_conns;
+
+                /* Move to next connection */
+                if (g_bletest_current_conns < BLETEST_CFG_CONCURRENT_CONNS) {
+                    /* restart initiating */
+                    g_bletest_cur_peer_addr[5] += 1;
+                    g_dev_addr[5] += 1;
+                    bletest_init_initiator();
+                }
+            }
+        }
+    } else {
+        if ((int32_t)(os_time_get() - g_next_os_time) >= 0) {
+            if ((g_bletest_state == 1) || (g_bletest_state == 3)) {
+                for (i = 0; i < g_bletest_current_conns; ++i) {
+                    if (ble_ll_conn_find_active_conn(i + 1)) {
+                        host_hci_cmd_le_rd_chanmap(i+1);
+                        host_hci_outstanding_opcode = 0;
+                    }   
+                }
+            } else if (g_bletest_state == 2) {
+                new_chan_map[0] = 0;
+                new_chan_map[1] = 0x3;
+                new_chan_map[2] = 0;
+                new_chan_map[3] = 0;
+                new_chan_map[4] = 0;
+                host_hci_cmd_le_set_host_chan_class(new_chan_map);
+                host_hci_outstanding_opcode = 0;
+            } else {
+                for (i = 0; i < g_bletest_current_conns; ++i) {
+                    if (ble_ll_conn_find_active_conn(i + 1)) {
+                        host_hci_cmd_read_rssi(i+1);
+                        host_hci_outstanding_opcode = 0;
+                    }   
+                }
+            }
+            ++g_bletest_state;
+            g_next_os_time = os_time_get() + OS_TICKS_PER_SEC * 5;
+        }
+    }
+}
+#endif
+
+#if (BLETEST_CFG_ROLE == BLETEST_ROLE_ADVERTISER)
+/* 
+ * Test wrapper to get packets. Only get a packet if we have more than half
+ * left
+ */ 
+static struct os_mbuf *
+bletest_get_packet(void)
+{
+    struct os_mbuf *om;
+
+    om = NULL;
+    if (g_mbuf_pool.omp_pool->mp_num_free >= 5) {
+        om = os_msys_get_pkthdr(BLE_MBUF_PAYLOAD_SIZE, 
+                                sizeof(struct ble_mbuf_hdr));
+    }
+    return om;
+}
+
+#if 0
+void
+bletest_execute(void)
+{
+    int rc;
+
+    int i;
+    uint16_t pktlen;
+    uint16_t handle;
+    struct os_mbuf *om;
+    struct ble_ll_conn_sm *connsm;
+
+    handle = 1;
+    if ((int32_t)(os_time_get() - g_next_os_time) >= 0) {
+        if (g_bletest_state == 0) {
+            rc = host_hci_cmd_le_set_adv_enable(1);
+            host_hci_outstanding_opcode = 0;
+            assert(rc == 0);
+            g_bletest_state = 1;
+        } else if (g_bletest_state == 1) {
+            /* See if handle 1 has been created. If so, send packets */
+            connsm = ble_ll_conn_find_active_conn(handle);
+            if (connsm) {
+                /* Set connection end time */
+                g_bletest_conn_end = os_time_get() + 
+                    (OS_TICKS_PER_SEC * (60 * 15));
+                g_bletest_state = 2;
+            }
+        } else if (g_bletest_state == 2) {
+            if ((int32_t)(os_time_get() - g_bletest_conn_end) >= 0) {
+                g_bletest_state = 3;
+                host_hci_cmd_disconnect(handle, BLE_ERR_REM_USER_CONN_TERM);
+            } else {
+                om = bletest_get_packet();
+                if (om) {
+                    /* set payload length */
+                    pktlen = BLETEST_PKT_SIZE;
+                    om->om_len = BLETEST_PKT_SIZE + 4;
+
+                    /* Put the HCI header in the mbuf */
+                    htole16(om->om_data, handle);
+                    htole16(om->om_data + 2, om->om_len);
+
+                    /* Place L2CAP header in packet */
+                    htole16(om->om_data + 4, pktlen);
+                    om->om_data[6] = 0;
+                    om->om_data[7] = 0;
+
+                    /* Fill with incrementing pattern (starting from 1) */
+                    for (i = 0; i < pktlen; ++i) {
+                        om->om_data[8 + i] = (uint8_t)(i + 1);
+                    }
+
+                    /* Add length */
+                    om->om_len += 4;
+                    OS_MBUF_PKTHDR(om)->omp_len = om->om_len;
+                    ble_hci_transport_host_acl_data_send(om);
+                }
+                g_next_os_time += OS_TICKS_PER_SEC / 10;
+                return;
+            }
+        } else if (g_bletest_state == 3) {
+            /* We should be waiting for disconnect */
+            connsm = ble_ll_conn_find_active_conn(handle);
+            if (!connsm) {
+                /* Set to 0 if you want to restart advertising */
+                //g_bletest_state = 0;
+                g_bletest_state = 4;
+            }
+        }
+        g_next_os_time += OS_TICKS_PER_SEC;
+    }
+}
+#else
+static void
+bletest_execute_advertiser(void)
+{
+    int i,j;
+    int rc;
+    uint16_t handle;
+    uint16_t pktlen;
+    struct os_mbuf *om;
+
+    /* See if we should start advertising again */
+    if (g_bletest_current_conns < BLETEST_CFG_CONCURRENT_CONNS) {
+        handle = g_bletest_current_conns + 1;
+        if (ble_ll_conn_find_active_conn(handle)) {
+            /* Set LED to slower blink rate */
+            g_bletest_led_rate = OS_TICKS_PER_SEC;
+
+            /* advertising better be stopped! */
+            assert(ble_ll_adv_enabled() == 0);
+
+            /* Send the remote used features command */
+            rc = host_hci_cmd_le_read_rem_used_feat(handle);
+            host_hci_outstanding_opcode = 0;
+            if (rc) {
+                return;
+            }
+
+            /* Send the remote read version command */
+            rc = host_hci_cmd_rd_rem_version(handle);
+            host_hci_outstanding_opcode = 0;
+            if (rc) {
+                return;
+            }
+
+            /* set conn update time */
+            g_bletest_conn_upd_time = os_time_get() + (OS_TICKS_PER_SEC * 5);
+            g_bletest_start_update = 1;
+
+            /* Add to current connections */
+            ++g_bletest_current_conns;
+
+            /* Move to next connection */
+            if (g_bletest_current_conns < BLETEST_CFG_CONCURRENT_CONNS) {
+                /* restart initiating */
+                g_bletest_cur_peer_addr[5] += 1;
+                g_dev_addr[5] += 1;
+                bletest_init_advertising();
+                rc = host_hci_cmd_le_set_adv_enable(1);
+                host_hci_outstanding_opcode = 0;
+            }
+        }
+    }
+#if 0
+    if (g_bletest_start_update) {
+        if ((int32_t)(os_time_get() - g_bletest_conn_upd_time) >= 0) {
+            bletest_send_conn_update(1);
+            g_bletest_start_update = 0;
+        }
+    }
+#endif
+    /* See if it is time to hand a data packet to the connection */
+    if ((int32_t)(os_time_get() - g_next_os_time) >= 0) {
+        if (g_bletest_current_conns) {
+            for (i = 0; i < g_bletest_current_conns; ++i) {
+                if ((g_last_handle_used == 0) || 
+                    (g_last_handle_used > g_bletest_current_conns)) {
+                    g_last_handle_used = 1;
+                }
+                handle = g_last_handle_used;
+                if (ble_ll_conn_find_active_conn(handle)) {
+                    om = bletest_get_packet();
+                    if (om) {
+                        /* set payload length */
+                        pktlen = BLETEST_PKT_SIZE;
+                        om->om_len = BLETEST_PKT_SIZE + 4;
+
+                        /* Put the HCI header in the mbuf */
+                        htole16(om->om_data, handle);
+                        htole16(om->om_data + 2, om->om_len);
+
+                        /* Place L2CAP header in packet */
+                        htole16(om->om_data + 4, pktlen);
+                        om->om_data[6] = 0;
+                        om->om_data[7] = 0;
+                        om->om_len += 4;
+
+                        /* Fill with incrementing pattern (starting from 1) */
+                        for (j = 0; j < pktlen; ++j) {
+                            om->om_data[8 + j] = (uint8_t)(j + 1);
+                        }
+
+                        /* Add length */
+                        OS_MBUF_PKTHDR(om)->omp_len = om->om_len;
+                        ble_hci_transport_host_acl_data_send(om);
+
+                        /* Increment last handle used */
+                        ++g_last_handle_used;
+                    }
+                } else {
+                    ++g_last_handle_used;
+                }
+            }
+        }
+        g_next_os_time = os_time_get() + OS_TICKS_PER_SEC;
+    }
+}
+#endif
+#endif
+
+/**
+ * Main bletest function. Called by the task timer every 50 msecs.
+ * 
+ */
+void
+bletest_execute(void)
+{
+    /* Toggle LED at set rate */
+    if ((int32_t)(os_time_get() - g_bletest_next_led_time) >= 0) {
+        hal_gpio_toggle(LED_BLINK_PIN);
+        g_bletest_next_led_time = os_time_get() + g_bletest_led_rate;
+    }
+#if (BLETEST_CFG_ROLE == BLETEST_ROLE_ADVERTISER)
+    bletest_execute_advertiser();
+#endif
+#if (BLETEST_CFG_ROLE == BLETEST_ROLE_SCANNER)
+    bletest_execute_scanner();
+#endif
+#if (BLETEST_CFG_ROLE == BLETEST_ROLE_INITIATOR)
+    bletest_execute_initiator();
+#endif
+}
+
+/**
+ * Callback when BLE test timer expires. 
+ * 
+ * @param arg 
+ */
+void
+bletest_timer_cb(void *arg)
+{
+    /* Call the bletest code */
+    bletest_execute();
+
+    /* Re-start the timer (run every 50 msecs) */
+    os_callout_reset(&g_bletest_timer.cf_c, OS_TICKS_PER_SEC / 20);
+}
+
+/**
+ * BLE test task 
+ * 
+ * @param arg 
+ */
+void
+bletest_task_handler(void *arg)
+{
+    int rc;
+    uint64_t event_mask;
+    struct os_event *ev;
+    struct os_callout_func *cf;
+
+    /* Set LED blink rate */
+    g_bletest_led_rate = OS_TICKS_PER_SEC / 20;
+
+    /* Wait one second before starting test task */
+    os_time_delay(OS_TICKS_PER_SEC);
+
+    /* Initialize eventq */
+    os_eventq_init(&g_bletest_evq);
+
+    /* Initialize the host timer */
+    os_callout_func_init(&g_bletest_timer, &g_bletest_evq, bletest_timer_cb,
+                         NULL);
+
+    /* Send the reset command first */
+    rc = host_hci_cmd_send(BLE_HCI_OGF_CTLR_BASEBAND, BLE_HCI_OCF_CB_RESET,
+                           0, NULL);
+    assert(rc == 0);
+    host_hci_outstanding_opcode = 0;
+
+#if (BLETEST_CFG_ROLE == BLETEST_ROLE_ADVERTISER)
+    /* Initialize the advertiser */
+    console_printf("Starting BLE test task as advertiser\n");
+    bletest_init_advertising();
+#endif
+
+#if (BLETEST_CFG_ROLE == BLETEST_ROLE_SCANNER)
+    /* Initialize the scanner */
+    console_printf("Starting BLE test task as scanner\n");
+    bletest_init_scanner();
+#endif
+
+#if (BLETEST_CFG_ROLE == BLETEST_ROLE_INITIATOR)
+    /* Initialize the scanner */
+    console_printf("Starting BLE test task as initiator\n");
+    bletest_init_initiator();
+#endif
+
+    /* Set the event mask we want to display */
+    event_mask = 0x7FF;
+    rc = host_hci_cmd_le_set_event_mask(event_mask);
+    assert(rc == 0);
+    host_hci_outstanding_opcode = 0;
+
+    /* Turn on all events */
+    event_mask = 0xffffffffffffffff;
+    rc = host_hci_cmd_set_event_mask(event_mask);
+    assert(rc == 0);
+    host_hci_outstanding_opcode = 0;
+
+    /* Turn on all events */
+    rc = host_hci_cmd_rd_local_version();
+    assert(rc == 0);
+    host_hci_outstanding_opcode = 0;
+
+    /* Wait some time before starting */
+    os_time_delay(OS_TICKS_PER_SEC);
+
+    /* Init bletest variables */
+    g_bletest_state = 0;
+    g_next_os_time = os_time_get();
+
+    /* Begin advertising if we are an advertiser */
+#if (BLETEST_CFG_ROLE == BLETEST_ROLE_ADVERTISER)
+    rc = host_hci_cmd_le_set_adv_enable(1);
+    assert(rc == 0);
+    host_hci_outstanding_opcode = 0;
+#endif
+
+    bletest_timer_cb(NULL);
+
+    while (1) {
+        ev = os_eventq_get(&g_bletest_evq);
+        switch (ev->ev_type) {
+        case OS_EVENT_T_TIMER:
+            cf = (struct os_callout_func *)ev;
+            assert(cf->cf_func);
+            cf->cf_func(cf->cf_arg);
+            break;
+        default:
+            assert(0);
+            break;
+        }
+    }
+}
+
+/**
+ * init_tasks
+ *  
+ * Called by main.c after os_init(). This function performs initializations 
+ * that are required before tasks are running. 
+ *  
+ * @return int 0 success; error otherwise.
+ */
+static int
+init_tasks(void)
+{
+    int rc;
+
+    os_task_init(&bletest_task, "bletest", bletest_task_handler, NULL, 
+                 BLETEST_TASK_PRIO, OS_WAIT_FOREVER, bletest_stack, 
+                 BLETEST_STACK_SIZE);
+
+    /* Initialize host HCI */
+    rc = ble_hs_init(HOST_TASK_PRIO, NULL);
+    assert(rc == 0);
+
+    /* Initialize the BLE LL */
+    rc = ble_ll_init();
+    assert(rc == 0);
+
+    return 0;
+}
+
+/**
+ * main
+ *  
+ * The main function for the project. This function initializes the os, calls 
+ * init_tasks to initialize tasks (and possibly other objects), then starts the 
+ * OS. We should not return from os start. 
+ *  
+ * @return int NOTE: this function should never return!
+ */
+int
+main(void)
+{
+    int i;
+    int rc;
+    uint32_t seed;
+#if 0
+    int cnt;
+    struct nffs_area_desc descs[NFFS_AREA_MAX];
+#endif
+
+    /* Initialize OS */
+    os_init();
+
+    /* Set cputime to count at 1 usec increments */
+    rc = cputime_init(1000000);
+    assert(rc == 0);
+
+    rc = os_mempool_init(&g_mbuf_mempool, MBUF_NUM_MBUFS, 
+            MBUF_MEMBLOCK_SIZE, &g_mbuf_buffer[0], "mbuf_pool");
+    assert(rc == 0);
+
+    rc = os_mbuf_pool_init(&g_mbuf_pool, &g_mbuf_mempool, MBUF_MEMBLOCK_SIZE, 
+                           MBUF_NUM_MBUFS);
+    assert(rc == 0);
+
+    rc = os_msys_register(&g_mbuf_pool);
+    assert(rc == 0);
+
+    /* Dummy device address */
+#if BLETEST_CFG_ROLE == BLETEST_ROLE_ADVERTISER
+    g_dev_addr[0] = 0x00;
+    g_dev_addr[1] = 0x00;
+    g_dev_addr[2] = 0x00;
+    g_dev_addr[3] = 0x88;
+    g_dev_addr[4] = 0x88;
+    g_dev_addr[5] = 0x08;
+
+    g_bletest_cur_peer_addr[0] = 0x00;
+    g_bletest_cur_peer_addr[1] = 0x00;
+    g_bletest_cur_peer_addr[2] = 0x00;
+    g_bletest_cur_peer_addr[3] = 0x99;
+    g_bletest_cur_peer_addr[4] = 0x99;
+    g_bletest_cur_peer_addr[5] = 0x09;
+#else
+    g_dev_addr[0] = 0x00;
+    g_dev_addr[1] = 0x00;
+    g_dev_addr[2] = 0x00;
+    g_dev_addr[3] = 0x99;
+    g_dev_addr[4] = 0x99;
+    g_dev_addr[5] = 0x09;
+
+    g_bletest_cur_peer_addr[0] = 0x00;
+    g_bletest_cur_peer_addr[1] = 0x00;
+    g_bletest_cur_peer_addr[2] = 0x00;
+    g_bletest_cur_peer_addr[3] = 0x88;
+    g_bletest_cur_peer_addr[4] = 0x88;
+    g_bletest_cur_peer_addr[5] = 0x08;
+#endif
+
+    /* 
+     * Seed random number generator with least significant bytes of device
+     * address.
+     */ 
+    seed = 0;
+    for (i = 0; i < 4; ++i) {
+        seed |= g_dev_addr[i];
+        seed <<= 8;
+    }
+    srand(seed);
+
+    /* Set the led pin as an output */
+    g_led_pin = LED_BLINK_PIN;
+    hal_gpio_init_out(g_led_pin, 1);
+
+    /* Init the console */
+    rc = console_init(shell_console_rx_cb);
+    assert(rc == 0);
+
+#if 0
+    rc = hal_flash_init();
+    assert(rc == 0);
+
+    nffs_config.nc_num_inodes = 32;
+    nffs_config.nc_num_blocks = 64;
+    nffs_config.nc_num_files = 2;
+    nffs_config.nc_num_dirs = 2;
+    rc = nffs_init();
+    assert(rc == 0);
+
+    cnt = NFFS_AREA_MAX;
+    rc = flash_area_to_nffs_desc(FLASH_AREA_NFFS, &cnt, descs);
+    assert(rc == 0);
+    if (nffs_detect(descs) == FS_ECORRUPT) {
+        rc = nffs_format(descs);
+        assert(rc == 0);
+    }
+#endif
+
+    shell_task_init(SHELL_TASK_PRIO, shell_stack, SHELL_TASK_STACK_SIZE,
+                         SHELL_MAX_INPUT_LEN);
+
+    nmgr_task_init(NEWTMGR_TASK_PRIO, newtmgr_stack, NEWTMGR_TASK_STACK_SIZE);
+#if 0
+    imgmgr_module_init();
+#endif
+
+    /* Init statistics module */
+    stats_module_init();
+
+    /* Init tasks */
+    init_tasks();
+
+    /* Start the OS */
+    os_start();
+
+    /* os start should never return. If it does, this should be an error */
+    assert(0);
+
+    return rc;
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/apps/bletiny/pkg.yml
----------------------------------------------------------------------
diff --git a/apps/bletiny/pkg.yml b/apps/bletiny/pkg.yml
new file mode 100644
index 0000000..1956484
--- /dev/null
+++ b/apps/bletiny/pkg.yml
@@ -0,0 +1,34 @@
+# 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/bletiny
+pkg.vers: 0.8.0
+pkg.description: Shell application exposing the nimble GAP and GATT.
+pkg.author: Christopher Collins <cc...@apache.org>
+pkg.homepage:
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.type: app
+pkg.keywords:
+
+pkg.deps: 
+    - libs/os 
+    - sys/log
+    - net/nimble/controller
+    - net/nimble/host
+    - libs/console/full
+    - libs/shell
+    - libs/baselibc

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/apps/bletiny/src/bletiny_priv.h
----------------------------------------------------------------------
diff --git a/apps/bletiny/src/bletiny_priv.h b/apps/bletiny/src/bletiny_priv.h
new file mode 100644
index 0000000..e32251b
--- /dev/null
+++ b/apps/bletiny/src/bletiny_priv.h
@@ -0,0 +1,169 @@
+/**
+ * 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.
+ */
+
+#ifndef H_BLETINY_PRIV_
+#define H_BLETINY_PRIV_
+
+#include <inttypes.h>
+#include "nimble/nimble_opt.h"
+#include "log/log.h"
+#include "os/queue.h"
+
+#include "host/ble_gatt.h"
+struct ble_gap_white_entry;
+struct ble_hs_adv_fields;
+struct ble_gap_upd_params;
+struct ble_gap_crt_params;
+struct hci_adv_params;
+struct ble_l2cap_sig_update_req;
+struct ble_l2cap_sig_update_params;
+
+typedef int cmd_fn(int argc, char **argv);
+struct cmd_entry {
+    char *name;
+    cmd_fn *cb;
+};
+
+struct kv_pair {
+    char *key;
+    int val;
+};
+
+struct bletiny_dsc {
+    SLIST_ENTRY(bletiny_dsc) next;
+    struct ble_gatt_dsc dsc;
+};
+SLIST_HEAD(bletiny_dsc_list, bletiny_dsc);
+
+struct bletiny_chr {
+    SLIST_ENTRY(bletiny_chr) next;
+    struct ble_gatt_chr chr;
+
+    struct bletiny_dsc_list dscs;
+};
+SLIST_HEAD(bletiny_chr_list, bletiny_chr);
+
+struct bletiny_svc {
+    SLIST_ENTRY(bletiny_svc) next;
+    struct ble_gatt_service svc;
+
+    struct bletiny_chr_list chrs;
+};
+
+SLIST_HEAD(bletiny_svc_list, bletiny_svc);
+
+struct bletiny_conn {
+    uint16_t handle;
+    uint8_t addr_type;
+    uint8_t addr[6];
+
+    struct bletiny_svc_list svcs;
+};
+
+extern struct bletiny_conn bletiny_conns[NIMBLE_OPT_MAX_CONNECTIONS];
+extern int bletiny_num_conns;
+
+extern const char *bletiny_device_name;
+extern const uint16_t bletiny_appearance;
+extern const uint8_t bletiny_privacy_flag;
+extern uint8_t bletiny_reconnect_addr[6];
+extern uint8_t bletiny_pref_conn_params[8];
+extern uint8_t bletiny_gatt_service_changed[4];
+
+extern struct nmgr_transport nm_ble_transport;
+extern uint16_t nm_attr_val_handle;
+
+extern struct log bletiny_log;
+
+void print_addr(void *addr);
+void print_uuid(void *uuid128);
+const struct cmd_entry *parse_cmd_find(const struct cmd_entry *cmds,
+                                       char *name);
+struct kv_pair *parse_kv_find(struct kv_pair *kvs, char *name);
+char *parse_arg_find(char *key);
+long parse_arg_long_bounds(char *name, long min, long max, int *out_status);
+long parse_arg_long(char *name, int *staus);
+uint16_t parse_arg_uint16(char *name, int *status);
+uint16_t parse_arg_uint16_dflt(char *name, uint16_t dflt, int *out_status);
+uint32_t parse_arg_uint32(char *name, int *out_status);
+int parse_arg_kv(char *name, struct kv_pair *kvs);
+int parse_arg_byte_stream(char *name, int max_len, uint8_t *dst, int *out_len);
+int parse_arg_byte_stream_exact_length(char *name, uint8_t *dst, int len);
+int parse_arg_mac(char *name, uint8_t *dst);
+int parse_arg_uuid(char *name, uint8_t *dst_uuid128);
+int parse_err_too_few_args(char *cmd_name);
+int parse_arg_all(int argc, char **argv);
+int cmd_init(void);
+void periph_init(void);
+int nm_chr_access(uint16_t conn_handle, uint16_t attr_handle,
+                  uint8_t op, union ble_gatt_access_ctxt *ctxt,
+                  void *arg);
+int nm_rx_rsp(uint8_t *attr_val, uint16_t attr_len);
+void nm_init(void);
+void bletiny_lock(void);
+void bletiny_unlock(void);
+int bletiny_exchange_mtu(uint16_t conn_handle);
+int bletiny_disc_svcs(uint16_t conn_handle);
+int bletiny_disc_svc_by_uuid(uint16_t conn_handle, uint8_t *uuid128);
+int bletiny_disc_all_chrs(uint16_t conn_handle, uint16_t start_handle,
+                           uint16_t end_handle);
+int bletiny_disc_chrs_by_uuid(uint16_t conn_handle, uint16_t start_handle,
+                               uint16_t end_handle, uint8_t *uuid128);
+int bletiny_disc_all_dscs(uint16_t conn_handle, uint16_t chr_val_handle,
+                           uint16_t chr_end_handle);
+int bletiny_find_inc_svcs(uint16_t conn_handle, uint16_t start_handle,
+                           uint16_t end_handle);
+int bletiny_read(uint16_t conn_handle, uint16_t attr_handle);
+int bletiny_read_long(uint16_t conn_handle, uint16_t attr_handle);
+int bletiny_read_by_uuid(uint16_t conn_handle, uint16_t start_handle,
+                          uint16_t end_handle, uint8_t *uuid128);
+int bletiny_read_mult(uint16_t conn_handle, uint16_t *attr_handles,
+                       int num_attr_handles);
+int bletiny_write(uint16_t conn_handle, uint16_t attr_handle, void *value,
+                   uint16_t value_len);
+int bletiny_write_no_rsp(uint16_t conn_handle, uint16_t attr_handle,
+                          void *value, uint16_t value_len);
+int bletiny_write_long(uint16_t conn_handle, uint16_t attr_handle,
+                        void *value, uint16_t value_len);
+int bletiny_write_reliable(uint16_t conn_handle, struct ble_gatt_attr *attrs,
+                            int num_attrs);
+int bletiny_adv_start(int disc, int conn, uint8_t *peer_addr, int addr_type,
+                       struct hci_adv_params *params);
+int bletiny_adv_stop(void);
+int bletiny_conn_initiate(int addr_type, uint8_t *peer_addr,
+                           struct ble_gap_crt_params *params);
+int bletiny_conn_cancel(void);
+int bletiny_term_conn(uint16_t conn_handle);
+int bletiny_wl_set(struct ble_gap_white_entry *white_list,
+                    int white_list_count);
+int bletiny_scan(uint32_t dur_ms, uint8_t disc_mode, uint8_t scan_type,
+                  uint8_t filter_policy);
+int bletiny_set_adv_data(struct ble_hs_adv_fields *adv_fields);
+int bletiny_update_conn(uint16_t conn_handle,
+                         struct ble_gap_upd_params *params);
+void bletiny_chrup(uint16_t attr_handle);
+int bletiny_l2cap_update(uint16_t conn_handle,
+                          struct ble_l2cap_sig_update_params *params);
+int bletiny_show_rssi(uint16_t conn_handle);
+
+#define BLETINY_LOG_MODULE  (LOG_MODULE_PERUSER + 0)
+#define BLETINY_LOG(lvl, ...) \
+    LOG_ ## lvl(&bletiny_log, BLETINY_LOG_MODULE, __VA_ARGS__)
+
+#endif


[30/42] incubator-mynewt-core git commit: Initialize libs/os in libs/testutil's tu_init().

Posted by cc...@apache.org.
Initialize libs/os in libs/testutil's tu_init().

This is necessary for unit tests that run in sim and which don't explicitly
initialize the OS.  The set of blocked signals needs to be initialized before
any OS functions are called.  os_init() initializes the signal set.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/f51c77b0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/f51c77b0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/f51c77b0

Branch: refs/heads/master
Commit: f51c77b08e56a6798c336424ce73d7cee2e6ce02
Parents: 05ce86e
Author: Christopher Collins <cc...@gmail.com>
Authored: Fri Mar 11 12:12:02 2016 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Fri Mar 11 12:16:14 2016 -0800

----------------------------------------------------------------------
 libs/os/src/arch/sim/os_arch_sim.c          | 1 +
 libs/os/src/os_priv.h                       | 1 +
 libs/testutil/src/testutil.c                | 3 +++
 net/nimble/host/src/test/ble_hs_test_util.c | 2 ++
 net/nimble/host/src/test/ble_os_test.c      | 6 ------
 5 files changed, 7 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f51c77b0/libs/os/src/arch/sim/os_arch_sim.c
----------------------------------------------------------------------
diff --git a/libs/os/src/arch/sim/os_arch_sim.c b/libs/os/src/arch/sim/os_arch_sim.c
index 1daa94a..94182a8 100644
--- a/libs/os/src/arch/sim/os_arch_sim.c
+++ b/libs/os/src/arch/sim/os_arch_sim.c
@@ -310,6 +310,7 @@ os_arch_os_init(void)
 {
     g_current_task = NULL;
 
+    TAILQ_INIT(&g_os_task_list);
     TAILQ_INIT(&g_os_run_list);
     TAILQ_INIT(&g_os_sleep_list);
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f51c77b0/libs/os/src/os_priv.h
----------------------------------------------------------------------
diff --git a/libs/os/src/os_priv.h b/libs/os/src/os_priv.h
index 93a0c3a..dfc9e38 100644
--- a/libs/os/src/os_priv.h
+++ b/libs/os/src/os_priv.h
@@ -24,6 +24,7 @@ TAILQ_HEAD(os_task_list, os_task);
 
 extern struct os_task_list g_os_run_list;
 extern struct os_task_list g_os_sleep_list;
+extern struct os_task_list g_os_task_list;
 extern struct os_task *g_current_task;
 
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f51c77b0/libs/testutil/src/testutil.c
----------------------------------------------------------------------
diff --git a/libs/testutil/src/testutil.c b/libs/testutil/src/testutil.c
index 09842c5..e41a5a9 100644
--- a/libs/testutil/src/testutil.c
+++ b/libs/testutil/src/testutil.c
@@ -18,6 +18,7 @@
  */
 
 #include <assert.h>
+#include "os/os.h"
 #include "hal/hal_flash.h"
 #include "testutil/testutil.h"
 #include "testutil_priv.h"
@@ -29,6 +30,8 @@ int tu_first_idx;
 int
 tu_init(void)
 {
+    os_init();
+
     tu_any_failed = 0;
 
     return 0;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f51c77b0/net/nimble/host/src/test/ble_hs_test_util.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_hs_test_util.c b/net/nimble/host/src/test/ble_hs_test_util.c
index 642df70..9f8efc2 100644
--- a/net/nimble/host/src/test/ble_hs_test_util.c
+++ b/net/nimble/host/src/test/ble_hs_test_util.c
@@ -405,6 +405,8 @@ ble_hs_test_util_init(void)
     struct ble_hs_cfg cfg;
     int rc;
 
+    tu_init();
+
     os_msys_reset();
     stats_module_reset();
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f51c77b0/net/nimble/host/src/test/ble_os_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_os_test.c b/net/nimble/host/src/test/ble_os_test.c
index 2b722a2..5e57113 100644
--- a/net/nimble/host/src/test/ble_os_test.c
+++ b/net/nimble/host/src/test/ble_os_test.c
@@ -134,8 +134,6 @@ ble_gap_direct_connect_test_task_handler(void *arg)
 
 TEST_CASE(ble_gap_direct_connect_test_case)
 {
-    os_init();
-
     ble_hs_test_util_init();
 
     os_task_init(&ble_os_test_task,
@@ -216,8 +214,6 @@ ble_gap_gen_disc_test_task_handler(void *arg)
 
 TEST_CASE(ble_gap_gen_disc_test_case)
 {
-    os_init();
-
     ble_hs_test_util_init();
 
     os_task_init(&ble_os_test_task,
@@ -330,8 +326,6 @@ ble_gap_terminate_test_task_handler(void *arg)
 
 TEST_CASE(ble_gap_terminate_test_case)
 {
-    os_init();
-
     ble_hs_test_util_init();
 
     os_task_init(&ble_os_test_task,


[04/42] incubator-mynewt-core git commit: Reflect repository name change in yml files. Types in packages. Move projects -> apps.

Posted by cc...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/apps/bletiny/src/periph.c
----------------------------------------------------------------------
diff --git a/apps/bletiny/src/periph.c b/apps/bletiny/src/periph.c
new file mode 100644
index 0000000..d0f97e5
--- /dev/null
+++ b/apps/bletiny/src/periph.c
@@ -0,0 +1,344 @@
+/**
+ * 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 "bsp/bsp.h"
+#include "console/console.h"
+#include "host/ble_hs.h"
+#include "bletiny_priv.h"
+
+#define CHR_F_FULL_ACCESS       (BLE_GATT_CHR_F_READ                |   \
+                                 BLE_GATT_CHR_F_WRITE_NO_RSP        |   \
+                                 BLE_GATT_CHR_F_WRITE               |   \
+                                 BLE_GATT_CHR_F_NOTIFY              |   \
+                                 BLE_GATT_CHR_F_INDICATE)
+
+#define PERIPH_SVC_ALERT_UUID               0x1811
+#define PERIPH_CHR_SUP_NEW_ALERT_CAT_UUID   0x2A47
+#define PERIPH_CHR_NEW_ALERT                0x2A46
+#define PERIPH_CHR_SUP_UNR_ALERT_CAT_UUID   0x2A48
+#define PERIPH_CHR_UNR_ALERT_STAT_UUID      0x2A45
+#define PERIPH_CHR_ALERT_NOT_CTRL_PT        0x2A44
+
+static int
+periph_chr_access_gap(uint16_t conn_handle, uint16_t attr_handle, uint8_t op,
+                      union ble_gatt_access_ctxt *ctxt, void *arg);
+static int
+periph_chr_access_gatt(uint16_t conn_handle, uint16_t attr_handle, uint8_t op,
+                       union ble_gatt_access_ctxt *ctxt, void *arg);
+static int
+periph_chr_access_alert(uint16_t conn_handle, uint16_t attr_handle, uint8_t op,
+                        union ble_gatt_access_ctxt *ctxt, void *arg);
+
+static const struct ble_gatt_svc_def periph_svcs[] = {
+    [0] = {
+        /*** Service: GAP. */
+        .type = BLE_GATT_SVC_TYPE_PRIMARY,
+        .uuid128 = BLE_UUID16(BLE_GAP_SVC_UUID16),
+        .characteristics = (struct ble_gatt_chr_def[]) { {
+            /*** Characteristic: Device Name. */
+            .uuid128 = BLE_UUID16(BLE_GAP_CHR_UUID16_DEVICE_NAME),
+            .access_cb = periph_chr_access_gap,
+            .flags = BLE_GATT_CHR_F_READ,
+        }, {
+            /*** Characteristic: Appearance. */
+            .uuid128 = BLE_UUID16(BLE_GAP_CHR_UUID16_APPEARANCE),
+            .access_cb = periph_chr_access_gap,
+            .flags = BLE_GATT_CHR_F_READ,
+        }, {
+            /*** Characteristic: Peripheral Privacy Flag. */
+            .uuid128 = BLE_UUID16(BLE_GAP_CHR_UUID16_PERIPH_PRIV_FLAG),
+            .access_cb = periph_chr_access_gap,
+            .flags = BLE_GATT_CHR_F_READ,
+        }, {
+            /*** Characteristic: Reconnection Address. */
+            .uuid128 = BLE_UUID16(BLE_GAP_CHR_UUID16_RECONNECT_ADDR),
+            .access_cb = periph_chr_access_gap,
+            .flags = BLE_GATT_CHR_F_WRITE,
+        }, {
+            /*** Characteristic: Peripheral Preferred Connection Parameters. */
+            .uuid128 = BLE_UUID16(BLE_GAP_CHR_UUID16_PERIPH_PREF_CONN_PARAMS),
+            .access_cb = periph_chr_access_gap,
+            .flags = BLE_GATT_CHR_F_READ,
+        }, {
+            0, /* No more characteristics in this service. */
+        } },
+    },
+
+    [1] = {
+        /*** Service: GATT */
+        .type = BLE_GATT_SVC_TYPE_PRIMARY,
+        .uuid128 = BLE_UUID16(BLE_GATT_SVC_UUID16),
+        .characteristics = (struct ble_gatt_chr_def[]) { {
+            .uuid128 = BLE_UUID16(BLE_GATT_CHR_SERVICE_CHANGED_UUID16),
+            .access_cb = periph_chr_access_gatt,
+            .flags = BLE_GATT_CHR_F_INDICATE,
+        }, {
+            0, /* No more characteristics in this service. */
+        } },
+    },
+
+    [2] = {
+        /*** Alert Notification Service. */
+        .type = BLE_GATT_SVC_TYPE_PRIMARY,
+        .uuid128 = BLE_UUID16(PERIPH_SVC_ALERT_UUID),
+        .characteristics = (struct ble_gatt_chr_def[]) { {
+            .uuid128 = BLE_UUID16(PERIPH_CHR_SUP_NEW_ALERT_CAT_UUID),
+            .access_cb = periph_chr_access_alert,
+            .flags = BLE_GATT_CHR_F_READ,
+        }, {
+            .uuid128 = BLE_UUID16(PERIPH_CHR_NEW_ALERT),
+            .access_cb = periph_chr_access_alert,
+            .flags = BLE_GATT_CHR_F_NOTIFY,
+        }, {
+            .uuid128 = BLE_UUID16(PERIPH_CHR_SUP_UNR_ALERT_CAT_UUID),
+            .access_cb = periph_chr_access_alert,
+            .flags = BLE_GATT_CHR_F_READ,
+        }, {
+            .uuid128 = BLE_UUID16(PERIPH_CHR_UNR_ALERT_STAT_UUID),
+            .access_cb = periph_chr_access_alert,
+            .flags = BLE_GATT_CHR_F_NOTIFY,
+        }, {
+            .uuid128 = BLE_UUID16(PERIPH_CHR_ALERT_NOT_CTRL_PT),
+            .access_cb = periph_chr_access_alert,
+            .flags = BLE_GATT_CHR_F_WRITE,
+        }, {
+            0, /* No more characteristics in this service. */
+        } },
+    },
+
+    {
+        0, /* No more services. */
+    },
+};
+
+static int
+periph_chr_write(uint8_t op, union ble_gatt_access_ctxt *ctxt,
+                 uint16_t min_len, uint16_t max_len, void *dst, uint16_t *len)
+{
+    assert(op == BLE_GATT_ACCESS_OP_WRITE_CHR);
+    if (ctxt->chr_access.len < min_len ||
+        ctxt->chr_access.len > max_len) {
+        return BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN;
+    }
+    memcpy(dst, ctxt->chr_access.data, ctxt->chr_access.len);
+    if (len != NULL) {
+        *len = ctxt->chr_access.len;
+    }
+
+    return 0;
+}
+
+static int
+periph_chr_access_gap(uint16_t conn_handle, uint16_t attr_handle, uint8_t op,
+                      union ble_gatt_access_ctxt *ctxt, void *arg)
+{
+    uint16_t uuid16;
+
+    uuid16 = ble_uuid_128_to_16(ctxt->chr_access.chr->uuid128);
+    assert(uuid16 != 0);
+
+    switch (uuid16) {
+    case BLE_GAP_CHR_UUID16_DEVICE_NAME:
+        assert(op == BLE_GATT_ACCESS_OP_READ_CHR);
+        ctxt->chr_access.data = (void *)bletiny_device_name;
+        ctxt->chr_access.len = strlen(bletiny_device_name);
+        break;
+
+    case BLE_GAP_CHR_UUID16_APPEARANCE:
+        assert(op == BLE_GATT_ACCESS_OP_READ_CHR);
+        ctxt->chr_access.data = (void *)&bletiny_appearance;
+        ctxt->chr_access.len = sizeof bletiny_appearance;
+        break;
+
+    case BLE_GAP_CHR_UUID16_PERIPH_PRIV_FLAG:
+        assert(op == BLE_GATT_ACCESS_OP_READ_CHR);
+        ctxt->chr_access.data = (void *)&bletiny_privacy_flag;
+        ctxt->chr_access.len = sizeof bletiny_privacy_flag;
+        break;
+
+    case BLE_GAP_CHR_UUID16_RECONNECT_ADDR:
+        assert(op == BLE_GATT_ACCESS_OP_WRITE_CHR);
+        if (ctxt->chr_access.len != sizeof bletiny_reconnect_addr) {
+            return BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN;
+        }
+        memcpy(bletiny_reconnect_addr, ctxt->chr_access.data,
+               sizeof bletiny_reconnect_addr);
+        break;
+
+    case BLE_GAP_CHR_UUID16_PERIPH_PREF_CONN_PARAMS:
+        assert(op == BLE_GATT_ACCESS_OP_READ_CHR);
+        ctxt->chr_access.data = (void *)&bletiny_pref_conn_params;
+        ctxt->chr_access.len = sizeof bletiny_pref_conn_params;
+        break;
+
+    default:
+        assert(0);
+        break;
+    }
+
+    return 0;
+}
+
+static int
+periph_chr_access_gatt(uint16_t conn_handle, uint16_t attr_handle, uint8_t op,
+                       union ble_gatt_access_ctxt *ctxt, void *arg)
+{
+    uint16_t uuid16;
+
+    uuid16 = ble_uuid_128_to_16(ctxt->chr_access.chr->uuid128);
+    assert(uuid16 != 0);
+
+    switch (uuid16) {
+    case BLE_GATT_CHR_SERVICE_CHANGED_UUID16:
+        if (op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
+            if (ctxt->chr_access.len != sizeof bletiny_gatt_service_changed) {
+                return BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN;
+            }
+            memcpy(bletiny_gatt_service_changed, ctxt->chr_access.data,
+                   sizeof bletiny_gatt_service_changed);
+        } else if (op == BLE_GATT_ACCESS_OP_READ_CHR) {
+            ctxt->chr_access.data = (void *)&bletiny_gatt_service_changed;
+            ctxt->chr_access.len = sizeof bletiny_gatt_service_changed;
+        }
+        break;
+
+    default:
+        assert(0);
+        break;
+    }
+
+    return 0;
+}
+
+#define PERIPH_NEW_ALERT_VAL_MAX_LEN    64
+
+static const uint8_t periph_new_alert_cat = 0x01; /* Simple alert. */
+static uint8_t periph_new_alert_val[PERIPH_NEW_ALERT_VAL_MAX_LEN];
+static uint16_t periph_new_alert_val_len;
+static const uint8_t periph_unr_alert_cat = 0x01; /* Simple alert. */
+static uint16_t periph_unr_alert_stat;
+static uint16_t periph_alert_not_ctrl_pt;
+
+static int
+periph_chr_access_alert(uint16_t conn_handle, uint16_t attr_handle, uint8_t op,
+                        union ble_gatt_access_ctxt *ctxt, void *arg)
+{
+    uint16_t uuid16;
+    int rc;
+
+    uuid16 = ble_uuid_128_to_16(ctxt->chr_access.chr->uuid128);
+    assert(uuid16 != 0);
+
+    switch (uuid16) {
+    case PERIPH_CHR_SUP_NEW_ALERT_CAT_UUID:
+        assert(op == BLE_GATT_ACCESS_OP_READ_CHR);
+        ctxt->chr_access.data = (void *)&periph_new_alert_cat;
+        ctxt->chr_access.len = sizeof periph_new_alert_cat;
+        return 0;
+
+    case PERIPH_CHR_NEW_ALERT:
+        if (op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
+            rc = periph_chr_write(op, ctxt, 0, sizeof periph_new_alert_val,
+                                  periph_new_alert_val,
+                                  &periph_new_alert_val_len);
+            return rc;
+        } else if (op == BLE_GATT_ACCESS_OP_READ_CHR) {
+            ctxt->chr_access.data = (void *)&periph_new_alert_val;
+            ctxt->chr_access.len = sizeof periph_new_alert_val;
+            return 0;
+        }
+
+    case PERIPH_CHR_SUP_UNR_ALERT_CAT_UUID:
+        assert(op == BLE_GATT_ACCESS_OP_READ_CHR);
+        ctxt->chr_access.data = (void *)&periph_unr_alert_cat;
+        ctxt->chr_access.len = sizeof periph_unr_alert_cat;
+        return 0;
+
+    case PERIPH_CHR_UNR_ALERT_STAT_UUID:
+        if (op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
+            rc = periph_chr_write(op, ctxt, 2, 2, &periph_unr_alert_stat, NULL);
+        } else {
+            ctxt->chr_access.data = (void *)&periph_unr_alert_stat;
+            ctxt->chr_access.len = sizeof periph_unr_alert_stat;
+            rc = 0;
+        }
+        return rc;
+
+    case PERIPH_CHR_ALERT_NOT_CTRL_PT:
+        if (op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
+            rc = periph_chr_write(op, ctxt, 2, 2, &periph_alert_not_ctrl_pt,
+                                  NULL);
+        } else {
+            rc = BLE_ATT_ERR_UNLIKELY;
+        }
+        return rc;
+
+    default:
+        assert(0);
+        return BLE_ATT_ERR_UNLIKELY;
+    }
+}
+
+static void
+periph_register_cb(uint8_t op, union ble_gatt_register_ctxt *ctxt, void *arg)
+{
+    uint16_t uuid16;
+
+    switch (op) {
+    case BLE_GATT_REGISTER_OP_SVC:
+        uuid16 = ble_uuid_128_to_16(ctxt->svc_reg.svc->uuid128);
+        assert(uuid16 != 0);
+        BLETINY_LOG(DEBUG, "registered service 0x%04x with handle=%d\n",
+                    uuid16, ctxt->svc_reg.handle);
+        break;
+
+    case BLE_GATT_REGISTER_OP_CHR:
+        uuid16 = ble_uuid_128_to_16(ctxt->chr_reg.chr->uuid128);
+        assert(uuid16 != 0);
+        BLETINY_LOG(DEBUG, "registering characteristic 0x%04x with "
+                           "def_handle=%d val_handle=%d\n",
+                    uuid16, ctxt->chr_reg.def_handle,
+                    ctxt->chr_reg.val_handle);
+        break;
+
+    case BLE_GATT_REGISTER_OP_DSC:
+        uuid16 = ble_uuid_128_to_16(ctxt->dsc_reg.dsc->uuid128);
+        assert(uuid16 != 0);
+        BLETINY_LOG(DEBUG, "registering descriptor 0x%04x with handle=%d "
+                           "chr_handle=%d\n",
+                    uuid16, ctxt->dsc_reg.dsc_handle,
+                    ctxt->dsc_reg.chr_def_handle);
+        break;
+
+    default:
+        assert(0);
+        break;
+    }
+}
+
+void
+periph_init(void)
+{
+    int rc;
+
+    rc = ble_gatts_register_svcs(periph_svcs, periph_register_cb, NULL);
+    assert(rc == 0);
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/apps/blinky/pkg.yml
----------------------------------------------------------------------
diff --git a/apps/blinky/pkg.yml b/apps/blinky/pkg.yml
new file mode 100644
index 0000000..5a4a97f
--- /dev/null
+++ b/apps/blinky/pkg.yml
@@ -0,0 +1,36 @@
+#
+# 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/blinky
+pkg.vers: 0.8.0
+pkg.description: Basic example application which blinks an LED.
+pkg.author: Marko Kiiskila <ma...@runtime.io>
+pkg.homepage: http://mynewt.apache.org/os/get_acclimated/project2/
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.type: app
+pkg.keywords:
+
+pkg.deps:
+    - libs/console/full
+    - libs/newtmgr
+    - libs/os
+    - libs/shell
+    - sys/config
+    - sys/log
+    - sys/stats

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/apps/blinky/src/main.c
----------------------------------------------------------------------
diff --git a/apps/blinky/src/main.c b/apps/blinky/src/main.c
new file mode 100755
index 0000000..5c46883
--- /dev/null
+++ b/apps/blinky/src/main.c
@@ -0,0 +1,200 @@
+/**
+ * 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 "os/os.h"
+#include "bsp/bsp.h"
+#include "hal/hal_gpio.h"
+#include "console/console.h"
+#include "shell/shell.h"
+#include "log/log.h"
+#include "stats/stats.h"
+#include "config/config.h"
+#include <assert.h>
+#include <string.h>
+#ifdef ARCH_sim
+#include <mcu/mcu_sim.h>
+#endif
+
+/* Init all tasks */
+volatile int tasks_initialized;
+int init_tasks(void);
+
+/* Task 1 */
+#define TASK1_PRIO (1)
+#define TASK1_STACK_SIZE    OS_STACK_ALIGN(1024)
+struct os_task task1;
+os_stack_t stack1[TASK1_STACK_SIZE];
+static volatile int g_task1_loops;
+
+/* Task 2 */
+#define TASK2_PRIO (2)
+#define TASK2_STACK_SIZE    OS_STACK_ALIGN(1024)
+struct os_task task2;
+os_stack_t stack2[TASK2_STACK_SIZE];
+
+#define SHELL_TASK_PRIO (3)
+#define SHELL_MAX_INPUT_LEN     (256)
+#define SHELL_TASK_STACK_SIZE (OS_STACK_ALIGN(1024))
+os_stack_t shell_stack[SHELL_TASK_STACK_SIZE];
+
+struct log_handler log_console_handler;
+struct log my_log;
+
+static volatile int g_task2_loops;
+
+/* Global test semaphore */
+struct os_sem g_test_sem;
+
+/* For LED toggling */
+int g_led_pin;
+
+#define DEFAULT_MBUF_MPOOL_BUF_LEN (256)
+#define DEFAULT_MBUF_MPOOL_NBUFS (5)
+
+uint8_t default_mbuf_mpool_data[DEFAULT_MBUF_MPOOL_BUF_LEN *
+    DEFAULT_MBUF_MPOOL_NBUFS];
+
+struct os_mbuf_pool default_mbuf_pool;
+struct os_mempool default_mbuf_mpool;
+
+
+void
+task1_handler(void *arg)
+{
+    struct os_task *t;
+
+    /* Set the led pin for the E407 devboard */
+    g_led_pin = LED_BLINK_PIN;
+    hal_gpio_init_out(g_led_pin, 1);
+
+    while (1) {
+        t = os_sched_get_current_task();
+        assert(t->t_func == task1_handler);
+
+        ++g_task1_loops;
+
+        /* Wait one second */
+        os_time_delay(1000);
+
+        /* Toggle the LED */
+        hal_gpio_toggle(g_led_pin);
+
+        /* Release semaphore to task 2 */
+        os_sem_release(&g_test_sem);
+    }
+}
+
+void
+task2_handler(void *arg)
+{
+    struct os_task *t;
+
+    while (1) {
+        /* just for debug; task 2 should be the running task */
+        t = os_sched_get_current_task();
+        assert(t->t_func == task2_handler);
+
+        /* Increment # of times we went through task loop */
+        ++g_task2_loops;
+
+        /* Wait for semaphore from ISR */
+        os_sem_pend(&g_test_sem, OS_TIMEOUT_NEVER);
+    }
+}
+
+/**
+ * init_tasks
+ *
+ * Called by main.c after os_init(). This function performs initializations
+ * that are required before tasks are running.
+ *
+ * @return int 0 success; error otherwise.
+ */
+int
+init_tasks(void)
+{
+    /* Initialize global test semaphore */
+    os_sem_init(&g_test_sem, 0);
+
+    os_task_init(&task1, "task1", task1_handler, NULL,
+            TASK1_PRIO, OS_WAIT_FOREVER, stack1, TASK1_STACK_SIZE);
+
+    os_task_init(&task2, "task2", task2_handler, NULL,
+            TASK2_PRIO, OS_WAIT_FOREVER, stack2, TASK2_STACK_SIZE);
+
+    tasks_initialized = 1;
+    return 0;
+}
+
+/**
+ * main
+ *
+ * The main function for the project. This function initializes the os, calls
+ * init_tasks to initialize tasks (and possibly other objects), then starts the
+ * OS. We should not return from os start.
+ *
+ * @return int NOTE: this function should never return!
+ */
+int
+main(int argc, char **argv)
+{
+    int rc;
+
+#ifdef ARCH_sim
+    mcu_sim_parse_args(argc, argv);
+#endif
+
+    conf_init();
+
+    log_init();
+    log_console_handler_init(&log_console_handler);
+    log_register("log", &my_log, &log_console_handler);
+
+    LOG_DEBUG(&my_log, LOG_MODULE_DEFAULT, "bla");
+    LOG_DEBUG(&my_log, LOG_MODULE_DEFAULT, "bab");
+
+    os_init();
+
+    rc = os_mempool_init(&default_mbuf_mpool, DEFAULT_MBUF_MPOOL_NBUFS,
+            DEFAULT_MBUF_MPOOL_BUF_LEN, default_mbuf_mpool_data,
+            "default_mbuf_data");
+    assert(rc == 0);
+
+    rc = os_mbuf_pool_init(&default_mbuf_pool, &default_mbuf_mpool,
+            DEFAULT_MBUF_MPOOL_BUF_LEN, DEFAULT_MBUF_MPOOL_NBUFS);
+    assert(rc == 0);
+
+    rc = os_msys_register(&default_mbuf_pool);
+    assert(rc == 0);
+
+    shell_task_init(SHELL_TASK_PRIO, shell_stack, SHELL_TASK_STACK_SIZE,
+                    SHELL_MAX_INPUT_LEN);
+
+    (void) console_init(shell_console_rx_cb);
+
+    stats_module_init();
+
+    rc = init_tasks();
+    os_start();
+
+    /* os start should never return. If it does, this should be an error */
+    assert(0);
+
+    return rc;
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/apps/boot/pkg.yml
----------------------------------------------------------------------
diff --git a/apps/boot/pkg.yml b/apps/boot/pkg.yml
new file mode 100644
index 0000000..71c29ca
--- /dev/null
+++ b/apps/boot/pkg.yml
@@ -0,0 +1,38 @@
+#
+# 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/boot
+pkg.vers: 0.8.0
+pkg.description: Boot loader application.
+pkg.author: Christopher Collins <ch...@apache.org>
+pkg.homepage: http://mynewt.apache.org/os/modules/bootloader/bootloader/
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.type: app
+pkg.keywords:
+    - loader
+
+pkg.features: bootloader
+pkg.deps:
+    - fs/nffs
+    - libs/baselibc
+    - libs/bootutil
+    - libs/console/stub
+    - libs/mbedtls
+    - libs/os
+    - libs/util

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/apps/boot/src/boot.c
----------------------------------------------------------------------
diff --git a/apps/boot/src/boot.c b/apps/boot/src/boot.c
new file mode 100755
index 0000000..1eff268
--- /dev/null
+++ b/apps/boot/src/boot.c
@@ -0,0 +1,110 @@
+/**
+ * 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 <stddef.h>
+#include <inttypes.h>
+#include <hal/flash_map.h>
+#include <os/os.h>
+#include <bsp/bsp.h>
+#include <hal/hal_system.h>
+#include <hal/hal_flash.h>
+#include <log/log.h>
+#include "nffs/nffs.h"
+#include "bootutil/image.h"
+#include "bootutil/loader.h"
+
+/* we currently need extra nffs_area_descriptors for booting since the 
+ * boot code uses these to keep track of which block to write and copy.*/
+#define BOOT_AREA_DESC_MAX  (256)
+#define AREA_DESC_MAX       (BOOT_AREA_DESC_MAX + NFFS_AREA_MAX)
+
+int
+main(void)
+{
+    struct nffs_area_desc descs[AREA_DESC_MAX];
+    /** Contains indices of the areas which can contain image data. */
+    uint8_t img_areas[AREA_DESC_MAX];
+    /** Areas representing the beginning of image slots. */
+    uint8_t img_starts[2];
+    int cnt;
+    int total;
+    struct boot_rsp rsp;
+    int rc;
+    struct boot_req req = {
+        .br_area_descs = descs,
+        .br_image_areas = img_areas,
+        .br_slot_areas = img_starts,
+    };
+
+    os_init();
+
+    rc = hal_flash_init();
+    assert(rc == 0);    
+    
+    cnt = BOOT_AREA_DESC_MAX;
+    rc = flash_area_to_nffs_desc(FLASH_AREA_IMAGE_0, &cnt, descs);
+    img_starts[0] = 0;
+    total = cnt;
+
+    cnt = BOOT_AREA_DESC_MAX - total;
+    assert(cnt >= 0);
+    rc = flash_area_to_nffs_desc(FLASH_AREA_IMAGE_1, &cnt, &descs[total]);
+    assert(rc == 0);
+    img_starts[1] = total;
+    total += cnt;
+    
+    cnt = BOOT_AREA_DESC_MAX - total;
+    assert(cnt >= 0);
+    rc = flash_area_to_nffs_desc(FLASH_AREA_IMAGE_SCRATCH, &cnt, &descs[total]);
+    assert(rc == 0);
+    req.br_scratch_area_idx = total;
+    total += cnt;
+
+    req.br_num_image_areas = total;
+
+    for (cnt = 0; cnt < total; cnt++) {
+        img_areas[cnt] = cnt;
+    }
+
+    cnt = BOOT_AREA_DESC_MAX - total;
+    
+    /* make sure we have enough left to initialize the NFFS with the 
+     * right number of maximum areas otherwise the file-system will not
+     * be readable */
+    assert(cnt >= NFFS_AREA_MAX);
+    rc = flash_area_to_nffs_desc(FLASH_AREA_NFFS, &cnt, &descs[total]);
+    assert(rc == 0);
+    req.br_nffs_area_idx = total;
+    total += cnt;
+
+    nffs_config.nc_num_inodes = 50;
+    nffs_config.nc_num_blocks = 50;
+    nffs_config.nc_num_cache_blocks = 32;
+
+    log_init();
+    
+    rc = boot_go(&req, &rsp);
+    assert(rc == 0);
+
+    system_start((void *)(rsp.br_image_addr + rsp.br_hdr->ih_hdr_size));
+
+    return 0;
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/apps/ffs2native/pkg.yml
----------------------------------------------------------------------
diff --git a/apps/ffs2native/pkg.yml b/apps/ffs2native/pkg.yml
new file mode 100644
index 0000000..718b0ac
--- /dev/null
+++ b/apps/ffs2native/pkg.yml
@@ -0,0 +1,33 @@
+#
+# 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/ffs2native
+pkg.vers: 0.8.0
+pkg.description: Support application for debugging the Newtron Flash File System.
+pkg.author: Christopher Collins <cc...@apache.org>
+pkg.homepage:
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.type: app
+pkg.keywords:
+
+pkg.deps:
+    - fs/nffs
+    - hw/hal
+    - libs/console/full
+    - libs/os

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/apps/ffs2native/src/main.c
----------------------------------------------------------------------
diff --git a/apps/ffs2native/src/main.c b/apps/ffs2native/src/main.c
new file mode 100644
index 0000000..9192f14
--- /dev/null
+++ b/apps/ffs2native/src/main.c
@@ -0,0 +1,366 @@
+/**
+ * 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.
+ */
+
+/**
+ * XXX
+ * This is a hack of a tool which prints the structure of an nffs file system.
+ * It needs to be rewritten properly.
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <inttypes.h>
+#include <unistd.h>
+#include <dirent.h>
+#include <strings.h>
+#include "../src/nffs_priv.h"
+#include <os/queue.h>
+#include <fs/fs.h>
+#include <bsp/bsp.h>
+#include <nffs/nffs.h>
+#include <hal/hal_flash.h>
+#include <hal/flash_map.h>
+#ifdef ARCH_sim
+#include <mcu/mcu_sim.h>
+#endif
+
+static const char *copy_in_dir;
+static const char *progname;
+
+#define MAX_AREAS	16
+static struct nffs_area_desc area_descs[MAX_AREAS];
+
+static void usage(int rc);
+
+static void
+copyfs(FILE *fp)
+{
+    uint32_t dst_addr;
+    int rc;
+    int c;
+
+    dst_addr = area_descs[0].nad_offset;
+    while (1) {
+        c = getc(fp);
+        if (c == EOF) {
+            return;
+        }
+
+        rc = hal_flash_write(area_descs[0].nad_flash_id, dst_addr, &c, 1);
+        assert(rc == 0);
+
+        dst_addr++;
+    }
+}
+
+static void
+print_inode_entry(struct nffs_inode_entry *inode_entry, int indent)
+{
+    struct nffs_inode inode;
+    char name[NFFS_FILENAME_MAX_LEN + 1];
+    uint32_t area_offset;
+    uint8_t area_idx;
+    int rc;
+
+    rc = nffs_inode_from_entry(&inode, inode_entry);
+    assert(rc == 0);
+
+    nffs_flash_loc_expand(inode_entry->nie_hash_entry.nhe_flash_loc,
+                         &area_idx, &area_offset);
+
+    rc = nffs_flash_read(area_idx,
+                         area_offset + sizeof (struct nffs_disk_inode),
+                         name, inode.ni_filename_len);
+    assert(rc == 0);
+
+    name[inode.ni_filename_len] = '\0';
+
+    printf("%*s%s\n", indent, "", name[0] == '\0' ? "/" : name);
+}
+
+static void
+process_inode_entry(struct nffs_inode_entry *inode_entry, int indent)
+{
+    struct nffs_inode_entry *child;
+
+    print_inode_entry(inode_entry, indent);
+
+    if (nffs_hash_id_is_dir(inode_entry->nie_hash_entry.nhe_id)) {
+        SLIST_FOREACH(child, &inode_entry->nie_child_list, nie_sibling_next) {
+            process_inode_entry(child, indent + 2);
+        }
+    }
+}
+
+static int
+print_nffs_inode(int idx, uint32_t off)
+{
+    struct nffs_disk_inode ndi;
+    char filename[128];
+    int len;
+    int rc;
+
+    rc = nffs_flash_read(idx, off, &ndi, sizeof(ndi));
+    assert(rc == 0);
+
+    memset(filename, 0, sizeof(filename));
+    len = min(sizeof(filename) - 1, ndi.ndi_filename_len);
+    rc = nffs_flash_read(idx, off + sizeof(ndi), filename, len);
+    printf("      %x-%d inode %d/%d %s\n",
+      off, ndi.ndi_filename_len, ndi.ndi_id, ndi.ndi_seq, filename);
+    return sizeof(ndi) + ndi.ndi_filename_len;
+}
+
+static int
+print_nffs_block(int idx, uint32_t off)
+{
+    struct nffs_disk_block ndb;
+    int rc;
+
+    rc = nffs_flash_read(idx, off, &ndb, sizeof(ndb));
+    assert(rc == 0);
+
+    printf("      %x-%d block %u/%u belongs to %u\n",
+      off, ndb.ndb_data_len, ndb.ndb_id, ndb.ndb_seq, ndb.ndb_inode_id);
+    return sizeof(ndb) + ndb.ndb_data_len;
+}
+
+static int
+print_nffs_object(int idx, uint32_t off)
+{
+    uint32_t magic;
+    int rc;
+
+    rc = nffs_flash_read(idx, off, &magic, sizeof(magic));
+    assert(rc == 0);
+
+    switch (magic) {
+    case NFFS_INODE_MAGIC:
+        return print_nffs_inode(idx, off);
+
+    case NFFS_BLOCK_MAGIC:
+        return print_nffs_block(idx, off);
+        break;
+
+    case 0xffffffff:
+        assert(0);
+        return 0;
+
+    default:
+        printf("      %x Corruption\n", off);
+        return 1;
+    }
+}
+
+static void
+print_nffs_area(int idx)
+{
+    struct nffs_area *area;
+    struct nffs_disk_area darea;
+    int off;
+    int rc;
+
+    area = &nffs_areas[idx];
+    rc = nffs_flash_read(idx, 0, &darea, sizeof(darea));
+    assert(rc == 0);
+    if (!nffs_area_magic_is_set(&darea)) {
+        printf("Area header corrupt!\n");
+        return;
+    }
+    off = sizeof (struct nffs_disk_area);
+    while (off < area->na_cur) {
+        off += print_nffs_object(idx, off);
+    }
+}
+
+static void
+print_nffs_areas(void)
+{
+    int i;
+    struct nffs_area *area;
+
+    for (i = 0; i < nffs_num_areas; i++) {
+        if (nffs_scratch_area_idx == i) {
+            printf(" sc ");
+        } else {
+            printf("    ");
+        }
+
+        area = &nffs_areas[i];
+        printf("%d: cur:%d id:%d 0x%x-0x%x\n",
+          i, area->na_cur, area->na_id,
+          area->na_offset, area->na_offset + area->na_length);
+        print_nffs_area(i);
+    }
+}
+
+static void
+printfs(void)
+{
+    printf("\n\nNFFS contents:\n");
+    process_inode_entry(nffs_root_dir, 0);
+    printf("\nNFFS areas:\n");
+    print_nffs_areas();
+}
+
+static int
+copy_in_file(char *src, char *dst)
+{
+    struct fs_file *nf;
+    FILE *fp;
+    int rc;
+    char data[2048];
+    int ret = 0;
+
+    rc = fs_open(dst, FS_ACCESS_WRITE, &nf);
+    assert(rc == 0);
+
+    fp = fopen(src, "r");
+    if (!fp) {
+        perror("fopen()");
+        assert(0);
+    }
+    while ((rc = fread(data, 1, sizeof(data), fp))) {
+        rc = fs_write(nf, data, rc);
+        if (rc) {
+            ret = rc;
+            break;
+        }
+    }
+    rc = fs_close(nf);
+    assert(rc == 0);
+    fclose(fp);
+    return ret;
+}
+
+void
+copy_in_directory(const char *src, const char *dst)
+{
+    DIR *dr;
+    struct dirent *entry;
+    char src_name[1024];
+    char dst_name[1024];
+    int rc;
+
+    dr = opendir(src);
+    if (!dr) {
+        perror("opendir");
+        usage(1);
+    }
+    while ((entry = readdir(dr))) {
+        snprintf(src_name, sizeof(src_name), "%s/%s", src, entry->d_name);
+        snprintf(dst_name, sizeof(dst_name), "%s/%s", dst, entry->d_name);
+        if (entry->d_type == DT_DIR &&
+          strcmp(entry->d_name, ".") && strcmp(entry->d_name, "..")) {
+            rc = fs_mkdir(dst_name);
+            copy_in_directory(src_name, dst_name);
+            assert(rc == 0);
+        } else if (entry->d_type == DT_REG) {
+            printf("Copying %s\n", dst_name);
+            rc = copy_in_file(src_name, dst_name);
+            if (rc) {
+                printf("  error code %d ", rc);
+                switch (rc) {
+                case FS_ENOMEM:
+                    printf("out of memory\n");
+                    break;
+                case FS_EFULL:
+                    printf("disk is full\n");
+                    break;
+                default:
+                    printf("\n");
+                }
+                break;
+            }
+        } else {
+            printf("Skipping %s\n", src_name);
+        }
+    }
+    closedir(dr);
+}
+
+static void
+usage(int rc)
+{
+    printf("%s [-c]|[-d dir][-f flash_file]\n", progname);
+    printf("  Tool for operating on simulator flash image file\n");
+    printf("   -c: ...\n");
+    printf("   -d: use dir as root for NFFS portion and create flash image\n");
+    printf("   -f: flash_file is the name of the flash image file\n");
+    exit(rc);
+}
+
+int
+main(int argc, char **argv)
+{
+    FILE *fp;
+    int rc;
+    int ch;
+    int cnt;
+
+    progname = argv[0];
+
+    while ((ch = getopt(argc, argv, "c:d:f:")) != -1) {
+        switch (ch) {
+        case 'c':
+            fp = fopen(optarg, "rb");
+            assert(fp != NULL);
+            copyfs(fp);
+            fclose(fp);
+            break;
+        case 'd':
+            copy_in_dir = optarg;
+            break;
+        case 'f':
+            native_flash_file = optarg;
+            break;
+        case '?':
+        default:
+            usage(0);
+        }
+    }
+
+    os_init();
+    rc = flash_area_to_nffs_desc(FLASH_AREA_NFFS, &cnt, area_descs);
+    assert(rc == 0);
+
+    rc = hal_flash_init();
+    assert(rc == 0);
+
+    rc = nffs_init();
+    assert(rc == 0);
+
+    if (copy_in_dir) {
+        /*
+         * Build filesystem from contents of directory
+         */
+        rc = nffs_format(area_descs);
+        assert(rc == 0);
+        copy_in_directory(copy_in_dir, "");
+    } else {
+        rc = nffs_detect(area_descs);
+        if (rc) {
+            printf("nffs_detect() failed\n");
+            exit(0);
+        }
+    }
+    printfs();
+
+    return 0;
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/apps/luatest/pkg.yml
----------------------------------------------------------------------
diff --git a/apps/luatest/pkg.yml b/apps/luatest/pkg.yml
new file mode 100644
index 0000000..3fefaa8
--- /dev/null
+++ b/apps/luatest/pkg.yml
@@ -0,0 +1,33 @@
+# 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/luatest
+pkg.vers: 0.8.0
+pkg.description: Simple project for testing Lua scripting.
+pkg.author: Marko Kiiskila <ma...@runtime.io>
+pkg.homepage:
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.type: app
+pkg.keywords:
+
+pkg.deps:
+     - fs/nffs
+     - libs/os
+     - libs/elua/elua_base
+     - libs/console/full
+     - libs/shell
+

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/apps/luatest/src/main.c
----------------------------------------------------------------------
diff --git a/apps/luatest/src/main.c b/apps/luatest/src/main.c
new file mode 100755
index 0000000..76dd13f
--- /dev/null
+++ b/apps/luatest/src/main.c
@@ -0,0 +1,115 @@
+/**
+ * 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 <os/os.h>
+#include <bsp/bsp.h>
+#include <hal/hal_flash.h>
+#include <console/console.h>
+#include <shell/shell.h>
+#include <elua_base/elua.h>
+#include <fs/fs.h>
+#include <nffs/nffs.h>
+#include <hal/flash_map.h>
+#ifdef ARCH_sim
+#include <mcu/mcu_sim.h>
+#endif
+
+/* Init all tasks */
+int init_tasks(void);
+
+/* Shell */
+#define SHELL_TASK_PRIO      (8)
+#define SHELL_MAX_INPUT_LEN     (256)
+#define SHELL_TASK_STACK_SIZE (OS_STACK_ALIGN(2048))
+static os_stack_t shell_stack[SHELL_TASK_STACK_SIZE];
+
+static void
+create_script_file(void)
+{
+    char filename[] = "/foobar";
+    char script[] = "print \"eat my shorts\"\n";
+    struct fs_file *nf;
+    int rc;
+
+    rc = fs_open(filename, FS_ACCESS_READ, &nf);
+    if (rc) {
+        rc = fs_open(filename, FS_ACCESS_WRITE, &nf);
+        assert(rc == 0);
+        rc = fs_write(nf, script, strlen(script));
+        assert(rc == 0);
+    }
+    fs_close(nf);
+}
+
+/**
+ * main
+ *
+ * The main function for the project. This function initializes the os, calls
+ * init_tasks to initialize tasks (and possibly other objects), then starts the
+ * OS. We should not return from os start.
+ *
+ * @return int NOTE: this function should never return!
+ */
+int
+main(int argc, char **argv)
+{
+    int rc;
+    struct nffs_area_desc descs[NFFS_AREA_MAX];
+    int cnt;
+
+#ifdef ARCH_sim
+    mcu_sim_parse_args(argc, argv);
+#endif
+
+    rc = hal_flash_init();
+    assert(rc == 0);
+
+    /* Initialize OS */
+    os_init();
+
+    /* Init tasks */
+    shell_task_init(SHELL_TASK_PRIO, shell_stack, SHELL_TASK_STACK_SIZE,
+                         SHELL_MAX_INPUT_LEN);
+    console_init(shell_console_rx_cb);
+
+    nffs_init();
+
+    cnt = NFFS_AREA_MAX;
+    rc = flash_area_to_nffs_desc(FLASH_AREA_NFFS, &cnt, descs);
+    assert(rc == 0);
+
+    if (nffs_detect(descs) == FS_ECORRUPT) {
+        rc = nffs_format(descs);
+        assert(rc == 0);
+    }
+
+    lua_init();
+    create_script_file();
+
+    /* Start the OS */
+    os_start();
+
+    /* os start should never return. If it does, this should be an error */
+    assert(0);
+
+    return rc;
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/apps/slinky/pkg.yml
----------------------------------------------------------------------
diff --git a/apps/slinky/pkg.yml b/apps/slinky/pkg.yml
new file mode 100644
index 0000000..d5f792a
--- /dev/null
+++ b/apps/slinky/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/slinky
+pkg.vers: 0.8.0
+pkg.description: Example application which uses a variety of mynewt features.
+pkg.author: Marko Kiiskila <ma...@runtime.io>
+pkg.homepage:
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.type: app
+pkg.keywords:
+
+pkg.deps:
+    - fs/nffs
+    - libs/baselibc
+    - libs/console/full
+    - libs/flash_test    
+    - libs/imgmgr
+    - libs/newtmgr
+    - libs/os
+    - libs/shell
+    - libs/util
+    - sys/config
+    - sys/log
+    - sys/stats

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/apps/slinky/src/main.c
----------------------------------------------------------------------
diff --git a/apps/slinky/src/main.c b/apps/slinky/src/main.c
new file mode 100755
index 0000000..edaad80
--- /dev/null
+++ b/apps/slinky/src/main.c
@@ -0,0 +1,296 @@
+/**
+ * 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 <os/os.h>
+#include <bsp/bsp.h>
+#include <hal/hal_gpio.h>
+#include <hal/hal_flash.h>
+#include <console/console.h>
+#include <shell/shell.h>
+#include <log/log.h>
+#include <stats/stats.h>
+#include <config/config.h>
+#include <hal/flash_map.h>
+#include <fs/fs.h>
+#include <nffs/nffs.h>
+#include <newtmgr/newtmgr.h>
+#include <imgmgr/imgmgr.h>
+#include <assert.h>
+#include <string.h>
+#include <json/json.h>
+#include <flash_test/flash_test.h>
+
+#ifdef ARCH_sim
+#include <mcu/mcu_sim.h>
+#endif
+
+/* Init all tasks */
+volatile int tasks_initialized;
+int init_tasks(void);
+
+/* Task 1 */
+#define TASK1_PRIO (1)
+#define TASK1_STACK_SIZE    OS_STACK_ALIGN(128)
+struct os_task task1;
+os_stack_t stack1[TASK1_STACK_SIZE];
+static volatile int g_task1_loops;
+
+/* Task 2 */
+#define TASK2_PRIO (2)
+#define TASK2_STACK_SIZE    OS_STACK_ALIGN(128)
+struct os_task task2;
+os_stack_t stack2[TASK2_STACK_SIZE];
+
+#define SHELL_TASK_PRIO (3)
+#define SHELL_MAX_INPUT_LEN     (256)
+#define SHELL_TASK_STACK_SIZE (OS_STACK_ALIGN(384))
+os_stack_t shell_stack[SHELL_TASK_STACK_SIZE];
+
+#define NEWTMGR_TASK_PRIO (4)
+#define NEWTMGR_TASK_STACK_SIZE (OS_STACK_ALIGN(512))
+os_stack_t newtmgr_stack[NEWTMGR_TASK_STACK_SIZE];
+
+struct log_handler log_console_handler;
+struct log my_log;
+
+static volatile int g_task2_loops;
+
+/* Global test semaphore */
+struct os_sem g_test_sem;
+
+/* For LED toggling */
+int g_led_pin;
+
+#define DEFAULT_MBUF_MPOOL_BUF_LEN (256)
+#define DEFAULT_MBUF_MPOOL_NBUFS (10)
+
+uint8_t default_mbuf_mpool_data[DEFAULT_MBUF_MPOOL_BUF_LEN *
+    DEFAULT_MBUF_MPOOL_NBUFS];
+
+struct os_mbuf_pool default_mbuf_pool;
+struct os_mempool default_mbuf_mpool;
+
+static char *test_conf_get(int argc, char **argv, char *val, int max_len);
+static int test_conf_set(int argc, char **argv, char *val);
+static int test_conf_commit(void);
+
+static struct conf_handler test_conf_handler = {
+    .ch_name = "test",
+    .ch_get = test_conf_get,
+    .ch_set = test_conf_set,
+    .ch_commit = test_conf_commit
+};
+
+static uint8_t test8;
+static uint8_t test8_shadow;
+static char test_str[32];
+
+static char *
+test_conf_get(int argc, char **argv, char *buf, int max_len)
+{
+    if (argc == 1) {
+        if (!strcmp(argv[0], "8")) {
+            return conf_str_from_value(CONF_INT8, &test8, buf, max_len);
+        } else if (!strcmp(argv[0], "str")) {
+            return test_str;
+        }
+    }
+    return NULL;
+}
+
+static int
+test_conf_set(int argc, char **argv, char *val)
+{
+    if (argc == 1) {
+        if (!strcmp(argv[0], "8")) {
+            return CONF_VALUE_SET(val, CONF_INT8, test8_shadow);
+        } else if (!strcmp(argv[0], "str")) {
+            return CONF_VALUE_SET(val, CONF_STRING, test_str);
+        }
+    }
+    return OS_ENOENT;
+}
+
+static int
+test_conf_commit(void)
+{
+    test8 = test8_shadow;
+
+    return 0;
+}
+
+void
+task1_handler(void *arg)
+{
+    struct os_task *t;
+
+    /* Set the led pin for the E407 devboard */
+    g_led_pin = LED_BLINK_PIN;
+    hal_gpio_init_out(g_led_pin, 1);
+
+    while (1) {
+        t = os_sched_get_current_task();
+        assert(t->t_func == task1_handler);
+
+        ++g_task1_loops;
+
+        /* Wait one second */
+        os_time_delay(1000);
+
+        /* Toggle the LED */
+        hal_gpio_toggle(g_led_pin);
+
+        /* Release semaphore to task 2 */
+        os_sem_release(&g_test_sem);
+    }
+}
+
+void
+task2_handler(void *arg)
+{
+    struct os_task *t;
+
+    while (1) {
+        /* just for debug; task 2 should be the running task */
+        t = os_sched_get_current_task();
+        assert(t->t_func == task2_handler);
+
+        /* Increment # of times we went through task loop */
+        ++g_task2_loops;
+
+        /* Wait for semaphore from ISR */
+        os_sem_pend(&g_test_sem, OS_TIMEOUT_NEVER);
+    }
+}
+
+/**
+ * init_tasks
+ *
+ * Called by main.c after os_init(). This function performs initializations
+ * that are required before tasks are running.
+ *
+ * @return int 0 success; error otherwise.
+ */
+int
+init_tasks(void)
+{
+    /* Initialize global test semaphore */
+    os_sem_init(&g_test_sem, 0);
+
+    os_task_init(&task1, "task1", task1_handler, NULL,
+            TASK1_PRIO, OS_WAIT_FOREVER, stack1, TASK1_STACK_SIZE);
+
+    os_task_init(&task2, "task2", task2_handler, NULL,
+            TASK2_PRIO, OS_WAIT_FOREVER, stack2, TASK2_STACK_SIZE);
+
+    tasks_initialized = 1;
+    return 0;
+}
+
+
+/**
+ * main
+ *
+ * The main function for the project. This function initializes the os, calls
+ * init_tasks to initialize tasks (and possibly other objects), then starts the
+ * OS. We should not return from os start.
+ *
+ * @return int NOTE: this function should never return!
+ */
+int
+main(int argc, char **argv)
+{
+    int rc;
+    int cnt;
+
+    /* NFFS_AREA_MAX is defined in the BSP-specified bsp.h header file. */
+    struct nffs_area_desc descs[NFFS_AREA_MAX];
+
+#ifdef ARCH_sim
+    mcu_sim_parse_args(argc, argv);
+#endif
+
+    conf_init();
+    rc = conf_register(&test_conf_handler);
+    assert(rc == 0);
+
+
+    log_init();
+
+    log_console_handler_init(&log_console_handler);
+    log_register("log", &my_log, &log_console_handler);
+
+    LOG_DEBUG(&my_log, LOG_MODULE_DEFAULT, "bla");
+    LOG_DEBUG(&my_log, LOG_MODULE_DEFAULT, "bab");
+
+    os_init();
+
+    rc = os_mempool_init(&default_mbuf_mpool, DEFAULT_MBUF_MPOOL_NBUFS, 
+            DEFAULT_MBUF_MPOOL_BUF_LEN, default_mbuf_mpool_data, 
+            "default_mbuf_data");
+    assert(rc == 0);
+
+    rc = os_mbuf_pool_init(&default_mbuf_pool, &default_mbuf_mpool, 
+            DEFAULT_MBUF_MPOOL_BUF_LEN, DEFAULT_MBUF_MPOOL_NBUFS);
+    assert(rc == 0);
+
+    rc = os_msys_register(&default_mbuf_pool);
+    assert(rc == 0);
+
+    rc = hal_flash_init();
+    assert(rc == 0);
+
+    /* Initialize nffs's internal state. */
+    rc = nffs_init();
+    assert(rc == 0);
+
+    /* Convert the set of flash blocks we intend to use for nffs into an array
+     * of nffs area descriptors.
+     */
+    cnt = NFFS_AREA_MAX;
+    rc = flash_area_to_nffs_desc(FLASH_AREA_NFFS, &cnt, descs);
+    assert(rc == 0);
+
+    /* Attempt to restore an existing nffs file system from flash. */
+    if (nffs_detect(descs) == FS_ECORRUPT) {
+        /* No valid nffs instance detected; format a new one. */
+        rc = nffs_format(descs);
+        assert(rc == 0);
+    }
+
+    shell_task_init(SHELL_TASK_PRIO, shell_stack, SHELL_TASK_STACK_SIZE,
+                    SHELL_MAX_INPUT_LEN);
+
+    (void) console_init(shell_console_rx_cb);
+
+    nmgr_task_init(NEWTMGR_TASK_PRIO, newtmgr_stack, NEWTMGR_TASK_STACK_SIZE);
+    imgmgr_module_init();
+
+    stats_module_init();
+
+    flash_test_init();
+    
+    rc = init_tasks();
+    os_start();
+
+    /* os start should never return. If it does, this should be an error */
+    assert(0);
+
+    return rc;
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/apps/test/pkg.yml
----------------------------------------------------------------------
diff --git a/apps/test/pkg.yml b/apps/test/pkg.yml
new file mode 100644
index 0000000..f375073
--- /dev/null
+++ b/apps/test/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/test
+pkg.vers: 0.8.0
+pkg.description: Automated test suite for mynewt core functionality.
+pkg.author: Christopher Collins <cc...@apache.org>
+pkg.homepage:
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.type: app
+pkg.keywords:
+
+pkg.deps:
+    - fs/nffs
+    - libs/bootutil
+    - libs/console/full
+    - libs/mbedtls
+    - libs/os
+    - libs/testreport
+    - libs/testutil
+    - libs/util
+    - sys/config
+
+pkg.features:
+    - test

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/apps/test/src/test.c
----------------------------------------------------------------------
diff --git a/apps/test/src/test.c b/apps/test/src/test.c
new file mode 100644
index 0000000..57c6418
--- /dev/null
+++ b/apps/test/src/test.c
@@ -0,0 +1,44 @@
+/**
+ * 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 <stddef.h>
+#include "os/os_test.h"
+#include "nffs/nffs_test.h"
+#include "bootutil/bootutil_test.h"
+#include "testutil/testutil.h"
+#include "mbedtls/mbedtls_test.h"
+#include "config/config_test.h"
+
+extern int util_test_all(void);
+
+int
+main(void)
+{
+    tu_config.tc_print_results = 1;
+    tu_init();
+
+    os_test_all();
+    nffs_test_all();
+    boot_test_all();
+    util_test_all();
+    mbedtls_test_all();
+    config_test_all();
+
+    return 0;
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/compiler/arm-none-eabi-m0/compiler.yml
----------------------------------------------------------------------
diff --git a/compiler/arm-none-eabi-m0/compiler.yml b/compiler/arm-none-eabi-m0/compiler.yml
new file mode 100644
index 0000000..88a9e11
--- /dev/null
+++ b/compiler/arm-none-eabi-m0/compiler.yml
@@ -0,0 +1,33 @@
+#
+# 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.
+#
+
+compiler.path.cc: arm-none-eabi-gcc
+compiler.path.archive: arm-none-eabi-ar
+compiler.path.as: arm-none-eabi-gcc -x assembler-with-cpp
+compiler.path.objdump: arm-none-eabi-objdump
+compiler.path.objsize: arm-none-eabi-size
+compiler.path.objcopy: arm-none-eabi-objcopy
+
+compiler.flags.default: -mcpu=cortex-m0 -mthumb-interwork -mthumb -Wall -Werror -fno-exceptions -fomit-frame-pointer
+compiler.flags.optimized: [compiler.flags.default, -Os -ggdb]
+compiler.flags.debug: [compiler.flags.default, -O1 -ggdb]
+
+compiler.ld.flags: -static -lgcc
+compiler.ld.resolve_circular_deps: true
+compiler.ld.mapfile: true

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/compiler/arm-none-eabi-m0/pkg.yml
----------------------------------------------------------------------
diff --git a/compiler/arm-none-eabi-m0/pkg.yml b/compiler/arm-none-eabi-m0/pkg.yml
index c45947f..36972c5 100644
--- a/compiler/arm-none-eabi-m0/pkg.yml
+++ b/compiler/arm-none-eabi-m0/pkg.yml
@@ -22,24 +22,10 @@ pkg.vers: 0.8.0
 pkg.description: Compiler definition for ARM Cortex-M0 gcc cross compiler.
 pkg.author: wes3 <wi...@runtime.io>
 pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.type: compiler
 pkg.keywords:
     - arm
     - compiler
     - cortex
     - m0
-
-compiler.path.cc: arm-none-eabi-gcc
-compiler.path.archive: arm-none-eabi-ar
-compiler.path.as: arm-none-eabi-gcc -x assembler-with-cpp
-compiler.path.objdump: arm-none-eabi-objdump
-compiler.path.objsize: arm-none-eabi-size
-compiler.path.objcopy: arm-none-eabi-objcopy
-
-compiler.flags.default: -mcpu=cortex-m0 -mthumb-interwork -mthumb -Wall -Werror -fno-exceptions -fomit-frame-pointer
-compiler.flags.optimized: [compiler.flags.default, -Os -ggdb]
-compiler.flags.debug: [compiler.flags.default, -O1 -ggdb]
-
-compiler.ld.flags: -static -lgcc
-compiler.ld.resolve_circular_deps: true
-compiler.ld.mapfile: true

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/compiler/arm-none-eabi-m4/compiler.yml
----------------------------------------------------------------------
diff --git a/compiler/arm-none-eabi-m4/compiler.yml b/compiler/arm-none-eabi-m4/compiler.yml
new file mode 100644
index 0000000..e2203b7
--- /dev/null
+++ b/compiler/arm-none-eabi-m4/compiler.yml
@@ -0,0 +1,33 @@
+#
+# 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.
+#
+
+compiler.path.cc: arm-none-eabi-gcc
+compiler.path.archive: arm-none-eabi-ar
+compiler.path.as: arm-none-eabi-gcc -x assembler-with-cpp
+compiler.path.objdump: arm-none-eabi-objdump
+compiler.path.objsize: arm-none-eabi-size
+compiler.path.objcopy: arm-none-eabi-objcopy
+
+compiler.flags.default: -mcpu=cortex-m4 -mthumb-interwork -mthumb -Wall -Werror -fno-exceptions
+compiler.flags.optimized: [compiler.flags.default, -Os -ggdb]
+compiler.flags.debug: [compiler.flags.default, -O1 -ggdb]
+
+compiler.ld.flags: -static -lgcc
+compiler.ld.resolve_circular_deps: true
+compiler.ld.mapfile: true

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/compiler/arm-none-eabi-m4/pkg.yml
----------------------------------------------------------------------
diff --git a/compiler/arm-none-eabi-m4/pkg.yml b/compiler/arm-none-eabi-m4/pkg.yml
index 5bb457c..6b33971 100644
--- a/compiler/arm-none-eabi-m4/pkg.yml
+++ b/compiler/arm-none-eabi-m4/pkg.yml
@@ -22,25 +22,11 @@ pkg.vers: 0.8.0
 pkg.description: Compiler definition for ARM Cortex-M4 gcc cross compiler.
 pkg.author: sterling <st...@runtime.io>
 pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.type: compiler
 pkg.keywords:
     - arm
     - compiler
     - cortex
     - m4
     - gcc
-
-compiler.path.cc: arm-none-eabi-gcc
-compiler.path.archive: arm-none-eabi-ar
-compiler.path.as: arm-none-eabi-gcc -x assembler-with-cpp
-compiler.path.objdump: arm-none-eabi-objdump
-compiler.path.objsize: arm-none-eabi-size
-compiler.path.objcopy: arm-none-eabi-objcopy
-
-compiler.flags.default: -mcpu=cortex-m4 -mthumb-interwork -mthumb -Wall -Werror -fno-exceptions -fomit-frame-pointer
-compiler.flags.optimized: [compiler.flags.default, -Os -ggdb]
-compiler.flags.debug: [compiler.flags.default, -O1 -ggdb]
-
-compiler.ld.flags: -static -lgcc
-compiler.ld.resolve_circular_deps: true
-compiler.ld.mapfile: true

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/compiler/sim/compiler.yml
----------------------------------------------------------------------
diff --git a/compiler/sim/compiler.yml b/compiler/sim/compiler.yml
new file mode 100644
index 0000000..9c03ab5
--- /dev/null
+++ b/compiler/sim/compiler.yml
@@ -0,0 +1,32 @@
+#
+# 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.
+#
+compiler.path.cc: "/usr/local/bin/gcc-5" 
+compiler.path.as: "/usr/local/bin/gcc-5 -x assembler-with-cpp"
+compiler.path.archive: "ar"
+compiler.path.objdump: "gobjdump"
+compiler.path.objsize: "objsize"
+compiler.path.objcopy: "gobjcopy"
+
+compiler.flags.base: >
+    -m32 -Wall -Werror -ggdb -DMN_OSX
+
+compiler.flags.default: [compiler.flags.base, -O1]
+compiler.flags.debug: [compiler.flags.base, -O0]
+
+compiler.ld.mapfile: false

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/compiler/sim/linux-compiler.yml
----------------------------------------------------------------------
diff --git a/compiler/sim/linux-compiler.yml b/compiler/sim/linux-compiler.yml
index a0951a8..4b70e33 100644
--- a/compiler/sim/linux-compiler.yml
+++ b/compiler/sim/linux-compiler.yml
@@ -17,18 +17,6 @@
 # under the License.
 #
 
-pkg.name: compiler/sim
-pkg.vers: 0.8.0
-pkg.description: Compiler definition for native gcc compiler.
-pkg.author: sterling <st...@runtime.io>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
-pkg.keywords:
-    - sim
-    - compiler
-    - gcc
-
-
 compiler.path.cc: "gcc"
 compiler.path.archive: "ar"
 compiler.path.objdump: "objdump"

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/compiler/sim/osx-compiler.yml
----------------------------------------------------------------------
diff --git a/compiler/sim/osx-compiler.yml b/compiler/sim/osx-compiler.yml
index de62ed9..93dece4 100644
--- a/compiler/sim/osx-compiler.yml
+++ b/compiler/sim/osx-compiler.yml
@@ -16,18 +16,6 @@
 # specific language governing permissions and limitations
 # under the License.
 #
-
-pkg.name: compiler/sim
-pkg.vers: 0.8.0
-pkg.description: Compiler definition for native gcc compiler.
-pkg.author: sterling <st...@runtime.io>
-pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
-pkg.keywords:
-    - sim
-    - compiler
-    - gcc
-
 compiler.path.cc: "/usr/local/bin/gcc-5" 
 compiler.path.archive: "ar"
 compiler.path.objdump: "gobjdump"

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/compiler/sim/pkg.yml
----------------------------------------------------------------------
diff --git a/compiler/sim/pkg.yml b/compiler/sim/pkg.yml
index c9ace8f..6078cc2 100644
--- a/compiler/sim/pkg.yml
+++ b/compiler/sim/pkg.yml
@@ -22,23 +22,10 @@ pkg.vers: 0.8.0
 pkg.description: Compiler definition for native gcc compiler.
 pkg.author: sterling <st...@runtime.io>
 pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.type: compiler
 pkg.keywords:
     - sim
     - compiler
     - gcc
 
-compiler.path.cc: "/usr/local/bin/gcc-5" 
-compiler.path.as: "/usr/local/bin/gcc-5 -x assembler-with-cpp"
-compiler.path.archive: "ar"
-compiler.path.objdump: "gobjdump"
-compiler.path.objsize: "objsize"
-compiler.path.objcopy: "gobjcopy"
-
-compiler.flags.base: >
-    -m32 -Wall -Werror -ggdb -DMN_OSX
-
-compiler.flags.default: [compiler.flags.base, -O1]
-compiler.flags.debug: [compiler.flags.base, -O0]
-
-compiler.ld.mapfile: false

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/fs/fs/pkg.yml
----------------------------------------------------------------------
diff --git a/fs/fs/pkg.yml b/fs/fs/pkg.yml
index cefb0bb..f1e0fcd 100644
--- a/fs/fs/pkg.yml
+++ b/fs/fs/pkg.yml
@@ -22,7 +22,7 @@ pkg.vers: 0.8.0
 pkg.description: File system abstrction.
 pkg.author: Marko Kiiskila <ma...@apache.org>
 pkg.homepage: http://mynewt.apache.org/os/modules/filesystem/
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
 pkg.keywords:
     - file
     - filesystem
@@ -33,5 +33,5 @@ pkg.deps.SHELL:
 pkg.reqs.SHELL:
     - console
 pkg.cflags.SHELL: -DSHELL_PRESENT
-pkg.identities:
+pkg.features:
     - FS

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/fs/nffs/pkg.yml
----------------------------------------------------------------------
diff --git a/fs/nffs/pkg.yml b/fs/nffs/pkg.yml
index d1878ac..ff7c694 100644
--- a/fs/nffs/pkg.yml
+++ b/fs/nffs/pkg.yml
@@ -22,13 +22,13 @@ pkg.vers: 0.8.0
 pkg.description: Newtron Flash File System.
 pkg.author: Christopher Collins <cc...@apache.org>
 pkg.homepage: http://mynewt.apache.org/os/modules/nffs/
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
 pkg.keywords:
     - file
     - filesystem
     - ffs
 
-pkg.identities: NFFS
+pkg.features: NFFS
 pkg.deps:
     - fs/fs
     - hw/hal

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/hw/bsp/native/native_debug.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/native/native_debug.sh b/hw/bsp/native/native_debug.sh
index 75b948b..2c35d90 100755
--- a/hw/bsp/native/native_debug.sh
+++ b/hw/bsp/native/native_debug.sh
@@ -16,18 +16,19 @@
 # specific language governing permissions and limitations
 # under the License.
 #
-# Called $0 <binary> [identities ...]
+# Called $0 <bsp_path> <binary> [identities ...]
+#  - bsp_directory_path is absolute path to hw/bsp/bsp_name
 #  - binary is the path to prefix to target binary, .elf appended to name is
 #    the ELF file
 #  - identities is the project identities string.
 #
 #
-if [ $# -lt 1 ]; then
+if [ $# -lt 2 ]; then
     echo "Need binary to debug"
     exit 1
 fi
 
-FILE_NAME=$1.elf
+FILE_NAME=$2.elf
 
 echo "Debugging" $FILE_NAME
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/hw/bsp/native/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/native/pkg.yml b/hw/bsp/native/pkg.yml
index 8267691..47cf4fa 100644
--- a/hw/bsp/native/pkg.yml
+++ b/hw/bsp/native/pkg.yml
@@ -22,11 +22,13 @@ pkg.vers: 0.8.0
 pkg.description: BSP definition for native (amd64) applications.
 pkg.author: Christopher Collins <cc...@apache.org>
 pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.type: bsp
 pkg.keywords:
     - native
     - bsp
 
+pkg.compiler: compiler/sim
 pkg.deps: 
     - hw/mcu/native
 pkg.deps.BLE_DEVICE:

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/hw/bsp/nrf51dk-16kbram/nrf51dk-16kbram_debug.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf51dk-16kbram/nrf51dk-16kbram_debug.sh b/hw/bsp/nrf51dk-16kbram/nrf51dk-16kbram_debug.sh
index aae123e..cff7216 100755
--- a/hw/bsp/nrf51dk-16kbram/nrf51dk-16kbram_debug.sh
+++ b/hw/bsp/nrf51dk-16kbram/nrf51dk-16kbram_debug.sh
@@ -16,19 +16,20 @@
 # specific language governing permissions and limitations
 # under the License.
 #
-# Called: $0 <binary> [identities...]
+# Called: $0 <bsp_directory_path> <binary> [features...]
+#  - bsp_directory_path is absolute path to hw/bsp/bsp_name
 #  - binary is the path to prefix to target binary, .elf.bin appended to this
 #    name is the raw binary format of the binary.
-#  - identities is the project identities string. So you can have e.g. different
-#    flash offset for bootloader identity
+#  - features are the target features. So you can have e.g. different
+#    flash offset for bootloader 'feature'
 # 
 #
-if [ $# -lt 1 ]; then
+if [ $# -lt 2 ]; then
     echo "Need binary to download"
     exit 1
 fi
 
-FILE_NAME=$1.elf
+FILE_NAME=$2.elf
 GDB_CMD_FILE=.gdb_cmds
 
 echo "Debugging" $FILE_NAME

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/hw/bsp/nrf51dk-16kbram/nrf51dk-16kbram_download.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf51dk-16kbram/nrf51dk-16kbram_download.sh b/hw/bsp/nrf51dk-16kbram/nrf51dk-16kbram_download.sh
index 4d8691e..5ce4bfa 100755
--- a/hw/bsp/nrf51dk-16kbram/nrf51dk-16kbram_download.sh
+++ b/hw/bsp/nrf51dk-16kbram/nrf51dk-16kbram_download.sh
@@ -16,25 +16,27 @@
 # specific language governing permissions and limitations
 # under the License.
 #
-# Called: $0 <binary> [identities...]
+# Called: $0 <bsp_directory_path> <binary> [features...]
+#  - bsp_directory_path is absolute path to hw/bsp/bsp_name
 #  - binary is the path to prefix to target binary, .elf.bin appended to this
 #    name is the raw binary format of the binary.
-#  - identities is the project identities string. So you can have e.g. different
-#    flash offset for bootloader identity
+#  - features are the target features. So you can have e.g. different
+#    flash offset for bootloader 'feature'
 # 
 #
-if [ $# -lt 1 ]; then
+if [ $# -lt 2 ]; then
     echo "Need binary to download"
     exit 1
 fi
 
 IS_BOOTLOADER=0
-BASENAME=$1
+BASENAME=$2
 #JLINK_SCRIPT=.download.jlink
 GDB_CMD_FILE=.gdb_cmds
 
 # Look for 'bootloader' from 2nd arg onwards
 shift
+shift
 while [ $# -gt 0 ]; do
     if [ $1 = "bootloader" ]; then
 	IS_BOOTLOADER=1

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/hw/bsp/nrf51dk-16kbram/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf51dk-16kbram/pkg.yml b/hw/bsp/nrf51dk-16kbram/pkg.yml
index ca82ca5..b0aab54 100644
--- a/hw/bsp/nrf51dk-16kbram/pkg.yml
+++ b/hw/bsp/nrf51dk-16kbram/pkg.yml
@@ -22,11 +22,13 @@ pkg.vers: 0.8.0
 pkg.description: BSP definition for a Nordic nRF51 DK SoC with 16kB RAM.
 pkg.author: Christopher Collins <ch...@apache.org>
 pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.type: bsp
 pkg.keywords:
     - nrf51
     - nrf51dk
 
+pkg.compiler: compiler/arm-none-eabi-m0
 pkg.linkerscript: "nrf51dk-16kbram.ld"
 pkg.linkerscript.bootloader.OVERWRITE: "boot-nrf51dk-16kbram.ld"
 pkg.downloadscript: nrf51dk-16kbram_download.sh

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/hw/bsp/nrf51dk/nrf51dk_debug.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf51dk/nrf51dk_debug.sh b/hw/bsp/nrf51dk/nrf51dk_debug.sh
index aae123e..0fe4c82 100755
--- a/hw/bsp/nrf51dk/nrf51dk_debug.sh
+++ b/hw/bsp/nrf51dk/nrf51dk_debug.sh
@@ -16,19 +16,20 @@
 # specific language governing permissions and limitations
 # under the License.
 #
-# Called: $0 <binary> [identities...]
+# Called: $0 <bsp_directory_path> <binary> [features...]
+#  - bsp_directory_path is absolute path to hw/bsp/bsp_name
 #  - binary is the path to prefix to target binary, .elf.bin appended to this
 #    name is the raw binary format of the binary.
-#  - identities is the project identities string. So you can have e.g. different
-#    flash offset for bootloader identity
+#  - features is the project identities string. So you can have e.g. different
+#    flash offset for bootloader 'feature'
 # 
 #
-if [ $# -lt 1 ]; then
+if [ $# -lt 2 ]; then
     echo "Need binary to download"
     exit 1
 fi
 
-FILE_NAME=$1.elf
+FILE_NAME=$2.elf
 GDB_CMD_FILE=.gdb_cmds
 
 echo "Debugging" $FILE_NAME

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/hw/bsp/nrf51dk/nrf51dk_download.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf51dk/nrf51dk_download.sh b/hw/bsp/nrf51dk/nrf51dk_download.sh
index 4d8691e..152fa14 100755
--- a/hw/bsp/nrf51dk/nrf51dk_download.sh
+++ b/hw/bsp/nrf51dk/nrf51dk_download.sh
@@ -16,24 +16,26 @@
 # specific language governing permissions and limitations
 # under the License.
 #
-# Called: $0 <binary> [identities...]
+# Called: $0 <bsp_directory_path> <binary> [features...]
+#  - bsp_directory_path is absolute path to hw/bsp/bsp_name
 #  - binary is the path to prefix to target binary, .elf.bin appended to this
 #    name is the raw binary format of the binary.
-#  - identities is the project identities string. So you can have e.g. different
-#    flash offset for bootloader identity
+#  - features is the project features string. So you can have e.g. different
+#    flash offset for bootloader 'feature'
 # 
 #
-if [ $# -lt 1 ]; then
+if [ $# -lt 2 ]; then
     echo "Need binary to download"
     exit 1
 fi
 
 IS_BOOTLOADER=0
-BASENAME=$1
+BASENAME=$2
 #JLINK_SCRIPT=.download.jlink
 GDB_CMD_FILE=.gdb_cmds
 
-# Look for 'bootloader' from 2nd arg onwards
+# Look for 'bootloader' from 3rd arg onwards
+shift
 shift
 while [ $# -gt 0 ]; do
     if [ $1 = "bootloader" ]; then

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/hw/bsp/nrf51dk/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf51dk/pkg.yml b/hw/bsp/nrf51dk/pkg.yml
index 94cd052..056b976 100644
--- a/hw/bsp/nrf51dk/pkg.yml
+++ b/hw/bsp/nrf51dk/pkg.yml
@@ -22,11 +22,13 @@ pkg.vers: 0.8.0
 pkg.description: BSP definition for the Nordic nRF51 DK SoC.
 pkg.author: wes3 <wi...@runtime.io>
 pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.type: bsp
 pkg.keywords:
     - nrf51
     - nrf51dk
 
+pkg.compiler: compiler/arm-none-eabi-m0
 pkg.linkerscript: "nrf51dk.ld" 
 pkg.linkerscript.bootloader.OVERWRITE: "boot-nrf51dk.ld"
 pkg.downloadscript: nrf51dk_download.sh

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/hw/bsp/nrf52pdk/nrf52pdk_debug.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf52pdk/nrf52pdk_debug.sh b/hw/bsp/nrf52pdk/nrf52pdk_debug.sh
index 85385cf..9ea091c 100755
--- a/hw/bsp/nrf52pdk/nrf52pdk_debug.sh
+++ b/hw/bsp/nrf52pdk/nrf52pdk_debug.sh
@@ -16,11 +16,12 @@
 # specific language governing permissions and limitations
 # under the License.
 #
-# Called: $0 <binary> [identities...]
+# Called: $0 <bsp_directory_path> <binary> [features...]
+#  - bsp_directory_path is absolute path to hw/bsp/bsp_name
 #  - binary is the path to prefix to target binary, .elf.bin appended to this
 #    name is the raw binary format of the binary.
-#  - identities is the project identities string. So you can have e.g. different
-#    flash offset for bootloader identity
+#  - features are the target features. So you can have e.g. different
+#    flash offset for bootloader 'feature'
 # 
 #
 if [ $# -lt 1 ]; then
@@ -28,7 +29,7 @@ if [ $# -lt 1 ]; then
     exit 1
 fi
 
-FILE_NAME=$1.elf
+FILE_NAME=$2.elf
 GDB_CMD_FILE=.gdb_cmds
 
 echo "Debugging" $FILE_NAME

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/hw/bsp/nrf52pdk/nrf52pdk_download.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf52pdk/nrf52pdk_download.sh b/hw/bsp/nrf52pdk/nrf52pdk_download.sh
index a897368..c0259c1 100755
--- a/hw/bsp/nrf52pdk/nrf52pdk_download.sh
+++ b/hw/bsp/nrf52pdk/nrf52pdk_download.sh
@@ -16,20 +16,21 @@
 # specific language governing permissions and limitations
 # under the License.
 #
-# Called: $0 <binary> [identities...]
+# Called: $0 <bsp_directory_path> <binary> [features...]
+#  - bsp_directory_path is absolute path to hw/bsp/bsp_name
 #  - binary is the path to prefix to target binary, .elf.bin appended to this
 #    name is the raw binary format of the binary.
-#  - identities is the project identities string. So you can have e.g. different
-#    flash offset for bootloader identity
+#  - features are the target features. So you can have e.g. different
+#    flash offset for bootloader 'feature'
 # 
 #
-if [ $# -lt 1 ]; then
+if [ $# -lt 2 ]; then
     echo "Need binary to download"
     exit 1
 fi
 
 FLASH_OFFSET=0x0
-FILE_NAME=$1.elf.bin
+FILE_NAME=$2.elf.bin
 JLINK_SCRIPT=.download.jlink
 
 echo "Downloading" $FILE_NAME "to" $FLASH_OFFSET

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/hw/bsp/nrf52pdk/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf52pdk/pkg.yml b/hw/bsp/nrf52pdk/pkg.yml
index 06e12f9..b136084 100644
--- a/hw/bsp/nrf52pdk/pkg.yml
+++ b/hw/bsp/nrf52pdk/pkg.yml
@@ -22,11 +22,13 @@ pkg.vers: 0.8.0
 pkg.description: BSP definition for the Nordic nRF52 Preview DK SoC.
 pkg.author: wes3 <wi...@runtime.io>
 pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.type: bsp
 pkg.keywords:
     - nrf52
     - nrf52dk
 
+pkg.compiler: compiler/arm-none-eabi-m4
 pkg.linkerscript: "nrf52pdk.ld"
 pkg.linkerscript.bootloader.OVERWRITE: "boot-nrf52pdk.ld"
 pkg.downloadscript: nrf52pdk_download.sh

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_debug.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_debug.sh b/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_debug.sh
index 6a8ec28..d402753 100755
--- a/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_debug.sh
+++ b/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_debug.sh
@@ -16,18 +16,21 @@
 # specific language governing permissions and limitations
 # under the License.
 #
-# Called: $0 <binary> [identities...]
+# Called: $0 <bsp_path> <binary> [identities...]
+#  - bsp_directory_path is absolute path to hw/bsp/bsp_name
 #  - binary is the path to prefix to target binary, .elf appended to name is
 #    the ELF file
 #  - identities is the project identities string.
 # 
 #
-if [ $# -lt 1 ]; then
+set -x
+if [ $# -lt 2 ]; then
     echo "Need binary to debug"
     exit 1
 fi
 
-FILE_NAME=$1.elf
+MY_PATH=$1
+FILE_NAME=$2.elf
 GDB_CMD_FILE=.gdb_cmds
 
 echo "Debugging" $FILE_NAME
@@ -37,7 +40,7 @@ echo "Debugging" $FILE_NAME
 # Exit openocd when gdb detaches.
 #
 set -m
-openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -s hw/bsp/olimex_stm32-e407_devboard -f f407.cfg -c "gdb_port 3333; telnet_port 4444; stm32f4x.cpu configure -event gdb-detach {shutdown}" -c init -c "reset halt" &
+openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -s $MY_PATH -f f407.cfg -c "gdb_port 3333; telnet_port 4444; stm32f4x.cpu configure -event gdb-detach {shutdown}" -c init -c "reset halt" &
 set +m
 
 echo "target remote localhost:3333" > $GDB_CMD_FILE

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_download.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_download.sh b/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_download.sh
index 3467e64..e48aa35 100755
--- a/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_download.sh
+++ b/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_download.sh
@@ -16,22 +16,25 @@
 # specific language governing permissions and limitations
 # under the License.
 #
-# Called: $0 <binary> [identities...]
+# Called: $0 <bsp_directory_path> <binary> [features...]
+#  - bsp_directory_path is absolute path to hw/bsp/bsp_name
 #  - binary is the path to prefix to target binary, .elf.bin appended to this
 #    name is the raw binary format of the binary.
-#  - identities is the project identities string. So you can have e.g. different
-#    flash offset for bootloader identity
+#  - features are the target features. So you can have e.g. different
+#    flash offset for bootloader 'feature'
 # 
 #
-if [ $# -lt 1 ]; then
+if [ $# -lt 2 ]; then
     echo "Need binary to download"
     exit 1
 fi
 
-BASENAME=$1
+MYPATH=$1
+BASENAME=$2
 IS_BOOTLOADER=0
 
-# Look for 'bootloader' from 2nd arg onwards
+# Look for 'bootloader' from 3rd arg onwards
+shift
 shift
 while [ $# -gt 0 ]; do
     if [ $1 = "bootloader" ]; then
@@ -49,5 +52,5 @@ else
 fi
 echo "Downloading" $FILE_NAME "to" $FLASH_OFFSET
 
-openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -s hw/bsp/olimex_stm32-e407_devboard -f f407.cfg -c init -c "reset halt" -c "flash write_image erase $FILE_NAME $FLASH_OFFSET" -c "reset run" -c shutdown
+openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -s $MYPATH -f f407.cfg -c init -c "reset halt" -c "flash write_image erase $FILE_NAME $FLASH_OFFSET" -c "reset run" -c shutdown
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/hw/bsp/olimex_stm32-e407_devboard/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/olimex_stm32-e407_devboard/pkg.yml b/hw/bsp/olimex_stm32-e407_devboard/pkg.yml
index 9aa47bf..885693e 100644
--- a/hw/bsp/olimex_stm32-e407_devboard/pkg.yml
+++ b/hw/bsp/olimex_stm32-e407_devboard/pkg.yml
@@ -22,12 +22,14 @@ pkg.vers: 0.8.0
 pkg.description: BSP definition for the Olimex STM32-E407 board.
 pkg.author: Sterling Hughes <st...@apache.org>
 pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
+pkg.type: bsp
 pkg.keywords:
     - olimex
     - stm32
     - e407
 
+pkg.compiler: compiler/arm-none-eabi-m4
 pkg.linkerscript: "olimex_stm32-e407_devboard.ld" 
 pkg.linkerscript.bootloader.OVERWRITE: "boot-olimex_stm32-e407_devboard.ld"
 pkg.downloadscript: "olimex_stm32-e407_devboard_download.sh"

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/hw/hal/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/hal/pkg.yml b/hw/hal/pkg.yml
index fb486ed..a92e9e4 100644
--- a/hw/hal/pkg.yml
+++ b/hw/hal/pkg.yml
@@ -22,7 +22,7 @@ pkg.vers: 0.8.0
 pkg.description: Hardware Abstraction Layer.
 pkg.author: wes3 <wi...@runtime.io>
 pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
 pkg.keywords:
 
 pkg.deps: libs/os

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/hw/mcu/native/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/mcu/native/pkg.yml b/hw/mcu/native/pkg.yml
index 60d585f..83b2ce1 100644
--- a/hw/mcu/native/pkg.yml
+++ b/hw/mcu/native/pkg.yml
@@ -22,7 +22,7 @@ pkg.vers: 0.8.0
 pkg.description: MCU definition native applications.
 pkg.author: Christopher Collins <ch...@apache.org>
 pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
 pkg.keywords:
     - native
     - x86

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/hw/mcu/nordic/nrf51xxx/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/nrf51xxx/pkg.yml b/hw/mcu/nordic/nrf51xxx/pkg.yml
index 2fea49c..d200472 100644
--- a/hw/mcu/nordic/nrf51xxx/pkg.yml
+++ b/hw/mcu/nordic/nrf51xxx/pkg.yml
@@ -22,7 +22,7 @@ pkg.vers: 0.8.0
 pkg.description: MCU definition for Nordic nRF51 ARM Cortex-M0 chips.
 pkg.author: wes3 <wi...@runtime.io>
 pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
 pkg.keywords:
     - nrf51
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/hw/mcu/nordic/nrf52xxx/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/nrf52xxx/pkg.yml b/hw/mcu/nordic/nrf52xxx/pkg.yml
index fa47e5d..780b308 100644
--- a/hw/mcu/nordic/nrf52xxx/pkg.yml
+++ b/hw/mcu/nordic/nrf52xxx/pkg.yml
@@ -22,7 +22,7 @@ pkg.vers: 0.8.0
 pkg.description: MCU definition for Nordic nRF52 ARM Cortex-M4 chips.
 pkg.author: wes3 <wi...@runtime.io>
 pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
 pkg.keywords:
     - nrf52
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/hw/mcu/stm/stm32f4xx/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/mcu/stm/stm32f4xx/pkg.yml b/hw/mcu/stm/stm32f4xx/pkg.yml
index abe9e96..843110a 100644
--- a/hw/mcu/stm/stm32f4xx/pkg.yml
+++ b/hw/mcu/stm/stm32f4xx/pkg.yml
@@ -22,7 +22,7 @@ pkg.vers: 0.8.0
 pkg.description: MCU definition for STM32F4 ARM Cortex-M4 chips.
 pkg.author: wes3 <wi...@runtime.io>
 pkg.homepage:
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
 pkg.keywords:
     - stm32
     - stm32f4

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/libs/baselibc/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/baselibc/pkg.yml b/libs/baselibc/pkg.yml
index 460d1c6..1b242da 100644
--- a/libs/baselibc/pkg.yml
+++ b/libs/baselibc/pkg.yml
@@ -22,11 +22,11 @@ pkg.vers: 0.8.0
 pkg.description: Simple libc for embedded systems.
 pkg.author: Petteri Aimonen
 pkg.homepage: https://github.com/PetteriAimonen/Baselibc
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
 pkg.keywords:
     - libc
 
-pkg.req_caps:
+pkg.req_apis:
     - console
-pkg.identities:
+pkg.features:
     - LIBC

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/libs/bootutil/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/bootutil/pkg.yml b/libs/bootutil/pkg.yml
index 6373d6d..5424dd2 100644
--- a/libs/bootutil/pkg.yml
+++ b/libs/bootutil/pkg.yml
@@ -22,7 +22,7 @@ pkg.vers: 0.8.0
 pkg.description: The bootutil library performs most of the functions of a boot loader.
 pkg.author: Christopher Collins <cc...@apache.org>
 pkg.homepage: http://mynewt.apache.org/os/modules/bootloader/bootloader/
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
 pkg.keywords:
     - boot
     - bootloader

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/libs/cmsis-core/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/cmsis-core/pkg.yml b/libs/cmsis-core/pkg.yml
index 87d7d48..9cd9aef 100644
--- a/libs/cmsis-core/pkg.yml
+++ b/libs/cmsis-core/pkg.yml
@@ -22,7 +22,7 @@ pkg.vers: 0.8.0
 pkg.description: CMSIS-CORE abstraction layer for Cortex-M processors.
 pkg.author: Keil
 pkg.homepage: http://www.keil.com/pack/doc/CMSIS/Core/html/index.html
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
 pkg.keywords:
     - cmsis
     - core

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/libs/console/full/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/console/full/pkg.yml b/libs/console/full/pkg.yml
index ac145c1..68830ab 100644
--- a/libs/console/full/pkg.yml
+++ b/libs/console/full/pkg.yml
@@ -22,10 +22,10 @@ pkg.vers: 0.8.0
 pkg.description: Text-based IO interface.
 pkg.author: Marko Kiiskila <ma...@runtime.io>
 pkg.homepage: http://mynewt.apache.org/os/modules/console/console/
-pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
+pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
 pkg.keywords:
 
 pkg.deps:
     - hw/hal
     - libs/os
-pkg.caps: console
+pkg.apis: console