Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers sn_config.h Source File

sn_config.h

00001 /*
00002  * Copyright (c) 2016 ARM Limited. All rights reserved.
00003  * SPDX-License-Identifier: Apache-2.0
00004  * Licensed under the Apache License, Version 2.0 (the License); you may
00005  * not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  * http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
00012  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef SN_CONFIG_H
00018 #define SN_CONFIG_H
00019 
00020 #ifdef MBED_CLIENT_USER_CONFIG_FILE
00021 #include MBED_CLIENT_USER_CONFIG_FILE
00022 #endif
00023 
00024 #ifdef MBED_CLOUD_CLIENT_USER_CONFIG_FILE
00025 #include MBED_CLOUD_CLIENT_USER_CONFIG_FILE
00026 #endif
00027 
00028 #ifdef MBED_CLOUD_CLIENT_CONFIGURATION_ENABLED
00029 #include "mbed-cloud-client/MbedCloudClientConfig.h"
00030 #endif
00031 
00032 /**
00033 * \brief Configuration options (set of defines and values)
00034 *
00035 *  This lists set of compile-time options that needs to be used to enable
00036 *  or disable features selectively, and set the values for the mandatory
00037 *  parameters.
00038 */
00039 
00040 /**
00041  * \def SN_COAP_DUPLICATION_MAX_MSGS_COUNT
00042  * \brief For Message duplication detection
00043  * Init value for the maximum count of messages to be stored for duplication detection
00044  * Setting of this value to 0 will disable duplication check, also reduce use of ROM memory
00045  * Default is set to 0.
00046  */
00047 #ifdef MBED_CONF_MBED_CLIENT_SN_COAP_DUPLICATION_MAX_MSGS_COUNT
00048 #define SN_COAP_DUPLICATION_MAX_MSGS_COUNT MBED_CONF_MBED_CLIENT_SN_COAP_DUPLICATION_MAX_MSGS_COUNT
00049 #endif
00050 
00051 #ifndef SN_COAP_DUPLICATION_MAX_MSGS_COUNT
00052 #define SN_COAP_DUPLICATION_MAX_MSGS_COUNT              0
00053 #endif
00054 
00055 /**
00056  * \def SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE
00057  * \brief For Message blockwising
00058  * Init value for the maximum payload size to be sent and received at one blockwise message
00059  * Setting of this value to 0 with SN_COAP_BLOCKWISE_ENABLED will disable this feature, and
00060  * also reduce use of ROM memory.
00061  * Note: This define is common for both received and sent Blockwise messages
00062  */
00063 #ifdef MBED_CONF_MBED_CLIENT_SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE
00064 #define SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE MBED_CONF_MBED_CLIENT_SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE
00065 #endif
00066 
00067 #ifndef SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE
00068 #define SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE              0  /**< Must be 2^x and x is at least 4. Suitable values: 0, 16, 32, 64, 128, 256, 512 and 1024 */
00069 #endif
00070 
00071 /**
00072  * \def SN_COAP_DISABLE_RESENDINGS
00073  * \brief Disables resending feature. Resending feature should not be needed
00074  * when using CoAP with TCP transport for example. By default resendings are
00075  * enabled. Set to 1 to disable.
00076  */
00077 #ifdef SN_COAP_DISABLE_RESENDINGS
00078 #define ENABLE_RESENDINGS                               0   /** Disable resendings **/
00079 #else
00080 #define ENABLE_RESENDINGS                               1   /**< Enable / Disable resending from library in building */
00081 #endif
00082 
00083 /**
00084  * \def SN_COAP_RESENDING_QUEUE_SIZE_MSGS
00085  * \brief Sets the number of messages stored
00086  * in the resending queue. Default is 2
00087  */
00088 #ifdef MBED_CONF_MBED_CLIENT_SN_COAP_RESENDING_QUEUE_SIZE_MSGS
00089 #define SN_COAP_RESENDING_QUEUE_SIZE_MSGS MBED_CONF_MBED_CLIENT_SN_COAP_RESENDING_QUEUE_SIZE_MSGS
00090 #endif
00091 
00092 #ifndef SN_COAP_RESENDING_QUEUE_SIZE_MSGS
00093 #define SN_COAP_RESENDING_QUEUE_SIZE_MSGS               2   /**< Default re-sending queue size - defines how many messages can be stored. Setting this to 0 disables feature */
00094 #endif
00095 
00096 /**
00097  * \def DEFAULT_RESPONSE_TIMEOUT
00098  * \brief Sets the CoAP re-send interval in seconds.
00099  * By default is 10 seconds.
00100  */
00101 #ifndef DEFAULT_RESPONSE_TIMEOUT
00102 #define DEFAULT_RESPONSE_TIMEOUT                        10  /**< Default re-sending timeout as seconds */
00103 #endif
00104 
00105 /**
00106  * \def SN_COAP_RESENDING_QUEUE_SIZE_BYTES
00107  * \brief Sets the size of the re-sending buffer.
00108  * Setting this to 0 disables this feature.
00109  * By default, this feature is disabled.
00110  */
00111 #ifdef MBED_CONF_MBED_CLIENT_SN_COAP_RESENDING_QUEUE_SIZE_BYTES
00112 #define SN_COAP_RESENDING_QUEUE_SIZE_BYTES MBED_CONF_MBED_CLIENT_SN_COAP_RESENDING_QUEUE_SIZE_BYTES
00113 #endif
00114 
00115 #ifndef SN_COAP_RESENDING_QUEUE_SIZE_BYTES
00116 #define SN_COAP_RESENDING_QUEUE_SIZE_BYTES              0   /**< Default re-sending queue size - defines size of the re-sending buffer. Setting this to 0 disables feature */
00117 #endif
00118 
00119 /**
00120  * \def SN_COAP_MAX_INCOMING_MESSAGE_SIZE
00121  * \brief Sets the maximum size (in bytes) that
00122  * mbed Client will allow to be handled while
00123  * receiving big payload in blockwise mode.
00124  * Application can set this value based on their
00125  * available storage capability.
00126  * By default, maximum size is UINT16_MAX, 65535 bytes.
00127  */
00128 #ifndef SN_COAP_MAX_INCOMING_MESSAGE_SIZE
00129 #define SN_COAP_MAX_INCOMING_MESSAGE_SIZE               UINT16_MAX
00130 #endif
00131 
00132 /**
00133  * \def SN_COAP_MAX_NONBLOCKWISE_PAYLOAD_SIZE
00134  * \brief Sets the maximum payload size allowed before blockwising the message.
00135  * This option should only be used when using TCP and TLS as transport
00136  * with known maximum fragment size. This optimizes the number of messages
00137  * if it is possible to send larger than 1kB messages without blockwise transfer.
00138  * If payload length is larger than SN_COAP_MAX_NONBLOCKWISE_PAYLOAD_SIZE
00139  * it will be sent using blockwise transfer.
00140  * By default, this feature is disabled, 0 disables the feature, set to positive
00141  * value larger than SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE to enable.
00142  * Note that value should be less than transport layer maximum fragment size.
00143  * Note that value has no effect if blockwise transfer is disabled.
00144  */
00145 #ifndef SN_COAP_MAX_NONBLOCKWISE_PAYLOAD_SIZE
00146 #define SN_COAP_MAX_NONBLOCKWISE_PAYLOAD_SIZE           0
00147 #endif
00148 
00149 /**
00150  * \def SN_COAP_BLOCKWISE_ENABLED
00151  * \brief Enables the blockwise functionality in CoAP library also when blockwise payload
00152  * size is set to '0' in  SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE.
00153  */
00154 #ifndef SN_COAP_BLOCKWISE_ENABLED
00155 #define SN_COAP_BLOCKWISE_ENABLED                       0  /**< Enable blockwise */
00156 #endif
00157 
00158 /**
00159  * \def SN_COAP_RESENDING_MAX_COUNT
00160  * \brief Defines how many times CoAP library tries to re-send the CoAP packet.
00161  * By default value is 3.
00162  */
00163 #ifndef SN_COAP_RESENDING_MAX_COUNT
00164 #define SN_COAP_RESENDING_MAX_COUNT                     3
00165 #endif
00166 
00167 /**
00168  * \def SN_COAP_MAX_ALLOWED_RESENDING_COUNT
00169  * \brief Maximum allowed count of re-sending that can be set at runtime via
00170  * 'sn_coap_protocol_set_retransmission_parameters()' API.
00171  * By default value is 6.
00172  */
00173 #ifndef SN_COAP_MAX_ALLOWED_RESENDING_COUNT
00174 #define SN_COAP_MAX_ALLOWED_RESENDING_COUNT             6   /**< Maximum allowed count of re-sending */
00175 #endif
00176 
00177 /**
00178  * \def SN_COAP_MAX_ALLOWED_RESPONSE_TIMEOUT
00179  * \brief Maximum allowed re-send interval in seconds that can be set at runtime via
00180  * 'sn_coap_protocol_set_retransmission_parameters()' API.
00181  * By default value is 40.
00182  */
00183 #ifndef SN_COAP_MAX_ALLOWED_RESPONSE_TIMEOUT
00184 #define SN_COAP_MAX_ALLOWED_RESPONSE_TIMEOUT            40  /**< Maximum allowed re-sending timeout */
00185 #endif
00186 
00187 /**
00188  * \def SN_COAP_MAX_ALLOWED_RESENDING_BUFF_SIZE_MSGS
00189  * \brief Maximum allowed count of messages that can be stored into resend buffer at runtime via
00190  * 'sn_coap_protocol_set_retransmission_buffer()' API.
00191  * By default value is 6.
00192  */
00193 #ifndef SN_COAP_MAX_ALLOWED_RESENDING_BUFF_SIZE_MSGS
00194 #define SN_COAP_MAX_ALLOWED_RESENDING_BUFF_SIZE_MSGS    6   /**< Maximum allowed number of saved re-sending messages */
00195 #endif
00196 
00197 /**
00198  * \def SN_COAP_MAX_ALLOWED_RESENDING_BUFF_SIZE_BYTES
00199  * \brief Maximum size of messages in bytes that can be stored into resend buffer at runtime via
00200  * 'sn_coap_protocol_set_retransmission_buffer()' API.
00201  * By default value is 512.
00202  */
00203 #ifndef SN_COAP_MAX_ALLOWED_RESENDING_BUFF_SIZE_BYTES
00204 #define SN_COAP_MAX_ALLOWED_RESENDING_BUFF_SIZE_BYTES   512 /**< Maximum allowed size of re-sending buffer */
00205 #endif
00206 
00207 /**
00208  * \def SN_COAP_MAX_ALLOWED_DUPLICATION_MESSAGE_COUNT
00209  * \brief Maximum allowed number of saved messages for message duplicate searching
00210  * that can be set via 'sn_coap_protocol_set_duplicate_buffer_size' API.
00211  * By default value is 6.
00212  */
00213 #ifndef SN_COAP_MAX_ALLOWED_DUPLICATION_MESSAGE_COUNT
00214 #define SN_COAP_MAX_ALLOWED_DUPLICATION_MESSAGE_COUNT   6
00215 #endif
00216 
00217 /**
00218  * \def SN_COAP_DUPLICATION_MAX_TIME_MSGS_STORED
00219  * \brief Maximum time in seconds howe long message is kept for duplicate detection.
00220  * By default 60 seconds.
00221  */
00222 #ifndef SN_COAP_DUPLICATION_MAX_TIME_MSGS_STORED
00223 #define SN_COAP_DUPLICATION_MAX_TIME_MSGS_STORED    60 /** RESPONSE_TIMEOUT * RESPONSE_RANDOM_FACTOR * (2 ^ MAX_RETRANSMIT - 1) + the expected maximum round trip time **/
00224 #endif
00225 
00226 /**
00227  * \def SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED
00228  * \brief Maximum time in seconds how long (messages and payload) are be stored for blockwising.
00229  * Longer time will increase the memory consumption in lossy networks.
00230  * By default 60 seconds.
00231  */
00232 #ifdef MBED_CONF_MBED_CLIENT_SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED
00233 #define SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED MBED_CONF_MBED_CLIENT_SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED
00234 #endif
00235 
00236 #ifndef SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED
00237 #define SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED      60 /**< Maximum time in seconds of data (messages and payload) to be stored for blockwising */
00238 #endif
00239 
00240 /**
00241  * \def SN_COAP_MAX_INCOMING_BLOCK_MESSAGE_SIZE
00242  * \brief Maximum size of blockwise message that can be received.
00243  * By default 65535 bytes.
00244  */
00245 #ifdef MBED_CONF_MBED_CLIENT_SN_COAP_MAX_INCOMING_MESSAGE_SIZE
00246 #define SN_COAP_MAX_INCOMING_BLOCK_MESSAGE_SIZE MBED_CONF_MBED_CLIENT_SN_COAP_MAX_INCOMING_MESSAGE_SIZE
00247 #endif
00248 
00249 #ifndef SN_COAP_MAX_INCOMING_BLOCK_MESSAGE_SIZE
00250 #define SN_COAP_MAX_INCOMING_BLOCK_MESSAGE_SIZE     UINT16_MAX
00251 #endif
00252 
00253 /**
00254  * \def SN_COAP_BLOCKWISE_INTERNAL_BLOCK_2_HANDLING_ENABLED
00255  * \brief A size optimization switch, which removes the blockwise Block2 response if set to 0.
00256  * handling code which is typically overridden by a call of "sn_coap_protocol_handle_block2_response_internally(coap, false);".
00257  * By default the code is there, so the override can be reversed by "sn_coap_protocol_handle_block2_response_internally(coap, true)".
00258  */
00259 #ifndef SN_COAP_BLOCKWISE_INTERNAL_BLOCK_2_HANDLING_ENABLED
00260 #define SN_COAP_BLOCKWISE_INTERNAL_BLOCK_2_HANDLING_ENABLED  1
00261 #endif
00262 
00263 /**
00264  * \def SN_COAP_REDUCE_BLOCKWISE_HEAP_FOOTPRINT
00265  * \brief A heap optimization switch, which removes unnecessary copy of the blockwise data.
00266  * If enabled, application must NOT free the payload when it gets the COAP_STATUS_PARSER_BLOCKWISE_MSG_RECEIVED status.
00267  * Application must call sn_coap_protocol_block_remove() instead.
00268  */
00269 #ifndef SN_COAP_REDUCE_BLOCKWISE_HEAP_FOOTPRINT
00270 #define SN_COAP_REDUCE_BLOCKWISE_HEAP_FOOTPRINT              0   /**< Disabled by default */
00271 #endif
00272 
00273 #endif // SN_CONFIG_H