Unverified Commit a3a0b93b authored by Chun Fan's avatar Chun Fan Committed by GitHub
Browse files

Merge pull request #61 from NordicSemiconductor/feature/reset-refactor

Feature/reset refactor
parents 5d6aa475 c758e903
......@@ -4,7 +4,7 @@ _build
**/CMakeCache.txt
*.pyc
**/build
sdk/
/sdk/
# Object files
*.o
......
......@@ -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
......
......@@ -40,7 +40,6 @@
#include "ble.h"
#include "ble_app.h"
#include "conn_systemreset.h"
#include <stdint.h>
......@@ -271,13 +270,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);
}
......@@ -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 <stdlib.h>
......@@ -65,12 +67,12 @@ uint32_t sd_rpc_serial_port_enum(sd_rpc_serial_port_desc_t serial_port_descs[],
if(ret != NRF_SUCCESS)
{
return ret;
return ret;
}
if(descs.size() > *size)
{
ret = NRF_ERROR_DATA_SIZE;
ret = NRF_ERROR_DATA_SIZE;
}
*size = (uint32_t) descs.size();
......@@ -78,7 +80,7 @@ uint32_t sd_rpc_serial_port_enum(sd_rpc_serial_port_desc_t serial_port_descs[],
if(ret == NRF_SUCCESS)
{
int i = 0;
for(auto it = descs.begin(); it != descs.end(); ++it)
for(auto it = descs.begin(); it != descs.end(); ++it)
{
strcpy_s(serial_port_descs[i].port, SD_RPC_MAXPATHLEN, (*it)->comName.c_str());
strcpy_s(serial_port_descs[i].manufacturer, SD_RPC_MAXPATHLEN, (*it)->manufacturer.c_str());
......@@ -91,8 +93,8 @@ uint32_t sd_rpc_serial_port_enum(sd_rpc_serial_port_desc_t serial_port_descs[],
++i;
}
}
for(auto it = descs.begin(); it != descs.end(); ++it)
for(auto it = descs.begin(); it != descs.end(); ++it)
{
delete *it;
}
......@@ -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);
}
/*
* 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;
}
......@@ -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
......
......@@ -361,7 +361,7 @@ uint32_t ble_enable_req_enc(ble_enable_params_t * p_ble_enable_params,
uint32_t ble_enable_rsp_dec(uint8_t const * const p_buf,
uint32_t packet_len,
uint32_t * const p_result_code);
/**@brief Encodes @ref sd_ble_opt_get command request.
*
* @sa @ref nrf51_opt_get_encoding for packet format,
......
/**
* 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
......@@ -35,7 +35,7 @@
* 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 <stdlib.h>
#include <string.h>
......
/**
* Copyright (c) 2013 - 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
......@@ -35,7 +35,7 @@
* 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 BLE_APP_H__
#define BLE_APP_H__
......
/* 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;
}
/**
* 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
......@@ -35,7 +35,7 @@
* 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__
......@@ -44,6 +44,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
......@@ -68,7 +79,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);
/** @} */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment