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.
Files changed (341) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +88 -0
  3. data/LICENSE.txt +21 -0
  4. data/README.md +350 -0
  5. data/ext/simpleble/extconf.rb +57 -0
  6. data/ext/simpleble/simpleble_ruby.c +682 -0
  7. data/lib/simpleble/adapter.rb +10 -0
  8. data/lib/simpleble/characteristic.rb +36 -0
  9. data/lib/simpleble/descriptor.rb +8 -0
  10. data/lib/simpleble/exceptions.rb +25 -0
  11. data/lib/simpleble/peripheral.rb +64 -0
  12. data/lib/simpleble/service.rb +16 -0
  13. data/lib/simpleble/version.rb +3 -0
  14. data/lib/simpleble.rb +40 -0
  15. data/vendor/simpleble/build_simplecble/CMakeFiles/4.0.3/CompilerIdCXX/CMakeCXXCompilerId.cpp +920 -0
  16. data/vendor/simpleble/build_simplecble/CMakeFiles/4.0.3/CompilerIdCXX/apple-sdk.cpp +1 -0
  17. data/vendor/simpleble/build_simplecble/CMakeFiles/4.1.0/CompilerIdCXX/CMakeCXXCompilerId.cpp +949 -0
  18. data/vendor/simpleble/build_simplecble/CMakeFiles/4.1.0/CompilerIdCXX/apple-sdk.cpp +1 -0
  19. data/vendor/simpleble/build_simplecble/export/simplecble/export.h +43 -0
  20. data/vendor/simpleble/build_simplecble/simpleble/export/simpleble/export.h +43 -0
  21. data/vendor/simpleble/dependencies/external/kvn/kvn_bytearray.h +222 -0
  22. data/vendor/simpleble/dependencies/external/kvn/kvn_safe_callback.hpp +66 -0
  23. data/vendor/simpleble/dependencies/external/kvn/logfwd.hpp +35 -0
  24. data/vendor/simpleble/dependencies/internal/fmt/args.h +220 -0
  25. data/vendor/simpleble/dependencies/internal/fmt/base.h +2962 -0
  26. data/vendor/simpleble/dependencies/internal/fmt/chrono.h +2338 -0
  27. data/vendor/simpleble/dependencies/internal/fmt/color.h +610 -0
  28. data/vendor/simpleble/dependencies/internal/fmt/compile.h +539 -0
  29. data/vendor/simpleble/dependencies/internal/fmt/core.h +5 -0
  30. data/vendor/simpleble/dependencies/internal/fmt/format-inl.h +1949 -0
  31. data/vendor/simpleble/dependencies/internal/fmt/format.h +4244 -0
  32. data/vendor/simpleble/dependencies/internal/fmt/os.h +427 -0
  33. data/vendor/simpleble/dependencies/internal/fmt/ostream.h +166 -0
  34. data/vendor/simpleble/dependencies/internal/fmt/printf.h +633 -0
  35. data/vendor/simpleble/dependencies/internal/fmt/ranges.h +850 -0
  36. data/vendor/simpleble/dependencies/internal/fmt/std.h +726 -0
  37. data/vendor/simpleble/dependencies/internal/fmt/xchar.h +373 -0
  38. data/vendor/simpleble/dependencies/internal/simplejni/Common.hpp +579 -0
  39. data/vendor/simpleble/dependencies/internal/simplejni/References.hpp +151 -0
  40. data/vendor/simpleble/dependencies/internal/simplejni/Registry.hpp +183 -0
  41. data/vendor/simpleble/dependencies/internal/simplejni/VM.hpp +88 -0
  42. data/vendor/simpleble/examples/simpleble/src/connect.cpp +67 -0
  43. data/vendor/simpleble/examples/simpleble/src/connect_safe.cpp +91 -0
  44. data/vendor/simpleble/examples/simpleble/src/list_adapters.cpp +22 -0
  45. data/vendor/simpleble/examples/simpleble/src/list_adapters_safe.cpp +33 -0
  46. data/vendor/simpleble/examples/simpleble/src/list_paired.cpp +27 -0
  47. data/vendor/simpleble/examples/simpleble/src/multiconnect.cpp +60 -0
  48. data/vendor/simpleble/examples/simpleble/src/notify.cpp +85 -0
  49. data/vendor/simpleble/examples/simpleble/src/notify_multi.cpp +101 -0
  50. data/vendor/simpleble/examples/simpleble/src/power_cycle.cpp +43 -0
  51. data/vendor/simpleble/examples/simpleble/src/read.cpp +82 -0
  52. data/vendor/simpleble/examples/simpleble/src/scan.cpp +62 -0
  53. data/vendor/simpleble/examples/simpleble/src/utils.cpp +59 -0
  54. data/vendor/simpleble/examples/simpleble/src/utils.hpp +27 -0
  55. data/vendor/simpleble/examples/simpleble/src/write.cpp +81 -0
  56. data/vendor/simpleble/examples/simplebluez/ble_nus/ble_nus.cpp +138 -0
  57. data/vendor/simpleble/examples/simplebluez/connect/connect.cpp +119 -0
  58. data/vendor/simpleble/examples/simplebluez/list_adapters/list_adapters.cpp +44 -0
  59. data/vendor/simpleble/examples/simplebluez/list_paired/list_paired.cpp +48 -0
  60. data/vendor/simpleble/examples/simplebluez/notify/notify.cpp +145 -0
  61. data/vendor/simpleble/examples/simplebluez/pair/pair.cpp +181 -0
  62. data/vendor/simpleble/examples/simplebluez/read/read.cpp +141 -0
  63. data/vendor/simpleble/examples/simplebluez/scan/scan.cpp +85 -0
  64. data/vendor/simpleble/examples/simplecble/c/connect.c +163 -0
  65. data/vendor/simpleble/examples/simplecble/c/notify.c +217 -0
  66. data/vendor/simpleble/examples/simplecble/c/scan.c +164 -0
  67. data/vendor/simpleble/examples/simpledbus/notification.cpp +24 -0
  68. data/vendor/simpleble/hitl/src/test_sanity.cpp +48 -0
  69. data/vendor/simpleble/install_simplecble/include/simpleble/Adapter.h +102 -0
  70. data/vendor/simpleble/install_simplecble/include/simpleble/AdapterSafe.h +58 -0
  71. data/vendor/simpleble/install_simplecble/include/simpleble/Advanced.h +50 -0
  72. data/vendor/simpleble/install_simplecble/include/simpleble/Characteristic.h +39 -0
  73. data/vendor/simpleble/install_simplecble/include/simpleble/Config.h +55 -0
  74. data/vendor/simpleble/install_simplecble/include/simpleble/Descriptor.h +30 -0
  75. data/vendor/simpleble/install_simplecble/include/simpleble/Exceptions.h +72 -0
  76. data/vendor/simpleble/install_simplecble/include/simpleble/Logging.h +73 -0
  77. data/vendor/simpleble/install_simplecble/include/simpleble/Peripheral.h +82 -0
  78. data/vendor/simpleble/install_simplecble/include/simpleble/PeripheralSafe.h +64 -0
  79. data/vendor/simpleble/install_simplecble/include/simpleble/Service.h +34 -0
  80. data/vendor/simpleble/install_simplecble/include/simpleble/SimpleBLE.h +8 -0
  81. data/vendor/simpleble/install_simplecble/include/simpleble/Types.h +49 -0
  82. data/vendor/simpleble/install_simplecble/include/simpleble/Utils.h +13 -0
  83. data/vendor/simpleble/install_simplecble/include/simpleble/export.h +43 -0
  84. data/vendor/simpleble/install_simplecble/include/simpleble/kvn/kvn_bytearray.h +222 -0
  85. data/vendor/simpleble/install_simplecble/include/simplecble/adapter.h +188 -0
  86. data/vendor/simpleble/install_simplecble/include/simplecble/logging.h +37 -0
  87. data/vendor/simpleble/install_simplecble/include/simplecble/peripheral.h +304 -0
  88. data/vendor/simpleble/install_simplecble/include/simplecble/simpleble.h +21 -0
  89. data/vendor/simpleble/install_simplecble/include/simplecble/types.h +73 -0
  90. data/vendor/simpleble/install_simplecble/include/simplecble/utils.h +27 -0
  91. data/vendor/simpleble/simpleble/include/simpleble/Adapter.h +102 -0
  92. data/vendor/simpleble/simpleble/include/simpleble/AdapterSafe.h +58 -0
  93. data/vendor/simpleble/simpleble/include/simpleble/Characteristic.h +39 -0
  94. data/vendor/simpleble/simpleble/include/simpleble/Config.h +55 -0
  95. data/vendor/simpleble/simpleble/include/simpleble/Descriptor.h +30 -0
  96. data/vendor/simpleble/simpleble/include/simpleble/Exceptions.h +72 -0
  97. data/vendor/simpleble/simpleble/include/simpleble/Logging.h +73 -0
  98. data/vendor/simpleble/simpleble/include/simpleble/Peripheral.h +82 -0
  99. data/vendor/simpleble/simpleble/include/simpleble/PeripheralSafe.h +64 -0
  100. data/vendor/simpleble/simpleble/include/simpleble/Service.h +34 -0
  101. data/vendor/simpleble/simpleble/include/simpleble/SimpleBLE.h +8 -0
  102. data/vendor/simpleble/simpleble/include/simpleble/Types.h +49 -0
  103. data/vendor/simpleble/simpleble/include/simpleble/Utils.h +13 -0
  104. data/vendor/simpleble/simpleble/include/simpleble_c/adapter.h +188 -0
  105. data/vendor/simpleble/simpleble/include/simpleble_c/logging.h +37 -0
  106. data/vendor/simpleble/simpleble/include/simpleble_c/peripheral.h +304 -0
  107. data/vendor/simpleble/simpleble/include/simpleble_c/simpleble.h +21 -0
  108. data/vendor/simpleble/simpleble/include/simpleble_c/types.h +73 -0
  109. data/vendor/simpleble/simpleble/include/simpleble_c/utils.h +27 -0
  110. data/vendor/simpleble/simpleble/src/CommonUtils.h +63 -0
  111. data/vendor/simpleble/simpleble/src/Exceptions.cpp +31 -0
  112. data/vendor/simpleble/simpleble/src/Logging.cpp +136 -0
  113. data/vendor/simpleble/simpleble/src/LoggingInternal.h +85 -0
  114. data/vendor/simpleble/simpleble/src/Utils.cpp +24 -0
  115. data/vendor/simpleble/simpleble/src/backends/android/AdapterAndroid.cpp +101 -0
  116. data/vendor/simpleble/simpleble/src/backends/android/AdapterAndroid.h +70 -0
  117. data/vendor/simpleble/simpleble/src/backends/android/BackendAndroid.cpp +40 -0
  118. data/vendor/simpleble/simpleble/src/backends/android/BackendAndroid.h +20 -0
  119. data/vendor/simpleble/simpleble/src/backends/android/PeripheralAndroid.cpp +365 -0
  120. data/vendor/simpleble/simpleble/src/backends/android/PeripheralAndroid.h +90 -0
  121. data/vendor/simpleble/simpleble/src/backends/android/bridge/BluetoothGattCallback.cpp +432 -0
  122. data/vendor/simpleble/simpleble/src/backends/android/bridge/BluetoothGattCallback.h +102 -0
  123. data/vendor/simpleble/simpleble/src/backends/android/bridge/ScanCallback.cpp +142 -0
  124. data/vendor/simpleble/simpleble/src/backends/android/bridge/ScanCallback.h +55 -0
  125. data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothAdapter.cpp +107 -0
  126. data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothAdapter.h +55 -0
  127. data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothDevice.cpp +68 -0
  128. data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothDevice.h +54 -0
  129. data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGatt.cpp +115 -0
  130. data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGatt.h +75 -0
  131. data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattCharacteristic.cpp +142 -0
  132. data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattCharacteristic.h +66 -0
  133. data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattDescriptor.cpp +67 -0
  134. data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattDescriptor.h +46 -0
  135. data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattService.cpp +106 -0
  136. data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattService.h +47 -0
  137. data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/le/BluetoothScanner.cpp +47 -0
  138. data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/le/BluetoothScanner.h +37 -0
  139. data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/le/ScanRecord.cpp +69 -0
  140. data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/le/ScanRecord.h +41 -0
  141. data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/le/ScanResult.cpp +63 -0
  142. data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/le/ScanResult.h +42 -0
  143. data/vendor/simpleble/simpleble/src/backends/android/types/android/os/ParcelUUID.cpp +32 -0
  144. data/vendor/simpleble/simpleble/src/backends/android/types/android/os/ParcelUUID.h +30 -0
  145. data/vendor/simpleble/simpleble/src/backends/android/types/android/util/SparseArray.cpp +54 -0
  146. data/vendor/simpleble/simpleble/src/backends/android/types/android/util/SparseArray.h +37 -0
  147. data/vendor/simpleble/simpleble/src/backends/android/types/java/util/Iterator.cpp +36 -0
  148. data/vendor/simpleble/simpleble/src/backends/android/types/java/util/Iterator.h +28 -0
  149. data/vendor/simpleble/simpleble/src/backends/android/types/java/util/List.cpp +29 -0
  150. data/vendor/simpleble/simpleble/src/backends/android/types/java/util/List.h +27 -0
  151. data/vendor/simpleble/simpleble/src/backends/android/types/java/util/Set.cpp +33 -0
  152. data/vendor/simpleble/simpleble/src/backends/android/types/java/util/Set.h +28 -0
  153. data/vendor/simpleble/simpleble/src/backends/android/types/java/util/UUID.cpp +26 -0
  154. data/vendor/simpleble/simpleble/src/backends/android/types/java/util/UUID.h +29 -0
  155. data/vendor/simpleble/simpleble/src/backends/common/AdapterBase.cpp +53 -0
  156. data/vendor/simpleble/simpleble/src/backends/common/AdapterBase.h +81 -0
  157. data/vendor/simpleble/simpleble/src/backends/common/AdapterBaseTypes.h +22 -0
  158. data/vendor/simpleble/simpleble/src/backends/common/BackendBase.h +20 -0
  159. data/vendor/simpleble/simpleble/src/backends/common/BackendUtils.h +33 -0
  160. data/vendor/simpleble/simpleble/src/backends/common/CharacteristicBase.cpp +28 -0
  161. data/vendor/simpleble/simpleble/src/backends/common/CharacteristicBase.h +38 -0
  162. data/vendor/simpleble/simpleble/src/backends/common/DescriptorBase.cpp +7 -0
  163. data/vendor/simpleble/simpleble/src/backends/common/DescriptorBase.h +19 -0
  164. data/vendor/simpleble/simpleble/src/backends/common/PeripheralBase.h +82 -0
  165. data/vendor/simpleble/simpleble/src/backends/common/ServiceBase.cpp +18 -0
  166. data/vendor/simpleble/simpleble/src/backends/common/ServiceBase.h +28 -0
  167. data/vendor/simpleble/simpleble/src/backends/linux/AdapterLinux.cpp +102 -0
  168. data/vendor/simpleble/simpleble/src/backends/linux/AdapterLinux.h +55 -0
  169. data/vendor/simpleble/simpleble/src/backends/linux/BackendBluez.cpp +87 -0
  170. data/vendor/simpleble/simpleble/src/backends/linux/PeripheralLinux.cpp +376 -0
  171. data/vendor/simpleble/simpleble/src/backends/linux/PeripheralLinux.h +90 -0
  172. data/vendor/simpleble/simpleble/src/backends/macos/AdapterBaseMacOS.h +29 -0
  173. data/vendor/simpleble/simpleble/src/backends/macos/AdapterMac.h +78 -0
  174. data/vendor/simpleble/simpleble/src/backends/macos/PeripheralBaseMacOS.h +49 -0
  175. data/vendor/simpleble/simpleble/src/backends/macos/PeripheralMac.h +81 -0
  176. data/vendor/simpleble/simpleble/src/backends/macos/Utils.h +9 -0
  177. data/vendor/simpleble/simpleble/src/backends/plain/AdapterPlain.cpp +65 -0
  178. data/vendor/simpleble/simpleble/src/backends/plain/AdapterPlain.h +49 -0
  179. data/vendor/simpleble/simpleble/src/backends/plain/BackendPlain.cpp +30 -0
  180. data/vendor/simpleble/simpleble/src/backends/plain/PeripheralPlain.cpp +159 -0
  181. data/vendor/simpleble/simpleble/src/backends/plain/PeripheralPlain.h +72 -0
  182. data/vendor/simpleble/simpleble/src/backends/windows/AdapterWindows.cpp +330 -0
  183. data/vendor/simpleble/simpleble/src/backends/windows/AdapterWindows.h +89 -0
  184. data/vendor/simpleble/simpleble/src/backends/windows/BackendWinRT.cpp +67 -0
  185. data/vendor/simpleble/simpleble/src/backends/windows/BackendWinRT.h +18 -0
  186. data/vendor/simpleble/simpleble/src/backends/windows/MtaManager.cpp +49 -0
  187. data/vendor/simpleble/simpleble/src/backends/windows/MtaManager.h +90 -0
  188. data/vendor/simpleble/simpleble/src/backends/windows/PeripheralWindows.cpp +487 -0
  189. data/vendor/simpleble/simpleble/src/backends/windows/PeripheralWindows.h +129 -0
  190. data/vendor/simpleble/simpleble/src/backends/windows/Utils.cpp +146 -0
  191. data/vendor/simpleble/simpleble/src/backends/windows/Utils.h +47 -0
  192. data/vendor/simpleble/simpleble/src/builders/BuildVec.h +32 -0
  193. data/vendor/simpleble/simpleble/src/builders/BuilderBase.h +87 -0
  194. data/vendor/simpleble/simpleble/src/external/TaskRunner.hpp +99 -0
  195. data/vendor/simpleble/simpleble/src/external/ThreadRunner.h +52 -0
  196. data/vendor/simpleble/simpleble/src/external/kvn_safe_callback.hpp +66 -0
  197. data/vendor/simpleble/simpleble/src/external/kvn_safe_map.hpp +94 -0
  198. data/vendor/simpleble/simpleble/src/external/kvn_threadrunner.hpp +70 -0
  199. data/vendor/simpleble/simpleble/src/external/logfwd.hpp +35 -0
  200. data/vendor/simpleble/simpleble/src/frontends/base/Adapter.cpp +111 -0
  201. data/vendor/simpleble/simpleble/src/frontends/base/Backend.cpp +83 -0
  202. data/vendor/simpleble/simpleble/src/frontends/base/Backend.h +76 -0
  203. data/vendor/simpleble/simpleble/src/frontends/base/Characteristic.cpp +56 -0
  204. data/vendor/simpleble/simpleble/src/frontends/base/Descriptor.cpp +21 -0
  205. data/vendor/simpleble/simpleble/src/frontends/base/Peripheral.cpp +113 -0
  206. data/vendor/simpleble/simpleble/src/frontends/base/Service.cpp +26 -0
  207. data/vendor/simpleble/simpleble/src/frontends/safe/AdapterSafe.cpp +158 -0
  208. data/vendor/simpleble/simpleble/src/frontends/safe/PeripheralSafe.cpp +219 -0
  209. data/vendor/simpleble/simpleble/src_c/adapter.cpp +204 -0
  210. data/vendor/simpleble/simpleble/src_c/logging.cpp +19 -0
  211. data/vendor/simpleble/simpleble/src_c/peripheral.cpp +444 -0
  212. data/vendor/simpleble/simpleble/src_c/simpleble.cpp +5 -0
  213. data/vendor/simpleble/simpleble/src_c/utils.cpp +15 -0
  214. data/vendor/simpleble/simpleble/test/src/main.cpp +8 -0
  215. data/vendor/simpleble/simpleble/test/src/test_bytearray.cpp +246 -0
  216. data/vendor/simpleble/simpleble/test/src/test_utils.cpp +24 -0
  217. data/vendor/simpleble/simplebluez/include/simplebluez/Adapter.h +46 -0
  218. data/vendor/simpleble/simplebluez/include/simplebluez/Agent.h +52 -0
  219. data/vendor/simpleble/simplebluez/include/simplebluez/Bluez.h +37 -0
  220. data/vendor/simpleble/simplebluez/include/simplebluez/BluezOrg.h +22 -0
  221. data/vendor/simpleble/simplebluez/include/simplebluez/BluezOrgBluez.h +26 -0
  222. data/vendor/simpleble/simplebluez/include/simplebluez/BluezRoot.h +32 -0
  223. data/vendor/simpleble/simplebluez/include/simplebluez/Characteristic.h +46 -0
  224. data/vendor/simpleble/simplebluez/include/simplebluez/Descriptor.h +33 -0
  225. data/vendor/simpleble/simplebluez/include/simplebluez/Device.h +64 -0
  226. data/vendor/simpleble/simplebluez/include/simplebluez/Exceptions.h +43 -0
  227. data/vendor/simpleble/simplebluez/include/simplebluez/Service.h +27 -0
  228. data/vendor/simpleble/simplebluez/include/simplebluez/Types.h +9 -0
  229. data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/Adapter1.h +49 -0
  230. data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/Agent1.h +100 -0
  231. data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/AgentManager1.h +24 -0
  232. data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/Battery1.h +32 -0
  233. data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/Device1.h +62 -0
  234. data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/GattCharacteristic1.h +48 -0
  235. data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/GattDescriptor1.h +41 -0
  236. data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/GattService1.h +28 -0
  237. data/vendor/simpleble/simplebluez/src/Adapter.cpp +78 -0
  238. data/vendor/simpleble/simplebluez/src/Agent.cpp +72 -0
  239. data/vendor/simpleble/simplebluez/src/Bluez.cpp +45 -0
  240. data/vendor/simpleble/simplebluez/src/BluezOrg.cpp +20 -0
  241. data/vendor/simpleble/simplebluez/src/BluezOrgBluez.cpp +23 -0
  242. data/vendor/simpleble/simplebluez/src/BluezRoot.cpp +44 -0
  243. data/vendor/simpleble/simplebluez/src/Characteristic.cpp +64 -0
  244. data/vendor/simpleble/simplebluez/src/Descriptor.cpp +27 -0
  245. data/vendor/simpleble/simplebluez/src/Device.cpp +104 -0
  246. data/vendor/simpleble/simplebluez/src/Exceptions.cpp +29 -0
  247. data/vendor/simpleble/simplebluez/src/Logging.cpp +52 -0
  248. data/vendor/simpleble/simplebluez/src/Logging.h +57 -0
  249. data/vendor/simpleble/simplebluez/src/Service.cpp +33 -0
  250. data/vendor/simpleble/simplebluez/src/interfaces/Adapter1.cpp +123 -0
  251. data/vendor/simpleble/simplebluez/src/interfaces/Agent1.cpp +143 -0
  252. data/vendor/simpleble/simplebluez/src/interfaces/AgentManager1.cpp +34 -0
  253. data/vendor/simpleble/simplebluez/src/interfaces/Battery1.cpp +30 -0
  254. data/vendor/simpleble/simplebluez/src/interfaces/Device1.cpp +170 -0
  255. data/vendor/simpleble/simplebluez/src/interfaces/GattCharacteristic1.cpp +118 -0
  256. data/vendor/simpleble/simplebluez/src/interfaces/GattDescriptor1.cpp +78 -0
  257. data/vendor/simpleble/simplebluez/src/interfaces/GattService1.cpp +28 -0
  258. data/vendor/simpleble/simplebluez/test/src/helpers/PythonRunner.cpp +53 -0
  259. data/vendor/simpleble/simplebluez/test/src/helpers/PythonRunner.h +24 -0
  260. data/vendor/simpleble/simplebluez/test/src/main.cpp +16 -0
  261. data/vendor/simpleble/simplecble/include/simplecble/adapter.h +188 -0
  262. data/vendor/simpleble/simplecble/include/simplecble/logging.h +37 -0
  263. data/vendor/simpleble/simplecble/include/simplecble/peripheral.h +304 -0
  264. data/vendor/simpleble/simplecble/include/simplecble/simpleble.h +21 -0
  265. data/vendor/simpleble/simplecble/include/simplecble/types.h +73 -0
  266. data/vendor/simpleble/simplecble/include/simplecble/utils.h +27 -0
  267. data/vendor/simpleble/simplecble/src/adapter.cpp +204 -0
  268. data/vendor/simpleble/simplecble/src/logging.cpp +19 -0
  269. data/vendor/simpleble/simplecble/src/peripheral.cpp +444 -0
  270. data/vendor/simpleble/simplecble/src/simpleble.cpp +5 -0
  271. data/vendor/simpleble/simplecble/src/utils.cpp +15 -0
  272. data/vendor/simpleble/simpledbus/include/simpledbus/advanced/Interface.h +67 -0
  273. data/vendor/simpleble/simpledbus/include/simpledbus/advanced/InterfaceRegistry.h +64 -0
  274. data/vendor/simpleble/simpledbus/include/simpledbus/advanced/Proxy.h +117 -0
  275. data/vendor/simpleble/simpledbus/include/simpledbus/base/Connection.h +50 -0
  276. data/vendor/simpleble/simpledbus/include/simpledbus/base/Exceptions.h +56 -0
  277. data/vendor/simpleble/simpledbus/include/simpledbus/base/Holder.h +147 -0
  278. data/vendor/simpleble/simpledbus/include/simpledbus/base/Logging.h +57 -0
  279. data/vendor/simpleble/simpledbus/include/simpledbus/base/Message.h +89 -0
  280. data/vendor/simpleble/simpledbus/include/simpledbus/base/Path.h +24 -0
  281. data/vendor/simpleble/simpledbus/include/simpledbus/interfaces/ObjectManager.h +26 -0
  282. data/vendor/simpleble/simpledbus/src/advanced/Interface.cpp +155 -0
  283. data/vendor/simpleble/simpledbus/src/advanced/Proxy.cpp +375 -0
  284. data/vendor/simpleble/simpledbus/src/base/Connection.cpp +222 -0
  285. data/vendor/simpleble/simpledbus/src/base/Exceptions.cpp +39 -0
  286. data/vendor/simpleble/simpledbus/src/base/Holder.cpp +739 -0
  287. data/vendor/simpleble/simpledbus/src/base/Logging.cpp +52 -0
  288. data/vendor/simpleble/simpledbus/src/base/Message.cpp +622 -0
  289. data/vendor/simpleble/simpledbus/src/base/Path.cpp +129 -0
  290. data/vendor/simpleble/simpledbus/src/interfaces/ObjectManager.cpp +58 -0
  291. data/vendor/simpleble/simpledbus/test/src/helpers/PythonRunner.cpp +53 -0
  292. data/vendor/simpleble/simpledbus/test/src/helpers/PythonRunner.h +24 -0
  293. data/vendor/simpleble/simpledbus/test/src/main.cpp +16 -0
  294. data/vendor/simpleble/simpledbus/test/src/test_holder.cpp +184 -0
  295. data/vendor/simpleble/simpledbus/test/src/test_message.cpp +397 -0
  296. data/vendor/simpleble/simpledbus/test/src/test_path.cpp +76 -0
  297. data/vendor/simpleble/simpledbus/test/src/test_proxy_children.cpp +109 -0
  298. data/vendor/simpleble/simpledbus/test/src/test_proxy_interfaces.cpp +102 -0
  299. data/vendor/simpleble/simpledbus/test/src/test_proxy_lifetime.cpp +18 -0
  300. data/vendor/simpleble/simpledroidble/simpledroidble/src/main/cpp/ThreadRunner.h +89 -0
  301. data/vendor/simpleble/simpledroidble/simpledroidble/src/main/cpp/android_utils.cpp +55 -0
  302. data/vendor/simpleble/simpledroidble/simpledroidble/src/main/cpp/android_utils.h +18 -0
  303. data/vendor/simpleble/simpledroidble/simpledroidble/src/main/cpp/simpleble_android.cpp +813 -0
  304. data/vendor/simpleble/simplejavable/cpp/src/core/AdapterWrapper.cpp +37 -0
  305. data/vendor/simpleble/simplejavable/cpp/src/core/AdapterWrapper.h +23 -0
  306. data/vendor/simpleble/simplejavable/cpp/src/core/Cache.cpp +58 -0
  307. data/vendor/simpleble/simplejavable/cpp/src/core/Cache.h +34 -0
  308. data/vendor/simpleble/simplejavable/cpp/src/core/PeripheralWrapper.cpp +17 -0
  309. data/vendor/simpleble/simplejavable/cpp/src/core/PeripheralWrapper.h +19 -0
  310. data/vendor/simpleble/simplejavable/cpp/src/java/lang/ArrayList.cpp +257 -0
  311. data/vendor/simpleble/simplejavable/cpp/src/java/lang/ArrayList.h +78 -0
  312. data/vendor/simpleble/simplejavable/cpp/src/java/lang/HashMap.cpp +96 -0
  313. data/vendor/simpleble/simplejavable/cpp/src/java/lang/HashMap.h +54 -0
  314. data/vendor/simpleble/simplejavable/cpp/src/java/lang/Integer.cpp +93 -0
  315. data/vendor/simpleble/simplejavable/cpp/src/java/lang/Integer.h +49 -0
  316. data/vendor/simpleble/simplejavable/cpp/src/java/lang/Iterator.cpp +85 -0
  317. data/vendor/simpleble/simplejavable/cpp/src/java/lang/Iterator.h +48 -0
  318. data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/AdapterCallback.cpp +91 -0
  319. data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/AdapterCallback.h +90 -0
  320. data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/Characteristic.cpp +35 -0
  321. data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/Characteristic.h +60 -0
  322. data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/DataCallback.cpp +33 -0
  323. data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/DataCallback.h +45 -0
  324. data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/Descriptor.cpp +30 -0
  325. data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/Descriptor.h +49 -0
  326. data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/PeripheralCallback.cpp +41 -0
  327. data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/PeripheralCallback.h +51 -0
  328. data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/Service.cpp +33 -0
  329. data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/Service.h +54 -0
  330. data/vendor/simpleble/simplejavable/cpp/src/simplejavable.cpp +361 -0
  331. data/vendor/simpleble/simplepyble/src/main.cpp +55 -0
  332. data/vendor/simpleble/simplepyble/src/wrap_adapter.cpp +106 -0
  333. data/vendor/simpleble/simplepyble/src/wrap_characteristic.cpp +56 -0
  334. data/vendor/simpleble/simplepyble/src/wrap_config.cpp +136 -0
  335. data/vendor/simpleble/simplepyble/src/wrap_descriptor.cpp +21 -0
  336. data/vendor/simpleble/simplepyble/src/wrap_peripheral.cpp +217 -0
  337. data/vendor/simpleble/simplepyble/src/wrap_service.cpp +32 -0
  338. data/vendor/simpleble/simplepyble/src/wrap_types.cpp +21 -0
  339. data/vendor/simpleble/simplersble/src/bindings/Bindings.cpp +338 -0
  340. data/vendor/simpleble/simplersble/src/bindings/Bindings.hpp +178 -0
  341. metadata +430 -0
