3 * Copyright (c) 2021 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.
22 #if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
25 namespace DeviceLayer {
28 /// Iterates over available BlueZ adapters
32 /// AdapterIterator iterator;
33 /// while (iterator.Next()) {
34 /// std::cout << iterator.GetAddress() << std::endl;
37 /// Data is provided through the bluez dbus interface. You can view
38 /// this data in the commandline using commands such as:
40 /// busctl introspect org.bluez /org/bluez/hci0
46 /// Moves to the next DBUS interface.
48 /// MUST be called before any of the 'current value' methods are
49 /// used (iterator gets initialized on the first call of Next).
52 // Information about the current value. Safe to call only after
53 // "Next" has returned true.
54 uint32_t GetIndex() const { return mCurrent.index; }
55 const char * GetAddress() const { return mCurrent.address.c_str(); }
56 const char * GetAlias() const { return mCurrent.alias.c_str(); }
57 const char * GetName() const { return mCurrent.name.c_str(); }
58 bool IsPowered() const { return mCurrent.powered; }
59 BluezAdapter1 * GetAdapter() const { return mCurrent.adapter; }
62 /// Sets up the DBUS manager and loads the list
65 /// Loads the next value in the list.
67 /// Returns true if a value could be loaded, false if no more items to
71 static constexpr size_t kMaxAddressLength = 19; // xx:xx:xx:xx:xx:xx
72 static constexpr size_t kMaxNameLength = 64;
74 GDBusObjectManager * mManager = nullptr; // DBus connection
75 GList * mObjectList = nullptr; // listing of objects on the bus
76 GList * mCurrentListItem = nullptr; // current item viewed in the list
78 // data valid only if Next() returns true
86 BluezAdapter1 * adapter;
90 } // namespace Internal
91 } // namespace DeviceLayer
94 #endif // CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE