Rtos API example

Embed: (wiki syntax)

« Back to documentation index

net_thread_test.h File Reference

net_thread_test.h File Reference

Thread Library Test API. More...

Go to the source code of this file.

Functions

int_fast8_t arm_nwk_6lowpan_thread_test_add_neighbour (int8_t interface_id, uint16_t neighbour_short_addr, uint_fast8_t link_margin_db, uint8_t id_sequence, const uint8_t *id_mask, const uint8_t *route_data)
 Add a static neighbour.
int8_t thread_reed_set_advertisement_interval (int8_t interface_id, uint16_t advertisement_interval, uint16_t jitter_interval)
 API to set reed advertisement interval.
int_fast8_t arm_nwk_6lowpan_thread_test_remove_neighbour (int8_t interface_id, uint16_t neighbour_short_addr)
 Remove a static neighbour.
void arm_nwk_6lowpan_thread_test_print_routing_database (int8_t interface_id)
 Print routing database.
int thread_test_max_accepted_router_id_limit_set (int8_t interface_id, uint8_t maxRouterLimit)
 Thread Leader max router ID limit set.
int8_t thread_routing_set_network_id_timeout (int8_t interface_id, uint16_t network_id_timeout)
 Set Thread network ID timeout.
int8_t thread_routing_get_network_id_timeout (int8_t interface_id, uint16_t *network_id_timeout)
 Get Thread network ID timeout.
int thread_test_print_network_data (int8_t interface_id)
 Print Thread network data.
int thread_test_set_context_id_reuse_timeout (int8_t interface_id, uint32_t timeout)
 Thread Leader Context ID reuse timeout set.
int thread_test_remove_router_by_id (int8_t interface_id, uint8_t routerId)
 Leader of Thread network can kick Router out from Network.
int thread_test_router_downgrade (int8_t interface_id)
 Start router downgrade process.
int thread_test_security_material_set (int8_t interface_id, bool enableSecurity, uint8_t *thrMasterKey, uint32_t thrKeySequenceCounter, uint32_t thrKeyRotation)
 Set Thread Security Material.
int thread_test_version_set (int8_t interface_id, uint8_t version)
 Set Thread version number.
int thread_test_router_selection_jitter_set (int8_t interface_id, uint32_t jitter)
 Set Thread router selection jitter.
int thread_test_min_delay_timer_set (int8_t interface_id, uint32_t delay_timer_value)
 Sets the thread MIN_DELAY_TIMER default value.
int thread_test_increment_key_sequence_counter (int8_t interface_id)
 Increment Thread key sequence counter.
int thread_test_key_sequence_counter_update (int8_t interface_id, uint32_t thrKeySequenceCounter)
 Set new Thread key sequence counter.
int thread_test_key_rotation_update (int8_t interface_id, uint32_t thrKeyRotation)
 Set new Thread key rotation value.
int thread_test_router_select_threshold_values_set (int8_t interface_id, uint8_t upgradeThreshold, uint8_t downgradeThreshold)
 Thread router select threshold values set.
int thread_test_panid_query_send (int8_t interface_id, uint8_t *address_ptr, uint16_t session_id, uint16_t panid, uint8_t channel_page, uint8_t *mask_ptr)
 Send PAN ID query message to destination.
int thread_test_energy_scan_send (int8_t interface_id, uint8_t *address_ptr, uint16_t session_id, uint8_t channel_page, uint8_t *mask_ptr, uint16_t period, uint8_t count, uint16_t duration)
 Send energy scan message to destination.
int thread_test_announce_ntf_send (int8_t interface_id, uint8_t *address_ptr, uint32_t channel, uint16_t panid, uint64_t timestamp)
 Send announcement message.
int thread_test_announce_begin_send (int8_t interface_id, uint8_t *address_ptr, uint16_t session_id, uint8_t channel_page, uint8_t *mask_ptr, uint16_t period, uint8_t count)
 Send energy scan message to destination.
int thread_test_partition_info_get (int8_t interface_id, uint32_t *partition_id, uint8_t *weighting, uint8_t *data_version, uint8_t *stable_data_version, uint8_t *leader_id)
 Get partition info.
int thread_test_partition_info_set (int8_t interface_id, uint32_t partition_id)
 Set next partition ID when we next time partition.
int8_t thread_test_thread_information_get (int8_t interface_id, uint16_t *short_addr, uint8_t *router_count, bool *network_stable)
 Get thread information.
int8_t thread_test_child_count_get (int8_t interface_id)
 Get child count.
int8_t thread_test_child_info_get (int8_t interface_id, uint8_t index, uint16_t *short_addr, bool *sleepy, uint8_t *mac64, uint8_t *margin)
 Get child information.
int8_t thread_test_neighbour_info_get (int8_t interface_id, uint8_t index, uint16_t *short_addr, uint8_t *mac64, uint8_t *margin)
 Get neighbour information.
