mynewt-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sterl...@apache.org
Subject [16/49] incubator-mynewt-core git commit: directory re-org
Date Thu, 29 Sep 2016 01:34:23 GMT
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6a7432f4/libs/flash_test/src/flash_test/flash_test.c
----------------------------------------------------------------------
diff --git a/libs/flash_test/src/flash_test/flash_test.c b/libs/flash_test/src/flash_test/flash_test.c
deleted file mode 100644
index 980cbba..0000000
--- a/libs/flash_test/src/flash_test/flash_test.c
+++ /dev/null
@@ -1,155 +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 <inttypes.h>
-#include <os/os.h>
-#include <console/console.h>
-#include <flash_test/flash_test.h>
-#include <hal/hal_bsp.h>
-#include <hal/hal_flash.h>
-#include <hal/hal_flash_int.h>
-#include <shell/shell.h>
-#include <stdio.h>
-#include <string.h>
-
-static int flash_cli_cmd(int argc, char **argv);
-static struct shell_cmd flash_cmd_struct = {
-    .sc_cmd = "flash",
-    .sc_cmd_func = flash_cli_cmd
-};
-
-static int
-flash_cli_cmd(int argc, char **argv)
-{
-    const struct hal_flash *hf;
-    uint32_t off = 0;
-    uint32_t sz = 1;
-    int sec_cnt;
-    int i;
-    int soff;
-    char *eptr;
-    char tmp_buf[8];
-    char pr_str[80];
-
-    hf = bsp_flash_dev(0);
-    if (!hf) {
-        console_printf("No flash device present\n");
-        return 0;
-    }
-    if (argc == 1) {
-        /*
-         * print status
-         */
-        console_printf("Flash at 0x%lx size 0x%lx with %d sectors,"
-          "alignment req %d bytes\n", 
-                (long unsigned int) hf->hf_base_addr, 
-                (long unsigned int) hf->hf_size,
-                hf->hf_sector_cnt, 
-                hf->hf_align);
-        sec_cnt = hf->hf_sector_cnt;
-        if (sec_cnt > 32) {
-            sec_cnt = 32;
-        }
-        for (i = 0; i < sec_cnt; i++) {
-            console_printf("  %d: %lx\n", i, 
-                    (long unsigned int) hal_flash_sector_size(hf, i));
-        }
-        if (sec_cnt != hf->hf_sector_cnt) {
-            console_printf("...  %d: %lx\n", hf->hf_sector_cnt - 1,
-              (long unsigned int) hal_flash_sector_size(hf, hf->hf_sector_cnt - 1));
-        }
-        return 0;
-    }
-    if (argc > 2) {
-        off = strtoul(argv[2], &eptr, 0);
-        if (*eptr != '\0') {
-            console_printf("Invalid offset %s\n", argv[2]);
-            goto err;
-        }
-    }
-    if (argc > 3) {
-        sz = strtoul(argv[3], &eptr, 0);
-        if (*eptr != '\0') {
-            console_printf("Invalid size %s\n", argv[3]);
-            goto err;
-        }
-    }
-    if (!strcmp(argv[1], "erase")) {
-        console_printf("Erase 0x%lx + %lx\n", 
-                (long unsigned int) off, (long unsigned int) sz);
-
-        if (hal_flash_erase(0, off, sz)) {
-            console_printf("Flash erase failed\n");
-        }
-        console_printf("Done!\n");
-    } else if (!strcmp(argv[1], "read")) {
-        console_printf("Read 0x%lx + %lx\n", 
-                (long unsigned int) off, (long unsigned int) sz);
-        sz += off;
-        while (off < sz) {
-            sec_cnt = min(sizeof(tmp_buf), sz - off);
-            if (hal_flash_read(0, off, tmp_buf, sec_cnt)) {
-                console_printf("flash read failure at %lx\n", 
-                        (long unsigned int) off);
-                break;
-            }
-            for (i = 0, soff = 0; i < sec_cnt; i++) {
-                soff += snprintf(pr_str + soff, sizeof(pr_str) - soff,
-                  "0x%02x ", tmp_buf[i] & 0xff);
-            }
-            console_printf("  0x%lx: %s\n", 
-                    (long unsigned int) off, pr_str);
-            off += sec_cnt;
-        }
-    } else if (!strcmp(argv[1], "write")) {
-        console_printf("Write 0x%lx + %lx\n", 
-                (long unsigned int) off, (long unsigned int) sz);
-
-        sz += off;
-        for (i = 0; i < sizeof(tmp_buf); i++) {
-            tmp_buf[i] = i + 1;
-        }
-
-        while (off < sz) {
-            sec_cnt = min(sizeof(tmp_buf), sz - off);
-            if (hal_flash_write(0, off, tmp_buf, sec_cnt)) {
-                console_printf("flash write failure at %lx\n", 
-                        (long unsigned int) off);
-            }
-            off += sec_cnt;
-        }
-        console_printf("Done!\n");
-    } else if ( !strcmp(argv[1], "?") || !strcmp(argv[1], "help"))
-    {
-        console_printf("Commands Available\n");
-        console_printf("flash -- dumps sector map \n");
-        console_printf("flash read <offset> <size> -- reads bytes from flash \n");
-        console_printf("flash write <offset>  <size>  -- writes incrementing data pattern 0-8 to flash \n");
-        console_printf("flash erase <offset> <size> -- erases flash \n");
-    }
-    return 0;
-err:
-    return -1;
-}
-
-
-int
-flash_test_init(void) {
-    shell_cmd_register(&flash_cmd_struct);
-    return 0;
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6a7432f4/libs/imgmgr/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/imgmgr/pkg.yml b/libs/imgmgr/pkg.yml
index 65d12a5..8ff48b4 100644
--- a/libs/imgmgr/pkg.yml
+++ b/libs/imgmgr/pkg.yml
@@ -24,8 +24,8 @@ pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
 
 pkg.deps:
-    - libs/bootutil
-    - libs/util
+    - boot/bootutil
+    - encoding/base64
 
 pkg.req_apis:
     - newtmgr
@@ -37,7 +37,7 @@ pkg.deps.IMGMGR_COREDUMP:
     - sys/coredump
 
 pkg.deps.IMGMGR_SHELL:
-    - libs/shell
+    - sys/shell
 
 pkg.init_function: imgmgr_module_init
 pkg.init_stage: 5

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6a7432f4/libs/imgmgr/src/imgmgr.c
----------------------------------------------------------------------
diff --git a/libs/imgmgr/src/imgmgr.c b/libs/imgmgr/src/imgmgr.c
index 04ec43c..ed317b8 100644
--- a/libs/imgmgr/src/imgmgr.c
+++ b/libs/imgmgr/src/imgmgr.c
@@ -26,7 +26,7 @@
 #include "hal/hal_bsp.h"
 #include "hal/flash_map.h"
 #include "json/json.h"
-#include "util/base64.h"
+#include "base64/base64.h"
 #include "bootutil/image.h"
 #include "bootutil/bootutil_misc.h"
 #include "newtmgr/newtmgr.h"

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6a7432f4/libs/imgmgr/src/imgmgr_boot.c
----------------------------------------------------------------------
diff --git a/libs/imgmgr/src/imgmgr_boot.c b/libs/imgmgr/src/imgmgr_boot.c
index 0473f25..1168278 100644
--- a/libs/imgmgr/src/imgmgr_boot.c
+++ b/libs/imgmgr/src/imgmgr_boot.c
@@ -28,7 +28,7 @@
 #include <bootutil/image.h>
 #include <bootutil/bootutil_misc.h>
 #include <json/json.h>
-#include <util/base64.h>
+#include <base64/base64.h>
 #include <hal/hal_bsp.h>
 
 #include "imgmgr/imgmgr.h"

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6a7432f4/libs/imgmgr/src/imgmgr_cli.c
----------------------------------------------------------------------
diff --git a/libs/imgmgr/src/imgmgr_cli.c b/libs/imgmgr/src/imgmgr_cli.c
index da1c0bf..ee0e862 100644
--- a/libs/imgmgr/src/imgmgr_cli.c
+++ b/libs/imgmgr/src/imgmgr_cli.c
@@ -32,7 +32,7 @@
 #include <bootutil/image.h>
 #include <bootutil/bootutil_misc.h>
 
-#include <util/hex.h>
+#include <base64/hex.h>
 
 #include "imgmgr/imgmgr.h"
 #include "imgmgr_priv.h"

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6a7432f4/libs/imgmgr/src/imgmgr_coredump.c
----------------------------------------------------------------------
diff --git a/libs/imgmgr/src/imgmgr_coredump.c b/libs/imgmgr/src/imgmgr_coredump.c
index 17c430d..79ff608 100644
--- a/libs/imgmgr/src/imgmgr_coredump.c
+++ b/libs/imgmgr/src/imgmgr_coredump.c
@@ -26,7 +26,7 @@
 #include "hal/flash_map.h"
 #include "newtmgr/newtmgr.h"
 #include "coredump/coredump.h"
-#include "util/base64.h"
+#include "base64/base64.h"
 
 #include "imgmgr/imgmgr.h"
 #include "imgmgr_priv.h"

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6a7432f4/libs/imgmgr/src/imgmgr_fs.c
----------------------------------------------------------------------
diff --git a/libs/imgmgr/src/imgmgr_fs.c b/libs/imgmgr/src/imgmgr_fs.c
index af4579d..d44fd55 100644
--- a/libs/imgmgr/src/imgmgr_fs.c
+++ b/libs/imgmgr/src/imgmgr_fs.c
@@ -32,7 +32,7 @@
 #include "bootutil/image.h"
 #include "fs/fs.h"
 #include "json/json.h"
-#include "util/base64.h"
+#include "base64/base64.h"
 #include "bsp/bsp.h"
 
 #include "imgmgr/imgmgr.h"

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6a7432f4/libs/iotivity/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/iotivity/pkg.yml b/libs/iotivity/pkg.yml
index 6c2480e..bfd0b31 100644
--- a/libs/iotivity/pkg.yml
+++ b/libs/iotivity/pkg.yml
@@ -24,8 +24,8 @@ pkg.homepage: "https://www.iotivity.org/"
 pkg.keywords:
 
 pkg.deps:
-    - "@apache-mynewt-core/libs/tinycbor"
-    - "@apache-mynewt-core/libs/os"
+    - "@apache-mynewt-core/encoding/tinycbor"
+    - "@apache-mynewt-core/kernel/os"
     - "@apache-mynewt-core/sys/log"
 
 pkg.deps.OC_TRANSPORT_GATT:
@@ -34,10 +34,10 @@ pkg.deps.OC_TRANSPORT_GATT:
     - "@apache-mynewt-core/net/nimble/host/services/gatt"
 
 pkg.deps.OC_TRANSPORT_IP:
-    - "@apache-mynewt-core/sys/mn_socket"
+    - "@apache-mynewt-core/net/ip/mn_socket"
 
 pkg.deps.OC_TRANSPORT_SERIAL:
-    - "@apache-mynewt-core/libs/shell"
+    - "@apache-mynewt-core/sys/shell"
 
 # remove debug option to save logging
 pkg.cflags: -std=c99

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6a7432f4/libs/json/MSJSON_COPYING
----------------------------------------------------------------------
diff --git a/libs/json/MSJSON_COPYING b/libs/json/MSJSON_COPYING
deleted file mode 100644
index 2267ff2..0000000
--- a/libs/json/MSJSON_COPYING
+++ /dev/null
@@ -1,28 +0,0 @@
-			BSD LICENSE
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-
-Redistributions of source code must retain the above copyright
-notice, this list of conditions and the following disclaimer.
-
-Redistributions in binary form must reproduce the above copyright
-notice, this list of conditions and the following disclaimer in the
-documentation and/or other materials provided with the distribution.
-
-Neither name of the GPSD project nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR
-CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6a7432f4/libs/json/include/json/json.h
----------------------------------------------------------------------
diff --git a/libs/json/include/json/json.h b/libs/json/include/json/json.h
deleted file mode 100644
index ecf098a..0000000
--- a/libs/json/include/json/json.h
+++ /dev/null
@@ -1,245 +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 _JSON_H_
-#define _JSON_H_
-
-#include <stdbool.h>
-#include <stdint.h>
-#include <ctype.h>
-#include <stdio.h>
-#include <sys/types.h>
-
-
-#define JSON_VALUE_TYPE_BOOL   (0)
-#define JSON_VALUE_TYPE_UINT64 (1)
-#define JSON_VALUE_TYPE_INT64  (2)
-#define JSON_VALUE_TYPE_STRING (3)
-#define JSON_VALUE_TYPE_ARRAY  (4)
-#define JSON_VALUE_TYPE_OBJECT (5)
-
-/**
- * For encode.  The contents of a JSON value to encode.
- */
-struct json_value {
-    uint8_t jv_pad1;
-    uint8_t jv_type;
-    uint16_t jv_len;
-
-    union {
-        uint64_t u;
-        float fl;
-        char *str;
-        struct {
-            char **keys;
-            struct json_value **values;
-        } composite;
-    } jv_val;
-};
-
-#define JSON_VALUE_STRING(__jv, __str)        \
-    (__jv)->jv_type = JSON_VALUE_TYPE_STRING; \
-    (__jv)->jv_len = strlen(__str);           \
-    (__jv)->jv_val.str = (__str);
-
-#define JSON_VALUE_STRINGN(__jv, __str, __len) \
-    (__jv)->jv_type = JSON_VALUE_TYPE_STRING;  \
-    (__jv)->jv_len = (uint16_t) (__len);                    \
-    (__jv)->jv_val.str = (__str);
-
-#define JSON_VALUE_BOOL(__jv, __v)            \
-    (__jv)->jv_type = JSON_VALUE_TYPE_BOOL;   \
-    (__jv)->jv_val.u = (__v);
-
-#define JSON_VALUE_INT(__jv, __v)             \
-    (__jv)->jv_type = JSON_VALUE_TYPE_INT64;  \
-    (__jv)->jv_val.u = (uint64_t) __v;
-
-#define JSON_VALUE_UINT(__jv, __v)            \
-    (__jv)->jv_type = JSON_VALUE_TYPE_UINT64; \
-    (__jv)->jv_val.u = (uint64_t) __v;
-
-/* Encoding functions */
-typedef int (*json_write_func_t)(void *buf, char *data,
-        int len);
-
-struct json_encoder {
-    json_write_func_t je_write;
-    void *je_arg;
-    int je_wr_commas:1;
-    char je_encode_buf[64];
-};
-
-
-#define JSON_NITEMS(x) (int)(sizeof(x)/sizeof(x[0]))
-
-int json_encode_object_start(struct json_encoder *);
-int json_encode_object_key(struct json_encoder *encoder, char *key);
-int json_encode_object_entry(struct json_encoder *, char *,
-        struct json_value *);
-int json_encode_object_finish(struct json_encoder *);
-
-int json_encode_array_name(struct json_encoder *encoder, char *name);
-int json_encode_array_start(struct json_encoder *encoder);
-int json_encode_array_value(struct json_encoder *encoder, struct json_value *val);
-int json_encode_array_finish(struct json_encoder *encoder);
-
-/* Json parser definitions */
-typedef enum {
-    t_integer,
-    t_uinteger,
-    t_real,
-    t_string,
-    t_boolean,
-    t_character,
-    t_object,
-    t_structobject,
-    t_array,
-    t_check,
-    t_ignore
-} json_type;
-
-struct json_enum_t {
-    char *name;
-    long long int value;
-};
-
-struct json_array_t {
-    json_type element_type;
-    union {
-        struct {
-            const struct json_attr_t *subtype;
-            char *base;
-            size_t stride;
-        } objects;
-        struct {
-            char **ptrs;
-            char *store;
-            int storelen;
-        } strings;
-        struct {
-            long long int *store;
-        } integers;
-        struct {
-            long long unsigned int *store;
-        } uintegers;
-        struct {
-            double *store;
-        } reals;
-        struct {
-            bool *store;
-        } booleans;
-    } arr;
-    int *count;
-    int maxlen;
-};
-
-struct json_attr_t {
-    char *attribute;
-    json_type type;
-    union {
-        long long int *integer;
-        long long unsigned int *uinteger;
-        double *real;
-        char *string;
-        bool *boolean;
-        char *character;
-        struct json_array_t array;
-        size_t offset;
-    } addr;
-    union {
-        long long int integer;
-        long long unsigned int uinteger;
-        double real;
-        bool boolean;
-        char character;
-        char *check;
-    } dflt;
-    size_t len;
-    const struct json_enum_t *map;
-    bool nodefault;
-};
-
-struct json_buffer;
-
-/* when you implement a json buffer, you must implement these functions */
-
-/* returns the next character in the buffer or '\0'*/
-typedef char (*json_buffer_read_next_byte_t)(struct json_buffer *);
-/* returns the previous character in the buffer or '\0' */
-typedef char (*json_buffer_read_prev_byte_t)(struct json_buffer *);
-/* returns the number of characters read or zero */
-typedef int (*json_buffer_readn_t)(struct json_buffer *, char *buf, int n);
-
-struct json_buffer {
-    json_buffer_readn_t jb_readn;
-    json_buffer_read_next_byte_t jb_read_next;
-    json_buffer_read_prev_byte_t jb_read_prev;
-};
-
-#define JSON_ATTR_MAX        31        /* max chars in JSON attribute name */
-#define JSON_VAL_MAX        512        /* max chars in JSON value part */
-
-int json_read_object(struct json_buffer *, const struct json_attr_t *);
-int json_read_array(struct json_buffer *, const struct json_array_t *);
-
-#define JSON_ERR_OBSTART     1   /* non-WS when expecting object start */
-#define JSON_ERR_ATTRSTART   2   /* non-WS when expecting attrib start */
-#define JSON_ERR_BADATTR     3   /* unknown attribute name */
-#define JSON_ERR_ATTRLEN     4   /* attribute name too long */
-#define JSON_ERR_NOARRAY     5   /* saw [ when not expecting array */
-#define JSON_ERR_NOBRAK      6   /* array element specified, but no [ */
-#define JSON_ERR_STRLONG     7   /* string value too long */
-#define JSON_ERR_TOKLONG     8   /* token value too long */
-#define JSON_ERR_BADTRAIL    9   /* garbage while expecting comma or } or ] */
-#define JSON_ERR_ARRAYSTART  10  /* didn't find expected array start */
-#define JSON_ERR_OBJARR      11  /* error while parsing object array */
-#define JSON_ERR_SUBTOOLONG  12  /* too many array elements */
-#define JSON_ERR_BADSUBTRAIL 13  /* garbage while expecting array comma */
-#define JSON_ERR_SUBTYPE     14  /* unsupported array element type */
-#define JSON_ERR_BADSTRING   15  /* error while string parsing */
-#define JSON_ERR_CHECKFAIL   16  /* check attribute not matched */
-#define JSON_ERR_NOPARSTR    17  /* can't support strings in parallel arrays */
-#define JSON_ERR_BADENUM     18  /* invalid enumerated value */
-#define JSON_ERR_QNONSTRING  19  /* saw quoted value when expecting nonstring */
-#define JSON_ERR_NONQSTRING  19  /* didn't see quoted value when expecting string */
-#define JSON_ERR_MISC        20  /* other data conversion error */
-#define JSON_ERR_BADNUM      21  /* error while parsing a numerical argument */
-#define JSON_ERR_NULLPTR     22  /* unexpected null value or attribute pointer */
-
-/*
- * Use the following macros to declare template initializers for structobject
- * arrays.  Writing the equivalents out by hand is error-prone.
- *
- * JSON_STRUCT_OBJECT takes a structure name s, and a fieldname f in s.
- *
- * JSON_STRUCT_ARRAY takes the name of a structure array, a pointer to a an
- * initializer defining the subobject type, and the address of an integer to
- * store the length in.
- */
-#define JSON_STRUCT_OBJECT(s, f)        .addr.offset = offsetof(s, f)
-#define JSON_STRUCT_ARRAY(a, e, n) \
-        .addr.array.element_type = t_structobject, \
-        .addr.array.arr.objects.subtype = e, \
-        .addr.array.arr.objects.base = (char*)a, \
-        .addr.array.arr.objects.stride = sizeof(a[0]), \
-        .addr.array.count = n, \
-        .addr.array.maxlen = (int)(sizeof(a)/sizeof(a[0]))
-
-#endif /* _JSON_H_ */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6a7432f4/libs/json/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/json/pkg.yml b/libs/json/pkg.yml
deleted file mode 100644
index 4944622..0000000
--- a/libs/json/pkg.yml
+++ /dev/null
@@ -1,26 +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: libs/json 
-pkg.description: JSON encoding / decoding library.
-pkg.author: "Apache Mynewt <dev@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/6a7432f4/libs/json/src/json_decode.c
----------------------------------------------------------------------
diff --git a/libs/json/src/json_decode.c b/libs/json/src/json_decode.c
deleted file mode 100644
index b78bbfd..0000000
--- a/libs/json/src/json_decode.c
+++ /dev/null
@@ -1,670 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-
-#include "json/json.h"
-
-/**
- * This file is based upon microjson, from Eric S Raymond.
- *
- * License information for MicroJSON is in the package file MSJSON_COPYING,
- * it is BSD licensed source code.
- */
-
-
-/****************************************************************************
-
-NAME
-   mjson.c - parse JSON into fixed-extent data structures
-
-DESCRIPTION
-   This module parses a large subset of JSON (JavaScript Object
-Notation).  Unlike more general JSON parsers, it doesn't use malloc(3)
-and doesn't support polymorphism; you need to give it a set of
-template structures describing the expected shape of the incoming
-JSON, and it will error out if that shape is not matched.  When the
-parse succeeds, attribute values will be extracted into static
-locations specified in the template structures.
-
-   The "shape" of a JSON object in the type signature of its
-attributes (and attribute values, and so on recursively down through
-all nestings of objects and arrays).  This parser is indifferent to
-the order of attributes at any level, but you have to tell it in
-advance what the type of each attribute value will be and where the
-parsed value will be stored. The template structures may supply
-default values to be used when an expected attribute is omitted.
-
-   The preceding paragraph told one fib.  A single attribute may
-actually have a span of multiple specifications with different
-syntactically distinguishable types (e.g. string vs. real vs. integer
-vs. boolean, but not signed integer vs. unsigned integer).  The parser
-will match the right spec against the actual data.
-
-   The dialect this parses has some limitations.  First, it cannot
-recognize the JSON "null" value. Second, all elements of an array must
-be of the same type. Third, characters may not be array elements (this
-restriction could be lifted)
-
-   There are separate entry points for beginning a parse of either
-JSON object or a JSON array. JSON "float" quantities are actually
-stored as doubles.
-
-   This parser processes object arrays in one of two different ways,
-defending on whether the array subtype is declared as object or
-structobject.
-
-   Object arrays take one base address per object subfield, and are
-mapped into parallel C arrays (one per subfield).  Strings are not
-supported in this kind of array, as they don't have a "natural" size
-to use as an offset multiplier.
-
-   Structobjects arrays are a way to parse a list of objects to a set
-of modifications to a corresponding array of C structs.  The trick is
-that the array object initialization has to specify both the C struct
-array's base address and the stride length (the size of the C struct).
-If you initialize the offset fields with the correct offsetof calls,
-everything will work. Strings are supported but all string storage
-has to be inline in the struct.
-
-PERMISSIONS
-   This file is Copyright (c) 2014 by Eric S. Raymond
-   BSD terms apply: see the file COPYING in the distribution root for details.
-
-***************************************************************************/
-
-#include <string.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <stdarg.h>
-#include <ctype.h>
-#include <math.h>        /* for HUGE_VAL */
-
-static void
-json_skip_ws(struct json_buffer *jb)
-{
-    char c;
-
-    do {
-        c = jb->jb_read_next(jb);
-    } while (isspace(c));
-
-    jb->jb_read_prev(jb);
-}
-
-static char
-json_peek(struct json_buffer *jb)
-{
-    char c;
-
-    jb->jb_read_next(jb);
-    c = jb->jb_read_prev(jb);
-
-    return c;
-}
-
-static char *
-json_target_address(const struct json_attr_t *cursor,
-        const struct json_array_t *parent, int offset)
-{
-    char *targetaddr = NULL;
-    if (parent == NULL || parent->element_type != t_structobject) {
-        /* ordinary case - use the address in the cursor structure */
-        switch (cursor->type) {
-        case t_ignore:
-            targetaddr = NULL;
-            break;
-        case t_integer:
-            targetaddr = (char *)&cursor->addr.integer[offset];
-            break;
-        case t_uinteger:
-            targetaddr = (char *)&cursor->addr.uinteger[offset];
-            break;
-        case t_real:
-            targetaddr = (char *)&cursor->addr.real[offset];
-            break;
-        case t_string:
-            targetaddr = cursor->addr.string;
-            break;
-        case t_boolean:
-            targetaddr = (char *)&cursor->addr.boolean[offset];
-            break;
-        case t_character:
-            targetaddr = (char *)&cursor->addr.character[offset];
-            break;
-        default:
-            targetaddr = NULL;
-            break;
-        }
-    } else {
-        /* tricky case - hacking a member in an array of structures */
-        targetaddr =
-            parent->arr.objects.base + (offset * parent->arr.objects.stride) +
-            cursor->addr.offset;
-    }
-    return targetaddr;
-}
-
-static int
-json_internal_read_object(struct json_buffer *jb,
-                          const struct json_attr_t *attrs,
-                          const struct json_array_t *parent,
-                          int offset)
-{
-    char c;
-    enum {
-        init, await_attr, in_attr, await_value, in_val_string,
-        in_escape, in_val_token, post_val, post_array
-    } state = 0;
-    char attrbuf[JSON_ATTR_MAX + 1], *pattr = NULL;
-    char valbuf[JSON_VAL_MAX + 1], *pval = NULL;
-    bool value_quoted = false;
-    char uescape[5];    /* enough space for 4 hex digits and '\0' */
-    const struct json_attr_t *cursor;
-    int substatus, n, maxlen = 0;
-    unsigned int u;
-    const struct json_enum_t *mp;
-    char *lptr;
-
-#ifdef S_SPLINT_S
-    /* prevents gripes about buffers not being completely defined */
-    memset(valbuf, '\0', sizeof(valbuf));
-    memset(attrbuf, '\0', sizeof(attrbuf));
-#endif /* S_SPLINT_S */
-
-    /* stuff fields with defaults in case they're omitted in the JSON input */
-    for (cursor = attrs; cursor->attribute != NULL; cursor++) {
-        if (!cursor->nodefault) {
-            lptr = json_target_address(cursor, parent, offset);
-            if (lptr != NULL) {
-                switch (cursor->type) {
-                case t_integer:
-                    memcpy(lptr, &cursor->dflt.integer, sizeof(long long int));
-                    break;
-                case t_uinteger:
-                    memcpy(lptr, &cursor->dflt.uinteger,
-                           sizeof(long long unsigned int));
-                    break;
-                case t_real:
-                    memcpy(lptr, &cursor->dflt.real, sizeof(double));
-                    break;
-                case t_string:
-                    if (parent != NULL
-                        && parent->element_type != t_structobject
-                        && offset > 0) {
-                        return JSON_ERR_NOPARSTR;
-                    }
-                    lptr[0] = '\0';
-                    break;
-                case t_boolean:
-                    memcpy(lptr, &cursor->dflt.boolean, sizeof(bool));
-                    break;
-                case t_character:
-                    lptr[0] = cursor->dflt.character;
-                    break;
-                case t_object:        /* silences a compiler warning */
-                case t_structobject:
-                case t_array:
-                case t_check:
-                case t_ignore:
-                    break;
-                }
-            }
-        }
-    }
-
-    /* parse input JSON */
-    for (c = jb->jb_read_next(jb); c != '\0'; c = jb->jb_read_next(jb)) {
-        switch (state) {
-        case init:
-            if (isspace((unsigned char) c)) {
-                continue;
-            } else if (c == '{') {
-                state = await_attr;
-            } else {
-                return JSON_ERR_OBSTART;
-            }
-            break;
-        case await_attr:
-            if (isspace((unsigned char) c)) {
-                continue;
-            } else if (c == '"') {
-                state = in_attr;
-                pattr = attrbuf;
-            } else if (c == '}') {
-                break;
-            } else {
-                return JSON_ERR_ATTRSTART;
-            }
-            break;
-        case in_attr:
-            if (pattr == NULL) {
-                /* don't update end here, leave at attribute start */
-                return JSON_ERR_NULLPTR;
-            }
-            if (c == '"') {
-                *pattr++ = '\0';
-                for (cursor = attrs; cursor->attribute != NULL; cursor++) {
-                    if (strcmp(cursor->attribute, attrbuf) == 0) {
-                        break;
-                    }
-                }
-                if (cursor->attribute == NULL) {
-                    /* don't update end here, leave at attribute start */
-                    return JSON_ERR_BADATTR;
-                }
-                state = await_value;
-                if (cursor->type == t_string) {
-                    maxlen = (int)cursor->len - 1;
-                } else if (cursor->type == t_check) {
-                    maxlen = (int)strlen(cursor->dflt.check);
-                } else if (cursor->type == t_ignore) {
-                    maxlen = JSON_VAL_MAX;
-                } else if (cursor->map != NULL) {
-                    maxlen = (int)sizeof(valbuf) - 1;
-                } else if (cursor->type == t_boolean) {
-                    maxlen = 5; /* false */
-                }
-                pval = valbuf;
-            } else if (pattr >= attrbuf + JSON_ATTR_MAX - 1) {
-                /* don't update end here, leave at attribute start */
-                return JSON_ERR_ATTRLEN;
-            } else {
-                *pattr++ = c;
-            }
-            break;
-        case await_value:
-            if (isspace((unsigned char) c) || c == ':') {
-                continue;
-            } else if (c == '[') {
-                if (cursor->type != t_array) {
-                    return JSON_ERR_NOARRAY;
-                }
-                c = jb->jb_read_prev(jb);
-                substatus = json_read_array(jb, &cursor->addr.array);
-                if (substatus != 0) {
-                    return substatus;
-                }
-                state = post_array;
-            } else if (cursor->type == t_array) {
-                return JSON_ERR_NOBRAK;
-            } else if (c == '"') {
-                value_quoted = true;
-                state = in_val_string;
-                pval = valbuf;
-            } else {
-                value_quoted = false;
-                state = in_val_token;
-                pval = valbuf;
-                *pval++ = c;
-            }
-            break;
-        case in_val_string:
-            if (pval == NULL) {
-                /* don't update end here, leave at value start */
-                return JSON_ERR_NULLPTR;
-            }
-            if (c == '\\') {
-                state = in_escape;
-            } else if (c == '"') {
-                *pval++ = '\0';
-                state = post_val;
-            } else if (pval > valbuf + JSON_VAL_MAX - 1
-                       || pval > valbuf + maxlen) {
-                /* don't update end here, leave at value start */
-                return JSON_ERR_STRLONG;        /*  */
-            } else {
-                *pval++ = c;
-            }
-            break;
-        case in_escape:
-            if (pval == NULL) {
-                /* don't update end here, leave at value start */
-                return JSON_ERR_NULLPTR;
-            }
-            switch (c) {
-            case 'b':
-                *pval++ = '\b';
-                break;
-            case 'f':
-                *pval++ = '\f';
-                break;
-            case 'n':
-                *pval++ = '\n';
-                break;
-            case 'r':
-                *pval++ = '\r';
-                break;
-            case 't':
-                *pval++ = '\t';
-                break;
-            case 'u':
-                for (n = 0; n < 4 && c != '\0'; n++) {
-                    uescape[n] = c;
-                    c = jb->jb_read_next(jb);
-                }
-                // Scroll back one
-                c = jb->jb_read_prev(jb);
-                (void)sscanf(uescape, "%04x", &u);
-                *pval++ = (char)u;        /* will truncate values above 0xff */
-                break;
-            default:                /* handles double quote and solidus */
-                *pval++ = c;
-                break;
-            }
-            state = in_val_string;
-            break;
-        case in_val_token:
-            if (pval == NULL) {
-                /* don't update end here, leave at value start */
-                return JSON_ERR_NULLPTR;
-            }
-            if (isspace((unsigned char) c) || c == ',' || c == '}') {
-                *pval = '\0';
-                state = post_val;
-                if (c == '}' || c == ',') {
-                    c = jb->jb_read_prev(jb);
-                }
-            } else if (pval > valbuf + JSON_VAL_MAX - 1) {
-                /* don't update end here, leave at value start */
-                return JSON_ERR_TOKLONG;
-            } else {
-                *pval++ = c;
-            }
-            break;
-        case post_val:
-            /*
-             * We know that cursor points at the first spec matching
-             * the current attribute.  We don't know that it's *the*
-             * correct spec; our dialect allows there to be any number
-             * of adjacent ones with the same attrname but different
-             * types.  Here's where we try to seek forward for a
-             * matching type/attr pair if we're not looking at one.
-             */
-            for (;;) {
-                int seeking = cursor->type;
-                if (value_quoted && (cursor->type == t_string)) {
-                    break;
-                }
-                if ((strcmp(valbuf, "true")==0 || strcmp(valbuf, "false")==0)
-                        && seeking == t_boolean) {
-                    break;
-                }
-                if (isdigit((unsigned char) valbuf[0])) {
-                    bool decimal = strchr(valbuf, '.') != NULL;
-                    if (decimal && seeking == t_real) {
-                        break;
-                    }
-                    if (!decimal && (seeking == t_integer ||
-                                     seeking == t_uinteger)) {
-                        break;
-                    }
-                }
-                if (cursor[1].attribute==NULL) {       /* out of possiblities */
-                    break;
-                }
-                if (strcmp(cursor[1].attribute, attrbuf)!=0) {
-                    break;
-                }
-                ++cursor;
-            }
-            if (value_quoted
-                && (cursor->type != t_string && cursor->type != t_character
-                    && cursor->type != t_check && cursor->type != t_ignore
-                    && cursor->map == 0)) {
-                return JSON_ERR_QNONSTRING;
-            }
-            if (!value_quoted
-                && (cursor->type == t_string || cursor->type == t_check
-                    || cursor->map != 0)) {
-                return JSON_ERR_NONQSTRING;
-            }
-            if (cursor->map != 0) {
-                for (mp = cursor->map; mp->name != NULL; mp++) {
-                    if (strcmp(mp->name, valbuf) == 0) {
-                        goto foundit;
-                    }
-                }
-                return JSON_ERR_BADENUM;
-              foundit:
-                (void)snprintf(valbuf, sizeof(valbuf), "%lld", mp->value);
-            }
-            lptr = json_target_address(cursor, parent, offset);
-            if (lptr != NULL) {
-                switch (cursor->type) {
-                case t_integer: {
-                        long long int tmp =
-                            (long long int)strtoll(valbuf, NULL, 10);
-                        memcpy(lptr, &tmp, sizeof(long long int));
-                    }
-                    break;
-                case t_uinteger: {
-                        long long unsigned int tmp =
-                            (long long unsigned int)strtoull(valbuf, NULL, 10);
-                        memcpy(lptr, &tmp, sizeof(long long unsigned int));
-                    }
-                    break;
-                case t_real: {
-#ifdef FLOAT_SUPPORT
-                        double tmp = atof(valbuf);
-                        memcpy(lptr, &tmp, sizeof(double));
-#else
-                        return JSON_ERR_MISC;
-#endif
-                    }
-                    break;
-                case t_string:
-                    if (parent != NULL
-                        && parent->element_type != t_structobject
-                        && offset > 0) {
-                        return JSON_ERR_NOPARSTR;
-                    }
-                    (void)strncpy(lptr, valbuf, cursor->len);
-                    valbuf[sizeof(valbuf)-1] = '\0';
-                    break;
-                case t_boolean: {
-                        bool tmp = (strcmp(valbuf, "true") == 0);
-                        memcpy(lptr, &tmp, sizeof(bool));
-                    }
-                    break;
-                case t_character:
-                    if (strlen(valbuf) > 1) {
-                        /* don't update end here, leave at value start */
-                        return JSON_ERR_STRLONG;
-                    } else {
-                        lptr[0] = valbuf[0];
-                    }
-                    break;
-                case t_ignore:        /* silences a compiler warning */
-                case t_object:        /* silences a compiler warning */
-                case t_structobject:
-                case t_array:
-                    break;
-                case t_check:
-                    if (strcmp(cursor->dflt.check, valbuf) != 0) {
-                        /* don't update end here, leave at start of attribute */
-                        return JSON_ERR_CHECKFAIL;
-                    }
-                    break;
-                }
-            }
-            /*@fallthrough@*/
-        case post_array:
-            if (isspace((unsigned char) c)) {
-                continue;
-            } else if (c == ',') {
-                state = await_attr;
-            } else if (c == '}') {
-                c = jb->jb_read_next(jb);
-                goto good_parse;
-            } else {
-                return JSON_ERR_BADTRAIL;
-            }
-            break;
-        }
-    }
-
-  good_parse:
-    /* in case there's another object following, consume trailing WS */
-    while (isspace((unsigned char) jb->jb_read_next(jb))) {
-    }
-    return 0;
-}
-
-int
-json_read_array(struct json_buffer *jb, const struct json_array_t *arr)
-{
-    char valbuf[64];
-    char c;
-    int substatus, offset, arrcount;
-    char *tp;
-    int n, count;
-
-    json_skip_ws(jb);
-
-    if (jb->jb_read_next(jb) != '[') {
-        return JSON_ERR_ARRAYSTART;
-    }
-
-    tp = arr->arr.strings.store;
-    arrcount = 0;
-
-    json_skip_ws(jb);
-
-    if (json_peek(jb) == ']') {
-        goto breakout;
-    }
-
-    for (offset = 0; offset < arr->maxlen; offset++) {
-        json_skip_ws(jb);
-
-        char *ep = NULL;
-        switch (arr->element_type) {
-        case t_string:
-            if (jb->jb_read_next(jb) != '"') {
-                return JSON_ERR_BADSTRING;
-            }
-            arr->arr.strings.ptrs[offset] = tp;
-            for (; tp - arr->arr.strings.store < arr->arr.strings.storelen;
-                 tp++) {
-                c = jb->jb_read_next(jb);
-                if (c == '"') {
-                    c = jb->jb_read_next(jb);
-                    *tp++ = '\0';
-                    goto stringend;
-                } else if (c == '\0') {
-                    return JSON_ERR_BADSTRING;
-                } else {
-                    *tp = c;
-                    c = jb->jb_read_next(jb);
-                }
-            }
-            return JSON_ERR_BADSTRING;
-          stringend:
-            break;
-        case t_object:
-        case t_structobject:
-            substatus =
-                json_internal_read_object(jb, arr->arr.objects.subtype, arr,
-                                          offset);
-            if (substatus != 0) {
-                return substatus;
-            }
-            break;
-        case t_integer:
-            n = jb->jb_readn(jb, valbuf, sizeof(valbuf)-1);
-            valbuf[n] = '\0';
-
-            arr->arr.integers.store[offset] = strtoll(valbuf, &ep, 0);
-            if (ep == valbuf) {
-                return JSON_ERR_BADNUM;
-            } else {
-                count = n - (ep - valbuf);
-                while (count-- > 0) {
-                    jb->jb_read_prev(jb);
-                }
-            }
-            break;
-        case t_uinteger:
-            n = jb->jb_readn(jb, valbuf, sizeof(valbuf)-1);
-            valbuf[n] = '\0';
-
-            arr->arr.uintegers.store[offset] = strtoull(valbuf, &ep, 0);
-            if (ep == valbuf) {
-                return JSON_ERR_BADNUM;
-            } else {
-                count = n - (ep - valbuf);
-                while (count-- > 0) {
-                    jb->jb_read_prev(jb);
-                }
-            }
-            break;
-        case t_real:
-#ifdef FLOAT_SUPPORT
-            n = jb->jb_readn(jb, valbuf, sizeof(valbuf)-1);
-            valbuf[n] = '\0';
-
-            arr->arr.reals.store[offset] = strtod(valbuf, &ep);
-            if (ep == valbuf) {
-                return JSON_ERR_BADNUM;
-            } else {
-                count = ep - valbuf;
-                while (count-- > 0) {
-                    c = jb->jb_read_next(jb);
-                }
-            }
-#else
-            return JSON_ERR_MISC;
-#endif
-            break;
-        case t_boolean:
-            n = jb->jb_readn(jb, valbuf, 5);
-            valbuf[n] = '\0';
-
-            if (strncmp(valbuf, "true", 4) == 0) {
-                arr->arr.booleans.store[offset] = true;
-                count = n - 4;
-            } else if (strncmp(valbuf, "false", 5) == 0) {
-                arr->arr.booleans.store[offset] = false;
-                count = n - 5;
-            } else {
-                return JSON_ERR_MISC;
-            }
-
-            assert(count >= 0);
-            while (count-- > 0) {
-                jb->jb_read_prev(jb);
-            }
-            break;
-        case t_character:
-        case t_array:
-        case t_check:
-        case t_ignore:
-            return JSON_ERR_SUBTYPE;
-        }
-        arrcount++;
-        json_skip_ws(jb);
-
-        c = jb->jb_read_next(jb);
-        if (c == ']') {
-            goto breakout;
-        } else if (c != ',') {
-            return JSON_ERR_BADSUBTRAIL;
-        }
-    }
-    return JSON_ERR_SUBTOOLONG;
-  breakout:
-    if (arr->count != NULL) {
-        *(arr->count) = arrcount;
-    }
-    return 0;
-}
-
-int
-json_read_object(struct json_buffer *jb, const struct json_attr_t *attrs)
-{
-    int st;
-
-    st = json_internal_read_object(jb, attrs, NULL, 0);
-    return st;
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6a7432f4/libs/json/src/json_encode.c
----------------------------------------------------------------------
diff --git a/libs/json/src/json_encode.c b/libs/json/src/json_encode.c
deleted file mode 100644
index 8512a66..0000000
--- a/libs/json/src/json_encode.c
+++ /dev/null
@@ -1,248 +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 <stdio.h>
-#include <string.h>
-
-#include <json/json.h>
-
-#define JSON_ENCODE_OBJECT_START(__e) \
-    (__e)->je_write((__e)->je_arg, "{", sizeof("{")-1);
-
-#define JSON_ENCODE_OBJECT_END(__e) \
-    (__e)->je_write((__e)->je_arg, "}", sizeof("}")-1);
-
-#define JSON_ENCODE_ARRAY_START(__e) \
-    (__e)->je_write((__e)->je_arg, "[", sizeof("[")-1);
-
-#define JSON_ENCODE_ARRAY_END(__e) \
-    (__e)->je_write((__e)->je_arg, "]", sizeof("]")-1);
-
-
-int
-json_encode_object_start(struct json_encoder *encoder)
-{
-    if (encoder->je_wr_commas) {
-        encoder->je_write(encoder->je_arg, ",", sizeof(",")-1);
-        encoder->je_wr_commas = 0;
-    }
-    JSON_ENCODE_OBJECT_START(encoder);
-    encoder->je_wr_commas = 0;
-
-    return (0);
-}
-
-static int
-json_encode_value(struct json_encoder *encoder, struct json_value *jv)
-{
-    int rc;
-    int i;
-    int len;
-
-    switch (jv->jv_type) {
-        case JSON_VALUE_TYPE_BOOL:
-            len = sprintf(encoder->je_encode_buf, "%s",
-                    jv->jv_val.u > 0 ? "true" : "false");
-            encoder->je_write(encoder->je_arg, encoder->je_encode_buf, len);
-            break;
-        case JSON_VALUE_TYPE_UINT64:
-            len = sprintf(encoder->je_encode_buf, "%llu",
-                    jv->jv_val.u);
-            encoder->je_write(encoder->je_arg, encoder->je_encode_buf, len);
-            break;
-        case JSON_VALUE_TYPE_INT64:
-            len = sprintf(encoder->je_encode_buf, "%lld",
-                    jv->jv_val.u);
-            encoder->je_write(encoder->je_arg, encoder->je_encode_buf, len);
-            break;
-        case JSON_VALUE_TYPE_STRING:
-            encoder->je_write(encoder->je_arg, "\"", sizeof("\"")-1);
-            for (i = 0; i < jv->jv_len; i++) {
-                switch (jv->jv_val.str[i]) {
-                    case '"':
-                    case '/':
-                    case '\\':
-                        encoder->je_write(encoder->je_arg, "\\",
-                                sizeof("\\")-1);
-                        encoder->je_write(encoder->je_arg,
-                                (char *) &jv->jv_val.str[i], 1);
-
-                        break;
-                    case '\t':
-                        encoder->je_write(encoder->je_arg, "\\t",
-                                sizeof("\\t")-1);
-                        break;
-                    case '\r':
-                        encoder->je_write(encoder->je_arg, "\\r",
-                                sizeof("\\r")-1);
-                        break;
-                    case '\n':
-                        encoder->je_write(encoder->je_arg, "\\n",
-                                sizeof("\\n")-1);
-                        break;
-                    case '\f':
-                        encoder->je_write(encoder->je_arg, "\\f",
-                                sizeof("\\f")-1);
-                        break;
-                    case '\b':
-                        encoder->je_write(encoder->je_arg, "\\b",
-                                sizeof("\\b")-1);
-                        break;
-                   default:
-                        encoder->je_write(encoder->je_arg,
-                                (char *) &jv->jv_val.str[i], 1);
-                        break;
-                }
-
-            }
-            encoder->je_write(encoder->je_arg, "\"", sizeof("\"")-1);
-            break;
-        case JSON_VALUE_TYPE_ARRAY:
-            JSON_ENCODE_ARRAY_START(encoder);
-            for (i = 0; i < jv->jv_len; i++) {
-                rc = json_encode_value(encoder, jv->jv_val.composite.values[i]);
-                if (rc != 0) {
-                    goto err;
-                }
-                if (i != jv->jv_len - 1) {
-                    encoder->je_write(encoder->je_arg, ",", sizeof(",")-1);
-                }
-            }
-            JSON_ENCODE_ARRAY_END(encoder);
-            break;
-        case JSON_VALUE_TYPE_OBJECT:
-            JSON_ENCODE_OBJECT_START(encoder);
-            for (i = 0; i < jv->jv_len; i++) {
-                rc = json_encode_object_entry(encoder,
-                        jv->jv_val.composite.keys[i],
-                        jv->jv_val.composite.values[i]);
-                if (rc != 0) {
-                    goto err;
-                }
-            }
-            JSON_ENCODE_OBJECT_END(encoder);
-            break;
-        default:
-            rc = -1;
-            goto err;
-    }
-
-
-    return (0);
-err:
-    return (rc);
-}
-
-int
-json_encode_object_key(struct json_encoder *encoder, char *key)
-{
-    if (encoder->je_wr_commas) {
-        encoder->je_write(encoder->je_arg, ",", sizeof(",")-1);
-        encoder->je_wr_commas = 0;
-    }
-
-    /* Write the key entry */
-    encoder->je_write(encoder->je_arg, "\"", sizeof("\"")-1);
-    encoder->je_write(encoder->je_arg, key, strlen(key));
-    encoder->je_write(encoder->je_arg, "\": ", sizeof("\": ")-1);
-
-    return (0);
-}
-
-int
-json_encode_object_entry(struct json_encoder *encoder, char *key,
-        struct json_value *val)
-{
-    int rc;
-
-    if (encoder->je_wr_commas) {
-        encoder->je_write(encoder->je_arg, ",", sizeof(",")-1);
-        encoder->je_wr_commas = 0;
-    }
-    /* Write the key entry */
-    encoder->je_write(encoder->je_arg, "\"", sizeof("\"")-1);
-    encoder->je_write(encoder->je_arg, key, strlen(key));
-    encoder->je_write(encoder->je_arg, "\": ", sizeof("\": ")-1);
-
-    rc = json_encode_value(encoder, val);
-    if (rc != 0) {
-        goto err;
-    }
-    encoder->je_wr_commas = 1;
-
-    return (0);
-err:
-    return (rc);
-}
-
-int
-json_encode_object_finish(struct json_encoder *encoder)
-{
-    JSON_ENCODE_OBJECT_END(encoder);
-    /* Useful in case of nested objects. */
-    encoder->je_wr_commas = 1;
-
-    return (0);
-}
-
-int
-json_encode_array_name(struct json_encoder *encoder, char *name)
-{
-    return json_encode_object_key(encoder, name);
-}
-
-int
-json_encode_array_start(struct json_encoder *encoder)
-{
-    JSON_ENCODE_ARRAY_START(encoder);
-    encoder->je_wr_commas = 0;
-
-    return (0);
-}
-
-int
-json_encode_array_value(struct json_encoder *encoder, struct json_value *jv)
-{
-    int rc;
-
-    if (encoder->je_wr_commas) {
-        encoder->je_write(encoder->je_arg, ",", sizeof(",")-1);
-        encoder->je_wr_commas = 0;
-    }
-
-    rc = json_encode_value(encoder, jv);
-    if (rc != 0) {
-        goto err;
-    }
-    encoder->je_wr_commas = 1;
-
-    return (0);
-err:
-    return (rc);
-}
-
-
-int
-json_encode_array_finish(struct json_encoder *encoder)
-{
-    encoder->je_wr_commas = 1;
-    JSON_ENCODE_ARRAY_END(encoder);
-
-    return (0);
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6a7432f4/libs/json/test/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/json/test/pkg.yml b/libs/json/test/pkg.yml
deleted file mode 100644
index 65f2de0..0000000
--- a/libs/json/test/pkg.yml
+++ /dev/null
@@ -1,30 +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: libs/json/test
-pkg.type: unittest
-pkg.description: "JSON unit tests."
-pkg.author: "Apache Mynewt <dev@mynewt.incubator.apache.org>"
-pkg.homepage: "http://mynewt.apache.org/"
-pkg.keywords:
-
-pkg.deps: 
-    - libs/json
-    - libs/testutil
-
-pkg.deps.SELFTEST:
-    - libs/console/stub

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6a7432f4/libs/json/test/src/test_json.c
----------------------------------------------------------------------
diff --git a/libs/json/test/src/test_json.c b/libs/json/test/src/test_json.c
deleted file mode 100644
index dab3f06..0000000
--- a/libs/json/test/src/test_json.c
+++ /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.
- */
-
-#include "syscfg/syscfg.h"
-#include "testutil/testutil.h"
-#include "test_json.h"
-
-
-TEST_SUITE(test_json_suite) {
-    test_json_simple_encode();
-    test_json_simple_decode();
-}
-
-#if MYNEWT_VAL(SELFTEST)
-
-int
-main(int argc, char **argv)
-{
-    tu_config.tc_print_results = 1;
-    tu_init();
-
-    test_json_suite();
-
-    return tu_any_failed;
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6a7432f4/libs/json/test/src/test_json.h
----------------------------------------------------------------------
diff --git a/libs/json/test/src/test_json.h b/libs/json/test/src/test_json.h
deleted file mode 100644
index ea5efcf..0000000
--- a/libs/json/test/src/test_json.h
+++ /dev/null
@@ -1,27 +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 TEST_JSON_H
-#define TEST_JSON_H
-
-TEST_CASE_DECL(test_json_simple_encode);
-TEST_CASE_DECL(test_json_simple_decode);
-
-#endif /* TEST_JSON_H */
-

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6a7432f4/libs/json/test/src/test_json_simple.c
----------------------------------------------------------------------
diff --git a/libs/json/test/src/test_json_simple.c b/libs/json/test/src/test_json_simple.c
deleted file mode 100644
index 0f9e10e..0000000
--- a/libs/json/test/src/test_json_simple.c
+++ /dev/null
@@ -1,360 +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 "testutil/testutil.h"
-#include "test_json.h"
-#include "json/json.h"
-
-static char *output = "{\"KeyBool\": true,\"KeyInt\": -1234,\"KeyUint\": 1353214,\"KeyString\": \"foobar\",\"KeyStringN\": \"foobarlong\",\"KeyIntArr\": [153,2532,-322]}";
-
-static char *output1 ="{\"KeyBoolArr\": [true, false], \"KeyUintArr\": [0, 65535, 4294967295, 8589934590, 3451257]}";
-static char *outputboolspace = "{\"KeyBoolArr\": [    true    ,    false,true         ]}";
-static char *outputboolempty = "{\"KeyBoolArr\": , \"KeyBoolArr\": [  ]}";
-
-static char bigbuf[512];
-static int buf_index;
-
-static int test_write(void *buf, char* data, int len) {
-    int i;
-    for(i = 0; i < len; i++) {
-        bigbuf[buf_index++] = data[i];
-    }
-    return len;
-}
-
-TEST_CASE(test_json_simple_encode){
-    struct json_encoder encoder;
-    struct json_value value;
-    int rc;
-
-    /* reset the state of the internal test */
-    buf_index = 0;
-    memset(&encoder, 0, sizeof(encoder));
-
-    encoder.je_write = test_write;
-    encoder.je_arg= NULL;
-
-    rc = json_encode_object_start(&encoder);
-    TEST_ASSERT(rc == 0);
-
-    JSON_VALUE_BOOL(&value, 1);
-    rc = json_encode_object_entry(&encoder, "KeyBool", &value);
-    TEST_ASSERT(rc == 0);
-
-    JSON_VALUE_INT(&value, -1234);
-    rc = json_encode_object_entry(&encoder, "KeyInt", &value);
-    TEST_ASSERT(rc == 0);
-
-    JSON_VALUE_UINT(&value, 1353214);
-    rc = json_encode_object_entry(&encoder, "KeyUint", &value);
-    TEST_ASSERT(rc == 0);
-
-    JSON_VALUE_STRING(&value, "foobar");
-    rc = json_encode_object_entry(&encoder, "KeyString", &value);
-    TEST_ASSERT(rc == 0);
-
-    /* we'll decode later differently */
-    JSON_VALUE_STRINGN(&value, "foobarlongstring", 10);
-    rc = json_encode_object_entry(&encoder, "KeyStringN", &value);
-    TEST_ASSERT(rc == 0);
-
-    rc = json_encode_array_name(&encoder, "KeyIntArr");
-    TEST_ASSERT(rc == 0);
-
-    rc = json_encode_array_start(&encoder);
-    TEST_ASSERT(rc == 0);
-
-    JSON_VALUE_INT(&value, 153);
-    rc = json_encode_array_value(&encoder, &value);
-    TEST_ASSERT(rc == 0);
-
-    JSON_VALUE_INT(&value, 2532);
-    rc = json_encode_array_value(&encoder, &value);
-    TEST_ASSERT(rc == 0);
-
-    JSON_VALUE_INT(&value, -322);
-    rc = json_encode_array_value(&encoder, &value);
-    TEST_ASSERT(rc == 0);
-
-    rc = json_encode_array_finish(&encoder);
-    TEST_ASSERT(rc == 0);
-
-    rc = json_encode_object_finish(&encoder);
-    TEST_ASSERT(rc == 0);
-
-    /* does it match what we expect it to */
-    rc = strcmp(bigbuf, output);
-    TEST_ASSERT(rc == 0);
-}
-
-
-/* a test structure to hold the json flat buffer and pass bytes
- * to the decoder */
-struct test_jbuf {
-    /* json_buffer must be first element in the structure */
-    struct json_buffer json_buf;
-    char * start_buf;
-    char * end_buf;
-    int current_position;
-};
-
-
-static char
-test_jbuf_read_next(struct json_buffer *jb) {
-    char c;
-    struct test_jbuf  *ptjb = (struct test_jbuf*) jb;
-
-    if((ptjb->start_buf + ptjb->current_position) <= ptjb->end_buf) {
-        c = *(ptjb->start_buf + ptjb->current_position);
-        ptjb->current_position++;
-        return c;
-    }
-    return '\0';
-}
-
-/* this goes backward in the buffer one character */
-static char
-test_jbuf_read_prev(struct json_buffer *jb) {
-    char c;
-    struct test_jbuf  *ptjb = (struct test_jbuf*) jb;
-    if(ptjb->current_position) {
-       ptjb->current_position--;
-       c = *(ptjb->start_buf + ptjb->current_position);
-       return c;
-    }
-
-    /* can't rewind */
-    return '\0';
-
-}
-
-static int
-test_jbuf_readn(struct json_buffer *jb, char *buf, int size) {
-    struct test_jbuf  *ptjb = (struct test_jbuf*) jb;
-
-    int remlen;
-
-    remlen = ptjb->end_buf - (ptjb->start_buf + ptjb->current_position);
-    if (size > remlen) {
-        size = remlen;
-    }
-
-    memcpy(buf, ptjb->start_buf + ptjb->current_position, size);
-    ptjb->current_position += size;
-    return size;
-}
-
-static void
-test_buf_init(struct test_jbuf *ptjb, char *string) {
-    /* initialize the decode */
-    ptjb->json_buf.jb_read_next = test_jbuf_read_next;
-    ptjb->json_buf.jb_read_prev = test_jbuf_read_prev;
-    ptjb->json_buf.jb_readn = test_jbuf_readn;
-    ptjb->start_buf = string;
-    ptjb->end_buf = string + strlen(string);
-    /* end buf points to the NULL */
-    ptjb->current_position = 0;
-}
-
-/* now test the decode on a string */
-TEST_CASE(test_json_simple_decode){
-    struct test_jbuf tjb;
-    struct test_jbuf tjb1;
-    struct test_jbuf tjbboolspacearr;
-    struct test_jbuf tjbboolemptyarr;
-    long long unsigned int uint_val;
-    long long int int_val;
-    bool bool_val;
-    char string1[16];
-    char string2[16];
-    long long int intarr[8];
-    int rc;
-    int rc1;
-    int rcbsa;
-    int array_count;
-    int array_countemp;
-    bool boolarr[2];
-    unsigned long long uintarr[5];
-    int array_count1;
-    int array_count1u;
-    bool boolspacearr[3];
-    bool boolemptyarr[2];
-    
-    struct json_attr_t test_attr[7] = {
-        [0] = {
-            .attribute = "KeyBool",
-            .type = t_boolean,
-            .addr.boolean = &bool_val,
-            .nodefault = true
-        },
-        [1] = {
-            .attribute = "KeyInt",
-            .type = t_integer,
-            .addr.integer = &int_val,
-            .nodefault = true
-            },
-        [2] = {
-            .attribute = "KeyUint",
-            .type = t_uinteger,
-            .addr.uinteger = &uint_val,
-            .nodefault = true
-            },
-        [3] = {
-            .attribute = "KeyString",
-            .type = t_string,
-            .addr.string = string1,
-            .nodefault = true,
-            .len = sizeof(string1)
-            },
-        [4] = {
-            .attribute = "KeyStringN",
-            .type = t_string,
-            .addr.string = string2,
-            .nodefault = true,
-            .len = sizeof(string2)
-        },
-        [5] = {
-            .attribute = "KeyIntArr",
-            .type = t_array,
-            .addr.array = {
-                .element_type = t_integer,
-                .arr.integers.store = intarr,
-                .maxlen = sizeof intarr / sizeof intarr[0],
-                .count = &array_count,
-            },
-            .nodefault = true,
-            .len = sizeof(intarr)
-        },
-        [6] = {
-            .attribute = NULL
-        }
-    };
-    
-    test_buf_init(&tjb, output);
-
-    rc = json_read_object(&tjb.json_buf, test_attr);
-    TEST_ASSERT(rc==0);
-    TEST_ASSERT(bool_val == 1);
-    TEST_ASSERT(int_val ==  -1234);
-    TEST_ASSERT(uint_val == 1353214);
-
-    rc = memcmp(string1, "foobar", strlen("foobar"));
-    TEST_ASSERT(rc==0);
-
-    rc = memcmp(string2, "foobarlongstring", 10);
-    TEST_ASSERT(rc==0);
-
-    TEST_ASSERT(array_count == 3);
-    TEST_ASSERT(intarr[0] == 153);
-    TEST_ASSERT(intarr[1] == 2532);
-    TEST_ASSERT(intarr[2] == -322);
-
-   /*testing for the boolean*/
-   struct json_attr_t test_attr1[2] = {
-       [0] = {
-           .attribute = "KeyBoolArr",
-           .type = t_array,
-           .addr.array = {
-               .element_type = t_boolean,
-               .arr.booleans.store = boolarr,
-               .maxlen = sizeof boolarr / sizeof boolarr[0],
-               .count =&array_count1,
-           },
-           .nodefault = true,
-           .len = sizeof( boolarr),
-       },
-
-       [1] = {
-           .attribute = "KeyUintArr",
-           .type = t_array,
-           .addr.array = {
-               .element_type = t_uinteger,
-               .arr.uintegers.store = uintarr,
-               .maxlen = sizeof uintarr / sizeof uintarr[0],
-               .count =&array_count1u,
-           },
-           .nodefault = true,
-           .len = sizeof( uintarr),
-       }
-   };
-   
-   test_buf_init(&tjb1, output1);
-
-   rc1 = json_read_object(&tjb1.json_buf, test_attr1);
-   TEST_ASSERT(rc1==0);
-
-   TEST_ASSERT(boolarr[0] == true);
-   TEST_ASSERT(boolarr[1] == false);
-
-   TEST_ASSERT(uintarr[0] == 0);
-   TEST_ASSERT(uintarr[1] == 65535);
-   TEST_ASSERT(uintarr[2] == 4294967295ULL);
-   TEST_ASSERT(uintarr[3] == 8589934590ULL);
-   TEST_ASSERT(uintarr[4] == 3451257ULL);
-
-    /*testing arrays with empty spaces within the elements*/
-    struct json_attr_t test_boolspacearr[2] = {
-       [0] = {    
-           .attribute = "KeyBoolArr",
-           .type = t_array,
-           .addr.array = {
-               .element_type = t_boolean,
-               .arr.booleans.store = boolspacearr,
-               .maxlen = sizeof boolspacearr / sizeof boolspacearr[0],
-               .count =&array_count1,
-           },
-           .nodefault = true,
-           .len = sizeof( boolspacearr),
-       }
-           
-    };
-    
-    test_buf_init(&tjbboolspacearr, outputboolspace);
-
-    rcbsa = json_read_object(&tjbboolspacearr.json_buf, test_boolspacearr);
-    TEST_ASSERT(rcbsa == 0);
-
-    TEST_ASSERT(boolspacearr[0] == true);
-    TEST_ASSERT(boolspacearr[1] == false);
-    TEST_ASSERT(boolspacearr[2] == true);
-
-    /*testing array with empty value*/
-    struct json_attr_t test_boolemptyarr[2] = {
-        [0] = {
-            .attribute = "KeyBoolArr",
-           .type = t_array,
-           .addr.array = {
-               .element_type = t_boolean,
-               .arr.booleans.store = boolemptyarr,
-               .maxlen = sizeof boolemptyarr / sizeof boolemptyarr[0],
-               .count =&array_countemp,
-           },
-           .nodefault = true,
-           .len = sizeof( boolemptyarr),
-        }
-    };
-   
-   test_buf_init(&tjbboolemptyarr, outputboolempty);
-
-    rcbsa = json_read_object(&tjbboolemptyarr.json_buf, test_boolemptyarr);
-    TEST_ASSERT(rcbsa == 6); 
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6a7432f4/libs/newtmgr/nmgr_os/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/newtmgr/nmgr_os/pkg.yml b/libs/newtmgr/nmgr_os/pkg.yml
index 66a3f13..21c7eca 100644
--- a/libs/newtmgr/nmgr_os/pkg.yml
+++ b/libs/newtmgr/nmgr_os/pkg.yml
@@ -25,10 +25,10 @@ pkg.keywords:
 
 pkg.deps:
     - hw/hal
-    - libs/os
-    - libs/json
+    - kernel/os
+    - encoding/json
     - libs/util
-    - libs/testutil
+    - test/testutil
     - sys/reboot
 
 pkg.req_apis:

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6a7432f4/libs/newtmgr/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/newtmgr/pkg.yml b/libs/newtmgr/pkg.yml
index 0afb997..8312355 100644
--- a/libs/newtmgr/pkg.yml
+++ b/libs/newtmgr/pkg.yml
@@ -25,11 +25,11 @@ pkg.keywords:
 
 pkg.deps:
     - hw/hal
-    - libs/os
-    - libs/json
+    - kernel/os
+    - encoding/json
     - libs/newtmgr/nmgr_os
     - libs/util
-    - libs/shell
+    - sys/shell
     - sys/reboot
 
 pkg.deps.BLE_HOST:

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6a7432f4/libs/newtmgr/transport/ble/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/newtmgr/transport/ble/pkg.yml b/libs/newtmgr/transport/ble/pkg.yml
index 8c444fe..e3a9117 100644
--- a/libs/newtmgr/transport/ble/pkg.yml
+++ b/libs/newtmgr/transport/ble/pkg.yml
@@ -26,7 +26,7 @@ pkg.keywords:
     - bluetooth
 
 pkg.deps:
-    - libs/os
+    - kernel/os
     - net/nimble
 
 pkg.init_function: newtmgr_ble_pkg_init

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6a7432f4/libs/newtmgr_oic/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/newtmgr_oic/pkg.yml b/libs/newtmgr_oic/pkg.yml
index 69cc00b..3bd41fb 100644
--- a/libs/newtmgr_oic/pkg.yml
+++ b/libs/newtmgr_oic/pkg.yml
@@ -24,13 +24,13 @@ pkg.homepage: "http://mynewt.apache.org/"
 pkg.keywords:
 
 pkg.deps:
-    - libs/os
+    - kernel/os
     - libs/iotivity
-    - libs/json
+    - encoding/json
     - libs/newtmgr/nmgr_os
     - libs/util
-    - libs/testutil
-    - libs/shell
+    - test/testutil
+    - sys/shell
     - sys/reboot
 
 pkg.cflags:

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6a7432f4/libs/os/include/os/arch/cortex_m0/os/os_arch.h
----------------------------------------------------------------------
diff --git a/libs/os/include/os/arch/cortex_m0/os/os_arch.h b/libs/os/include/os/arch/cortex_m0/os/os_arch.h
deleted file mode 100755
index 1a83ba9..0000000
--- a/libs/os/include/os/arch/cortex_m0/os/os_arch.h
+++ /dev/null
@@ -1,74 +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 _OS_ARCH_ARM_H
-#define _OS_ARCH_ARM_H
-
-#include <stdint.h>
-#include <mcu/cortex_m0.h>
-
-struct os_task;
-
-/* Run in priviliged or unprivileged Thread mode */
-#define OS_RUN_PRIV         (0)
-#define OS_RUN_UNPRIV       (1)
-
-/* CPU status register */
-typedef uint32_t os_sr_t;
-/* Stack type, aligned to a 32-bit word. */
-#define OS_STACK_PATTERN    (0xdeadbeef)
-
-typedef uint32_t os_stack_t;
-#define OS_ALIGNMENT        (4)
-#define OS_STACK_ALIGNMENT  (8)
-
-/*
- * Stack sizes for common OS tasks
- */
-#define OS_SANITY_STACK_SIZE (64)
-#define OS_IDLE_STACK_SIZE (64)
-
-#define OS_STACK_ALIGN(__nmemb) \
-    (OS_ALIGN((__nmemb), 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())
-/* Exit a critical section, restore processor state and unblock interrupts */
-#define OS_EXIT_CRITICAL(__os_sr) (os_arch_restore_sr(__os_sr))
-#define OS_ASSERT_CRITICAL() (assert(os_arch_in_critical()))
-
-os_stack_t *os_arch_task_stack_init(struct os_task *, os_stack_t *, int);
-void timer_handler(void);
-void os_arch_ctx_sw(struct os_task *);
-os_sr_t os_arch_save_sr(void);
-void os_arch_restore_sr(os_sr_t);
-int os_arch_in_critical(void);
-void os_arch_init(void);
-uint32_t os_arch_start(void);
-os_error_t os_arch_os_init(void);
-os_error_t os_arch_os_start(void);
-void os_set_env(os_stack_t *);
-void os_arch_init_task_stack(os_stack_t *sf);
-void os_default_irq_asm(void);
-
-/* External function prototypes supplied by BSP */
-void os_bsp_systick_init(uint32_t os_ticks_per_sec, int prio);
-void os_bsp_ctx_sw(void);
-
-#endif /* _OS_ARCH_ARM_H */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6a7432f4/libs/os/include/os/arch/cortex_m4/os/os_arch.h
----------------------------------------------------------------------
diff --git a/libs/os/include/os/arch/cortex_m4/os/os_arch.h b/libs/os/include/os/arch/cortex_m4/os/os_arch.h
deleted file mode 100755
index 9e43a7a..0000000
--- a/libs/os/include/os/arch/cortex_m4/os/os_arch.h
+++ /dev/null
@@ -1,75 +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 _OS_ARCH_ARM_H
-#define _OS_ARCH_ARM_H
-
-#include <stdint.h>
-#include "mcu/cortex_m4.h"
-
-struct os_task;
-
-/* Run in priviliged or unprivileged Thread mode */
-#define OS_RUN_PRIV         (0)
-#define OS_RUN_UNPRIV       (1)
-
-/* CPU status register */
-typedef uint32_t os_sr_t;
-/* Stack type, aligned to a 32-bit word. */
-#define OS_STACK_PATTERN    (0xdeadbeef)
-
-typedef uint32_t os_stack_t;
-#define OS_ALIGNMENT        (4)
-#define OS_STACK_ALIGNMENT  (8)
-
-/*
- * Stack sizes for common OS tasks
- */
-#define OS_SANITY_STACK_SIZE (64)
-#define OS_IDLE_STACK_SIZE (64)
-
-#define OS_STACK_ALIGN(__nmemb) \
-    (OS_ALIGN((__nmemb), 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())
-/* Exit a critical section, restore processor state and unblock interrupts */
-#define OS_EXIT_CRITICAL(__os_sr) (os_arch_restore_sr(__os_sr))
-#define OS_ASSERT_CRITICAL() (assert(os_arch_in_critical()))
-
-os_stack_t *os_arch_task_stack_init(struct os_task *, os_stack_t *, int);
-void timer_handler(void);
-void os_arch_ctx_sw(struct os_task *);
-os_sr_t os_arch_save_sr(void);
-void os_arch_restore_sr(os_sr_t);
-int os_arch_in_critical(void);
-void os_arch_init(void);
-uint32_t os_arch_start(void);
-os_error_t os_arch_os_init(void);
-os_error_t os_arch_os_start(void);
-void os_set_env(os_stack_t *);
-void os_arch_init_task_stack(os_stack_t *sf);
-void os_default_irq_asm(void);
-
-/* External function prototypes supplied by BSP */
-void os_bsp_systick_init(uint32_t os_tick_per_sec, int prio);
-void os_bsp_idle(os_time_t ticks);
-void os_bsp_ctx_sw(void);
-
-#endif /* _OS_ARCH_ARM_H */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6a7432f4/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
deleted file mode 100644
index d9570c8..0000000
--- a/libs/os/include/os/arch/sim/os/os_arch.h
+++ /dev/null
@@ -1,74 +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 _OS_ARCH_SIM_H
-#define _OS_ARCH_SIM_H
-
-#include <mcu/mcu_sim.h>
-
-struct os_task;
-
-/* CPU status register */
-typedef unsigned int os_sr_t;
-/* Stack type, aligned to a 32-bit word. */
-#define OS_STACK_PATTERN (0xdeadbeef)
-
-typedef unsigned int os_stack_t;
-#define OS_ALIGNMENT (4)
-#define OS_STACK_ALIGNMENT (16)
-
-/*
- * Stack sizes for common OS tasks
- */
-#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) * 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())
-/* Exit a critical section, restore processor state and unblock interrupts */
-#define OS_EXIT_CRITICAL(__os_sr) (os_arch_restore_sr(__os_sr))
-#define OS_ASSERT_CRITICAL() (assert(os_arch_in_critical()))
-
-void _Die(char *file, int line);
-
-os_stack_t *os_arch_task_stack_init(struct os_task *, os_stack_t *, int);
-void os_arch_ctx_sw(struct os_task *);
-os_sr_t os_arch_save_sr(void);
-void os_arch_restore_sr(os_sr_t sr);
-int os_arch_in_critical(void);
-os_error_t os_arch_os_init(void);
-void os_arch_os_stop(void);
-os_error_t os_arch_os_start(void);
-
-#endif /* _OS_ARCH_SIM_H */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6a7432f4/libs/os/include/os/endian.h
----------------------------------------------------------------------
diff --git a/libs/os/include/os/endian.h b/libs/os/include/os/endian.h
deleted file mode 100644
index ffb054d..0000000
--- a/libs/os/include/os/endian.h
+++ /dev/null
@@ -1,92 +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_ENDIAN_
-#define H_ENDIAN_
-
-#include <inttypes.h>
-
-#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
-
-#ifndef ntohll
-#define ntohll(x)  ((uint64_t)(x))
-#endif
-
-#ifndef htonll
-#define htonll(x)  ((uint64_t)(x))
-#endif
-
-#ifndef ntohl
-#define ntohl(x)   ((uint32_t)(x))
-#endif
-
-#ifndef htonl
-#define htonl(x)   ((uint32_t)(x))
-#endif
-
-#ifndef ntohs
-#define ntohs(x)   ((uint16_t)(x))
-#endif
-
-#ifndef htons
-#define htons(x)   ((uint16_t)(x))
-#endif
-
-#else
-
-#ifndef ntohll
-#define ntohll(x)   ((uint64_t)                     \
-     ((((x) & 0xff00000000000000ull) >> 56) |       \
-      (((x) & 0x00ff000000000000ull) >> 40) |       \
-      (((x) & 0x0000ff0000000000ull) >> 24) |       \
-      (((x) & 0x000000ff00000000ull) >>  8) |       \
-      (((x) & 0x00000000ff000000ull) <<  8) |       \
-      (((x) & 0x0000000000ff0000ull) << 24) |       \
-      (((x) & 0x000000000000ff00ull) << 40) |       \
-      (((x) & 0x00000000000000ffull) << 56)))
-#endif
-
-#ifndef htonll
-#define htonll      ntohll
-#endif
-
-#ifndef ntohl
-#define ntohl(x)    ((uint32_t)                     \
-    ((((x) & 0xff000000) >> 24) |                   \
-     (((x) & 0x00ff0000) >>  8) |                   \
-     (((x) & 0x0000ff00) <<  8) |                   \
-     (((x) & 0x000000ff) << 24)))
-#endif
-
-#ifndef htonl
-#define htonl       ntohl
-#endif
-
-#ifndef htons
-#define htons(x)   ((uint16_t)                      \
-    ((((x) & 0xff00) >> 8) |                        \
-     (((x) & 0x00ff) << 8)))
-#endif
-
-#ifndef ntohs
-#define ntohs       htons
-#endif
-
-#endif
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6a7432f4/libs/os/include/os/os.h
----------------------------------------------------------------------
diff --git a/libs/os/include/os/os.h b/libs/os/include/os/os.h
deleted file mode 100644
index 0f1879c..0000000
--- a/libs/os/include/os/os.h
+++ /dev/null
@@ -1,101 +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 _OS_H
-#define _OS_H
-
-#include <stdlib.h>
-//#include <stdint.h>
-
-#ifndef min
-#define min(a, b) ((a)<(b)?(a):(b))
-#endif
-
-#ifndef max
-#define max(a, b) ((a)>(b)?(a):(b))
-#endif
-
-#define os_get_return_addr() (__builtin_return_address(0))
-
-#define OS_ALIGN(__n, __a) (                             \
-        (((__n) & ((__a) - 1)) == 0)                   ? \
-            (__n)                                      : \
-            ((__n) + ((__a) - ((__n) & ((__a) - 1))))    \
-        )
-
-
-/**
- * Whether or not the operating system has been started.  Set to
- * 1 right before first task is run.
- */
-extern int g_os_started;
-
-int os_info_init(void);
-
-/**
- * Returns 1 if the OS has been started, 0 if it has not yet been
- * been started.
- */
-int os_started(void);
-
-/* OS error enumerations */
-enum os_error {
-    OS_OK = 0,
-    OS_ENOMEM = 1,
-    OS_EINVAL = 2,
-    OS_INVALID_PARM = 3,
-    OS_MEM_NOT_ALIGNED = 4,
-    OS_BAD_MUTEX = 5,
-    OS_TIMEOUT = 6,
-    OS_ERR_IN_ISR = 7,      /* Function cannot be called from ISR */
-    OS_ERR_PRIV = 8,        /* Privileged access error */
-    OS_NOT_STARTED = 9,     /* Operating must be started to call this function, but isn't */
-    OS_ENOENT = 10,         /* No such thing */
-    OS_EBUSY = 11,          /* Resource busy */
-    OS_ERROR = 12,           /* Generic Error */
-};
-
-#define OS_WAIT_FOREVER (-1)
-
-typedef enum os_error os_error_t;
-
-#define OS_IDLE_PRIO (0xff)
-
-void os_init(void);
-void os_start(void);
-
-/* XXX: Not sure if this should go here; I want to differentiate API that
- * should be called by application developers as those that should not. */
-void os_init_idle_task(void);
-
-#include "os/os_sanity.h"
-#include "os/os_arch.h"
-#include "os/os_time.h"
-#include "os/os_task.h"
-#include "os/os_sched.h"
-#include "os/os_eventq.h"
-#include "os/os_callout.h"
-#include "os/os_heap.h"
-#include "os/os_mutex.h"
-#include "os/os_sem.h"
-#include "os/os_mempool.h"
-#include "os/os_mbuf.h"
-#include "os/os_dev.h"
-
-#endif /* _OS_H */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6a7432f4/libs/os/include/os/os_callout.h
----------------------------------------------------------------------
diff --git a/libs/os/include/os/os_callout.h b/libs/os/include/os/os_callout.h
deleted file mode 100644
index baa377a..0000000
--- a/libs/os/include/os/os_callout.h
+++ /dev/null
@@ -1,60 +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 _OS_CALLOUT_H
-#define _OS_CALLOUT_H
-
-#define OS_CALLOUT_F_QUEUED (0x01)
-
-struct os_callout {
-    struct os_event c_ev;
-    struct os_eventq *c_evq;
-    uint32_t c_ticks;
-    TAILQ_ENTRY(os_callout) c_next;
-};
-
-typedef void (*os_callout_func_t)(void *);
-
-struct os_callout_func {
-    /* Must be the first element in the structure for casting
-     * purposes.
-     */
-    struct os_callout cf_c;
-    os_callout_func_t cf_func;
-};
-#define CF_ARG(__cf) ((__cf)->cf_c.c_ev.ev_arg)
-
-void os_callout_func_init(struct os_callout_func *cf, struct os_eventq *evq,
-  os_callout_func_t timo_func, void *ev_arg);
-void os_callout_stop(struct os_callout *);
-int os_callout_reset(struct os_callout *, int32_t);
-void os_callout_tick(void);
-os_time_t os_callout_wakeup_ticks(os_time_t now);
-
-static inline int
-os_callout_queued(struct os_callout *c)
-{
-    return c->c_next.tqe_prev != NULL;
-}
-
-#endif /* _OS_CALLOUT_H */
-
-
-

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6a7432f4/libs/os/include/os/os_cfg.h
----------------------------------------------------------------------
diff --git a/libs/os/include/os/os_cfg.h b/libs/os/include/os/os_cfg.h
deleted file mode 100644
index 40c1e91..0000000
--- a/libs/os/include/os/os_cfg.h
+++ /dev/null
@@ -1,25 +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 _OS_CFG_H_
-#define _OS_CFG_H_ 
-
-
-#endif /* _OS_CFG_H_ */



Mime
View raw message