| /* |
| * |
| * Copyright (c) 2021 Project CHIP Authors |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| |
| // THIS FILE IS GENERATED BY ZAP |
| |
| #include <core/CHIPCore.h> |
| |
| #include <app/CommandSender.h> |
| #include <app/InteractionModelEngine.h> |
| #include <lib/support/Span.h> |
| |
| #include <controller/CHIPDevice.h> |
| |
| #include "gen/CHIPClientCallbacks.h" |
| #include "gen/CHIPClusters.h" |
| |
| using namespace chip; |
| using namespace chip::app; |
| |
| namespace { |
| |
| // Define pointers for external ZCL response delegates. |
| |
| using SuccessResponseDelegate = void (*)(); |
| using FailureResponseDelegate = void (*)(uint8_t); |
| SuccessResponseDelegate gSuccessResponseDelegate; |
| FailureResponseDelegate gFailureResponseDelegate; |
| |
| // Define callbacks for ZCL commands and attribute requests. |
| |
| void OnDefaultSuccessResponse(void * /* context */) |
| { |
| if (gSuccessResponseDelegate != nullptr) |
| gSuccessResponseDelegate(); |
| } |
| |
| void OnDefaultFailureResponse(void * /* context */, uint8_t status) |
| { |
| if (gFailureResponseDelegate != nullptr) |
| gFailureResponseDelegate(status); |
| } |
| |
| template <class AttributeType> |
| void OnAttributeResponse(void * /* context */, AttributeType) |
| { |
| if (gSuccessResponseDelegate != nullptr) |
| gSuccessResponseDelegate(); |
| } |
| |
| chip::Callback::Callback<DefaultSuccessCallback> gDefaultSuccessCallback{ OnDefaultSuccessResponse, nullptr }; |
| chip::Callback::Callback<DefaultFailureCallback> gDefaultFailureCallback{ OnDefaultFailureResponse, nullptr }; |
| chip::Callback::Callback<BooleanAttributeCallback> gBooleanAttributeCallback{ OnAttributeResponse<bool>, nullptr }; |
| chip::Callback::Callback<Int8uAttributeCallback> gInt8uAttributeCallback{ OnAttributeResponse<uint8_t>, nullptr }; |
| chip::Callback::Callback<Int8sAttributeCallback> gInt8sAttributeCallback{ OnAttributeResponse<int8_t>, nullptr }; |
| chip::Callback::Callback<Int16uAttributeCallback> gInt16uAttributeCallback{ OnAttributeResponse<uint16_t>, nullptr }; |
| chip::Callback::Callback<Int16sAttributeCallback> gInt16sAttributeCallback{ OnAttributeResponse<int16_t>, nullptr }; |
| chip::Callback::Callback<Int32uAttributeCallback> gInt32uAttributeCallback{ OnAttributeResponse<uint32_t>, nullptr }; |
| chip::Callback::Callback<Int32sAttributeCallback> gInt32sAttributeCallback{ OnAttributeResponse<int32_t>, nullptr }; |
| chip::Callback::Callback<Int64uAttributeCallback> gInt64uAttributeCallback{ OnAttributeResponse<uint64_t>, nullptr }; |
| chip::Callback::Callback<Int64sAttributeCallback> gInt64sAttributeCallback{ OnAttributeResponse<int64_t>, nullptr }; |
| chip::Callback::Callback<StringAttributeCallback> gStringAttributeCallback{ OnAttributeResponse<ByteSpan>, nullptr }; |
| |
| } // namespace |
| |
| extern "C" { |
| |
| void chip_ime_SetSuccessResponseDelegate(SuccessResponseDelegate delegate) |
| { |
| gSuccessResponseDelegate = delegate; |
| } |
| |
| void chip_ime_SetFailureResponseDelegate(FailureResponseDelegate delegate) |
| { |
| gFailureResponseDelegate = delegate; |
| } |
| } |