simpleble 0.0.1
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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +88 -0
- data/LICENSE.txt +21 -0
- data/README.md +350 -0
- data/ext/simpleble/extconf.rb +57 -0
- data/ext/simpleble/simpleble_ruby.c +682 -0
- data/lib/simpleble/adapter.rb +10 -0
- data/lib/simpleble/characteristic.rb +36 -0
- data/lib/simpleble/descriptor.rb +8 -0
- data/lib/simpleble/exceptions.rb +25 -0
- data/lib/simpleble/peripheral.rb +64 -0
- data/lib/simpleble/service.rb +16 -0
- data/lib/simpleble/version.rb +3 -0
- data/lib/simpleble.rb +40 -0
- data/vendor/simpleble/build_simplecble/CMakeFiles/4.0.3/CompilerIdCXX/CMakeCXXCompilerId.cpp +920 -0
- data/vendor/simpleble/build_simplecble/CMakeFiles/4.0.3/CompilerIdCXX/apple-sdk.cpp +1 -0
- data/vendor/simpleble/build_simplecble/CMakeFiles/4.1.0/CompilerIdCXX/CMakeCXXCompilerId.cpp +949 -0
- data/vendor/simpleble/build_simplecble/CMakeFiles/4.1.0/CompilerIdCXX/apple-sdk.cpp +1 -0
- data/vendor/simpleble/build_simplecble/export/simplecble/export.h +43 -0
- data/vendor/simpleble/build_simplecble/simpleble/export/simpleble/export.h +43 -0
- data/vendor/simpleble/dependencies/external/kvn/kvn_bytearray.h +222 -0
- data/vendor/simpleble/dependencies/external/kvn/kvn_safe_callback.hpp +66 -0
- data/vendor/simpleble/dependencies/external/kvn/logfwd.hpp +35 -0
- data/vendor/simpleble/dependencies/internal/fmt/args.h +220 -0
- data/vendor/simpleble/dependencies/internal/fmt/base.h +2962 -0
- data/vendor/simpleble/dependencies/internal/fmt/chrono.h +2338 -0
- data/vendor/simpleble/dependencies/internal/fmt/color.h +610 -0
- data/vendor/simpleble/dependencies/internal/fmt/compile.h +539 -0
- data/vendor/simpleble/dependencies/internal/fmt/core.h +5 -0
- data/vendor/simpleble/dependencies/internal/fmt/format-inl.h +1949 -0
- data/vendor/simpleble/dependencies/internal/fmt/format.h +4244 -0
- data/vendor/simpleble/dependencies/internal/fmt/os.h +427 -0
- data/vendor/simpleble/dependencies/internal/fmt/ostream.h +166 -0
- data/vendor/simpleble/dependencies/internal/fmt/printf.h +633 -0
- data/vendor/simpleble/dependencies/internal/fmt/ranges.h +850 -0
- data/vendor/simpleble/dependencies/internal/fmt/std.h +726 -0
- data/vendor/simpleble/dependencies/internal/fmt/xchar.h +373 -0
- data/vendor/simpleble/dependencies/internal/simplejni/Common.hpp +579 -0
- data/vendor/simpleble/dependencies/internal/simplejni/References.hpp +151 -0
- data/vendor/simpleble/dependencies/internal/simplejni/Registry.hpp +183 -0
- data/vendor/simpleble/dependencies/internal/simplejni/VM.hpp +88 -0
- data/vendor/simpleble/examples/simpleble/src/connect.cpp +67 -0
- data/vendor/simpleble/examples/simpleble/src/connect_safe.cpp +91 -0
- data/vendor/simpleble/examples/simpleble/src/list_adapters.cpp +22 -0
- data/vendor/simpleble/examples/simpleble/src/list_adapters_safe.cpp +33 -0
- data/vendor/simpleble/examples/simpleble/src/list_paired.cpp +27 -0
- data/vendor/simpleble/examples/simpleble/src/multiconnect.cpp +60 -0
- data/vendor/simpleble/examples/simpleble/src/notify.cpp +85 -0
- data/vendor/simpleble/examples/simpleble/src/notify_multi.cpp +101 -0
- data/vendor/simpleble/examples/simpleble/src/power_cycle.cpp +43 -0
- data/vendor/simpleble/examples/simpleble/src/read.cpp +82 -0
- data/vendor/simpleble/examples/simpleble/src/scan.cpp +62 -0
- data/vendor/simpleble/examples/simpleble/src/utils.cpp +59 -0
- data/vendor/simpleble/examples/simpleble/src/utils.hpp +27 -0
- data/vendor/simpleble/examples/simpleble/src/write.cpp +81 -0
- data/vendor/simpleble/examples/simplebluez/ble_nus/ble_nus.cpp +138 -0
- data/vendor/simpleble/examples/simplebluez/connect/connect.cpp +119 -0
- data/vendor/simpleble/examples/simplebluez/list_adapters/list_adapters.cpp +44 -0
- data/vendor/simpleble/examples/simplebluez/list_paired/list_paired.cpp +48 -0
- data/vendor/simpleble/examples/simplebluez/notify/notify.cpp +145 -0
- data/vendor/simpleble/examples/simplebluez/pair/pair.cpp +181 -0
- data/vendor/simpleble/examples/simplebluez/read/read.cpp +141 -0
- data/vendor/simpleble/examples/simplebluez/scan/scan.cpp +85 -0
- data/vendor/simpleble/examples/simplecble/c/connect.c +163 -0
- data/vendor/simpleble/examples/simplecble/c/notify.c +217 -0
- data/vendor/simpleble/examples/simplecble/c/scan.c +164 -0
- data/vendor/simpleble/examples/simpledbus/notification.cpp +24 -0
- data/vendor/simpleble/hitl/src/test_sanity.cpp +48 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/Adapter.h +102 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/AdapterSafe.h +58 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/Advanced.h +50 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/Characteristic.h +39 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/Config.h +55 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/Descriptor.h +30 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/Exceptions.h +72 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/Logging.h +73 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/Peripheral.h +82 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/PeripheralSafe.h +64 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/Service.h +34 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/SimpleBLE.h +8 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/Types.h +49 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/Utils.h +13 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/export.h +43 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/kvn/kvn_bytearray.h +222 -0
- data/vendor/simpleble/install_simplecble/include/simplecble/adapter.h +188 -0
- data/vendor/simpleble/install_simplecble/include/simplecble/logging.h +37 -0
- data/vendor/simpleble/install_simplecble/include/simplecble/peripheral.h +304 -0
- data/vendor/simpleble/install_simplecble/include/simplecble/simpleble.h +21 -0
- data/vendor/simpleble/install_simplecble/include/simplecble/types.h +73 -0
- data/vendor/simpleble/install_simplecble/include/simplecble/utils.h +27 -0
- data/vendor/simpleble/simpleble/include/simpleble/Adapter.h +102 -0
- data/vendor/simpleble/simpleble/include/simpleble/AdapterSafe.h +58 -0
- data/vendor/simpleble/simpleble/include/simpleble/Characteristic.h +39 -0
- data/vendor/simpleble/simpleble/include/simpleble/Config.h +55 -0
- data/vendor/simpleble/simpleble/include/simpleble/Descriptor.h +30 -0
- data/vendor/simpleble/simpleble/include/simpleble/Exceptions.h +72 -0
- data/vendor/simpleble/simpleble/include/simpleble/Logging.h +73 -0
- data/vendor/simpleble/simpleble/include/simpleble/Peripheral.h +82 -0
- data/vendor/simpleble/simpleble/include/simpleble/PeripheralSafe.h +64 -0
- data/vendor/simpleble/simpleble/include/simpleble/Service.h +34 -0
- data/vendor/simpleble/simpleble/include/simpleble/SimpleBLE.h +8 -0
- data/vendor/simpleble/simpleble/include/simpleble/Types.h +49 -0
- data/vendor/simpleble/simpleble/include/simpleble/Utils.h +13 -0
- data/vendor/simpleble/simpleble/include/simpleble_c/adapter.h +188 -0
- data/vendor/simpleble/simpleble/include/simpleble_c/logging.h +37 -0
- data/vendor/simpleble/simpleble/include/simpleble_c/peripheral.h +304 -0
- data/vendor/simpleble/simpleble/include/simpleble_c/simpleble.h +21 -0
- data/vendor/simpleble/simpleble/include/simpleble_c/types.h +73 -0
- data/vendor/simpleble/simpleble/include/simpleble_c/utils.h +27 -0
- data/vendor/simpleble/simpleble/src/CommonUtils.h +63 -0
- data/vendor/simpleble/simpleble/src/Exceptions.cpp +31 -0
- data/vendor/simpleble/simpleble/src/Logging.cpp +136 -0
- data/vendor/simpleble/simpleble/src/LoggingInternal.h +85 -0
- data/vendor/simpleble/simpleble/src/Utils.cpp +24 -0
- data/vendor/simpleble/simpleble/src/backends/android/AdapterAndroid.cpp +101 -0
- data/vendor/simpleble/simpleble/src/backends/android/AdapterAndroid.h +70 -0
- data/vendor/simpleble/simpleble/src/backends/android/BackendAndroid.cpp +40 -0
- data/vendor/simpleble/simpleble/src/backends/android/BackendAndroid.h +20 -0
- data/vendor/simpleble/simpleble/src/backends/android/PeripheralAndroid.cpp +365 -0
- data/vendor/simpleble/simpleble/src/backends/android/PeripheralAndroid.h +90 -0
- data/vendor/simpleble/simpleble/src/backends/android/bridge/BluetoothGattCallback.cpp +432 -0
- data/vendor/simpleble/simpleble/src/backends/android/bridge/BluetoothGattCallback.h +102 -0
- data/vendor/simpleble/simpleble/src/backends/android/bridge/ScanCallback.cpp +142 -0
- data/vendor/simpleble/simpleble/src/backends/android/bridge/ScanCallback.h +55 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothAdapter.cpp +107 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothAdapter.h +55 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothDevice.cpp +68 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothDevice.h +54 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGatt.cpp +115 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGatt.h +75 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattCharacteristic.cpp +142 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattCharacteristic.h +66 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattDescriptor.cpp +67 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattDescriptor.h +46 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattService.cpp +106 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattService.h +47 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/le/BluetoothScanner.cpp +47 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/le/BluetoothScanner.h +37 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/le/ScanRecord.cpp +69 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/le/ScanRecord.h +41 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/le/ScanResult.cpp +63 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/le/ScanResult.h +42 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/os/ParcelUUID.cpp +32 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/os/ParcelUUID.h +30 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/util/SparseArray.cpp +54 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/util/SparseArray.h +37 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/java/util/Iterator.cpp +36 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/java/util/Iterator.h +28 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/java/util/List.cpp +29 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/java/util/List.h +27 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/java/util/Set.cpp +33 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/java/util/Set.h +28 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/java/util/UUID.cpp +26 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/java/util/UUID.h +29 -0
- data/vendor/simpleble/simpleble/src/backends/common/AdapterBase.cpp +53 -0
- data/vendor/simpleble/simpleble/src/backends/common/AdapterBase.h +81 -0
- data/vendor/simpleble/simpleble/src/backends/common/AdapterBaseTypes.h +22 -0
- data/vendor/simpleble/simpleble/src/backends/common/BackendBase.h +20 -0
- data/vendor/simpleble/simpleble/src/backends/common/BackendUtils.h +33 -0
- data/vendor/simpleble/simpleble/src/backends/common/CharacteristicBase.cpp +28 -0
- data/vendor/simpleble/simpleble/src/backends/common/CharacteristicBase.h +38 -0
- data/vendor/simpleble/simpleble/src/backends/common/DescriptorBase.cpp +7 -0
- data/vendor/simpleble/simpleble/src/backends/common/DescriptorBase.h +19 -0
- data/vendor/simpleble/simpleble/src/backends/common/PeripheralBase.h +82 -0
- data/vendor/simpleble/simpleble/src/backends/common/ServiceBase.cpp +18 -0
- data/vendor/simpleble/simpleble/src/backends/common/ServiceBase.h +28 -0
- data/vendor/simpleble/simpleble/src/backends/linux/AdapterLinux.cpp +102 -0
- data/vendor/simpleble/simpleble/src/backends/linux/AdapterLinux.h +55 -0
- data/vendor/simpleble/simpleble/src/backends/linux/BackendBluez.cpp +87 -0
- data/vendor/simpleble/simpleble/src/backends/linux/PeripheralLinux.cpp +376 -0
- data/vendor/simpleble/simpleble/src/backends/linux/PeripheralLinux.h +90 -0
- data/vendor/simpleble/simpleble/src/backends/macos/AdapterBaseMacOS.h +29 -0
- data/vendor/simpleble/simpleble/src/backends/macos/AdapterMac.h +78 -0
- data/vendor/simpleble/simpleble/src/backends/macos/PeripheralBaseMacOS.h +49 -0
- data/vendor/simpleble/simpleble/src/backends/macos/PeripheralMac.h +81 -0
- data/vendor/simpleble/simpleble/src/backends/macos/Utils.h +9 -0
- data/vendor/simpleble/simpleble/src/backends/plain/AdapterPlain.cpp +65 -0
- data/vendor/simpleble/simpleble/src/backends/plain/AdapterPlain.h +49 -0
- data/vendor/simpleble/simpleble/src/backends/plain/BackendPlain.cpp +30 -0
- data/vendor/simpleble/simpleble/src/backends/plain/PeripheralPlain.cpp +159 -0
- data/vendor/simpleble/simpleble/src/backends/plain/PeripheralPlain.h +72 -0
- data/vendor/simpleble/simpleble/src/backends/windows/AdapterWindows.cpp +330 -0
- data/vendor/simpleble/simpleble/src/backends/windows/AdapterWindows.h +89 -0
- data/vendor/simpleble/simpleble/src/backends/windows/BackendWinRT.cpp +67 -0
- data/vendor/simpleble/simpleble/src/backends/windows/BackendWinRT.h +18 -0
- data/vendor/simpleble/simpleble/src/backends/windows/MtaManager.cpp +49 -0
- data/vendor/simpleble/simpleble/src/backends/windows/MtaManager.h +90 -0
- data/vendor/simpleble/simpleble/src/backends/windows/PeripheralWindows.cpp +487 -0
- data/vendor/simpleble/simpleble/src/backends/windows/PeripheralWindows.h +129 -0
- data/vendor/simpleble/simpleble/src/backends/windows/Utils.cpp +146 -0
- data/vendor/simpleble/simpleble/src/backends/windows/Utils.h +47 -0
- data/vendor/simpleble/simpleble/src/builders/BuildVec.h +32 -0
- data/vendor/simpleble/simpleble/src/builders/BuilderBase.h +87 -0
- data/vendor/simpleble/simpleble/src/external/TaskRunner.hpp +99 -0
- data/vendor/simpleble/simpleble/src/external/ThreadRunner.h +52 -0
- data/vendor/simpleble/simpleble/src/external/kvn_safe_callback.hpp +66 -0
- data/vendor/simpleble/simpleble/src/external/kvn_safe_map.hpp +94 -0
- data/vendor/simpleble/simpleble/src/external/kvn_threadrunner.hpp +70 -0
- data/vendor/simpleble/simpleble/src/external/logfwd.hpp +35 -0
- data/vendor/simpleble/simpleble/src/frontends/base/Adapter.cpp +111 -0
- data/vendor/simpleble/simpleble/src/frontends/base/Backend.cpp +83 -0
- data/vendor/simpleble/simpleble/src/frontends/base/Backend.h +76 -0
- data/vendor/simpleble/simpleble/src/frontends/base/Characteristic.cpp +56 -0
- data/vendor/simpleble/simpleble/src/frontends/base/Descriptor.cpp +21 -0
- data/vendor/simpleble/simpleble/src/frontends/base/Peripheral.cpp +113 -0
- data/vendor/simpleble/simpleble/src/frontends/base/Service.cpp +26 -0
- data/vendor/simpleble/simpleble/src/frontends/safe/AdapterSafe.cpp +158 -0
- data/vendor/simpleble/simpleble/src/frontends/safe/PeripheralSafe.cpp +219 -0
- data/vendor/simpleble/simpleble/src_c/adapter.cpp +204 -0
- data/vendor/simpleble/simpleble/src_c/logging.cpp +19 -0
- data/vendor/simpleble/simpleble/src_c/peripheral.cpp +444 -0
- data/vendor/simpleble/simpleble/src_c/simpleble.cpp +5 -0
- data/vendor/simpleble/simpleble/src_c/utils.cpp +15 -0
- data/vendor/simpleble/simpleble/test/src/main.cpp +8 -0
- data/vendor/simpleble/simpleble/test/src/test_bytearray.cpp +246 -0
- data/vendor/simpleble/simpleble/test/src/test_utils.cpp +24 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/Adapter.h +46 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/Agent.h +52 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/Bluez.h +37 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/BluezOrg.h +22 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/BluezOrgBluez.h +26 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/BluezRoot.h +32 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/Characteristic.h +46 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/Descriptor.h +33 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/Device.h +64 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/Exceptions.h +43 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/Service.h +27 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/Types.h +9 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/Adapter1.h +49 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/Agent1.h +100 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/AgentManager1.h +24 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/Battery1.h +32 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/Device1.h +62 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/GattCharacteristic1.h +48 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/GattDescriptor1.h +41 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/GattService1.h +28 -0
- data/vendor/simpleble/simplebluez/src/Adapter.cpp +78 -0
- data/vendor/simpleble/simplebluez/src/Agent.cpp +72 -0
- data/vendor/simpleble/simplebluez/src/Bluez.cpp +45 -0
- data/vendor/simpleble/simplebluez/src/BluezOrg.cpp +20 -0
- data/vendor/simpleble/simplebluez/src/BluezOrgBluez.cpp +23 -0
- data/vendor/simpleble/simplebluez/src/BluezRoot.cpp +44 -0
- data/vendor/simpleble/simplebluez/src/Characteristic.cpp +64 -0
- data/vendor/simpleble/simplebluez/src/Descriptor.cpp +27 -0
- data/vendor/simpleble/simplebluez/src/Device.cpp +104 -0
- data/vendor/simpleble/simplebluez/src/Exceptions.cpp +29 -0
- data/vendor/simpleble/simplebluez/src/Logging.cpp +52 -0
- data/vendor/simpleble/simplebluez/src/Logging.h +57 -0
- data/vendor/simpleble/simplebluez/src/Service.cpp +33 -0
- data/vendor/simpleble/simplebluez/src/interfaces/Adapter1.cpp +123 -0
- data/vendor/simpleble/simplebluez/src/interfaces/Agent1.cpp +143 -0
- data/vendor/simpleble/simplebluez/src/interfaces/AgentManager1.cpp +34 -0
- data/vendor/simpleble/simplebluez/src/interfaces/Battery1.cpp +30 -0
- data/vendor/simpleble/simplebluez/src/interfaces/Device1.cpp +170 -0
- data/vendor/simpleble/simplebluez/src/interfaces/GattCharacteristic1.cpp +118 -0
- data/vendor/simpleble/simplebluez/src/interfaces/GattDescriptor1.cpp +78 -0
- data/vendor/simpleble/simplebluez/src/interfaces/GattService1.cpp +28 -0
- data/vendor/simpleble/simplebluez/test/src/helpers/PythonRunner.cpp +53 -0
- data/vendor/simpleble/simplebluez/test/src/helpers/PythonRunner.h +24 -0
- data/vendor/simpleble/simplebluez/test/src/main.cpp +16 -0
- data/vendor/simpleble/simplecble/include/simplecble/adapter.h +188 -0
- data/vendor/simpleble/simplecble/include/simplecble/logging.h +37 -0
- data/vendor/simpleble/simplecble/include/simplecble/peripheral.h +304 -0
- data/vendor/simpleble/simplecble/include/simplecble/simpleble.h +21 -0
- data/vendor/simpleble/simplecble/include/simplecble/types.h +73 -0
- data/vendor/simpleble/simplecble/include/simplecble/utils.h +27 -0
- data/vendor/simpleble/simplecble/src/adapter.cpp +204 -0
- data/vendor/simpleble/simplecble/src/logging.cpp +19 -0
- data/vendor/simpleble/simplecble/src/peripheral.cpp +444 -0
- data/vendor/simpleble/simplecble/src/simpleble.cpp +5 -0
- data/vendor/simpleble/simplecble/src/utils.cpp +15 -0
- data/vendor/simpleble/simpledbus/include/simpledbus/advanced/Interface.h +67 -0
- data/vendor/simpleble/simpledbus/include/simpledbus/advanced/InterfaceRegistry.h +64 -0
- data/vendor/simpleble/simpledbus/include/simpledbus/advanced/Proxy.h +117 -0
- data/vendor/simpleble/simpledbus/include/simpledbus/base/Connection.h +50 -0
- data/vendor/simpleble/simpledbus/include/simpledbus/base/Exceptions.h +56 -0
- data/vendor/simpleble/simpledbus/include/simpledbus/base/Holder.h +147 -0
- data/vendor/simpleble/simpledbus/include/simpledbus/base/Logging.h +57 -0
- data/vendor/simpleble/simpledbus/include/simpledbus/base/Message.h +89 -0
- data/vendor/simpleble/simpledbus/include/simpledbus/base/Path.h +24 -0
- data/vendor/simpleble/simpledbus/include/simpledbus/interfaces/ObjectManager.h +26 -0
- data/vendor/simpleble/simpledbus/src/advanced/Interface.cpp +155 -0
- data/vendor/simpleble/simpledbus/src/advanced/Proxy.cpp +375 -0
- data/vendor/simpleble/simpledbus/src/base/Connection.cpp +222 -0
- data/vendor/simpleble/simpledbus/src/base/Exceptions.cpp +39 -0
- data/vendor/simpleble/simpledbus/src/base/Holder.cpp +739 -0
- data/vendor/simpleble/simpledbus/src/base/Logging.cpp +52 -0
- data/vendor/simpleble/simpledbus/src/base/Message.cpp +622 -0
- data/vendor/simpleble/simpledbus/src/base/Path.cpp +129 -0
- data/vendor/simpleble/simpledbus/src/interfaces/ObjectManager.cpp +58 -0
- data/vendor/simpleble/simpledbus/test/src/helpers/PythonRunner.cpp +53 -0
- data/vendor/simpleble/simpledbus/test/src/helpers/PythonRunner.h +24 -0
- data/vendor/simpleble/simpledbus/test/src/main.cpp +16 -0
- data/vendor/simpleble/simpledbus/test/src/test_holder.cpp +184 -0
- data/vendor/simpleble/simpledbus/test/src/test_message.cpp +397 -0
- data/vendor/simpleble/simpledbus/test/src/test_path.cpp +76 -0
- data/vendor/simpleble/simpledbus/test/src/test_proxy_children.cpp +109 -0
- data/vendor/simpleble/simpledbus/test/src/test_proxy_interfaces.cpp +102 -0
- data/vendor/simpleble/simpledbus/test/src/test_proxy_lifetime.cpp +18 -0
- data/vendor/simpleble/simpledroidble/simpledroidble/src/main/cpp/ThreadRunner.h +89 -0
- data/vendor/simpleble/simpledroidble/simpledroidble/src/main/cpp/android_utils.cpp +55 -0
- data/vendor/simpleble/simpledroidble/simpledroidble/src/main/cpp/android_utils.h +18 -0
- data/vendor/simpleble/simpledroidble/simpledroidble/src/main/cpp/simpleble_android.cpp +813 -0
- data/vendor/simpleble/simplejavable/cpp/src/core/AdapterWrapper.cpp +37 -0
- data/vendor/simpleble/simplejavable/cpp/src/core/AdapterWrapper.h +23 -0
- data/vendor/simpleble/simplejavable/cpp/src/core/Cache.cpp +58 -0
- data/vendor/simpleble/simplejavable/cpp/src/core/Cache.h +34 -0
- data/vendor/simpleble/simplejavable/cpp/src/core/PeripheralWrapper.cpp +17 -0
- data/vendor/simpleble/simplejavable/cpp/src/core/PeripheralWrapper.h +19 -0
- data/vendor/simpleble/simplejavable/cpp/src/java/lang/ArrayList.cpp +257 -0
- data/vendor/simpleble/simplejavable/cpp/src/java/lang/ArrayList.h +78 -0
- data/vendor/simpleble/simplejavable/cpp/src/java/lang/HashMap.cpp +96 -0
- data/vendor/simpleble/simplejavable/cpp/src/java/lang/HashMap.h +54 -0
- data/vendor/simpleble/simplejavable/cpp/src/java/lang/Integer.cpp +93 -0
- data/vendor/simpleble/simplejavable/cpp/src/java/lang/Integer.h +49 -0
- data/vendor/simpleble/simplejavable/cpp/src/java/lang/Iterator.cpp +85 -0
- data/vendor/simpleble/simplejavable/cpp/src/java/lang/Iterator.h +48 -0
- data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/AdapterCallback.cpp +91 -0
- data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/AdapterCallback.h +90 -0
- data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/Characteristic.cpp +35 -0
- data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/Characteristic.h +60 -0
- data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/DataCallback.cpp +33 -0
- data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/DataCallback.h +45 -0
- data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/Descriptor.cpp +30 -0
- data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/Descriptor.h +49 -0
- data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/PeripheralCallback.cpp +41 -0
- data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/PeripheralCallback.h +51 -0
- data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/Service.cpp +33 -0
- data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/Service.h +54 -0
- data/vendor/simpleble/simplejavable/cpp/src/simplejavable.cpp +361 -0
- data/vendor/simpleble/simplepyble/src/main.cpp +55 -0
- data/vendor/simpleble/simplepyble/src/wrap_adapter.cpp +106 -0
- data/vendor/simpleble/simplepyble/src/wrap_characteristic.cpp +56 -0
- data/vendor/simpleble/simplepyble/src/wrap_config.cpp +136 -0
- data/vendor/simpleble/simplepyble/src/wrap_descriptor.cpp +21 -0
- data/vendor/simpleble/simplepyble/src/wrap_peripheral.cpp +217 -0
- data/vendor/simpleble/simplepyble/src/wrap_service.cpp +32 -0
- data/vendor/simpleble/simplepyble/src/wrap_types.cpp +21 -0
- data/vendor/simpleble/simplersble/src/bindings/Bindings.cpp +338 -0
- data/vendor/simpleble/simplersble/src/bindings/Bindings.hpp +178 -0
- metadata +430 -0
@@ -0,0 +1,82 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include <functional>
|
4
|
+
#include <map>
|
5
|
+
#include <memory>
|
6
|
+
#include <vector>
|
7
|
+
|
8
|
+
#include <simpleble/Types.h>
|
9
|
+
|
10
|
+
namespace SimpleBLE {
|
11
|
+
|
12
|
+
class ServiceBase;
|
13
|
+
|
14
|
+
/**
|
15
|
+
* Abstract base class for Bluetooth adapter implementations.
|
16
|
+
*
|
17
|
+
* Each backend must implement this class.
|
18
|
+
*
|
19
|
+
* Notes for implementers: ...
|
20
|
+
*/
|
21
|
+
class PeripheralBase {
|
22
|
+
public:
|
23
|
+
virtual ~PeripheralBase() = default;
|
24
|
+
|
25
|
+
virtual void* underlying() const = 0;
|
26
|
+
|
27
|
+
virtual std::string identifier() = 0;
|
28
|
+
virtual BluetoothAddress address() = 0;
|
29
|
+
virtual BluetoothAddressType address_type() = 0;
|
30
|
+
virtual int16_t rssi() = 0;
|
31
|
+
|
32
|
+
/**
|
33
|
+
* @brief Provides the advertised transmit power in dBm.
|
34
|
+
*
|
35
|
+
* @note If the field has not been advertised by the peripheral,
|
36
|
+
* the returned value will be -32768.
|
37
|
+
*/
|
38
|
+
virtual int16_t tx_power() = 0;
|
39
|
+
virtual uint16_t mtu() = 0;
|
40
|
+
|
41
|
+
virtual void connect() = 0;
|
42
|
+
virtual void disconnect() = 0;
|
43
|
+
virtual bool is_connected() = 0;
|
44
|
+
virtual bool is_connectable() = 0;
|
45
|
+
virtual bool is_paired() = 0;
|
46
|
+
virtual void unpair() = 0;
|
47
|
+
|
48
|
+
/**
|
49
|
+
* Available services (if the peripheral is connected).
|
50
|
+
*/
|
51
|
+
virtual std::vector<std::shared_ptr<ServiceBase>> available_services() = 0;
|
52
|
+
|
53
|
+
/**
|
54
|
+
* Advertised services (if the peripheral is not connected).
|
55
|
+
*/
|
56
|
+
virtual std::vector<std::shared_ptr<ServiceBase>> advertised_services() = 0;
|
57
|
+
|
58
|
+
virtual std::map<uint16_t, ByteArray> manufacturer_data() = 0;
|
59
|
+
|
60
|
+
// clang-format off
|
61
|
+
/* These methods are called by the frontend ONLY when the device is connected.
|
62
|
+
*/
|
63
|
+
// clang-format off
|
64
|
+
virtual ByteArray read(BluetoothUUID const& service, BluetoothUUID const& characteristic) = 0;
|
65
|
+
virtual void write_request(BluetoothUUID const& service, BluetoothUUID const& characteristic, ByteArray const& data) = 0;
|
66
|
+
virtual void write_command(BluetoothUUID const& service, BluetoothUUID const& characteristic, ByteArray const& data) = 0;
|
67
|
+
virtual void notify(BluetoothUUID const& service, BluetoothUUID const& characteristic, std::function<void(ByteArray payload)> callback) = 0;
|
68
|
+
virtual void indicate(BluetoothUUID const& service, BluetoothUUID const& characteristic, std::function<void(ByteArray payload)> callback) = 0;
|
69
|
+
virtual void unsubscribe(BluetoothUUID const& service, BluetoothUUID const& characteristic) = 0;
|
70
|
+
|
71
|
+
virtual ByteArray read(BluetoothUUID const& service, BluetoothUUID const& characteristic, BluetoothUUID const& descriptor) = 0;
|
72
|
+
virtual void write(BluetoothUUID const& service, BluetoothUUID const& characteristic, BluetoothUUID const& descriptor, ByteArray const& data) = 0;
|
73
|
+
// clang-format on
|
74
|
+
|
75
|
+
virtual void set_callback_on_connected(std::function<void()> on_connected) = 0;
|
76
|
+
virtual void set_callback_on_disconnected(std::function<void()> on_disconnected) = 0;
|
77
|
+
|
78
|
+
protected:
|
79
|
+
PeripheralBase() = default;
|
80
|
+
};
|
81
|
+
|
82
|
+
} // namespace SimpleBLE
|
@@ -0,0 +1,18 @@
|
|
1
|
+
|
2
|
+
#include "ServiceBase.h"
|
3
|
+
#include "CommonUtils.h"
|
4
|
+
|
5
|
+
using namespace SimpleBLE;
|
6
|
+
|
7
|
+
ServiceBase::ServiceBase(const BluetoothUUID& uuid) : uuid_(uuid) {}
|
8
|
+
|
9
|
+
ServiceBase::ServiceBase(const BluetoothUUID& uuid, const ByteArray& data) : uuid_(uuid), data_(data) {}
|
10
|
+
|
11
|
+
ServiceBase::ServiceBase(const BluetoothUUID& uuid, SharedPtrVector<CharacteristicBase>& characteristics)
|
12
|
+
: uuid_(uuid), characteristics_(characteristics) {}
|
13
|
+
|
14
|
+
BluetoothUUID ServiceBase::uuid() { return uuid_; }
|
15
|
+
|
16
|
+
ByteArray ServiceBase::data() { return data_; }
|
17
|
+
|
18
|
+
SharedPtrVector<CharacteristicBase> ServiceBase::characteristics() { return characteristics_; }
|
@@ -0,0 +1,28 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include <simpleble/Exceptions.h>
|
4
|
+
#include <simpleble/Types.h>
|
5
|
+
#include <memory>
|
6
|
+
|
7
|
+
namespace SimpleBLE {
|
8
|
+
|
9
|
+
class CharacteristicBase;
|
10
|
+
|
11
|
+
class ServiceBase {
|
12
|
+
public:
|
13
|
+
ServiceBase(const BluetoothUUID& uuid);
|
14
|
+
ServiceBase(const BluetoothUUID& uuid, const ByteArray& data);
|
15
|
+
ServiceBase(const BluetoothUUID& uuid, std::vector<std::shared_ptr<CharacteristicBase>>& characteristics);
|
16
|
+
virtual ~ServiceBase() = default;
|
17
|
+
|
18
|
+
BluetoothUUID uuid();
|
19
|
+
ByteArray data();
|
20
|
+
std::vector<std::shared_ptr<CharacteristicBase>> characteristics();
|
21
|
+
|
22
|
+
protected:
|
23
|
+
BluetoothUUID uuid_;
|
24
|
+
ByteArray data_;
|
25
|
+
std::vector<std::shared_ptr<CharacteristicBase>> characteristics_;
|
26
|
+
};
|
27
|
+
|
28
|
+
} // namespace SimpleBLE
|
@@ -0,0 +1,102 @@
|
|
1
|
+
#include <thread>
|
2
|
+
|
3
|
+
#include <simpleble/Peripheral.h>
|
4
|
+
|
5
|
+
#include "AdapterLinux.h"
|
6
|
+
#include "BuildVec.h"
|
7
|
+
#include "BuilderBase.h"
|
8
|
+
#include "CommonUtils.h"
|
9
|
+
#include "PeripheralLinux.h"
|
10
|
+
|
11
|
+
using namespace SimpleBLE;
|
12
|
+
|
13
|
+
bool AdapterLinux::bluetooth_enabled() { return adapter_->powered(); }
|
14
|
+
|
15
|
+
AdapterLinux::AdapterLinux(std::shared_ptr<SimpleBluez::Adapter> adapter) : adapter_(adapter) {}
|
16
|
+
|
17
|
+
AdapterLinux::~AdapterLinux() { adapter_->clear_on_device_updated(); }
|
18
|
+
|
19
|
+
void* AdapterLinux::underlying() const { return adapter_.get(); }
|
20
|
+
|
21
|
+
std::string AdapterLinux::identifier() { return adapter_->identifier(); }
|
22
|
+
|
23
|
+
BluetoothAddress AdapterLinux::address() { return adapter_->address(); }
|
24
|
+
|
25
|
+
void AdapterLinux::power_on() {
|
26
|
+
// TODO: This will be implemented after SimpleDBus and SimpleBluez are updated to the new architecture.
|
27
|
+
}
|
28
|
+
|
29
|
+
void AdapterLinux::power_off() {
|
30
|
+
// TODO: This will be implemented after SimpleDBus and SimpleBluez are updated to the new architecture.
|
31
|
+
}
|
32
|
+
|
33
|
+
bool AdapterLinux::is_powered() {
|
34
|
+
return adapter_->powered();
|
35
|
+
}
|
36
|
+
|
37
|
+
void AdapterLinux::scan_start() {
|
38
|
+
seen_peripherals_.clear();
|
39
|
+
|
40
|
+
adapter_->set_on_device_updated([this](std::shared_ptr<SimpleBluez::Device> device) {
|
41
|
+
if (!this->is_scanning_) {
|
42
|
+
return;
|
43
|
+
}
|
44
|
+
|
45
|
+
if (this->peripherals_.count(device->address()) == 0) {
|
46
|
+
// If the incoming peripheral has never been seen before, create and save a reference to it.
|
47
|
+
auto base_peripheral = std::make_shared<PeripheralLinux>(device, this->adapter_);
|
48
|
+
this->peripherals_.insert(std::make_pair(device->address(), base_peripheral));
|
49
|
+
}
|
50
|
+
|
51
|
+
// Update the received advertising data.
|
52
|
+
auto peripheral = this->peripherals_.at(device->address());
|
53
|
+
|
54
|
+
// Check if the device has been seen before, to forward the correct call to the user.
|
55
|
+
if (this->seen_peripherals_.count(device->address()) == 0) {
|
56
|
+
// Store it in our table of seen peripherals
|
57
|
+
this->seen_peripherals_.insert(std::make_pair(device->address(), peripheral));
|
58
|
+
SAFE_CALLBACK_CALL(this->_callback_on_scan_found, Factory::build(peripheral));
|
59
|
+
} else {
|
60
|
+
SAFE_CALLBACK_CALL(this->_callback_on_scan_updated, Factory::build(peripheral));
|
61
|
+
}
|
62
|
+
});
|
63
|
+
|
64
|
+
// Start scanning and notify the user.
|
65
|
+
adapter_->discovery_start();
|
66
|
+
|
67
|
+
// TODO: Does a discovery filter need to be set?
|
68
|
+
|
69
|
+
SAFE_CALLBACK_CALL(this->_callback_on_scan_start);
|
70
|
+
is_scanning_ = true;
|
71
|
+
}
|
72
|
+
|
73
|
+
void AdapterLinux::scan_stop() {
|
74
|
+
adapter_->discovery_stop();
|
75
|
+
is_scanning_ = false;
|
76
|
+
SAFE_CALLBACK_CALL(this->_callback_on_scan_stop);
|
77
|
+
|
78
|
+
// Important: Bluez might continue scanning if another process is also requesting
|
79
|
+
// scanning from the adapter. The use of the is_scanning_ flag is to prevent
|
80
|
+
// any scan updates to reach the user when not expected.
|
81
|
+
}
|
82
|
+
|
83
|
+
void AdapterLinux::scan_for(int timeout_ms) {
|
84
|
+
scan_start();
|
85
|
+
std::this_thread::sleep_for(std::chrono::milliseconds(timeout_ms));
|
86
|
+
scan_stop();
|
87
|
+
}
|
88
|
+
|
89
|
+
bool AdapterLinux::scan_is_active() { return is_scanning_ && adapter_->discovering(); }
|
90
|
+
|
91
|
+
SharedPtrVector<PeripheralBase> AdapterLinux::scan_get_results() { return Util::values(seen_peripherals_); }
|
92
|
+
|
93
|
+
SharedPtrVector<PeripheralBase> AdapterLinux::get_paired_peripherals() {
|
94
|
+
SharedPtrVector<PeripheralBase> peripherals;
|
95
|
+
|
96
|
+
auto paired_list = adapter_->device_paired_get();
|
97
|
+
for (auto& device : paired_list) {
|
98
|
+
peripherals.push_back(std::make_shared<PeripheralLinux>(device, this->adapter_));
|
99
|
+
}
|
100
|
+
|
101
|
+
return peripherals;
|
102
|
+
}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include <simpleble/Exceptions.h>
|
4
|
+
#include <simpleble/Types.h>
|
5
|
+
|
6
|
+
#include "../common/AdapterBase.h"
|
7
|
+
|
8
|
+
#include <kvn_safe_callback.hpp>
|
9
|
+
|
10
|
+
#include <simplebluez/Adapter.h>
|
11
|
+
|
12
|
+
#include <atomic>
|
13
|
+
#include <functional>
|
14
|
+
#include <memory>
|
15
|
+
#include <string>
|
16
|
+
#include <vector>
|
17
|
+
|
18
|
+
namespace SimpleBLE {
|
19
|
+
|
20
|
+
class PeripheralLinux;
|
21
|
+
|
22
|
+
class AdapterLinux : public SimpleBLE::AdapterBase {
|
23
|
+
public:
|
24
|
+
AdapterLinux(std::shared_ptr<SimpleBluez::Adapter> adapter);
|
25
|
+
virtual ~AdapterLinux();
|
26
|
+
|
27
|
+
void* underlying() const override;
|
28
|
+
|
29
|
+
virtual std::string identifier() override;
|
30
|
+
virtual BluetoothAddress address() override;
|
31
|
+
|
32
|
+
virtual void power_on() override;
|
33
|
+
virtual void power_off() override;
|
34
|
+
virtual bool is_powered() override;
|
35
|
+
|
36
|
+
virtual void scan_start() override;
|
37
|
+
virtual void scan_stop() override;
|
38
|
+
virtual void scan_for(int timeout_ms) override;
|
39
|
+
virtual bool scan_is_active() override;
|
40
|
+
virtual std::vector<std::shared_ptr<PeripheralBase>> scan_get_results() override;
|
41
|
+
|
42
|
+
virtual std::vector<std::shared_ptr<PeripheralBase>> get_paired_peripherals() override;
|
43
|
+
|
44
|
+
virtual bool bluetooth_enabled() override;
|
45
|
+
|
46
|
+
private:
|
47
|
+
std::shared_ptr<SimpleBluez::Adapter> adapter_;
|
48
|
+
|
49
|
+
std::atomic_bool is_scanning_;
|
50
|
+
|
51
|
+
std::map<BluetoothAddress, std::shared_ptr<PeripheralLinux>> peripherals_;
|
52
|
+
std::map<BluetoothAddress, std::shared_ptr<PeripheralLinux>> seen_peripherals_;
|
53
|
+
};
|
54
|
+
|
55
|
+
} // namespace SimpleBLE
|
@@ -0,0 +1,87 @@
|
|
1
|
+
#include "AdapterLinux.h"
|
2
|
+
#include "BackendBase.h"
|
3
|
+
#include "BackendUtils.h"
|
4
|
+
#include "CommonUtils.h"
|
5
|
+
|
6
|
+
#include <simplebluez/Bluez.h>
|
7
|
+
|
8
|
+
#include <atomic>
|
9
|
+
#include <memory>
|
10
|
+
#include <mutex>
|
11
|
+
#include <thread>
|
12
|
+
|
13
|
+
namespace SimpleBLE {
|
14
|
+
|
15
|
+
class BackendBluez : public BackendSingleton<BackendBluez> {
|
16
|
+
public:
|
17
|
+
BackendBluez(buildToken);
|
18
|
+
virtual ~BackendBluez();
|
19
|
+
|
20
|
+
SimpleBluez::Bluez bluez;
|
21
|
+
|
22
|
+
virtual SharedPtrVector<AdapterBase> get_adapters() override;
|
23
|
+
virtual bool bluetooth_enabled() override;
|
24
|
+
std::string name() const noexcept override;
|
25
|
+
|
26
|
+
private:
|
27
|
+
std::thread* async_thread;
|
28
|
+
std::atomic_bool async_thread_active;
|
29
|
+
void async_thread_function();
|
30
|
+
};
|
31
|
+
|
32
|
+
std::shared_ptr<BackendBase> BACKEND_LINUX() { return BackendBluez::get(); }
|
33
|
+
|
34
|
+
BackendBluez::BackendBluez(buildToken) {
|
35
|
+
static std::mutex get_mutex; // Static mutex to ensure thread safety when accessing the logger
|
36
|
+
std::scoped_lock lock(get_mutex); // Unlock the mutex on function return
|
37
|
+
|
38
|
+
bluez.init();
|
39
|
+
async_thread_active = true;
|
40
|
+
async_thread = new std::thread(&BackendBluez::async_thread_function, this);
|
41
|
+
}
|
42
|
+
|
43
|
+
BackendBluez::~BackendBluez() {
|
44
|
+
async_thread_active = false;
|
45
|
+
while (!async_thread->joinable()) {
|
46
|
+
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
47
|
+
}
|
48
|
+
async_thread->join();
|
49
|
+
delete async_thread;
|
50
|
+
}
|
51
|
+
|
52
|
+
SharedPtrVector<AdapterBase> BackendBluez::get_adapters() {
|
53
|
+
SharedPtrVector<AdapterBase> adapter_list;
|
54
|
+
|
55
|
+
auto internal_adapters = bluez.get_adapters();
|
56
|
+
for (auto& adapter : internal_adapters) {
|
57
|
+
adapter_list.push_back(std::make_shared<AdapterLinux>(adapter));
|
58
|
+
}
|
59
|
+
return adapter_list;
|
60
|
+
}
|
61
|
+
|
62
|
+
bool BackendBluez::bluetooth_enabled() {
|
63
|
+
bool enabled = false;
|
64
|
+
|
65
|
+
auto internal_adapters = bluez.get_adapters();
|
66
|
+
for (auto& adapter : internal_adapters) {
|
67
|
+
if (adapter->powered()) {
|
68
|
+
enabled = true;
|
69
|
+
break;
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
return enabled;
|
74
|
+
}
|
75
|
+
|
76
|
+
std::string BackendBluez::name() const noexcept { return "SimpleBluez"; }
|
77
|
+
|
78
|
+
void BackendBluez::async_thread_function() {
|
79
|
+
SAFE_RUN({ bluez.register_agent(); });
|
80
|
+
|
81
|
+
while (async_thread_active) {
|
82
|
+
SAFE_RUN({ bluez.run_async(); });
|
83
|
+
std::this_thread::sleep_for(std::chrono::microseconds(100));
|
84
|
+
}
|
85
|
+
}
|
86
|
+
|
87
|
+
} // namespace SimpleBLE
|