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

Add reset for v5

parent 5d6aa475
......@@ -833,6 +833,7 @@ static void ble_evt_dispatch(adapter_t * adapter, ble_evt_t * p_ble_evt)
{
case BLE_GAP_EVT_CONNECTED:
on_connected(&(p_ble_evt->evt.gap_evt));
conn_systemreset(m_adapter);
break;
case BLE_GAP_EVT_DISCONNECTED:
......
......@@ -43,7 +43,7 @@
#include <string>
AdapterInternal::AdapterInternal(SerializationTransport *_transport):
AdapterInternal::AdapterInternal(SerializationTransport *_transport):
eventCallback(nullptr),
statusCallback(nullptr),
logCallback(nullptr),
......@@ -51,7 +51,7 @@ AdapterInternal::AdapterInternal(SerializationTransport *_transport):
{
this->transport = _transport;
}
AdapterInternal::~AdapterInternal()
{
delete transport;
......
......@@ -275,9 +275,18 @@ uint32_t sd_ble_user_mem_reply(adapter_t *adapter, uint16_t conn_handle, ble_use
uint32_t conn_systemreset(adapter_t *adapter)
{
printf("lalala\n");
encode_function_t encode_function = [&](uint8_t *buffer, uint32_t *length) -> uint32_t {
return 0;
return conn_systemreset_enc(buffer, length);
};
return encode_decode(adapter, encode_function, nullptr);
}
// uint32_t conn_systemreset_enc(uint8_t * const p_buf,
// uint32_t * const p_buf_len)
// {
// printf("lololo\n");
// SER_REQ_ENC_BEGIN(CONN_SYSTEMRESET);
// SER_REQ_ENC_END;
// }
......@@ -65,12 +65,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 +78,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 +91,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;
}
......
......@@ -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__
......@@ -66,7 +66,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
......
......@@ -78,6 +78,7 @@ enum BLE_COMMON_SVCS
SD_BLE_USER_MEM_REPLY, /**< User Memory Reply. */
SD_BLE_OPT_SET, /**< Set a BLE option. */
SD_BLE_OPT_GET, /**< Get a BLE option. */
CONN_SYSTEMRESET,
};
/**
......@@ -621,6 +622,8 @@ SD_RPC_API uint32_t sd_ble_opt_set(adapter_t *adapter, uint32_t opt_id, ble_opt_
*/
SD_RPC_API uint32_t sd_ble_opt_get(adapter_t *adapter, uint32_t opt_id, ble_opt_t *p_opt);
SD_RPC_API uint32_t conn_systemreset(adapter_t *adapter);
/** @} */
#ifdef __cplusplus
}
......
/**
* 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>
......@@ -504,3 +504,12 @@ 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)
{
printf("lololo\n");
SER_REQ_ENC_BEGIN(CONN_SYSTEMRESET);
SER_REQ_ENC_END;
}
/**
* 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__
......@@ -514,6 +514,10 @@ 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 - 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__
......@@ -68,7 +68,7 @@ extern "C" {
* @retval NRF_SUCCESS Encoding success.
* @retval NRF_ERROR_INTERNAL Encoding failure. Transport error.
*/
uint32_t conn_systemreset(void);
// uint32_t conn_systemreset(void);
/** @} */
......
......@@ -79,6 +79,7 @@ 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,
};
/**
......@@ -609,6 +610,8 @@ 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));
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