blob: 924fdc6fefbffedca1970fcda51905f130f27bd4 [file] [log] [blame]
/*
*
* Copyright (c) 2025 Project CHIP Authors
*
* you may not use this file except in compliance with the License.
* Licensed under the Apache License, Version 2.0 (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.
*/
/**
* @file
* Provides an implementation of the NFCCommissioningManager singleton object
* for the Darwin platforms.
*/
#pragma once
#include <platform/internal/NFCCommissioningManager.h>
#include <transport/raw/NfcApplicationDelegate.h>
#if CHIP_DEVICE_CONFIG_ENABLE_NFC_BASED_COMMISSIONING
namespace chip {
namespace DeviceLayer {
namespace Internal {
/**
* Concrete implementation of the NFCCommissioningManagerImpl singleton object for the Darwin platforms.
*/
class NFCCommissioningManagerImpl final : public NFCCommissioningManager, private Nfc::NfcApplicationDelegate
{
// Allow the NFCCommissioningManager interface class to delegate method calls to
// the implementation methods provided by this class.
friend NFCCommissioningManager;
public:
NFCCommissioningManagerImpl() {}
// ===== Members that implement virtual methods on NfcApplicationDelegate.
void SetNFCBase(Transport::NFCBase * nfcBase) override;
bool CanSendToPeer(const Transport::PeerAddress & address) override;
CHIP_ERROR SendToNfcTag(const Transport::PeerAddress & address, System::PacketBufferHandle && msgBuf) override;
private:
// ===== Members that implement the NFCCommissioningManager internal interface.
CHIP_ERROR _Init();
void _Shutdown();
Nfc::NFCReaderTransport * _GetNFCReaderTransport() const { return mReaderTransport.get(); }
void _SetNFCReaderTransport(Nfc::NFCReaderTransport * readerTransport);
// ===== Members for internal use by the following friends.
friend NFCCommissioningManager & NFCCommissioningMgr();
friend NFCCommissioningManagerImpl & NFCCommissioningMgrImpl();
Transport::NFCBase * mNFCBase = nullptr;
std::unique_ptr<chip::Nfc::NFCReaderTransport> mReaderTransport;
};
} // namespace Internal
} // namespace DeviceLayer
} // namespace chip
#endif // CHIP_DEVICE_CONFIG_ENABLE_NFC_BASED_COMMISSIONING