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,67 @@
1
+ #pragma once
2
+
3
+ #include <simpledbus/base/Connection.h>
4
+
5
+ #include <atomic>
6
+ #include <map>
7
+ #include <memory>
8
+ #include <mutex>
9
+ #include <string>
10
+
11
+ namespace SimpleDBus {
12
+
13
+ class Interface {
14
+ public:
15
+ Interface(std::shared_ptr<Connection> conn, const std::string& bus_name, const std::string& path,
16
+ const std::string& interface_name);
17
+
18
+ virtual ~Interface() = default;
19
+
20
+ // ----- LIFE CYCLE -----
21
+ void load(Holder options);
22
+ void unload();
23
+ bool is_loaded() const;
24
+
25
+ // ----- METHODS -----
26
+ Message create_method_call(const std::string& method_name);
27
+
28
+ // ----- PROPERTIES -----
29
+ virtual void property_changed(std::string option_name);
30
+
31
+ // ! These functions are used by the Properties interface. We need better nomenclature!
32
+ Holder property_collect();
33
+ Holder property_collect_single(const std::string& property_name);
34
+ void property_modify(const std::string& property_name, const Holder& value);
35
+
36
+ // ! TODO: We need to figure out a good architecture to let any generic interface access the Properties object of its Proxy.
37
+ Holder property_get_all();
38
+ Holder property_get(const std::string& property_name);
39
+ void property_set(const std::string& property_name, const Holder& value);
40
+ void property_refresh(const std::string& property_name);
41
+
42
+ // ----- SIGNALS -----
43
+ void signal_property_changed(Holder changed_properties, Holder invalidated_properties);
44
+
45
+ // ----- MESSAGES -----
46
+ virtual void message_handle(Message& msg);
47
+
48
+ protected:
49
+ std::atomic_bool _loaded{true};
50
+
51
+ std::string _path;
52
+ std::string _bus_name;
53
+ std::string _interface_name;
54
+ std::shared_ptr<Connection> _conn;
55
+
56
+ std::recursive_mutex _property_update_mutex;
57
+ std::map<std::string, bool> _property_valid_map;
58
+
59
+ /**
60
+ * @brief Dictionary containing all properties.
61
+ *
62
+ * @note: When accessing this object, the _property_update_mutex must be locked.
63
+ */
64
+ std::map<std::string, Holder> _properties;
65
+ };
66
+
67
+ } // namespace SimpleDBus
@@ -0,0 +1,64 @@
1
+ #pragma once
2
+
3
+ #include <functional>
4
+ #include <memory>
5
+ #include <stdexcept>
6
+ #include <string>
7
+ #include <typeindex>
8
+
9
+ #include <simpledbus/base/Connection.h>
10
+ #include <simpledbus/base/Holder.h>
11
+ #include <simpledbus/base/Logging.h>
12
+
13
+ namespace SimpleDBus {
14
+
15
+ class Interface;
16
+
17
+ using CreatorFunction = std::shared_ptr<Interface> (*)(std::shared_ptr<Connection>, const std::string&,
18
+ const std::string&, const Holder&);
19
+
20
+ class InterfaceRegistry {
21
+ public:
22
+ static InterfaceRegistry& getInstance() {
23
+ static InterfaceRegistry instance;
24
+ return instance;
25
+ }
26
+
27
+ template <typename T>
28
+ void registerClass(const std::string& key, CreatorFunction creator) {
29
+ static_assert(std::is_base_of<Interface, T>::value, "T must inherit from Interface");
30
+ creators[key] = creator;
31
+ }
32
+
33
+ bool isRegistered(const std::string& key) const {
34
+ return creators.find(key) != creators.end();
35
+ }
36
+
37
+ // NOTES; We need a method inside Interfaces that will automatically retrieve the Interface name for the class.
38
+ std::shared_ptr<Interface> create(const std::string& key, std::shared_ptr<Connection> conn,
39
+ const std::string& bus_name, const std::string& path,
40
+ const Holder& options) const {
41
+ auto it = creators.find(key);
42
+ if (it != creators.end()) {
43
+ auto iface = it->second(conn, bus_name, path, options);
44
+ iface->load(options);
45
+ return iface;
46
+ }
47
+ return nullptr;
48
+ }
49
+
50
+ private:
51
+ std::unordered_map<std::string, CreatorFunction> creators;
52
+ InterfaceRegistry() = default;
53
+ };
54
+
55
+ template <typename T>
56
+ struct AutoRegisterInterface {
57
+ AutoRegisterInterface(const std::string& key, CreatorFunction creator) {
58
+ static_assert(std::is_base_of<Interface, T>::value, "T must inherit from Interface");
59
+ InterfaceRegistry::getInstance().registerClass<T>(key, creator);
60
+ LOG_DEBUG("Registered class with key {}", key);
61
+ }
62
+ };
63
+
64
+ } // namespace SimpleDBus
@@ -0,0 +1,117 @@
1
+ #pragma once
2
+
3
+ #include <simpledbus/base/Connection.h>
4
+
5
+ #include <simpledbus/advanced/Interface.h>
6
+ #include <kvn/kvn_safe_callback.hpp>
7
+ #include <simpledbus/base/Path.h>
8
+
9
+ #include <memory>
10
+ #include <mutex>
11
+ #include <string>
12
+
13
+ namespace SimpleDBus {
14
+
15
+ class Interface;
16
+
17
+ class Proxy {
18
+ public:
19
+ Proxy(std::shared_ptr<Connection> conn, const std::string& bus_name, const std::string& path);
20
+ virtual ~Proxy();
21
+
22
+ bool valid() const;
23
+ void invalidate();
24
+ std::string path() const;
25
+ std::string bus_name() const;
26
+
27
+ bool path_exists(const std::string& path);
28
+ std::shared_ptr<Proxy> path_get(const std::string& path);
29
+
30
+ bool interface_exists(const std::string& name);
31
+ std::shared_ptr<Interface> interface_get(const std::string& name);
32
+
33
+ const std::map<std::string, std::shared_ptr<Proxy>>& children();
34
+ const std::map<std::string, std::shared_ptr<Interface>>& interfaces();
35
+
36
+ virtual std::shared_ptr<Proxy> path_create(const std::string& path);
37
+
38
+ // ----- PATH HANDLING -----
39
+ void register_object_path();
40
+ void unregister_object_path();
41
+
42
+ // ----- INTROSPECTION -----
43
+ // ! TODO: This should be moved to the Introspectable interface.
44
+ std::string introspect();
45
+
46
+ // ----- INTERFACE HANDLING -----
47
+ // // ! We are making the assumption that the Properties interface is always available.
48
+ // std::shared_ptr<Properties> properties() {
49
+ // return std::dynamic_pointer_cast<Properties>(interface_get("org.freedesktop.DBus.Properties"));
50
+ // }
51
+
52
+ size_t interfaces_count();
53
+ bool interfaces_loaded();
54
+ void interfaces_load(Holder managed_interfaces);
55
+ void interfaces_reload(Holder managed_interfaces);
56
+ void interfaces_unload(Holder removed_interfaces);
57
+
58
+ // ----- CHILD HANDLING -----
59
+ void path_add(const std::string& path, Holder managed_interfaces);
60
+ bool path_remove(const std::string& path, Holder removed_interfaces);
61
+ bool path_prune();
62
+ Holder path_collect();
63
+
64
+ // ----- MANUAL CHILD HANDLING -----
65
+ // ! This function is used to manually add children to the proxy.
66
+ void path_append_child(const std::string& path, std::shared_ptr<Proxy> child);
67
+ void path_remove_child(const std::string& path);
68
+ // ----- MESSAGE HANDLING -----
69
+ void message_forward(Message& msg);
70
+ void message_handle(Message& msg);
71
+
72
+ // ----- CALLBACKS -----
73
+ kvn::safe_callback<void(std::string)> on_child_created;
74
+ kvn::safe_callback<void()> on_signal_received;
75
+
76
+ // ----- TEMPLATE METHODS -----
77
+ // ! This method returns a Proxy descendant object.
78
+ template <typename T>
79
+ std::vector<std::shared_ptr<T>> children_casted() {
80
+ std::vector<std::shared_ptr<T>> result;
81
+ std::scoped_lock lock(_child_access_mutex);
82
+ for (auto& [path, child] : _children) {
83
+ result.push_back(std::dynamic_pointer_cast<T>(child));
84
+ }
85
+ return result;
86
+ }
87
+
88
+ // ! This method returns a Proxy descendant object.
89
+ template <typename T>
90
+ std::vector<std::shared_ptr<T>> children_casted_with_prefix(const std::string& prefix) {
91
+ std::vector<std::shared_ptr<T>> result;
92
+ std::scoped_lock lock(_child_access_mutex);
93
+ for (auto& [path, child] : _children) {
94
+ const std::string next_child = SimpleDBus::Path::next_child_strip(_path, path);
95
+ if (next_child.find(prefix) == 0) {
96
+ result.push_back(std::dynamic_pointer_cast<T>(child));
97
+ }
98
+ }
99
+ return result;
100
+ }
101
+
102
+ protected:
103
+ bool _valid;
104
+ bool _registered;
105
+ std::string _path;
106
+ std::string _bus_name;
107
+
108
+ std::shared_ptr<Connection> _conn;
109
+
110
+ std::map<std::string, std::shared_ptr<Interface>> _interfaces;
111
+ std::map<std::string, std::shared_ptr<Proxy>> _children;
112
+
113
+ std::recursive_mutex _interface_access_mutex;
114
+ std::recursive_mutex _child_access_mutex;
115
+ };
116
+
117
+ } // namespace SimpleDBus
@@ -0,0 +1,50 @@
1
+ #pragma once
2
+
3
+ #include <dbus/dbus.h>
4
+ #include <mutex>
5
+ #include <unordered_map>
6
+ #include <functional>
7
+ #include "Message.h"
8
+
9
+ namespace SimpleDBus {
10
+
11
+ class Message;
12
+
13
+ class Connection {
14
+ public:
15
+ Connection(::DBusBusType dbus_bus_type);
16
+ ~Connection();
17
+
18
+ void init();
19
+ void uninit();
20
+ bool is_initialized();
21
+
22
+ void add_match(std::string rule);
23
+ void remove_match(std::string rule);
24
+
25
+ void read_write();
26
+ void read_write_dispatch();
27
+ Message pop_message();
28
+
29
+ void send(Message& msg);
30
+ Message send_with_reply_and_block(Message& msg);
31
+
32
+ bool register_object_path(const std::string& path, std::function<void(Message&)> handler);
33
+ bool unregister_object_path(const std::string& path);
34
+
35
+ // ----- PROPERTIES -----
36
+ std::string unique_name();
37
+
38
+ private:
39
+ bool _initialized = false;
40
+
41
+ ::DBusBusType _dbus_bus_type;
42
+ ::DBusConnection* _conn;
43
+
44
+ std::recursive_mutex _mutex;
45
+
46
+ static DBusHandlerResult static_message_handler(DBusConnection* connection, DBusMessage* message, void* user_data);
47
+ std::unordered_map<std::string, std::function<void(Message&)>> _message_handlers;
48
+ };
49
+
50
+ } // namespace SimpleDBus
@@ -0,0 +1,56 @@
1
+ #pragma once
2
+
3
+ #include <stdexcept>
4
+ #include <string>
5
+
6
+ namespace SimpleDBus {
7
+
8
+ namespace Exception {
9
+
10
+ class BaseException : public std::exception {};
11
+
12
+ class NotInitialized : public BaseException {
13
+ public:
14
+ NotInitialized();
15
+ const char* what() const noexcept override;
16
+ };
17
+
18
+ class DBusException : public BaseException {
19
+ public:
20
+ DBusException(const std::string& err_name, const std::string& err_message);
21
+ const char* what() const noexcept override;
22
+
23
+ private:
24
+ std::string _message;
25
+ };
26
+
27
+ class SendFailed : public BaseException {
28
+ public:
29
+ SendFailed(const std::string& err_name, const std::string& err_message, const std::string& msg_str);
30
+ const char* what() const noexcept override;
31
+
32
+ private:
33
+ std::string _message;
34
+ };
35
+
36
+ class InterfaceNotFoundException : public BaseException {
37
+ public:
38
+ InterfaceNotFoundException(const std::string& path, const std::string& interface);
39
+ const char* what() const noexcept override;
40
+
41
+ private:
42
+ std::string _message;
43
+ };
44
+
45
+ class PathNotFoundException : public BaseException {
46
+ public:
47
+ PathNotFoundException(const std::string& path, const std::string& subpath);
48
+ const char* what() const noexcept override;
49
+
50
+ private:
51
+ std::string _message;
52
+ };
53
+
54
+ } // namespace Exception
55
+
56
+ } // namespace SimpleDBus
@@ -0,0 +1,147 @@
1
+ #pragma once
2
+
3
+ #include <any>
4
+ #include <optional>
5
+ #include <cstdint>
6
+ #include <map>
7
+ #include <string>
8
+ #include <vector>
9
+
10
+ namespace SimpleDBus {
11
+
12
+ class ObjectPath {
13
+ public:
14
+ ObjectPath(const std::string& path) : path(path) {}
15
+ ObjectPath(const char* path) : path(path) {}
16
+ operator std::string() const { return path; }
17
+ bool operator<(const ObjectPath& other) const { return path < other.path; }
18
+
19
+ private:
20
+ std::string path;
21
+ };
22
+
23
+ class Signature {
24
+ public:
25
+ Signature(const std::string& signature) : signature(signature) {}
26
+ Signature(const char* signature) : signature(signature) {}
27
+ operator std::string() const { return signature; }
28
+ bool operator<(const Signature& other) const { return signature < other.signature; }
29
+
30
+ private:
31
+ std::string signature;
32
+ };
33
+
34
+ class Holder;
35
+
36
+ class Holder {
37
+ public:
38
+ Holder();
39
+ ~Holder();
40
+
41
+ bool operator!=(const Holder& rhs) const;
42
+ bool operator==(const Holder& rhs) const;
43
+
44
+ typedef enum {
45
+ NONE,
46
+ BYTE,
47
+ BOOLEAN,
48
+ INT16,
49
+ UINT16,
50
+ INT32,
51
+ UINT32,
52
+ INT64,
53
+ UINT64,
54
+ DOUBLE,
55
+ STRING,
56
+ OBJ_PATH,
57
+ SIGNATURE,
58
+ ARRAY,
59
+ DICT
60
+ } Type;
61
+
62
+ Type type() const;
63
+ std::string represent() const;
64
+ std::string signature() const;
65
+ void signature_override(const std::string& signature);
66
+
67
+ // TODO: Deprecate these functions in favor of templated version.
68
+ static Holder create_boolean(bool value);
69
+ static Holder create_byte(uint8_t value);
70
+ static Holder create_int16(int16_t value);
71
+ static Holder create_uint16(uint16_t value);
72
+ static Holder create_int32(int32_t value);
73
+ static Holder create_uint32(uint32_t value);
74
+ static Holder create_int64(int64_t value);
75
+ static Holder create_uint64(uint64_t value);
76
+ static Holder create_double(double value);
77
+ static Holder create_string(const std::string& str);
78
+ static Holder create_object_path(const ObjectPath& path);
79
+ static Holder create_signature(const Signature& signature);
80
+ static Holder create_array();
81
+ static Holder create_dict();
82
+
83
+ std::any get_contents() const;
84
+
85
+ // TODO: Deprecate these functions in favor of templated version.
86
+ bool get_boolean() const;
87
+ uint8_t get_byte() const;
88
+ int16_t get_int16() const;
89
+ uint16_t get_uint16() const;
90
+ int32_t get_int32() const;
91
+ uint32_t get_uint32() const;
92
+ int64_t get_int64() const;
93
+ uint64_t get_uint64() const;
94
+ double get_double() const;
95
+ std::string get_string() const;
96
+ std::string get_object_path() const;
97
+ std::string get_signature() const;
98
+ std::vector<Holder> get_array() const;
99
+ std::map<uint8_t, Holder> get_dict_uint8() const;
100
+ std::map<uint16_t, Holder> get_dict_uint16() const;
101
+ std::map<uint32_t, Holder> get_dict_uint32() const;
102
+ std::map<uint64_t, Holder> get_dict_uint64() const;
103
+ std::map<int16_t, Holder> get_dict_int16() const;
104
+ std::map<int32_t, Holder> get_dict_int32() const;
105
+ std::map<int64_t, Holder> get_dict_int64() const;
106
+ std::map<std::string, Holder> get_dict_string() const;
107
+ std::map<std::string, Holder> get_dict_object_path() const;
108
+ std::map<std::string, Holder> get_dict_signature() const;
109
+
110
+ void dict_append(Type key_type, std::any key, Holder value);
111
+ void array_append(Holder holder);
112
+
113
+ // Template speciallizations.
114
+ template <typename T>
115
+ static Holder create();
116
+
117
+ template <typename T>
118
+ static Holder create(T value);
119
+
120
+ template <typename T>
121
+ T get() const;
122
+
123
+ private:
124
+ Type _type = NONE;
125
+ std::optional<std::string> _signature;
126
+
127
+ bool holder_boolean = false;
128
+ uint64_t holder_integer = 0;
129
+ double holder_double = 0;
130
+ std::string holder_string;
131
+ std::vector<Holder> holder_array;
132
+
133
+ // Dictionaries are stored within a vector as a tuple of <key_type, key, holder>
134
+ std::vector<std::tuple<Type, std::any, Holder>> holder_dict;
135
+
136
+ std::vector<std::string> _represent_container() const;
137
+ std::string _represent_simple() const;
138
+ std::string _signature_simple() const;
139
+
140
+ template <typename T>
141
+ std::map<T, Holder> _get_dict(Type key_type) const;
142
+
143
+ static std::string _signature_type(Type type) noexcept;
144
+ static std::string _represent_type(Type type, std::any value) noexcept;
145
+ };
146
+
147
+ } // namespace SimpleDBus
@@ -0,0 +1,57 @@
1
+ #pragma once
2
+
3
+ #include <fmt/core.h>
4
+ #include <cstdint>
5
+ #include <string>
6
+
7
+ namespace SimpleDBus {
8
+
9
+ // clang-format off
10
+
11
+ void log_fatal(const std::string& file, uint32_t line, const std::string& function, const std::string& message);
12
+ void log_error(const std::string& file, uint32_t line, const std::string& function, const std::string& message);
13
+ void log_warn(const std::string& file, uint32_t line, const std::string& function, const std::string& message);
14
+ void log_info(const std::string& file, uint32_t line, const std::string& function, const std::string& message);
15
+ void log_debug(const std::string& file, uint32_t line, const std::string& function, const std::string& message);
16
+ void log_verbose(const std::string& file, uint32_t line, const std::string& function, const std::string& message);
17
+
18
+ template <typename T, typename... Args>
19
+ void log_fatal(const std::string& file, uint32_t line, const std::string& function, const T& t, const Args&... args) {
20
+ log_fatal(file, line, function, fmt::format(t, args...));
21
+ }
22
+
23
+ template <typename T, typename... Args>
24
+ void log_error(const std::string& file, uint32_t line, const std::string& function, const T& t, const Args&... args) {
25
+ log_error(file, line, function, fmt::format(t, args...));
26
+ }
27
+
28
+ template <typename T, typename... Args>
29
+ void log_warn(const std::string& file, uint32_t line, const std::string& function, const T& t, const Args&... args) {
30
+ log_warn(file, line, function, fmt::format(t, args...));
31
+ }
32
+
33
+ template <typename T, typename... Args>
34
+ void log_info(const std::string& file, uint32_t line, const std::string& function, const T& t, const Args&... args) {
35
+ log_info(file, line, function, fmt::format(t, args...));
36
+ }
37
+
38
+ template <typename T, typename... Args>
39
+ void log_debug(const std::string& file, uint32_t line, const std::string& function, const T& t, const Args&... args) {
40
+ log_debug(file, line, function, fmt::format(t, args...));
41
+ }
42
+
43
+ template <typename T, typename... Args>
44
+ void log_verbose(const std::string& file, uint32_t line, const std::string& function, const T& t, const Args&... args) {
45
+ log_verbose(file, line, function, fmt::format(t, args...));
46
+ }
47
+
48
+ // clang-format on
49
+
50
+ } // namespace SimpleDBus
51
+
52
+ #define LOG_FATAL(...) SimpleDBus::log_fatal(__FILE__, __LINE__, __PRETTY_FUNCTION__, __VA_ARGS__)
53
+ #define LOG_ERROR(...) SimpleDBus::log_error(__FILE__, __LINE__, __PRETTY_FUNCTION__, __VA_ARGS__)
54
+ #define LOG_WARN(...) SimpleDBus::log_warn(__FILE__, __LINE__, __PRETTY_FUNCTION__, __VA_ARGS__)
55
+ #define LOG_INFO(...) SimpleDBus::log_info(__FILE__, __LINE__, __PRETTY_FUNCTION__, __VA_ARGS__)
56
+ #define LOG_DEBUG(...) SimpleDBus::log_debug(__FILE__, __LINE__, __PRETTY_FUNCTION__, __VA_ARGS__)
57
+ #define LOG_VERBOSE(...) SimpleDBus::log_verbose(__FILE__, __LINE__, __PRETTY_FUNCTION__, __VA_ARGS__)
@@ -0,0 +1,89 @@
1
+ #pragma once
2
+
3
+ #include <dbus/dbus.h>
4
+ #include <atomic>
5
+ #include <string>
6
+ #include <vector>
7
+ #include "Holder.h"
8
+
9
+ namespace SimpleDBus {
10
+
11
+ class Message {
12
+ public:
13
+ enum class Type {
14
+ INVALID = DBUS_MESSAGE_TYPE_INVALID,
15
+ METHOD_CALL = DBUS_MESSAGE_TYPE_METHOD_CALL,
16
+ METHOD_RETURN = DBUS_MESSAGE_TYPE_METHOD_RETURN,
17
+ ERROR = DBUS_MESSAGE_TYPE_ERROR,
18
+ SIGNAL = DBUS_MESSAGE_TYPE_SIGNAL,
19
+ };
20
+
21
+ static constexpr int INVALID_UNIQUE_ID = -1;
22
+
23
+ Message();
24
+ Message(Message&& other) noexcept;
25
+ Message(const Message& other);
26
+ Message& operator=(Message&& other) noexcept;
27
+ Message& operator=(const Message& other);
28
+ ~Message();
29
+
30
+ operator DBusMessage*() const;
31
+
32
+ bool is_valid() const;
33
+ void append_argument(const Holder& argument, const std::string& signature);
34
+ Holder extract();
35
+ void extract_reset();
36
+ bool extract_has_next();
37
+ void extract_next();
38
+ std::string to_string(bool append_arguments = false) const;
39
+
40
+ uint32_t get_ref_count() const;
41
+ int32_t get_unique_id() const;
42
+ uint32_t get_serial() const;
43
+ std::string get_signature();
44
+ std::string get_interface() const;
45
+ std::string get_path() const;
46
+ std::string get_member() const;
47
+ Type get_type() const;
48
+
49
+ bool is_signal(const std::string& interface, const std::string& signal_name) const;
50
+ bool is_method_call(const std::string& interface, const std::string& method) const;
51
+
52
+ static Message from_retained(DBusMessage* msg);
53
+ static Message from_acquired(DBusMessage* msg);
54
+ static Message create_method_call(const std::string& bus_name, const std::string& path,
55
+ const std::string& interface, const std::string& method);
56
+ static Message create_method_return(const Message& msg);
57
+ static Message create_error(const Message& msg, const std::string& error_name, const std::string& error_message);
58
+ static Message create_signal(const std::string& path, const std::string& interface, const std::string& signal);
59
+
60
+ private:
61
+ static std::atomic_int32_t _creation_counter;
62
+
63
+ int _indent = 0;
64
+ int32_t _unique_id = INVALID_UNIQUE_ID;
65
+ DBusMessageIter _iter;
66
+ bool _iter_initialized = false;
67
+ bool _is_extracted = false;
68
+ Holder _extracted;
69
+ DBusMessage* _msg = nullptr;
70
+ std::vector<Holder> _arguments;
71
+
72
+ Holder _extract_bytearray(DBusMessageIter* iter);
73
+ Holder _extract_array(DBusMessageIter* iter);
74
+ Holder _extract_dict(DBusMessageIter* iter);
75
+ Holder _extract_generic(DBusMessageIter* iter);
76
+
77
+ /**
78
+ * @brief Append argument to the DBus message iterator.
79
+ * @param iter DBus message iterator.
80
+ * @param argument Argument to append.
81
+ * @param signature Signature of the argument.
82
+ */
83
+ void _append_argument(DBusMessageIter* iter, const Holder& argument, const std::string& signature);
84
+
85
+ void _invalidate();
86
+ void _safe_delete();
87
+ };
88
+
89
+ } // namespace SimpleDBus
@@ -0,0 +1,24 @@
1
+ #pragma once
2
+
3
+ #include <string>
4
+ #include <vector>
5
+
6
+ namespace SimpleDBus {
7
+
8
+ class Path {
9
+ public:
10
+ static size_t count_elements(const std::string& path);
11
+ static std::string fetch_elements(const std::string& path, size_t count);
12
+ static std::vector<std::string> split_elements(const std::string& path);
13
+
14
+ static bool is_descendant(const std::string& base, const std::string& path);
15
+ static bool is_ascendant(const std::string& base, const std::string& path);
16
+
17
+ static bool is_child(const std::string& base, const std::string& path);
18
+ static bool is_parent(const std::string& base, const std::string& path);
19
+
20
+ static std::string next_child(const std::string& base, const std::string& path);
21
+ static std::string next_child_strip(const std::string& base, const std::string& path);
22
+ };
23
+
24
+ } // namespace SimpleDBus