simplejsble 0.0.1 → 0.0.3

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/NitroSimplejsble.podspec +58 -0
  2. package/android/CMakeLists.txt +35 -0
  3. package/android/build.gradle +142 -0
  4. package/android/fix-prefab.gradle +51 -0
  5. package/android/gradle.properties +5 -0
  6. package/android/src/main/AndroidManifest.xml +2 -0
  7. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  8. package/android/src/main/java/com/margelo/nitro/simplejsble/NitroSimplejsblePackage.kt +18 -0
  9. package/cpp/HybridAdapter.cpp +20 -0
  10. package/cpp/HybridAdapter.hpp +22 -0
  11. package/ios/Bridge.h +8 -0
  12. package/ios/CMakeLists.txt +21 -0
  13. package/ios/SimpleBLE.xcframework/Info.plist +47 -0
  14. package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/Adapter.h +102 -0
  15. package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/AdapterSafe.h +58 -0
  16. package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/Advanced.h +50 -0
  17. package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/Characteristic.h +39 -0
  18. package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/Config.h +64 -0
  19. package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/Descriptor.h +30 -0
  20. package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/Exceptions.h +72 -0
  21. package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/Logging.h +73 -0
  22. package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/Peripheral.h +82 -0
  23. package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/PeripheralSafe.h +64 -0
  24. package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/Service.h +34 -0
  25. package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/SimpleBLE.h +8 -0
  26. package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/Types.h +49 -0
  27. package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/Utils.h +13 -0
  28. package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/export.h +43 -0
  29. package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/kvn/kvn_bytearray.h +297 -0
  30. package/ios/SimpleBLE.xcframework/ios-arm64/libsimpleble.a +0 -0
  31. package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/Adapter.h +102 -0
  32. package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/AdapterSafe.h +58 -0
  33. package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/Advanced.h +50 -0
  34. package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/Characteristic.h +39 -0
  35. package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/Config.h +64 -0
  36. package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/Descriptor.h +30 -0
  37. package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/Exceptions.h +72 -0
  38. package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/Logging.h +73 -0
  39. package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/Peripheral.h +82 -0
  40. package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/PeripheralSafe.h +64 -0
  41. package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/Service.h +34 -0
  42. package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/SimpleBLE.h +8 -0
  43. package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/Types.h +49 -0
  44. package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/Utils.h +13 -0
  45. package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/export.h +43 -0
  46. package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/kvn/kvn_bytearray.h +297 -0
  47. package/ios/SimpleBLE.xcframework/ios-arm64-simulator/libsimpleble.a +0 -0
  48. package/ios/build_simpleble.sh +51 -0
  49. package/ios/simpleble_iphoneos_arm64/include/simpleble/Adapter.h +102 -0
  50. package/ios/simpleble_iphoneos_arm64/include/simpleble/AdapterSafe.h +58 -0
  51. package/ios/simpleble_iphoneos_arm64/include/simpleble/Advanced.h +50 -0
  52. package/ios/simpleble_iphoneos_arm64/include/simpleble/Characteristic.h +39 -0
  53. package/ios/simpleble_iphoneos_arm64/include/simpleble/Config.h +64 -0
  54. package/ios/simpleble_iphoneos_arm64/include/simpleble/Descriptor.h +30 -0
  55. package/ios/simpleble_iphoneos_arm64/include/simpleble/Exceptions.h +72 -0
  56. package/ios/simpleble_iphoneos_arm64/include/simpleble/Logging.h +73 -0
  57. package/ios/simpleble_iphoneos_arm64/include/simpleble/Peripheral.h +82 -0
  58. package/ios/simpleble_iphoneos_arm64/include/simpleble/PeripheralSafe.h +64 -0
  59. package/ios/simpleble_iphoneos_arm64/include/simpleble/Service.h +34 -0
  60. package/ios/simpleble_iphoneos_arm64/include/simpleble/SimpleBLE.h +8 -0
  61. package/ios/simpleble_iphoneos_arm64/include/simpleble/Types.h +49 -0
  62. package/ios/simpleble_iphoneos_arm64/include/simpleble/Utils.h +13 -0
  63. package/ios/simpleble_iphoneos_arm64/include/simpleble/export.h +43 -0
  64. package/ios/simpleble_iphoneos_arm64/include/simpleble/kvn/kvn_bytearray.h +297 -0
  65. package/ios/simpleble_iphoneos_arm64/lib/cmake/simpleble/simpleble-config-release.cmake +19 -0
  66. package/ios/simpleble_iphoneos_arm64/lib/cmake/simpleble/simpleble-config.cmake +107 -0
  67. package/ios/simpleble_iphoneos_arm64/lib/libsimpleble.a +0 -0
  68. package/ios/simpleble_iphoneos_arm64/lib/pkgconfig/simpleble.pc +11 -0
  69. package/ios/simpleble_iphonesimulator_arm64/include/simpleble/Adapter.h +102 -0
  70. package/ios/simpleble_iphonesimulator_arm64/include/simpleble/AdapterSafe.h +58 -0
  71. package/ios/simpleble_iphonesimulator_arm64/include/simpleble/Advanced.h +50 -0
  72. package/ios/simpleble_iphonesimulator_arm64/include/simpleble/Characteristic.h +39 -0
  73. package/ios/simpleble_iphonesimulator_arm64/include/simpleble/Config.h +64 -0
  74. package/ios/simpleble_iphonesimulator_arm64/include/simpleble/Descriptor.h +30 -0
  75. package/ios/simpleble_iphonesimulator_arm64/include/simpleble/Exceptions.h +72 -0
  76. package/ios/simpleble_iphonesimulator_arm64/include/simpleble/Logging.h +73 -0
  77. package/ios/simpleble_iphonesimulator_arm64/include/simpleble/Peripheral.h +82 -0
  78. package/ios/simpleble_iphonesimulator_arm64/include/simpleble/PeripheralSafe.h +64 -0
  79. package/ios/simpleble_iphonesimulator_arm64/include/simpleble/Service.h +34 -0
  80. package/ios/simpleble_iphonesimulator_arm64/include/simpleble/SimpleBLE.h +8 -0
  81. package/ios/simpleble_iphonesimulator_arm64/include/simpleble/Types.h +49 -0
  82. package/ios/simpleble_iphonesimulator_arm64/include/simpleble/Utils.h +13 -0
  83. package/ios/simpleble_iphonesimulator_arm64/include/simpleble/export.h +43 -0
  84. package/ios/simpleble_iphonesimulator_arm64/include/simpleble/kvn/kvn_bytearray.h +297 -0
  85. package/ios/simpleble_iphonesimulator_arm64/lib/cmake/simpleble/simpleble-config-release.cmake +19 -0
  86. package/ios/simpleble_iphonesimulator_arm64/lib/cmake/simpleble/simpleble-config.cmake +107 -0
  87. package/ios/simpleble_iphonesimulator_arm64/lib/libsimpleble.a +0 -0
  88. package/ios/simpleble_iphonesimulator_arm64/lib/pkgconfig/simpleble.pc +11 -0
  89. package/lib/index.d.ts +2 -0
  90. package/lib/index.js +2 -0
  91. package/lib/specs/Adapter.nitro.d.ts +9 -0
  92. package/lib/specs/Adapter.nitro.js +1 -0
  93. package/nitro.json +23 -0
  94. package/nitrogen/generated/.gitattributes +1 -0
  95. package/nitrogen/generated/android/NitroSimplejsble+autolinking.cmake +81 -0
  96. package/nitrogen/generated/android/NitroSimplejsble+autolinking.gradle +27 -0
  97. package/nitrogen/generated/android/NitroSimplejsbleOnLoad.cpp +44 -0
  98. package/nitrogen/generated/android/NitroSimplejsbleOnLoad.hpp +25 -0
  99. package/nitrogen/generated/android/kotlin/com/margelo/nitro/simplejsble/NitroSimplejsbleOnLoad.kt +35 -0
  100. package/nitrogen/generated/ios/NitroSimplejsble+autolinking.rb +60 -0
  101. package/nitrogen/generated/ios/NitroSimplejsble-Swift-Cxx-Bridge.cpp +17 -0
  102. package/nitrogen/generated/ios/NitroSimplejsble-Swift-Cxx-Bridge.hpp +27 -0
  103. package/nitrogen/generated/ios/NitroSimplejsble-Swift-Cxx-Umbrella.hpp +38 -0
  104. package/nitrogen/generated/ios/NitroSimplejsbleAutolinking.mm +35 -0
  105. package/nitrogen/generated/ios/NitroSimplejsbleAutolinking.swift +12 -0
  106. package/nitrogen/generated/shared/c++/HybridAdapterSpec.cpp +23 -0
  107. package/nitrogen/generated/shared/c++/HybridAdapterSpec.hpp +68 -0
  108. package/package.json +108 -6
  109. package/react-native.config.js +16 -0
  110. package/src/index.ts +5 -0
  111. package/src/specs/Adapter.nitro.ts +9 -0
  112. package/README.md +0 -0
  113. package/index.js +0 -6
@@ -0,0 +1,58 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = "NitroSimplejsble"
7
+ s.version = package["version"]
8
+ s.summary = package["description"]
9
+ s.homepage = package["homepage"]
10
+ s.license = package["license"]
11
+ s.authors = package["author"]
12
+
13
+ s.platforms = { :ios => min_ios_version_supported, :visionos => 1.0 }
14
+
15
+ s.source = { :path => "." }
16
+
17
+ # Build SimpleBLE from source using CMake during pod install
18
+ s.prepare_command = <<-CMD
19
+ echo "Building SimpleBLE for iOS..."
20
+ chmod +x ios/build_simpleble.sh
21
+ ios/build_simpleble.sh
22
+ CMD
23
+
24
+ s.source_files = [
25
+ # Implementation (Swift)
26
+ "ios/**/*.{swift}",
27
+ # Autolinking/Registration (Objective-C++)
28
+ "ios/**/*.{m,mm}",
29
+ # Implementation (C++ objects)
30
+ "cpp/**/*.{hpp,cpp}",
31
+ ]
32
+
33
+ # Exclude CMakeLists.txt from source files
34
+ s.exclude_files = ["ios/CMakeLists.txt"]
35
+
36
+ load 'nitrogen/generated/ios/NitroSimplejsble+autolinking.rb'
37
+ add_nitrogen_files(s)
38
+
39
+ s.dependency 'React-jsi'
40
+ s.dependency 'React-callinvoker'
41
+ install_modules_dependencies(s)
42
+
43
+ # Required frameworks for SimpleBLE iOS backend
44
+ s.frameworks = ['Foundation', 'CoreBluetooth']
45
+
46
+ # Vendored XCFramework containing all architectures
47
+ s.ios.vendored_frameworks = 'ios/SimpleBLE.xcframework'
48
+
49
+ # Configure header search paths for SimpleBLE
50
+ current_pod_target_xcconfig = s.attributes_hash['pod_target_xcconfig'] || {}
51
+ s.pod_target_xcconfig = current_pod_target_xcconfig.merge({
52
+ 'HEADER_SEARCH_PATHS' => [
53
+ '"$(inherited)"',
54
+ '"$(PODS_TARGET_SRCROOT)/ios/simpleble_iphoneos_arm64/include"',
55
+ '"$(PODS_TARGET_SRCROOT)/ios/simpleble_iphonesimulator_arm64/include"',
56
+ ].join(' '),
57
+ })
58
+ end
@@ -0,0 +1,35 @@
1
+ project(NitroSimplejsble)
2
+ cmake_minimum_required(VERSION 3.9.0)
3
+
4
+ set (PACKAGE_NAME NitroSimplejsble)
5
+ set (CMAKE_VERBOSE_MAKEFILE ON)
6
+ set (CMAKE_CXX_STANDARD 20)
7
+
8
+ # Define C++ library and add all sources
9
+ add_library(${PACKAGE_NAME} SHARED
10
+ src/main/cpp/cpp-adapter.cpp
11
+ ../cpp/HybridAdapter.cpp
12
+ )
13
+
14
+ # Add Nitrogen specs :)
15
+ include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/NitroSimplejsble+autolinking.cmake)
16
+
17
+ # Add simpleble
18
+ # Path: packages/simplejsble/android → ../../../../simpleble
19
+ add_subdirectory(${CMAKE_SOURCE_DIR}/../../../../simpleble ${CMAKE_BINARY_DIR}/simpleble)
20
+
21
+ # Set up local includes
22
+ include_directories(
23
+ "src/main/cpp"
24
+ "../cpp"
25
+ )
26
+
27
+ find_library(LOG_LIB log)
28
+
29
+ # Link all libraries together
30
+ target_link_libraries(
31
+ ${PACKAGE_NAME}
32
+ ${LOG_LIB}
33
+ simpleble::simpleble # <-- SimpleBLE library
34
+ android # <-- Android core
35
+ )
@@ -0,0 +1,142 @@
1
+ buildscript {
2
+ repositories {
3
+ google()
4
+ mavenCentral()
5
+ }
6
+
7
+ dependencies {
8
+ classpath "com.android.tools.build:gradle:8.13.2"
9
+ }
10
+ }
11
+
12
+ def reactNativeArchitectures() {
13
+ def value = rootProject.getProperties().get("reactNativeArchitectures")
14
+ return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
15
+ }
16
+
17
+ def isNewArchitectureEnabled() {
18
+ return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
19
+ }
20
+
21
+ apply plugin: "com.android.library"
22
+ apply plugin: 'org.jetbrains.kotlin.android'
23
+ apply from: '../nitrogen/generated/android/NitroSimplejsble+autolinking.gradle'
24
+ apply from: "./fix-prefab.gradle"
25
+
26
+ if (isNewArchitectureEnabled()) {
27
+ apply plugin: "com.facebook.react"
28
+ }
29
+
30
+ def getExtOrDefault(name) {
31
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["NitroSimplejsble_" + name]
32
+ }
33
+
34
+ def getExtOrIntegerDefault(name) {
35
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["NitroSimplejsble_" + name]).toInteger()
36
+ }
37
+
38
+ android {
39
+ namespace "com.margelo.nitro.simplejsble"
40
+
41
+ ndkVersion getExtOrDefault("ndkVersion")
42
+ compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
43
+
44
+ defaultConfig {
45
+ minSdkVersion getExtOrIntegerDefault("minSdkVersion")
46
+ targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
47
+ buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
48
+ multiDexEnabled true
49
+
50
+ externalNativeBuild {
51
+ cmake {
52
+ cppFlags "-frtti -fexceptions -Wall -Wextra -fstack-protector-all"
53
+ arguments "-DANDROID_STL=c++_shared", "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON"
54
+ abiFilters (*reactNativeArchitectures())
55
+
56
+ buildTypes {
57
+ debug {
58
+ cppFlags "-O1 -g"
59
+ }
60
+ release {
61
+ cppFlags "-O2"
62
+ }
63
+ }
64
+ }
65
+ }
66
+ }
67
+
68
+ externalNativeBuild {
69
+ cmake {
70
+ path "CMakeLists.txt"
71
+ }
72
+ }
73
+
74
+ packagingOptions {
75
+ excludes = [
76
+ "META-INF",
77
+ "META-INF/**",
78
+ "**/libc++_shared.so",
79
+ "**/libfbjni.so",
80
+ "**/libjsi.so",
81
+ "**/libfolly_json.so",
82
+ "**/libfolly_runtime.so",
83
+ "**/libglog.so",
84
+ "**/libhermes.so",
85
+ "**/libhermes-executor-debug.so",
86
+ "**/libhermes_executor.so",
87
+ "**/libreactnative.so",
88
+ "**/libreactnativejni.so",
89
+ "**/libturbomodulejsijni.so",
90
+ "**/libreact_nativemodule_core.so",
91
+ "**/libjscexecutor.so"
92
+ ]
93
+ }
94
+
95
+ buildFeatures {
96
+ buildConfig true
97
+ prefab true
98
+ }
99
+
100
+ buildTypes {
101
+ release {
102
+ minifyEnabled false
103
+ }
104
+ }
105
+
106
+ lintOptions {
107
+ disable "GradleCompatible"
108
+ }
109
+
110
+ compileOptions {
111
+ sourceCompatibility JavaVersion.VERSION_1_8
112
+ targetCompatibility JavaVersion.VERSION_1_8
113
+ }
114
+
115
+ sourceSets {
116
+ main {
117
+ if (isNewArchitectureEnabled()) {
118
+ java.srcDirs += [
119
+ // React Codegen files
120
+ "${project.buildDir}/generated/source/codegen/java"
121
+ ]
122
+ }
123
+ }
124
+ }
125
+ }
126
+
127
+ repositories {
128
+ mavenCentral()
129
+ google()
130
+ }
131
+
132
+
133
+ dependencies {
134
+ // For < 0.71, this will be from the local maven repo
135
+ // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
136
+ //noinspection GradleDynamicVersion
137
+ implementation "com.facebook.react:react-native:+"
138
+
139
+ // Add a dependency on NitroModules
140
+ implementation project(":react-native-nitro-modules")
141
+ }
142
+
@@ -0,0 +1,51 @@
1
+ tasks.configureEach { task ->
2
+ // Make sure that we generate our prefab publication file only after having built the native library
3
+ // so that not a header publication file, but a full configuration publication will be generated, which
4
+ // will include the .so file
5
+
6
+ def prefabConfigurePattern = ~/^prefab(.+)ConfigurePackage$/
7
+ def matcher = task.name =~ prefabConfigurePattern
8
+ if (matcher.matches()) {
9
+ def variantName = matcher[0][1]
10
+ task.outputs.upToDateWhen { false }
11
+ task.dependsOn("externalNativeBuild${variantName}")
12
+ }
13
+ }
14
+
15
+ afterEvaluate {
16
+ def abis = reactNativeArchitectures()
17
+ rootProject.allprojects.each { proj ->
18
+ if (proj === rootProject) return
19
+
20
+ def dependsOnThisLib = proj.configurations.findAll { it.canBeResolved }.any { config ->
21
+ config.dependencies.any { dep ->
22
+ dep.group == project.group && dep.name == project.name
23
+ }
24
+ }
25
+ if (!dependsOnThisLib && proj != project) return
26
+
27
+ if (!proj.plugins.hasPlugin('com.android.application') && !proj.plugins.hasPlugin('com.android.library')) {
28
+ return
29
+ }
30
+
31
+ def variants = proj.android.hasProperty('applicationVariants') ? proj.android.applicationVariants : proj.android.libraryVariants
32
+ // Touch the prefab_config.json files to ensure that in ExternalNativeJsonGenerator.kt we will re-trigger the prefab CLI to
33
+ // generate a libnameConfig.cmake file that will contain our native library (.so).
34
+ // See this condition: https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:build-system/gradle-core/src/main/java/com/android/build/gradle/tasks/ExternalNativeJsonGenerator.kt;l=207-219?q=createPrefabBuildSystemGlue
35
+ variants.all { variant ->
36
+ def variantName = variant.name
37
+ abis.each { abi ->
38
+ def searchDir = new File(proj.projectDir, ".cxx/${variantName}")
39
+ if (!searchDir.exists()) return
40
+ def matches = []
41
+ searchDir.eachDir { randomDir ->
42
+ def prefabFile = new File(randomDir, "${abi}/prefab_config.json")
43
+ if (prefabFile.exists()) matches << prefabFile
44
+ }
45
+ matches.each { prefabConfig ->
46
+ prefabConfig.setLastModified(System.currentTimeMillis())
47
+ }
48
+ }
49
+ }
50
+ }
51
+ }
@@ -0,0 +1,5 @@
1
+ NitroSimplejsble_kotlinVersion=2.1.20
2
+ NitroSimplejsble_minSdkVersion=23
3
+ NitroSimplejsble_targetSdkVersion=36
4
+ NitroSimplejsble_compileSdkVersion=36
5
+ NitroSimplejsble_ndkVersion=27.1.12297006
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>
@@ -0,0 +1,6 @@
1
+ #include <jni.h>
2
+ #include "NitroSimplejsbleOnLoad.hpp"
3
+
4
+ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
5
+ return margelo::nitro::simplejsble::initialize(vm);
6
+ }
@@ -0,0 +1,18 @@
1
+ package com.margelo.nitro.simplejsble
2
+
3
+ import com.facebook.react.bridge.NativeModule
4
+ import com.facebook.react.bridge.ReactApplicationContext
5
+ import com.facebook.react.module.model.ReactModuleInfoProvider
6
+ import com.facebook.react.BaseReactPackage
7
+
8
+ class NitroSimplejsblePackage : BaseReactPackage() {
9
+ override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? = null
10
+
11
+ override fun getReactModuleInfoProvider(): ReactModuleInfoProvider = ReactModuleInfoProvider { HashMap() }
12
+
13
+ companion object {
14
+ init {
15
+ NitroSimplejsbleOnLoad.initializeNative()
16
+ }
17
+ }
18
+ }
@@ -0,0 +1,20 @@
1
+ #include "HybridAdapter.hpp"
2
+
3
+ namespace margelo::nitro::simplejsble {
4
+
5
+ std::string HybridAdapter::greet(const std::string& name) { return "Hello, " + name + "!"; }
6
+
7
+ std::vector<std::shared_ptr<HybridAdapterSpec>> HybridAdapter::get_adapters() {
8
+ std::vector<std::shared_ptr<HybridAdapterSpec>> result;
9
+
10
+ for (auto& adapter : SimpleBLE::Adapter::get_adapters()) {
11
+ auto hybrid_adapter = std::make_shared<HybridAdapter>(adapter);
12
+ result.push_back(hybrid_adapter);
13
+ }
14
+
15
+ return result;
16
+ }
17
+
18
+ bool HybridAdapter::bluetooth_enabled() { return SimpleBLE::Adapter::bluetooth_enabled(); }
19
+
20
+ } // namespace margelo::nitro::simplejsble
@@ -0,0 +1,22 @@
1
+ #pragma once
2
+
3
+ #include "HybridAdapterSpec.hpp"
4
+ #include <simpleble/SimpleBLE.h>
5
+ #include <string>
6
+
7
+ namespace margelo::nitro::simplejsble {
8
+
9
+ class HybridAdapter : public HybridAdapterSpec {
10
+ public:
11
+ HybridAdapter() : HybridObject(TAG) {}
12
+ HybridAdapter(SimpleBLE::Adapter adapter) : HybridObject(TAG), _adapter(adapter) {}
13
+
14
+ std::string greet(const std::string& name) override;
15
+ std::vector<std::shared_ptr<HybridAdapterSpec>> get_adapters() override;
16
+ bool bluetooth_enabled() override;
17
+
18
+ private:
19
+ SimpleBLE::Adapter _adapter;
20
+ };
21
+
22
+ } // namespace margelo::nitro::simplejsble
package/ios/Bridge.h ADDED
@@ -0,0 +1,8 @@
1
+ //
2
+ // Bridge.h
3
+ // NitroSimplejsble
4
+ //
5
+ // Created by Marc Rousavy on 22.07.24.
6
+ //
7
+
8
+ #pragma once
@@ -0,0 +1,21 @@
1
+ cmake_minimum_required(VERSION 3.21)
2
+
3
+ # Path: packages/simplejsble/ios → ../../../.. → repo root (where simpleble/ lives)
4
+ set(PROJECT_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../..)
5
+ set(BUILD_SHARED_LIBS OFF) # Static library for iOS
6
+
7
+ include(${PROJECT_ROOT_DIR}/cmake/prelude.cmake)
8
+
9
+ project(simpleble-ios VERSION ${SIMPLEBLE_VERSION_BASE} LANGUAGES CXX C OBJCXX)
10
+
11
+ include(${PROJECT_ROOT_DIR}/cmake/epilogue.cmake)
12
+
13
+ add_subdirectory(${PROJECT_ROOT_DIR}/simpleble ${CMAKE_BINARY_DIR}/simpleble)
14
+
15
+ # Install library
16
+ install(TARGETS simpleble ARCHIVE DESTINATION lib)
17
+
18
+ # Install headers (including generated export.h)
19
+ install(DIRECTORY ${PROJECT_ROOT_DIR}/simpleble/include/simpleble/ DESTINATION include/simpleble)
20
+ install(DIRECTORY ${CMAKE_BINARY_DIR}/simpleble/export/simpleble/ DESTINATION include/simpleble)
21
+ install(FILES ${PROJECT_ROOT_DIR}/dependencies/external/kvn/kvn_bytearray.h DESTINATION include/simpleble/kvn)
@@ -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>
@@ -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