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