diff options
Diffstat (limited to 'thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers')
44 files changed, 5356 insertions, 0 deletions
diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_acknowledge_message_tx.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_acknowledge_message_tx.c new file mode 100644 index 0000000..ee4e763 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_acknowledge_message_tx.c @@ -0,0 +1,90 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_acknowledge_message_tx_req_enc(uint8_t channel, + uint8_t size, + uint8_t const * const p_mesg, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + uint8_t svc_number = SVC_ANT_TX_ACKNOWLEDGED_MESSAGE; + uint32_t err_code = NRF_SUCCESS; + uint32_t buf_len = *p_buf_len; + uint32_t index = 0; + + err_code = uint8_t_enc(&svc_number, p_buf, buf_len, &index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + err_code = uint8_t_enc(&channel, p_buf, buf_len, &index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + err_code = uint8_t_enc(&size, p_buf, buf_len, &index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + err_code = uint8_vector_enc(p_mesg, size, p_buf, buf_len, &index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + + +uint32_t ant_acknowledge_message_tx_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + // Use the ble cmd rsp dec function because it is adequte to decode + // the command response as it is the same for both ant and ble. + return ser_ble_cmd_rsp_dec(p_buf, packet_len, SVC_ANT_TX_ACKNOWLEDGED_MESSAGE, p_result_code); +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_active_search_sharing_cycles_get.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_active_search_sharing_cycles_get.c new file mode 100644 index 0000000..f0312f3 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_active_search_sharing_cycles_get.c @@ -0,0 +1,96 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_active_search_sharing_cycles_get_req_enc(uint8_t channel, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + uint32_t index = 0; + uint32_t err_code = NRF_SUCCESS; + + + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + p_buf[index++] = SVC_ANT_ACTIVE_SEARCH_SHARING_CYCLES_GET; + p_buf[index++] = channel; + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + +uint32_t ant_active_search_sharing_cycles_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + void * const p_cycles, + uint32_t * const p_result_code) +{ + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_result_code); + + uint32_t index = 0; + uint32_t err_code = ser_ble_cmd_rsp_result_code_dec(p_buf, &index, packet_len, + SVC_ANT_ACTIVE_SEARCH_SHARING_CYCLES_GET, p_result_code); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + if (*p_result_code != NRF_SUCCESS) + { + SER_ASSERT_LENGTH_EQ(index, packet_len); + + return NRF_SUCCESS; + } + + err_code = uint8_t_dec(p_buf, packet_len, &index, p_cycles); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + SER_ASSERT_LENGTH_EQ(index, packet_len); + + return NRF_SUCCESS; +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_active_search_sharing_cycles_set.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_active_search_sharing_cycles_set.c new file mode 100644 index 0000000..a0e27d8 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_active_search_sharing_cycles_set.c @@ -0,0 +1,78 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_active_search_sharing_cycles_set_req_enc(uint8_t channel, + uint8_t cycles, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + uint32_t index = 0; + uint32_t err_code = NRF_SUCCESS; + + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + p_buf[index++] = SVC_ANT_ACTIVE_SEARCH_SHARING_CYCLES_SET; + p_buf[index++] = channel; + p_buf[index++] = cycles; + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + +uint32_t ant_active_search_sharing_cycles_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + // Use the ble cmd rsp dec function because it is adequte to decode + // the command response as it is the same for both ant and ble. + return ser_ble_cmd_rsp_dec(p_buf, packet_len, SVC_ANT_ACTIVE_SEARCH_SHARING_CYCLES_SET, p_result_code); +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_adv_burst_config_set.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_adv_burst_config_set.c new file mode 100644 index 0000000..74020ee --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_adv_burst_config_set.c @@ -0,0 +1,86 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_adv_burst_config_set_req_enc(uint8_t const * const p_config, + uint8_t size, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + uint8_t svc_number = SVC_ANT_ADV_BURST_CONFIG_SET; + uint32_t err_code = NRF_SUCCESS; + uint32_t buf_len = *p_buf_len; + uint32_t index = 0; + + err_code = uint8_t_enc(&svc_number, p_buf, buf_len, &index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + err_code = uint8_t_enc(&size, p_buf, buf_len, &index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + err_code = uint8_vector_enc(p_config, size, p_buf, buf_len, &index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + + +uint32_t ant_adv_burst_config_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + // Use the ble cmd rsp dec function because it is adequte to decode + // the command response as it is the same for both ant and ble. + return ser_ble_cmd_rsp_dec(p_buf, packet_len, SVC_ANT_ADV_BURST_CONFIG_SET, p_result_code); +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_app.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_app.h new file mode 100644 index 0000000..c3c7fd2 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_app.h @@ -0,0 +1,1652 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef ANT_APP_H__ +#define ANT_APP_H__ + +/** + * @addtogroup ser_app_s212_codecs Application codecs for S212 + * @ingroup ser_codecs_app + */ + +/**@file + * + * @defgroup ant_app Application command request encoders and command response decoders + * @{ + * @ingroup ser_app_s212_codecs + * + * @brief Application command request encoders and command response decoders. + */ +//#include "ble.h" +#include "ant_interface.h" + +/**@brief Encodes @ref sd_ant_enable command request. + * + * @sa @ref ant_enable_rsp_dec for command response decoder. + * + * @param[in] p_ant_enable_params Pointer to an @ref ANT_ENABLE structure. + * @param[in] p_buf Pointer to buffer where encoded data command will be + * returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_enable_req_enc(ANT_ENABLE * p_ant_enable_params, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_enable command. + * + * @sa @ref ant_enable_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_enable_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_channel_assign command request. + * + * @sa @ref ant_channel_assign_rsp_dec for command response decoder. + * + * @param[in] channel Channel is an unsigned char (1 octet) denoting the channel + * to assign. + * @param[in] channel_type Channel Type is an unsigned char (1 octet) denoting the + * channel type. See Assign Channel Parameters/Assign Channel + * Types in ant_parameters.h. + * @param[in] network Network is an unsigned char (1 octet) denoting the network + * key to associate with the channel. + * @param[in] ext_assign Ext Assign is a bit field (1 octet) for an extended + * assign. See Ext. Assign Channel Parameters in + * ant_parameters.h. + * @param[in] p_buf Pointer to buffer where encoded data command will be + * returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_channel_assign_req_enc(uint8_t channel, + uint8_t channel_type, + uint8_t network, + uint8_t ext_assign, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_channel_assign command. + * + * @sa @ref ant_channel_assign_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_channel_assign_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_channel_open command request. + * + * @sa @ref ant_channel_open_with_offset_rsp_dec for command response decoder. + * + * @param[in] channel Channel is an unsigned char (1 octet) denoting the channel to + * open. + * @param[in] usOffset Denote the offset from which to start the channel. + * + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_channel_open_with_offset_req_enc(uint8_t channel, + uint16_t usOffset, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_channel_open command. + * + * @sa @ref ant_channel_open_with_offset_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_channel_open_with_offset_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_channel_id_set command request. + * + * @sa @ref ant_channel_id_set_rsp_dec for command response decoder. + * + * @param[in] channel Channel is an unsigned char (1 octet) denoting the channel + * number to set. + * @param[in] device_number Device Number is an unsigned short (2 octets) denoting the + * device number. + * @param[in] device_type Device Type is an unsigned char (1 octet) denoting the device + * type. + * @param[in] transmit_type Transmit Type is an unsigned char (1 octet) denoting the + * transmission type. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_channel_id_set_req_enc(uint8_t channel, + uint16_t device_number, + uint8_t device_type, + uint8_t transmit_type, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_channel_id_set command. + * + * @sa @ref ant_channel_id_set_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_channel_id_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_channel_period_set command request. + * + * @sa @ref ant_channel_period_set_rsp_dec for command response decoder. + * + * @param[in] channel Channel is an unsigned char (1 octet) denoting the channel + * number to set the period to. + * @param[in] period Period is an unsigned short (2 octets) denoting the period in + * 32 kHz counts (usPeriod/32768 s). + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_channel_period_set_req_enc(uint8_t channel, + uint16_t period, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_channel_period_set command. + * + * @sa @ref ant_channel_period_set_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_channel_period_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_channel_radio_freq_set command request. + * + * @sa @ref ant_channel_radio_freq_set_rsp_dec for command response decoder. + * + * @param[in] channel Channel is an unsigned char (1 octet) denoting the channel + * number to set to. + * @param[in] freq Freq is an unsigned char (1 octet) denoting the radio + * frequency offset from 2400 MHz (eg. 2466 MHz, ucFreq = 66). + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_channel_radio_freq_set_req_enc(uint8_t channel, + uint8_t freq, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_channel_radio_freq_set command. + * + * @sa @ref ant_channel_radio_freq_set_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_channel_radio_freq_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_broadcast_message_tx command request. + * + * @sa @ref ant_broadcast_message_tx_rsp_dec for command response decoder. + * + * @param[in] channel Channel is an unsigned char (1 octet) denoting the channel to + * send the data on. + * @param[in] size Size is an unsigned char (1 octet) denoting the size of the + * message, ucSize must be 8. + * @param[in] p_mesg Mesg is the buffer where the message is located (array must be + * 8 octets). + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_broadcast_message_tx_req_enc(uint8_t channel, + uint8_t size, + uint8_t const * const p_mesg, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_broadcast_message_tx command. + * + * @sa @ref ant_broadcast_message_tx_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_broadcast_message_tx_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + + +/**@brief Encodes @ref sd_ant_acknowledge_message_tx command request. + * + * @sa @ref ant_acknowledge_message_tx_rsp_dec for command response decoder. + * + * @param[in] channel Channel is an unsigned char (1 octet) denoting the channel to + * send the data on. + * @param[in] size Size is an unsigned char (1 octet) denoting the size of the + * message, ucSize must be 8. + * @param[in] p_mesg Mesg is the buffer where the message is located (array must be + * 8 octets). + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_acknowledge_message_tx_req_enc(uint8_t channel, + uint8_t size, + uint8_t const * const p_mesg, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_acknowledge_message_tx command. + * + * @sa @ref ant_acknowledge_message_tx_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_acknowledge_message_tx_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_channel_unassign command request. + * + * @sa @ref ant_channel_unassign_rsp_dec for command response decoder. + * + * @param[in] channel Channel is an unsigned char (1 octet) denoting the channel + * to unassign. + * @param[in] p_buf Pointer to buffer where encoded data command will be + * returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_channel_unassign_req_enc(uint8_t channel, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_channel_unassign command. + * + * @sa @ref ant_channel_unassign_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_channel_unassign_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_channel_close command request. + * + * @sa @ref ant_channel_close_rsp_dec for command response decoder. + * + * @param[in] channel Channel is an unsigned char (1 octet) denoting the channel + * to close. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_channel_close_req_enc(uint8_t channel, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_channel_close command. + * + * @sa @ref ant_channel_close_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_channel_close_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_network_address_set command request. + * + * @sa @ref ant_network_address_set_rsp_dec for command response decoder. + * + * @param[in] network Network is an unsigned char (1 octet) denoting the network + * number to assign the network address to. + * @param[in] p_network_key Network key is the pointer to location of the Network Key (8 + * octets in length). + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_network_address_set_req_enc(uint8_t network, + uint8_t const * const p_network_key, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_network_address_set command. + * + * @sa @ref ant_network_address_set_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_network_address_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_channel_radio_tx_power_set command request. + * + * @sa @ref ant_channel_radio_tx_power_set_rsp_dec for command response decoder. + * + * @param[in] channel Channel is an unsigned char (1 octet) denoting the channel + * number to assign the radio TX power. + * @param[in] tx_power TX Power is an unsigned char (1 octet) denoting the ANT + * transmit power index. See Radio TX Power Definitions in + * ant_parameters.h. + * @param[in] custom_tx_power Custom TX Power is an unsigned char (1 octet) denoting the + * custom nRF transmit power as defined in nrf51_bitfields.h. + * Only applicable if tx_power is set to custom TX power + * selection. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_channel_radio_tx_power_set_req_enc(uint8_t channel, + uint8_t tx_power, + uint8_t custom_tx_power, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_channel_radio_tx_power_set command. + * + * @sa @ref ant_channel_radio_tx_power_set_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_channel_radio_tx_power_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_channel_rx_search_timeout_set command request. + * + * @sa @ref ant_channel_rx_search_timeout_set_rsp_dec for command response decoder. + * + * @param[in] channel Channel is an unsigned char (1 octet) denoting the channel + * number to set. + * @param[in] timeout Timeout is an unsigned char (1 octet) denoting the time-out + * value. + * When applied to an assigned slave channel, ucTimeout is in 2.5 + * second increments. Default = 10 (25 s) at channel assignment. + * When applied to an assigned master channel, ucTimeout is in + * 250 ms increments. Default = 0 (disabled) at channel assignment + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_channel_rx_search_timeout_set_req_enc(uint8_t channel, + uint8_t timeout, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_channel_rx_search_timeout_set command. + * + * @sa @ref ant_channel_rx_search_timeout_set_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_channel_rx_search_timeout_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_channel_low_priority_rx_search_timeout_set command request. + * + * @sa @ref ant_channel_low_priority_rx_search_timeout_set_rsp_dec for command response decoder. + * + * @param[in] channel Channel is an unsigned char (1 octet) denoting the channel + * number to set. + * @param[in] timeout Timeout is an unsigned char (1 octet) denoting the time-out + * value in 2.5 seconds increments. Default = 2 (5s). + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_channel_low_priority_rx_search_timeout_set_req_enc(uint8_t channel, + uint8_t timeout, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_channel_low_priority_rx_search_timeout_set command. + * + * @sa @ref ant_channel_low_priority_rx_search_timeout_set_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_channel_low_priority_rx_search_timeout_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_prox_search_set command request. + * + * @sa @ref ant_prox_search_set_rsp_dec for command response decoder. + * + * @param[in] channel Channel is an unsigned char (1 octet) denoting the channel + * number. + * @param[in] prox_threshold Prox threshold is an unsigned char (1 octet) denoting the + * minimum RSSI threshold required for acquisition during a + * search. See Radio Proximity Search Threshold in + * ant_parameters.h. + * @param[in] custom_prox_threshold Custom prox threshold is an unsigned char (1 octet) denoting + * the custom minimum RSSI threshold for acquisition during a + * search. Only applicable if ucProxThreshold is set to custom + * proximity selection. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_prox_search_set_req_enc(uint8_t channel, + uint8_t prox_threshold, + uint8_t custom_prox_threshold, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_prox_search_set command. + * + * @sa @ref ant_prox_search_set_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_prox_search_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_search_waveform_set command request. + * + * @sa @ref ant_search_waveform_set_rsp_dec for command response decoder. + * + * @param[in] channel Channel is an unsigned char (1 octet) denoting the channel + * number. + * @param[in] waveform Waveform is an unsigned short (2 octets) denoting the channel + * waveform period (usWaveform/32768 s). Default = 316. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_search_waveform_set_req_enc(uint8_t channel, + uint16_t waveform, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_search_waveform_set command. + * + * @sa @ref ant_search_waveform_set_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_search_waveform_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_channel_id_get command request. + * + * @sa @ref ant_channel_id_get_rsp_dec for command response decoder. + * + * @param[in] channel Channel is an unsigned char (1 octet) denoting the channel + * number. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_channel_id_get_req_enc(uint8_t channel, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_channel_id_get command. + * + * @sa @ref ant_channel_id_get_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[in] p_device_number Pointer to device number. + * @param[in] p_device_type Pointer to device type. + * @param[in] p_transmit_type Pointer to transmit type. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_channel_id_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + void * const p_device_number, + void * const p_device_type, + void * const p_transmit_type, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_channel_radio_freq_get command request. + * + * @sa @ref ant_channel_radio_freq_get_rsp_dec for command response decoder. + * + * @param[in] channel Channel is an unsigned char (1 octet) denoting the channel + * number. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_channel_radio_freq_get_req_enc(uint8_t channel, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_channel_radio_freq_get command. + * + * @sa @ref ant_channel_radio_freq_get_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[in] p_r_freq Pointer to radio frequency. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_channel_radio_freq_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + void * const p_r_freq, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_channel_period_get command request. + * + * @sa @ref ant_channel_period_get_rsp_dec for command response decoder. + * + * @param[in] channel Channel is an unsigned char (1 octet) denoting the channel + * number. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_channel_period_get_req_enc(uint8_t channel, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_channel_period_get command. + * + * @sa @ref ant_channel_period_get_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[in] p_period Pointer to period + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_channel_period_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + void * p_period, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_search_channel_priority_set command request. + * + * @sa @ref ant_search_channel_priority_set_rsp_dec for command response decoder. + * + * @param[in] channel Channel is an unsigned char (1 octet) denoting the channel + * number. + * @param[in] search_priority Search Priority is an unsigned char (1 octet) denoting the + * search priority value. 0 to 7 (Default = 0). + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_search_channel_priority_set_req_enc(uint8_t channel, + uint8_t search_priority, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_search_channel_priority_set command. + * + * @sa @ref ant_search_channel_priority_set_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_search_channel_priority_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + + +/**@brief Encodes @ref sd_ant_active_search_sharing_cycles_set command request. + * + * @sa @ref ant_active_search_sharing_cycles_set_rsp_dec for command response decoder. + * + * @param[in] channel Channel is an unsigned char (1 octet) denoting the channel + * number. + * @param[in] cycles Cycles is an unsigned char (1 octet) denoting the number of + * cycles to set. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_active_search_sharing_cycles_set_req_enc(uint8_t channel, + uint8_t cycles, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_active_search_sharing_cycles_set command. + * + * @sa @ref ant_active_search_sharing_cycles_set_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_active_search_sharing_cycles_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_lib_config_set command request. + * + * @sa @ref ant_lib_config_set_rsp_dec for command response decoder. + * + * @param[in] ant_lib_config ANT Lib Config an unsigned char (1 octet) denoting the ANT lib + * config bit flags. See ANT Library Config in ant_parameters.h. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_lib_config_set_req_enc(uint8_t ant_lib_config, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_lib_config_set command. + * + * @sa @ref ant_lib_config_set_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_lib_config_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_active_search_sharing_cycles_get command request. + * + * @sa @ref ant_active_search_sharing_cycles_get_rsp_dec for command response decoder. + * + * @param[in] channel Channel is an unsigned char (1 octet) denoting the channel + * number. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_active_search_sharing_cycles_get_req_enc(uint8_t channel, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_active_search_sharing_cycles_get command. + * + * @sa @ref ant_active_search_sharing_cycles_get_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[in] p_cycles Pointer to cycles. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_active_search_sharing_cycles_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + void * const p_cycles, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_lib_config_get command request. + * + * @sa @ref ant_lib_config_get_rsp_dec for command response decoder. + * + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_lib_config_get_req_enc(uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_lib_config_get command. + * + * @sa @ref ant_lib_config_get_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[in] p_ant_lib_config Pointer to the ANT library configuration. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_lib_config_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + void * const p_ant_lib_config, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_lib_config_clear command request. + * + * @sa @ref ant_lib_config_clear_rsp_dec for command response decoder. + * + * @param[in] ant_lib_config ANT lib config is an unsigned char (1 octet) denoting the + * ANT lib config bit(s) to clear. See ANT Library Config in + * ant_parameters.h. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_lib_config_clear_req_enc(uint8_t ant_lib_config, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_lib_config_clear command. + * + * @sa @ref ant_lib_config_clear_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_lib_config_clear_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_stack_reset command request. + * + * @sa @ref ant_stack_reset_rsp_dec for command response decoder. + * + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_stack_reset_req_enc(uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_stack_reset command. + * + * @sa @ref ant_stack_reset_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_stack_reset_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_rx_scan_mode_start command request. + * + * @sa @ref ant_rx_scan_mode_start_rsp_dec for command response decoder. + * + * @param[in] sync_channel_packets_only Sync channel packets only is an unsigned char (1 octet) + * denoting synchronous channel only scanning mode. + * 0 = disable, 1 = enable. + * @param[in] p_buf Pointer to buffer where encoded data command will be + * returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_rx_scan_mode_start_req_enc(uint8_t sync_channel_packets_only, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_rx_scan_mode_start command. + * + * @sa @ref ant_rx_scan_mode_start_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_rx_scan_mode_start_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_id_list_add command request. + * + * @sa @ref ant_id_list_add_rsp_dec for command response decoder. + * + * @param[in] channel Channel is an unsigned char (1 octet) denoting the channel + * number to add the list entry to. + * @param[in] p_dev_id Dev ID is the pointer to the buffer (4 octets) containing + * device ID information with the following format: + * Byte0 = DeviceNumber_LSB + * Byte1 = DeviceNumber_MSB + * Byte2 = DeviceType + * Byte3 = TransType + * @param[in] list_index List index is an unsigned char (1 octet) denoting the index + * where the specified channel ID is to be placed in the list (0-3). + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_id_list_add_req_enc(uint8_t channel, + uint8_t const * const p_dev_id, + uint8_t list_index, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_id_list_add command. + * + * @sa @ref ant_id_list_add_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_id_list_add_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_id_list_config command request. + * + * @sa @ref ant_id_list_config_rsp_dec for command response decoder. + * + * @param[in] channel Channel is an unsigned char (1 octet) denoting the + * channel number of the device ID list. + * @param[in] id_list_size ID list size is an unsigned char (1 octet) denoting the size of + * the inclusion or exclusion list (0-4). + * @param[in] inc_exc_flag Inc exc flag is an unsigned char (1 octet) denoting the type of + * list as Include(0) or Exclude(1). + * @param[in] channel + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_id_list_config_req_enc(uint8_t channel, + uint8_t id_list_size, + uint8_t inc_exc_flag, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_id_list_config command. + * + * @sa @ref ant_id_list_config_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_id_list_config_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_channel_status_get command request. + * + * @sa @ref ant_channel_status_get_rsp_dec for command response decoder. + * + * @param[in] channel Channel is an unsigned char (1 octet) denoting the channel + * number. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_channel_status_get_req_enc(uint8_t channel, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_channel_status_get command. + * + * @sa @ref ant_channel_status_get_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[in] p_status Pointer to status + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_channel_status_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + void * const p_status, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_cw_test_mode_init command request. + * + * @sa @ref ant_cw_test_mode_init_rsp_dec for command response decoder. + * + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_cw_test_mode_init_req_enc(uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_cw_test_mode_init command. + * + * @sa @ref ant_cw_test_mode_init_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_cw_test_mode_init_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_cw_test_mode command request. + * + * @sa @ref ant_cw_test_mode_rsp_dec for command response decoder. + * + * @param[in] radio_freq Radio freq is an unsigned char (1 octet) denoting the radio + * frequency offset from 2400 MHz for continuous wave mode. + * (eg. 2466 MHz, ucRadioFreq = 66). + * @param[in] tx_power TX Power is an unsigned char (1 octet) denoting the ANT transmit + * power index for continuous wave mode. See Radio TX Power + * Definitions in ant_parameters.h + * @param[in] custom_tx_power Custom TX power is an unsigned char (1 octet) denoting the + * custom nRF transmit power as defined in nrf51_bitfields.h. Only + * applicable if ucTxPower is set to custom TX power selection. + * @param[in] mode Mode is an unsigned char (1 octet) denoting test mode type where + * 0 = cw tx carrier transmission, 1 = cw tx modulated transmission. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_cw_test_mode_req_enc(uint8_t radio_freq, + uint8_t tx_power, + uint8_t custom_tx_power, + uint8_t mode, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_cw_test_mode command. + * + * @sa @ref ant_cw_test_mode_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_cw_test_mode_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_version_get command request. + * + * @sa @ref ant_version_get_rsp_dec for command response decoder. + * + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_version_get_req_enc(uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_version_get command. + * + * @sa @ref ant_version_get_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[in] p_version Pointer to version string buffer. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_version_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + void * * const p_version, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_capabilities_get command request. + * + * @sa @ref ant_capabilities_get_rsp_dec for command response decoder. + * + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_capabilities_get_req_enc(uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_capabilities_get command. + * + * @sa @ref ant_capabilities_get_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[in] pp_capabilities Pointer to pointer to capabilities buffer. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_capabilities_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + void * * const pp_capabilities, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_crypto_channel_enable command request. + * + * @sa @ref ant_crypto_channel_enable_rsp_dec for command response decoder. + * + * @param[in] channel Channel is an unsigned char (1 octet) denoting the channel in + * which encryption mode is set. + * @param[in] enable Enable is an unsigned char (1 octet) denoting the encryption + * mode. See Encrypted Channel Defines in ant_parameters.h. + * @param[in] key_num Key num is an unsigned char (1 octet) denoting the key index of + * the 128-bit key to be used for encryption. The key index range + * is bound by the number of encrypted channels configured by + * sd_ant_enable(). If sd_ant_enable() is not used then by default + * key num is 0. Range is [0 to (num encrypted channels - 1)], if + * 1 or more encrypted channels are configured. + * @param[in] decimation_rate Decimation rate is an unsigned char (1 octet) denoting the + * decimate rate to apply for encrypted slave channel. Must be > 0. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_crypto_channel_enable_req_enc(uint8_t channel, + uint8_t enable, + uint8_t key_num, + uint8_t decimation_rate, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_crypto_channel_enable command. + * + * @sa @ref ant_crypto_channel_enable_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_crypto_channel_enable_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_adv_burst_config_set command request. + * + * @sa @ref ant_adv_burst_config_set_rsp_dec for command response decoder. + * + * @param[in] p_config Config is a buffer containing the advanced burst + * configuration to be set. + * @param[in] size Size is an unsigned char (1 octet) denoting the size of the + * configuration parameter buffer. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_adv_burst_config_set_req_enc(uint8_t const * const p_config, + uint8_t size, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_adv_burst_config_set command. + * + * @sa @ref ant_adv_burst_config_set_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_adv_burst_config_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_crypto_key_set command request. + * + * @sa @ref ant_crypto_key_set_rsp_dec for command response decoder. + * + * @param[in] key_num Key num is an unsigned char (1 octet) denoting the key index for + * assignment. + * @param[in] p_key Buffer (16 octets) containing the 128-bit AES key to be + * assigned to the key index. + * + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_crypto_key_set_req_enc(uint8_t key_num, + uint8_t const * const p_key, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_crypto_key_set command. + * + * @sa @ref ant_crypto_key_set_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_crypto_key_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_crypto_info_set command request. + * + * @sa @ref ant_crypto_info_set_rsp_dec for command response decoder. + * + * @param[in] type Type is an unsigned char (1 octet) denoting the type of + * information being set. + * @param[in] p_info Pointer to a buffer buffer containing the information being set. + * + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_crypto_info_set_req_enc(uint8_t type, + uint8_t const * const p_info, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_crypto_info_set command. + * + * @sa @ref ant_crypto_info_set_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_crypto_info_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_crypto_info_get command request. + * + * @sa @ref ant_crypto_info_get_rsp_dec for command response decoder. + * + * @param[in] type Type is an unsigned char (1 octet) denoting the type of + * information being set. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_crypto_info_get_req_enc(uint8_t type, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_crypto_info_get command. + * + * @sa @ref ant_crypto_info_get_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[in] p_info Pointer to the info buffer. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_crypto_info_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + void * const p_info, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_coex_config_set command request. + * + * @sa @ref ant_coex_config_set_rsp_dec for command response decoder. + * + * @param[in] channel Channel is an unsigned char (1 octet) denoting the channel for + * which the coexistence configuration is to be set + * @param[in] p_config Pointer to a buffer containing the configuration to be set. + * @param[in] p_adv_coex_config Pointer to a buffer containing the advanced coexistence configuration + * to be set. + * + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_coex_config_set_req_enc(uint8_t channel, + ANT_BUFFER_PTR const * const p_config, + ANT_BUFFER_PTR const * const p_adv_coex_config, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_coex_config_set command. + * + * @sa @ref ant_coex_config_set_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_coex_config_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ant_coex_config_get command request. + * + * @sa @ref ant_coex_config_get_rsp_dec for command response decoder. + * + * @param[in] channel Channel is an unsigned char (1 octet) denoting the channel to + * query. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ant_coex_config_get_req_enc(uint8_t channel, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ant_coex_config_get command. + * + * @sa @ref ant_coex_config_get_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[in] p_coex_config Pointer to the coexistence configuration buffer. + * @param[in] p_adv_coex_config Pointer to the advanced coexistence configuration buffer. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ant_coex_config_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + void * const p_coex_config, + void * const p_adv_coex_config, + uint32_t * const p_result_code); +/** @} */ +#endif diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_broadcast_message_tx.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_broadcast_message_tx.c new file mode 100644 index 0000000..86548e0 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_broadcast_message_tx.c @@ -0,0 +1,90 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_broadcast_message_tx_req_enc(uint8_t channel, + uint8_t size, + uint8_t const * const p_mesg, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + uint8_t svc_number = SVC_ANT_TX_BROADCAST_MESSAGE; + uint32_t err_code = NRF_SUCCESS; + uint32_t buf_len = *p_buf_len; + uint32_t index = 0; + + err_code = uint8_t_enc(&svc_number, p_buf, buf_len, &index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + err_code = uint8_t_enc(&channel, p_buf, buf_len, &index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + err_code = uint8_t_enc(&size, p_buf, buf_len, &index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + err_code = uint8_vector_enc(p_mesg, size, p_buf, buf_len, &index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + + +uint32_t ant_broadcast_message_tx_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + // Use the ble cmd rsp dec function because it is adequte to decode + // the command response as it is the same for both ant and ble. + return ser_ble_cmd_rsp_dec(p_buf, packet_len, SVC_ANT_TX_BROADCAST_MESSAGE, p_result_code); +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_capabilities_get.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_capabilities_get.c new file mode 100644 index 0000000..9d47722 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_capabilities_get.c @@ -0,0 +1,93 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_capabilities_get_req_enc(uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + uint32_t index = 0; + uint32_t err_code = NRF_SUCCESS; + + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + p_buf[index++] = SVC_ANT_CAPABILITIES; + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + +uint32_t ant_capabilities_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + void * * const pp_capabilities, + uint32_t * const p_result_code) +{ + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_result_code); + + uint32_t index = 0; + uint32_t err_code = ser_ble_cmd_rsp_result_code_dec(p_buf, &index, packet_len, + SVC_ANT_CAPABILITIES, p_result_code); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + if (*p_result_code != NRF_SUCCESS) + { + SER_ASSERT_LENGTH_EQ(index, packet_len); + + return NRF_SUCCESS; + } + + err_code = uint8_vector_dec(p_buf, packet_len, &index, (uint8_t *)*pp_capabilities, MESG_CAPABILITIES_SIZE); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + SER_ASSERT_LENGTH_EQ(index, packet_len); + + return NRF_SUCCESS; +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_assign.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_assign.c new file mode 100644 index 0000000..ca4a44a --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_assign.c @@ -0,0 +1,83 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_channel_assign_req_enc(uint8_t channel, + uint8_t channel_type, + uint8_t network, + uint8_t ext_assign, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + uint32_t index = 0; + uint32_t err_code = NRF_SUCCESS; + + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + p_buf[index++] = SVC_ANT_CHANNEL_ASSIGN; + p_buf[index++] = channel; + p_buf[index++] = channel_type; + p_buf[index++] = network; + p_buf[index++] = ext_assign; + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + + +uint32_t ant_channel_assign_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + // Use the ble cmd rsp dec function because it is adequte to decode + // the command response as it is the same for both ant and ble. + return ser_ble_cmd_rsp_dec(p_buf, packet_len, SVC_ANT_CHANNEL_ASSIGN, p_result_code); +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_close.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_close.c new file mode 100644 index 0000000..bd3995d --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_close.c @@ -0,0 +1,76 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_channel_close_req_enc(uint8_t channel, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + uint32_t index = 0; + uint32_t err_code = NRF_SUCCESS; + + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + p_buf[index++] = SVC_ANT_CHANNEL_CLOSE; + p_buf[index++] = channel; + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + +uint32_t ant_channel_close_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + // Use the ble cmd rsp dec function because it is adequte to decode + // the command response as it is the same for both ant and ble. + return ser_ble_cmd_rsp_dec(p_buf, packet_len, SVC_ANT_CHANNEL_CLOSE, p_result_code); +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_id_get.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_id_get.c new file mode 100644 index 0000000..a4b11cd --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_id_get.c @@ -0,0 +1,103 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_channel_id_get_req_enc(uint8_t channel, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + uint32_t index = 0; + uint32_t err_code = NRF_SUCCESS; + + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + p_buf[index++] = SVC_ANT_CHANNEL_ID_GET; + p_buf[index++] = channel; + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + +uint32_t ant_channel_id_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + void * const p_device_number, + void * const p_device_type, + void * const p_transmit_type, + uint32_t * const p_result_code) +{ + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_result_code); + + uint32_t index = 0; + uint32_t err_code = ser_ble_cmd_rsp_result_code_dec(p_buf, &index, packet_len, + SVC_ANT_CHANNEL_ID_GET, p_result_code); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + if (*p_result_code != NRF_SUCCESS) + { + SER_ASSERT_LENGTH_EQ(index, packet_len); + + return NRF_SUCCESS; + } + + err_code = uint16_t_dec(p_buf, packet_len, &index, p_device_number); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + err_code = uint8_t_dec(p_buf, packet_len, &index, p_device_type); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + err_code = uint8_t_dec(p_buf, packet_len, &index, p_transmit_type); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + SER_ASSERT_LENGTH_EQ(index, packet_len); + + return NRF_SUCCESS; +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_id_set.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_id_set.c new file mode 100644 index 0000000..09563b3 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_id_set.c @@ -0,0 +1,83 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_channel_id_set_req_enc(uint8_t channel, + uint16_t device_number, + uint8_t device_type, + uint8_t transmit_type, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + uint32_t index = 0; + uint32_t err_code = NRF_SUCCESS; + + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + p_buf[index++] = SVC_ANT_CHANNEL_ID_SET; + p_buf[index++] = channel; + index += uint16_encode(device_number, &p_buf[index]); + p_buf[index++] = device_type; + p_buf[index++] = transmit_type; + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + + +uint32_t ant_channel_id_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + // Use the ble cmd rsp dec function because it is adequte to decode + // the command response as it is the same for both ant and ble. + return ser_ble_cmd_rsp_dec(p_buf, packet_len, SVC_ANT_CHANNEL_ID_SET, p_result_code); +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_low_priority_rx_search_timeout_set.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_low_priority_rx_search_timeout_set.c new file mode 100644 index 0000000..135f470 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_low_priority_rx_search_timeout_set.c @@ -0,0 +1,79 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_channel_low_priority_rx_search_timeout_set_req_enc(uint8_t channel, + uint8_t timeout, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + uint32_t index = 0; + uint32_t err_code = NRF_SUCCESS; + + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + p_buf[index++] = SVC_ANT_CHANNEL_LOW_PRIO_RX_SEARCH_TIMEOUT_SET; + p_buf[index++] = channel; + p_buf[index++] = timeout; + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + + +uint32_t ant_channel_low_priority_rx_search_timeout_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + // Use the ble cmd rsp dec function because it is adequte to decode + // the command response as it is the same for both ant and ble. + return ser_ble_cmd_rsp_dec(p_buf, packet_len, SVC_ANT_CHANNEL_LOW_PRIO_RX_SEARCH_TIMEOUT_SET, p_result_code); +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_open_with_offset.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_open_with_offset.c new file mode 100644 index 0000000..c4e30ef --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_open_with_offset.c @@ -0,0 +1,79 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_channel_open_with_offset_req_enc(uint8_t channel, + uint16_t usOffset, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + uint32_t index = 0; + uint32_t err_code = NRF_SUCCESS; + + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + p_buf[index++] = SVC_ANT_CHANNEL_OPEN; + p_buf[index++] = channel; + index += uint16_encode(usOffset, &p_buf[index]); + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + + +uint32_t ant_channel_open_with_offset_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + // Use the ble cmd rsp dec function because it is adequte to decode + // the command response as it is the same for both ant and ble. + return ser_ble_cmd_rsp_dec(p_buf, packet_len, SVC_ANT_CHANNEL_OPEN, p_result_code); +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_period_get.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_period_get.c new file mode 100644 index 0000000..09576fe --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_period_get.c @@ -0,0 +1,94 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_channel_period_get_req_enc(uint8_t channel, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + uint32_t index = 0; + uint32_t err_code = NRF_SUCCESS; + + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + p_buf[index++] = SVC_ANT_CHANNEL_PERIOD_GET; + p_buf[index++] = channel; + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + +uint32_t ant_channel_period_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + void * p_period, + uint32_t * const p_result_code) +{ + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_result_code); + + uint32_t index = 0; + uint32_t err_code = ser_ble_cmd_rsp_result_code_dec(p_buf, &index, packet_len, + SVC_ANT_CHANNEL_PERIOD_GET, p_result_code); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + if (*p_result_code != NRF_SUCCESS) + { + SER_ASSERT_LENGTH_EQ(index, packet_len); + + return NRF_SUCCESS; + } + + err_code = uint16_t_dec(p_buf, packet_len, &index, p_period); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + SER_ASSERT_LENGTH_EQ(index, packet_len); + + return NRF_SUCCESS; +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_period_set.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_period_set.c new file mode 100644 index 0000000..292f8f9 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_period_set.c @@ -0,0 +1,78 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_channel_period_set_req_enc(uint8_t channel, + uint16_t period, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + uint32_t index = 0; + uint32_t err_code = NRF_SUCCESS; + + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + p_buf[index++] = SVC_ANT_CHANNEL_PERIOD_SET; + p_buf[index++] = channel; + index += uint16_encode(period, &p_buf[index]); + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + +uint32_t ant_channel_period_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + // Use the ble cmd rsp dec function because it is adequte to decode + // the command response as it is the same for both ant and ble. + return ser_ble_cmd_rsp_dec(p_buf, packet_len, SVC_ANT_CHANNEL_PERIOD_SET, p_result_code); +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_radio_freq_get.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_radio_freq_get.c new file mode 100644 index 0000000..6651862 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_radio_freq_get.c @@ -0,0 +1,95 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_channel_radio_freq_get_req_enc(uint8_t channel, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + uint32_t index = 0; + uint32_t err_code = NRF_SUCCESS; + + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + p_buf[index++] = SVC_ANT_CHANNEL_RADIO_FREQ_GET; + p_buf[index++] = channel; + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + +uint32_t ant_channel_radio_freq_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + void * const p_r_freq, + uint32_t * const p_result_code) +{ + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_result_code); + + uint32_t index = 0; + uint32_t err_code = ser_ble_cmd_rsp_result_code_dec(p_buf, &index, packet_len, + SVC_ANT_CHANNEL_RADIO_FREQ_GET, p_result_code); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + if (*p_result_code != NRF_SUCCESS) + { + SER_ASSERT_LENGTH_EQ(index, packet_len); + + return NRF_SUCCESS; + } + + err_code = uint8_t_dec(p_buf, packet_len, &index, p_r_freq); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + SER_ASSERT_LENGTH_EQ(index, packet_len); + + return NRF_SUCCESS; +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_radio_freq_set.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_radio_freq_set.c new file mode 100644 index 0000000..5638e97 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_radio_freq_set.c @@ -0,0 +1,78 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_channel_radio_freq_set_req_enc(uint8_t channel, + uint8_t freq, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + uint32_t index = 0; + uint32_t err_code = NRF_SUCCESS; + + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + p_buf[index++] = SVC_ANT_CHANNEL_RADIO_FREQ_SET; + p_buf[index++] = channel; + p_buf[index++] = freq; + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + +uint32_t ant_channel_radio_freq_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + // Use the ble cmd rsp dec function because it is adequte to decode + // the command response as it is the same for both ant and ble. + return ser_ble_cmd_rsp_dec(p_buf, packet_len, SVC_ANT_CHANNEL_RADIO_FREQ_SET, p_result_code); +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_radio_tx_power_set.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_radio_tx_power_set.c new file mode 100644 index 0000000..c7ea273 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_radio_tx_power_set.c @@ -0,0 +1,81 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_channel_radio_tx_power_set_req_enc(uint8_t channel, + uint8_t tx_power, + uint8_t custom_tx_power, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + uint32_t index = 0; + uint32_t err_code = NRF_SUCCESS; + + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + p_buf[index++] = SVC_ANT_CHANNEL_RADIO_TX_POWER_SET; + p_buf[index++] = channel; + p_buf[index++] = tx_power; + p_buf[index++] = custom_tx_power; + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + + +uint32_t ant_channel_radio_tx_power_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + // Use the ble cmd rsp dec function because it is adequte to decode + // the command response as it is the same for both ant and ble. + return ser_ble_cmd_rsp_dec(p_buf, packet_len, SVC_ANT_CHANNEL_RADIO_TX_POWER_SET, p_result_code); +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_rx_search_timeout_set.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_rx_search_timeout_set.c new file mode 100644 index 0000000..1ac542d --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_rx_search_timeout_set.c @@ -0,0 +1,79 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_channel_rx_search_timeout_set_req_enc(uint8_t channel, + uint8_t timeout, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + uint32_t index = 0; + uint32_t err_code = NRF_SUCCESS; + + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + p_buf[index++] = SVC_ANT_CHANNEL_SEARCH_TIMEOUT_SET; + p_buf[index++] = channel; + p_buf[index++] = timeout; + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + + +uint32_t ant_channel_rx_search_timeout_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + // Use the ble cmd rsp dec function because it is adequte to decode + // the command response as it is the same for both ant and ble. + return ser_ble_cmd_rsp_dec(p_buf, packet_len, SVC_ANT_CHANNEL_SEARCH_TIMEOUT_SET, p_result_code); +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_status_get.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_status_get.c new file mode 100644 index 0000000..2ed53eb --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_status_get.c @@ -0,0 +1,95 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_channel_status_get_req_enc(uint8_t channel, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + uint32_t index = 0; + uint32_t err_code = NRF_SUCCESS; + + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + p_buf[index++] = SVC_ANT_CHANNEL_STATUS_GET; + p_buf[index++] = channel; + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + +uint32_t ant_channel_status_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + void * const p_status, + uint32_t * const p_result_code) +{ + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_result_code); + + uint32_t index = 0; + uint32_t err_code = ser_ble_cmd_rsp_result_code_dec(p_buf, &index, packet_len, + SVC_ANT_CHANNEL_STATUS_GET, p_result_code); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + if (*p_result_code != NRF_SUCCESS) + { + SER_ASSERT_LENGTH_EQ(index, packet_len); + + return NRF_SUCCESS; + } + + err_code = uint8_t_dec(p_buf, packet_len, &index, p_status); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + SER_ASSERT_LENGTH_EQ(index, packet_len); + + return NRF_SUCCESS; +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_unassign.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_unassign.c new file mode 100644 index 0000000..1c82fe9 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_channel_unassign.c @@ -0,0 +1,76 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_channel_unassign_req_enc(uint8_t channel, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + uint32_t index = 0; + uint32_t err_code = NRF_SUCCESS; + + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + p_buf[index++] = SVC_ANT_CHANNEL_UNASSIGN; + p_buf[index++] = channel; + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + +uint32_t ant_channel_unassign_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + // Use the ble cmd rsp dec function because it is adequte to decode + // the command response as it is the same for both ant and ble. + return ser_ble_cmd_rsp_dec(p_buf, packet_len, SVC_ANT_CHANNEL_UNASSIGN, p_result_code); +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_coex_config_get.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_coex_config_get.c new file mode 100644 index 0000000..a38f497 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_coex_config_get.c @@ -0,0 +1,130 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" +#include "ant_interface.h" + +uint32_t ant_coex_config_get_req_enc(uint8_t channel, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + uint8_t svc_number = SVC_ANT_COEX_CONFIG_GET; + uint32_t err_code = NRF_SUCCESS; + uint32_t buf_len = *p_buf_len; + uint32_t index = 0; + + err_code = uint8_t_enc(&svc_number, p_buf, buf_len, &index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + err_code = uint8_t_enc(&channel, p_buf, buf_len, &index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + +uint32_t ant_coex_config_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + void * const p_coex_config, + void * const p_adv_coex_config, + uint32_t * const p_result_code) +{ + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_result_code); + + uint32_t index = 0; + uint32_t err_code = ser_ble_cmd_rsp_result_code_dec(p_buf, &index, packet_len, + SVC_ANT_COEX_CONFIG_GET, p_result_code); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + if (*p_result_code != NRF_SUCCESS) + { + SER_ASSERT_LENGTH_EQ(index, packet_len); + + return NRF_SUCCESS; + } + + uint8_t coex_config_size; + uint8_t coex_config_buffer[(MESG_BUFFER_SIZE / 2) - 1]; + + uint8_t adv_coex_config_size; + uint8_t adv_coex_config_buffer[(MESG_BUFFER_SIZE / 2) - 1]; + + err_code = uint8_t_dec(p_buf, packet_len, &index, &coex_config_size); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + err_code = uint8_vector_dec(p_buf, packet_len, &index, coex_config_buffer, coex_config_size); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + err_code = uint8_t_dec(p_buf, packet_len, &index, &(adv_coex_config_size)); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + err_code = uint8_vector_dec(p_buf, packet_len, &index, adv_coex_config_buffer, adv_coex_config_size); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + + if (p_coex_config) + { + ((ANT_BUFFER_PTR *)p_coex_config)->ucBufferSize = coex_config_size; + memcpy(((ANT_BUFFER_PTR *)p_coex_config)->pucBuffer, coex_config_buffer,((ANT_BUFFER_PTR *)p_coex_config)->ucBufferSize); + } + + if (p_adv_coex_config) + { + ((ANT_BUFFER_PTR *)p_adv_coex_config)->ucBufferSize = coex_config_size; + memcpy(((ANT_BUFFER_PTR *)p_adv_coex_config)->pucBuffer, coex_config_buffer,((ANT_BUFFER_PTR *)p_adv_coex_config)->ucBufferSize); + } + + SER_ASSERT_LENGTH_LEQ(index, packet_len); + + return NRF_SUCCESS; +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_coex_config_set.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_coex_config_set.c new file mode 100644 index 0000000..4465abc --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_coex_config_set.c @@ -0,0 +1,109 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_coex_config_set_req_enc(uint8_t channel, + ANT_BUFFER_PTR const * const p_coex_config, + ANT_BUFFER_PTR const * const p_adv_coex_config, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + uint8_t svc_number = SVC_ANT_COEX_CONFIG_SET; + uint32_t err_code = NRF_SUCCESS; + uint32_t buf_len = *p_buf_len; + uint32_t index = 0; + + err_code = uint8_t_enc(&svc_number, p_buf, buf_len, &index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + err_code = uint8_t_enc(&channel, p_buf, buf_len, &index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + // Encode coex config buffer size + uint8_t coex_config_buffer_size = p_coex_config -> ucBufferSize; + err_code = uint8_t_enc(&coex_config_buffer_size, p_buf, buf_len, &index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + // Encode coex config buffer + err_code = uint8_vector_enc(p_coex_config -> pucBuffer, + coex_config_buffer_size, + p_buf, + buf_len, + &index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + // Encode advanced coex config buffer size + uint8_t adv_coex_config_buffer_size = p_adv_coex_config -> ucBufferSize; + err_code = uint8_t_enc(&adv_coex_config_buffer_size, p_buf, buf_len, &index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + // Encode advanced coex config buffer + err_code = uint8_vector_enc(p_adv_coex_config -> pucBuffer, + adv_coex_config_buffer_size, + p_buf, + buf_len, + &index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + +uint32_t ant_coex_config_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + // Use the ble cmd rsp dec function because it is adequte to decode + // the command response as it is the same for both ant and ble. + return ser_ble_cmd_rsp_dec(p_buf, packet_len, SVC_ANT_COEX_CONFIG_SET, p_result_code); +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_crypto_channel_enable.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_crypto_channel_enable.c new file mode 100644 index 0000000..9071c89 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_crypto_channel_enable.c @@ -0,0 +1,82 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_crypto_channel_enable_req_enc(uint8_t channel, + uint8_t enable, + uint8_t key_num, + uint8_t decimation_rate, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + uint32_t index = 0; + uint32_t err_code = NRF_SUCCESS; + + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + p_buf[index++] = SVC_ANT_CRYPTO_CHANNEL_ENABLE; + p_buf[index++] = channel; + p_buf[index++] = enable; + p_buf[index++] = key_num; + p_buf[index++] = decimation_rate; + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + +uint32_t ant_crypto_channel_enable_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + // Use the ble cmd rsp dec function because it is adequte to decode + // the command response as it is the same for both ant and ble. + return ser_ble_cmd_rsp_dec(p_buf, packet_len, SVC_ANT_CRYPTO_CHANNEL_ENABLE, p_result_code); +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_crypto_info_get.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_crypto_info_get.c new file mode 100644 index 0000000..6a2b5a4 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_crypto_info_get.c @@ -0,0 +1,123 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_crypto_info_get_req_enc(uint8_t type, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + uint8_t svc_number = SVC_ANT_CRYPTO_INFO_GET; + uint32_t err_code = NRF_SUCCESS; + uint32_t buf_len = *p_buf_len; + uint32_t index = 0; + + err_code = uint8_t_enc(&svc_number, p_buf, buf_len, &index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + err_code = uint8_t_enc(&type, p_buf, buf_len, &index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + SER_ASSERT_LENGTH_LEQ(index, buf_len); + + *p_buf_len = index; + + return err_code; +} + +uint32_t ant_crypto_info_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + void * const p_info, + uint32_t * const p_result_code) +{ + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_result_code); + + uint32_t index = 0; + uint32_t err_code = ser_ble_cmd_rsp_result_code_dec(p_buf, &index, packet_len, + SVC_ANT_CRYPTO_INFO_GET, p_result_code); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + if (*p_result_code != NRF_SUCCESS) + { + SER_ASSERT_LENGTH_EQ(index, packet_len); + + return NRF_SUCCESS; + } + + uint8_t type; + uint8_t crypto_info_size; + + err_code = uint8_t_dec(p_buf, packet_len, &index, &type); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + switch (type) + { + case ENCRYPTION_INFO_GET_SUPPORTED_MODE: + crypto_info_size = MESG_CONFIG_ENCRYPT_REQ_CAPABILITIES_SIZE - MESG_CHANNEL_NUM_SIZE; + break; + case ENCRYPTION_INFO_GET_CRYPTO_ID: + crypto_info_size = MESG_CONFIG_ENCRYPT_REQ_CONFIG_ID_SIZE - MESG_CHANNEL_NUM_SIZE; + break; + case ENCRYPTION_INFO_GET_CUSTOM_USER_DATA: + crypto_info_size = (MESG_CONFIG_ENCRYPT_REQ_CONFIG_USER_DATA_SIZE - + MESG_CHANNEL_NUM_SIZE); + break; + default: + crypto_info_size = 0; + break; + } + + err_code = uint8_vector_dec(p_buf, packet_len, &index, (uint8_t *)p_info, crypto_info_size); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + SER_ASSERT_LENGTH_LEQ(index, packet_len); + + return NRF_SUCCESS; +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_crypto_info_set.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_crypto_info_set.c new file mode 100644 index 0000000..b56987a --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_crypto_info_set.c @@ -0,0 +1,90 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_crypto_info_set_req_enc(uint8_t type, + uint8_t const * const p_config, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + uint8_t svc_number = SVC_ANT_CRYPTO_INFO_SET; + uint32_t err_code = NRF_SUCCESS; + uint32_t buf_len = *p_buf_len; + uint32_t index = 0; + + err_code = uint8_t_enc(&svc_number, p_buf, buf_len, &index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + err_code = uint8_t_enc(&type, p_buf, buf_len, &index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + uint8_t crypto_info_size = (MESG_CONFIG_ENCRYPT_REQ_CONFIG_USER_DATA_SIZE - + MESG_CHANNEL_NUM_SIZE) + + (MESG_CONFIG_ENCRYPT_REQ_CONFIG_ID_SIZE - + MESG_CHANNEL_NUM_SIZE); + + err_code = uint8_vector_enc(p_config, crypto_info_size, p_buf, buf_len, &index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + +uint32_t ant_crypto_info_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + // Use the ble cmd rsp dec function because it is adequte to decode + // the command response as it is the same for both ant and ble. + return ser_ble_cmd_rsp_dec(p_buf, packet_len, SVC_ANT_CRYPTO_INFO_SET, p_result_code); +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_crypto_key_set.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_crypto_key_set.c new file mode 100644 index 0000000..4c1b05c --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_crypto_key_set.c @@ -0,0 +1,85 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_crypto_key_set_req_enc(uint8_t key_num, + uint8_t const * const p_key, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + uint8_t svc_number = SVC_ANT_CRYPTO_KEY_SET; + uint32_t err_code = NRF_SUCCESS; + uint32_t buf_len = *p_buf_len; + uint32_t index = 0; + + err_code = uint8_t_enc(&svc_number, p_buf, buf_len, &index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + err_code = uint8_t_enc(&key_num, p_buf, buf_len, &index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + err_code = uint8_vector_enc(p_key, SIZE_OF_ENCRYPTED_KEY, p_buf, buf_len, &index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + +uint32_t ant_crypto_key_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + // Use the ble cmd rsp dec function because it is adequte to decode + // the command response as it is the same for both ant and ble. + return ser_ble_cmd_rsp_dec(p_buf, packet_len, SVC_ANT_CRYPTO_KEY_SET, p_result_code); +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_cw_test_mode.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_cw_test_mode.c new file mode 100644 index 0000000..c149907 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_cw_test_mode.c @@ -0,0 +1,82 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_cw_test_mode_req_enc(uint8_t radio_freq, + uint8_t tx_power, + uint8_t custom_tx_power, + uint8_t mode, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + uint32_t index = 0; + uint32_t err_code = NRF_SUCCESS; + + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + p_buf[index++] = SVC_ANT_CW_TEST_MODE; + p_buf[index++] = radio_freq; + p_buf[index++] = tx_power; + p_buf[index++] = custom_tx_power; + p_buf[index++] = mode; + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + +uint32_t ant_cw_test_mode_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + // Use the ble cmd rsp dec function because it is adequte to decode + // the command response as it is the same for both ant and ble. + return ser_ble_cmd_rsp_dec(p_buf, packet_len, SVC_ANT_CW_TEST_MODE, p_result_code); +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_cw_test_mode_init.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_cw_test_mode_init.c new file mode 100644 index 0000000..706fd3b --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_cw_test_mode_init.c @@ -0,0 +1,74 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_cw_test_mode_init_req_enc(uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + uint32_t index = 0; + uint32_t err_code = NRF_SUCCESS; + + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + p_buf[index++] = SVC_ANT_INIT_CW_TEST_MODE; + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + +uint32_t ant_cw_test_mode_init_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + // Use the ble cmd rsp dec function because it is adequte to decode + // the command response as it is the same for both ant and ble. + return ser_ble_cmd_rsp_dec(p_buf, packet_len, SVC_ANT_INIT_CW_TEST_MODE, p_result_code); +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_enable.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_enable.c new file mode 100644 index 0000000..e8b9f20 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_enable.c @@ -0,0 +1,79 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_enable_req_enc(ANT_ENABLE * const p_channel_enable, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + uint32_t index = 0; + uint32_t err_code = NRF_SUCCESS; + + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + p_buf[index++] = SVC_ANT_ENABLE; + + err_code = cond_field_enc(p_channel_enable, p_buf, *p_buf_len, &index, ANT_ENABLE_enc); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + + +uint32_t ant_enable_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + // Use the ble cmd rsp dec function because it is adequte to decode + // the command response as it is the same for both ant and ble. + return ser_ble_cmd_rsp_dec(p_buf, packet_len, SVC_ANT_ENABLE, p_result_code); +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_event.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_event.c new file mode 100644 index 0000000..afad594 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_event.c @@ -0,0 +1,74 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +//#include "ble_app.h" +//#include "ble_evt_app.h" +//#include "ble_gap_evt_app.h" +//#include "ble_gattc_evt_app.h" +//#include "ble_gatts_evt_app.h" +//#include "ble_l2cap_evt_app.h" +#include "ble_serialization.h" +#include "app_util.h" +#include "nrf_sdh_ant.h" +#include "ant_struct_serialization.h" +#include "ant_parameters.h" + +uint32_t ant_event_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ant_evt_t * const p_event, + uint32_t * const p_event_len) +{ + uint32_t index = SER_ANT_EVT_ID_POS; + uint32_t err_code = NRF_SUCCESS; + + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_event_len); + SER_ASSERT_LENGTH_LEQ(SER_EVT_HEADER_SIZE, packet_len); + SER_ASSERT_NOT_NULL(p_event); + + err_code = ant_evt_t_dec(p_buf, packet_len, &index, p_event); + + SER_ASSERT_LENGTH_EQ(index, packet_len); + *p_event_len = index; + + SER_ASSERT_LENGTH_LEQ(p_event->channel, MAX_ANT_CHANNELS); + + return err_code; +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_event.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_event.h new file mode 100644 index 0000000..da62571 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_event.h @@ -0,0 +1,81 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef __ANT_EVENT_H__ +#define __ANT_EVENT_H__ + +#include "ble_serialization.h" +#include "app_util.h" +#include "nrf_sdh_ant.h" + +/** + * @addtogroup ser_app_s212_codecs + * @{ + */ + + +/**@brief Event decoding dispatcher. + * + * The event decoding dispatcher will route the event packet to the correct decoder, which in turn + * decodes the contents of the event and updates the \p p_event struct. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of the event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to the \ref ant_evt_t buffer where the decoded event will be + * stored. If NULL, the required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of the decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold the decoded event. + * @retval NRF_ERROR_NOT_FOUND Decoding failure. No event decoder is available. + */ +uint32_t ant_event_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ant_evt_t * const p_event, + uint32_t * const p_event_len); +/** @} */ + +#endif diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_id_list_add.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_id_list_add.c new file mode 100644 index 0000000..ef318e0 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_id_list_add.c @@ -0,0 +1,91 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" +#include "ant_parameters.h" + +uint32_t ant_id_list_add_req_enc(uint8_t channel, + uint8_t const * const p_dev_id, + uint8_t list_index, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + uint8_t svc_number = SVC_ANT_ID_LIST_ADD; + uint32_t err_code = NRF_SUCCESS; + uint32_t buf_len = *p_buf_len; + uint32_t index = 0; + + err_code = uint8_t_enc(&svc_number, p_buf, buf_len, &index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + err_code = uint8_t_enc(&channel, p_buf, buf_len, &index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + err_code = uint8_vector_enc(p_dev_id, ANT_ID_SIZE, p_buf, buf_len, &index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + err_code = uint8_t_enc(&list_index, p_buf, buf_len, &index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + + +uint32_t ant_id_list_add_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + // Use the ble cmd rsp dec function because it is adequte to decode + // the command response as it is the same for both ant and ble. + return ser_ble_cmd_rsp_dec(p_buf, packet_len, SVC_ANT_ID_LIST_ADD, p_result_code); +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_id_list_config.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_id_list_config.c new file mode 100644 index 0000000..305dec8 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_id_list_config.c @@ -0,0 +1,81 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_id_list_config_req_enc(uint8_t channel, + uint8_t id_list_size, + uint8_t inc_exc_flag, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + uint32_t index = 0; + uint32_t err_code = NRF_SUCCESS; + + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + p_buf[index++] = SVC_ANT_ID_LIST_CONFIG; + p_buf[index++] = channel; + p_buf[index++] = id_list_size; + p_buf[index++] = inc_exc_flag; + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + + +uint32_t ant_id_list_config_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + // Use the ble cmd rsp dec function because it is adequte to decode + // the command response as it is the same for both ant and ble. + return ser_ble_cmd_rsp_dec(p_buf, packet_len, SVC_ANT_ID_LIST_CONFIG, p_result_code); +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_lib_config_clear.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_lib_config_clear.c new file mode 100644 index 0000000..0a703b2 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_lib_config_clear.c @@ -0,0 +1,76 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_lib_config_clear_req_enc(uint8_t ant_lib_config, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + uint32_t index = 0; + uint32_t err_code = NRF_SUCCESS; + + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + p_buf[index++] = SVC_ANT_LIB_CONFIG_CLEAR; + p_buf[index++] = ant_lib_config; + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + +uint32_t ant_lib_config_clear_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + // Use the ble cmd rsp dec function because it is adequte to decode + // the command response as it is the same for both ant and ble. + return ser_ble_cmd_rsp_dec(p_buf, packet_len, SVC_ANT_LIB_CONFIG_CLEAR, p_result_code); +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_lib_config_get.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_lib_config_get.c new file mode 100644 index 0000000..93f8819 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_lib_config_get.c @@ -0,0 +1,93 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_lib_config_get_req_enc(uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + uint32_t index = 0; + uint32_t err_code = NRF_SUCCESS; + + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + p_buf[index++] = SVC_ANT_LIB_CONFIG_GET; + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + +uint32_t ant_lib_config_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + void * const p_ant_lib_config, + uint32_t * const p_result_code) +{ + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_result_code); + + uint32_t index = 0; + uint32_t err_code = ser_ble_cmd_rsp_result_code_dec(p_buf, &index, packet_len, + SVC_ANT_LIB_CONFIG_GET, p_result_code); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + if (*p_result_code != NRF_SUCCESS) + { + SER_ASSERT_LENGTH_EQ(index, packet_len); + + return NRF_SUCCESS; + } + + err_code = uint8_t_dec(p_buf, packet_len, &index, p_ant_lib_config); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + SER_ASSERT_LENGTH_EQ(index, packet_len); + + return NRF_SUCCESS; +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_lib_config_set.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_lib_config_set.c new file mode 100644 index 0000000..3f00546 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_lib_config_set.c @@ -0,0 +1,76 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_lib_config_set_req_enc(uint8_t ant_lib_config, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + uint32_t index = 0; + uint32_t err_code = NRF_SUCCESS; + + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + p_buf[index++] = SVC_ANT_LIB_CONFIG_SET; + p_buf[index++] = ant_lib_config; + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + +uint32_t ant_lib_config_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + // Use the ble cmd rsp dec function because it is adequte to decode + // the command response as it is the same for both ant and ble. + return ser_ble_cmd_rsp_dec(p_buf, packet_len, SVC_ANT_LIB_CONFIG_SET, p_result_code); +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_network_address_set.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_network_address_set.c new file mode 100644 index 0000000..fade1d4 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_network_address_set.c @@ -0,0 +1,85 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_network_address_set_req_enc(uint8_t network, + uint8_t const * const p_network_key, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + uint8_t svc_number = SVC_ANT_NETWORK_KEY_SET; + uint32_t err_code = NRF_SUCCESS; + uint32_t buf_len = *p_buf_len; + uint32_t index = 0; + + err_code = uint8_t_enc(&svc_number, p_buf, buf_len, &index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + err_code = uint8_t_enc(&network, p_buf, buf_len, &index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + err_code = uint8_vector_enc(p_network_key, MESG_NETWORK_KEY_SIZE - MESG_CHANNEL_NUM_SIZE, p_buf, buf_len, &index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + +uint32_t ant_network_address_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + // Use the ble cmd rsp dec function because it is adequte to decode + // the command response as it is the same for both ant and ble. + return ser_ble_cmd_rsp_dec(p_buf, packet_len, SVC_ANT_NETWORK_KEY_SET, p_result_code); +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_prox_search_set.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_prox_search_set.c new file mode 100644 index 0000000..45b5415 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_prox_search_set.c @@ -0,0 +1,81 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_prox_search_set_req_enc(uint8_t channel, + uint8_t prox_threshold, + uint8_t custom_prox_threshold, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + uint32_t index = 0; + uint32_t err_code = NRF_SUCCESS; + + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + p_buf[index++] = SVC_ANT_PROX_SEARCH_SET; + p_buf[index++] = channel; + p_buf[index++] = prox_threshold; + p_buf[index++] = custom_prox_threshold; + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + + +uint32_t ant_prox_search_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + // Use the ble cmd rsp dec function because it is adequte to decode + // the command response as it is the same for both ant and ble. + return ser_ble_cmd_rsp_dec(p_buf, packet_len, SVC_ANT_PROX_SEARCH_SET, p_result_code); +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_rx_scan_mode_start.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_rx_scan_mode_start.c new file mode 100644 index 0000000..6cdefe7 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_rx_scan_mode_start.c @@ -0,0 +1,76 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_rx_scan_mode_start_req_enc(uint8_t sync_scan_channel_packets_only, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + uint32_t index = 0; + uint32_t err_code = NRF_SUCCESS; + + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + p_buf[index++] = SVC_ANT_RX_SCAN_MODE_START; + p_buf[index++] = sync_scan_channel_packets_only; + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + +uint32_t ant_rx_scan_mode_start_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + // Use the ble cmd rsp dec function because it is adequte to decode + // the command response as it is the same for both ant and ble. + return ser_ble_cmd_rsp_dec(p_buf, packet_len, SVC_ANT_RX_SCAN_MODE_START, p_result_code); +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_search_channel_priority_set.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_search_channel_priority_set.c new file mode 100644 index 0000000..0ad7a55 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_search_channel_priority_set.c @@ -0,0 +1,78 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_search_channel_priority_set_req_enc(uint8_t channel, + uint8_t search_priority, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + uint32_t index = 0; + uint32_t err_code = NRF_SUCCESS; + + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + p_buf[index++] = SVC_ANT_SEARCH_CHANNEL_PRIORITY_SET; + p_buf[index++] = channel; + p_buf[index++] = search_priority; + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + +uint32_t ant_search_channel_priority_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + // Use the ble cmd rsp dec function because it is adequte to decode + // the command response as it is the same for both ant and ble. + return ser_ble_cmd_rsp_dec(p_buf, packet_len, SVC_ANT_SEARCH_CHANNEL_PRIORITY_SET, p_result_code); +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_search_waveform_set.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_search_waveform_set.c new file mode 100644 index 0000000..6204445 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_search_waveform_set.c @@ -0,0 +1,79 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_search_waveform_set_req_enc(uint8_t channel, + uint16_t waveform, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + uint32_t index = 0; + uint32_t err_code = NRF_SUCCESS; + + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + p_buf[index++] = SVC_ANT_SEARCH_WAVEFORM_SET; + p_buf[index++] = channel; + index += uint16_encode(waveform, &p_buf[index]); + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + + +uint32_t ant_search_waveform_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + // Use the ble cmd rsp dec function because it is adequte to decode + // the command response as it is the same for both ant and ble. + return ser_ble_cmd_rsp_dec(p_buf, packet_len, SVC_ANT_SEARCH_WAVEFORM_SET, p_result_code); +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_stack_reset.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_stack_reset.c new file mode 100644 index 0000000..15fb65d --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_stack_reset.c @@ -0,0 +1,74 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_stack_reset_req_enc(uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + uint32_t index = 0; + uint32_t err_code = NRF_SUCCESS; + + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + p_buf[index++] = SVC_ANT_STACK_INIT; + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + +uint32_t ant_stack_reset_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + // Use the ble cmd rsp dec function because it is adequte to decode + // the command response as it is the same for both ant and ble. + return ser_ble_cmd_rsp_dec(p_buf, packet_len, SVC_ANT_STACK_INIT, p_result_code); +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_version_get.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_version_get.c new file mode 100644 index 0000000..f0159de --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/serialization/application/codecs/ant/serializers/ant_version_get.c @@ -0,0 +1,93 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> +#include "ant_app.h" +#include "ble_serialization.h" +#include "ant_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +uint32_t ant_version_get_req_enc(uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + uint32_t index = 0; + uint32_t err_code = NRF_SUCCESS; + + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + p_buf[index++] = SVC_ANT_VERSION; + + SER_ASSERT_LENGTH_LEQ(index, *p_buf_len); + + *p_buf_len = index; + + return err_code; +} + +uint32_t ant_version_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + void * * const p_version, + uint32_t * const p_result_code) +{ + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_result_code); + + uint32_t index = 0; + uint32_t err_code = ser_ble_cmd_rsp_result_code_dec(p_buf, &index, packet_len, + SVC_ANT_VERSION, p_result_code); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + if (*p_result_code != NRF_SUCCESS) + { + SER_ASSERT_LENGTH_EQ(index, packet_len); + + return NRF_SUCCESS; + } + + err_code = uint8_vector_dec(p_buf, packet_len, &index, (uint8_t *)*p_version, MESG_BUFFER_SIZE); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + SER_ASSERT_LENGTH_EQ(index, packet_len); + + return NRF_SUCCESS; +} |