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,138 @@
1
+ #include <simplebluez/Bluez.h>
2
+ #include <simplebluez/Exceptions.h>
3
+
4
+ #include <atomic>
5
+ #include <chrono>
6
+ #include <cstdlib>
7
+ #include <iomanip>
8
+ #include <iostream>
9
+ #include <thread>
10
+
11
+ SimpleBluez::Bluez bluez;
12
+
13
+ std::atomic_bool async_thread_active = true;
14
+ void async_thread_function() {
15
+ while (async_thread_active) {
16
+ bluez.run_async();
17
+ std::this_thread::sleep_for(std::chrono::microseconds(10));
18
+ }
19
+ }
20
+
21
+ void millisecond_delay(int ms) {
22
+ for (int i = 0; i < ms; i++) {
23
+ std::this_thread::sleep_for(std::chrono::milliseconds(1));
24
+ }
25
+ }
26
+
27
+ void print_byte_array(SimpleBluez::ByteArray& bytes) {
28
+ for (auto byte : bytes) {
29
+ std::cout << std::hex << std::setfill('0') << (uint32_t)((uint8_t)byte) << " ";
30
+ break;
31
+ }
32
+ std::cout << std::endl;
33
+ }
34
+
35
+ std::vector<std::shared_ptr<SimpleBluez::Device>> peripherals;
36
+
37
+ int main(int argc, char* argv[]) {
38
+ int selection = -1;
39
+
40
+ bluez.init();
41
+ std::thread* async_thread = new std::thread(async_thread_function);
42
+
43
+ auto adapters = bluez.get_adapters();
44
+ std::cout << "Available adapters:" << std::endl;
45
+ for (int i = 0; i < adapters.size(); i++) {
46
+ std::cout << "[" << i << "] " << adapters[i]->identifier() << " [" << adapters[i]->address() << "]"
47
+ << std::endl;
48
+ }
49
+
50
+ std::cout << "Please select an adapter to scan: ";
51
+ std::cin >> selection;
52
+ if (selection < 0 || selection >= adapters.size()) {
53
+ std::cout << "Invalid selection" << std::endl;
54
+ return 1;
55
+ }
56
+
57
+ auto adapter = adapters[selection];
58
+ std::cout << "Scanning " << adapter->identifier() << " [" << adapter->address() << "]" << std::endl;
59
+
60
+ SimpleBluez::Adapter::DiscoveryFilter filter;
61
+ filter.Transport = SimpleBluez::Adapter::DiscoveryFilter::TransportType::LE;
62
+ adapter->discovery_filter(filter);
63
+
64
+ adapter->set_on_device_updated([](std::shared_ptr<SimpleBluez::Device> device) {
65
+ if (device->name() == "") {
66
+ return;
67
+ }
68
+
69
+ if (std::find(peripherals.begin(), peripherals.end(), device) == peripherals.end()) {
70
+ std::cout << "Found device: " << device->name() << " [" << device->address() << "]" << std::endl;
71
+ peripherals.push_back(device);
72
+ }
73
+ });
74
+
75
+ adapter->discovery_start();
76
+ millisecond_delay(3000);
77
+ adapter->discovery_stop();
78
+
79
+ std::cout << "The following devices were found:" << std::endl;
80
+ for (int i = 0; i < peripherals.size(); i++) {
81
+ std::cout << "[" << i << "] " << peripherals[i]->name() << " [" << peripherals[i]->address() << "]"
82
+ << std::endl;
83
+ }
84
+
85
+ std::cout << "Please select a device to connect to: ";
86
+ std::cin >> selection;
87
+
88
+ if (selection >= 0 && selection < peripherals.size()) {
89
+ auto peripheral = peripherals[selection];
90
+ std::cout << "Connecting to " << peripheral->name() << " [" << peripheral->address() << "]" << std::endl;
91
+
92
+ for (int attempt = 0; attempt < 3; attempt++) {
93
+ try {
94
+ peripheral->connect();
95
+ } catch (SimpleDBus::Exception::SendFailed& e) {
96
+ millisecond_delay(100);
97
+ }
98
+ }
99
+
100
+ if (!peripheral->connected() || !peripheral->services_resolved()) {
101
+ std::cout << "Failed to connect to " << peripheral->name() << " [" << peripheral->address() << "]"
102
+ << std::endl;
103
+ return 1;
104
+ }
105
+
106
+ std::cout << "Successfully connected, testing NUS service." << std::endl;
107
+
108
+ auto characteristic_rx = peripheral->get_characteristic("6e400001-b5a3-f393-e0a9-e50e24dcca9e",
109
+ "6e400002-b5a3-f393-e0a9-e50e24dcca9e");
110
+
111
+ characteristic_rx->write_command("Hello World");
112
+
113
+ auto characteristic_tx = peripheral->get_characteristic("6e400001-b5a3-f393-e0a9-e50e24dcca9e",
114
+ "6e400003-b5a3-f393-e0a9-e50e24dcca9e");
115
+
116
+ characteristic_tx->set_on_value_changed([&](SimpleBluez::ByteArray new_value) { print_byte_array(new_value); });
117
+
118
+ characteristic_tx->start_notify();
119
+ millisecond_delay(3000);
120
+ characteristic_tx->stop_notify();
121
+ millisecond_delay(1000);
122
+
123
+ peripheral->disconnect();
124
+
125
+ // Sleep for an additional second before returning.
126
+ // If there are any unexpected events, this example will help debug them.
127
+ millisecond_delay(1000);
128
+ }
129
+
130
+ async_thread_active = false;
131
+ while (!async_thread->joinable()) {
132
+ millisecond_delay(10);
133
+ }
134
+ async_thread->join();
135
+ delete async_thread;
136
+
137
+ return 0;
138
+ }
@@ -0,0 +1,119 @@
1
+ #include <simplebluez/Bluez.h>
2
+ #include <simplebluez/Exceptions.h>
3
+
4
+ #include <atomic>
5
+ #include <chrono>
6
+ #include <cstdlib>
7
+ #include <iomanip>
8
+ #include <iostream>
9
+ #include <thread>
10
+
11
+ SimpleBluez::Bluez bluez;
12
+
13
+ std::atomic_bool async_thread_active = true;
14
+ void async_thread_function() {
15
+ while (async_thread_active) {
16
+ bluez.run_async();
17
+ std::this_thread::sleep_for(std::chrono::microseconds(100));
18
+ }
19
+ }
20
+
21
+ void millisecond_delay(int ms) {
22
+ for (int i = 0; i < ms; i++) {
23
+ std::this_thread::sleep_for(std::chrono::milliseconds(1));
24
+ }
25
+ }
26
+
27
+ std::vector<std::shared_ptr<SimpleBluez::Device>> peripherals;
28
+
29
+ int main(int argc, char* argv[]) {
30
+ int selection = -1;
31
+
32
+ bluez.init();
33
+ std::thread* async_thread = new std::thread(async_thread_function);
34
+
35
+ auto adapters = bluez.get_adapters();
36
+ std::cout << "Available adapters:" << std::endl;
37
+ for (int i = 0; i < adapters.size(); i++) {
38
+ std::cout << "[" << i << "] " << adapters[i]->identifier() << " [" << adapters[i]->address() << "]"
39
+ << std::endl;
40
+ }
41
+
42
+ std::cout << "Please select an adapter to scan: ";
43
+ std::cin >> selection;
44
+ if (selection < 0 || selection >= adapters.size()) {
45
+ std::cout << "Invalid selection" << std::endl;
46
+ return 1;
47
+ }
48
+
49
+ auto adapter = adapters[selection];
50
+ std::cout << "Scanning " << adapter->identifier() << " [" << adapter->address() << "]" << std::endl;
51
+
52
+ SimpleBluez::Adapter::DiscoveryFilter filter;
53
+ filter.Transport = SimpleBluez::Adapter::DiscoveryFilter::TransportType::LE;
54
+ adapter->discovery_filter(filter);
55
+
56
+ adapter->set_on_device_updated([](std::shared_ptr<SimpleBluez::Device> device) {
57
+ if (std::find(peripherals.begin(), peripherals.end(), device) == peripherals.end()) {
58
+ std::cout << "Found device: " << device->name() << " [" << device->address() << "]" << std::endl;
59
+ peripherals.push_back(device);
60
+ }
61
+ });
62
+
63
+ adapter->discovery_start();
64
+ millisecond_delay(3000);
65
+ adapter->discovery_stop();
66
+
67
+ std::cout << "The following devices were found:" << std::endl;
68
+ for (int i = 0; i < peripherals.size(); i++) {
69
+ std::cout << "[" << i << "] " << peripherals[i]->name() << " [" << peripherals[i]->address() << "]"
70
+ << std::endl;
71
+ }
72
+
73
+ std::cout << "Please select a device to connect to: ";
74
+ std::cin >> selection;
75
+
76
+ if (selection >= 0 && selection < peripherals.size()) {
77
+ auto peripheral = peripherals[selection];
78
+ std::cout << "Connecting to " << peripheral->name() << " [" << peripheral->address() << "]" << std::endl;
79
+
80
+ for (int attempt = 0; attempt < 3; attempt++) {
81
+ try {
82
+ peripheral->connect();
83
+ } catch (SimpleDBus::Exception::SendFailed& e) {
84
+ millisecond_delay(100);
85
+ }
86
+ }
87
+
88
+ if (!peripheral->connected() || !peripheral->services_resolved()) {
89
+ std::cout << "Failed to connect to " << peripheral->name() << " [" << peripheral->address() << "]"
90
+ << std::endl;
91
+ return 1;
92
+ }
93
+
94
+ std::cout << "Successfully connected, listing services." << std::endl;
95
+ for (auto service : peripheral->services()) {
96
+ std::cout << "Service: " << service->uuid() << std::endl;
97
+ for (auto characteristic : service->characteristics()) {
98
+ std::cout << " Characteristic: " << characteristic->uuid() << std::endl;
99
+ for (auto descriptor : characteristic->descriptors()) {
100
+ std::cout << " Descriptor: " << descriptor->uuid() << std::endl;
101
+ }
102
+ }
103
+ }
104
+ peripheral->disconnect();
105
+
106
+ // Sleep for an additional second before returning.
107
+ // If there are any unexpected events, this example will help debug them.
108
+ millisecond_delay(1000);
109
+ }
110
+
111
+ async_thread_active = false;
112
+ while (!async_thread->joinable()) {
113
+ millisecond_delay(10);
114
+ }
115
+ async_thread->join();
116
+ delete async_thread;
117
+
118
+ return 0;
119
+ }
@@ -0,0 +1,44 @@
1
+ #include <simplebluez/Bluez.h>
2
+
3
+ #include <chrono>
4
+ #include <cstdlib>
5
+ #include <iomanip>
6
+ #include <iostream>
7
+ #include <thread>
8
+
9
+ SimpleBluez::Bluez bluez;
10
+
11
+ std::atomic_bool async_thread_active = true;
12
+ void async_thread_function() {
13
+ while (async_thread_active) {
14
+ bluez.run_async();
15
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
16
+ }
17
+ }
18
+
19
+ void millisecond_delay(int ms) {
20
+ for (int i = 0; i < ms; i++) {
21
+ std::this_thread::sleep_for(std::chrono::milliseconds(1));
22
+ }
23
+ }
24
+
25
+ int main(int argc, char* argv[]) {
26
+ bluez.init();
27
+ std::thread* async_thread = new std::thread(async_thread_function);
28
+
29
+ auto adapters = bluez.get_adapters();
30
+ std::cout << "The following adapters were found:" << std::endl;
31
+ for (int i = 0; i < adapters.size(); i++) {
32
+ std::cout << "[" << i << "] " << adapters[i]->identifier() << " [" << adapters[i]->address() << "]"
33
+ << std::endl;
34
+ }
35
+
36
+ async_thread_active = false;
37
+ while (!async_thread->joinable()) {
38
+ millisecond_delay(10);
39
+ }
40
+ async_thread->join();
41
+ delete async_thread;
42
+
43
+ return 0;
44
+ }
@@ -0,0 +1,48 @@
1
+ #include <simplebluez/Bluez.h>
2
+
3
+ #include <chrono>
4
+ #include <cstdlib>
5
+ #include <iomanip>
6
+ #include <iostream>
7
+ #include <thread>
8
+
9
+ SimpleBluez::Bluez bluez;
10
+
11
+ std::atomic_bool async_thread_active = true;
12
+ void async_thread_function() {
13
+ while (async_thread_active) {
14
+ bluez.run_async();
15
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
16
+ }
17
+ }
18
+
19
+ void millisecond_delay(int ms) {
20
+ for (int i = 0; i < ms; i++) {
21
+ std::this_thread::sleep_for(std::chrono::milliseconds(1));
22
+ }
23
+ }
24
+
25
+ int main(int argc, char* argv[]) {
26
+ bluez.init();
27
+ std::thread* async_thread = new std::thread(async_thread_function);
28
+
29
+ auto adapters = bluez.get_adapters();
30
+ std::cout << "The following adapters were found:" << std::endl;
31
+ for (int i = 0; i < adapters.size(); i++) {
32
+ std::cout << "[" << i << "] " << adapters[i]->identifier() << " [" << adapters[i]->address() << "]"
33
+ << std::endl;
34
+ auto paired_list = adapters[i]->device_paired_get();
35
+ for (auto& device : paired_list) {
36
+ std::cout << "\t" << device->address() << " " << device->name() << std::endl;
37
+ }
38
+ }
39
+
40
+ async_thread_active = false;
41
+ while (!async_thread->joinable()) {
42
+ millisecond_delay(10);
43
+ }
44
+ async_thread->join();
45
+ delete async_thread;
46
+
47
+ return 0;
48
+ }
@@ -0,0 +1,145 @@
1
+ #include <simplebluez/Bluez.h>
2
+ #include <simplebluez/Exceptions.h>
3
+
4
+ #include <atomic>
5
+ #include <chrono>
6
+ #include <cstdlib>
7
+ #include <iomanip>
8
+ #include <iostream>
9
+ #include <thread>
10
+
11
+ SimpleBluez::Bluez bluez;
12
+
13
+ std::atomic_bool async_thread_active = true;
14
+ void async_thread_function() {
15
+ while (async_thread_active) {
16
+ bluez.run_async();
17
+ std::this_thread::sleep_for(std::chrono::microseconds(100));
18
+ }
19
+ }
20
+
21
+ void millisecond_delay(int ms) {
22
+ for (int i = 0; i < ms; i++) {
23
+ std::this_thread::sleep_for(std::chrono::milliseconds(1));
24
+ }
25
+ }
26
+
27
+ void print_byte_array(SimpleBluez::ByteArray& bytes) {
28
+ for (auto byte : bytes) {
29
+ std::cout << std::hex << std::setfill('0') << (uint32_t)((uint8_t)byte) << " ";
30
+ break;
31
+ }
32
+ std::cout << std::endl;
33
+ }
34
+
35
+ std::vector<std::shared_ptr<SimpleBluez::Device>> peripherals;
36
+
37
+ int main(int argc, char* argv[]) {
38
+ int selection = -1;
39
+
40
+ bluez.init();
41
+ std::thread* async_thread = new std::thread(async_thread_function);
42
+
43
+ auto adapters = bluez.get_adapters();
44
+ std::cout << "Available adapters:" << std::endl;
45
+ for (int i = 0; i < adapters.size(); i++) {
46
+ std::cout << "[" << i << "] " << adapters[i]->identifier() << " [" << adapters[i]->address() << "]"
47
+ << std::endl;
48
+ }
49
+
50
+ std::cout << "Please select an adapter to scan: ";
51
+ std::cin >> selection;
52
+ if (selection < 0 || selection >= adapters.size()) {
53
+ std::cout << "Invalid selection" << std::endl;
54
+ return 1;
55
+ }
56
+
57
+ auto adapter = adapters[selection];
58
+ std::cout << "Scanning " << adapter->identifier() << " [" << adapter->address() << "]" << std::endl;
59
+
60
+ SimpleBluez::Adapter::DiscoveryFilter filter;
61
+ filter.Transport = SimpleBluez::Adapter::DiscoveryFilter::TransportType::LE;
62
+ adapter->discovery_filter(filter);
63
+
64
+ adapter->set_on_device_updated([](std::shared_ptr<SimpleBluez::Device> device) {
65
+ if (std::find(peripherals.begin(), peripherals.end(), device) == peripherals.end()) {
66
+ std::cout << "Found device: " << device->name() << " [" << device->address() << "]" << std::endl;
67
+ peripherals.push_back(device);
68
+ }
69
+ });
70
+
71
+ adapter->discovery_start();
72
+ millisecond_delay(3000);
73
+ adapter->discovery_stop();
74
+
75
+ std::cout << "The following devices were found:" << std::endl;
76
+ for (int i = 0; i < peripherals.size(); i++) {
77
+ std::cout << "[" << i << "] " << peripherals[i]->name() << " [" << peripherals[i]->address() << "]"
78
+ << std::endl;
79
+ }
80
+
81
+ std::cout << "Please select a device to connect to: ";
82
+ std::cin >> selection;
83
+
84
+ if (selection >= 0 && selection < peripherals.size()) {
85
+ auto peripheral = peripherals[selection];
86
+ std::cout << "Connecting to " << peripheral->name() << " [" << peripheral->address() << "]" << std::endl;
87
+
88
+ for (int attempt = 0; attempt < 3; attempt++) {
89
+ try {
90
+ peripheral->connect();
91
+ } catch (SimpleDBus::Exception::SendFailed& e) {
92
+ millisecond_delay(100);
93
+ }
94
+ }
95
+
96
+ if (!peripheral->connected() || !peripheral->services_resolved()) {
97
+ std::cout << "Failed to connect to " << peripheral->name() << " [" << peripheral->address() << "]"
98
+ << std::endl;
99
+ return 1;
100
+ }
101
+
102
+ // Store all services and characteristics in a vector.
103
+ std::vector<std::pair<std::shared_ptr<SimpleBluez::Service>, std::shared_ptr<SimpleBluez::Characteristic>>>
104
+ char_list;
105
+ for (auto service : peripheral->services()) {
106
+ for (auto characteristic : service->characteristics()) {
107
+ char_list.push_back(std::make_pair(service, characteristic));
108
+ }
109
+ }
110
+
111
+ std::cout << "The following services and characteristics were found:" << std::endl;
112
+ for (int i = 0; i < char_list.size(); i++) {
113
+ std::cout << "[" << i << "] " << char_list[i].first->uuid() << " " << char_list[i].second->uuid()
114
+ << std::endl;
115
+ }
116
+
117
+ std::cout << "Please select a characteristic to read: ";
118
+ std::cin >> selection;
119
+
120
+ if (selection >= 0 && selection < char_list.size()) {
121
+ auto characteristic = char_list[selection].second;
122
+ characteristic->set_on_value_changed(
123
+ [&](SimpleBluez::ByteArray new_value) { print_byte_array(new_value); });
124
+
125
+ characteristic->start_notify();
126
+ millisecond_delay(5000);
127
+ characteristic->stop_notify();
128
+ }
129
+
130
+ peripheral->disconnect();
131
+
132
+ // Sleep for an additional second before returning.
133
+ // If there are any unexpected events, this example will help debug them.
134
+ millisecond_delay(1000);
135
+ }
136
+
137
+ async_thread_active = false;
138
+ while (!async_thread->joinable()) {
139
+ millisecond_delay(10);
140
+ }
141
+ async_thread->join();
142
+ delete async_thread;
143
+
144
+ return 0;
145
+ }
@@ -0,0 +1,181 @@
1
+ #include <simplebluez/Bluez.h>
2
+ #include <simplebluez/Exceptions.h>
3
+
4
+ #include <atomic>
5
+ #include <chrono>
6
+ #include <cstdlib>
7
+ #include <iomanip>
8
+ #include <iostream>
9
+ #include <thread>
10
+
11
+ SimpleBluez::Bluez bluez;
12
+
13
+ std::atomic_bool async_thread_active = true;
14
+ void async_thread_function() {
15
+ while (async_thread_active) {
16
+ bluez.run_async();
17
+ std::this_thread::sleep_for(std::chrono::microseconds(100));
18
+ }
19
+ }
20
+
21
+ void millisecond_delay(int ms) {
22
+ for (int i = 0; i < ms; i++) {
23
+ std::this_thread::sleep_for(std::chrono::milliseconds(1));
24
+ }
25
+ }
26
+
27
+ std::vector<std::shared_ptr<SimpleBluez::Device>> peripherals;
28
+
29
+ int main(int argc, char* argv[]) {
30
+ int selection = -1;
31
+
32
+ bluez.init();
33
+ std::thread* async_thread = new std::thread(async_thread_function);
34
+
35
+ auto agent = bluez.get_agent();
36
+ agent->set_capabilities(SimpleBluez::Agent::Capabilities::KeyboardDisplay);
37
+
38
+ // Configure all callback handlers for the agent, as part of this example.
39
+ agent->set_on_request_pin_code([&]() {
40
+ std::cout << "Agent::RequestPinCode" << std::endl;
41
+ return "123456";
42
+ });
43
+
44
+ agent->set_on_display_pin_code([&](const std::string& pin_code) {
45
+ std::cout << "Agent::DisplayPinCode: " << pin_code << std::endl;
46
+ return true;
47
+ });
48
+
49
+ agent->set_on_request_passkey([&]() {
50
+ std::cout << "Agent::RequestPasskey" << std::endl;
51
+ return 123456;
52
+ });
53
+
54
+ agent->set_on_display_passkey([&](uint32_t passkey, uint16_t entered) {
55
+ std::cout << "Agent::DisplayPasskey: " << passkey << " (" << entered << " entered)" << std::endl;
56
+ });
57
+
58
+ agent->set_on_request_confirmation([&](uint32_t passkey) {
59
+ std::cout << "Agent::RequestConfirmation: " << passkey << std::endl;
60
+ return true;
61
+ });
62
+
63
+ agent->set_on_request_authorization([&]() {
64
+ std::cout << "Agent::RequestAuthorization" << std::endl;
65
+ return true;
66
+ });
67
+
68
+ agent->set_on_authorize_service([&](const std::string& uuid) {
69
+ std::cout << "Agent::AuthorizeService: " << uuid << std::endl;
70
+ return true;
71
+ });
72
+
73
+ bluez.register_agent();
74
+
75
+ auto adapters = bluez.get_adapters();
76
+ std::cout << "Available adapters:" << std::endl;
77
+ for (int i = 0; i < adapters.size(); i++) {
78
+ std::cout << "[" << i << "] " << adapters[i]->identifier() << " [" << adapters[i]->address() << "]"
79
+ << std::endl;
80
+ }
81
+
82
+ std::cout << "Please select an adapter to scan: ";
83
+ std::cin >> selection;
84
+ if (selection < 0 || selection >= adapters.size()) {
85
+ std::cout << "Invalid selection" << std::endl;
86
+ return 1;
87
+ }
88
+
89
+ auto adapter = adapters[selection];
90
+ std::cout << "Scanning " << adapter->identifier() << " [" << adapter->address() << "]" << std::endl;
91
+
92
+ SimpleBluez::Adapter::DiscoveryFilter filter;
93
+ filter.Transport = SimpleBluez::Adapter::DiscoveryFilter::TransportType::LE;
94
+ adapter->discovery_filter(filter);
95
+
96
+ adapter->set_on_device_updated([](std::shared_ptr<SimpleBluez::Device> device) {
97
+ if (std::find(peripherals.begin(), peripherals.end(), device) == peripherals.end()) {
98
+ std::cout << "Found device: " << device->name() << " [" << device->address() << "]" << std::endl;
99
+ peripherals.push_back(device);
100
+ }
101
+ });
102
+
103
+ adapter->discovery_start();
104
+ millisecond_delay(3000);
105
+ adapter->discovery_stop();
106
+
107
+ std::cout << "The following devices were found:" << std::endl;
108
+ for (int i = 0; i < peripherals.size(); i++) {
109
+ std::cout << "[" << i << "] " << peripherals[i]->name() << " [" << peripherals[i]->address() << "]"
110
+ << std::endl;
111
+ }
112
+
113
+ std::cout << "Please select a device to pair to: ";
114
+ std::cin >> selection;
115
+
116
+ if (selection >= 0 && selection < peripherals.size()) {
117
+ auto peripheral = peripherals[selection];
118
+ std::cout << "Pairing to " << peripheral->name() << " [" << peripheral->address() << "]" << std::endl;
119
+
120
+ for (int attempt = 0; attempt < 3; attempt++) {
121
+ try {
122
+ peripheral->connect();
123
+
124
+ // At this point, the connection will be established,
125
+ // but services might not be resolved yet
126
+
127
+ for (int i = 0; i < 10; i++) {
128
+ std::cout << "Waiting for services to resolve..." << std::endl;
129
+ millisecond_delay(100);
130
+ if (peripheral->services_resolved()) {
131
+ break;
132
+ }
133
+ }
134
+
135
+ if (peripheral->connected() && peripheral->services_resolved()) {
136
+ break;
137
+ }
138
+
139
+ } catch (SimpleDBus::Exception::SendFailed& e) {
140
+ millisecond_delay(100);
141
+ }
142
+ }
143
+
144
+ if (!peripheral->connected() || !peripheral->services_resolved()) {
145
+ std::cout << "Failed to connect to " << peripheral->name() << " [" << peripheral->address() << "]"
146
+ << std::endl;
147
+ return 1;
148
+ }
149
+
150
+ std::cout << "Successfully connected, listing services." << std::endl;
151
+ for (auto service : peripheral->services()) {
152
+ std::cout << "Service: " << service->uuid() << std::endl;
153
+ for (auto characteristic : service->characteristics()) {
154
+ std::cout << " Characteristic: " << characteristic->uuid() << std::endl;
155
+ for (auto descriptor : characteristic->descriptors()) {
156
+ std::cout << " Descriptor: " << descriptor->uuid() << std::endl;
157
+ }
158
+ }
159
+ }
160
+
161
+ millisecond_delay(2000);
162
+ peripheral->disconnect();
163
+
164
+ if (peripheral->paired()) {
165
+ adapter->device_remove(peripheral->path());
166
+ }
167
+
168
+ // Sleep for an additional second before returning.
169
+ // If there are any unexpected events, this example will help debug them.
170
+ millisecond_delay(1000);
171
+ }
172
+
173
+ async_thread_active = false;
174
+ while (!async_thread->joinable()) {
175
+ millisecond_delay(10);
176
+ }
177
+ async_thread->join();
178
+ delete async_thread;
179
+
180
+ return 0;
181
+ }