simplejsble 0.0.28 → 0.0.30

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 (30) hide show
  1. package/NitroSimplejsble.podspec +78 -22
  2. package/VERSION +1 -1
  3. package/android/SIMPLEDROIDBRIDGE_INTEGRATION.md +77 -0
  4. package/android/build.gradle +2 -2
  5. package/android/gradle.properties +3 -3
  6. package/dependencies/external/kvn/kvn_bytearray.h +7 -0
  7. package/ios/CMAKE_INSTALL_OPTIONS.md +50 -0
  8. package/lib/index.js +2 -0
  9. package/lib/specs/Adapter.nitro.js +1 -0
  10. package/package.json +4 -3
  11. package/simpleble/CMakeLists.txt +1 -6
  12. package/simpleble/src/backends/dongl/AdapterDongl.cpp +10 -143
  13. package/simpleble/src/backends/dongl/AdapterDongl.h +0 -1
  14. package/simpleble/src/backends/dongl/PeripheralDongl.cpp +120 -118
  15. package/simpleble/src/backends/dongl/PeripheralDongl.h +9 -2
  16. package/simpleble/src/backends/dongl/protocol/d2h.pb.h +9 -26
  17. package/simpleble/src/backends/dongl/protocol/h2d.pb.h +2 -12
  18. package/simpleble/src/backends/dongl/serial/Protocol.cpp +1 -755
  19. package/simpleble/src/backends/dongl/serial/Protocol.h +0 -75
  20. package/simpleble/test/src/test_bytearray.cpp +7 -0
  21. package/simpleble/src/backends/dongl/protocol/softdevice.pb.c +0 -18
  22. package/simpleble/src/backends/dongl/protocol/softdevice.pb.h +0 -815
  23. package/simpleble/src/backends/dongl/protocol/softdevice_gap.pb.c +0 -339
  24. package/simpleble/src/backends/dongl/protocol/softdevice_gap.pb.h +0 -2086
  25. package/simpleble/src/backends/dongl/protocol/softdevice_gattc.pb.c +0 -114
  26. package/simpleble/src/backends/dongl/protocol/softdevice_gattc.pb.h +0 -772
  27. package/simpleble/src/backends/dongl/protocol/softdevice_gatts.pb.c +0 -117
  28. package/simpleble/src/backends/dongl/protocol/softdevice_gatts.pb.h +0 -766
  29. package/simpleble/src/backends/dongl/protocol/softdevice_types.pb.c +0 -207
  30. package/simpleble/src/backends/dongl/protocol/softdevice_types.pb.h +0 -1686
@@ -10,31 +10,36 @@ Pod::Spec.new do |s|
10
10
  s.license = package["license"]
11
11
  s.authors = package["author"]
12
12
 
13
- s.platforms = { :ios => min_ios_version_supported }
13
+ s.platforms = {
14
+ :ios => min_ios_version_supported,
15
+ :osx => '10.13'
16
+ }
14
17
 
15
18
  s.source = { :path => "." }
16
19
 
17
20
  # Build SimpleBLE from source only if XCFramework doesn't exist
18
21
  # When installed from npm, the pre-built XCFramework is already included
19
22
  s.prepare_command = <<-CMD
20
- # Build iOS XCFramework if not present
23
+ # Build iOS/macOS XCFramework if not present
21
24
  if [ -d "ios/SimpleBLE.xcframework" ]; then
22
- echo "SimpleBLE.xcframework (iOS) already exists, skipping build"
25
+ echo "SimpleBLE.xcframework already exists, skipping build"
23
26
  else
24
- echo "Building SimpleBLE for iOS..."
27
+ echo "Building SimpleBLE for iOS and macOS..."
25
28
  set -e
26
29
  IOS_DIR="ios"
27
30
  IOS_DEPLOYMENT_TARGET="${IOS_DEPLOYMENT_TARGET:-13.4}"
