simplejsble 0.0.7 → 0.0.9

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 (113) hide show
  1. package/{simplejsble/packages/simplejsble/NitroSimplejsble.podspec → NitroSimplejsble.podspec} +2 -11
  2. package/{simplejsble/packages/simplejsble/android → android}/CMakeLists.txt +7 -7
  3. package/{simplejsble/packages/simplejsble/android → android}/build.gradle +0 -1
  4. package/{simplejsble/packages/simplejsble/ios → ios}/CMakeLists.txt +2 -13
  5. package/ios/SimpleBLE.xcframework/Info.plist +47 -0
  6. package/ios/SimpleBLE.xcframework/ios-arm64/libsimpleble.a +0 -0
  7. package/ios/SimpleBLE.xcframework/ios-arm64-simulator/libsimpleble.a +0 -0
  8. package/{simplejsble/packages/simplejsble/ios → ios}/build_simpleble.sh +0 -14
  9. package/ios/simpleble_iphoneos_arm64/include/simpleble/Adapter.h +102 -0
  10. package/ios/simpleble_iphoneos_arm64/include/simpleble/AdapterSafe.h +58 -0
  11. package/ios/simpleble_iphoneos_arm64/include/simpleble/Advanced.h +50 -0
  12. package/ios/simpleble_iphoneos_arm64/include/simpleble/Characteristic.h +39 -0
  13. package/ios/simpleble_iphoneos_arm64/include/simpleble/Config.h +64 -0
  14. package/ios/simpleble_iphoneos_arm64/include/simpleble/Descriptor.h +30 -0
  15. package/ios/simpleble_iphoneos_arm64/include/simpleble/Exceptions.h +72 -0
  16. package/ios/simpleble_iphoneos_arm64/include/simpleble/Logging.h +73 -0
  17. package/ios/simpleble_iphoneos_arm64/include/simpleble/Peripheral.h +82 -0
  18. package/ios/simpleble_iphoneos_arm64/include/simpleble/PeripheralSafe.h +64 -0
  19. package/ios/simpleble_iphoneos_arm64/include/simpleble/Service.h +34 -0
  20. package/ios/simpleble_iphoneos_arm64/include/simpleble/SimpleBLE.h +8 -0
  21. package/ios/simpleble_iphoneos_arm64/include/simpleble/Types.h +49 -0
  22. package/ios/simpleble_iphoneos_arm64/include/simpleble/Utils.h +13 -0
  23. package/ios/simpleble_iphoneos_arm64/include/simpleble/export.h +43 -0
  24. package/ios/simpleble_iphoneos_arm64/include/simpleble/kvn/kvn_bytearray.h +297 -0
  25. package/ios/simpleble_iphoneos_arm64/lib/cmake/simpleble/simpleble-config-release.cmake +19 -0
  26. package/ios/simpleble_iphoneos_arm64/lib/cmake/simpleble/simpleble-config.cmake +107 -0
  27. package/ios/simpleble_iphoneos_arm64/lib/libsimpleble.a +0 -0
  28. package/ios/simpleble_iphoneos_arm64/lib/pkgconfig/simpleble.pc +11 -0
  29. package/ios/simpleble_iphonesimulator_arm64/include/simpleble/Adapter.h +102 -0
  30. package/ios/simpleble_iphonesimulator_arm64/include/simpleble/AdapterSafe.h +58 -0
  31. package/ios/simpleble_iphonesimulator_arm64/include/simpleble/Advanced.h +50 -0
  32. package/ios/simpleble_iphonesimulator_arm64/include/simpleble/Characteristic.h +39 -0
  33. package/ios/simpleble_iphonesimulator_arm64/include/simpleble/Config.h +64 -0
  34. package/ios/simpleble_iphonesimulator_arm64/include/simpleble/Descriptor.h +30 -0
  35. package/ios/simpleble_iphonesimulator_arm64/include/simpleble/Exceptions.h +72 -0
  36. package/ios/simpleble_iphonesimulator_arm64/include/simpleble/Logging.h +73 -0
  37. package/ios/simpleble_iphonesimulator_arm64/include/simpleble/Peripheral.h +82 -0
  38. package/ios/simpleble_iphonesimulator_arm64/include/simpleble/PeripheralSafe.h +64 -0
  39. package/ios/simpleble_iphonesimulator_arm64/include/simpleble/Service.h +34 -0
  40. package/ios/simpleble_iphonesimulator_arm64/include/simpleble/SimpleBLE.h +8 -0
  41. package/ios/simpleble_iphonesimulator_arm64/include/simpleble/Types.h +49 -0
  42. package/ios/simpleble_iphonesimulator_arm64/include/simpleble/Utils.h +13 -0
  43. package/ios/simpleble_iphonesimulator_arm64/include/simpleble/export.h +43 -0
  44. package/ios/simpleble_iphonesimulator_arm64/include/simpleble/kvn/kvn_bytearray.h +297 -0
  45. package/ios/simpleble_iphonesimulator_arm64/lib/cmake/simpleble/simpleble-config-release.cmake +19 -0
  46. package/ios/simpleble_iphonesimulator_arm64/lib/cmake/simpleble/simpleble-config.cmake +107 -0
  47. package/ios/simpleble_iphonesimulator_arm64/lib/libsimpleble.a +0 -0
  48. package/ios/simpleble_iphonesimulator_arm64/lib/pkgconfig/simpleble.pc +11 -0
  49. package/lib/index.d.ts +2 -0
  50. package/lib/index.js +2 -0
  51. package/lib/specs/Adapter.nitro.d.ts +9 -0
  52. package/lib/specs/Adapter.nitro.js +1 -0
  53. package/package.json +25 -23
  54. package/LICENSE.md +0 -89
  55. package/README.rst +0 -125
  56. /package/{simplejsble/packages/simplejsble/android → android}/fix-prefab.gradle +0 -0
  57. /package/{simplejsble/packages/simplejsble/android → android}/gradle.properties +0 -0
  58. /package/{simplejsble/packages/simplejsble/android → android}/src/main/AndroidManifest.xml +0 -0
  59. /package/{simplejsble/packages/simplejsble/android → android}/src/main/cpp/cpp-adapter.cpp +0 -0
  60. /package/{simplejsble/packages/simplejsble/android → android}/src/main/java/com/margelo/nitro/simplejsble/NitroSimplejsblePackage.kt +0 -0
  61. /package/{simplejsble/packages/simplejsble/cpp → cpp}/HybridAdapter.cpp +0 -0
  62. /package/{simplejsble/packages/simplejsble/cpp → cpp}/HybridAdapter.hpp +0 -0
  63. /package/{simplejsble/packages/simplejsble/ios → ios}/Bridge.h +0 -0
  64. /package/{simplejsble/packages/simplejsble/ios/simpleble_iphonesimulator_arm64/include → ios/SimpleBLE.xcframework/ios-arm64/Headers}/simpleble/Adapter.h +0 -0
  65. /package/{simplejsble/packages/simplejsble/ios/simpleble_iphonesimulator_arm64/include → ios/SimpleBLE.xcframework/ios-arm64/Headers}/simpleble/AdapterSafe.h +0 -0
  66. /package/{simplejsble/packages/simplejsble/ios/simpleble_iphonesimulator_arm64/include → ios/SimpleBLE.xcframework/ios-arm64/Headers}/simpleble/Advanced.h +0 -0
  67. /package/{simplejsble/packages/simplejsble/ios/simpleble_iphonesimulator_arm64/include → ios/SimpleBLE.xcframework/ios-arm64/Headers}/simpleble/Characteristic.h +0 -0
  68. /package/{simplejsble/packages/simplejsble/ios/simpleble_iphonesimulator_arm64/include → ios/SimpleBLE.xcframework/ios-arm64/Headers}/simpleble/Config.h +0 -0
  69. /package/{simplejsble/packages/simplejsble/ios/simpleble_iphonesimulator_arm64/include → ios/SimpleBLE.xcframework/ios-arm64/Headers}/simpleble/Descriptor.h +0 -0
  70. /package/{simplejsble/packages/simplejsble/ios/simpleble_iphonesimulator_arm64/include → ios/SimpleBLE.xcframework/ios-arm64/Headers}/simpleble/Exceptions.h +0 -0
  71. /package/{simplejsble/packages/simplejsble/ios/simpleble_iphonesimulator_arm64/include → ios/SimpleBLE.xcframework/ios-arm64/Headers}/simpleble/Logging.h +0 -0
  72. /package/{simplejsble/packages/simplejsble/ios/simpleble_iphonesimulator_arm64/include → ios/SimpleBLE.xcframework/ios-arm64/Headers}/simpleble/Peripheral.h +0 -0
  73. /package/{simplejsble/packages/simplejsble/ios/simpleble_iphonesimulator_arm64/include → ios/SimpleBLE.xcframework/ios-arm64/Headers}/simpleble/PeripheralSafe.h +0 -0
  74. /package/{simplejsble/packages/simplejsble/ios/simpleble_iphonesimulator_arm64/include → ios/SimpleBLE.xcframework/ios-arm64/Headers}/simpleble/Service.h +0 -0
  75. /package/{simplejsble/packages/simplejsble/ios/simpleble_iphonesimulator_arm64/include → ios/SimpleBLE.xcframework/ios-arm64/Headers}/simpleble/SimpleBLE.h +0 -0
  76. /package/{simplejsble/packages/simplejsble/ios/simpleble_iphonesimulator_arm64/include → ios/SimpleBLE.xcframework/ios-arm64/Headers}/simpleble/Types.h +0 -0
  77. /package/{simplejsble/packages/simplejsble/ios/simpleble_iphonesimulator_arm64/include → ios/SimpleBLE.xcframework/ios-arm64/Headers}/simpleble/Utils.h +0 -0
  78. /package/{simplejsble/packages/simplejsble/ios/simpleble_iphonesimulator_arm64/include → ios/SimpleBLE.xcframework/ios-arm64/Headers}/simpleble/export.h +0 -0
  79. /package/{simplejsble/packages/simplejsble/ios/simpleble_iphonesimulator_arm64/include → ios/SimpleBLE.xcframework/ios-arm64/Headers}/simpleble/kvn/kvn_bytearray.h +0 -0
  80. /package/{simplejsble/packages/simplejsble/ios/simpleble_iphoneos_arm64/include → ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers}/simpleble/Adapter.h +0 -0
  81. /package/{simplejsble/packages/simplejsble/ios/simpleble_iphoneos_arm64/include → ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers}/simpleble/AdapterSafe.h +0 -0
  82. /package/{simplejsble/packages/simplejsble/ios/simpleble_iphoneos_arm64/include → ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers}/simpleble/Advanced.h +0 -0
  83. /package/{simplejsble/packages/simplejsble/ios/simpleble_iphoneos_arm64/include → ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers}/simpleble/Characteristic.h +0 -0
  84. /package/{simplejsble/packages/simplejsble/ios/simpleble_iphoneos_arm64/include → ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers}/simpleble/Config.h +0 -0
  85. /package/{simplejsble/packages/simplejsble/ios/simpleble_iphoneos_arm64/include → ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers}/simpleble/Descriptor.h +0 -0
  86. /package/{simplejsble/packages/simplejsble/ios/simpleble_iphoneos_arm64/include → ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers}/simpleble/Exceptions.h +0 -0
  87. /package/{simplejsble/packages/simplejsble/ios/simpleble_iphoneos_arm64/include → ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers}/simpleble/Logging.h +0 -0
  88. /package/{simplejsble/packages/simplejsble/ios/simpleble_iphoneos_arm64/include → ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers}/simpleble/Peripheral.h +0 -0
  89. /package/{simplejsble/packages/simplejsble/ios/simpleble_iphoneos_arm64/include → ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers}/simpleble/PeripheralSafe.h +0 -0
  90. /package/{simplejsble/packages/simplejsble/ios/simpleble_iphoneos_arm64/include → ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers}/simpleble/Service.h +0 -0
  91. /package/{simplejsble/packages/simplejsble/ios/simpleble_iphoneos_arm64/include → ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers}/simpleble/SimpleBLE.h +0 -0
  92. /package/{simplejsble/packages/simplejsble/ios/simpleble_iphoneos_arm64/include → ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers}/simpleble/Types.h +0 -0
  93. /package/{simplejsble/packages/simplejsble/ios/simpleble_iphoneos_arm64/include → ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers}/simpleble/Utils.h +0 -0
  94. /package/{simplejsble/packages/simplejsble/ios/simpleble_iphoneos_arm64/include → ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers}/simpleble/export.h +0 -0
  95. /package/{simplejsble/packages/simplejsble/ios/simpleble_iphoneos_arm64/include → ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers}/simpleble/kvn/kvn_bytearray.h +0 -0
  96. /package/{simplejsble/packages/simplejsble/nitro.json → nitro.json} +0 -0
  97. /package/{simplejsble/packages/simplejsble/nitrogen → nitrogen}/generated/.gitattributes +0 -0
  98. /package/{simplejsble/packages/simplejsble/nitrogen → nitrogen}/generated/android/NitroSimplejsble+autolinking.cmake +0 -0
  99. /package/{simplejsble/packages/simplejsble/nitrogen → nitrogen}/generated/android/NitroSimplejsble+autolinking.gradle +0 -0
  100. /package/{simplejsble/packages/simplejsble/nitrogen → nitrogen}/generated/android/NitroSimplejsbleOnLoad.cpp +0 -0
  101. /package/{simplejsble/packages/simplejsble/nitrogen → nitrogen}/generated/android/NitroSimplejsbleOnLoad.hpp +0 -0
  102. /package/{simplejsble/packages/simplejsble/nitrogen → nitrogen}/generated/android/kotlin/com/margelo/nitro/simplejsble/NitroSimplejsbleOnLoad.kt +0 -0
  103. /package/{simplejsble/packages/simplejsble/nitrogen → nitrogen}/generated/ios/NitroSimplejsble+autolinking.rb +0 -0
  104. /package/{simplejsble/packages/simplejsble/nitrogen → nitrogen}/generated/ios/NitroSimplejsble-Swift-Cxx-Bridge.cpp +0 -0
  105. /package/{simplejsble/packages/simplejsble/nitrogen → nitrogen}/generated/ios/NitroSimplejsble-Swift-Cxx-Bridge.hpp +0 -0
  106. /package/{simplejsble/packages/simplejsble/nitrogen → nitrogen}/generated/ios/NitroSimplejsble-Swift-Cxx-Umbrella.hpp +0 -0
  107. /package/{simplejsble/packages/simplejsble/nitrogen → nitrogen}/generated/ios/NitroSimplejsbleAutolinking.mm +0 -0
  108. /package/{simplejsble/packages/simplejsble/nitrogen → nitrogen}/generated/ios/NitroSimplejsbleAutolinking.swift +0 -0
  109. /package/{simplejsble/packages/simplejsble/nitrogen → nitrogen}/generated/shared/c++/HybridAdapterSpec.cpp +0 -0
  110. /package/{simplejsble/packages/simplejsble/nitrogen → nitrogen}/generated/shared/c++/HybridAdapterSpec.hpp +0 -0
  111. /package/{simplejsble/packages/simplejsble/react-native.config.js → react-native.config.js} +0 -0
  112. /package/{simplejsble/packages/simplejsble/src → src}/index.ts +0 -0
  113. /package/{simplejsble/packages/simplejsble/src → src}/specs/Adapter.nitro.ts +0 -0
