Skip to content

Commit eccb4ab

Browse files
dawidprzybylorlubos
authored andcommitted
nrf_802154: rev d37b238526ceaa99e94e197327ccb043e1316c40
This commit updates revision of the nrf_802154 component. Signed-off-by: Dawid Przybylo <[email protected]>
1 parent 60e8510 commit eccb4ab

File tree

9 files changed

+205
-27
lines changed

9 files changed

+205
-27
lines changed

nrf_802154/common/include/nrf_802154.h

+23
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,29 @@ void nrf_802154_extended_address_set(const uint8_t * p_extended_address);
348348
*/
349349
void nrf_802154_short_address_set(const uint8_t * p_short_address);
350350

351+
/**
352+
* @brief Sets the alternate short address of the device.
353+
*
354+
* The alternate short address should be used when you need to change the
355+
* device short address without loss of connectivity.
356+
* The API addresses a race condition, where a remote peer sends a frame destined
357+
* to the old device address, but this device has already changed the short address
358+
* to a new one. The alternate address should be cleared after a while, after the new
359+
* short address becomes known to the peers.
360+
*
361+
* The API is meant to be used as follows:
362+
* 1. Set the alternate short address to the current old address.
363+
* 2. Set the primary short address (@ref nrf_802154_short_address_set) to the new address.
364+
* 3. Wait until the new short address becomes known among the peers.
365+
* 4. Clear the alternate short address.
366+
*
367+
* @param[in] p_short_address Pointer to the short address (2 bytes, little-endian).
368+
* Setting this value to NULL clears the alternate address.
369+
*
370+
* This function makes a copy of the address.
371+
*/
372+
void nrf_802154_alternate_short_address_set(const uint8_t * p_short_address);
373+
351374
#if !NRF_802154_SERIALIZATION_HOST || defined(DOXYGEN)
352375
/**
353376
* @}

nrf_802154/doc/CHANGELOG.rst

+8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ Changelog
1010
All notable changes to this project are documented in this file.
1111
See also :ref:`nrf_802154_limitations` for permanent limitations.
1212

13+
Main branch - nRF 802.15.4 Radio Driver
14+
***************************************
15+
16+
Added
17+
=====
18+
19+
* Added the :c:func:`nrf_802154_alternate_short_address_set` function, which allows for setting the secondary short address that will be accepted by the frame filter. (KRKNWK-20051)
20+
1321
nRF Connect SDK v3.0.0 - nRF 802.15.4 Radio Driver
1422
**************************************************
1523

nrf_802154/driver/src/mac_features/nrf_802154_filter.c

+7-6
Original file line numberDiff line numberDiff line change
@@ -337,19 +337,20 @@ static bool dst_pan_id_check(const uint8_t * p_panid, uint8_t frame_type)
337337
*/
338338
static bool dst_short_addr_check(const uint8_t * p_dst_addr)
339339
{
340-
bool result;
341-
342340
if ((0 == memcmp(p_dst_addr, nrf_802154_pib_short_address_get(), SHORT_ADDRESS_SIZE)) ||
343341
(0 == memcmp(p_dst_addr, BROADCAST_ADDRESS, SHORT_ADDRESS_SIZE)))
344342
{
345-
result = true;
343+
return true;
346344
}
347-
else
345+
346+
const uint8_t * alternate_address = nrf_802154_pib_alternate_short_address_get();
347+
348+
if (alternate_address && (0 == memcmp(p_dst_addr, alternate_address, SHORT_ADDRESS_SIZE)))
348349
{
349-
result = false;
350+
return true;
350351
}
351352

352-
return result;
353+
return false;
353354
}
354355

