1 /* 2 * Copyright (c) 2017, Nordic Semiconductor ASA 3 * All rights reserved. 4 * 5 * SPDX-License-Identifier: BSD-3-Clause 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions are met: 9 * 10 * 1. Redistributions of source code must retain the above copyright notice, this 11 * list of conditions and the following disclaimer. 12 * 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 17 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its 18 * contributors may be used to endorse or promote products derived from this 19 * software without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 * POSSIBILITY OF SUCH DAMAGE. 32 * 33 */ 34 35 /** 36 * @brief Module that contains an ACK data generator for the nRF 802.15.4 radio driver. 37 * 38 * @note The current implementation supports setting pending bit and IEs in 802.15.4-2015 Enh-Ack frames. 39 */ 40 41 #ifndef NRF_802154_ACK_DATA_H 42 #define NRF_802154_ACK_DATA_H 43 44 #include <stdbool.h> 45 #include <stdint.h> 46 47 #include "nrf_802154_types.h" 48 #include "mac_features/nrf_802154_frame_parser.h" 49 50 /** 51 * @brief Initializes the ACK data generator module. 52 */ 53 void nrf_802154_ack_data_init(void); 54 55 /** 56 * @brief Enables or disables the ACK data generator module. 57 * 58 * @param[in] enabled True if the module is to be enabled. False otherwise. 59 */ 60 void nrf_802154_ack_data_enable(bool enabled); 61 62 /** 63 * @brief Adds an address to the ACK data list. 64 * 65 * ACK frames sent in response to frames with the source address matching any address from the ACK data list 66 * will have the appropriate data set. If the source address does not match any of the addresses in the 67 * list, the ACK frame will not have the data set. 68 * 69 * @param[in] p_addr Pointer to the address that is to be added to the list. 70 * @param[in] extended Indication if @p p_addr is an extended address or a short address. 71 * @param[in] data_type Type of data to be set. Refer to the @ref nrf_802154_ack_data_t type. 72 * @param[in] p_data Pointer to the data to be set. 73 * @param[in] data_len Length of the @p p_data buffer. 74 * 75 * @retval true Address successfully added to the list. 76 * @retval false Address not added to the list (list is full). 77 */ 78 bool nrf_802154_ack_data_for_addr_set(const uint8_t * p_addr, 79 bool extended, 80 nrf_802154_ack_data_t data_type, 81 const void * p_data, 82 uint8_t data_len); 83 84 /** 85 * @brief Removes an address from the ACK data list. 86 * 87 * ACK frames sent in response to frames with the source address matching any address from 88 * the ACK data list will have the appropriate data set. If the source address does not match 89 * any of the addresses in the list, the ACK frame will not have the data set. 90 * 91 * @param[in] p_addr Pointer to the address that is to be removed from the list. 92 * @param[in] extended Indication if @p p_addr is an extended address or a short address. 93 * @param[in] data_type Type of data that is to be cleared for @p p_addr. 94 * 95 * @retval true Address successfully removed from the list. 96 * @retval false Address not removed from the list (address is missing from the list). 97 */ 98 bool nrf_802154_ack_data_for_addr_clear(const uint8_t * p_addr, 99 bool extended, 100 nrf_802154_ack_data_t data_type); 101 102 /** 103 * @brief Removes all addresses of a given length from the ACK data list. 104 * 105 * @param[in] extended Indication if all extended addresses or all short addresses are 106 * to be removed from the list. 107 * @param[in] data_type Type of data that is to be cleared for all addresses of a given length. 108 */ 109 void nrf_802154_ack_data_reset(bool extended, nrf_802154_ack_data_t data_type); 110 111 /** 112 * @brief Select the source matching algorithm. 113 * 114 * @note This function is to be called after the driver initialization, but before the transceiver is enabled. 115 * 116 * When calling @ref nrf_802154_ack_data_pending_bit_should_be_set, one of several algorithms 117 * for source address matching will be chosen. To ensure a specific algorithm is selected, 118 * call this function before @ref nrf_802154_ack_data_pending_bit_should_be_set. 119 * 120 * @param[in] match_method Source matching method to be used. 121 */ 122 void nrf_802154_ack_data_src_addr_matching_method_set(nrf_802154_src_addr_match_t match_method); 123 124 /** 125 * @brief Checks if a pending bit is to be set in the ACK frame sent in response to a given frame. 126 * 127 * @param[in] p_frame_data Pointer to the frame parser data for which the ACK frame is being prepared. 128 * 129 * @retval true Pending bit is to be set. 130 * @retval false Pending bit is to be cleared. 131 */ 132 bool nrf_802154_ack_data_pending_bit_should_be_set( 133 const nrf_802154_frame_parser_data_t * p_frame_data); 134 135 /** 136 * @brief Gets the IE data stored in the list for the source address of the provided frame. 137 * 138 * @param[in] p_src_addr Pointer to the source address to search for in the list. 139 * @param[in] src_addr_ext If the source address is extended. 140 * @param[out] p_ie_length Length of the IE data. 141 * 142 * @returns Either pointer to the stored IE data or NULL if the IE data is not to be set. 143 */ 144 const uint8_t * nrf_802154_ack_data_ie_get(const uint8_t * p_src_addr, 145 bool src_addr_ext, 146 uint8_t * p_ie_length); 147 148 #endif // NRF_802154_ACK_DATA_H 149