Commit f302feaf authored by Chun Fan's avatar Chun Fan
Browse files

Refactor reset function for v5

parent 2f0f4f3f
......@@ -145,6 +145,8 @@ 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);
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 conn_systemreset_enc(buffer, length);
};
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.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(buffer, length);
};
return encode_decode(adapter, encode_function, nullptr);
}
......@@ -504,11 +504,3 @@ uint32_t ble_cfg_set_rsp_dec(uint8_t const * const p_buf,
SER_RSP_DEC_RESULT_ONLY(SD_BLE_CFG_SET);
}
#endif //NRF_SD_BLE_API_VERSION >= 4
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;
}
......@@ -514,9 +514,6 @@ uint32_t ble_event_dec(uint8_t const * const p_buf,
ble_evt_t * const p_event,
uint32_t * const p_event_len);
uint32_t conn_systemreset_enc(uint8_t * const p_buf,
uint32_t * const p_buf_len);
/** @} */
#ifdef __cplusplus
......
/* 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.h"
uint32_t conn_systemreset(uint8_t * const p_buf,
uint32_t * const p_buf_len)
{
SER_REQ_ENC_BEGIN(CONN_SYSTEMRESET);
SER_REQ_ENC_END;
}
......@@ -43,7 +43,10 @@
#ifdef __cplusplus
extern "C" {
#endif
enum CONN_SVCS
{
CONN_SYSTEMRESET = 0,
};
/**
* @addtogroup ser_codecs Serialization codecs
* @ingroup ble_sdk_lib_serialization
......@@ -69,6 +72,8 @@ extern "C" {
* @retval NRF_ERROR_INTERNAL Encoding failure. Transport error.
*/
// uint32_t conn_systemreset(void);
uint32_t conn_systemreset(uint8_t * const p_buf,
uint32_t * const p_buf_len);
/** @} */
......
......@@ -79,7 +79,6 @@ enum BLE_COMMON_SVCS
SD_BLE_OPT_SET, /**< Set a BLE option. */
SD_BLE_OPT_GET, /**< Get a BLE option. */
SD_BLE_CFG_SET, /**< Add a configuration to the BLE stack. */
CONN_SYSTEMRESET,
};
/**
......@@ -610,10 +609,6 @@ SVCALL(SD_BLE_OPT_SET, uint32_t, sd_ble_opt_set(adapter_t *adapter, uint32_t opt
*/
SVCALL(SD_BLE_OPT_GET, uint32_t, sd_ble_opt_get(adapter_t *adapter, uint32_t opt_id, ble_opt_t *p_opt));
// TODO: Relocate conn_systemrest to a better place.
// TODO: Add comments for conn_systemreset function, both here and enc header.
SVCALL(CONN_SYSTEMRESET, uint32_t, conn_systemreset(adapter_t *adapter));
/** @} */
#ifdef __cplusplus
}
......
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