28
-
29
- build_for_platform() {
31
+ MACOS_DEPLOYMENT_TARGET="${MACOS_DEPLOYMENT_TARGET:-10.13}"
32
+
33
+ # Build for iOS platforms (iphoneos, iphonesimulator)
34
+ build_for_ios_platform() {
30
35
  local PLATFORM=$1 # iphoneos or iphonesimulator
31
36
  local ARCH=$2 # arm64 or x86_64
32
-
37
+
33
38
  local BUILD_DIR="${IOS_DIR}/build_${PLATFORM}_${ARCH}"
34
39
  local INSTALL_DIR="${IOS_DIR}/simpleble_${PLATFORM}_${ARCH}"
35
-
40
+
36
41
  echo "Building SimpleBLE for ${PLATFORM} (${ARCH})..."
37
-
42
+
38
43
  cmake -B "${BUILD_DIR}" -S "${IOS_DIR}" \
39
44
  -DCMAKE_BUILD_TYPE=Release \
40
45
  -DCMAKE_SYSTEM_NAME=iOS \
@@ -44,31 +49,74 @@ Pod::Spec.new do |s|
44
49
  -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
45
50
  -DBUILD_SHARED_LIBS=OFF \
46
51
  -DSIMPLEBLE_EXCLUDE_C=ON
47
-
52
+
53
+ cmake --build "${BUILD_DIR}" --config Release --parallel
54
+ cmake --install "${BUILD_DIR}" --config Release
55
+
56
+ echo "Installed to ${INSTALL_DIR}"
57
+ }
58
+
59
+ # Build for macOS platforms
60
+ build_for_macos_platform() {
61
+ local ARCH=$1 # arm64 or x86_64
62
+
63
+ local BUILD_DIR="${IOS_DIR}/build_macosx_${ARCH}"
64
+ local INSTALL_DIR="${IOS_DIR}/simpleble_macosx_${ARCH}"
65
+
66
+ echo "Building SimpleBLE for macOS (${ARCH})..."
67
+
68
+ cmake -B "${BUILD_DIR}" -S "${IOS_DIR}" \
69
+ -DCMAKE_BUILD_TYPE=Release \
70
+ -DCMAKE_SYSTEM_NAME=Darwin \
71
+ -DCMAKE_OSX_SYSROOT="macosx" \
72
+ -DCMAKE_OSX_ARCHITECTURES="${ARCH}" \
73
+ -DCMAKE_OSX_DEPLOYMENT_TARGET="${MACOS_DEPLOYMENT_TARGET}" \
74
+ -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
75
+ -DBUILD_SHARED_LIBS=OFF \
76
+ -DSIMPLEBLE_EXCLUDE_C=ON
77
+
48
78
  cmake --build "${BUILD_DIR}" --config Release --parallel
49
79
  cmake --install "${BUILD_DIR}" --config Release
50
-
80
+
51
81
  echo "Installed to ${INSTALL_DIR}"
52
82
  }
53
-
54
- # Build for device
55
- build_for_platform "iphoneos" "arm64"
56
-
57
- # Build for simulator (Apple Silicon)
58
- build_for_platform "iphonesimulator" "arm64"
59
-
60
- # Create XCFramework from the static libraries
83
+
84
+ # Build for iOS device
85
+ build_for_ios_platform "iphoneos" "arm64"
86
+
87
+ # Build for iOS simulator (Apple Silicon)
88
+ build_for_ios_platform "iphonesimulator" "arm64"
89
+
90
+ # Build for macOS (Apple Silicon)
91
+ build_for_macos_platform "arm64"
92
+
93
+ # Build for macOS (Intel)
94
+ build_for_macos_platform "x86_64"
95
+
96
+ # Create universal macOS library
97
+ echo "Creating universal macOS library..."
98
+ MACOS_UNIVERSAL_DIR="${IOS_DIR}/simpleble_macosx_universal"
99
+ mkdir -p "${MACOS_UNIVERSAL_DIR}/lib"
100
+ cp -r "${IOS_DIR}/simpleble_macosx_arm64/include" "${MACOS_UNIVERSAL_DIR}/"
101
+ lipo -create \
102
+ "${IOS_DIR}/simpleble_macosx_arm64/lib/libsimpleble.a" \
103
+ "${IOS_DIR}/simpleble_macosx_x86_64/lib/libsimpleble.a" \
104
+ -output "${MACOS_UNIVERSAL_DIR}/lib/libsimpleble.a"
105
+
106
+ # Create XCFramework from the static libraries (iOS + macOS)
61
107
  echo "Creating XCFramework..."
62
108
  XCFRAMEWORK_PATH="${IOS_DIR}/SimpleBLE.xcframework"
63
109
  rm -rf "${XCFRAMEWORK_PATH}"
64
-
110
+
65
111
  xcodebuild -create-xcframework \
66
112
  -library "${IOS_DIR}/simpleble_iphoneos_arm64/lib/libsimpleble.a" \
67
113
  -headers "${IOS_DIR}/simpleble_iphoneos_arm64/include" \
68
114
  -library "${IOS_DIR}/simpleble_iphonesimulator_arm64/lib/libsimpleble.a" \
69
115
  -headers "${IOS_DIR}/simpleble_iphonesimulator_arm64/include" \
116
+ -library "${MACOS_UNIVERSAL_DIR}/lib/libsimpleble.a" \
117
+ -headers "${MACOS_UNIVERSAL_DIR}/include" \
70
118
  -output "${XCFRAMEWORK_PATH}"
71
-
119
+
72
120
  echo "SimpleBLE build complete!"
73
121
  echo "XCFramework created at: ${XCFRAMEWORK_PATH}"
74
122
  fi
@@ -95,9 +143,12 @@ Pod::Spec.new do |s|
95
143
 
96
144
  # Required frameworks for SimpleBLE
97
145
  s.frameworks = ['Foundation', 'CoreBluetooth']
146
+ # macOS requires additional frameworks for classic Bluetooth support
147
+ s.osx.frameworks = ['Foundation', 'CoreBluetooth', 'IOBluetooth', 'IOKit']
98
148
 
99
- # Vendored XCFramework containing all architectures
149
+ # Vendored XCFramework containing all architectures (iOS + macOS)
100
150
  s.ios.vendored_frameworks = 'ios/SimpleBLE.xcframework'
151
+ s.osx.vendored_frameworks = 'ios/SimpleBLE.xcframework'
101
152
 
102
153
  # Configure header search paths for SimpleBLE
103
154
  current_pod_target_xcconfig = s.attributes_hash['pod_target_xcconfig'] || {}
@@ -107,6 +158,11 @@ Pod::Spec.new do |s|
107
158
  # iOS header paths
108
159
  '"$(PODS_TARGET_SRCROOT)/ios/simpleble_iphoneos_arm64/include"',
109
160
  '"$(PODS_TARGET_SRCROOT)/ios/simpleble_iphonesimulator_arm64/include"',
161
+ # macOS header paths
162
+ '"$(PODS_TARGET_SRCROOT)/ios/simpleble_macosx_arm64/include"',
163
+ '"$(PODS_TARGET_SRCROOT)/ios/simpleble_macosx_x86_64/include"',
164
+ '"$(PODS_TARGET_SRCROOT)/ios/simpleble_macosx_universal/include"',
110
165
  ].join(' '),
