simplejsble 0.0.47 → 0.0.48
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/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 +50 -0
- package/cpp/HybridCharacteristic.hpp +37 -0
- package/cpp/HybridDescriptor.cpp +13 -0
- package/cpp/HybridDescriptor.hpp +25 -0
- package/cpp/HybridPeripheral.cpp +95 -0
- package/cpp/HybridPeripheral.hpp +27 -0
- package/cpp/HybridService.cpp +31 -0
- package/cpp/HybridService.hpp +30 -0
- package/lib/index.d.ts +5 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/specs/Characteristic.nitro.d.ts +45 -0
- package/lib/specs/Characteristic.nitro.d.ts.map +1 -0
- package/lib/specs/Characteristic.nitro.js +2 -0
- package/lib/specs/Descriptor.nitro.d.ts +15 -0
- package/lib/specs/Descriptor.nitro.d.ts.map +1 -0
- package/lib/specs/Descriptor.nitro.js +1 -0
- package/lib/specs/Peripheral.nitro.d.ts +76 -0
- package/lib/specs/Peripheral.nitro.d.ts.map +1 -1
- package/lib/specs/Peripheral.nitro.js +1 -0
- package/lib/specs/Service.nitro.d.ts +25 -0
- package/lib/specs/Service.nitro.d.ts.map +1 -0
- package/lib/specs/Service.nitro.js +2 -0
- package/lib/utils/bytearray.d.ts +49 -0
- package/lib/utils/bytearray.d.ts.map +1 -0
- package/lib/utils/bytearray.js +72 -0
- package/nitrogen/generated/android/NitroSimplejsble+autolinking.cmake +3 -0
- package/nitrogen/generated/shared/c++/HybridCharacteristicSpec.cpp +29 -0
- package/nitrogen/generated/shared/c++/HybridCharacteristicSpec.hpp +74 -0
- package/nitrogen/generated/shared/c++/HybridDescriptorSpec.cpp +22 -0
- package/nitrogen/generated/shared/c++/HybridDescriptorSpec.hpp +63 -0
- package/nitrogen/generated/shared/c++/HybridPeripheralSpec.cpp +10 -0
- package/nitrogen/generated/shared/c++/HybridPeripheralSpec.hpp +17 -0
- package/nitrogen/generated/shared/c++/HybridServiceSpec.cpp +24 -0
- package/nitrogen/generated/shared/c++/HybridServiceSpec.hpp +70 -0
- package/package.json +1 -1
- package/src/index.ts +6 -1
- package/src/specs/Characteristic.nitro.ts +54 -0
- package/src/specs/Descriptor.nitro.ts +17 -0
- package/src/specs/Peripheral.nitro.ts +86 -0
- package/src/specs/Service.nitro.ts +29 -0
- package/src/utils/bytearray.ts +79 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -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<HybridDescriptor>> HybridCharacteristic::descriptors() {
|
|
15
|
+
std::vector<SimpleBLE::Descriptor> characteristic_descriptors = _characteristic.descriptors();
|
|
16
|
+
std::vector<std::shared_ptr<HybridDescriptor>> 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 HybridDescriptor;
|
|
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<HybridDescriptor>> 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
|
package/cpp/HybridPeripheral.cpp
CHANGED
|
@@ -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<HybridService>> HybridPeripheral::services() {
|
|
85
|
+
std::vector<SimpleBLE::Service> peripheral_services = _peripheral.services();
|
|
86
|
+
std::vector<std::shared_ptr<HybridService>> 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, ArrayBuffer> HybridPeripheral::manufacturer_data() {
|
|
97
|
+
std::map<uint16_t, SimpleBLE::ByteArray> peripheral_manufacturer_data = _peripheral.manufacturer_data();
|
|
98
|
+
std::unordered_map<double, 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
|
+
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, 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, 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(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(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
|
+
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, 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
|
+
ArrayBuffer HybridPeripheral::toArrayBuffer(const SimpleBLE::ByteArray& data) {
|
|
168
|
+
return ArrayBuffer(reinterpret_cast<const uint8_t*>(data.data()), data.size());
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
SimpleBLE::ByteArray HybridPeripheral::fromArrayBuffer(const 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
|
package/cpp/HybridPeripheral.hpp
CHANGED
|
@@ -5,9 +5,13 @@
|
|
|
5
5
|
#include <simpleble/SimpleBLE.h>
|
|
6
6
|
#include <functional>
|
|
7
7
|
#include <string>
|
|
8
|
+
#include <map>
|
|
9
|
+
#include <utility>
|
|
8
10
|
|
|
9
11
|
namespace margelo::nitro::simplejsble {
|
|
10
12
|
|
|
13
|
+
class HybridService;
|
|
14
|
+
|
|
11
15
|
class HybridPeripheral : public HybridPeripheralSpec {
|
|
12
16
|
public:
|
|
13
17
|
HybridPeripheral() : HybridObject(TAG) {}
|
|
@@ -32,6 +36,23 @@ class HybridPeripheral : public HybridPeripheralSpec {
|
|
|
32
36
|
void set_callback_on_connected(const std::function<void()>& callback) override;
|
|
33
37
|
void set_callback_on_disconnected(const std::function<void()>& callback) override;
|
|
34
38
|
|
|
39
|
+
std::vector<std::shared_ptr<HybridService>> services() override;
|
|
40
|
+
std::unordered_map<double, ArrayBuffer> manufacturer_data() override;
|
|
41
|
+
|
|
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;
|
|
45
|
+
void notify(const std::string& service, const std::string& characteristic,
|
|
46
|
+
const std::function<void(ArrayBuffer)>& callback) override;
|
|
47
|
+
void indicate(const std::string& service, const std::string& characteristic,
|
|
48
|
+
const std::function<void(ArrayBuffer)>& callback) override;
|
|
49
|
+
void unsubscribe(const std::string& service, const std::string& characteristic) override;
|
|
50
|
+
|
|
51
|
+
ArrayBuffer read_descriptor(const std::string& service, const std::string& characteristic,
|
|
52
|
+
const std::string& descriptor) override;
|
|
53
|
+
void write_descriptor(const std::string& service, const std::string& characteristic,
|
|
54
|
+
const std::string& descriptor, ArrayBuffer data) override;
|
|
55
|
+
|
|
35
56
|
SimpleBLE::Peripheral& getInternal() { return _peripheral; }
|
|
36
57
|
const SimpleBLE::Peripheral& getInternal() const { return _peripheral; }
|
|
37
58
|
|
|
@@ -40,6 +61,12 @@ class HybridPeripheral : public HybridPeripheralSpec {
|
|
|
40
61
|
|
|
41
62
|
std::function<void()> _onConnected;
|
|
42
63
|
std::function<void()> _onDisconnected;
|
|
64
|
+
|
|
65
|
+
std::map<std::pair<std::string, std::string>, std::function<void(ArrayBuffer)>> _notifyCallbacks;
|
|
66
|
+
|
|
67
|
+
// 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& buffer);
|
|
43
70
|
};
|
|
44
71
|
|
|
45
72
|
} // 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
|
+
ArrayBuffer HybridService::data() {
|
|
15
|
+
SimpleBLE::ByteArray bytes = _service.data();
|
|
16
|
+
return ArrayBuffer(reinterpret_cast<const uint8_t*>(bytes.data()), bytes.size());
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
std::vector<std::shared_ptr<HybridCharacteristic>> HybridService::characteristics() {
|
|
20
|
+
std::vector<SimpleBLE::Characteristic> service_characteristics = _service.characteristics();
|
|
21
|
+
std::vector<std::shared_ptr<HybridCharacteristic>> 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,30 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "HybridServiceSpec.hpp"
|
|
4
|
+
#include <simpleble/SimpleBLE.h>
|
|
5
|
+
#include <memory>
|
|
6
|
+
#include <vector>
|
|
7
|
+
|
|
8
|
+
namespace margelo::nitro::simplejsble {
|
|
9
|
+
|
|
10
|
+
class HybridCharacteristic;
|
|
11
|
+
|
|
12
|
+
class HybridService : public HybridServiceSpec {
|
|
13
|
+
public:
|
|
14
|
+
HybridService() : HybridObject(TAG) {}
|
|
15
|
+
explicit HybridService(SimpleBLE::Service service)
|
|
16
|
+
: HybridObject(TAG), _service(std::move(service)) {}
|
|
17
|
+
|
|
18
|
+
bool initialized() override;
|
|
19
|
+
std::string uuid() override;
|
|
20
|
+
ArrayBuffer data() override;
|
|
21
|
+
std::vector<std::shared_ptr<HybridCharacteristic>> characteristics() override;
|
|
22
|
+
|
|
23
|
+
SimpleBLE::Service& getInternal() { return _service; }
|
|
24
|
+
const SimpleBLE::Service& getInternal() const { return _service; }
|
|
25
|
+
|
|
26
|
+
private:
|
|
27
|
+
SimpleBLE::Service _service;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
} // 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
|
-
|
|
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
|
package/lib/index.d.ts.map
CHANGED
|
@@ -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;
|
|
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
|
@@ -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,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;
|
|
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;AAC9D,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAE9C;;;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;;OAEG;IACH,GAAG,IAAI,MAAM,CAAA;IAEb;;OAEG;IACH,OAAO,IAAI,IAAI,CAAA;IAEf;;OAEG;IACH,UAAU,IAAI,IAAI,CAAA;IAElB;;OAEG;IACH,YAAY,IAAI,OAAO,CAAA;IAEvB;;OAEG;IACH,cAAc,IAAI,OAAO,CAAA;IAEzB;;OAEG;IACH,SAAS,IAAI,OAAO,CAAA;IAEpB;;OAEG;IACH,MAAM,IAAI,IAAI,CAAA;IAEd;;OAEG;IACH,yBAAyB,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAAA;IAErD;;OAEG;IACH,4BAA4B,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAAA;IAExD;;;OAGG;IACH,QAAQ,IAAI,OAAO,EAAE,CAAA;IAErB;;;OAGG;IACH,iBAAiB,IAAI,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;IAEhD;;;;;;OAMG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,WAAW,CAAA;IAE1D;;;;;;OAMG;IACH,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI,CAAA;IAE/E;;;;;;OAMG;IACH,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI,CAAA;IAE/E;;;;;;OAMG;IACH,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,GAAG,IAAI,CAAA;IAE5F;;;;;;OAMG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,GAAG,IAAI,CAAA;IAE9F;;;;;OAKG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;IAE1D;;;;;;;OAOG;IACH,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"}
|
|
@@ -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,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a hex string to a Uint8Array.
|
|
3
|
+
* Spaces and common separators (-, :) are automatically removed.
|
|
4
|
+
*
|
|
5
|
+
* @param hex Hex string (e.g., "48656c6c6f" or "48 65 6c 6c 6f")
|
|
6
|
+
* @returns Uint8Array containing the decoded bytes
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const data = fromHex("48656c6c6f");
|
|
10
|
+
* const data2 = fromHex("48 65 6c 6c 6f");
|
|
11
|
+
* const data3 = fromHex("48:65:6c:6c:6f");
|
|
12
|
+
*/
|
|
13
|
+
export declare function fromHex(hex: string): Uint8Array;
|
|
14
|
+
/**
|
|
15
|
+
* Convert a Uint8Array to a hex string.
|
|
16
|
+
*
|
|
17
|
+
* @param data Uint8Array to convert
|
|
18
|
+
* @param withSpaces If true, separates bytes with spaces (default: false)
|
|
19
|
+
* @returns Hex string representation
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* const data = new Uint8Array([72, 101, 108, 108, 111]);
|
|
23
|
+
* toHex(data); // "48656c6c6f"
|
|
24
|
+
* toHex(data, true); // "48 65 6c 6c 6f"
|
|
25
|
+
*/
|
|
26
|
+
export declare function toHex(data: Uint8Array, withSpaces?: boolean): string;
|
|
27
|
+
/**
|
|
28
|
+
* Convert a Uint8Array to a UTF-8 string.
|
|
29
|
+
*
|
|
30
|
+
* @param data Uint8Array containing UTF-8 encoded text
|
|
31
|
+
* @returns Decoded string
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* const data = new Uint8Array([72, 101, 108, 108, 111]);
|
|
35
|
+
* toString(data); // "Hello"
|
|
36
|
+
*/
|
|
37
|
+
export declare function toString(data: Uint8Array): string;
|
|
38
|
+
/**
|
|
39
|
+
* Convert a UTF-8 string to a Uint8Array.
|
|
40
|
+
*
|
|
41
|
+
* @param str String to encode
|
|
42
|
+
* @returns Uint8Array containing UTF-8 encoded bytes
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* const data = fromString("Hello");
|
|
46
|
+
* // Uint8Array([72, 101, 108, 108, 111])
|
|
47
|
+
*/
|
|
48
|
+
export declare function fromString(str: string): Uint8Array;
|
|
49
|
+
//# sourceMappingURL=bytearray.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bytearray.d.ts","sourceRoot":"","sources":["../../src/utils/bytearray.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAiB/C;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,UAAU,GAAE,OAAe,GAAG,MAAM,CAK3E;AAED;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAGjD;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAGlD"}
|