You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by st...@apache.org on 2016/07/27 23:13:34 UTC
[05/51] [partial] incubator-mynewt-core git commit: add stm32 and
nordic sdks based on new structure
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_app.h
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_app.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_app.h
new file mode 100644
index 0000000..989fd59
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_app.h
@@ -0,0 +1,631 @@
+/* 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_GATTS_APP_H__
+#define BLE_GATTS_APP_H__
+
+/**
+ * @addtogroup ser_codecs Serialization codecs
+ * @ingroup ble_sdk_lib_serialization
+ */
+
+/**
+ * @addtogroup ser_app_s130_codecs Application s130 codecs
+ * @ingroup ser_codecs
+ */
+
+/**@file
+ *
+ * @defgroup ble_gatts_app GATTS Application command request encoders and command response decoders
+ * @{
+ * @ingroup ser_app_s130_codecs
+ *
+ * @brief GATTS Application command request encoders and command response decoders.
+ */
+#include "ble_gatts.h"
+#include "ble.h"
+
+/**@brief Encodes @ref sd_ble_gatts_value_get command request.
+ *
+ * @sa @ref nrf51_gatts_value_get_encoding for packet format,
+ * @ref ble_gatts_value_get_rsp_dec for command response decoder.
+ *
+ * @param[in] conn_handle Connection handle.
+ * @param[in] handle Attribute handle.
+ * @param[in] p_value Pointer to attribute value information.
+ * @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_data_len and \p p_data will not be updated by the command
+ * request encoder. Updated values are set by @ref ble_gatts_value_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_gatts_value_get_req_enc(uint16_t conn_handle,
+ uint16_t handle,
+ ble_gatts_value_t const * const p_value,
+ uint8_t * const p_buf,
+ uint32_t * const p_buf_len);
+
+/**@brief Decodes response to @ref sd_ble_gatts_value_get command.
+ *
+ * @sa @ref nrf51_gatts_value_get_encoding for packet format,
+ * @ref ble_gatts_value_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_value Pointer to structure where the attribute value 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_value is too small to hold decoded
+ * value from response.
+ */
+uint32_t ble_gatts_value_get_rsp_dec(uint8_t const * const p_buf,
+ uint32_t packet_len,
+ ble_gatts_value_t * const p_value,
+ uint32_t * const p_result_code);
+
+/**@brief Encodes @ref sd_ble_gatts_hvx command request.
+ *
+ * @sa @ref nrf51_gatts_hvx_encoding for packet format,
+ * @ref ble_gatts_hvx_rsp_dec for command response decoder.
+ *
+ * @param[in] conn_handle Connection handle.
+ * @param[in] p_hvx_params Pointer to an HVx parameters structure to be encoded.
+ * @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_hvx_params will not be updated by the command
+ * request encoder. Updated values are set by @ref ble_gatts_hvx_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_gatts_hvx_req_enc(uint16_t conn_handle,
+ ble_gatts_hvx_params_t const * const p_hvx_params,
+ uint8_t * const p_buf,
+ uint32_t * const p_buf_len);
+
+/**@brief Decodes response to @ref sd_ble_gatts_hvx command.
+ *
+ * @sa @ref nrf51_gatts_hvx_encoding for packet format,
+ * @ref ble_gatts_hvx_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.
+ * @param[out] pp_bytes_written Pointer to pointer to location where number of bytes is written.
+ *
+ * @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_gatts_hvx_rsp_dec(uint8_t const * const p_buf,
+ uint32_t packet_len,
+ uint32_t * const p_result_code,
+ uint16_t * * const pp_bytes_written);
+
+/**@brief Encodes @ref sd_ble_gatts_characteristic_add command request.
+ *
+ * @sa @ref nrf51_characteristics_add_encoding for packet format,
+ * @ref ble_gatts_characteristic_add_rsp_dec for command response decoder.
+ *
+ * @param[in] service_handle Handle of the service where the characteristic is to be placed.
+ * If @ref BLE_GATT_HANDLE_INVALID is used, it will be placed
+ * sequentially.
+ * @param[in] p_char_md Pointer to a @ref ble_gatts_char_md_t structure, characteristic
+ * metadata.
+ * @param[in] p_attr_char_value Pointer to a @ref ble_gatts_attr_t structure, corresponding to
+ * the characteristic value.
+ * @param[in] p_handles Pointer to a @ref ble_gatts_char_handles_t structure, where the
+ * assigned handles will be stored.
+ * @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_handles will not be updated by the command
+ * request encoder. Updated values are set by @ref ble_gatts_characteristic_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_gatts_characteristic_add_req_enc
+ (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 * const p_handles,
+ uint8_t * const p_buf,
+ uint32_t * const p_buf_len);
+
+/**@brief Decodes response to @ref sd_ble_gatts_characteristic_add command.
+ *
+ * @sa @ref nrf51_characteristics_add_encoding for packet format,
+ * @ref ble_gatts_characteristic_add_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_handles Pointer to pointer to location where handles should be decoded.
+ * @param[out] p_result_code Pointer to command result code decode location.
+ *
+ * @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_gatts_characteristic_add_rsp_dec(uint8_t const * const p_buf,
+ uint32_t packet_len,
+ uint16_t * * const pp_handles,
+ uint32_t * const p_result_code);
+
+
+/**@brief Encodes @ref sd_ble_gatts_service_add command request.
+ *
+ * @sa @ref nrf51_gatts_service_add_encoding for packet format,
+ * @ref ble_gatts_service_add_rsp_dec for command response decoder.
+ *
+ * @param[in] type Toggles between primary and secondary services,
+ * see @ref BLE_GATTS_SRVC_TYPES.
+ * @param[in] p_uuid Pointer to service UUID.
+ * @param[in] p_conn_handle Pointer to a 16-bit word where the assigned handle will be stored.
+ * @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_conn_handle will not be updated by the command
+ * request encoder. Updated values are set by @ref ble_gatts_service_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_gatts_service_add_req_enc(uint8_t type,
+ ble_uuid_t const * const p_uuid,
+ uint16_t const * const p_conn_handle,
+ uint8_t * const p_buf,
+ uint32_t * const p_buf_len);
+
+/**@brief Decodes response to @ref sd_ble_gatts_service_add command.
+ *
+ * @sa @ref nrf51_gatts_service_add_encoding for packet format,
+ * @ref ble_gatts_service_add_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_conn_handle Connection handle.
+ * @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_gatts_service_add_rsp_dec(uint8_t const * const p_buf,
+ uint32_t packet_len,
+ uint16_t * const p_conn_handle,
+ uint32_t * const p_result_code);
+
+/**@brief Encodes @ref sd_ble_gatts_sys_attr_set command request.
+ *
+ * @sa @ref nrf51_gatts_sys_attr_set_encoding for packet format,
+ * @ref ble_gatts_sys_attr_set_rsp_dec for command response decoder.
+ *
+ * @param[in] conn_handle Connection handle.
+ * @param[in] p_sys_attr_data Pointer to a buffer (at least \p sys_attr_data_len bytes long)
+ * containing the attribute value to write.
+ * @param[in] sys_attr_data_len Length (in bytes) of \p p_sys_attr_data.
+ * @param[in] flags Optional additional flags.
+ * @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_gatts_sys_attr_set_req_enc(uint16_t conn_handle,
+ uint8_t const * const p_sys_attr_data,
+ uint16_t sys_attr_data_len,
+ uint32_t flags,
+ uint8_t * const p_buf,
+ uint32_t * const p_buf_len);
+
+/**@brief Decodes response to @ref sd_ble_gatts_sys_attr_set command.
+ *
+ * @sa @ref nrf51_gatts_sys_attr_set_encoding for packet format,
+ * @ref ble_gatts_sys_attr_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.
+ *
+ * @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_gatts_sys_attr_set_rsp_dec(uint8_t const * const p_buf,
+ uint32_t packet_len,
+ uint32_t * const p_result_code);
+
+/**@brief Encodes @ref sd_ble_gatts_value_set command request.
+ *
+ * @sa @ref nrf51_gatts_value_set_encoding for packet format,
+ * @ref ble_gatts_value_set_rsp_dec for command response decoder.
+ *
+ * @param[in] conn_handle Connection handle.
+ * @param[in] handle Attribute handle.
+ * @param[in] p_value Pointer to attribute value information.
+ * @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_gatts_value_set_req_enc(uint16_t conn_handle,
+ uint16_t handle,
+ ble_gatts_value_t * p_value,
+ uint8_t * const p_buf,
+ uint32_t * const p_buf_len);
+
+/**@brief Decodes response to @ref sd_ble_gatts_value_set command.
+ *
+ * @sa @ref nrf51_gatts_value_set_encoding for packet format,
+ * @ref ble_gatts_value_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_value Pointer to attribute value information..
+ * @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_gatts_value_set_rsp_dec(uint8_t const * const p_buf,
+ uint32_t packet_len,
+ ble_gatts_value_t * const p_value,
+ uint32_t * const p_result_code);
+
+/**@brief Encodes @ref sd_ble_gatts_sys_attr_get command request.
+ *
+ * @sa @ref nrf51_gatts_sys_attr_get_encoding for packet format,
+ * @ref ble_gatts_sys_attr_get_rsp_dec for command response decoder.
+ *
+ * @param[in] conn_handle Connection handle of the connection.
+ * @param[in] p_sys_attr_data Pointer to buffer where updated information about system
+ * attributes will be stored. Can be NULL to calculate required
+ * size.
+ * @param[in] p_sys_attr_data_len Size of p_sys_attr_data buffer if \p p_sys_attr_data is
+ * not NULL.
+ * @param[in] flags Additional optional flags.
+ * @param[in,out] 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_sys_attr_data and \p p_sys_attr_data_len will not be updated by the command
+ * request encoder. Updated values are set by @ref ble_gatts_sys_attr_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_gatts_sys_attr_get_req_enc(uint16_t conn_handle,
+ uint8_t const * const p_sys_attr_data,
+ uint16_t const * const p_sys_attr_data_len,
+ uint32_t flags,
+ uint8_t * const p_buf,
+ uint32_t * p_buf_len);
+
+/**@brief Decodes response to @ref sd_ble_gatts_sys_attr_get command.
+ *
+ * @sa @ref nrf51_gatts_sys_attr_get_encoding for packet format,
+ * @ref ble_gatts_sys_attr_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_sys_attr_data Pointer to a buffer where updated information about system
+ * attributes will be stored.
+ * @param[in,out] p_sys_attr_data_len \c in: Size (in bytes) of \p p_sys_attr_data buffer.
+ * \c out: Length of decoded contents of \p p_sys_attr_data.
+ * @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_sys_attr_data 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_gatts_sys_attr_get_rsp_dec(uint8_t const * const p_buf,
+ uint32_t packet_len,
+ uint8_t * const p_sys_attr_data,
+ uint16_t * const p_sys_attr_data_len,
+ uint32_t * const p_result_code);
+
+/**@brief Encodes @ref sd_ble_gatts_descriptor_add command request.
+ *
+ * @sa @ref nrf51_descriptor_add_encoding for packet format,
+ * @ref ble_gatts_descriptor_add_rsp_dec for command response decoder.
+ *
+ * @param[in] char_handle Handle of the characteristic where the description is to be placed.
+ * If @ref BLE_GATT_HANDLE_INVALID is used, it will be placed
+ * sequentially.
+ * @param[in] p_attr Pointer to a @ref ble_gatts_attr_t structure, characteristic
+ * metadata.
+ * @param[in] p_handle Pointer to a @ref ble_gatts_char_handles_t structure, where the
+ * assigned handles will be stored.
+ * @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_gatts_descriptor_add_req_enc(uint16_t char_handle,
+ ble_gatts_attr_t const * const p_attr,
+ uint16_t * const p_handle,
+ uint8_t * const p_buf,
+ uint32_t * const p_buf_len);
+
+/**@brief Decodes response to @ref sd_ble_gatts_descriptor_add command.
+ *
+ * @sa @ref nrf51_descriptor_add_encoding for packet format,
+ * @ref ble_gatts_descriptor_add_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_handle Pointer to bufer where descriptor handle will be
+ returned.
+ * @param[out] p_result_code Pointer to command result code decode location.
+ *
+ * @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_gatts_descriptor_add_rsp_dec(uint8_t const * const p_buf,
+ uint32_t packet_len,
+ uint16_t * const p_handle,
+ uint32_t * const p_result_code);
+
+/**@brief Encodes @ref sd_ble_gatts_include_add command request.
+ *
+ * @sa @ref nrf51_gatts_include_add_encoding for packet format,
+ * @ref ble_gatts_include_add_rsp_dec for command response decoder.
+ *
+ * @param[in] service_handle Handle of the service where the included service is to be placed.
+ * @param[in] inc_srvc_handle Handle of the included service
+ * @param[in] p_include_handle Pointer to Pointer to a 16-bit word where the assigned handle will be stored.
+ * @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_gatts_include_add_req_enc(uint16_t service_handle,
+ uint16_t inc_srvc_handle,
+ uint16_t * const p_include_handle,
+ uint8_t * const p_buf,
+ uint32_t * const p_buf_len);
+
+/**@brief Decodes response to @ref sd_ble_gatts_include_add command.
+ *
+ * @sa @ref nrf51_gatts_include_add_encoding for packet format,
+ * @ref ble_gatts_include_add_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_include_handle Pointer to a 16-bit word where the assigned handle will be stored.
+ * @param[out] p_result_code Pointer to command result code decode location.
+ *
+ * @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_gatts_include_add_rsp_dec(uint8_t const * const p_buf,
+ uint32_t packet_len,
+ uint16_t * const p_include_handle,
+ uint32_t * const p_result_code);
+
+
+/**@brief Encodes @ref sd_ble_gatts_rw_authorize_reply command request.
+ *
+ * @sa @ref nrf51_gatts_rw_authorize_reply_encoding for packet format,
+ * @ref ble_gatts_rw_authorize_reply_rsp_dec for command response decoder.
+ *
+ * @param[in] conn_handle Connection handle.
+ * @param[in] p_reply_params Pointer to \ref ble_gatts_rw_authorize_reply_params_t
+ * @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 Encoding failure. Invalid param provided in p_reply_params.
+ */
+uint32_t ble_gatts_rw_authorize_reply_req_enc(
+ uint16_t conn_handle,
+ ble_gatts_rw_authorize_reply_params_t const * const
+ p_reply_params,
+ uint8_t * const
+ p_buf,
+ uint32_t * const
+ p_buf_len);
+
+/**@brief Decodes response to @ref sd_ble_gatts_rw_authorize_reply command.
+ *
+ * @sa @ref nrf51_gatts_rw_authorize_reply_encoding for packet format,
+ * @ref ble_gatts_rw_authorize_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.
+ *
+ * @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_gatts_rw_authorize_reply_rsp_dec(uint8_t const * const p_buf,
+ uint32_t packet_len,
+ uint32_t * const p_result_code);
+
+/**@brief Encodes @ref sd_ble_gatts_service_changed command request.
+ *
+ * @sa @ref nrf51_service_changed_encoding for packet format,
+ * @ref ble_gatts_service_changed_rsp_dec for command response decoder.
+ *
+ * @param[in] conn_handle Connection handle.
+ * @param[in] start_handle Start of affected attribute handle range.
+ * @param[in] end_handle End of affected attribute handle range.
+ * @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 Encoding failure. Invalid param provided in p_reply_params.
+ */
+uint32_t ble_gatts_service_changed_req_enc(uint16_t conn_handle,
+ uint16_t start_handle,
+ uint16_t end_handle,
+ uint8_t * const p_buf,
+ uint32_t * const p_buf_len);
+
+/**@brief Decodes response to @ref sd_ble_gatts_service_changed command.
+ *
+ * @sa @ref nrf51_service_changed_encoding for packet format,
+ * @ref ble_gatts_service_changed_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.
+ *
+ * @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_gatts_service_changed_rsp_dec(uint8_t const * const p_buf,
+ uint32_t packet_len,
+ uint32_t * const p_result_code);
+
+/**@brief Encodes @ref sd_ble_gatts_attr_get command request.
+ *
+ * @sa @ref ble_gatts_attr_get_rsp_dec for command response decoder.
+ *
+ * @param[in] handle See @ref sd_ble_gatts_attr_get.
+ * @param[in] p_uuid See @ref sd_ble_gatts_attr_get.
+ * @param[out] p_md See @ref sd_ble_gatts_attr_get.
+ * @param[in,out] 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_gatts_attr_get_req_enc(uint16_t handle,
+ ble_uuid_t * p_uuid,
+ ble_gatts_attr_md_t * p_md,
+ uint8_t * const p_buf,
+ uint32_t * p_buf_len);
+
+/**@brief Decodes response to @ref sd_ble_gatts_attr_get command.
+ *
+ * @sa @ref ble_gatts_attr_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_md Pointer to address where to put output data.
+ * @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_gatts_attr_get_rsp_dec(uint8_t const * const p_buf,
+ uint32_t packet_len,
+ ble_gatts_attr_md_t ** pp_md,
+ uint32_t * const p_result_code);
+
+/**@brief Encodes @ref sd_ble_gatts_initial_user_handle_get command request.
+ *
+ * @sa @ref ble_gatts_initial_user_handle_get_rsp_dec for command response decoder.
+ *
+ * @param[out] p_handle See @ref sd_ble_gatts_initial_user_handle_get.
+ * @param[in,out] 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_gatts_initial_user_handle_get_req_enc(uint16_t * p_handle,
+ uint8_t * const p_buf,
+ uint32_t * p_buf_len);
+
+/**@brief Decodes response to @ref sd_ble_gatts_initial_user_handle_get command.
+ *
+ * @sa @ref ble_gatts_initial_user_handle_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_handle Pointer to address where to put output data.
+ * @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_gatts_initial_user_handle_get_rsp_dec(uint8_t const * const p_buf,
+ uint32_t packet_len,
+ uint16_t ** pp_handle,
+ uint32_t * const p_result_code);
+/** @} */
+#endif //BLE_GATTS_APP_H__
+
+
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_attr_get.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_attr_get.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_attr_get.c
new file mode 100644
index 0000000..c2e7b44
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_attr_get.c
@@ -0,0 +1,86 @@
+/* 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_app.h"
+#include <stdlib.h>
+#include <string.h>
+#include "ble_serialization.h"
+#include "ble_gatts_struct_serialization.h"
+#include "ble_struct_serialization.h"
+#include "cond_field_serialization.h"
+#include "app_util.h"
+
+
+uint32_t ble_gatts_attr_get_req_enc(uint16_t handle,
+ ble_uuid_t * p_uuid,
+ ble_gatts_attr_md_t * p_md,
+ uint8_t * const p_buf,
+ uint32_t * p_buf_len)
+{
+ uint32_t index = 0;
+ uint32_t err_code = NRF_SUCCESS;
+ uint32_t total_len = *p_buf_len;
+
+ SER_ASSERT_NOT_NULL(p_buf);
+ SER_ASSERT_NOT_NULL(p_buf_len);
+
+ p_buf[index++] = SD_BLE_GATTS_ATTR_GET;
+
+ err_code = uint16_t_enc(&handle, p_buf, total_len, &index);
+ SER_ASSERT(err_code == NRF_SUCCESS, err_code);
+
+ err_code = cond_field_enc(p_uuid, p_buf, total_len, &index, ble_uuid_t_enc);
+ SER_ASSERT(err_code == NRF_SUCCESS, err_code);
+
+ err_code = cond_field_enc(p_md, p_buf, total_len, &index, NULL);
+ SER_ASSERT(err_code == NRF_SUCCESS, err_code);
+
+ *p_buf_len = index;
+
+ return NRF_SUCCESS;
+}
+
+
+uint32_t ble_gatts_attr_get_rsp_dec(uint8_t const * const p_buf,
+ uint32_t packet_len,
+ ble_gatts_attr_md_t ** pp_md,
+ uint32_t * const p_result_code)
+{
+ SER_ASSERT_NOT_NULL(p_buf);
+ SER_ASSERT_NOT_NULL(p_result_code);
+ uint32_t err_code;
+ uint32_t index = 0;
+ uint32_t decode_result = ser_ble_cmd_rsp_result_code_dec(p_buf,
+ &index,
+ packet_len,
+ SD_BLE_GATTS_ATTR_GET,
+ p_result_code);
+
+ if (decode_result != NRF_SUCCESS)
+ {
+ return decode_result;
+ }
+
+ if (*p_result_code != NRF_SUCCESS)
+ {
+ SER_ASSERT_LENGTH_EQ(index, packet_len);
+ return NRF_SUCCESS;
+ }
+
+ err_code = cond_field_dec(p_buf, packet_len, &index, (void * *)pp_md,
+ ble_gatts_attr_md_dec);
+ SER_ASSERT(err_code == NRF_SUCCESS, err_code);
+
+ SER_ASSERT_LENGTH_EQ(index, packet_len);
+
+ return NRF_SUCCESS;
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_characteristic_add.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_characteristic_add.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_characteristic_add.c
new file mode 100644
index 0000000..b72e14b
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_characteristic_add.c
@@ -0,0 +1,89 @@
+/* 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_app.h"
+#include <string.h>
+#include "ble_serialization.h"
+#include "ble_gatts.h"
+#include "app_util.h"
+#include "cond_field_serialization.h"
+#include "ble_gatts_struct_serialization.h"
+
+uint32_t ble_gatts_characteristic_add_req_enc(
+ 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 * const p_handles,
+ uint8_t * const p_buf,
+ uint32_t * const p_buf_len)
+{
+ SER_ASSERT_NOT_NULL(p_buf);
+ SER_ASSERT_NOT_NULL(p_buf_len);
+
+ uint32_t index = 0;
+ uint32_t err_code = NRF_SUCCESS;
+ uint8_t opcode = SD_BLE_GATTS_CHARACTERISTIC_ADD;
+ uint32_t buf_len = *p_buf_len;
+
+ err_code = uint8_t_enc(&opcode, p_buf, buf_len, &index);
+ SER_ASSERT(err_code == NRF_SUCCESS, err_code);
+
+ err_code = uint16_t_enc(&service_handle, p_buf, buf_len, &index);
+ SER_ASSERT(err_code == NRF_SUCCESS, err_code);
+
+ err_code = cond_field_enc(p_char_md, p_buf, buf_len, &index, ble_gatts_char_md_enc);
+ SER_ERROR_CHECK(err_code == NRF_SUCCESS, err_code);
+
+ err_code = cond_field_enc(p_attr_char_value, p_buf, buf_len, &index, ble_gatts_attr_enc);
+ SER_ERROR_CHECK(err_code == NRF_SUCCESS, err_code);
+
+ err_code = cond_field_enc(p_handles, p_buf, buf_len, &index, NULL);
+ SER_ASSERT(err_code == NRF_SUCCESS, err_code);
+
+ *p_buf_len = index;
+
+ return err_code;
+}
+
+
+uint32_t ble_gatts_characteristic_add_rsp_dec(uint8_t const * const p_buf,
+ uint32_t buf_len,
+ uint16_t * * const pp_handles,
+ uint32_t * const p_result_code)
+{
+ SER_ASSERT_NOT_NULL(p_buf);
+ SER_ASSERT_NOT_NULL(p_result_code);
+
+ uint32_t index = 0;
+
+ uint32_t err_code = ser_ble_cmd_rsp_result_code_dec(p_buf, &index, buf_len,
+ SD_BLE_GATTS_CHARACTERISTIC_ADD,
+ p_result_code);
+ SER_ASSERT(err_code == NRF_SUCCESS, err_code);
+
+ if (*p_result_code != NRF_SUCCESS)
+ {
+ SER_ASSERT_LENGTH_EQ(index, buf_len);
+ return NRF_SUCCESS;
+ }
+
+ err_code = cond_field_dec(p_buf,
+ buf_len,
+ &index,
+ (void * *)pp_handles,
+ ble_gatts_char_handles_dec);
+ SER_ASSERT(err_code == NRF_SUCCESS, err_code);
+
+ SER_ASSERT_LENGTH_EQ(index, buf_len);
+
+ return err_code;
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_descriptor_add.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_descriptor_add.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_descriptor_add.c
new file mode 100644
index 0000000..43b45d8
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_descriptor_add.c
@@ -0,0 +1,91 @@
+/* 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_gatts_app.h"
+#include <stdlib.h>
+#include <string.h>
+#include "ble_serialization.h"
+#include "ble_gap.h"
+#include "app_util.h"
+#include "cond_field_serialization.h"
+#include "ble_gatts_struct_serialization.h"
+
+
+uint32_t ble_gatts_descriptor_add_req_enc(uint16_t char_handle,
+ ble_gatts_attr_t const * const p_attr,
+ uint16_t * const p_handle,
+ uint8_t * const p_buf,
+ uint32_t * const p_buf_len)
+{
+ uint32_t index = 0;
+
+ SER_ASSERT_NOT_NULL(p_buf);
+ SER_ASSERT_NOT_NULL(p_buf_len);
+
+ SER_ASSERT_LENGTH_LEQ(1, *p_buf_len);
+ p_buf[index++] = SD_BLE_GATTS_DESCRIPTOR_ADD;
+
+ uint32_t err_code = uint16_t_enc(&char_handle, p_buf, *p_buf_len, &index);
+ SER_ASSERT(err_code == NRF_SUCCESS, err_code);
+
+ err_code = cond_field_enc(p_attr,
+ p_buf,
+ *p_buf_len,
+ &index,
+ ble_gatts_attr_enc);
+ SER_ERROR_CHECK(err_code == NRF_SUCCESS, err_code);
+
+ SER_ASSERT_LENGTH_LEQ(index + 1, *p_buf_len);
+ p_buf[index++] = (p_handle != NULL) ? SER_FIELD_PRESENT :
+ SER_FIELD_NOT_PRESENT;
+
+ *p_buf_len = index;
+
+ return err_code;
+}
+
+uint32_t ble_gatts_descriptor_add_rsp_dec(uint8_t const * const p_buf,
+ uint32_t packet_len,
+ uint16_t * const p_handle,
+ uint32_t * const p_result_code)
+{
+ SER_ASSERT_NOT_NULL(p_buf);
+ SER_ASSERT_NOT_NULL(p_result_code);
+
+ uint32_t index = 0;
+ uint32_t decode_result = ser_ble_cmd_rsp_result_code_dec(p_buf,
+ &index,
+ packet_len,
+ SD_BLE_GATTS_DESCRIPTOR_ADD,
+ p_result_code);
+
+ if (decode_result != NRF_SUCCESS)
+ {
+ return decode_result;
+ }
+
+ if (*p_result_code != NRF_SUCCESS)
+ {
+ SER_ASSERT_LENGTH_EQ(index, packet_len);
+ return NRF_SUCCESS;
+ }
+
+ SER_ASSERT_LENGTH_LEQ(index + 2, packet_len);
+ SER_ASSERT_NOT_NULL(p_handle);
+
+ uint16_dec(p_buf, packet_len, &index, p_handle);
+
+ SER_ASSERT_LENGTH_EQ(index, packet_len);
+
+ return NRF_SUCCESS;
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_evt_app.h
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_evt_app.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_evt_app.h
new file mode 100644
index 0000000..21e9b29
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_evt_app.h
@@ -0,0 +1,186 @@
+/* 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 BLE_GATTS_EVT_APP_H__
+#define BLE_GATTS_EVT_APP_H__
+
+/**
+ * @addtogroup ser_codecs Serialization codecs
+ * @ingroup ble_sdk_lib_serialization
+ */
+
+/**
+ * @addtogroup ser_app_s130_codecs Application s130 codecs
+ * @ingroup ser_codecs
+ */
+
+/**@file
+ *
+ * @defgroup ble_gatts_evt_app GATTS Application event decoders
+ * @{
+ * @ingroup ser_app_s130_codecs
+ *
+ * @brief GATTS Application event decoders.
+ */
+#include "ble.h"
+
+/**
+ * @brief Decodes ble_gatts_evt_hvc event.
+ *
+ * @sa @ref nrf51_gatts_evt_hvc_encoding for packet format.
+ *
+ * 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 the beginning of an event packet.
+ * @param[in] packet_len Length (in bytes) of the 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.
+ */
+uint32_t ble_gatts_evt_hvc_dec(uint8_t const * const p_buf,
+ uint32_t packet_len,
+ ble_evt_t * const p_event,
+ uint32_t * const p_event_len);
+
+/**
+ * @brief Decodes ble_gatts_evt_rw_authorize_request event.
+ *
+ * @sa @ref nrf51_evt_rw_authorize_request for packet format.
+ *
+ * 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 the beginning of an event packet.
+ * @param[in] packet_len Length (in bytes) of the 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.
+ */
+uint32_t ble_gatts_evt_rw_authorize_request_dec(uint8_t const * const p_buf,
+ uint32_t packet_len,
+ ble_evt_t * const p_event,
+ uint32_t * const p_event_len);
+
+/**
+ * @brief Decodes ble_gatts_evt_sc_confirm event.
+ *
+ * @sa @ref nrf51_gatts_evt_sc_confirm_encoding for packet format.
+ *
+ * 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 the beginning of an event packet.
+ * @param[in] packet_len Length (in bytes) of the 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.
+ */
+uint32_t ble_gatts_evt_sc_confirm_dec(uint8_t const * const p_buf,
+ uint32_t packet_len,
+ ble_evt_t * const p_event,
+ uint32_t * const p_event_len);
+
+/**
+ * @brief Decodes ble_gatts_evt_sys_attr_missing event.
+ *
+ * @sa @ref nrf51_evt_sys_attr_missing_encoding for packet format.
+ *
+ * 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 the beginning of an event packet.
+ * @param[in] packet_len Length (in bytes) of the 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.
+ */
+uint32_t ble_gatts_evt_sys_attr_missing_dec(uint8_t const * const p_buf,
+ uint32_t packet_len,
+ ble_evt_t * const p_event,
+ uint32_t * const p_event_len);
+
+/**
+ * @brief Decodes ble_gatts_evt_timeout event.
+ *
+ * @sa @ref nrf51_gatts_evt_timeout_encoding for packet format.
+ *
+ * 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 the beginning of an event packet.
+ * @param[in] packet_len Length (in bytes) of the 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.
+ */
+uint32_t ble_gatts_evt_timeout_dec(uint8_t const * const p_buf,
+ uint32_t packet_len,
+ ble_evt_t * const p_event,
+ uint32_t * const p_event_len);
+
+/**
+ * @brief Decodes ble_gatts_evt_write event.
+ *
+ * @sa @ref nrf51_evt_write_encoding for packet format.
+ *
+ * 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 the beginning of an event packet.
+ * @param[in] packet_len Length (in bytes) of the 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.
+ */
+uint32_t ble_gatts_evt_write_dec(uint8_t const * const p_buf,
+ uint32_t packet_len,
+ ble_evt_t * const p_event,
+ uint32_t * const p_event_len);
+
+/** @} */
+#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_evt_hvc.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_evt_hvc.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_evt_hvc.c
new file mode 100644
index 0000000..4707ae8
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_evt_hvc.c
@@ -0,0 +1,51 @@
+/* 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_evt_app.h"
+#include "ble_serialization.h"
+#include "app_util.h"
+
+
+uint32_t ble_gatts_evt_hvc_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 index = 0;
+
+ SER_ASSERT_NOT_NULL(p_buf);
+ SER_ASSERT_NOT_NULL(p_event_len);
+
+ SER_ASSERT_LENGTH_LEQ(SER_EVT_CONN_HANDLE_SIZE + 1, packet_len);
+
+ uint32_t event_len = SER_EVT_CONN_HANDLE_SIZE + sizeof (ble_gatts_evt_hvc_t);
+
+ if (p_event == NULL)
+ {
+ *p_event_len = event_len;
+ return NRF_SUCCESS;
+ }
+
+ SER_ASSERT(event_len <= *p_event_len, NRF_ERROR_DATA_SIZE);
+
+ p_event->header.evt_id = BLE_GATTS_EVT_HVC;
+ p_event->header.evt_len = event_len;
+
+ uint16_dec(p_buf, packet_len, &index, &p_event->evt.gatts_evt.conn_handle);
+ uint16_dec(p_buf, packet_len, &index, &p_event->evt.gatts_evt.params.hvc.handle);
+
+ SER_ASSERT_LENGTH_EQ(index, packet_len);
+
+ *p_event_len = event_len;
+
+ return NRF_SUCCESS;
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_evt_rw_authorize_request.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_evt_rw_authorize_request.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_evt_rw_authorize_request.c
new file mode 100644
index 0000000..9335725
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_evt_rw_authorize_request.c
@@ -0,0 +1,78 @@
+/* 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_gatts_evt_app.h"
+#include "ble_serialization.h"
+#include "ble_gatts_struct_serialization.h"
+#include "app_ble_user_mem.h"
+#include "app_util.h"
+
+extern ser_ble_user_mem_t m_app_user_mem_table[];
+
+uint32_t ble_gatts_evt_rw_authorize_request_dec(uint8_t const * const p_buf,
+ uint32_t packet_len,
+ ble_evt_t * const p_event,
+ uint32_t * const p_event_len)
+{
+ SER_ASSERT_NOT_NULL(p_buf);
+ SER_ASSERT_NOT_NULL(p_event_len);
+
+ uint32_t index = 0;
+ uint32_t err_code = NRF_SUCCESS;
+
+ uint32_t in_event_len = *p_event_len;
+
+ *p_event_len = offsetof(ble_evt_t, evt.gatts_evt.params) - sizeof (ble_evt_hdr_t);
+
+ uint16_t conn_handle;
+ err_code = uint16_t_dec(p_buf, packet_len, &index, &conn_handle);
+ SER_ASSERT(err_code == NRF_SUCCESS, err_code);
+
+ void * p_void_authorize_request = NULL;
+
+ if (p_event != NULL)
+ {
+ SER_ASSERT_LENGTH_LEQ(*p_event_len, in_event_len);
+
+ p_event->header.evt_id = BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST;
+ p_event->evt.gatts_evt.conn_handle = conn_handle;
+
+ p_void_authorize_request = &(p_event->evt.gatts_evt.params.authorize_request);
+ }
+ uint32_t tmp_event_len = in_event_len - *p_event_len;
+ err_code = ble_gatts_evt_rw_authorize_request_t_dec(p_buf,
+ packet_len,
+ &index,
+ &tmp_event_len,
+ p_void_authorize_request);
+ SER_ASSERT(err_code == NRF_SUCCESS, err_code);
+
+ *p_event_len += tmp_event_len;
+
+ if(p_event != NULL)
+ {
+ if((p_event->evt.gatts_evt.params.authorize_request.type == BLE_GATTS_AUTHORIZE_TYPE_WRITE) && (p_event->evt.gatts_evt.params.authorize_request.request.write.op == BLE_GATTS_OP_EXEC_WRITE_REQ_NOW))
+ {
+ uint32_t conn_index;
+
+ if(app_ble_user_mem_context_find(p_event->evt.gatts_evt.conn_handle, &conn_index) != NRF_ERROR_NOT_FOUND)
+ {
+ err_code = len16data_dec(p_buf, packet_len, &index, &m_app_user_mem_table[conn_index].mem_block.p_mem, &m_app_user_mem_table[conn_index].mem_block.len);
+ SER_ASSERT(err_code == NRF_SUCCESS, err_code);
+ }
+ }
+ }
+
+ SER_ASSERT_LENGTH_EQ(index, packet_len);
+
+ return err_code;
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_evt_sc_confirm.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_evt_sc_confirm.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_evt_sc_confirm.c
new file mode 100644
index 0000000..4f6d2c4
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_evt_sc_confirm.c
@@ -0,0 +1,49 @@
+/* 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_gatts_evt_app.h"
+#include "ble_serialization.h"
+#include "app_util.h"
+
+
+uint32_t ble_gatts_evt_sc_confirm_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 index = 0;
+
+ SER_ASSERT_NOT_NULL(p_buf);
+ SER_ASSERT_NOT_NULL(p_event_len);
+
+ SER_ASSERT_LENGTH_LEQ(SER_EVT_CONN_HANDLE_SIZE, packet_len);
+
+ uint32_t event_len = SER_EVT_CONN_HANDLE_SIZE;
+
+ if (p_event == NULL)
+ {
+ *p_event_len = event_len;
+ return NRF_SUCCESS;
+ }
+
+ SER_ASSERT(event_len <= *p_event_len, NRF_ERROR_DATA_SIZE);
+
+ p_event->header.evt_id = BLE_GATTS_EVT_SC_CONFIRM;
+ p_event->header.evt_len = event_len;
+
+ uint16_dec(p_buf, packet_len, &index, &p_event->evt.gatts_evt.conn_handle);
+
+ SER_ASSERT_LENGTH_EQ(index, packet_len);
+ *p_event_len = event_len;
+
+ return NRF_SUCCESS;
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_evt_sys_attr_missing.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_evt_sys_attr_missing.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_evt_sys_attr_missing.c
new file mode 100644
index 0000000..d9a0d0c
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_evt_sys_attr_missing.c
@@ -0,0 +1,51 @@
+/* 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_evt_app.h"
+#include "ble_serialization.h"
+#include "app_util.h"
+
+
+uint32_t ble_gatts_evt_sys_attr_missing_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 index = 0;
+
+ SER_ASSERT_NOT_NULL(p_buf);
+ SER_ASSERT_NOT_NULL(p_event_len);
+
+ SER_ASSERT_LENGTH_LEQ(3, packet_len);
+
+ uint32_t event_len = (uint16_t) (offsetof(ble_evt_t, evt.gatts_evt.params.sys_attr_missing)) +
+ sizeof (ble_gatts_evt_sys_attr_missing_t) -
+ sizeof (ble_evt_hdr_t);
+
+ if (p_event == NULL)
+ {
+ *p_event_len = event_len;
+ return NRF_SUCCESS;
+ }
+
+ SER_ASSERT(event_len <= *p_event_len, NRF_ERROR_DATA_SIZE);
+
+ p_event->header.evt_id = BLE_GATTS_EVT_SYS_ATTR_MISSING;
+ p_event->header.evt_len = event_len;
+ uint16_dec(p_buf, packet_len, &index, &p_event->evt.gap_evt.conn_handle);
+ uint8_dec(p_buf, packet_len, &index, &p_event->evt.gatts_evt.params.sys_attr_missing.hint);
+
+ SER_ASSERT_LENGTH_EQ(index, packet_len);
+ *p_event_len = event_len;
+
+ return NRF_SUCCESS;
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_evt_timeout.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_evt_timeout.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_evt_timeout.c
new file mode 100644
index 0000000..bb959b7
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_evt_timeout.c
@@ -0,0 +1,50 @@
+/* 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_evt_app.h"
+#include "ble_serialization.h"
+#include "app_util.h"
+
+
+uint32_t ble_gatts_evt_timeout_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 index = 0;
+
+ SER_ASSERT_NOT_NULL(p_buf);
+ SER_ASSERT_NOT_NULL(p_event_len);
+
+ SER_ASSERT_LENGTH_LEQ(SER_EVT_CONN_HANDLE_SIZE + 1, packet_len);
+
+ uint32_t event_len = SER_EVT_CONN_HANDLE_SIZE + sizeof (ble_gatts_evt_timeout_t);
+
+ if (p_event == NULL)
+ {
+ *p_event_len = event_len;
+ return NRF_SUCCESS;
+ }
+
+ SER_ASSERT(event_len <= *p_event_len, NRF_ERROR_DATA_SIZE);
+
+ p_event->header.evt_id = BLE_GATTS_EVT_TIMEOUT;
+ p_event->header.evt_len = event_len;
+
+ uint16_dec(p_buf, packet_len, &index, &p_event->evt.gatts_evt.conn_handle);
+ uint8_dec(p_buf, packet_len, &index, &p_event->evt.gatts_evt.params.timeout.src);
+
+ SER_ASSERT_LENGTH_EQ(index, packet_len);
+ *p_event_len = event_len;
+
+ return NRF_SUCCESS;
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_evt_write.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_evt_write.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_evt_write.c
new file mode 100644
index 0000000..3d8610c
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_evt_write.c
@@ -0,0 +1,78 @@
+/* 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_evt_app.h"
+#include <string.h>
+#include "ble_serialization.h"
+#include "ble_gatts_struct_serialization.h"
+#include "app_ble_user_mem.h"
+#include "app_util.h"
+
+extern ser_ble_user_mem_t m_app_user_mem_table[];
+
+uint32_t ble_gatts_evt_write_dec(uint8_t const * const p_buf,
+ uint32_t packet_len,
+ ble_evt_t * const p_event,
+ uint32_t * const p_event_len)
+{
+ SER_ASSERT_NOT_NULL(p_buf);
+ SER_ASSERT_NOT_NULL(p_event_len);
+
+ uint32_t err_code = NRF_SUCCESS;
+ uint32_t index = 0;
+
+ uint32_t in_event_len = *p_event_len;
+
+ *p_event_len = offsetof(ble_evt_t, evt.gatts_evt.params) - sizeof (ble_evt_hdr_t);
+
+ uint16_t conn_handle;
+ err_code = uint16_t_dec(p_buf, packet_len, &index, &conn_handle);
+ SER_ASSERT(err_code == NRF_SUCCESS, err_code);
+
+ void * p_void_write = NULL;
+
+ if (p_event != NULL)
+ {
+ SER_ASSERT_LENGTH_LEQ(*p_event_len, in_event_len);
+ p_event->evt.gatts_evt.conn_handle = conn_handle;
+
+ p_void_write = &(p_event->evt.gatts_evt.params.write);
+ }
+
+ uint32_t tmp_struct_len = in_event_len - *p_event_len;
+ err_code = ble_gatts_evt_write_t_dec(p_buf,
+ packet_len,
+ &index,
+ &tmp_struct_len,
+ p_void_write);
+ SER_ASSERT(err_code == NRF_SUCCESS, err_code);
+
+ *p_event_len += tmp_struct_len;
+
+ if(p_event != NULL)
+ {
+ if(p_event->evt.gatts_evt.params.write.op == BLE_GATTS_OP_EXEC_WRITE_REQ_NOW)
+ {
+ uint32_t conn_index;
+
+ if(app_ble_user_mem_context_find(p_event->evt.gatts_evt.conn_handle, &conn_index) != NRF_ERROR_NOT_FOUND)
+ {
+ err_code = len16data_dec(p_buf, packet_len, &index, &m_app_user_mem_table[conn_index].mem_block.p_mem, &m_app_user_mem_table[conn_index].mem_block.len);
+ SER_ASSERT(err_code == NRF_SUCCESS, err_code);
+ }
+ }
+ }
+
+ SER_ASSERT_LENGTH_EQ(index, packet_len);
+
+ return err_code;
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_hvx.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_hvx.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_hvx.c
new file mode 100644
index 0000000..bfdf455
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_hvx.c
@@ -0,0 +1,115 @@
+/* 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_app.h"
+#include <string.h>
+#include "ble_serialization.h"
+#include "cond_field_serialization.h"
+#include "ble_gap.h"
+#include "app_util.h"
+
+
+uint32_t ble_gatts_hvx_req_enc(uint16_t conn_handle,
+ ble_gatts_hvx_params_t const * const p_hvx_params,
+ uint8_t * const p_buf,
+ uint32_t * const p_buf_len)
+{
+ uint32_t index = 0;
+
+ SER_ASSERT_NOT_NULL(p_buf);
+ SER_ASSERT_NOT_NULL(p_buf_len);
+
+ SER_ASSERT(p_hvx_params == NULL ||
+ !(p_hvx_params->p_len == NULL && p_hvx_params->p_data != NULL), NRF_ERROR_NULL);
+
+ SER_ASSERT_LENGTH_LEQ(index + 1 + 2 + 1 + 1, *p_buf_len);
+
+ p_buf[index++] = SD_BLE_GATTS_HVX;
+ index += uint16_encode(conn_handle, &p_buf[index]);
+
+ p_buf[index++] = (p_hvx_params != NULL) ? SER_FIELD_PRESENT : SER_FIELD_NOT_PRESENT;
+
+ if (p_hvx_params != NULL)
+ {
+ SER_ASSERT_LENGTH_LEQ(index + 2 + 1 + 2 + 2, *p_buf_len);
+ index += uint16_encode(p_hvx_params->handle, &p_buf[index]);
+ p_buf[index++] = p_hvx_params->type;
+ index += uint16_encode(p_hvx_params->offset, &p_buf[index]);
+
+ if (p_hvx_params->p_len != NULL)
+ {
+ SER_ASSERT_LENGTH_LEQ(index + 1 + 2 + 1, *p_buf_len);
+
+ SER_ERROR_CHECK(*p_hvx_params->p_len <= BLE_GATTS_VAR_ATTR_LEN_MAX,
+ NRF_ERROR_INVALID_PARAM);
+ p_buf[index++] = SER_FIELD_PRESENT;
+ index += uint16_encode(*(p_hvx_params->p_len), &p_buf[index]);
+
+ if (p_hvx_params->p_data != NULL)
+ {
+ SER_ASSERT_LENGTH_LEQ(index + 1 + *(p_hvx_params->p_len), *p_buf_len);
+ p_buf[index++] = SER_FIELD_PRESENT;
+ memcpy(&(p_buf[index]), p_hvx_params->p_data, *(p_hvx_params->p_len));
+ index += *(p_hvx_params->p_len);
+ }
+ else
+ {
+ p_buf[index++] = SER_FIELD_NOT_PRESENT;
+ }
+ }
+ else
+ {
+ p_buf[index++] = SER_FIELD_NOT_PRESENT;
+ p_buf[index++] = SER_FIELD_NOT_PRESENT;
+ }
+ }
+
+ *p_buf_len = index;
+
+ return NRF_SUCCESS;
+}
+
+
+uint32_t ble_gatts_hvx_rsp_dec(uint8_t const * const p_buf,
+ uint32_t packet_len,
+ uint32_t * const p_result_code,
+ uint16_t * * const pp_bytes_written)
+{
+ SER_ASSERT_NOT_NULL(p_buf);
+ SER_ASSERT_NOT_NULL(p_result_code);
+
+ uint32_t err_code;
+ uint32_t index = 0;
+ uint32_t decode_result = ser_ble_cmd_rsp_result_code_dec(p_buf,
+ &index,
+ packet_len,
+ SD_BLE_GATTS_HVX,
+ p_result_code);
+
+ if (decode_result != NRF_SUCCESS)
+ {
+ return decode_result;
+ }
+
+ if (*p_result_code != NRF_SUCCESS)
+ {
+ SER_ASSERT_LENGTH_EQ(index, packet_len);
+ return NRF_SUCCESS;
+ }
+
+ err_code = cond_field_dec(p_buf, packet_len, &index, (void * *)pp_bytes_written, uint16_t_dec);
+ SER_ASSERT(err_code == NRF_SUCCESS, err_code);
+
+ SER_ASSERT_LENGTH_EQ(index, packet_len);
+
+ return NRF_SUCCESS;
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_include_add.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_include_add.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_include_add.c
new file mode 100644
index 0000000..4a5faca
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_include_add.c
@@ -0,0 +1,74 @@
+/* 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_app.h"
+#include "ble_serialization.h"
+#include "ble_gatts.h"
+#include "app_util.h"
+
+
+uint32_t ble_gatts_include_add_req_enc(uint16_t service_handle,
+ uint16_t inc_srvc_handle,
+ uint16_t * const p_include_handle,
+ 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(6, *p_buf_len);
+
+ uint32_t index = 0;
+ uint32_t buf_len = *p_buf_len;
+ uint32_t err_code;
+ uint8_t opCode = SD_BLE_GATTS_INCLUDE_ADD;
+ uint8_t presenceFlag;
+
+ err_code = uint8_t_enc(&opCode, p_buf, *p_buf_len, &index);
+ SER_ASSERT(err_code == NRF_SUCCESS, err_code);
+ err_code = uint16_t_enc(&service_handle, p_buf, buf_len, &index);
+ SER_ASSERT(err_code == NRF_SUCCESS, err_code);
+ err_code = uint16_t_enc(&inc_srvc_handle, p_buf, buf_len, &index);
+ SER_ASSERT(err_code == NRF_SUCCESS, err_code);
+ presenceFlag = (p_include_handle != NULL) ? SER_FIELD_PRESENT : SER_FIELD_NOT_PRESENT;
+ err_code = uint8_t_enc(&presenceFlag, p_buf, *p_buf_len, &index);
+ SER_ASSERT(err_code == NRF_SUCCESS, err_code);
+ *p_buf_len = index;
+ return err_code;
+
+}
+
+
+uint32_t ble_gatts_include_add_rsp_dec(uint8_t const * const p_buf,
+ uint32_t packet_len,
+ uint16_t * const p_include_handle,
+ uint32_t * const p_result_code)
+{
+ uint32_t index = 0;
+ uint32_t err_code;
+
+ err_code = ser_ble_cmd_rsp_result_code_dec(p_buf, &index, packet_len,
+ SD_BLE_GATTS_INCLUDE_ADD,
+ p_result_code);
+ SER_ASSERT(err_code == NRF_SUCCESS, err_code);
+
+ if (*p_result_code != NRF_SUCCESS)
+ {
+ SER_ASSERT_LENGTH_EQ(index, packet_len);
+ return NRF_SUCCESS;
+ }
+ SER_ASSERT_NOT_NULL(p_include_handle);
+ SER_ASSERT_LENGTH_LEQ(index + 2, packet_len);
+ err_code = uint16_t_dec(p_buf, packet_len, &index, p_include_handle);
+ SER_ASSERT_LENGTH_EQ(index, packet_len);
+ return err_code;
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_initial_user_handle_get.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_initial_user_handle_get.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_initial_user_handle_get.c
new file mode 100644
index 0000000..fc66a6a
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/ble_gatts_initial_user_handle_get.c
@@ -0,0 +1,78 @@
+/* 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_app.h"
+#include <stdlib.h>
+#include <string.h>
+#include "ble_serialization.h"
+#include "ble_gatts_struct_serialization.h"
+#include "ble_struct_serialization.h"
+#include "cond_field_serialization.h"
+#include "app_util.h"
+
+
+uint32_t ble_gatts_initial_user_handle_get_req_enc(uint16_t * p_handle,
+ uint8_t * const p_buf,
+ uint32_t * p_buf_len)
+{
+ uint32_t index = 0;
+ uint32_t err_code = NRF_SUCCESS;
+ uint32_t total_len = *p_buf_len;
+
+ SER_ASSERT_NOT_NULL(p_buf);
+ SER_ASSERT_NOT_NULL(p_buf_len);
+
+ p_buf[index++] = SD_BLE_GATTS_INITIAL_USER_HANDLE_GET;
+
+ err_code = cond_field_enc(p_handle, p_buf, total_len, &index, NULL);
+ SER_ASSERT(err_code == NRF_SUCCESS, err_code);
+
+ *p_buf_len = index;
+
+ return NRF_SUCCESS;
+}
+
+
+uint32_t ble_gatts_initial_user_handle_get_rsp_dec(uint8_t const * const p_buf,
+ uint32_t packet_len,
+ uint16_t ** pp_handle,
+ uint32_t * const p_result_code)
+{
+ SER_ASSERT_NOT_NULL(p_buf);
+ SER_ASSERT_NOT_NULL(p_result_code);
+ uint32_t err_code;
+ uint32_t index = 0;
+ uint32_t decode_result = ser_ble_cmd_rsp_result_code_dec(p_buf,
+ &index,
+ packet_len,
+ SD_BLE_GATTS_INITIAL_USER_HANDLE_GET,
+ p_result_code);
+
+ if (decode_result != NRF_SUCCESS)
+ {
+ return decode_result;
+ }
+
+ if (*p_result_code != NRF_SUCCESS)
+ {
+ SER_ASSERT_LENGTH_EQ(index, packet_len);
+ return NRF_SUCCESS;
+ }
+
+ err_code = cond_field_dec(p_buf, packet_len, &index, (void * *)pp_handle,
+ uint16_t_dec);
+ SER_ASSERT(err_code == NRF_SUCCESS, err_code);
+
+ SER_ASSERT_LENGTH_EQ(index, packet_len);
+
+ return NRF_SUCCESS;
+}