int thread_test_diagnostic_command_send (int8_t interface_id, uint8_t *address_ptr, const char *uri_ptr, uint8_t request_length, uint8_t *request_ptr, response_cb *resp_cb)
 Send diagnostic command DEPRECATED.
int thread_test_coap_request_send (int8_t interface_id, uint8_t *address_ptr, uint16_t port, uint8_t msg_type, uint8_t msg_code, uint16_t content_format, const char *uri_ptr, uint8_t *request_ptr, uint8_t request_length, coap_response_cb *resp_cb)
 Send diagnostic request.
int8_t thread_test_initial_slaac_iid_set (int8_t interface_id, uint8_t *iid)
 Set initial SLAAC iid.
int8_t thread_test_router_id_request_send (int8_t interface_id, uint8_t status)
 Send router ID request.
int8_t thread_test_joiner_router_joiner_port_set (uint16_t port)
 Set joiner port to joiner router device.
int8_t thread_test_router_address_set (int8_t interface_id, uint16_t router_addr)
 set a router address to be requested.

Detailed Description

Thread Library Test API.

Warning:
NOTICE! This is test API must not be used externally.
This file is not part of the version number control and can change any time.

Definition in file net_thread_test.h.


Function Documentation

int_fast8_t arm_nwk_6lowpan_thread_test_add_neighbour ( int8_t  interface_id,
uint16_t  neighbour_short_addr,
uint_fast8_t  link_margin_db,
uint8_t  id_sequence,
const uint8_t *  id_mask,
const uint8_t *  route_data 
)

Add a static neighbour.

Test API: Add a neighbour. Adds, or updates, a non-expiring neighbour to the Thread Link Set, and updates the Route Set accordingly. Basically equivalent to receiving an MLE advertisement with a Route TLV, except it doesn't expire.

See draft-kelsey-thread-routing-00 for more info on data format.

Parameters:
interface_idInterface to modify
neighbour_addrNeighbour short address (must be a router address)
link_margin_dbNotional link margin for reception from this neighbour.
id_sequenceSequence number for id_mask
id_maskBit mask of router IDs
route_dataOne octet per set bit in id_mask
Returns:
0 Success
<0 Failure
void arm_nwk_6lowpan_thread_test_print_routing_database ( int8_t  interface_id )

Print routing database.

Test API: Dump the routing data base (Router ID Set, Link Set and Route Set) to the debug channel.

Parameters:
interface_idInterface to interrogate
int_fast8_t arm_nwk_6lowpan_thread_test_remove_neighbour ( int8_t  interface_id,
uint16_t  neighbour_short_addr 
)

Remove a static neighbour.

Test API: Remove a neighbour. Remove a neighbour from the Thread Link Set (whether added through arm_nwk_6lowpan_thread_test_add_neighbour, or automatically through MLE).

Parameters:
interface_idInterface to modify
neighbour_addrNeighbour short address (must be a router address)
Returns:
0 Success
-1 Not an existing neighbour
<-1 Other errors
int8_t thread_reed_set_advertisement_interval ( int8_t  interface_id,
uint16_t  advertisement_interval,
uint16_t  jitter_interval 
)

API to set reed advertisement interval.

Parameters:
interface_idInterface to modify
advertisement_intervalInterval between advertisements to be set
jitter_intervalMaximum value of random jitter interval to be added to advertisement_interval
Returns:
0 Success
< 0 Other errors
int8_t thread_routing_get_network_id_timeout ( int8_t  interface_id,
uint16_t *  network_id_timeout 
)

Get Thread network ID timeout.

Parameters:
interface_idInterface to modify
network_id_timeoutpointer, where current network id timeout will be saved as seconds
Returns:
0 Success
-1 Invalid interface id
-2 Thread not active
-3 invalid pointer
int8_t thread_routing_set_network_id_timeout ( int8_t  interface_id,
uint16_t  network_id_timeout 
)

Set Thread network ID timeout.

Parameters:
interface_idInterface to modify
network_id_timeoutnetwork timeout as seconds
Returns:
0 Success
-1 Invalid interface id
-2 Thread not active
-3 invalid timeout value
int thread_test_announce_begin_send ( int8_t  interface_id,
uint8_t *  address_ptr,
uint16_t  session_id,
uint8_t  channel_page,
uint8_t *  mask_ptr,
uint16_t  period,
uint8_t  count 
)

Send energy scan message to destination.

Parameters:
interface_idNetwork Interface
Returns:
0, Set OK
<0 Set Fail
int thread_test_announce_ntf_send ( int8_t  interface_id,
uint8_t *  address_ptr,
uint32_t  channel,
uint16_t  panid,
uint64_t  timestamp 
)

Send announcement message.

