Mbed Cloud example program for workshop in W27 2018.

Dependencies:   MMA7660 LM75B

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers m2mconstants.h Source File

m2mconstants.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2015 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 #ifndef M2MCONSTANTS_H
00017 #define M2MCONSTANTS_H
00018 
00019 /*! \file m2mconstants.h
00020 * \brief File defining all the constants used across mbed-client.
00021 */
00022 
00023 #include <stdint.h>
00024 #include "m2mconfig.h"
00025 
00026 const int MAX_VALUE_LENGTH = 256;
00027 const int BUFFER_LENGTH = 1152;
00028 
00029 const uint8_t MINIMUM_REGISTRATION_TIME = 60; //in seconds
00030 const uint8_t ONE_SECOND_TIMER = 1;
00031 const uint8_t MAX_ALLOWED_STRING_LENGTH = 64;
00032 const uint8_t MAX_ALLOWED_ERROR_STRING_LENGTH = 64;
00033 const uint16_t OPTIMUM_LIFETIME = 3600;
00034 const uint16_t REDUCE_LIFETIME = 900;
00035 const float REDUCTION_FACTOR = 0.75f;
00036 
00037 // XXX:
00038 //                               <name></><inst-id></><res-name>
00039 //#define MAX_OBJECT_INSTANCE_NAME (255 + 1 + 5 + 1 + 255 + 1 + 5)
00040 //                           <name></><inst-id></><inst-id><zero-terminator>
00041 #define MAX_OBJECT_PATH_NAME (255 + 1 + 5 + 1 + 5 + 1)
00042 
00043 // values per: draft-ietf-core-observe-16
00044 // OMA LWM2M CR ref.
00045 #define START_OBSERVATION 0
00046 #define STOP_OBSERVATION 1
00047 
00048 #define COAP "coap://"
00049 #define COAPS  "coaps://"
00050 #define BOOTSTRAP_URI "bs"
00051 // PUT attributes to be checked from server
00052 #define EQUAL  "="
00053 #define AMP  "&"
00054 #define PMIN  "pmin"
00055 #define PMAX  "pmax"
00056 #define GT  "gt"
00057 #define LT  "lt"
00058 #define ST_SIZE  "st"
00059 #define STP  "stp"
00060 #define CANCEL  "cancel"
00061 
00062 // just a helper for "String default_value = "";" pattern
00063 extern const String EMPTY;
00064 
00065 //LWM2MOBJECT NAME/ID
00066 #define M2M_SECURITY_ID  "0"
00067 #define M2M_SERVER_ID  "1"
00068 #define M2M_ACCESS_CONTROL_ID  "2"
00069 #define M2M_DEVICE_ID  "3"
00070 #define M2M_CONNECTIVITY_MONITOR_ID  "4"
00071 #define M2M_FIRMWARE_ID  "5"
00072 #define M2M_LOCATION_ID  "6"
00073 #define M2M_CONNECTIVITY_STATISTICS_ID  "7"
00074 #define RESERVED_ID  "8"
00075 
00076 //OMA RESOURCE TYPE
00077 #define OMA_RESOURCE_TYPE  "" //oma.lwm2m
00078 
00079 //DEVICE RESOURCES
00080 #define DEVICE_MANUFACTURER  "0"
00081 #define DEVICE_DEVICE_TYPE  "17"
00082 #define DEVICE_MODEL_NUMBER  "1"
00083 #define DEVICE_SERIAL_NUMBER  "2"
00084 #define DEVICE_HARDWARE_VERSION  "18"
00085 #define DEVICE_FIRMWARE_VERSION  "3"
00086 #define DEVICE_SOFTWARE_VERSION  "19"
00087 #define DEVICE_REBOOT  "4"
00088 #define DEVICE_FACTORY_RESET  "5"
00089 #define DEVICE_AVAILABLE_POWER_SOURCES  "6"
00090 #define DEVICE_POWER_SOURCE_VOLTAGE  "7"
00091 #define DEVICE_POWER_SOURCE_CURRENT  "8"
00092 #define DEVICE_BATTERY_LEVEL  "9"
00093 #define DEVICE_BATTERY_STATUS  "20"
00094 #define DEVICE_MEMORY_FREE  "10"
00095 #define DEVICE_MEMORY_TOTAL  "21"
00096 #define DEVICE_ERROR_CODE  "11"
00097 #define DEVICE_RESET_ERROR_CODE  "12"
00098 #define DEVICE_CURRENT_TIME  "13"
00099 #define DEVICE_UTC_OFFSET  "14"
00100 #define DEVICE_TIMEZONE  "15"
00101 #define DEVICE_SUPPORTED_BINDING_MODE  "16"
00102 #define BINDING_MODE_UDP  "U"
00103 #define BINDING_MODE_UDP_QUEUE  "UQ"
00104 #define BINDING_MODE_SMS  "S"
00105 #define BINDING_MODE_SMS_QUEUE  "SQ"
00106 #define ERROR_CODE_VALUE  "0"
00107 
00108 //SECURITY RESOURCES
00109 #define SECURITY_M2M_SERVER_URI  "0"
00110 #define SECURITY_BOOTSTRAP_SERVER  "1"
00111 #define SECURITY_SECURITY_MODE  "2"
00112 #define SECURITY_PUBLIC_KEY  "3"
00113 #define SECURITY_SERVER_PUBLIC_KEY  "4"
00114 #define SECURITY_SECRET_KEY  "5"
00115 #define SECURITY_SMS_SECURITY_MODE  "6"
00116 #define SECURITY_SMS_BINDING_KEY  "7"
00117 #define SECURITY_SMS_BINDING_SECRET_KEY  "8"
00118 #define SECURITY_M2M_SERVER_SMS_NUMBER  "9"
00119 #define SECURITY_SHORT_SERVER_ID  "10"
00120 #define SECURITY_CLIENT_HOLD_OFF_TIME  "11"
00121 
00122 //SERVER RESOURCES
00123 #define SERVER_PATH_PREFIX "1/0/"
00124 #define SERVER_SHORT_SERVER_ID  "0"
00125 #define SERVER_LIFETIME  "1"
00126 #define SERVER_DEFAULT_MIN_PERIOD  "2"
00127 #define SERVER_DEFAULT_MAX_PERIOD  "3"
00128 #define SERVER_DISABLE  "4"
00129 #define SERVER_DISABLE_TIMEOUT  "5"
00130 #define SERVER_NOTIFICATION_STORAGE  "6"
00131 #define SERVER_BINDING  "7"
00132 #define SERVER_REGISTRATION_UPDATE  "8"
00133 #define SERVER_LIFETIME_PATH SERVER_PATH_PREFIX SERVER_LIFETIME
00134 
00135 //FIRMWARE RESOURCES
00136 #define FIRMWARE_PATH_PREFIX "5/0/"
00137 #define FIRMWARE_PACKAGE  "0"
00138 #define FIRMWARE_PACKAGE_URI  "1"
00139 #define FIRMWARE_UPDATE  "2"
00140 #define FIRMWARE_STATE  "3"
00141 #define FIRMWARE_UPDATE_SUPPORTED_OBJECTS  "4"
00142 #define FIRMWARE_UPDATE_RESULT  "5"
00143 #define FIRMWARE_PACKAGE_NAME  "6"
00144 #define FIRMWARE_PACKAGE_VERSION  "7"
00145 #define FIRMAWARE_PACKAGE_URI_PATH FIRMWARE_PATH_PREFIX FIRMWARE_PACKAGE_URI
00146 
00147 // Error Strings
00148 
00149 #define ERROR_REASON_1 "No security object found for Bootstrap"
00150 #define ERROR_REASON_2 "Bootstrap not allowed for now, try later"
00151 #define ERROR_REASON_3 "Bootstrap feature is disabled"
00152 #define ERROR_REASON_4 "No security object found for Registration"
00153 #define ERROR_REASON_5 "Registration not allowed for now, try later"
00154 #define ERROR_REASON_6 "Unregistration not allowed for now, try later"
00155 #define ERROR_REASON_7 "Client is not connected, cannot send data now"
00156 #define ERROR_REASON_8 "LWM2M server rejected client registration"
00157 #define ERROR_REASON_9 "Client in reconnection mode %s"
00158 #define ERROR_REASON_10 "Client cannot connect anymore %s"
00159 #define ERROR_REASON_11 "Bootstrap server URL is not correctly formed"
00160 #define ERROR_REASON_12 "Bootstrap resource is not correctly formed"
00161 #define ERROR_REASON_13 "LWM2M server URL is not correctly formed"
00162 #define ERROR_REASON_14 "LWM2M server address is not set correctly in client"
00163 #define ERROR_REASON_15 "Failed to do full registration because of missing parameters in registration"
00164 #define ERROR_REASON_16 "Cannot unregister as client is not registered"
00165 #define ERROR_REASON_17 "Incoming CoAP message parsing failed"
00166 #define ERROR_REASON_18 "Sending reg-update failed as lifetime is less than 60 sec"
00167 #define ERROR_REASON_19 "LWM2M server URL is not correctly formed"
00168 #define ERROR_REASON_20 "BS PUT fails :%s"
00169 #define ERROR_REASON_21 "BS DEL fails :%s"
00170 #define ERROR_REASON_22 "BS FIN fails :%s"
00171 #define ERROR_REASON_23 "Bootstrap SecureConnection failed"
00172 #define ERROR_REASON_24 "LWM2M server rejected client unregistration (not-found)"
00173 #define ERROR_REASON_25 "Failed to allocate registration message"
00174 
00175 #define COAP_ERROR_REASON_1 "bad-request"
00176 #define COAP_ERROR_REASON_2 "bad-option"
00177 #define COAP_ERROR_REASON_3 "request-entity-incomplete"
00178 #define COAP_ERROR_REASON_4 "precondition-failed"
00179 #define COAP_ERROR_REASON_5 "request-entity-too-large"
00180 #define COAP_ERROR_REASON_6 "unsupported-content-format"
00181 #define COAP_ERROR_REASON_7 "response-unauthorized"
00182 #define COAP_ERROR_REASON_8 "response-forbidden"
00183 #define COAP_ERROR_REASON_9 "not-acceptable"
00184 #define COAP_ERROR_REASON_10 "not-found"
00185 #define COAP_ERROR_REASON_11 "method-not-allowed"
00186 #define COAP_ERROR_REASON_12 "message-sending-failed"
00187 #define COAP_ERROR_REASON_13 "service-unavailable"
00188 #define COAP_ERROR_REASON_14 "internal-server-error"
00189 #define COAP_ERROR_REASON_15 "bad-gateway"
00190 #define COAP_ERROR_REASON_16 "gateway-timeout"
00191 #define COAP_ERROR_REASON_17 "proxying-not-supported"
00192 #define COAP_NO_ERROR        "no-error"
00193 
00194 #define ERROR_SECURE_CONNECTION "SecureConnectionFailed"
00195 #define ERROR_DNS               "DnsResolvingFailed"
00196 #define ERROR_NETWORK           "NetworkError"
00197 #define ERROR_NO                "No error"
00198 
00199 #define MAX_RECONNECT_TIMEOUT        604800
00200 #define RECONNECT_INCREMENT_FACTOR   2
00201 
00202 #define AUTO_OBS_TOKEN_MIN 1
00203 #define AUTO_OBS_TOKEN_MAX 1023
00204 
00205 // TLV serializer / deserializer
00206 const uint8_t TYPE_RESOURCE = 0xC0;
00207 const uint8_t TYPE_MULTIPLE_RESOURCE = 0x80;
00208 const uint8_t TYPE_RESOURCE_INSTANCE = 0x40;
00209 const uint8_t TYPE_OBJECT_INSTANCE = 0x0;
00210 
00211 const uint8_t ID8 = 0x0;
00212 const uint8_t ID16 = 0x20;
00213 
00214 const uint8_t LENGTH8 = 0x08;
00215 const uint8_t LENGTH16 = 0x10;
00216 const uint8_t LENGTH24 = 0x18;
00217 
00218 const uint8_t COAP_CONTENT_OMA_PLAIN_TEXT_TYPE = 0;
00219 const uint8_t COAP_CONTENT_OMA_TLV_TYPE_OLD = 99;
00220 const uint16_t COAP_CONTENT_OMA_TLV_TYPE = 11542;
00221 const uint16_t COAP_CONTENT_OMA_JSON_TYPE = 11543;
00222 const uint8_t COAP_CONTENT_OMA_OPAQUE_TYPE = 42;
00223 
00224 const uint16_t MAX_UNINT_16_COUNT = 65535;
00225 
00226 #endif // M2MCONSTANTS_H