166
+ 'GCC_PREPROCESSOR_DEFINITIONS' => ['$(inherited)', 'OS_OBJECT_USE_OBJC=1']
111
167
  })
112
168
  end
package/VERSION CHANGED
@@ -1 +1 @@
1
- 0.10.4
1
+ 0.11.0
@@ -0,0 +1,77 @@
1
+ # SimpleDroidBridge Integration Decision
2
+
3
+ ## Current Approach
4
+
5
+ In `build.gradle`, the simpledroidbridge Java sources are included directly:
6
+
7
+ ```gradle
8
+ sourceSets {
9
+ main {
10
+ java.srcDirs += ["../simpledroidbridge/src/main/java"]
11
+ }
12
+ }
13
+ ```
14
+
15
+ ## Why Not Use `implementation project(":simpledroidbridge")`?
16
+
17
+ ### Option 1: `java.srcDirs` (Current)
18
+
19
+ Compiles simpledroidbridge sources directly into the main library.
20
+
21
+ **Pros:**
22
+ - No configuration needed in consumer app
23
+ - Works seamlessly in npm package context
24
+ - No build config conflicts
25
+ - React Native autolinking works out of the box
26
+
27
+ **Cons:**
28
+ - Sources compiled together (single output)
29
+
30
+ ### Option 2: `implementation project(":simpledroidbridge")`
31
+
32
+ Would treat simpledroidbridge as a separate Gradle module dependency.
33
+
34
+ **Pros:**
35
+ - Cleaner separation of modules
36
+ - Could be reused independently
37
+
38
+ **Cons:**
39
+ - Requires consumer app's `settings.gradle.kts` to include:
40
+ ```kotlin
41
+ include(":simpledroidbridge")
42
+ project(":simpledroidbridge").projectDir = File("node_modules/simplejsble/simpledroidbridge")
43
+ ```
44
+ - `simpledroidbridge/build.gradle.kts` has its own SDK versions (`compileSdk = 31`, `minSdk = 31`) which may conflict with consumer apps
45
+ - React Native autolinking doesn't handle transitive local project dependencies
46
+ - Complex path resolution for npm packages
47
+
48
+ ## Comparison
49
+
50
+ | Aspect | `java.srcDirs` | `project(":simpledroidbridge")` |
51
+ |--------|----------------|--------------------------------|
52
+ | Consumer setup | None required | Must modify settings.gradle |
53
+ | Build config conflicts | None | Possible SDK version conflicts |
54
+ | npm package compatibility | Works out of the box | Complex path resolution |
55
+ | Autolinking | Works | Not supported |
56
+
57
+ ## Conclusion
58
+
59
+ The `java.srcDirs` approach is the right choice for npm package distribution. Converting to a project dependency would add unnecessary friction for package consumers.
60
+
61
+ ## Package Structure
62
+
63
+ The npm package bundles simpledroidbridge (defined in `package.json`):
64
+
65
+ ```json
66
+ {
67
+ "files": [
68
+ "android/",
69
+ "simpledroidbridge/",
70
+ ...
71
+ ]
72
+ }
73
+ ```
74
+
75
+ This allows the relative path `../simpledroidbridge/src/main/java` to work correctly from the `android/` folder in both:
76
+ - Monorepo development
77
+ - npm package installation (`node_modules/simplejsble/`)
@@ -107,8 +107,8 @@ android {
107
107
  }