Parameters:
interface_idNetwork Interface
channelhigh uint16 is the channel page, lower part is the channel number on that page
Returns:
0, Set OK
<0 Set Fail
int8_t thread_test_child_count_get ( int8_t  interface_id )

Get child count.

Parameters:
interface_idNetwork Interface
Returns:
0, Set OK
<0 Set Fail
int8_t thread_test_child_info_get ( int8_t  interface_id,
uint8_t  index,
uint16_t *  short_addr,
bool *  sleepy,
uint8_t *  mac64,
uint8_t *  margin 
)

Get child information.

get information for index child. if found returns 0 with correct information.

Parameters:
interface_idNetwork Interface
Returns:
0, OK
<0 Fail no child with this index found
int thread_test_coap_request_send ( int8_t  interface_id,
uint8_t *  address_ptr,
uint16_t  port,
uint8_t  msg_type,
uint8_t  msg_code,
uint16_t  content_format,
const char *  uri_ptr,
uint8_t *  request_ptr,
uint8_t  request_length,
coap_response_cb *  resp_cb 
)

Send diagnostic request.

Parameters:
interface_idNetwork Interface
address_ptrAddress to which the command is sent
msg_typeUri for the command
msg_codeUri for the command
uri_ptrUri for the command
request_lengthThe length of the request
request_ptrPointer to the beginning of the request contents
resp_cbPointer to callback function that is called after the reply for the command is obtained
Returns:
0, Command send OK
<0 Command send Fail
int thread_test_diagnostic_command_send ( int8_t  interface_id,
uint8_t *  address_ptr,
const char *  uri_ptr,
uint8_t  request_length,
uint8_t *  request_ptr,
response_cb *  resp_cb 
)

Send diagnostic command DEPRECATED.

Parameters:
interface_idNetwork Interface
address_ptrAddress to which the command is sent
uri_ptrUri for the command
request_lengthThe length of the request
request_ptrPointer to the beginning of the request contents
resp_cbPointer to callback function that is called after the reply for the command is obtained
Returns:
0, Command send OK
<0 Command send Fail
int thread_test_energy_scan_send ( int8_t  interface_id,
uint8_t *  address_ptr,
uint16_t  session_id,
uint8_t  channel_page,
uint8_t *  mask_ptr,
uint16_t  period,
uint8_t  count,
uint16_t  duration 
)

Send energy scan message to destination.

Parameters:
interface_idNetwork Interface
Returns:
0, Set OK
<0 Set Fail
int thread_test_increment_key_sequence_counter ( int8_t  interface_id )

Increment Thread key sequence counter.

Parameters:
interface_idNetwork Interface
Returns:
0, OK
<0 Error
int8_t thread_test_initial_slaac_iid_set ( int8_t  interface_id,
uint8_t *  iid 
)

Set initial SLAAC iid.

Parameters:
interface_idNetwork Interface
iidInterface identifier pointer must be 8 bytes long buffer. can be NULL to disable.
Returns:
0, Command OK
<0 Command Fail
int8_t thread_test_joiner_router_joiner_port_set ( uint16_t  port )

Set joiner port to joiner router device.

If port == 0, then default port is used.

Parameters:
iidJoiner port.
Returns:
0, Command OK
<0 Command Fail
int thread_test_key_rotation_update ( int8_t  interface_id,
uint32_t  thrKeyRotation 
)

Set new Thread key rotation value.

Parameters:
interface_idNetwork interface ID
thrKeyRotationKey rotation value in seconds
Returns:
0, OK
<0 Error
int thread_test_key_sequence_counter_update ( int8_t  interface_id,
uint32_t  thrKeySequenceCounter 
)

Set new Thread key sequence counter.

Call define new key and next key same time

Parameters:
interface_idNetwork Interface
thrKeySequenceCounterthis need to be bigger than current sequence
Returns:
0, OK
<0 Error
int thread_test_max_accepted_router_id_limit_set ( int8_t  interface_id,
uint8_t  maxRouterLimit 
)

Thread Leader max router ID limit set.

This function should use just for test purpose Thread define this by default to 32

Parameters:
interface_idNetwork Interface
maxRouterLimitMin Accepted value is 1 and max 32

return 0, Set OK return <0 Set Fail

int thread_test_min_delay_timer_set ( int8_t  interface_id,
uint32_t  delay_timer_value 
)

Sets the thread MIN_DELAY_TIMER default value.

Parameters:
interface_idNetwork Interface
delay_timer_valuedelay timer value in seconds used in leader
Returns:
0, OK
<0 Error
int8_t thread_test_neighbour_info_get ( int8_t  interface_id,
uint8_t  index,
uint16_t *  short_addr,
uint8_t *  mac64,
uint8_t *  margin 
)

Get neighbour information.

