Mistake on this page? Email us
m2mconstants.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 ARM Limited. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  * Licensed under the Apache License, Version 2.0 (the License); you may
5  * not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef M2MCONSTANTS_H
17 #define M2MCONSTANTS_H
18 
23 #include <stdint.h>
24 #include "m2mconfig.h"
25 
26 const int MAX_VALUE_LENGTH = 256;
27 const int BUFFER_LENGTH = 1152;
28 
29 const uint8_t MINIMUM_REGISTRATION_TIME = 60; //in seconds
30 const uint8_t ONE_SECOND_TIMER = 1;
31 const uint8_t MAX_ALLOWED_STRING_LENGTH = 64;
32 const uint8_t MAX_ALLOWED_ERROR_STRING_LENGTH = 64;
33 const uint16_t OPTIMUM_LIFETIME = 3600;
34 const uint16_t REDUCE_LIFETIME = 900;
35 const float REDUCTION_FACTOR = 0.75f;
36 const uint16_t MAX_CERTIFICATE_SIZE = 1024;
37 const uint16_t CONFIG_BOOLEAN_ITEM_SIZE = 4;
38 
39 // XXX:
40 // <name></><inst-id></><res-name>
41 //#define MAX_OBJECT_INSTANCE_NAME (255 + 1 + 5 + 1 + 255 + 1 + 5)
42 // <name></><inst-id></><inst-id><zero-terminator>
43 #define MAX_OBJECT_PATH_NAME (255 + 1 + 5 + 1 + 5 + 1)
44 
45 // values per: draft-ietf-core-observe-16
46 // OMA LWM2M CR ref.
47 #define START_OBSERVATION 0
48 #define STOP_OBSERVATION 1
49 
50 #define COAP "coap://"
51 #define COAPS "coaps://"
52 #define BOOTSTRAP_URI "bs"
53 // PUT attributes to be checked from server
54 #define EQUAL "="
55 #define AMP "&"
56 #define PMIN "pmin"
57 #define PMAX "pmax"
58 #define GT "gt"
59 #define LT "lt"
60 #define ST_SIZE "st"
61 #define CANCEL "cancel"
62 
63 // Different query parameters
64 #define QUERY_PARAM_IEP "iep"
65 #define QUERY_PARAM_EST "est"
66 #define QUERY_PARAM_AID "aid"
67 
68 // Different query parameter values
69 #define QUERY_VALUE_TRUE "true"
70 
71 // just a helper for "String default_value = "";" pattern
72 extern const String EMPTY;
73 
74 //LWM2MOBJECT NAME/ID
75 #define M2M_SECURITY_ID "0"
76 #define M2M_SERVER_ID "1"
77 #define M2M_ACCESS_CONTROL_ID "2"
78 #define M2M_DEVICE_ID "3"
79 #define M2M_CONNECTIVITY_MONITOR_ID "4"
80 #define M2M_FIRMWARE_ID "5"
81 #define M2M_LOCATION_ID "6"
82 #define M2M_CONNECTIVITY_STATISTICS_ID "7"
83 #define RESERVED_ID "8"
84 
85 //OMA RESOURCE TYPE
86 #define OMA_RESOURCE_TYPE "" //oma.lwm2m
87 
88 //DEVICE RESOURCES
89 #define DEVICE_MANUFACTURER "0"
90 #define DEVICE_DEVICE_TYPE "17"
91 #define DEVICE_MODEL_NUMBER "1"
92 #define DEVICE_SERIAL_NUMBER "2"
93 #define DEVICE_HARDWARE_VERSION "18"
94 #define DEVICE_FIRMWARE_VERSION "3"
95 #define DEVICE_SOFTWARE_VERSION "19"
96 #define DEVICE_REBOOT "4"
97 #define DEVICE_FACTORY_RESET "5"
98 #define DEVICE_AVAILABLE_POWER_SOURCES "6"
99 #define DEVICE_POWER_SOURCE_VOLTAGE "7"
100 #define DEVICE_POWER_SOURCE_CURRENT "8"
101 #define DEVICE_BATTERY_LEVEL "9"
102 #define DEVICE_BATTERY_STATUS "20"
103 #define DEVICE_MEMORY_FREE "10"
104 #define DEVICE_MEMORY_TOTAL "21"
105 #define DEVICE_ERROR_CODE "11"
106 #define DEVICE_RESET_ERROR_CODE "12"
107 #define DEVICE_CURRENT_TIME "13"
108 #define DEVICE_UTC_OFFSET "14"
109 #define DEVICE_TIMEZONE "15"
110 #define DEVICE_SUPPORTED_BINDING_MODE "16"
111 #define BINDING_MODE_UDP "U"
112 #define BINDING_MODE_UDP_QUEUE "UQ"
113 #define BINDING_MODE_SMS "S"
114 #define BINDING_MODE_SMS_QUEUE "SQ"
115 #define ERROR_CODE_VALUE "0"
116 
117 //SECURITY RESOURCES
118 #define SECURITY_M2M_SERVER_URI "0"
119 #define SECURITY_BOOTSTRAP_SERVER "1"
120 #define SECURITY_SECURITY_MODE "2"
121 #define SECURITY_PUBLIC_KEY "3"
122 #define SECURITY_SERVER_PUBLIC_KEY "4"
123 #define SECURITY_SECRET_KEY "5"
124 #define SECURITY_SMS_SECURITY_MODE "6"
125 #define SECURITY_SMS_BINDING_KEY "7"
126 #define SECURITY_SMS_BINDING_SECRET_KEY "8"
127 #define SECURITY_M2M_SERVER_SMS_NUMBER "9"
128 #define SECURITY_SHORT_SERVER_ID "10"
129 #define SECURITY_CLIENT_HOLD_OFF_TIME "11"
130 
131 #define SECURITY_OPEN_CERTIFICATE_CHAIN "12"
132 #define SECURITY_CLOSE_CERTIFICATE_CHAIN "13"
133 #define SECURITY_READ_CERTIFICATE_CHAIN "14"
134 
135 //SERVER RESOURCES
136 #define SERVER_PATH_PREFIX "1/0/"
137 #define SERVER_SHORT_SERVER_ID "0"
138 #define SERVER_LIFETIME "1"
139 #define SERVER_DEFAULT_MIN_PERIOD "2"
140 #define SERVER_DEFAULT_MAX_PERIOD "3"
141 #define SERVER_DISABLE "4"
142 #define SERVER_DISABLE_TIMEOUT "5"
143 #define SERVER_NOTIFICATION_STORAGE "6"
144 #define SERVER_BINDING "7"
145 #define SERVER_REGISTRATION_UPDATE "8"
146 #define SERVER_LIFETIME_PATH SERVER_PATH_PREFIX SERVER_LIFETIME
147 
148 //FIRMWARE RESOURCES
149 #define FIRMWARE_PATH_PREFIX "5/0/"
150 #define FIRMWARE_PACKAGE "0"
151 #define FIRMWARE_PACKAGE_URI "1"
152 #define FIRMWARE_UPDATE "2"
153 #define FIRMWARE_STATE "3"
154 #define FIRMWARE_UPDATE_SUPPORTED_OBJECTS "4"
155 #define FIRMWARE_UPDATE_RESULT "5"
156 #define FIRMWARE_PACKAGE_NAME "6"
157 #define FIRMWARE_PACKAGE_VERSION "7"
158 #define FIRMAWARE_PACKAGE_URI_PATH FIRMWARE_PATH_PREFIX FIRMWARE_PACKAGE_URI
159 
160 // Error Strings
161 
162 #define ERROR_REASON_1 "No security object found for Bootstrap"
163 #define ERROR_REASON_3 "Bootstrap feature is disabled"
164 #define ERROR_REASON_4 "No security object found for Registration"
165 #define ERROR_REASON_5 "Registration not allowed for now, try later"
166 #define ERROR_REASON_6 "Unregistration not allowed for now, try later"
167 #define ERROR_REASON_7 "Client is not connected, cannot send data now"
168 #define ERROR_REASON_8 "LWM2M server rejected client registration"
169 #define ERROR_REASON_9 "Client in reconnection mode %s"
170 #define ERROR_REASON_10 "Client cannot connect anymore %s"
171 #define ERROR_REASON_13 "LWM2M server URL is not correctly formed"
172 #define ERROR_REASON_14 "LWM2M server address is not set correctly in client"
173 #define ERROR_REASON_15 "Failed to do full registration because of missing parameters in registration"
174 #define ERROR_REASON_16 "Cannot unregister as client is not registered"
175 #define ERROR_REASON_17 "Incoming CoAP message parsing failed"
176 #define ERROR_REASON_18 "Sending reg-update failed as lifetime is less than 60 sec"
177 #define ERROR_REASON_19 "LWM2M server URL is not correctly formed"
178 #ifndef MBED_CLIENT_DISABLE_BOOTSTRAP_FEATURE
179 #define ERROR_REASON_2 "Bootstrap not allowed for now, try later"
180 #define ERROR_REASON_11 "Bootstrap server URL is not correctly formed"
181 #define ERROR_REASON_12 "Bootstrap resource is not correctly formed"
182 #define ERROR_REASON_20 "BS PUT fails :%s"
183 #define ERROR_REASON_21 "BS DEL fails :%s"
184 #define ERROR_REASON_22 "BS FIN fails :%s"
185 #define ERROR_REASON_23 "Bootstrap SecureConnection failed"
186 #define ERROR_REASON_26 "BS FIN fails: missing EST iep param"
187 #endif
188 #define ERROR_REASON_24 "LWM2M server rejected client unregistration (not-found)"
189 #define ERROR_REASON_25 "Failed to allocate registration message"
190 #define ERROR_REASON_27 "Call already in progress"
191 #define ERROR_REASON_28 "Message sending timed out"
192 #define ERROR_REASON_29 "Call not allowed for now, wrong state"
193 
194 #define COAP_ERROR_REASON_1 "bad-request"
195 #define COAP_ERROR_REASON_2 "bad-option"
196 #define COAP_ERROR_REASON_3 "request-entity-incomplete"
197 #define COAP_ERROR_REASON_4 "precondition-failed"
198 #define COAP_ERROR_REASON_5 "request-entity-too-large"
199 #define COAP_ERROR_REASON_6 "unsupported-content-format"
200 #define COAP_ERROR_REASON_7 "response-unauthorized"
201 #define COAP_ERROR_REASON_8 "response-forbidden"
202 #define COAP_ERROR_REASON_9 "not-acceptable"
203 #define COAP_ERROR_REASON_10 "not-found"
204 #define COAP_ERROR_REASON_11 "method-not-allowed"
205 #define COAP_ERROR_REASON_12 "message-sending-failed"
206 #define COAP_ERROR_REASON_13 "service-unavailable"
207 #define COAP_ERROR_REASON_14 "internal-server-error"
208 #define COAP_ERROR_REASON_15 "bad-gateway"
209 #define COAP_ERROR_REASON_16 "gateway-timeout"
210 #define COAP_ERROR_REASON_17 "proxying-not-supported"
211 #define COAP_NO_ERROR "no-error"
212 
213 #define ERROR_SECURE_CONNECTION "SecureConnectionFailed"
214 #define ERROR_DNS "DnsResolvingFailed"
215 #define ERROR_NETWORK "NetworkError"
216 #define ERROR_NO "No error"
217 #define ERROR_NO_MEMORY "Memory allocation failed"
218 #define ERROR_FAILED_TO_READ_CREDENTIALS "Failed to read credentials"
219 
220 #define MAX_RECONNECT_TIMEOUT 604800
221 #define RECONNECT_INCREMENT_FACTOR 2
222 
223 #define AUTO_OBS_TOKEN_MIN 1
224 #define AUTO_OBS_TOKEN_MAX 1023
225 
226 #define RESPONSE_RANDOM_FACTOR 1.5
228 // TLV serializer / deserializer
229 const uint8_t TYPE_RESOURCE = 0xC0;
230 const uint8_t TYPE_MULTIPLE_RESOURCE = 0x80;
231 const uint8_t TYPE_RESOURCE_INSTANCE = 0x40;
232 const uint8_t TYPE_OBJECT_INSTANCE = 0x0;
233 
234 const uint8_t ID8 = 0x0;
235 const uint8_t ID16 = 0x20;
236 
237 const uint8_t LENGTH8 = 0x08;
238 const uint8_t LENGTH16 = 0x10;
239 const uint8_t LENGTH24 = 0x18;
240 
241 const uint8_t COAP_CONTENT_OMA_PLAIN_TEXT_TYPE = 0;
242 const uint8_t COAP_CONTENT_OMA_TLV_TYPE_OLD = 99;
243 const uint16_t COAP_CONTENT_OMA_TLV_TYPE = 11542;
244 const uint16_t COAP_CONTENT_OMA_JSON_TYPE = 11543;
245 const uint8_t COAP_CONTENT_OMA_OPAQUE_TYPE = 42;
246 
247 const uint16_t MAX_UNINT_16_COUNT = 65535;
248 
249 #endif // M2MCONSTANTS_H
Definition: m2mstring.h:33
File defining all system build time configuration used by mbed-client.