108
108
 
109
109
  compileOptions {
110
- sourceCompatibility JavaVersion.VERSION_1_8
111
- targetCompatibility JavaVersion.VERSION_1_8
110
+ sourceCompatibility JavaVersion.VERSION_1_9
111
+ targetCompatibility JavaVersion.VERSION_1_9
112
112
  }
113
113
 
114
114
  sourceSets {
@@ -1,5 +1,5 @@
1
1
  NitroSimplejsble_kotlinVersion=2.1.20
2
- NitroSimplejsble_minSdkVersion=23
3
- NitroSimplejsble_targetSdkVersion=36
4
- NitroSimplejsble_compileSdkVersion=36
2
+ NitroSimplejsble_minSdkVersion=31
3
+ NitroSimplejsble_targetSdkVersion=31
4
+ NitroSimplejsble_compileSdkVersion=31
5
5
  NitroSimplejsble_ndkVersion=27.1.12297006
@@ -3,6 +3,7 @@
3
3
 
4
4
  #include <cstdint>
5
5
  #include <cstring>
6
+ #include <initializer_list>
6
7
  #include <iomanip>
7
8
  #include <iostream>
8
9
  #include <memory>
@@ -30,6 +31,12 @@ class bytearray {
30
31
  */
31
32
  bytearray(const std::vector<uint8_t>& vec) : data_(vec) {}
32
33
 
34
+ /**
35
+ * @brief Constructs byte array from an initializer list of uint8_t.
36
+ * @param list An initializer list of uint8_t.
37
+ */
38
+ bytearray(std::initializer_list<uint8_t> list) : data_(list) {}
39
+
33
40
  /**
34
41
  * @brief Constructs byte array from a raw pointer and size.
35
42
  * @param ptr A pointer to uint8_t data.
@@ -0,0 +1,50 @@
1
+ # CMake Install Options Reference
2
+
3
+ ## Install Target Destinations
4
+
5
+ | Destination | Purpose | File Types |
6
+ |-------------|---------|------------|
7
+ | `ARCHIVE` | Static libraries and import libraries | `.a`, `.lib` (Windows import libs) |
8
+ | `LIBRARY` | Shared libraries | `.so`, `.dylib` |
9
+ | `RUNTIME` | Executables and DLLs | `.exe`, `.dll` |
10
+
11
+ ## Recommended Variables (via `GNUInstallDirs`)
12
+
13
+ ```cmake
14
+ include(GNUInstallDirs)
15
+ ```
16
+
17
+ | Variable | Default Value | Purpose |
18
+ |----------|---------------|---------|
19
+ | `CMAKE_INSTALL_LIBDIR` | `lib` | Library installation directory |
20
+ | `CMAKE_INSTALL_INCLUDEDIR` | `include` | Header installation directory |
21
+ | `CMAKE_INSTALL_BINDIR` | `bin` | Binary/executable installation directory |
22
+
23
+ ## Current iOS CMakeLists.txt
24
+
25
+ ```cmake
26
+ install(TARGETS simpleble ARCHIVE DESTINATION lib)
27
+
28
+ install(DIRECTORY ${PROJECT_ROOT_DIR}/simpleble/include/simpleble/ DESTINATION include/simpleble)
29
+ install(DIRECTORY ${CMAKE_BINARY_DIR}/simpleble/export/simpleble/ DESTINATION include/simpleble)
30
+ install(FILES ${PROJECT_ROOT_DIR}/dependencies/external/kvn/kvn_bytearray.h DESTINATION include/simpleble/kvn)
31
+ ```
32
+
33
+ ## Recommended Update (matching main simpleble pattern)
34
+
35
+ ```cmake
36
+ include(GNUInstallDirs)
37
+
38
+ install(TARGETS simpleble ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
39
+
40
+ install(DIRECTORY ${PROJECT_ROOT_DIR}/simpleble/include/simpleble/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/simpleble)
41
+ install(DIRECTORY ${CMAKE_BINARY_DIR}/simpleble/export/simpleble/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/simpleble)
42
+ install(FILES ${PROJECT_ROOT_DIR}/dependencies/external/kvn/kvn_bytearray.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/simpleble/kvn)
43
+ ```
44
+
45
+ ## Notes
46
+
47
+ - For iOS static builds (`BUILD_SHARED_LIBS OFF`), only `ARCHIVE` is needed
48
+ - `LIBRARY` is unnecessary since we're not building shared libraries
49
+ - Using CMake variables instead of hardcoded paths improves portability
50
+ - Header installation is required separately from library installation for XCFramework builds
package/lib/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import { NitroModules } from "react-native-nitro-modules";
2
+ export const HybridAdapter = NitroModules.createHybridObject("Adapter");
@@ -0,0 +1 @@
1
+ import {} from 'react-native-nitro-modules';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "simplejsble",
3
- "version": "0.0.28",
3
+ "version": "0.0.30",
4
4
  "description": "React Native Bluetooth Low Energy library using SimpleBLE with Nitro Modules",
5
5
  "main": "lib/index",
6
6
  "module": "lib/index",
@@ -29,7 +29,7 @@
29
29
  "prepack": "npm run build && npx nitrogen && bash scripts/prepare-package.sh",
30
30
  "typecheck": "tsc --noEmit",
31
31
  "build": "tsc",
32
- "clean": "rm -rf simpleble simpledroidbridge cmake dependencies VERSION nitrogen lib android/build android/.cxx android/.gradle ios/build_iphoneos_arm64 ios/build_iphonesimulator_arm64 ios/simpleble_iphoneos_arm64 ios/simpleble_iphonesimulator_arm64 ios/SimpleBLE.xcframework",
32
+ "clean": "rm -rf simpleble simpledroidbridge cmake dependencies VERSION nitrogen lib tsconfig.tsbuildinfo android/build android/.cxx android/.gradle ios/build_iphoneos_arm64 ios/build_iphonesimulator_arm64 ios/simpleble_iphoneos_arm64 ios/simpleble_iphonesimulator_arm64 ios/build_macosx_arm64 ios/build_macosx_x86_64 ios/simpleble_macosx_arm64 ios/simpleble_macosx_x86_64 ios/simpleble_macosx_universal ios/SimpleBLE.xcframework",
33
33
  "lint": "eslint \"**/*.{js,ts,tsx}\" --fix",
34
34
  "prepublishOnly": "npm run typecheck",
35
35
  "postpublish": "npm run clean",
@@ -44,7 +44,8 @@
44
44
  "nitro",
45
45
  "nitro-modules",
46
46
  "ios",
47
- "android"
47
+ "android",
48
+ "macos"
48
49
  ],
49
50
  "repository": {
50
51
  "type": "git",
@@ -166,12 +166,7 @@ set(SIMPLEBLE_DONGL_SOURCES
166
166
  ${CMAKE_CURRENT_SOURCE_DIR}/src/backends/dongl/protocol/d2h.pb.c
167
167
  ${CMAKE_CURRENT_SOURCE_DIR}/src/backends/dongl/protocol/h2d.pb.c
168
168
  ${CMAKE_CURRENT_SOURCE_DIR}/src/backends/dongl/protocol/basic.pb.c
169
- ${CMAKE_CURRENT_SOURCE_DIR}/src/backends/dongl/protocol/simpleble.pb.c
170
- ${CMAKE_CURRENT_SOURCE_DIR}/src/backends/dongl/protocol/softdevice.pb.c
171
- ${CMAKE_CURRENT_SOURCE_DIR}/src/backends/dongl/protocol/softdevice_gap.pb.c
172
- ${CMAKE_CURRENT_SOURCE_DIR}/src/backends/dongl/protocol/softdevice_gattc.pb.c
173
- ${CMAKE_CURRENT_SOURCE_DIR}/src/backends/dongl/protocol/softdevice_gatts.pb.c
174
- ${CMAKE_CURRENT_SOURCE_DIR}/src/backends/dongl/protocol/softdevice_types.pb.c)
169
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/backends/dongl/protocol/simpleble.pb.c)
175
170
 
176
171
  if(SIMPLEBLE_PLAIN)
177
172
  list(APPEND SIMPLEBLE_DONGL_SOURCES
@@ -31,9 +31,6 @@ AdapterDongl::AdapterDongl(const std::string& device_path)
31
31
 
32
32
  _serial_protocol->set_event_callback([this](const dongl_Event& event) {
33
33
  switch (event.which_evt) {
34
- case dongl_Event_softdevice_tag:
35
- _on_softdevice_event(event.evt.softdevice);
36
- break;
37
34
  case dongl_Event_simpleble_tag:
38
35
  _on_simpleble_event(event.evt.simpleble);
39
36
  break;
@@ -225,145 +222,15 @@ void AdapterDongl::_on_simpleble_event(const simpleble_Event& event) {
225
222
  }
226
223
  break;
227
224
  }
228
- }
229
- }
230
225
 
231
- void AdapterDongl::_on_softdevice_event(const sd_Event& event) {
232
- // //fmt::print("Received event: {}\n", event.which_evt);
233
-
234
- // switch (event.which_evt) {
235
- // case sd_Event_gap_adv_report_tag: {
236
- // BluetoothAddress mac_address = fmt::format(
237
- // "{:02X}:{:02X}:{:02X}:{:02X}:{:02X}:{:02X}", event.evt.gap_adv_report.peer_addr.addr[0],
238
- // event.evt.gap_adv_report.peer_addr.addr[1], event.evt.gap_adv_report.peer_addr.addr[2],
239
- // event.evt.gap_adv_report.peer_addr.addr[3], event.evt.gap_adv_report.peer_addr.addr[4],
240
- // event.evt.gap_adv_report.peer_addr.addr[5]);
241
-
242
- // BluetoothAddressType address_type = SimpleBLE::BluetoothAddressType::UNSPECIFIED;
243
- // if (event.evt.gap_adv_report.peer_addr.addr_type == sd_types_BleGapAddrType_BLE_GAP_ADDR_TYPE_PUBLIC) {
244
- // address_type = SimpleBLE::BluetoothAddressType::PUBLIC;
245
- // } else if (event.evt.gap_adv_report.peer_addr.addr_type ==
246
- // sd_types_BleGapAddrType_BLE_GAP_ADDR_TYPE_RANDOM_STATIC ||
247
- // event.evt.gap_adv_report.peer_addr.addr_type ==
248
- // sd_types_BleGapAddrType_BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE) {
249
- // address_type = SimpleBLE::BluetoothAddressType::RANDOM;
250
- // }
251
-
252
- // std::string identifier = "";
253
- // std::map<uint16_t, ByteArray> manufacturer_data = {};
254
- // std::map<BluetoothUUID, ByteArray> service_data = {};
255
-
256
- // // Parse the advertising data
257
- // size_t offset = 0;
258
- // while (offset < event.evt.gap_adv_report.data.len) {
259
- // if (offset + 1 >= event.evt.gap_adv_report.data.len) break;
260
-
261
- // uint8_t length = event.evt.gap_adv_report.data.data.bytes[offset++];
262
- // if (length == 0 || offset + length > event.evt.gap_adv_report.data.len) break;
263
-
264
- // if (offset >= event.evt.gap_adv_report.data.len) break;
265
- // uint8_t ad_type = event.evt.gap_adv_report.data.data.bytes[offset++];
266
-
267
- // size_t data_length = length - 1; // AD Type takes 1 byte
268
- // if (data_length == 0 || offset + data_length > event.evt.gap_adv_report.data.len) break;
269
-
270
- // switch (ad_type) {
271
- // case 0x08: // Shortened Local Name
272
- // case 0x09: // Complete Local Name
273
- // if (data_length > 0) {
274
- // identifier = std::string(
275
- // reinterpret_cast<const char*>(&event.evt.gap_adv_report.data.data.bytes[offset]),
276
- // data_length);
277
- // }
278
- // break;
279
-
280
- // case 0xFF: // Manufacturer Specific Data
281
- // if (data_length >= 2) { // Need at least company ID (2 bytes)
282
- // uint16_t company_id = event.evt.gap_adv_report.data.data.bytes[offset] |
283
- // (event.evt.gap_adv_report.data.data.bytes[offset + 1] << 8);
284
- // ByteArray manufacturer_bytes(
285
- // &event.evt.gap_adv_report.data.data.bytes[offset + 2],
286
- // &event.evt.gap_adv_report.data.data.bytes[offset + data_length]);
287
- // manufacturer_data[company_id] = manufacturer_bytes;
288
- // }
289
- // break;
290
-
291
- // case 0x16: // Service Data - 16-bit UUID
292
- // if (data_length >= 2) { // Need at least UUID (2 bytes)
293
- // uint16_t service_uuid_16 = event.evt.gap_adv_report.data.data.bytes[offset] |
294
- // (event.evt.gap_adv_report.data.data.bytes[offset + 1] << 8);
295
- // BluetoothUUID service_uuid = fmt::format("{:04x}", service_uuid_16);
296
- // ByteArray service_bytes(
297
- // &event.evt.gap_adv_report.data.data.bytes[offset + 2],
298
- // &event.evt.gap_adv_report.data.data.bytes[offset + data_length]);
299
- // service_data[service_uuid] = service_bytes;
300
- // }
301
- // break;
302
-
303
- // case 0x20: // Service Data - 32-bit UUID
304
- // if (data_length >= 4) { // Need at least UUID (4 bytes)
305
- // uint32_t service_uuid_32 = event.evt.gap_adv_report.data.data.bytes[offset] |
306
- // (event.evt.gap_adv_report.data.data.bytes[offset + 1] << 8) |
307
- // (event.evt.gap_adv_report.data.data.bytes[offset + 2] << 16) |
308
- // (event.evt.gap_adv_report.data.data.bytes[offset + 3] << 24);
309
- // BluetoothUUID service_uuid = fmt::format("{:08x}", service_uuid_32);
310
- // ByteArray service_bytes(
311
- // &event.evt.gap_adv_report.data.data.bytes[offset + 4],
312
- // &event.evt.gap_adv_report.data.data.bytes[offset + data_length]);
313
- // service_data[service_uuid] = service_bytes;
314
- // }
315
- // break;
316
-
317
- // case 0x21: // Service Data - 128-bit UUID
318
- // if (data_length >= 16) { // Need at least UUID (16 bytes)
319
- // // Convert to UUID string format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
320
- // BluetoothUUID service_uuid = fmt::format(
321
- // "{:02x}{:02x}{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}",
322
- // event.evt.gap_adv_report.data.data.bytes[offset + 15], // Little endian byte order
323
- // event.evt.gap_adv_report.data.data.bytes[offset + 14],
324
- // event.evt.gap_adv_report.data.data.bytes[offset + 13],
325
- // event.evt.gap_adv_report.data.data.bytes[offset + 12],
326
- // event.evt.gap_adv_report.data.data.bytes[offset + 11],
327
- // event.evt.gap_adv_report.data.data.bytes[offset + 10],
328
- // event.evt.gap_adv_report.data.data.bytes[offset + 9],
329
- // event.evt.gap_adv_report.data.data.bytes[offset + 8],
330
- // event.evt.gap_adv_report.data.data.bytes[offset + 7],
331
- // event.evt.gap_adv_report.data.data.bytes[offset + 6],
332
- // event.evt.gap_adv_report.data.data.bytes[offset + 5],
333
- // event.evt.gap_adv_report.data.data.bytes[offset + 4],
334
- // event.evt.gap_adv_report.data.data.bytes[offset + 3],
335
- // event.evt.gap_adv_report.data.data.bytes[offset + 2],
336
- // event.evt.gap_adv_report.data.data.bytes[offset + 1],
337
- // event.evt.gap_adv_report.data.data.bytes[offset]);
338
- // ByteArray service_bytes(
339
- // &event.evt.gap_adv_report.data.data.bytes[offset + 16],
340
- // &event.evt.gap_adv_report.data.data.bytes[offset + data_length]);
341
- // service_data[service_uuid] = service_bytes;
342
- // }
343
- // break;
344
-
345
- // default:
346
- // // Skip unknown AD types
347
- // break;
348
- // }
349
-
350
- // offset += data_length;
351
- // }
352
-
353
- // auto advertising_data = advertising_data_t{
354
- // .identifier = identifier,
355
- // .address_type = address_type,
356
- // .mac_address = mac_address,
357
- // .connectable = event.evt.gap_adv_report.type.connectable,
358
- // .rssi = event.evt.gap_adv_report.rssi,
359
- // .tx_power = event.evt.gap_adv_report.tx_power,
360
- // .manufacturer_data = manufacturer_data,
361
- // .service_data = service_data,
362
- // };
363
- // _scan_received_callback(advertising_data);
364
- // break;
365
- // }
366
- // default:
367
- // break;
368
- // }
226
+ case simpleble_Event_value_changed_evt_tag: {
227
+ for (auto& [address, peripheral] : this->peripherals_) {
228
+ if (peripheral->conn_handle() == event.evt.value_changed_evt.conn_handle) {
229
+ peripheral->notify_value_changed(event.evt.value_changed_evt);
230
+ break;
231
+ }
232
+ }
233
+ break;
234
+ }
235
+ }
369
236
  }
@@ -48,7 +48,6 @@ class AdapterDongl : public AdapterBase {
48
48
 
49
49
  private:
50
50
  void _scan_received_callback(advertising_data_t data);
51
- void _on_softdevice_event(const sd_Event& event);
52
51
  void _on_simpleble_event(const simpleble_Event& event);
53
52
 
54
53
  std::shared_ptr<Dongl::Serial::Protocol> _serial_protocol;