Parameters:
interface_idNetwork Interface
Returns:
0, Set OK
<0 Set Fail
int thread_test_panid_query_send ( int8_t  interface_id,
uint8_t *  address_ptr,
uint16_t  session_id,
uint16_t  panid,
uint8_t  channel_page,
uint8_t *  mask_ptr 
)

Send PAN ID query message to destination.

Parameters:
interface_idNetwork Interface
Returns:
0, Set OK
<0 Set Fail
int thread_test_partition_info_get ( int8_t  interface_id,
uint32_t *  partition_id,
uint8_t *  weighting,
uint8_t *  data_version,
uint8_t *  stable_data_version,
uint8_t *  leader_id 
)

Get partition info.

Parameters:
interface_idNetwork Interface
partition_idCurrent partition id can be NULL if not needed.
weightingCurrent weighting can be NULL if not needed.
data_versionCurrent data version can be NULL if not needed.
stable_data_versionCurrent stable data version can be NULL if not needed.
leader_idCurrent leader id can be NULL if not needed.
Returns:
0, Set OK
<0 Set Fail
int thread_test_partition_info_set ( int8_t  interface_id,
uint32_t  partition_id 
)

Set next partition ID when we next time partition.

This is used to control specific behaviour in tests.

Parameters:
interface_idNetwork Interface
Returns:
0, Set OK
<0 Set Fail
int thread_test_print_network_data ( int8_t  interface_id )

Print Thread network data.

Parameters:
interface_idNetwork Interface
Returns:
0, OK
<0 Not OK
int thread_test_remove_router_by_id ( int8_t  interface_id,
uint8_t  routerId 
)

Leader of Thread network can kick Router out from Network.

Parameters:
interface_idNetwork Interface
routerIdRoutter id of router that is kicked
Returns:
0, Remove OK
<0 Remove fail
int8_t thread_test_router_address_set ( int8_t  interface_id,
uint16_t  router_addr 
)

set a router address to be requested.

For a router, this address is sent address solicit request to leader and for leader this is the router address

Parameters:
interface_idNetwork Interface
router_addrAddress requested
Returns:
0, Command OK
<0 Command Fail
int thread_test_router_downgrade ( int8_t  interface_id )

Start router downgrade process.

Parameters:
interface_idNetwork Interface
Returns:
0, downgrade started
<0 fail
int8_t thread_test_router_id_request_send ( int8_t  interface_id,
uint8_t  status 
)

Send router ID request.

Parameters:
interface_idNetwork Interface
statusValue of router ID request status TLV
Returns:
0, Command OK
<0 Command Fail
int thread_test_router_select_threshold_values_set ( int8_t  interface_id,
uint8_t  upgradeThreshold,
uint8_t  downgradeThreshold 
)

Thread router select threshold values set.

Parameters:
interface_idNetwork Interface
upgradeThresholdSet REED up grade to router threshold
downgradeThresholdSet Router down grade to REED threshold
Returns:
0, Set OK
<0 Set Fail
int thread_test_router_selection_jitter_set ( int8_t  interface_id,
uint32_t  jitter 
)

Set Thread router selection jitter.

Parameters:
interface_idNetwork Interface
valuemust be over 1 default is 120
Returns:
0, OK
<0 Error
int thread_test_security_material_set ( int8_t  interface_id,
bool  enableSecurity,
uint8_t *  thrMasterKey,
uint32_t  thrKeySequenceCounter,
uint32_t  thrKeyRotation 
)

Set Thread Security Material.

Terms are defined in Thread security specification

Parameters:
interface_idNetwork Interface
enableSecurityBoolean for enable security or disable
thrMasterKeyMaster Key material which will be used for generating new key
thrKeySequenceCounterPeriodic counter used to generate new MAC and MLE keys
thrKeyRotationUpdate period (in seconds) for thrKeySequenceCounter
Returns:
0, ADD OK
<0 Add Not OK
int thread_test_set_context_id_reuse_timeout ( int8_t  interface_id,
uint32_t  timeout 
)

Thread Leader Context ID reuse timeout set.

This function should be used to change default 48 hours to shorter one

Parameters:
interface_idNetwork Interface
timeoutMin Accepted value is 60 seconds and max 48 hours (48*3600)
Returns:
0, Set OK
<0 Set Fail
int8_t thread_test_thread_information_get ( int8_t  interface_id,
uint16_t *  short_addr,
uint8_t *  router_count,
bool *  network_stable 
)

Get thread information.

Parameters:
interface_idNetwork Interface
short_addrown short address
router_countamount of active routers in network
network_stablestable network achieved no upgrade or downgrade pending
Returns:
0, Set OK
<0 Set Fail
int thread_test_version_set ( int8_t  interface_id,
uint8_t  version 
)

Set Thread version number.

Parameters:
interface_idNetwork Interface
version"1 == Thread version 1.0" or "2 == Thread version 1.1"
Returns:
0, OK
<0 Error