simplejsble 0.0.4 → 0.0.6
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.
- package/VERSION +1 -0
- package/android/CMakeLists.txt +62 -20
- package/cmake/epilogue.cmake +81 -0
- package/cmake/find/FindDBus1.cmake +20 -0
- package/cmake/find/Findfmt.cmake +41 -0
- package/cmake/find/Findgoogletest.cmake +18 -0
- package/cmake/parse_version.cmake +45 -0
- package/cmake/prelude.cmake +8 -0
- package/dependencies/README +4 -0
- package/dependencies/external/kvn/kvn_bytearray.h +297 -0
- package/dependencies/external/kvn/kvn_safe_callback.hpp +66 -0
- package/dependencies/external/kvn/logfwd.hpp +35 -0
- package/dependencies/internal/include/fmt/LICENSE +27 -0
- package/dependencies/internal/include/fmt/args.h +220 -0
- package/dependencies/internal/include/fmt/base.h +2962 -0
- package/dependencies/internal/include/fmt/chrono.h +2338 -0
- package/dependencies/internal/include/fmt/color.h +610 -0
- package/dependencies/internal/include/fmt/compile.h +539 -0
- package/dependencies/internal/include/fmt/core.h +5 -0
- package/dependencies/internal/include/fmt/format-inl.h +1949 -0
- package/dependencies/internal/include/fmt/format.h +4244 -0
- package/dependencies/internal/include/fmt/os.h +427 -0
- package/dependencies/internal/include/fmt/ostream.h +166 -0
- package/dependencies/internal/include/fmt/printf.h +633 -0
- package/dependencies/internal/include/fmt/ranges.h +850 -0
- package/dependencies/internal/include/fmt/std.h +726 -0
- package/dependencies/internal/include/fmt/xchar.h +373 -0
- package/dependencies/internal/include/nanopb/pb.h +948 -0
- package/dependencies/internal/include/nanopb/pb_common.h +49 -0
- package/dependencies/internal/include/nanopb/pb_decode.h +204 -0
- package/dependencies/internal/include/nanopb/pb_encode.h +195 -0
- package/dependencies/internal/include/simplejni/Common.hpp +598 -0
- package/dependencies/internal/include/simplejni/References.hpp +151 -0
- package/dependencies/internal/include/simplejni/Registry.hpp +249 -0
- package/dependencies/internal/include/simplejni/VM.hpp +93 -0
- package/dependencies/internal/src/nanopb/pb_common.c +388 -0
- package/dependencies/internal/src/nanopb/pb_decode.c +1763 -0
- package/dependencies/internal/src/nanopb/pb_encode.c +1009 -0
- package/dependencies/internal/src/simplejni/Common.cpp +4 -0
- package/package.json +5 -1
- package/simpleble/CMakeLists.txt +519 -0
- package/simpleble/cmake/simpleble.pc.in +11 -0
- package/simpleble/include/simpleble/Adapter.h +102 -0
- package/simpleble/include/simpleble/AdapterSafe.h +58 -0
- package/simpleble/include/simpleble/Advanced.h +50 -0
- package/simpleble/include/simpleble/Characteristic.h +39 -0
- package/simpleble/include/simpleble/Config.h +64 -0
- package/simpleble/include/simpleble/Descriptor.h +30 -0
- package/simpleble/include/simpleble/Exceptions.h +72 -0
- package/simpleble/include/simpleble/Logging.h +73 -0
- package/simpleble/include/simpleble/Peripheral.h +82 -0
- package/simpleble/include/simpleble/PeripheralSafe.h +64 -0
- package/simpleble/include/simpleble/Service.h +34 -0
- package/simpleble/include/simpleble/SimpleBLE.h +8 -0
- package/simpleble/include/simpleble/Types.h +49 -0
- package/simpleble/include/simpleble/Utils.h +13 -0
- package/simpleble/include/simpleble_c/DEPRECATED +2 -0
- package/simpleble/include/simpleble_c/adapter.h +188 -0
- package/simpleble/include/simpleble_c/logging.h +37 -0
- package/simpleble/include/simpleble_c/peripheral.h +304 -0
- package/simpleble/include/simpleble_c/simpleble.h +21 -0
- package/simpleble/include/simpleble_c/types.h +73 -0
- package/simpleble/include/simpleble_c/utils.h +27 -0
- package/simpleble/src/CommonUtils.h +63 -0
- package/simpleble/src/Config.cpp +25 -0
- package/simpleble/src/Exceptions.cpp +31 -0
- package/simpleble/src/Logging.cpp +136 -0
- package/simpleble/src/LoggingInternal.h +85 -0
- package/simpleble/src/Utils.cpp +24 -0
- package/simpleble/src/backends/android/AdapterAndroid.cpp +101 -0
- package/simpleble/src/backends/android/AdapterAndroid.h +67 -0
- package/simpleble/src/backends/android/BackendAndroid.cpp +41 -0
- package/simpleble/src/backends/android/BackendAndroid.h +26 -0
- package/simpleble/src/backends/android/PeripheralAndroid.cpp +365 -0
- package/simpleble/src/backends/android/PeripheralAndroid.h +90 -0
- package/simpleble/src/backends/android/bridge/BluetoothGattCallback.cpp +432 -0
- package/simpleble/src/backends/android/bridge/BluetoothGattCallback.h +102 -0
- package/simpleble/src/backends/android/bridge/ScanCallback.cpp +142 -0
- package/simpleble/src/backends/android/bridge/ScanCallback.h +55 -0
- package/simpleble/src/backends/android/types/android/bluetooth/BluetoothAdapter.cpp +107 -0
- package/simpleble/src/backends/android/types/android/bluetooth/BluetoothAdapter.h +55 -0
- package/simpleble/src/backends/android/types/android/bluetooth/BluetoothDevice.cpp +68 -0
- package/simpleble/src/backends/android/types/android/bluetooth/BluetoothDevice.h +54 -0
- package/simpleble/src/backends/android/types/android/bluetooth/BluetoothGatt.cpp +115 -0
- package/simpleble/src/backends/android/types/android/bluetooth/BluetoothGatt.h +75 -0
- package/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattCharacteristic.cpp +142 -0
- package/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattCharacteristic.h +66 -0
- package/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattDescriptor.cpp +67 -0
- package/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattDescriptor.h +46 -0
- package/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattService.cpp +106 -0
- package/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattService.h +47 -0
- package/simpleble/src/backends/android/types/android/bluetooth/le/BluetoothScanner.cpp +47 -0
- package/simpleble/src/backends/android/types/android/bluetooth/le/BluetoothScanner.h +37 -0
- package/simpleble/src/backends/android/types/android/bluetooth/le/ScanRecord.cpp +69 -0
- package/simpleble/src/backends/android/types/android/bluetooth/le/ScanRecord.h +41 -0
- package/simpleble/src/backends/android/types/android/bluetooth/le/ScanResult.cpp +63 -0
- package/simpleble/src/backends/android/types/android/bluetooth/le/ScanResult.h +42 -0
- package/simpleble/src/backends/android/types/android/os/ParcelUUID.cpp +32 -0
- package/simpleble/src/backends/android/types/android/os/ParcelUUID.h +30 -0
- package/simpleble/src/backends/android/types/android/util/SparseArray.cpp +54 -0
- package/simpleble/src/backends/android/types/android/util/SparseArray.h +37 -0
- package/simpleble/src/backends/android/types/java/util/Iterator.cpp +36 -0
- package/simpleble/src/backends/android/types/java/util/Iterator.h +28 -0
- package/simpleble/src/backends/android/types/java/util/List.cpp +29 -0
- package/simpleble/src/backends/android/types/java/util/List.h +27 -0
- package/simpleble/src/backends/android/types/java/util/Set.cpp +33 -0
- package/simpleble/src/backends/android/types/java/util/Set.h +28 -0
- package/simpleble/src/backends/android/types/java/util/UUID.cpp +26 -0
- package/simpleble/src/backends/android/types/java/util/UUID.h +29 -0
- package/simpleble/src/backends/common/AdapterBase.cpp +53 -0
- package/simpleble/src/backends/common/AdapterBase.h +81 -0
- package/simpleble/src/backends/common/AdapterBaseTypes.h +22 -0
- package/simpleble/src/backends/common/BackendBase.h +20 -0
- package/simpleble/src/backends/common/BackendUtils.h +33 -0
- package/simpleble/src/backends/common/CharacteristicBase.cpp +28 -0
- package/simpleble/src/backends/common/CharacteristicBase.h +38 -0
- package/simpleble/src/backends/common/DescriptorBase.cpp +7 -0
- package/simpleble/src/backends/common/DescriptorBase.h +19 -0
- package/simpleble/src/backends/common/PeripheralBase.h +82 -0
- package/simpleble/src/backends/common/ServiceBase.cpp +18 -0
- package/simpleble/src/backends/common/ServiceBase.h +28 -0
- package/simpleble/src/backends/dongl/AdapterBaseTypes.h +22 -0
- package/simpleble/src/backends/dongl/AdapterDongl.cpp +369 -0
- package/simpleble/src/backends/dongl/AdapterDongl.h +60 -0
- package/simpleble/src/backends/dongl/BackendDongl.cpp +35 -0
- package/simpleble/src/backends/dongl/PeripheralDongl.cpp +562 -0
- package/simpleble/src/backends/dongl/PeripheralDongl.h +136 -0
- package/simpleble/src/backends/dongl/protocol/basic.pb.c +33 -0
- package/simpleble/src/backends/dongl/protocol/basic.pb.h +172 -0
- package/simpleble/src/backends/dongl/protocol/d2h.pb.c +18 -0
- package/simpleble/src/backends/dongl/protocol/d2h.pb.h +118 -0
- package/simpleble/src/backends/dongl/protocol/h2d.pb.c +12 -0
- package/simpleble/src/backends/dongl/protocol/h2d.pb.h +69 -0
- package/simpleble/src/backends/dongl/protocol/simpleble.pb.c +123 -0
- package/simpleble/src/backends/dongl/protocol/simpleble.pb.h +908 -0
- package/simpleble/src/backends/dongl/protocol/softdevice.pb.c +18 -0
- package/simpleble/src/backends/dongl/protocol/softdevice.pb.h +815 -0
- package/simpleble/src/backends/dongl/protocol/softdevice_gap.pb.c +339 -0
- package/simpleble/src/backends/dongl/protocol/softdevice_gap.pb.h +2086 -0
- package/simpleble/src/backends/dongl/protocol/softdevice_gattc.pb.c +114 -0
- package/simpleble/src/backends/dongl/protocol/softdevice_gattc.pb.h +772 -0
- package/simpleble/src/backends/dongl/protocol/softdevice_gatts.pb.c +117 -0
- package/simpleble/src/backends/dongl/protocol/softdevice_gatts.pb.h +766 -0
- package/simpleble/src/backends/dongl/protocol/softdevice_types.pb.c +207 -0
- package/simpleble/src/backends/dongl/protocol/softdevice_types.pb.h +1686 -0
- package/simpleble/src/backends/dongl/serial/Protocol.cpp +887 -0
- package/simpleble/src/backends/dongl/serial/Protocol.h +117 -0
- package/simpleble/src/backends/dongl/serial/ProtocolBase.cpp +95 -0
- package/simpleble/src/backends/dongl/serial/ProtocolBase.h +54 -0
- package/simpleble/src/backends/dongl/serial/Wire.cpp +133 -0
- package/simpleble/src/backends/dongl/serial/Wire.h +116 -0
- package/simpleble/src/backends/dongl/usb/UsbHelper.cpp +53 -0
- package/simpleble/src/backends/dongl/usb/UsbHelper.h +32 -0
- package/simpleble/src/backends/dongl/usb/UsbHelperApple.cpp +266 -0
- package/simpleble/src/backends/dongl/usb/UsbHelperApple.h +34 -0
- package/simpleble/src/backends/dongl/usb/UsbHelperImpl.h +29 -0
- package/simpleble/src/backends/dongl/usb/UsbHelperLinux.cpp +21 -0
- package/simpleble/src/backends/dongl/usb/UsbHelperLinux.h +22 -0
- package/simpleble/src/backends/dongl/usb/UsbHelperNull.cpp +21 -0
- package/simpleble/src/backends/dongl/usb/UsbHelperNull.h +22 -0
- package/simpleble/src/backends/dongl/usb/UsbHelperWindows.cpp +21 -0
- package/simpleble/src/backends/dongl/usb/UsbHelperWindows.h +22 -0
- package/simpleble/src/backends/linux/AdapterLinux.cpp +102 -0
- package/simpleble/src/backends/linux/AdapterLinux.h +55 -0
- package/simpleble/src/backends/linux/BackendBluez.cpp +90 -0
- package/simpleble/src/backends/linux/PeripheralLinux.cpp +394 -0
- package/simpleble/src/backends/linux/PeripheralLinux.h +90 -0
- package/simpleble/src/backends/linux_legacy/AdapterLinuxLegacy.cpp +102 -0
- package/simpleble/src/backends/linux_legacy/AdapterLinuxLegacy.h +55 -0
- package/simpleble/src/backends/linux_legacy/BackendBluezLegacy.cpp +87 -0
- package/simpleble/src/backends/linux_legacy/PeripheralLinuxLegacy.cpp +376 -0
- package/simpleble/src/backends/linux_legacy/PeripheralLinuxLegacy.h +90 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/Adapter.h +46 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/Agent.h +52 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/Bluez.h +37 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/BluezOrg.h +22 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/BluezOrgBluez.h +26 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/BluezRoot.h +32 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/Characteristic.h +47 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/Descriptor.h +33 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/Device.h +64 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/Exceptions.h +43 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/Service.h +27 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/Types.h +9 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/interfaces/Adapter1.h +49 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/interfaces/Agent1.h +100 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/interfaces/AgentManager1.h +24 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/interfaces/Battery1.h +32 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/interfaces/Device1.h +62 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/interfaces/GattCharacteristic1.h +48 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/interfaces/GattDescriptor1.h +41 -0
- package/simpleble/src/backends/linux_legacy/include/simplebluezlegacy/interfaces/GattService1.h +28 -0
- package/simpleble/src/backends/linux_legacy/include/simpledbuslegacy/advanced/Interface.h +67 -0
- package/simpleble/src/backends/linux_legacy/include/simpledbuslegacy/advanced/InterfaceRegistry.h +62 -0
- package/simpleble/src/backends/linux_legacy/include/simpledbuslegacy/advanced/Proxy.h +117 -0
- package/simpleble/src/backends/linux_legacy/include/simpledbuslegacy/base/Connection.h +50 -0
- package/simpleble/src/backends/linux_legacy/include/simpledbuslegacy/base/Exceptions.h +56 -0
- package/simpleble/src/backends/linux_legacy/include/simpledbuslegacy/base/Holder.h +147 -0
- package/simpleble/src/backends/linux_legacy/include/simpledbuslegacy/base/Logging.h +57 -0
- package/simpleble/src/backends/linux_legacy/include/simpledbuslegacy/base/Message.h +89 -0
- package/simpleble/src/backends/linux_legacy/include/simpledbuslegacy/base/Path.h +24 -0
- package/simpleble/src/backends/linux_legacy/include/simpledbuslegacy/interfaces/ObjectManager.h +26 -0
- package/simpleble/src/backends/linux_legacy/src/Adapter.cpp +78 -0
- package/simpleble/src/backends/linux_legacy/src/Agent.cpp +72 -0
- package/simpleble/src/backends/linux_legacy/src/Bluez.cpp +45 -0
- package/simpleble/src/backends/linux_legacy/src/BluezOrg.cpp +20 -0
- package/simpleble/src/backends/linux_legacy/src/BluezOrgBluez.cpp +23 -0
- package/simpleble/src/backends/linux_legacy/src/BluezRoot.cpp +44 -0
- package/simpleble/src/backends/linux_legacy/src/Characteristic.cpp +64 -0
- package/simpleble/src/backends/linux_legacy/src/Descriptor.cpp +27 -0
- package/simpleble/src/backends/linux_legacy/src/Device.cpp +104 -0
- package/simpleble/src/backends/linux_legacy/src/Exceptions.cpp +29 -0
- package/simpleble/src/backends/linux_legacy/src/Service.cpp +33 -0
- package/simpleble/src/backends/linux_legacy/src/advanced/Interface.cpp +155 -0
- package/simpleble/src/backends/linux_legacy/src/advanced/Proxy.cpp +374 -0
- package/simpleble/src/backends/linux_legacy/src/base/Connection.cpp +219 -0
- package/simpleble/src/backends/linux_legacy/src/base/Exceptions.cpp +39 -0
- package/simpleble/src/backends/linux_legacy/src/base/Holder.cpp +739 -0
- package/simpleble/src/backends/linux_legacy/src/base/Message.cpp +622 -0
- package/simpleble/src/backends/linux_legacy/src/base/Path.cpp +129 -0
- package/simpleble/src/backends/linux_legacy/src/interfaces/Adapter1.cpp +123 -0
- package/simpleble/src/backends/linux_legacy/src/interfaces/Agent1.cpp +143 -0
- package/simpleble/src/backends/linux_legacy/src/interfaces/AgentManager1.cpp +34 -0
- package/simpleble/src/backends/linux_legacy/src/interfaces/Battery1.cpp +30 -0
- package/simpleble/src/backends/linux_legacy/src/interfaces/Device1.cpp +170 -0
- package/simpleble/src/backends/linux_legacy/src/interfaces/GattCharacteristic1.cpp +118 -0
- package/simpleble/src/backends/linux_legacy/src/interfaces/GattDescriptor1.cpp +78 -0
- package/simpleble/src/backends/linux_legacy/src/interfaces/GattService1.cpp +28 -0
- package/simpleble/src/backends/linux_legacy/src/interfaces/ObjectManager.cpp +58 -0
- package/simpleble/src/backends/macos/AdapterBaseMacOS.h +29 -0
- package/simpleble/src/backends/macos/AdapterBaseMacOS.mm +235 -0
- package/simpleble/src/backends/macos/AdapterMac.h +78 -0
- package/simpleble/src/backends/macos/AdapterMac.mm +156 -0
- package/simpleble/src/backends/macos/BackendCoreBluetooth.mm +45 -0
- package/simpleble/src/backends/macos/PeripheralBaseMacOS.h +49 -0
- package/simpleble/src/backends/macos/PeripheralBaseMacOS.mm +714 -0
- package/simpleble/src/backends/macos/PeripheralMac.h +81 -0
- package/simpleble/src/backends/macos/PeripheralMac.mm +229 -0
- package/simpleble/src/backends/macos/Utils.h +9 -0
- package/simpleble/src/backends/macos/Utils.mm +23 -0
- package/simpleble/src/backends/plain/AdapterPlain.cpp +65 -0
- package/simpleble/src/backends/plain/AdapterPlain.h +49 -0
- package/simpleble/src/backends/plain/BackendPlain.cpp +30 -0
- package/simpleble/src/backends/plain/PeripheralPlain.cpp +159 -0
- package/simpleble/src/backends/plain/PeripheralPlain.h +72 -0
- package/simpleble/src/backends/windows/AdapterWindows.cpp +338 -0
- package/simpleble/src/backends/windows/AdapterWindows.h +89 -0
- package/simpleble/src/backends/windows/BackendWinRT.cpp +67 -0
- package/simpleble/src/backends/windows/BackendWinRT.h +18 -0
- package/simpleble/src/backends/windows/MtaManager.cpp +49 -0
- package/simpleble/src/backends/windows/MtaManager.h +90 -0
- package/simpleble/src/backends/windows/PeripheralWindows.cpp +487 -0
- package/simpleble/src/backends/windows/PeripheralWindows.h +129 -0
- package/simpleble/src/backends/windows/Utils.cpp +146 -0
- package/simpleble/src/backends/windows/Utils.h +47 -0
- package/simpleble/src/builders/BuildVec.h +32 -0
- package/simpleble/src/builders/BuilderBase.h +87 -0
- package/simpleble/src/external/TaskRunner.hpp +99 -0
- package/simpleble/src/external/ThreadRunner.h +52 -0
- package/simpleble/src/external/kvn_safe_callback.hpp +66 -0
- package/simpleble/src/external/kvn_safe_map.hpp +94 -0
- package/simpleble/src/external/kvn_threadrunner.hpp +70 -0
- package/simpleble/src/external/logfwd.hpp +35 -0
- package/simpleble/src/frontends/base/Adapter.cpp +111 -0
- package/simpleble/src/frontends/base/Advanced.cpp +34 -0
- package/simpleble/src/frontends/base/Backend.cpp +95 -0
- package/simpleble/src/frontends/base/Backend.h +76 -0
- package/simpleble/src/frontends/base/Characteristic.cpp +56 -0
- package/simpleble/src/frontends/base/Descriptor.cpp +21 -0
- package/simpleble/src/frontends/base/Peripheral.cpp +113 -0
- package/simpleble/src/frontends/base/Service.cpp +26 -0
- package/simpleble/src/frontends/safe/AdapterSafe.cpp +158 -0
- package/simpleble/src/frontends/safe/PeripheralSafe.cpp +219 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
#include <simpleble/Peripheral.h>
|
|
2
|
+
|
|
3
|
+
#include <simpleble/Exceptions.h>
|
|
4
|
+
#include "BuildVec.h"
|
|
5
|
+
#include "PeripheralBase.h"
|
|
6
|
+
|
|
7
|
+
using namespace SimpleBLE;
|
|
8
|
+
|
|
9
|
+
bool Peripheral::initialized() const { return internal_ != nullptr; }
|
|
10
|
+
|
|
11
|
+
PeripheralBase* Peripheral::operator->() {
|
|
12
|
+
if (!initialized()) throw Exception::NotInitialized();
|
|
13
|
+
|
|
14
|
+
return internal_.get();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const PeripheralBase* Peripheral::operator->() const {
|
|
18
|
+
if (!initialized()) throw Exception::NotInitialized();
|
|
19
|
+
|
|
20
|
+
return internal_.get();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
std::string Peripheral::identifier() { return (*this)->identifier(); }
|
|
24
|
+
|
|
25
|
+
SimpleBLE::BluetoothAddress Peripheral::address() { return (*this)->address(); }
|
|
26
|
+
|
|
27
|
+
SimpleBLE::BluetoothAddressType Peripheral::address_type() { return (*this)->address_type(); }
|
|
28
|
+
|
|
29
|
+
int16_t Peripheral::rssi() { return (*this)->rssi(); }
|
|
30
|
+
|
|
31
|
+
int16_t Peripheral::tx_power() { return (*this)->tx_power(); }
|
|
32
|
+
|
|
33
|
+
uint16_t Peripheral::mtu() { return (*this)->mtu(); }
|
|
34
|
+
|
|
35
|
+
void Peripheral::connect() { return (*this)->connect(); }
|
|
36
|
+
|
|
37
|
+
void Peripheral::disconnect() { return (*this)->disconnect(); }
|
|
38
|
+
|
|
39
|
+
bool Peripheral::is_connected() { return (*this)->is_connected(); }
|
|
40
|
+
|
|
41
|
+
bool Peripheral::is_connectable() { return (*this)->is_connectable(); }
|
|
42
|
+
|
|
43
|
+
bool Peripheral::is_paired() { return (*this)->is_paired(); }
|
|
44
|
+
|
|
45
|
+
void Peripheral::unpair() { return (*this)->unpair(); }
|
|
46
|
+
|
|
47
|
+
std::vector<Service> Peripheral::services() {
|
|
48
|
+
return Factory::vector(is_connected() ? internal_->available_services() : internal_->advertised_services());
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
std::map<uint16_t, ByteArray> Peripheral::manufacturer_data() { return (*this)->manufacturer_data(); }
|
|
52
|
+
|
|
53
|
+
ByteArray Peripheral::read(BluetoothUUID const& service, BluetoothUUID const& characteristic) {
|
|
54
|
+
if (!is_connected()) throw Exception::NotConnected();
|
|
55
|
+
|
|
56
|
+
return internal_->read(service, characteristic);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
void Peripheral::write_request(BluetoothUUID const& service, BluetoothUUID const& characteristic,
|
|
60
|
+
ByteArray const& data) {
|
|
61
|
+
if (!is_connected()) throw Exception::NotConnected();
|
|
62
|
+
|
|
63
|
+
internal_->write_request(service, characteristic, data);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
void Peripheral::write_command(BluetoothUUID const& service, BluetoothUUID const& characteristic,
|
|
67
|
+
ByteArray const& data) {
|
|
68
|
+
if (!is_connected()) throw Exception::NotConnected();
|
|
69
|
+
|
|
70
|
+
internal_->write_command(service, characteristic, data);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
void Peripheral::notify(BluetoothUUID const& service, BluetoothUUID const& characteristic,
|
|
74
|
+
std::function<void(ByteArray payload)> callback) {
|
|
75
|
+
if (!is_connected()) throw Exception::NotConnected();
|
|
76
|
+
|
|
77
|
+
internal_->notify(service, characteristic, std::move(callback));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
void Peripheral::indicate(BluetoothUUID const& service, BluetoothUUID const& characteristic,
|
|
81
|
+
std::function<void(ByteArray payload)> callback) {
|
|
82
|
+
if (!is_connected()) throw Exception::NotConnected();
|
|
83
|
+
|
|
84
|
+
internal_->indicate(service, characteristic, std::move(callback));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
void Peripheral::unsubscribe(BluetoothUUID const& service, BluetoothUUID const& characteristic) {
|
|
88
|
+
if (!is_connected()) throw Exception::NotConnected();
|
|
89
|
+
|
|
90
|
+
internal_->unsubscribe(service, characteristic);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
ByteArray Peripheral::read(BluetoothUUID const& service, BluetoothUUID const& characteristic,
|
|
94
|
+
BluetoothUUID const& descriptor) {
|
|
95
|
+
if (!is_connected()) throw Exception::NotConnected();
|
|
96
|
+
|
|
97
|
+
return internal_->read(service, characteristic, descriptor);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
void Peripheral::write(BluetoothUUID const& service, BluetoothUUID const& characteristic,
|
|
101
|
+
BluetoothUUID const& descriptor, ByteArray const& data) {
|
|
102
|
+
if (!is_connected()) throw Exception::NotConnected();
|
|
103
|
+
|
|
104
|
+
internal_->write(service, characteristic, descriptor, data);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
void Peripheral::set_callback_on_connected(std::function<void()> on_connected) {
|
|
108
|
+
(*this)->set_callback_on_connected(std::move(on_connected));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
void Peripheral::set_callback_on_disconnected(std::function<void()> on_disconnected) {
|
|
112
|
+
(*this)->set_callback_on_disconnected(std::move(on_disconnected));
|
|
113
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#include <simpleble/Service.h>
|
|
2
|
+
|
|
3
|
+
#include "BuildVec.h"
|
|
4
|
+
#include "ServiceBase.h"
|
|
5
|
+
|
|
6
|
+
using namespace SimpleBLE;
|
|
7
|
+
|
|
8
|
+
bool Service::initialized() const { return internal_ != nullptr; }
|
|
9
|
+
|
|
10
|
+
ServiceBase* Service::operator->() {
|
|
11
|
+
if (!initialized()) throw Exception::NotInitialized();
|
|
12
|
+
|
|
13
|
+
return internal_.get();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const ServiceBase* Service::operator->() const {
|
|
17
|
+
if (!initialized()) throw Exception::NotInitialized();
|
|
18
|
+
|
|
19
|
+
return internal_.get();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
BluetoothUUID Service::uuid() { return (*this)->uuid(); }
|
|
23
|
+
|
|
24
|
+
ByteArray Service::data() { return (*this)->data(); }
|
|
25
|
+
|
|
26
|
+
std::vector<Characteristic> Service::characteristics() { return Factory::vector((*this)->characteristics()); }
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
#include <simpleble/AdapterSafe.h>
|
|
2
|
+
|
|
3
|
+
using namespace SimpleBLE;
|
|
4
|
+
|
|
5
|
+
using SPeripheral = SimpleBLE::Safe::Peripheral;
|
|
6
|
+
using SAdapter = SimpleBLE::Safe::Adapter;
|
|
7
|
+
|
|
8
|
+
using UAdapter = SimpleBLE::Adapter;
|
|
9
|
+
|
|
10
|
+
SAdapter::Adapter(UAdapter& adapter) : internal_(adapter) {}
|
|
11
|
+
SAdapter::Adapter(UAdapter&& adapter) : internal_(std::move(adapter)) {}
|
|
12
|
+
|
|
13
|
+
std::optional<std::string> SAdapter::identifier() noexcept {
|
|
14
|
+
try {
|
|
15
|
+
return internal_.identifier();
|
|
16
|
+
} catch (...) {
|
|
17
|
+
return std::nullopt;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
std::optional<SimpleBLE::BluetoothAddress> SAdapter::address() noexcept {
|
|
22
|
+
try {
|
|
23
|
+
return internal_.address();
|
|
24
|
+
} catch (...) {
|
|
25
|
+
return std::nullopt;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
SAdapter::operator SimpleBLE::Adapter() const noexcept { return internal_; }
|
|
30
|
+
|
|
31
|
+
bool SAdapter::scan_start() noexcept {
|
|
32
|
+
try {
|
|
33
|
+
internal_.scan_start();
|
|
34
|
+
return true;
|
|
35
|
+
} catch (...) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
bool SAdapter::scan_stop() noexcept {
|
|
41
|
+
try {
|
|
42
|
+
internal_.scan_stop();
|
|
43
|
+
return true;
|
|
44
|
+
} catch (...) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
bool SAdapter::scan_for(int timeout_ms) noexcept {
|
|
50
|
+
try {
|
|
51
|
+
internal_.scan_for(timeout_ms);
|
|
52
|
+
return true;
|
|
53
|
+
} catch (...) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
std::optional<bool> SAdapter::scan_is_active() noexcept {
|
|
59
|
+
try {
|
|
60
|
+
return internal_.scan_is_active();
|
|
61
|
+
} catch (...) {
|
|
62
|
+
return std::nullopt;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
std::optional<std::vector<SPeripheral>> SAdapter::scan_get_results() noexcept {
|
|
67
|
+
try {
|
|
68
|
+
std::vector<SPeripheral> r;
|
|
69
|
+
for (auto p : internal_.scan_get_results()) {
|
|
70
|
+
r.push_back(std::move(p));
|
|
71
|
+
}
|
|
72
|
+
return r;
|
|
73
|
+
} catch (...) {
|
|
74
|
+
return std::nullopt;
|
|
75
|
+
}
|
|
76
|
+
return std::nullopt;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
std::optional<std::vector<SPeripheral>> SAdapter::get_paired_peripherals() noexcept {
|
|
80
|
+
try {
|
|
81
|
+
std::vector<SPeripheral> r;
|
|
82
|
+
for (auto p : internal_.get_paired_peripherals()) {
|
|
83
|
+
r.push_back(std::move(p));
|
|
84
|
+
}
|
|
85
|
+
return r;
|
|
86
|
+
} catch (...) {
|
|
87
|
+
return std::nullopt;
|
|
88
|
+
}
|
|
89
|
+
return std::nullopt;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
bool SAdapter::set_callback_on_scan_start(std::function<void()> on_scan_start) noexcept {
|
|
93
|
+
try {
|
|
94
|
+
internal_.set_callback_on_scan_start(std::move(on_scan_start));
|
|
95
|
+
return true;
|
|
96
|
+
} catch (...) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
bool SAdapter::set_callback_on_scan_stop(std::function<void()> on_scan_stop) noexcept {
|
|
102
|
+
try {
|
|
103
|
+
internal_.set_callback_on_scan_stop(std::move(on_scan_stop));
|
|
104
|
+
return true;
|
|
105
|
+
} catch (...) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
bool SAdapter::set_callback_on_scan_updated(std::function<void(SPeripheral)> on_scan_updated) noexcept {
|
|
111
|
+
try {
|
|
112
|
+
internal_.set_callback_on_scan_updated(
|
|
113
|
+
[on_scan_updated = std::move(on_scan_updated)](auto p) { on_scan_updated(p); });
|
|
114
|
+
return true;
|
|
115
|
+
} catch (...) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
bool SAdapter::set_callback_on_scan_found(std::function<void(SPeripheral)> on_scan_found) noexcept {
|
|
121
|
+
try {
|
|
122
|
+
internal_.set_callback_on_scan_found([on_scan_found = std::move(on_scan_found)](auto p) { on_scan_found(p); });
|
|
123
|
+
return true;
|
|
124
|
+
} catch (...) {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// NOTE: this should be the implementation once per-adapters are supported
|
|
130
|
+
/*
|
|
131
|
+
std::optional<bool> SAdapter::bluetooth_enabled() noexcept {
|
|
132
|
+
try {
|
|
133
|
+
return internal_.bluetooth_enabled();
|
|
134
|
+
} catch (...) {
|
|
135
|
+
return std::nullopt;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
*/
|
|
139
|
+
std::optional<bool> SAdapter::bluetooth_enabled() noexcept {
|
|
140
|
+
try {
|
|
141
|
+
return UAdapter::bluetooth_enabled();
|
|
142
|
+
} catch (...) {
|
|
143
|
+
return std::nullopt;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
std::optional<std::vector<SAdapter>> SAdapter::get_adapters() noexcept {
|
|
148
|
+
try {
|
|
149
|
+
auto adapters = UAdapter::get_adapters();
|
|
150
|
+
std::vector<SAdapter> safe_adapters;
|
|
151
|
+
for (auto& adapter : adapters) {
|
|
152
|
+
safe_adapters.push_back(std::move(adapter));
|
|
153
|
+
}
|
|
154
|
+
return safe_adapters;
|
|
155
|
+
} catch (...) {
|
|
156
|
+
return std::nullopt;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
#include <simpleble/Exceptions.h>
|
|
2
|
+
#include <simpleble/PeripheralSafe.h>
|
|
3
|
+
|
|
4
|
+
using namespace SimpleBLE::Safe;
|
|
5
|
+
|
|
6
|
+
using SPeripheral = SimpleBLE::Safe::Peripheral;
|
|
7
|
+
using UPeripheral = SimpleBLE::Peripheral;
|
|
8
|
+
|
|
9
|
+
SPeripheral::Peripheral(UPeripheral& peripheral) : internal_(peripheral) {}
|
|
10
|
+
SPeripheral::Peripheral(UPeripheral&& peripheral) : internal_(std::move(peripheral)) {}
|
|
11
|
+
|
|
12
|
+
std::optional<std::string> SPeripheral::identifier() noexcept {
|
|
13
|
+
try {
|
|
14
|
+
return internal_.identifier();
|
|
15
|
+
} catch (...) {
|
|
16
|
+
return std::nullopt;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
std::optional<SimpleBLE::BluetoothAddress> SPeripheral::address() noexcept {
|
|
21
|
+
try {
|
|
22
|
+
return internal_.address();
|
|
23
|
+
} catch (...) {
|
|
24
|
+
return std::nullopt;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
std::optional<SimpleBLE::BluetoothAddressType> SPeripheral::address_type() noexcept {
|
|
29
|
+
try {
|
|
30
|
+
return internal_.address_type();
|
|
31
|
+
} catch (...) {
|
|
32
|
+
return std::nullopt;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
std::optional<int16_t> SPeripheral::rssi() noexcept {
|
|
37
|
+
try {
|
|
38
|
+
return internal_.rssi();
|
|
39
|
+
} catch (...) {
|
|
40
|
+
return std::nullopt;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
std::optional<int16_t> SPeripheral::tx_power() noexcept {
|
|
45
|
+
try {
|
|
46
|
+
return internal_.tx_power();
|
|
47
|
+
} catch (...) {
|
|
48
|
+
return std::nullopt;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
std::optional<uint16_t> SPeripheral::mtu() noexcept {
|
|
52
|
+
try {
|
|
53
|
+
return internal_.mtu();
|
|
54
|
+
} catch (...) {
|
|
55
|
+
return std::nullopt;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
bool SPeripheral::connect() noexcept {
|
|
60
|
+
try {
|
|
61
|
+
internal_.connect();
|
|
62
|
+
return true;
|
|
63
|
+
} catch (...) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
bool SPeripheral::disconnect() noexcept {
|
|
69
|
+
try {
|
|
70
|
+
internal_.disconnect();
|
|
71
|
+
return true;
|
|
72
|
+
} catch (...) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
std::optional<bool> SPeripheral::is_connected() noexcept {
|
|
78
|
+
try {
|
|
79
|
+
return internal_.is_connected();
|
|
80
|
+
} catch (...) {
|
|
81
|
+
return std::nullopt;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
std::optional<bool> SPeripheral::is_connectable() noexcept {
|
|
86
|
+
try {
|
|
87
|
+
return internal_.is_connectable();
|
|
88
|
+
} catch (...) {
|
|
89
|
+
return std::nullopt;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
std::optional<bool> SPeripheral::is_paired() noexcept {
|
|
94
|
+
try {
|
|
95
|
+
return internal_.is_paired();
|
|
96
|
+
} catch (...) {
|
|
97
|
+
return std::nullopt;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
bool SPeripheral::unpair() noexcept {
|
|
102
|
+
try {
|
|
103
|
+
internal_.unpair();
|
|
104
|
+
return true;
|
|
105
|
+
} catch (...) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
std::optional<std::map<uint16_t, SimpleBLE::ByteArray>> SPeripheral::manufacturer_data() noexcept {
|
|
111
|
+
try {
|
|
112
|
+
return internal_.manufacturer_data();
|
|
113
|
+
} catch (...) {
|
|
114
|
+
return std::nullopt;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
std::optional<std::vector<SimpleBLE::Service>> SPeripheral::services() noexcept {
|
|
119
|
+
try {
|
|
120
|
+
return internal_.services();
|
|
121
|
+
} catch (...) {
|
|
122
|
+
return std::nullopt;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
std::optional<SimpleBLE::ByteArray> SPeripheral::read(BluetoothUUID const& service,
|
|
127
|
+
BluetoothUUID const& characteristic) noexcept {
|
|
128
|
+
try {
|
|
129
|
+
return internal_.read(service, characteristic);
|
|
130
|
+
} catch (...) {
|
|
131
|
+
return std::nullopt;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
bool SPeripheral::write_request(BluetoothUUID const& service, BluetoothUUID const& characteristic,
|
|
136
|
+
ByteArray const& data) noexcept {
|
|
137
|
+
try {
|
|
138
|
+
internal_.write_request(service, characteristic, data);
|
|
139
|
+
return true;
|
|
140
|
+
} catch (...) {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
bool SPeripheral::write_command(BluetoothUUID const& service, BluetoothUUID const& characteristic,
|
|
146
|
+
ByteArray const& data) noexcept {
|
|
147
|
+
try {
|
|
148
|
+
internal_.write_command(service, characteristic, data);
|
|
149
|
+
return true;
|
|
150
|
+
} catch (...) {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
bool SPeripheral::notify(BluetoothUUID const& service, BluetoothUUID const& characteristic,
|
|
156
|
+
std::function<void(ByteArray payload)> callback) noexcept {
|
|
157
|
+
try {
|
|
158
|
+
internal_.notify(service, characteristic, std::move(callback));
|
|
159
|
+
return true;
|
|
160
|
+
} catch (...) {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
bool SPeripheral::indicate(BluetoothUUID const& service, BluetoothUUID const& characteristic,
|
|
166
|
+
std::function<void(ByteArray payload)> callback) noexcept {
|
|
167
|
+
try {
|
|
168
|
+
internal_.indicate(service, characteristic, std::move(callback));
|
|
169
|
+
return true;
|
|
170
|
+
} catch (...) {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
bool SPeripheral::unsubscribe(BluetoothUUID const& service, BluetoothUUID const& characteristic) noexcept {
|
|
176
|
+
try {
|
|
177
|
+
internal_.unsubscribe(service, characteristic);
|
|
178
|
+
return true;
|
|
179
|
+
} catch (...) {
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
std::optional<SimpleBLE::ByteArray> SPeripheral::read(BluetoothUUID const& service, BluetoothUUID const& characteristic,
|
|
185
|
+
BluetoothUUID const& descriptor) noexcept {
|
|
186
|
+
try {
|
|
187
|
+
return internal_.read(service, characteristic, descriptor);
|
|
188
|
+
} catch (...) {
|
|
189
|
+
return std::nullopt;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
bool SPeripheral::write(BluetoothUUID const& service, BluetoothUUID const& characteristic,
|
|
194
|
+
BluetoothUUID const& descriptor, ByteArray const& data) noexcept {
|
|
195
|
+
try {
|
|
196
|
+
internal_.write(service, characteristic, descriptor, data);
|
|
197
|
+
return true;
|
|
198
|
+
} catch (...) {
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
bool SPeripheral::set_callback_on_connected(std::function<void()> on_connected) noexcept {
|
|
204
|
+
try {
|
|
205
|
+
internal_.set_callback_on_connected(std::move(on_connected));
|
|
206
|
+
return true;
|
|
207
|
+
} catch (...) {
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
bool SPeripheral::set_callback_on_disconnected(std::function<void()> on_disconnected) noexcept {
|
|
213
|
+
try {
|
|
214
|
+
internal_.set_callback_on_disconnected(std::move(on_disconnected));
|
|
215
|
+
return true;
|
|
216
|
+
} catch (...) {
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
}
|