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,164 @@
|
|
1
|
+
#include <stdio.h>
|
2
|
+
#include <stdlib.h>
|
3
|
+
|
4
|
+
#ifdef _WIN32
|
5
|
+
#define SLEEP_SEC(x) _sleep(x * 1000)
|
6
|
+
#else
|
7
|
+
#include <unistd.h>
|
8
|
+
#define SLEEP_SEC(x) sleep(x)
|
9
|
+
#endif
|
10
|
+
|
11
|
+
#include "simpleble_c/simpleble.h"
|
12
|
+
|
13
|
+
static void print_buffer_hex(uint8_t* buf, size_t len, bool newline) {
|
14
|
+
for (size_t i = 0; i < len; i++) {
|
15
|
+
printf("%02X", buf[i]);
|
16
|
+
|
17
|
+
if (i < (len - 1)) {
|
18
|
+
printf(" ");
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
if (newline) {
|
23
|
+
printf("\n");
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
static void adapter_on_scan_start(simpleble_adapter_t adapter, void* userdata);
|
28
|
+
static void adapter_on_scan_stop(simpleble_adapter_t adapter, void* userdata);
|
29
|
+
static void adapter_on_scan_found(simpleble_adapter_t adapter, simpleble_peripheral_t peripheral, void* userdata);
|
30
|
+
static void adapter_on_scan_updated(simpleble_adapter_t adapter, simpleble_peripheral_t peripheral, void* userdata);
|
31
|
+
|
32
|
+
int main() {
|
33
|
+
// NOTE: It's necessary to call this function before any other to allow the
|
34
|
+
// underlying driver to run its initialization routine.
|
35
|
+
size_t adapter_count = simpleble_adapter_get_count();
|
36
|
+
if (adapter_count == 0) {
|
37
|
+
printf("No adapter was found.\n");
|
38
|
+
return 1;
|
39
|
+
}
|
40
|
+
|
41
|
+
// TODO: Allow the user to pick an adapter.
|
42
|
+
simpleble_adapter_t adapter = simpleble_adapter_get_handle(0);
|
43
|
+
if (adapter == NULL) {
|
44
|
+
printf("No adapter was found.\n");
|
45
|
+
return 1;
|
46
|
+
}
|
47
|
+
|
48
|
+
simpleble_adapter_set_callback_on_scan_start(adapter, adapter_on_scan_start, NULL);
|
49
|
+
simpleble_adapter_set_callback_on_scan_stop(adapter, adapter_on_scan_stop, NULL);
|
50
|
+
simpleble_adapter_set_callback_on_scan_found(adapter, adapter_on_scan_found, NULL);
|
51
|
+
simpleble_adapter_set_callback_on_scan_updated(adapter, adapter_on_scan_updated, NULL);
|
52
|
+
|
53
|
+
simpleble_adapter_scan_for(adapter, 5000);
|
54
|
+
|
55
|
+
// Sleep for an additional second before returning.
|
56
|
+
// If there are any detections during this period, it means that the
|
57
|
+
// internal peripheral took longer to stop than anticipated.
|
58
|
+
SLEEP_SEC(1);
|
59
|
+
|
60
|
+
size_t peripheral_count = simpleble_adapter_scan_get_results_count(adapter);
|
61
|
+
for (size_t peripheral_index = 0; peripheral_index < peripheral_count; peripheral_index++) {
|
62
|
+
simpleble_peripheral_t peripheral = simpleble_adapter_scan_get_results_handle(adapter, peripheral_index);
|
63
|
+
|
64
|
+
char* peripheral_identifier = simpleble_peripheral_identifier(peripheral);
|
65
|
+
char* peripheral_address = simpleble_peripheral_address(peripheral);
|
66
|
+
|
67
|
+
bool peripheral_connectable = false;
|
68
|
+
simpleble_peripheral_is_connectable(peripheral, &peripheral_connectable);
|
69
|
+
|
70
|
+
int16_t peripheral_rssi = simpleble_peripheral_rssi(peripheral);
|
71
|
+
|
72
|
+
printf("[%zu] %s [%s] %d dBm %s\n", peripheral_index, peripheral_identifier, peripheral_address,
|
73
|
+
peripheral_rssi, peripheral_connectable ? "Connectable" : "Non-Connectable");
|
74
|
+
|
75
|
+
size_t services_count = simpleble_peripheral_services_count(peripheral);
|
76
|
+
for (size_t service_index = 0; service_index < services_count; service_index++) {
|
77
|
+
simpleble_service_t service;
|
78
|
+
simpleble_peripheral_services_get(peripheral, service_index, &service);
|
79
|
+
|
80
|
+
printf(" Service UUID: %s\n", service.uuid.value);
|
81
|
+
printf(" Service data: ");
|
82
|
+
print_buffer_hex(service.data, service.data_length, true);
|
83
|
+
}
|
84
|
+
|
85
|
+
size_t manufacturer_data_count = simpleble_peripheral_manufacturer_data_count(peripheral);
|
86
|
+
for (size_t manuf_data_index = 0; manuf_data_index < manufacturer_data_count; manuf_data_index++) {
|
87
|
+
simpleble_manufacturer_data_t manuf_data;
|
88
|
+
simpleble_peripheral_manufacturer_data_get(peripheral, manuf_data_index, &manuf_data);
|
89
|
+
printf(" Manufacturer ID: %04X\n", manuf_data.manufacturer_id);
|
90
|
+
printf(" Manufacturer data: ");
|
91
|
+
print_buffer_hex(manuf_data.data, manuf_data.data_length, true);
|
92
|
+
}
|
93
|
+
|
94
|
+
// Let's not forget to release the associated handles and memory
|
95
|
+
simpleble_peripheral_release_handle(peripheral);
|
96
|
+
simpleble_free(peripheral_address);
|
97
|
+
simpleble_free(peripheral_identifier);
|
98
|
+
}
|
99
|
+
|
100
|
+
// Let's not forget to release the associated handle.
|
101
|
+
simpleble_adapter_release_handle(adapter);
|
102
|
+
|
103
|
+
return 0;
|
104
|
+
}
|
105
|
+
|
106
|
+
static void adapter_on_scan_start(simpleble_adapter_t adapter, void* userdata) {
|
107
|
+
char* identifier = simpleble_adapter_identifier(adapter);
|
108
|
+
|
109
|
+
if (identifier == NULL) {
|
110
|
+
return;
|
111
|
+
}
|
112
|
+
|
113
|
+
printf("Adapter %s started scanning.\n", identifier);
|
114
|
+
|
115
|
+
// Let's not forget to clear the allocated memory.
|
116
|
+
simpleble_free(identifier);
|
117
|
+
}
|
118
|
+
|
119
|
+
static void adapter_on_scan_stop(simpleble_adapter_t adapter, void* userdata) {
|
120
|
+
char* identifier = simpleble_adapter_identifier(adapter);
|
121
|
+
|
122
|
+
if (identifier == NULL) {
|
123
|
+
return;
|
124
|
+
}
|
125
|
+
|
126
|
+
printf("Adapter %s stopped scanning.\n", identifier);
|
127
|
+
|
128
|
+
// Let's not forget to clear the allocated memory.
|
129
|
+
simpleble_free(identifier);
|
130
|
+
}
|
131
|
+
|
132
|
+
static void adapter_on_scan_found(simpleble_adapter_t adapter, simpleble_peripheral_t peripheral, void* userdata) {
|
133
|
+
char* adapter_identifier = simpleble_adapter_identifier(adapter);
|
134
|
+
char* peripheral_identifier = simpleble_peripheral_identifier(peripheral);
|
135
|
+
char* peripheral_address = simpleble_peripheral_address(peripheral);
|
136
|
+
|
137
|
+
if (adapter_identifier == NULL || peripheral_identifier == NULL || peripheral_address == NULL) {
|
138
|
+
return;
|
139
|
+
}
|
140
|
+
|
141
|
+
printf("Adapter %s found device: %s [%s]\n", adapter_identifier, peripheral_identifier, peripheral_address);
|
142
|
+
|
143
|
+
// Let's not forget to release the associated handles and memory
|
144
|
+
simpleble_peripheral_release_handle(peripheral);
|
145
|
+
simpleble_free(peripheral_address);
|
146
|
+
simpleble_free(peripheral_identifier);
|
147
|
+
}
|
148
|
+
|
149
|
+
static void adapter_on_scan_updated(simpleble_adapter_t adapter, simpleble_peripheral_t peripheral, void* userdata) {
|
150
|
+
char* adapter_identifier = simpleble_adapter_identifier(adapter);
|
151
|
+
char* peripheral_identifier = simpleble_peripheral_identifier(peripheral);
|
152
|
+
char* peripheral_address = simpleble_peripheral_address(peripheral);
|
153
|
+
|
154
|
+
if (adapter_identifier == NULL || peripheral_identifier == NULL || peripheral_address == NULL) {
|
155
|
+
return;
|
156
|
+
}
|
157
|
+
|
158
|
+
printf("Adapter %s updated device: %s [%s]\n", adapter_identifier, peripheral_identifier, peripheral_address);
|
159
|
+
|
160
|
+
// Let's not forget to release the associated handles and memory
|
161
|
+
simpleble_peripheral_release_handle(peripheral);
|
162
|
+
simpleble_free(peripheral_address);
|
163
|
+
simpleble_free(peripheral_identifier);
|
164
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#include <simpledbus/base/Connection.h>
|
2
|
+
#include <simpledbus/base/Message.h>
|
3
|
+
|
4
|
+
int main(int argc, char* argv[]) {
|
5
|
+
SimpleDBus::Connection conn(DBUS_BUS_SESSION);
|
6
|
+
conn.init();
|
7
|
+
|
8
|
+
auto msg = SimpleDBus::Message::create_method_call(
|
9
|
+
"org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", "Notify");
|
10
|
+
|
11
|
+
// For information on these arguments, have a look at the interface definition.
|
12
|
+
msg.append_argument(SimpleDBus::Holder::create_string("SimpleDBUS Example"), DBUS_TYPE_STRING_AS_STRING);
|
13
|
+
msg.append_argument(SimpleDBus::Holder::create_uint32(42), DBUS_TYPE_UINT32_AS_STRING);
|
14
|
+
msg.append_argument(SimpleDBus::Holder::create_string("ubuntu-logo"), DBUS_TYPE_STRING_AS_STRING);
|
15
|
+
msg.append_argument(SimpleDBus::Holder::create_string("SimpleDBus Notify Summary"), DBUS_TYPE_STRING_AS_STRING);
|
16
|
+
msg.append_argument(SimpleDBus::Holder::create_string("This is a SimpleDBus notification."),
|
17
|
+
DBUS_TYPE_STRING_AS_STRING);
|
18
|
+
msg.append_argument(SimpleDBus::Holder::create_array(), "as");
|
19
|
+
msg.append_argument(SimpleDBus::Holder::create_dict(), "a{sv}");
|
20
|
+
msg.append_argument(SimpleDBus::Holder::create_int32(5000), DBUS_TYPE_INT32_AS_STRING);
|
21
|
+
conn.send_with_reply_and_block(msg);
|
22
|
+
|
23
|
+
return 0;
|
24
|
+
}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#include <gtest/gtest.h>
|
2
|
+
#include <chrono>
|
3
|
+
#include <thread>
|
4
|
+
#include "simpleble/SimpleBLE.h"
|
5
|
+
|
6
|
+
TEST(BLESanityTest, FullSequentialTest) {
|
7
|
+
// Initialize adapter
|
8
|
+
auto adapters = SimpleBLE::Adapter::get_adapters();
|
9
|
+
ASSERT_FALSE(adapters.empty()) << "No Bluetooth adapters found";
|
10
|
+
SimpleBLE::Adapter adapter = adapters[0];
|
11
|
+
EXPECT_TRUE(adapter.bluetooth_enabled());
|
12
|
+
|
13
|
+
// Scan for device
|
14
|
+
SimpleBLE::Peripheral target_peripheral;
|
15
|
+
const std::string TARGET_MAC = "11:22:33:44:55:66"; // Replace with your device's MAC
|
16
|
+
const std::string TARGET_NAME = "SimpleBLE DUT";
|
17
|
+
bool device_found = false;
|
18
|
+
|
19
|
+
adapter.set_callback_on_scan_found([&](SimpleBLE::Peripheral peripheral) {
|
20
|
+
std::cout << "Found device: " << peripheral.identifier() << " (" << peripheral.address() << ")" << std::endl;
|
21
|
+
|
22
|
+
if (peripheral.address() == TARGET_MAC || peripheral.identifier() == TARGET_NAME) {
|
23
|
+
target_peripheral = peripheral;
|
24
|
+
device_found = true;
|
25
|
+
}
|
26
|
+
});
|
27
|
+
|
28
|
+
adapter.scan_for(10000);
|
29
|
+
ASSERT_TRUE(device_found) << "Target device not found during scan";
|
30
|
+
EXPECT_EQ(target_peripheral.identifier(), TARGET_NAME);
|
31
|
+
EXPECT_TRUE(target_peripheral.is_connectable());
|
32
|
+
|
33
|
+
// Connect and check services
|
34
|
+
ASSERT_NO_THROW(target_peripheral.connect()) << "Failed to connect to target device";
|
35
|
+
|
36
|
+
auto services = target_peripheral.services();
|
37
|
+
EXPECT_FALSE(services.empty()) << "No services found on connected device";
|
38
|
+
|
39
|
+
// Print services for debugging
|
40
|
+
for (auto& service : services) {
|
41
|
+
std::cout << "Found service: " << service.uuid() << std::endl;
|
42
|
+
}
|
43
|
+
|
44
|
+
// Cleanup
|
45
|
+
if (target_peripheral.is_connected()) {
|
46
|
+
target_peripheral.disconnect();
|
47
|
+
}
|
48
|
+
}
|
@@ -0,0 +1,102 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include <functional>
|
4
|
+
#include <memory>
|
5
|
+
#include <string>
|
6
|
+
#include <vector>
|
7
|
+
|
8
|
+
#include <simpleble/export.h>
|
9
|
+
|
10
|
+
#include <simpleble/Exceptions.h>
|
11
|
+
#include <simpleble/Peripheral.h>
|
12
|
+
#include <simpleble/Types.h>
|
13
|
+
|
14
|
+
namespace SimpleBLE {
|
15
|
+
|
16
|
+
class AdapterBase;
|
17
|
+
|
18
|
+
/**
|
19
|
+
* Bluetooth Adapter.
|
20
|
+
*
|
21
|
+
* A default-constructed Adapter object is not initialized. Calling any method
|
22
|
+
* other than `initialized()` on an uninitialized Adapter will throw an exception
|
23
|
+
* of type `SimpleBLE::NotInitialized`.
|
24
|
+
*
|
25
|
+
* NOTE: This class is intended to be used by the user only. Library developers
|
26
|
+
* should use shared pointers to `AdapterBase` instead.
|
27
|
+
*/
|
28
|
+
class SIMPLEBLE_EXPORT Adapter {
|
29
|
+
public:
|
30
|
+
Adapter() = default;
|
31
|
+
virtual ~Adapter() = default;
|
32
|
+
|
33
|
+
bool initialized() const;
|
34
|
+
|
35
|
+
/**
|
36
|
+
* Retrieve the underlying OS object/handle.
|
37
|
+
*
|
38
|
+
* For certain compatibility with external libraries, we sometimes need to
|
39
|
+
* expose the actual OS handle to the user. This is particularly important
|
40
|
+
* for MacOS right now.
|
41
|
+
*/
|
42
|
+
void* underlying() const;
|
43
|
+
|
44
|
+
std::string identifier();
|
45
|
+
BluetoothAddress address();
|
46
|
+
|
47
|
+
/**
|
48
|
+
* Control the power state of the adapter.
|
49
|
+
*
|
50
|
+
* NOTE: The power on/off functionality is only supported on Windows and Linux (implementation pending).
|
51
|
+
* On other platforms, this method will do nothing.
|
52
|
+
* NOTE: Callbacks are currently a placeholder for future implementation.
|
53
|
+
*/
|
54
|
+
void power_on();
|
55
|
+
void power_off();
|
56
|
+
bool is_powered();
|
57
|
+
void set_callback_on_power_on(std::function<void()> on_power_on);
|
58
|
+
void set_callback_on_power_off(std::function<void()> on_power_off);
|
59
|
+
|
60
|
+
void scan_start();
|
61
|
+
void scan_stop();
|
62
|
+
void scan_for(int timeout_ms);
|
63
|
+
bool scan_is_active();
|
64
|
+
std::vector<Peripheral> scan_get_results();
|
65
|
+
|
66
|
+
void set_callback_on_scan_start(std::function<void()> on_scan_start);
|
67
|
+
void set_callback_on_scan_stop(std::function<void()> on_scan_stop);
|
68
|
+
void set_callback_on_scan_updated(std::function<void(Peripheral)> on_scan_updated);
|
69
|
+
void set_callback_on_scan_found(std::function<void(Peripheral)> on_scan_found);
|
70
|
+
|
71
|
+
/**
|
72
|
+
* Retrieve a list of all paired peripherals.
|
73
|
+
*
|
74
|
+
* NOTE:This method is currently only supported by the Linux, Windows and Android backends.
|
75
|
+
*/
|
76
|
+
std::vector<Peripheral> get_paired_peripherals();
|
77
|
+
|
78
|
+
/**
|
79
|
+
* Retrieve a list of all connected peripherals.
|
80
|
+
*
|
81
|
+
* NOTE: This method is currently only supported by the Windows backend. (More backends coming soon.)
|
82
|
+
*/
|
83
|
+
std::vector<Peripheral> get_connected_peripherals();
|
84
|
+
|
85
|
+
static bool bluetooth_enabled();
|
86
|
+
|
87
|
+
/**
|
88
|
+
* Fetches a list of all available adapters from all available backends.
|
89
|
+
*
|
90
|
+
* This will cause backends to be instantiated/initialized and adapters
|
91
|
+
* too.
|
92
|
+
*/
|
93
|
+
static std::vector<Adapter> get_adapters();
|
94
|
+
|
95
|
+
protected:
|
96
|
+
AdapterBase* operator->();
|
97
|
+
const AdapterBase* operator->() const;
|
98
|
+
|
99
|
+
std::shared_ptr<AdapterBase> internal_;
|
100
|
+
};
|
101
|
+
|
102
|
+
} // namespace SimpleBLE
|
@@ -0,0 +1,58 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include <simpleble/export.h>
|
4
|
+
|
5
|
+
#include <simpleble/Adapter.h>
|
6
|
+
#include <simpleble/PeripheralSafe.h>
|
7
|
+
#include <memory>
|
8
|
+
#include <optional>
|
9
|
+
#include <vector>
|
10
|
+
|
11
|
+
namespace SimpleBLE {
|
12
|
+
|
13
|
+
namespace Safe {
|
14
|
+
|
15
|
+
/**
|
16
|
+
* Wrapper around the Adapter class that provides a noexcept interface.
|
17
|
+
*
|
18
|
+
* We use instances of this class directly and not through shared_ptr because
|
19
|
+
* this is just a wrapper around the Adapter class, which is already managed by
|
20
|
+
* shared_ptr.
|
21
|
+
*/
|
22
|
+
class SIMPLEBLE_EXPORT Adapter {
|
23
|
+
public:
|
24
|
+
Adapter(SimpleBLE::Adapter& adapter);
|
25
|
+
Adapter(SimpleBLE::Adapter&& adapter);
|
26
|
+
virtual ~Adapter() = default;
|
27
|
+
|
28
|
+
std::optional<std::string> identifier() noexcept;
|
29
|
+
std::optional<BluetoothAddress> address() noexcept;
|
30
|
+
|
31
|
+
bool scan_start() noexcept;
|
32
|
+
bool scan_stop() noexcept;
|
33
|
+
bool scan_for(int timeout_ms) noexcept;
|
34
|
+
std::optional<bool> scan_is_active() noexcept;
|
35
|
+
std::optional<std::vector<SimpleBLE::Safe::Peripheral>> scan_get_results() noexcept;
|
36
|
+
|
37
|
+
bool set_callback_on_scan_start(std::function<void()> on_scan_start) noexcept;
|
38
|
+
bool set_callback_on_scan_stop(std::function<void()> on_scan_stop) noexcept;
|
39
|
+
bool set_callback_on_scan_updated(std::function<void(SimpleBLE::Safe::Peripheral)> on_scan_updated) noexcept;
|
40
|
+
bool set_callback_on_scan_found(std::function<void(SimpleBLE::Safe::Peripheral)> on_scan_found) noexcept;
|
41
|
+
|
42
|
+
std::optional<std::vector<SimpleBLE::Safe::Peripheral>> get_paired_peripherals() noexcept;
|
43
|
+
|
44
|
+
static std::optional<bool> bluetooth_enabled() noexcept;
|
45
|
+
static std::optional<std::vector<SimpleBLE::Safe::Adapter>> get_adapters() noexcept;
|
46
|
+
|
47
|
+
/**
|
48
|
+
* Cast to the underlying adapter object.
|
49
|
+
*/
|
50
|
+
operator SimpleBLE::Adapter() const noexcept;
|
51
|
+
|
52
|
+
protected:
|
53
|
+
SimpleBLE::Adapter internal_;
|
54
|
+
};
|
55
|
+
|
56
|
+
} // namespace Safe
|
57
|
+
|
58
|
+
} // namespace SimpleBLE
|
@@ -0,0 +1,50 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include <simpleble/export.h>
|
4
|
+
|
5
|
+
#if __APPLE__
|
6
|
+
#include "TargetConditionals.h"
|
7
|
+
#endif
|
8
|
+
|
9
|
+
/**
|
10
|
+
* Advanced Features
|
11
|
+
*
|
12
|
+
* The functions presented in this namespace are OS-specific backdoors that are
|
13
|
+
* not part of the standard SimpleBLE API, which allow the user to access
|
14
|
+
* low-level details of the implementation for advanced use cases.
|
15
|
+
*
|
16
|
+
* These functions should be used with caution.
|
17
|
+
*/
|
18
|
+
|
19
|
+
#if defined(_WIN32)
|
20
|
+
namespace SimpleBLE::Advanced::Windows {}
|
21
|
+
|
22
|
+
#endif
|
23
|
+
|
24
|
+
#if TARGET_OS_OSX
|
25
|
+
namespace SimpleBLE::Advanced::MacOS {}
|
26
|
+
|
27
|
+
#endif
|
28
|
+
|
29
|
+
#if TARGET_OS_IOS
|
30
|
+
namespace SimpleBLE::Advanced::iOS {}
|
31
|
+
|
32
|
+
#endif
|
33
|
+
|
34
|
+
#if defined(__ANDROID__)
|
35
|
+
|
36
|
+
#include <jni.h>
|
37
|
+
|
38
|
+
namespace SimpleBLE::Advanced::Android {
|
39
|
+
|
40
|
+
JavaVM* SIMPLEBLE_EXPORT get_jvm();
|
41
|
+
void SIMPLEBLE_EXPORT set_jvm(JavaVM* jvm);
|
42
|
+
|
43
|
+
} // namespace SimpleBLE::Advanced::Android
|
44
|
+
|
45
|
+
#endif
|
46
|
+
|
47
|
+
#if defined(__linux__) && !defined(__ANDROID__)
|
48
|
+
namespace SimpleBLE::Advanced::Linux {}
|
49
|
+
|
50
|
+
#endif
|
@@ -0,0 +1,39 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include <memory>
|
4
|
+
|
5
|
+
#include <simpleble/export.h>
|
6
|
+
|
7
|
+
#include <simpleble/Descriptor.h>
|
8
|
+
#include <simpleble/Exceptions.h>
|
9
|
+
#include <simpleble/Types.h>
|
10
|
+
|
11
|
+
namespace SimpleBLE {
|
12
|
+
|
13
|
+
class CharacteristicBase;
|
14
|
+
|
15
|
+
class SIMPLEBLE_EXPORT Characteristic {
|
16
|
+
public:
|
17
|
+
Characteristic() = default;
|
18
|
+
virtual ~Characteristic() = default;
|
19
|
+
|
20
|
+
bool initialized() const;
|
21
|
+
|
22
|
+
BluetoothUUID uuid();
|
23
|
+
std::vector<Descriptor> descriptors();
|
24
|
+
std::vector<std::string> capabilities();
|
25
|
+
|
26
|
+
bool can_read();
|
27
|
+
bool can_write_request();
|
28
|
+
bool can_write_command();
|
29
|
+
bool can_notify();
|
30
|
+
bool can_indicate();
|
31
|
+
|
32
|
+
protected:
|
33
|
+
CharacteristicBase* operator->();
|
34
|
+
const CharacteristicBase* operator->() const;
|
35
|
+
|
36
|
+
std::shared_ptr<CharacteristicBase> internal_;
|
37
|
+
};
|
38
|
+
|
39
|
+
} // namespace SimpleBLE
|
@@ -0,0 +1,55 @@
|
|
1
|
+
#pragma once
|
2
|
+
#include <chrono>
|
3
|
+
|
4
|
+
namespace SimpleBLE {
|
5
|
+
namespace Config {
|
6
|
+
namespace SimpleBluez {
|
7
|
+
inline static std::chrono::steady_clock::duration connection_timeout = std::chrono::seconds(2);
|
8
|
+
inline static std::chrono::steady_clock::duration disconnection_timeout = std::chrono::seconds(1);
|
9
|
+
|
10
|
+
static void reset() {
|
11
|
+
connection_timeout = std::chrono::seconds(2);
|
12
|
+
disconnection_timeout = std::chrono::seconds(1);
|
13
|
+
}
|
14
|
+
}
|
15
|
+
|
16
|
+
namespace WinRT {
|
17
|
+
inline static bool experimental_use_own_mta_apartment = true;
|
18
|
+
inline static bool experimental_reinitialize_winrt_apartment_on_main_thread = false;
|
19
|
+
|
20
|
+
static void reset() {
|
21
|
+
experimental_use_own_mta_apartment = true;
|
22
|
+
experimental_reinitialize_winrt_apartment_on_main_thread = false;
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
namespace CoreBluetooth {
|
27
|
+
static void reset() {}
|
28
|
+
}
|
29
|
+
|
30
|
+
namespace Android {
|
31
|
+
enum class ConnectionPriorityRequest {
|
32
|
+
DISABLED = -1,
|
33
|
+
BALANCED = 0,
|
34
|
+
HIGH = 1,
|
35
|
+
LOW_POWER = 2,
|
36
|
+
DCK = 3
|
37
|
+
};
|
38
|
+
|
39
|
+
inline static ConnectionPriorityRequest connection_priority_request = ConnectionPriorityRequest::DISABLED;
|
40
|
+
|
41
|
+
static void reset() {
|
42
|
+
connection_priority_request = ConnectionPriorityRequest::DISABLED;
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
namespace Base {
|
47
|
+
static void reset_all() {
|
48
|
+
SimpleBluez::reset();
|
49
|
+
WinRT::reset();
|
50
|
+
CoreBluetooth::reset();
|
51
|
+
Android::reset();
|
52
|
+
}
|
53
|
+
}
|
54
|
+
} // namespace Config
|
55
|
+
} // namespace SimpleBLE
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include <memory>
|
4
|
+
|
5
|
+
#include <simpleble/export.h>
|
6
|
+
|
7
|
+
#include <simpleble/Exceptions.h>
|
8
|
+
#include <simpleble/Types.h>
|
9
|
+
|
10
|
+
namespace SimpleBLE {
|
11
|
+
|
12
|
+
class DescriptorBase;
|
13
|
+
|
14
|
+
class SIMPLEBLE_EXPORT Descriptor {
|
15
|
+
public:
|
16
|
+
Descriptor() = default;
|
17
|
+
virtual ~Descriptor() = default;
|
18
|
+
|
19
|
+
bool initialized() const;
|
20
|
+
|
21
|
+
BluetoothUUID uuid();
|
22
|
+
|
23
|
+
protected:
|
24
|
+
DescriptorBase* operator->();
|
25
|
+
const DescriptorBase* operator->() const;
|
26
|
+
|
27
|
+
std::shared_ptr<DescriptorBase> internal_;
|
28
|
+
};
|
29
|
+
|
30
|
+
} // namespace SimpleBLE
|
@@ -0,0 +1,72 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include <stdexcept>
|
4
|
+
#include <string>
|
5
|
+
|
6
|
+
#include <simpleble/export.h>
|
7
|
+
|
8
|
+
#include "Types.h"
|
9
|
+
|
10
|
+
namespace SimpleBLE {
|
11
|
+
|
12
|
+
namespace Exception {
|
13
|
+
|
14
|
+
class SIMPLEBLE_EXPORT BaseException : public std::runtime_error {
|
15
|
+
public:
|
16
|
+
BaseException(const std::string& __arg) : std::runtime_error(__arg) {}
|
17
|
+
};
|
18
|
+
|
19
|
+
class SIMPLEBLE_EXPORT NotInitialized : public BaseException {
|
20
|
+
public:
|
21
|
+
NotInitialized();
|
22
|
+
};
|
23
|
+
|
24
|
+
class SIMPLEBLE_EXPORT NotConnected : public BaseException {
|
25
|
+
public:
|
26
|
+
NotConnected();
|
27
|
+
};
|
28
|
+
|
29
|
+
class SIMPLEBLE_EXPORT InvalidReference : public BaseException {
|
30
|
+
public:
|
31
|
+
InvalidReference();
|
32
|
+
};
|
33
|
+
|
34
|
+
class SIMPLEBLE_EXPORT ServiceNotFound : public BaseException {
|
35
|
+
public:
|
36
|
+
ServiceNotFound(BluetoothUUID uuid);
|
37
|
+
};
|
38
|
+
|
39
|
+
class SIMPLEBLE_EXPORT CharacteristicNotFound : public BaseException {
|
40
|
+
public:
|
41
|
+
CharacteristicNotFound(BluetoothUUID uuid);
|
42
|
+
};
|
43
|
+
|
44
|
+
class SIMPLEBLE_EXPORT DescriptorNotFound : public BaseException {
|
45
|
+
public:
|
46
|
+
DescriptorNotFound(BluetoothUUID uuid);
|
47
|
+
};
|
48
|
+
|
49
|
+
class SIMPLEBLE_EXPORT OperationNotSupported : public BaseException {
|
50
|
+
public:
|
51
|
+
OperationNotSupported();
|
52
|
+
};
|
53
|
+
|
54
|
+
class SIMPLEBLE_EXPORT OperationFailed : public BaseException {
|
55
|
+
public:
|
56
|
+
OperationFailed();
|
57
|
+
OperationFailed(const std::string& err_msg);
|
58
|
+
};
|
59
|
+
|
60
|
+
class SIMPLEBLE_EXPORT WinRTException : public BaseException {
|
61
|
+
public:
|
62
|
+
WinRTException(int32_t err_code, const std::string& err_msg);
|
63
|
+
};
|
64
|
+
|
65
|
+
class SIMPLEBLE_EXPORT CoreBluetoothException : public BaseException {
|
66
|
+
public:
|
67
|
+
CoreBluetoothException(const std::string& err_msg);
|
68
|
+
};
|
69
|
+
|
70
|
+
} // namespace Exception
|
71
|
+
|
72
|
+
} // namespace SimpleBLE
|