Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
m2mtlvserializer.h
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 #include "mbed-client/m2mvector.h" 00017 #include "mbed-client/m2mobject.h" 00018 #include "mbed-client/m2mobjectinstance.h" 00019 #include "mbed-client/m2mresource.h" 00020 00021 /** 00022 * @brief M2MTLVSerializer 00023 * TLV Serialiser constructs the binary representation of object instances, 00024 * resources and resource instances (see OMA-LWM2M specification, chapter 6.1 00025 * for resource model) as OMA-TLV according described in chapter 6.3.3. 00026 * 00027 */ 00028 class M2MTLVSerializer { 00029 00030 public: 00031 00032 /** 00033 * Constructor. 00034 */ 00035 M2MTLVSerializer(); 00036 00037 /** 00038 * Destructor. 00039 */ 00040 ~M2MTLVSerializer(); 00041 00042 /** 00043 * Serialises given objects instances that contain resources or multiple 00044 * resources. Object instance IDs are also encoded. This method must be 00045 * used when an operation targets an object with (potential) multiple 00046 * instances like "GET /1". In that case the generated TLV will contain the 00047 * following data: 00048 * <ul> 00049 * <li> ./0 00050 * <li> ./0/0 00051 * <li> ./0/1 00052 * <li> ... 00053 * <li> ./1 00054 * <li> ./1/0 00055 * <li> ./1/1 00056 * <li> ... 00057 * </ul> 00058 * 00059 * @param objects List of object instances. 00060 * @return Object instances encoded binary as OMA-TLV 00061 * @see #serializeObjectInstances(List) 00062 */ 00063 uint8_t* serialize(M2MObjectInstanceList object_instance_list, uint32_t &size); 00064 00065 /** 00066 * Serialises given resources with no information about the parent object 00067 * instance. This method must be used when an operation targets an object 00068 * instance like "GET /1/0" or a single-instance object like "GET /3//". 00069 * Resources may have single or multiple instances. The generated TLV will 00070 * contain the following data as response to "GET /3//": 00071 * <ul> 00072 * <li> ./0 00073 * <li> ./1 00074 * <li> ./2 00075 * <li> ./6/0 (1st instance of a multiple resource) 00076 * <li> ./6/1 (2nd instance of a multiple resource) 00077 * <li> ... 00078 * </ul> 00079 * @param resources Array of resources and resource instances. 00080 * @return Resources encoded binary as OMA-TLV 00081 * @see #serializeResources(List) 00082 */ 00083 uint8_t* serialize(M2MResourceList resource_list, uint32_t &size); 00084 00085 uint8_t* serialize(M2MResource *resource, uint32_t &size); 00086 00087 private : 00088 00089 uint8_t* serialize_object_instances(M2MObjectInstanceList object_instance_list, uint32_t &size); 00090 00091 uint8_t* serialize_resources(M2MResourceList resource_list, uint32_t &size, bool &valid); 00092 00093 void serialize(uint16_t id, M2MObjectInstance *object_instance, uint8_t *&data, uint32_t &size); 00094 00095 bool serialize (M2MResource *resource, uint8_t *&data, uint32_t &size); 00096 00097 bool serialize_resource(M2MResource *resource, uint8_t *&data, uint32_t &size); 00098 00099 bool serialize_multiple_resource(M2MResource *resource, uint8_t *&data, uint32_t &size); 00100 00101 void serialize_resource_instance(uint16_t id, M2MResourceInstance *resource, uint8_t *&data, uint32_t &size); 00102 00103 void serialize_TILV (uint8_t type, uint16_t id, uint8_t *value, uint32_t value_length, uint8_t *&data, uint32_t &size); 00104 00105 uint8_t* serialize_id(uint16_t id, uint32_t &size); 00106 00107 uint8_t* serialize_length(uint32_t length, uint32_t &size); 00108 };
Generated on Tue Jul 12 2022 21:20:28 by
1.7.2