Mayank Gupta / Mbed OS pelion-example-frdm

Dependencies:   FXAS21002 FXOS8700Q

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers m2mobservationhandler.h Source File

m2mobservationhandler.h

Go to the documentation of this file.
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 #ifndef M2M_OBSERVATION_HANDLER_H
00017 #define M2M_OBSERVATION_HANDLER_H
00018 
00019 // Needed for M2MBase::Operation
00020 #include "m2mbase.h"
00021 #include "mbed-client/coap_response.h"
00022 //FORWARD DECLARATION
00023 class M2MResourceInstance;
00024 
00025 /*! \file m2mobservationhandler.h
00026  * \brief M2MObservationHandler.
00027  * An interface for handling observation
00028  * callbacks from different objects.
00029  *
00030  */
00031 class M2MObservationHandler
00032 {
00033   public:
00034 
00035     /**
00036      * \brief The observation callback to be sent to the
00037      * server due to a change in a parameter under observation.
00038      * \param object The observed object whose information needs to be sent.
00039      * \param obs_number The observation number.
00040      * \param changed_instance_ids A list of changed object instance IDs.
00041      * \param send_object Indicates whether the whole object will be sent or not.
00042      *
00043      * \return True if the message was send, False if there is already ongoing notification.
00044      */
00045     virtual bool observation_to_be_sent(M2MBase *object,
00046                                         uint16_t obs_number,
00047                                         const m2m::Vector<uint16_t> &changed_instance_ids,
00048                                         bool send_object = false) = 0;
00049 
00050     /**
00051      * \brief A callback for removing an NSDL resource from the data structures.
00052      * \param The M2MBase derived observed object whose information
00053      * needs to be removed.
00054      */
00055     virtual void resource_to_be_deleted(M2MBase *base) = 0;
00056 
00057     /**
00058      * \brief A callback indicating that the value of the resource object is updated by server.
00059      * \param base The object whose value is updated.
00060      * \param object_name The name of the updated resource, default is empty.
00061      */
00062     virtual void value_updated(M2MBase *base) = 0;
00063 
00064     /**
00065      * \brief A callback for removing an object from the list.
00066      * \param object The M2MObject to be removed.
00067      */
00068     virtual void remove_object(M2MBase *object) = 0;
00069 
00070 #ifndef DISABLE_DELAYED_RESPONSE
00071     /**
00072      * \brief Sends a delayed post response to the server with 'COAP_MSG_CODE_RESPONSE_CHANGED' response code.
00073      * \param base The resource sending the response.
00074      */
00075     virtual void send_delayed_response(M2MBase *base) = 0;
00076 #endif
00077 
00078 #ifdef ENABLE_ASYNC_REST_RESPONSE
00079     /**
00080      * \brief Sends async response to the server for the given operation with the given response code.
00081      * \param base The resource sending the response.
00082      * \param payload Payload for the resource.
00083      * \param payload_len Length of the payload.
00084      * \param token Token for the incoming CoAP request.
00085      * \param token_len Token length for the incoming CoAP request.
00086      * \param code The response code for the operation, for example: COAP_MSG_CODE_RESPONSE_CHANGED.
00087      */
00088     virtual void send_asynchronous_response(M2MBase *base,
00089                                             const uint8_t *payload,
00090                                             size_t payload_len,
00091                                             const uint8_t* token,
00092                                             const uint8_t token_len,
00093                                             coap_response_code_e code) = 0;
00094 #endif
00095 };
00096 
00097 
00098 #endif // M2M_OBSERVATION_HANDLER_H