Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nrf_802154: rev 559b3d38a1f490371ebac659959d2eebda078b58 #221

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions drivers/nrf_802154/common/include/nrf_802154.h
Original file line number Diff line number Diff line change
Expand Up @@ -1594,6 +1594,24 @@ void nrf_802154_csl_writer_anchor_time_set(uint64_t anchor_time);
*/
void nrf_802154_rx_on_when_idle_set(bool rx_on_when_idle);

/**
* @brief Sets the value of CST period to inject into the CST information element.
*
* @param[in] period CST period value.
*/
void nrf_802154_cst_writer_period_set(uint16_t period);

/**
* @brief Sets the anchor time based on which the next CST window time and the CST phase is calculated.
*
* This function sets an anchor time which is a time of a CST window, based which on the times of future CST windows are
* calculated. It is assumed that all other CST windows occur at time @c anchor_time + @c n * @c cst_period where @c n is
* an integer. Note that the anchor time can be both in the past and in the future.
*
* @param[in] anchor_time Anchor time value.
*/
void nrf_802154_cst_writer_anchor_time_set(uint64_t anchor_time);

/**
* @}
* @defgroup nrf_802154_test_modes Test modes
Expand Down
2 changes: 1 addition & 1 deletion drivers/nrf_802154/common/include/nrf_802154_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ extern "C" {
*
*/
#ifndef NRF_802154_MAX_ACK_IE_SIZE
#define NRF_802154_MAX_ACK_IE_SIZE 8
#define NRF_802154_MAX_ACK_IE_SIZE 16
#endif

/**
Expand Down
2 changes: 2 additions & 0 deletions drivers/nrf_802154/common/include/nrf_802154_const.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@
#define IE_VENDOR_THREAD_MARGIN_FLOOR 0 ///< Thread Vendor-specific ACK Probing margin floor value used for scaling
#define IE_VENDOR_THREAD_RSSI_CEIL 0 ///< Thread Vendor-specific ACK Probing RSSI ceil value used for scaling
#define IE_VENDOR_THREAD_MARGIN_CEIL 130 ///< Thread Vendor-specific ACK Probing margin ceil value used for scaling
#define IE_VENDOR_THREAD_CST_ID 0x02 ///< Thread Vendor-specific CST IE subtype ID
#define IE_VENDOR_THREAD_CST_SIZE 8 ///< Thread Vendor-specific CST IE size
#define IE_CSL_SYMBOLS_PER_UNIT 10 ///< Number of symbols per phase/period unit
#define IE_CSL_PERIOD_MAX 0xffff ///< Maximum CSL IE phase/period value
#define IE_CSL_SIZE_MIN 4 ///< Minimal size of the CSL IE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,14 +481,28 @@ static bool addr_add(const uint8_t * p_addr,
return false;
}

memmove(p_addr_array + entry_size * (location + 1),
p_addr_array + entry_size * (location),
uint8_t * p_entry_at_location = p_addr_array + entry_size * location;

memmove(p_entry_at_location + entry_size,
p_entry_at_location,
(*p_addr_array_len - location) * entry_size);

memcpy(p_addr_array + entry_size * location,
memcpy(p_entry_at_location,
p_addr,
extended ? EXTENDED_ADDRESS_SIZE : SHORT_ADDRESS_SIZE);

if (data_type == NRF_802154_ACK_DATA_IE)
{
/* The content of ie_data_t in the structure indexed by location
* is uninitialized (can have old content). Let's initialize it. */
ie_data_t * p_ie_data = extended ?
&(((ack_ext_ie_data_t *)p_entry_at_location)->ie_data) :
&(((ack_short_ie_data_t *)p_entry_at_location)->ie_data);

p_ie_data->len = 0U;
/* p_ie_data->p_data does not need initialization when len is set to zero. */
}

(*p_addr_array_len)++;

return true;
Expand Down Expand Up @@ -562,18 +576,60 @@ static bool addr_remove(uint32_t location, nrf_802154_ack_data_t data_type, bool
return true;
}

static void ie_data_add(uint32_t location, bool extended, const uint8_t * p_data, uint8_t data_len)
/**
* @brief Replace or append an Information Element to the ACK data.
*
* If the target ACK data already contains an Information Element with the same
* ID as the new Information Element, the existing IE is replaced with the new
* one. Otherwise, the new IE is appended to the target ACK data.
*
* @param[in] location Index of the ACK data buffer to be modified.
* @param[in] extended Indication whether the ACK data buffer for
* an extended or a short address is to be modified.
* @param[in] p_data New Information Element data.
* @param[in] data_len New Information Element data length.
*
* @retval true The new Information Element has been added successfully.
* @retval false The new Information Element has not fitted in the buffer.
*/
static bool ie_data_set(uint32_t location, bool extended, const uint8_t * p_data, uint8_t data_len)
{
if (extended)
ie_data_t * ie_data =
extended ? &m_ie.ext_data[location].ie_data : &m_ie.short_data[location].ie_data;

const uint8_t new_ie_id = nrf_802154_frame_parser_ie_id_get(p_data);

for (const uint8_t * ie = nrf_802154_frame_parser_header_ie_iterator_begin(ie_data->p_data);
nrf_802154_frame_parser_ie_iterator_end(ie, ie_data->p_data + ie_data->len) == false;
ie = nrf_802154_frame_parser_ie_iterator_next(ie))
{
memcpy(m_ie.ext_data[location].ie_data.p_data, p_data, data_len);
m_ie.ext_data[location].ie_data.len = data_len;
if (nrf_802154_frame_parser_ie_id_get(ie) != new_ie_id)
{
continue;
}

if (IE_DATA_OFFSET + nrf_802154_frame_parser_ie_length_get(ie) != data_len)
{
/* Overwriting an existing IE with a different size is not supported. */
return false;
}

memcpy((uint8_t *)ie, p_data, data_len);
return true;
}
else

/* Append IE data with the new IE. */

if (ie_data->len + data_len > NRF_802154_MAX_ACK_IE_SIZE)
{
memcpy(m_ie.short_data[location].ie_data.p_data, p_data, data_len);
m_ie.short_data[location].ie_data.len = data_len;
/* No space to fit it the new IE. */
return false;
}

memcpy(ie_data->p_data + ie_data->len, p_data, data_len);
ie_data->len += data_len;

return true;
}

/***************************************************************************************************
Expand Down Expand Up @@ -607,7 +663,7 @@ bool nrf_802154_ack_data_for_addr_set(const uint8_t * p_addr,
{
if (data_type == NRF_802154_ACK_DATA_IE)
{
ie_data_add(location, extended, p_data, data_len);
return ie_data_set(location, extended, p_data, data_len);
}

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,14 @@ static inline bool nrf_802154_frame_parser_panid_compression_is_set(
static inline bool nrf_802154_frame_parser_ar_bit_is_set(
const nrf_802154_frame_parser_data_t * p_parser_data)
{
return (p_parser_data->p_frame[ACK_REQUEST_OFFSET] & ACK_REQUEST_BIT) ? true : false;
if ((p_parser_data->p_frame[FRAME_TYPE_OFFSET] & FRAME_TYPE_MASK) == FRAME_TYPE_MULTIPURPOSE)
{
return false;
}
else
{
return (p_parser_data->p_frame[ACK_REQUEST_OFFSET] & ACK_REQUEST_BIT) ? true : false;
}
}

/**
Expand Down
Loading