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 * Provides an implementation of the BLEManager singleton object
21 * for the Darwin platforms.
26 #if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
29 namespace DeviceLayer {
32 using namespace chip::Ble;
35 * Concrete implementation of the BLEManagerImpl singleton object for the Darwin platforms.
37 class BLEManagerImpl final : public BLEManager, private BleLayer
39 // Allow the BLEManager interface class to delegate method calls to
40 // the implementation methods provided by this class.
44 CHIP_ERROR ConfigureBle(uint32_t aNodeId, bool aIsCentral) { return CHIP_NO_ERROR; }
47 // ===== Members that implement the BLEManager internal interface.
49 CHIP_ERROR _Init(void);
50 CHIPoBLEServiceMode _GetCHIPoBLEServiceMode(void);
51 CHIP_ERROR _SetCHIPoBLEServiceMode(CHIPoBLEServiceMode val);
52 bool _IsAdvertisingEnabled(void);
53 CHIP_ERROR _SetAdvertisingEnabled(bool val);
54 bool _IsAdvertising(void);
55 CHIP_ERROR _SetAdvertisingMode(BLEAdvertisingMode mode);
56 CHIP_ERROR _GetDeviceName(char * buf, size_t bufSize);
57 CHIP_ERROR _SetDeviceName(const char * deviceName);
58 uint16_t _NumConnections(void);
59 void _OnPlatformEvent(const ChipDeviceEvent * event);
60 BleLayer * _GetBleLayer(void);
62 // ===== Members for internal use by the following friends.
64 friend BLEManager & BLEMgr(void);
65 friend BLEManagerImpl & BLEMgrImpl(void);
67 static BLEManagerImpl sInstance;
71 * Returns a reference to the public interface of the BLEManager singleton object.
73 * Internal components should use this to access features of the BLEManager object
74 * that are common to all platforms.
76 inline BLEManager & BLEMgr(void)
78 return BLEManagerImpl::sInstance;
82 * Returns the platform-specific implementation of the BLEManager singleton object.
84 * Internal components can use this to gain access to features of the BLEManager
85 * that are specific to the Darwin platforms.
87 inline BLEManagerImpl & BLEMgrImpl(void)
89 return BLEManagerImpl::sInstance;
92 } // namespace Internal
93 } // namespace DeviceLayer
96 #endif // CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE