simplejsble 0.0.47 → 0.0.49

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 (46) hide show
  1. package/apple/SimpleBLE.xcframework/Info.plist +8 -8
  2. package/apple/SimpleBLE.xcframework/ios-arm64/libsimpleble.a +0 -0
  3. package/apple/SimpleBLE.xcframework/ios-arm64-simulator/libsimpleble.a +0 -0
  4. package/apple/SimpleBLE.xcframework/macos-arm64_x86_64/libsimpleble.a +0 -0
  5. package/cpp/HybridCharacteristic.cpp +50 -0
  6. package/cpp/HybridCharacteristic.hpp +37 -0
  7. package/cpp/HybridDescriptor.cpp +13 -0
  8. package/cpp/HybridDescriptor.hpp +25 -0
  9. package/cpp/HybridPeripheral.cpp +95 -0
  10. package/cpp/HybridPeripheral.hpp +28 -0
  11. package/cpp/HybridService.cpp +31 -0
  12. package/cpp/HybridService.hpp +31 -0
  13. package/lib/index.d.ts +5 -1
  14. package/lib/index.d.ts.map +1 -1
  15. package/lib/index.js +1 -0
  16. package/lib/specs/Characteristic.nitro.d.ts +45 -0
  17. package/lib/specs/Characteristic.nitro.d.ts.map +1 -0
  18. package/lib/specs/Characteristic.nitro.js +2 -0
  19. package/lib/specs/Descriptor.nitro.d.ts +15 -0
  20. package/lib/specs/Descriptor.nitro.d.ts.map +1 -0
  21. package/lib/specs/Descriptor.nitro.js +1 -0
  22. package/lib/specs/Peripheral.nitro.d.ts +76 -0
  23. package/lib/specs/Peripheral.nitro.d.ts.map +1 -1
  24. package/lib/specs/Peripheral.nitro.js +1 -0
  25. package/lib/specs/Service.nitro.d.ts +25 -0
  26. package/lib/specs/Service.nitro.d.ts.map +1 -0
  27. package/lib/specs/Service.nitro.js +2 -0
  28. package/lib/utils/bytearray.d.ts +49 -0
  29. package/lib/utils/bytearray.d.ts.map +1 -0
  30. package/lib/utils/bytearray.js +72 -0
  31. package/nitrogen/generated/android/NitroSimplejsble+autolinking.cmake +3 -0
  32. package/nitrogen/generated/shared/c++/HybridCharacteristicSpec.cpp +29 -0
  33. package/nitrogen/generated/shared/c++/HybridCharacteristicSpec.hpp +74 -0
  34. package/nitrogen/generated/shared/c++/HybridDescriptorSpec.cpp +22 -0
  35. package/nitrogen/generated/shared/c++/HybridDescriptorSpec.hpp +63 -0
  36. package/nitrogen/generated/shared/c++/HybridPeripheralSpec.cpp +10 -0
  37. package/nitrogen/generated/shared/c++/HybridPeripheralSpec.hpp +17 -0
  38. package/nitrogen/generated/shared/c++/HybridServiceSpec.cpp +24 -0
  39. package/nitrogen/generated/shared/c++/HybridServiceSpec.hpp +70 -0
  40. package/package.json +1 -1
  41. package/src/index.ts +6 -1
  42. package/src/specs/Characteristic.nitro.ts +54 -0
  43. package/src/specs/Descriptor.nitro.ts +17 -0
  44. package/src/specs/Peripheral.nitro.ts +86 -0
  45. package/src/specs/Service.nitro.ts +29 -0
  46. package/src/utils/bytearray.ts +79 -0
@@ -10,17 +10,16 @@
10
10
  <key>HeadersPath</key>
11
11
  <string>Headers</string>
12
12
  <key>LibraryIdentifier</key>
13
- <string>ios-arm64-simulator</string>
13
+ <string>macos-arm64_x86_64</string>
14
14
  <key>LibraryPath</key>
15
15
  <string>libsimpleble.a</string>
16
16
  <key>SupportedArchitectures</key>
17
17
  <array>
18
18
  <string>arm64</string>
19
+ <string>x86_64</string>
19
20
  </array>
20
21
  <key>SupportedPlatform</key>
21
- <string>ios</string>
22
- <key>SupportedPlatformVariant</key>
23
- <string>simulator</string>
22
+ <string>macos</string>
24
23
  </dict>
25
24
  <dict>
26
25
  <key>BinaryPath</key>
@@ -28,16 +27,15 @@
28
27
  <key>HeadersPath</key>
29
28
  <string>Headers</string>
30
29
  <key>LibraryIdentifier</key>
31
- <string>macos-arm64_x86_64</string>
30
+ <string>ios-arm64</string>
32
31
  <key>LibraryPath</key>
33
32
  <string>libsimpleble.a</string>
34
33
  <key>SupportedArchitectures</key>
35
34
  <array>
36
35
  <string>arm64</string>
37
- <string>x86_64</string>
38
36
  </array>
39
37
  <key>SupportedPlatform</key>
40
- <string>macos</string>
38
+ <string>ios</string>
41
39
  </dict>
42
40
  <dict>
43
41
  <key>BinaryPath</key>
@@ -45,7 +43,7 @@
45
43
  <key>HeadersPath</key>
46
44
  <string>Headers</string>
47
45
  <key>LibraryIdentifier</key>
48
- <string>ios-arm64</string>
46
+ <string>ios-arm64-simulator</string>
49
47
  <key>LibraryPath</key>
50
48
  <string>libsimpleble.a</string>
51
49
  <key>SupportedArchitectures</key>
@@ -54,6 +52,8 @@
54
52
  </array>
55
53
  <key>SupportedPlatform</key>
56
54
  <string>ios</string>
55
+ <key>SupportedPlatformVariant</key>
56
+ <string>simulator</string>
57
57
  </dict>
58
58
  </array>
59
59
  <key>CFBundlePackageType</key>
@@ -0,0 +1,50 @@
1
+ #include "HybridCharacteristic.hpp"
2
+ #include "HybridDescriptor.hpp"
3
+
4
+ namespace margelo::nitro::simplejsble {
5
+
6
+ bool HybridCharacteristic::initialized() {
7
+ return _characteristic.initialized();
8
+ }
9
+
10
+ std::string HybridCharacteristic::uuid() {
11
+ return _characteristic.uuid();
12
+ }
13
+
14
+ std::vector<std::shared_ptr<HybridDescriptorSpec>> HybridCharacteristic::descriptors() {
15
+ std::vector<SimpleBLE::Descriptor> characteristic_descriptors = _characteristic.descriptors();
16
+ std::vector<std::shared_ptr<HybridDescriptorSpec>> hybrid_descriptors;
17
+ hybrid_descriptors.reserve(characteristic_descriptors.size());
18
+
19
+ for (auto& descriptor : characteristic_descriptors) {
20
+ hybrid_descriptors.push_back(std::make_shared<HybridDescriptor>(std::move(descriptor)));
21
+ }
22
+
23
+ return hybrid_descriptors;
24
+ }
25
+
26
+ std::vector<std::string> HybridCharacteristic::capabilities() {
27
+ return _characteristic.capabilities();
28
+ }
29
+
30
+ bool HybridCharacteristic::can_read() {
31
+ return _characteristic.can_read();
32
+ }
33
+
34
+ bool HybridCharacteristic::can_write_request() {
35
+ return _characteristic.can_write_request();
36
+ }
37
+
38
+ bool HybridCharacteristic::can_write_command() {
39
+ return _characteristic.can_write_command();
40
+ }
41
+
42
+ bool HybridCharacteristic::can_notify() {
43
+ return _characteristic.can_notify();
44
+ }
45
+
46
+ bool HybridCharacteristic::can_indicate() {
47
+ return _characteristic.can_indicate();
48
+ }
49
+
50
+ } // namespace margelo::nitro::simplejsble
@@ -0,0 +1,37 @@
1
+ #pragma once
2
+
3
+ #include "HybridCharacteristicSpec.hpp"
4
+ #include <simpleble/SimpleBLE.h>
5
+ #include <memory>
6
+ #include <vector>
7
+ #include <string>
8
+
9
+ namespace margelo::nitro::simplejsble {
10
+
11
+ // Forward declaration
12
+ class HybridDescriptorSpec;
13
+
14
+ class HybridCharacteristic : public HybridCharacteristicSpec {
15
+ public:
16
+ HybridCharacteristic() : HybridObject(TAG) {}
17
+ explicit HybridCharacteristic(SimpleBLE::Characteristic characteristic)
18
+ : HybridObject(TAG), _characteristic(std::move(characteristic)) {}
19
+
20
+ bool initialized() override;
21
+ std::string uuid() override;
22
+ std::vector<std::shared_ptr<HybridDescriptorSpec>> descriptors() override;
23
+ std::vector<std::string> capabilities() override;
24
+ bool can_read() override;
25
+ bool can_write_request() override;
26
+ bool can_write_command() override;
27
+ bool can_notify() override;
28
+ bool can_indicate() override;
29
+
30
+ SimpleBLE::Characteristic& getInternal() { return _characteristic; }
31
+ const SimpleBLE::Characteristic& getInternal() const { return _characteristic; }
32
+
33
+ private:
34
+ SimpleBLE::Characteristic _characteristic;
35
+ };
36
+
37
+ } // namespace margelo::nitro::simplejsble
@@ -0,0 +1,13 @@
1
+ #include "HybridDescriptor.hpp"
2
+
3
+ namespace margelo::nitro::simplejsble {
4
+
5
+ bool HybridDescriptor::initialized() {
6
+ return _descriptor.initialized();
7
+ }
8
+
9
+ std::string HybridDescriptor::uuid() {
10
+ return _descriptor.uuid();
11
+ }
12
+
13
+ } // namespace margelo::nitro::simplejsble
@@ -0,0 +1,25 @@
1
+ #pragma once
2
+
3
+ #include "HybridDescriptorSpec.hpp"
4
+ #include <simpleble/SimpleBLE.h>
5
+ #include <string>
6
+
7
+ namespace margelo::nitro::simplejsble {
8
+
9
+ class HybridDescriptor : public HybridDescriptorSpec {
10
+ public:
11
+ HybridDescriptor() : HybridObject(TAG) {}
12
+ explicit HybridDescriptor(SimpleBLE::Descriptor descriptor)
13
+ : HybridObject(TAG), _descriptor(std::move(descriptor)) {}
14
+
15
+ bool initialized() override;
16
+ std::string uuid() override;
17
+
18
+ SimpleBLE::Descriptor& getInternal() { return _descriptor; }
19
+ const SimpleBLE::Descriptor& getInternal() const { return _descriptor; }
20
+
21
+ private:
22
+ SimpleBLE::Descriptor _descriptor;
23
+ };
24
+
25
+ } // namespace margelo::nitro::simplejsble
@@ -1,4 +1,5 @@
1
1
  #include "HybridPeripheral.hpp"
