This is a fork due to permission issues

Dependencies:   mbed Socket lwip-eth lwip-sys lwip

Fork of 6_songs-from-the-cloud by MakingMusicWorkshop

Committer:
maclobdell
Date:
Wed May 18 19:06:32 2016 +0000
Revision:
0:f7c60d3e7b8a
clean version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
maclobdell 0:f7c60d3e7b8a 1 # How to use the mbed Client API
maclobdell 0:f7c60d3e7b8a 2
maclobdell 0:f7c60d3e7b8a 3 This section explains how to create different types of Objects, Object Instances and Resources for the client to comply with the OMA LWM2M specifications.
maclobdell 0:f7c60d3e7b8a 4
maclobdell 0:f7c60d3e7b8a 5 In order for the client to communicate its resources to the mbed Device Server (mbed DS), it needs to create Objects, Object Instances and Resources. You can do this easily with the Client C++ APIs, where the client can define its resources in a similar structure to the one defined in the LWM2M specification.
maclobdell 0:f7c60d3e7b8a 6
maclobdell 0:f7c60d3e7b8a 7 This quick guide will explain how you can create and configure these resources using the C++ API.
maclobdell 0:f7c60d3e7b8a 8
maclobdell 0:f7c60d3e7b8a 9 ## How to create and configure Objects
maclobdell 0:f7c60d3e7b8a 10
maclobdell 0:f7c60d3e7b8a 11 The M2MObject class is derived from the M2MBase class, so all the public methods can be used from the M2MObject and its derived classes.
maclobdell 0:f7c60d3e7b8a 12
maclobdell 0:f7c60d3e7b8a 13 ### Creating OMA-defined Objects
maclobdell 0:f7c60d3e7b8a 14
maclobdell 0:f7c60d3e7b8a 15 #### Device Object
maclobdell 0:f7c60d3e7b8a 16
maclobdell 0:f7c60d3e7b8a 17 There is a direct API in the M2MInterfaceFactory class to create a Device Object:
maclobdell 0:f7c60d3e7b8a 18
maclobdell 0:f7c60d3e7b8a 19 `static M2MDevice *create_device();`
maclobdell 0:f7c60d3e7b8a 20
maclobdell 0:f7c60d3e7b8a 21 Because there can be only one instance of M2MDevice, it is a static class and you can delete it as follows:
maclobdell 0:f7c60d3e7b8a 22
maclobdell 0:f7c60d3e7b8a 23 `M2MDevice::delete_instance();`
maclobdell 0:f7c60d3e7b8a 24
maclobdell 0:f7c60d3e7b8a 25 Check the M2MDevice class documentation to see how to configure the device object, as well as how to create appropriate Resources and assign values to them.
maclobdell 0:f7c60d3e7b8a 26
maclobdell 0:f7c60d3e7b8a 27 #### Security Object
maclobdell 0:f7c60d3e7b8a 28
maclobdell 0:f7c60d3e7b8a 29 There is a direct API in the M2MInterfaceFactory class to create a Security Object:
maclobdell 0:f7c60d3e7b8a 30
maclobdell 0:f7c60d3e7b8a 31 `static M2MSecurity *create_security(M2MSecurity::ServerType server_type);`
maclobdell 0:f7c60d3e7b8a 32
maclobdell 0:f7c60d3e7b8a 33 You can create a Bootstrap or normal mbed Device Server by passing the appropriate `enum` value.
maclobdell 0:f7c60d3e7b8a 34
maclobdell 0:f7c60d3e7b8a 35 Check the M2MSecurity class documentation to see how to configure the security object, as well as how to create appropriate Resources and assign values to them.
maclobdell 0:f7c60d3e7b8a 36
maclobdell 0:f7c60d3e7b8a 37 #### Creating a custom Object
maclobdell 0:f7c60d3e7b8a 38
maclobdell 0:f7c60d3e7b8a 39 As per the OMA LWM2M specification, the client must have defined Objects, under which it can create Object Instances. You can create an M2MObject using this API from the M2MInterfaceFactory class:
maclobdell 0:f7c60d3e7b8a 40
maclobdell 0:f7c60d3e7b8a 41 `static M2MObject *create_object(const String &name);`
maclobdell 0:f7c60d3e7b8a 42
maclobdell 0:f7c60d3e7b8a 43 You need to pass the name of the Object that you would like to create (for example `Test`); this will create an object with that name in mbed DS.
maclobdell 0:f7c60d3e7b8a 44
maclobdell 0:f7c60d3e7b8a 45 #### Configuring the Object
maclobdell 0:f7c60d3e7b8a 46
maclobdell 0:f7c60d3e7b8a 47 Once you have created an Object (whether OMA-specific or custom), you can configure various parameters in that object so that they can be controlled or modified to affect communication with mbed DS.
maclobdell 0:f7c60d3e7b8a 48
maclobdell 0:f7c60d3e7b8a 49 Here, we discuss a few of the most important parameters, which you must configure properly to work with the objects.
maclobdell 0:f7c60d3e7b8a 50
maclobdell 0:f7c60d3e7b8a 51 ##### Setting Operation Mode
maclobdell 0:f7c60d3e7b8a 52
maclobdell 0:f7c60d3e7b8a 53 You can set the operation mode of the objects so that they can handle `GET`, `PUT`, `POST`, `DELETE` or a combination of these requests coming from mbed DS.
maclobdell 0:f7c60d3e7b8a 54
maclobdell 0:f7c60d3e7b8a 55 The API that sets the operation mode (present in the M2MBase class) is:
maclobdell 0:f7c60d3e7b8a 56
maclobdell 0:f7c60d3e7b8a 57 `virtual void set_operation(M2MBase::Operation operation);`
maclobdell 0:f7c60d3e7b8a 58
maclobdell 0:f7c60d3e7b8a 59 ##### Setting Observable Mode
maclobdell 0:f7c60d3e7b8a 60
maclobdell 0:f7c60d3e7b8a 61 You can set the object to be an observing resource. You can set the observable mode using the following API:
maclobdell 0:f7c60d3e7b8a 62
maclobdell 0:f7c60d3e7b8a 63 `virtual void set_observable(bool observable);`
maclobdell 0:f7c60d3e7b8a 64
maclobdell 0:f7c60d3e7b8a 65 ##### Setting CoAP content type
maclobdell 0:f7c60d3e7b8a 66
maclobdell 0:f7c60d3e7b8a 67 Currently, the only available content type is the OMA TLV type. The OMA TLV type works only for objects with a numeric value. For example, if you are creating a custom object it must be of a numeric type like `100`; only then the CoAP TLV type will work for the custom object.
maclobdell 0:f7c60d3e7b8a 68
maclobdell 0:f7c60d3e7b8a 69 If you want your object to support the TLV type, set the object's CoAP content type as `99`:
maclobdell 0:f7c60d3e7b8a 70
maclobdell 0:f7c60d3e7b8a 71 `virtual void set_coap_content_type(const uint8_t content_type);`
maclobdell 0:f7c60d3e7b8a 72
maclobdell 0:f7c60d3e7b8a 73 Later we will introduce support for the JSON content types.
maclobdell 0:f7c60d3e7b8a 74
maclobdell 0:f7c60d3e7b8a 75 ## How to create and configure Object Instances
maclobdell 0:f7c60d3e7b8a 76
maclobdell 0:f7c60d3e7b8a 77 The M2MObjectInstance class is derived from the M2MBase class, so all the public methods from M2MObjectInstance and its derived classes can be used.
maclobdell 0:f7c60d3e7b8a 78
maclobdell 0:f7c60d3e7b8a 79 ### Creating OMA defined ObjectInstance
maclobdell 0:f7c60d3e7b8a 80
maclobdell 0:f7c60d3e7b8a 81 #### Device ObjectInstance
maclobdell 0:f7c60d3e7b8a 82
maclobdell 0:f7c60d3e7b8a 83 Because there can only be one instance for the Device Object, the ObjectInstance is automatically created when creating an M2MDevice Object.
maclobdell 0:f7c60d3e7b8a 84
maclobdell 0:f7c60d3e7b8a 85 #### Security ObjectInstance
maclobdell 0:f7c60d3e7b8a 86
maclobdell 0:f7c60d3e7b8a 87 Because there can only be one instance for the Device Object, the Object Instance is automatically created when creating an M2MDevice Object based on a selected server type.
maclobdell 0:f7c60d3e7b8a 88
maclobdell 0:f7c60d3e7b8a 89 #### Creating custom object instances
maclobdell 0:f7c60d3e7b8a 90
maclobdell 0:f7c60d3e7b8a 91 As per the OMA LWM2M specification, the client must have created Object Instances under Objects, which will eventually contain Resources.
maclobdell 0:f7c60d3e7b8a 92
maclobdell 0:f7c60d3e7b8a 93 You can create an M2M Object Instance using this API from the M2MObject class:
maclobdell 0:f7c60d3e7b8a 94
maclobdell 0:f7c60d3e7b8a 95 `M2MObject::create_object_instance(uint16_t instance_id);`
maclobdell 0:f7c60d3e7b8a 96
maclobdell 0:f7c60d3e7b8a 97 You can pass an Object Instance ID to create appropriate Object Instances. Normally, Object Instances will start from `0` and increment. So the Object Instance structure on the mbed DS side would look like this:
maclobdell 0:f7c60d3e7b8a 98
maclobdell 0:f7c60d3e7b8a 99 `Object/Object Instance ID`
maclobdell 0:f7c60d3e7b8a 100
maclobdell 0:f7c60d3e7b8a 101 You need to pass the name of the Object Instance ID that you would like to create (for example `0`); this will create an object `/Test/0` in mbed DS.
maclobdell 0:f7c60d3e7b8a 102
maclobdell 0:f7c60d3e7b8a 103 ### Configuring the Object Instance
maclobdell 0:f7c60d3e7b8a 104
maclobdell 0:f7c60d3e7b8a 105 When you have created an Object Instance (whether OMA-specific or custom), you can configure various parameters in that object so that they can be controlled or modified to affect communication with mbed DS.
maclobdell 0:f7c60d3e7b8a 106
maclobdell 0:f7c60d3e7b8a 107 Here, we present a few of the most important parameters that you must configure properly to work with the object instances.
maclobdell 0:f7c60d3e7b8a 108
maclobdell 0:f7c60d3e7b8a 109 #### Setting operation mode
maclobdell 0:f7c60d3e7b8a 110
maclobdell 0:f7c60d3e7b8a 111 You can set the operation mode of the Object Instances so that they can handle `GET`, `PUT`, `POST`, `DELETE` or a combination of these requests coming from mbed DS.
maclobdell 0:f7c60d3e7b8a 112
maclobdell 0:f7c60d3e7b8a 113 The API that you can use to set the operation mode (present in the M2MBase class) is:
maclobdell 0:f7c60d3e7b8a 114
maclobdell 0:f7c60d3e7b8a 115 `virtual void set_operation(M2MBase::Operation operation);`
maclobdell 0:f7c60d3e7b8a 116
maclobdell 0:f7c60d3e7b8a 117 #### Setting observable mode
maclobdell 0:f7c60d3e7b8a 118
maclobdell 0:f7c60d3e7b8a 119 You can set the object to be an observing resource.
maclobdell 0:f7c60d3e7b8a 120
maclobdell 0:f7c60d3e7b8a 121 You can set the observable mode using the following API:
maclobdell 0:f7c60d3e7b8a 122
maclobdell 0:f7c60d3e7b8a 123 `virtual void set_observable(bool observable);`
maclobdell 0:f7c60d3e7b8a 124
maclobdell 0:f7c60d3e7b8a 125 #### Setting CoAP content type
maclobdell 0:f7c60d3e7b8a 126
maclobdell 0:f7c60d3e7b8a 127 Currently, the only available content type is the OMA TLV type. The OMA TLV type works only for objects with a numeric value. For example, if are creating a custom object it must be of a numeric type like `100`; only then the CoAP TLV type will work for the custom object.
maclobdell 0:f7c60d3e7b8a 128
maclobdell 0:f7c60d3e7b8a 129 If you want your object to support the TLV type, set the CoAP content type of the object to `99`:
maclobdell 0:f7c60d3e7b8a 130
maclobdell 0:f7c60d3e7b8a 131 `virtual void set_coap_content_type(const uint8_t content_type);`
maclobdell 0:f7c60d3e7b8a 132
maclobdell 0:f7c60d3e7b8a 133 Later we will introduce support for the JSON content types.
maclobdell 0:f7c60d3e7b8a 134
maclobdell 0:f7c60d3e7b8a 135 Apart from this, there are multiple APIs that provide getter and remove functions for Object Instances in the M2MObjectInstance class; check the API documentation for their usage.
maclobdell 0:f7c60d3e7b8a 136
maclobdell 0:f7c60d3e7b8a 137 ## How to create and configure Resources and Resource Instances
maclobdell 0:f7c60d3e7b8a 138
maclobdell 0:f7c60d3e7b8a 139 The M2MResource class is derived from the M2MResourceInstance, which in turn is derived from the M2MBase class, so all the public methods can be used from M2MResource or M2MResourceInstance and their derived classes.
maclobdell 0:f7c60d3e7b8a 140
maclobdell 0:f7c60d3e7b8a 141 ### Creating OMA-defined Resources
maclobdell 0:f7c60d3e7b8a 142
maclobdell 0:f7c60d3e7b8a 143 #### Device Object Resources
maclobdell 0:f7c60d3e7b8a 144
maclobdell 0:f7c60d3e7b8a 145 There are direct APIs to create and set values for the Device Resources. You can create the required Resource and set values based on their data types.
maclobdell 0:f7c60d3e7b8a 146
maclobdell 0:f7c60d3e7b8a 147 - For Resources that take `string` values:
maclobdell 0:f7c60d3e7b8a 148
maclobdell 0:f7c60d3e7b8a 149 `M2MResource* create_resource(DeviceResource resource, const String &value);`
maclobdell 0:f7c60d3e7b8a 150
maclobdell 0:f7c60d3e7b8a 151 - For Resources that take `integer` values:
maclobdell 0:f7c60d3e7b8a 152
maclobdell 0:f7c60d3e7b8a 153 `M2MResource* create_resource(DeviceResource resource, uint32_t value);`
maclobdell 0:f7c60d3e7b8a 154
maclobdell 0:f7c60d3e7b8a 155 - There are a few resources that can have multiple instances. To create these resources, use these APIs:
maclobdell 0:f7c60d3e7b8a 156
maclobdell 0:f7c60d3e7b8a 157 `M2MResourceInstance* create_resource_instance(DeviceResource resource, uint32_t value,uint16_t instance_id);`
maclobdell 0:f7c60d3e7b8a 158
maclobdell 0:f7c60d3e7b8a 159 Where `instance_id` is the Resource Instance ID, for example `/3/0/11/0`.
maclobdell 0:f7c60d3e7b8a 160
maclobdell 0:f7c60d3e7b8a 161 Check the M2MDevice API documentation to find which enums are supported for `integer` or `string` value types.
maclobdell 0:f7c60d3e7b8a 162
maclobdell 0:f7c60d3e7b8a 163 There are other APIs in the M2MDevice class that you can use to set, remove and modify new values for the resources.
maclobdell 0:f7c60d3e7b8a 164
maclobdell 0:f7c60d3e7b8a 165 #### Security Object Resources
maclobdell 0:f7c60d3e7b8a 166
maclobdell 0:f7c60d3e7b8a 167 There are direct APIs to create and set values for the Security Resources, based on their data types.
maclobdell 0:f7c60d3e7b8a 168
maclobdell 0:f7c60d3e7b8a 169 Most of the mandatory resources are created automatically when you create an M2MSecurity object. You can set their values using the following APIs:
maclobdell 0:f7c60d3e7b8a 170
maclobdell 0:f7c60d3e7b8a 171 - For resources that take `integer` values:
maclobdell 0:f7c60d3e7b8a 172
maclobdell 0:f7c60d3e7b8a 173 `bool set_resource_value(SecurityResource resource,uint32_t value);`
maclobdell 0:f7c60d3e7b8a 174
maclobdell 0:f7c60d3e7b8a 175 - For resources that take `string` values:
maclobdell 0:f7c60d3e7b8a 176
maclobdell 0:f7c60d3e7b8a 177 `bool set_resource_value(SecurityResource resource,const String &value);`
maclobdell 0:f7c60d3e7b8a 178
maclobdell 0:f7c60d3e7b8a 179 - For resources that take binary values, like setting public keys and certificates:
maclobdell 0:f7c60d3e7b8a 180
maclobdell 0:f7c60d3e7b8a 181 `bool set_resource_value(SecurityResource resource,onst uint8_t *value,const uint16_t length);`
maclobdell 0:f7c60d3e7b8a 182
maclobdell 0:f7c60d3e7b8a 183 - You can create and set values for Resources that are not mandatory, and which take an `integer` value, using this API:
maclobdell 0:f7c60d3e7b8a 184
maclobdell 0:f7c60d3e7b8a 185 `M2MResource* create_resource(SecurityResource resource, uint32_t value);`
maclobdell 0:f7c60d3e7b8a 186
maclobdell 0:f7c60d3e7b8a 187 Check the M2MSecurity API documentation to find which enums are supported for `integer`, `string` or `uint8_t*` value types.
maclobdell 0:f7c60d3e7b8a 188
maclobdell 0:f7c60d3e7b8a 189 There are more APIs in the M2MSecurity class that you can use to set, remove and modify Resource values.
maclobdell 0:f7c60d3e7b8a 190
maclobdell 0:f7c60d3e7b8a 191 #### Creating custom Resources
maclobdell 0:f7c60d3e7b8a 192
maclobdell 0:f7c60d3e7b8a 193 As per the OMA LWM2M specification, the client must have Resources under Object Instances which belong to Objects.
maclobdell 0:f7c60d3e7b8a 194
maclobdell 0:f7c60d3e7b8a 195 You can create different types of Resources or Resource Instances.
maclobdell 0:f7c60d3e7b8a 196
maclobdell 0:f7c60d3e7b8a 197 There are two types of Resources:
maclobdell 0:f7c60d3e7b8a 198
maclobdell 0:f7c60d3e7b8a 199 - **M2MResource**: a resource with a unique instance, for example `/Test/0/Resource`.
maclobdell 0:f7c60d3e7b8a 200
maclobdell 0:f7c60d3e7b8a 201 - **M2MResourceInstance**: a resource with multiple instances, for example `/Test/0/Resource/0`, `/Test/0/Resource/1`.
maclobdell 0:f7c60d3e7b8a 202
maclobdell 0:f7c60d3e7b8a 203 Apart from these two types, you can create two types of Resource and Resource Instances:
maclobdell 0:f7c60d3e7b8a 204
maclobdell 0:f7c60d3e7b8a 205 - Static: Resource and Resource Instances whose value does not change over time.
maclobdell 0:f7c60d3e7b8a 206 - Dynamic: Resource and Resource Instances whose value can change. These resources can be made observable.
maclobdell 0:f7c60d3e7b8a 207
maclobdell 0:f7c60d3e7b8a 208 **Creating dynamic and static single-instance Resources**
maclobdell 0:f7c60d3e7b8a 209
maclobdell 0:f7c60d3e7b8a 210 As per the OMA LWM2M specification, the client must have created Resources under Object Instance. You can create M2MResource from the M2MObjectInstance class.
maclobdell 0:f7c60d3e7b8a 211
maclobdell 0:f7c60d3e7b8a 212 - You can create a single-instance Resource with a static value using this API:
maclobdell 0:f7c60d3e7b8a 213
maclobdell 0:f7c60d3e7b8a 214 ```
maclobdell 0:f7c60d3e7b8a 215 M2MResource* create_static_resource(const String &resource_name,
maclobdell 0:f7c60d3e7b8a 216 const String &resource_type,
maclobdell 0:f7c60d3e7b8a 217 M2MResourceInstance::ResourceType type,
maclobdell 0:f7c60d3e7b8a 218 const uint8_t *value,
maclobdell 0:f7c60d3e7b8a 219 const uint8_t value_length,
maclobdell 0:f7c60d3e7b8a 220 bool multiple_instance = false);
maclobdell 0:f7c60d3e7b8a 221 ```
maclobdell 0:f7c60d3e7b8a 222
maclobdell 0:f7c60d3e7b8a 223 - You can create a single-instance Resource with a dynamic value that can be set later on, using this API:
maclobdell 0:f7c60d3e7b8a 224
maclobdell 0:f7c60d3e7b8a 225 ```
maclobdell 0:f7c60d3e7b8a 226 M2MResource* create_dynamic_resource(const String &resource_name,
maclobdell 0:f7c60d3e7b8a 227 const String &resource_type,
maclobdell 0:f7c60d3e7b8a 228 M2MResourceInstance::ResourceType type,
maclobdell 0:f7c60d3e7b8a 229 bool observable,
maclobdell 0:f7c60d3e7b8a 230 bool multiple_instance = false);
maclobdell 0:f7c60d3e7b8a 231 ```
maclobdell 0:f7c60d3e7b8a 232
maclobdell 0:f7c60d3e7b8a 233 These APIs take different parameters that you can see in the documentation.
maclobdell 0:f7c60d3e7b8a 234
maclobdell 0:f7c60d3e7b8a 235 **Creating dynamic and static Resource Instances**
maclobdell 0:f7c60d3e7b8a 236
maclobdell 0:f7c60d3e7b8a 237 As per the OMA LWM2M specification, the client must have created Resource Instances under Resources. You can create M2MResourceInstance from the M2MObjectInstance class.
maclobdell 0:f7c60d3e7b8a 238
maclobdell 0:f7c60d3e7b8a 239 - You can create a Resource Instance with a static value using this API:
maclobdell 0:f7c60d3e7b8a 240
maclobdell 0:f7c60d3e7b8a 241 ```
maclobdell 0:f7c60d3e7b8a 242 M2MResourceInstance* create_static_resource_instance(const String &resource_name,
maclobdell 0:f7c60d3e7b8a 243 const String &resource_type,
maclobdell 0:f7c60d3e7b8a 244 M2MResourceInstance::ResourceType type,
maclobdell 0:f7c60d3e7b8a 245 const uint8_t *value,
maclobdell 0:f7c60d3e7b8a 246 const uint8_t value_length,
maclobdell 0:f7c60d3e7b8a 247 uint16_t instance_id);
maclobdell 0:f7c60d3e7b8a 248 ```
maclobdell 0:f7c60d3e7b8a 249
maclobdell 0:f7c60d3e7b8a 250 - You can create a Resource Instance with a dynamic value that can be set later on, using this API:
maclobdell 0:f7c60d3e7b8a 251
maclobdell 0:f7c60d3e7b8a 252 ```
maclobdell 0:f7c60d3e7b8a 253 M2MResourceInstance* create_dynamic_resource_instance(const String &resource_name,
maclobdell 0:f7c60d3e7b8a 254 const String &resource_type,
maclobdell 0:f7c60d3e7b8a 255 M2MResourceInstance::ResourceType type,
maclobdell 0:f7c60d3e7b8a 256 bool observable,
maclobdell 0:f7c60d3e7b8a 257 uint16_t instance_id);
maclobdell 0:f7c60d3e7b8a 258 ```
maclobdell 0:f7c60d3e7b8a 259
maclobdell 0:f7c60d3e7b8a 260 These APIs take different parameters that you can see in the documentation.
maclobdell 0:f7c60d3e7b8a 261
maclobdell 0:f7c60d3e7b8a 262 #### Configuring the Resource and Resource Instance
maclobdell 0:f7c60d3e7b8a 263
maclobdell 0:f7c60d3e7b8a 264 When you have created a Resource or Resource Instance (whether OMA-specific or custom), you can configure various parameters so they can be controlled or modified to affect communication with mbed DS.
maclobdell 0:f7c60d3e7b8a 265
maclobdell 0:f7c60d3e7b8a 266 Here, we present a few of the most important parameters that you must configure properly to work with the Resource and Resource Instance.
maclobdell 0:f7c60d3e7b8a 267
maclobdell 0:f7c60d3e7b8a 268 ##### Setting Operation Mode
maclobdell 0:f7c60d3e7b8a 269
maclobdell 0:f7c60d3e7b8a 270 You can set the Resource or Resource Instance operation mode so that they can handle `GET`, `PUT`, `POST`, `DELETE` or a combination of these requests coming from mbed DS.
maclobdell 0:f7c60d3e7b8a 271
maclobdell 0:f7c60d3e7b8a 272 The API that you can use to set the operation mode (present in the M2MBase class) is:
maclobdell 0:f7c60d3e7b8a 273
maclobdell 0:f7c60d3e7b8a 274 `virtual void set_operation(M2MBase::Operation operation);`
maclobdell 0:f7c60d3e7b8a 275
maclobdell 0:f7c60d3e7b8a 276 ##### Setting the value of a dynamic Resource or Resource Instance
maclobdell 0:f7c60d3e7b8a 277
maclobdell 0:f7c60d3e7b8a 278 You can set the value of a dynamic Resource or Resource Instance so that they can be sent to mbed DS using `GET` requests.
maclobdell 0:f7c60d3e7b8a 279
maclobdell 0:f7c60d3e7b8a 280 The API used to set the values (present in the M2MResourceInstance class) is:
maclobdell 0:f7c60d3e7b8a 281
maclobdell 0:f7c60d3e7b8a 282 `virtual bool set_value(const uint8_t *value, const uint32_t value_length);`
maclobdell 0:f7c60d3e7b8a 283
maclobdell 0:f7c60d3e7b8a 284 ##### Setting an executable function
maclobdell 0:f7c60d3e7b8a 285
maclobdell 0:f7c60d3e7b8a 286 For Dynamic Resources, you can pass a function pointer to the Resource or Resource Instance. It will be executed when mbed DS calls a `POST` method on that resource. The Resource or Resource Instance must support the `POST` operation mode for this feature to work.
maclobdell 0:f7c60d3e7b8a 287
maclobdell 0:f7c60d3e7b8a 288 You can pass the function pointer using this API:
maclobdell 0:f7c60d3e7b8a 289
maclobdell 0:f7c60d3e7b8a 290 `virtual void set_execute_function(execute_callback callback);`
maclobdell 0:f7c60d3e7b8a 291
maclobdell 0:f7c60d3e7b8a 292 Apart from this, there are multiple APIs that provide getter and remove functions for Resource and Resource Instances in the M2MResource and M2MResourceInstance classes. Check the API documentation for their usage.
maclobdell 0:f7c60d3e7b8a 293
maclobdell 0:f7c60d3e7b8a 294 ## API documentation
maclobdell 0:f7c60d3e7b8a 295
maclobdell 0:f7c60d3e7b8a 296 You can generate Doxygen API documentation for these APIs from a doxy file in the `doxygen` folder. You need to run the `doxygen` command from the `doxygen/` folder; it will generate a `docs` folder at the API source directory root level, where you can find the detailed documentation for each API.