pick up wakaama files from https://github.com/eclipse/wakaama

Committer:
terencez
Date:
Wed Apr 19 11:27:34 2017 +0000
Revision:
0:c2dff8cbb91a
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew 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 /*
terencez 0:c2dff8cbb91a 23 Copyright (c) 2013, 2014 Intel Corporation
terencez 0:c2dff8cbb91a 24
terencez 0:c2dff8cbb91a 25 Redistribution and use in source and binary forms, with or without modification,
terencez 0:c2dff8cbb91a 26 are permitted provided that the following conditions are met:
terencez 0:c2dff8cbb91a 27
terencez 0:c2dff8cbb91a 28 * Redistributions of source code must retain the above copyright notice,
terencez 0:c2dff8cbb91a 29 this list of conditions and the following disclaimer.
terencez 0:c2dff8cbb91a 30 * Redistributions in binary form must reproduce the above copyright notice,
terencez 0:c2dff8cbb91a 31 this list of conditions and the following disclaimer in the documentation
terencez 0:c2dff8cbb91a 32 and/or other materials provided with the distribution.
terencez 0:c2dff8cbb91a 33 * Neither the name of Intel Corporation nor the names of its contributors
terencez 0:c2dff8cbb91a 34 may be used to endorse or promote products derived from this software
terencez 0:c2dff8cbb91a 35 without specific prior written permission.
terencez 0:c2dff8cbb91a 36
terencez 0:c2dff8cbb91a 37 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
terencez 0:c2dff8cbb91a 38 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
terencez 0:c2dff8cbb91a 39 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
terencez 0:c2dff8cbb91a 40 IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
terencez 0:c2dff8cbb91a 41 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
terencez 0:c2dff8cbb91a 42 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
terencez 0:c2dff8cbb91a 43 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
terencez 0:c2dff8cbb91a 44 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
terencez 0:c2dff8cbb91a 45 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
terencez 0:c2dff8cbb91a 46 THE POSSIBILITY OF SUCH DAMAGE.
terencez 0:c2dff8cbb91a 47
terencez 0:c2dff8cbb91a 48 David Navarro <david.navarro@intel.com>
terencez 0:c2dff8cbb91a 49
terencez 0:c2dff8cbb91a 50 */
terencez 0:c2dff8cbb91a 51
terencez 0:c2dff8cbb91a 52 #include "internals.h"
terencez 0:c2dff8cbb91a 53 #include <stdlib.h>
terencez 0:c2dff8cbb91a 54 #include <string.h>
terencez 0:c2dff8cbb91a 55 #include <ctype.h>
terencez 0:c2dff8cbb91a 56
terencez 0:c2dff8cbb91a 57
terencez 0:c2dff8cbb91a 58 static int prv_parseNumber(uint8_t * uriString,
terencez 0:c2dff8cbb91a 59 size_t uriLength,
terencez 0:c2dff8cbb91a 60 size_t * headP)
terencez 0:c2dff8cbb91a 61 {
terencez 0:c2dff8cbb91a 62 int result = 0;
terencez 0:c2dff8cbb91a 63
terencez 0:c2dff8cbb91a 64 if (uriString[*headP] == '/')
terencez 0:c2dff8cbb91a 65 {
terencez 0:c2dff8cbb91a 66 // empty Object Instance ID with resource ID is not allowed
terencez 0:c2dff8cbb91a 67 return -1;
terencez 0:c2dff8cbb91a 68 }
terencez 0:c2dff8cbb91a 69 while (*headP < uriLength && uriString[*headP] != '/')
terencez 0:c2dff8cbb91a 70 {
terencez 0:c2dff8cbb91a 71 if ('0' <= uriString[*headP] && uriString[*headP] <= '9')
terencez 0:c2dff8cbb91a 72 {
terencez 0:c2dff8cbb91a 73 result += uriString[*headP] - '0';
terencez 0:c2dff8cbb91a 74 result *= 10;
terencez 0:c2dff8cbb91a 75 }
terencez 0:c2dff8cbb91a 76 else
terencez 0:c2dff8cbb91a 77 {
terencez 0:c2dff8cbb91a 78 return -1;
terencez 0:c2dff8cbb91a 79 }
terencez 0:c2dff8cbb91a 80 *headP += 1;
terencez 0:c2dff8cbb91a 81 }
terencez 0:c2dff8cbb91a 82
terencez 0:c2dff8cbb91a 83 result /= 10;
terencez 0:c2dff8cbb91a 84 return result;
terencez 0:c2dff8cbb91a 85 }
terencez 0:c2dff8cbb91a 86
terencez 0:c2dff8cbb91a 87
terencez 0:c2dff8cbb91a 88 int uri_getNumber(uint8_t * uriString,
terencez 0:c2dff8cbb91a 89 size_t uriLength)
terencez 0:c2dff8cbb91a 90 {
terencez 0:c2dff8cbb91a 91 size_t index = 0;
terencez 0:c2dff8cbb91a 92
terencez 0:c2dff8cbb91a 93 return prv_parseNumber(uriString, uriLength, &index);
terencez 0:c2dff8cbb91a 94 }
terencez 0:c2dff8cbb91a 95
terencez 0:c2dff8cbb91a 96
terencez 0:c2dff8cbb91a 97 lwm2m_uri_t * uri_decode(char * altPath,
terencez 0:c2dff8cbb91a 98 multi_option_t *uriPath)
terencez 0:c2dff8cbb91a 99 {
terencez 0:c2dff8cbb91a 100 lwm2m_uri_t * uriP;
terencez 0:c2dff8cbb91a 101 int readNum;
terencez 0:c2dff8cbb91a 102
terencez 0:c2dff8cbb91a 103 LOG_ARG("altPath: \"%s\"", altPath);
terencez 0:c2dff8cbb91a 104
terencez 0:c2dff8cbb91a 105 uriP = (lwm2m_uri_t *)lwm2m_malloc(sizeof(lwm2m_uri_t));
terencez 0:c2dff8cbb91a 106 if (NULL == uriP) return NULL;
terencez 0:c2dff8cbb91a 107
terencez 0:c2dff8cbb91a 108 memset(uriP, 0, sizeof(lwm2m_uri_t));
terencez 0:c2dff8cbb91a 109
terencez 0:c2dff8cbb91a 110 // Read object ID
terencez 0:c2dff8cbb91a 111 if (NULL != uriPath
terencez 0:c2dff8cbb91a 112 && URI_REGISTRATION_SEGMENT_LEN == uriPath->len
terencez 0:c2dff8cbb91a 113 && 0 == strncmp(URI_REGISTRATION_SEGMENT, (char *)uriPath->data, uriPath->len))
terencez 0:c2dff8cbb91a 114 {
terencez 0:c2dff8cbb91a 115 uriP->flag |= LWM2M_URI_FLAG_REGISTRATION;
terencez 0:c2dff8cbb91a 116 uriPath = uriPath->next;
terencez 0:c2dff8cbb91a 117 if (uriPath == NULL) return uriP;
terencez 0:c2dff8cbb91a 118 }
terencez 0:c2dff8cbb91a 119 else if (NULL != uriPath
terencez 0:c2dff8cbb91a 120 && URI_BOOTSTRAP_SEGMENT_LEN == uriPath->len
terencez 0:c2dff8cbb91a 121 && 0 == strncmp(URI_BOOTSTRAP_SEGMENT, (char *)uriPath->data, uriPath->len))
terencez 0:c2dff8cbb91a 122 {
terencez 0:c2dff8cbb91a 123 uriP->flag |= LWM2M_URI_FLAG_BOOTSTRAP;
terencez 0:c2dff8cbb91a 124 uriPath = uriPath->next;
terencez 0:c2dff8cbb91a 125 if (uriPath != NULL) goto error;
terencez 0:c2dff8cbb91a 126 return uriP;
terencez 0:c2dff8cbb91a 127 }
terencez 0:c2dff8cbb91a 128
terencez 0:c2dff8cbb91a 129 if ((uriP->flag & LWM2M_URI_MASK_TYPE) != LWM2M_URI_FLAG_REGISTRATION)
terencez 0:c2dff8cbb91a 130 {
terencez 0:c2dff8cbb91a 131 // Read altPath if any
terencez 0:c2dff8cbb91a 132 if (altPath != NULL)
terencez 0:c2dff8cbb91a 133 {
terencez 0:c2dff8cbb91a 134 int i;
terencez 0:c2dff8cbb91a 135 if (NULL == uriPath)
terencez 0:c2dff8cbb91a 136 {
terencez 0:c2dff8cbb91a 137 lwm2m_free(uriP);
terencez 0:c2dff8cbb91a 138 return NULL;
terencez 0:c2dff8cbb91a 139 }
terencez 0:c2dff8cbb91a 140 for (i = 0 ; i < uriPath->len ; i++)
terencez 0:c2dff8cbb91a 141 {
terencez 0:c2dff8cbb91a 142 if (uriPath->data[i] != altPath[i+1])
terencez 0:c2dff8cbb91a 143 {
terencez 0:c2dff8cbb91a 144 lwm2m_free(uriP);
terencez 0:c2dff8cbb91a 145 return NULL;
terencez 0:c2dff8cbb91a 146 }
terencez 0:c2dff8cbb91a 147 }
terencez 0:c2dff8cbb91a 148 uriPath = uriPath->next;
terencez 0:c2dff8cbb91a 149 }
terencez 0:c2dff8cbb91a 150 if (NULL == uriPath || uriPath->len == 0)
terencez 0:c2dff8cbb91a 151 {
terencez 0:c2dff8cbb91a 152 uriP->flag |= LWM2M_URI_FLAG_DELETE_ALL;
terencez 0:c2dff8cbb91a 153 return uriP;
terencez 0:c2dff8cbb91a 154 }
terencez 0:c2dff8cbb91a 155 }
terencez 0:c2dff8cbb91a 156
terencez 0:c2dff8cbb91a 157 readNum = uri_getNumber(uriPath->data, uriPath->len);
terencez 0:c2dff8cbb91a 158 if (readNum < 0 || readNum > LWM2M_MAX_ID) goto error;
terencez 0:c2dff8cbb91a 159 uriP->objectId = (uint16_t)readNum;
terencez 0:c2dff8cbb91a 160 uriP->flag |= LWM2M_URI_FLAG_OBJECT_ID;
terencez 0:c2dff8cbb91a 161 uriPath = uriPath->next;
terencez 0:c2dff8cbb91a 162
terencez 0:c2dff8cbb91a 163 if ((uriP->flag & LWM2M_URI_MASK_TYPE) == LWM2M_URI_FLAG_REGISTRATION)
terencez 0:c2dff8cbb91a 164 {
terencez 0:c2dff8cbb91a 165 if (uriPath != NULL) goto error;
terencez 0:c2dff8cbb91a 166 return uriP;
terencez 0:c2dff8cbb91a 167 }
terencez 0:c2dff8cbb91a 168 uriP->flag |= LWM2M_URI_FLAG_DM;
terencez 0:c2dff8cbb91a 169
terencez 0:c2dff8cbb91a 170 if (uriPath == NULL) return uriP;
terencez 0:c2dff8cbb91a 171
terencez 0:c2dff8cbb91a 172 // Read object instance
terencez 0:c2dff8cbb91a 173 if (uriPath->len != 0)
terencez 0:c2dff8cbb91a 174 {
terencez 0:c2dff8cbb91a 175 readNum = uri_getNumber(uriPath->data, uriPath->len);
terencez 0:c2dff8cbb91a 176 if (readNum < 0 || readNum >= LWM2M_MAX_ID) goto error;
terencez 0:c2dff8cbb91a 177 uriP->instanceId = (uint16_t)readNum;
terencez 0:c2dff8cbb91a 178 uriP->flag |= LWM2M_URI_FLAG_INSTANCE_ID;
terencez 0:c2dff8cbb91a 179 }
terencez 0:c2dff8cbb91a 180 uriPath = uriPath->next;
terencez 0:c2dff8cbb91a 181
terencez 0:c2dff8cbb91a 182 if (uriPath == NULL) return uriP;
terencez 0:c2dff8cbb91a 183
terencez 0:c2dff8cbb91a 184 // Read resource ID
terencez 0:c2dff8cbb91a 185 if (uriPath->len != 0)
terencez 0:c2dff8cbb91a 186 {
terencez 0:c2dff8cbb91a 187 // resource ID without an instance ID is not allowed
terencez 0:c2dff8cbb91a 188 if ((uriP->flag & LWM2M_URI_FLAG_INSTANCE_ID) == 0) goto error;
terencez 0:c2dff8cbb91a 189
terencez 0:c2dff8cbb91a 190 readNum = uri_getNumber(uriPath->data, uriPath->len);
terencez 0:c2dff8cbb91a 191 if (readNum < 0 || readNum > LWM2M_MAX_ID) goto error;
terencez 0:c2dff8cbb91a 192 uriP->resourceId = (uint16_t)readNum;
terencez 0:c2dff8cbb91a 193 uriP->flag |= LWM2M_URI_FLAG_RESOURCE_ID;
terencez 0:c2dff8cbb91a 194 }
terencez 0:c2dff8cbb91a 195
terencez 0:c2dff8cbb91a 196 // must be the last segment
terencez 0:c2dff8cbb91a 197 if (NULL == uriPath->next)
terencez 0:c2dff8cbb91a 198 {
terencez 0:c2dff8cbb91a 199 LOG_URI(uriP);
terencez 0:c2dff8cbb91a 200 return uriP;
terencez 0:c2dff8cbb91a 201 }
terencez 0:c2dff8cbb91a 202
terencez 0:c2dff8cbb91a 203 error:
terencez 0:c2dff8cbb91a 204 LOG("Exiting on error");
terencez 0:c2dff8cbb91a 205 lwm2m_free(uriP);
terencez 0:c2dff8cbb91a 206 return NULL;
terencez 0:c2dff8cbb91a 207 }
terencez 0:c2dff8cbb91a 208
terencez 0:c2dff8cbb91a 209 int lwm2m_stringToUri(const char * buffer,
terencez 0:c2dff8cbb91a 210 size_t buffer_len,
terencez 0:c2dff8cbb91a 211 lwm2m_uri_t * uriP)
terencez 0:c2dff8cbb91a 212 {
terencez 0:c2dff8cbb91a 213 size_t head;
terencez 0:c2dff8cbb91a 214 int readNum;
terencez 0:c2dff8cbb91a 215
terencez 0:c2dff8cbb91a 216 LOG_ARG("buffer_len: %u, buffer: \"%.*s\"", buffer_len, buffer_len, buffer);
terencez 0:c2dff8cbb91a 217
terencez 0:c2dff8cbb91a 218 if (buffer == NULL || buffer_len == 0 || uriP == NULL) return 0;
terencez 0:c2dff8cbb91a 219
terencez 0:c2dff8cbb91a 220 memset(uriP, 0, sizeof(lwm2m_uri_t));
terencez 0:c2dff8cbb91a 221
terencez 0:c2dff8cbb91a 222 // Skip any white space
terencez 0:c2dff8cbb91a 223 head = 0;
terencez 0:c2dff8cbb91a 224 while (head < buffer_len && isspace(buffer[head]&0xFF))
terencez 0:c2dff8cbb91a 225 {
terencez 0:c2dff8cbb91a 226 head++;
terencez 0:c2dff8cbb91a 227 }
terencez 0:c2dff8cbb91a 228 if (head == buffer_len) return 0;
terencez 0:c2dff8cbb91a 229
terencez 0:c2dff8cbb91a 230 // Check the URI start with a '/'
terencez 0:c2dff8cbb91a 231 if (buffer[head] != '/') return 0;
terencez 0:c2dff8cbb91a 232 head++;
terencez 0:c2dff8cbb91a 233 if (head == buffer_len) return 0;
terencez 0:c2dff8cbb91a 234
terencez 0:c2dff8cbb91a 235 // Read object ID
terencez 0:c2dff8cbb91a 236 readNum = prv_parseNumber((uint8_t *)buffer, buffer_len, &head);
terencez 0:c2dff8cbb91a 237 if (readNum < 0 || readNum > LWM2M_MAX_ID) return 0;
terencez 0:c2dff8cbb91a 238 uriP->objectId = (uint16_t)readNum;
terencez 0:c2dff8cbb91a 239 uriP->flag |= LWM2M_URI_FLAG_OBJECT_ID;
terencez 0:c2dff8cbb91a 240
terencez 0:c2dff8cbb91a 241 if (buffer[head] == '/') head += 1;
terencez 0:c2dff8cbb91a 242 if (head >= buffer_len)
terencez 0:c2dff8cbb91a 243 {
terencez 0:c2dff8cbb91a 244 LOG_ARG("Parsed characters: %u", head);
terencez 0:c2dff8cbb91a 245 LOG_URI(uriP);
terencez 0:c2dff8cbb91a 246 return head;
terencez 0:c2dff8cbb91a 247 }
terencez 0:c2dff8cbb91a 248
terencez 0:c2dff8cbb91a 249 readNum = prv_parseNumber((uint8_t *)buffer, buffer_len, &head);
terencez 0:c2dff8cbb91a 250 if (readNum < 0 || readNum >= LWM2M_MAX_ID) return 0;
terencez 0:c2dff8cbb91a 251 uriP->instanceId = (uint16_t)readNum;
terencez 0:c2dff8cbb91a 252 uriP->flag |= LWM2M_URI_FLAG_INSTANCE_ID;
terencez 0:c2dff8cbb91a 253
terencez 0:c2dff8cbb91a 254 if (buffer[head] == '/') head += 1;
terencez 0:c2dff8cbb91a 255 if (head >= buffer_len)
terencez 0:c2dff8cbb91a 256 {
terencez 0:c2dff8cbb91a 257 LOG_ARG("Parsed characters: %u", head);
terencez 0:c2dff8cbb91a 258 LOG_URI(uriP);
terencez 0:c2dff8cbb91a 259 return head;
terencez 0:c2dff8cbb91a 260 }
terencez 0:c2dff8cbb91a 261
terencez 0:c2dff8cbb91a 262 readNum = prv_parseNumber((uint8_t *)buffer, buffer_len, &head);
terencez 0:c2dff8cbb91a 263 if (readNum < 0 || readNum >= LWM2M_MAX_ID) return 0;
terencez 0:c2dff8cbb91a 264 uriP->resourceId = (uint16_t)readNum;
terencez 0:c2dff8cbb91a 265 uriP->flag |= LWM2M_URI_FLAG_RESOURCE_ID;
terencez 0:c2dff8cbb91a 266
terencez 0:c2dff8cbb91a 267 if (head != buffer_len) return 0;
terencez 0:c2dff8cbb91a 268
terencez 0:c2dff8cbb91a 269 LOG_ARG("Parsed characters: %u", head);
terencez 0:c2dff8cbb91a 270 LOG_URI(uriP);
terencez 0:c2dff8cbb91a 271
terencez 0:c2dff8cbb91a 272 return head;
terencez 0:c2dff8cbb91a 273 }
terencez 0:c2dff8cbb91a 274
terencez 0:c2dff8cbb91a 275 int uri_toString(lwm2m_uri_t * uriP,
terencez 0:c2dff8cbb91a 276 uint8_t * buffer,
terencez 0:c2dff8cbb91a 277 size_t bufferLen,
terencez 0:c2dff8cbb91a 278 uri_depth_t * depthP)
terencez 0:c2dff8cbb91a 279 {
terencez 0:c2dff8cbb91a 280 size_t head;
terencez 0:c2dff8cbb91a 281 int res;
terencez 0:c2dff8cbb91a 282
terencez 0:c2dff8cbb91a 283 LOG_ARG("bufferLen: %u", bufferLen);
terencez 0:c2dff8cbb91a 284 LOG_URI(uriP);
terencez 0:c2dff8cbb91a 285
terencez 0:c2dff8cbb91a 286 buffer[0] = '/';
terencez 0:c2dff8cbb91a 287
terencez 0:c2dff8cbb91a 288 if (uriP == NULL)
terencez 0:c2dff8cbb91a 289 {
terencez 0:c2dff8cbb91a 290 if (depthP) *depthP = URI_DEPTH_OBJECT;
terencez 0:c2dff8cbb91a 291 return 1;
terencez 0:c2dff8cbb91a 292 }
terencez 0:c2dff8cbb91a 293
terencez 0:c2dff8cbb91a 294 head = 1;
terencez 0:c2dff8cbb91a 295
terencez 0:c2dff8cbb91a 296 res = utils_intToText(uriP->objectId, buffer + head, bufferLen - head);
terencez 0:c2dff8cbb91a 297 if (res <= 0) return -1;
terencez 0:c2dff8cbb91a 298 head += res;
terencez 0:c2dff8cbb91a 299 if (head >= bufferLen - 1) return -1;
terencez 0:c2dff8cbb91a 300 if (depthP) *depthP = URI_DEPTH_OBJECT_INSTANCE;
terencez 0:c2dff8cbb91a 301
terencez 0:c2dff8cbb91a 302 if (LWM2M_URI_IS_SET_INSTANCE(uriP))
terencez 0:c2dff8cbb91a 303 {
terencez 0:c2dff8cbb91a 304 buffer[head] = '/';
terencez 0:c2dff8cbb91a 305 head++;
terencez 0:c2dff8cbb91a 306 res = utils_intToText(uriP->instanceId, buffer + head, bufferLen - head);
terencez 0:c2dff8cbb91a 307 if (res <= 0) return -1;
terencez 0:c2dff8cbb91a 308 head += res;
terencez 0:c2dff8cbb91a 309 if (head >= bufferLen - 1) return -1;
terencez 0:c2dff8cbb91a 310 if (depthP) *depthP = URI_DEPTH_RESOURCE;
terencez 0:c2dff8cbb91a 311 if (LWM2M_URI_IS_SET_RESOURCE(uriP))
terencez 0:c2dff8cbb91a 312 {
terencez 0:c2dff8cbb91a 313 buffer[head] = '/';
terencez 0:c2dff8cbb91a 314 head++;
terencez 0:c2dff8cbb91a 315 res = utils_intToText(uriP->resourceId, buffer + head, bufferLen - head);
terencez 0:c2dff8cbb91a 316 if (res <= 0) return -1;
terencez 0:c2dff8cbb91a 317 head += res;
terencez 0:c2dff8cbb91a 318 if (head >= bufferLen - 1) return -1;
terencez 0:c2dff8cbb91a 319 if (depthP) *depthP = URI_DEPTH_RESOURCE_INSTANCE;
terencez 0:c2dff8cbb91a 320 }
terencez 0:c2dff8cbb91a 321 }
terencez 0:c2dff8cbb91a 322
terencez 0:c2dff8cbb91a 323 buffer[head] = '/';
terencez 0:c2dff8cbb91a 324 head++;
terencez 0:c2dff8cbb91a 325
terencez 0:c2dff8cbb91a 326 LOG_ARG("length: %u, buffer: \"%.*s\"", head, head, buffer);
terencez 0:c2dff8cbb91a 327
terencez 0:c2dff8cbb91a 328 return head;
terencez 0:c2dff8cbb91a 329 }