simplernble 1.2.1-dev105 → 1.2.1-dev114
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/README.md +37 -27
- package/native/VERSION +1 -1
- package/native/simpleble/src/backends/android/PeripheralAndroid.h +3 -2
- package/native/simpleble/src/backends/simulator/LocalPeripheralSimulator.cpp +8 -1
- package/package.json +1 -1
- package/prebuilt/release/SimpleBLE.xcframework/ios-arm64/libsimpleble.a +0 -0
- package/prebuilt/release/SimpleBLE.xcframework/ios-arm64_x86_64-simulator/libsimpleble.a +0 -0
package/README.md
CHANGED
|
@@ -1,16 +1,32 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<
|
|
3
|
-
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/simpleble/simpleble/main/docs/public/simpleBLE-logo.png">
|
|
4
|
+
<img src="https://raw.githubusercontent.com/simpleble/simpleble/main/docs/public/simpleBLE-logo-dark.png" alt="SimpleBLE" width="360">
|
|
5
|
+
</picture>
|
|
4
6
|
</p>
|
|
5
7
|
|
|
6
8
|
# SimpleRnBLE
|
|
7
9
|
|
|
10
|
+
**Build Bluetooth once. Ship it everywhere.**
|
|
11
|
+
|
|
8
12
|
SimpleRnBLE brings [SimpleBLE](https://github.com/simpleble/simpleble) to React
|
|
9
13
|
Native apps on iOS and Android. Discover and connect Bluetooth peripherals, read
|
|
10
14
|
and write GATT values, subscribe to notifications, and host local GATT services
|
|
11
|
-
through one API, with TypeScript types included.
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
through one API, with TypeScript types included.
|
|
16
|
+
|
|
17
|
+
## Why SimpleRnBLE
|
|
18
|
+
|
|
19
|
+
- **One cross-platform API:** Keep your Bluetooth code the same on iOS and Android.
|
|
20
|
+
- **Native underneath:** Calls go straight from JavaScript to SimpleBLE's C++ core through [Nitro](https://nitro.margelo.com), on top of CoreBluetooth and Android Bluetooth.
|
|
21
|
+
- **Built for real products:** Act as a central or a peripheral on both platforms.
|
|
22
|
+
- **Commercially supported:** Ship proprietary applications with commercial licensing and direct technical support from the team that builds SimpleBLE.
|
|
23
|
+
|
|
24
|
+
## Support and resources
|
|
25
|
+
|
|
26
|
+
- **Documentation:** The [usage guide](https://docs.simpleble.org/simplernble/usage?utm_source=npm&utm_medium=referral&utm_campaign=simplernble_readme&utm_content=support) and [example app](https://github.com/simpleble/simpleble/tree/main/examples/simplernble) cover every API.
|
|
27
|
+
- **Commercial support:** Visit [simpleble.org](https://simpleble.org/?utm_source=npm&utm_medium=referral&utm_campaign=simplernble_readme&utm_content=support) or [email us](mailto:contact@simpleble.org) about licensing and professional services.
|
|
28
|
+
- **Community:** Ask questions and share projects in [GitHub Discussions](https://github.com/simpleble/simpleble/discussions).
|
|
29
|
+
- **Contribute:** Send changes to [simpleble/simpleble](https://github.com/simpleble/simpleble/tree/main/simplernble); the [publishing guide](https://github.com/simpleble/simpleble/blob/main/docs/extras/simplernble-publishing.md) covers builds and releases.
|
|
14
30
|
|
|
15
31
|
## Get started
|
|
16
32
|
|
|
@@ -26,11 +42,6 @@ the NDK. Set your app's targets to match: `minSdkVersion = 31` in
|
|
|
26
42
|
`android/build.gradle`, and `platform :ios, '15.8'` in `ios/Podfile`. In Expo,
|
|
27
43
|
use a development build and set both with `expo-build-properties`.
|
|
28
44
|
|
|
29
|
-
Declare Bluetooth usage with `NSBluetoothAlwaysUsageDescription` in your iOS
|
|
30
|
-
`Info.plist`. On Android, request `BLUETOOTH_SCAN` and `BLUETOOTH_CONNECT` at
|
|
31
|
-
runtime, plus `BLUETOOTH_ADVERTISE` to host services; SimpleRnBLE declares them
|
|
32
|
-
in its manifest.
|
|
33
|
-
|
|
34
45
|
Scan for five seconds and print what was found:
|
|
35
46
|
|
|
36
47
|
```ts
|
|
@@ -39,11 +50,18 @@ import { Adapter } from 'simplernble';
|
|
|
39
50
|
const [adapter] = await Adapter.getAdapters();
|
|
40
51
|
|
|
41
52
|
adapter.on('scanFound', peripheral => {
|
|
42
|
-
console.log(peripheral.identifier()
|
|
53
|
+
console.log(`${peripheral.identifier()} [${peripheral.address()}] ${peripheral.rssi()} dBm`);
|
|
43
54
|
});
|
|
44
55
|
await adapter.scanFor(5000);
|
|
45
56
|
```
|
|
46
57
|
|
|
58
|
+
## Permissions
|
|
59
|
+
|
|
60
|
+
Declare Bluetooth usage with `NSBluetoothAlwaysUsageDescription` in your iOS
|
|
61
|
+
`Info.plist`. On Android, request `BLUETOOTH_SCAN` and `BLUETOOTH_CONNECT` at
|
|
62
|
+
runtime, plus `BLUETOOTH_ADVERTISE` to host services; SimpleRnBLE declares them
|
|
63
|
+
in its manifest.
|
|
64
|
+
|
|
47
65
|
## Scanning and events
|
|
48
66
|
|
|
49
67
|
Adapters and peripherals emit events, with `on()`, `once()`, and `off()`. An
|
|
@@ -111,15 +129,15 @@ changing them.
|
|
|
111
129
|
|
|
112
130
|
## Platforms
|
|
113
131
|
|
|
114
|
-
| Platform | Requirements |
|
|
115
|
-
| --- | --- |
|
|
116
|
-
| iOS 15.8 or newer | `NSBluetoothAlwaysUsageDescription` in `Info.plist` |
|
|
117
|
-
| Android 12 (API 31) or newer | Runtime Bluetooth permissions; the Android NDK to build |
|
|
132
|
+
| Platform | Architectures | Requirements |
|
|
133
|
+
| --- | --- | --- |
|
|
134
|
+
| iOS 15.8 or newer | arm64, plus arm64 and x64 simulators | `NSBluetoothAlwaysUsageDescription` in `Info.plist` |
|
|
135
|
+
| Android 12 (API 31) or newer | arm64-v8a, armeabi-v7a, x86, x86_64 | Runtime Bluetooth permissions; the Android NDK to build |
|
|
118
136
|
|
|
119
137
|
SimpleRnBLE needs React Native 0.80 or newer with the New Architecture, and
|
|
120
138
|
`react-native-nitro-modules` 0.37. `Logging` routes SimpleBLE's log, and
|
|
121
139
|
`Config` holds the Android backend settings. See the
|
|
122
|
-
[usage guide](https://docs.simpleble.org/simplernble/usage) for permissions,
|
|
140
|
+
[usage guide](https://docs.simpleble.org/simplernble/usage?utm_source=npm&utm_medium=referral&utm_campaign=simplernble_readme&utm_content=platforms) for permissions,
|
|
123
141
|
Expo, and platform details.
|
|
124
142
|
|
|
125
143
|
## Versions
|
|
@@ -131,24 +149,16 @@ under the `latest` tag, and development builds of the main branch under `dev`:
|
|
|
131
149
|
npm install simplernble@dev
|
|
132
150
|
```
|
|
133
151
|
|
|
134
|
-
## Documentation and support
|
|
135
|
-
|
|
136
|
-
- Read the [SimpleRnBLE usage guide](https://docs.simpleble.org/simplernble/usage).
|
|
137
|
-
- Try the [example app](https://github.com/simpleble/simpleble/tree/main/examples/simplernble).
|
|
138
|
-
- Join the [Discord community](https://discord.gg/N9HqNEcvP3).
|
|
139
|
-
- Contribute in [simpleble/simpleble](https://github.com/simpleble/simpleble/tree/main/simplernble); see the [development and publishing guide](https://github.com/simpleble/simpleble/blob/main/docs/extras/simplernble-publishing.md).
|
|
140
|
-
- Visit [simpleble.org](https://simpleble.org/) for commercial licensing and professional services.
|
|
141
|
-
|
|
142
152
|
## License
|
|
143
153
|
|
|
144
154
|
SimpleRnBLE follows the [SimpleBLE license](https://github.com/simpleble/simpleble/blob/main/LICENSE.md),
|
|
145
155
|
the Business Source License 1.1 (BUSL-1.1). It is free for non-commercial use,
|
|
146
156
|
and commercial use needs a commercial license. We offer free commercial licenses
|
|
147
157
|
for small projects and early-stage companies: [email us](mailto:contact@simpleble.org)
|
|
148
|
-
or [leave us a message](https://www.simpleble.org/contact) to discuss your use
|
|
158
|
+
or [leave us a message](https://www.simpleble.org/contact?utm_source=npm&utm_medium=referral&utm_campaign=simplernble_readme&utm_content=license) to discuss your use
|
|
149
159
|
case. Commercial licenses carry no royalties or revenue sharing; see the
|
|
150
|
-
[licensing page](https://docs.simpleble.org/licensing) for terms.
|
|
160
|
+
[licensing page](https://docs.simpleble.org/licensing?utm_source=npm&utm_medium=referral&utm_campaign=simplernble_readme&utm_content=license) for terms.
|
|
151
161
|
|
|
152
162
|
---
|
|
153
163
|
|
|
154
|
-
**SimpleBLE** is a project powered by [The California Open Source Company](https://californiaopensource.com
|
|
164
|
+
**SimpleBLE** is a project powered by [The California Open Source Company](https://californiaopensource.com/?utm_source=npm&utm_medium=referral&utm_campaign=simplernble_readme&utm_content=footer).
|
package/native/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.2.1-
|
|
1
|
+
1.2.1-dev114
|
|
@@ -66,8 +66,9 @@ class PeripheralAndroid : public PeripheralBase {
|
|
|
66
66
|
|
|
67
67
|
int16_t rssi_ = INT16_MIN;
|
|
68
68
|
int16_t tx_power_ = INT16_MIN;
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
|
|
70
|
+
// NOTE: A bonded device has no advertisement until it is scanned. Like Windows, assume it is connectable.
|
|
71
|
+
bool connectable_ = true;
|
|
71
72
|
|
|
72
73
|
std::vector<std::string> advertised_services_;
|
|
73
74
|
std::map<uint16_t, kvn::bytearray> manufacturer_data_;
|
|
@@ -473,7 +473,14 @@ class PeripheralSimulator final : public PeripheralBase {
|
|
|
473
473
|
return device_->started && environment && environment->is_active();
|
|
474
474
|
}
|
|
475
475
|
|
|
476
|
-
bool is_advertising() override {
|
|
476
|
+
bool is_advertising() override {
|
|
477
|
+
if (!is_started()) return false;
|
|
478
|
+
|
|
479
|
+
// Same rule as the environment: the device stops advertising once it has as many connections as it accepts.
|
|
480
|
+
auto core = device_->internal();
|
|
481
|
+
std::lock_guard<std::mutex> lock(core->mutex);
|
|
482
|
+
return core->connections.size() < core->settings.max_connections;
|
|
483
|
+
}
|
|
477
484
|
|
|
478
485
|
void set_callback_on_client_connected(std::function<void(BluetoothAddress)> callback) override {
|
|
479
486
|
if (callback) {
|
package/package.json
CHANGED
|
Binary file
|