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,44 @@
|
|
1
|
+
#include <simplebluez/BluezRoot.h>
|
2
|
+
#include <simplebluez/BluezOrg.h>
|
3
|
+
#include <simpledbus/interfaces/ObjectManager.h>
|
4
|
+
|
5
|
+
using namespace SimpleBluez;
|
6
|
+
|
7
|
+
BluezRoot::BluezRoot(std::shared_ptr<SimpleDBus::Connection> conn, const std::string& bus_name, const std::string& path)
|
8
|
+
: Proxy(conn, bus_name, path) {
|
9
|
+
|
10
|
+
_interfaces.emplace(std::make_pair("org.freedesktop.DBus.ObjectManager", std::make_shared<SimpleDBus::ObjectManager>(conn, _bus_name, _path)));
|
11
|
+
|
12
|
+
object_manager()->InterfacesAdded = [&](std::string path, SimpleDBus::Holder options) { path_add(path, options); };
|
13
|
+
object_manager()->InterfacesRemoved = [&](std::string path, SimpleDBus::Holder options) {
|
14
|
+
path_remove(path, options);
|
15
|
+
};
|
16
|
+
|
17
|
+
// Create the agent that will handle pairing.
|
18
|
+
_agent = std::make_shared<Agent>(_conn, "org.bluez", "/agent");
|
19
|
+
path_append_child("/agent", std::static_pointer_cast<SimpleDBus::Proxy>(_agent));
|
20
|
+
}
|
21
|
+
|
22
|
+
void BluezRoot::load_managed_objects() {
|
23
|
+
SimpleDBus::Holder managed_objects = object_manager()->GetManagedObjects();
|
24
|
+
for (auto& [path, managed_interfaces] : managed_objects.get_dict_object_path()) {
|
25
|
+
path_add(path, managed_interfaces);
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
std::vector<std::shared_ptr<Adapter>> BluezRoot::get_adapters() {
|
30
|
+
return std::dynamic_pointer_cast<BluezOrg>(path_get("/org"))->get_adapters();
|
31
|
+
}
|
32
|
+
|
33
|
+
std::shared_ptr<Agent> BluezRoot::get_agent() { return std::dynamic_pointer_cast<Agent>(path_get("/agent")); }
|
34
|
+
|
35
|
+
void BluezRoot::register_agent() { std::dynamic_pointer_cast<BluezOrg>(path_get("/org"))->register_agent(_agent); }
|
36
|
+
|
37
|
+
std::shared_ptr<SimpleDBus::Proxy> BluezRoot::path_create(const std::string& path) {
|
38
|
+
auto child = std::make_shared<BluezOrg>(_conn, _bus_name, path);
|
39
|
+
return std::static_pointer_cast<SimpleDBus::Proxy>(child);
|
40
|
+
}
|
41
|
+
|
42
|
+
std::shared_ptr<SimpleDBus::ObjectManager> BluezRoot::object_manager() {
|
43
|
+
return std::dynamic_pointer_cast<SimpleDBus::ObjectManager>(interface_get("org.freedesktop.DBus.ObjectManager"));
|
44
|
+
}
|
@@ -0,0 +1,64 @@
|
|
1
|
+
#include <simplebluez/Characteristic.h>
|
2
|
+
#include <simplebluez/Descriptor.h>
|
3
|
+
#include <simplebluez/Exceptions.h>
|
4
|
+
|
5
|
+
using namespace SimpleBluez;
|
6
|
+
|
7
|
+
Characteristic::Characteristic(std::shared_ptr<SimpleDBus::Connection> conn, const std::string& bus_name,
|
8
|
+
const std::string& path)
|
9
|
+
: Proxy(conn, bus_name, path) {}
|
10
|
+
|
11
|
+
Characteristic::~Characteristic() {}
|
12
|
+
|
13
|
+
std::shared_ptr<SimpleDBus::Proxy> Characteristic::path_create(const std::string& path) {
|
14
|
+
auto child = std::make_shared<Descriptor>(_conn, _bus_name, path);
|
15
|
+
return std::static_pointer_cast<SimpleDBus::Proxy>(child);
|
16
|
+
}
|
17
|
+
|
18
|
+
std::vector<std::shared_ptr<Descriptor>> Characteristic::descriptors() { return children_casted<Descriptor>(); }
|
19
|
+
|
20
|
+
std::shared_ptr<GattCharacteristic1> Characteristic::gattcharacteristic1() {
|
21
|
+
return std::dynamic_pointer_cast<GattCharacteristic1>(interface_get("org.bluez.GattCharacteristic1"));
|
22
|
+
}
|
23
|
+
|
24
|
+
bool Characteristic::notifying() { return gattcharacteristic1()->Notifying(); }
|
25
|
+
|
26
|
+
std::string Characteristic::uuid() { return gattcharacteristic1()->UUID(); }
|
27
|
+
|
28
|
+
ByteArray Characteristic::value() { return gattcharacteristic1()->Value(); }
|
29
|
+
|
30
|
+
std::vector<std::string> Characteristic::flags() { return gattcharacteristic1()->Flags(); }
|
31
|
+
|
32
|
+
uint16_t Characteristic::mtu() { return gattcharacteristic1()->MTU(); }
|
33
|
+
|
34
|
+
ByteArray Characteristic::read() { return gattcharacteristic1()->ReadValue(); }
|
35
|
+
|
36
|
+
void Characteristic::write_request(ByteArray value) {
|
37
|
+
gattcharacteristic1()->WriteValue(value, GattCharacteristic1::WriteType::REQUEST);
|
38
|
+
}
|
39
|
+
|
40
|
+
void Characteristic::write_command(ByteArray value) {
|
41
|
+
gattcharacteristic1()->WriteValue(value, GattCharacteristic1::WriteType::COMMAND);
|
42
|
+
}
|
43
|
+
|
44
|
+
void Characteristic::start_notify() { gattcharacteristic1()->StartNotify(); }
|
45
|
+
|
46
|
+
void Characteristic::stop_notify() { gattcharacteristic1()->StopNotify(); }
|
47
|
+
|
48
|
+
std::shared_ptr<Descriptor> Characteristic::get_descriptor(const std::string& uuid) {
|
49
|
+
auto descriptors_all = descriptors();
|
50
|
+
|
51
|
+
for (auto& descriptor : descriptors_all) {
|
52
|
+
if (descriptor->uuid() == uuid) {
|
53
|
+
return descriptor;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
throw Exception::DescriptorNotFoundException(uuid);
|
58
|
+
}
|
59
|
+
|
60
|
+
void Characteristic::set_on_value_changed(std::function<void(ByteArray new_value)> callback) {
|
61
|
+
gattcharacteristic1()->OnValueChanged.load([this, callback]() { callback(gattcharacteristic1()->Value()); });
|
62
|
+
}
|
63
|
+
|
64
|
+
void Characteristic::clear_on_value_changed() { gattcharacteristic1()->OnValueChanged.unload(); }
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#include <simplebluez/Descriptor.h>
|
2
|
+
|
3
|
+
using namespace SimpleBluez;
|
4
|
+
|
5
|
+
Descriptor::Descriptor(std::shared_ptr<SimpleDBus::Connection> conn, const std::string& bus_name,
|
6
|
+
const std::string& path)
|
7
|
+
: Proxy(conn, bus_name, path) {}
|
8
|
+
|
9
|
+
Descriptor::~Descriptor() {}
|
10
|
+
|
11
|
+
std::shared_ptr<GattDescriptor1> Descriptor::gattdescriptor1() {
|
12
|
+
return std::dynamic_pointer_cast<GattDescriptor1>(interface_get("org.bluez.GattDescriptor1"));
|
13
|
+
}
|
14
|
+
|
15
|
+
std::string Descriptor::uuid() { return gattdescriptor1()->UUID(); }
|
16
|
+
|
17
|
+
ByteArray Descriptor::value() { return gattdescriptor1()->Value(); }
|
18
|
+
|
19
|
+
ByteArray Descriptor::read() { return gattdescriptor1()->ReadValue(); }
|
20
|
+
|
21
|
+
void Descriptor::write(ByteArray value) { gattdescriptor1()->WriteValue(value); }
|
22
|
+
|
23
|
+
void Descriptor::set_on_value_changed(std::function<void(ByteArray new_value)> callback) {
|
24
|
+
gattdescriptor1()->OnValueChanged.load([this, callback]() { callback(gattdescriptor1()->Value()); });
|
25
|
+
}
|
26
|
+
|
27
|
+
void Descriptor::clear_on_value_changed() { gattdescriptor1()->OnValueChanged.unload(); }
|
@@ -0,0 +1,104 @@
|
|
1
|
+
#include <simplebluez/Device.h>
|
2
|
+
#include <simplebluez/Exceptions.h>
|
3
|
+
#include <simplebluez/Service.h>
|
4
|
+
|
5
|
+
#include <simpledbus/base/Path.h>
|
6
|
+
|
7
|
+
using namespace SimpleBluez;
|
8
|
+
|
9
|
+
Device::Device(std::shared_ptr<SimpleDBus::Connection> conn, const std::string& bus_name, const std::string& path)
|
10
|
+
: Proxy(conn, bus_name, path) {}
|
11
|
+
|
12
|
+
Device::~Device() {}
|
13
|
+
|
14
|
+
std::shared_ptr<SimpleDBus::Proxy> Device::path_create(const std::string& path) {
|
15
|
+
const std::string next_child = SimpleDBus::Path::next_child_strip(_path, path);
|
16
|
+
|
17
|
+
if (next_child.find("service") == 0) {
|
18
|
+
auto child = std::make_shared<Service>(_conn, _bus_name, path);
|
19
|
+
return std::static_pointer_cast<SimpleDBus::Proxy>(child);
|
20
|
+
} else {
|
21
|
+
return std::make_shared<Proxy>(_conn, _bus_name, path);
|
22
|
+
}
|
23
|
+
}
|
24
|
+
|
25
|
+
std::shared_ptr<Device1> Device::device1() {
|
26
|
+
return std::dynamic_pointer_cast<Device1>(interface_get("org.bluez.Device1"));
|
27
|
+
}
|
28
|
+
|
29
|
+
std::shared_ptr<Battery1> Device::battery1() {
|
30
|
+
return std::dynamic_pointer_cast<Battery1>(interface_get("org.bluez.Battery1"));
|
31
|
+
}
|
32
|
+
|
33
|
+
std::vector<std::shared_ptr<Service>> Device::services() { return children_casted_with_prefix<Service>("service"); }
|
34
|
+
|
35
|
+
std::shared_ptr<Service> Device::get_service(const std::string& uuid) {
|
36
|
+
auto services_all = services();
|
37
|
+
|
38
|
+
for (auto& service : services_all) {
|
39
|
+
if (service->uuid() == uuid) {
|
40
|
+
return service;
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
throw Exception::ServiceNotFoundException(uuid);
|
45
|
+
}
|
46
|
+
|
47
|
+
std::shared_ptr<Characteristic> Device::get_characteristic(const std::string& service_uuid,
|
48
|
+
const std::string& characteristic_uuid) {
|
49
|
+
auto service = get_service(service_uuid);
|
50
|
+
return service->get_characteristic(characteristic_uuid);
|
51
|
+
}
|
52
|
+
|
53
|
+
void Device::pair() { device1()->Pair(); }
|
54
|
+
|
55
|
+
void Device::cancel_pairing() { device1()->CancelPairing(); }
|
56
|
+
|
57
|
+
void Device::connect() { device1()->Connect(); }
|
58
|
+
|
59
|
+
void Device::disconnect() { device1()->Disconnect(); }
|
60
|
+
|
61
|
+
std::string Device::address() { return device1()->Address(); }
|
62
|
+
|
63
|
+
std::string Device::address_type() { return device1()->AddressType(); }
|
64
|
+
|
65
|
+
std::string Device::name() { return device1()->Name(); }
|
66
|
+
|
67
|
+
std::string Device::alias() { return device1()->Alias(); }
|
68
|
+
|
69
|
+
int16_t Device::rssi() { return device1()->RSSI(); }
|
70
|
+
|
71
|
+
int16_t Device::tx_power() { return device1()->TxPower(); }
|
72
|
+
|
73
|
+
std::vector<std::string> Device::uuids() { return device1()->UUIDs(); }
|
74
|
+
|
75
|
+
std::map<uint16_t, ByteArray> Device::manufacturer_data() { return device1()->ManufacturerData(); }
|
76
|
+
|
77
|
+
std::map<std::string, ByteArray> Device::service_data() { return device1()->ServiceData(); }
|
78
|
+
|
79
|
+
bool Device::paired() { return device1()->Paired(); }
|
80
|
+
|
81
|
+
bool Device::connected() { return device1()->Connected(); }
|
82
|
+
|
83
|
+
bool Device::services_resolved() { return device1()->ServicesResolved(); }
|
84
|
+
|
85
|
+
void Device::set_on_disconnected(std::function<void()> callback) { device1()->OnDisconnected.load(callback); }
|
86
|
+
|
87
|
+
void Device::clear_on_disconnected() { device1()->OnDisconnected.unload(); }
|
88
|
+
|
89
|
+
void Device::set_on_services_resolved(std::function<void()> callback) { device1()->OnServicesResolved.load(callback); }
|
90
|
+
|
91
|
+
void Device::clear_on_services_resolved() { device1()->OnServicesResolved.unload(); }
|
92
|
+
|
93
|
+
bool Device::has_battery_interface() { return interface_exists("org.bluez.Battery1"); }
|
94
|
+
|
95
|
+
uint8_t Device::battery_percentage() { return battery1()->Percentage(); }
|
96
|
+
|
97
|
+
void Device::set_on_battery_percentage_changed(std::function<void(uint8_t new_value)> callback) {
|
98
|
+
battery1()->OnPercentageChanged.load([this, callback]() { callback(battery1()->Percentage()); });
|
99
|
+
// As the `property_changed` callback only occurs when the property is changed, we need to manually
|
100
|
+
// call the callback once to make sure the callback is called with the current value.
|
101
|
+
battery1()->OnPercentageChanged();
|
102
|
+
}
|
103
|
+
|
104
|
+
void Device::clear_on_battery_percentage_changed() { battery1()->OnPercentageChanged.unload(); }
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#include <simplebluez/Exceptions.h>
|
2
|
+
|
3
|
+
#include <fmt/core.h>
|
4
|
+
|
5
|
+
namespace SimpleBluez {
|
6
|
+
|
7
|
+
namespace Exception {
|
8
|
+
|
9
|
+
ServiceNotFoundException::ServiceNotFoundException(const std::string& service) {
|
10
|
+
_message = fmt::format("Service {} not found.", service);
|
11
|
+
}
|
12
|
+
|
13
|
+
const char* ServiceNotFoundException::what() const noexcept { return _message.c_str(); }
|
14
|
+
|
15
|
+
CharacteristicNotFoundException::CharacteristicNotFoundException(const std::string& characteristic) {
|
16
|
+
_message = fmt::format("Characteristic {} not found.", characteristic);
|
17
|
+
}
|
18
|
+
|
19
|
+
const char* CharacteristicNotFoundException::what() const noexcept { return _message.c_str(); }
|
20
|
+
|
21
|
+
DescriptorNotFoundException::DescriptorNotFoundException(const std::string& descriptor) {
|
22
|
+
_message = fmt::format("Descriptor {} not found.", descriptor);
|
23
|
+
}
|
24
|
+
|
25
|
+
const char* DescriptorNotFoundException::what() const noexcept { return _message.c_str(); }
|
26
|
+
|
27
|
+
} // namespace Exception
|
28
|
+
|
29
|
+
} // namespace SimpleBluez
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#include "Logging.h"
|
2
|
+
#include "kvn/logfwd.hpp"
|
3
|
+
|
4
|
+
#ifndef SIMPLEBLUEZ_LOG_LEVEL
|
5
|
+
#warning "SIMPLEBLUEZ_LOG_LEVEL not defined, using default value: FATAL"
|
6
|
+
#define SIMPLEBLUEZ_LOG_LEVEL FATAL
|
7
|
+
#endif
|
8
|
+
|
9
|
+
static const logfwd::level log_level = logfwd::level::SIMPLEBLUEZ_LOG_LEVEL;
|
10
|
+
|
11
|
+
namespace SimpleBluez {
|
12
|
+
|
13
|
+
void log_fatal(const std::string& file, uint32_t line, const std::string& function, const std::string& message) {
|
14
|
+
if (log_level >= logfwd::level::FATAL) {
|
15
|
+
logfwd::receive(logfwd::level::FATAL, "SimpleBluez", file, line, function, message);
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
19
|
+
void log_error(const std::string& file, uint32_t line, const std::string& function, const std::string& message) {
|
20
|
+
if (log_level >= logfwd::level::ERROR) {
|
21
|
+
logfwd::receive(logfwd::level::ERROR, "SimpleBluez", file, line, function, message);
|
22
|
+
}
|
23
|
+
}
|
24
|
+
|
25
|
+
void log_warn(const std::string& file, uint32_t line, const std::string& function, const std::string& message) {
|
26
|
+
if (log_level >= logfwd::level::WARN) {
|
27
|
+
logfwd::receive(logfwd::level::WARN, "SimpleBluez", file, line, function, message);
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
void log_info(const std::string& file, uint32_t line, const std::string& function, const std::string& message) {
|
32
|
+
if (log_level >= logfwd::level::INFO) {
|
33
|
+
logfwd::receive(logfwd::level::INFO, "SimpleBluez", file, line, function, message);
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
void log_debug(const std::string& file, uint32_t line, const std::string& function, const std::string& message) {
|
38
|
+
if (log_level >= logfwd::level::DEBUG) {
|
39
|
+
logfwd::receive(logfwd::level::DEBUG, "SimpleBluez", file, line, function, message);
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
void log_verbose(const std::string& file, uint32_t line, const std::string& function, const std::string& message) {
|
44
|
+
if (log_level >= logfwd::level::VERBOSE) {
|
45
|
+
logfwd::receive(logfwd::level::VERBOSE, "SimpleBluez", file, line, function, message);
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
} // namespace SimpleBluez
|
50
|
+
|
51
|
+
__attribute__((weak)) void logfwd::receive(logfwd::level level, const std::string& module, const std::string& file,
|
52
|
+
uint32_t line, const std::string& function, const std::string& message) {}
|
@@ -0,0 +1,57 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include <fmt/core.h>
|
4
|
+
#include <cstdint>
|
5
|
+
#include <string>
|
6
|
+
|
7
|
+
namespace SimpleBluez {
|
8
|
+
|
9
|
+
// clang-format off
|
10
|
+
|
11
|
+
void log_fatal(const std::string& file, uint32_t line, const std::string& function, const std::string& message);
|
12
|
+
void log_error(const std::string& file, uint32_t line, const std::string& function, const std::string& message);
|
13
|
+
void log_warn(const std::string& file, uint32_t line, const std::string& function, const std::string& message);
|
14
|
+
void log_info(const std::string& file, uint32_t line, const std::string& function, const std::string& message);
|
15
|
+
void log_debug(const std::string& file, uint32_t line, const std::string& function, const std::string& message);
|
16
|
+
void log_verbose(const std::string& file, uint32_t line, const std::string& function, const std::string& message);
|
17
|
+
|
18
|
+
template <typename T, typename... Args>
|
19
|
+
void log_fatal(const std::string& file, uint32_t line, const std::string& function, const T& t, const Args&... args) {
|
20
|
+
log_fatal(file, line, function, fmt::format(t, args...));
|
21
|
+
}
|
22
|
+
|
23
|
+
template <typename T, typename... Args>
|
24
|
+
void log_error(const std::string& file, uint32_t line, const std::string& function, const T& t, const Args&... args) {
|
25
|
+
log_error(file, line, function, fmt::format(t, args...));
|
26
|
+
}
|
27
|
+
|
28
|
+
template <typename T, typename... Args>
|
29
|
+
void log_warn(const std::string& file, uint32_t line, const std::string& function, const T& t, const Args&... args) {
|
30
|
+
log_warn(file, line, function, fmt::format(t, args...));
|
31
|
+
}
|
32
|
+
|
33
|
+
template <typename T, typename... Args>
|
34
|
+
void log_info(const std::string& file, uint32_t line, const std::string& function, const T& t, const Args&... args) {
|
35
|
+
log_info(file, line, function, fmt::format(t, args...));
|
36
|
+
}
|
37
|
+
|
38
|
+
template <typename T, typename... Args>
|
39
|
+
void log_debug(const std::string& file, uint32_t line, const std::string& function, const T& t, const Args&... args) {
|
40
|
+
log_debug(file, line, function, fmt::format(t, args...));
|
41
|
+
}
|
42
|
+
|
43
|
+
template <typename T, typename... Args>
|
44
|
+
void log_verbose(const std::string& file, uint32_t line, const std::string& function, const T& t, const Args&... args) {
|
45
|
+
log_verbose(file, line, function, fmt::format(t, args...));
|
46
|
+
}
|
47
|
+
|
48
|
+
// clang-format on
|
49
|
+
|
50
|
+
} // namespace SimpleBluez
|
51
|
+
|
52
|
+
#define LOG_FATAL(...) SimpleBluez::log_fatal(__FILE__, __LINE__, __PRETTY_FUNCTION__, __VA_ARGS__)
|
53
|
+
#define LOG_ERROR(...) SimpleBluez::log_error(__FILE__, __LINE__, __PRETTY_FUNCTION__, __VA_ARGS__)
|
54
|
+
#define LOG_WARN(...) SimpleBluez::log_warn(__FILE__, __LINE__, __PRETTY_FUNCTION__, __VA_ARGS__)
|
55
|
+
#define LOG_INFO(...) SimpleBluez::log_info(__FILE__, __LINE__, __PRETTY_FUNCTION__, __VA_ARGS__)
|
56
|
+
#define LOG_DEBUG(...) SimpleBluez::log_debug(__FILE__, __LINE__, __PRETTY_FUNCTION__, __VA_ARGS__)
|
57
|
+
#define LOG_VERBOSE(...) SimpleBluez::log_verbose(__FILE__, __LINE__, __PRETTY_FUNCTION__, __VA_ARGS__)
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#include <simplebluez/Characteristic.h>
|
2
|
+
#include <simplebluez/Exceptions.h>
|
3
|
+
#include <simplebluez/Service.h>
|
4
|
+
|
5
|
+
using namespace SimpleBluez;
|
6
|
+
|
7
|
+
Service::Service(std::shared_ptr<SimpleDBus::Connection> conn, const std::string& bus_name, const std::string& path)
|
8
|
+
: Proxy(conn, bus_name, path) {}
|
9
|
+
|
10
|
+
std::shared_ptr<SimpleDBus::Proxy> Service::path_create(const std::string& path) {
|
11
|
+
auto child = std::make_shared<Characteristic>(_conn, _bus_name, path);
|
12
|
+
return std::static_pointer_cast<SimpleDBus::Proxy>(child);
|
13
|
+
}
|
14
|
+
|
15
|
+
std::shared_ptr<GattService1> Service::gattservice1() {
|
16
|
+
return std::dynamic_pointer_cast<GattService1>(interface_get("org.bluez.GattService1"));
|
17
|
+
}
|
18
|
+
|
19
|
+
std::vector<std::shared_ptr<Characteristic>> Service::characteristics() { return children_casted<Characteristic>(); }
|
20
|
+
|
21
|
+
std::shared_ptr<Characteristic> Service::get_characteristic(const std::string& uuid) {
|
22
|
+
auto characteristics_all = characteristics();
|
23
|
+
|
24
|
+
for (auto& characteristic : characteristics_all) {
|
25
|
+
if (characteristic->uuid() == uuid) {
|
26
|
+
return characteristic;
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
throw Exception::CharacteristicNotFoundException(uuid);
|
31
|
+
}
|
32
|
+
|
33
|
+
std::string Service::uuid() { return gattservice1()->UUID(); }
|
@@ -0,0 +1,123 @@
|
|
1
|
+
#include "simplebluez/interfaces/Adapter1.h"
|
2
|
+
|
3
|
+
using namespace SimpleBluez;
|
4
|
+
|
5
|
+
const SimpleDBus::AutoRegisterInterface<Adapter1> Adapter1::registry{
|
6
|
+
"org.bluez.Adapter1",
|
7
|
+
// clang-format off
|
8
|
+
[](std::shared_ptr<SimpleDBus::Connection> conn, const std::string& bus_name, const std::string& path, const SimpleDBus::Holder& options) -> std::shared_ptr<SimpleDBus::Interface> {
|
9
|
+
return std::static_pointer_cast<SimpleDBus::Interface>(std::make_shared<Adapter1>(conn, path));
|
10
|
+
}
|
11
|
+
// clang-format on
|
12
|
+
};
|
13
|
+
|
14
|
+
Adapter1::Adapter1(std::shared_ptr<SimpleDBus::Connection> conn, std::string path)
|
15
|
+
: SimpleDBus::Interface(conn, "org.bluez", path, "org.bluez.Adapter1") {}
|
16
|
+
|
17
|
+
void Adapter1::StartDiscovery() {
|
18
|
+
auto msg = create_method_call("StartDiscovery");
|
19
|
+
_conn->send_with_reply_and_block(msg);
|
20
|
+
}
|
21
|
+
|
22
|
+
void Adapter1::StopDiscovery() {
|
23
|
+
auto msg = create_method_call("StopDiscovery");
|
24
|
+
_conn->send_with_reply_and_block(msg);
|
25
|
+
// NOTE: It might take a few seconds until the peripheral reports that is has actually stopped discovering.
|
26
|
+
}
|
27
|
+
|
28
|
+
SimpleDBus::Holder Adapter1::GetDiscoveryFilters() {
|
29
|
+
auto msg = create_method_call("GetDiscoveryFilters");
|
30
|
+
SimpleDBus::Message reply_msg = _conn->send_with_reply_and_block(msg);
|
31
|
+
SimpleDBus::Holder discovery_filters = reply_msg.extract();
|
32
|
+
return discovery_filters;
|
33
|
+
}
|
34
|
+
|
35
|
+
void Adapter1::SetDiscoveryFilter(DiscoveryFilter filter) {
|
36
|
+
SimpleDBus::Holder properties = SimpleDBus::Holder::create_dict();
|
37
|
+
|
38
|
+
if (filter.UUIDs.size() > 0) {
|
39
|
+
SimpleDBus::Holder uuids = SimpleDBus::Holder::create_array();
|
40
|
+
for (size_t i = 0; i < filter.UUIDs.size(); i++) {
|
41
|
+
uuids.array_append(SimpleDBus::Holder::create_string(filter.UUIDs.at(i)));
|
42
|
+
}
|
43
|
+
properties.dict_append(SimpleDBus::Holder::Type::ARRAY, "UUIDs", uuids);
|
44
|
+
}
|
45
|
+
|
46
|
+
if (filter.RSSI.has_value()) {
|
47
|
+
properties.dict_append(SimpleDBus::Holder::Type::INT16, "RSSI",
|
48
|
+
SimpleDBus::Holder::create_int16(filter.RSSI.value()));
|
49
|
+
}
|
50
|
+
|
51
|
+
if (filter.Pathloss.has_value()) {
|
52
|
+
properties.dict_append(SimpleDBus::Holder::Type::UINT16, "Pathloss",
|
53
|
+
SimpleDBus::Holder::create_uint16(filter.Pathloss.value()));
|
54
|
+
}
|
55
|
+
|
56
|
+
switch (filter.Transport) {
|
57
|
+
case DiscoveryFilter::TransportType::AUTO: {
|
58
|
+
properties.dict_append(SimpleDBus::Holder::Type::STRING, "Transport",
|
59
|
+
SimpleDBus::Holder::create_string("auto"));
|
60
|
+
break;
|
61
|
+
}
|
62
|
+
case DiscoveryFilter::TransportType::BREDR: {
|
63
|
+
properties.dict_append(SimpleDBus::Holder::Type::STRING, "Transport",
|
64
|
+
SimpleDBus::Holder::create_string("bredr"));
|
65
|
+
break;
|
66
|
+
}
|
67
|
+
case DiscoveryFilter::TransportType::LE: {
|
68
|
+
properties.dict_append(SimpleDBus::Holder::Type::STRING, "Transport",
|
69
|
+
SimpleDBus::Holder::create_string("le"));
|
70
|
+
break;
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
if (!filter.DuplicateData) {
|
75
|
+
properties.dict_append(SimpleDBus::Holder::Type::BOOLEAN, "DuplicateData",
|
76
|
+
SimpleDBus::Holder::create_boolean(false));
|
77
|
+
}
|
78
|
+
|
79
|
+
if (filter.Discoverable) {
|
80
|
+
properties.dict_append(SimpleDBus::Holder::Type::BOOLEAN, "Discoverable",
|
81
|
+
SimpleDBus::Holder::create_boolean(false));
|
82
|
+
}
|
83
|
+
|
84
|
+
if (filter.Pattern.size() > 0) {
|
85
|
+
properties.dict_append(SimpleDBus::Holder::Type::STRING, "Pattern",
|
86
|
+
SimpleDBus::Holder::create_string(filter.Pattern));
|
87
|
+
}
|
88
|
+
|
89
|
+
auto msg = create_method_call("SetDiscoveryFilter");
|
90
|
+
msg.append_argument(properties, "a{sv}");
|
91
|
+
_conn->send_with_reply_and_block(msg);
|
92
|
+
}
|
93
|
+
|
94
|
+
void Adapter1::RemoveDevice(std::string device_path) {
|
95
|
+
auto msg = create_method_call("RemoveDevice");
|
96
|
+
msg.append_argument(SimpleDBus::Holder::create_object_path(device_path), "o");
|
97
|
+
_conn->send_with_reply_and_block(msg);
|
98
|
+
}
|
99
|
+
|
100
|
+
bool Adapter1::Discovering(bool refresh) {
|
101
|
+
if (refresh) {
|
102
|
+
property_refresh("Discovering");
|
103
|
+
}
|
104
|
+
|
105
|
+
std::scoped_lock lock(_property_update_mutex);
|
106
|
+
return _properties["Discovering"].get_boolean();
|
107
|
+
}
|
108
|
+
|
109
|
+
bool Adapter1::Powered(bool refresh) {
|
110
|
+
if (refresh) {
|
111
|
+
property_refresh("Powered");
|
112
|
+
}
|
113
|
+
|
114
|
+
std::scoped_lock lock(_property_update_mutex);
|
115
|
+
return _properties["Powered"].get_boolean();
|
116
|
+
}
|
117
|
+
|
118
|
+
std::string Adapter1::Address() {
|
119
|
+
std::scoped_lock lock(_property_update_mutex);
|
120
|
+
return _properties["Address"].get_string();
|
121
|
+
}
|
122
|
+
|
123
|
+
void Adapter1::property_changed(std::string option_name) {}
|