Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
net_thread_test.h
00001 /* 00002 * Copyright (c) 2014-2015 ARM Limited. All rights reserved. 00003 * 00004 * SPDX-License-Identifier: LicenseRef-PBL 00005 * 00006 * Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * https://www.mbed.com/licenses/PBL-1.0 00010 * 00011 * See the License for the specific language governing permissions and limitations under the License. 00012 * 00013 */ 00014 /** 00015 * \file net_thread_test.h 00016 * \brief Thread Library Test API. 00017 * 00018 * \warning NOTICE! This is test API must not be used externally. 00019 * 00020 * \warning This file is not part of the version number control and can change any time. 00021 * 00022 */ 00023 00024 #ifndef NET_THREAD_TEST_H_ 00025 #define NET_THREAD_TEST_H_ 00026 00027 #ifdef __cplusplus 00028 extern "C" { 00029 #endif 00030 00031 #include "ns_types.h" 00032 00033 #define thread_test_router_upgrade(iface) thread_test_router_id_request_send(iface, 2) // THREAD_COAP_STATUS_TLV_TOO_FEW_ROUTERS 00034 /** 00035 * \brief Add a static neighbour 00036 * 00037 * Test API: Add a neighbour. Adds, or updates, a non-expiring neighbour to the 00038 * Thread Link Set, and updates the Route Set accordingly. Basically equivalent 00039 * to receiving an MLE advertisement with a Route TLV, except it doesn't expire. 00040 * 00041 * See draft-kelsey-thread-routing-00 for more info on data format. 00042 * 00043 * \param interface_id Interface to modify 00044 * \param neighbour_addr Neighbour short address (must be a router address) 00045 * \param link_margin_db Notional link margin for reception from this neighbour. 00046 * \param id_sequence Sequence number for id_mask 00047 * \param id_mask Bit mask of router IDs 00048 * \param route_data One octet per set bit in id_mask 00049 * 00050 * \return 0 Success 00051 * \return <0 Failure 00052 */ 00053 int_fast8_t arm_nwk_6lowpan_thread_test_add_neighbour( 00054 int8_t interface_id, 00055 uint16_t neighbour_short_addr, 00056 uint_fast8_t link_margin_db, 00057 uint8_t id_sequence, 00058 const uint8_t *id_mask, 00059 const uint8_t *route_data); 00060 00061 /** 00062 * \brief API to set reed advertisement interval 00063 * \param interface_id Interface to modify 00064 * \param advertisement_interval Interval between advertisements to be set 00065 * \param jitter_interval Maximum value of random jitter interval to be added to advertisement_interval 00066 * \return 0 Success 00067 * \return < 0 Other errors 00068 */ 00069 int8_t thread_reed_set_advertisement_interval(int8_t interface_id, uint16_t advertisement_interval, uint16_t jitter_interval); 00070 00071 /** 00072 * \brief Remove a static neighbour 00073 * 00074 * Test API: Remove a neighbour. Remove a neighbour from the Thread Link Set 00075 * (whether added through arm_nwk_6lowpan_thread_test_add_neighbour, or 00076 * automatically through MLE). 00077 * 00078 * \param interface_id Interface to modify 00079 * \param neighbour_addr Neighbour short address (must be a router address) 00080 * 00081 * \return 0 Success 00082 * \return -1 Not an existing neighbour 00083 * \return <-1 Other errors 00084 */ 00085 int_fast8_t arm_nwk_6lowpan_thread_test_remove_neighbour( 00086 int8_t interface_id, 00087 uint16_t neighbour_short_addr); 00088 00089 /** 00090 * \brief Print routing database 00091 * 00092 * Test API: Dump the routing data base (Router ID Set, Link Set and Route 00093 * Set) to the debug channel. 00094 * 00095 * \param interface_id Interface to interrogate 00096 */ 00097 void arm_nwk_6lowpan_thread_test_print_routing_database(int8_t interface_id); 00098 00099 00100 /** 00101 * \brief Thread Leader max router ID limit set 00102 * 00103 * This function should use just for test purpose Thread define this by default to 32 00104 * 00105 * \param interface_id Network Interface 00106 * \param maxRouterLimit Min Accepted value is 1 and max 32 00107 * 00108 * return 0, Set OK 00109 * return <0 Set Fail 00110 */ 00111 int thread_test_max_accepted_router_id_limit_set( 00112 int8_t interface_id, 00113 uint8_t maxRouterLimit); 00114 00115 /** 00116 * \brief Set Thread network ID timeout 00117 * 00118 * \param interface_id Interface to modify 00119 * \param network_id_timeout network timeout as seconds 00120 * 00121 * \return 0 Success 00122 * \return -1 Invalid interface id 00123 * \return -2 Thread not active 00124 * \return -3 invalid timeout value 00125 */ 00126 int8_t thread_routing_set_network_id_timeout(int8_t interface_id, uint16_t network_id_timeout); 00127 00128 /** 00129 * \brief Get Thread network ID timeout 00130 * 00131 * \param interface_id Interface to modify 00132 * \param network_id_timeout pointer, where current network id timeout will be saved as seconds 00133 * 00134 * \return 0 Success 00135 * \return -1 Invalid interface id 00136 * \return -2 Thread not active 00137 * \return -3 invalid pointer 00138 */ 00139 int8_t thread_routing_get_network_id_timeout(int8_t interface_id, uint16_t *network_id_timeout); 00140 00141 /** 00142 * \brief Print Thread network data 00143 * 00144 * \param interface_id Network Interface 00145 * 00146 * \return 0, OK 00147 * \return <0 Not OK 00148 */ 00149 00150 int thread_test_print_network_data(int8_t interface_id); 00151 00152 /** 00153 * \brief Thread Leader Context ID reuse timeout set 00154 * 00155 * This function should be used to change default 48 hours to shorter one 00156 * 00157 * \param interface_id Network Interface 00158 * \param timeout Min Accepted value is 60 seconds and max 48 hours (48*3600) 00159 * 00160 * \return 0, Set OK 00161 * \return <0 Set Fail 00162 */ 00163 int thread_test_set_context_id_reuse_timeout( 00164 int8_t interface_id, 00165 uint32_t timeout); 00166 00167 /** 00168 * \brief Leader of Thread network can kick Router out from Network. 00169 * 00170 * \param interface_id Network Interface 00171 * \param routerId Routter id of router that is kicked 00172 * 00173 * \return 0, Remove OK 00174 * \return <0 Remove fail 00175 */ 00176 int thread_test_remove_router_by_id(int8_t interface_id, uint8_t routerId); 00177 00178 /** 00179 * \brief Start router downgrade process. 00180 * 00181 * \param interface_id Network Interface 00182 * 00183 * \return 0, downgrade started 00184 * \return <0 fail 00185 */ 00186 int thread_test_router_downgrade(int8_t interface_id); 00187 00188 /** 00189 * \brief Set Thread Security Material. Terms are defined in Thread security specification 00190 * 00191 * \param interface_id Network Interface 00192 * \param enableSecurity Boolean for enable security or disable 00193 * \param thrMasterKey Master Key material which will be used for generating new key 00194 * \param thrKeySequenceCounter Periodic counter used to generate new MAC and MLE keys 00195 * \param thrKeyRotation Update period (in seconds) for thrKeySequenceCounter 00196 * 00197 * \return 0, ADD OK 00198 * \return <0 Add Not OK 00199 */ 00200 int thread_test_security_material_set(int8_t interface_id, bool enableSecurity, uint8_t *thrMasterKey, uint32_t thrKeySequenceCounter, uint32_t thrKeyRotation); 00201 00202 /** 00203 * \brief Set Thread version number. 00204 * 00205 * \param interface_id Network Interface 00206 * \param version "1 == Thread version 1.0" or "2 == Thread version 1.1" 00207 * 00208 * \return 0, OK 00209 * \return <0 Error 00210 */ 00211 int thread_test_version_set(int8_t interface_id, uint8_t version); 00212 /** 00213 * \brief Set Thread router selection jitter. 00214 * 00215 * \param interface_id Network Interface 00216 * \param value must be over 1 default is 120 00217 * 00218 * \return 0, OK 00219 * \return <0 Error 00220 */ 00221 int thread_test_router_selection_jitter_set(int8_t interface_id, uint32_t jitter); 00222 00223 /** 00224 * \brief Increment Thread key sequence counter 00225 * 00226 * \param interface_id Network Interface 00227 * 00228 * \return 0, OK 00229 * \return <0 Error 00230 */ 00231 int thread_test_increment_key_sequence_counter(int8_t interface_id); 00232 00233 /** 00234 * \brief Set new Thread key sequence counter 00235 * 00236 * Call define new key and next key same time 00237 * 00238 * \param interface_id Network Interface 00239 * \param thrKeySequenceCounter this need to be bigger than current sequence 00240 * 00241 * \return 0, OK 00242 * \return <0 Error 00243 */ 00244 int thread_test_key_sequence_counter_update(int8_t interface_id, uint32_t thrKeySequenceCounter); 00245 00246 /** 00247 * \brief Thread router select threshold values set 00248 * 00249 * \param interface_id Network Interface 00250 * \param upgradeThreshold Set REED up grade to router threshold 00251 * \param downgradeThreshold Set Router down grade to REED threshold 00252 * 00253 * \return 0, Set OK 00254 * \return <0 Set Fail 00255 */ 00256 int thread_test_router_select_threshold_values_set( 00257 int8_t interface_id, 00258 uint8_t upgradeThreshold, 00259 uint8_t downgradeThreshold); 00260 00261 /** 00262 * \brief Send PAN ID query message to destination 00263 * 00264 * \param interface_id Network Interface 00265 * 00266 * \return 0, Set OK 00267 * \return <0 Set Fail 00268 */ 00269 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); 00270 00271 /** 00272 * \brief Send energy scan message to destination 00273 * 00274 * \param interface_id Network Interface 00275 * 00276 * \return 0, Set OK 00277 * \return <0 Set Fail 00278 */ 00279 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); 00280 00281 /** 00282 * \brief Send announcement message 00283 * 00284 * \param interface_id Network Interface 00285 * \param channel high uint16 is the channel page, lower part is the channel number on that page 00286 * 00287 * \return 0, Set OK 00288 * \return <0 Set Fail 00289 */ 00290 int thread_test_announce_ntf_send(int8_t interface_id, uint8_t *address_ptr, uint32_t channel, uint16_t panid, uint64_t timestamp); 00291 00292 /** 00293 * \brief Send energy scan message to destination 00294 * 00295 * \param interface_id Network Interface 00296 * 00297 * \return 0, Set OK 00298 * \return <0 Set Fail 00299 */ 00300 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); 00301 00302 /** 00303 * \brief Get partition info 00304 * 00305 * \param interface_id Network Interface 00306 * \param partition_id Current partition id can be NULL if not needed. 00307 * \param weighting Current weighting can be NULL if not needed. 00308 * \param data_version Current data version can be NULL if not needed. 00309 * \param stable_data_version Current stable data version can be NULL if not needed. 00310 * \param leader_id Current leader id can be NULL if not needed. 00311 * 00312 * \return 0, Set OK 00313 * \return <0 Set Fail 00314 */ 00315 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); 00316 00317 /** 00318 * \brief Set next partition ID when we next time partition. This is used to control specific behaviour in tests. 00319 * 00320 * \param interface_id Network Interface 00321 * 00322 * \return 0, Set OK 00323 * \return <0 Set Fail 00324 */ 00325 int thread_test_partition_info_set(int8_t interface_id, uint32_t partition_id); 00326 00327 /** 00328 * \brief Get child count 00329 * 00330 * \param interface_id Network Interface 00331 * 00332 * \return 0, Set OK 00333 * \return <0 Set Fail 00334 */ 00335 int8_t thread_test_child_count_get(int8_t interface_id); 00336 00337 /** 00338 * \brief Get child information 00339 * 00340 * get information for index child. if found returns 0 with correct information. 00341 * 00342 * \param interface_id Network Interface 00343 * 00344 * \return 0, OK 00345 * \return <0 Fail no child with this index found 00346 */ 00347 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); 00348 00349 /** 00350 * \brief Get neighbour information 00351 * 00352 * \param interface_id Network Interface 00353 * 00354 * \return 0, Set OK 00355 * \return <0 Set Fail 00356 */ 00357 int8_t thread_test_neighbour_info_get(int8_t interface_id, uint8_t index, uint16_t *short_addr, uint8_t *mac64, uint8_t *margin); 00358 00359 typedef int (response_cb)(int8_t interface_id, uint8_t *response_ptr, uint16_t response_len); 00360 00361 /** 00362 * \brief Send diagnostic command DEPRECATED 00363 * 00364 * \param interface_id Network Interface 00365 * \param address_ptr Address to which the command is sent 00366 * \param uri_ptr Uri for the command 00367 * \param request_length The length of the request 00368 * \param request_ptr Pointer to the beginning of the request contents 00369 * \param resp_cb Pointer to callback function that is called after the reply for the command is obtained 00370 * \return 0, Command send OK 00371 * \return <0 Command send Fail 00372 */ 00373 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); 00374 00375 typedef int (coap_response_cb)(int8_t interface_id, uint8_t message_code, uint8_t message_type, uint8_t *response_ptr, uint16_t response_len); 00376 00377 /** 00378 * \brief Send diagnostic request 00379 * 00380 * \param interface_id Network Interface 00381 * \param address_ptr Address to which the command is sent 00382 * \param msg_type Uri for the command 00383 * \param msg_code Uri for the command 00384 * \param uri_ptr Uri for the command 00385 * \param request_length The length of the request 00386 * \param request_ptr Pointer to the beginning of the request contents 00387 * \param resp_cb Pointer to callback function that is called after the reply for the command is obtained 00388 * 00389 * \return 0, Command send OK 00390 * \return <0 Command send Fail 00391 */ 00392 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); 00393 00394 /** 00395 * \brief Set initial SLAAC iid. 00396 * 00397 * \param interface_id Network Interface 00398 * \param iid Interface identifier pointer must be 8 bytes long buffer. can be NULL to disable. 00399 * \return 0, Command OK 00400 * \return <0 Command Fail 00401 */ 00402 int8_t thread_test_initial_slaac_iid_set(int8_t interface_id, uint8_t *iid); 00403 00404 /** 00405 * \brief Send router ID request. 00406 * 00407 * \param interface_id Network Interface 00408 * \param status Value of router ID request status TLV 00409 * \return 0, Command OK 00410 * \return <0 Command Fail 00411 */ 00412 int8_t thread_test_router_id_request_send(int8_t interface_id, uint8_t status); 00413 00414 /** 00415 * \brief Set joiner port to joiner router device. 00416 * If port == 0, then default port is used. 00417 * 00418 * \param iid Joiner port. 00419 * \return 0, Command OK 00420 * \return <0 Command Fail 00421 */ 00422 int8_t thread_test_joiner_router_joiner_port_set(uint16_t port); 00423 00424 #ifdef __cplusplus 00425 } 00426 #endif 00427 00428 #endif /* NET_THREAD_TEST_H_ */
Generated on Tue Jul 12 2022 18:19:32 by
