Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tinyCBOR external library and apply mynewt upstream patch from intel/tinycbor#83 #5912

Merged
merged 4 commits into from
Feb 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ext/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ source "ext/hal/Kconfig"

source "ext/lib/crypto/Kconfig"

source "ext/lib/encoding/Kconfig"

source "ext/debug/Kconfig"

endmenu
1 change: 1 addition & 0 deletions ext/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
add_subdirectory(crypto)
add_subdirectory(encoding)
1 change: 1 addition & 0 deletions ext/lib/encoding/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory_if_kconfig(tinycbor)
24 changes: 24 additions & 0 deletions ext/lib/encoding/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# 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.
#

menu "Encoding"

source "ext/lib/encoding/tinycbor/Kconfig"

endmenu
16 changes: 16 additions & 0 deletions ext/lib/encoding/tinycbor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
zephyr_interface_library_named(TINYCBOR)

target_include_directories(TINYCBOR INTERFACE src)

zephyr_library()
zephyr_library_sources(
src/cbor_buf_reader.c
src/cbor_buf_writer.c
src/cborencoder.c
src/cborerrorstrings.c
src/cborparser.c
)
zephyr_library_sources_ifdef(CONFIG_NEWLIB_LIBC src/cborparser_dup_string.c)

zephyr_library_link_libraries(TINYCBOR)
target_link_libraries(TINYCBOR INTERFACE zephyr_interface)
87 changes: 87 additions & 0 deletions ext/lib/encoding/tinycbor/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#
# 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.
#

config TINYCBOR
bool
prompt "tinyCBOR Support"
default n
help
This option enables the tinyCBOR library.

if TINYCBOR

config CBOR_NO_DFLT_WRITER
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe find a better name for this? At least get rid of the acronym.

I've been calling this the ability to encode to a linear buffer, as opposed to a net_buf.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any suggestion ?

bool
prompt "No default writer support"
default n
help
This option specifies whether a default writer exists.

config CBOR_NO_DFLT_READER
bool
prompt "No default reader support"
default n
help
This option specifies whether a default reader exists.

config CBOR_ENCODER_NO_CHECK_USER
bool
prompt "No encoder checks for user args for validity"
default n
help
This option specifies whether a check user exists for a cbor encoder.

config CBOR_PARSER_MAX_RECURSIONS
int
prompt "Parser max recursions"
default 1024
help
This option specifies max recursions for the parser.

config CBOR_PARSER_NO_STRICT_CHECKS
bool
prompt "No strict parser checks"
default n
help
This option enables the strict parser checks.

config CBOR_NO_FLOATING_POINT
bool
select NEWLIB_LIBC
prompt "No Floating point support"
default y
help
This option enables floating point support.

config CBOR_NO_HALF_FLOAT_TYPE
bool
select NEWLIB_LIBC
prompt "No Half float type support"
default y
help
This option enables half float type support.

config CBOR_WITHOUT_OPEN_MEMSTREAM
bool
prompt "Without open memstream"
default y
help
This option enables open memstream support.

endif #TINYCBOR
21 changes: 21 additions & 0 deletions ext/lib/encoding/tinycbor/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 Intel Corporation

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
13 changes: 13 additions & 0 deletions ext/lib/encoding/tinycbor/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Concise Binary Object Representation (CBOR) Library
---------------------------------------------------

To build TinyCBOR:

make

If you want to change the compiler or pass extra compiler flags:

make CC=clang CFLAGS="-m32 -Oz" LDFLAGS="-m32"

Documentation: https://intel.github.io/tinycbor/current/

1 change: 1 addition & 0 deletions ext/lib/encoding/tinycbor/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.5
123 changes: 123 additions & 0 deletions ext/lib/encoding/tinycbor/src/cbor.dox
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/****************************************************************************
**
** Copyright (C) 2016 Intel Corporation
**
** Permission is hereby granted, free of charge, to any person obtaining a copy
** of this software and associated documentation files (the "Software"), to deal
** in the Software without restriction, including without limitation the rights
** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
** copies of the Software, and to permit persons to whom the Software is
** furnished to do so, subject to the following conditions:
**
** The above copyright notice and this permission notice shall be included in
** all copies or substantial portions of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
** THE SOFTWARE.
**
****************************************************************************/

