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,31 @@
|
|
1
|
+
#include <fmt/core.h>
|
2
|
+
#include <simpleble/Exceptions.h>
|
3
|
+
|
4
|
+
using namespace SimpleBLE;
|
5
|
+
using namespace SimpleBLE::Exception;
|
6
|
+
|
7
|
+
NotInitialized::NotInitialized() : BaseException("Object has not been initialized.") {}
|
8
|
+
|
9
|
+
NotConnected::NotConnected() : BaseException("Peripheral is not connected.") {}
|
10
|
+
|
11
|
+
InvalidReference::InvalidReference() : BaseException("Underlying reference to object is invalid.") {}
|
12
|
+
|
13
|
+
ServiceNotFound::ServiceNotFound(BluetoothUUID uuid) : BaseException("Service with UUID " + uuid + " not found.") {}
|
14
|
+
|
15
|
+
CharacteristicNotFound::CharacteristicNotFound(BluetoothUUID uuid)
|
16
|
+
: BaseException("Characteristic with UUID " + uuid + " not found") {}
|
17
|
+
|
18
|
+
DescriptorNotFound::DescriptorNotFound(BluetoothUUID uuid)
|
19
|
+
: BaseException("Descriptor with UUID " + uuid + " not found") {}
|
20
|
+
|
21
|
+
OperationNotSupported::OperationNotSupported() : BaseException("The requested operation is not supported.") {}
|
22
|
+
|
23
|
+
OperationFailed::OperationFailed() : BaseException("The requested operation has failed.") {}
|
24
|
+
|
25
|
+
OperationFailed::OperationFailed(const std::string& err_msg) : BaseException("Operation Failed: " + err_msg) {}
|
26
|
+
|
27
|
+
WinRTException::WinRTException(int32_t err_code, const std::string& err_msg)
|
28
|
+
: BaseException(fmt::format("WinRT Exception. Error code {}: {}", err_code, err_msg)) {}
|
29
|
+
|
30
|
+
CoreBluetoothException::CoreBluetoothException(const std::string& err_msg)
|
31
|
+
: BaseException(fmt::format("CoreBluetooth Exception: {}", err_msg)) {}
|
@@ -0,0 +1,136 @@
|
|
1
|
+
#include "simpleble/Logging.h"
|
2
|
+
|
3
|
+
#include <fmt/chrono.h>
|
4
|
+
#include <fmt/core.h>
|
5
|
+
#include <ctime>
|
6
|
+
#include <fstream>
|
7
|
+
#include <mutex>
|
8
|
+
|
9
|
+
using namespace SimpleBLE::Logging;
|
10
|
+
|
11
|
+
Logger* Logger::get() {
|
12
|
+
static std::mutex get_mutex; // Static mutex to ensure thread safety when accessing the logger
|
13
|
+
std::scoped_lock lock(get_mutex); // Unlock the mutex on function return
|
14
|
+
static Logger instance; // Static instance of the logger to ensure proper lifecycle management
|
15
|
+
return &instance;
|
16
|
+
}
|
17
|
+
|
18
|
+
Logger::Logger() { log_default_stdout(); }
|
19
|
+
|
20
|
+
Logger::~Logger() {}
|
21
|
+
|
22
|
+
void Logger::set_level(Level level) {
|
23
|
+
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
24
|
+
level_ = level;
|
25
|
+
}
|
26
|
+
|
27
|
+
Level Logger::get_level() {
|
28
|
+
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
29
|
+
return level_;
|
30
|
+
}
|
31
|
+
|
32
|
+
void Logger::set_callback(Callback callback) {
|
33
|
+
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
34
|
+
callback_ = callback;
|
35
|
+
}
|
36
|
+
|
37
|
+
bool Logger::has_callback() {
|
38
|
+
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
39
|
+
return callback_ != nullptr;
|
40
|
+
}
|
41
|
+
|
42
|
+
void Logger::log(Level level, const std::string& module, const std::string& file, uint32_t line,
|
43
|
+
const std::string& function, const std::string& message) {
|
44
|
+
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
45
|
+
|
46
|
+
if (level <= level_ && callback_ != nullptr) {
|
47
|
+
try {
|
48
|
+
callback_(level, module, file, line, function, message);
|
49
|
+
} catch (...) {
|
50
|
+
// Clearly, if the logging callback throws an exception, we should not crash.
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
std::string Logger::level_to_str(Level level) {
|
56
|
+
std::string level_str;
|
57
|
+
switch (level) {
|
58
|
+
case Level::Verbose:
|
59
|
+
level_str = "VERBOSE";
|
60
|
+
break;
|
61
|
+
case Level::Debug:
|
62
|
+
level_str = "DEBUG";
|
63
|
+
break;
|
64
|
+
case Level::Info:
|
65
|
+
level_str = "INFO";
|
66
|
+
break;
|
67
|
+
case Level::Warn:
|
68
|
+
level_str = "WARNING";
|
69
|
+
break;
|
70
|
+
case Level::Error:
|
71
|
+
level_str = "ERROR";
|
72
|
+
break;
|
73
|
+
case Level::Fatal:
|
74
|
+
level_str = "FATAL";
|
75
|
+
break;
|
76
|
+
case Level::None:
|
77
|
+
level_str = "NONE";
|
78
|
+
break;
|
79
|
+
}
|
80
|
+
return level_str;
|
81
|
+
}
|
82
|
+
|
83
|
+
void Logger::log_default_stdout() {
|
84
|
+
set_callback([](Level level, const std::string& module, const std::string& file, uint32_t line,
|
85
|
+
const std::string& function, const std::string& message) {
|
86
|
+
std::string level_str = level_to_str(level);
|
87
|
+
fmt::print("[{}] {}: {}:{} in {}: {}\n", level_str, module, file, line, function, message);
|
88
|
+
});
|
89
|
+
}
|
90
|
+
|
91
|
+
void Logger::log_default_file() {
|
92
|
+
std::time_t t = std::time(nullptr);
|
93
|
+
std::string date_time_str = fmt::format("{:%Y-%m-%d_%H-%M-%S}", fmt::localtime(t));
|
94
|
+
std::string filename = fmt::format("simpleble_{}", date_time_str);
|
95
|
+
log_default_file(filename);
|
96
|
+
}
|
97
|
+
|
98
|
+
void Logger::log_default_file(const std::string path) {
|
99
|
+
set_callback([=](Level level, const std::string& module, const std::string& file, uint32_t line,
|
100
|
+
const std::string& function, const std::string& message) {
|
101
|
+
std::string level_str = level_to_str(level);
|
102
|
+
std::string log_message = fmt::format("[{}] {}: {}:{} in {}: {}\n", level_str, module, file, line, function,
|
103
|
+
message);
|
104
|
+
|
105
|
+
std::ofstream outfile;
|
106
|
+
outfile.open(path, std::ios_base::app); // open the file in append mode
|
107
|
+
outfile << log_message;
|
108
|
+
outfile.close();
|
109
|
+
});
|
110
|
+
}
|
111
|
+
|
112
|
+
#if defined(__linux__) || defined(__APPLE__)
|
113
|
+
// For Linux and MacOS, implement a strong definition of the logfwd receive library.
|
114
|
+
#include "kvn/logfwd.hpp"
|
115
|
+
|
116
|
+
// clang-format off
|
117
|
+
void logfwd::receive(
|
118
|
+
logfwd::level level,
|
119
|
+
const std::string& module,
|
120
|
+
const std::string& file,
|
121
|
+
uint32_t line,
|
122
|
+
const std::string& function,
|
123
|
+
const std::string& message) {
|
124
|
+
|
125
|
+
// Forward logs from internal modules into the SimpleBLE logger.
|
126
|
+
Logger::get()->log(
|
127
|
+
static_cast<Level>(level),
|
128
|
+
fmt::format("SimpleBLE->{}", module),
|
129
|
+
file,
|
130
|
+
line,
|
131
|
+
function,
|
132
|
+
message);
|
133
|
+
}
|
134
|
+
// clang-format on
|
135
|
+
|
136
|
+
#endif
|
@@ -0,0 +1,85 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include <fmt/core.h>
|
4
|
+
#include "simpleble/Logging.h"
|
5
|
+
|
6
|
+
#define SIMPLEBLE_LOG_LEVEL_NONE 0
|
7
|
+
#define SIMPLEBLE_LOG_LEVEL_FATAL 1
|
8
|
+
#define SIMPLEBLE_LOG_LEVEL_ERROR 2
|
9
|
+
#define SIMPLEBLE_LOG_LEVEL_WARN 3
|
10
|
+
#define SIMPLEBLE_LOG_LEVEL_INFO 4
|
11
|
+
#define SIMPLEBLE_LOG_LEVEL_DEBUG 5
|
12
|
+
#define SIMPLEBLE_LOG_LEVEL_VERBOSE 6
|
13
|
+
|
14
|
+
#ifndef SIMPLEBLE_LOG_LEVEL
|
15
|
+
#define SIMPLEBLE_LOG_LEVEL SIMPLEBLE_LOG_LEVEL_VERBOSE
|
16
|
+
#endif
|
17
|
+
|
18
|
+
// clang-format off
|
19
|
+
|
20
|
+
#if SIMPLEBLE_LOG_LEVEL == SIMPLEBLE_LOG_LEVEL_VERBOSE
|
21
|
+
|
22
|
+
#define SIMPLEBLE_LOG_FATAL(msg) SimpleBLE::Logging::Logger::get()->log(SimpleBLE::Logging::Level::Fatal, "SimpleBLE", __FILE__, __LINE__, __func__, msg)
|
23
|
+
#define SIMPLEBLE_LOG_ERROR(msg) SimpleBLE::Logging::Logger::get()->log(SimpleBLE::Logging::Level::Error, "SimpleBLE", __FILE__, __LINE__, __func__, msg)
|
24
|
+
#define SIMPLEBLE_LOG_WARN(msg) SimpleBLE::Logging::Logger::get()->log(SimpleBLE::Logging::Level::Warn, "SimpleBLE", __FILE__, __LINE__, __func__, msg)
|
25
|
+
#define SIMPLEBLE_LOG_INFO(msg) SimpleBLE::Logging::Logger::get()->log(SimpleBLE::Logging::Level::Info, "SimpleBLE", __FILE__, __LINE__, __func__, msg)
|
26
|
+
#define SIMPLEBLE_LOG_DEBUG(msg) SimpleBLE::Logging::Logger::get()->log(SimpleBLE::Logging::Level::Debug, "SimpleBLE", __FILE__, __LINE__, __func__, msg)
|
27
|
+
#define SIMPLEBLE_LOG_VERBOSE(msg) SimpleBLE::Logging::Logger::get()->log(SimpleBLE::Logging::Level::VERBOSE, "SimpleBLE", __FILE__, __LINE__, __func__, msg)
|
28
|
+
|
29
|
+
#elif SIMPLEBLE_LOG_LEVEL == SIMPLEBLE_LOG_LEVEL_DEBUG
|
30
|
+
|
31
|
+
#define SIMPLEBLE_LOG_FATAL(msg) SimpleBLE::Logging::Logger::get()->log(SimpleBLE::Logging::Level::Fatal, "SimpleBLE", __FILE__, __LINE__, __func__, msg)
|
32
|
+
#define SIMPLEBLE_LOG_ERROR(msg) SimpleBLE::Logging::Logger::get()->log(SimpleBLE::Logging::Level::Error, "SimpleBLE", __FILE__, __LINE__, __func__, msg)
|
33
|
+
#define SIMPLEBLE_LOG_WARN(msg) SimpleBLE::Logging::Logger::get()->log(SimpleBLE::Logging::Level::Warn, "SimpleBLE", __FILE__, __LINE__, __func__, msg)
|
34
|
+
#define SIMPLEBLE_LOG_INFO(msg) SimpleBLE::Logging::Logger::get()->log(SimpleBLE::Logging::Level::Info, "SimpleBLE", __FILE__, __LINE__, __func__, msg)
|
35
|
+
#define SIMPLEBLE_LOG_DEBUG(msg) SimpleBLE::Logging::Logger::get()->log(SimpleBLE::Logging::Level::Debug, "SimpleBLE", __FILE__, __LINE__, __func__, msg)
|
36
|
+
#define SIMPLEBLE_LOG_VERBOSE(msg)
|
37
|
+
|
38
|
+
#elif SIMPLEBLE_LOG_LEVEL == SIMPLEBLE_LOG_LEVEL_INFO
|
39
|
+
|
40
|
+
#define SIMPLEBLE_LOG_FATAL(msg) SimpleBLE::Logging::Logger::get()->log(SimpleBLE::Logging::Level::Fatal, "SimpleBLE", __FILE__, __LINE__, __func__, msg)
|
41
|
+
#define SIMPLEBLE_LOG_ERROR(msg) SimpleBLE::Logging::Logger::get()->log(SimpleBLE::Logging::Level::Error, "SimpleBLE", __FILE__, __LINE__, __func__, msg)
|
42
|
+
#define SIMPLEBLE_LOG_WARN(msg) SimpleBLE::Logging::Logger::get()->log(SimpleBLE::Logging::Level::Warn, "SimpleBLE", __FILE__, __LINE__, __func__, msg)
|
43
|
+
#define SIMPLEBLE_LOG_INFO(msg) SimpleBLE::Logging::Logger::get()->log(SimpleBLE::Logging::Level::Info, "SimpleBLE", __FILE__, __LINE__, __func__, msg)
|
44
|
+
#define SIMPLEBLE_LOG_DEBUG(msg)
|
45
|
+
#define SIMPLEBLE_LOG_VERBOSE(msg)
|
46
|
+
|
47
|
+
#elif SIMPLEBLE_LOG_LEVEL == SIMPLEBLE_LOG_LEVEL_WARN
|
48
|
+
|
49
|
+
#define SIMPLEBLE_LOG_FATAL(msg) SimpleBLE::Logging::Logger::get()->log(SimpleBLE::Logging::Level::Fatal, "SimpleBLE", __FILE__, __LINE__, __func__, msg)
|
50
|
+
#define SIMPLEBLE_LOG_ERROR(msg) SimpleBLE::Logging::Logger::get()->log(SimpleBLE::Logging::Level::Error, "SimpleBLE", __FILE__, __LINE__, __func__, msg)
|
51
|
+
#define SIMPLEBLE_LOG_WARN(msg) SimpleBLE::Logging::Logger::get()->log(SimpleBLE::Logging::Level::Warn, "SimpleBLE", __FILE__, __LINE__, __func__, msg)
|
52
|
+
#define SIMPLEBLE_LOG_INFO(msg)
|
53
|
+
#define SIMPLEBLE_LOG_DEBUG(msg)
|
54
|
+
#define SIMPLEBLE_LOG_VERBOSE(msg)
|
55
|
+
|
56
|
+
#elif SIMPLEBLE_LOG_LEVEL == SIMPLEBLE_LOG_LEVEL_ERROR
|
57
|
+
|
58
|
+
#define SIMPLEBLE_LOG_FATAL(msg) SimpleBLE::Logging::Logger::get()->log(SimpleBLE::Logging::Level::Fatal, "SimpleBLE", __FILE__, __LINE__, __func__, msg)
|
59
|
+
#define SIMPLEBLE_LOG_ERROR(msg) SimpleBLE::Logging::Logger::get()->log(SimpleBLE::Logging::Level::Error, "SimpleBLE", __FILE__, __LINE__, __func__, msg)
|
60
|
+
#define SIMPLEBLE_LOG_WARN(msg)
|
61
|
+
#define SIMPLEBLE_LOG_INFO(msg)
|
62
|
+
#define SIMPLEBLE_LOG_DEBUG(msg)
|
63
|
+
#define SIMPLEBLE_LOG_VERBOSE(msg)
|
64
|
+
|
65
|
+
#elif SIMPLEBLE_LOG_LEVEL == SIMPLEBLE_LOG_LEVEL_FATAL
|
66
|
+
|
67
|
+
#define SIMPLEBLE_LOG_FATAL(msg) SimpleBLE::Logging::Logger::get()->log(SimpleBLE::Logging::Level::Fatal, "SimpleBLE", __FILE__, __LINE__, __func__, msg)
|
68
|
+
#define SIMPLEBLE_LOG_ERROR(msg)
|
69
|
+
#define SIMPLEBLE_LOG_WARN(msg)
|
70
|
+
#define SIMPLEBLE_LOG_INFO(msg)
|
71
|
+
#define SIMPLEBLE_LOG_DEBUG(msg)
|
72
|
+
#define SIMPLEBLE_LOG_VERBOSE(msg)
|
73
|
+
|
74
|
+
#else
|
75
|
+
|
76
|
+
#define SIMPLEBLE_LOG_FATAL(msg)
|
77
|
+
#define SIMPLEBLE_LOG_ERROR(msg)
|
78
|
+
#define SIMPLEBLE_LOG_WARN(msg)
|
79
|
+
#define SIMPLEBLE_LOG_INFO(msg)
|
80
|
+
#define SIMPLEBLE_LOG_DEBUG(msg)
|
81
|
+
#define SIMPLEBLE_LOG_VERBOSE(msg)
|
82
|
+
|
83
|
+
#endif
|
84
|
+
|
85
|
+
// clang-format on
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#include <simpleble/Utils.h>
|
2
|
+
#if SIMPLEBLE_BACKEND_MACOS || SIMPLEBLE_BACKEND_IOS
|
3
|
+
#include "TargetConditionals.h"
|
4
|
+
#endif
|
5
|
+
|
6
|
+
namespace SimpleBLE {
|
7
|
+
|
8
|
+
OperatingSystem get_operating_system() {
|
9
|
+
#ifdef _WIN32
|
10
|
+
return OperatingSystem::WINDOWS;
|
11
|
+
#elif TARGET_OS_OSX
|
12
|
+
return OperatingSystem::MACOS;
|
13
|
+
#elif TARGET_OS_IOS
|
14
|
+
return OperatingSystem::IOS;
|
15
|
+
#elif __linux__
|
16
|
+
return OperatingSystem::LINUX;
|
17
|
+
#elif __ANDROID__
|
18
|
+
return OperatingSystem::ANDROID;
|
19
|
+
#endif
|
20
|
+
}
|
21
|
+
|
22
|
+
std::string get_simpleble_version() { return SIMPLEBLE_VERSION; }
|
23
|
+
|
24
|
+
} // namespace SimpleBLE
|
@@ -0,0 +1,101 @@
|
|
1
|
+
#include "AdapterAndroid.h"
|
2
|
+
#include "BackendAndroid.h"
|
3
|
+
#include "BuilderBase.h"
|
4
|
+
#include "CommonUtils.h"
|
5
|
+
#include "PeripheralAndroid.h"
|
6
|
+
#include "simpleble/Peripheral.h"
|
7
|
+
|
8
|
+
#include <types/android/bluetooth/BluetoothDevice.h>
|
9
|
+
#include <types/android/bluetooth/le/ScanResult.h>
|
10
|
+
#include <android/log.h>
|
11
|
+
#include <fmt/core.h>
|
12
|
+
#include <jni.h>
|
13
|
+
#include <thread>
|
14
|
+
|
15
|
+
using namespace SimpleBLE;
|
16
|
+
|
17
|
+
bool AdapterAndroid::bluetooth_enabled() { return backend_->bluetooth_enabled(); }
|
18
|
+
|
19
|
+
AdapterAndroid::AdapterAndroid(std::shared_ptr<BackendAndroid> backend) : backend_(backend) {
|
20
|
+
_btScanCallback.set_callback_onScanResult([this](Android::ScanResult scan_result) {
|
21
|
+
std::string address = scan_result.getDevice().getAddress();
|
22
|
+
|
23
|
+
if (this->peripherals_.count(address) == 0) {
|
24
|
+
// If the incoming peripheral has never been seen before, create and save a reference to it.
|
25
|
+
auto base_peripheral = std::make_shared<PeripheralAndroid>(scan_result.getDevice());
|
26
|
+
this->peripherals_.insert(std::make_pair(address, base_peripheral));
|
27
|
+
}
|
28
|
+
|
29
|
+
// Update the received advertising data.
|
30
|
+
auto base_peripheral = this->peripherals_.at(address);
|
31
|
+
base_peripheral->update_advertising_data(scan_result);
|
32
|
+
|
33
|
+
// Convert the base object into an external-facing Peripheral object
|
34
|
+
Peripheral peripheral = Factory::build(base_peripheral);
|
35
|
+
|
36
|
+
// Check if the device has been seen before, to forward the correct call to the user.
|
37
|
+
if (this->seen_peripherals_.count(address) == 0) {
|
38
|
+
// Store it in our table of seen peripherals
|
39
|
+
this->seen_peripherals_.insert(std::make_pair(address, base_peripheral));
|
40
|
+
SAFE_CALLBACK_CALL(this->_callback_on_scan_found, peripheral);
|
41
|
+
} else {
|
42
|
+
SAFE_CALLBACK_CALL(this->_callback_on_scan_updated, peripheral);
|
43
|
+
}
|
44
|
+
});
|
45
|
+
}
|
46
|
+
|
47
|
+
AdapterAndroid::~AdapterAndroid() {}
|
48
|
+
|
49
|
+
void* AdapterAndroid::underlying() const { return nullptr; }
|
50
|
+
|
51
|
+
std::string AdapterAndroid::identifier() { return _btAdapter.getName(); }
|
52
|
+
|
53
|
+
BluetoothAddress AdapterAndroid::address() { return BluetoothAddress(_btAdapter.getAddress()); }
|
54
|
+
|
55
|
+
void AdapterAndroid::power_on() {
|
56
|
+
// NOTE: This feature was deprecated in API level 33.
|
57
|
+
// Despite us targeting API level 31, we'll play nicely and not call this method.
|
58
|
+
// https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#enable()
|
59
|
+
}
|
60
|
+
|
61
|
+
void AdapterAndroid::power_off() {
|
62
|
+
// NOTE: This feature was deprecated in API level 33.
|
63
|
+
// Despite us targeting API level 31, we'll play nicely and not call this method.
|
64
|
+
// https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#disable()
|
65
|
+
}
|
66
|
+
|
67
|
+
bool AdapterAndroid::is_powered() { return _btAdapter.isEnabled(); }
|
68
|
+
|
69
|
+
void AdapterAndroid::scan_start() {
|
70
|
+
seen_peripherals_.clear();
|
71
|
+
_btScanner.startScan(_btScanCallback);
|
72
|
+
scanning_ = true;
|
73
|
+
SAFE_CALLBACK_CALL(this->_callback_on_scan_start);
|
74
|
+
}
|
75
|
+
|
76
|
+
void AdapterAndroid::scan_stop() {
|
77
|
+
_btScanner.stopScan(_btScanCallback);
|
78
|
+
scanning_ = false;
|
79
|
+
SAFE_CALLBACK_CALL(this->_callback_on_scan_stop);
|
80
|
+
}
|
81
|
+
|
82
|
+
void AdapterAndroid::scan_for(int timeout_ms) {
|
83
|
+
scan_start();
|
84
|
+
std::this_thread::sleep_for(std::chrono::milliseconds(timeout_ms));
|
85
|
+
scan_stop();
|
86
|
+
}
|
87
|
+
|
88
|
+
bool AdapterAndroid::scan_is_active() { return scanning_; }
|
89
|
+
|
90
|
+
SharedPtrVector<PeripheralBase> AdapterAndroid::scan_get_results() { return Util::values(seen_peripherals_); }
|
91
|
+
|
92
|
+
SharedPtrVector<PeripheralBase> AdapterAndroid::get_paired_peripherals() {
|
93
|
+
SharedPtrVector<PeripheralBase> peripherals;
|
94
|
+
|
95
|
+
auto paired_list = _btAdapter.getBondedDevices();
|
96
|
+
for (auto& device : paired_list) {
|
97
|
+
peripherals.push_back(std::make_shared<PeripheralAndroid>(device));
|
98
|
+
}
|
99
|
+
|
100
|
+
return peripherals;
|
101
|
+
}
|
@@ -0,0 +1,70 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include <simpleble/Exceptions.h>
|
4
|
+
#include <simpleble/Types.h>
|
5
|
+
|
6
|
+
#include "../common/AdapterBase.h"
|
7
|
+
|
8
|
+
#include <kvn_safe_callback.hpp>
|
9
|
+
|
10
|
+
#include <atomic>
|
11
|
+
#include <functional>
|
12
|
+
#include <memory>
|
13
|
+
#include <string>
|
14
|
+
#include <vector>
|
15
|
+
|
16
|
+
#include "types/android/bluetooth/BluetoothAdapter.h"
|
17
|
+
#include "types/android/bluetooth/le/BluetoothScanner.h"
|
18
|
+
#include "bridge/ScanCallback.h"
|
19
|
+
|
20
|
+
namespace SimpleBLE {
|
21
|
+
|
22
|
+
class BackendAndroid;
|
23
|
+
class PeripheralAndroid;
|
24
|
+
class Peripheral;
|
25
|
+
|
26
|
+
class AdapterAndroid : public AdapterBase {
|
27
|
+
public:
|
28
|
+
AdapterAndroid(std::shared_ptr<BackendAndroid> backend);
|
29
|
+
virtual ~AdapterAndroid();
|
30
|
+
|
31
|
+
virtual void* underlying() const override;
|
32
|
+
|
33
|
+
virtual std::string identifier() override;
|
34
|
+
virtual BluetoothAddress address() override;
|
35
|
+
|
36
|
+
virtual void power_on() override;
|
37
|
+
virtual void power_off() override;
|
38
|
+
virtual bool is_powered() override;
|
39
|
+
|
40
|
+
virtual void scan_start() override;
|
41
|
+
virtual void scan_stop() override;
|
42
|
+
virtual void scan_for(int timeout_ms) override;
|
43
|
+
virtual bool scan_is_active() override;
|
44
|
+
virtual std::vector<std::shared_ptr<PeripheralBase>> scan_get_results() override;
|
45
|
+
|
46
|
+
virtual std::vector<std::shared_ptr<PeripheralBase>> get_paired_peripherals() override;
|
47
|
+
|
48
|
+
virtual bool bluetooth_enabled() override;
|
49
|
+
|
50
|
+
// NOTE: The following methods have been made public to allow the JNI layer to call them, but
|
51
|
+
// should not be called directly by the user.
|
52
|
+
|
53
|
+
void onScanResultCallback(JNIEnv* env, jobject thiz, jint callback_type, jobject result);
|
54
|
+
void onBatchScanResultsCallback(JNIEnv* env, jobject thiz, jobject results);
|
55
|
+
void onScanFailedCallback(JNIEnv* env, jobject thiz, jint error_code);
|
56
|
+
|
57
|
+
private:
|
58
|
+
std::shared_ptr<BackendAndroid> backend_;
|
59
|
+
|
60
|
+
Android::BluetoothAdapter _btAdapter = Android::BluetoothAdapter::getDefaultAdapter();
|
61
|
+
Android::BluetoothScanner _btScanner = _btAdapter.getBluetoothLeScanner();
|
62
|
+
Android::Bridge::ScanCallback _btScanCallback;
|
63
|
+
|
64
|
+
std::map<BluetoothAddress, std::shared_ptr<PeripheralAndroid>> peripherals_;
|
65
|
+
std::map<BluetoothAddress, std::shared_ptr<PeripheralAndroid>> seen_peripherals_;
|
66
|
+
|
67
|
+
std::atomic<bool> scanning_{false};
|
68
|
+
};
|
69
|
+
|
70
|
+
} // namespace SimpleBLE
|
@@ -0,0 +1,40 @@
|
|
1
|
+
#include "BackendAndroid.h"
|
2
|
+
#include "AdapterAndroid.h"
|
3
|
+
#include "BuildVec.h"
|
4
|
+
#include "CommonUtils.h"
|
5
|
+
#include "types/android/bluetooth/BluetoothAdapter.h"
|
6
|
+
#include "simplejni/Registry.hpp"
|
7
|
+
|
8
|
+
#include <android/log.h>
|
9
|
+
#include <fmt/core.h>
|
10
|
+
|
11
|
+
#include <string>
|
12
|
+
|
13
|
+
namespace SimpleBLE {
|
14
|
+
|
15
|
+
std::shared_ptr<BackendAndroid> BACKEND_ANDROID() { return BackendAndroid::get(); }
|
16
|
+
|
17
|
+
BackendAndroid::BackendAndroid(buildToken) {
|
18
|
+
SimpleJNI::Registrar::get().preload(SimpleJNI::VM::env());
|
19
|
+
}
|
20
|
+
|
21
|
+
std::string BackendAndroid::name() const noexcept { return "Android"; }
|
22
|
+
|
23
|
+
SharedPtrVector<AdapterBase> BackendAndroid::get_adapters() {
|
24
|
+
SharedPtrVector<AdapterBase> adapters;
|
25
|
+
adapters.push_back(std::make_shared<AdapterAndroid>(shared_from_this()));
|
26
|
+
|
27
|
+
return adapters;
|
28
|
+
}
|
29
|
+
|
30
|
+
bool BackendAndroid::bluetooth_enabled() {
|
31
|
+
Android::BluetoothAdapter btAdapter = Android::BluetoothAdapter::getDefaultAdapter();
|
32
|
+
|
33
|
+
bool isEnabled = btAdapter.isEnabled();
|
34
|
+
int bluetoothState = btAdapter.getState();
|
35
|
+
__android_log_write(ANDROID_LOG_INFO, "SimpleBLE", fmt::format("Bluetooth state: {}", bluetoothState).c_str());
|
36
|
+
|
37
|
+
return isEnabled; // bluetoothState == 12;
|
38
|
+
}
|
39
|
+
|
40
|
+
} // namespace SimpleBLE
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include "../common/BackendBase.h"
|
4
|
+
#include "../common/BackendUtils.h"
|
5
|
+
|
6
|
+
namespace SimpleBLE {
|
7
|
+
|
8
|
+
class BackendAndroid : public BackendSingleton<BackendAndroid> {
|
9
|
+
public:
|
10
|
+
BackendAndroid(buildToken);
|
11
|
+
virtual ~BackendAndroid() = default;
|
12
|
+
|
13
|
+
virtual std::vector<std::shared_ptr<AdapterBase>> get_adapters() override;
|
14
|
+
virtual bool bluetooth_enabled() override;
|
15
|
+
virtual std::string name() const noexcept override;
|
16
|
+
|
17
|
+
private:
|
18
|
+
};
|
19
|
+
|
20
|
+
} // namespace SimpleBLE
|