@@ -67,7 +67,7 @@ The Client API allows setting values to Resources, an array of Resource Instance
67
67
68
68
The ** Write** operation is used to overwrite the value of a Resource, an array of Resource Instances or multiple Resources from an Object Instance.
69
69
70
- Whenever there is a valid ` PUT ` operation for any of the resources, the application will receive a callback:
70
+ Whenever there is a valid ` PUT ` operation for any of the resources, the application will receive a callback:
71
71
72
72
```
73
73
void value_updated(M2MBase *base, M2MBase::BaseType type)
@@ -119,6 +119,33 @@ void value_updated(M2MBase *base, M2MBase::BaseType type) {
119
119
}
120
120
}
121
121
```
122
+ By default callbacks are handled in value_updated() function but application can also define callback function for individual resource.
123
+ Check the code snippet below for usage.
124
+
125
+ ```
126
+ static void value_updated_global(const char *name) {
127
+ if(name) {
128
+ ...
129
+ }
130
+ }
131
+
132
+ void M2MLWClient::value_updated_function(const char* name) {
133
+ if (name) {
134
+ ...
135
+ }
136
+ }
137
+
138
+ M2MResource* res = inst->create_dynamic_resource("D", "ResourceTest", true);
139
+ char buffer[20];
140
+ int size = sprintf(buffer,"%d",_value);
141
+ res->set_operation(M2MBase::GET_PUT_POST_DELETE_ALLOWED);
142
+ res->set_value((const uint8_t*)buffer, (const uint32_t)size);
143
+ res->set_value_updated_function(value_updated_callback(this,&MbedClient::value_updated_function));
144
+ /* Overloaded function can be used If callback function is not in class scope.
145
+ res2->set_value_updated_function(value_updated_callback2(&value_updated_global));
146
+ */
147
+
148
+ ```
122
149
123
150
## The Write Attributes operation
124
151
@@ -182,7 +209,7 @@ if(_object) {
182
209
(const uint32_t)size);
183
210
res->set_execute_function(execute_callback(this,&M2MLWClient::execute_function));
184
211
/* Overloaded function can be used If callback function is not in class scope.
185
- res->set_execute_function(&execute_function_2);
212
+ res->set_execute_function(execute_callback_2( &execute_function_2) );
186
213
*/
187
214
```
188
215
0 commit comments