355356
/**

nrf_802154/driver/src/nrf_802154.c

+5
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,11 @@ void nrf_802154_short_address_set(const uint8_t * p_short_address)
187187
nrf_802154_pib_short_address_set(p_short_address);
188188
}
189189

190+
void nrf_802154_alternate_short_address_set(const uint8_t * p_short_address)
191+
{
192+
nrf_802154_pib_alternate_short_address_set(p_short_address);
193+
}
194+
190195
void nrf_802154_init(void)
191196
{
192197
static const nrf_802154_sl_crit_sect_interface_t crit_sect_int =

nrf_802154/driver/src/nrf_802154_pib.c

+27
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747

4848
#include "nrf_802154_config.h"
4949
#include "nrf_802154_const.h"
50+
#include "nrf_802154_sl_atomics.h"
5051

5152
#define CSMACA_BE_MAXIMUM 8 ///< The maximum allowed CSMA-CA backoff exponent (BE) that results from the implementation
5253

@@ -89,6 +90,7 @@ typedef struct
8990
int8_t tx_power; ///< Transmit power.
9091
uint8_t pan_id[PAN_ID_SIZE]; ///< Pan Id of this node.
9192
uint8_t short_addr[SHORT_ADDRESS_SIZE]; ///< Short Address of this node.
93+
uint8_t alt_short_addr[SHORT_ADDRESS_SIZE]; ///< Alternate short address of this node.
9294
uint8_t extended_addr[EXTENDED_ADDRESS_SIZE]; ///< Extended Address of this node.
9395
nrf_802154_cca_cfg_t cca; ///< CCA mode and thresholds.
9496
bool promiscuous : 1; ///< Indicating if radio is in promiscuous mode.
@@ -97,6 +99,7 @@ typedef struct
9799
uint8_t channel : 5; ///< Channel on which the node receives messages.
98100
bool rx_on_when_idle; ///< Indicating if radio is in RxOnWhenIdle mode.
99101
nrf_802154_pib_coex_t coex; ///< Coex-related fields.
102+
uint8_t alt_short_addr_present; ///< Indicates if the alternate short address is configured.
100103

101104
#if NRF_802154_CSMA_CA_ENABLED
102105
nrf_802154_pib_csmaca_t csmaca; ///< CSMA-CA related fields.
@@ -212,6 +215,7 @@ void nrf_802154_pib_init(void)
212215
m_data.test_modes.csmaca_backoff = NRF_802154_TEST_MODE_CSMACA_BACKOFF_RANDOM;
213216
#endif
214217

218+
nrf_802154_sl_atomic_store_u8(&m_data.alt_short_addr_present, false);
215219
}
216220

217221
bool nrf_802154_pib_promiscuous_get(void)
@@ -304,6 +308,29 @@ void nrf_802154_pib_short_address_set(const uint8_t * p_short_address)
304308
memcpy(m_data.short_addr, p_short_address, SHORT_ADDRESS_SIZE);
305309
}
306310

311+
const uint8_t * nrf_802154_pib_alternate_short_address_get(void)
312+
{
313+
if (false == nrf_802154_sl_atomic_load_u8(&m_data.alt_short_addr_present))
314+
{
315+
return NULL;
316+
}
317+
318+
return m_data.alt_short_addr;
319+
}
320+
321+
void nrf_802154_pib_alternate_short_address_set(const uint8_t * p_short_address)
322+
{
323+
if (p_short_address)
324+
{
325+
memcpy(m_data.alt_short_addr, p_short_address, SHORT_ADDRESS_SIZE);
326+
nrf_802154_sl_atomic_store_u8(&m_data.alt_short_addr_present, true);
327+
}
328+
else
329+
{
330+
nrf_802154_sl_atomic_store_u8(&m_data.alt_short_addr_present, false);
331+
}
332+
}
333+
307334
void nrf_802154_pib_cca_cfg_set(const nrf_802154_cca_cfg_t * p_cca_cfg)
308335
{
309336
switch (p_cca_cfg->mode)

nrf_802154/driver/src/nrf_802154_pib.h

+18
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,24 @@ const uint8_t * nrf_802154_pib_short_address_get(void);
190190
*/
191191
void nrf_802154_pib_short_address_set(const uint8_t * p_short_address);
192192

