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:40 UTC
[11/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/middleware/app_mw_ble_gattc.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/middleware/app_mw_ble_gattc.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/middleware/app_mw_ble_gattc.c
new file mode 100644
index 0000000..aed1fdf
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/middleware/app_mw_ble_gattc.c
@@ -0,0 +1,467 @@
+/* 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 <stdint.h>
+#include "ble_gattc.h"
+#include "ble_gattc_app.h"
+#include "ble_serialization.h"
+#include "ser_sd_transport.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 sd_ble_gattc_primary_services_discover 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 gattc_primary_services_discover_rsp_dec(const uint8_t * p_buffer, uint16_t length)
+{
+ uint32_t result_code;
+
+ const uint32_t err_code = ble_gattc_primary_services_discover_rsp_dec(p_buffer,
+ length,
+ &result_code);
+
+ APP_ERROR_CHECK(err_code);
+
+
+
+ return result_code;
+}
+
+uint32_t sd_ble_gattc_primary_services_discover(uint16_t conn_handle,
+ uint16_t start_handle,
+ ble_uuid_t const * const p_srvc_uuid)
+{
+ uint8_t * p_buffer;
+ uint32_t buffer_length = 0;
+
+ tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length);
+
+ const uint32_t err_code = ble_gattc_primary_services_discover_req_enc(conn_handle,
+ start_handle,
+ p_srvc_uuid,
+ &(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),
+ gattc_primary_services_discover_rsp_dec);
+}
+
+/**@brief Command response callback function for @ref sd_ble_gattc_relationships_discover 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 gattc_relationships_discover_rsp_dec(const uint8_t * p_buffer, uint16_t length)
+{
+ uint32_t result_code;
+
+ const uint32_t err_code = ble_gattc_relationships_discover_rsp_dec(p_buffer,
+ length,
+ &result_code);
+
+ APP_ERROR_CHECK(err_code);
+
+
+
+ return result_code;
+}
+
+uint32_t sd_ble_gattc_relationships_discover(uint16_t conn_handle,
+ ble_gattc_handle_range_t const * const p_handle_range)
+{
+ uint8_t * p_buffer;
+ uint32_t buffer_length = 0;
+
+ tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length);
+
+ const uint32_t err_code = ble_gattc_relationships_discover_req_enc(conn_handle,
+ p_handle_range,
+ &(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),
+ gattc_relationships_discover_rsp_dec);
+}
+
+/**@brief Command response callback function for @ref sd_ble_gattc_characteristics_discover 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 gattc_characteristics_discover_rsp_dec(const uint8_t * p_buffer, uint16_t length)
+{
+ uint32_t result_code;
+
+ const uint32_t err_code = ble_gattc_characteristics_discover_rsp_dec(p_buffer,
+ length,
+ &result_code);
+
+ APP_ERROR_CHECK(err_code);
+
+
+
+ return result_code;
+}
+
+uint32_t sd_ble_gattc_characteristics_discover(
+ uint16_t conn_handle,
+ ble_gattc_handle_range_t const * const
+ p_handle_range)
+{
+ uint8_t * p_buffer;
+ uint32_t buffer_length = 0;
+
+ tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length);
+
+ const uint32_t err_code = ble_gattc_characteristics_discover_req_enc(conn_handle,
+ p_handle_range,
+ &(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),
+ gattc_characteristics_discover_rsp_dec);
+}
+
+/**@brief Command response callback function for @ref sd_ble_gattc_descriptors_discover 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 gattc_descriptors_discover_rsp_dec(const uint8_t * p_buffer, uint16_t length)
+{
+ uint32_t result_code;
+
+ const uint32_t err_code = ble_gattc_descriptors_discover_rsp_dec(p_buffer, length, &result_code);
+
+ APP_ERROR_CHECK(err_code);
+
+
+
+ return result_code;
+}
+
+uint32_t sd_ble_gattc_descriptors_discover(uint16_t conn_handle,
+ ble_gattc_handle_range_t const * const p_handle_range)
+{
+ uint8_t * p_buffer;
+ uint32_t buffer_length = 0;
+
+ tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length);
+
+ const uint32_t err_code = ble_gattc_descriptors_discover_req_enc(conn_handle,
+ p_handle_range,
+ &(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),
+ gattc_descriptors_discover_rsp_dec);
+}
+
+/**@brief Command response callback function for @ref sd_ble_gattc_char_value_by_uuid_read 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 gattc_char_value_by_uuid_read_rsp_dec(const uint8_t * p_buffer, uint16_t length)
+{
+ uint32_t result_code;
+
+ const uint32_t err_code = ble_gattc_char_value_by_uuid_read_rsp_dec(p_buffer,
+ length,
+ &result_code);
+
+ APP_ERROR_CHECK(err_code);
+
+
+
+ return result_code;
+}
+
+uint32_t sd_ble_gattc_char_value_by_uuid_read(uint16_t conn_handle,
+ ble_uuid_t const * const p_uuid,
+ ble_gattc_handle_range_t const * const p_handle_range)
+{
+ uint8_t * p_buffer;
+ uint32_t buffer_length = 0;
+
+ tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length);
+
+ const uint32_t err_code = ble_gattc_char_value_by_uuid_read_req_enc(conn_handle,
+ p_uuid,
+ p_handle_range,
+ &(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),
+ gattc_char_value_by_uuid_read_rsp_dec);
+}
+
+/**@brief Command response callback function for @ref sd_ble_gattc_read 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 gattc_read_rsp_dec(const uint8_t * p_buffer, uint16_t length)
+{
+ uint32_t result_code;
+
+ const uint32_t err_code = ble_gattc_read_rsp_dec(p_buffer, length, &result_code);
+
+ APP_ERROR_CHECK(err_code);
+
+
+
+ return result_code;
+}
+
+uint32_t sd_ble_gattc_read(uint16_t conn_handle,
+ uint16_t handle,
+ uint16_t offset)
+{
+ uint8_t * p_buffer;
+ uint32_t buffer_length = 0;
+
+ tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length);
+
+ const uint32_t err_code = ble_gattc_read_req_enc(conn_handle,
+ handle,
+ offset,
+ &(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),
+ gattc_read_rsp_dec);
+}
+
+/**@brief Command response callback function for @ref sd_ble_gattc_char_values_read 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 gattc_char_values_read_rsp_dec(const uint8_t * p_buffer, uint16_t length)
+{
+ uint32_t result_code;
+
+ const uint32_t err_code = ble_gattc_char_values_read_rsp_dec(p_buffer, length, &result_code);
+
+ APP_ERROR_CHECK(err_code);
+
+
+
+ return result_code;
+}
+
+uint32_t sd_ble_gattc_char_values_read(uint16_t conn_handle,
+ uint16_t const * const p_handles,
+ uint16_t handle_count)
+{
+ uint8_t * p_buffer;
+ uint32_t buffer_length = 0;
+
+ tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length);
+
+ const uint32_t err_code = ble_gattc_char_values_read_req_enc(conn_handle,
+ p_handles,
+ handle_count,
+ &(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),
+ gattc_char_values_read_rsp_dec);
+}
+
+/**@brief Command response callback function for @ref sd_ble_gattc_write 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 gattc_write_rsp_dec(const uint8_t * p_buffer, uint16_t length)
+{
+ uint32_t result_code;
+
+ const uint32_t err_code = ble_gattc_write_rsp_dec(p_buffer, length, &result_code);
+
+ APP_ERROR_CHECK(err_code);
+
+
+
+ return result_code;
+}
+
+uint32_t sd_ble_gattc_write(uint16_t conn_handle,
+ ble_gattc_write_params_t const * const p_write_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_gattc_write_req_enc(conn_handle,
+ p_write_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),
+ gattc_write_rsp_dec);
+}
+
+/**@brief Command response callback function for @ref sd_ble_gattc_hv_confirm 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 gattc_hv_confirm_rsp_dec(const uint8_t * p_buffer, uint16_t length)
+{
+ uint32_t result_code;
+
+ const uint32_t err_code = ble_gattc_hv_confirm_rsp_dec(p_buffer, length, &result_code);
+
+ APP_ERROR_CHECK(err_code);
+
+
+
+ return result_code;
+}
+
+uint32_t sd_ble_gattc_hv_confirm(uint16_t conn_handle,
+ uint16_t 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_gattc_hv_confirm_req_enc(conn_handle,
+ 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),
+ gattc_hv_confirm_rsp_dec);
+}
+
+
+/**@brief Command response callback function for @ref sd_ble_gattc_info_discover 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 gattc_attr_info_discover_rsp_dec(const uint8_t * p_buffer, uint16_t length)
+{
+ uint32_t result_code;
+
+ const uint32_t err_code = ble_gattc_attr_info_discover_rsp_dec(p_buffer, length, &result_code);
+
+ APP_ERROR_CHECK(err_code);
+
+ return result_code;
+}
+
+uint32_t sd_ble_gattc_attr_info_discover(uint16_t conn_handle,
+ ble_gattc_handle_range_t const * const p_handle_range)
+{
+ uint8_t * p_buffer;
+ uint32_t buffer_length = 0;
+
+ tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length);
+
+ const uint32_t err_code = ble_gattc_attr_info_discover_req_enc(conn_handle,
+ p_handle_range,
+ &(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),
+ gattc_attr_info_discover_rsp_dec);
+}
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/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
new file mode 100644
index 0000000..f9ede04
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/middleware/app_mw_ble_gatts.c
@@ -0,0 +1,665 @@
+/* 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/f06c2d2b/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
new file mode 100644
index 0000000..d4cf91c
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/middleware/app_mw_ble_l2cap.c
@@ -0,0 +1,165 @@
+/* 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/f06c2d2b/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
new file mode 100644
index 0000000..9fc2231
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/middleware/app_mw_nrf_soc.c
@@ -0,0 +1,144 @@
+/* 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/f06c2d2b/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
new file mode 100644
index 0000000..8b0c7ae
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/app_ble_gap_sec_keys.c
@@ -0,0 +1,73 @@
+/* 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/f06c2d2b/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
new file mode 100644
index 0000000..8d547d4
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/app_ble_gap_sec_keys.h
@@ -0,0 +1,81 @@
+/* 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
+
+/**
+ * @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);
+/** @} */
+
+#endif //_APP_BLE_GAP_SEC_KEYS_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/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
new file mode 100644
index 0000000..14a268c
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/app_ble_user_mem.c
@@ -0,0 +1,74 @@
+/* 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/f06c2d2b/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
new file mode 100644
index 0000000..f6bc731
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/app_ble_user_mem.h
@@ -0,0 +1,81 @@
+/* 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
+
+/**
+ * @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);
+/** @} */
+
+#endif //_APP_BLE_USER_MEM_H