From b8b288960c1ecaf56eb2bf4022002d03a765eb78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Inge=20Hanssen?= Date: Tue, 19 Dec 2017 12:57:52 +0100 Subject: [PATCH] Port reset function from master branch --- .gitignore | 3 +- include/common/sd_rpc.h | 9 ++ src/common/ble_impl.cpp | 11 --- src/common/sd_rpc_impl.cpp | 10 ++ .../codecs/common/conn_systemreset_app.c | 52 +++++++++++ ...n_systemreset.h => conn_systemreset_app.h} | 16 +++- .../codecs/common/conn_systemreset.h | 52 ----------- .../codecs/common/conn_systemreset_app.c | 21 +++++ .../codecs/common/conn_systemreset_app.h | 91 +++++++++++++++++++ 9 files changed, 199 insertions(+), 66 deletions(-) create mode 100644 src/sd_api_v2/sdk/components/serialization/application/codecs/common/conn_systemreset_app.c rename src/sd_api_v2/sdk/components/serialization/application/codecs/common/{conn_systemreset.h => conn_systemreset_app.h} (91%) mode change 100755 => 100644 delete mode 100755 src/sd_api_v3/sdk/components/serialization/application/codecs/common/conn_systemreset.h create mode 100644 src/sd_api_v3/sdk/components/serialization/application/codecs/common/conn_systemreset_app.c create mode 100644 src/sd_api_v3/sdk/components/serialization/application/codecs/common/conn_systemreset_app.h diff --git a/.gitignore b/.gitignore index f828094dc..b3311fe62 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,8 @@ _build **/CMakeFiles **/CMakeCache.txt *.pyc -sdk/ +**/build +/sdk/ # Object files *.o diff --git a/include/common/sd_rpc.h b/include/common/sd_rpc.h index 9cc414b65..fd4482ee9 100644 --- a/include/common/sd_rpc.h +++ b/include/common/sd_rpc.h @@ -145,6 +145,15 @@ SD_RPC_API uint32_t sd_rpc_close(adapter_t *adapter); */ SD_RPC_API uint32_t sd_rpc_log_handler_severity_filter_set(adapter_t *adapter, sd_rpc_log_severity_t severity_filter); +/**@brief Reset the connectivity chip. + * + * @param[in] adapter The transport adapter. + * + * @retval NRF_SUCCESS The connectivity chip was reset successfully. + * @retval NRF_ERROR There was an error reset the connectivity chip. + */ +SD_RPC_API uint32_t sd_rpc_conn_reset(adapter_t *adapter); + #ifdef __cplusplus } #endif // __cplusplus diff --git a/src/common/ble_impl.cpp b/src/common/ble_impl.cpp index 8563fa519..53b4abeae 100755 --- a/src/common/ble_impl.cpp +++ b/src/common/ble_impl.cpp @@ -40,7 +40,6 @@ #include "ble.h" #include "ble_app.h" -#include "conn_systemreset.h" #include @@ -240,13 +239,3 @@ uint32_t sd_ble_user_mem_reply(adapter_t *adapter, uint16_t conn_handle, ble_use return encode_decode(adapter, encode_function, decode_function); } - - -uint32_t conn_systemreset(adapter_t *adapter) -{ - encode_function_t encode_function = [&](uint8_t *buffer, uint32_t *length) -> uint32_t { - return 0; - }; - - return encode_decode(adapter, encode_function, nullptr); -} diff --git a/src/common/sd_rpc_impl.cpp b/src/common/sd_rpc_impl.cpp index a6994c8ac..1c1093509 100644 --- a/src/common/sd_rpc_impl.cpp +++ b/src/common/sd_rpc_impl.cpp @@ -43,6 +43,8 @@ #include "uart_boost.h" #include "uart_settings_boost.h" #include "serial_port_enum.h" +#include "conn_systemreset_app.h" +#include "ble_common.h" #include @@ -185,3 +187,11 @@ uint32_t sd_rpc_log_handler_severity_filter_set(adapter_t *adapter, sd_rpc_log_s return adapterLayer->logSeverityFilterSet(severity_filter); } +uint32_t sd_rpc_conn_reset(adapter_t *adapter) +{ + encode_function_t encode_function = [&](uint8_t *buffer, uint32_t *length) -> uint32_t { + return conn_systemreset_enc(buffer, length); + }; + + return encode_decode(adapter, encode_function, nullptr); +} diff --git a/src/sd_api_v2/sdk/components/serialization/application/codecs/common/conn_systemreset_app.c b/src/sd_api_v2/sdk/components/serialization/application/codecs/common/conn_systemreset_app.c new file mode 100644 index 000000000..361d10eb6 --- /dev/null +++ b/src/sd_api_v2/sdk/components/serialization/application/codecs/common/conn_systemreset_app.c @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016 Nordic Semiconductor ASA + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. 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. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of other + * contributors to this software may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * 4. This software must only be used in or with a processor manufactured by Nordic + * Semiconductor ASA, or in or with a processor manufactured by a third party that + * is used in combination with a processor manufactured by Nordic Semiconductor. + * + * 5. Any software provided in binary or object form under this license must not be + * reverse engineered, decompiled, modified and/or disassembled. + * + * 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 COPYRIGHT HOLDER 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. + */ + +#include "ble_serialization.h" +#include "conn_systemreset_app.h" + +uint32_t conn_systemreset_enc(uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + SER_ASSERT_LENGTH_LEQ(2, *p_buf_len); + + *p_buf = CONN_SYSTEMRESET; + *p_buf_len = 1; + + return NRF_SUCCESS; +} diff --git a/src/sd_api_v2/sdk/components/serialization/application/codecs/common/conn_systemreset.h b/src/sd_api_v2/sdk/components/serialization/application/codecs/common/conn_systemreset_app.h old mode 100755 new mode 100644 similarity index 91% rename from src/sd_api_v2/sdk/components/serialization/application/codecs/common/conn_systemreset.h rename to src/sd_api_v2/sdk/components/serialization/application/codecs/common/conn_systemreset_app.h index 1a840a942..7273b88c1 --- a/src/sd_api_v2/sdk/components/serialization/application/codecs/common/conn_systemreset.h +++ b/src/sd_api_v2/sdk/components/serialization/application/codecs/common/conn_systemreset_app.h @@ -34,7 +34,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #ifndef CONN_SYSTEMRESET_H__ #define CONN_SYSTEMRESET_H__ @@ -42,6 +42,17 @@ extern "C" { #endif +/** @addtogroup CONN_ENUMERATIONS Enumerations + * @{ */ + +/** + * @brief Connectivity API SVC numbers. + */ +enum CONN_SVCS +{ + CONN_SYSTEMRESET = 0x00, +}; + /** * @addtogroup ser_codecs Serialization codecs * @ingroup ble_sdk_lib_serialization @@ -66,7 +77,8 @@ extern "C" { * @retval NRF_SUCCESS Encoding success. * @retval NRF_ERROR_INTERNAL Encoding failure. Transport error. */ -uint32_t conn_systemreset(void); +uint32_t conn_systemreset_enc(uint8_t * const p_buf, + uint32_t * const p_buf_len); /** @} */ #ifdef __cplusplus diff --git a/src/sd_api_v3/sdk/components/serialization/application/codecs/common/conn_systemreset.h b/src/sd_api_v3/sdk/components/serialization/application/codecs/common/conn_systemreset.h deleted file mode 100755 index 5fe68d135..000000000 --- a/src/sd_api_v3/sdk/components/serialization/application/codecs/common/conn_systemreset.h +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved. - * - * The information contained herein is property of Nordic Semiconductor ASA. - * Terms and conditions of usage are described in detail in NORDIC - * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. - * - * Licensees are granted free, non-transferable use of the information. NO - * WARRANTY of ANY KIND is provided. This heading must NOT be removed from - * the file. - * - */ - -#ifndef CONN_SYSTEMRESET_H__ -#define CONN_SYSTEMRESET_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup ser_codecs Serialization codecs - * @ingroup ble_sdk_lib_serialization - */ - -/** - * @addtogroup ser_app_common_codecs Application common codecs - * @ingroup ser_codecs - */ - -/**@file - * - * @defgroup conn_systemreset Connectivity chip reset command request encoder - * @{ - * @ingroup ser_app_common_codecs - * - * @brief Connectivity chip reset command request encoder. - */ - -/**@brief Function for performing the connectivity chip reset. - * - * @retval NRF_SUCCESS Encoding success. - * @retval NRF_ERROR_INTERNAL Encoding failure. Transport error. - */ -uint32_t conn_systemreset(void); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif // CONN_SYSTEMRESET_H__ diff --git a/src/sd_api_v3/sdk/components/serialization/application/codecs/common/conn_systemreset_app.c b/src/sd_api_v3/sdk/components/serialization/application/codecs/common/conn_systemreset_app.c new file mode 100644 index 000000000..3e26d2989 --- /dev/null +++ b/src/sd_api_v3/sdk/components/serialization/application/codecs/common/conn_systemreset_app.c @@ -0,0 +1,21 @@ +/* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +#include "ble_serialization.h" +#include "conn_systemreset_app.h" + +uint32_t conn_systemreset_enc(uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(CONN_SYSTEMRESET); + SER_REQ_ENC_END; +} diff --git a/src/sd_api_v3/sdk/components/serialization/application/codecs/common/conn_systemreset_app.h b/src/sd_api_v3/sdk/components/serialization/application/codecs/common/conn_systemreset_app.h new file mode 100644 index 000000000..4361bc06a --- /dev/null +++ b/src/sd_api_v3/sdk/components/serialization/application/codecs/common/conn_systemreset_app.h @@ -0,0 +1,91 @@ +/** + * Copyright (c) 2014 - 2017, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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. + * + */ +#ifndef CONN_SYSTEMRESET_H__ +#define CONN_SYSTEMRESET_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/** @addtogroup CONN_ENUMERATIONS Enumerations + * @{ */ + +/** + * @brief Connectivity API SVC numbers. + */ +enum CONN_SVCS +{ + CONN_SYSTEMRESET = 0x00, +}; + +/** + * @addtogroup ser_codecs Serialization codecs + * @ingroup ble_sdk_lib_serialization + */ + +/** + * @addtogroup ser_app_common_codecs Application common codecs + * @ingroup ser_codecs_app + */ + +/**@file + * + * @defgroup conn_systemreset Connectivity chip reset command request encoder + * @{ + * @ingroup ser_app_common_codecs + * + * @brief Connectivity chip reset command request encoder. + */ + +/**@brief Function for performing the connectivity chip reset. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_INTERNAL Encoding failure. Transport error. + */ +uint32_t conn_systemreset_enc(uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // CONN_SYSTEMRESET_H__