193+
/**
194+
* @brief Gets the alternate short address of this device.
195+
*
196+
* @returns Pointer to the buffer containing the short address (2 bytes, little-endian)
197+
* or NULL if the alternate address is cleared.
198+
*/
199+
const uint8_t * nrf_802154_pib_alternate_short_address_get(void);
200+
201+
/**
202+
* @brief Sets the alternate short address of the device.
203+
*
204+
* @param[in] p_short_address Pointer to the short address (2 bytes, little-endian).
205+
* Setting this value to NULL clears the alternate address.
206+
*
207+
* This function makes a copy of the address.
208+
*/
209+
void nrf_802154_pib_alternate_short_address_set(const uint8_t * p_short_address);
210+
193211
/**
194212
* @brief Sets the radio CCA mode and threshold.
195213
*

nrf_802154/serialization/src/include/nrf_802154_spinel_datatypes.h

+33-21
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,11 @@ typedef enum
483483
SPINEL_PROP_VENDOR_NORDIC_NRF_802154_RECEIVE_AT_SCHEDULED_CANCEL =
484484
SPINEL_PROP_VENDOR_NORDIC_NRF_802154__BEGIN + 69,
485485

486+
/**
487+
* Vendor property for nrf_802154_alternate_short_address_set serialization.
488+
*/
489+
SPINEL_PROP_VENDOR_NORDIC_NRF_802154_ALTERNATE_SHORT_ADDRESS_SET =
490+
SPINEL_PROP_VENDOR_NORDIC_NRF_802154__BEGIN + 70,
486491
} spinel_prop_vendor_key_t;
487492

488493
/**
@@ -879,110 +884,117 @@ typedef enum
879884
*/
880885
#define SPINEL_DATATYPE_NRF_802154_SHORT_ADDRESS_SET SPINEL_DATATYPE_DATA_S
881886

887+
/**
888+
* @brief Spinel data type description for nrf_802154_short_address_set.
889+
*/
890+
#define SPINEL_DATATYPE_NRF_802154_ALTERNATE_SHORT_ADDRESS_SET\
891+
SPINEL_DATATYPE_BOOL_S /* Data valid flag */ \
892+
SPINEL_DATATYPE_DATA_S /* Alternative short address */ \
893+
882894
/**
883895
* @brief Spinel data type description for nrf_802154_extended_address_set.
884896
*/
885-
#define SPINEL_DATATYPE_NRF_802154_EXTENDED_ADDRESS_SET SPINEL_DATATYPE_DATA_S
897+
#define SPINEL_DATATYPE_NRF_802154_EXTENDED_ADDRESS_SET SPINEL_DATATYPE_DATA_S
886898

887899
/**
888900
* @brief Spinel data type description for nrf_802154_pan_coord_set.
889901
*/
890-
#define SPINEL_DATATYPE_NRF_802154_PAN_COORD_SET SPINEL_DATATYPE_BOOL_S
902+
#define SPINEL_DATATYPE_NRF_802154_PAN_COORD_SET SPINEL_DATATYPE_BOOL_S
891903

892904
/**
893905
* @brief Spinel data type description for nrf_802154_pan_coord_get result.
894906
*/
895-
#define SPINEL_DATATYPE_NRF_802154_PAN_COORD_GET_RET SPINEL_DATATYPE_BOOL_S
907+
#define SPINEL_DATATYPE_NRF_802154_PAN_COORD_GET_RET SPINEL_DATATYPE_BOOL_S
896908

897909
/**
898910
* @brief Spinel data type description for nrf_802154_pan_coord_get.
899911
*/
900-
#define SPINEL_DATATYPE_NRF_802154_PAN_COORD_GET SPINEL_DATATYPE_NULL_S
912+
#define SPINEL_DATATYPE_NRF_802154_PAN_COORD_GET SPINEL_DATATYPE_NULL_S
901913

902914
/**
903915
* @brief Spinel data type description for nrf_802154_promiscuous_set.
904916
*/
905-
#define SPINEL_DATATYPE_NRF_802154_PROMISCUOUS_SET SPINEL_DATATYPE_BOOL_S
917+
#define SPINEL_DATATYPE_NRF_802154_PROMISCUOUS_SET SPINEL_DATATYPE_BOOL_S
906918

907919
/**
908920
* @brief Spinel data type description for nrf_802154_rx_on_when_idle_set.
909921
*/
910-
#define SPINEL_DATATYPE_NRF_802154_RX_ON_WHEN_IDLE_SET SPINEL_DATATYPE_BOOL_S
922+
#define SPINEL_DATATYPE_NRF_802154_RX_ON_WHEN_IDLE_SET SPINEL_DATATYPE_BOOL_S
911923

