http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/middleware/app_mw_ble_gatts.c ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/middleware/app_mw_ble_gatts.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/middleware/app_mw_ble_gatts.c deleted file mode 100644 index f9ede04..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/middleware/app_mw_ble_gatts.c +++ /dev/null @@ -1,665 +0,0 @@ -/* Copyright (c) 2013 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_gatts.h" -#include <stdint.h> -#include "ble_serialization.h" -#include "ser_sd_transport.h" -#include "ble_gatts_app.h" -#include "app_error.h" - - -//Pointer for sd calls output params -static void * mp_out_params[3]; - -static void tx_buf_alloc(uint8_t * * p_data, uint16_t * p_len) -{ - uint32_t err_code; - - do - { - err_code = ser_sd_transport_tx_alloc(p_data, p_len); - } - while (err_code != NRF_SUCCESS); - *p_data[0] = SER_PKT_TYPE_CMD; - *p_len -= 1; -} - -/**@brief Command response callback function for @ref sd_ble_gatts_sys_attr_set BLE command. - * - * Callback for decoding the command response return code. - * - * @param[in] p_buffer Pointer to begin of command response buffer. - * @param[in] length Length of data in bytes. - * - * @return Decoded command response return code. - */ -static uint32_t gatts_sys_attr_set_rsp_dec(const uint8_t * p_buffer, uint16_t length) -{ - uint32_t result_code; - - const uint32_t err_code = ble_gatts_sys_attr_set_rsp_dec(p_buffer, length, &result_code); - - APP_ERROR_CHECK(err_code); - - - - return result_code; -} - - -uint32_t sd_ble_gatts_sys_attr_set(uint16_t conn_handle, - uint8_t const * const p_sys_attr_data, - uint16_t len, - uint32_t flags) -{ - uint8_t * p_buffer; - uint32_t buffer_length = 0; - - tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); - const uint32_t err_code = ble_gatts_sys_attr_set_req_enc(conn_handle, - p_sys_attr_data, - len, - flags, - &(p_buffer[1]), - &buffer_length); - APP_ERROR_CHECK(err_code); - - //@note: Increment buffer length as internally managed packet type field must be included. - return ser_sd_transport_cmd_write(p_buffer, - (++buffer_length), - gatts_sys_attr_set_rsp_dec); -} - - -/**@brief Command response callback function for @ref sd_ble_gatts_hvx BLE command. - * - * Callback for decoding the command response return code. - * - * @param[in] p_buffer Pointer to begin of command response buffer. - * @param[in] length Length of data in bytes. - * - * @return Decoded command response return code. - */ -static uint32_t gatts_hvx_rsp_dec(const uint8_t * p_buffer, uint16_t length) -{ - uint32_t result_code; - - const uint32_t err_code = ble_gatts_hvx_rsp_dec(p_buffer, length, &result_code, - (uint16_t * *)&mp_out_params[0]); - - APP_ERROR_CHECK(err_code); - - return result_code; -} - - -uint32_t sd_ble_gatts_hvx(uint16_t conn_handle, ble_gatts_hvx_params_t const * const p_hvx_params) -{ - uint8_t * p_buffer; - uint32_t buffer_length = 0; - - tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); - mp_out_params[0] = (p_hvx_params) ? p_hvx_params->p_len : NULL; - - const uint32_t err_code = ble_gatts_hvx_req_enc(conn_handle, - p_hvx_params, - &(p_buffer[1]), - &buffer_length); - APP_ERROR_CHECK(err_code); - - //@note: Increment buffer length as internally managed packet type field must be included. - return ser_sd_transport_cmd_write(p_buffer, - (++buffer_length), - gatts_hvx_rsp_dec); -} - - -/**@brief Command response callback function for @ref sd_ble_gatts_service_add BLE command. - * - * Callback for decoding the output parameters and the command response return code. - * - * @param[in] p_buffer Pointer to begin of command response buffer. - * @param[in] length Length of data in bytes. - * - * @return Decoded command response return code. - */ -static uint32_t gatts_service_add_rsp_dec(const uint8_t * p_buffer, uint16_t length) -{ - uint32_t result_code; - - const uint32_t err_code = - ble_gatts_service_add_rsp_dec(p_buffer, - length, - (uint16_t *)mp_out_params[0], - &result_code); - - APP_ERROR_CHECK(err_code); - - - - return result_code; -} - - -uint32_t sd_ble_gatts_service_add(uint8_t type, - ble_uuid_t const * const p_uuid, - uint16_t * const p_handle) -{ - uint8_t * p_buffer; - uint32_t buffer_length = 0; - - tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); - mp_out_params[0] = p_handle; - - const uint32_t err_code = ble_gatts_service_add_req_enc(type, - p_uuid, - p_handle, - &(p_buffer[1]), - &buffer_length); - APP_ERROR_CHECK(err_code); - - //@note: Increment buffer length as internally managed packet type field must be included. - return ser_sd_transport_cmd_write(p_buffer, - (++buffer_length), - gatts_service_add_rsp_dec); -} - -/**@brief Command response callback function for @ref sd_ble_gatts_service_add BLE command. - * - * Callback for decoding the output parameters and the command response return code. - * - * @param[in] p_buffer Pointer to begin of command response buffer. - * @param[in] length Length of data in bytes. - * - * @return Decoded command response return code. - */ -static uint32_t gatts_service_changed_rsp_dec(const uint8_t * p_buffer, uint16_t length) -{ - uint32_t result_code = NRF_SUCCESS; - - const uint32_t err_code = ble_gatts_service_changed_rsp_dec(p_buffer, - length, - &result_code); - - APP_ERROR_CHECK(err_code); - - - - return result_code; -} - -uint32_t sd_ble_gatts_service_changed(uint16_t conn_handle, - uint16_t start_handle, - uint16_t end_handle) -{ - uint8_t * p_buffer; - uint32_t buffer_length = 0; - - tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); - const uint32_t err_code = ble_gatts_service_changed_req_enc(conn_handle, - start_handle, - end_handle, - &(p_buffer[1]), - &buffer_length); - - APP_ERROR_CHECK(err_code); - - //@note: Increment buffer length as internally managed packet type field must be included. - return ser_sd_transport_cmd_write(p_buffer, - (++buffer_length), - gatts_service_changed_rsp_dec); -} - -/**@brief Command response callback function for @ref sd_ble_gatts_include_add BLE command. - * - * Callback for decoding the output parameters and the command response return code. - * - * @param[in] p_buffer Pointer to begin of command response buffer. - * @param[in] length Length of data in bytes. - * - * @return Decoded command response return code. - */ -static uint32_t gatts_include_add_rsp_dec(const uint8_t * p_buffer, uint16_t length) -{ - uint32_t result_code = NRF_SUCCESS; - - const uint32_t err_code = - ble_gatts_include_add_rsp_dec(p_buffer, - length, - (uint16_t *) mp_out_params[0], - &result_code); - - APP_ERROR_CHECK(err_code); - - - - return result_code; -} - -uint32_t sd_ble_gatts_include_add(uint16_t service_handle, - uint16_t inc_serv_handle, - uint16_t * const p_include_handle) -{ - uint8_t * p_buffer; - uint32_t buffer_length = 0; - - tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); - mp_out_params[0] = p_include_handle; - - const uint32_t err_code = ble_gatts_include_add_req_enc(service_handle, - inc_serv_handle, - p_include_handle, - &(p_buffer[1]), - &buffer_length); - - APP_ERROR_CHECK(err_code); - - //@note: Increment buffer length as internally managed packet type field must be included. - return ser_sd_transport_cmd_write(p_buffer, - (++buffer_length), - gatts_include_add_rsp_dec); -} - -/**@brief Command response callback function for @ref sd_ble_gatts_characteristic_add BLE command. - * - * Callback for decoding the output parameters and the command response return code. - * - * @param[in] p_buffer Pointer to begin of command response buffer. - * @param[in] length Length of data in bytes. - * - * @return Decoded command response return code. - */ -static uint32_t gatts_characteristic_add_rsp_dec(const uint8_t * p_buffer, uint16_t length) -{ - uint32_t result_code; - - const uint32_t err_code = ble_gatts_characteristic_add_rsp_dec( - p_buffer, - length, - (uint16_t * *)&mp_out_params[0], - &result_code); - - APP_ERROR_CHECK(err_code); - - return result_code; -} - - -uint32_t sd_ble_gatts_characteristic_add(uint16_t service_handle, - ble_gatts_char_md_t const * const p_char_md, - ble_gatts_attr_t const * const p_attr_char_value, - ble_gatts_char_handles_t * const p_handles) -{ - uint8_t * p_buffer; - uint32_t buffer_length = 0; - - tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); - mp_out_params[0] = p_handles; - - const uint32_t err_code = ble_gatts_characteristic_add_req_enc(service_handle, - p_char_md, - p_attr_char_value, - p_handles, - &(p_buffer[1]), - &buffer_length); - APP_ERROR_CHECK(err_code); - - //@note: Increment buffer length as internally managed packet type field must be included. - return ser_sd_transport_cmd_write(p_buffer, - (++buffer_length), - gatts_characteristic_add_rsp_dec); -} - -/**@brief Command response callback function for @ref sd_ble_gatts_descriptor_add BLE command. - * - * Callback for decoding the output parameters and the command response return code. - * - * @param[in] p_buffer Pointer to begin of command response buffer. - * @param[in] length Length of data in bytes. - * - * @return Decoded command response return code. - */ -static uint32_t gatts_descriptor_add_rsp_dec(const uint8_t * p_buffer, uint16_t length) -{ - uint32_t result_code = NRF_SUCCESS; - - const uint32_t err_code = - ble_gatts_descriptor_add_rsp_dec(p_buffer, - length, - (uint16_t *) mp_out_params[0], - &result_code); - - APP_ERROR_CHECK(err_code); - - - - return result_code; -} - -uint32_t sd_ble_gatts_descriptor_add(uint16_t char_handle, - ble_gatts_attr_t const * const p_attr, - uint16_t * const p_handle) -{ - uint8_t * p_buffer; - uint32_t buffer_length = 0; - - tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); - mp_out_params[0] = p_handle; - - const uint32_t err_code = ble_gatts_descriptor_add_req_enc(char_handle, - p_attr, - p_handle, - &(p_buffer[1]), - &buffer_length); - - APP_ERROR_CHECK(err_code); - - //@note: Increment buffer length as internally managed packet type field must be included. - return ser_sd_transport_cmd_write(p_buffer, - (++buffer_length), - gatts_descriptor_add_rsp_dec); -} - -/**@brief Command response callback function for @ref sd_ble_gatts_rw_authorize_reply BLE command. - * - * Callback for decoding the output parameters and the command response return code. - * - * @param[in] p_buffer Pointer to begin of command response buffer. - * @param[in] length Length of data in bytes. - * - * @return Decoded command response return code. - */ -static uint32_t gatts_rw_authorize_reply_rsp_dec(const uint8_t * p_buffer, uint16_t length) -{ - uint32_t result_code = NRF_SUCCESS; - - const uint32_t err_code = ble_gatts_rw_authorize_reply_rsp_dec(p_buffer, - length, - &result_code); - - APP_ERROR_CHECK(err_code); - - - - return result_code; -} - -uint32_t sd_ble_gatts_rw_authorize_reply( - uint16_t conn_handle, - ble_gatts_rw_authorize_reply_params_t const * const - p_rw_authorize_reply_params) -{ - - uint8_t * p_buffer; - uint32_t buffer_length = 0; - - tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); - - const uint32_t err_code = ble_gatts_rw_authorize_reply_req_enc(conn_handle, - p_rw_authorize_reply_params, - &(p_buffer[1]), - &buffer_length); - - APP_ERROR_CHECK(err_code); - - //@note: Increment buffer length as internally managed packet type field must be included. - return ser_sd_transport_cmd_write(p_buffer, - (++buffer_length), - gatts_rw_authorize_reply_rsp_dec); -} - -/**@brief Command response callback function for @ref sd_ble_gatts_value_get BLE command. - * - * Callback for decoding the output parameters and the command response return code. - * - * @param[in] p_buffer Pointer to begin of command response buffer. - * @param[in] length Length of data in bytes. - * - * @return Decoded command response return code. - */ -static uint32_t gatts_value_get_rsp_dec(const uint8_t * p_buffer, uint16_t length) -{ - uint32_t result_code; - - const uint32_t err_code = ble_gatts_value_get_rsp_dec(p_buffer, - length, - (ble_gatts_value_t *)mp_out_params[0], - &result_code); - - APP_ERROR_CHECK(err_code); - - - - return result_code; -} - -uint32_t sd_ble_gatts_value_get(uint16_t conn_handle, - uint16_t handle, - ble_gatts_value_t * p_value) -{ - uint8_t * p_buffer; - uint32_t buffer_length = 0; - - tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); - mp_out_params[0] = p_value; - - const uint32_t err_code = ble_gatts_value_get_req_enc(conn_handle, - handle, - p_value, - &(p_buffer[1]), - &buffer_length); - - APP_ERROR_CHECK(err_code); - - //@note: Increment buffer length as internally managed packet type field must be included. - return ser_sd_transport_cmd_write(p_buffer, - (++buffer_length), - gatts_value_get_rsp_dec); -} - -/**@brief Command response callback function for @ref sd_ble_gatts_value_set BLE command. - * - * Callback for decoding the output parameters and the command response return code. - * - * @param[in] p_buffer Pointer to begin of command response buffer. - * @param[in] length Length of data in bytes. - * - * @return Decoded command response return code. - */ -static uint32_t gatts_value_set_rsp_dec(const uint8_t * p_buffer, uint16_t length) -{ - uint32_t result_code; - - const uint32_t err_code = ble_gatts_value_set_rsp_dec( - p_buffer, - length, - (ble_gatts_value_t *)mp_out_params[0], - &result_code); - - APP_ERROR_CHECK(err_code); - - return result_code; -} - - -uint32_t sd_ble_gatts_value_set(uint16_t conn_handle, - uint16_t handle, - ble_gatts_value_t * p_value) -{ - uint8_t * p_buffer; - uint32_t buffer_length = 0; - - tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); - mp_out_params[0] = p_value; - - const uint32_t err_code = ble_gatts_value_set_req_enc(conn_handle, - handle, - p_value, - &(p_buffer[1]), - &buffer_length); - //@note: Should never fail. - APP_ERROR_CHECK(err_code); - - //@note: Increment buffer length as internally managed packet type field must be included. - return ser_sd_transport_cmd_write(p_buffer, - (++buffer_length), - gatts_value_set_rsp_dec); -} - - -/**@brief Command response callback function for @ref sd_ble_gatts_sys_attr_get BLE command. - * - * Callback for decoding the output parameters and the command response return code. - * - * @param[in] p_buffer Pointer to begin of command response buffer. - * @param[in] length Length of data in bytes. - * - * @return Decoded command response return code. - */ -static uint32_t gatts_sys_attr_get_rsp_dec(const uint8_t * p_buffer, uint16_t length) -{ - uint32_t result_code; - - const uint32_t err_code = ble_gatts_sys_attr_get_rsp_dec( - p_buffer, - length, - (uint8_t *) mp_out_params[0], - (uint16_t *) mp_out_params[1], - &result_code); - - APP_ERROR_CHECK(err_code); - - return result_code; -} - - -uint32_t sd_ble_gatts_sys_attr_get(uint16_t conn_handle, - uint8_t * const p_sys_attr_data, - uint16_t * const p_len, - uint32_t flags) -{ - uint8_t * p_buffer; - uint32_t buffer_length = 0; - - tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); - mp_out_params[0] = p_sys_attr_data; - mp_out_params[1] = p_len; - - const uint32_t err_code = ble_gatts_sys_attr_get_req_enc(conn_handle, - p_sys_attr_data, - p_len, - flags, - &(p_buffer[1]), - &buffer_length); - //@note: Should never fail. - APP_ERROR_CHECK(err_code); - - //@note: Increment buffer length as internally managed packet type field must be included. - return ser_sd_transport_cmd_write(p_buffer, - (++buffer_length), - gatts_sys_attr_get_rsp_dec); -} - -/**@brief Command response callback function for @ref sd_ble_gatts_attr_get BLE command. - * - * Callback for decoding the output parameters and the command response return code. - * - * @param[in] p_buffer Pointer to begin of command response buffer. - * @param[in] length Length of data in bytes. - * - * @return Decoded command response return code. - */ -static uint32_t gatts_attr_get_rsp_dec(const uint8_t * p_buffer, uint16_t length) -{ - uint32_t result_code; - - const uint32_t err_code = ble_gatts_attr_get_rsp_dec( - p_buffer, - length, - (ble_gatts_attr_md_t **)&mp_out_params[0], - &result_code); - - APP_ERROR_CHECK(err_code); - - return result_code; -} - - -uint32_t sd_ble_gatts_attr_get(uint16_t handle, - ble_uuid_t * p_uuid, - ble_gatts_attr_md_t * p_md) -{ - uint8_t * p_buffer; - uint32_t buffer_length = 0; - - tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); - mp_out_params[0] = p_md; - - const uint32_t err_code = ble_gatts_attr_get_req_enc(handle, - p_uuid, - p_md, - &(p_buffer[1]), - &buffer_length); - //@note: Should never fail. - APP_ERROR_CHECK(err_code); - - //@note: Increment buffer length as internally managed packet type field must be included. - return ser_sd_transport_cmd_write(p_buffer, - (++buffer_length), - gatts_attr_get_rsp_dec); -} - -/**@brief Command response callback function for @ref sd_ble_gatts_initial_user_handle_get BLE command. - * - * Callback for decoding the output parameters and the command response return code. - * - * @param[in] p_buffer Pointer to begin of command response buffer. - * @param[in] length Length of data in bytes. - * - * @return Decoded command response return code. - */ -static uint32_t gatts_initial_user_handle_get_rsp_dec(const uint8_t * p_buffer, uint16_t length) -{ - uint32_t result_code; - - const uint32_t err_code = ble_gatts_initial_user_handle_get_rsp_dec( - p_buffer, - length, - (uint16_t **)&mp_out_params[0], - &result_code); - - APP_ERROR_CHECK(err_code); - - return result_code; -} - - -uint32_t sd_ble_gatts_initial_user_handle_get(uint16_t * p_handle) -{ - uint8_t * p_buffer; - uint32_t buffer_length = 0; - - tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); - mp_out_params[0] = p_handle; - - const uint32_t err_code = ble_gatts_initial_user_handle_get_req_enc(p_handle, - &(p_buffer[1]), - &buffer_length); - //@note: Should never fail. - APP_ERROR_CHECK(err_code); - - //@note: Increment buffer length as internally managed packet type field must be included. - return ser_sd_transport_cmd_write(p_buffer, - (++buffer_length), - gatts_initial_user_handle_get_rsp_dec); -}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/middleware/app_mw_ble_l2cap.c ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/middleware/app_mw_ble_l2cap.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/middleware/app_mw_ble_l2cap.c deleted file mode 100644 index d4cf91c..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/middleware/app_mw_ble_l2cap.c +++ /dev/null @@ -1,165 +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. - * - */ - -#include "ble_gap.h" -#include <stdint.h> -#include "ble_serialization.h" -#include "ser_sd_transport.h" -#include "ble_l2cap_app.h" -#include "app_error.h" - -static void tx_buf_alloc(uint8_t * * p_data, uint16_t * p_len) -{ - uint32_t err_code; - - do - { - err_code = ser_sd_transport_tx_alloc(p_data, p_len); - } - while (err_code != NRF_SUCCESS); - *p_data[0] = SER_PKT_TYPE_CMD; - *p_len -= 1; -} -/**@brief Command response callback function for @ref ble_l2cap_cid_register_req_enc BLE command. - * - * Callback for decoding the output parameters and the command response return code. - * - * @param[in] p_buffer Pointer to begin of command response buffer. - * @param[in] length Length of data in bytes. - * - * @return Decoded command response return code. - */ -static uint32_t l2cap_cid_register_rsp_dec(const uint8_t * p_buffer, uint16_t length) -{ - uint32_t result_code; - - const uint32_t err_code = - ble_l2cap_cid_register_rsp_dec(p_buffer, - length, - &result_code); - - APP_ERROR_CHECK(err_code); - - return result_code; -} - - -uint32_t sd_ble_l2cap_cid_register(uint16_t cid) -{ - - uint8_t * p_buffer; - uint32_t buffer_length = 0; - - tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); - const uint32_t err_code = ble_l2cap_cid_register_req_enc(cid, - &(p_buffer[1]), - &buffer_length); - //@note: Should never fail. - APP_ERROR_CHECK(err_code); - - //@note: Increment buffer length as internally managed packet type field must be included. - return ser_sd_transport_cmd_write(p_buffer, - (++buffer_length), - l2cap_cid_register_rsp_dec); -} - -/**@brief Command response callback function for @ref ble_l2cap_cid_unregister_req_enc BLE command. - * - * Callback for decoding the output parameters and the command response return code. - * - * @param[in] p_buffer Pointer to begin of command response buffer. - * @param[in] length Length of data in bytes. - * - * @return Decoded command response return code. - */ -static uint32_t l2cap_cid_unregister_rsp_dec(const uint8_t * p_buffer, uint16_t length) -{ - uint32_t result_code; - - const uint32_t err_code = - ble_l2cap_cid_unregister_rsp_dec(p_buffer, - length, - &result_code); - - APP_ERROR_CHECK(err_code); - - - - return result_code; -} - - -uint32_t sd_ble_l2cap_cid_unregister(uint16_t cid) -{ - uint8_t * p_buffer; - uint32_t buffer_length = 0; - - tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); - const uint32_t err_code = ble_l2cap_cid_unregister_req_enc(cid, - &(p_buffer[1]), - &buffer_length); - //@note: Should never fail. - APP_ERROR_CHECK(err_code); - - //@note: Increment buffer length as internally managed packet type field must be included. - return ser_sd_transport_cmd_write(p_buffer, - (++buffer_length), - l2cap_cid_unregister_rsp_dec); -} - -/**@brief Command response callback function for @ref ble_l2cap_tx_req_enc BLE command. - * - * Callback for decoding the output parameters and the command response return code. - * - * @param[in] p_buffer Pointer to begin of command response buffer. - * @param[in] length Length of data in bytes. - * - * @return Decoded command response return code. - */ -static uint32_t l2cap_tx_rsp_dec(const uint8_t * p_buffer, uint16_t length) -{ - uint32_t result_code; - - const uint32_t err_code = - ble_l2cap_tx_rsp_dec(p_buffer, - length, - &result_code); - - APP_ERROR_CHECK(err_code); - - - - return result_code; -} - - -uint32_t sd_ble_l2cap_tx(uint16_t conn_handle, - ble_l2cap_header_t const * const p_header, - uint8_t const * const p_data) -{ - - uint8_t * p_buffer; - uint32_t buffer_length = 0; - - tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); - const uint32_t err_code = ble_l2cap_tx_req_enc(conn_handle, p_header, p_data, - &(p_buffer[1]), - &buffer_length); - //@note: Should never fail. - APP_ERROR_CHECK(err_code); - - //@note: Increment buffer length as internally managed packet type field must be included. - return ser_sd_transport_cmd_write(p_buffer, - (++buffer_length), - l2cap_tx_rsp_dec); -} - http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/middleware/app_mw_nrf_soc.c ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/middleware/app_mw_nrf_soc.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/middleware/app_mw_nrf_soc.c deleted file mode 100644 index 9fc2231..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/middleware/app_mw_nrf_soc.c +++ /dev/null @@ -1,144 +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. - * - */ - -#include "nrf_soc.h" -#include <stdint.h> -#include <string.h> -#include "ser_sd_transport.h" -#include "nrf_soc_app.h" -#include "nrf_error_soc.h" -#include "app_error.h" -#include "ble_serialization.h" - -#include "ser_app_power_system_off.h" - -static void * mp_out_param; - -static void tx_buf_alloc(uint8_t * * p_data, uint16_t * p_len) -{ - uint32_t err_code; - - do - { - err_code = ser_sd_transport_tx_alloc(p_data, p_len); - } - while (err_code != NRF_SUCCESS); - *p_data[0] = SER_PKT_TYPE_CMD; - *p_len -= 1; -} - - -uint32_t sd_power_system_off(void) -{ - uint8_t * p_buffer; - uint32_t buffer_length = 0; - - tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); - const uint32_t err_code = power_system_off_req_enc(&(p_buffer[1]), &buffer_length); - APP_ERROR_CHECK(err_code); - - ser_app_power_system_off_set(); - - //@note: Increment buffer length as internally managed packet type field must be included. - return ser_sd_transport_cmd_write(p_buffer, - (++buffer_length), - NULL); -} - - -/**@brief Command response callback function for @ref sd_temp_get BLE command. - * - * Callback for decoding the output parameters and the command response return code. - * - * @param[in] p_buffer Pointer to begin of command response buffer. - * @param[in] length Length of data in bytes. - * - * @return Decoded command response return code. - */ - -static uint32_t mw_temp_get_rsp_dec(const uint8_t * p_buffer, uint16_t length) -{ - uint32_t result_code; - - const uint32_t err_code = temp_get_rsp_dec(p_buffer, - length, - &result_code, - (int32_t *)mp_out_param); - - APP_ERROR_CHECK(err_code); - - return result_code; -} - -uint32_t sd_temp_get(int32_t * p_temp) -{ - - uint8_t * p_buffer; - uint32_t buffer_length = 0; - - tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); - mp_out_param = p_temp; - - const uint32_t err_code = temp_get_req_enc(p_temp, - &(p_buffer[1]), - &buffer_length); - APP_ERROR_CHECK(err_code); - - //@note: Increment buffer length as internally managed packet type field must be included. - return ser_sd_transport_cmd_write(p_buffer, - (++buffer_length), - mw_temp_get_rsp_dec); -} - -/**@brief Command response callback function for @ref sd_ecb_block_encrypt BLE command. - * - * Callback for decoding the output parameters and the command response return code. - * - * @param[in] p_buffer Pointer to begin of command response buffer. - * @param[in] length Length of data in bytes. - * - * @return Decoded command response return code. - */ - -static uint32_t mw_ecb_block_encrypt_rsp_dec(const uint8_t * p_buffer, uint16_t length) -{ - uint32_t result_code; - - const uint32_t err_code = ecb_block_encrypt_rsp_dec(p_buffer, - length, - (nrf_ecb_hal_data_t *)mp_out_param, - &result_code); - - APP_ERROR_CHECK(err_code); - - return result_code; -} - -uint32_t sd_ecb_block_encrypt(nrf_ecb_hal_data_t * p_ecb_data) -{ - - uint8_t * p_buffer; - uint32_t buffer_length = 0; - - tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); - mp_out_param = p_ecb_data; - - const uint32_t err_code = ecb_block_encrypt_req_enc(p_ecb_data, - &(p_buffer[1]), - &buffer_length); - APP_ERROR_CHECK(err_code); - - //@note: Increment buffer length as internally managed packet type field must be included. - return ser_sd_transport_cmd_write(p_buffer, - (++buffer_length), - mw_ecb_block_encrypt_rsp_dec); -} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/app_ble_gap_sec_keys.c ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/app_ble_gap_sec_keys.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/app_ble_gap_sec_keys.c deleted file mode 100644 index 8b0c7ae..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/app_ble_gap_sec_keys.c +++ /dev/null @@ -1,73 +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. - * - */ - -#include "app_ble_gap_sec_keys.h" -#include "nrf_error.h" -#include <stddef.h> - -ser_ble_gap_app_keyset_t m_app_keys_table[SER_MAX_CONNECTIONS]; - -uint32_t app_ble_gap_sec_context_create(uint16_t conn_handle, uint32_t *p_index) -{ - uint32_t err_code = NRF_ERROR_NO_MEM; - uint32_t i; - - for (i=0; i<SER_MAX_CONNECTIONS; i++ ) - { - if ( ! m_app_keys_table[i].conn_active ) - { - m_app_keys_table[i].conn_active = 1; - m_app_keys_table[i].conn_handle = conn_handle; - *p_index = i; - err_code = NRF_SUCCESS; - break; - } - } - - return err_code; -} - -uint32_t app_ble_gap_sec_context_destroy(uint16_t conn_handle) -{ - uint32_t err_code = NRF_ERROR_NOT_FOUND; - uint32_t i; - - for (i=0; i<SER_MAX_CONNECTIONS; i++ ) - { - if ( m_app_keys_table[i].conn_handle == conn_handle ) - { - m_app_keys_table[i].conn_active = 0; - err_code = NRF_SUCCESS; - break; - } - } - - return err_code; -} - -uint32_t app_ble_gap_sec_context_find(uint16_t conn_handle, uint32_t *p_index) -{ - uint32_t err_code = NRF_ERROR_NOT_FOUND; - uint32_t i; - - for (i=0; i<SER_MAX_CONNECTIONS; i++ ) - { - if ( (m_app_keys_table[i].conn_handle == conn_handle) && (m_app_keys_table[i].conn_active == 1) ) - { - *p_index = i; - err_code = NRF_SUCCESS; - break; - } - } - - return err_code; -} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/app_ble_gap_sec_keys.h ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/app_ble_gap_sec_keys.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/app_ble_gap_sec_keys.h deleted file mode 100644 index 525e939..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/app_ble_gap_sec_keys.h +++ /dev/null @@ -1,89 +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 _APP_BLE_GAP_SEC_KEYS_H -#define _APP_BLE_GAP_SEC_KEYS_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup ser_codecs Serialization codecs - * @ingroup ble_sdk_lib_serialization - */ - -/** - * @addtogroup ser_app_s130_codecs Application s130 codecs - * @ingroup ser_codecs - */ - - /**@file - * - * @defgroup app_ble_gap_sec_keys GAP Functions for managing memory for security keys in application device. - * @{ - * @ingroup ser_app_s130_codecs - * - * @brief GAP Application auxiliary functions for synchronizing GAP security keys with the ones stored in the connectivity device. - */ - -#include "ble_gap.h" -#include <stdint.h> - -#define SER_MAX_CONNECTIONS 2 - -/**@brief GAP connection - keyset mapping structure. - * - * @note This structure is used to map keysets to connection instances, and will be stored in a static table. - */ -typedef struct -{ - uint16_t conn_handle; /**< Connection handle.*/ - uint8_t conn_active; /**< Indication that keys for this connection are used by soft device. 0: keys used; 1: keys not used*/ - ble_gap_sec_keyset_t keyset; /**< Keyset structure, see @ref ble_gap_sec_keyset_t.*/ -} ser_ble_gap_app_keyset_t; - -/**@brief allocates instance in m_app_keys_table[] for storage of encryption keys. - * - * @param[in] conn_handle conn_handle - * @param[out] p_index pointer to the index of allocated instance - * - * @retval NRF_SUCCESS Context allocated. - * @retval NRF_ERROR_NO_MEM No free instance available. - */ -uint32_t app_ble_gap_sec_context_create(uint16_t conn_handle, uint32_t *p_index); - -/**@brief release instance identified by a connection handle. - * - * @param[in] conn_handle conn_handle - * - * @retval NRF_SUCCESS Context released. - * @retval NRF_ERROR_NOT_FOUND instance with conn_handle not found - */ -uint32_t app_ble_gap_sec_context_destroy(uint16_t conn_handle); - -/**@brief finds index of instance identified by a connection handle in m_app_keys_table[]. - * - * @param[in] conn_handle conn_handle - * - * @param[out] p_index Pointer to the index of the entry in the context table corresponding to the given conn_handle - * - * @retval NRF_SUCCESS Context found - * @retval NRF_ERROR_NOT_FOUND instance with conn_handle not found - */ -uint32_t app_ble_gap_sec_context_find(uint16_t conn_handle, uint32_t *p_index); -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif //_APP_BLE_GAP_SEC_KEYS_H http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/app_ble_user_mem.c ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/app_ble_user_mem.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/app_ble_user_mem.c deleted file mode 100644 index 14a268c..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/app_ble_user_mem.c +++ /dev/null @@ -1,74 +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. - * - */ - -#include "app_ble_user_mem.h" -#include "ser_config.h" -#include "nrf_error.h" -#include <stddef.h> - -ser_ble_user_mem_t m_app_user_mem_table[SER_MAX_CONNECTIONS]; - -uint32_t app_ble_user_mem_context_create(uint16_t conn_handle, uint32_t *p_index) -{ - uint32_t err_code = NRF_ERROR_NO_MEM; - uint32_t i; - - for (i=0; i<SER_MAX_CONNECTIONS; i++ ) - { - if ( ! m_app_user_mem_table[i].conn_active ) - { - m_app_user_mem_table[i].conn_active = 1; - m_app_user_mem_table[i].conn_handle = conn_handle; - *p_index = i; - err_code = NRF_SUCCESS; - break; - } - } - - return err_code; -} - -uint32_t app_ble_user_mem_context_destroy(uint16_t conn_handle) -{ - uint32_t err_code = NRF_ERROR_NOT_FOUND; - uint32_t i; - - for (i=0; i<SER_MAX_CONNECTIONS; i++ ) - { - if ( m_app_user_mem_table[i].conn_handle == conn_handle ) - { - m_app_user_mem_table[i].conn_active = 0; - err_code = NRF_SUCCESS; - break; - } - } - - return err_code; -} - -uint32_t app_ble_user_mem_context_find(uint16_t conn_handle, uint32_t *p_index) -{ - uint32_t err_code = NRF_ERROR_NOT_FOUND; - uint32_t i; - - for (i=0; i<SER_MAX_CONNECTIONS; i++ ) - { - if ( (m_app_user_mem_table[i].conn_handle == conn_handle) && (m_app_user_mem_table[i].conn_active == 1) ) - { - *p_index = i; - err_code = NRF_SUCCESS; - break; - } - } - - return err_code; -} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/app_ble_user_mem.h ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/app_ble_user_mem.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/app_ble_user_mem.h deleted file mode 100644 index c7ab7ca..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/app_ble_user_mem.h +++ /dev/null @@ -1,89 +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 _APP_BLE_USER_MEM_H -#define _APP_BLE_USER_MEM_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup ser_codecs Serialization codecs - * @ingroup ble_sdk_lib_serialization - */ - -/** - * @addtogroup ser_app_s130_codecs Application s130 codecs - * @ingroup ser_codecs - */ - - /**@file - * - * @defgroup app_ble_user_mem Functions for managing memory for user memory request in application device. - * @{ - * @ingroup ser_app_s130_codecs - * - * @brief Application auxiliary functions for synchronizing user memory with the one stored in the connectivity device. - */ - -#include "ble.h" -#include "ser_config.h" -#include <stdint.h> - -/**@brief Connection - user memory mapping structure. - * - * @note This structure is used to map user memory to connection instances, and will be stored in a static table. - */ -//lint -esym(452,ser_ble_user_mem_t) -typedef struct -{ - uint16_t conn_handle; /**< Connection handle.*/ - uint8_t conn_active; /**< Indication that user memory for this connection is used by soft device. 0: memory used; 1: memory not used*/ - ble_user_mem_block_t mem_block; /**< User memory block structure, see @ref ble_user_mem_block_t.*/ -} ser_ble_user_mem_t; - -/**@brief allocates instance in m_user_mem_table[] for storage. - * - * @param[in] conn_handle conn_handle - * @param[out] p_index pointer to the index of allocated instance - * - * @retval NRF_SUCCESS Context allocated. - * @retval NRF_ERROR_NO_MEM No free instance available. - */ -uint32_t app_ble_user_mem_context_create(uint16_t conn_handle, uint32_t *p_index); - -/**@brief release instance identified by a connection handle. - * - * @param[in] conn_handle conn_handle - * - * @retval NRF_SUCCESS Context released. - * @retval NRF_ERROR_NOT_FOUND instance with conn_handle not found - */ -uint32_t app_ble_user_mem_context_destroy(uint16_t conn_handle); - -/**@brief finds index of instance identified by a connection handle in m_user_mem_table[]. - * - * @param[in] conn_handle conn_handle - * - * @param[out] p_index Pointer to the index of the entry in the context table corresponding to the given conn_handle - * - * @retval NRF_SUCCESS Context found - * @retval NRF_ERROR_NOT_FOUND instance with conn_handle not found - */ -uint32_t app_ble_user_mem_context_find(uint16_t conn_handle, uint32_t *p_index); -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif //_APP_BLE_USER_MEM_H http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_app.h ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_app.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_app.h deleted file mode 100644 index a0f5c29..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_app.h +++ /dev/null @@ -1,455 +0,0 @@ -/* Copyright (c) 2013 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 BLE_APP_H__ -#define BLE_APP_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup ser_codecs Serialization codecs - * @ingroup ble_sdk_lib_serialization - */ - -/** - * @addtogroup ser_app_s130_codecs Application s130 codecs - * @ingroup ser_codecs - */ - -/**@file - * - * @defgroup ble_app Application command request encoders and command response decoders - * @{ - * @ingroup ser_app_s130_codecs - * - * @brief Application command request encoders and command response decoders. - */ -#include "ble.h" -/** - * @brief Encodes @ref sd_ble_tx_packet_count_get command request. - * - * @sa @ref nrf51_tx_packet_count_get_encoding for packet format, - * @ref ble_tx_packet_count_get_rsp_dec for command response decoder. - * - * @param[in] conn_handle Connection handle. - * @param[in] p_count Pointer to count value to be filled. - * @param[in] p_buf Pointer to buffer where encoded data command will be returned. - * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. - * \c out: Length of encoded command packet. - * - * @note \p p_count will not be updated by the command - * request encoder. Updated values are set by @ref ble_tx_packet_count_get_rsp_dec. - * - * @retval NRF_SUCCESS Encoding success. - * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. - * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. - */ -uint32_t ble_tx_packet_count_get_req_enc(uint16_t conn_handle, - uint8_t const * const p_count, - uint8_t * const p_buf, - uint32_t * const p_buf_len); - -/** - * @brief Decodes response to @ref sd_ble_tx_packet_count_get command. - * - * @sa @ref nrf51_tx_packet_count_get_encoding for packet format, - * @ref ble_tx_packet_count_get_req_enc for command request encoder. - * - * @param[in] p_buf Pointer to beginning of command response packet. - * @param[in] packet_len Length (in bytes) of response packet. - * @param[out] pp_count Pointer to pointer to count value. - * @param[out] p_result_code Command result code. - * - * @retval NRF_SUCCESS Decoding success. - * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. - * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. - * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match - * expected operation code. - */ -uint32_t ble_tx_packet_count_get_rsp_dec(uint8_t const * const p_buf, - uint32_t packet_len, - uint8_t * * const pp_count, - uint32_t * const p_result_code); - -/**@brief Encodes @ref sd_ble_uuid_encode command request. - * - * @sa @ref nrf51_uuid_encode_encoding for packet format, - * @ref ble_uuid_encode_rsp_dec for command response decoder. - * - * @param[in] p_uuid Pointer to a @ref ble_uuid_t structure that will be encoded into bytes. - * @param[in] p_uuid_le_len Size of \p p_uuid_le if \p p_uuid_le is not NULL - * @param[in] p_uuid_le Pointer to a buffer where the little endian raw UUID bytes(2 or 16) - * will be stored. Can be NULL to calculate required size. - * @param[in] p_buf Pointer to buffer where encoded data command will be returned. - * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. - * \c out: Length of encoded command packet. - * - * @note \p p_uuid_le_len and \p p_uuid_le will not be updated by the command - * request encoder. Updated values are set by @ref ble_uuid_encode_rsp_dec. - * - * @retval NRF_SUCCESS Encoding success. - * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. - * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. - */ -uint32_t ble_uuid_encode_req_enc(ble_uuid_t const * const p_uuid, - uint8_t const * const p_uuid_le_len, - uint8_t const * const p_uuid_le, - uint8_t * const p_buf, - uint32_t * const p_buf_len); - -/**@brief Decodes response to @ref sd_ble_uuid_encode command. - * - * @sa @ref nrf51_uuid_encode_encoding for packet format, - * @ref ble_uuid_encode_req_enc for command request encoder. - * - * @param[in] p_buf Pointer to beginning of command response packet. - * @param[in] packet_len Length (in bytes) of response packet. - * @param[in,out] p_uuid_le_len \c in: Size (in bytes) of \p p_uuid_le buffer. - * \c out: Length of decoded contents of \p p_uuid_le. - * @param[out] p_uuid_le Pointer to a buffer where the encoded UUID will be stored. - * @param[out] p_result_code Command result code. - * - * @retval NRF_SUCCESS Decoding success. - * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. - * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. - * @retval NRF_ERROR_DATA_SIZE Length of \p p_uuid_le is too small to hold decoded - * value from response. - * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected - * operation code. - */ -uint32_t ble_uuid_encode_rsp_dec(uint8_t const * const p_buf, - uint32_t packet_len, - uint8_t * const p_uuid_le_len, - uint8_t * const p_uuid_le, - uint32_t * const p_result_code); - -/**@brief Encodes @ref sd_ble_uuid_decode command request. - * - * @sa @ref nrf51_uuid_decode_encoding for packet format, - * @ref ble_uuid_decode_rsp_dec for command response decoder. - * - * @param[in] uuid_le_len Size of \p p_uuid_le if \p p_uuid_le is not NULL - * @param[in] p_uuid_le Pointer to a buffer where the little endian raw UUID bytes(2 or 16) - * is stored. - * @param[out] p_uuid Pointer to a @ref ble_uuid_t structure were raw UUID will be decoded. - * @param[in] p_buf Pointer to buffer where encoded data command will be returned. - * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. - * \c out: Length of encoded command packet. - * - * @note \p p_uuid will not be updated by the command request encoder. - * Updated values are set by @ref ble_uuid_decode_rsp_dec. - * - * @retval NRF_SUCCESS Encoding success. - * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. - * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. - */ -uint32_t ble_uuid_decode_req_enc(uint8_t uuid_le_len, - uint8_t const * const p_uuid_le, - ble_uuid_t * const p_uuid, - uint8_t * const p_buf, - uint32_t * const p_buf_len); - -/**@brief Decodes response to @ref sd_ble_uuid_decode command. - * - * @sa @ref nrf51_uuid_decode_encoding for packet format, - * @ref ble_uuid_decode_req_enc for command request encoder. - * - * @param[in] p_buf Pointer to beginning of command response packet. - * @param[in] packet_len Length (in bytes) of response packet. - * @param[out] p_uuid Pointer to a buffer where the decoded UUID will be stored. - * @param[out] p_result_code Command result code. - * - * @retval NRF_SUCCESS Decoding success. - * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. - * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. - * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected - * operation code. - */ -uint32_t ble_uuid_decode_rsp_dec(uint8_t const * const p_buf, - uint32_t packet_len, - ble_uuid_t * * const p_uuid, - uint32_t * const p_result_code); - -/**@brief Encodes @ref sd_ble_uuid_vs_add command request. - * - * @sa @ref nrf51_uuid_vs_add_encoding for packet format, - * @ref ble_uuid_vs_add_rsp_dec for command response decoder. - * - * @param[in] p_vs_uuid Pointer to a @ref ble_uuid128_t structure. - * @param[in] p_uuid_type Pointer to uint8_t where UUID type will be returned. - * @param[in] p_buf Pointer to buffer where encoded data command will be returned. - * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. - * \c out: Length of encoded command packet. - * - * @note \p p_uuid_type will not be updated by the command request encoder. - * Updated values are set by @ref ble_uuid_vs_add_rsp_dec. - * - * @retval NRF_SUCCESS Encoding success. - * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. - * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. - */ -uint32_t ble_uuid_vs_add_req_enc(ble_uuid128_t const * const p_vs_uuid, - uint8_t * const p_uuid_type, - uint8_t * const p_buf, - uint32_t * const p_buf_len); - -/**@brief Decodes response to @ref sd_ble_uuid_vs_add command. - * - * @sa @ref nrf51_uuid_vs_add_encoding for packet format, - * @ref ble_uuid_vs_add_req_enc for command request encoder. - * - * @param[in] p_buf Pointer to beginning of command response packet. - * @param[in] buf_len Length (in bytes) of response packet. - * @param[out] pp_uuid_type Pointer to a pointer to uint8_t where the decoded UUID type will be stored. - * @param[out] p_result_code Command result code. - * - * @retval NRF_SUCCESS Decoding success. - * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. - * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. - * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected - * operation code. - */ -uint32_t ble_uuid_vs_add_rsp_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint8_t * * const pp_uuid_type, - uint32_t * const p_result_code); - -/**@brief Encodes @ref sd_ble_version_get command request. - * - * @sa @ref nrf51_version_get_encoding for packet format, - * @ref ble_version_get_rsp_dec for command response decoder. - * - * @param[in] p_version Pointer to a @ref ble_version_t structure to be filled by the response. - * @param[in] p_buf Pointer to buffer where encoded data command will be returned. - * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. - * \c out: Length of encoded command packet. - * - * @retval NRF_SUCCESS Encoding success. - * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. - * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. - */ -uint32_t ble_version_get_req_enc(ble_version_t const * const p_version, - uint8_t * const p_buf, - uint32_t * const p_buf_len); - -/**@brief Decodes response to @ref sd_ble_version_get command. - * - * @sa @ref nrf51_version_get_encoding for packet format, - * @ref ble_version_get_req_enc for command request encoder. - * - * @param[in] p_buf Pointer to beginning of command response packet. - * @param[in] packet_len Length (in bytes) of response packet. - * @param[out] p_version Pointer to a @ref ble_version_t where decoded version will be stored. - * @param[out] p_result_code Command result code. - * - * @return NRF_SUCCESS Version information stored successfully. - * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. - * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to - * hold decoded event. - */ -uint32_t ble_version_get_rsp_dec(uint8_t const * const p_buf, - uint32_t packet_len, - ble_version_t * p_version, - uint32_t * const p_result_code); - - -/**@brief Encodes @ref sd_ble_opt_set command request. - * - * @sa @ref nrf51_opt_set_encoding for packet format, - * @ref ble_opt_set_rsp_dec for command response decoder. - * - * @param[in] opt_id Identifies type of parameter in ble_opt_t union. - * @param[in] p_opt Pointer to ble_opt_t union. - * @param[in] p_buf Pointer to buffer where encoded data command will be returned. - * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. - * \c out: Length of encoded command packet. - * - * @retval NRF_SUCCESS Encoding success. - * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. - * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. - * @retval NRF_ERROR_INVALID_PARAM Invalid opt id. - */ -uint32_t ble_opt_set_req_enc(uint32_t const opt_id, - ble_opt_t const * const p_opt, - uint8_t * const p_buf, - uint32_t * const p_buf_len); - -/**@brief Decodes response to @ref sd_ble_opt_set command. - * - * @sa @ref nrf51_opt_set_encoding for packet format, - * @ref ble_opt_set_req_enc for command request encoder. - * - * @param[in] p_buf Pointer to beginning of command response packet. - * @param[in] packet_len Length (in bytes) of response packet. - * @param[out] p_result_code Command result code. - * - * @return NRF_SUCCESS Version information stored successfully. - * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. - */ -uint32_t ble_opt_set_rsp_dec(uint8_t const * const p_buf, - uint32_t packet_len, - uint32_t * const p_result_code); - -/**@brief Encodes @ref sd_ble_enable command request. - * - * @sa @ref nrf51_enable_encoding for packet format, - * @ref ble_enable_rsp_dec for command response decoder. - * - * @param[in] p_ble_enable_params Pointer to a @ref ble_enable_params_t structure. - * @param[in] p_buf Pointer to buffer where encoded data command will be returned. - * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. - * \c out: Length of encoded command packet. - * - * @retval NRF_SUCCESS Encoding success. - * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. - * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. - */ -uint32_t ble_enable_req_enc(ble_enable_params_t * p_ble_enable_params, - uint8_t * const p_buf, - uint32_t * const p_buf_len); - -/**@brief Decodes response to @ref sd_ble_enable command. - * - * @sa @ref nrf51_enable_encoding for packet format, - * @ref ble_enable_req_enc for command request encoder. - * - * @param[in] p_buf Pointer to beginning of command response packet. - * @param[in] packet_len Length (in bytes) of response packet. - * @param[out] p_result_code Command result code. - * - * @return NRF_SUCCESS Success. - * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. - * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to - * hold decoded event. - */ -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, - * @ref ble_opt_get_rsp_dec for command response decoder. - * - * @param[in] opt_id Identifies type of parameter in ble_opt_t union. - * @param[in] p_opt Pointer to a @ref ble_opt_t union to be filled by the response. - * @param[in] p_buf Pointer to buffer where encoded data command will be returned. - * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. - * \c out: Length of encoded command packet. - * - * @retval NRF_SUCCESS Encoding success. - * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. - * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. - * @retval NRF_ERROR_INVALID_PARAM Invalid opt id. - */ -uint32_t ble_opt_get_req_enc(uint32_t opt_id, - ble_opt_t const * const p_opt, - uint8_t * const p_buf, - uint32_t * const p_buf_len); - -/**@brief Decodes response to @ref sd_ble_opt_get command. - * - * @sa @ref nrf51_opt_get_encoding for packet format, - * @ref ble_opt_get_req_enc for command request encoder. - * - * @param[in] p_buf Pointer to beginning of command response packet. - * @param[in] packet_len Length (in bytes) of response packet. - * @param[out] p_opt_id Pointer to a decoded opt_id - * @param[out] p_opt Pointer to a decoded @ref ble_opt_t union - * @param[out] p_result_code Command result code. - * - * @return NRF_SUCCESS Opt stored successfully. - * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. - * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to - * hold decoded event. - * @retval NRF_ERROR_INVALID_PARAM Invalid opt id. - */ - -uint32_t ble_opt_get_rsp_dec(uint8_t const * const p_buf, - uint32_t packet_len, - uint32_t * const p_opt_id, - ble_opt_t * const p_opt, - uint32_t * const p_result_code); - -/**@brief Encodes @ref sd_ble_user_mem_reply command request. - * - * @sa @ref nrf51_user_mem_reply_encoding for packet format, - * @ref ble_user_mem_reply_rsp_dec for command response decoder. - * - * @param[in] conn_handle Connection Handle. - * @param[in] p_block Pointer to a @ref ble_user_mem_block_t structure. - * @param[in] p_buf Pointer to buffer where encoded data command will be returned. - * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. - * \c out: Length of encoded command packet. - * - * @retval NRF_SUCCESS Encoding success. - * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. - * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. - * @retval NRF_ERROR_INVALID_PARAM Invalid opt id. - */ -uint32_t ble_user_mem_reply_req_enc(uint16_t conn_handle, - ble_user_mem_block_t const * p_block, - uint8_t * const p_buf, - uint32_t * const p_buf_len); - -/**@brief Decodes response to @ref sd_ble_user_mem_reply command. - * - * @sa @ref nrf51_user_mem_reply_encoding for packet format, - * @ref ble_user_mem_reply_req_enc for command request encoder. - * - * @param[in] p_buf Pointer to beginning of command response packet. - * @param[in] packet_len Length (in bytes) of response packet. - * @param[out] p_result_code Command result code. - * - * @return NRF_SUCCESS Opt stored successfully. - * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. - * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to - * hold decoded event. - * @retval NRF_ERROR_INVALID_PARAM Invalid opt id. - */ -uint32_t ble_user_mem_reply_rsp_dec(uint8_t const * const p_buf, - uint32_t packet_len, - uint32_t * const p_result_code); - -/**@brief Event decoding dispatcher. - * - * The event decoding dispatcher will route the event packet to the correct decoder which in turn - * decodes the contents of the event and updates the \p p_event struct. - * - * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. - * - * @param[in] p_buf Pointer to beginning of event packet. - * @param[in] packet_len Length (in bytes) of event packet. - * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be - * stored. If NULL, required length will be returned in \p p_event_len. - * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. - * \c out: Length of decoded contents of \p p_event. - * - * @retval NRF_SUCCESS Decoding success. - * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. - * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. - * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to - * hold decoded event. - * @retval NRF_ERROR_NOT_FOUND Decoding failure. No event decoder is available. - */ -uint32_t ble_event_dec(uint8_t const * const p_buf, - uint32_t packet_len, - ble_evt_t * const p_event, - uint32_t * const p_event_len); - -/** @} */ -#ifdef __cplusplus -} -#endif - -#endif http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_enable.c ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_enable.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_enable.c deleted file mode 100644 index 0c3aa29..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_enable.c +++ /dev/null @@ -1,50 +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. - * - */ - -#include <stdlib.h> -#include <string.h> -#include "ble_app.h" -#include "ble_serialization.h" -#include "ble_struct_serialization.h" -#include "cond_field_serialization.h" -#include "app_util.h" - - -uint32_t ble_enable_req_enc(ble_enable_params_t * p_ble_enable_params, - uint8_t * const p_buf, - uint32_t * const p_buf_len) -{ - uint32_t index = 0; - uint32_t err_code = NRF_SUCCESS; - - SER_ASSERT_NOT_NULL(p_buf); - SER_ASSERT_NOT_NULL(p_buf_len); - - SER_ASSERT_LENGTH_LEQ(index + 2, *p_buf_len); - - p_buf[index++] = SD_BLE_ENABLE; - - err_code = cond_field_enc(p_ble_enable_params, p_buf, *p_buf_len, &index, ble_enable_params_t_enc); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - *p_buf_len = index; - - return err_code; -} - - -uint32_t ble_enable_rsp_dec(uint8_t const * const p_buf, - uint32_t packet_len, - uint32_t * const p_result_code) -{ - return ser_ble_cmd_rsp_dec(p_buf, packet_len, SD_BLE_ENABLE, p_result_code); -} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_event.c ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_event.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_event.c deleted file mode 100644 index 197e42f..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_event.c +++ /dev/null @@ -1,262 +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. - * - */ - -#include "ble_app.h" -#include "ble_evt_app.h" -#include "ble_gap_evt_app.h" -#include "ble_gattc_evt_app.h" -#include "ble_gatts_evt_app.h" -#include "ble_l2cap_evt_app.h" -#include "ble_serialization.h" -#include "app_util.h" - -uint32_t ble_event_dec(uint8_t const * const p_buf, - uint32_t packet_len, - ble_evt_t * const p_event, - uint32_t * const p_event_len) -{ - uint32_t err_code; - - SER_ASSERT_NOT_NULL(p_buf); - SER_ASSERT_NOT_NULL(p_event_len); - SER_ASSERT_LENGTH_LEQ(SER_EVT_HEADER_SIZE, packet_len); - - - const uint16_t event_id = uint16_decode(&p_buf[SER_EVT_ID_POS]); - const uint8_t * p_sub_buffer = &p_buf[SER_EVT_HEADER_SIZE]; - const uint32_t sub_packet_len = packet_len - SER_EVT_HEADER_SIZE; - - if (p_event) - { - SER_ASSERT_LENGTH_LEQ(sizeof (ble_evt_hdr_t), *p_event_len); - *p_event_len -= sizeof (ble_evt_hdr_t); - } - - switch (event_id) - { - case BLE_EVT_TX_COMPLETE: - err_code = ble_evt_tx_complete_dec(p_sub_buffer, sub_packet_len, p_event, p_event_len); - break; - - case BLE_EVT_USER_MEM_REQUEST: - err_code = ble_evt_user_mem_request_dec(p_sub_buffer, sub_packet_len, p_event, p_event_len); - break; - - case BLE_EVT_USER_MEM_RELEASE: - err_code = ble_evt_user_mem_release_dec(p_sub_buffer, sub_packet_len, p_event, p_event_len); - break; - - case BLE_GAP_EVT_PASSKEY_DISPLAY: - err_code = ble_gap_evt_passkey_display_dec(p_sub_buffer, sub_packet_len, p_event, - p_event_len); - break; - - case BLE_GAP_EVT_AUTH_KEY_REQUEST: - err_code = ble_gap_evt_auth_key_request_dec(p_sub_buffer, sub_packet_len, p_event, - p_event_len); - break; - - case BLE_GAP_EVT_CONN_PARAM_UPDATE: - err_code = ble_gap_evt_conn_param_update_dec(p_sub_buffer, sub_packet_len, p_event, - p_event_len); - break; - - case BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST: - err_code = ble_gap_evt_conn_param_update_request_dec(p_sub_buffer, sub_packet_len, p_event, - p_event_len); - break; - - case BLE_GAP_EVT_CONN_SEC_UPDATE: - err_code = ble_gap_evt_conn_sec_update_dec(p_sub_buffer, sub_packet_len, p_event, - p_event_len); - break; - - case BLE_GAP_EVT_CONNECTED: - err_code = ble_gap_evt_connected_dec(p_sub_buffer, sub_packet_len, p_event, p_event_len); - break; - - case BLE_GAP_EVT_DISCONNECTED: - err_code = ble_gap_evt_disconnected_dec(p_sub_buffer, - sub_packet_len, - p_event, - p_event_len); - break; - - case BLE_GAP_EVT_TIMEOUT: - err_code = ble_gap_evt_timeout_dec(p_sub_buffer, sub_packet_len, p_event, p_event_len); - break; - - case BLE_GAP_EVT_RSSI_CHANGED: - err_code = ble_gap_evt_rssi_changed_dec(p_sub_buffer, - sub_packet_len, - p_event, - p_event_len); - break; - - case BLE_GAP_EVT_SEC_INFO_REQUEST: - err_code = ble_gap_evt_sec_info_request_dec(p_sub_buffer, sub_packet_len, p_event, - p_event_len); - break; - - case BLE_GAP_EVT_SEC_PARAMS_REQUEST: - err_code = ble_gap_evt_sec_params_request_dec(p_sub_buffer, sub_packet_len, p_event, - p_event_len); - break; - - case BLE_GAP_EVT_AUTH_STATUS: - err_code = ble_gap_evt_auth_status_dec(p_sub_buffer, - sub_packet_len, - p_event, - p_event_len); - break; - - case BLE_GAP_EVT_SEC_REQUEST: - err_code = ble_gap_evt_sec_request_dec(p_sub_buffer, - sub_packet_len, - p_event, - p_event_len); - break; - - case BLE_GAP_EVT_KEY_PRESSED: - err_code = ble_gap_evt_key_pressed_dec(p_sub_buffer, - sub_packet_len, - p_event, - p_event_len); - break; - - case BLE_GAP_EVT_LESC_DHKEY_REQUEST: - err_code = ble_gap_evt_lesc_dhkey_request_dec(p_sub_buffer, - sub_packet_len, - p_event, - p_event_len); - break; - - case BLE_GATTC_EVT_CHAR_DISC_RSP: - err_code = ble_gattc_evt_char_disc_rsp_dec(p_sub_buffer, sub_packet_len, p_event, - p_event_len); - break; - - case BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP: - err_code = ble_gattc_evt_char_val_by_uuid_read_rsp_dec(p_sub_buffer, - sub_packet_len, - p_event, - p_event_len); - break; - - case BLE_GATTC_EVT_DESC_DISC_RSP: - err_code = ble_gattc_evt_desc_disc_rsp_dec(p_sub_buffer, sub_packet_len, p_event, - p_event_len); - break; - - case BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP: - err_code = ble_gattc_evt_prim_srvc_disc_rsp_dec(p_sub_buffer, sub_packet_len, p_event, - p_event_len); - break; - - case BLE_GATTC_EVT_READ_RSP: - err_code = ble_gattc_evt_read_rsp_dec(p_sub_buffer, - sub_packet_len, - p_event, - p_event_len); - break; - - case BLE_GATTC_EVT_HVX: - err_code = ble_gattc_evt_hvx_dec(p_sub_buffer, sub_packet_len, p_event, p_event_len); - break; - - case BLE_GATTC_EVT_TIMEOUT: - err_code = ble_gattc_evt_timeout_dec(p_sub_buffer, sub_packet_len, p_event, p_event_len); - break; - - case BLE_GATTC_EVT_WRITE_RSP: - err_code = ble_gattc_evt_write_rsp_dec(p_sub_buffer, - sub_packet_len, - p_event, - p_event_len); - break; - - case BLE_GATTC_EVT_CHAR_VALS_READ_RSP: - err_code = ble_gattc_evt_char_vals_read_rsp_dec(p_sub_buffer, - sub_packet_len, - p_event, - p_event_len); - break; - - case BLE_GATTC_EVT_REL_DISC_RSP: - err_code = ble_gattc_evt_rel_disc_rsp_dec(p_sub_buffer, - sub_packet_len, - p_event, - p_event_len); - break; - - case BLE_GATTC_EVT_ATTR_INFO_DISC_RSP: - err_code = ble_gattc_evt_attr_info_disc_rsp_dec(p_sub_buffer, - sub_packet_len, - p_event, - p_event_len); - break; - - case BLE_GATTS_EVT_WRITE: - err_code = ble_gatts_evt_write_dec(p_sub_buffer, sub_packet_len, p_event, p_event_len); - break; - - case BLE_GATTS_EVT_TIMEOUT: - err_code = ble_gatts_evt_timeout_dec(p_sub_buffer, sub_packet_len, p_event, p_event_len); - break; - - case BLE_GATTS_EVT_SC_CONFIRM: - err_code = ble_gatts_evt_sc_confirm_dec(p_sub_buffer, - sub_packet_len, - p_event, - p_event_len); - break; - - case BLE_GATTS_EVT_HVC: - err_code = ble_gatts_evt_hvc_dec(p_sub_buffer, sub_packet_len, p_event, p_event_len); - break; - - case BLE_GATTS_EVT_SYS_ATTR_MISSING: - err_code = ble_gatts_evt_sys_attr_missing_dec(p_sub_buffer, sub_packet_len, p_event, - p_event_len); - break; - - case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST: - err_code = ble_gatts_evt_rw_authorize_request_dec(p_sub_buffer, sub_packet_len, p_event, - p_event_len); - break; - - case BLE_L2CAP_EVT_RX: - err_code = ble_l2cap_evt_rx_dec(p_sub_buffer, sub_packet_len, p_event, p_event_len); - break; - - case BLE_GAP_EVT_ADV_REPORT: - err_code = ble_gap_evt_adv_report_dec(p_sub_buffer, sub_packet_len, p_event, p_event_len); - break; - - case BLE_GAP_EVT_SCAN_REQ_REPORT: - err_code = ble_gap_evt_scan_req_report_dec(p_sub_buffer, sub_packet_len, p_event, p_event_len); - break; - default: - err_code = NRF_ERROR_NOT_FOUND; - break; - } - - if (p_event != NULL) - { - p_event->header.evt_id = (err_code == NRF_SUCCESS) ? event_id : 0; - p_event->header.evt_len = (err_code == NRF_SUCCESS) ? - (uint16_t)*p_event_len : 0; - } - - *p_event_len += sizeof(ble_evt_hdr_t); - return err_code; -}