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,204 @@
|
|
1
|
+
#include <simpleble_c/adapter.h>
|
2
|
+
|
3
|
+
#include <simpleble/AdapterSafe.h>
|
4
|
+
|
5
|
+
#include <cstring>
|
6
|
+
|
7
|
+
bool simpleble_adapter_is_bluetooth_enabled(void) {
|
8
|
+
return SimpleBLE::Safe::Adapter::bluetooth_enabled().value_or(false);
|
9
|
+
}
|
10
|
+
|
11
|
+
size_t simpleble_adapter_get_count(void) {
|
12
|
+
return SimpleBLE::Safe::Adapter::get_adapters().value_or(std::vector<SimpleBLE::Safe::Adapter>()).size();
|
13
|
+
}
|
14
|
+
|
15
|
+
simpleble_adapter_t simpleble_adapter_get_handle(size_t index) {
|
16
|
+
auto adapter_list = SimpleBLE::Safe::Adapter::get_adapters().value_or(std::vector<SimpleBLE::Safe::Adapter>());
|
17
|
+
|
18
|
+
if (index >= adapter_list.size()) {
|
19
|
+
return nullptr;
|
20
|
+
}
|
21
|
+
|
22
|
+
SimpleBLE::Safe::Adapter* handle = new SimpleBLE::Safe::Adapter(adapter_list[index]);
|
23
|
+
return handle;
|
24
|
+
}
|
25
|
+
|
26
|
+
void simpleble_adapter_release_handle(simpleble_adapter_t handle) {
|
27
|
+
if (handle == nullptr) {
|
28
|
+
return;
|
29
|
+
}
|
30
|
+
|
31
|
+
SimpleBLE::Safe::Adapter* adapter = (SimpleBLE::Safe::Adapter*)handle;
|
32
|
+
delete adapter;
|
33
|
+
}
|
34
|
+
|
35
|
+
char* simpleble_adapter_identifier(simpleble_adapter_t handle) {
|
36
|
+
if (handle == nullptr) {
|
37
|
+
return nullptr;
|
38
|
+
}
|
39
|
+
|
40
|
+
SimpleBLE::Safe::Adapter* adapter = (SimpleBLE::Safe::Adapter*)handle;
|
41
|
+
std::string identifier = adapter->identifier().value_or("");
|
42
|
+
char* c_identifier = (char*)malloc(identifier.size() + 1);
|
43
|
+
strcpy(c_identifier, identifier.c_str());
|
44
|
+
return c_identifier;
|
45
|
+
}
|
46
|
+
|
47
|
+
char* simpleble_adapter_address(simpleble_adapter_t handle) {
|
48
|
+
if (handle == nullptr) {
|
49
|
+
return nullptr;
|
50
|
+
}
|
51
|
+
|
52
|
+
SimpleBLE::Safe::Adapter* adapter = (SimpleBLE::Safe::Adapter*)handle;
|
53
|
+
std::string address = adapter->address().value_or("");
|
54
|
+
char* c_address = (char*)malloc(address.size() + 1);
|
55
|
+
strcpy(c_address, address.c_str());
|
56
|
+
return c_address;
|
57
|
+
}
|
58
|
+
|
59
|
+
simpleble_err_t simpleble_adapter_scan_start(simpleble_adapter_t handle) {
|
60
|
+
if (handle == nullptr) {
|
61
|
+
return SIMPLEBLE_FAILURE;
|
62
|
+
}
|
63
|
+
|
64
|
+
SimpleBLE::Safe::Adapter* adapter = (SimpleBLE::Safe::Adapter*)handle;
|
65
|
+
return adapter->scan_start() ? SIMPLEBLE_SUCCESS : SIMPLEBLE_FAILURE;
|
66
|
+
}
|
67
|
+
|
68
|
+
simpleble_err_t simpleble_adapter_scan_stop(simpleble_adapter_t handle) {
|
69
|
+
if (handle == nullptr) {
|
70
|
+
return SIMPLEBLE_FAILURE;
|
71
|
+
}
|
72
|
+
|
73
|
+
SimpleBLE::Safe::Adapter* adapter = (SimpleBLE::Safe::Adapter*)handle;
|
74
|
+
return adapter->scan_stop() ? SIMPLEBLE_SUCCESS : SIMPLEBLE_FAILURE;
|
75
|
+
}
|
76
|
+
|
77
|
+
simpleble_err_t simpleble_adapter_scan_is_active(simpleble_adapter_t handle, bool* active) {
|
78
|
+
if (handle == nullptr || active == nullptr) {
|
79
|
+
return SIMPLEBLE_FAILURE;
|
80
|
+
}
|
81
|
+
|
82
|
+
SimpleBLE::Safe::Adapter* adapter = (SimpleBLE::Safe::Adapter*)handle;
|
83
|
+
|
84
|
+
std::optional<bool> is_active = adapter->scan_is_active();
|
85
|
+
*active = is_active.value_or(false);
|
86
|
+
return is_active.has_value() ? SIMPLEBLE_SUCCESS : SIMPLEBLE_FAILURE;
|
87
|
+
}
|
88
|
+
|
89
|
+
simpleble_err_t simpleble_adapter_scan_for(simpleble_adapter_t handle, int timeout_ms) {
|
90
|
+
if (handle == nullptr) {
|
91
|
+
return SIMPLEBLE_FAILURE;
|
92
|
+
}
|
93
|
+
|
94
|
+
SimpleBLE::Safe::Adapter* adapter = (SimpleBLE::Safe::Adapter*)handle;
|
95
|
+
return adapter->scan_for(timeout_ms) ? SIMPLEBLE_SUCCESS : SIMPLEBLE_FAILURE;
|
96
|
+
}
|
97
|
+
|
98
|
+
size_t simpleble_adapter_scan_get_results_count(simpleble_adapter_t handle) {
|
99
|
+
if (handle == nullptr) {
|
100
|
+
return 0;
|
101
|
+
}
|
102
|
+
|
103
|
+
SimpleBLE::Safe::Adapter* adapter = (SimpleBLE::Safe::Adapter*)handle;
|
104
|
+
return adapter->scan_get_results().value_or(std::vector<SimpleBLE::Safe::Peripheral>()).size();
|
105
|
+
}
|
106
|
+
|
107
|
+
simpleble_peripheral_t simpleble_adapter_scan_get_results_handle(simpleble_adapter_t handle, size_t index) {
|
108
|
+
if (handle == nullptr) {
|
109
|
+
return nullptr;
|
110
|
+
}
|
111
|
+
|
112
|
+
SimpleBLE::Safe::Adapter* adapter = (SimpleBLE::Safe::Adapter*)handle;
|
113
|
+
auto results = adapter->scan_get_results().value_or(std::vector<SimpleBLE::Safe::Peripheral>());
|
114
|
+
|
115
|
+
if (index >= results.size()) {
|
116
|
+
return nullptr;
|
117
|
+
}
|
118
|
+
|
119
|
+
SimpleBLE::Safe::Peripheral* peripheral_handle = new SimpleBLE::Safe::Peripheral(results[index]);
|
120
|
+
return peripheral_handle;
|
121
|
+
}
|
122
|
+
|
123
|
+
size_t simpleble_adapter_get_paired_peripherals_count(simpleble_adapter_t handle) {
|
124
|
+
if (handle == nullptr) {
|
125
|
+
return 0;
|
126
|
+
}
|
127
|
+
|
128
|
+
SimpleBLE::Safe::Adapter* adapter = (SimpleBLE::Safe::Adapter*)handle;
|
129
|
+
return adapter->get_paired_peripherals().value_or(std::vector<SimpleBLE::Safe::Peripheral>()).size();
|
130
|
+
}
|
131
|
+
|
132
|
+
simpleble_peripheral_t simpleble_adapter_get_paired_peripherals_handle(simpleble_adapter_t handle, size_t index) {
|
133
|
+
if (handle == nullptr) {
|
134
|
+
return nullptr;
|
135
|
+
}
|
136
|
+
|
137
|
+
SimpleBLE::Safe::Adapter* adapter = (SimpleBLE::Safe::Adapter*)handle;
|
138
|
+
auto results = adapter->get_paired_peripherals().value_or(std::vector<SimpleBLE::Safe::Peripheral>());
|
139
|
+
|
140
|
+
if (index >= results.size()) {
|
141
|
+
return nullptr;
|
142
|
+
}
|
143
|
+
|
144
|
+
SimpleBLE::Safe::Peripheral* peripheral_handle = new SimpleBLE::Safe::Peripheral(results[index]);
|
145
|
+
return peripheral_handle;
|
146
|
+
}
|
147
|
+
|
148
|
+
simpleble_err_t simpleble_adapter_set_callback_on_scan_start(simpleble_adapter_t handle,
|
149
|
+
void (*callback)(simpleble_adapter_t, void*),
|
150
|
+
void* userdata) {
|
151
|
+
if (handle == nullptr) {
|
152
|
+
return SIMPLEBLE_FAILURE;
|
153
|
+
}
|
154
|
+
|
155
|
+
SimpleBLE::Safe::Adapter* adapter = (SimpleBLE::Safe::Adapter*)handle;
|
156
|
+
|
157
|
+
bool success = adapter->set_callback_on_scan_start([=]() { callback(handle, userdata); });
|
158
|
+
return success ? SIMPLEBLE_SUCCESS : SIMPLEBLE_FAILURE;
|
159
|
+
}
|
160
|
+
|
161
|
+
simpleble_err_t simpleble_adapter_set_callback_on_scan_stop(simpleble_adapter_t handle,
|
162
|
+
void (*callback)(simpleble_adapter_t, void*),
|
163
|
+
void* userdata) {
|
164
|
+
if (handle == nullptr) {
|
165
|
+
return SIMPLEBLE_FAILURE;
|
166
|
+
}
|
167
|
+
|
168
|
+
SimpleBLE::Safe::Adapter* adapter = (SimpleBLE::Safe::Adapter*)handle;
|
169
|
+
|
170
|
+
bool success = adapter->set_callback_on_scan_stop([=]() { callback(handle, userdata); });
|
171
|
+
return success ? SIMPLEBLE_SUCCESS : SIMPLEBLE_FAILURE;
|
172
|
+
}
|
173
|
+
|
174
|
+
simpleble_err_t simpleble_adapter_set_callback_on_scan_updated(
|
175
|
+
simpleble_adapter_t handle, void (*callback)(simpleble_adapter_t, simpleble_peripheral_t, void*), void* userdata) {
|
176
|
+
if (handle == nullptr) {
|
177
|
+
return SIMPLEBLE_FAILURE;
|
178
|
+
}
|
179
|
+
|
180
|
+
SimpleBLE::Safe::Adapter* adapter = (SimpleBLE::Safe::Adapter*)handle;
|
181
|
+
|
182
|
+
bool success = adapter->set_callback_on_scan_updated([=](SimpleBLE::Safe::Peripheral peripheral) {
|
183
|
+
// Create a peripheral handle
|
184
|
+
SimpleBLE::Safe::Peripheral* peripheral_handle = new SimpleBLE::Safe::Peripheral(peripheral);
|
185
|
+
callback(handle, peripheral_handle, userdata);
|
186
|
+
});
|
187
|
+
return success ? SIMPLEBLE_SUCCESS : SIMPLEBLE_FAILURE;
|
188
|
+
}
|
189
|
+
|
190
|
+
simpleble_err_t simpleble_adapter_set_callback_on_scan_found(
|
191
|
+
simpleble_adapter_t handle, void (*callback)(simpleble_adapter_t, simpleble_peripheral_t, void*), void* userdata) {
|
192
|
+
if (handle == nullptr) {
|
193
|
+
return SIMPLEBLE_FAILURE;
|
194
|
+
}
|
195
|
+
|
196
|
+
SimpleBLE::Safe::Adapter* adapter = (SimpleBLE::Safe::Adapter*)handle;
|
197
|
+
|
198
|
+
bool success = adapter->set_callback_on_scan_found([=](SimpleBLE::Safe::Peripheral peripheral) {
|
199
|
+
// Create a peripheral handle
|
200
|
+
SimpleBLE::Safe::Peripheral* peripheral_handle = new SimpleBLE::Safe::Peripheral(peripheral);
|
201
|
+
callback(handle, peripheral_handle, userdata);
|
202
|
+
});
|
203
|
+
return success ? SIMPLEBLE_SUCCESS : SIMPLEBLE_FAILURE;
|
204
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#include <simpleble/Logging.h>
|
2
|
+
#include <simpleble_c/logging.h>
|
3
|
+
|
4
|
+
void simpleble_logging_set_level(simpleble_log_level_t level) {
|
5
|
+
SimpleBLE::Logging::Logger::get()->set_level(static_cast<SimpleBLE::Logging::Level>(level));
|
6
|
+
}
|
7
|
+
|
8
|
+
void simpleble_logging_set_callback(simpleble_log_callback_t callback) {
|
9
|
+
SimpleBLE::Logging::Logger::get()->set_callback(
|
10
|
+
[callback](SimpleBLE::Logging::Level level, const std::string& module, const std::string& file, uint32_t line,
|
11
|
+
const std::string& function, const std::string& message) {
|
12
|
+
try {
|
13
|
+
callback(static_cast<simpleble_log_level_t>(level), module.c_str(), file.c_str(), line,
|
14
|
+
function.c_str(), message.c_str());
|
15
|
+
} catch (...) {
|
16
|
+
// Clearly, if the logging callback throws an exception, we should not crash.
|
17
|
+
}
|
18
|
+
});
|
19
|
+
}
|
@@ -0,0 +1,444 @@
|
|
1
|
+
#include <simpleble_c/peripheral.h>
|
2
|
+
|
3
|
+
#include <simpleble/PeripheralSafe.h>
|
4
|
+
|
5
|
+
#include <climits>
|
6
|
+
#include <cstring>
|
7
|
+
#include <map>
|
8
|
+
|
9
|
+
void simpleble_peripheral_release_handle(simpleble_peripheral_t handle) {
|
10
|
+
if (handle == nullptr) {
|
11
|
+
return;
|
12
|
+
}
|
13
|
+
|
14
|
+
SimpleBLE::Safe::Peripheral* peripheral = (SimpleBLE::Safe::Peripheral*)handle;
|
15
|
+
delete peripheral;
|
16
|
+
}
|
17
|
+
|
18
|
+
char* simpleble_peripheral_identifier(simpleble_peripheral_t handle) {
|
19
|
+
if (handle == nullptr) {
|
20
|
+
return nullptr;
|
21
|
+
}
|
22
|
+
|
23
|
+
SimpleBLE::Safe::Peripheral* peripheral = (SimpleBLE::Safe::Peripheral*)handle;
|
24
|
+
std::string identifier = peripheral->identifier().value_or("");
|
25
|
+
char* c_identifier = (char*)malloc(identifier.size() + 1);
|
26
|
+
strcpy(c_identifier, identifier.c_str());
|
27
|
+
return c_identifier;
|
28
|
+
}
|
29
|
+
|
30
|
+
char* simpleble_peripheral_address(simpleble_peripheral_t handle) {
|
31
|
+
if (handle == nullptr) {
|
32
|
+
return nullptr;
|
33
|
+
}
|
34
|
+
|
35
|
+
SimpleBLE::Safe::Peripheral* peripheral = (SimpleBLE::Safe::Peripheral*)handle;
|
36
|
+
std::string address = peripheral->address().value_or("");
|
37
|
+
char* c_address = (char*)malloc(address.size() + 1);
|
38
|
+
strcpy(c_address, address.c_str());
|
39
|
+
return c_address;
|
40
|
+
}
|
41
|
+
|
42
|
+
simpleble_address_type_t simpleble_peripheral_address_type(simpleble_peripheral_t handle) {
|
43
|
+
if (handle == nullptr) {
|
44
|
+
return SIMPLEBLE_ADDRESS_TYPE_UNSPECIFIED;
|
45
|
+
}
|
46
|
+
|
47
|
+
SimpleBLE::Safe::Peripheral* peripheral = (SimpleBLE::Safe::Peripheral*)handle;
|
48
|
+
SimpleBLE::BluetoothAddressType address_type = peripheral->address_type().value_or(
|
49
|
+
SimpleBLE::BluetoothAddressType::UNSPECIFIED);
|
50
|
+
return (simpleble_address_type_t)address_type;
|
51
|
+
}
|
52
|
+
|
53
|
+
int16_t simpleble_peripheral_rssi(simpleble_peripheral_t handle) {
|
54
|
+
if (handle == nullptr) {
|
55
|
+
return INT16_MIN;
|
56
|
+
}
|
57
|
+
|
58
|
+
SimpleBLE::Safe::Peripheral* peripheral = (SimpleBLE::Safe::Peripheral*)handle;
|
59
|
+
return peripheral->rssi().value_or(INT16_MIN);
|
60
|
+
}
|
61
|
+
|
62
|
+
int16_t simpleble_peripheral_tx_power(simpleble_peripheral_t handle) {
|
63
|
+
if (handle == nullptr) {
|
64
|
+
return INT16_MIN;
|
65
|
+
}
|
66
|
+
|
67
|
+
SimpleBLE::Safe::Peripheral* peripheral = (SimpleBLE::Safe::Peripheral*)handle;
|
68
|
+
return peripheral->tx_power().value_or(INT16_MIN);
|
69
|
+
}
|
70
|
+
|
71
|
+
uint16_t simpleble_peripheral_mtu(simpleble_peripheral_t handle) {
|
72
|
+
if (handle == nullptr) {
|
73
|
+
return 0;
|
74
|
+
}
|
75
|
+
|
76
|
+
SimpleBLE::Safe::Peripheral* peripheral = (SimpleBLE::Safe::Peripheral*)handle;
|
77
|
+
return peripheral->mtu().value_or(0);
|
78
|
+
}
|
79
|
+
|
80
|
+
simpleble_err_t simpleble_peripheral_connect(simpleble_peripheral_t handle) {
|
81
|
+
if (handle == nullptr) {
|
82
|
+
return SIMPLEBLE_FAILURE;
|
83
|
+
}
|
84
|
+
|
85
|
+
SimpleBLE::Safe::Peripheral* peripheral = (SimpleBLE::Safe::Peripheral*)handle;
|
86
|
+
return peripheral->connect() ? SIMPLEBLE_SUCCESS : SIMPLEBLE_FAILURE;
|
87
|
+
}
|
88
|
+
|
89
|
+
simpleble_err_t simpleble_peripheral_disconnect(simpleble_peripheral_t handle) {
|
90
|
+
if (handle == nullptr) {
|
91
|
+
return SIMPLEBLE_FAILURE;
|
92
|
+
}
|
93
|
+
|
94
|
+
SimpleBLE::Safe::Peripheral* peripheral = (SimpleBLE::Safe::Peripheral*)handle;
|
95
|
+
return peripheral->disconnect() ? SIMPLEBLE_SUCCESS : SIMPLEBLE_FAILURE;
|
96
|
+
}
|
97
|
+
|
98
|
+
simpleble_err_t simpleble_peripheral_is_connected(simpleble_peripheral_t handle, bool* connected) {
|
99
|
+
if (handle == nullptr || connected == nullptr) {
|
100
|
+
return SIMPLEBLE_FAILURE;
|
101
|
+
}
|
102
|
+
|
103
|
+
SimpleBLE::Safe::Peripheral* peripheral = (SimpleBLE::Safe::Peripheral*)handle;
|
104
|
+
|
105
|
+
std::optional<bool> is_connected = peripheral->is_connected();
|
106
|
+
*connected = is_connected.value_or(false);
|
107
|
+
return is_connected.has_value() ? SIMPLEBLE_SUCCESS : SIMPLEBLE_FAILURE;
|
108
|
+
}
|
109
|
+
|
110
|
+
simpleble_err_t simpleble_peripheral_is_connectable(simpleble_peripheral_t handle, bool* connectable) {
|
111
|
+
if (handle == nullptr || connectable == nullptr) {
|
112
|
+
return SIMPLEBLE_FAILURE;
|
113
|
+
}
|
114
|
+
|
115
|
+
SimpleBLE::Safe::Peripheral* peripheral = (SimpleBLE::Safe::Peripheral*)handle;
|
116
|
+
|
117
|
+
std::optional<bool> is_connectable = peripheral->is_connectable();
|
118
|
+
*connectable = is_connectable.value_or(false);
|
119
|
+
return is_connectable.has_value() ? SIMPLEBLE_SUCCESS : SIMPLEBLE_FAILURE;
|
120
|
+
}
|
121
|
+
|
122
|
+
simpleble_err_t simpleble_peripheral_is_paired(simpleble_peripheral_t handle, bool* paired) {
|
123
|
+
if (handle == nullptr || paired == nullptr) {
|
124
|
+
return SIMPLEBLE_FAILURE;
|
125
|
+
}
|
126
|
+
|
127
|
+
SimpleBLE::Safe::Peripheral* peripheral = (SimpleBLE::Safe::Peripheral*)handle;
|
128
|
+
|
129
|
+
std::optional<bool> is_paired = peripheral->is_paired();
|
130
|
+
*paired = is_paired.value_or(false);
|
131
|
+
return is_paired.has_value() ? SIMPLEBLE_SUCCESS : SIMPLEBLE_FAILURE;
|
132
|
+
}
|
133
|
+
|
134
|
+
simpleble_err_t simpleble_peripheral_unpair(simpleble_peripheral_t handle) {
|
135
|
+
if (handle == nullptr) {
|
136
|
+
return SIMPLEBLE_FAILURE;
|
137
|
+
}
|
138
|
+
|
139
|
+
SimpleBLE::Safe::Peripheral* peripheral = (SimpleBLE::Safe::Peripheral*)handle;
|
140
|
+
return peripheral->unpair() ? SIMPLEBLE_SUCCESS : SIMPLEBLE_FAILURE;
|
141
|
+
}
|
142
|
+
|
143
|
+
size_t simpleble_peripheral_services_count(simpleble_peripheral_t handle) {
|
144
|
+
if (handle == nullptr) {
|
145
|
+
return 0;
|
146
|
+
}
|
147
|
+
|
148
|
+
SimpleBLE::Safe::Peripheral* peripheral = (SimpleBLE::Safe::Peripheral*)handle;
|
149
|
+
auto services = peripheral->services();
|
150
|
+
if (services.has_value()) {
|
151
|
+
return services.value().size();
|
152
|
+
} else {
|
153
|
+
return 0;
|
154
|
+
}
|
155
|
+
}
|
156
|
+
|
157
|
+
simpleble_err_t simpleble_peripheral_services_get(simpleble_peripheral_t handle, size_t index,
|
158
|
+
simpleble_service_t* services) {
|
159
|
+
if (handle == nullptr || services == nullptr) {
|
160
|
+
return SIMPLEBLE_FAILURE;
|
161
|
+
}
|
162
|
+
|
163
|
+
memset(services, 0, sizeof(simpleble_service_t));
|
164
|
+
|
165
|
+
SimpleBLE::Safe::Peripheral* peripheral = (SimpleBLE::Safe::Peripheral*)handle;
|
166
|
+
auto peripheral_services = peripheral->services();
|
167
|
+
if (!peripheral_services.has_value()) {
|
168
|
+
return SIMPLEBLE_FAILURE;
|
169
|
+
}
|
170
|
+
|
171
|
+
if (index >= peripheral_services.value().size()) {
|
172
|
+
return SIMPLEBLE_FAILURE;
|
173
|
+
}
|
174
|
+
|
175
|
+
SimpleBLE::Service service = peripheral_services.value()[index];
|
176
|
+
|
177
|
+
memcpy(services->uuid.value, service.uuid().c_str(), SIMPLEBLE_UUID_STR_LEN);
|
178
|
+
|
179
|
+
services->data_length = service.data().size();
|
180
|
+
memcpy(services->data, service.data().data(), service.data().size());
|
181
|
+
|
182
|
+
services->characteristic_count = service.characteristics().size();
|
183
|
+
if (services->characteristic_count > SIMPLEBLE_CHARACTERISTIC_MAX_COUNT) {
|
184
|
+
services->characteristic_count = SIMPLEBLE_CHARACTERISTIC_MAX_COUNT;
|
185
|
+
}
|
186
|
+
|
187
|
+
for (size_t i = 0; i < services->characteristic_count; i++) {
|
188
|
+
SimpleBLE::Characteristic characteristic = service.characteristics()[i];
|
189
|
+
|
190
|
+
services->characteristics[i].can_read = characteristic.can_read();
|
191
|
+
services->characteristics[i].can_write_request = characteristic.can_write_request();
|
192
|
+
services->characteristics[i].can_write_command = characteristic.can_write_command();
|
193
|
+
services->characteristics[i].can_notify = characteristic.can_notify();
|
194
|
+
services->characteristics[i].can_indicate = characteristic.can_indicate();
|
195
|
+
|
196
|
+
memcpy(services->characteristics[i].uuid.value, characteristic.uuid().c_str(), SIMPLEBLE_UUID_STR_LEN);
|
197
|
+
services->characteristics[i].descriptor_count = characteristic.descriptors().size();
|
198
|
+
|
199
|
+
if (services->characteristics[i].descriptor_count > SIMPLEBLE_DESCRIPTOR_MAX_COUNT) {
|
200
|
+
services->characteristics[i].descriptor_count = SIMPLEBLE_DESCRIPTOR_MAX_COUNT;
|
201
|
+
}
|
202
|
+
|
203
|
+
for (size_t j = 0; j < services->characteristics[i].descriptor_count; j++) {
|
204
|
+
SimpleBLE::Descriptor descriptor = characteristic.descriptors()[j];
|
205
|
+
|
206
|
+
memcpy(services->characteristics[i].descriptors[j].uuid.value, descriptor.uuid().c_str(),
|
207
|
+
SIMPLEBLE_UUID_STR_LEN);
|
208
|
+
}
|
209
|
+
}
|
210
|
+
|
211
|
+
return SIMPLEBLE_SUCCESS;
|
212
|
+
}
|
213
|
+
|
214
|
+
size_t simpleble_peripheral_manufacturer_data_count(simpleble_peripheral_t handle) {
|
215
|
+
if (handle == nullptr) {
|
216
|
+
return 0;
|
217
|
+
}
|
218
|
+
|
219
|
+
SimpleBLE::Safe::Peripheral* peripheral = (SimpleBLE::Safe::Peripheral*)handle;
|
220
|
+
|
221
|
+
auto manufacturer_data = peripheral->manufacturer_data();
|
222
|
+
if (manufacturer_data.has_value()) {
|
223
|
+
return manufacturer_data.value().size();
|
224
|
+
} else {
|
225
|
+
return 0;
|
226
|
+
}
|
227
|
+
}
|
228
|
+
|
229
|
+
simpleble_err_t simpleble_peripheral_manufacturer_data_get(simpleble_peripheral_t handle, size_t index,
|
230
|
+
simpleble_manufacturer_data_t* manufacturer_data) {
|
231
|
+
if (handle == nullptr || manufacturer_data == nullptr) {
|
232
|
+
return SIMPLEBLE_FAILURE;
|
233
|
+
}
|
234
|
+
|
235
|
+
SimpleBLE::Safe::Peripheral* peripheral = (SimpleBLE::Safe::Peripheral*)handle;
|
236
|
+
|
237
|
+
auto peripheral_manufacturer_data = peripheral->manufacturer_data();
|
238
|
+
if (!peripheral_manufacturer_data.has_value()) {
|
239
|
+
return SIMPLEBLE_FAILURE;
|
240
|
+
}
|
241
|
+
|
242
|
+
if (index >= peripheral_manufacturer_data.value().size()) {
|
243
|
+
return SIMPLEBLE_FAILURE;
|
244
|
+
}
|
245
|
+
|
246
|
+
// Build an iterator and advance to the expected element
|
247
|
+
std::map<uint16_t, SimpleBLE::ByteArray>::iterator it = peripheral_manufacturer_data.value().begin();
|
248
|
+
for (size_t i = 0; i < index; i++) {
|
249
|
+
it++;
|
250
|
+
}
|
251
|
+
|
252
|
+
auto& selected_manufacturer_data = *it;
|
253
|
+
manufacturer_data->manufacturer_id = selected_manufacturer_data.first;
|
254
|
+
manufacturer_data->data_length = selected_manufacturer_data.second.size();
|
255
|
+
memcpy(manufacturer_data->data, selected_manufacturer_data.second.data(), selected_manufacturer_data.second.size());
|
256
|
+
|
257
|
+
return SIMPLEBLE_SUCCESS;
|
258
|
+
}
|
259
|
+
|
260
|
+
simpleble_err_t simpleble_peripheral_read(simpleble_peripheral_t handle, simpleble_uuid_t service,
|
261
|
+
simpleble_uuid_t characteristic, uint8_t** data, size_t* data_length) {
|
262
|
+
if (handle == nullptr || data == nullptr || data_length == nullptr) {
|
263
|
+
return SIMPLEBLE_FAILURE;
|
264
|
+
}
|
265
|
+
|
266
|
+
// Clear the initial values for safety
|
267
|
+
*data = nullptr;
|
268
|
+
*data_length = 0;
|
269
|
+
|
270
|
+
// Perform the read operation
|
271
|
+
SimpleBLE::Safe::Peripheral* peripheral = (SimpleBLE::Safe::Peripheral*)handle;
|
272
|
+
std::optional<SimpleBLE::ByteArray> read_data = peripheral->read(SimpleBLE::BluetoothUUID(service.value),
|
273
|
+
SimpleBLE::BluetoothUUID(characteristic.value));
|
274
|
+
|
275
|
+
// Early return if the operation failed
|
276
|
+
if (!read_data.has_value()) {
|
277
|
+
return SIMPLEBLE_FAILURE;
|
278
|
+
}
|
279
|
+
|
280
|
+
*data_length = read_data.value().size();
|
281
|
+
*data = static_cast<uint8_t*>(malloc(*data_length));
|
282
|
+
memcpy(*data, read_data.value().data(), *data_length);
|
283
|
+
|
284
|
+
return SIMPLEBLE_SUCCESS;
|
285
|
+
}
|
286
|
+
|
287
|
+
simpleble_err_t simpleble_peripheral_write_request(simpleble_peripheral_t handle, simpleble_uuid_t service,
|
288
|
+
simpleble_uuid_t characteristic, const uint8_t* data,
|
289
|
+
size_t data_length) {
|
290
|
+
if (handle == nullptr || data == nullptr) {
|
291
|
+
return SIMPLEBLE_FAILURE;
|
292
|
+
}
|
293
|
+
|
294
|
+
SimpleBLE::Safe::Peripheral* peripheral = (SimpleBLE::Safe::Peripheral*)handle;
|
295
|
+
|
296
|
+
bool success = peripheral->write_request(SimpleBLE::BluetoothUUID(service.value),
|
297
|
+
SimpleBLE::BluetoothUUID(characteristic.value),
|
298
|
+
SimpleBLE::ByteArray((const char*)data, data_length));
|
299
|
+
|
300
|
+
return success ? SIMPLEBLE_SUCCESS : SIMPLEBLE_FAILURE;
|
301
|
+
}
|
302
|
+
|
303
|
+
simpleble_err_t simpleble_peripheral_write_command(simpleble_peripheral_t handle, simpleble_uuid_t service,
|
304
|
+
simpleble_uuid_t characteristic, const uint8_t* data,
|
305
|
+
size_t data_length) {
|
306
|
+
if (handle == nullptr || data == nullptr) {
|
307
|
+
return SIMPLEBLE_FAILURE;
|
308
|
+
}
|
309
|
+
|
310
|
+
SimpleBLE::Safe::Peripheral* peripheral = (SimpleBLE::Safe::Peripheral*)handle;
|
311
|
+
|
312
|
+
bool success = peripheral->write_command(SimpleBLE::BluetoothUUID(service.value),
|
313
|
+
SimpleBLE::BluetoothUUID(characteristic.value),
|
314
|
+
SimpleBLE::ByteArray((const char*)data, data_length));
|
315
|
+
|
316
|
+
return success ? SIMPLEBLE_SUCCESS : SIMPLEBLE_FAILURE;
|
317
|
+
}
|
318
|
+
|
319
|
+
simpleble_err_t simpleble_peripheral_notify(simpleble_peripheral_t handle, simpleble_uuid_t service,
|
320
|
+
simpleble_uuid_t characteristic,
|
321
|
+
void (*callback)(simpleble_peripheral_t, simpleble_uuid_t, simpleble_uuid_t,
|
322
|
+
const uint8_t*, size_t, void*),
|
323
|
+
void* userdata) {
|
324
|
+
if (handle == nullptr || callback == nullptr) {
|
325
|
+
return SIMPLEBLE_FAILURE;
|
326
|
+
}
|
327
|
+
|
328
|
+
SimpleBLE::Safe::Peripheral* peripheral = (SimpleBLE::Safe::Peripheral*)handle;
|
329
|
+
|
330
|
+
bool success = peripheral->notify(SimpleBLE::BluetoothUUID(service.value),
|
331
|
+
SimpleBLE::BluetoothUUID(characteristic.value), [=](SimpleBLE::ByteArray data) {
|
332
|
+
callback(handle, service, characteristic, (const uint8_t*)data.data(),
|
333
|
+
data.size(), userdata);
|
334
|
+
});
|
335
|
+
|
336
|
+
return success ? SIMPLEBLE_SUCCESS : SIMPLEBLE_FAILURE;
|
337
|
+
}
|
338
|
+
|
339
|
+
simpleble_err_t simpleble_peripheral_indicate(simpleble_peripheral_t handle, simpleble_uuid_t service,
|
340
|
+
simpleble_uuid_t characteristic,
|
341
|
+
void (*callback)(simpleble_peripheral_t, simpleble_uuid_t,
|
342
|
+
simpleble_uuid_t, const uint8_t*, size_t, void*),
|
343
|
+
void* userdata) {
|
344
|
+
if (handle == nullptr || callback == nullptr) {
|
345
|
+
return SIMPLEBLE_FAILURE;
|
346
|
+
}
|
347
|
+
|
348
|
+
SimpleBLE::Safe::Peripheral* peripheral = (SimpleBLE::Safe::Peripheral*)handle;
|
349
|
+
|
350
|
+
bool success = peripheral->indicate(SimpleBLE::BluetoothUUID(service.value),
|
351
|
+
SimpleBLE::BluetoothUUID(characteristic.value), [=](SimpleBLE::ByteArray data) {
|
352
|
+
callback(handle, service, characteristic, (const uint8_t*)data.data(),
|
353
|
+
data.size(), userdata);
|
354
|
+
});
|
355
|
+
|
356
|
+
return success ? SIMPLEBLE_SUCCESS : SIMPLEBLE_FAILURE;
|
357
|
+
}
|
358
|
+
|
359
|
+
simpleble_err_t simpleble_peripheral_unsubscribe(simpleble_peripheral_t handle, simpleble_uuid_t service,
|
360
|
+
simpleble_uuid_t characteristic) {
|
361
|
+
if (handle == nullptr) {
|
362
|
+
return SIMPLEBLE_FAILURE;
|
363
|
+
}
|
364
|
+
|
365
|
+
SimpleBLE::Safe::Peripheral* peripheral = (SimpleBLE::Safe::Peripheral*)handle;
|
366
|
+
|
367
|
+
bool success = peripheral->unsubscribe(SimpleBLE::BluetoothUUID(service.value),
|
368
|
+
SimpleBLE::BluetoothUUID(characteristic.value));
|
369
|
+
|
370
|
+
return success ? SIMPLEBLE_SUCCESS : SIMPLEBLE_FAILURE;
|
371
|
+
}
|
372
|
+
|
373
|
+
simpleble_err_t simpleble_peripheral_read_descriptor(simpleble_peripheral_t handle, simpleble_uuid_t service,
|
374
|
+
simpleble_uuid_t characteristic, simpleble_uuid_t descriptor,
|
375
|
+
uint8_t** data, size_t* data_length) {
|
376
|
+
if (handle == nullptr || data == nullptr || data_length == nullptr) {
|
377
|
+
return SIMPLEBLE_FAILURE;
|
378
|
+
}
|
379
|
+
|
380
|
+
// Clear the initial values for safety
|
381
|
+
*data = nullptr;
|
382
|
+
*data_length = 0;
|
383
|
+
|
384
|
+
// Perform the read operation
|
385
|
+
SimpleBLE::Safe::Peripheral* peripheral = (SimpleBLE::Safe::Peripheral*)handle;
|
386
|
+
std::optional<SimpleBLE::ByteArray> read_data = peripheral->read(SimpleBLE::BluetoothUUID(service.value),
|
387
|
+
SimpleBLE::BluetoothUUID(characteristic.value),
|
388
|
+
SimpleBLE::BluetoothUUID(descriptor.value));
|
389
|
+
|
390
|
+
// Early return if the operation failed
|
391
|
+
if (!read_data.has_value()) {
|
392
|
+
return SIMPLEBLE_FAILURE;
|
393
|
+
}
|
394
|
+
|
395
|
+
*data_length = read_data.value().size();
|
396
|
+
*data = static_cast<uint8_t*>(malloc(*data_length));
|
397
|
+
memcpy(*data, read_data.value().data(), *data_length);
|
398
|
+
|
399
|
+
return SIMPLEBLE_SUCCESS;
|
400
|
+
}
|
401
|
+
|
402
|
+
simpleble_err_t simpleble_peripheral_write_descriptor(simpleble_peripheral_t handle, simpleble_uuid_t service,
|
403
|
+
simpleble_uuid_t characteristic, simpleble_uuid_t descriptor,
|
404
|
+
const uint8_t* data, size_t data_length) {
|
405
|
+
if (handle == nullptr || data == nullptr) {
|
406
|
+
return SIMPLEBLE_FAILURE;
|
407
|
+
}
|
408
|
+
|
409
|
+
SimpleBLE::Safe::Peripheral* peripheral = (SimpleBLE::Safe::Peripheral*)handle;
|
410
|
+
|
411
|
+
bool success = peripheral->write(
|
412
|
+
SimpleBLE::BluetoothUUID(service.value), SimpleBLE::BluetoothUUID(characteristic.value),
|
413
|
+
SimpleBLE::BluetoothUUID(descriptor.value), SimpleBLE::ByteArray((const char*)data, data_length));
|
414
|
+
|
415
|
+
return success ? SIMPLEBLE_SUCCESS : SIMPLEBLE_FAILURE;
|
416
|
+
}
|
417
|
+
|
418
|
+
simpleble_err_t simpleble_peripheral_set_callback_on_connected(simpleble_peripheral_t handle,
|
419
|
+
void (*callback)(simpleble_peripheral_t, void*),
|
420
|
+
void* userdata) {
|
421
|
+
if (handle == nullptr || callback == nullptr) {
|
422
|
+
return SIMPLEBLE_FAILURE;
|
423
|
+
}
|
424
|
+
|
425
|
+
SimpleBLE::Safe::Peripheral* peripheral = (SimpleBLE::Safe::Peripheral*)handle;
|
426
|
+
|
427
|
+
bool success = peripheral->set_callback_on_connected([=]() { callback(handle, userdata); });
|
428
|
+
|
429
|
+
return success ? SIMPLEBLE_SUCCESS : SIMPLEBLE_FAILURE;
|
430
|
+
}
|
431
|
+
|
432
|
+
simpleble_err_t simpleble_peripheral_set_callback_on_disconnected(simpleble_peripheral_t handle,
|
433
|
+
void (*callback)(simpleble_peripheral_t, void*),
|
434
|
+
void* userdata) {
|
435
|
+
if (handle == nullptr || callback == nullptr) {
|
436
|
+
return SIMPLEBLE_FAILURE;
|
437
|
+
}
|
438
|
+
|
439
|
+
SimpleBLE::Safe::Peripheral* peripheral = (SimpleBLE::Safe::Peripheral*)handle;
|
440
|
+
|
441
|
+
bool success = peripheral->set_callback_on_disconnected([=]() { callback(handle, userdata); });
|
442
|
+
|
443
|
+
return success ? SIMPLEBLE_SUCCESS : SIMPLEBLE_FAILURE;
|
444
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#include <simpleble_c/utils.h>
|
2
|
+
|
3
|
+
#include <simpleble_c/types.h>
|
4
|
+
|
5
|
+
simpleble_os_t simpleble_get_operating_system() {
|
6
|
+
#ifdef _WIN32
|
7
|
+
return SIMPLEBLE_OS_WINDOWS;
|
8
|
+
#elif __APPLE__
|
9
|
+
return SIMPLEBLE_OS_MACOS;
|
10
|
+
#elif __linux__
|
11
|
+
return SIMPLEBLE_OS_LINUX;
|
12
|
+
#endif
|
13
|
+
}
|
14
|
+
|
15
|
+
const char* simpleble_get_version() { return SIMPLEBLE_VERSION; }
|