pick up wakaama files from https://github.com/eclipse/wakaama
core/internals.h@0:1fa43ab66921, 2017-04-19 (annotated)
- Committer:
- terencez
- Date:
- Wed Apr 19 11:30:02 2017 +0000
- Revision:
- 0:1fa43ab66921
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
terencez | 0:1fa43ab66921 | 1 | /******************************************************************************* |
terencez | 0:1fa43ab66921 | 2 | * |
terencez | 0:1fa43ab66921 | 3 | * Copyright (c) 2013, 2014 Intel Corporation and others. |
terencez | 0:1fa43ab66921 | 4 | * All rights reserved. This program and the accompanying materials |
terencez | 0:1fa43ab66921 | 5 | * are made available under the terms of the Eclipse Public License v1.0 |
terencez | 0:1fa43ab66921 | 6 | * and Eclipse Distribution License v1.0 which accompany this distribution. |
terencez | 0:1fa43ab66921 | 7 | * |
terencez | 0:1fa43ab66921 | 8 | * The Eclipse Public License is available at |
terencez | 0:1fa43ab66921 | 9 | * http://www.eclipse.org/legal/epl-v10.html |
terencez | 0:1fa43ab66921 | 10 | * The Eclipse Distribution License is available at |
terencez | 0:1fa43ab66921 | 11 | * http://www.eclipse.org/org/documents/edl-v10.php. |
terencez | 0:1fa43ab66921 | 12 | * |
terencez | 0:1fa43ab66921 | 13 | * Contributors: |
terencez | 0:1fa43ab66921 | 14 | * David Navarro, Intel Corporation - initial API and implementation |
terencez | 0:1fa43ab66921 | 15 | * Fabien Fleutot - Please refer to git log |
terencez | 0:1fa43ab66921 | 16 | * Toby Jaffey - Please refer to git log |
terencez | 0:1fa43ab66921 | 17 | * Bosch Software Innovations GmbH - Please refer to git log |
terencez | 0:1fa43ab66921 | 18 | * Pascal Rieux - Please refer to git log |
terencez | 0:1fa43ab66921 | 19 | * |
terencez | 0:1fa43ab66921 | 20 | *******************************************************************************/ |
terencez | 0:1fa43ab66921 | 21 | /* |
terencez | 0:1fa43ab66921 | 22 | Copyright (c) 2013, 2014 Intel Corporation |
terencez | 0:1fa43ab66921 | 23 | |
terencez | 0:1fa43ab66921 | 24 | Redistribution and use in source and binary forms, with or without modification, |
terencez | 0:1fa43ab66921 | 25 | are permitted provided that the following conditions are met: |
terencez | 0:1fa43ab66921 | 26 | |
terencez | 0:1fa43ab66921 | 27 | * Redistributions of source code must retain the above copyright notice, |
terencez | 0:1fa43ab66921 | 28 | this list of conditions and the following disclaimer. |
terencez | 0:1fa43ab66921 | 29 | * Redistributions in binary form must reproduce the above copyright notice, |
terencez | 0:1fa43ab66921 | 30 | this list of conditions and the following disclaimer in the documentation |
terencez | 0:1fa43ab66921 | 31 | and/or other materials provided with the distribution. |
terencez | 0:1fa43ab66921 | 32 | * Neither the name of Intel Corporation nor the names of its contributors |
terencez | 0:1fa43ab66921 | 33 | may be used to endorse or promote products derived from this software |
terencez | 0:1fa43ab66921 | 34 | without specific prior written permission. |
terencez | 0:1fa43ab66921 | 35 | |
terencez | 0:1fa43ab66921 | 36 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
terencez | 0:1fa43ab66921 | 37 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
terencez | 0:1fa43ab66921 | 38 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
terencez | 0:1fa43ab66921 | 39 | IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
terencez | 0:1fa43ab66921 | 40 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
terencez | 0:1fa43ab66921 | 41 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
terencez | 0:1fa43ab66921 | 42 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
terencez | 0:1fa43ab66921 | 43 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
terencez | 0:1fa43ab66921 | 44 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
terencez | 0:1fa43ab66921 | 45 | THE POSSIBILITY OF SUCH DAMAGE. |
terencez | 0:1fa43ab66921 | 46 | |
terencez | 0:1fa43ab66921 | 47 | David Navarro <david.navarro@intel.com> |
terencez | 0:1fa43ab66921 | 48 | |
terencez | 0:1fa43ab66921 | 49 | */ |
terencez | 0:1fa43ab66921 | 50 | |
terencez | 0:1fa43ab66921 | 51 | #ifndef _LWM2M_INTERNALS_H_ |
terencez | 0:1fa43ab66921 | 52 | #define _LWM2M_INTERNALS_H_ |
terencez | 0:1fa43ab66921 | 53 | |
terencez | 0:1fa43ab66921 | 54 | #include "liblwm2m.h" |
terencez | 0:1fa43ab66921 | 55 | |
terencez | 0:1fa43ab66921 | 56 | #include <stdlib.h> |
terencez | 0:1fa43ab66921 | 57 | #include <string.h> |
terencez | 0:1fa43ab66921 | 58 | #include <stdio.h> |
terencez | 0:1fa43ab66921 | 59 | #include <stdint.h> |
terencez | 0:1fa43ab66921 | 60 | #include <stddef.h> |
terencez | 0:1fa43ab66921 | 61 | #include <stdbool.h> |
terencez | 0:1fa43ab66921 | 62 | |
terencez | 0:1fa43ab66921 | 63 | #include "er-coap-13/er-coap-13.h" |
terencez | 0:1fa43ab66921 | 64 | |
terencez | 0:1fa43ab66921 | 65 | #ifdef LWM2M_WITH_LOGS |
terencez | 0:1fa43ab66921 | 66 | #include <inttypes.h> |
terencez | 0:1fa43ab66921 | 67 | #define LOG(STR) lwm2m_printf("[%s:%d] " STR "\r\n", __func__ , __LINE__) |
terencez | 0:1fa43ab66921 | 68 | #define LOG_ARG(FMT, ...) lwm2m_printf("[%s:%d] " FMT "\r\n", __func__ , __LINE__ , __VA_ARGS__) |
terencez | 0:1fa43ab66921 | 69 | #define LOG_URI(URI) \ |
terencez | 0:1fa43ab66921 | 70 | { \ |
terencez | 0:1fa43ab66921 | 71 | if ((URI) == NULL) lwm2m_printf("[%s:%d] NULL\r\n", __func__ , __LINE__); \ |
terencez | 0:1fa43ab66921 | 72 | else \ |
terencez | 0:1fa43ab66921 | 73 | { \ |
terencez | 0:1fa43ab66921 | 74 | lwm2m_printf("[%s:%d] /%d", __func__ , __LINE__ , (URI)->objectId); \ |
terencez | 0:1fa43ab66921 | 75 | if (LWM2M_URI_IS_SET_INSTANCE(URI)) lwm2m_printf("/%d", (URI)->instanceId); \ |
terencez | 0:1fa43ab66921 | 76 | if (LWM2M_URI_IS_SET_RESOURCE(URI)) lwm2m_printf("/%d", (URI)->resourceId); \ |
terencez | 0:1fa43ab66921 | 77 | lwm2m_printf("\r\n"); \ |
terencez | 0:1fa43ab66921 | 78 | } \ |
terencez | 0:1fa43ab66921 | 79 | } |
terencez | 0:1fa43ab66921 | 80 | #define STR_STATUS(S) \ |
terencez | 0:1fa43ab66921 | 81 | ((S) == STATE_DEREGISTERED ? "STATE_DEREGISTERED" : \ |
terencez | 0:1fa43ab66921 | 82 | ((S) == STATE_REG_PENDING ? "STATE_REG_PENDING" : \ |
terencez | 0:1fa43ab66921 | 83 | ((S) == STATE_REGISTERED ? "STATE_REGISTERED" : \ |
terencez | 0:1fa43ab66921 | 84 | ((S) == STATE_REG_FAILED ? "STATE_REG_FAILED" : \ |
terencez | 0:1fa43ab66921 | 85 | ((S) == STATE_REG_UPDATE_PENDING ? "STATE_REG_UPDATE_PENDING" : \ |
terencez | 0:1fa43ab66921 | 86 | ((S) == STATE_REG_UPDATE_NEEDED ? "STATE_REG_UPDATE_NEEDED" : \ |
terencez | 0:1fa43ab66921 | 87 | ((S) == STATE_REG_FULL_UPDATE_NEEDED ? "STATE_REG_FULL_UPDATE_NEEDED" : \ |
terencez | 0:1fa43ab66921 | 88 | ((S) == STATE_DEREG_PENDING ? "STATE_DEREG_PENDING" : \ |
terencez | 0:1fa43ab66921 | 89 | ((S) == STATE_BS_HOLD_OFF ? "STATE_BS_HOLD_OFF" : \ |
terencez | 0:1fa43ab66921 | 90 | ((S) == STATE_BS_INITIATED ? "STATE_BS_INITIATED" : \ |
terencez | 0:1fa43ab66921 | 91 | ((S) == STATE_BS_PENDING ? "STATE_BS_PENDING" : \ |
terencez | 0:1fa43ab66921 | 92 | ((S) == STATE_BS_FINISHED ? "STATE_BS_FINISHED" : \ |
terencez | 0:1fa43ab66921 | 93 | ((S) == STATE_BS_FINISHING ? "STATE_BS_FINISHING" : \ |
terencez | 0:1fa43ab66921 | 94 | ((S) == STATE_BS_FAILING ? "STATE_BS_FAILING" : \ |
terencez | 0:1fa43ab66921 | 95 | ((S) == STATE_BS_FAILED ? "STATE_BS_FAILED" : \ |
terencez | 0:1fa43ab66921 | 96 | "Unknown"))))))))))))))) |
terencez | 0:1fa43ab66921 | 97 | #define STR_MEDIA_TYPE(M) \ |
terencez | 0:1fa43ab66921 | 98 | ((M) == LWM2M_CONTENT_TEXT ? "LWM2M_CONTENT_TEXT" : \ |
terencez | 0:1fa43ab66921 | 99 | ((M) == LWM2M_CONTENT_LINK ? "LWM2M_CONTENT_LINK" : \ |
terencez | 0:1fa43ab66921 | 100 | ((M) == LWM2M_CONTENT_OPAQUE ? "LWM2M_CONTENT_OPAQUE" : \ |
terencez | 0:1fa43ab66921 | 101 | ((M) == LWM2M_CONTENT_TLV ? "LWM2M_CONTENT_TLV" : \ |
terencez | 0:1fa43ab66921 | 102 | ((M) == LWM2M_CONTENT_JSON ? "LWM2M_CONTENT_JSON" : \ |
terencez | 0:1fa43ab66921 | 103 | "Unknown"))))) |
terencez | 0:1fa43ab66921 | 104 | #define STR_STATE(S) \ |
terencez | 0:1fa43ab66921 | 105 | ((S) == STATE_INITIAL ? "STATE_INITIAL" : \ |
terencez | 0:1fa43ab66921 | 106 | ((S) == STATE_BOOTSTRAP_REQUIRED ? "STATE_BOOTSTRAP_REQUIRED" : \ |
terencez | 0:1fa43ab66921 | 107 | ((S) == STATE_BOOTSTRAPPING ? "STATE_BOOTSTRAPPING" : \ |
terencez | 0:1fa43ab66921 | 108 | ((S) == STATE_REGISTER_REQUIRED ? "STATE_REGISTER_REQUIRED" : \ |
terencez | 0:1fa43ab66921 | 109 | ((S) == STATE_REGISTERING ? "STATE_REGISTERING" : \ |
terencez | 0:1fa43ab66921 | 110 | ((S) == STATE_READY ? "STATE_READY" : \ |
terencez | 0:1fa43ab66921 | 111 | "Unknown")))))) |
terencez | 0:1fa43ab66921 | 112 | #else |
terencez | 0:1fa43ab66921 | 113 | #define LOG_ARG(FMT, ...) |
terencez | 0:1fa43ab66921 | 114 | #define LOG(STR) |
terencez | 0:1fa43ab66921 | 115 | #define LOG_URI(URI) |
terencez | 0:1fa43ab66921 | 116 | #endif |
terencez | 0:1fa43ab66921 | 117 | |
terencez | 0:1fa43ab66921 | 118 | #define LWM2M_DEFAULT_LIFETIME 86400 |
terencez | 0:1fa43ab66921 | 119 | |
terencez | 0:1fa43ab66921 | 120 | #ifdef LWM2M_SUPPORT_JSON |
terencez | 0:1fa43ab66921 | 121 | #define REG_LWM2M_RESOURCE_TYPE ">;rt=\"oma.lwm2m\";ct=11543," |
terencez | 0:1fa43ab66921 | 122 | #define REG_LWM2M_RESOURCE_TYPE_LEN 25 |
terencez | 0:1fa43ab66921 | 123 | #else |
terencez | 0:1fa43ab66921 | 124 | #define REG_LWM2M_RESOURCE_TYPE ">;rt=\"oma.lwm2m\"," |
terencez | 0:1fa43ab66921 | 125 | #define REG_LWM2M_RESOURCE_TYPE_LEN 17 |
terencez | 0:1fa43ab66921 | 126 | #endif |
terencez | 0:1fa43ab66921 | 127 | #define REG_START "<" |
terencez | 0:1fa43ab66921 | 128 | #define REG_DEFAULT_PATH "/" |
terencez | 0:1fa43ab66921 | 129 | |
terencez | 0:1fa43ab66921 | 130 | #define REG_OBJECT_MIN_LEN 5 // "</n>," |
terencez | 0:1fa43ab66921 | 131 | #define REG_PATH_END ">," |
terencez | 0:1fa43ab66921 | 132 | #define REG_PATH_SEPARATOR "/" |
terencez | 0:1fa43ab66921 | 133 | |
terencez | 0:1fa43ab66921 | 134 | #define REG_OBJECT_PATH "<%s/%hu>," |
terencez | 0:1fa43ab66921 | 135 | #define REG_OBJECT_INSTANCE_PATH "<%s/%hu/%hu>," |
terencez | 0:1fa43ab66921 | 136 | |
terencez | 0:1fa43ab66921 | 137 | #define URI_REGISTRATION_SEGMENT "rd" |
terencez | 0:1fa43ab66921 | 138 | #define URI_REGISTRATION_SEGMENT_LEN 2 |
terencez | 0:1fa43ab66921 | 139 | #define URI_BOOTSTRAP_SEGMENT "bs" |
terencez | 0:1fa43ab66921 | 140 | #define URI_BOOTSTRAP_SEGMENT_LEN 2 |
terencez | 0:1fa43ab66921 | 141 | |
terencez | 0:1fa43ab66921 | 142 | #define QUERY_STARTER "?" |
terencez | 0:1fa43ab66921 | 143 | #define QUERY_NAME "ep=" |
terencez | 0:1fa43ab66921 | 144 | #define QUERY_NAME_LEN 3 // strlen("ep=") |
terencez | 0:1fa43ab66921 | 145 | #define QUERY_SMS "sms=" |
terencez | 0:1fa43ab66921 | 146 | #define QUERY_SMS_LEN 4 |
terencez | 0:1fa43ab66921 | 147 | #define QUERY_LIFETIME "lt=" |
terencez | 0:1fa43ab66921 | 148 | #define QUERY_LIFETIME_LEN 3 |
terencez | 0:1fa43ab66921 | 149 | #define QUERY_VERSION "lwm2m=" |
terencez | 0:1fa43ab66921 | 150 | #define QUERY_VERSION_LEN 6 |
terencez | 0:1fa43ab66921 | 151 | #define QUERY_BINDING "b=" |
terencez | 0:1fa43ab66921 | 152 | #define QUERY_BINDING_LEN 2 |
terencez | 0:1fa43ab66921 | 153 | #define QUERY_DELIMITER "&" |
terencez | 0:1fa43ab66921 | 154 | |
terencez | 0:1fa43ab66921 | 155 | #define LWM2M_VERSION "1.0" |
terencez | 0:1fa43ab66921 | 156 | #define LWM2M_VERSION_LEN 3 |
terencez | 0:1fa43ab66921 | 157 | |
terencez | 0:1fa43ab66921 | 158 | #define QUERY_VERSION_FULL QUERY_VERSION LWM2M_VERSION |
terencez | 0:1fa43ab66921 | 159 | #define QUERY_VERSION_FULL_LEN QUERY_VERSION_LEN+LWM2M_VERSION_LEN |
terencez | 0:1fa43ab66921 | 160 | |
terencez | 0:1fa43ab66921 | 161 | #define REG_URI_START '<' |
terencez | 0:1fa43ab66921 | 162 | #define REG_URI_END '>' |
terencez | 0:1fa43ab66921 | 163 | #define REG_DELIMITER ',' |
terencez | 0:1fa43ab66921 | 164 | #define REG_ATTR_SEPARATOR ';' |
terencez | 0:1fa43ab66921 | 165 | #define REG_ATTR_EQUALS '=' |
terencez | 0:1fa43ab66921 | 166 | #define REG_ATTR_TYPE_KEY "rt" |
terencez | 0:1fa43ab66921 | 167 | #define REG_ATTR_TYPE_KEY_LEN 2 |
terencez | 0:1fa43ab66921 | 168 | #define REG_ATTR_TYPE_VALUE "\"oma.lwm2m\"" |
terencez | 0:1fa43ab66921 | 169 | #define REG_ATTR_TYPE_VALUE_LEN 11 |
terencez | 0:1fa43ab66921 | 170 | #define REG_ATTR_CONTENT_KEY "ct" |
terencez | 0:1fa43ab66921 | 171 | #define REG_ATTR_CONTENT_KEY_LEN 2 |
terencez | 0:1fa43ab66921 | 172 | #define REG_ATTR_CONTENT_JSON "11543" // Temporary value |
terencez | 0:1fa43ab66921 | 173 | #define REG_ATTR_CONTENT_JSON_LEN 5 |
terencez | 0:1fa43ab66921 | 174 | |
terencez | 0:1fa43ab66921 | 175 | #define ATTR_SERVER_ID_STR "ep=" |
terencez | 0:1fa43ab66921 | 176 | #define ATTR_SERVER_ID_LEN 3 |
terencez | 0:1fa43ab66921 | 177 | #define ATTR_MIN_PERIOD_STR "pmin=" |
terencez | 0:1fa43ab66921 | 178 | #define ATTR_MIN_PERIOD_LEN 5 |
terencez | 0:1fa43ab66921 | 179 | #define ATTR_MAX_PERIOD_STR "pmax=" |
terencez | 0:1fa43ab66921 | 180 | #define ATTR_MAX_PERIOD_LEN 5 |
terencez | 0:1fa43ab66921 | 181 | #define ATTR_GREATER_THAN_STR "gt=" |
terencez | 0:1fa43ab66921 | 182 | #define ATTR_GREATER_THAN_LEN 3 |
terencez | 0:1fa43ab66921 | 183 | #define ATTR_LESS_THAN_STR "lt=" |
terencez | 0:1fa43ab66921 | 184 | #define ATTR_LESS_THAN_LEN 3 |
terencez | 0:1fa43ab66921 | 185 | #define ATTR_STEP_STR "stp=" |
terencez | 0:1fa43ab66921 | 186 | #define ATTR_STEP_LEN 4 |
terencez | 0:1fa43ab66921 | 187 | #define ATTR_DIMENSION_STR "dim=" |
terencez | 0:1fa43ab66921 | 188 | #define ATTR_DIMENSION_LEN 4 |
terencez | 0:1fa43ab66921 | 189 | |
terencez | 0:1fa43ab66921 | 190 | #define URI_MAX_STRING_LEN 18 // /65535/65535/65535 |
terencez | 0:1fa43ab66921 | 191 | #define _PRV_64BIT_BUFFER_SIZE 8 |
terencez | 0:1fa43ab66921 | 192 | |
terencez | 0:1fa43ab66921 | 193 | #define LINK_ITEM_START "<" |
terencez | 0:1fa43ab66921 | 194 | #define LINK_ITEM_START_SIZE 1 |
terencez | 0:1fa43ab66921 | 195 | #define LINK_ITEM_END ">," |
terencez | 0:1fa43ab66921 | 196 | #define LINK_ITEM_END_SIZE 2 |
terencez | 0:1fa43ab66921 | 197 | #define LINK_ITEM_DIM_START ">;dim=" |
terencez | 0:1fa43ab66921 | 198 | #define LINK_ITEM_DIM_START_SIZE 6 |
terencez | 0:1fa43ab66921 | 199 | #define LINK_ITEM_ATTR_END "," |
terencez | 0:1fa43ab66921 | 200 | #define LINK_ITEM_ATTR_END_SIZE 1 |
terencez | 0:1fa43ab66921 | 201 | #define LINK_URI_SEPARATOR "/" |
terencez | 0:1fa43ab66921 | 202 | #define LINK_URI_SEPARATOR_SIZE 1 |
terencez | 0:1fa43ab66921 | 203 | #define LINK_ATTR_SEPARATOR ";" |
terencez | 0:1fa43ab66921 | 204 | #define LINK_ATTR_SEPARATOR_SIZE 1 |
terencez | 0:1fa43ab66921 | 205 | |
terencez | 0:1fa43ab66921 | 206 | #define ATTR_FLAG_NUMERIC (uint8_t)(LWM2M_ATTR_FLAG_LESS_THAN | LWM2M_ATTR_FLAG_GREATER_THAN | LWM2M_ATTR_FLAG_STEP) |
terencez | 0:1fa43ab66921 | 207 | |
terencez | 0:1fa43ab66921 | 208 | #define LWM2M_URI_FLAG_DM (uint8_t)0x00 |
terencez | 0:1fa43ab66921 | 209 | #define LWM2M_URI_FLAG_DELETE_ALL (uint8_t)0x10 |
terencez | 0:1fa43ab66921 | 210 | #define LWM2M_URI_FLAG_REGISTRATION (uint8_t)0x20 |
terencez | 0:1fa43ab66921 | 211 | #define LWM2M_URI_FLAG_BOOTSTRAP (uint8_t)0x40 |
terencez | 0:1fa43ab66921 | 212 | |
terencez | 0:1fa43ab66921 | 213 | #define LWM2M_URI_MASK_TYPE (uint8_t)0x70 |
terencez | 0:1fa43ab66921 | 214 | #define LWM2M_URI_MASK_ID (uint8_t)0x07 |
terencez | 0:1fa43ab66921 | 215 | |
terencez | 0:1fa43ab66921 | 216 | typedef struct |
terencez | 0:1fa43ab66921 | 217 | { |
terencez | 0:1fa43ab66921 | 218 | uint16_t clientID; |
terencez | 0:1fa43ab66921 | 219 | lwm2m_uri_t uri; |
terencez | 0:1fa43ab66921 | 220 | lwm2m_result_callback_t callback; |
terencez | 0:1fa43ab66921 | 221 | void * userData; |
terencez | 0:1fa43ab66921 | 222 | } dm_data_t; |
terencez | 0:1fa43ab66921 | 223 | |
terencez | 0:1fa43ab66921 | 224 | typedef enum |
terencez | 0:1fa43ab66921 | 225 | { |
terencez | 0:1fa43ab66921 | 226 | URI_DEPTH_OBJECT, |
terencez | 0:1fa43ab66921 | 227 | URI_DEPTH_OBJECT_INSTANCE, |
terencez | 0:1fa43ab66921 | 228 | URI_DEPTH_RESOURCE, |
terencez | 0:1fa43ab66921 | 229 | URI_DEPTH_RESOURCE_INSTANCE |
terencez | 0:1fa43ab66921 | 230 | } uri_depth_t; |
terencez | 0:1fa43ab66921 | 231 | |
terencez | 0:1fa43ab66921 | 232 | #ifdef LWM2M_BOOTSTRAP_SERVER_MODE |
terencez | 0:1fa43ab66921 | 233 | typedef struct |
terencez | 0:1fa43ab66921 | 234 | { |
terencez | 0:1fa43ab66921 | 235 | bool isUri; |
terencez | 0:1fa43ab66921 | 236 | lwm2m_uri_t uri; |
terencez | 0:1fa43ab66921 | 237 | lwm2m_bootstrap_callback_t callback; |
terencez | 0:1fa43ab66921 | 238 | void * userData; |
terencez | 0:1fa43ab66921 | 239 | } bs_data_t; |
terencez | 0:1fa43ab66921 | 240 | #endif |
terencez | 0:1fa43ab66921 | 241 | |
terencez | 0:1fa43ab66921 | 242 | // defined in uri.c |
terencez | 0:1fa43ab66921 | 243 | lwm2m_uri_t * uri_decode(char * altPath, multi_option_t *uriPath); |
terencez | 0:1fa43ab66921 | 244 | int uri_getNumber(uint8_t * uriString, size_t uriLength); |
terencez | 0:1fa43ab66921 | 245 | int uri_toString(lwm2m_uri_t * uriP, uint8_t * buffer, size_t bufferLen, uri_depth_t * depthP); |
terencez | 0:1fa43ab66921 | 246 | |
terencez | 0:1fa43ab66921 | 247 | // defined in objects.c |
terencez | 0:1fa43ab66921 | 248 | coap_status_t object_readData(lwm2m_context_t * contextP, lwm2m_uri_t * uriP, int * sizeP, lwm2m_data_t ** dataP); |
terencez | 0:1fa43ab66921 | 249 | coap_status_t object_read(lwm2m_context_t * contextP, lwm2m_uri_t * uriP, lwm2m_media_type_t * formatP, uint8_t ** bufferP, size_t * lengthP); |
terencez | 0:1fa43ab66921 | 250 | coap_status_t object_write(lwm2m_context_t * contextP, lwm2m_uri_t * uriP, lwm2m_media_type_t format, uint8_t * buffer, size_t length); |
terencez | 0:1fa43ab66921 | 251 | coap_status_t object_create(lwm2m_context_t * contextP, lwm2m_uri_t * uriP, lwm2m_media_type_t format, uint8_t * buffer, size_t length); |
terencez | 0:1fa43ab66921 | 252 | coap_status_t object_execute(lwm2m_context_t * contextP, lwm2m_uri_t * uriP, uint8_t * buffer, size_t length); |
terencez | 0:1fa43ab66921 | 253 | coap_status_t object_delete(lwm2m_context_t * contextP, lwm2m_uri_t * uriP); |
terencez | 0:1fa43ab66921 | 254 | coap_status_t object_discover(lwm2m_context_t * contextP, lwm2m_uri_t * uriP, lwm2m_server_t * serverP, uint8_t ** bufferP, size_t * lengthP); |
terencez | 0:1fa43ab66921 | 255 | uint8_t object_checkReadable(lwm2m_context_t * contextP, lwm2m_uri_t * uriP); |
terencez | 0:1fa43ab66921 | 256 | uint8_t object_checkNumeric(lwm2m_context_t * contextP, lwm2m_uri_t * uriP); |
terencez | 0:1fa43ab66921 | 257 | bool object_isInstanceNew(lwm2m_context_t * contextP, uint16_t objectId, uint16_t instanceId); |
terencez | 0:1fa43ab66921 | 258 | int object_getRegisterPayload(lwm2m_context_t * contextP, uint8_t * buffer, size_t length); |
terencez | 0:1fa43ab66921 | 259 | int object_getServers(lwm2m_context_t * contextP); |
terencez | 0:1fa43ab66921 | 260 | coap_status_t object_createInstance(lwm2m_context_t * contextP, lwm2m_uri_t * uriP, lwm2m_data_t * dataP); |
terencez | 0:1fa43ab66921 | 261 | coap_status_t object_writeInstance(lwm2m_context_t * contextP, lwm2m_uri_t * uriP, lwm2m_data_t * dataP); |
terencez | 0:1fa43ab66921 | 262 | |
terencez | 0:1fa43ab66921 | 263 | // defined in transaction.c |
terencez | 0:1fa43ab66921 | 264 | lwm2m_transaction_t * transaction_new(void * sessionH, coap_method_t method, char * altPath, lwm2m_uri_t * uriP, uint16_t mID, uint8_t token_len, uint8_t* token); |
terencez | 0:1fa43ab66921 | 265 | int transaction_send(lwm2m_context_t * contextP, lwm2m_transaction_t * transacP); |
terencez | 0:1fa43ab66921 | 266 | void transaction_free(lwm2m_transaction_t * transacP); |
terencez | 0:1fa43ab66921 | 267 | void transaction_remove(lwm2m_context_t * contextP, lwm2m_transaction_t * transacP); |
terencez | 0:1fa43ab66921 | 268 | bool transaction_handleResponse(lwm2m_context_t * contextP, void * fromSessionH, coap_packet_t * message, coap_packet_t * response); |
terencez | 0:1fa43ab66921 | 269 | void transaction_step(lwm2m_context_t * contextP, time_t currentTime, time_t * timeoutP); |
terencez | 0:1fa43ab66921 | 270 | |
terencez | 0:1fa43ab66921 | 271 | // defined in management.c |
terencez | 0:1fa43ab66921 | 272 | coap_status_t dm_handleRequest(lwm2m_context_t * contextP, lwm2m_uri_t * uriP, lwm2m_server_t * serverP, coap_packet_t * message, coap_packet_t * response); |
terencez | 0:1fa43ab66921 | 273 | |
terencez | 0:1fa43ab66921 | 274 | // defined in observe.c |
terencez | 0:1fa43ab66921 | 275 | coap_status_t observe_handleRequest(lwm2m_context_t * contextP, lwm2m_uri_t * uriP, lwm2m_server_t * serverP, int size, lwm2m_data_t * dataP, coap_packet_t * message, coap_packet_t * response); |
terencez | 0:1fa43ab66921 | 276 | void observe_cancel(lwm2m_context_t * contextP, uint16_t mid, void * fromSessionH); |
terencez | 0:1fa43ab66921 | 277 | coap_status_t observe_setParameters(lwm2m_context_t * contextP, lwm2m_uri_t * uriP, lwm2m_server_t * serverP, lwm2m_attributes_t * attrP); |
terencez | 0:1fa43ab66921 | 278 | void observe_step(lwm2m_context_t * contextP, time_t currentTime, time_t * timeoutP); |
terencez | 0:1fa43ab66921 | 279 | bool observe_handleNotify(lwm2m_context_t * contextP, void * fromSessionH, coap_packet_t * message, coap_packet_t * response); |
terencez | 0:1fa43ab66921 | 280 | void observe_remove(lwm2m_observation_t * observationP); |
terencez | 0:1fa43ab66921 | 281 | lwm2m_observed_t * observe_findByUri(lwm2m_context_t * contextP, lwm2m_uri_t * uriP); |
terencez | 0:1fa43ab66921 | 282 | |
terencez | 0:1fa43ab66921 | 283 | // defined in registration.c |
terencez | 0:1fa43ab66921 | 284 | coap_status_t registration_handleRequest(lwm2m_context_t * contextP, lwm2m_uri_t * uriP, void * fromSessionH, coap_packet_t * message, coap_packet_t * response); |
terencez | 0:1fa43ab66921 | 285 | void registration_deregister(lwm2m_context_t * contextP, lwm2m_server_t * serverP); |
terencez | 0:1fa43ab66921 | 286 | void registration_freeClient(lwm2m_client_t * clientP); |
terencez | 0:1fa43ab66921 | 287 | uint8_t registration_start(lwm2m_context_t * contextP); |
terencez | 0:1fa43ab66921 | 288 | void registration_step(lwm2m_context_t * contextP, time_t currentTime, time_t * timeoutP); |
terencez | 0:1fa43ab66921 | 289 | lwm2m_status_t registration_getStatus(lwm2m_context_t * contextP); |
terencez | 0:1fa43ab66921 | 290 | |
terencez | 0:1fa43ab66921 | 291 | // defined in packet.c |
terencez | 0:1fa43ab66921 | 292 | coap_status_t message_send(lwm2m_context_t * contextP, coap_packet_t * message, void * sessionH); |
terencez | 0:1fa43ab66921 | 293 | |
terencez | 0:1fa43ab66921 | 294 | // defined in bootstrap.c |
terencez | 0:1fa43ab66921 | 295 | void bootstrap_step(lwm2m_context_t * contextP, uint32_t currentTime, time_t* timeoutP); |
terencez | 0:1fa43ab66921 | 296 | coap_status_t bootstrap_handleCommand(lwm2m_context_t * contextP, lwm2m_uri_t * uriP, lwm2m_server_t * serverP, coap_packet_t * message, coap_packet_t * response); |
terencez | 0:1fa43ab66921 | 297 | coap_status_t bootstrap_handleDeleteAll(lwm2m_context_t * context, void * fromSessionH); |
terencez | 0:1fa43ab66921 | 298 | coap_status_t bootstrap_handleFinish(lwm2m_context_t * context, void * fromSessionH); |
terencez | 0:1fa43ab66921 | 299 | uint8_t bootstrap_handleRequest(lwm2m_context_t * contextP, lwm2m_uri_t * uriP, void * fromSessionH, coap_packet_t * message, coap_packet_t * response); |
terencez | 0:1fa43ab66921 | 300 | void bootstrap_start(lwm2m_context_t * contextP); |
terencez | 0:1fa43ab66921 | 301 | lwm2m_status_t bootstrap_getStatus(lwm2m_context_t * contextP); |
terencez | 0:1fa43ab66921 | 302 | |
terencez | 0:1fa43ab66921 | 303 | // defined in tlv.c |
terencez | 0:1fa43ab66921 | 304 | int tlv_parse(uint8_t * buffer, size_t bufferLen, lwm2m_data_t ** dataP); |
terencez | 0:1fa43ab66921 | 305 | int tlv_serialize(bool isResourceInstance, int size, lwm2m_data_t * dataP, uint8_t ** bufferP); |
terencez | 0:1fa43ab66921 | 306 | |
terencez | 0:1fa43ab66921 | 307 | // defined in json.c |
terencez | 0:1fa43ab66921 | 308 | #ifdef LWM2M_SUPPORT_JSON |
terencez | 0:1fa43ab66921 | 309 | int json_parse(lwm2m_uri_t * uriP, uint8_t * buffer, size_t bufferLen, lwm2m_data_t ** dataP); |
terencez | 0:1fa43ab66921 | 310 | int json_serialize(lwm2m_uri_t * uriP, int size, lwm2m_data_t * tlvP, uint8_t ** bufferP); |
terencez | 0:1fa43ab66921 | 311 | #endif |
terencez | 0:1fa43ab66921 | 312 | |
terencez | 0:1fa43ab66921 | 313 | // defined in discover.c |
terencez | 0:1fa43ab66921 | 314 | int discover_serialize(lwm2m_context_t * contextP, lwm2m_uri_t * uriP, lwm2m_server_t * serverP, int size, lwm2m_data_t * dataP, uint8_t ** bufferP); |
terencez | 0:1fa43ab66921 | 315 | |
terencez | 0:1fa43ab66921 | 316 | // defined in block1.c |
terencez | 0:1fa43ab66921 | 317 | coap_status_t coap_block1_handler(lwm2m_block1_data_t ** block1Data, uint16_t mid, uint8_t * buffer, size_t length, uint16_t blockSize, uint32_t blockNum, bool blockMore, uint8_t ** outputBuffer, size_t * outputLength); |
terencez | 0:1fa43ab66921 | 318 | void free_block1_buffer(lwm2m_block1_data_t * block1Data); |
terencez | 0:1fa43ab66921 | 319 | |
terencez | 0:1fa43ab66921 | 320 | // defined in utils.c |
terencez | 0:1fa43ab66921 | 321 | lwm2m_data_type_t utils_depthToDatatype(uri_depth_t depth); |
terencez | 0:1fa43ab66921 | 322 | lwm2m_binding_t utils_stringToBinding(uint8_t *buffer, size_t length); |
terencez | 0:1fa43ab66921 | 323 | lwm2m_media_type_t utils_convertMediaType(coap_content_type_t type); |
terencez | 0:1fa43ab66921 | 324 | int utils_isAltPathValid(const char * altPath); |
terencez | 0:1fa43ab66921 | 325 | int utils_stringCopy(char * buffer, size_t length, const char * str); |
terencez | 0:1fa43ab66921 | 326 | int utils_intCopy(char * buffer, size_t length, int32_t value); |
terencez | 0:1fa43ab66921 | 327 | size_t utils_intToText(int64_t data, uint8_t * string, size_t length); |
terencez | 0:1fa43ab66921 | 328 | size_t utils_floatToText(double data, uint8_t * string, size_t length); |
terencez | 0:1fa43ab66921 | 329 | int utils_plainTextToInt64(uint8_t * buffer, int length, int64_t * dataP); |
terencez | 0:1fa43ab66921 | 330 | int utils_plainTextToFloat64(uint8_t * buffer, int length, double * dataP); |
terencez | 0:1fa43ab66921 | 331 | size_t utils_int64ToPlainText(int64_t data, uint8_t ** bufferP); |
terencez | 0:1fa43ab66921 | 332 | size_t utils_float64ToPlainText(double data, uint8_t ** bufferP); |
terencez | 0:1fa43ab66921 | 333 | size_t utils_boolToPlainText(bool data, uint8_t ** bufferP); |
terencez | 0:1fa43ab66921 | 334 | void utils_copyValue(void * dst, const void * src, size_t len); |
terencez | 0:1fa43ab66921 | 335 | int utils_opaqueToInt(const uint8_t * buffer, size_t buffer_len, int64_t * dataP); |
terencez | 0:1fa43ab66921 | 336 | int utils_opaqueToFloat(const uint8_t * buffer, size_t buffer_len, double * dataP); |
terencez | 0:1fa43ab66921 | 337 | size_t utils_encodeInt(int64_t data, uint8_t data_buffer[_PRV_64BIT_BUFFER_SIZE]); |
terencez | 0:1fa43ab66921 | 338 | size_t utils_encodeFloat(double data, uint8_t data_buffer[_PRV_64BIT_BUFFER_SIZE]); |
terencez | 0:1fa43ab66921 | 339 | size_t utils_base64ToOpaque(uint8_t * dataP, size_t dataLen, uint8_t ** bufferP); |
terencez | 0:1fa43ab66921 | 340 | size_t utils_opaqueToBase64(uint8_t * dataP, size_t dataLen, uint8_t ** bufferP); |
terencez | 0:1fa43ab66921 | 341 | size_t utils_base64Encode(uint8_t * dataP, size_t dataLen, uint8_t * bufferP, size_t bufferLen); |
terencez | 0:1fa43ab66921 | 342 | #ifdef LWM2M_CLIENT_MODE |
terencez | 0:1fa43ab66921 | 343 | lwm2m_server_t * utils_findServer(lwm2m_context_t * contextP, void * fromSessionH); |
terencez | 0:1fa43ab66921 | 344 | lwm2m_server_t * utils_findBootstrapServer(lwm2m_context_t * contextP, void * fromSessionH); |
terencez | 0:1fa43ab66921 | 345 | #endif |
terencez | 0:1fa43ab66921 | 346 | |
terencez | 0:1fa43ab66921 | 347 | #endif |