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
@@ -1,13 +1,6 @@
1
1
  require "json"
2
2
 
3
- # package.json is now at repo root, podspec is in simplejsble/packages/simplejsble/
4
- # Try repo root first (npm package), then local (monorepo development)
5
- package_json_path = File.join(__dir__, "..", "..", "..", "package.json")
6
- if !File.exist?(package_json_path)
7
- # Fallback to local package.json for monorepo development
8
- package_json_path = File.join(__dir__, "package.json")
9
- end
10
- package = JSON.parse(File.read(package_json_path))
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
11
4
 
12
5
  Pod::Spec.new do |s|
13
6
  s.name = "NitroSimplejsble"
@@ -19,9 +12,7 @@ Pod::Spec.new do |s|
19
12
 
20
13
  s.platforms = { :ios => min_ios_version_supported, :visionos => 1.0 }
21
14
 
22
- # When package.json is at repo root, podspec is in simplejsble/packages/simplejsble/
23
- # So we need to reference the podspec's directory, not the repo root
24
- s.source = { :path => File.dirname(__FILE__) }
15
+ s.source = { :path => "." }
25
16
 
26
17
  # Build SimpleBLE from source only if XCFramework doesn't exist
27
18
  # When installed from npm, the pre-built XCFramework is already included
@@ -2,13 +2,13 @@ cmake_minimum_required(VERSION 3.9.0)
2
2
 
3
3
  # Determine if we're in the SimpleBLE monorepo or npm package
4
4
  # In monorepo: packages/simplejsble/android → ../../../../ has cmake/
5
- # In npm: simplejsble/packages/simplejsble/android → ../../../ has cmake/ (at repo root in package)
6
- if(EXISTS "${CMAKE_SOURCE_DIR}/../../../../cmake/prelude.cmake")
7
- # Monorepo: packages/simplejsble/android ../../../../
8
- set(PROJECT_ROOT_DIR ${CMAKE_SOURCE_DIR}/../../../../)
9
- elseif(EXISTS "${CMAKE_SOURCE_DIR}/../../../cmake/prelude.cmake")
10
- # npm package: simplejsble/packages/simplejsble/android → ../../../ (to repo root in package)
11
- set(PROJECT_ROOT_DIR ${CMAKE_SOURCE_DIR}/../../../)
5
+ # In npm: node_modules/simplejsble/android → ../ has cmake/ (bundled)
6
+ if(EXISTS "${CMAKE_SOURCE_DIR}/../cmake/prelude.cmake")
7
+ # npm package - bundled cmake
8
+ set(PROJECT_ROOT_DIR ${CMAKE_SOURCE_DIR}/..)
9
+ elseif(EXISTS "${CMAKE_SOURCE_DIR}/../../../../cmake/prelude.cmake")
10
+ # Monorepo
11
+ set(PROJECT_ROOT_DIR ${CMAKE_SOURCE_DIR}/../../../..)
12
12
  else()
13
13
  message(FATAL_ERROR "Cannot find SimpleBLE cmake files. Make sure you're using a complete package.")
14
14
  endif()
@@ -51,7 +51,6 @@ android {
51
51
  cmake {
52
52
  cppFlags "-frtti -fexceptions -Wall -Wextra -fstack-protector-all"
53
53
  arguments "-DANDROID_STL=c++_shared", "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON"
54
- abiFilters (*reactNativeArchitectures())
55
54
 
56
55
  buildTypes {
57
56
  debug {
@@ -1,18 +1,7 @@
1
1
  cmake_minimum_required(VERSION 3.21)
2
2
 
3
- # Determine if we're in monorepo or npm package
4
- # In monorepo: packages/simplejsble/ios → ../../../../ has cmake/
5
- # In npm: simplejsble/packages/simplejsble/ios → ../../../ has cmake/ (at repo root in package)
6
- if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../../../cmake/prelude.cmake")
7
- # Monorepo: packages/simplejsble/ios → ../../../../
8
- set(PROJECT_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../../)
9
- elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/prelude.cmake")
10
- # npm package: simplejsble/packages/simplejsble/ios → ../../../ (to repo root in package)
11
- set(PROJECT_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../)
12
- else()
13
- message(FATAL_ERROR "Cannot find SimpleBLE cmake files. Make sure you're using a complete package.")
14
- endif()
15
-
3
+ # Path: packages/simplejsble/ios ../../../.. repo root (where simpleble/ lives)
4
+ set(PROJECT_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../..)
16
5
  set(BUILD_SHARED_LIBS OFF) # Static library for iOS
17
6
 
18
7
  include(${PROJECT_ROOT_DIR}/cmake/prelude.cmake)
@@ -0,0 +1,47 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>AvailableLibraries</key>
6
+ <array>
7
+ <dict>
8
+ <key>BinaryPath</key>
9
+ <string>libsimpleble.a</string>
10
+ <key>HeadersPath</key>
11
+ <string>Headers</string>
12
+ <key>LibraryIdentifier</key>
13
+ <string>ios-arm64</string>
14
+ <key>LibraryPath</key>
15
+ <string>libsimpleble.a</string>
16
+ <key>SupportedArchitectures</key>
17
+ <array>
18
+ <string>arm64</string>
19
+ </array>
20
+ <key>SupportedPlatform</key>
21
+ <string>ios</string>
22
+ </dict>
23
+ <dict>
24
+ <key>BinaryPath</key>
25
+ <string>libsimpleble.a</string>
26
+ <key>HeadersPath</key>
27
+ <string>Headers</string>
28
+ <key>LibraryIdentifier</key>
29
+ <string>ios-arm64-simulator</string>
30
+ <key>LibraryPath</key>
31
+ <string>libsimpleble.a</string>
32
+ <key>SupportedArchitectures</key>
33
+ <array>
34
+ <string>arm64</string>
35
+ </array>
36
+ <key>SupportedPlatform</key>
37
+ <string>ios</string>
38
+ <key>SupportedPlatformVariant</key>
39
+ <string>simulator</string>
40
+ </dict>
41
+ </array>
42
+ <key>CFBundlePackageType</key>
43
+ <string>XFWK</string>
44
+ <key>XCFrameworkFormatVersion</key>
45
+ <string>1.0</string>
46
+ </dict>
47
+ </plist>
@@ -4,20 +4,6 @@ set -e
4
4
  SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
5
  IOS_DEPLOYMENT_TARGET="${IOS_DEPLOYMENT_TARGET:-13.4}"
6
6
 
7
- # Determine if we're in monorepo or npm package
8
- # In monorepo: packages/simplejsble/ios → ../../../../ has cmake/
9
- # In npm: simplejsble/packages/simplejsble/ios → ../../../ has cmake/ (at repo root in package)
10
- if [ -f "${SCRIPT_DIR}/../../../../cmake/prelude.cmake" ]; then
11
- # Monorepo: packages/simplejsble/ios → ../../../../
12
- PROJECT_ROOT_DIR="${SCRIPT_DIR}/../../../../"
13
- elif [ -f "${SCRIPT_DIR}/../../../cmake/prelude.cmake" ]; then
14
- # npm package: simplejsble/packages/simplejsble/ios → ../../../ (to repo root in package)
15
- PROJECT_ROOT_DIR="${SCRIPT_DIR}/../../../"
16
- else
17
- echo "Error: Cannot find SimpleBLE cmake files. Make sure you're using a complete package."
18
- exit 1
19
- fi
20
-
21
7
  build_for_platform() {
22
8
  local PLATFORM=$1 # iphoneos or iphonesimulator
23
9
  local ARCH=$2 # arm64 or x86_64
@@ -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