初始版本

This commit is contained in:
xiaozhengsheng
2025-08-19 09:49:41 +08:00
parent 10f1ddf1c1
commit 6df0f7d96e
2974 changed files with 1712873 additions and 54 deletions

View File

@@ -0,0 +1,90 @@
/**
* Copyright (c) 2017 - 2020, 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);
}

View File

@@ -0,0 +1,96 @@
/**
* Copyright (c) 2017 - 2020, 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;
}

View File

@@ -0,0 +1,78 @@
/**
* Copyright (c) 2017 - 2020, 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);
}

View File

@@ -0,0 +1,86 @@
/**
* Copyright (c) 2017 - 2020, 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);
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,90 @@
/**
* Copyright (c) 2017 - 2020, 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);
}

View File

@@ -0,0 +1,93 @@
/**
* Copyright (c) 2017 - 2020, 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;
}

View File

@@ -0,0 +1,83 @@
/**
* Copyright (c) 2017 - 2020, 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);
}

View File

@@ -0,0 +1,76 @@
/**
* Copyright (c) 2017 - 2020, 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);
}

View File

@@ -0,0 +1,103 @@
/**
* Copyright (c) 2017 - 2020, 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;
}

View File

@@ -0,0 +1,83 @@
/**
* Copyright (c) 2017 - 2020, 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);
}

View File

@@ -0,0 +1,79 @@
/**
* Copyright (c) 2017 - 2020, 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);
}

View File

@@ -0,0 +1,79 @@
/**
* Copyright (c) 2017 - 2020, 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);
}

View File

@@ -0,0 +1,94 @@
/**
* Copyright (c) 2017 - 2020, 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;
}

View File

@@ -0,0 +1,78 @@
/**
* Copyright (c) 2017 - 2020, 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);
}

View File

@@ -0,0 +1,95 @@
/**
* Copyright (c) 2017 - 2020, 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;
}

View File

@@ -0,0 +1,78 @@
/**
* Copyright (c) 2017 - 2020, 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);
}

View File

@@ -0,0 +1,81 @@
/**
* Copyright (c) 2017 - 2020, 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);
}

View File

@@ -0,0 +1,79 @@
/**
* Copyright (c) 2017 - 2020, 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);
}

View File

@@ -0,0 +1,95 @@
/**
* Copyright (c) 2017 - 2020, 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;
}

View File

@@ -0,0 +1,76 @@
/**
* Copyright (c) 2017 - 2020, 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);
}

View File

@@ -0,0 +1,130 @@
/**
* Copyright (c) 2017 - 2020, 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;
}

View File

@@ -0,0 +1,109 @@
/**
* Copyright (c) 2017 - 2020, 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);
}

View File

@@ -0,0 +1,82 @@
/**
* Copyright (c) 2017 - 2020, 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);
}

View File

@@ -0,0 +1,123 @@
/**
* Copyright (c) 2017 - 2020, 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;
}

View File

@@ -0,0 +1,90 @@
/**
* Copyright (c) 2017 - 2020, 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);
}

View File

@@ -0,0 +1,85 @@
/**
* Copyright (c) 2017 - 2020, 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);
}

View File

@@ -0,0 +1,82 @@
/**
* Copyright (c) 2017 - 2020, 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);
}

View File

@@ -0,0 +1,74 @@
/**
* Copyright (c) 2017 - 2020, 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);
}

View File

@@ -0,0 +1,79 @@
/**
* Copyright (c) 2017 - 2020, 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);
}

View File

@@ -0,0 +1,74 @@
/**
* Copyright (c) 2017 - 2020, 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;
}

View File

@@ -0,0 +1,81 @@
/**
* Copyright (c) 2017 - 2020, 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

View File

@@ -0,0 +1,91 @@
/**
* Copyright (c) 2017 - 2020, 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);
}

View File

@@ -0,0 +1,81 @@
/**
* Copyright (c) 2017 - 2020, 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);
}

View File

@@ -0,0 +1,76 @@
/**
* Copyright (c) 2017 - 2020, 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);
}

View File

@@ -0,0 +1,93 @@
/**
* Copyright (c) 2017 - 2020, 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;
}

View File

@@ -0,0 +1,76 @@
/**
* Copyright (c) 2017 - 2020, 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);
}

View File

@@ -0,0 +1,85 @@
/**
* Copyright (c) 2017 - 2020, 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);
}

View File

@@ -0,0 +1,81 @@
/**
* Copyright (c) 2017 - 2020, 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);
}

View File

@@ -0,0 +1,76 @@
/**
* Copyright (c) 2017 - 2020, 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);
}

View File

@@ -0,0 +1,78 @@
/**
* Copyright (c) 2017 - 2020, 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);
}

View File

@@ -0,0 +1,79 @@
/**
* Copyright (c) 2017 - 2020, 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);
}

View File

@@ -0,0 +1,74 @@
/**
* Copyright (c) 2017 - 2020, 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);
}

View File

@@ -0,0 +1,93 @@
/**
* Copyright (c) 2017 - 2020, 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;
}