Skip to content

Commit 4022ad9

Browse files
author
Arto Kinnunen
authored
Add new test API for clearing Thread stack values (#1624)
Reset Thread cached values: -link configuration
1 parent ffb47a2 commit 4022ad9

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

nanostack/net_thread_test.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,19 @@ int thread_test_increment_key_sequence_counter(int8_t interface_id);
274274
*/
275275
int thread_test_key_sequence_counter_update(int8_t interface_id, uint32_t thrKeySequenceCounter);
276276

277+
/**
278+
* \brief Resets cached values from stack
279+
*
280+
Resets link configuration from cache and from NVM.
281+
*
282+
*
283+
* \param interface_id Network Interface
284+
*
285+
* \return 0, OK
286+
* \return <0 Error
287+
*/
288+
int thread_test_stack_cache_reset(int8_t interface_id);
289+
277290
/**
278291
* \brief Set new Thread key rotation value
279292
*

source/6LoWPAN/Thread/thread_test_api.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#include "6LoWPAN/Thread/thread_bootstrap.h"
4848
#include "6LoWPAN/Thread/thread_router_bootstrap.h"
4949
#include "6LoWPAN/Thread/thread_discovery.h"
50+
#include "6LoWPAN/Thread/thread_nvm_store.h"
5051
#include "6LoWPAN/Thread/thread_extension_bootstrap.h"
5152
#include "MLE/mle.h"
5253
#include "thread_meshcop_lib.h"
@@ -413,6 +414,27 @@ int thread_test_key_sequence_counter_update(int8_t interface_id, uint32_t thrKey
413414
#endif
414415
}
415416

417+
int thread_test_stack_cache_reset(int8_t interface_id)
418+
{
419+
#ifdef HAVE_THREAD
420+
protocol_interface_info_entry_t *cur;
421+
422+
cur = protocol_stack_interface_info_get_by_id(interface_id);
423+
if (!cur) {
424+
tr_warn("Invalid interface id");
425+
return -1;
426+
}
427+
428+
// Reset link information
429+
(void) thread_nvm_store_link_info_clear();
430+
431+
return 0;
432+
#else
433+
(void)interface_id;
434+
return -1;
435+
#endif
436+
}
437+
416438
int thread_test_key_rotation_update(int8_t interface_id, uint32_t thrKeyRotation)
417439
{
418440
#ifdef HAVE_THREAD

0 commit comments

Comments
 (0)