simplejsble 0.0.48 → 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.
- package/apple/SimpleBLE.xcframework/Info.plist +8 -8
- package/apple/SimpleBLE.xcframework/ios-arm64/libsimpleble.a +0 -0
- package/apple/SimpleBLE.xcframework/ios-arm64-simulator/libsimpleble.a +0 -0
- package/apple/SimpleBLE.xcframework/macos-arm64_x86_64/libsimpleble.a +0 -0
- package/cpp/HybridCharacteristic.cpp +2 -2
- package/cpp/HybridCharacteristic.hpp +2 -2
- package/cpp/HybridPeripheral.cpp +16 -16
- package/cpp/HybridPeripheral.hpp +14 -13
- package/cpp/HybridService.cpp +4 -4
- package/cpp/HybridService.hpp +4 -3
- package/package.json +1 -1
|
@@ -10,17 +10,16 @@
|
|
|
10
10
|
<key>HeadersPath</key>
|
|
11
11
|
<string>Headers</string>
|
|
12
12
|
<key>LibraryIdentifier</key>
|
|
13
|
-
<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>
|
|
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>
|
|
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>
|
|
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>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -11,9 +11,9 @@ std::string HybridCharacteristic::uuid() {
|
|
|
11
11
|
return _characteristic.uuid();
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
std::vector<std::shared_ptr<
|
|
14
|
+
std::vector<std::shared_ptr<HybridDescriptorSpec>> HybridCharacteristic::descriptors() {
|
|
15
15
|
std::vector<SimpleBLE::Descriptor> characteristic_descriptors = _characteristic.descriptors();
|
|
16
|
-
std::vector<std::shared_ptr<
|
|
16
|
+
std::vector<std::shared_ptr<HybridDescriptorSpec>> hybrid_descriptors;
|
|
17
17
|
hybrid_descriptors.reserve(characteristic_descriptors.size());
|
|
18
18
|
|
|
19
19
|
for (auto& descriptor : characteristic_descriptors) {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
namespace margelo::nitro::simplejsble {
|
|
10
10
|
|
|
11
11
|
// Forward declaration
|
|
12
|
-
class
|
|
12
|
+
class HybridDescriptorSpec;
|
|
13
13
|
|
|
14
14
|
class HybridCharacteristic : public HybridCharacteristicSpec {
|
|
15
15
|
public:
|
|
@@ -19,7 +19,7 @@ class HybridCharacteristic : public HybridCharacteristicSpec {
|
|
|
19
19
|
|
|
20
20
|
bool initialized() override;
|
|
21
21
|
std::string uuid() override;
|
|
22
|
-
std::vector<std::shared_ptr<
|
|
22
|
+
std::vector<std::shared_ptr<HybridDescriptorSpec>> descriptors() override;
|
|
23
23
|
std::vector<std::string> capabilities() override;
|
|
24
24
|
bool can_read() override;
|
|
25
25
|
bool can_write_request() override;
|
package/cpp/HybridPeripheral.cpp
CHANGED
|
@@ -81,9 +81,9 @@ void HybridPeripheral::set_callback_on_disconnected(const std::function<void()>&
|
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
std::vector<std::shared_ptr<
|
|
84
|
+
std::vector<std::shared_ptr<HybridServiceSpec>> HybridPeripheral::services() {
|
|
85
85
|
std::vector<SimpleBLE::Service> peripheral_services = _peripheral.services();
|
|
86
|
-
std::vector<std::shared_ptr<
|
|
86
|
+
std::vector<std::shared_ptr<HybridServiceSpec>> hybrid_services;
|
|
87
87
|
hybrid_services.reserve(peripheral_services.size());
|
|
88
88
|
|
|
89
89
|
for (auto& service : peripheral_services) {
|
|
@@ -93,9 +93,9 @@ std::vector<std::shared_ptr<HybridService>> HybridPeripheral::services() {
|
|
|
93
93
|
return hybrid_services;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
std::unordered_map<double, ArrayBuffer
|
|
96
|
+
std::unordered_map<double, std::shared_ptr<ArrayBuffer>> HybridPeripheral::manufacturer_data() {
|
|
97
97
|
std::map<uint16_t, SimpleBLE::ByteArray> peripheral_manufacturer_data = _peripheral.manufacturer_data();
|
|
98
|
-
std::unordered_map<double, ArrayBuffer
|
|
98
|
+
std::unordered_map<double, std::shared_ptr<ArrayBuffer>> manufacturer_array_buffer_map;
|
|
99
99
|
|
|
100
100
|
for (const auto& pair : peripheral_manufacturer_data) {
|
|
101
101
|
manufacturer_array_buffer_map[static_cast<double>(pair.first)] = toArrayBuffer(pair.second);
|
|
@@ -104,23 +104,23 @@ std::unordered_map<double, ArrayBuffer> HybridPeripheral::manufacturer_data() {
|
|
|
104
104
|
return manufacturer_array_buffer_map;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
ArrayBuffer HybridPeripheral::read(const std::string& service, const std::string& characteristic) {
|
|
107
|
+
std::shared_ptr<ArrayBuffer> HybridPeripheral::read(const std::string& service, const std::string& characteristic) {
|
|
108
108
|
SimpleBLE::ByteArray peripheral_read_data = _peripheral.read(service, characteristic);
|
|
109
109
|
return toArrayBuffer(peripheral_read_data);
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
void HybridPeripheral::write_request(const std::string& service, const std::string& characteristic, ArrayBuffer data) {
|
|
112
|
+
void HybridPeripheral::write_request(const std::string& service, const std::string& characteristic, const std::shared_ptr<ArrayBuffer>& data) {
|
|
113
113
|
SimpleBLE::ByteArray bytes = fromArrayBuffer(data);
|
|
114
114
|
_peripheral.write_request(service, characteristic, bytes);
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
void HybridPeripheral::write_command(const std::string& service, const std::string& characteristic, ArrayBuffer data) {
|
|
117
|
+
void HybridPeripheral::write_command(const std::string& service, const std::string& characteristic, const std::shared_ptr<ArrayBuffer>& data) {
|
|
118
118
|
SimpleBLE::ByteArray bytes = fromArrayBuffer(data);
|
|
119
119
|
_peripheral.write_command(service, characteristic, bytes);
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
void HybridPeripheral::notify(const std::string& service, const std::string& characteristic,
|
|
123
|
-
const std::function<void(ArrayBuffer)>& callback) {
|
|
123
|
+
const std::function<void(const std::shared_ptr<ArrayBuffer>&)>& callback) {
|
|
124
124
|
auto key = std::make_pair(service, characteristic);
|
|
125
125
|
_notifyCallbacks[key] = callback;
|
|
126
126
|
|
|
@@ -133,7 +133,7 @@ void HybridPeripheral::notify(const std::string& service, const std::string& cha
|
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
void HybridPeripheral::indicate(const std::string& service, const std::string& characteristic,
|
|
136
|
-
const std::function<void(ArrayBuffer)>& callback) {
|
|
136
|
+
const std::function<void(const std::shared_ptr<ArrayBuffer>&)>& callback) {
|
|
137
137
|
auto key = std::make_pair(service, characteristic);
|
|
138
138
|
_notifyCallbacks[key] = callback; //@alejo: verify if its necessary to store our own reference to the callback
|
|
139
139
|
|
|
@@ -151,27 +151,27 @@ void HybridPeripheral::unsubscribe(const std::string& service, const std::string
|
|
|
151
151
|
_peripheral.unsubscribe(service, characteristic);
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
ArrayBuffer HybridPeripheral::read_descriptor(const std::string& service, const std::string& characteristic,
|
|
154
|
+
std::shared_ptr<ArrayBuffer> HybridPeripheral::read_descriptor(const std::string& service, const std::string& characteristic,
|
|
155
155
|
const std::string& descriptor) {
|
|
156
156
|
SimpleBLE::ByteArray peripheral_descriptor_data = _peripheral.read(service, characteristic, descriptor);
|
|
157
157
|
return toArrayBuffer(peripheral_descriptor_data);
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
void HybridPeripheral::write_descriptor(const std::string& service, const std::string& characteristic,
|
|
161
|
-
const std::string& descriptor, ArrayBuffer data) {
|
|
161
|
+
const std::string& descriptor, const std::shared_ptr<ArrayBuffer>& data) {
|
|
162
162
|
SimpleBLE::ByteArray bytes = fromArrayBuffer(data);
|
|
163
163
|
_peripheral.write(service, characteristic, descriptor, bytes);
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
// Helper methods to cast between SimpleBLE::ByteArray and ArrayBuffer (NitroModules native type)
|
|
167
|
-
ArrayBuffer HybridPeripheral::toArrayBuffer(const SimpleBLE::ByteArray& data) {
|
|
168
|
-
return ArrayBuffer(reinterpret_cast<const uint8_t*>(data.data()), data.size());
|
|
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
169
|
}
|
|
170
170
|
|
|
171
|
-
SimpleBLE::ByteArray HybridPeripheral::fromArrayBuffer(const ArrayBuffer
|
|
171
|
+
SimpleBLE::ByteArray HybridPeripheral::fromArrayBuffer(const std::shared_ptr<ArrayBuffer>& buffer) {
|
|
172
172
|
return SimpleBLE::ByteArray(
|
|
173
|
-
static_cast<const uint8_t*>(buffer
|
|
174
|
-
buffer
|
|
173
|
+
static_cast<const uint8_t*>(buffer->data()),
|
|
174
|
+
buffer->size()
|
|
175
175
|
);
|
|
176
176
|
}
|
|
177
177
|
|
package/cpp/HybridPeripheral.hpp
CHANGED
|
@@ -6,11 +6,12 @@
|
|
|
6
6
|
#include <functional>
|
|
7
7
|
#include <string>
|
|
8
8
|
#include <map>
|
|
9
|
+
#include <unordered_map>
|
|
9
10
|
#include <utility>
|
|
10
11
|
|
|
11
12
|
namespace margelo::nitro::simplejsble {
|
|
12
13
|
|
|
13
|
-
class
|
|
14
|
+
class HybridServiceSpec;
|
|
14
15
|
|
|
15
16
|
class HybridPeripheral : public HybridPeripheralSpec {
|
|
16
17
|
public:
|
|
@@ -36,22 +37,22 @@ class HybridPeripheral : public HybridPeripheralSpec {
|
|
|
36
37
|
void set_callback_on_connected(const std::function<void()>& callback) override;
|
|
37
38
|
void set_callback_on_disconnected(const std::function<void()>& callback) override;
|
|
38
39
|
|
|
39
|
-
std::vector<std::shared_ptr<
|
|
40
|
-
std::unordered_map<double, ArrayBuffer
|
|
40
|
+
std::vector<std::shared_ptr<HybridServiceSpec>> services() override;
|
|
41
|
+
std::unordered_map<double, std::shared_ptr<ArrayBuffer>> manufacturer_data() override;
|
|
41
42
|
|
|
42
|
-
ArrayBuffer read(const std::string& service, const std::string& characteristic) override;
|
|
43
|
-
void write_request(const std::string& service, const std::string& characteristic, ArrayBuffer data) override;
|
|
44
|
-
void write_command(const std::string& service, const std::string& characteristic, ArrayBuffer data) override;
|
|
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;
|
|
45
46
|
void notify(const std::string& service, const std::string& characteristic,
|
|
46
|
-
const std::function<void(ArrayBuffer)>& callback) override;
|
|
47
|
+
const std::function<void(const std::shared_ptr<ArrayBuffer>&)>& callback) override;
|
|
47
48
|
void indicate(const std::string& service, const std::string& characteristic,
|
|
48
|
-
const std::function<void(ArrayBuffer)>& callback) override;
|
|
49
|
+
const std::function<void(const std::shared_ptr<ArrayBuffer>&)>& callback) override;
|
|
49
50
|
void unsubscribe(const std::string& service, const std::string& characteristic) override;
|
|
50
51
|
|
|
51
|
-
ArrayBuffer read_descriptor(const std::string& service, const std::string& characteristic,
|
|
52
|
+
std::shared_ptr<ArrayBuffer> read_descriptor(const std::string& service, const std::string& characteristic,
|
|
52
53
|
const std::string& descriptor) override;
|
|
53
54
|
void write_descriptor(const std::string& service, const std::string& characteristic,
|
|
54
|
-
const std::string& descriptor, ArrayBuffer data) override;
|
|
55
|
+
const std::string& descriptor, const std::shared_ptr<ArrayBuffer>& data) override;
|
|
55
56
|
|
|
56
57
|
SimpleBLE::Peripheral& getInternal() { return _peripheral; }
|
|
57
58
|
const SimpleBLE::Peripheral& getInternal() const { return _peripheral; }
|
|
@@ -62,11 +63,11 @@ class HybridPeripheral : public HybridPeripheralSpec {
|
|
|
62
63
|
std::function<void()> _onConnected;
|
|
63
64
|
std::function<void()> _onDisconnected;
|
|
64
65
|
|
|
65
|
-
std::map<std::pair<std::string, std::string>, std::function<void(ArrayBuffer)>> _notifyCallbacks;
|
|
66
|
+
std::map<std::pair<std::string, std::string>, std::function<void(const std::shared_ptr<ArrayBuffer>&)>> _notifyCallbacks;
|
|
66
67
|
|
|
67
68
|
// Helper methods to cast between SimpleBLE::ByteArray and ArrayBuffer (NitroModules native type)
|
|
68
|
-
static ArrayBuffer toArrayBuffer(const SimpleBLE::ByteArray& data);
|
|
69
|
-
static SimpleBLE::ByteArray fromArrayBuffer(const ArrayBuffer
|
|
69
|
+
static std::shared_ptr<ArrayBuffer> toArrayBuffer(const SimpleBLE::ByteArray& data);
|
|
70
|
+
static SimpleBLE::ByteArray fromArrayBuffer(const std::shared_ptr<ArrayBuffer>& buffer);
|
|
70
71
|
};
|
|
71
72
|
|
|
72
73
|
} // namespace margelo::nitro::simplejsble
|
package/cpp/HybridService.cpp
CHANGED
|
@@ -11,14 +11,14 @@ std::string HybridService::uuid() {
|
|
|
11
11
|
return _service.uuid();
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
ArrayBuffer HybridService::data() {
|
|
14
|
+
std::shared_ptr<ArrayBuffer> HybridService::data() {
|
|
15
15
|
SimpleBLE::ByteArray bytes = _service.data();
|
|
16
|
-
return ArrayBuffer(reinterpret_cast<const uint8_t*>(bytes.data()), bytes.size());
|
|
16
|
+
return std::make_shared<ArrayBuffer>(reinterpret_cast<const uint8_t*>(bytes.data()), bytes.size());
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
std::vector<std::shared_ptr<
|
|
19
|
+
std::vector<std::shared_ptr<HybridCharacteristicSpec>> HybridService::characteristics() {
|
|
20
20
|
std::vector<SimpleBLE::Characteristic> service_characteristics = _service.characteristics();
|
|
21
|
-
std::vector<std::shared_ptr<
|
|
21
|
+
std::vector<std::shared_ptr<HybridCharacteristicSpec>> hybrid_characteristics;
|
|
22
22
|
hybrid_characteristics.reserve(service_characteristics.size());
|
|
23
23
|
|
|
24
24
|
for (auto& characteristic : service_characteristics) {
|
package/cpp/HybridService.hpp
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
#include "HybridServiceSpec.hpp"
|
|
4
4
|
#include <simpleble/SimpleBLE.h>
|
|
5
|
+
#include <NitroModules/ArrayBuffer.hpp>
|
|
5
6
|
#include <memory>
|
|
6
7
|
#include <vector>
|
|
7
8
|
|
|
8
9
|
namespace margelo::nitro::simplejsble {
|
|
9
10
|
|
|
10
|
-
class
|
|
11
|
+
class HybridCharacteristicSpec;
|
|
11
12
|
|
|
12
13
|
class HybridService : public HybridServiceSpec {
|
|
13
14
|
public:
|
|
@@ -17,8 +18,8 @@ class HybridService : public HybridServiceSpec {
|
|
|
17
18
|
|
|
18
19
|
bool initialized() override;
|
|
19
20
|
std::string uuid() override;
|
|
20
|
-
ArrayBuffer data() override;
|
|
21
|
-
std::vector<std::shared_ptr<
|
|
21
|
+
std::shared_ptr<ArrayBuffer> data() override;
|
|
22
|
+
std::vector<std::shared_ptr<HybridCharacteristicSpec>> characteristics() override;
|
|
22
23
|
|
|
23
24
|
SimpleBLE::Service& getInternal() { return _service; }
|
|
24
25
|
const SimpleBLE::Service& getInternal() const { return _service; }
|