@@ -0,0 +1,35 @@
1
+ #ifndef LOGFWD_HPP
2
+ #define LOGFWD_HPP
3
+
4
+ #include <string>
5
+
6
+ namespace logfwd {
7
+
8
+ enum level : int {
9
+ NONE = 0,
10
+ FATAL,
11
+ ERROR,
12
+ WARN,
13
+ INFO,
14
+ #pragma push_macro("DEBUG")
15
+ #undef DEBUG
16
+ DEBUG,
17
+ #pragma pop_macro("DEBUG")
18
+ VERBOSE,
19
+ };
20
+
21
+ // clang-format off
22
+
23
+ void receive(
24
+ level level,
25
+ const std::string& module,
26
+ const std::string& file,
27
+ uint32_t line,
28
+ const std::string& function,
29
+ const std::string& message);
30
+
31
+ // clang-format on
32
+
33
+ } // namespace logfwd
34
+
35
+ #endif // LOGFWD_HPP
@@ -0,0 +1,111 @@
1
+ #include <simpleble/Adapter.h>
2
+ #include "Backend.h"
3
+
4
+ #include "BuildVec.h"
5
+ #include "LoggingInternal.h"
6
+ #include "backends/common/AdapterBase.h"
7
+
8
+ using namespace SimpleBLE;
9
+
10
+ std::vector<Adapter> Adapter::get_adapters() {
11
+ std::vector<Adapter> adapter_list;
12
+ for (auto& backend : Backend::get_backends()) {
13
+ for (auto& adapter : backend.get_adapters()) {
14
+ adapter_list.push_back(adapter);
15
+ }
16
+ }
17
+
18
+ return adapter_list;
19
+ }
20
+
21
+ // TODO: this should be the implementation of the per-backend bluetooth_enabled() function
22
+ // bool Adapter::bluetooth_enabled() { return (*this)->bluetooth_enabled(); }
23
+
24
+ bool Adapter::bluetooth_enabled() { return get_enabled_backend().bluetooth_enabled(); }
25
+
26
+ bool Adapter::initialized() const { return internal_ != nullptr; }
27
+
28
+ void* Adapter::underlying() const { return (*this)->underlying(); }
29
+
30
+ /**
31
+ * Return the adapter implementation if it is initialized.
32
+ *
33
+ * @throws SimpleBLE::NotInitialized if the adapter is not initialized.
34
+ */
35
+ AdapterBase* Adapter::operator->() {
36
+ if (!internal_) {
37
+ throw Exception::NotInitialized();
38
+ }
39
+ return internal_.get();
40
+ }
41
+
42
+ const AdapterBase* Adapter::operator->() const {
43
+ if (!internal_) {
44
+ throw Exception::NotInitialized();
45
+ }
46
+ return internal_.get();
47
+ }
48
+
49
+ std::string Adapter::identifier() { return (*this)->identifier(); }
50
+
51
+ BluetoothAddress Adapter::address() { return (*this)->address(); }
52
+
53
+ void Adapter::power_on() { (*this)->power_on(); }
54
+
55
+ void Adapter::power_off() { (*this)->power_off(); }
56
+
57
+ bool Adapter::is_powered() { return (*this)->is_powered(); }
58
+
59
+ void Adapter::set_callback_on_power_on(std::function<void()> on_power_on) {
60
+ (*this)->set_callback_on_power_on(std::move(on_power_on));
61
+ }
62
+
63
+ void Adapter::set_callback_on_power_off(std::function<void()> on_power_off) {
64
+ (*this)->set_callback_on_power_off(std::move(on_power_off));
65
+ }
66
+
67
+ void Adapter::scan_start() {
68
+ if (!bluetooth_enabled()) {
69
+ SIMPLEBLE_LOG_WARN(fmt::format("Bluetooth is not enabled."));
70
+ return;
71
+ }
72
+ (*this)->scan_start();
73
+ }
74
+
75
+ void Adapter::scan_stop() {
76
+ if (!bluetooth_enabled()) {
77
+ SIMPLEBLE_LOG_WARN(fmt::format("Bluetooth is not enabled."));
78
+ return;
79
+ }
80
+ (*this)->scan_stop();
81
+ }
82
+
83
+ void Adapter::scan_for(int timeout_ms) {
84
+ if (!bluetooth_enabled()) {
85
+ SIMPLEBLE_LOG_WARN(fmt::format("Bluetooth is not enabled."));
86
+ return;
87
+ }
88
+ (*this)->scan_for(timeout_ms);
89
+ }
90
+
91
+ bool Adapter::scan_is_active() { return (*this)->scan_is_active(); }
92
+
93
+ std::vector<Peripheral> Adapter::scan_get_results() { return Factory::vector((*this)->scan_get_results()); }
94
+
95
+ std::vector<Peripheral> Adapter::get_paired_peripherals() { return Factory::vector((*this)->get_paired_peripherals()); }
96
+
97
+ void Adapter::set_callback_on_scan_start(std::function<void()> on_scan_start) {
98
+ (*this)->set_callback_on_scan_start(std::move(on_scan_start));
99
+ }
100
+
101
+ void Adapter::set_callback_on_scan_stop(std::function<void()> on_scan_stop) {
102
+ (*this)->set_callback_on_scan_stop(std::move(on_scan_stop));
103
+ }
104
+
105
+ void Adapter::set_callback_on_scan_updated(std::function<void(Peripheral)> on_scan_updated) {
106
+ (*this)->set_callback_on_scan_updated(std::move(on_scan_updated));
107
+ }
108
+
109
+ void Adapter::set_callback_on_scan_found(std::function<void(Peripheral)> on_scan_found) {
110
+ (*this)->set_callback_on_scan_found(std::move(on_scan_found));
111
+ }
@@ -0,0 +1,83 @@
1
+ #include <vector>
2
+
3
+ #include <simpleble/Adapter.h>
4
+ #include <simpleble/Exceptions.h>
5
+
6
+ #include "BackendBase.h"
7
+ #include "BuildVec.h"
8
+ #include "CommonUtils.h"
9
+
10
+ #include "Backend.h"
11
+
12
+ using namespace SimpleBLE;
13
+
14
+ namespace SimpleBLE {
15
+
16
+ static std::shared_ptr<BackendBase> _get_enabled_backend() {
17
+ using BackendPtr = std::shared_ptr<BackendBase>(void);
18
+
19
+ if constexpr (SIMPLEBLE_BACKEND_LINUX) {
20
+ extern BackendPtr BACKEND_LINUX;
21
+ return BACKEND_LINUX();
22
+ } else if constexpr (SIMPLEBLE_BACKEND_WINDOWS) {
23
+ extern BackendPtr BACKEND_WINDOWS;
24
+ return BACKEND_WINDOWS();
25
+ } else if constexpr (SIMPLEBLE_BACKEND_ANDROID) {
26
+ extern BackendPtr BACKEND_ANDROID;
27
+ return BACKEND_ANDROID();
28
+ } else if constexpr (SIMPLEBLE_BACKEND_MACOS) {
29
+ extern BackendPtr BACKEND_MACOS;
30
+ return BACKEND_MACOS();
31
+ } else if constexpr (SIMPLEBLE_BACKEND_IOS) {
32
+ extern BackendPtr BACKEND_MACOS;
33
+ return BACKEND_MACOS();
34
+ } else if constexpr (SIMPLEBLE_BACKEND_PLAIN) {
35
+ extern BackendPtr BACKEND_PLAIN;
36
+ return BACKEND_PLAIN();
37
+ }
38
+
39
+ throw Exception::NotInitialized();
40
+ }
41
+
42
+ Backend get_enabled_backend() { return Factory::build(_get_enabled_backend()); }
43
+
44
+ // NOTE: in the future, this can return multiple backends
45
+ static SharedPtrVector<BackendBase> _get_backends() {
46
+ SharedPtrVector<BackendBase> backends = {_get_enabled_backend()};
47
+ return backends;
48
+ }
49
+
50
+ } // namespace SimpleBLE
51
+
52
+ std::vector<Backend> Backend::get_backends() { return Factory::vector(_get_backends()); }
53
+
54
+ bool Backend::initialized() const { return internal_ != nullptr; }
55
+
56
+ BackendBase* Backend::operator->() {
57
+ if (!initialized()) {
58
+ throw Exception::NotInitialized();
59
+ }
60
+ return internal_.get();
61
+ }
62
+
63
+ const BackendBase* Backend::operator->() const {
64
+ if (!initialized()) {
65
+ throw Exception::NotInitialized();
66
+ }
67
+ return internal_.get();
68
+ }
69
+
70
+ std::vector<Adapter> Backend::get_adapters() { return Factory::vector((*this)->get_adapters()); }
71
+
72
+ bool Backend::bluetooth_enabled() { return (*this)->bluetooth_enabled(); }
73
+
74
+ std::optional<Backend> Backend::first_bluetooth_enabled() {
75
+ for (auto& backend : get_backends()) {
76
+ if (backend->bluetooth_enabled()) {
77
+ return backend;
78
+ }
79
+ }
80
+ return std::nullopt;
81
+ }
82
+
83
+ std::string Backend::name() const noexcept { return (*this)->name(); }
@@ -0,0 +1,76 @@
1
+ #pragma once
2
+
3
+ #include <memory>
4
+ #include <optional>
5
+ #include <string>
6
+ #include <vector>
7
+
8
+ #include <simpleble/Adapter.h>
9
+ #include <simpleble/export.h>
10
+
11
+ namespace SimpleBLE {
12
+
13
+ class BackendBase;
14
+
15
+ /**
16
+ * Backend.
17
+ *
18
+ * NOTE: backends must not implement this class directly, but instead derive
19
+ * from BackendBase, defined in Backend.h.
20
+ *
21
+ * This frontend class is hidden from users for the time being. Once the API
22
+ * stabilizes, this class will be exposed to users.
23
+ */
24
+ class SIMPLEBLE_EXPORT Backend {
25
+ public:
26
+ Backend() = default;
27
+ virtual ~Backend() = default;
28
+
29
+ bool initialized() const;
30
+
31
+ /**
32
+ * Get a list of all available adapters from this backend.
33
+ */
34
+ std::vector<Adapter> get_adapters();
35
+
36
+ /**
37
+ * Check if Bluetooth is enabled for this backend.
38
+ */
39
+ bool bluetooth_enabled();
40
+
41
+ /**
42
+ * Get the first backend that has Bluetooth enabled.
43
+ *
44
+ * @return The first backend that has Bluetooth enabled, or std::nullopt if
45
+ * no backends have Bluetooth enabled.
46
+ */
47
+ static std::optional<Backend> first_bluetooth_enabled();
48
+
49
+ /**
50
+ * Get the name of the backend.
51
+ */
52
+ std::string name() const noexcept;
53
+
54
+ /**
55
+ * Get all available backends.
56
+ *
57
+ * This will cause backends to be instantiated/initialized.
58
+ */
59
+ static std::vector<Backend> get_backends();
60
+
61
+ protected:
62
+ BackendBase* operator->();
63
+ const BackendBase* operator->() const;
64
+
65
+ std::shared_ptr<BackendBase> internal_;
66
+ };
67
+
68
+ /**
69
+ * Get the enabled backend.
70
+ *
71
+ * Note: this function should not be part of the public API and will be deleted
72
+ * once multiple backends are supported.
73
+ */
74
+ Backend get_enabled_backend();
75
+
76
+ } // namespace SimpleBLE
@@ -0,0 +1,56 @@
1
+ #include <simpleble/Characteristic.h>
2
+
3
+ #include "BuildVec.h"
4
+ #include "CharacteristicBase.h"
5
+
6
+ using namespace SimpleBLE;
7
+
8
+ BluetoothUUID Characteristic::uuid() { return (*this)->uuid(); }
9
+
10
+ std::vector<Descriptor> Characteristic::descriptors() { return Factory::vector((*this)->descriptors()); }
11
+
12
+ std::vector<std::string> Characteristic::capabilities() {
13
+ std::vector<std::string> capabilities;
14
+
15
+ if (can_read()) {
16
+ capabilities.push_back("read");
17
+ }
18
+
19
+ if (can_write_request()) {
20
+ capabilities.push_back("write_request");
21
+ }
22
+
23
+ if (can_write_command()) {
24
+ capabilities.push_back("write_command");
25
+ }
26
+
27
+ if (can_notify()) {
28
+ capabilities.push_back("notify");
29
+ }
30
+
31
+ if (can_indicate()) {
32
+ capabilities.push_back("indicate");
33
+ }
34
+
35
+ return capabilities;
36
+ }
37
+
38
+ bool Characteristic::initialized() const { return internal_ != nullptr; }
39
+
40
+ CharacteristicBase* Characteristic::operator->() {
41
+ if (!initialized()) throw Exception::NotInitialized();
42
+
43
+ return internal_.get();
44
+ }
45
+
46
+ const CharacteristicBase* Characteristic::operator->() const {
47
+ if (!initialized()) throw Exception::NotInitialized();
48
+
49
+ return internal_.get();
50
+ }
51
+
52
+ bool Characteristic::can_read() { return (*this)->can_read(); }
53
+ bool Characteristic::can_write_request() { return (*this)->can_write_request(); }
54
+ bool Characteristic::can_write_command() { return (*this)->can_write_command(); }
55
+ bool Characteristic::can_notify() { return (*this)->can_notify(); }
56
+ bool Characteristic::can_indicate() { return (*this)->can_indicate(); }
@@ -0,0 +1,21 @@
1
+ #include <simpleble/Descriptor.h>
2
+
3
+ #include "DescriptorBase.h"
4
+
5
+ using namespace SimpleBLE;
6
+
7
+ bool Descriptor::initialized() const { return internal_ != nullptr; }
8
+
9
+ DescriptorBase* Descriptor::operator->() {
10
+ if (!initialized()) throw Exception::NotInitialized();
11
+
12
+ return internal_.get();
13
+ }
14
+
15
+ const DescriptorBase* Descriptor::operator->() const {
16
+ if (!initialized()) throw Exception::NotInitialized();
17
+
18
+ return internal_.get();
19
+ }
20
+
21
+ BluetoothUUID Descriptor::uuid() { return (*this)->uuid(); }
@@ -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
+ }