912924
/**
913925
* @brief Spinel data type description for nrf_802154_cca.
914926
*/
915-
#define SPINEL_DATATYPE_NRF_802154_CCA SPINEL_DATATYPE_NULL_S
927+
#define SPINEL_DATATYPE_NRF_802154_CCA SPINEL_DATATYPE_NULL_S
916928

917929
/**
918930
* @brief Spinel data type description for nrf_802154_cca result.
919931
*/
920-
#define SPINEL_DATATYPE_NRF_802154_CCA_RET SPINEL_DATATYPE_BOOL_S
932+
#define SPINEL_DATATYPE_NRF_802154_CCA_RET SPINEL_DATATYPE_BOOL_S
921933

922934
/**
923935
* @brief Spinel data type description for nrf_802154_cca_done.
924936
*/
925-
#define SPINEL_DATATYPE_NRF_802154_CCA_DONE SPINEL_DATATYPE_BOOL_S
937+
#define SPINEL_DATATYPE_NRF_802154_CCA_DONE SPINEL_DATATYPE_BOOL_S
926938

927939
/**
928940
* @brief Spinel data type description for nrf_802154_cca_failed.
929941
*/
930-
#define SPINEL_DATATYPE_NRF_802154_CCA_FAILED SPINEL_DATATYPE_UINT8_S
942+
#define SPINEL_DATATYPE_NRF_802154_CCA_FAILED SPINEL_DATATYPE_UINT8_S
931943

932944
/**
933945
* @brief Spinel data type description for nrf_802154_energy_detection.
934946
*/
935-
#define SPINEL_DATATYPE_NRF_802154_ENERGY_DETECTION SPINEL_DATATYPE_UINT32_S
947+
#define SPINEL_DATATYPE_NRF_802154_ENERGY_DETECTION SPINEL_DATATYPE_UINT32_S
936948

937949
/**
938950
* @brief Spinel data type description for nrf_802154_energy_detection result.
939951
*/
940-
#define SPINEL_DATATYPE_NRF_802154_ENERGY_DETECTION_RET SPINEL_DATATYPE_BOOL_S
952+
#define SPINEL_DATATYPE_NRF_802154_ENERGY_DETECTION_RET SPINEL_DATATYPE_BOOL_S
941953

942954
/**
943955
* @brief Spinel data type description for nrf_802154_energy_detected.
944956
*/
945-
#define SPINEL_DATATYPE_NRF_802154_ENERGY_DETECTED SPINEL_DATATYPE_INT8_S
957+
#define SPINEL_DATATYPE_NRF_802154_ENERGY_DETECTED SPINEL_DATATYPE_INT8_S
946958

947959
/**
948960
* @brief Spinel data type description for nrf_802154_energy_detection_failed.
949961
*/
950-
#define SPINEL_DATATYPE_NRF_802154_ENERGY_DETECTION_FAILED SPINEL_DATATYPE_UINT8_S
962+
#define SPINEL_DATATYPE_NRF_802154_ENERGY_DETECTION_FAILED SPINEL_DATATYPE_UINT8_S
951963

952964
/**
953965
* @brief Spinel data type description for nrf_802154_continuous_carrier.
954966
*/
955-
#define SPINEL_DATATYPE_NRF_802154_CONTINUOUS_CARRIER SPINEL_DATATYPE_NULL_S
967+
#define SPINEL_DATATYPE_NRF_802154_CONTINUOUS_CARRIER SPINEL_DATATYPE_NULL_S
956968

957969
/**
958970
* @brief Spinel data type description for nrf_802154_nrf_802154_continuous_carrier result.
959971
*/
960-
#define SPINEL_DATATYPE_NRF_802154_CONTINUOUS_CARRIER_RET SPINEL_DATATYPE_BOOL_S
972+
#define SPINEL_DATATYPE_NRF_802154_CONTINUOUS_CARRIER_RET SPINEL_DATATYPE_BOOL_S
961973

