Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers thread_constants.h Source File

thread_constants.h

00001 /*
00002  * Copyright (c) 2016-2019, Arm Limited and affiliates.
00003  * SPDX-License-Identifier: BSD-3-Clause
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  *
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  * 3. Neither the name of the copyright holder nor the
00014  *    names of its contributors may be used to endorse or promote products
00015  *    derived from this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027  * POSSIBILITY OF SUCH DAMAGE.
00028  */
00029 
00030 #ifndef THREAD_CONSTANTS_H_
00031 #define THREAD_CONSTANTS_H_
00032 
00033 /**
00034  * Constants defined in Thread specifications. All configured values are defined in thread_config.h
00035  */
00036 
00037 /**
00038  * Default management port assigned by IANA.
00039  * nick:MM
00040  */
00041 #define THREAD_MANAGEMENT_PORT 61631
00042 
00043 /**
00044  * Default joiner port. Joiner must learn this from Discovery response during network discovery.
00045  * nick:MJ
00046  */
00047 #define THREAD_DEFAULT_JOINER_PORT 49153
00048 
00049 /**
00050  * Default Commissioning port. This can be changed if this is not available and advertised in network discovery.
00051  * nick: MC
00052  */
00053 #define THREAD_COMMISSIONING_PORT 49191
00054 
00055 /**
00056  *  End device default timeout.
00057  */
00058 #define THREAD_END_DEVICE_DEFAULT_TIMEOUT 240
00059 
00060 /**
00061  *  COAP Status TLV values (TLV TYPE 4)
00062  */
00063 #define THREAD_COAP_STATUS_TLV_SUCCESS                  0
00064 #define THREAD_COAP_STATUS_TLV_NO_ADDRESS_AVAILABLE     1
00065 #define THREAD_COAP_STATUS_TLV_TOO_FEW_ROUTERS          2
00066 #define THREAD_COAP_STATUS_TLV_HAVE_CHILD_ID_REQUEST    3
00067 #define THREAD_COAP_STATUS_TLV_PARENT_PARTITION_CHANGE  4
00068 
00069 
00070 /**
00071  * Constants for Connectivity TLV (TLV TYPE 15)
00072  */
00073 #define THREAD_CONNECTIVITY_TLV_PARENT_PRIORITY_HIGH     1
00074 #define THREAD_CONNECTIVITY_TLV_PARENT_PRIORITY_MEDIUM   0
00075 #define THREAD_CONNECTIVITY_TLV_PARENT_PRIORITY_LOW      -1
00076 
00077 /**
00078  * per-SED IPv6 buffer sizes and datagram count specified in the Thread Conformance specification
00079  */
00080 #define THREAD_SED_BUFFER_MIN_SIZE          106
00081 #define THREAD_SED_DATAGRAM_MIN_COUNT       1
00082 
00083 
00084 /**
00085  * Thread TLV length
00086  */
00087 #define THREAD_HAS_ROUTE_TLV_LENGTH         3
00088 #define THREAD_BORDER_ROUTER_TLV_LENGTH     4
00089 #define THREAD_6LOWPAN_ID_TLV_LENGTH        2
00090 #define THREAD_IPV6_ADDRESS_TLV_LENGTH      16
00091 
00092 /**
00093  * Uris defined by thread specifications
00094  */
00095 #define THREAD_URI_NETWORK_DATA                 "a/sd"   //<* Leader
00096 #define THREAD_URI_NEIGHBOR_DISCOVERY_DATA_REQ  "a/nd"   //<* 1.1 feature
00097 
00098 #define THREAD_URI_ROUTER_ID_ASSIGNMENT         "a/as"   //<* Leader
00099 #define THREAD_URI_ROUTER_ID_RELEASE            "a/ar"   //<* Leader
00100 
00101 #define THREAD_URI_ADDRESS_QUERY_REQUEST        "a/aq"   //<* All Routers
00102 #define THREAD_URI_ADDRESS_NOTIFICATION         "a/an"   //<* All Routers
00103 #define THREAD_URI_ADDRESS_ERROR                "a/ae"   //<* All Nodes
00104 
00105 #define THREAD_URI_DIAGNOSTIC_RESET             "d/dr"   //<* All Nodes
00106 #define THREAD_URI_DIAGNOSTIC_REQUEST           "d/dg"   //<* All Nodes
00107 #define THREAD_URI_DIAGNOSTIC_QUERY             "d/dq"   //<* All Routers
00108 #define THREAD_URI_DIAGNOSTIC_ANSWER            "d/da"   //<* All Routers
00109 
00110 
00111 #define THREAD_URI_MANAGEMENT_GET               "c/mg"  //<* Leader
00112 #define THREAD_URI_MANAGEMENT_SET               "c/ms"  //<* Leader
00113 #define THREAD_URI_LEADER_PETITION              "c/lp"  //<* Leader
00114 #define THREAD_URI_LEADER_KEEP_ALIVE            "c/la"  //<* Leader
00115 
00116 #define THREAD_URI_RELAY_TRANSMIT               "c/tx"  //<* Joiner router
00117 #define THREAD_URI_RELAY_RECEIVE                "c/rx"  //<* Border router, native commissioner
00118 
00119 #define THREAD_URI_JOINER_ENTRUST               "c/je"  //<* Joiner
00120 #define THREAD_URI_JOINER_FINALIZATION          "c/jf"  //<* Commissioner, native commissioner
00121 #define THREAD_URI_JOINER_APPLICATION_REQUEST   "c/ja"  //<* Any thread device
00122 
00123 #define THREAD_URI_COMMISSIONER_PETITION        "c/cp"  //<* Border router
00124 #define THREAD_URI_COMMISSIONER_KEEP_ALIVE      "c/ca"  //<* Border router
00125 
00126 #define THREAD_URI_UDP_RECVEIVE_NOTIFICATION    "c/ur"  //<* Commissioner
00127 #define THREAD_URI_UDP_TRANSMIT_NOTIFICATION    "c/ut"  //<* Border router
00128 
00129 #define THREAD_URI_PANID_QUERY                  "c/pq"  //<* 1.1 feature
00130 #define THREAD_URI_PANID_CONFLICT               "c/pc"  //<* 1.1 feature
00131 #define THREAD_URI_ED_SCAN                      "c/es"  //<* 1.1 feature
00132 #define THREAD_URI_ED_REPORT                    "c/er"  //<* 1.1 feature
00133 #define THREAD_URI_MANAGEMENT_ANNOUNCE_NTF      "c/an"  //<* 1.1 feature
00134 #define THREAD_URI_MANAGEMENT_ANNOUNCE_BEGIN    "c/ab"  //<* 1.1 feature
00135 
00136 #define THREAD_URI_ACTIVE_GET                   "c/ag"  //<* 1.1 feature
00137 #define THREAD_URI_ACTIVE_SET                   "c/as"  //<* 1.1 feature
00138 #define THREAD_URI_PENDING_GET                  "c/pg"  //<* 1.1 feature
00139 #define THREAD_URI_PENDING_SET                  "c/ps"  //<* 1.1 feature
00140 #define THREAD_URI_COMMISSIONER_GET             "c/cg"  //<* 1.1 feature
00141 #define THREAD_URI_COMMISSIONER_SET             "c/cs"  //<* 1.1 feature
00142 #define THREAD_URI_DATASET_CHANGED              "c/dc"  //<* 1.1 feature
00143 
00144 #define THREAD_DEFAULT_COAP_RESOLUTION 1
00145 #define THREAD_DEFAULT_KEY_SWITCH_GUARD_TIME 624 // Hours
00146 #define THREAD_DEFAULT_KEY_ROTATION 672 // Hours
00147 #define THREAD_COMMISSIONER_KEEP_ALIVE_INTERVAL 50000    // Default thread commissioner keep-alive message interval (milliseconds)
00148 #define THREAD_DELAY_JOIN_ENT 50 // Minimum delay for Joiner router before sending joiner entrust (milliseconds)
00149 
00150 #define THREAD_FAILED_CHILD_TRANSMISSIONS 4
00151 #define THREAD_FAILED_ROUTER_TRANSMISSIONS 4
00152 #define THREAD_MAC_TRANSMISSIONS 4
00153 
00154 #define THREAD_MAX_NETWORK_DATA_SIZE 254
00155 
00156 // How many seconds a server MUST wait after a data update has been rejected by the Leader before resending the update
00157 #define THREAD_DATA_RESUBMIT_DELAY  300
00158 
00159 // The maximum length of Commissioning Data TLV (including type & length)
00160 //   - Commissioner Session ID, Border Agent Locator TLV, Steering Data TLV
00161 #define THREAD_MAX_COMM_DATA_TLV_LEN 28
00162 
00163 // Channel page 0 super frame duration is used to convert times from ms time to exponent value in MAC
00164 #define CHANNEL_PAGE_0_SUPERFRAME_DURATION  15.36
00165 
00166 #define THREAD_ENTERPRISE_NUMBER 44970
00167 
00168 #define THREAD_ADDR_REG_RETRY_INTERVAL 300
00169 #define THREAD_PROACTIVE_AN_INTERVAL 3600
00170 
00171 // Router defines
00172 #define ROUTER_SELECTION_JITTER 120
00173 #define REED_ADVERTISEMENT_INTERVAL 570
00174 #define REED_ADVERTISEMENT_MAX_JITTER 60
00175 #define MIN_DOWNGRADE_NEIGHBORS 7
00176 #define THREAD_REED_ADVERTISEMENT_DELAY 5000
00177 
00178 // Interval after which REED can send an advertisement to help others merge to higher partition.
00179 // This is not related to default REED advertisements.
00180 #define THREAD_REED_MERGE_ADVERTISEMENT_INTERVAL 120
00181 
00182 /** Default Threshold for router Selection */
00183 #define ROUTER_DOWNGRADE_THRESHOLD 23 // Define downGrade Threshold when active router is higher than this
00184 #define ROUTER_UPGRADE_THRESHOLD 16 // Define upgrade Threshold fort REED when Active Router Count is smaller than this upgrade is possible
00185 
00186 /** Thread prefix minimum lifetime in seconds */
00187 #define THREAD_MIN_PREFIX_LIFETIME  3600
00188 
00189 #define THREAD_MCAST_ADDR_PER_MSG 4 // One multicast registration message fits 4 addresses by default
00190 
00191 /**
00192  * Minimum specified MLR timeout in seconds
00193  */
00194 #define THREAD_DEFAULT_MIN_MLR_TIMEOUT 300
00195 
00196 /**
00197  * Default Autonomous enrollment port.
00198   */
00199 #define THREAD_DEFAULT_AE_PORT 49192
00200 
00201 /**
00202  * Default NMK port.
00203  */
00204 #define THREAD_DEFAULT_NMKP_PORT 49193
00205 
00206 /**
00207  * Default registrar port
00208  */
00209 #define THREAD_DEFAULT_REGISTRAR_PORT 5684
00210 
00211 #define THREAD_URI_BBR_MCAST_LISTENER_REPORT    "n/mr"  //<* 1.2 feature
00212 #define THREAD_URI_BBR_DOMAIN_ADDRESS_REGISTRATION "n/dr"  //<* 1.2 feature
00213 #define THREAD_URI_BBR_DOMAIN_ADDRESS_NOTIFICATION "n/dn"  //<* 1.2 feature
00214 #define THREAD_URI_BBR_BB_QRY_NTF               "b/bq"  //<* Backbone border router
00215 #define THREAD_URI_BBR_BB_ANS_NTF               "b/ba"  //<* Backbone border router
00216 #define THREAD_URI_BBR_BMLR_NTF                 "b/bmr" //<* 1.2 feature
00217 #define THREAD_URI_BBR_TRI_RX_NTF               "c/rxr"  //<* Backbone border router
00218 #define THREAD_URI_BBR_NMK_RX_NTF               "c/rxb"  //<* Backbone border router
00219 #define THREAD_URI_BBR_TRI_TX_NTF               "c/txr"  //<* Backbone border router
00220 #define THREAD_URI_BBR_NMK_TX_NTF               "c/txb"  //<* Backbone border router
00221 #define THREAD_URI_BBR_NMKP_REQ                 "c/cjf"  //<* Backbone border router
00222 #define THREAD_URI_MGMT_SEC_PENDING_SET         "c/sp"   //<* Secure Dissemination of Pending Operational Dataset
00223 
00224 #define THREAD_URI_REENROLL_REQ                 "c/re"  //<* Device re-enrollment request
00225 #define THREAD_URI_RESET_REQ                    "c/rt"  //<* Device reset request - instruct to remove itself from Thread domain
00226 #define THREAD_URI_BBR_DATA_REQ                 "c/bg"  //<* BBR data request
00227 #define THREAD_URI_BBR_DATA_SET                 "c/bs"  //<* BBR data set
00228 
00229 #define THREAD_URI_TRI_TX_NTF                   ".well-known/thread/c/txr"  //<* Registrar
00230 #define THREAD_URI_TRI_RX_NTF                   ".well-known/thread/c/rxr"  //<* Registrar
00231 
00232 #define THREAD_URI_SIMPLEENROLL                 ".well-known/est/sen"       //<* Registrar
00233 #define THREAD_URI_CSRATTRS                     ".well-known/est/att"       //<* Registrar
00234 #define THREAD_URI_RAT                          ".well-known/est/rv"        //<* Registrar
00235 #define THREAD_URI_SIMPLEREENROLL               ".well-known/est/sren"      //<* Registrar
00236 
00237 /** Thread BBR service id */
00238 #define THREAD_SERVICE_DATA_BBR 0x01
00239 
00240 /** Thread 1.2 CoAP content types */
00241 #define THREAD_CONTENT_FORMAT_AUDITNONCE                   (sn_coap_content_format_e)65000
00242 #define THREAD_CONTENT_FORMAT_CSRATTRS                     (sn_coap_content_format_e)65002
00243 #define THREAD_CONTENT_FORMAT_PKCS10                       (sn_coap_content_format_e)65003
00244 
00245 /**
00246  * Thread 1.2 Security policy options. Default for all is '1';
00247  */
00248 
00249 #define THREAD_SECURITY_POLICY_CCM_DISABLED       0x04
00250 #define THREAD_SECURITY_POLICY_AE_DISABLED        0x02
00251 #define THREAD_SECURITY_POLICY_NMP_DISABLED       0x01
00252 #define THREAD_SECURITY_POLICY_NCR_DISABLED       0x40
00253 #define THREAD_SECURITY_POLICY_VR_VALUE           0x07
00254 
00255 /**
00256  * Thread 1.2 Status TLV in DUA.rsp message.
00257  * /
00258 0 – Successful registration
00259 2 – Registration rejected: Target EID is not a valid DUA; e.g. incorrect Domain Prefix
00260 3 – Registration rejected: DUA is already in use by another Device
00261 4 – Registration rejected: BBR resource shortage
00262 5 – Registration rejected: BBR is not Primary at this moment
00263 6 – Registration failure: Reason(s) not further specified
00264 */
00265 
00266 #define THREAD_ST_DUA_SUCCESS                 0
00267 #define THREAD_ST_DUA_INVALID                 2 //Fatal
00268 #define THREAD_ST_DUA_DUPLICATE               3 //Fatal
00269 #define THREAD_ST_DUA_NO_RESOURCES            4
00270 #define THREAD_ST_DUA_BBR_NOT_PRIMARY         5
00271 #define THREAD_ST_DUA_GENERAL_FAILURE         6
00272 
00273 
00274 #define THREAD_VERSION_1_2 3
00275 
00276 
00277 #endif /* THREAD_CONSTANTS_H_ */