2
+ #include "HybridService.hpp"
2
3
 
3
4
  namespace margelo::nitro::simplejsble {
4
5
 
@@ -80,4 +81,98 @@ void HybridPeripheral::set_callback_on_disconnected(const std::function<void()>&
80
81
  });
81
82
  }
82
83
 
84
+ std::vector<std::shared_ptr<HybridServiceSpec>> HybridPeripheral::services() {
85
+ std::vector<SimpleBLE::Service> peripheral_services = _peripheral.services();
86
+ std::vector<std::shared_ptr<HybridServiceSpec>> hybrid_services;
87
+ hybrid_services.reserve(peripheral_services.size());
88
+
89
+ for (auto& service : peripheral_services) {
90
+ hybrid_services.push_back(std::make_shared<HybridService>(std::move(service)));
91
+ }
92
+
93
+ return hybrid_services;
94
+ }
95
+
96
+ std::unordered_map<double, std::shared_ptr<ArrayBuffer>> HybridPeripheral::manufacturer_data() {
97
+ std::map<uint16_t, SimpleBLE::ByteArray> peripheral_manufacturer_data = _peripheral.manufacturer_data();
98
+ std::unordered_map<double, std::shared_ptr<ArrayBuffer>> manufacturer_array_buffer_map;
99
+
100
+ for (const auto& pair : peripheral_manufacturer_data) {
101
+ manufacturer_array_buffer_map[static_cast<double>(pair.first)] = toArrayBuffer(pair.second);
102
+ }
103
+
104
+ return manufacturer_array_buffer_map;
105
+ }
106
+
107
+ std::shared_ptr<ArrayBuffer> HybridPeripheral::read(const std::string& service, const std::string& characteristic) {
108
+ SimpleBLE::ByteArray peripheral_read_data = _peripheral.read(service, characteristic);
109
+ return toArrayBuffer(peripheral_read_data);
110
+ }
111
+
112
+ void HybridPeripheral::write_request(const std::string& service, const std::string& characteristic, const std::shared_ptr<ArrayBuffer>& data) {
113
+ SimpleBLE::ByteArray bytes = fromArrayBuffer(data);
114
+ _peripheral.write_request(service, characteristic, bytes);
115
+ }
116
+
117
+ void HybridPeripheral::write_command(const std::string& service, const std::string& characteristic, const std::shared_ptr<ArrayBuffer>& data) {
118
+ SimpleBLE::ByteArray bytes = fromArrayBuffer(data);
119
+ _peripheral.write_command(service, characteristic, bytes);
120
+ }
121
+
122
+ void HybridPeripheral::notify(const std::string& service, const std::string& characteristic,
123
+ const std::function<void(const std::shared_ptr<ArrayBuffer>&)>& callback) {
124
+ auto key = std::make_pair(service, characteristic);
125
+ _notifyCallbacks[key] = callback;
126
+
127
+ _peripheral.notify(service, characteristic, [this, key](SimpleBLE::ByteArray payload) {
128
+ auto it = _notifyCallbacks.find(key);
129
+ if (it != _notifyCallbacks.end() && it->second) {
130
+ it->second(toArrayBuffer(payload));
131
+ }
132
+ });
133
+ }
134
+
135
+ void HybridPeripheral::indicate(const std::string& service, const std::string& characteristic,
136
+ const std::function<void(const std::shared_ptr<ArrayBuffer>&)>& callback) {
137
+ auto key = std::make_pair(service, characteristic);
138
+ _notifyCallbacks[key] = callback; //@alejo: verify if its necessary to store our own reference to the callback
139
+
140
+ _peripheral.indicate(service, characteristic, [this, key](SimpleBLE::ByteArray payload) {
141
+ auto it = _notifyCallbacks.find(key);
142
+ if (it != _notifyCallbacks.end() && it->second) {
143
+ it->second(toArrayBuffer(payload));
144
+ }
145
+ });
146
+ }
147
+
148
+ void HybridPeripheral::unsubscribe(const std::string& service, const std::string& characteristic) {
149
+ auto key = std::make_pair(service, characteristic);
150
+ _notifyCallbacks.erase(key);
151
+ _peripheral.unsubscribe(service, characteristic);
152
+ }
153
+
154
+ std::shared_ptr<ArrayBuffer> HybridPeripheral::read_descriptor(const std::string& service, const std::string& characteristic,
155
+ const std::string& descriptor) {
156
+ SimpleBLE::ByteArray peripheral_descriptor_data = _peripheral.read(service, characteristic, descriptor);
157
+ return toArrayBuffer(peripheral_descriptor_data);
158
+ }
159
+
160
+ void HybridPeripheral::write_descriptor(const std::string& service, const std::string& characteristic,
161
+ const std::string& descriptor, const std::shared_ptr<ArrayBuffer>& data) {
162
+ SimpleBLE::ByteArray bytes = fromArrayBuffer(data);
163
+ _peripheral.write(service, characteristic, descriptor, bytes);
164
+ }
165
+
166
+ // Helper methods to cast between SimpleBLE::ByteArray and ArrayBuffer (NitroModules native type)
167
+ std::shared_ptr<ArrayBuffer> HybridPeripheral::toArrayBuffer(const SimpleBLE::ByteArray& data) {
168
+ return std::make_shared<ArrayBuffer>(reinterpret_cast<const uint8_t*>(data.data()), data.size());
169
+ }
170
+
171
+ SimpleBLE::ByteArray HybridPeripheral::fromArrayBuffer(const std::shared_ptr<ArrayBuffer>& buffer) {
172
+ return SimpleBLE::ByteArray(
173
+ static_cast<const uint8_t*>(buffer->data()),
174
+ buffer->size()
175
+ );
176
+ }
177
+
83
178
  } // namespace margelo::nitro::simplejsble
