3 * Copyright (c) 2020 Project CHIP Authors
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
20 * This file contains definitions for the CHIP DeviceManager Interface
22 * This object will co-ordinate multiple activities such as
23 * initialisation, rendezvous, session mgmt and other such
24 * activities within the CHIP stack. This is a singleton object.
29 #include <core/CHIPCore.h>
30 #include <core/CHIPError.h>
31 #include <platform/CHIPDeviceLayer.h>
33 #include <support/DLLUtil.h>
41 namespace DeviceManager {
45 * This class provides a skeleton for all the callback functions. The functions will be
46 * called by other objects within the CHIP stack for specific events.
47 * Applications interested in receiving specific callbacks can specialize this class and handle
48 * these events in their implementation of this class.
50 class DLL_EXPORT CHIPDeviceManagerCallbacks
55 * Called when CHIP Device events (PublicEventTypes) are triggered.
57 * @param event ChipDeviceEvent that occurred
58 * @param arg arguments specific to the event, if any
60 virtual void DeviceEventCallback(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg);
64 * Called after an attribute has been changed
66 * @param endpoint endpoint id
67 * @param clusterID cluster id
68 * @param attributeId attribute id that was changed
69 * @param mask mask of the attribute
70 * @param manufacturerCode manufacturer code
71 * @param type attribute type
72 * @param size size of the attribute
73 * @param value pointer to the new value
75 virtual void PostAttributeChangeCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId,
76 uint8_t mask, uint16_t manufacturerCode, uint8_t type, uint8_t size, uint8_t * value)
78 virtual ~CHIPDeviceManagerCallbacks() {}
83 * A common class that drives other components of the CHIP stack
85 class DLL_EXPORT CHIPDeviceManager
88 CHIPDeviceManager(const CHIPDeviceManager &) = delete;
89 CHIPDeviceManager(const CHIPDeviceManager &&) = delete;
90 CHIPDeviceManager & operator=(const CHIPDeviceManager &) = delete;
92 static CHIPDeviceManager & GetInstance()
94 static CHIPDeviceManager instance;
100 * Initialise CHIPDeviceManager
102 * @param cb Application's instance of the CHIPDeviceManagerCallbacks for consuming events
104 CHIP_ERROR Init(CHIPDeviceManagerCallbacks * cb);
108 * Fetch a pointer to the registered CHIPDeviceManagerCallbacks object.
111 CHIPDeviceManagerCallbacks * GetCHIPDeviceManagerCallbacks() { return mCB; }
114 * Use internally for registration of the ChipDeviceEvents
116 static void CommonDeviceEventHandler(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg);
119 CHIPDeviceManagerCallbacks * mCB = nullptr;
120 CHIPDeviceManager() {}
123 } // namespace DeviceManager