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,81 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include <simpleble/Exceptions.h>
|
4
|
+
#include <simpleble/Types.h>
|
5
|
+
|
6
|
+
#include "AdapterBaseTypes.h"
|
7
|
+
#include "PeripheralBase.h"
|
8
|
+
|
9
|
+
#include <kvn_safe_callback.hpp>
|
10
|
+
|
11
|
+
#include <memory>
|
12
|
+
|
13
|
+
namespace SimpleBLE {
|
14
|
+
|
15
|
+
class PeripheralMac : public PeripheralBase {
|
16
|
+
public:
|
17
|
+
PeripheralMac(void* opaque_peripheral, void* opaque_adapter, advertising_data_t advertising_data);
|
18
|
+
~PeripheralMac();
|
19
|
+
|
20
|
+
virtual void* underlying() const override;
|
21
|
+
|
22
|
+
virtual std::string identifier() override;
|
23
|
+
virtual BluetoothAddress address() override;
|
24
|
+
virtual BluetoothAddressType address_type() override;
|
25
|
+
virtual int16_t tx_power() override;
|
26
|
+
virtual int16_t rssi() override;
|
27
|
+
virtual uint16_t mtu() override;
|
28
|
+
|
29
|
+
virtual void connect() override;
|
30
|
+
virtual void disconnect() override;
|
31
|
+
virtual bool is_connected() override;
|
32
|
+
virtual bool is_connectable() override;
|
33
|
+
virtual bool is_paired() override;
|
34
|
+
virtual void unpair() override;
|
35
|
+
|
36
|
+
virtual std::vector<std::shared_ptr<ServiceBase>> available_services() override;
|
37
|
+
virtual std::vector<std::shared_ptr<ServiceBase>> advertised_services() override;
|
38
|
+
virtual std::map<uint16_t, ByteArray> manufacturer_data() override;
|
39
|
+
|
40
|
+
// clang-format off
|
41
|
+
virtual ByteArray read(BluetoothUUID const& service, BluetoothUUID const& characteristic) override;
|
42
|
+
virtual void write_request(BluetoothUUID const& service, BluetoothUUID const& characteristic, ByteArray const& data) override;
|
43
|
+
virtual void write_command(BluetoothUUID const& service, BluetoothUUID const& characteristic, ByteArray const& data) override;
|
44
|
+
virtual void notify(BluetoothUUID const& service, BluetoothUUID const& characteristic, std::function<void(ByteArray payload)> callback) override;
|
45
|
+
virtual void indicate(BluetoothUUID const& service, BluetoothUUID const& characteristic, std::function<void(ByteArray payload)> callback) override;
|
46
|
+
virtual void unsubscribe(BluetoothUUID const& service, BluetoothUUID const& characteristic) override;
|
47
|
+
|
48
|
+
virtual ByteArray read(BluetoothUUID const& service, BluetoothUUID const& characteristic, BluetoothUUID const& descriptor) override;
|
49
|
+
virtual void write(BluetoothUUID const& service, BluetoothUUID const& characteristic, BluetoothUUID const& descriptor, ByteArray const& data) override;
|
50
|
+
// clang-format on
|
51
|
+
|
52
|
+
virtual void set_callback_on_connected(std::function<void()> on_connected) override;
|
53
|
+
virtual void set_callback_on_disconnected(std::function<void()> on_disconnected) override;
|
54
|
+
|
55
|
+
void delegate_did_connect();
|
56
|
+
void delegate_did_fail_to_connect(void* opaque_error);
|
57
|
+
void delegate_did_disconnect(void* opaque_error);
|
58
|
+
|
59
|
+
void update_advertising_data(advertising_data_t advertising_data);
|
60
|
+
|
61
|
+
protected:
|
62
|
+
/**
|
63
|
+
* Holds a pointer to the Objective-C representation of this object.
|
64
|
+
*/
|
65
|
+
void* opaque_internal_;
|
66
|
+
|
67
|
+
int16_t rssi_;
|
68
|
+
int16_t tx_power_;
|
69
|
+
|
70
|
+
bool is_connectable_;
|
71
|
+
|
72
|
+
bool manual_disconnect_triggered_;
|
73
|
+
|
74
|
+
std::map<uint16_t, ByteArray> manufacturer_data_;
|
75
|
+
std::map<BluetoothUUID, ByteArray> service_data_;
|
76
|
+
|
77
|
+
kvn::safe_callback<void()> callback_on_connected_;
|
78
|
+
kvn::safe_callback<void()> callback_on_disconnected_;
|
79
|
+
};
|
80
|
+
|
81
|
+
} // namespace SimpleBLE
|
@@ -0,0 +1,65 @@
|
|
1
|
+
#include <simpleble/Peripheral.h>
|
2
|
+
|
3
|
+
#include "AdapterPlain.h"
|
4
|
+
#include "BuilderBase.h"
|
5
|
+
#include "CommonUtils.h"
|
6
|
+
#include "PeripheralBase.h"
|
7
|
+
#include "PeripheralPlain.h"
|
8
|
+
|
9
|
+
#include <memory>
|
10
|
+
#include <thread>
|
11
|
+
|
12
|
+
using namespace SimpleBLE;
|
13
|
+
|
14
|
+
bool AdapterPlain::bluetooth_enabled() { return true; }
|
15
|
+
|
16
|
+
AdapterPlain::AdapterPlain() {}
|
17
|
+
|
18
|
+
AdapterPlain::~AdapterPlain() {}
|
19
|
+
|
20
|
+
void* AdapterPlain::underlying() const { return nullptr; }
|
21
|
+
|
22
|
+
std::string AdapterPlain::identifier() { return "Plain Adapter"; }
|
23
|
+
|
24
|
+
BluetoothAddress AdapterPlain::address() { return "AA:BB:CC:DD:EE:FF"; }
|
25
|
+
|
26
|
+
void AdapterPlain::power_on() {}
|
27
|
+
|
28
|
+
void AdapterPlain::power_off() {}
|
29
|
+
|
30
|
+
bool AdapterPlain::is_powered() { return true; }
|
31
|
+
|
32
|
+
void AdapterPlain::scan_start() {
|
33
|
+
is_scanning_ = true;
|
34
|
+
SAFE_CALLBACK_CALL(this->_callback_on_scan_start_);
|
35
|
+
|
36
|
+
Peripheral peripheral = Factory::build(std::make_shared<PeripheralPlain>());
|
37
|
+
SAFE_CALLBACK_CALL(this->_callback_on_scan_found_, peripheral);
|
38
|
+
SAFE_CALLBACK_CALL(this->_callback_on_scan_updated_, peripheral);
|
39
|
+
}
|
40
|
+
|
41
|
+
void AdapterPlain::scan_stop() {
|
42
|
+
is_scanning_ = false;
|
43
|
+
SAFE_CALLBACK_CALL(this->_callback_on_scan_stop_);
|
44
|
+
}
|
45
|
+
|
46
|
+
void AdapterPlain::scan_for(int timeout_ms) {
|
47
|
+
scan_start();
|
48
|
+
std::this_thread::sleep_for(std::chrono::milliseconds(timeout_ms));
|
49
|
+
scan_stop();
|
50
|
+
}
|
51
|
+
|
52
|
+
bool AdapterPlain::scan_is_active() { return is_scanning_; }
|
53
|
+
SharedPtrVector<PeripheralBase> AdapterPlain::scan_get_results() {
|
54
|
+
SharedPtrVector<PeripheralBase> peripherals;
|
55
|
+
peripherals.push_back(std::make_shared<PeripheralPlain>());
|
56
|
+
|
57
|
+
return peripherals;
|
58
|
+
}
|
59
|
+
|
60
|
+
SharedPtrVector<PeripheralBase> AdapterPlain::get_paired_peripherals() {
|
61
|
+
SharedPtrVector<PeripheralBase> peripherals;
|
62
|
+
peripherals.push_back(std::make_shared<PeripheralPlain>());
|
63
|
+
|
64
|
+
return peripherals;
|
65
|
+
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include <simpleble/Exceptions.h>
|
4
|
+
#include <simpleble/Types.h>
|
5
|
+
|
6
|
+
#include "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
|
+
namespace SimpleBLE {
|
17
|
+
|
18
|
+
/**
|
19
|
+
* Dummy adapter for testing purposes.
|
20
|
+
*/
|
21
|
+
class AdapterPlain : public AdapterBase {
|
22
|
+
public:
|
23
|
+
AdapterPlain();
|
24
|
+
virtual ~AdapterPlain();
|
25
|
+
|
26
|
+
virtual void* underlying() const override;
|
27
|
+
|
28
|
+
virtual std::string identifier() override;
|
29
|
+
virtual BluetoothAddress address() override;
|
30
|
+
|
31
|
+
virtual void power_on() override;
|
32
|
+
virtual void power_off() override;
|
33
|
+
virtual bool is_powered() override;
|
34
|
+
|
35
|
+
virtual void scan_start() override;
|
36
|
+
virtual void scan_stop() override;
|
37
|
+
virtual void scan_for(int timeout_ms) override;
|
38
|
+
virtual bool scan_is_active() override;
|
39
|
+
virtual std::vector<std::shared_ptr<PeripheralBase>> scan_get_results() override;
|
40
|
+
|
41
|
+
virtual std::vector<std::shared_ptr<PeripheralBase>> get_paired_peripherals() override;
|
42
|
+
|
43
|
+
virtual bool bluetooth_enabled() override;
|
44
|
+
|
45
|
+
private:
|
46
|
+
std::atomic_bool is_scanning_{false};
|
47
|
+
};
|
48
|
+
|
49
|
+
} // namespace SimpleBLE
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#include <string>
|
2
|
+
#include "AdapterPlain.h"
|
3
|
+
#include "BackendUtils.h"
|
4
|
+
#include "CommonUtils.h"
|
5
|
+
|
6
|
+
namespace SimpleBLE {
|
7
|
+
|
8
|
+
class BackendPlain : public BackendSingleton<BackendPlain> {
|
9
|
+
public:
|
10
|
+
BackendPlain(buildToken) {};
|
11
|
+
virtual ~BackendPlain() = default;
|
12
|
+
|
13
|
+
virtual SharedPtrVector<AdapterBase> get_adapters() override;
|
14
|
+
virtual bool bluetooth_enabled() override;
|
15
|
+
std::string name() const noexcept override;
|
16
|
+
};
|
17
|
+
|
18
|
+
std::shared_ptr<BackendBase> BACKEND_PLAIN() { return BackendPlain::get(); }
|
19
|
+
|
20
|
+
std::string BackendPlain::name() const noexcept { return "Plain"; }
|
21
|
+
|
22
|
+
bool BackendPlain::bluetooth_enabled() { return true; }
|
23
|
+
|
24
|
+
SharedPtrVector<AdapterBase> BackendPlain::get_adapters() {
|
25
|
+
SharedPtrVector<AdapterBase> adapters;
|
26
|
+
adapters.push_back(std::make_shared<AdapterPlain>());
|
27
|
+
return adapters;
|
28
|
+
}
|
29
|
+
|
30
|
+
} // namespace SimpleBLE
|
@@ -0,0 +1,159 @@
|
|
1
|
+
#include "PeripheralPlain.h"
|
2
|
+
|
3
|
+
#include "CharacteristicBase.h"
|
4
|
+
#include "DescriptorBase.h"
|
5
|
+
#include "ServiceBase.h"
|
6
|
+
|
7
|
+
#include <simpleble/Exceptions.h>
|
8
|
+
|
9
|
+
#include <memory>
|
10
|
+
|
11
|
+
#include "CommonUtils.h"
|
12
|
+
#include "LoggingInternal.h"
|
13
|
+
|
14
|
+
using namespace SimpleBLE;
|
15
|
+
using namespace std::chrono_literals;
|
16
|
+
|
17
|
+
const SimpleBLE::BluetoothUUID BATTERY_SERVICE_UUID = "0000180f-0000-1000-8000-00805f9b34fb";
|
18
|
+
const SimpleBLE::BluetoothUUID BATTERY_CHARACTERISTIC_UUID = "00002a19-0000-1000-8000-00805f9b34fb";
|
19
|
+
|
20
|
+
PeripheralPlain::PeripheralPlain() {}
|
21
|
+
|
22
|
+
PeripheralPlain::~PeripheralPlain() {}
|
23
|
+
|
24
|
+
void* PeripheralPlain::underlying() const { return nullptr; }
|
25
|
+
|
26
|
+
std::string PeripheralPlain::identifier() { return "Plain Peripheral"; }
|
27
|
+
|
28
|
+
BluetoothAddress PeripheralPlain::address() { return "11:22:33:44:55:66"; }
|
29
|
+
|
30
|
+
BluetoothAddressType PeripheralPlain::address_type() { return BluetoothAddressType::PUBLIC; };
|
31
|
+
|
32
|
+
int16_t PeripheralPlain::rssi() { return -60; }
|
33
|
+
|
34
|
+
int16_t PeripheralPlain::tx_power() { return 5; }
|
35
|
+
|
36
|
+
uint16_t PeripheralPlain::mtu() {
|
37
|
+
if (is_connected()) {
|
38
|
+
return 247;
|
39
|
+
} else {
|
40
|
+
return 0;
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
void PeripheralPlain::connect() {
|
45
|
+
connected_ = true;
|
46
|
+
paired_ = true;
|
47
|
+
SAFE_CALLBACK_CALL(this->callback_on_connected_);
|
48
|
+
}
|
49
|
+
|
50
|
+
void PeripheralPlain::disconnect() {
|
51
|
+
connected_ = false;
|
52
|
+
SAFE_CALLBACK_CALL(this->callback_on_disconnected_);
|
53
|
+
}
|
54
|
+
bool PeripheralPlain::is_connected() { return connected_; }
|
55
|
+
|
56
|
+
bool PeripheralPlain::is_connectable() { return true; }
|
57
|
+
|
58
|
+
bool PeripheralPlain::is_paired() { return paired_; }
|
59
|
+
|
60
|
+
void PeripheralPlain::unpair() { paired_ = false; }
|
61
|
+
|
62
|
+
SharedPtrVector<ServiceBase> PeripheralPlain::available_services() {
|
63
|
+
if (!connected_) return {};
|
64
|
+
|
65
|
+
SharedPtrVector<ServiceBase> service_list;
|
66
|
+
SharedPtrVector<DescriptorBase> descriptor_list;
|
67
|
+
SharedPtrVector<CharacteristicBase> characteristic_list = {std::make_shared<CharacteristicBase>(
|
68
|
+
BATTERY_CHARACTERISTIC_UUID, descriptor_list, true, false, false, true, false)};
|
69
|
+
|
70
|
+
service_list.push_back(std::make_shared<ServiceBase>(BATTERY_SERVICE_UUID, characteristic_list));
|
71
|
+
return service_list;
|
72
|
+
}
|
73
|
+
|
74
|
+
SharedPtrVector<ServiceBase> PeripheralPlain::advertised_services() { return {}; }
|
75
|
+
|
76
|
+
std::map<uint16_t, ByteArray> PeripheralPlain::manufacturer_data() { return {{0x004C, "test"}}; }
|
77
|
+
|
78
|
+
ByteArray PeripheralPlain::read(BluetoothUUID const& service, BluetoothUUID const& characteristic) { return {}; }
|
79
|
+
|
80
|
+
void PeripheralPlain::write_request(BluetoothUUID const& service, BluetoothUUID const& characteristic,
|
81
|
+
ByteArray const& data) {}
|
82
|
+
|
83
|
+
void PeripheralPlain::write_command(BluetoothUUID const& service, BluetoothUUID const& characteristic,
|
84
|
+
ByteArray const& data) {}
|
85
|
+
|
86
|
+
void PeripheralPlain::notify(BluetoothUUID const& service, BluetoothUUID const& characteristic,
|
87
|
+
std::function<void(ByteArray payload)> callback) {
|
88
|
+
if (callback) {
|
89
|
+
callback_mutex_.lock();
|
90
|
+
callbacks_[{service, characteristic}] = std::move(callback);
|
91
|
+
callback_mutex_.unlock();
|
92
|
+
|
93
|
+
task_runner_.dispatch(
|
94
|
+
[this, service, characteristic]() -> std::optional<std::chrono::seconds> {
|
95
|
+
std::lock_guard<std::mutex> lock(callback_mutex_);
|
96
|
+
auto it = this->callbacks_.find({service, characteristic});
|
97
|
+
|
98
|
+
if (it == this->callbacks_.end()) {
|
99
|
+
return std::nullopt;
|
100
|
+
}
|
101
|
+
|
102
|
+
it->second("Hello from notify");
|
103
|
+
return 1s;
|
104
|
+
},
|
105
|
+
1s);
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
void PeripheralPlain::indicate(BluetoothUUID const& service, BluetoothUUID const& characteristic,
|
110
|
+
std::function<void(ByteArray payload)> callback) {
|
111
|
+
if (callback) {
|
112
|
+
callback_mutex_.lock();
|
113
|
+
callbacks_[{service, characteristic}] = std::move(callback);
|
114
|
+
callback_mutex_.unlock();
|
115
|
+
|
116
|
+
task_runner_.dispatch(
|
117
|
+
[this, service, characteristic]() -> std::optional<std::chrono::seconds> {
|
118
|
+
std::lock_guard<std::mutex> lock(callback_mutex_);
|
119
|
+
auto it = this->callbacks_.find({service, characteristic});
|
120
|
+
|
121
|
+
if (it == this->callbacks_.end()) {
|
122
|
+
return std::nullopt;
|
123
|
+
}
|
124
|
+
|
125
|
+
it->second("Hello from notify");
|
126
|
+
return 1s;
|
127
|
+
},
|
128
|
+
1s);
|
129
|
+
}
|
130
|
+
}
|
131
|
+
|
132
|
+
void PeripheralPlain::unsubscribe(BluetoothUUID const& service, BluetoothUUID const& characteristic) {
|
133
|
+
std::lock_guard<std::mutex> lock(callback_mutex_);
|
134
|
+
callbacks_.erase({service, characteristic});
|
135
|
+
}
|
136
|
+
|
137
|
+
ByteArray PeripheralPlain::read(BluetoothUUID const& service, BluetoothUUID const& characteristic,
|
138
|
+
BluetoothUUID const& descriptor) {
|
139
|
+
return {};
|
140
|
+
}
|
141
|
+
|
142
|
+
void PeripheralPlain::write(BluetoothUUID const& service, BluetoothUUID const& characteristic,
|
143
|
+
BluetoothUUID const& descriptor, ByteArray const& data) {}
|
144
|
+
|
145
|
+
void PeripheralPlain::set_callback_on_connected(std::function<void()> on_connected) {
|
146
|
+
if (on_connected) {
|
147
|
+
callback_on_connected_.load(std::move(on_connected));
|
148
|
+
} else {
|
149
|
+
callback_on_connected_.unload();
|
150
|
+
}
|
151
|
+
}
|
152
|
+
|
153
|
+
void PeripheralPlain::set_callback_on_disconnected(std::function<void()> on_disconnected) {
|
154
|
+
if (on_disconnected) {
|
155
|
+
callback_on_disconnected_.load(std::move(on_disconnected));
|
156
|
+
} else {
|
157
|
+
callback_on_disconnected_.unload();
|
158
|
+
}
|
159
|
+
}
|
@@ -0,0 +1,72 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include <simpleble/Exceptions.h>
|
4
|
+
#include <simpleble/Service.h>
|
5
|
+
#include <simpleble/Types.h>
|
6
|
+
#include "PeripheralBase.h"
|
7
|
+
|
8
|
+
#include <TaskRunner.hpp>
|
9
|
+
#include <kvn_safe_callback.hpp>
|
10
|
+
|
11
|
+
#include <atomic>
|
12
|
+
#include <map>
|
13
|
+
#include <memory>
|
14
|
+
#include <mutex>
|
15
|
+
|
16
|
+
namespace SimpleBLE {
|
17
|
+
|
18
|
+
class PeripheralPlain : public PeripheralBase {
|
19
|
+
public:
|
20
|
+
PeripheralPlain();
|
21
|
+
virtual ~PeripheralPlain();
|
22
|
+
|
23
|
+
void* underlying() const override;
|
24
|
+
|
25
|
+
virtual std::string identifier() override;
|
26
|
+
virtual BluetoothAddress address() override;
|
27
|
+
virtual BluetoothAddressType address_type() override;
|
28
|
+
virtual int16_t rssi() override;
|
29
|
+
virtual int16_t tx_power() override;
|
30
|
+
virtual uint16_t mtu() override;
|
31
|
+
|
32
|
+
virtual void connect() override;
|
33
|
+
virtual void disconnect() override;
|
34
|
+
virtual bool is_connected() override;
|
35
|
+
virtual bool is_connectable() override;
|
36
|
+
virtual bool is_paired() override;
|
37
|
+
virtual void unpair() override;
|
38
|
+
|
39
|
+
virtual std::vector<std::shared_ptr<ServiceBase>> available_services() override;
|
40
|
+
virtual std::vector<std::shared_ptr<ServiceBase>> advertised_services() override;
|
41
|
+
|
42
|
+
virtual std::map<uint16_t, ByteArray> manufacturer_data() override;
|
43
|
+
|
44
|
+
// clang-format off
|
45
|
+
virtual ByteArray read(BluetoothUUID const& service, BluetoothUUID const& characteristic) override;
|
46
|
+
virtual void write_request(BluetoothUUID const& service, BluetoothUUID const& characteristic, ByteArray const& data) override;
|
47
|
+
virtual void write_command(BluetoothUUID const& service, BluetoothUUID const& characteristic, ByteArray const& data) override;
|
48
|
+
virtual void notify(BluetoothUUID const& service, BluetoothUUID const& characteristic, std::function<void(ByteArray payload)> callback) override;
|
49
|
+
virtual void indicate(BluetoothUUID const& service, BluetoothUUID const& characteristic, std::function<void(ByteArray payload)> callback) override;
|
50
|
+
virtual void unsubscribe(BluetoothUUID const& service, BluetoothUUID const& characteristic) override;
|
51
|
+
|
52
|
+
virtual ByteArray read(BluetoothUUID const& service, BluetoothUUID const& characteristic, BluetoothUUID const& descriptor) override;
|
53
|
+
virtual void write(BluetoothUUID const& service, BluetoothUUID const& characteristic, BluetoothUUID const& descriptor, ByteArray const& data) override;
|
54
|
+
// clang-format on
|
55
|
+
|
56
|
+
virtual void set_callback_on_connected(std::function<void()> on_connected) override;
|
57
|
+
virtual void set_callback_on_disconnected(std::function<void()> on_disconnected) override;
|
58
|
+
|
59
|
+
private:
|
60
|
+
std::atomic_bool connected_{false};
|
61
|
+
std::atomic_bool paired_{false};
|
62
|
+
|
63
|
+
kvn::safe_callback<void()> callback_on_connected_;
|
64
|
+
kvn::safe_callback<void()> callback_on_disconnected_;
|
65
|
+
|
66
|
+
std::mutex callback_mutex_;
|
67
|
+
std::map<std::pair<BluetoothUUID, BluetoothUUID>, std::function<void(ByteArray payload)>> callbacks_;
|
68
|
+
|
69
|
+
TaskRunner task_runner_;
|
70
|
+
};
|
71
|
+
|
72
|
+
} // namespace SimpleBLE
|