blob: d558dbc2533c266d6ce17c6ef1a4039c5fd8dd97 [file] [log] [blame]
/*
*
* Copyright (c) 2022 Project CHIP Authors
* All rights reserved.
*
* 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.
*/
/**
* @file
* Provides the implementation of the Device Layer Connectivity Manager class
* for the Open IOT SDK platform.
*/
#pragma once
#include <platform/CHIPDeviceConfig.h>
#include <platform/ConnectivityManager.h>
#include <platform/internal/GenericConnectivityManagerImpl.h>
#include <platform/internal/GenericConnectivityManagerImpl_NoBLE.h>
#include <platform/internal/GenericConnectivityManagerImpl_NoThread.h>
#include <platform/internal/GenericConnectivityManagerImpl_NoWiFi.h>
#include <platform/internal/GenericConnectivityManagerImpl_UDP.h>
#if INET_CONFIG_ENABLE_TCP_ENDPOINT
#include <platform/internal/GenericConnectivityManagerImpl_TCP.h>
#endif
namespace chip {
namespace DeviceLayer {
/**
* Concrete implementation of the ConnectivityManager singleton object for the Open IoT SDK platform.
*/
class ConnectivityManagerImpl final : public ConnectivityManager,
public Internal::GenericConnectivityManagerImpl<ConnectivityManagerImpl>,
public Internal::GenericConnectivityManagerImpl_UDP<ConnectivityManagerImpl>,
#if INET_CONFIG_ENABLE_TCP_ENDPOINT
public Internal::GenericConnectivityManagerImpl_TCP<ConnectivityManagerImpl>,
#endif
public Internal::GenericConnectivityManagerImpl_NoWiFi<ConnectivityManagerImpl>,
public Internal::GenericConnectivityManagerImpl_NoBLE<ConnectivityManagerImpl>,
public Internal::GenericConnectivityManagerImpl_NoThread<ConnectivityManagerImpl>
{
// Allow the ConnectivityManager interface class to delegate method calls to
// the implementation methods provided by this class.
friend class ConnectivityManager;
private:
CHIP_ERROR _Init(void);
void _OnPlatformEvent(const ChipDeviceEvent * event);
friend ConnectivityManager & ConnectivityMgr(void);
friend ConnectivityManagerImpl & ConnectivityMgrImpl(void);
static ConnectivityManagerImpl sInstance;
public:
CHIP_ERROR PostEvent(const ChipDeviceEvent * event, bool die);
void AddTask(AsyncWorkFunct workFunct, intptr_t arg);
};
/**
* Returns the public interface of the ConnectivityManager singleton object.
*
* chip applications should use this to access features of the ConnectivityManager object
* that are common to all platforms.
*/
inline ConnectivityManager & ConnectivityMgr(void)
{
return ConnectivityManagerImpl::sInstance;
}
/**
* Returns the platform-specific implementation of the ConnectivityManager singleton object.
*
* chip applications can use this to gain access to features of the ConnectivityManager
* that are specific to the Open IoT SDK platform.
*/
inline ConnectivityManagerImpl & ConnectivityMgrImpl(void)
{
return ConnectivityManagerImpl::sInstance;
}
} // namespace DeviceLayer
} // namespace chip