Example

Dependencies:   FXAS21002 FXOS8700Q

Committer:
maygup01
Date:
Tue Nov 19 09:49:38 2019 +0000
Revision:
0:11cc2b7889af
Example

Who changed what in which revision?

UserRevisionLine numberNew contents of line
maygup01 0:11cc2b7889af 1 /*
maygup01 0:11cc2b7889af 2 * Copyright (c) 2015 ARM Limited. All rights reserved.
maygup01 0:11cc2b7889af 3 * SPDX-License-Identifier: Apache-2.0
maygup01 0:11cc2b7889af 4 * Licensed under the Apache License, Version 2.0 (the License); you may
maygup01 0:11cc2b7889af 5 * not use this file except in compliance with the License.
maygup01 0:11cc2b7889af 6 * You may obtain a copy of the License at
maygup01 0:11cc2b7889af 7 *
maygup01 0:11cc2b7889af 8 * http://www.apache.org/licenses/LICENSE-2.0
maygup01 0:11cc2b7889af 9 *
maygup01 0:11cc2b7889af 10 * Unless required by applicable law or agreed to in writing, software
maygup01 0:11cc2b7889af 11 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
maygup01 0:11cc2b7889af 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
maygup01 0:11cc2b7889af 13 * See the License for the specific language governing permissions and
maygup01 0:11cc2b7889af 14 * limitations under the License.
maygup01 0:11cc2b7889af 15 */
maygup01 0:11cc2b7889af 16 #ifndef M2M_OBSERVATION_HANDLER_H
maygup01 0:11cc2b7889af 17 #define M2M_OBSERVATION_HANDLER_H
maygup01 0:11cc2b7889af 18
maygup01 0:11cc2b7889af 19 // Needed for M2MBase::Operation
maygup01 0:11cc2b7889af 20 #include "m2mbase.h"
maygup01 0:11cc2b7889af 21 #include "mbed-client/coap_response.h"
maygup01 0:11cc2b7889af 22 //FORWARD DECLARATION
maygup01 0:11cc2b7889af 23 class M2MResourceInstance;
maygup01 0:11cc2b7889af 24
maygup01 0:11cc2b7889af 25 /*! \file m2mobservationhandler.h
maygup01 0:11cc2b7889af 26 * \brief M2MObservationHandler.
maygup01 0:11cc2b7889af 27 * An interface for handling observation
maygup01 0:11cc2b7889af 28 * callbacks from different objects.
maygup01 0:11cc2b7889af 29 *
maygup01 0:11cc2b7889af 30 */
maygup01 0:11cc2b7889af 31 class M2MObservationHandler
maygup01 0:11cc2b7889af 32 {
maygup01 0:11cc2b7889af 33 public:
maygup01 0:11cc2b7889af 34
maygup01 0:11cc2b7889af 35 /**
maygup01 0:11cc2b7889af 36 * \brief The observation callback to be sent to the
maygup01 0:11cc2b7889af 37 * server due to a change in a parameter under observation.
maygup01 0:11cc2b7889af 38 * \param object The observed object whose information needs to be sent.
maygup01 0:11cc2b7889af 39 * \param obs_number The observation number.
maygup01 0:11cc2b7889af 40 * \param changed_instance_ids A list of changed object instance IDs.
maygup01 0:11cc2b7889af 41 * \param send_object Indicates whether the whole object will be sent or not.
maygup01 0:11cc2b7889af 42 *
maygup01 0:11cc2b7889af 43 * \return True if the message was send, False if there is already ongoing notification.
maygup01 0:11cc2b7889af 44 */
maygup01 0:11cc2b7889af 45 virtual bool observation_to_be_sent(M2MBase *object,
maygup01 0:11cc2b7889af 46 uint16_t obs_number,
maygup01 0:11cc2b7889af 47 const m2m::Vector<uint16_t> &changed_instance_ids,
maygup01 0:11cc2b7889af 48 bool send_object = false) = 0;
maygup01 0:11cc2b7889af 49
maygup01 0:11cc2b7889af 50 /**
maygup01 0:11cc2b7889af 51 * \brief A callback for removing an NSDL resource from the data structures.
maygup01 0:11cc2b7889af 52 * \param The M2MBase derived observed object whose information
maygup01 0:11cc2b7889af 53 * needs to be removed.
maygup01 0:11cc2b7889af 54 */
maygup01 0:11cc2b7889af 55 virtual void resource_to_be_deleted(M2MBase *base) = 0;
maygup01 0:11cc2b7889af 56
maygup01 0:11cc2b7889af 57 /**
maygup01 0:11cc2b7889af 58 * \brief A callback indicating that the value of the resource object is updated by server.
maygup01 0:11cc2b7889af 59 * \param base The object whose value is updated.
maygup01 0:11cc2b7889af 60 * \param object_name The name of the updated resource, default is empty.
maygup01 0:11cc2b7889af 61 */
maygup01 0:11cc2b7889af 62 virtual void value_updated(M2MBase *base) = 0;
maygup01 0:11cc2b7889af 63
maygup01 0:11cc2b7889af 64 /**
maygup01 0:11cc2b7889af 65 * \brief A callback for removing an object from the list.
maygup01 0:11cc2b7889af 66 * \param object The M2MObject to be removed.
maygup01 0:11cc2b7889af 67 */
maygup01 0:11cc2b7889af 68 virtual void remove_object(M2MBase *object) = 0;
maygup01 0:11cc2b7889af 69
maygup01 0:11cc2b7889af 70 #ifndef DISABLE_DELAYED_RESPONSE
maygup01 0:11cc2b7889af 71 /**
maygup01 0:11cc2b7889af 72 * \brief Sends a delayed post response to the server with 'COAP_MSG_CODE_RESPONSE_CHANGED' response code.
maygup01 0:11cc2b7889af 73 * \param base The resource sending the response.
maygup01 0:11cc2b7889af 74 */
maygup01 0:11cc2b7889af 75 virtual void send_delayed_response(M2MBase *base) = 0;
maygup01 0:11cc2b7889af 76 #endif
maygup01 0:11cc2b7889af 77
maygup01 0:11cc2b7889af 78 #ifdef ENABLE_ASYNC_REST_RESPONSE
maygup01 0:11cc2b7889af 79 /**
maygup01 0:11cc2b7889af 80 * \brief Sends async response to the server for the given operation with the given response code.
maygup01 0:11cc2b7889af 81 * \param base The resource sending the response.
maygup01 0:11cc2b7889af 82 * \param payload Payload for the resource.
maygup01 0:11cc2b7889af 83 * \param payload_len Length of the payload.
maygup01 0:11cc2b7889af 84 * \param token Token for the incoming CoAP request.
maygup01 0:11cc2b7889af 85 * \param token_len Token length for the incoming CoAP request.
maygup01 0:11cc2b7889af 86 * \param code The response code for the operation, for example: COAP_MSG_CODE_RESPONSE_CHANGED.
maygup01 0:11cc2b7889af 87 */
maygup01 0:11cc2b7889af 88 virtual void send_asynchronous_response(M2MBase *base,
maygup01 0:11cc2b7889af 89 const uint8_t *payload,
maygup01 0:11cc2b7889af 90 size_t payload_len,
maygup01 0:11cc2b7889af 91 const uint8_t* token,
maygup01 0:11cc2b7889af 92 const uint8_t token_len,
maygup01 0:11cc2b7889af 93 coap_response_code_e code) = 0;
maygup01 0:11cc2b7889af 94 #endif
maygup01 0:11cc2b7889af 95 };
maygup01 0:11cc2b7889af 96
maygup01 0:11cc2b7889af 97
maygup01 0:11cc2b7889af 98 #endif // M2M_OBSERVATION_HANDLER_H