@@ -5,9 +5,14 @@
5
5
  #include <simpleble/SimpleBLE.h>
6
6
  #include <functional>
7
7
  #include <string>
8
+ #include <map>
9
+ #include <unordered_map>
10
+ #include <utility>
8
11
 
9
12
  namespace margelo::nitro::simplejsble {
10
13
 
14
+ class HybridServiceSpec;
15
+
11
16
  class HybridPeripheral : public HybridPeripheralSpec {
12
17
  public:
13
18
  HybridPeripheral() : HybridObject(TAG) {}
@@ -32,6 +37,23 @@ class HybridPeripheral : public HybridPeripheralSpec {
32
37
  void set_callback_on_connected(const std::function<void()>& callback) override;
33
38
  void set_callback_on_disconnected(const std::function<void()>& callback) override;
34
39
 
40
+ std::vector<std::shared_ptr<HybridServiceSpec>> services() override;
41
+ std::unordered_map<double, std::shared_ptr<ArrayBuffer>> manufacturer_data() override;
42
+
43
+ std::shared_ptr<ArrayBuffer> read(const std::string& service, const std::string& characteristic) override;
44
+ void write_request(const std::string& service, const std::string& characteristic, const std::shared_ptr<ArrayBuffer>& data) override;
45
+ void write_command(const std::string& service, const std::string& characteristic, const std::shared_ptr<ArrayBuffer>& data) override;
46
+ void notify(const std::string& service, const std::string& characteristic,
47
+ const std::function<void(const std::shared_ptr<ArrayBuffer>&)>& callback) override;
48
+ void indicate(const std::string& service, const std::string& characteristic,
49
+ const std::function<void(const std::shared_ptr<ArrayBuffer>&)>& callback) override;
50
+ void unsubscribe(const std::string& service, const std::string& characteristic) override;
51
+
52
+ std::shared_ptr<ArrayBuffer> read_descriptor(const std::string& service, const std::string& characteristic,
53
+ const std::string& descriptor) override;
54
+ void write_descriptor(const std::string& service, const std::string& characteristic,
55
+ const std::string& descriptor, const std::shared_ptr<ArrayBuffer>& data) override;
56
+
35
57
  SimpleBLE::Peripheral& getInternal() { return _peripheral; }
36
58
  const SimpleBLE::Peripheral& getInternal() const { return _peripheral; }
37
59
 
@@ -40,6 +62,12 @@ class HybridPeripheral : public HybridPeripheralSpec {
40
62
 
41
63
  std::function<void()> _onConnected;
42
64
  std::function<void()> _onDisconnected;
65
+
66
+ std::map<std::pair<std::string, std::string>, std::function<void(const std::shared_ptr<ArrayBuffer>&)>> _notifyCallbacks;
67
+
68
+ // Helper methods to cast between SimpleBLE::ByteArray and ArrayBuffer (NitroModules native type)
69
+ static std::shared_ptr<ArrayBuffer> toArrayBuffer(const SimpleBLE::ByteArray& data);
70
+ static SimpleBLE::ByteArray fromArrayBuffer(const std::shared_ptr<ArrayBuffer>& buffer);
43
71
  };
44
72
 
45
73
  } // namespace margelo::nitro::simplejsble
@@ -0,0 +1,31 @@
1
+ #include "HybridService.hpp"
2
+ #include "HybridCharacteristic.hpp"
3
+
4
+ namespace margelo::nitro::simplejsble {
5
+
6
+ bool HybridService::initialized() {
7
+ return _service.initialized();
8
+ }
9
+
10
+ std::string HybridService::uuid() {
11
+ return _service.uuid();
12
+ }
13
+
14
+ std::shared_ptr<ArrayBuffer> HybridService::data() {
15
+ SimpleBLE::ByteArray bytes = _service.data();
16
+ return std::make_shared<ArrayBuffer>(reinterpret_cast<const uint8_t*>(bytes.data()), bytes.size());
17
+ }
18
+
19
+ std::vector<std::shared_ptr<HybridCharacteristicSpec>> HybridService::characteristics() {
20
+ std::vector<SimpleBLE::Characteristic> service_characteristics = _service.characteristics();
21
+ std::vector<std::shared_ptr<HybridCharacteristicSpec>> hybrid_characteristics;
22
+ hybrid_characteristics.reserve(service_characteristics.size());
23
+
24
+ for (auto& characteristic : service_characteristics) {
25
+ hybrid_characteristics.push_back(std::make_shared<HybridCharacteristic>(std::move(characteristic)));
26
+ }
27
+
28
+ return hybrid_characteristics;
29
+ }
30
+
31
+ } // namespace margelo::nitro::simplejsble
@@ -0,0 +1,31 @@
1
+ #pragma once
2
+
3
+ #include "HybridServiceSpec.hpp"
4
+ #include <simpleble/SimpleBLE.h>
5
+ #include <NitroModules/ArrayBuffer.hpp>
6
+ #include <memory>
7
+ #include <vector>
8
+
9
+ namespace margelo::nitro::simplejsble {
10
+
11
+ class HybridCharacteristicSpec;
12
+
13
+ class HybridService : public HybridServiceSpec {
14
+ public:
15
+ HybridService() : HybridObject(TAG) {}
16
+ explicit HybridService(SimpleBLE::Service service)
17
+ : HybridObject(TAG), _service(std::move(service)) {}
18
+
19
+ bool initialized() override;
20
+ std::string uuid() override;
21
+ std::shared_ptr<ArrayBuffer> data() override;
22
+ std::vector<std::shared_ptr<HybridCharacteristicSpec>> characteristics() override;
23
+
24
+ SimpleBLE::Service& getInternal() { return _service; }
25
+ const SimpleBLE::Service& getInternal() const { return _service; }
26
+
27
+ private:
28
+ SimpleBLE::Service _service;
29
+ };
30
+
31
+ } // namespace margelo::nitro::simplejsble
package/lib/index.d.ts CHANGED
@@ -1,5 +1,9 @@
1
1
  import type { Adapter } from "./specs/Adapter.nitro";
2
2
  import type { Peripheral, BluetoothAddressType } from "./specs/Peripheral.nitro";
3
- export type { Adapter, Peripheral, BluetoothAddressType };
3
+ import type { Service } from "./specs/Service.nitro";
4
+ import type { Characteristic } from "./specs/Characteristic.nitro";
5
+ import type { Descriptor } from "./specs/Descriptor.nitro";
6
+ export type { Adapter, Peripheral, BluetoothAddressType, Service, Characteristic, Descriptor };
7
+ export { fromHex, toHex, toString, fromString } from "./utils/bytearray";
4
8
  export declare const HybridAdapter: Adapter;
5
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEjF,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,CAAC;AAE1D,eAAO,MAAM,aAAa,SAAsD,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACjF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE3D,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,CAAC;AAE/F,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEzE,eAAO,MAAM,aAAa,SAAsD,CAAC"}
package/lib/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  import { NitroModules } from "react-native-nitro-modules";
2
+ export { fromHex, toHex, toString, fromString } from "./utils/bytearray";
2
3
  export const HybridAdapter = NitroModules.createHybridObject("Adapter");
@@ -0,0 +1,45 @@
1
+ import { type HybridObject } from 'react-native-nitro-modules';
2
+ import { type Descriptor } from './Descriptor.nitro';
3
+ export interface Characteristic extends HybridObject<{
4
+ ios: 'c++';
5
+ android: 'c++';
6
+ }> {
7
+ /**
8
+ * Check if the characteristic is initialized (has a valid internal handle).
9
+ */
10
+ initialized(): boolean;
11
+ /**
12
+ * Get the characteristic UUID.
13
+ */
14
+ uuid(): string;
15
+ /**
16
+ * Get all descriptors belonging to this characteristic.
17
+ */
18
+ descriptors(): Descriptor[];
19
+ /**
20
+ * Get a list of capability strings for this characteristic.
21
+ * Example: ["read", "write", "notify"]
22
+ */
23
+ capabilities(): string[];
24
+ /**
25
+ * Check if the characteristic supports read operations.
26
+ */
27
+ can_read(): boolean;
28
+ /**
29
+ * Check if the characteristic supports write-request operations.
30
+ */
31
+ can_write_request(): boolean;
32
+ /**
33
+ * Check if the characteristic supports write-command operations.
34
+ */
35
+ can_write_command(): boolean;
36
+ /**
37
+ * Check if the characteristic supports notify operations.
38
+ */
39
+ can_notify(): boolean;
40
+ /**
41
+ * Check if the characteristic supports indicate operations.
42
+ */
43
+ can_indicate(): boolean;
44
+ }
45
+ //# sourceMappingURL=Characteristic.nitro.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Characteristic.nitro.d.ts","sourceRoot":"","sources":["../../src/specs/Characteristic.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAEpD,MAAM,WAAW,cACf,SAAQ,YAAY,CAAC;IACnB,GAAG,EAAE,KAAK,CAAA;IACV,OAAO,EAAE,KAAK,CAAA;CACf,CAAC;IACF;;OAEG;IACH,WAAW,IAAI,OAAO,CAAA;IAEtB;;OAEG;IACH,IAAI,IAAI,MAAM,CAAA;IAEd;;OAEG;IACH,WAAW,IAAI,UAAU,EAAE,CAAA;IAE3B;;;OAGG;IACH,YAAY,IAAI,MAAM,EAAE,CAAA;IAExB;;OAEG;IACH,QAAQ,IAAI,OAAO,CAAA;IAEnB;;OAEG;IACH,iBAAiB,IAAI,OAAO,CAAA;IAE5B;;OAEG;IACH,iBAAiB,IAAI,OAAO,CAAA;IAE5B;;OAEG;IACH,UAAU,IAAI,OAAO,CAAA;IAErB;;OAEG;IACH,YAAY,IAAI,OAAO,CAAA;CACxB"}
@@ -0,0 +1,2 @@
1
+ import {} from 'react-native-nitro-modules';
2
+ import {} from './Descriptor.nitro';
@@ -0,0 +1,15 @@
1
+ import { type HybridObject } from 'react-native-nitro-modules';
2
+ export interface Descriptor extends HybridObject<{
3
+ ios: 'c++';
4
+ android: 'c++';
5
+ }> {
6
+ /**
7
+ * Check if the descriptor is initialized (has a valid internal handle).
8
+ */
9
+ initialized(): boolean;
10
+ /**
11
+ * Get the descriptor UUID.
12
+ */
13
+ uuid(): string;
14
+ }
15
+ //# sourceMappingURL=Descriptor.nitro.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Descriptor.nitro.d.ts","sourceRoot":"","sources":["../../src/specs/Descriptor.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAE9D,MAAM,WAAW,UACf,SAAQ,YAAY,CAAC;IACnB,GAAG,EAAE,KAAK,CAAA;IACV,OAAO,EAAE,KAAK,CAAA;CACf,CAAC;IACF;;OAEG;IACH,WAAW,IAAI,OAAO,CAAA;IAEtB;;OAEG;IACH,IAAI,IAAI,MAAM,CAAA;CACf"}
@@ -0,0 +1 @@
1
+ import {} from 'react-native-nitro-modules';
@@ -1,4 +1,5 @@
1
1
  import { type HybridObject } from 'react-native-nitro-modules';
2
+ import { type Service } from './Service.nitro';
2
3
  /**
3
4
  * Bluetooth address type enumeration.
4
5
  * Maps to SimpleBLE::BluetoothAddressType
@@ -74,5 +75,80 @@ export interface Peripheral extends HybridObject<{
74
75
  * Set callback to be invoked when the peripheral disconnects.
75
76
  */
76
77
  set_callback_on_disconnected(callback: () => void): void;
78
+ /**
79
+ * Get all services available on the peripheral.
80
+ * Requires an active connection.
81
+ */
82
+ services(): Service[];
83
+ /**
84
+ * Get manufacturer data from the peripheral's advertisement.
85
+ * Returns a map of manufacturer ID (number) to data (ArrayBuffer).
86
+ */
87
+ manufacturer_data(): Record<number, ArrayBuffer>;
88
+ /**
89
+ * Read a characteristic value.
90
+ * Requires an active connection.
91
+ * @param service Service UUID
92
+ * @param characteristic Characteristic UUID
93
+ * @returns ArrayBuffer containing the characteristic data
94
+ */
95
+ read(service: string, characteristic: string): ArrayBuffer;
96
+ /**
97
+ * Write to a characteristic using write-request (with response).
98
+ * Requires an active connection.
99
+ * @param service Service UUID
100
+ * @param characteristic Characteristic UUID
101
+ * @param data Data to write as ArrayBuffer
102
+ */
103
+ write_request(service: string, characteristic: string, data: ArrayBuffer): void;
104
+ /**
105
+ * Write to a characteristic using write-command (without response).
106
+ * Requires an active connection.
107
+ * @param service Service UUID
108
+ * @param characteristic Characteristic UUID
109
+ * @param data Data to write as ArrayBuffer
110
+ */
111
+ write_command(service: string, characteristic: string, data: ArrayBuffer): void;
112
+ /**
113
+ * Subscribe to notifications from a characteristic.
114
+ * Requires an active connection.
115
+ * @param service Service UUID
116
+ * @param characteristic Characteristic UUID
117
+ * @param callback Callback to receive notification data as ArrayBuffer
118
+ */
119
+ notify(service: string, characteristic: string, callback: (data: ArrayBuffer) => void): void;
120
+ /**
121
+ * Subscribe to indications from a characteristic.
122
+ * Requires an active connection.
123
+ * @param service Service UUID
124
+ * @param characteristic Characteristic UUID
125
+ * @param callback Callback to receive indication data as ArrayBuffer
126
+ */
127
+ indicate(service: string, characteristic: string, callback: (data: ArrayBuffer) => void): void;
128
+ /**
129
+ * Unsubscribe from notifications or indications on a characteristic.
130
+ * Requires an active connection.
131
+ * @param service Service UUID
132
+ * @param characteristic Characteristic UUID
133
+ */
134
+ unsubscribe(service: string, characteristic: string): void;
135
+ /**
136
+ * Read a descriptor value.
137
+ * Requires an active connection.
138
+ * @param service Service UUID
139
+ * @param characteristic Characteristic UUID
140
+ * @param descriptor Descriptor UUID
141
+ * @returns ArrayBuffer containing the descriptor data
142
+ */
143
+ read_descriptor(service: string, characteristic: string, descriptor: string): ArrayBuffer;
144
+ /**
145
+ * Write to a descriptor.
146
+ * Requires an active connection.
147
+ * @param service Service UUID
148
+ * @param characteristic Characteristic UUID
149
+ * @param descriptor Descriptor UUID
150
+ * @param data Data to write as ArrayBuffer
151
+ */
152
+ write_descriptor(service: string, characteristic: string, descriptor: string, data: ArrayBuffer): void;
77
153
  }
78
154
  //# sourceMappingURL=Peripheral.nitro.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Peripheral.nitro.d.ts","sourceRoot":"","sources":["../../src/specs/Peripheral.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAE9D;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,QAAQ,GAAG,aAAa,CAAA;AAEtE;;;;GAIG;AACH,MAAM,WAAW,UACf,SAAQ,YAAY,CAAC;IACnB,GAAG,EAAE,KAAK,CAAA;IACV,OAAO,EAAE,KAAK,CAAA;CACf,CAAC;IACF;;OAEG;IACH,WAAW,IAAI,OAAO,CAAA;IAEtB;;OAEG;IACH,UAAU,IAAI,MAAM,CAAA;IAEpB;;OAEG;IACH,OAAO,IAAI,MAAM,CAAA;IAEjB;;OAEG;IACH,YAAY,IAAI,oBAAoB,CAAA;IAEpC;;OAEG;IACH,IAAI,IAAI,MAAM,CAAA;IAEd;;;OAGG;IACH,QAAQ,IAAI,MAAM,CAAA;IAElB;;O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,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,WAAW,CAAA;IAEzF;;;;;;;OAOG;IACH,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI,CAAA;CACvG"}
@@ -1 +1,2 @@
1
1
  import {} from 'react-native-nitro-modules';
2
+ import {} from './Service.nitro';
@@ -0,0 +1,25 @@
1
+ import { type HybridObject } from 'react-native-nitro-modules';
2
+ import { type Characteristic } from './Characteristic.nitro';
3
+ export interface Service extends HybridObject<{
4
+ ios: 'c++';
5
+ android: 'c++';
6
+ }> {
7
+ /**
8
+ * Check if the service is initialized (has a valid internal handle).
9
+ */
10
+ initialized(): boolean;
11
+ /**
12
+ * Get the service UUID.
13
+ */
14
+ uuid(): string;
15
+ /**
16
+ * Get the service data (if advertised).
17
+ * Returns raw ArrayBuffer containing the service data bytes.
18
+ */
19
+ data(): ArrayBuffer;
20
+ /**
21
+ * Get all characteristics belonging to this service.
22
+ */
23
+ characteristics(): Characteristic[];
24
+ }
25
+ //# sourceMappingURL=Service.nitro.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Service.nitro.d.ts","sourceRoot":"","sources":["../../src/specs/Service.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAE5D,MAAM,WAAW,OACf,SAAQ,YAAY,CAAC;IACnB,GAAG,EAAE,KAAK,CAAA;IACV,OAAO,EAAE,KAAK,CAAA;CACf,CAAC;IACF;;OAEG;IACH,WAAW,IAAI,OAAO,CAAA;IAEtB;;OAEG;IACH,IAAI,IAAI,MAAM,CAAA;IAEd;;;OAGG;IACH,IAAI,IAAI,WAAW,CAAA;IAEnB;;OAEG;IACH,eAAe,IAAI,cAAc,EAAE,CAAA;CACpC"}
@@ -0,0 +1,2 @@
1
+ import {} from 'react-native-nitro-modules';
2
+ import {} from './Characteristic.nitro';