Mbed Cloud example program for workshop in W27 2018.

Dependencies:   MMA7660 LM75B

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers resource.h Source File

resource.h

00001 // ----------------------------------------------------------------------------
00002 // Copyright 2016-2017 ARM Ltd.
00003 //
00004 // SPDX-License-Identifier: Apache-2.0
00005 //
00006 // Licensed under the Apache License, Version 2.0 (the "License");
00007 // you may not use this file except in compliance with the License.
00008 // You may obtain a copy of the License at
00009 //
00010 //     http://www.apache.org/licenses/LICENSE-2.0
00011 //
00012 // Unless required by applicable law or agreed to in writing, software
00013 // distributed under the License is distributed on an "AS IS" BASIS,
00014 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015 // See the License for the specific language governing permissions and
00016 // limitations under the License.
00017 // ----------------------------------------------------------------------------
00018 
00019 
00020 #ifndef RESOURCE_H
00021 #define RESOURCE_H
00022 
00023 
00024 /**
00025  * \brief Helper function for creating different kind of resources.
00026  *        The path of the resource will be "object_id/instance_id/resource_id"
00027  *        For example if object_id = 1, instance_id = 2, resource_id = 3
00028  *        the path would be 1/2/3
00029  *
00030  * \param list Pointer to the object list,
00031  *             contains objects to be registered to the server.
00032  * \param object_id Name of the object in integer format.
00033  * \param instance_id Name of the instance in integer format.
00034  * \param resource_id Name of the resource in integer format.
00035  * \param resource_type Resource type name.
00036  * \param data_type Data type of the resource value.
00037  * \param allowed Methods allowed for accessing this resource.
00038  * \param value Resource value as a null terminated string.
00039  *              May be set as NULL.
00040  * \param observable Resource set observable if true.
00041  * \param cb Function pointer to either:
00042  *           value_updated_callback2 if allowed & GET_PUT_ALLOWED
00043  *           OR
00044  *           execute_callback_2 in if allowed & POST_ALLOWED.
00045  *           In other cases this parameter is ignored.
00046  *
00047  *        NOTE: This function is not designed to support setting both
00048  *              GET_PUT_ALLOWED and POST_ALLOWED for parameter allowed
00049  *              at the same time.
00050  * \param notification_status_cb Function pointer to notification_delivery_status_cb
00051  *          if resource is set to be observable.
00052  */
00053 M2MResource* add_resource(M2MObjectList *list,
00054                           uint16_t object_id,
00055                           uint16_t instance_id,
00056                           uint16_t resource_id,
00057                           const char *resource_type,
00058                           M2MResourceInstance::ResourceType data_type,
00059                           M2MBase::Operation allowed,
00060                           const char *value,
00061                           bool observable,
00062                           Callback<void(const char*)> *put_cb,
00063                           Callback<void(void*)> *post_cb,
00064                           Callback<void(const M2MBase&, const NoticationDeliveryStatus)> *notification_status_cb);
00065 
00066 #endif //RESOURCE_H