/**
* \mainpage
* The TinyCBOR $(VERSION) library is a small CBOR encoder and decoder library,
* optimized for very fast operation with very small footprint. The main encoder
* and decoder functions do not allocate memory.
*
* TinyCBOR is divided into the following groups of functions and structures:
* - \ref CborGlobals
* - \ref CborEncoding
* - \ref CborParsing
* - \ref CborPretty
* - \ref CborToJson
*/

/**
* \file <cbor.h>
* The <cbor.h> is the main header in TinyCBOR and defines the constants used by most functions
* as well as the structures for encoding (CborEncoder) and decoding (CborValue).
*
* \sa <cborjson.h>
*/

/**
* \file <cborjson.h>
* The <cborjson.h> file contains the routines that are used to convert a CBOR
* data stream into JSON.
*
* \sa <cbor.h>
*/

/**
* \defgroup CborGlobals Global constants
* \brief Constants used by all TinyCBOR function groups.
*/

/**
* \addtogroup CborGlobals
* @{
*/

/**
* \var size_t CborIndefiniteLength
*
* This variable is a constant used to indicate that the length of the map or
* array is not yet determined. It is used in functions
* cbor_encoder_create_map() and cbor_encoder_create_array()
*/

/**
* \enum CborType
* The CborType enum contains the types known to TinyCBOR.
*
* \value CborIntegerType Type is an integer value, positive, negative or zero
* \value CborByteStringType Type is a string of arbitrary raw bytes
* \value CborTextStringType Type is a text string encoded in UTF-8
* \value CborArrayType Type is a CBOR array
* \value CborMapType Type is a CBOR map (an associative container with key and value pairs)
* \value CborTagType Type is a CBOR tag (a 64-bit integer describing the item that follows, see CborKnownTags)
* \value CborSimpleType Type is one of CBOR Simple Types
* \value CborBooleanType Type is a boolean (true or false)
* \value CborNullType Type encodes a null
* \value CborUndefinedType Type encodes an undefined value
* \value CborHalfFloatType Type is an IEEE 754 half precision (16-bit) floating point type
* \value CborFloatType Type is an IEEE 754 single precision (32-bit) floating point type
* \value CborDoubleType Type is an IEEE 754 double precision (64-bit) floating point type
* \value CborInvalidType Type is not valid (this value is used to indicate error conditions)
*/

/**
* \enum CborKnownTags
* The CborKnownTags enum contains known tags specified in RFC 7049, for use by the application.
* TinyCBOR does not usually interpret the meaning of these tags and does not add them to the
* output stream, unless specifically instructed to do so in functions for that effect.
*
* \value CborDateTimeStringTag Text string contains a date-time encoded in RFC 3339 format, "YYYY-MM-DD hh:mm:ss+zzzz"
* \value CborUnixTime_tTag Number is a Unix time_t quantity, the number of seconds since 1970-01-01 midnight UTC
* \value CborPositiveBignumTag Item is a CBOR byte string encoding a positive integer of arbitrary precision
* \value CborNegativeBignumTag Item is a CBOR byte string encoding a negative integer of arbitrary precision
* \value CborDecimalTag Item is a CBOR array of two integers encoding a fixed-point decimal
* \value CborBigfloatTag Item is a bigfloat
* \value CborExpectedBase64urlTag Item is a CBOR byte string that is expected to be encoded as Base64Url
* \value CborExpectedBase64Tag Item is a CBOR byte string that is expected to be encoded as Base64
* \value CborExpectedBase16Tag Item is a CBOR byte string that is expected to be encoded as Base16 (also known as "hexdump")
* \value CborUriTag Item is a CBOR text string containing an URI (RFC 3986) or IRI (RFC 3987)
* \value CborBase64urlTag Item is a CBOR text string that was encoded as Base64Url
* \value CborBase64Tag Item is a CBOR text string that was encoded as Base64
* \value CborRegularExpressionTag Item is a CBOR text string containing a regular expression
* \value CborMimeMessageTag Item is a CBOR text string containing a MIME message (RFC 2045, 2046, 2047, 2822)
* \value CborSignatureTag Item contains CBOR-encoded data.
* This tag is also used as "file magic," marking a file as containing CBOR
*/

/**
* \typedef CborTag
* This typedef is an unsigned 64-bit integer. Known CBOR tags can be used from the CborKnownTags enum
* but the user application may use other tag values than the ones specified in RFC 7049.
*/

/** @} */
Loading