simplejsble 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/VERSION +1 -0
- package/android/CMakeLists.txt +62 -20
- package/cmake/epilogue.cmake +81 -0
- package/cmake/find/FindDBus1.cmake +20 -0
- package/cmake/find/Findfmt.cmake +41 -0
- package/cmake/find/Findgoogletest.cmake +18 -0
- package/cmake/parse_version.cmake +45 -0
- package/cmake/prelude.cmake +8 -0
- package/dependencies/README +4 -0
- package/dependencies/external/kvn/kvn_bytearray.h +297 -0
- package/dependencies/external/kvn/kvn_safe_callback.hpp +66 -0
- package/dependencies/external/kvn/logfwd.hpp +35 -0
- package/dependencies/internal/include/fmt/LICENSE +27 -0
- package/dependencies/internal/include/fmt/args.h +220 -0
- package/dependencies/internal/include/fmt/base.h +2962 -0
- package/dependencies/internal/include/fmt/chrono.h +2338 -0
- package/dependencies/internal/include/fmt/color.h +610 -0
- package/dependencies/internal/include/fmt/compile.h +539 -0
- package/dependencies/internal/include/fmt/core.h +5 -0
- package/dependencies/internal/include/fmt/format-inl.h +1949 -0
- package/dependencies/internal/include/fmt/format.h +4244 -0
- package/dependencies/internal/include/fmt/os.h +427 -0
- package/dependencies/internal/include/fmt/ostream.h +166 -0
- package/dependencies/internal/include/fmt/printf.h +633 -0
- package/dependencies/internal/include/fmt/ranges.h +850 -0
- package/dependencies/internal/include/fmt/std.h +726 -0
- package/dependencies/internal/include/fmt/xchar.h +373 -0
- package/dependencies/internal/include/nanopb/pb.h +948 -0
- package/dependencies/internal/include/nanopb/pb_common.h +49 -0
- package/dependencies/internal/include/nanopb/pb_decode.h +204 -0
- package/dependencies/internal/include/nanopb/pb_encode.h +195 -0
- package/dependencies/internal/include/simplejni/Common.hpp +598 -0
- package/dependencies/internal/include/simplejni/References.hpp +151 -0
- package/dependencies/internal/include/simplejni/Registry.hpp +249 -0
- package/dependencies/internal/include/simplejni/VM.hpp +93 -0
- package/dependencies/internal/src/nanopb/pb_common.c +388 -0
- package/dependencies/internal/src/nanopb/pb_decode.c +1763 -0
- package/dependencies/internal/src/nanopb/pb_encode.c +1009 -0
- package/dependencies/internal/src/simplejni/Common.cpp +4 -0
- package/package.json +5 -1
- package/simpleble/CMakeLists.txt +519 -0
- package/simpleble/cmake/simpleble.pc.in +11 -0
- package/simpleble/include/simpleble/Adapter.h +102 -0
- package/simpleble/include/simpleble/AdapterSafe.h +58 -0
- package/simpleble/include/simpleble/Advanced.h +50 -0
- package/simpleble/include/simpleble/Characteristic.h +39 -0
- package/simpleble/include/simpleble/Config.h +64 -0
- package/simpleble/include/simpleble/Descriptor.h +30 -0
- package/simpleble/include/simpleble/Exceptions.h +72 -0
- package/simpleble/include/simpleble/Logging.h +73 -0
- package/simpleble/include/simpleble/Peripheral.h +82 -0
- package/simpleble/include/simpleble/PeripheralSafe.h +64 -0
- package/simpleble/include/simpleble/Service.h +34 -0
- package/simpleble/include/simpleble/SimpleBLE.h +8 -0
- package/simpleble/include/simpleble/Types.h +49 -0
- package/simpleble/include/simpleble/Utils.h +13 -0
- package/simpleble/include/simpleble_c/DEPRECATED +2 -0
- package/simpleble/include/simpleble_c/adapter.h +188 -0
- package/simpleble/include/simpleble_c/logging.h +37 -0
- package/simpleble/include/simpleble_c/peripheral.h +304 -0
- package/simpleble/include/simpleble_c/simpleble.h +21 -0
- package/simpleble/include/simpleble_c/types.h +73 -0
- package/simpleble/include/simpleble_c/utils.h +27 -0
- package/simpleble/src/CommonUtils.h +63 -0
- package/simpleble/src/Config.cpp +25 -0
- package/simpleble/src/Exceptions.cpp +31 -0
- package/simpleble/src/Logging.cpp +136 -0
- package/simpleble/src/LoggingInternal.h +85 -0
- package/simpleble/src/Utils.cpp +24 -0
- package/simpleble/src/backends/android/AdapterAndroid.cpp +101 -0
- package/simpleble/src/backends/android/AdapterAndroid.h +67 -0
- package/simpleble/src/backends/android/BackendAndroid.cpp +41 -0
- package/simpleble/src/backends/android/BackendAndroid.h +26 -0
- package/simpleble/src/backends/android/PeripheralAndroid.cpp +365 -0
- package/simpleble/src/backends/android/PeripheralAndroid.h +90 -0
- package/simpleble/src/backends/android/bridge/BluetoothGattCallback.cpp +432 -0
- package/simpleble/src/backends/android/bridge/BluetoothGattCallback.h +102 -0
- package/simpleble/src/backends/android/bridge/ScanCallback.cpp +142 -0
- package/simpleble/src/backends/android/bridge/ScanCallback.h +55 -0
- package/simpleble/src/backends/android/types/android/bluetooth/BluetoothAdapter.cpp +107 -0
- package/simpleble/src/backends/android/types/android/bluetooth/BluetoothAdapter.h +55 -0
- package/simpleble/src/backends/android/types/android/bluetooth/BluetoothDevice.cpp +68 -0
- package/simpleble/src/backends/android/types/android/bluetooth/BluetoothDevice.h +54 -0
- package/simpleble/src/backends/android/types/android/bluetooth/BluetoothGatt.cpp +115 -0
- package/simpleble/src/backends/android/types/android/bluetooth/BluetoothGatt.h +75 -0
- package/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattCharacteristic.cpp +142 -0
- package/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattCharacteristic.h +66 -0
- package/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattDescriptor.cpp +67 -0
- package/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattDescriptor.h +46 -0
- package/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattService.cpp +106 -0
- package/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattService.h +47 -0
- package/simpleble/src/backends/android/types/android/bluetooth/le/BluetoothScanner.cpp +47 -0
- package/simpleble/src/backends/android/types/android/bluetooth/le/BluetoothScanner.h +37 -0
- package/simpleble/src/backends/android/types/android/bluetooth/le/ScanRecord.cpp +69 -0
- package/simpleble/src/backends/android/types/android/bluetooth/le/ScanRecord.h +41 -0
- package/simpleble/src/backends/android/types/android/bluetooth/le/ScanResult.cpp +63 -0
- package/simpleble/src/backends/android/types/android/bluetooth/le/ScanResult.h +42 -0
- package/simpleble/src/backends/android/types/android/os/ParcelUUID.cpp +32 -0
- package/simpleble/src/backends/android/types/android/os/ParcelUUID.h +30 -0
- package/simpleble/src/backends/android/types/android/util/SparseArray.cpp +54 -0
- package/simpleble/src/backends/android/types/android/util/SparseArray.h +37 -0
- package/simpleble/src/backends/android/types/java/util/Iterator.cpp +36 -0
- package/simpleble/src/backends/android/types/java/util/Iterator.h +28 -0
- package/simpleble/src/backends/android/types/java/util/List.cpp +29 -0
- package/simpleble/src/backends/android/types/java/util/List.h +27 -0
- package/simpleble/src/backends/android/types/java/util/Set.cpp +33 -0
- package/simpleble/src/backends/android/types/java/util/Set.h +28 -0
- package/simpleble/src/backends/android/types/java/util/UUID.cpp +26 -0
- package/simpleble/src/backends/android/types/java/util/UUID.h +29 -0
- package/simpleble/src/backends/common/AdapterBase.cpp +53 -0
- package/simpleble/src/backends/common/AdapterBase.h +81 -0
- package/simpleble/src/backends/common/AdapterBaseTypes.h +22 -0
- package/simpleble/src/backends/common/BackendBase.h +20 -0
- package/simpleble/src/backends/common/BackendUtils.h +33 -0
- package/simpleble/src/backends/common/CharacteristicBase.cpp +28 -0
- package/simpleble/src/backends/common/CharacteristicBase.h +38 -0
- package/simpleble/src/backends/common/DescriptorBase.cpp +7 -0
- package/simpleble/src/backends/common/DescriptorBase.h +19 -0
- package/simpleble/src/backends/common/PeripheralBase.h +82 -0
- package/simpleble/src/backends/common/ServiceBase.cpp +18 -0
- package/simpleble/src/backends/common/ServiceBase.h +28 -0
- package/simpleble/src/backends/dongl/AdapterBaseTypes.h +22 -0
- package/simpleble/src/backends/dongl/AdapterDongl.cpp +369 -0
- package/simpleble/src/backends/dongl/AdapterDongl.h +60 -0
- package/simpleble/src/backends/dongl/BackendDongl.cpp +35 -0
- package/simpleble/src/backends/dongl/PeripheralDongl.cpp +562 -0
- package/simpleble/src/backends/dongl/PeripheralDongl.h +136 -0
- package/simpleble/src/backends/dongl/protocol/basic.pb.c +33 -0
- package/simpleble/src/backends/dongl/protocol/basic.pb.h +172 -0
- package/simpleble/src/backends/dongl/protocol/d2h.pb.c +18 -0
- package/simpleble/src/backends/dongl/protocol/d2h.pb.h +118 -0
- package/simpleble/src/backends/dongl/protocol/h2d.pb.c +12 -0
- package/simpleble/src/backends/dongl/protocol/h2d.pb.h +69 -0
- package/simpleble/src/backends/dongl/protocol/simpleble.pb.c +123 -0
- package/simpleble/src/backends/dongl/protocol/simpleble.pb.h +908 -0
- package/simpleble/src/backends/dongl/protocol/softdevice.pb.c +18 -0
- package/simpleble/src/backends/dongl/protocol/softdevice.pb.h +815 -0
- package/simpleble/src/backends/dongl/protocol/softdevice_gap.pb.c +339 -0
- package/simpleble/src/backends/dongl/protocol/softdevice_gap.pb.h +2086 -0
- package/simpleble/src/backends/dongl/protocol/softdevice_gattc.pb.c +114 -0
- package/simpleble/src/backends/dongl/protocol/softdevice_gattc.pb.h +772 -0
- package/simpleble/src/backends/dongl/protocol/softdevice_gatts.pb.c +117 -0
- package/simpleble/src/backends/dongl/protocol/softdevice_gatts.pb.h +766 -0
- package/simpleble/src/backends/dongl/protocol/softdevice_types.pb.c +207 -0
- package/simpleble/src/backends/dongl/protocol/softdevice_types.pb.h +1686 -0
- package/simpleble/src/backends/dongl/serial/Protocol.cpp +887 -0
- package/simpleble/src/backends/dongl/serial/Protocol.h +117 -0
- package/simpleble/src/backends/dongl/serial/ProtocolBase.cpp +95 -0
- package/simpleble/src/backends/dongl/serial/ProtocolBase.h +54 -0
- package/simpleble/src/backends/dongl/serial/Wire.cpp +133 -0
- package/simpleble/src/backends/dongl/serial/Wire.h +116 -0
- package/simpleble/src/backends/dongl/usb/UsbHelper.cpp +53 -0
- package/simpleble/src/backends/dongl/usb/UsbHelper.h +32 -0
- package/simpleble/src/backends/dongl/usb/UsbHelperApple.cpp +266 -0
- package/simpleble/src/backends/dongl/usb/UsbHelperApple.h +34 -0
- package/simpleble/src/backends/dongl/usb/UsbHelperImpl.h +29 -0
- package/simpleble/src/backends/dongl/usb/UsbHelperLinux.cpp +21 -0
- package/simpleble/src/backends/dongl/usb/UsbHelperLinux.h +22 -0
- package/simpleble/src/backends/dongl/usb/UsbHelperNull.cpp +21 -0
- package/simpleble/src/backends/dongl/usb/UsbHelperNull.h +22 -0
- package/simpleble/src/backends/dongl/usb/UsbHelperWindows.cpp +21 -0
- package/simpleble/src/backends/dongl/usb/UsbHelperWindows.h +22 -0
- package/simpleble/src/backends/linux/AdapterLinux.cpp +102 -0
- package/simpleble/src/backends/linux/AdapterLinux.h +55 -0
- package/simpleble/src/backends/linux/BackendBluez.cpp +90 -0
- package/simpleble/src/backends/linux/PeripheralLinux.cpp +394 -0
- package/simpleble/src/backends/linux/PeripheralLinux.h +90 -0
- package/simpleble/src/backends/linux_legacy/AdapterLinuxLegacy.cpp +102 -0
- package/simpleble/src/backends/linux_legacy/AdapterLinuxLegacy.h +55 -0
- package/simpleble/src/backends/linux_legacy/BackendBluezLegacy.cpp +87 -0
- package/simpleble/src/backends/linux_legacy/PeripheralLinuxLegacy.cpp +376 -0
- package/simpleble/src/backends/linux_legacy/PeripheralLinuxLegacy.h +90 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/Adapter.h +46 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/Agent.h +52 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/Bluez.h +37 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/BluezOrg.h +22 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/BluezOrgBluez.h +26 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/BluezRoot.h +32 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/Characteristic.h +47 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/Descriptor.h +33 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/Device.h +64 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/Exceptions.h +43 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/Service.h +27 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/Types.h +9 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/interfaces/Adapter1.h +49 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/interfaces/Agent1.h +100 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/interfaces/AgentManager1.h +24 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/interfaces/Battery1.h +32 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/interfaces/Device1.h +62 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/interfaces/GattCharacteristic1.h +48 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/interfaces/GattDescriptor1.h +41 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/interfaces/GattService1.h +28 -0
- package/simpleble/src/backends/linux_legacy/include/simpledbuslegacy/advanced/Interface.h +67 -0
- package/simpleble/src/backends/linux_legacy/include/simpledbuslegacy/advanced/InterfaceRegistry.h +62 -0
- package/simpleble/src/backends/linux_legacy/include/simpledbuslegacy/advanced/Proxy.h +117 -0
- package/simpleble/src/backends/linux_legacy/include/simpledbuslegacy/base/Connection.h +50 -0
- package/simpleble/src/backends/linux_legacy/include/simpledbuslegacy/base/Exceptions.h +56 -0
- package/simpleble/src/backends/linux_legacy/include/simpledbuslegacy/base/Holder.h +147 -0
- package/simpleble/src/backends/linux_legacy/include/simpledbuslegacy/base/Logging.h +57 -0
- package/simpleble/src/backends/linux_legacy/include/simpledbuslegacy/base/Message.h +89 -0
- package/simpleble/src/backends/linux_legacy/include/simpledbuslegacy/base/Path.h +24 -0
- package/simpleble/src/backends/linux_legacy/include/simpledbuslegacy/interfaces/ObjectManager.h +26 -0
- package/simpleble/src/backends/linux_legacy/src/Adapter.cpp +78 -0
- package/simpleble/src/backends/linux_legacy/src/Agent.cpp +72 -0
- package/simpleble/src/backends/linux_legacy/src/Bluez.cpp +45 -0
- package/simpleble/src/backends/linux_legacy/src/BluezOrg.cpp +20 -0
- package/simpleble/src/backends/linux_legacy/src/BluezOrgBluez.cpp +23 -0
- package/simpleble/src/backends/linux_legacy/src/BluezRoot.cpp +44 -0
- package/simpleble/src/backends/linux_legacy/src/Characteristic.cpp +64 -0
- package/simpleble/src/backends/linux_legacy/src/Descriptor.cpp +27 -0
- package/simpleble/src/backends/linux_legacy/src/Device.cpp +104 -0
- package/simpleble/src/backends/linux_legacy/src/Exceptions.cpp +29 -0
- package/simpleble/src/backends/linux_legacy/src/Service.cpp +33 -0
- package/simpleble/src/backends/linux_legacy/src/advanced/Interface.cpp +155 -0
- package/simpleble/src/backends/linux_legacy/src/advanced/Proxy.cpp +374 -0
- package/simpleble/src/backends/linux_legacy/src/base/Connection.cpp +219 -0
- package/simpleble/src/backends/linux_legacy/src/base/Exceptions.cpp +39 -0
- package/simpleble/src/backends/linux_legacy/src/base/Holder.cpp +739 -0
- package/simpleble/src/backends/linux_legacy/src/base/Message.cpp +622 -0
- package/simpleble/src/backends/linux_legacy/src/base/Path.cpp +129 -0
- package/simpleble/src/backends/linux_legacy/src/interfaces/Adapter1.cpp +123 -0
- package/simpleble/src/backends/linux_legacy/src/interfaces/Agent1.cpp +143 -0
- package/simpleble/src/backends/linux_legacy/src/interfaces/AgentManager1.cpp +34 -0
- package/simpleble/src/backends/linux_legacy/src/interfaces/Battery1.cpp +30 -0
- package/simpleble/src/backends/linux_legacy/src/interfaces/Device1.cpp +170 -0
- package/simpleble/src/backends/linux_legacy/src/interfaces/GattCharacteristic1.cpp +118 -0
- package/simpleble/src/backends/linux_legacy/src/interfaces/GattDescriptor1.cpp +78 -0
- package/simpleble/src/backends/linux_legacy/src/interfaces/GattService1.cpp +28 -0
- package/simpleble/src/backends/linux_legacy/src/interfaces/ObjectManager.cpp +58 -0
- package/simpleble/src/backends/macos/AdapterBaseMacOS.h +29 -0
- package/simpleble/src/backends/macos/AdapterBaseMacOS.mm +235 -0
- package/simpleble/src/backends/macos/AdapterMac.h +78 -0
- package/simpleble/src/backends/macos/AdapterMac.mm +156 -0
- package/simpleble/src/backends/macos/BackendCoreBluetooth.mm +45 -0
- package/simpleble/src/backends/macos/PeripheralBaseMacOS.h +49 -0
- package/simpleble/src/backends/macos/PeripheralBaseMacOS.mm +714 -0
- package/simpleble/src/backends/macos/PeripheralMac.h +81 -0
- package/simpleble/src/backends/macos/PeripheralMac.mm +229 -0
- package/simpleble/src/backends/macos/Utils.h +9 -0
- package/simpleble/src/backends/macos/Utils.mm +23 -0
- package/simpleble/src/backends/plain/AdapterPlain.cpp +65 -0
- package/simpleble/src/backends/plain/AdapterPlain.h +49 -0
- package/simpleble/src/backends/plain/BackendPlain.cpp +30 -0
- package/simpleble/src/backends/plain/PeripheralPlain.cpp +159 -0
- package/simpleble/src/backends/plain/PeripheralPlain.h +72 -0
- package/simpleble/src/backends/windows/AdapterWindows.cpp +338 -0
- package/simpleble/src/backends/windows/AdapterWindows.h +89 -0
- package/simpleble/src/backends/windows/BackendWinRT.cpp +67 -0
- package/simpleble/src/backends/windows/BackendWinRT.h +18 -0
- package/simpleble/src/backends/windows/MtaManager.cpp +49 -0
- package/simpleble/src/backends/windows/MtaManager.h +90 -0
- package/simpleble/src/backends/windows/PeripheralWindows.cpp +487 -0
- package/simpleble/src/backends/windows/PeripheralWindows.h +129 -0
- package/simpleble/src/backends/windows/Utils.cpp +146 -0
- package/simpleble/src/backends/windows/Utils.h +47 -0
- package/simpleble/src/builders/BuildVec.h +32 -0
- package/simpleble/src/builders/BuilderBase.h +87 -0
- package/simpleble/src/external/TaskRunner.hpp +99 -0
- package/simpleble/src/external/ThreadRunner.h +52 -0
- package/simpleble/src/external/kvn_safe_callback.hpp +66 -0
- package/simpleble/src/external/kvn_safe_map.hpp +94 -0
- package/simpleble/src/external/kvn_threadrunner.hpp +70 -0
- package/simpleble/src/external/logfwd.hpp +35 -0
- package/simpleble/src/frontends/base/Adapter.cpp +111 -0
- package/simpleble/src/frontends/base/Advanced.cpp +34 -0
- package/simpleble/src/frontends/base/Backend.cpp +95 -0
- package/simpleble/src/frontends/base/Backend.h +76 -0
- package/simpleble/src/frontends/base/Characteristic.cpp +56 -0
- package/simpleble/src/frontends/base/Descriptor.cpp +21 -0
- package/simpleble/src/frontends/base/Peripheral.cpp +113 -0
- package/simpleble/src/frontends/base/Service.cpp +26 -0
- package/simpleble/src/frontends/safe/AdapterSafe.cpp +158 -0
- package/simpleble/src/frontends/safe/PeripheralSafe.cpp +219 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Thread-safe map implementation with custom comparator support
|
|
3
|
+
*/
|
|
4
|
+
#ifndef KVN_SAFE_MAP_HPP
|
|
5
|
+
#define KVN_SAFE_MAP_HPP
|
|
6
|
+
|
|
7
|
+
#include <map>
|
|
8
|
+
#include <memory>
|
|
9
|
+
#include <mutex>
|
|
10
|
+
#include <optional>
|
|
11
|
+
|
|
12
|
+
namespace kvn {
|
|
13
|
+
|
|
14
|
+
template <typename _Key, typename _Value, typename _Compare = std::less<_Key>>
|
|
15
|
+
class safe_map {
|
|
16
|
+
public:
|
|
17
|
+
safe_map() = default;
|
|
18
|
+
explicit safe_map(const _Compare& comp) : _map(comp) {}
|
|
19
|
+
|
|
20
|
+
// Remove copy constructor and copy assignment
|
|
21
|
+
safe_map(const safe_map&) = delete;
|
|
22
|
+
safe_map& operator=(const safe_map&) = delete;
|
|
23
|
+
|
|
24
|
+
// Move operations
|
|
25
|
+
safe_map(safe_map&&) noexcept = default;
|
|
26
|
+
safe_map& operator=(safe_map&&) noexcept = default;
|
|
27
|
+
|
|
28
|
+
// Add this inside the safe_map class
|
|
29
|
+
_Value& operator[](const _Key& key) {
|
|
30
|
+
std::scoped_lock lock(_mutex);
|
|
31
|
+
return _map[key];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const _Value& operator[](const _Key& key) const {
|
|
35
|
+
std::scoped_lock lock(_mutex);
|
|
36
|
+
return _map[key];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
void insert(const _Key& key, const _Value& value) {
|
|
40
|
+
std::scoped_lock lock(_mutex);
|
|
41
|
+
_map.insert_or_assign(key, value);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
void insert(_Key&& key, _Value&& value) {
|
|
45
|
+
std::scoped_lock lock(_mutex);
|
|
46
|
+
_map.insert_or_assign(std::move(key), std::move(value));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
bool erase(const _Key& key) {
|
|
50
|
+
std::scoped_lock lock(_mutex);
|
|
51
|
+
return _map.erase(key) > 0;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
std::optional<_Value> get(const _Key& key) const {
|
|
55
|
+
std::scoped_lock lock(_mutex);
|
|
56
|
+
auto it = _map.find(key);
|
|
57
|
+
if (it != _map.end()) {
|
|
58
|
+
return it->second;
|
|
59
|
+
}
|
|
60
|
+
return std::nullopt;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
bool contains(const _Key& key) const {
|
|
64
|
+
std::scoped_lock lock(_mutex);
|
|
65
|
+
return _map.contains(key);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
size_t size() const {
|
|
69
|
+
std::scoped_lock lock(_mutex);
|
|
70
|
+
return _map.size();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
void clear() {
|
|
74
|
+
std::scoped_lock lock(_mutex);
|
|
75
|
+
_map.clear();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
template <typename _Func>
|
|
79
|
+
void atomic_update(const _Key& key, _Func update_func) {
|
|
80
|
+
std::scoped_lock lock(_mutex);
|
|
81
|
+
auto it = _map.find(key);
|
|
82
|
+
if (it != _map.end()) {
|
|
83
|
+
update_func(it->second);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
protected:
|
|
88
|
+
mutable std::recursive_mutex _mutex;
|
|
89
|
+
std::map<_Key, _Value, _Compare> _map;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
} // namespace kvn
|
|
93
|
+
|
|
94
|
+
#endif // KVN_SAFE_MAP_HPP
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* SPDX-FileCopyrightText: 2025 Kevin Dewald <kevin@dewald.me>
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
#ifndef KVN_THREADRUNNER_HPP
|
|
8
|
+
#define KVN_THREADRUNNER_HPP
|
|
9
|
+
|
|
10
|
+
#include <condition_variable>
|
|
11
|
+
#include <functional>
|
|
12
|
+
#include <mutex>
|
|
13
|
+
#include <queue>
|
|
14
|
+
#include <thread>
|
|
15
|
+
|
|
16
|
+
namespace kvn {
|
|
17
|
+
|
|
18
|
+
class thread_runner {
|
|
19
|
+
public:
|
|
20
|
+
thread_runner() : _stop(false) { _thread = std::thread(&thread_runner::thread_func, this); }
|
|
21
|
+
|
|
22
|
+
// Remove copy constructor and copy assignment
|
|
23
|
+
thread_runner(const thread_runner&) = delete;
|
|
24
|
+
thread_runner& operator=(const thread_runner&) = delete;
|
|
25
|
+
|
|
26
|
+
virtual ~thread_runner() {
|
|
27
|
+
{
|
|
28
|
+
std::unique_lock<std::mutex> lock(_mutex);
|
|
29
|
+
_stop = true;
|
|
30
|
+
_cv.notify_one();
|
|
31
|
+
}
|
|
32
|
+
_thread.join();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
void enqueue(std::function<void()> func) {
|
|
36
|
+
{
|
|
37
|
+
std::unique_lock<std::mutex> lock(_mutex);
|
|
38
|
+
_queue.push(std::move(func));
|
|
39
|
+
lock.unlock(); // Unlock before notify
|
|
40
|
+
_cv.notify_one();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
protected:
|
|
45
|
+
void thread_func() {
|
|
46
|
+
while (true) {
|
|
47
|
+
std::function<void()> func;
|
|
48
|
+
{
|
|
49
|
+
std::unique_lock<std::mutex> lock(_mutex);
|
|
50
|
+
_cv.wait(lock, [this] { return _stop || !_queue.empty(); });
|
|
51
|
+
if (_stop && _queue.empty()) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
func = std::move(_queue.front());
|
|
55
|
+
_queue.pop();
|
|
56
|
+
}
|
|
57
|
+
func();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
std::thread _thread;
|
|
62
|
+
std::mutex _mutex;
|
|
63
|
+
std::condition_variable _cv;
|
|
64
|
+
std::queue<std::function<void()>> _queue;
|
|
65
|
+
bool _stop;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
} // namespace kvn
|
|
69
|
+
|
|
70
|
+
#endif // KVN_THREADRUNNER_HPP
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#ifndef LOGFWD_HPP
|
|
2
|
+
#define LOGFWD_HPP
|
|
3
|
+
|
|
4
|
+
#include <string>
|
|
5
|
+
|
|
6
|
+
namespace logfwd {
|
|
7
|
+
|
|
8
|
+
enum level : int {
|
|
9
|
+
NONE = 0,
|
|
10
|
+
FATAL,
|
|
11
|
+
ERROR,
|
|
12
|
+
WARN,
|
|
13
|
+
INFO,
|
|
14
|
+
#pragma push_macro("DEBUG")
|
|
15
|
+
#undef DEBUG
|
|
16
|
+
DEBUG,
|
|
17
|
+
#pragma pop_macro("DEBUG")
|
|
18
|
+
VERBOSE,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// clang-format off
|
|
22
|
+
|
|
23
|
+
void receive(
|
|
24
|
+
level level,
|
|
25
|
+
const std::string& module,
|
|
26
|
+
const std::string& file,
|
|
27
|
+
uint32_t line,
|
|
28
|
+
const std::string& function,
|
|
29
|
+
const std::string& message);
|
|
30
|
+
|
|
31
|
+
// clang-format on
|
|
32
|
+
|
|
33
|
+
} // namespace logfwd
|
|
34
|
+
|
|
35
|
+
#endif // LOGFWD_HPP
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
#include <simpleble/Adapter.h>
|
|
2
|
+
#include "Backend.h"
|
|
3
|
+
|
|
4
|
+
#include "BuildVec.h"
|
|
5
|
+
#include "LoggingInternal.h"
|
|
6
|
+
#include "backends/common/AdapterBase.h"
|
|
7
|
+
|
|
8
|
+
using namespace SimpleBLE;
|
|
9
|
+
|
|
10
|
+
std::vector<Adapter> Adapter::get_adapters() {
|
|
11
|
+
std::vector<Adapter> adapter_list;
|
|
12
|
+
for (auto& backend : Backend::get_backends()) {
|
|
13
|
+
for (auto& adapter : backend.get_adapters()) {
|
|
14
|
+
adapter_list.push_back(adapter);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return adapter_list;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// TODO: this should be the implementation of the per-backend bluetooth_enabled() function
|
|
22
|
+
// bool Adapter::bluetooth_enabled() { return (*this)->bluetooth_enabled(); }
|
|
23
|
+
|
|
24
|
+
bool Adapter::bluetooth_enabled() { return get_enabled_backend().bluetooth_enabled(); }
|
|
25
|
+
|
|
26
|
+
bool Adapter::initialized() const { return internal_ != nullptr; }
|
|
27
|
+
|
|
28
|
+
void* Adapter::underlying() const { return (*this)->underlying(); }
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Return the adapter implementation if it is initialized.
|
|
32
|
+
*
|
|
33
|
+
* @throws SimpleBLE::NotInitialized if the adapter is not initialized.
|
|
34
|
+
*/
|
|
35
|
+
AdapterBase* Adapter::operator->() {
|
|
36
|
+
if (!internal_) {
|
|
37
|
+
throw Exception::NotInitialized();
|
|
38
|
+
}
|
|
39
|
+
return internal_.get();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const AdapterBase* Adapter::operator->() const {
|
|
43
|
+
if (!internal_) {
|
|
44
|
+
throw Exception::NotInitialized();
|
|
45
|
+
}
|
|
46
|
+
return internal_.get();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
std::string Adapter::identifier() { return (*this)->identifier(); }
|
|
50
|
+
|
|
51
|
+
BluetoothAddress Adapter::address() { return (*this)->address(); }
|
|
52
|
+
|
|
53
|
+
void Adapter::power_on() { (*this)->power_on(); }
|
|
54
|
+
|
|
55
|
+
void Adapter::power_off() { (*this)->power_off(); }
|
|
56
|
+
|
|
57
|
+
bool Adapter::is_powered() { return (*this)->is_powered(); }
|
|
58
|
+
|
|
59
|
+
void Adapter::set_callback_on_power_on(std::function<void()> on_power_on) {
|
|
60
|
+
(*this)->set_callback_on_power_on(std::move(on_power_on));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
void Adapter::set_callback_on_power_off(std::function<void()> on_power_off) {
|
|
64
|
+
(*this)->set_callback_on_power_off(std::move(on_power_off));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
void Adapter::scan_start() {
|
|
68
|
+
if (!bluetooth_enabled()) {
|
|
69
|
+
SIMPLEBLE_LOG_WARN(fmt::format("Bluetooth is not enabled."));
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
(*this)->scan_start();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
void Adapter::scan_stop() {
|
|
76
|
+
if (!bluetooth_enabled()) {
|
|
77
|
+
SIMPLEBLE_LOG_WARN(fmt::format("Bluetooth is not enabled."));
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
(*this)->scan_stop();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
void Adapter::scan_for(int timeout_ms) {
|
|
84
|
+
if (!bluetooth_enabled()) {
|
|
85
|
+
SIMPLEBLE_LOG_WARN(fmt::format("Bluetooth is not enabled."));
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
(*this)->scan_for(timeout_ms);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
bool Adapter::scan_is_active() { return (*this)->scan_is_active(); }
|
|
92
|
+
|
|
93
|
+
std::vector<Peripheral> Adapter::scan_get_results() { return Factory::vector((*this)->scan_get_results()); }
|
|
94
|
+
|
|
95
|
+
std::vector<Peripheral> Adapter::get_paired_peripherals() { return Factory::vector((*this)->get_paired_peripherals()); }
|
|
96
|
+
|
|
97
|
+
void Adapter::set_callback_on_scan_start(std::function<void()> on_scan_start) {
|
|
98
|
+
(*this)->set_callback_on_scan_start(std::move(on_scan_start));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
void Adapter::set_callback_on_scan_stop(std::function<void()> on_scan_stop) {
|
|
102
|
+
(*this)->set_callback_on_scan_stop(std::move(on_scan_stop));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
void Adapter::set_callback_on_scan_updated(std::function<void(Peripheral)> on_scan_updated) {
|
|
106
|
+
(*this)->set_callback_on_scan_updated(std::move(on_scan_updated));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
void Adapter::set_callback_on_scan_found(std::function<void(Peripheral)> on_scan_found) {
|
|
110
|
+
(*this)->set_callback_on_scan_found(std::move(on_scan_found));
|
|
111
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#include "simpleble/Advanced.h"
|
|
2
|
+
|
|
3
|
+
#if defined(_WIN32)
|
|
4
|
+
namespace SimpleBLE::Advanced::Windows {}
|
|
5
|
+
|
|
6
|
+
#endif
|
|
7
|
+
|
|
8
|
+
#if TARGET_OS_OSX
|
|
9
|
+
namespace SimpleBLE::Advanced::MacOS {}
|
|
10
|
+
|
|
11
|
+
#endif
|
|
12
|
+
|
|
13
|
+
#if TARGET_OS_IOS
|
|
14
|
+
namespace SimpleBLE::Advanced::iOS {}
|
|
15
|
+
|
|
16
|
+
#endif
|
|
17
|
+
|
|
18
|
+
#if defined(__ANDROID__)
|
|
19
|
+
|
|
20
|
+
#include "simplejni/VM.hpp"
|
|
21
|
+
|
|
22
|
+
namespace SimpleBLE::Advanced::Android {
|
|
23
|
+
|
|
24
|
+
JavaVM* get_jvm() { return SimpleJNI::VM::jvm(); }
|
|
25
|
+
void set_jvm(JavaVM* jvm) { SimpleJNI::VM::jvm(jvm); }
|
|
26
|
+
|
|
27
|
+
} // namespace SimpleBLE::Advanced::Android
|
|
28
|
+
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
#if defined(__linux__) && !defined(__ANDROID__)
|
|
32
|
+
namespace SimpleBLE::Advanced::Linux {}
|
|
33
|
+
|
|
34
|
+
#endif
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#include <vector>
|
|
2
|
+
|
|
3
|
+
#include <simpleble/Adapter.h>
|
|
4
|
+
#include <simpleble/Config.h>
|
|
5
|
+
#include <simpleble/Exceptions.h>
|
|
6
|
+
|
|
7
|
+
#include "BackendBase.h"
|
|
8
|
+
#include "BuildVec.h"
|
|
9
|
+
#include "CommonUtils.h"
|
|
10
|
+
|
|
11
|
+
#include "Backend.h"
|
|
12
|
+
|
|
13
|
+
using namespace SimpleBLE;
|
|
14
|
+
|
|
15
|
+
namespace SimpleBLE {
|
|
16
|
+
|
|
17
|
+
static std::shared_ptr<BackendBase> _get_enabled_backend() {
|
|
18
|
+
using BackendPtr = std::shared_ptr<BackendBase>(void);
|
|
19
|
+
|
|
20
|
+
if (Config::Dongl::use_dongl_backend) {
|
|
21
|
+
extern BackendPtr BACKEND_DONGL;
|
|
22
|
+
return BACKEND_DONGL();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if constexpr (SIMPLEBLE_BACKEND_LINUX) {
|
|
26
|
+
extern BackendPtr BACKEND_LINUX;
|
|
27
|
+
extern BackendPtr BACKEND_LINUX_LEGACY;
|
|
28
|
+
|
|
29
|
+
if (Config::SimpleBluez::use_legacy_bluez_backend) {
|
|
30
|
+
return BACKEND_LINUX_LEGACY();
|
|
31
|
+
} else {
|
|
32
|
+
return BACKEND_LINUX();
|
|
33
|
+
}
|
|
34
|
+
} else if constexpr (SIMPLEBLE_BACKEND_WINDOWS) {
|
|
35
|
+
extern BackendPtr BACKEND_WINDOWS;
|
|
36
|
+
return BACKEND_WINDOWS();
|
|
37
|
+
} else if constexpr (SIMPLEBLE_BACKEND_ANDROID) {
|
|
38
|
+
extern BackendPtr BACKEND_ANDROID;
|
|
39
|
+
return BACKEND_ANDROID();
|
|
40
|
+
} else if constexpr (SIMPLEBLE_BACKEND_MACOS) {
|
|
41
|
+
extern BackendPtr BACKEND_MACOS;
|
|
42
|
+
return BACKEND_MACOS();
|
|
43
|
+
} else if constexpr (SIMPLEBLE_BACKEND_IOS) {
|
|
44
|
+
extern BackendPtr BACKEND_MACOS;
|
|
45
|
+
return BACKEND_MACOS();
|
|
46
|
+
} else if constexpr (SIMPLEBLE_BACKEND_PLAIN) {
|
|
47
|
+
extern BackendPtr BACKEND_PLAIN;
|
|
48
|
+
return BACKEND_PLAIN();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
throw Exception::NotInitialized();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
Backend get_enabled_backend() { return Factory::build(_get_enabled_backend()); }
|
|
55
|
+
|
|
56
|
+
// NOTE: in the future, this can return multiple backends
|
|
57
|
+
static SharedPtrVector<BackendBase> _get_backends() {
|
|
58
|
+
SharedPtrVector<BackendBase> backends = {_get_enabled_backend()};
|
|
59
|
+
return backends;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
} // namespace SimpleBLE
|
|
63
|
+
|
|
64
|
+
std::vector<Backend> Backend::get_backends() { return Factory::vector(_get_backends()); }
|
|
65
|
+
|
|
66
|
+
bool Backend::initialized() const { return internal_ != nullptr; }
|
|
67
|
+
|
|
68
|
+
BackendBase* Backend::operator->() {
|
|
69
|
+
if (!initialized()) {
|
|
70
|
+
throw Exception::NotInitialized();
|
|
71
|
+
}
|
|
72
|
+
return internal_.get();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const BackendBase* Backend::operator->() const {
|
|
76
|
+
if (!initialized()) {
|
|
77
|
+
throw Exception::NotInitialized();
|
|
78
|
+
}
|
|
79
|
+
return internal_.get();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
std::vector<Adapter> Backend::get_adapters() { return Factory::vector((*this)->get_adapters()); }
|
|
83
|
+
|
|
84
|
+
bool Backend::bluetooth_enabled() { return (*this)->bluetooth_enabled(); }
|
|
85
|
+
|
|
86
|
+
std::optional<Backend> Backend::first_bluetooth_enabled() {
|
|
87
|
+
for (auto& backend : get_backends()) {
|
|
88
|
+
if (backend->bluetooth_enabled()) {
|
|
89
|
+
return backend;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return std::nullopt;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
std::string Backend::name() const noexcept { return (*this)->name(); }
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <optional>
|
|
5
|
+
#include <string>
|
|
6
|
+
#include <vector>
|
|
7
|
+
|
|
8
|
+
#include <simpleble/Adapter.h>
|
|
9
|
+
#include <simpleble/export.h>
|
|
10
|
+
|
|
11
|
+
namespace SimpleBLE {
|
|
12
|
+
|
|
13
|
+
class BackendBase;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Backend.
|
|
17
|
+
*
|
|
18
|
+
* NOTE: backends must not implement this class directly, but instead derive
|
|
19
|
+
* from BackendBase, defined in Backend.h.
|
|
20
|
+
*
|
|
21
|
+
* This frontend class is hidden from users for the time being. Once the API
|
|
22
|
+
* stabilizes, this class will be exposed to users.
|
|
23
|
+
*/
|
|
24
|
+
class SIMPLEBLE_EXPORT Backend {
|
|
25
|
+
public:
|
|
26
|
+
Backend() = default;
|
|
27
|
+
virtual ~Backend() = default;
|
|
28
|
+
|
|
29
|
+
bool initialized() const;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Get a list of all available adapters from this backend.
|
|
33
|
+
*/
|
|
34
|
+
std::vector<Adapter> get_adapters();
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Check if Bluetooth is enabled for this backend.
|
|
38
|
+
*/
|
|
39
|
+
bool bluetooth_enabled();
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Get the first backend that has Bluetooth enabled.
|
|
43
|
+
*
|
|
44
|
+
* @return The first backend that has Bluetooth enabled, or std::nullopt if
|
|
45
|
+
* no backends have Bluetooth enabled.
|
|
46
|
+
*/
|
|
47
|
+
static std::optional<Backend> first_bluetooth_enabled();
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Get the name of the backend.
|
|
51
|
+
*/
|
|
52
|
+
std::string name() const noexcept;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Get all available backends.
|
|
56
|
+
*
|
|
57
|
+
* This will cause backends to be instantiated/initialized.
|
|
58
|
+
*/
|
|
59
|
+
static std::vector<Backend> get_backends();
|
|
60
|
+
|
|
61
|
+
protected:
|
|
62
|
+
BackendBase* operator->();
|
|
63
|
+
const BackendBase* operator->() const;
|
|
64
|
+
|
|
65
|
+
std::shared_ptr<BackendBase> internal_;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Get the enabled backend.
|
|
70
|
+
*
|
|
71
|
+
* Note: this function should not be part of the public API and will be deleted
|
|
72
|
+
* once multiple backends are supported.
|
|
73
|
+
*/
|
|
74
|
+
Backend get_enabled_backend();
|
|
75
|
+
|
|
76
|
+
} // namespace SimpleBLE
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#include <simpleble/Characteristic.h>
|
|
2
|
+
|
|
3
|
+
#include "BuildVec.h"
|
|
4
|
+
#include "CharacteristicBase.h"
|
|
5
|
+
|
|
6
|
+
using namespace SimpleBLE;
|
|
7
|
+
|
|
8
|
+
BluetoothUUID Characteristic::uuid() { return (*this)->uuid(); }
|
|
9
|
+
|
|
10
|
+
std::vector<Descriptor> Characteristic::descriptors() { return Factory::vector((*this)->descriptors()); }
|
|
11
|
+
|
|
12
|
+
std::vector<std::string> Characteristic::capabilities() {
|
|
13
|
+
std::vector<std::string> capabilities;
|
|
14
|
+
|
|
15
|
+
if (can_read()) {
|
|
16
|
+
capabilities.push_back("read");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (can_write_request()) {
|
|
20
|
+
capabilities.push_back("write_request");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (can_write_command()) {
|
|
24
|
+
capabilities.push_back("write_command");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (can_notify()) {
|
|
28
|
+
capabilities.push_back("notify");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (can_indicate()) {
|
|
32
|
+
capabilities.push_back("indicate");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return capabilities;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
bool Characteristic::initialized() const { return internal_ != nullptr; }
|
|
39
|
+
|
|
40
|
+
CharacteristicBase* Characteristic::operator->() {
|
|
41
|
+
if (!initialized()) throw Exception::NotInitialized();
|
|
42
|
+
|
|
43
|
+
return internal_.get();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const CharacteristicBase* Characteristic::operator->() const {
|
|
47
|
+
if (!initialized()) throw Exception::NotInitialized();
|
|
48
|
+
|
|
49
|
+
return internal_.get();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
bool Characteristic::can_read() { return (*this)->can_read(); }
|
|
53
|
+
bool Characteristic::can_write_request() { return (*this)->can_write_request(); }
|
|
54
|
+
bool Characteristic::can_write_command() { return (*this)->can_write_command(); }
|
|
55
|
+
bool Characteristic::can_notify() { return (*this)->can_notify(); }
|
|
56
|
+
bool Characteristic::can_indicate() { return (*this)->can_indicate(); }
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#include <simpleble/Descriptor.h>
|
|
2
|
+
|
|
3
|
+
#include "DescriptorBase.h"
|
|
4
|
+
|
|
5
|
+
using namespace SimpleBLE;
|
|
6
|
+
|
|
7
|
+
bool Descriptor::initialized() const { return internal_ != nullptr; }
|
|
8
|
+
|
|
9
|
+
DescriptorBase* Descriptor::operator->() {
|
|
10
|
+
if (!initialized()) throw Exception::NotInitialized();
|
|
11
|
+
|
|
12
|
+
return internal_.get();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const DescriptorBase* Descriptor::operator->() const {
|
|
16
|
+
if (!initialized()) throw Exception::NotInitialized();
|
|
17
|
+
|
|
18
|
+
return internal_.get();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
BluetoothUUID Descriptor::uuid() { return (*this)->uuid(); }
|