react-native-ble-manager
Advanced tools
Comparing version 8.7.0 to 8.8.0
154
index.d.ts
declare module "react-native-ble-manager" { | ||
// android states: https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#EXTRA_STATE | ||
// ios states: https://developer.apple.com/documentation/corebluetooth/cbcentralmanagerstate | ||
export enum BleState { | ||
Unknown = 'unknown', // [iOS only] | ||
Resetting = 'resetting', // [iOS only] | ||
Unsupported = 'unsupported', | ||
Unauthorized = 'unauthorized', // [iOS only] | ||
On = 'on', | ||
Off = 'off', | ||
TurningOn = 'turning_on', // [android only] | ||
TurningOff = 'turning_off', // [android only] | ||
} | ||
export interface Peripheral { | ||
@@ -12,3 +26,4 @@ id: string; | ||
localName?: string; | ||
manufacturerData?: any; | ||
manufacturerData?: CustomAdvertisingData, | ||
serviceData?: CustomAdvertisingData, | ||
serviceUUIDs?: string[]; | ||
@@ -18,7 +33,13 @@ txPowerLevel?: number; | ||
export interface CustomAdvertisingData { | ||
CDVType : 'ArrayBuffer', | ||
bytes: Uint8Array, | ||
data: string // base64-encoded string of the data | ||
} | ||
export interface StartOptions { | ||
showAlert?: boolean; | ||
restoreIdentifierKey?: string; | ||
queueIdentifierKey?: string; | ||
forceLegacy?: boolean; | ||
showAlert?: boolean; // [iOS only] | ||
restoreIdentifierKey?: string; // [iOS only] | ||
queueIdentifierKey?: string; // [iOS only] | ||
forceLegacy?: boolean; // [android only] | ||
} | ||
@@ -28,12 +49,50 @@ | ||
// [android only] | ||
// https://developer.android.com/reference/android/bluetooth/le/ScanSettings | ||
export interface ScanOptions { | ||
numberOfMatches?: number; | ||
matchMode?: number; | ||
callbackType?: number; | ||
scanMode?: number; | ||
numberOfMatches?: BleScanMatchCount; | ||
matchMode?: BleScanMatchMode; | ||
callbackType?: BleScanCallbackType; | ||
scanMode?: BleScanMode; | ||
reportDelay?: number; | ||
phy?: number; | ||
phy?: BleScanPhyMode; | ||
legacy?: boolean; | ||
} | ||
// [android only] | ||
export enum BleScanMode { | ||
Opportunistic = -1, | ||
LowPower = 0, | ||
Balanced = 1, | ||
LowLatency = 2, | ||
} | ||
// [android only] | ||
export enum BleScanMatchMode { | ||
Aggressive = 1, | ||
Sticky = 2, | ||
} | ||
// [android only] | ||
export enum BleScanCallbackType { | ||
AllMatches = 1, | ||
FirstMatch = 2, | ||
MatchLost = 4, | ||
} | ||
// [android only] | ||
export enum BleScanMatchCount { | ||
OneAdvertisement = 1, | ||
FewAdvertisements = 2, | ||
MaxAdvertisements = 3, | ||
} | ||
// [android only] | ||
export enum BleScanPhyMode { | ||
LE_1M = 1, | ||
LE_2M = 2, | ||
LE_CODED = 3, | ||
ALL_SUPPORTED = 255, | ||
} | ||
export function scan( | ||
@@ -51,3 +110,5 @@ serviceUUIDs: string[], | ||
): Promise<void>; | ||
export function checkState(): void; | ||
export function startNotification( | ||
@@ -59,3 +120,3 @@ peripheralID: string, | ||
/// Android only | ||
// [android only] | ||
export function startNotificationUseBuffer( | ||
@@ -79,2 +140,3 @@ peripheralID: string, | ||
): Promise<any>; | ||
export function write( | ||
@@ -87,2 +149,3 @@ peripheralID: string, | ||
): Promise<void>; | ||
export function writeWithoutResponse( | ||
@@ -97,3 +160,3 @@ peripheralID: string, | ||
export function readRSSI(peripheralID: string): Promise<void>; | ||
export function readRSSI(peripheralID: string): Promise<number>; | ||
@@ -103,3 +166,5 @@ export function getConnectedPeripherals( | ||
): Promise<Peripheral[]>; | ||
export function getDiscoveredPeripherals(): Promise<Peripheral[]>; | ||
export function isPeripheralConnected( | ||
@@ -116,10 +181,15 @@ peripheralID: string, | ||
} | ||
// [Android only 21+] | ||
export function requestConnectionPriority( | ||
peripheralID: string, | ||
connectionPriority: ConnectionPriority | ||
): Promise<void>; | ||
/// Android only | ||
): Promise<boolean>; | ||
// [Android only] | ||
export function enableBluetooth(): Promise<void>; | ||
// [Android only] | ||
export function refreshCache(peripheralID: string): Promise<void>; | ||
// [Android only API 21+] | ||
@@ -132,4 +202,7 @@ export function requestMTU(peripheralID: string, mtu: number): Promise<number>; | ||
): Promise<void>; | ||
export function removeBond(peripheralID: string): Promise<void>; | ||
export function getBondedPeripherals(): Promise<Peripheral[]>; | ||
export function removePeripheral(peripheralID: string): Promise<void>; | ||
@@ -179,2 +252,55 @@ | ||
): Promise<PeripheralInfo>; | ||
export enum BleEventType { | ||
BleManagerDidUpdateState = 'BleManagerDidUpdateState', | ||
BleManagerStopScan = 'BleManagerStopScan', | ||
BleManagerDiscoverPeripheral = 'BleManagerDiscoverPeripheral', | ||
BleManagerDidUpdateValueForCharacteristic = 'BleManagerDidUpdateValueForCharacteristic', | ||
BleManagerConnectPeripheral = 'BleManagerConnectPeripheral', | ||
BleManagerDisconnectPeripheral = 'BleManagerDisconnectPeripheral', | ||
BleManagerPeripheralDidBond = 'BleManagerPeripheralDidBond', // [Android only] | ||
BleManagerCentralManagerWillRestoreState = 'BleManagerCentralManagerWillRestoreState', // [iOS only] | ||
BleManagerDidUpdateNotificationStateFor = 'BleManagerDidUpdateNotificationStateFor', // [iOS only] | ||
} | ||
export interface BleStopScanEvent { | ||
status?: number; // [iOS only] | ||
} | ||
export interface BleManagerDidUpdateStateEvent { | ||
state: BleState; | ||
} | ||
export interface BleConnectPeripheralEvent { | ||
readonly peripheral: string; // peripheral id | ||
readonly status?: number; // [android only] | ||
} | ||
export type BleDiscoverPeripheralEvent = Peripheral; | ||
// [Android only] | ||
export type BleBondedPeripheralEvent = Peripheral; | ||
export interface BleDisconnectPeripheralEvent { | ||
readonly peripheral: string; // peripheral id | ||
readonly status?: number; // [android only] disconnect reason. | ||
readonly domain?: string; // [iOS only] disconnect error domain. | ||
readonly code?: number; // [iOS only] disconnect error code. | ||
} | ||
export interface BleManagerDidUpdateValueForCharacteristicEvent { | ||
readonly characteristic: string; // characteristic UUID | ||
readonly peripheral: string; // peripheral id | ||
readonly service: string; // service UUID | ||
readonly value: Uint8Array; | ||
} | ||
// [iOS only] | ||
export interface BleManagerDidUpdateNotificationStateForEvent { | ||
readonly peripheral: string; // peripheral id | ||
readonly characteristic: string; // characteristic UUID | ||
readonly isNotifying: boolean; // is the characteristic notifying or not | ||
readonly domain: string; // error domain. | ||
readonly code: number; // error code. | ||
} | ||
} |
{ | ||
"name": "react-native-ble-manager", | ||
"version": "8.7.0", | ||
"version": "8.8.0", | ||
"description": "A BLE module for react native.", | ||
@@ -5,0 +5,0 @@ "main": "BleManager", |
@@ -444,3 +444,3 @@ # react-native-ble-manager | ||
Read the current value of the RSSI. | ||
Returns a `Promise` object. | ||
Returns a `Promise` object resolving with the updated RSSI value (`number`) if it succeeds. | ||
@@ -468,3 +468,3 @@ **Arguments** | ||
Request a connection parameter update. | ||
Returns a `Promise` object. | ||
Returns a `Promise` object which fulfills with the status of the request. | ||
@@ -713,3 +713,3 @@ **Arguments** | ||
- `state` - `String` - the new BLE state ('on'/'off'). | ||
- `state` - `String` - the new BLE state. can be one of `unknown` (iOS only), `resetting` (iOS only), `unsupported`, `unauthorized` (iOS only), `on`, `off`, `turning_on` (android only), `turning_off` (android only). | ||
@@ -716,0 +716,0 @@ **Examples** |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
221707
638