@@ -0,0 +1,107 @@
1
+ # Generated by CMake
2
+
3
+ if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.8)
4
+ message(FATAL_ERROR "CMake >= 2.8.12 required")
5
+ endif()
6
+ if(CMAKE_VERSION VERSION_LESS "2.8.12")
7
+ message(FATAL_ERROR "CMake >= 2.8.12 required")
8
+ endif()
9
+ cmake_policy(PUSH)
10
+ cmake_policy(VERSION 2.8.12...4.0)
11
+ #----------------------------------------------------------------
12
+ # Generated CMake target import file.
13
+ #----------------------------------------------------------------
14
+
15
+ # Commands may need to know the format version.
16
+ set(CMAKE_IMPORT_FILE_VERSION 1)
17
+
18
+ # Protect against multiple inclusion, which would fail when already imported targets are added once more.
19
+ set(_cmake_targets_defined "")
20
+ set(_cmake_targets_not_defined "")
21
+ set(_cmake_expected_targets "")
22
+ foreach(_cmake_expected_target IN ITEMS simpleble::simpleble)
23
+ list(APPEND _cmake_expected_targets "${_cmake_expected_target}")
24
+ if(TARGET "${_cmake_expected_target}")
25
+ list(APPEND _cmake_targets_defined "${_cmake_expected_target}")
26
+ else()
27
+ list(APPEND _cmake_targets_not_defined "${_cmake_expected_target}")
28
+ endif()
29
+ endforeach()
30
+ unset(_cmake_expected_target)
31
+ if(_cmake_targets_defined STREQUAL _cmake_expected_targets)
32
+ unset(_cmake_targets_defined)
33
+ unset(_cmake_targets_not_defined)
34
+ unset(_cmake_expected_targets)
35
+ unset(CMAKE_IMPORT_FILE_VERSION)
36
+ cmake_policy(POP)
37
+ return()
38
+ endif()
39
+ if(NOT _cmake_targets_defined STREQUAL "")
40
+ string(REPLACE ";" ", " _cmake_targets_defined_text "${_cmake_targets_defined}")
41
+ string(REPLACE ";" ", " _cmake_targets_not_defined_text "${_cmake_targets_not_defined}")
42
+ message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_cmake_targets_defined_text}\nTargets not yet defined: ${_cmake_targets_not_defined_text}\n")
43
+ endif()
44
+ unset(_cmake_targets_defined)
45
+ unset(_cmake_targets_not_defined)
46
+ unset(_cmake_expected_targets)
47
+
48
+
49
+ # Compute the installation prefix relative to this file.
50
+ get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
51
+ get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
52
+ get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
53
+ get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
54
+ if(_IMPORT_PREFIX STREQUAL "/")
55
+ set(_IMPORT_PREFIX "")
56
+ endif()
57
+
58
+ # Create imported target simpleble::simpleble
59
+ add_library(simpleble::simpleble STATIC IMPORTED)
60
+
61
+ set_target_properties(simpleble::simpleble PROPERTIES
62
+ INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
63
+ INTERFACE_LINK_LIBRARIES "-framework Foundation;-framework CoreBluetooth;ObjC"
64
+ )
65
+
66
+ # Load information for each installed configuration.
67
+ file(GLOB _cmake_config_files "${CMAKE_CURRENT_LIST_DIR}/simpleble-config-*.cmake")
68
+ foreach(_cmake_config_file IN LISTS _cmake_config_files)
69
+ include("${_cmake_config_file}")
70
+ endforeach()
71
+ unset(_cmake_config_file)
72
+ unset(_cmake_config_files)
73
+
74
+ # Cleanup temporary variables.
75
+ set(_IMPORT_PREFIX)
76
+
77
+ # Loop over all imported files and verify that they actually exist
78
+ foreach(_cmake_target IN LISTS _cmake_import_check_targets)
79
+ if(CMAKE_VERSION VERSION_LESS "3.28"
80
+ OR NOT DEFINED _cmake_import_check_xcframework_for_${_cmake_target}
81
+ OR NOT IS_DIRECTORY "${_cmake_import_check_xcframework_for_${_cmake_target}}")
82
+ foreach(_cmake_file IN LISTS "_cmake_import_check_files_for_${_cmake_target}")
83
+ if(NOT EXISTS "${_cmake_file}")
84
+ message(FATAL_ERROR "The imported target \"${_cmake_target}\" references the file
85
+ \"${_cmake_file}\"
86
+ but this file does not exist. Possible reasons include:
87
+ * The file was deleted, renamed, or moved to another location.
88
+ * An install or uninstall procedure did not complete successfully.
89
+ * The installation package was faulty and contained
90
+ \"${CMAKE_CURRENT_LIST_FILE}\"
91
+ but not all the files it references.
92
+ ")
93
+ endif()
94
+ endforeach()
95
+ endif()
96
+ unset(_cmake_file)
97
+ unset("_cmake_import_check_files_for_${_cmake_target}")
98
+ endforeach()
99
+ unset(_cmake_target)
100
+ unset(_cmake_import_check_targets)
101
+
102
+ # This file does not depend on other imported targets which have
103
+ # been exported from the same project but in a separate export set.
104
+
105
+ # Commands beyond this point should not need to know the version.
106
+ set(CMAKE_IMPORT_FILE_VERSION)
107
+ cmake_policy(POP)
@@ -0,0 +1,11 @@
1
+ prefix=/Users/alejorojas/work/caos/simpleble/simplejsble/packages/simplejsble/ios/simpleble_iphoneos_arm64
2
+ exec_prefix=/Users/alejorojas/work/caos/simpleble/simplejsble/packages/simplejsble/ios/simpleble_iphoneos_arm64
3
+ libdir=/Users/alejorojas/work/caos/simpleble/simplejsble/packages/simplejsble/ios/simpleble_iphoneos_arm64/lib
4
+ includedir=/Users/alejorojas/work/caos/simpleble/simplejsble/packages/simplejsble/ios/simpleble_iphoneos_arm64/include
5
+
6
+ Name: SimpleBLE
7
+ Description: "The ultimate fully-fledged cross-platform library for Bluetooth Low Energy (BLE)."
8
+ Version: 0.10.4
9
+ Libs: -L${libdir} -lsimpleble
10
+ Cflags: -I${includedir}
11
+ Conflicts:
@@ -0,0 +1,102 @@
1
+ #pragma once
2
+
3
+ #include <functional>
4
+ #include <memory>
5
+ #include <string>
6
+ #include <vector>
7
+
8
+ #include <simpleble/export.h>
9
+
10
+ #include <simpleble/Exceptions.h>
11
+ #include <simpleble/Peripheral.h>
12
+ #include <simpleble/Types.h>
13
+
14
+ namespace SimpleBLE {
15
+
16
+ class AdapterBase;
17
+
18
+ /**
19
+ * Bluetooth Adapter.
20
+ *
21
+ * A default-constructed Adapter object is not initialized. Calling any method
22
+ * other than `initialized()` on an uninitialized Adapter will throw an exception
23
+ * of type `SimpleBLE::NotInitialized`.
24
+ *
25
+ * NOTE: This class is intended to be used by the user only. Library developers
26
+ * should use shared pointers to `AdapterBase` instead.
27
+ */
28
+ class SIMPLEBLE_EXPORT Adapter {
29
+ public:
30
+ Adapter() = default;
31
+ virtual ~Adapter() = default;
32
+
33
+ bool initialized() const;
34
+
35
+ /**
36
+ * Retrieve the underlying OS object/handle.
37
+ *
38
+ * For certain compatibility with external libraries, we sometimes need to
39
+ * expose the actual OS handle to the user. This is particularly important
40
+ * for MacOS right now.
41
+ */
42
+ void* underlying() const;
43
+
44
+ std::string identifier();
45
+ BluetoothAddress address();
46
+
47
+ /**
48
+ * Control the power state of the adapter.
49
+ *
50
+ * NOTE: The power on/off functionality is only supported on Windows and Linux (implementation pending).
51
+ * On other platforms, this method will do nothing.
52
+ * NOTE: Callbacks are currently a placeholder for future implementation.
53
+ */
54
+ void power_on();
55
+ void power_off();
56
+ bool is_powered();
57
+ void set_callback_on_power_on(std::function<void()> on_power_on);
58
+ void set_callback_on_power_off(std::function<void()> on_power_off);
59
+
60
+ void scan_start();
61
+ void scan_stop();
62
+ void scan_for(int timeout_ms);
63
+ bool scan_is_active();
64
+ std::vector<Peripheral> scan_get_results();
65
+
66
+ void set_callback_on_scan_start(std::function<void()> on_scan_start);
67
+ void set_callback_on_scan_stop(std::function<void()> on_scan_stop);
68
+ void set_callback_on_scan_updated(std::function<void(Peripheral)> on_scan_updated);
69
+ void set_callback_on_scan_found(std::function<void(Peripheral)> on_scan_found);
70
+
71
+ /**
72
+ * Retrieve a list of all paired peripherals.
73
+ *
74
+ * NOTE:This method is currently only supported by the Linux, Windows and Android backends.
75
+ */
76
+ std::vector<Peripheral> get_paired_peripherals();
77
+
78
+ /**
79
+ * Retrieve a list of all connected peripherals.
80
+ *
81
+ * NOTE: This method is currently only supported by the Windows backend. (More backends coming soon.)
82
+ */
83
+ std::vector<Peripheral> get_connected_peripherals();
84
+
85
+ static bool bluetooth_enabled();
86
+
87
+ /**
88
+ * Fetches a list of all available adapters from all available backends.
89
+ *
90
+ * This will cause backends to be instantiated/initialized and adapters
91
+ * too.
92
+ */
93
+ static std::vector<Adapter> get_adapters();
94
+
95
+ protected:
96
+ AdapterBase* operator->();
97
+ const AdapterBase* operator->() const;
98
+
99
+ std::shared_ptr<AdapterBase> internal_;
100
+ };
101
+
102
+ } // namespace SimpleBLE
@@ -0,0 +1,58 @@
1
+ #pragma once
2
+
3
+ #include <simpleble/export.h>
4
+
5
+ #include <simpleble/Adapter.h>
6
+ #include <simpleble/PeripheralSafe.h>
7
+ #include <memory>
8
+ #include <optional>
9
+ #include <vector>
10
+
11
+ namespace SimpleBLE {
12
+
13
+ namespace Safe {
14
+
15
+ /**
16
+ * Wrapper around the Adapter class that provides a noexcept interface.
17
+ *
18
+ * We use instances of this class directly and not through shared_ptr because
19
+ * this is just a wrapper around the Adapter class, which is already managed by
20
+ * shared_ptr.
21
+ */
22
+ class SIMPLEBLE_EXPORT Adapter {
23
+ public:
24
+ Adapter(SimpleBLE::Adapter& adapter);
25
+ Adapter(SimpleBLE::Adapter&& adapter);
26
+ virtual ~Adapter() = default;
27
+
28
+ std::optional<std::string> identifier() noexcept;
29
+ std::optional<BluetoothAddress> address() noexcept;
30
+
31
+ bool scan_start() noexcept;
32
+ bool scan_stop() noexcept;
33
+ bool scan_for(int timeout_ms) noexcept;
34
+ std::optional<bool> scan_is_active() noexcept;
35
+ std::optional<std::vector<SimpleBLE::Safe::Peripheral>> scan_get_results() noexcept;
36
+
37
+ bool set_callback_on_scan_start(std::function<void()> on_scan_start) noexcept;
38
+ bool set_callback_on_scan_stop(std::function<void()> on_scan_stop) noexcept;
39
+ bool set_callback_on_scan_updated(std::function<void(SimpleBLE::Safe::Peripheral)> on_scan_updated) noexcept;
40
+ bool set_callback_on_scan_found(std::function<void(SimpleBLE::Safe::Peripheral)> on_scan_found) noexcept;
41
+
42
+ std::optional<std::vector<SimpleBLE::Safe::Peripheral>> get_paired_peripherals() noexcept;
43
+
44
+ static std::optional<bool> bluetooth_enabled() noexcept;
45
+ static std::optional<std::vector<SimpleBLE::Safe::Adapter>> get_adapters() noexcept;
46
+
47
+ /**
48
+ * Cast to the underlying adapter object.
49
+ */
50
+ operator SimpleBLE::Adapter() const noexcept;
51
+
52
+ protected:
53
+ SimpleBLE::Adapter internal_;
54
+ };
55
+
56
+ } // namespace Safe
57
+
58
+ } // namespace SimpleBLE
@@ -0,0 +1,50 @@
1
+ #pragma once
2
+
3
+ #include <simpleble/export.h>
4
+
5
+ #if __APPLE__
6
+ #include "TargetConditionals.h"
7
+ #endif
8
+
9
+ /**
10
+ * Advanced Features
11
+ *
12
+ * The functions presented in this namespace are OS-specific backdoors that are
13
+ * not part of the standard SimpleBLE API, which allow the user to access
14
+ * low-level details of the implementation for advanced use cases.
15
+ *
16
+ * These functions should be used with caution.
17
+ */
18
+
19
+ #if defined(_WIN32)
20
+ namespace SimpleBLE::Advanced::Windows {}
21
+
22
+ #endif
23
+
24
+ #if TARGET_OS_OSX
25
+ namespace SimpleBLE::Advanced::MacOS {}
26
+
27
+ #endif
28
+
29
+ #if TARGET_OS_IOS
30
+ namespace SimpleBLE::Advanced::iOS {}
31
+
32
+ #endif
33
+
34
+ #if defined(__ANDROID__)
35
+
36
+ #include <jni.h>
37
+
38
+ namespace SimpleBLE::Advanced::Android {
39
+
40
+ JavaVM* SIMPLEBLE_EXPORT get_jvm();
41
+ void SIMPLEBLE_EXPORT set_jvm(JavaVM* jvm);
42
+
43
+ } // namespace SimpleBLE::Advanced::Android
44
+
45
+ #endif
46
+
47
+ #if defined(__linux__) && !defined(__ANDROID__)
48
+ namespace SimpleBLE::Advanced::Linux {}
49
+
50
+ #endif
@@ -0,0 +1,39 @@
1
+ #pragma once
2
+
3
+ #include <memory>
4
+
5
+ #include <simpleble/export.h>
6
+
7
+ #include <simpleble/Descriptor.h>
8
+ #include <simpleble/Exceptions.h>
9
+ #include <simpleble/Types.h>
10
+
11
+ namespace SimpleBLE {
12
+
13
+ class CharacteristicBase;
14
+
15
+ class SIMPLEBLE_EXPORT Characteristic {
16
+ public:
17
+ Characteristic() = default;
18
+ virtual ~Characteristic() = default;
19
+
20
+ bool initialized() const;
21
+
22
+ BluetoothUUID uuid();
23
+ std::vector<Descriptor> descriptors();
24
+ std::vector<std::string> capabilities();
25
+
26
+ bool can_read();
27
+ bool can_write_request();
28
+ bool can_write_command();
29
+ bool can_notify();
30
+ bool can_indicate();
31
+
32
+ protected:
33
+ CharacteristicBase* operator->();
34
+ const CharacteristicBase* operator->() const;
35
+
36
+ std::shared_ptr<CharacteristicBase> internal_;
37
+ };
38
+
39
+ } // namespace SimpleBLE
@@ -0,0 +1,64 @@
1
+ #pragma once
2
+ #include <chrono>
3
+
4
+ namespace SimpleBLE {
5
+ namespace Config {
6
+ namespace SimpleBluez {
7
+ extern bool use_legacy_bluez_backend;
8
+ extern std::chrono::steady_clock::duration connection_timeout;
9
+ extern std::chrono::steady_clock::duration disconnection_timeout;
10
+
11
+ static void reset() {
12
+ use_legacy_bluez_backend = true;
13
+ connection_timeout = std::chrono::seconds(2);
14
+ disconnection_timeout = std::chrono::seconds(1);
15
+ }
16
+ }
17
+
18
+ namespace WinRT {
19
+ extern bool experimental_use_own_mta_apartment;
20
+ extern bool experimental_reinitialize_winrt_apartment_on_main_thread;
21
+
22
+ static void reset() {
23
+ experimental_use_own_mta_apartment = true;
24
+ experimental_reinitialize_winrt_apartment_on_main_thread = false;
25
+ }
26
+ }
27
+
28
+ namespace CoreBluetooth {
29
+ static void reset() {}
30
+ }
31
+
32
+ namespace Android {
33
+ enum class ConnectionPriorityRequest {
34
+ DISABLED = -1,
35
+ BALANCED = 0,
36
+ HIGH = 1,
37
+ LOW_POWER = 2,
38
+ DCK = 3
39
+ };
40
+
41
+ extern ConnectionPriorityRequest connection_priority_request;
42
+
43
+ static void reset() {
44
+ connection_priority_request = ConnectionPriorityRequest::DISABLED;
45
+ }
46
+ }
47
+
48
+ namespace Dongl {
49
+ extern bool use_dongl_backend;
50
+ static void reset() {
51
+ use_dongl_backend = false;
52
+ }
53
+ }
54
+
55
+ namespace Base {
56
+ static void reset_all() {
57
+ SimpleBluez::reset();
58
+ WinRT::reset();
59
+ CoreBluetooth::reset();
60
+ Android::reset();
61
+ }
62
+ }
63
+ } // namespace Config
64
+ } // namespace SimpleBLE
@@ -0,0 +1,30 @@
1
+ #pragma once
2
+
3
+ #include <memory>
4
+
5
+ #include <simpleble/export.h>
6
+
7
+ #include <simpleble/Exceptions.h>
8
+ #include <simpleble/Types.h>
9
+
10
+ namespace SimpleBLE {
11
+
12
+ class DescriptorBase;
13
+
14
+ class SIMPLEBLE_EXPORT Descriptor {
15
+ public:
16
+ Descriptor() = default;
17
+ virtual ~Descriptor() = default;
18
+
19
+ bool initialized() const;
20
+
21
+ BluetoothUUID uuid();
22
+
23
+ protected:
24
+ DescriptorBase* operator->();
25
+ const DescriptorBase* operator->() const;
26
+
27
+ std::shared_ptr<DescriptorBase> internal_;
28
+ };
29
+
30
+ } // namespace SimpleBLE
@@ -0,0 +1,72 @@
1
+ #pragma once
2
+
3
+ #include <stdexcept>
4
+ #include <string>
5
+
6
+ #include <simpleble/export.h>
7
+
8
+ #include "Types.h"
9
+
10
+ namespace SimpleBLE {
11
+
12
+ namespace Exception {
13
+
14
+ class SIMPLEBLE_EXPORT BaseException : public std::runtime_error {
15
+ public:
16
+ BaseException(const std::string& __arg) : std::runtime_error(__arg) {}
17
+ };
18
+
19
+ class SIMPLEBLE_EXPORT NotInitialized : public BaseException {
20
+ public:
21
+ NotInitialized();
22
+ };
23
+
24
+ class SIMPLEBLE_EXPORT NotConnected : public BaseException {
25
+ public:
26
+ NotConnected();
27
+ };
28
+
29
+ class SIMPLEBLE_EXPORT InvalidReference : public BaseException {
30
+ public:
31
+ InvalidReference();
32
+ };
33
+
34
+ class SIMPLEBLE_EXPORT ServiceNotFound : public BaseException {
35
+ public:
36
+ ServiceNotFound(BluetoothUUID uuid);
37
+ };
38
+
39
+ class SIMPLEBLE_EXPORT CharacteristicNotFound : public BaseException {
40
+ public:
41
+ CharacteristicNotFound(BluetoothUUID uuid);
42
+ };
43
+
44
+ class SIMPLEBLE_EXPORT DescriptorNotFound : public BaseException {
45
+ public:
46
+ DescriptorNotFound(BluetoothUUID uuid);
47
+ };
48
+
49
+ class SIMPLEBLE_EXPORT OperationNotSupported : public BaseException {
50
+ public:
51
+ OperationNotSupported();
52
+ };
53
+
54
+ class SIMPLEBLE_EXPORT OperationFailed : public BaseException {
55
+ public:
56
+ OperationFailed();
57
+ OperationFailed(const std::string& err_msg);
58
+ };
59
+
60
+ class SIMPLEBLE_EXPORT WinRTException : public BaseException {
61
+ public:
62
+ WinRTException(int32_t err_code, const std::string& err_msg);
63
+ };
64
+
65
+ class SIMPLEBLE_EXPORT CoreBluetoothException : public BaseException {
66
+ public:
67
+ CoreBluetoothException(const std::string& err_msg);
68
+ };
69
+
70
+ } // namespace Exception
71
+
72
+ } // namespace SimpleBLE
@@ -0,0 +1,73 @@
1
+ #pragma once
2
+
3
+ #include <cstdint>
4
+ #include <functional>
5
+ #include <mutex>
6
+ #include <string>
7
+
8
+ #include <simpleble/export.h>
9
+
10
+ namespace SimpleBLE {
11
+
12
+ namespace Logging {
13
+
14
+ enum Level : int {
15
+ None = 0,
16
+ Fatal,
17
+ Error,
18
+ Warn,
19
+ Info,
20
+ Debug,
21
+ Verbose,
22
+ };
23
+
24
+ // clang-format off
25
+ using Callback = std::function<void(
26
+ Level,
27
+ const std::string& module,
28
+ const std::string& file,
29
+ uint32_t line,
30
+ const std::string& function,
31
+ const std::string& message)>;
32
+ // clang-format on
33
+
34
+ class SIMPLEBLE_EXPORT Logger {
35
+ public:
36
+ static Logger* get();
37
+
38
+ void set_level(Level level);
39
+ Level get_level();
40
+
41
+ void set_callback(Callback callback);
42
+ bool has_callback();
43
+
44
+ void log_default_stdout();
45
+ void log_default_file();
46
+ void log_default_file(const std::string path);
47
+
48
+ // clang-format off
49
+ void log(
50
+ Level level,
51
+ const std::string& module,
52
+ const std::string& file,
53
+ uint32_t line,
54
+ const std::string& function,
55
+ const std::string& message);
56
+ // clang-format on
57
+
58
+ private:
59
+ Logger();
60
+ ~Logger();
61
+ Logger(Logger& other) = delete; // Remove copy constructor
62
+ void operator=(const Logger&) = delete; // Remove copy assignment
63
+
64
+ static std::string level_to_str(Level level);
65
+
66
+ Level level_{Level::Info};
67
+ Callback callback_{nullptr};
68
+ std::recursive_mutex mutex_;
69
+ };
70
+
71
+ } // namespace Logging
72
+
73
+ } // namespace SimpleBLE
@@ -0,0 +1,82 @@
1
+ #pragma once
2
+
3
+ #include <cstdint>
4
+ #include <functional>
5
+ #include <map>
6
+ #include <memory>
7
+ #include <string>
8
+ #include <vector>
9
+
10
+ #include <simpleble/export.h>
11
+
12
+ #include <simpleble/Exceptions.h>
13
+ #include <simpleble/Service.h>
14
+ #include <simpleble/Types.h>
15
+
16
+ namespace SimpleBLE {
17
+
18
+ class PeripheralBase;
19
+
20
+ class SIMPLEBLE_EXPORT Peripheral {
21
+ public:
22
+ Peripheral() = default;
23
+ virtual ~Peripheral() = default;
24
+
25
+ bool initialized() const;
26
+ void* underlying() const;
27
+
28
+ std::string identifier();
29
+ BluetoothAddress address();
30
+ BluetoothAddressType address_type();
31
+ int16_t rssi();
32
+
33
+ /**
34
+ * @brief Provides the advertised transmit power in dBm.
35
+ *
36
+ * @note If the field has not been advertised by the peripheral,
37
+ * the returned value will be -32768.
38
+ */
39
+ int16_t tx_power();
40
+ uint16_t mtu();
41
+
42
+ void connect();
43
+ void disconnect();
44
+ bool is_connected();
45
+ bool is_connectable();
46
+ bool is_paired();
47
+ void unpair();
48
+
49
+ /**
50
+ * @brief Provides a list of all services that are available on the peripheral.
51
+ *
52
+ * @note If the peripheral is not connected, it will return a list of services
53
+ * that were advertised by the device.
54
+ */
55
+ std::vector<Service> services();
56
+ std::map<uint16_t, ByteArray> manufacturer_data();
57
+
58
+ /* Calling any of the methods below when the device is not connected will throw
59
+ Exception::NotConnected */
60
+ // clang-format off
61
+ ByteArray read(BluetoothUUID const& service, BluetoothUUID const& characteristic);
62
+ void write_request(BluetoothUUID const& service, BluetoothUUID const& characteristic, ByteArray const& data);
63
+ void write_command(BluetoothUUID const& service, BluetoothUUID const& characteristic, ByteArray const& data);
64
+ void notify(BluetoothUUID const& service, BluetoothUUID const& characteristic, std::function<void(ByteArray payload)> callback);
65
+ void indicate(BluetoothUUID const& service, BluetoothUUID const& characteristic, std::function<void(ByteArray payload)> callback);
66
+ void unsubscribe(BluetoothUUID const& service, BluetoothUUID const& characteristic);
67
+
68
+ ByteArray read(BluetoothUUID const& service, BluetoothUUID const& characteristic, BluetoothUUID const& descriptor);
69
+ void write(BluetoothUUID const& service, BluetoothUUID const& characteristic, BluetoothUUID const& descriptor, ByteArray const& data);
70
+ // clang-format on
71
+
72
+ void set_callback_on_connected(std::function<void()> on_connected);
73
+ void set_callback_on_disconnected(std::function<void()> on_disconnected);
74
+
75
+ protected:
76
+ PeripheralBase* operator->();
77
+ const PeripheralBase* operator->() const;
78
+
79
+ std::shared_ptr<PeripheralBase> internal_;
80
+ };
81
+
82
+ } // namespace SimpleBLE