Commit 98d4ef89 authored by 焦延超's avatar 焦延超
Browse files

Initial commit

parents
No related merge requests found
Pipeline #67 failed with stages

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.
# These are supported funding model platforms
github: [marcosinigaglia]
"use strict";
var React = require("react-native");
var bleManager = React.NativeModules.BleManager;
class BleManager {
constructor() {
this.isPeripheralConnected = this.isPeripheralConnected.bind(this);
}
read(peripheralId, serviceUUID, characteristicUUID) {
return new Promise((fulfill, reject) => {
bleManager.read(
peripheralId,
serviceUUID,
characteristicUUID,
(error, data) => {
if (error) {
reject(error);
} else {
fulfill(data);
}
}
);
});
}
readRSSI(peripheralId) {
return new Promise((fulfill, reject) => {
bleManager.readRSSI(peripheralId, (error, rssi) => {
if (error) {
reject(error);
} else {
fulfill(rssi);
}
});
});
}
refreshCache(peripheralId) {
return new Promise((fulfill, reject) => {
bleManager.refreshCache(peripheralId, (error, result) => {
if (error) {
reject(error);
} else {
fulfill(result);
}
});
});
}
retrieveServices(peripheralId, services) {
return new Promise((fulfill, reject) => {
bleManager.retrieveServices(
peripheralId,
services,
(error, peripheral) => {
if (error) {
reject(error);
} else {
fulfill(peripheral);
}
}
);
});
}
write(peripheralId, serviceUUID, characteristicUUID, data, maxByteSize) {
if (maxByteSize == null) {
maxByteSize = 20;
}
return new Promise((fulfill, reject) => {
bleManager.write(
peripheralId,
serviceUUID,
characteristicUUID,
data,
maxByteSize,
error => {
if (error) {
reject(error);
} else {
fulfill();
}
}
);
});
}
writeWithoutResponse(
peripheralId,
serviceUUID,
characteristicUUID,
data,
maxByteSize,
queueSleepTime
) {
if (maxByteSize == null) {
maxByteSize = 20;
}
if (queueSleepTime == null) {
queueSleepTime = 10;
}
return new Promise((fulfill, reject) => {
bleManager.writeWithoutResponse(
peripheralId,
serviceUUID,
characteristicUUID,
data,
maxByteSize,
queueSleepTime,
error => {
if (error) {
reject(error);
} else {
fulfill();
}
}
);
});
}
connect(peripheralId) {
return new Promise((fulfill, reject) => {
bleManager.connect(peripheralId, error => {
if (error) {
reject(error);
} else {
fulfill();
}
});
});
}
createBond(peripheralId,peripheralPin=null) {
return new Promise((fulfill, reject) => {
bleManager.createBond(peripheralId,peripheralPin, error => {
if (error) {
reject(error);
} else {
fulfill();
}
});
});
}
removeBond(peripheralId) {
return new Promise((fulfill, reject) => {
bleManager.removeBond(peripheralId, error => {
if (error) {
reject(error);
} else {
fulfill();
}
});
});
}
disconnect(peripheralId, force = true) {
return new Promise((fulfill, reject) => {
bleManager.disconnect(peripheralId, force, error => {
if (error) {
reject(error);
} else {
fulfill();
}
});
});
}
startNotification(peripheralId, serviceUUID, characteristicUUID) {
return new Promise((fulfill, reject) => {
bleManager.startNotification(
peripheralId,
serviceUUID,
characteristicUUID,
error => {
if (error) {
reject(error);
} else {
fulfill();
}
}
);
});
}
startNotificationUseBuffer(
peripheralId,
serviceUUID,
characteristicUUID,
buffer
) {
return new Promise((fulfill, reject) => {
bleManager.startNotificationUseBuffer(
peripheralId,
serviceUUID,
characteristicUUID,
buffer,
error => {
if (error) {
reject(error);
} else {
fulfill();
}
}
);
});
}
stopNotification(peripheralId, serviceUUID, characteristicUUID) {
return new Promise((fulfill, reject) => {
bleManager.stopNotification(
peripheralId,
serviceUUID,
characteristicUUID,
error => {
if (error) {
reject(error);
} else {
fulfill();
}
}
);
});
}
checkState() {
bleManager.checkState();
}
start(options) {
return new Promise((fulfill, reject) => {
if (options == null) {
options = {};
}
bleManager.start(options, error => {
if (error) {
reject(error);
} else {
fulfill();
}
});
});
}
scan(serviceUUIDs, seconds, allowDuplicates, scanningOptions = {}) {
return new Promise((fulfill, reject) => {
if (allowDuplicates == null) {
allowDuplicates = false;
}
// (ANDROID) Match as many advertisement per filter as hw could allow
// dependes on current capability and availability of the resources in hw.
if (scanningOptions.numberOfMatches == null) {
scanningOptions.numberOfMatches = 3;
}
// (ANDROID) Defaults to MATCH_MODE_AGGRESSIVE
if (scanningOptions.matchMode == null) {
scanningOptions.matchMode = 1;
}
// (ANDROID) Defaults to SCAN_MODE_LOW_POWER on android
if (scanningOptions.scanMode == null) {
scanningOptions.scanMode = 0;
}
if (scanningOptions.reportDelay == null) {
scanningOptions.reportDelay = 0;
}
bleManager.scan(
serviceUUIDs,
seconds,
allowDuplicates,
scanningOptions,
error => {
if (error) {
reject(error);
} else {
fulfill();
}
}
);
});
}
stopScan() {
return new Promise((fulfill, reject) => {
bleManager.stopScan(error => {
if (error != null) {
reject(error);
} else {
fulfill();
}
});
});
}
enableBluetooth() {
return new Promise((fulfill, reject) => {
bleManager.enableBluetooth(error => {
if (error != null) {
reject(error);
} else {
fulfill();
}
});
});
}
getConnectedPeripherals(serviceUUIDs) {
return new Promise((fulfill, reject) => {
bleManager.getConnectedPeripherals(serviceUUIDs, (error, result) => {
if (error) {
reject(error);
} else {
if (result != null) {
fulfill(result);
} else {
fulfill([]);
}
}
});
});
}
getBondedPeripherals() {
return new Promise((fulfill, reject) => {
bleManager.getBondedPeripherals((error, result) => {
if (error) {
reject(error);
} else {
if (result != null) {
fulfill(result);
} else {
fulfill([]);
}
}
});
});
}
getDiscoveredPeripherals() {
return new Promise((fulfill, reject) => {
bleManager.getDiscoveredPeripherals((error, result) => {
if (error) {
reject(error);
} else {
if (result != null) {
fulfill(result);
} else {
fulfill([]);
}
}
});
});
}
removePeripheral(peripheralId) {
return new Promise((fulfill, reject) => {
bleManager.removePeripheral(peripheralId, error => {
if (error) {
reject(error);
} else {
fulfill();
}
});
});
}
isPeripheralConnected(peripheralId, serviceUUIDs) {
return this.getConnectedPeripherals(serviceUUIDs).then(result => {
if (
result.find(p => {
return p.id === peripheralId;
})
) {
return true;
} else {
return false;
}
});
}
requestConnectionPriority(peripheralId, connectionPriority) {
return new Promise((fulfill, reject) => {
bleManager.requestConnectionPriority(
peripheralId,
connectionPriority,
(error, status) => {
if (error) {
reject(error);
} else {
fulfill(status);
}
}
);
});
}
requestMTU(peripheralId, mtu) {
return new Promise((fulfill, reject) => {
bleManager.requestMTU(peripheralId, mtu, (error, mtu) => {
if (error) {
reject(error);
} else {
fulfill(mtu);
}
});
});
}
}
module.exports = new BleManager();
### Before open an issue
- Check the closed issues, your question maybe is not new.
- We can't debug your physical devices.
- If the library is not working 99% you did something wrong, in the code or in the phone permissions.
### Version
Tell us which versions you are using:
- react-native-ble-manager v?.?.?
- react-native v?.?
- iOS/Android v.?
### Expected behaviour
Tell us what should happen
### Actual behaviour
Tell us what happens instead
### Steps to reproduce
1.
2.
3.
### Stack trace and console log
Hint: it would help a lot if you enable the debugger ("Pause on exceptions" in the "Source" panel of Chrome dev tools) and spot the place where the error is thrown
```
```
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2014-2016 Don Coleman
Copyright 2016 Innove
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
# react-native-ble-manager
[![npm version](https://img.shields.io/npm/v/react-native-ble-manager.svg?style=flat)](https://www.npmjs.com/package/react-native-ble-manager)
[![npm downloads](https://img.shields.io/npm/dm/react-native-ble-manager.svg?style=flat)](https://www.npmjs.com/package/react-native-ble-manager)
[![GitHub issues](https://img.shields.io/github/issues/innoveit/react-native-ble-manager.svg?style=flat)](https://github.com/innoveit/react-native-ble-manager/issues)
This is a porting of https://github.com/don/cordova-plugin-ble-central project to React Native.
## Requirements
RN 0.60+
RN 0.40-0.59 supported until 6.7.X
RN 0.30-0.39 supported until 2.4.3
## Supported Platforms
- iOS 8+
- Android (API 19+)
## Install
```shell
npm i --save react-native-ble-manager
```
The library support the autolink feature.
##### Android - Update Manifest
```xml
// file: android/app/src/main/AndroidManifest.xml
...
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
...
```
##### iOS - Update Info.plist
In iOS >= 13 you need to add the `NSBluetoothAlwaysUsageDescription` string key.
## Note
- Remember to use the `start` method before anything.
- If you have problem with old devices try avoid to connect/read/write to a peripheral during scan.
- Android API >= 23 require the ACCESS_COARSE_LOCATION permission to scan for peripherals. React Native >= 0.33 natively support PermissionsAndroid like in the example.
- Before write, read or start notification you need to call `retrieveServices` method
## Example
The easiest way to test is simple make your AppRegistry point to our example component, like this:
```javascript
// in your index.ios.js or index.android.js
import React, { Component } from "react";
import { AppRegistry } from "react-native";
import App from "react-native-ble-manager/example/App"; //<-- simply point to the example js!
AppRegistry.registerComponent("MyAwesomeApp", () => App);
```
Or, you can still look into the whole [example](https://github.com/innoveit/react-native-ble-manager/tree/master/example) folder for a standalone project.
## Methods
### start(options)
Init the module.
Returns a `Promise` object.
Don't call this multiple times.
**Arguments**
- `options` - `JSON`
The parameter is optional the configuration keys are:
- `showAlert` - `Boolean` - [iOS only] Show or hide the alert if the bluetooth is turned off during initialization
- `restoreIdentifierKey` - `String` - [iOS only] Unique key to use for CoreBluetooth state restoration
- `queueIdentifierKey` - `String` - [iOS only] Unique key to use for a queue identifier on which CoreBluetooth events will be dispatched
- `forceLegacy` - `Boolean` - [Android only] Force to use the LegacyScanManager
**Examples**
```js
BleManager.start({ showAlert: false }).then(() => {
// Success code
console.log("Module initialized");
});
```
### scan(serviceUUIDs, seconds, allowDuplicates, scanningOptions)
Scan for availables peripherals.
Returns a `Promise` object.
**Arguments**
- `serviceUUIDs` - `Array of String` - the UUIDs of the services to looking for. On Android the filter works only for 5.0 or newer.
- `seconds` - `Integer` - the amount of seconds to scan.
- `allowDuplicates` - `Boolean` - [iOS only] allow duplicates in device scanning
- `scanningOptions` - `JSON` - [Android only] after Android 5.0, user can control specific ble scan behaviors:
- `numberOfMatches` - `Number` - corresponding to [`setNumOfMatches`](<https://developer.android.com/reference/android/bluetooth/le/ScanSettings.Builder.html#setNumOfMatches(int)>)
- `matchMode` - `Number` - corresponding to [`setMatchMode`](<https://developer.android.com/reference/android/bluetooth/le/ScanSettings.Builder.html#setMatchMode(int)>)
- `scanMode` - `Number` - corresponding to [`setScanMode`](<https://developer.android.com/reference/android/bluetooth/le/ScanSettings.Builder.html#setScanMode(int)>)
- `reportDelay` - `Number` - corresponding to [`setReportDelay`](<https://developer.android.com/reference/android/bluetooth/le/ScanSettings.Builder.html#setReportDelay(long)>)
**Examples**
```js
BleManager.scan([], 5, true).then(() => {
// Success code
console.log("Scan started");
});
```
### stopScan()
Stop the scanning.
Returns a `Promise` object.
**Examples**
```js
BleManager.stopScan().then(() => {
// Success code
console.log("Scan stopped");
});
```
### connect(peripheralId)
Attempts to connect to a peripheral. In many case if you can't connect you have to scan for the peripheral before.
Returns a `Promise` object.
> In iOS, attempts to connect to a peripheral do not time out (please see [Apple's doc](https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/1518766-connect)), so you might need to set a timer explicitly if you don't want this behavior.
**Arguments**
- `peripheralId` - `String` - the id/mac address of the peripheral to connect.
**Examples**
```js
BleManager.connect("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")
.then(() => {
// Success code
console.log("Connected");
})
.catch((error) => {
// Failure code
console.log(error);
});
```
### disconnect(peripheralId, force)
Disconnect from a peripheral.
Returns a `Promise` object.
**Arguments**
- `peripheralId` - `String` - the id/mac address of the peripheral to disconnect.
- `force` - `boolean` - [Android only] defaults to true, if true force closes gatt
connection and send the BleManagerDisconnectPeripheral
event immediately to Javascript, else disconnects the
connection and waits for [`disconnected state`](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_DISCONNECTED) to
[`close the gatt connection`](<https://developer.android.com/reference/android/bluetooth/BluetoothGatt#close()>)
and then sends the BleManagerDisconnectPeripheral to the
Javascript
**Examples**
```js
BleManager.disconnect("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")
.then(() => {
// Success code
console.log("Disconnected");
})
.catch((error) => {
// Failure code
console.log(error);
});
```
### enableBluetooth() [Android only]
Create the request to the user to activate the bluetooth.
Returns a `Promise` object.
**Examples**
```js
BleManager.enableBluetooth()
.then(() => {
// Success code
console.log("The bluetooth is already enabled or the user confirm");
})
.catch((error) => {
// Failure code
console.log("The user refuse to enable bluetooth");
});
```
### checkState()
Force the module to check the state of BLE and trigger a BleManagerDidUpdateState event.
**Examples**
```js
BleManager.checkState();
```
### startNotification(peripheralId, serviceUUID, characteristicUUID)
Start the notification on the specified characteristic, you need to call `retrieveServices` method before.
Returns a `Promise` object.
**Arguments**
- `peripheralId` - `String` - the id/mac address of the peripheral.
- `serviceUUID` - `String` - the UUID of the service.
- `characteristicUUID` - `String` - the UUID of the characteristic.
**Examples**
```js
BleManager.startNotification(
"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
)
.then(() => {
// Success code
console.log("Notification started");
})
.catch((error) => {
// Failure code
console.log(error);
});
```
### startNotificationUseBuffer(peripheralId, serviceUUID, characteristicUUID, buffer) [Android only]
Start the notification on the specified characteristic, you need to call `retrieveServices` method before. The buffer will collect a number or messages from the server and then emit once the buffer count it reached. Helpful to reducing the number or js bridge crossings when a characteristic is sending a lot of messages.
Returns a `Promise` object.
**Arguments**
- `peripheralId` - `String` - the id/mac address of the peripheral.
- `serviceUUID` - `String` - the UUID of the service.
- `characteristicUUID` - `String` - the UUID of the characteristic.
- `buffer` - `Integer` - a number of message to buffer prior to emit for the characteristic.
**Examples**
```js
BleManager.startNotification(
"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
1234
)
.then(() => {
// Success code
console.log("Notification started");
})
.catch((error) => {
// Failure code
console.log(error);
});
```
### stopNotification(peripheralId, serviceUUID, characteristicUUID)
Stop the notification on the specified characteristic.
Returns a `Promise` object.
**Arguments**
- `peripheralId` - `String` - the id/mac address of the peripheral.
- `serviceUUID` - `String` - the UUID of the service.
- `characteristicUUID` - `String` - the UUID of the characteristic.
### read(peripheralId, serviceUUID, characteristicUUID)
Read the current value of the specified characteristic, you need to call `retrieveServices` method before.
Returns a `Promise` object.
**Arguments**
- `peripheralId` - `String` - the id/mac address of the peripheral.
- `serviceUUID` - `String` - the UUID of the service.
- `characteristicUUID` - `String` - the UUID of the characteristic.
**Examples**
```js
BleManager.read(
"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
)
.then((readData) => {
// Success code
console.log("Read: " + readData);
const buffer = Buffer.Buffer.from(readData); //https://github.com/feross/buffer#convert-arraybuffer-to-buffer
const sensorData = buffer.readUInt8(1, true);
})
.catch((error) => {
// Failure code
console.log(error);
});
```
### write(peripheralId, serviceUUID, characteristicUUID, data, maxByteSize)
Write with response to the specified characteristic, you need to call `retrieveServices` method before.
Returns a `Promise` object.
**Arguments**
- `peripheralId` - `String` - the id/mac address of the peripheral.
- `serviceUUID` - `String` - the UUID of the service.
- `characteristicUUID` - `String` - the UUID of the characteristic.
- `data` - `Byte array` - the data to write.
- `maxByteSize` - `Integer` - specify the max byte size before splitting message
**Data preparation**
If your data is not in byte array format you should convert it first. For strings you can use `convert-string` or other npm package in order to achieve that.
Install the package first:
```shell
npm install convert-string
```
Then use it in your application:
```js
// Import/require in the beginning of the file
import { stringToBytes } from "convert-string";
// Convert data to byte array before write/writeWithoutResponse
const data = stringToBytes(yourStringData);
```
Feel free to use other packages or google how to convert into byte array if your data has other format.
**Examples**
```js
BleManager.write(
"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
data
)
.then(() => {
// Success code
console.log("Write: " + data);
})
.catch((error) => {
// Failure code
console.log(error);
});
```
### writeWithoutResponse(peripheralId, serviceUUID, characteristicUUID, data, maxByteSize, queueSleepTime)
Write without response to the specified characteristic, you need to call `retrieveServices` method before.
Returns a `Promise` object.
**Arguments**
- `peripheralId` - `String` - the id/mac address of the peripheral.
- `serviceUUID` - `String` - the UUID of the service.
- `characteristicUUID` - `String` - the UUID of the characteristic.
- `data` - `Byte array` - the data to write.
- `maxByteSize` - `Integer` - (Optional) specify the max byte size
- `queueSleepTime` - `Integer` - (Optional) specify the wait time before each write if the data is greater than maxByteSize
**Data preparation**
If your data is not in byte array format check info for the write function above.
**Example**
```js
BleManager.writeWithoutResponse(
"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
data
)
.then(() => {
// Success code
console.log("Writed: " + data);
})
.catch((error) => {
// Failure code
console.log(error);
});
```
### readRSSI(peripheralId)
Read the current value of the RSSI.
Returns a `Promise` object.
**Arguments**
- `peripheralId` - `String` - the id/mac address of the peripheral.
**Examples**
```js
BleManager.readRSSI("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")
.then((rssi) => {
// Success code
console.log("Current RSSI: " + rssi);
})
.catch((error) => {
// Failure code
console.log(error);
});
```
### requestConnectionPriority(peripheralId, connectionPriority) [Android only API 21+]
Request a connection parameter update.
Returns a `Promise` object.
**Arguments**
- `peripheralId` - `String` - the id/mac address of the peripheral.
- `connectionPriority` - `Integer` - the connection priority to be requested, as follows:
- 0 - balanced priority connection
- 1 - high priority connection
- 2 - low power priority connection
**Examples**
```js
BleManager.requestConnectionPriority("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", 1)
.then((status) => {
// Success code
console.log("Requested connection priority");
})
.catch((error) => {
// Failure code
console.log(error);
});
```
### requestMTU(peripheralId, mtu) [Android only API 21+]
Request an MTU size used for a given connection.
Returns a `Promise` object.
**Arguments**
- `peripheralId` - `String` - the id/mac address of the peripheral.
- `mtu` - `Integer` - the MTU size to be requested in bytes.
**Examples**
```js
BleManager.requestMTU("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", 512)
.then((mtu) => {
// Success code
console.log("MTU size changed to " + mtu + " bytes");
})
.catch((error) => {
// Failure code
console.log(error);
});
```
### retrieveServices(peripheralId[, serviceUUIDs])
Retrieve the peripheral's services and characteristics.
Returns a `Promise` object.
**Arguments**
- `peripheralId` - `String` - the id/mac address of the peripheral.
- `serviceUUIDs` - `String[]` - [iOS only] only retrieve these services.
**Examples**
```js
BleManager.retrieveServices("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX").then(
(peripheralInfo) => {
// Success code
console.log("Peripheral info:", peripheralInfo);
}
);
```
### refreshCache(peripheralId) [Android only]
refreshes the peripheral's services and characteristics cache
Returns a `Promise` object.
**Arguments**
- `peripheralId` - `String` - the id/mac address of the peripheral.
**Examples**
```js
BleManager.refreshCache("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")
.then((peripheralInfo) => {
// Success code
console.log("cache refreshed!");
})
.catch((error) => {
console.error(error);
});
```
### getConnectedPeripherals(serviceUUIDs)
Return the connected peripherals.
Returns a `Promise` object.
**Arguments**
- `serviceUUIDs` - `Array of String` - the UUIDs of the services to looking for.
**Examples**
```js
BleManager.getConnectedPeripherals([]).then((peripheralsArray) => {
// Success code
console.log("Connected peripherals: " + peripheralsArray.length);
});
```
### createBond(peripheralId,peripheralPin) [Android only]
Start the bonding (pairing) process with the remote device. If you pass peripheralPin(optional), bonding will be auto(without manual entering pin)
Returns a `Promise` object. The promise is resolved when either `new bond successfully created` or `bond already existed`, otherwise it will be rejected.
**Examples**
```js
BleManager.createBond(peripheralId)
.then(() => {
console.log("createBond success or there is already an existing one");
})
.catch(() => {
console.log("fail to bond");
});
```
### removeBond(peripheralId) [Android only]
Remove a paired device.
Returns a `Promise` object.
**Examples**
```js
BleManager.removeBond(peripheralId)
.then(() => {
console.log("removeBond success");
})
.catch(() => {
console.log("fail to remove the bond");
});
```
### getBondedPeripherals() [Android only]
Return the bonded peripherals.
Returns a `Promise` object.
**Examples**
```js
BleManager.getBondedPeripherals([]).then((bondedPeripheralsArray) => {
// Each peripheral in returned array will have id and name properties
console.log("Bonded peripherals: " + bondedPeripheralsArray.length);
});
```
### getDiscoveredPeripherals()
Return the discovered peripherals after a scan.
Returns a `Promise` object.
**Examples**
```js
BleManager.getDiscoveredPeripherals([]).then((peripheralsArray) => {
// Success code
console.log("Discovered peripherals: " + peripheralsArray.length);
});
```
### removePeripheral(peripheralId) [Android only]
Removes a disconnected peripheral from the cached list.
It is useful if the device is turned off, because it will be re-discovered upon turning on again.
Returns a `Promise` object.
**Arguments**
- `peripheralId` - `String` - the id/mac address of the peripheral.
### isPeripheralConnected(peripheralId, serviceUUIDs)
Check whether a specific peripheral is connected and return `true` or `false`.
Returns a `Promise` object.
**Examples**
```js
BleManager.isPeripheralConnected(
"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
[]
).then((isConnected) => {
if (isConnected) {
console.log("Peripheral is connected!");
} else {
console.log("Peripheral is NOT connected!");
}
});
```
## Events
### BleManagerStopScan
The scanning for peripherals is ended.
**Arguments**
- `none`
**Examples**
```js
bleManagerEmitter.addListener("BleManagerStopScan", () => {
// Scanning is stopped
});
```
### BleManagerDidUpdateState
The BLE change state.
**Arguments**
- `state` - `String` - the new BLE state ('on'/'off').
**Examples**
```js
bleManagerEmitter.addListener("BleManagerDidUpdateState", (args) => {
// The new state: args.state
});
```
### BleManagerDiscoverPeripheral
The scanning find a new peripheral.
**Arguments**
- `id` - `String` - the id of the peripheral
- `name` - `String` - the name of the peripheral
- `rssi` - `Number` - the RSSI value
- `advertising` - `JSON` - the advertising payload, here are some examples:
- `isConnectable` - `Boolean`
- `serviceUUIDs` - `Array of String`
- `manufacturerData` - `JSON` - contains the raw `bytes` and `data` (Base64 encoded string)
- `serviceData` - `JSON` - contains the raw `bytes` and `data` (Base64 encoded string)
- `txPowerLevel` - `Int`
**Examples**
```js
bleManagerEmitter.addListener("BleManagerDiscoverPeripheral", (args) => {
// The id: args.id
// The name: args.name
});
```
### BleManagerDidUpdateValueForCharacteristic
A characteristic notify a new value.
**Arguments**
- `value``Array` — the read value
- `peripheral``String` — the id of the peripheral
- `characteristic``String` — the UUID of the characteristic
- `service``String` — the UUID of the characteristic
> Event will only be emitted after successful `startNotification`.
**Example**
```js
import { bytesToString } from "convert-string";
import { NativeModules, NativeEventEmitter } from "react-native";
const BleManagerModule = NativeModules.BleManager;
const bleManagerEmitter = new NativeEventEmitter(BleManagerModule);
async function connectAndPrepare(peripheral, service, characteristic) {
// Connect to device
await BleManager.connect(peripheral);
// Before startNotification you need to call retrieveServices
await BleManager.retrieveServices(peripheral);
// To enable BleManagerDidUpdateValueForCharacteristic listener
await BleManager.startNotification(peripheral, service, characteristic);
// Add event listener
bleManagerEmitter.addListener(
"BleManagerDidUpdateValueForCharacteristic",
({ value, peripheral, characteristic, service }) => {
// Convert bytes array to string
const data = bytesToString(value);
console.log(`Recieved ${data} for characteristic ${characteristic}`);
}
);
// Actions triggereng BleManagerDidUpdateValueForCharacteristic event
}
```
### BleManagerConnectPeripheral
A peripheral was connected.
**Arguments**
- `peripheral` - `String` - the id of the peripheral
- `status` - `Number` - [Android only] connect [`reasons`](<https://developer.android.com/reference/android/bluetooth/BluetoothGattCallback.html#onConnectionStateChange(android.bluetooth.BluetoothGatt,%20int,%20int)>)
### BleManagerDisconnectPeripheral
A peripheral was disconnected.
**Arguments**
- `peripheral` - `String` - the id of the peripheral
- `status` - `Number` - [Android only] disconnect [`reasons`](<https://developer.android.com/reference/android/bluetooth/BluetoothGattCallback.html#onConnectionStateChange(android.bluetooth.BluetoothGatt,%20int,%20int)>)
### BleManagerCentralManagerWillRestoreState [iOS only]
This is fired when [`centralManager:WillRestoreState:`](https://developer.apple.com/documentation/corebluetooth/cbcentralmanagerdelegate/1518819-centralmanager) is called (app relaunched in the background to handle a bluetooth event).
**Arguments**
- `peripherals` - `Array` - an array of previously connected peripherals.
_For more on performing long-term bluetooth actions in the background:_
[iOS Bluetooth State Preservation and Restoration](https://developer.apple.com/library/archive/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/CoreBluetoothBackgroundProcessingForIOSApps/PerformingTasksWhileYourAppIsInTheBackground.html#//apple_ref/doc/uid/TP40013257-CH7-SW10)
[iOS Relaunch Conditions](https://developer.apple.com/library/archive/qa/qa1962/_index.html)
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":react-native-ble-manager" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/../../../android" external.system.id="GRADLE" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
<option name="GRADLE_PROJECT_PATH" value=":react-native-ble-manager" />
<option name="LAST_SUCCESSFUL_SYNC_AGP_VERSION" value="3.5.3" />
<option name="LAST_KNOWN_AGP_VERSION" value="3.5.3" />
</configuration>
</facet>
<facet type="android" name="Android">
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<afterSyncTasks>
<task>generateDebugSources</task>
</afterSyncTasks>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/build/generated/res/resValues/debug" />
<option name="TEST_RES_FOLDERS_RELATIVE_PATH" value="" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
<option name="PROJECT_TYPE" value="1" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7">
<output url="file://$MODULE_DIR$/build/intermediates/javac/debug/classes" />
<output-test url="file://$MODULE_DIR$/build/intermediates/javac/debugUnitTest/classes" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/ap_generated_sources/debug/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/debug/compileDebugAidl/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/renderscript_source_output_dir/debug/compileDebugRenderscript/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/ap_generated_sources/debugAndroidTest/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/debugAndroidTest/compileDebugAndroidTestAidl/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/renderscript_source_output_dir/debugAndroidTest/compileDebugAndroidTestRenderscript/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/ap_generated_sources/debugUnitTest/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build" />
</content>
<orderEntry type="jdk" jdkName="Android API 29 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Gradle: com.facebook.infer.annotation:infer-annotation:0.11.2@jar" level="project" />
<orderEntry type="library" name="Gradle: com.google.code.findbugs:jsr305:3.0.2@jar" level="project" />
<orderEntry type="library" name="Gradle: com.facebook.yoga:proguard-annotations:1.14.1@jar" level="project" />
<orderEntry type="library" name="Gradle: javax.inject:javax.inject:1@jar" level="project" />
<orderEntry type="library" name="Gradle: androidx.collection:collection:1.0.0@jar" level="project" />
<orderEntry type="library" name="Gradle: androidx.lifecycle:lifecycle-common:2.0.0@jar" level="project" />
<orderEntry type="library" name="Gradle: androidx.arch.core:core-common:2.0.0@jar" level="project" />
<orderEntry type="library" name="Gradle: androidx.annotation:annotation:1.0.0@jar" level="project" />
<orderEntry type="library" name="Gradle: com.facebook.soloader:nativeloader:0.8.2@jar" level="project" />
<orderEntry type="library" name="Gradle: com.squareup.okhttp3:okhttp-urlconnection:3.12.1@jar" level="project" />
<orderEntry type="library" name="Gradle: com.squareup.okhttp3:okhttp:3.12.1@jar" level="project" />
<orderEntry type="library" name="Gradle: com.squareup.okio:okio:1.15.0@jar" level="project" />
<orderEntry type="library" name="Gradle: com.facebook.fbjni:fbjni-java-only:0.0.3@jar" level="project" />
<orderEntry type="library" name="Gradle: com.facebook.react:react-native:0.63.3@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.appcompat:appcompat:1.0.2@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.fragment:fragment:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.vectordrawable:vectordrawable-animated:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.legacy:legacy-support-core-ui:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.swiperefreshlayout:swiperefreshlayout:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.legacy:legacy-support-core-utils:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.vectordrawable:vectordrawable:1.0.1@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.loader:loader:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.viewpager:viewpager:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.coordinatorlayout:coordinatorlayout:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.drawerlayout:drawerlayout:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.slidingpanelayout:slidingpanelayout:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.customview:customview:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.asynclayoutinflater:asynclayoutinflater:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.core:core:1.0.1@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.versionedparcelable:versionedparcelable:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.cursoradapter:cursoradapter:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.interpolator:interpolator:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.lifecycle:lifecycle-runtime:2.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.documentfile:documentfile:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.localbroadcastmanager:localbroadcastmanager:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.print:print:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.lifecycle:lifecycle-viewmodel:2.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.lifecycle:lifecycle-livedata:2.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.lifecycle:lifecycle-livedata-core:2.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.arch.core:core-runtime:2.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: com.facebook.fresco:fresco:2.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: com.facebook.fresco:fbcore:2.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: com.facebook.fresco:drawee:2.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: com.facebook.fresco:imagepipeline:2.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: com.facebook.fresco:imagepipeline-base:2.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: com.facebook.soloader:soloader:0.8.2@aar" level="project" />
<orderEntry type="library" name="Gradle: com.facebook.soloader:annotation:0.8.2@aar" level="project" />
<orderEntry type="library" name="Gradle: com.facebook.fresco:nativeimagefilters:2.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: com.facebook.fresco:nativeimagetranscoder:2.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: com.facebook.fresco:imagepipeline-okhttp3:2.0.0@aar" level="project" />
</component>
</module>
\ No newline at end of file
buildscript {
// The Android Gradle plugin is only required when opening the android folder stand-alone.
// This avoids unnecessary downloads and potential conflicts when the library is included as a
// module dependency in an application project.
if (project == rootProject) {
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.6.1")
}
}
}
apply plugin: 'com.android.library'
def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}
android {
compileSdkVersion safeExtGet("compileSdkVersion", 29)
defaultConfig {
minSdkVersion safeExtGet("minSdkVersion", 19)
}
lintOptions {
abortOnError false
}
}
repositories {
mavenCentral()
google()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
// To test url "$rootDir/../example/node_modules/react-native/android"
}
}
dependencies {
implementation "com.facebook.react:react-native:+"
// implementation "org.jetbrains.trove4j: trove4j: 20160824"
}
o/classes
File added
o/classes
File added
o/classes
File added
/**
* Automatically generated file. DO NOT MODIFY
*/
package it.innove;
public final class BuildConfig {
public static final boolean DEBUG = Boolean.parseBoolean("true");
public static final String LIBRARY_PACKAGE_NAME = "it.innove";
public static final String BUILD_TYPE = "debug";
public static final int VERSION_CODE = -1;
public static final String VERSION_NAME = "";
}
/**
* Automatically generated file. DO NOT MODIFY
*/
package it.innove;
public final class BuildConfig {
public static final boolean DEBUG = false;
public static final String LIBRARY_PACKAGE_NAME = "it.innove";
/**
* @deprecated APPLICATION_ID is misleading in libraries. For the library package name use LIBRARY_PACKAGE_NAME
*/
@Deprecated
public static final String APPLICATION_ID = "it.innove";
public static final String BUILD_TYPE = "release";
public static final String FLAVOR = "";
public static final int VERSION_CODE = -1;
public static final String VERSION_NAME = "";
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="it.innove" >
<uses-sdk android:minSdkVersion="23" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-feature
android:name="android.hardware.bluetooth_le"
android:required="false" />
</manifest>
\ No newline at end of file
{
"version": 1,
"applicationId": "it.innove",
"variantType": "LIBRARY",
"elements": [
{
"outputType": {
"type": "AAPT_FRIENDLY_MERGED_MANIFESTS"
},
"apkData": {
"type": "MAIN",
"splits": [],
"versionCode": -1,
"outputFile": "react-native-ble-manager-debug.aar",
"fullName": "debug",
"baseName": "debug",
"dirName": ""
},
"path": "AndroidManifest.xml",
"properties": {
"packageId": "it.innove",
"split": ""
}
}
]
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="it.innove" >
<uses-sdk android:minSdkVersion="23" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-feature
android:name="android.hardware.bluetooth_le"
android:required="false" />
</manifest>
\ No newline at end of file
[{"outputType":{"type":"AAPT_FRIENDLY_MERGED_MANIFESTS"},"apkData":{"type":"MAIN","splits":[],"versionCode":-1,"enabled":true,"outputFile":"react-native-ble-manager-release.aar","fullName":"release","baseName":"release"},"path":"AndroidManifest.xml","properties":{"packageId":"it.innove","split":""}}]
\ No newline at end of file
{}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment