http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/common/struct_ser/s130/ble_gattc_struct_serialization.c ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/common/struct_ser/s130/ble_gattc_struct_serialization.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/common/struct_ser/s130/ble_gattc_struct_serialization.c deleted file mode 100644 index 6016a0b..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/common/struct_ser/s130/ble_gattc_struct_serialization.c +++ /dev/null @@ -1,523 +0,0 @@ -/* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved. - * - * The information contained herein is property of Nordic Semiconductor ASA. - * Terms and conditions of usage are described in detail in NORDIC - * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. - * - * Licensees are granted free, non-transferable use of the information. NO - * WARRANTY of ANY KIND is provided. This heading must NOT be removed from - * the file. - * - */ -#include "ble_gattc_struct_serialization.h" -#include "ble_struct_serialization.h" -#include "ble_serialization.h" -#include "app_util.h" -#include "ble_gattc.h" -#include "cond_field_serialization.h" -#include <string.h> - -uint32_t ble_gattc_evt_char_val_by_uuid_read_rsp_t_enc(void const * const p_void_struct, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index) -{ - ble_gattc_evt_char_val_by_uuid_read_rsp_t * p_read = - (ble_gattc_evt_char_val_by_uuid_read_rsp_t *) p_void_struct; - uint32_t err_code = NRF_SUCCESS; - - err_code = uint16_t_enc(&(p_read->count), p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = uint16_t_enc(&(p_read->value_len), p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - uint32_t i; - ble_gattc_handle_value_t * p_handle_value = &p_read->handle_value[0]; - - for (i = 0; i < p_read->count; i++) - { - err_code = uint16_t_enc(&(p_handle_value->handle), p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - SER_ASSERT_LENGTH_LEQ(p_read->value_len, buf_len - *p_index); - memcpy(&p_buf[*p_index], p_handle_value->p_value, p_read->value_len); - *p_index += p_read->value_len; - - p_handle_value++; - } - - return err_code; -} - -uint32_t ble_gattc_evt_char_val_by_uuid_read_rsp_t_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - uint32_t * const p_struct_size, - void * const p_void_struct) -{ - ble_gattc_evt_char_val_by_uuid_read_rsp_t * p_read = - (ble_gattc_evt_char_val_by_uuid_read_rsp_t *) p_void_struct; - uint32_t err_code = NRF_SUCCESS; - uint16_t value_len; - uint16_t count; - uint32_t i; - - SER_ASSERT_LENGTH_LEQ(4, buf_len - *p_index); - uint16_dec(p_buf, buf_len, p_index, &count); - uint16_dec(p_buf, buf_len, p_index, &value_len); - - uint32_t total_struct_size = *p_struct_size; - - //calculate the size of the struct - *p_struct_size = offsetof(ble_gattc_evt_char_val_by_uuid_read_rsp_t, handle_value[0]); - *p_struct_size += sizeof(((ble_gattc_evt_char_val_by_uuid_read_rsp_t *)0)->handle_value[0]) * count; - *p_struct_size += value_len * count; - - if (p_read) - { - p_read->value_len = value_len; - p_read->count = count; - - ble_gattc_handle_value_t * p_handle_value; - uint8_t * p_value; - - SER_ASSERT_LENGTH_LEQ(*p_struct_size, total_struct_size); - - p_value = (uint8_t *)&p_read->handle_value[count]; - - for (i = 0; i < count; i++) - { - p_handle_value = (ble_gattc_handle_value_t *)&p_read->handle_value[i]; - p_handle_value->p_value = p_value; - - SER_ASSERT_LENGTH_LEQ(2, buf_len - *p_index); - uint16_dec(p_buf, buf_len, p_index, &(p_handle_value->handle)); - - SER_ASSERT_LENGTH_LEQ(p_read->value_len, buf_len - *p_index); - memcpy(p_handle_value->p_value, &p_buf[*p_index], p_read->value_len); - *p_index += p_read->value_len; - - p_value += value_len; - } - } - else - { - *p_index += count * (value_len + 2); - } - - return err_code; -} - -uint32_t ble_gattc_evt_char_vals_read_rsp_t_enc(void const * const p_void_struct, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index) -{ - ble_gattc_evt_char_vals_read_rsp_t * p_read = - (ble_gattc_evt_char_vals_read_rsp_t *) p_void_struct; - uint32_t error_code = NRF_SUCCESS; - - //Encode len - error_code = uint16_t_enc(&(p_read->len), p_buf, buf_len, p_index); - SER_ASSERT(error_code == NRF_SUCCESS, error_code); - - //Encode values - SER_ASSERT_LENGTH_LEQ(p_read->len, buf_len - *p_index); - memcpy(&p_buf[*p_index], p_read->values, p_read->len); - *p_index += p_read->len; - - return error_code; -} - -uint32_t ble_gattc_evt_char_vals_read_rsp_t_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_struct) -{ - ble_gattc_evt_char_vals_read_rsp_t * p_read = - (ble_gattc_evt_char_vals_read_rsp_t *) p_void_struct; - uint32_t error_code = NRF_SUCCESS; - - //Decode len - SER_ASSERT_LENGTH_LEQ(2, buf_len - *p_index); - uint16_dec(p_buf, buf_len, p_index, &(p_read->len)); - - //Decode values - SER_ASSERT_LENGTH_LEQ(p_read->len, buf_len - *p_index); - memcpy(p_read->values, &p_buf[*p_index], p_read->len); - *p_index += p_read->len; - - return error_code; -} - -uint32_t ble_gattc_handle_range_t_enc(void const * const p_void_struct, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index) -{ - ble_gattc_handle_range_t * p_range = (ble_gattc_handle_range_t *) p_void_struct; - uint32_t err_code = NRF_SUCCESS; - - err_code = uint16_t_enc(&(p_range->start_handle), p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = uint16_t_enc(&(p_range->end_handle), p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - return err_code; -} - -uint32_t ble_gattc_handle_range_t_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_struct) -{ - ble_gattc_handle_range_t * p_range = (ble_gattc_handle_range_t *) p_void_struct; - uint32_t err_code = NRF_SUCCESS; - - SER_ASSERT_LENGTH_LEQ(4, buf_len - *p_index); - uint16_dec(p_buf, buf_len, p_index, &(p_range->start_handle)); - uint16_dec(p_buf, buf_len, p_index, &(p_range->end_handle)); - - return err_code; -} - - -uint32_t ble_gattc_service_t_enc(void const * const p_void_struct, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index) -{ - uint32_t error_code = NRF_SUCCESS; - ble_gattc_service_t * p_service = (ble_gattc_service_t *) p_void_struct; - - error_code = ble_uuid_t_enc(&(p_service->uuid), p_buf, buf_len, p_index); - SER_ASSERT(error_code == NRF_SUCCESS, error_code); - error_code = ble_gattc_handle_range_t_enc(&(p_service->handle_range), p_buf, buf_len, p_index); - SER_ASSERT(error_code == NRF_SUCCESS, error_code); - - return error_code; -} - -uint32_t ble_gattc_service_t_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_struct) -{ - uint32_t error_code = NRF_SUCCESS; - ble_gattc_service_t * p_service = (ble_gattc_service_t *) p_void_struct; - - error_code = ble_uuid_t_dec(p_buf, buf_len, p_index, &(p_service->uuid)); - SER_ASSERT(error_code == NRF_SUCCESS, error_code); - error_code = ble_gattc_handle_range_t_dec(p_buf, buf_len, p_index, &(p_service->handle_range)); - SER_ASSERT(error_code == NRF_SUCCESS, error_code); - - return error_code; -} - -uint32_t ble_gattc_include_t_enc(void const * const p_void_struct, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index) -{ - uint32_t error_code = NRF_SUCCESS; - ble_gattc_include_t * p_include = (ble_gattc_include_t *) p_void_struct; - - error_code = uint16_t_enc(&(p_include->handle), p_buf, buf_len, p_index); - SER_ASSERT(error_code == NRF_SUCCESS, error_code); - error_code = ble_gattc_service_t_enc(&(p_include->included_srvc), p_buf, buf_len, p_index); - SER_ASSERT(error_code == NRF_SUCCESS, error_code); - - return error_code; -} - -uint32_t ble_gattc_include_t_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_struct) -{ - uint32_t error_code = NRF_SUCCESS; - ble_gattc_include_t * p_include = (ble_gattc_include_t *) p_void_struct; - - error_code = uint16_t_dec(p_buf, buf_len, p_index, &(p_include->handle)); - SER_ASSERT(error_code == NRF_SUCCESS, error_code); - error_code = ble_gattc_service_t_dec(p_buf, buf_len, p_index, &(p_include->included_srvc)); - SER_ASSERT(error_code == NRF_SUCCESS, error_code); - - return error_code; -} - -uint32_t ble_gattc_evt_rel_disc_rsp_t_enc(void const * const p_void_struct, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index) -{ - uint32_t error_code = NRF_SUCCESS; - uint32_t i; - ble_gattc_evt_rel_disc_rsp_t * p_rsp = (ble_gattc_evt_rel_disc_rsp_t *) p_void_struct; - - error_code = uint16_t_enc(&(p_rsp->count), p_buf, buf_len, p_index); - SER_ASSERT(error_code == NRF_SUCCESS, error_code); - - ble_gattc_include_t * p_include = (ble_gattc_include_t *) p_rsp->includes; - - for (i = 0; i < p_rsp->count; i++) - { - error_code = ble_gattc_include_t_enc(p_include, p_buf, buf_len, p_index); - SER_ASSERT(error_code == NRF_SUCCESS, error_code); - - p_include++; - } - - return error_code; -} - -uint32_t ble_gattc_evt_rel_disc_rsp_t_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_struct) -{ - uint32_t error_code = NRF_SUCCESS; - ble_gattc_evt_rel_disc_rsp_t * p_rsp = (ble_gattc_evt_rel_disc_rsp_t *) p_void_struct; - uint16_t include_count; - uint32_t i; - - error_code = uint16_t_dec(p_buf, buf_len, p_index, &include_count); - SER_ASSERT(error_code == NRF_SUCCESS, error_code); - p_rsp->count = include_count; - - ble_gattc_include_t * p_include = (ble_gattc_include_t *) p_rsp->includes; - - for (i = 0; i < include_count; i++) - { - error_code = ble_gattc_include_t_dec(p_buf, buf_len, p_index, p_include); - SER_ASSERT(error_code == NRF_SUCCESS, error_code); - - p_include++; - } - - return error_code; -} - -uint32_t ble_gattc_write_params_t_enc(void const * const p_void_write, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index) -{ - SER_ASSERT_NOT_NULL(p_void_write); - SER_ASSERT_NOT_NULL(p_buf); - SER_ASSERT_NOT_NULL(p_index); - - uint32_t err_code = NRF_SUCCESS; - - ble_gattc_write_params_t * p_write = (ble_gattc_write_params_t *)p_void_write; - - err_code = uint8_t_enc(&(p_write->write_op), p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = uint8_t_enc(&(p_write->flags), p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = uint16_t_enc(&(p_write->handle), p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = uint16_t_enc(&(p_write->offset), p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = len16data_enc(p_write->p_value, p_write->len, p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - return err_code; -} - -uint32_t ble_gattc_write_params_t_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_write) -{ - SER_ASSERT_NOT_NULL(p_buf); - SER_ASSERT_NOT_NULL(p_index); - SER_ASSERT_NOT_NULL(p_void_write); - - uint32_t err_code = NRF_SUCCESS; - - ble_gattc_write_params_t * p_write = (ble_gattc_write_params_t *)p_void_write; - - err_code = uint8_t_dec(p_buf, buf_len, p_index, &(p_write->write_op)); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = uint8_t_dec(p_buf, buf_len, p_index, &(p_write->flags)); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = uint16_t_dec(p_buf, buf_len, p_index, &(p_write->handle)); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = uint16_t_dec(p_buf, buf_len, p_index, &(p_write->offset)); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = len16data_dec(p_buf, buf_len, p_index, &(p_write->p_value), &(p_write->len)); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - return err_code; -} - -uint32_t ble_gattc_attr_info_t_16_enc(void const * const p_void_struct, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index) -{ - SER_ASSERT_NOT_NULL(p_void_struct); - SER_ASSERT_NOT_NULL(p_buf); - SER_ASSERT_NOT_NULL(p_index); - - uint32_t err_code = NRF_SUCCESS; - - ble_gattc_attr_info_t * p_attr_info = (ble_gattc_attr_info_t *)p_void_struct; - - err_code = uint16_t_enc(&(p_attr_info->handle), p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = ble_uuid_t_enc(&(p_attr_info->info.uuid16), p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - return err_code; -} - -uint32_t ble_gattc_attr_info_t_16_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_struct) -{ - SER_ASSERT_NOT_NULL(p_buf); - SER_ASSERT_NOT_NULL(p_index); - SER_ASSERT_NOT_NULL(p_void_struct); - - uint32_t err_code = NRF_SUCCESS; - - ble_gattc_attr_info_t * p_attr_info = (ble_gattc_attr_info_t *)p_void_struct; - - err_code = uint16_t_dec(p_buf, buf_len, p_index, &(p_attr_info->handle)); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = ble_uuid_t_dec(p_buf, buf_len, p_index, &(p_attr_info->info.uuid16)); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - return err_code; -} - -uint32_t ble_gattc_attr_info_t_128_enc(void const * const p_void_struct, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index) -{ - SER_ASSERT_NOT_NULL(p_void_struct); - SER_ASSERT_NOT_NULL(p_buf); - SER_ASSERT_NOT_NULL(p_index); - - uint32_t err_code = NRF_SUCCESS; - - ble_gattc_attr_info_t * p_attr_info = (ble_gattc_attr_info_t *)p_void_struct; - - err_code = uint16_t_enc(&(p_attr_info->handle), p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = ble_uuid128_t_enc(&(p_attr_info->info.uuid128), p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - return err_code; -} - -uint32_t ble_gattc_attr_info_t_128_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_struct) -{ - SER_ASSERT_NOT_NULL(p_buf); - SER_ASSERT_NOT_NULL(p_index); - SER_ASSERT_NOT_NULL(p_void_struct); - - uint32_t err_code = NRF_SUCCESS; - - ble_gattc_attr_info_t * p_attr_info = (ble_gattc_attr_info_t *)p_void_struct; - - err_code = uint16_t_dec(p_buf, buf_len, p_index, &(p_attr_info->handle)); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = ble_uuid128_t_dec(p_buf, buf_len, p_index, &(p_attr_info->info.uuid128)); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - return err_code; -} - -uint32_t ble_gattc_evt_attr_info_disc_rsp_t_enc(void const * const p_void_struct, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index) -{ - SER_ASSERT_NOT_NULL(p_void_struct); - SER_ASSERT_NOT_NULL(p_buf); - SER_ASSERT_NOT_NULL(p_index); - - uint32_t err_code = NRF_SUCCESS; - - ble_gattc_evt_attr_info_disc_rsp_t * p_rsp = (ble_gattc_evt_attr_info_disc_rsp_t *)p_void_struct; - - err_code = uint16_t_enc(&(p_rsp->count), p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = uint8_t_enc(&(p_rsp->format), p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - uint32_t i; - field_encoder_handler_t uuid_enc = (p_rsp->format == BLE_GATTC_ATTR_INFO_FORMAT_16BIT) ? - ble_gattc_attr_info_t_16_enc : ble_gattc_attr_info_t_128_enc; - - for (i = 0; i < p_rsp->count; i++) - { - err_code = uuid_enc(&(p_rsp->attr_info[i]), p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - } - - return err_code; -} - -uint32_t ble_gattc_evt_attr_info_disc_rsp_t_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_struct) -{ - SER_ASSERT_NOT_NULL(p_buf); - SER_ASSERT_NOT_NULL(p_index); - - uint32_t err_code = NRF_SUCCESS; - - ble_gattc_evt_attr_info_disc_rsp_t * p_rsp = (ble_gattc_evt_attr_info_disc_rsp_t *)p_void_struct; - - uint16_t count; - - err_code = uint16_t_dec(p_buf, buf_len, p_index, &count); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - if (p_rsp) - { - p_rsp->count = count; - err_code = uint8_t_dec(p_buf, buf_len, p_index, &p_rsp->format); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - uint32_t i; - field_decoder_handler_t uuid_dec = (p_rsp->format == BLE_GATTC_ATTR_INFO_FORMAT_16BIT) ? - ble_gattc_attr_info_t_16_dec : ble_gattc_attr_info_t_128_dec; - - for (i = 0; i < p_rsp->count; i++) - { - err_code = uuid_dec(p_buf, buf_len, p_index, &(p_rsp->attr_info[i])); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - } - } - else - { - *p_index = offsetof(ble_gattc_evt_attr_info_disc_rsp_t, attr_info) + count*sizeof(ble_gattc_attr_info_t); - } - return err_code; -}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/common/struct_ser/s130/ble_gattc_struct_serialization.h ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/common/struct_ser/s130/ble_gattc_struct_serialization.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/common/struct_ser/s130/ble_gattc_struct_serialization.h deleted file mode 100644 index c5ea0d4..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/common/struct_ser/s130/ble_gattc_struct_serialization.h +++ /dev/null @@ -1,125 +0,0 @@ -/* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved. - * - * The information contained herein is property of Nordic Semiconductor ASA. - * Terms and conditions of usage are described in detail in NORDIC - * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. - * - * Licensees are granted free, non-transferable use of the information. NO - * WARRANTY of ANY KIND is provided. This heading must NOT be removed from - * the file. - * - */ -#ifndef BLE_GATTC_STRUCT_SERIALIZATION_H -#define BLE_GATTC_STRUCT_SERIALIZATION_H - -#include "ble_gattc.h" - -#ifdef __cplusplus -extern "C" { -#endif - -uint32_t ble_gattc_evt_char_val_by_uuid_read_rsp_t_enc(void const * const p_void_struct, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index); - -uint32_t ble_gattc_evt_char_val_by_uuid_read_rsp_t_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - uint32_t * const p_struct_size, - void * const p_void_struct); - -uint32_t ble_gattc_evt_char_vals_read_rsp_t_enc(void const * const p_void_struct, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index); - -uint32_t ble_gattc_evt_char_vals_read_rsp_t_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_struct); - -uint32_t ble_gattc_handle_range_t_enc(void const * const p_void_struct, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index); - -uint32_t ble_gattc_handle_range_t_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_struct); - -uint32_t ble_gattc_service_t_enc(void const * const p_void_struct, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index); - -uint32_t ble_gattc_service_t_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_struct); - -uint32_t ble_gattc_include_t_enc(void const * const p_void_struct, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index); - -uint32_t ble_gattc_include_t_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_struct); - -uint32_t ble_gattc_evt_rel_disc_rsp_t_enc(void const * const p_void_struct, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index); - -uint32_t ble_gattc_evt_rel_disc_rsp_t_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_struct); - -uint32_t ble_gattc_write_params_t_enc(void const * const p_void_write, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index); - -uint32_t ble_gattc_write_params_t_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_write); - -uint32_t ble_gattc_attr_info_t_16_enc(void const * const p_void_struct, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index); - -uint32_t ble_gattc_attr_info_t_16_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_struct); - -uint32_t ble_gattc_attr_info_t_128_enc(void const * const p_void_struct, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index); - -uint32_t ble_gattc_attr_info_t_128_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_struct); - -uint32_t ble_gattc_evt_attr_info_disc_rsp_t_enc(void const * const p_void_struct, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index); - -uint32_t ble_gattc_evt_attr_info_disc_rsp_t_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_struct); -#ifdef __cplusplus -} -#endif - -#endif /*BLE_GATTC_STRUCT_SERIALIZATION_H*/ http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/common/struct_ser/s130/ble_gatts_struct_serialization.c ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/common/struct_ser/s130/ble_gatts_struct_serialization.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/common/struct_ser/s130/ble_gatts_struct_serialization.c deleted file mode 100644 index fe2fe83..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/common/struct_ser/s130/ble_gatts_struct_serialization.c +++ /dev/null @@ -1,899 +0,0 @@ -/* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved. - * - * The information contained herein is property of Nordic Semiconductor ASA. - * Terms and conditions of usage are described in detail in NORDIC - * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. - * - * Licensees are granted free, non-transferable use of the information. NO - * WARRANTY of ANY KIND is provided. This heading must NOT be removed from - * the file. - * - */ - -#include "ble_gatts_struct_serialization.h" -#include "ble_gap_struct_serialization.h" -#include "ble_struct_serialization.h" -#include "ble_serialization.h" -#include "app_util.h" -#include "ble_gatts.h" -#include "cond_field_serialization.h" -#include <string.h> - -uint32_t ser_ble_gatts_char_pf_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_char_pf) -{ - ble_gatts_char_pf_t * p_char_pf = (ble_gatts_char_pf_t *)p_void_char_pf; - - SER_ASSERT_LENGTH_LEQ(7, buf_len - *p_index); - - uint8_dec(p_buf, buf_len, p_index, &p_char_pf->format); - uint8_dec(p_buf, buf_len, p_index, (uint8_t *)&p_char_pf->exponent); - uint16_dec(p_buf, buf_len, p_index, &p_char_pf->unit); - uint8_dec(p_buf, buf_len, p_index, &p_char_pf->name_space); - uint16_dec(p_buf, buf_len, p_index, &p_char_pf->desc); - - return NRF_SUCCESS; -} - -uint32_t ser_ble_gatts_char_pf_enc(void const * const p_void_char_pf, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index) -{ - ble_gatts_char_pf_t * p_char_pf = (ble_gatts_char_pf_t *)p_void_char_pf; - uint32_t err_code = NRF_SUCCESS; - - err_code = uint8_t_enc(&p_char_pf->format, p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = uint8_t_enc(&p_char_pf->exponent, p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = uint16_t_enc(&p_char_pf->unit, p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = uint8_t_enc(&p_char_pf->name_space, p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = uint16_t_enc(&p_char_pf->desc, p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - return err_code; -} - -uint32_t ble_gatts_attr_md_enc(void const * const p_void_attr_md, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index) -{ - ble_gatts_attr_md_t * p_attr_md = (ble_gatts_attr_md_t *)p_void_attr_md; - uint32_t err_code = NRF_SUCCESS; - - err_code = ble_gap_conn_sec_mode_enc(&p_attr_md->read_perm, p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = ble_gap_conn_sec_mode_enc(&p_attr_md->write_perm, p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - /* serializer does not support attributes on stack */ - if (p_attr_md->vloc != BLE_GATTS_VLOC_STACK) - { - err_code = NRF_ERROR_INVALID_PARAM; - } - - uint8_t temp8; - temp8 = p_attr_md->vlen | - (p_attr_md->vloc << 1) | - (p_attr_md->rd_auth << 3) | - (p_attr_md->wr_auth << 4); - - SER_ASSERT_LENGTH_LEQ(1, buf_len - *p_index); - p_buf[*p_index] = temp8; - *p_index += 1; - - return err_code; -} - -uint32_t ble_gatts_attr_md_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_attr_md) -{ - ble_gatts_attr_md_t * p_attr_md = (ble_gatts_attr_md_t *)p_void_attr_md; - uint32_t err_code = NRF_SUCCESS; - uint8_t temp8; - - err_code = ble_gap_conn_sec_mode_dec(p_buf, buf_len, p_index, &p_attr_md->read_perm); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = ble_gap_conn_sec_mode_dec(p_buf, buf_len, p_index, &p_attr_md->write_perm); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - SER_ASSERT_LENGTH_LEQ(1, buf_len - *p_index); - uint8_dec(p_buf, buf_len, p_index, &temp8); - - p_attr_md->vlen = temp8; - p_attr_md->vloc = temp8 >> 1; - p_attr_md->rd_auth = temp8 >> 3; - p_attr_md->wr_auth = temp8 >> 4; - - return err_code; -} - -uint32_t ble_gatts_char_md_enc(void const * const p_void_char_md, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index) -{ - uint32_t err_code = NRF_SUCCESS; - - ble_gatts_char_md_t * p_char_md = (ble_gatts_char_md_t *)p_void_char_md; - uint8_t temp8; - - temp8 = p_char_md->char_props.broadcast | - (p_char_md->char_props.read << 1) | - (p_char_md->char_props.write_wo_resp << 2) | - (p_char_md->char_props.write << 3) | - (p_char_md->char_props.notify << 4) | - (p_char_md->char_props.indicate << 5) | - (p_char_md->char_props.auth_signed_wr << 6); - - err_code = uint8_t_enc(&temp8, p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - temp8 = p_char_md->char_ext_props.reliable_wr | - (p_char_md->char_ext_props.wr_aux << 1); - - err_code = uint8_t_enc(&temp8, p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = uint16_t_enc(&p_char_md->char_user_desc_max_size, p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - SER_ERROR_CHECK(p_char_md->char_user_desc_size <= BLE_GATTS_VAR_ATTR_LEN_MAX, - NRF_ERROR_INVALID_PARAM); - err_code = len16data_enc(p_char_md->p_char_user_desc, p_char_md->char_user_desc_size, p_buf, - buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = cond_field_enc(p_char_md->p_char_pf, - p_buf, - buf_len, - p_index, - ser_ble_gatts_char_pf_enc); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = cond_field_enc(p_char_md->p_user_desc_md, - p_buf, - buf_len, - p_index, - ble_gatts_attr_md_enc); - SER_ERROR_CHECK(err_code == NRF_SUCCESS, err_code); - - err_code = cond_field_enc(p_char_md->p_cccd_md, p_buf, buf_len, p_index, ble_gatts_attr_md_enc); - SER_ERROR_CHECK(err_code == NRF_SUCCESS, err_code); - - err_code = cond_field_enc(p_char_md->p_sccd_md, p_buf, buf_len, p_index, ble_gatts_attr_md_enc); - SER_ERROR_CHECK(err_code == NRF_SUCCESS, err_code); - - return err_code; -} - -uint32_t ble_gatts_char_md_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_char_md) -{ - uint32_t err_code = NRF_SUCCESS; - - ble_gatts_char_md_t * p_char_md = (ble_gatts_char_md_t *)p_void_char_md; - - SER_ASSERT_LENGTH_LEQ(2, buf_len - *p_index); - uint8_t temp8 = p_buf[*p_index]; - - p_char_md->char_props.broadcast = temp8 >> 0; - p_char_md->char_props.read = temp8 >> 1; - p_char_md->char_props.write_wo_resp = temp8 >> 2; - p_char_md->char_props.write = temp8 >> 3; - p_char_md->char_props.notify = temp8 >> 4; - p_char_md->char_props.indicate = temp8 >> 5; - p_char_md->char_props.auth_signed_wr = temp8 >> 6; - - temp8 = p_buf[*p_index + 1]; - p_char_md->char_ext_props.reliable_wr = temp8 >> 0; - p_char_md->char_ext_props.wr_aux = temp8 >> 1; - - *p_index += 2; - - SER_ASSERT_LENGTH_LEQ(2, buf_len - *p_index); - uint16_dec(p_buf, buf_len, p_index, &p_char_md->char_user_desc_max_size); - - err_code = len16data_dec(p_buf, - buf_len, - p_index, - &p_char_md->p_char_user_desc, - &p_char_md->char_user_desc_size); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = cond_field_dec(p_buf, - buf_len, - p_index, - (void * *)&p_char_md->p_char_pf, - ser_ble_gatts_char_pf_dec); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = cond_field_dec(p_buf, - buf_len, - p_index, - (void * *)&p_char_md->p_user_desc_md, - ble_gatts_attr_md_dec); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = cond_field_dec(p_buf, - buf_len, - p_index, - (void * *)&p_char_md->p_cccd_md, - ble_gatts_attr_md_dec); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = cond_field_dec(p_buf, - buf_len, - p_index, - (void * *)&p_char_md->p_sccd_md, - ble_gatts_attr_md_dec); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - return err_code; - -} - -uint32_t ble_gatts_attr_enc(void const * const p_void_gatts_attr, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index) -{ - uint32_t err_code = NRF_SUCCESS; - ble_gatts_attr_t * p_gatts_attr = (ble_gatts_attr_t *)p_void_gatts_attr; - - err_code = cond_field_enc((void *)p_gatts_attr->p_uuid, p_buf, buf_len, p_index, ble_uuid_t_enc); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = cond_field_enc((void *)p_gatts_attr->p_attr_md, - p_buf, - buf_len, - p_index, - ble_gatts_attr_md_enc); - SER_ERROR_CHECK(err_code == NRF_SUCCESS, err_code); - - err_code = uint16_t_enc(&p_gatts_attr->init_offs, p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = uint16_t_enc(&p_gatts_attr->max_len, p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - SER_ERROR_CHECK(p_gatts_attr->init_len <= BLE_GATTS_VAR_ATTR_LEN_MAX, NRF_ERROR_INVALID_PARAM); - //init len move just before p_data to be able to use len16data decoder. - err_code = len16data_enc(p_gatts_attr->p_value, p_gatts_attr->init_len, p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - return err_code; -} - -uint32_t ble_gatts_attr_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_gatts_attr) -{ - uint32_t err_code = NRF_SUCCESS; - ble_gatts_attr_t * p_gatts_attr = (ble_gatts_attr_t *)p_void_gatts_attr; - - err_code = cond_field_dec(p_buf, - buf_len, - p_index, - (void * *)&p_gatts_attr->p_uuid, - ble_uuid_t_dec); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = cond_field_dec(p_buf, - buf_len, - p_index, - (void * *)&p_gatts_attr->p_attr_md, - ble_gatts_attr_md_dec); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - SER_ASSERT_LENGTH_LEQ(4, buf_len - *p_index); - uint16_dec(p_buf, buf_len, p_index, &p_gatts_attr->init_offs); - uint16_dec(p_buf, buf_len, p_index, &p_gatts_attr->max_len); - - //init len move just before p_data to be able to use len16data decoder. - err_code = len16data_dec(p_buf, - buf_len, - p_index, - &p_gatts_attr->p_value, - &p_gatts_attr->init_len); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - return err_code; -} - -uint32_t ble_gatts_char_handles_enc(void const * const p_void_char_handles, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index) -{ - ble_gatts_char_handles_t * p_char_handles = (ble_gatts_char_handles_t *)p_void_char_handles; - uint32_t err_code = NRF_SUCCESS; - - err_code = uint16_t_enc(&p_char_handles->value_handle, p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = uint16_t_enc(&p_char_handles->user_desc_handle, p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = uint16_t_enc(&p_char_handles->cccd_handle, p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = uint16_t_enc(&p_char_handles->sccd_handle, p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - return err_code; -} - -uint32_t ble_gatts_char_handles_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_char_handles) -{ - ble_gatts_char_handles_t * p_char_handles = (ble_gatts_char_handles_t *)p_void_char_handles; - - SER_ASSERT_LENGTH_LEQ(8, buf_len - *p_index); - uint16_dec(p_buf, buf_len, p_index, &(p_char_handles->value_handle)); - uint16_dec(p_buf, buf_len, p_index, &p_char_handles->user_desc_handle); - uint16_dec(p_buf, buf_len, p_index, &p_char_handles->cccd_handle); - uint16_dec(p_buf, buf_len, p_index, &p_char_handles->sccd_handle); - - return NRF_SUCCESS; -} - -uint32_t ble_gatts_hvx_params_t_enc(void const * const p_void_hvx_params, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index) -{ - ble_gatts_hvx_params_t * p_hvx_params = (ble_gatts_hvx_params_t *)p_void_hvx_params; - - uint32_t err_code = NRF_SUCCESS; - - SER_ASSERT_LENGTH_LEQ(2 + 1 + 2, buf_len - *p_index); - - err_code = uint16_t_enc(&p_hvx_params->handle, p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = uint8_t_enc(&p_hvx_params->type, p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = uint16_t_enc(&p_hvx_params->offset, p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - if (p_hvx_params->p_len != NULL) - { - SER_ASSERT_LENGTH_LEQ(1, buf_len - *p_index); - p_buf[(*p_index)++] = SER_FIELD_PRESENT; - - err_code = uint16_t_enc(p_hvx_params->p_len, p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - } - - if (p_hvx_params->p_data != NULL) - { - SER_ASSERT_LENGTH_LEQ(1, buf_len - *p_index); - p_buf[(*p_index)++] = SER_FIELD_PRESENT; - - SER_ASSERT_LENGTH_LEQ(*p_hvx_params->p_len, buf_len - *p_index); - memcpy(&p_buf[*p_index], p_hvx_params->p_data, *p_hvx_params->p_len); - *p_index += *p_hvx_params->p_len; - } - - return err_code; -} - -uint32_t ble_gatts_hvx_params_t_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_hvx_params) -{ - ble_gatts_hvx_params_t * p_hvx_params = (ble_gatts_hvx_params_t *)p_void_hvx_params; - - uint32_t err_code = NRF_SUCCESS; - - SER_ASSERT_LENGTH_LEQ(2 + 1 + 2, buf_len - *p_index); - uint16_dec(p_buf, buf_len, p_index, &p_hvx_params->handle); - uint8_dec(p_buf, buf_len, p_index, &p_hvx_params->type); - uint16_dec(p_buf, buf_len, p_index, &p_hvx_params->offset); - - SER_ASSERT_NOT_NULL(&p_hvx_params->p_len); - err_code = cond_len16_cond_data_dec(p_buf, - buf_len, - p_index, - &p_hvx_params->p_data, - &p_hvx_params->p_len); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - return err_code; -} - -uint32_t ble_gatts_evt_write_t_enc(void const * const p_void_write, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index) -{ - ble_gatts_evt_write_t * p_write = (ble_gatts_evt_write_t *) p_void_write; - uint32_t error_code = NRF_SUCCESS; - - error_code = uint16_t_enc(&(p_write->handle), p_buf, buf_len, p_index); - SER_ASSERT(error_code == NRF_SUCCESS, error_code); - - error_code = ble_uuid_t_enc(&(p_write->uuid), p_buf, buf_len, p_index); - SER_ASSERT(error_code == NRF_SUCCESS, error_code); - - error_code = uint8_t_enc(&(p_write->op), p_buf, buf_len, p_index); - SER_ASSERT(error_code == NRF_SUCCESS, error_code); - - error_code = uint8_t_enc(&(p_write->auth_required), p_buf, buf_len, p_index); - SER_ASSERT(error_code == NRF_SUCCESS, error_code); - - error_code = uint16_t_enc(&(p_write->offset), p_buf, buf_len, p_index); - SER_ASSERT(error_code == NRF_SUCCESS, error_code); - - uint16_t data_len = p_write->len; - error_code = uint16_t_enc(&data_len, p_buf, buf_len, p_index); - SER_ASSERT(error_code == NRF_SUCCESS, error_code); - SER_ASSERT_LENGTH_LEQ(data_len, buf_len - *p_index); - memcpy(&p_buf[*p_index], p_write->data, data_len); - *p_index += data_len; - - return error_code; -} - -uint32_t ble_gatts_evt_write_t_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - uint32_t * const p_struct_len, - void * const p_void_write) -{ - SER_ASSERT_NOT_NULL(p_buf); - SER_ASSERT_NOT_NULL(p_index); - SER_ASSERT_NOT_NULL(p_struct_len); - - uint32_t err_code = NRF_SUCCESS; - uint32_t in_struct_len = *p_struct_len; - - *p_struct_len = offsetof(ble_gatts_evt_write_t, data); - - uint16_t handle; - err_code = uint16_t_dec(p_buf, buf_len, p_index, &handle); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - ble_uuid_t uuid; - err_code = ble_uuid_t_dec(p_buf, buf_len, p_index, &uuid); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - uint8_t op; - err_code = uint8_t_dec(p_buf, buf_len, p_index, &op); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - uint8_t auth_required; - err_code = uint8_t_dec(p_buf, buf_len, p_index, &auth_required); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - uint16_t offset; - err_code = uint16_t_dec(p_buf, buf_len, p_index, &offset); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - uint16_t len; - err_code = uint16_t_dec(p_buf, buf_len, p_index, &len); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - *p_struct_len += len; - - if (p_void_write != NULL) - { - ble_gatts_evt_write_t * p_write = (ble_gatts_evt_write_t *)p_void_write; - - SER_ASSERT_LENGTH_LEQ(*p_struct_len, in_struct_len); - - p_write->handle = handle; - p_write->uuid = uuid; - p_write->op = op; - p_write->auth_required = auth_required; - p_write->offset = offset; - p_write->len = len; - - SER_ASSERT_LENGTH_LEQ(p_write->len, buf_len - *p_index); - memcpy(p_write->data, &p_buf[*p_index], p_write->len); - } - - *p_index += len; - - return err_code; -} - -uint32_t ble_gatts_evt_read_t_enc(void const * const p_void_read, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index) -{ - SER_ASSERT_NOT_NULL(p_buf); - SER_ASSERT_NOT_NULL(p_index); - SER_ASSERT_NOT_NULL(p_void_read); - - ble_gatts_evt_read_t * p_read = (ble_gatts_evt_read_t *)p_void_read; - uint32_t err_code = NRF_SUCCESS; - - err_code = uint16_t_enc(&(p_read->handle), p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = ble_uuid_t_enc(&(p_read->uuid), p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = uint16_t_enc(&(p_read->offset), p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - return err_code; -} - -uint32_t ble_gatts_evt_read_t_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - uint32_t * const p_struct_len, - void * const p_void_read) -{ - SER_ASSERT_NOT_NULL(p_buf); - SER_ASSERT_NOT_NULL(p_index); - - uint32_t err_code = NRF_SUCCESS; - uint32_t in_struct_len = *p_struct_len; - - *p_struct_len = sizeof (ble_gatts_evt_read_t); - - uint16_t handle; - err_code = uint16_t_dec(p_buf, buf_len, p_index, &handle); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - ble_uuid_t uuid; - err_code = ble_uuid_t_dec(p_buf, buf_len, p_index, &uuid); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - uint16_t offset; - err_code = uint16_t_dec(p_buf, buf_len, p_index, &offset); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - if (p_void_read != NULL) - { - ble_gatts_evt_read_t * p_read = (ble_gatts_evt_read_t *)p_void_read; - - SER_ASSERT_LENGTH_LEQ(*p_struct_len, in_struct_len); - - p_read->handle = handle; - p_read->uuid = uuid; - p_read->offset = offset; - } - - return err_code; -} - -uint32_t ble_gatts_evt_rw_authorize_request_t_enc(void const * const p_void_authorize_request, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index) -{ - SER_ASSERT_NOT_NULL(p_buf); - SER_ASSERT_NOT_NULL(p_index); - SER_ASSERT_NOT_NULL(p_void_authorize_request); - - ble_gatts_evt_rw_authorize_request_t * p_authorize_request = - (ble_gatts_evt_rw_authorize_request_t *)p_void_authorize_request; - uint32_t err_code = NRF_SUCCESS; - - err_code = uint8_t_enc(&(p_authorize_request->type), p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - switch (p_authorize_request->type) - { - case BLE_GATTS_AUTHORIZE_TYPE_READ: - err_code = ble_gatts_evt_read_t_enc(&(p_authorize_request->request.read), - p_buf, - buf_len, - p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - break; - - case BLE_GATTS_AUTHORIZE_TYPE_WRITE: - err_code = ble_gatts_evt_write_t_enc(&(p_authorize_request->request.write), - p_buf, - buf_len, - p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - break; - - default: - case BLE_GATTS_AUTHORIZE_TYPE_INVALID: - err_code = NRF_ERROR_INVALID_PARAM; - break; - } - - return err_code; -} - -uint32_t ble_gatts_evt_rw_authorize_request_t_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - uint32_t * const p_struct_len, - void * const p_void_authorize_request) -{ - SER_ASSERT_NOT_NULL(p_buf); - SER_ASSERT_NOT_NULL(p_struct_len); - SER_ASSERT_NOT_NULL(p_index); - - uint32_t err_code = NRF_SUCCESS; - - uint8_t type; - err_code = uint8_t_dec(p_buf, buf_len, p_index, &type); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - uint32_t in_struct_len = *p_struct_len; - - *p_struct_len = offsetof(ble_gatts_evt_rw_authorize_request_t, request); - - ble_gatts_evt_rw_authorize_request_t * p_authorize_request = - (ble_gatts_evt_rw_authorize_request_t *)p_void_authorize_request; - - void * p_void_request = NULL; - - if (p_void_authorize_request != NULL) - { - p_authorize_request->type = type; - - SER_ASSERT_LENGTH_LEQ(*p_struct_len, in_struct_len); - - switch (type) - { - case BLE_GATTS_AUTHORIZE_TYPE_READ: - p_void_request = &(p_authorize_request->request.read); - break; - - case BLE_GATTS_AUTHORIZE_TYPE_WRITE: - p_void_request = &(p_authorize_request->request.write); - break; - - default: - case BLE_GATTS_AUTHORIZE_TYPE_INVALID: - return NRF_ERROR_INVALID_DATA; - } - } - - switch (type) - { - case BLE_GATTS_AUTHORIZE_TYPE_READ: - err_code = ble_gatts_evt_read_t_dec(p_buf, - buf_len, - p_index, - &in_struct_len, - p_void_request); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - break; - - case BLE_GATTS_AUTHORIZE_TYPE_WRITE: - err_code = ble_gatts_evt_write_t_dec(p_buf, - buf_len, - p_index, - &in_struct_len, - p_void_request); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - break; - - default: - case BLE_GATTS_AUTHORIZE_TYPE_INVALID: - return NRF_ERROR_INVALID_DATA; - } - *p_struct_len += in_struct_len; - - return err_code; -} - -uint32_t ble_gatts_authorize_params_t_enc(void const * const p_void_struct, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index) -{ - ble_gatts_authorize_params_t * p_params = - (ble_gatts_authorize_params_t *) p_void_struct; - uint32_t error_code = NRF_SUCCESS; - - error_code = uint16_t_enc(&(p_params->gatt_status), p_buf, buf_len, p_index); - SER_ASSERT(error_code == NRF_SUCCESS, error_code); - - uint8_t temp_val = p_params->update; - error_code = uint8_t_enc(&temp_val, p_buf, buf_len, p_index); - SER_ASSERT(error_code == NRF_SUCCESS, error_code); - - error_code = uint16_t_enc(&(p_params->offset), p_buf, buf_len, p_index); - SER_ASSERT(error_code == NRF_SUCCESS, error_code); - - error_code = len16data_enc(p_params->p_data, p_params->len, p_buf, buf_len, p_index); - SER_ASSERT(error_code == NRF_SUCCESS, error_code); - - return error_code; -} - -uint32_t ble_gatts_authorize_params_t_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_struct) -{ - ble_gatts_authorize_params_t * p_params = - (ble_gatts_authorize_params_t *) p_void_struct; - uint32_t error_code = NRF_SUCCESS; - - SER_ASSERT_LENGTH_LEQ(2, buf_len - *p_index); - uint16_dec(p_buf, buf_len, p_index, &p_params->gatt_status); - - uint8_t temp_val; - SER_ASSERT_LENGTH_LEQ(1, buf_len - *p_index); - uint8_dec(p_buf, buf_len, p_index, &temp_val); - p_params->update = temp_val; - - SER_ASSERT_LENGTH_LEQ(2, buf_len - *p_index); - uint16_dec(p_buf, buf_len, p_index, &p_params->offset); - - error_code = len16data_dec(p_buf, buf_len, p_index, (uint8_t **)&p_params->p_data, &p_params->len); - SER_ASSERT(error_code == NRF_SUCCESS, error_code); - - return error_code; -} - -uint32_t ble_gatts_rw_authorize_reply_params_t_enc(void const * const p_void_struct, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index) -{ - ble_gatts_rw_authorize_reply_params_t const * const p_params = - (ble_gatts_rw_authorize_reply_params_t * ) p_void_struct; - uint32_t error_code = NRF_SUCCESS; - - error_code = uint8_t_enc(&(p_params->type), p_buf, buf_len, p_index); - SER_ASSERT(error_code == NRF_SUCCESS, error_code); - - if (p_params->type == BLE_GATTS_AUTHORIZE_TYPE_READ) - { - error_code = ble_gatts_authorize_params_t_enc(&p_params->params.read, - p_buf, buf_len, p_index); - SER_ASSERT(error_code == NRF_SUCCESS, error_code); - } - else if (p_params->type == BLE_GATTS_AUTHORIZE_TYPE_WRITE) - { - error_code = ble_gatts_authorize_params_t_enc(&p_params->params.write, - p_buf, buf_len, p_index); - SER_ASSERT(error_code == NRF_SUCCESS, error_code); - } - else - { - return NRF_ERROR_INVALID_PARAM; - } - - return error_code; -} - -uint32_t ble_gatts_rw_authorize_reply_params_t_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_struct) -{ - ble_gatts_rw_authorize_reply_params_t * p_params = - (ble_gatts_rw_authorize_reply_params_t *) p_void_struct; - uint32_t error_code = NRF_SUCCESS; - - SER_ASSERT_LENGTH_LEQ(1, buf_len - *p_index); - uint8_dec(p_buf, buf_len, p_index, &(p_params->type)); - - if (p_params->type == BLE_GATTS_AUTHORIZE_TYPE_READ) - { - error_code = ble_gatts_authorize_params_t_dec(p_buf, buf_len, p_index, - &p_params->params.read); - SER_ASSERT(error_code == NRF_SUCCESS, error_code); - } - else if (p_params->type == BLE_GATTS_AUTHORIZE_TYPE_WRITE) - { - error_code = ble_gatts_authorize_params_t_dec(p_buf, buf_len, p_index, - &p_params->params.write); - SER_ASSERT(error_code == NRF_SUCCESS, error_code); - } - else - { - return NRF_ERROR_INVALID_PARAM; - } - - return error_code; -} - -uint32_t ble_gatts_enable_params_t_enc(void const * const p_void_struct, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index) -{ - ble_gatts_enable_params_t * p_enable_params = (ble_gatts_enable_params_t *)p_void_struct; - uint32_t err_code = NRF_SUCCESS; - uint8_t temp8 = 0; - - temp8 = (p_enable_params->service_changed & 0x01); - - err_code = uint8_t_enc((void *) &temp8, p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = uint32_t_enc(&(p_enable_params->attr_tab_size), p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - return err_code; -} - -uint32_t ble_gatts_enable_params_t_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_struct) -{ - ble_gatts_enable_params_t * p_enable_params = (ble_gatts_enable_params_t *)p_void_struct; - uint32_t err_code = NRF_SUCCESS; - uint8_t temp8 = 0; - - err_code = uint8_t_dec(p_buf, buf_len, p_index, (void *) &temp8); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - p_enable_params->service_changed = temp8 & 0x01; - - err_code = uint32_t_dec(p_buf, buf_len, p_index, (void *) &(p_enable_params->attr_tab_size)); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - return err_code; -} - -uint32_t ble_gatts_value_t_enc(void const * const p_void_struct, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index) -{ - ble_gatts_value_t * p_value = (ble_gatts_value_t *)p_void_struct; - uint32_t err_code = NRF_SUCCESS; - - err_code = uint16_t_enc((void *) &(p_value->len), p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = uint16_t_enc((void *) &(p_value->offset), p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = buf_enc(p_value->p_value, p_value->len, p_buf, buf_len, p_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - return err_code; -} - -uint32_t ble_gatts_value_t_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_struct) -{ - ble_gatts_value_t * p_value = (ble_gatts_value_t *)p_void_struct; - uint32_t err_code = NRF_SUCCESS; - uint16_t total_len = p_value->len; - - err_code = uint16_t_dec(p_buf, buf_len, p_index, (void *) &(p_value->len)); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = uint16_t_dec(p_buf, buf_len, p_index, (void *) &(p_value->offset)); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = buf_dec(p_buf, buf_len, p_index, &(p_value->p_value), total_len, p_value->len); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - return err_code; -} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/common/struct_ser/s130/ble_gatts_struct_serialization.h ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/common/struct_ser/s130/ble_gatts_struct_serialization.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/common/struct_ser/s130/ble_gatts_struct_serialization.h deleted file mode 100644 index 93e7252..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/common/struct_ser/s130/ble_gatts_struct_serialization.h +++ /dev/null @@ -1,158 +0,0 @@ -/* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved. - * - * The information contained herein is property of Nordic Semiconductor ASA. - * Terms and conditions of usage are described in detail in NORDIC - * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. - * - * Licensees are granted free, non-transferable use of the information. NO - * WARRANTY of ANY KIND is provided. This heading must NOT be removed from - * the file. - * - */ -#ifndef BLE_GATTS_STRUCT_SERIALIZATION_H -#define BLE_GATTS_STRUCT_SERIALIZATION_H - -#include "ble_gatts.h" - -#ifdef __cplusplus -extern "C" { -#endif - -uint32_t ser_ble_gatts_char_pf_enc(void const * const p_void_char_pf, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index); - -uint32_t ser_ble_gatts_char_pf_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_char_pf); - -uint32_t ble_gatts_attr_md_enc(void const * const p_void_attr_md, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index); - -uint32_t ble_gatts_attr_md_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_attr_md); - -uint32_t ble_gatts_char_md_enc(void const * const p_void_char_md, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index); - -uint32_t ble_gatts_char_md_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_char_md); - -uint32_t ble_gatts_attr_enc(void const * const p_void_gatts_attr, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index); - -uint32_t ble_gatts_attr_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_gatts_attr); - -uint32_t ble_gatts_char_handles_enc(void const * const p_void_char_handles, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index); - -uint32_t ble_gatts_char_handles_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_char_handles); - -uint32_t ble_gatts_evt_write_t_enc(void const * const p_void_write, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index); - -uint32_t ble_gatts_evt_write_t_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - uint32_t * const p_struct_len, - void * const p_void_write); - -uint32_t ble_gatts_hvx_params_t_enc(void const * const p_void_hvx_params, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index); - -uint32_t ble_gatts_hvx_params_t_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_hvx_params); - -uint32_t ble_gatts_evt_read_t_enc(void const * const p_void_read, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index); - -uint32_t ble_gatts_evt_read_t_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - uint32_t * const p_struct_len, - void * const p_void_read); - -uint32_t ble_gatts_evt_rw_authorize_request_t_enc(void const * const p_void_authorize_request, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index); - -uint32_t ble_gatts_evt_rw_authorize_request_t_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - uint32_t * const p_struct_size, - void * const p_void_authorize_request); - -uint32_t ble_gatts_authorize_params_t_enc(void const * const p_void_struct, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index); - -uint32_t ble_gatts_authorize_params_t_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_struct); - -uint32_t ble_gatts_rw_authorize_reply_params_t_enc(void const * const p_void_struct, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index); - -uint32_t ble_gatts_rw_authorize_reply_params_t_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_struct); - -uint32_t ble_gatts_enable_params_t_enc(void const * const p_void_struct, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index); - -uint32_t ble_gatts_enable_params_t_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_struct); - -uint32_t ble_gatts_value_t_enc(void const * const p_void_struct, - uint8_t * const p_buf, - uint32_t buf_len, - uint32_t * const p_index); - -uint32_t ble_gatts_value_t_dec(uint8_t const * const p_buf, - uint32_t buf_len, - uint32_t * const p_index, - void * const p_void_struct); - -#ifdef __cplusplus -} -#endif - -#endif /* BLE_GATTS_STRUCT_SERIALIZATION_H */