962974
/**
963975
* @brief Spinel data type description for nrf_802154_modulated_carrier.
964976
*/
965-
#define SPINEL_DATATYPE_NRF_802154_MODULATED_CARRIER SPINEL_DATATYPE_DATA_S
977+
#define SPINEL_DATATYPE_NRF_802154_MODULATED_CARRIER SPINEL_DATATYPE_DATA_S
966978

967979
/**
968980
* @brief Spinel data type description for nrf_802154_nrf_802154_modulated_carrier result.
969981
*/
970-
#define SPINEL_DATATYPE_NRF_802154_MODULATED_CARRIER_RET SPINEL_DATATYPE_BOOL_S
982+
#define SPINEL_DATATYPE_NRF_802154_MODULATED_CARRIER_RET SPINEL_DATATYPE_BOOL_S
971983

972984
/**
973985
* @brief Spinel data type description for nrf_802154_tx_power_get.
974986
*/
975-
#define SPINEL_DATATYPE_NRF_802154_TX_POWER_GET SPINEL_DATATYPE_NULL_S
987+
#define SPINEL_DATATYPE_NRF_802154_TX_POWER_GET SPINEL_DATATYPE_NULL_S
976988

977989
/**
978990
* @brief Spinel data type description for nrf_802154_tx_power_get result.
979991
*/
980-
#define SPINEL_DATATYPE_NRF_802154_TX_POWER_GET_RET SPINEL_DATATYPE_INT8_S
992+
#define SPINEL_DATATYPE_NRF_802154_TX_POWER_GET_RET SPINEL_DATATYPE_INT8_S
981993

982994
/**
983995
* @brief Spinel data type description for nrf_802154_tx_power_set.
984996
*/
985-
#define SPINEL_DATATYPE_NRF_802154_TX_POWER_SET SPINEL_DATATYPE_INT8_S
997+
#define SPINEL_DATATYPE_NRF_802154_TX_POWER_SET SPINEL_DATATYPE_INT8_S
986998

987999
/**
9881000
* @brief Spinel data type description for nrf_802154_received_timestamp_raw

nrf_802154/serialization/src/nrf_802154_spinel_app.c

+37
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,43 @@ void nrf_802154_short_address_set(const uint8_t * p_short_address)
657657
return;
658658
}
659659

660+
void nrf_802154_alternate_short_address_set(const uint8_t * p_short_address)
661+
{
662+
nrf_802154_ser_err_t res;
663+
664+
bool data_valid = p_short_address != NULL;
665+
uint8_t invalid_addr[2] = {0xff, 0xff};
666+
667+
if (!data_valid)
668+
{
669+
p_short_address = invalid_addr;
670+
}
671+
672+
SERIALIZATION_ERROR_INIT(error);
673+
674+
NRF_802154_SPINEL_LOG_BANNER_CALLING();
675+
NRF_802154_SPINEL_LOG_BUFF(p_short_address, SHORT_ADDRESS_SIZE);
676+
677+
nrf_802154_spinel_response_notifier_lock_before_request(SPINEL_PROP_LAST_STATUS);
678+
679+
res = nrf_802154_spinel_send_cmd_prop_value_set(
680+
SPINEL_PROP_VENDOR_NORDIC_NRF_802154_ALTERNATE_SHORT_ADDRESS_SET,
681+
SPINEL_DATATYPE_NRF_802154_ALTERNATE_SHORT_ADDRESS_SET,
682+
data_valid,
683+
p_short_address,
684+
SHORT_ADDRESS_SIZE);
685+
686+
SERIALIZATION_ERROR_CHECK(res, error, bail);
687+
688+
res = status_ok_await(CONFIG_NRF_802154_SER_DEFAULT_RESPONSE_TIMEOUT);
689+
SERIALIZATION_ERROR_CHECK(res, error, bail);
690+
691+
bail:
692+
SERIALIZATION_ERROR_RAISE_IF_FAILED(error);
693+
694+
return;
695+
}
696+
660697
void nrf_802154_extended_address_set(const uint8_t * p_extended_address)
661698
{
662699
nrf_802154_ser_err_t res;

0 commit comments

Comments
 (0)