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,338 @@
|
|
1
|
+
#include "Bindings.hpp"
|
2
|
+
#include <exception>
|
3
|
+
|
4
|
+
#include "simplersble/simplersble/src/lib.rs.h"
|
5
|
+
|
6
|
+
rust::Vec<Bindings::RustyAdapterWrapper> Bindings::RustyAdapter_get_adapters() {
|
7
|
+
rust::Vec<Bindings::RustyAdapterWrapper> result;
|
8
|
+
|
9
|
+
for (auto& adapter : SimpleBLE::Adapter::get_adapters()) {
|
10
|
+
Bindings::RustyAdapterWrapper wrapper;
|
11
|
+
wrapper.internal = std::make_unique<Bindings::RustyAdapter>(adapter);
|
12
|
+
result.push_back(std::move(wrapper));
|
13
|
+
}
|
14
|
+
|
15
|
+
return result;
|
16
|
+
}
|
17
|
+
|
18
|
+
bool Bindings::RustyAdapter_bluetooth_enabled() { return SimpleBLE::Adapter::bluetooth_enabled(); }
|
19
|
+
|
20
|
+
// InnerAdapter Bindings
|
21
|
+
|
22
|
+
void Bindings::RustyAdapter::link(SimpleRsBLE::InnerAdapter& target) const {
|
23
|
+
// Time to explain the weird shenanigan we're doing here:
|
24
|
+
// The TL;DR is that we're making the InnerAdapter(Rust) and the RustyAdapter(C++)
|
25
|
+
// point to each other in a safe way.
|
26
|
+
// To achieve this, the InnerAdapter(Rust) owns a RustyAdapter(C++) via a UniquePtr,
|
27
|
+
// which ensures that calls will always be made to a valid C++ object.
|
28
|
+
// We now give the RustyAdapter(C++) a pointer back to the InnerAdapter(Rust),
|
29
|
+
// so that callbacks can be forwarded back to the Rust domain.
|
30
|
+
// In order to ensure that the InnerAdapter(Rust) is always valid (given
|
31
|
+
// that Rust is keen on moving stuff around) the object is created as a
|
32
|
+
// Pin<Box<T>>
|
33
|
+
|
34
|
+
// `_adapter` is a pointer to a pointer, allowing us to manipulate the contents within const functions.
|
35
|
+
std::lock_guard<std::mutex> lock(_adapter_mutex);
|
36
|
+
_adapter = ⌖ // THIS LINE IS SUPER IMPORTANT
|
37
|
+
|
38
|
+
_internal->set_callback_on_scan_start([this]() {
|
39
|
+
if (this->_adapter == nullptr) return;
|
40
|
+
|
41
|
+
this->_adapter->on_callback_scan_start();
|
42
|
+
});
|
43
|
+
|
44
|
+
_internal->set_callback_on_scan_stop([this]() {
|
45
|
+
if (this->_adapter == nullptr) return;
|
46
|
+
|
47
|
+
this->_adapter->on_callback_scan_stop();
|
48
|
+
});
|
49
|
+
|
50
|
+
_internal->set_callback_on_scan_found([this](SimpleBLE::Peripheral peripheral) {
|
51
|
+
if (this->_adapter == nullptr) return;
|
52
|
+
|
53
|
+
Bindings::RustyPeripheralWrapper wrapper;
|
54
|
+
wrapper.internal = std::make_unique<Bindings::RustyPeripheral>(peripheral);
|
55
|
+
this->_adapter->on_callback_scan_found(wrapper);
|
56
|
+
});
|
57
|
+
|
58
|
+
_internal->set_callback_on_scan_updated([this](SimpleBLE::Peripheral peripheral) {
|
59
|
+
if (this->_adapter == nullptr) return;
|
60
|
+
|
61
|
+
Bindings::RustyPeripheralWrapper wrapper;
|
62
|
+
wrapper.internal = std::make_unique<Bindings::RustyPeripheral>(peripheral);
|
63
|
+
this->_adapter->on_callback_scan_updated(wrapper);
|
64
|
+
});
|
65
|
+
}
|
66
|
+
|
67
|
+
void Bindings::RustyAdapter::unlink() const {
|
68
|
+
// Clear all callbacks
|
69
|
+
_internal->set_callback_on_scan_start(nullptr);
|
70
|
+
_internal->set_callback_on_scan_stop(nullptr);
|
71
|
+
_internal->set_callback_on_scan_found(nullptr);
|
72
|
+
_internal->set_callback_on_scan_updated(nullptr);
|
73
|
+
|
74
|
+
// `_adapter` is a pointer to a pointer.
|
75
|
+
std::lock_guard<std::mutex> lock(_adapter_mutex);
|
76
|
+
_adapter = nullptr;
|
77
|
+
}
|
78
|
+
|
79
|
+
rust::String Bindings::RustyAdapter::identifier() const { return rust::String(_internal->identifier()); }
|
80
|
+
|
81
|
+
rust::String Bindings::RustyAdapter::address() const { return rust::String(_internal->address()); }
|
82
|
+
|
83
|
+
void Bindings::RustyAdapter::scan_start() const { _internal->scan_start(); }
|
84
|
+
|
85
|
+
void Bindings::RustyAdapter::scan_stop() const { _internal->scan_stop(); }
|
86
|
+
|
87
|
+
void Bindings::RustyAdapter::scan_for(int32_t timeout_ms) const { _internal->scan_for(timeout_ms); }
|
88
|
+
|
89
|
+
bool Bindings::RustyAdapter::scan_is_active() const { return _internal->scan_is_active(); }
|
90
|
+
|
91
|
+
rust::Vec<Bindings::RustyPeripheralWrapper> Bindings::RustyAdapter::scan_get_results() const {
|
92
|
+
rust::Vec<Bindings::RustyPeripheralWrapper> result;
|
93
|
+
|
94
|
+
for (auto& peripheral : _internal->scan_get_results()) {
|
95
|
+
Bindings::RustyPeripheralWrapper wrapper;
|
96
|
+
wrapper.internal = std::make_unique<Bindings::RustyPeripheral>(peripheral);
|
97
|
+
result.push_back(std::move(wrapper));
|
98
|
+
}
|
99
|
+
|
100
|
+
return result;
|
101
|
+
}
|
102
|
+
|
103
|
+
rust::Vec<Bindings::RustyPeripheralWrapper> Bindings::RustyAdapter::get_paired_peripherals() const {
|
104
|
+
rust::Vec<Bindings::RustyPeripheralWrapper> result;
|
105
|
+
|
106
|
+
for (auto& peripheral : _internal->get_paired_peripherals()) {
|
107
|
+
Bindings::RustyPeripheralWrapper wrapper;
|
108
|
+
wrapper.internal = std::make_unique<Bindings::RustyPeripheral>(peripheral);
|
109
|
+
result.push_back(std::move(wrapper));
|
110
|
+
}
|
111
|
+
|
112
|
+
return result;
|
113
|
+
}
|
114
|
+
|
115
|
+
// InnerPeripheral Bindings
|
116
|
+
|
117
|
+
void Bindings::RustyPeripheral::link(SimpleRsBLE::InnerPeripheral& target) const {
|
118
|
+
// Time to explain the weird shenanigan we're doing here:
|
119
|
+
// The TL;DR is that we're making the InnerPeripheral(Rust) and the RustyPeripheral(C++)
|
120
|
+
// point to each other in a safe way.
|
121
|
+
// To achieve this, the InnerPeripheral(Rust) owns a RustyPeripheral(C++) via a UniquePtr,
|
122
|
+
// which ensures that calls will always be made to a valid C++ object.
|
123
|
+
// We now give the RustyPeripheral(C++) a pointer back to the InnerPeripheral(Rust),
|
124
|
+
// so that callbacks can be forwarded back to the Rust domain.
|
125
|
+
// In order to ensure that the InnerPeripheral(Rust) is always valid (given
|
126
|
+
// that Rust is keen on moving stuff around) the object is created as a
|
127
|
+
// Pin<Box<T>>
|
128
|
+
|
129
|
+
// `_peripheral` is a pointer to a pointer, allowing us to manipulate the contents within const functions.
|
130
|
+
_peripheral = ⌖ // THIS LINE IS SUPER IMPORTANT
|
131
|
+
|
132
|
+
_internal->set_callback_on_connected([this]() {
|
133
|
+
if (this->_peripheral == nullptr) return;
|
134
|
+
|
135
|
+
this->_peripheral->on_callback_connected();
|
136
|
+
});
|
137
|
+
|
138
|
+
_internal->set_callback_on_disconnected([this]() {
|
139
|
+
if (this->_peripheral == nullptr) return;
|
140
|
+
|
141
|
+
this->_peripheral->on_callback_disconnected();
|
142
|
+
});
|
143
|
+
}
|
144
|
+
|
145
|
+
void Bindings::RustyPeripheral::unlink() const {
|
146
|
+
// Clear all callbacks
|
147
|
+
_internal->set_callback_on_connected(nullptr);
|
148
|
+
_internal->set_callback_on_disconnected(nullptr);
|
149
|
+
|
150
|
+
// `_peripheral` is a pointer to a pointer.
|
151
|
+
_peripheral = nullptr;
|
152
|
+
}
|
153
|
+
|
154
|
+
rust::String Bindings::RustyPeripheral::identifier() const { return rust::String(_internal->identifier()); }
|
155
|
+
|
156
|
+
rust::String Bindings::RustyPeripheral::address() const { return rust::String(_internal->address()); }
|
157
|
+
|
158
|
+
SimpleBLE::BluetoothAddressType Bindings::RustyPeripheral::address_type() const { return _internal->address_type(); }
|
159
|
+
|
160
|
+
int16_t Bindings::RustyPeripheral::rssi() const { return _internal->rssi(); }
|
161
|
+
|
162
|
+
int16_t Bindings::RustyPeripheral::tx_power() const { return _internal->tx_power(); }
|
163
|
+
|
164
|
+
uint16_t Bindings::RustyPeripheral::mtu() const { return _internal->mtu(); }
|
165
|
+
|
166
|
+
void Bindings::RustyPeripheral::connect() const { _internal->connect(); }
|
167
|
+
|
168
|
+
void Bindings::RustyPeripheral::disconnect() const { _internal->disconnect(); }
|
169
|
+
|
170
|
+
bool Bindings::RustyPeripheral::is_connected() const { return _internal->is_connected(); }
|
171
|
+
|
172
|
+
bool Bindings::RustyPeripheral::is_connectable() const { return _internal->is_connectable(); }
|
173
|
+
|
174
|
+
bool Bindings::RustyPeripheral::is_paired() const { return _internal->is_paired(); }
|
175
|
+
|
176
|
+
void Bindings::RustyPeripheral::unpair() const { _internal->unpair(); }
|
177
|
+
|
178
|
+
rust::Vec<Bindings::RustyServiceWrapper> Bindings::RustyPeripheral::services() const {
|
179
|
+
rust::Vec<Bindings::RustyServiceWrapper> result;
|
180
|
+
|
181
|
+
for (auto& service : _internal->services()) {
|
182
|
+
Bindings::RustyServiceWrapper wrapper;
|
183
|
+
wrapper.internal = std::make_unique<Bindings::RustyService>(service);
|
184
|
+
result.push_back(std::move(wrapper));
|
185
|
+
}
|
186
|
+
|
187
|
+
return result;
|
188
|
+
}
|
189
|
+
|
190
|
+
rust::Vec<Bindings::RustyManufacturerDataWrapper> Bindings::RustyPeripheral::manufacturer_data() const {
|
191
|
+
rust::Vec<Bindings::RustyManufacturerDataWrapper> result;
|
192
|
+
|
193
|
+
for (auto& manufacturer_data : _internal->manufacturer_data()) {
|
194
|
+
Bindings::RustyManufacturerDataWrapper wrapper;
|
195
|
+
wrapper.company_id = manufacturer_data.first;
|
196
|
+
|
197
|
+
for (auto& byte : manufacturer_data.second) {
|
198
|
+
wrapper.data.push_back(byte);
|
199
|
+
}
|
200
|
+
|
201
|
+
result.push_back(std::move(wrapper));
|
202
|
+
}
|
203
|
+
|
204
|
+
return result;
|
205
|
+
}
|
206
|
+
|
207
|
+
rust::Vec<uint8_t> Bindings::RustyPeripheral::read(rust::String const& service,
|
208
|
+
rust::String const& characteristic) const {
|
209
|
+
std::string read_result = _internal->read(std::string(service), std::string(characteristic));
|
210
|
+
|
211
|
+
rust::Vec<uint8_t> result;
|
212
|
+
for (auto& byte : read_result) {
|
213
|
+
result.push_back(byte);
|
214
|
+
}
|
215
|
+
|
216
|
+
return result;
|
217
|
+
}
|
218
|
+
|
219
|
+
void Bindings::RustyPeripheral::write_request(rust::String const& service_rs, rust::String const& characteristic_rs,
|
220
|
+
rust::Vec<uint8_t> const& data) const {
|
221
|
+
std::string service(service_rs);
|
222
|
+
std::string characteristic(characteristic_rs);
|
223
|
+
std::string data_vec((char*)data.data(), data.size());
|
224
|
+
|
225
|
+
_internal->write_request(service, characteristic, data_vec);
|
226
|
+
}
|
227
|
+
|
228
|
+
void Bindings::RustyPeripheral::write_command(rust::String const& service_rs, rust::String const& characteristic_rs,
|
229
|
+
rust::Vec<uint8_t> const& data) const {
|
230
|
+
std::string service(service_rs);
|
231
|
+
std::string characteristic(characteristic_rs);
|
232
|
+
std::string data_vec((char*)data.data(), data.size());
|
233
|
+
|
234
|
+
_internal->write_command(service, characteristic, data_vec);
|
235
|
+
}
|
236
|
+
|
237
|
+
void Bindings::RustyPeripheral::notify(rust::String const& service_rs, rust::String const& characteristic_rs) const {
|
238
|
+
std::string service(service_rs);
|
239
|
+
std::string characteristic(characteristic_rs);
|
240
|
+
|
241
|
+
_internal->notify(service, characteristic, [this, service_rs, characteristic_rs](std::string data) {
|
242
|
+
// NOTE: In this two cases we need to lock the mutex to ensure thread safety, as
|
243
|
+
// the callback cannot be cleared in the unlink() function.
|
244
|
+
std::lock_guard<std::mutex> lock(_peripheral_mutex);
|
245
|
+
if (this->_peripheral == nullptr) return;
|
246
|
+
|
247
|
+
rust::Vec<uint8_t> data_vec;
|
248
|
+
for (auto& byte : data) {
|
249
|
+
data_vec.push_back(byte);
|
250
|
+
}
|
251
|
+
|
252
|
+
this->_peripheral->on_callback_characteristic_updated(service_rs, characteristic_rs, data_vec);
|
253
|
+
});
|
254
|
+
}
|
255
|
+
|
256
|
+
void Bindings::RustyPeripheral::indicate(rust::String const& service_rs, rust::String const& characteristic_rs) const {
|
257
|
+
std::string service(service_rs);
|
258
|
+
std::string characteristic(characteristic_rs);
|
259
|
+
|
260
|
+
_internal->indicate(service, characteristic, [this, service_rs, characteristic_rs](std::string data) {
|
261
|
+
// NOTE: In this two cases we need to lock the mutex to ensure thread safety, as
|
262
|
+
// the callback cannot be cleared in the unlink() function.
|
263
|
+
std::lock_guard<std::mutex> lock(_peripheral_mutex);
|
264
|
+
if (this->_peripheral == nullptr) return;
|
265
|
+
|
266
|
+
rust::Vec<uint8_t> data_vec;
|
267
|
+
for (auto& byte : data) {
|
268
|
+
data_vec.push_back(byte);
|
269
|
+
}
|
270
|
+
|
271
|
+
this->_peripheral->on_callback_characteristic_updated(service_rs, characteristic_rs, data_vec);
|
272
|
+
});
|
273
|
+
}
|
274
|
+
|
275
|
+
void Bindings::RustyPeripheral::unsubscribe(rust::String const& service_rs,
|
276
|
+
rust::String const& characteristic_rs) const {
|
277
|
+
std::string service(service_rs);
|
278
|
+
std::string characteristic(characteristic_rs);
|
279
|
+
|
280
|
+
_internal->unsubscribe(service, characteristic);
|
281
|
+
}
|
282
|
+
|
283
|
+
rust::Vec<uint8_t> Bindings::RustyPeripheral::read_descriptor(rust::String const& service,
|
284
|
+
rust::String const& characteristic,
|
285
|
+
rust::String const& descriptor) const {
|
286
|
+
std::string read_result = _internal->read(std::string(service), std::string(characteristic),
|
287
|
+
std::string(descriptor));
|
288
|
+
|
289
|
+
rust::Vec<uint8_t> result;
|
290
|
+
for (auto& byte : read_result) {
|
291
|
+
result.push_back(byte);
|
292
|
+
}
|
293
|
+
|
294
|
+
return result;
|
295
|
+
}
|
296
|
+
|
297
|
+
void Bindings::RustyPeripheral::write_descriptor(rust::String const& service, rust::String const& characteristic,
|
298
|
+
rust::String const& descriptor, rust::Vec<uint8_t> const& data) const {
|
299
|
+
_internal->write(std::string(service), std::string(characteristic), std::string(descriptor),
|
300
|
+
std::string((char*)data.data(), data.size()));
|
301
|
+
}
|
302
|
+
|
303
|
+
// Service Bindings
|
304
|
+
|
305
|
+
rust::Vec<uint8_t> Bindings::RustyService::data() const {
|
306
|
+
rust::Vec<uint8_t> result;
|
307
|
+
for (auto& byte : _internal->data()) {
|
308
|
+
result.push_back(byte);
|
309
|
+
}
|
310
|
+
|
311
|
+
return result;
|
312
|
+
}
|
313
|
+
|
314
|
+
rust::Vec<Bindings::RustyCharacteristicWrapper> Bindings::RustyService::characteristics() const {
|
315
|
+
rust::Vec<Bindings::RustyCharacteristicWrapper> result;
|
316
|
+
|
317
|
+
for (auto& characteristic : _internal->characteristics()) {
|
318
|
+
Bindings::RustyCharacteristicWrapper wrapper;
|
319
|
+
wrapper.internal = std::make_unique<Bindings::RustyCharacteristic>(characteristic);
|
320
|
+
result.push_back(std::move(wrapper));
|
321
|
+
}
|
322
|
+
|
323
|
+
return result;
|
324
|
+
}
|
325
|
+
|
326
|
+
// Characteristic Bindings
|
327
|
+
|
328
|
+
rust::Vec<Bindings::RustyDescriptorWrapper> Bindings::RustyCharacteristic::descriptors() const {
|
329
|
+
rust::Vec<Bindings::RustyDescriptorWrapper> result;
|
330
|
+
|
331
|
+
for (auto& descriptor : _internal->descriptors()) {
|
332
|
+
Bindings::RustyDescriptorWrapper wrapper;
|
333
|
+
wrapper.internal = std::make_unique<Bindings::RustyDescriptor>(descriptor);
|
334
|
+
result.push_back(std::move(wrapper));
|
335
|
+
}
|
336
|
+
|
337
|
+
return result;
|
338
|
+
}
|
@@ -0,0 +1,178 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include "rust/cxx.h"
|
4
|
+
#include "simpleble/Adapter.h"
|
5
|
+
#include "simpleble/Peripheral.h"
|
6
|
+
|
7
|
+
#include <cstdint>
|
8
|
+
#include <iostream>
|
9
|
+
#include <memory>
|
10
|
+
#include <mutex>
|
11
|
+
|
12
|
+
namespace SimpleRsBLE {
|
13
|
+
|
14
|
+
struct InnerAdapter;
|
15
|
+
struct InnerPeripheral;
|
16
|
+
|
17
|
+
}; // namespace SimpleRsBLE
|
18
|
+
|
19
|
+
namespace Bindings {
|
20
|
+
|
21
|
+
struct RustyAdapterWrapper;
|
22
|
+
struct RustyPeripheralWrapper;
|
23
|
+
struct RustyServiceWrapper;
|
24
|
+
struct RustyCharacteristicWrapper;
|
25
|
+
struct RustyDescriptorWrapper;
|
26
|
+
struct RustyManufacturerDataWrapper;
|
27
|
+
|
28
|
+
rust::Vec<Bindings::RustyAdapterWrapper> RustyAdapter_get_adapters();
|
29
|
+
bool RustyAdapter_bluetooth_enabled();
|
30
|
+
|
31
|
+
class RustyAdapter {
|
32
|
+
public:
|
33
|
+
RustyAdapter() = default;
|
34
|
+
virtual ~RustyAdapter() { _internal.reset(); }
|
35
|
+
|
36
|
+
RustyAdapter(SimpleBLE::Adapter adapter) : _internal(new SimpleBLE::Adapter(std::move(adapter))) {};
|
37
|
+
|
38
|
+
void link(SimpleRsBLE::InnerAdapter& target) const;
|
39
|
+
void unlink() const;
|
40
|
+
|
41
|
+
rust::String identifier() const;
|
42
|
+
rust::String address() const;
|
43
|
+
|
44
|
+
void scan_start() const;
|
45
|
+
void scan_stop() const;
|
46
|
+
void scan_for(int32_t timeout_ms) const;
|
47
|
+
bool scan_is_active() const;
|
48
|
+
rust::Vec<Bindings::RustyPeripheralWrapper> scan_get_results() const;
|
49
|
+
|
50
|
+
rust::Vec<Bindings::RustyPeripheralWrapper> get_paired_peripherals() const;
|
51
|
+
|
52
|
+
private:
|
53
|
+
// NOTE: All internal properties need to be handled as pointers,
|
54
|
+
// allowing the calls to RustyAdapter to always be const.
|
55
|
+
// This might require us to store pointers to pointers, so it's
|
56
|
+
// important to be careful when handling these.
|
57
|
+
std::unique_ptr<SimpleBLE::Adapter> _internal;
|
58
|
+
mutable SimpleRsBLE::InnerAdapter* _adapter = nullptr;
|
59
|
+
mutable std::mutex _adapter_mutex;
|
60
|
+
};
|
61
|
+
|
62
|
+
class RustyPeripheral {
|
63
|
+
public:
|
64
|
+
RustyPeripheral() = default;
|
65
|
+
virtual ~RustyPeripheral() { _internal.reset(); }
|
66
|
+
|
67
|
+
RustyPeripheral(SimpleBLE::Peripheral peripheral) : _internal(new SimpleBLE::Peripheral(peripheral)) {}
|
68
|
+
|
69
|
+
void link(SimpleRsBLE::InnerPeripheral& target) const;
|
70
|
+
void unlink() const;
|
71
|
+
|
72
|
+
rust::String identifier() const;
|
73
|
+
rust::String address() const;
|
74
|
+
SimpleBLE::BluetoothAddressType address_type() const;
|
75
|
+
int16_t rssi() const;
|
76
|
+
|
77
|
+
int16_t tx_power() const;
|
78
|
+
uint16_t mtu() const;
|
79
|
+
|
80
|
+
void connect() const;
|
81
|
+
void disconnect() const;
|
82
|
+
bool is_connected() const;
|
83
|
+
bool is_connectable() const;
|
84
|
+
bool is_paired() const;
|
85
|
+
void unpair() const;
|
86
|
+
|
87
|
+
rust::Vec<Bindings::RustyServiceWrapper> services() const;
|
88
|
+
rust::Vec<Bindings::RustyManufacturerDataWrapper> manufacturer_data() const;
|
89
|
+
|
90
|
+
rust::Vec<uint8_t> read(rust::String const& service, rust::String const& characteristic) const;
|
91
|
+
void write_request(rust::String const& service, rust::String const& characteristic,
|
92
|
+
rust::Vec<uint8_t> const& data) const;
|
93
|
+
void write_command(rust::String const& service, rust::String const& characteristic,
|
94
|
+
rust::Vec<uint8_t> const& data) const;
|
95
|
+
void notify(rust::String const& service, rust::String const& characteristic) const;
|
96
|
+
void indicate(rust::String const& service, rust::String const& characteristic) const;
|
97
|
+
void unsubscribe(rust::String const& service, rust::String const& characteristic) const;
|
98
|
+
|
99
|
+
rust::Vec<uint8_t> read_descriptor(rust::String const& service, rust::String const& characteristic,
|
100
|
+
rust::String const& descriptor) const;
|
101
|
+
void write_descriptor(rust::String const& service, rust::String const& characteristic,
|
102
|
+
rust::String const& descriptor, rust::Vec<uint8_t> const& data) const;
|
103
|
+
|
104
|
+
private:
|
105
|
+
// NOTE: All internal properties need to be handled as pointers,
|
106
|
+
// allowing the calls to RustyPeripheral to always be const.
|
107
|
+
// This might require us to store pointers to pointers, so it's
|
108
|
+
// important to be careful when handling these.
|
109
|
+
std::unique_ptr<SimpleBLE::Peripheral> _internal;
|
110
|
+
mutable SimpleRsBLE::InnerPeripheral* _peripheral = nullptr;
|
111
|
+
mutable std::mutex _peripheral_mutex;
|
112
|
+
};
|
113
|
+
|
114
|
+
class RustyService {
|
115
|
+
public:
|
116
|
+
RustyService() = default;
|
117
|
+
virtual ~RustyService() = default;
|
118
|
+
|
119
|
+
RustyService(SimpleBLE::Service service) : _internal(new SimpleBLE::Service(std::move(service))) {}
|
120
|
+
|
121
|
+
rust::String uuid() const { return rust::String(_internal->uuid()); }
|
122
|
+
|
123
|
+
rust::Vec<uint8_t> data() const;
|
124
|
+
|
125
|
+
rust::Vec<Bindings::RustyCharacteristicWrapper> characteristics() const;
|
126
|
+
|
127
|
+
private:
|
128
|
+
// NOTE: All internal properties need to be handled as pointers,
|
129
|
+
// allowing the calls to RustyService to always be const.
|
130
|
+
// This might require us to store pointers to pointers, so it's
|
131
|
+
// important to be careful when handling these.
|
132
|
+
std::shared_ptr<SimpleBLE::Service> _internal;
|
133
|
+
};
|
134
|
+
|
135
|
+
class RustyCharacteristic {
|
136
|
+
public:
|
137
|
+
RustyCharacteristic() = default;
|
138
|
+
virtual ~RustyCharacteristic() = default;
|
139
|
+
|
140
|
+
RustyCharacteristic(SimpleBLE::Characteristic characteristic)
|
141
|
+
: _internal(new SimpleBLE::Characteristic(std::move(characteristic))) {}
|
142
|
+
|
143
|
+
rust::String uuid() const { return rust::String(_internal->uuid()); }
|
144
|
+
|
145
|
+
rust::Vec<Bindings::RustyDescriptorWrapper> descriptors() const;
|
146
|
+
|
147
|
+
bool can_read() const { return _internal->can_read(); }
|
148
|
+
bool can_write_request() const { return _internal->can_write_request(); }
|
149
|
+
bool can_write_command() const { return _internal->can_write_command(); }
|
150
|
+
bool can_notify() const { return _internal->can_notify(); }
|
151
|
+
bool can_indicate() const { return _internal->can_indicate(); }
|
152
|
+
|
153
|
+
private:
|
154
|
+
// NOTE: All internal properties need to be handled as pointers,
|
155
|
+
// allowing the calls to RustyCharacteristic to always be const.
|
156
|
+
// This might require us to store pointers to pointers, so it's
|
157
|
+
// important to be careful when handling these.
|
158
|
+
std::shared_ptr<SimpleBLE::Characteristic> _internal;
|
159
|
+
};
|
160
|
+
|
161
|
+
class RustyDescriptor {
|
162
|
+
public:
|
163
|
+
RustyDescriptor() = default;
|
164
|
+
virtual ~RustyDescriptor() = default;
|
165
|
+
|
166
|
+
RustyDescriptor(SimpleBLE::Descriptor descriptor) : _internal(new SimpleBLE::Descriptor(std::move(descriptor))) {}
|
167
|
+
|
168
|
+
rust::String uuid() const { return rust::String(_internal->uuid()); }
|
169
|
+
|
170
|
+
private:
|
171
|
+
// NOTE: All internal properties need to be handled as pointers,
|
172
|
+
// allowing the calls to RustyDescriptor to always be const.
|
173
|
+
// This might require us to store pointers to pointers, so it's
|
174
|
+
// important to be careful when handling these.
|
175
|
+
std::shared_ptr<SimpleBLE::Descriptor> _internal;
|
176
|
+
};
|
177
|
+
|
178
|
+
}; // namespace Bindings
|