Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@capacitor-community/bluetooth-le

Package Overview
Dependencies
Maintainers
29
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@capacitor-community/bluetooth-le - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

android/local.properties

13

CHANGELOG.md

@@ -5,2 +5,15 @@ # Changelog

## [0.4.0](https://github.com/capacitor-community/bluetooth-le/compare/v0.3.0...v0.4.0) (2021-03-14)
### Features
* add localName to scanResult ([483ee0e](https://github.com/capacitor-community/bluetooth-le/commit/483ee0e9ad5edd0c7f36f40662af5b8262030c80))
### Bug Fixes
* **android:** always add txPower to scanResult ([7943cc8](https://github.com/capacitor-community/bluetooth-le/commit/7943cc8f4f877edcdf31d63cab1250490cad7542))
* **ios:** reject initialize call when Bluetooth permission is denied ([b5bb292](https://github.com/capacitor-community/bluetooth-le/commit/b5bb2927ee77182b7605fe7e19c533d4e53dd4de))
## [0.3.0](https://github.com/capacitor-community/bluetooth-le/compare/v0.2.0...v0.3.0) (2021-02-27)

@@ -7,0 +20,0 @@

48

dist/docs.json

@@ -14,3 +14,3 @@ {

"tags": [],
"docs": "Initialize Bluetooth Low Energy (BLE). If it fails, BLE might be unavailable on this device.\r\nOn Android it will ask for the location permission. On iOS it will ask for the Bluetooth permission.\r\nFor an example, see [usage](#usage).",
"docs": "Initialize Bluetooth Low Energy (BLE). If it fails, BLE might be unavailable on this device.\nOn **Android** it will ask for the location permission. On **iOS** it will ask for the Bluetooth permission.\nFor an example, see [usage](#usage).",
"complexTypes": [],

@@ -25,3 +25,3 @@ "slug": "initialize"

"tags": [],
"docs": "Reports whether BLE is enabled on this device.\r\nAlways returns `true` on web.",
"docs": "Reports whether BLE is enabled on this device.\nAlways returns `true` on **web**.",
"complexTypes": [],

@@ -47,3 +47,3 @@ "slug": "getenabled"

],
"docs": "Register a callback function that will be invoked when BLE is enabled (true) or disabled (false) on this device.\r\nNot available on web (the callback will never be invoked).",
"docs": "Register a callback function that will be invoked when BLE is enabled (true) or disabled (false) on this device.\nNot available on **web** (the callback will never be invoked).",
"complexTypes": [],

@@ -79,3 +79,3 @@ "slug": "startenablednotifications"

],
"docs": "Request a peripheral BLE device to interact with. This will scan for available devices according to the filters in the options and show a dialog to pick a device.\r\nFor an example, see [usage](#usage).",
"docs": "Request a peripheral BLE device to interact with. This will scan for available devices according to the filters in the options and show a dialog to pick a device.\nFor an example, see [usage](#usage).",
"complexTypes": [

@@ -113,3 +113,3 @@ "BleDevice",

],
"docs": "Start scanning for BLE devices to interact with according to the filters in the options. The callback will be invoked on each device that is found.\r\nScanning will continue until `stopLEScan` is called. For an example, see [usage](#usage).\r\n**NOTE**: Use with care on web platform, the required API is still behind a flag in most browsers.",
"docs": "Start scanning for BLE devices to interact with according to the filters in the options. The callback will be invoked on each device that is found.\nScanning will continue until `stopLEScan` is called. For an example, see [usage](#usage).\n**NOTE**: Use with care on **web** platform, the required API is still behind a flag in most browsers.",
"complexTypes": [

@@ -426,3 +426,3 @@ "RequestBleDeviceOptions",

"tags": [],
"docs": "ID of the device, which will be needed for further calls.\r\nOn Android this is the BLE MAC address.\r\nOn iOS and web it is an identifier.",
"docs": "ID of the device, which will be needed for further calls.\nOn **Android** this is the BLE MAC address.\nOn **iOS** and **web** it is an identifier.",
"complexTypes": [],

@@ -434,3 +434,3 @@ "type": "string"

"tags": [],
"docs": "Name of the device.",
"docs": "Name of the peripheral device.",
"complexTypes": [],

@@ -458,3 +458,3 @@ "type": "string | undefined"

"tags": [],
"docs": "Filter devices by service UUIDs.\r\nUUIDs have to be specified as 128 bit UUID strings in lowercase,\r\ne.g. ['0000180d-0000-1000-8000-00805f9b34fb']\r\nThere is a helper function to convert numbers to UUIDs.\r\ne.g. [numberToUUID(0x180f)]. (see [UUID format](#uuid-format))",
"docs": "Filter devices by service UUIDs.\nUUIDs have to be specified as 128 bit UUID strings in lowercase,\ne.g. ['0000180d-0000-1000-8000-00805f9b34fb']\nThere is a helper function to convert numbers to UUIDs.\ne.g. [numberToUUID(0x180f)]. (see [UUID format](#uuid-format))",
"complexTypes": [],

@@ -480,3 +480,3 @@ "type": "string[] | undefined"

"tags": [],
"docs": "For web, all services that will be used have to be listed under services or optionalServices,\r\ne.g. [numberToUUID(0x180f)] (see [UUID format](#uuid-format))",
"docs": "For **web**, all services that will be used have to be listed under services or optionalServices,\ne.g. [numberToUUID(0x180f)] (see [UUID format](#uuid-format))",
"complexTypes": [],

@@ -488,3 +488,3 @@ "type": "string[] | undefined"

"tags": [],
"docs": "Normally scans will discard the second and subsequent advertisements from a single device.\r\nIf you need to receive them, set allowDuplicates to true (only applicable in `requestLEScan`).\r\n(default: false)",
"docs": "Normally scans will discard the second and subsequent advertisements from a single device.\nIf you need to receive them, set allowDuplicates to true (only applicable in `requestLEScan`).\n(default: false)",
"complexTypes": [],

@@ -514,3 +514,3 @@ "type": "boolean | undefined"

"tags": [],
"docs": "The device that was found in the scan",
"docs": "The peripheral device that was found in the scan.\n**Android** and **web**: `device.name` is always identical to `localName`.\n**iOS**: `device.name` is identical to `localName` the first time a device is discovered, but after connecting `device.name` is the cached GAP name in subsequent scans.",
"complexTypes": [

@@ -522,5 +522,12 @@ "BleDevice"

{
"name": "localName",
"tags": [],
"docs": "The name of the peripheral device from the advertisement data.",
"complexTypes": [],
"type": "string | undefined"
},
{
"name": "rssi",
"tags": [],
"docs": "Received Signal Strength Indication",
"docs": "Received Signal Strength Indication.",
"complexTypes": [],

@@ -539,3 +546,3 @@ "type": "number"

"tags": [],
"docs": "Manufacturer data, key is a company identifier and value is the data",
"docs": "Manufacturer data, key is a company identifier and value is the data.",
"complexTypes": [

@@ -549,3 +556,3 @@ "DataView"

"tags": [],
"docs": "Service data, key is a service UUID and value is the data",
"docs": "Service data, key is a service UUID and value is the data.",
"complexTypes": [

@@ -559,3 +566,3 @@ "DataView"

"tags": [],
"docs": "Advertised services",
"docs": "Advertised services.",
"complexTypes": [],

@@ -567,3 +574,3 @@ "type": "string[] | undefined"

"tags": [],
"docs": "Raw advertisement data (Android only)",
"docs": "Raw advertisement data (**Android** only).",
"complexTypes": [

@@ -1151,3 +1158,3 @@ "DataView"

"tags": [],
"docs": "Perform Bluetooth LE scan in low power mode. This mode is enforced if the scanning application is not in foreground.\r\nhttps://developer.android.com/reference/android/bluetooth/le/ScanSettings#SCAN_MODE_LOW_POWER"
"docs": "Perform Bluetooth LE scan in low power mode. This mode is enforced if the scanning application is not in foreground.\nhttps://developer.android.com/reference/android/bluetooth/le/ScanSettings#SCAN_MODE_LOW_POWER"
},

@@ -1158,3 +1165,3 @@ {

"tags": [],
"docs": "Perform Bluetooth LE scan in balanced power mode. (default) Scan results are returned at a rate that provides a good trade-off between scan frequency and power consumption.\r\nhttps://developer.android.com/reference/android/bluetooth/le/ScanSettings#SCAN_MODE_BALANCED"
"docs": "Perform Bluetooth LE scan in balanced power mode. (default) Scan results are returned at a rate that provides a good trade-off between scan frequency and power consumption.\nhttps://developer.android.com/reference/android/bluetooth/le/ScanSettings#SCAN_MODE_BALANCED"
},

@@ -1165,3 +1172,3 @@ {

"tags": [],
"docs": "Scan using highest duty cycle. It's recommended to only use this mode when the application is running in the foreground.\r\nhttps://developer.android.com/reference/android/bluetooth/le/ScanSettings#SCAN_MODE_LOW_LATENCY"
"docs": "Scan using highest duty cycle. It's recommended to only use this mode when the application is running in the foreground.\nhttps://developer.android.com/reference/android/bluetooth/le/ScanSettings#SCAN_MODE_LOW_LATENCY"
}

@@ -1171,3 +1178,4 @@ ]

],
"typeAliases": []
"typeAliases": [],
"pluginConfigs": []
}

@@ -6,3 +6,3 @@ import type { PluginListenerHandle } from '@capacitor/core';

* Initialize Bluetooth Low Energy (BLE). If it fails, BLE might be unavailable on this device.
* On Android it will ask for the location permission. On iOS it will ask for the Bluetooth permission.
* On **Android** it will ask for the location permission. On **iOS** it will ask for the Bluetooth permission.
* For an example, see [usage](#usage).

@@ -13,3 +13,3 @@ */

* Reports whether BLE is enabled on this device.
* Always returns `true` on web.
* Always returns `true` on **web**.
*/

@@ -19,3 +19,3 @@ getEnabled(): Promise<boolean>;

* Register a callback function that will be invoked when BLE is enabled (true) or disabled (false) on this device.
* Not available on web (the callback will never be invoked).
* Not available on **web** (the callback will never be invoked).
* @param callback Callback function to use when the BLE state changes.

@@ -37,3 +37,3 @@ */

* Scanning will continue until `stopLEScan` is called. For an example, see [usage](#usage).
* **NOTE**: Use with care on web platform, the required API is still behind a flag in most browsers.
* **NOTE**: Use with care on **web** platform, the required API is still behind a flag in most browsers.
* @param options

@@ -40,0 +40,0 @@ * @param callback

@@ -0,0 +0,0 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -0,0 +0,0 @@ export declare function numbersToDataView(value: number[]): DataView;

@@ -0,0 +0,0 @@ export function numbersToDataView(value) {

@@ -25,3 +25,3 @@ import type { PluginListenerHandle } from '@capacitor/core';

/**
* For web, all services that will be used have to be listed under services or optionalServices,
* For **web**, all services that will be used have to be listed under services or optionalServices,
* e.g. [numberToUUID(0x180f)] (see [UUID format](#uuid-format))

@@ -64,8 +64,8 @@ */

* ID of the device, which will be needed for further calls.
* On Android this is the BLE MAC address.
* On iOS and web it is an identifier.
* On **Android** this is the BLE MAC address.
* On **iOS** and **web** it is an identifier.
*/
deviceId: string;
/**
* Name of the device.
* Name of the peripheral device.
*/

@@ -103,2 +103,3 @@ name?: string;

device: BleDevice;
localName?: string;
rssi: number;

@@ -117,8 +118,14 @@ txPower: number;

/**
* The device that was found in the scan
* The peripheral device that was found in the scan.
* **Android** and **web**: `device.name` is always identical to `localName`.
* **iOS**: `device.name` is identical to `localName` the first time a device is discovered, but after connecting `device.name` is the cached GAP name in subsequent scans.
*/
device: BleDevice;
/**
* Received Signal Strength Indication
* The name of the peripheral device from the advertisement data.
*/
localName?: string;
/**
* Received Signal Strength Indication.
*/
rssi: number;

@@ -130,3 +137,3 @@ /**

/**
* Manufacturer data, key is a company identifier and value is the data
* Manufacturer data, key is a company identifier and value is the data.
*/

@@ -137,3 +144,3 @@ manufacturerData?: {

/**
* Service data, key is a service UUID and value is the data
* Service data, key is a service UUID and value is the data.
*/

@@ -144,7 +151,7 @@ serviceData?: {

/**
* Advertised services
* Advertised services.
*/
uuids?: string[];
/**
* Raw advertisement data (Android only)
* Raw advertisement data (**Android** only).
*/

@@ -151,0 +158,0 @@ rawAdvertisement?: DataView;

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ export * from './definitions';

@@ -0,0 +0,0 @@ export * from './definitions';

@@ -32,4 +32,5 @@ /// <reference types="web-bluetooth" />

private getDevice;
private getBleDevice;
}
declare const BluetoothLe: BluetoothLeWeb;
export { BluetoothLe };

@@ -56,5 +56,5 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

});
const { id, name, uuids } = device;
this.deviceMap.set(id, device);
return { deviceId: id, name, uuids };
this.deviceMap.set(device.id, device);
const bleDevice = this.getBleDevice(device);
return bleDevice;
});

@@ -85,8 +85,6 @@ }

BluetoothLe.discoverdDevices.set(deviceId, true);
const device = {
deviceId: deviceId,
name: event.device.name,
};
const device = BluetoothLe.getBleDevice(event.device);
const result = {
device,
localName: device.name,
rssi: event.rssi,

@@ -219,2 +217,12 @@ txPower: event.txPower,

}
getBleDevice(device) {
var _a;
const bleDevice = {
deviceId: device.id,
// use undefined instead of null if name is not available
name: (_a = device.name) !== null && _a !== void 0 ? _a : undefined,
uuids: device.uuids,
};
return bleDevice;
}
}

@@ -221,0 +229,0 @@ const BluetoothLe = new BluetoothLeWeb();

@@ -10,2 +10,3 @@ 'use strict';

*/
exports.ScanMode = void 0;
(function (ScanMode) {

@@ -89,3 +90,3 @@ /**

var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
var __awaiter$1 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

@@ -110,3 +111,3 @@ return new (P || (P = Promise))(function (resolve, reject) {

initialize() {
return __awaiter(this, void 0, void 0, function* () {
return __awaiter$1(this, void 0, void 0, function* () {
if (typeof navigator === 'undefined' || !navigator.bluetooth) {

@@ -121,3 +122,3 @@ throw new Error('Web Bluetooth API not available in this browser.');

getEnabled() {
return __awaiter(this, void 0, void 0, function* () {
return __awaiter$1(this, void 0, void 0, function* () {
// not available on web

@@ -128,3 +129,3 @@ return { value: true };

startEnabledNotifications() {
return __awaiter(this, void 0, void 0, function* () {
return __awaiter$1(this, void 0, void 0, function* () {
// not available on web

@@ -134,3 +135,3 @@ });

stopEnabledNotifications() {
return __awaiter(this, void 0, void 0, function* () {
return __awaiter$1(this, void 0, void 0, function* () {
// not available on web

@@ -140,3 +141,3 @@ });

requestDevice(options) {
return __awaiter(this, void 0, void 0, function* () {
return __awaiter$1(this, void 0, void 0, function* () {
const filters = this.getFilters(options);

@@ -148,9 +149,9 @@ const device = yield navigator.bluetooth.requestDevice({

});
const { id, name, uuids } = device;
this.deviceMap.set(id, device);
return { deviceId: id, name, uuids };
this.deviceMap.set(device.id, device);
const bleDevice = this.getBleDevice(device);
return bleDevice;
});
}
requestLEScan(options) {
return __awaiter(this, void 0, void 0, function* () {
return __awaiter$1(this, void 0, void 0, function* () {
this.requestBleDeviceOptions = options;

@@ -173,12 +174,10 @@ const filters = this.getFilters(options);

const deviceId = event.device.id;
BluetoothLe.deviceMap.set(deviceId, event.device);
const isNew = !BluetoothLe.discoverdDevices.has(deviceId);
if (isNew || ((_a = BluetoothLe.requestBleDeviceOptions) === null || _a === void 0 ? void 0 : _a.allowDuplicates)) {
BluetoothLe.discoverdDevices.set(deviceId, true);
const device = {
deviceId: deviceId,
name: event.device.name,
};
BluetoothLe$1.deviceMap.set(deviceId, event.device);
const isNew = !BluetoothLe$1.discoverdDevices.has(deviceId);
if (isNew || ((_a = BluetoothLe$1.requestBleDeviceOptions) === null || _a === void 0 ? void 0 : _a.allowDuplicates)) {
BluetoothLe$1.discoverdDevices.set(deviceId, true);
const device = BluetoothLe$1.getBleDevice(event.device);
const result = {
device,
localName: device.name,
rssi: event.rssi,

@@ -190,3 +189,3 @@ txPower: event.txPower,

};
BluetoothLe.notifyListeners('onScanResult', result);
BluetoothLe$1.notifyListeners('onScanResult', result);
}

@@ -196,3 +195,3 @@ }

var _a;
return __awaiter(this, void 0, void 0, function* () {
return __awaiter$1(this, void 0, void 0, function* () {
if ((_a = this.scan) === null || _a === void 0 ? void 0 : _a.active) {

@@ -206,3 +205,3 @@ this.scan.stop();

var _a;
return __awaiter(this, void 0, void 0, function* () {
return __awaiter$1(this, void 0, void 0, function* () {
const device = yield this.getDevice(options.deviceId);

@@ -218,7 +217,7 @@ device.removeEventListener('gattserverdisconnected', this.onDisconnected);

const key = `disconnected|${deviceId}`;
BluetoothLe.notifyListeners(key, null);
BluetoothLe$1.notifyListeners(key, null);
}
disconnect(options) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
return __awaiter$1(this, void 0, void 0, function* () {
(_a = this.getDevice(options.deviceId).gatt) === null || _a === void 0 ? void 0 : _a.disconnect();

@@ -229,3 +228,3 @@ });

var _a;
return __awaiter(this, void 0, void 0, function* () {
return __awaiter$1(this, void 0, void 0, function* () {
const service = yield ((_a = this.getDevice(options.deviceId).gatt) === null || _a === void 0 ? void 0 : _a.getPrimaryService(options === null || options === void 0 ? void 0 : options.service));

@@ -236,3 +235,3 @@ return service === null || service === void 0 ? void 0 : service.getCharacteristic(options === null || options === void 0 ? void 0 : options.characteristic);

read(options) {
return __awaiter(this, void 0, void 0, function* () {
return __awaiter$1(this, void 0, void 0, function* () {
const characteristic = yield this.getCharacteristic(options);

@@ -244,3 +243,3 @@ const value = yield (characteristic === null || characteristic === void 0 ? void 0 : characteristic.readValue());

write(options) {
return __awaiter(this, void 0, void 0, function* () {
return __awaiter$1(this, void 0, void 0, function* () {
const characteristic = yield this.getCharacteristic(options);

@@ -258,3 +257,3 @@ let dataView;

writeWithoutResponse(options) {
return __awaiter(this, void 0, void 0, function* () {
return __awaiter$1(this, void 0, void 0, function* () {
const characteristic = yield this.getCharacteristic(options);

@@ -272,3 +271,3 @@ let dataView;

startNotifications(options) {
return __awaiter(this, void 0, void 0, function* () {
return __awaiter$1(this, void 0, void 0, function* () {
const characteristic = yield this.getCharacteristic(options);

@@ -285,3 +284,3 @@ characteristic === null || characteristic === void 0 ? void 0 : characteristic.removeEventListener('characteristicvaluechanged', this.onCharacteristicValueChanged);

const key = `notification|${(_a = characteristic.service) === null || _a === void 0 ? void 0 : _a.device.id}|${(_b = characteristic.service) === null || _b === void 0 ? void 0 : _b.uuid}|${characteristic.uuid}`;
BluetoothLe.notifyListeners(key, {
BluetoothLe$1.notifyListeners(key, {
value: characteristic.value,

@@ -291,3 +290,3 @@ });

stopNotifications(options) {
return __awaiter(this, void 0, void 0, function* () {
return __awaiter$1(this, void 0, void 0, function* () {
const characteristic = yield this.getCharacteristic(options);

@@ -322,7 +321,17 @@ yield (characteristic === null || characteristic === void 0 ? void 0 : characteristic.stopNotifications());

}
getBleDevice(device) {
var _a;
const bleDevice = {
deviceId: device.id,
// use undefined instead of null if name is not available
name: (_a = device.name) !== null && _a !== void 0 ? _a : undefined,
uuids: device.uuids,
};
return bleDevice;
}
}
const BluetoothLe = new BluetoothLeWeb();
core.registerWebPlugin(BluetoothLe);
const BluetoothLe$1 = new BluetoothLeWeb();
core.registerWebPlugin(BluetoothLe$1);
var __awaiter$1 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

@@ -336,3 +345,3 @@ return new (P || (P = Promise))(function (resolve, reject) {

};
const { BluetoothLe: BluetoothLe$1 } = core.Plugins;
const { BluetoothLe } = core.Plugins;
class BleClientClass {

@@ -344,9 +353,9 @@ constructor() {

initialize() {
return __awaiter$1(this, void 0, void 0, function* () {
yield BluetoothLe$1.initialize();
return __awaiter(this, void 0, void 0, function* () {
yield BluetoothLe.initialize();
});
}
getEnabled() {
return __awaiter$1(this, void 0, void 0, function* () {
const result = yield BluetoothLe$1.getEnabled();
return __awaiter(this, void 0, void 0, function* () {
const result = yield BluetoothLe.getEnabled();
return result.value;

@@ -357,10 +366,10 @@ });

var _a;
return __awaiter$1(this, void 0, void 0, function* () {
return __awaiter(this, void 0, void 0, function* () {
const key = `onEnabledChanged`;
(_a = this.eventListeners.get(key)) === null || _a === void 0 ? void 0 : _a.remove();
const listener = BluetoothLe$1.addListener(key, result => {
const listener = BluetoothLe.addListener(key, result => {
callback(result.value);
});
this.eventListeners.set(key, listener);
yield BluetoothLe$1.startEnabledNotifications();
yield BluetoothLe.startEnabledNotifications();
});

@@ -370,11 +379,11 @@ }

var _a;
return __awaiter$1(this, void 0, void 0, function* () {
return __awaiter(this, void 0, void 0, function* () {
const key = `onEnabledChanged`;
(_a = this.eventListeners.get(key)) === null || _a === void 0 ? void 0 : _a.remove();
yield BluetoothLe$1.stopEnabledNotifications();
yield BluetoothLe.stopEnabledNotifications();
});
}
requestDevice(options) {
return __awaiter$1(this, void 0, void 0, function* () {
const device = yield BluetoothLe$1.requestDevice(options);
return __awaiter(this, void 0, void 0, function* () {
const device = yield BluetoothLe.requestDevice(options);
return device;

@@ -385,5 +394,5 @@ });

var _a;
return __awaiter$1(this, void 0, void 0, function* () {
return __awaiter(this, void 0, void 0, function* () {
(_a = this.scanListener) === null || _a === void 0 ? void 0 : _a.remove();
this.scanListener = BluetoothLe$1.addListener('onScanResult', (result) => {
this.scanListener = BluetoothLe.addListener('onScanResult', (result) => {
result.manufacturerData = this.convertObject(result.manufacturerData);

@@ -396,3 +405,3 @@ result.serviceData = this.convertObject(result.serviceData);

});
yield BluetoothLe$1.requestLEScan(options);
yield BluetoothLe.requestLEScan(options);
});

@@ -402,6 +411,6 @@ }

var _a;
return __awaiter$1(this, void 0, void 0, function* () {
return __awaiter(this, void 0, void 0, function* () {
(_a = this.scanListener) === null || _a === void 0 ? void 0 : _a.remove();
this.scanListener = null;
yield BluetoothLe$1.stopLEScan();
yield BluetoothLe.stopLEScan();
});

@@ -411,7 +420,7 @@ }

var _a;
return __awaiter$1(this, void 0, void 0, function* () {
return __awaiter(this, void 0, void 0, function* () {
if (onDisconnect) {
const key = `disconnected|${deviceId}`;
(_a = this.eventListeners.get(key)) === null || _a === void 0 ? void 0 : _a.remove();
const listener = BluetoothLe$1.addListener(key, () => {
const listener = BluetoothLe.addListener(key, () => {
onDisconnect(deviceId);

@@ -421,13 +430,13 @@ });

}
yield BluetoothLe$1.connect({ deviceId });
yield BluetoothLe.connect({ deviceId });
});
}
disconnect(deviceId) {
return __awaiter$1(this, void 0, void 0, function* () {
yield BluetoothLe$1.disconnect({ deviceId });
return __awaiter(this, void 0, void 0, function* () {
yield BluetoothLe.disconnect({ deviceId });
});
}
read(deviceId, service, characteristic) {
return __awaiter$1(this, void 0, void 0, function* () {
const result = yield BluetoothLe$1.read({
return __awaiter(this, void 0, void 0, function* () {
const result = yield BluetoothLe.read({
deviceId,

@@ -441,3 +450,3 @@ service,

write(deviceId, service, characteristic, value) {
return __awaiter$1(this, void 0, void 0, function* () {
return __awaiter(this, void 0, void 0, function* () {
let writeValue = value;

@@ -448,3 +457,3 @@ if (core.Capacitor.getPlatform() !== 'web') {

}
yield BluetoothLe$1.write({
yield BluetoothLe.write({
deviceId,

@@ -458,3 +467,3 @@ service,

writeWithoutResponse(deviceId, service, characteristic, value) {
return __awaiter$1(this, void 0, void 0, function* () {
return __awaiter(this, void 0, void 0, function* () {
let writeValue = value;

@@ -465,3 +474,3 @@ if (core.Capacitor.getPlatform() !== 'web') {

}
yield BluetoothLe$1.writeWithoutResponse({
yield BluetoothLe.writeWithoutResponse({
deviceId,

@@ -476,10 +485,10 @@ service,

var _a;
return __awaiter$1(this, void 0, void 0, function* () {
return __awaiter(this, void 0, void 0, function* () {
const key = `notification|${deviceId}|${service}|${characteristic}`;
(_a = this.eventListeners.get(key)) === null || _a === void 0 ? void 0 : _a.remove();
const listener = BluetoothLe$1.addListener(key, (event) => {
const listener = BluetoothLe.addListener(key, (event) => {
callback(this.convertValue(event === null || event === void 0 ? void 0 : event.value));
});
this.eventListeners.set(key, listener);
yield BluetoothLe$1.startNotifications({
yield BluetoothLe.startNotifications({
deviceId,

@@ -493,7 +502,7 @@ service,

var _a;
return __awaiter$1(this, void 0, void 0, function* () {
return __awaiter(this, void 0, void 0, function* () {
const key = `notification|${service}|${characteristic}`;
(_a = this.eventListeners.get(key)) === null || _a === void 0 ? void 0 : _a.remove();
this.eventListeners.delete(key);
yield BluetoothLe$1.stopNotifications({
yield BluetoothLe.stopNotifications({
deviceId,

@@ -528,3 +537,3 @@ service,

exports.BleClient = BleClient;
exports.BluetoothLe = BluetoothLe;
exports.BluetoothLe = BluetoothLe$1;
exports.BluetoothLeWeb = BluetoothLeWeb;

@@ -531,0 +540,0 @@ exports.dataViewToHexString = dataViewToHexString;

@@ -7,2 +7,3 @@ var capacitorCommunityBluetoothLe = (function (exports, core) {

*/
exports.ScanMode = void 0;
(function (ScanMode) {

@@ -86,3 +87,3 @@ /**

var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
var __awaiter$1 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

@@ -107,3 +108,3 @@ return new (P || (P = Promise))(function (resolve, reject) {

initialize() {
return __awaiter(this, void 0, void 0, function* () {
return __awaiter$1(this, void 0, void 0, function* () {
if (typeof navigator === 'undefined' || !navigator.bluetooth) {

@@ -118,3 +119,3 @@ throw new Error('Web Bluetooth API not available in this browser.');

getEnabled() {
return __awaiter(this, void 0, void 0, function* () {
return __awaiter$1(this, void 0, void 0, function* () {
// not available on web

@@ -125,3 +126,3 @@ return { value: true };

startEnabledNotifications() {
return __awaiter(this, void 0, void 0, function* () {
return __awaiter$1(this, void 0, void 0, function* () {
// not available on web

@@ -131,3 +132,3 @@ });

stopEnabledNotifications() {
return __awaiter(this, void 0, void 0, function* () {
return __awaiter$1(this, void 0, void 0, function* () {
// not available on web

@@ -137,3 +138,3 @@ });

requestDevice(options) {
return __awaiter(this, void 0, void 0, function* () {
return __awaiter$1(this, void 0, void 0, function* () {
const filters = this.getFilters(options);

@@ -145,9 +146,9 @@ const device = yield navigator.bluetooth.requestDevice({

});
const { id, name, uuids } = device;
this.deviceMap.set(id, device);
return { deviceId: id, name, uuids };
this.deviceMap.set(device.id, device);
const bleDevice = this.getBleDevice(device);
return bleDevice;
});
}
requestLEScan(options) {
return __awaiter(this, void 0, void 0, function* () {
return __awaiter$1(this, void 0, void 0, function* () {
this.requestBleDeviceOptions = options;

@@ -170,12 +171,10 @@ const filters = this.getFilters(options);

const deviceId = event.device.id;
BluetoothLe.deviceMap.set(deviceId, event.device);
const isNew = !BluetoothLe.discoverdDevices.has(deviceId);
if (isNew || ((_a = BluetoothLe.requestBleDeviceOptions) === null || _a === void 0 ? void 0 : _a.allowDuplicates)) {
BluetoothLe.discoverdDevices.set(deviceId, true);
const device = {
deviceId: deviceId,
name: event.device.name,
};
BluetoothLe$1.deviceMap.set(deviceId, event.device);
const isNew = !BluetoothLe$1.discoverdDevices.has(deviceId);
if (isNew || ((_a = BluetoothLe$1.requestBleDeviceOptions) === null || _a === void 0 ? void 0 : _a.allowDuplicates)) {
BluetoothLe$1.discoverdDevices.set(deviceId, true);
const device = BluetoothLe$1.getBleDevice(event.device);
const result = {
device,
localName: device.name,
rssi: event.rssi,

@@ -187,3 +186,3 @@ txPower: event.txPower,

};
BluetoothLe.notifyListeners('onScanResult', result);
BluetoothLe$1.notifyListeners('onScanResult', result);
}

@@ -193,3 +192,3 @@ }

var _a;
return __awaiter(this, void 0, void 0, function* () {
return __awaiter$1(this, void 0, void 0, function* () {
if ((_a = this.scan) === null || _a === void 0 ? void 0 : _a.active) {

@@ -203,3 +202,3 @@ this.scan.stop();

var _a;
return __awaiter(this, void 0, void 0, function* () {
return __awaiter$1(this, void 0, void 0, function* () {
const device = yield this.getDevice(options.deviceId);

@@ -215,7 +214,7 @@ device.removeEventListener('gattserverdisconnected', this.onDisconnected);

const key = `disconnected|${deviceId}`;
BluetoothLe.notifyListeners(key, null);
BluetoothLe$1.notifyListeners(key, null);
}
disconnect(options) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
return __awaiter$1(this, void 0, void 0, function* () {
(_a = this.getDevice(options.deviceId).gatt) === null || _a === void 0 ? void 0 : _a.disconnect();

@@ -226,3 +225,3 @@ });

var _a;
return __awaiter(this, void 0, void 0, function* () {
return __awaiter$1(this, void 0, void 0, function* () {
const service = yield ((_a = this.getDevice(options.deviceId).gatt) === null || _a === void 0 ? void 0 : _a.getPrimaryService(options === null || options === void 0 ? void 0 : options.service));

@@ -233,3 +232,3 @@ return service === null || service === void 0 ? void 0 : service.getCharacteristic(options === null || options === void 0 ? void 0 : options.characteristic);

read(options) {
return __awaiter(this, void 0, void 0, function* () {
return __awaiter$1(this, void 0, void 0, function* () {
const characteristic = yield this.getCharacteristic(options);

@@ -241,3 +240,3 @@ const value = yield (characteristic === null || characteristic === void 0 ? void 0 : characteristic.readValue());

write(options) {
return __awaiter(this, void 0, void 0, function* () {
return __awaiter$1(this, void 0, void 0, function* () {
const characteristic = yield this.getCharacteristic(options);

@@ -255,3 +254,3 @@ let dataView;

writeWithoutResponse(options) {
return __awaiter(this, void 0, void 0, function* () {
return __awaiter$1(this, void 0, void 0, function* () {
const characteristic = yield this.getCharacteristic(options);

@@ -269,3 +268,3 @@ let dataView;

startNotifications(options) {
return __awaiter(this, void 0, void 0, function* () {
return __awaiter$1(this, void 0, void 0, function* () {
const characteristic = yield this.getCharacteristic(options);

@@ -282,3 +281,3 @@ characteristic === null || characteristic === void 0 ? void 0 : characteristic.removeEventListener('characteristicvaluechanged', this.onCharacteristicValueChanged);

const key = `notification|${(_a = characteristic.service) === null || _a === void 0 ? void 0 : _a.device.id}|${(_b = characteristic.service) === null || _b === void 0 ? void 0 : _b.uuid}|${characteristic.uuid}`;
BluetoothLe.notifyListeners(key, {
BluetoothLe$1.notifyListeners(key, {
value: characteristic.value,

@@ -288,3 +287,3 @@ });

stopNotifications(options) {
return __awaiter(this, void 0, void 0, function* () {
return __awaiter$1(this, void 0, void 0, function* () {
const characteristic = yield this.getCharacteristic(options);

@@ -319,7 +318,17 @@ yield (characteristic === null || characteristic === void 0 ? void 0 : characteristic.stopNotifications());

}
getBleDevice(device) {
var _a;
const bleDevice = {
deviceId: device.id,
// use undefined instead of null if name is not available
name: (_a = device.name) !== null && _a !== void 0 ? _a : undefined,
uuids: device.uuids,
};
return bleDevice;
}
}
const BluetoothLe = new BluetoothLeWeb();
core.registerWebPlugin(BluetoothLe);
const BluetoothLe$1 = new BluetoothLeWeb();
core.registerWebPlugin(BluetoothLe$1);
var __awaiter$1 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

@@ -333,3 +342,3 @@ return new (P || (P = Promise))(function (resolve, reject) {

};
const { BluetoothLe: BluetoothLe$1 } = core.Plugins;
const { BluetoothLe } = core.Plugins;
class BleClientClass {

@@ -341,9 +350,9 @@ constructor() {

initialize() {
return __awaiter$1(this, void 0, void 0, function* () {
yield BluetoothLe$1.initialize();
return __awaiter(this, void 0, void 0, function* () {
yield BluetoothLe.initialize();
});
}
getEnabled() {
return __awaiter$1(this, void 0, void 0, function* () {
const result = yield BluetoothLe$1.getEnabled();
return __awaiter(this, void 0, void 0, function* () {
const result = yield BluetoothLe.getEnabled();
return result.value;

@@ -354,10 +363,10 @@ });

var _a;
return __awaiter$1(this, void 0, void 0, function* () {
return __awaiter(this, void 0, void 0, function* () {
const key = `onEnabledChanged`;
(_a = this.eventListeners.get(key)) === null || _a === void 0 ? void 0 : _a.remove();
const listener = BluetoothLe$1.addListener(key, result => {
const listener = BluetoothLe.addListener(key, result => {
callback(result.value);
});
this.eventListeners.set(key, listener);
yield BluetoothLe$1.startEnabledNotifications();
yield BluetoothLe.startEnabledNotifications();
});

@@ -367,11 +376,11 @@ }

var _a;
return __awaiter$1(this, void 0, void 0, function* () {
return __awaiter(this, void 0, void 0, function* () {
const key = `onEnabledChanged`;
(_a = this.eventListeners.get(key)) === null || _a === void 0 ? void 0 : _a.remove();
yield BluetoothLe$1.stopEnabledNotifications();
yield BluetoothLe.stopEnabledNotifications();
});
}
requestDevice(options) {
return __awaiter$1(this, void 0, void 0, function* () {
const device = yield BluetoothLe$1.requestDevice(options);
return __awaiter(this, void 0, void 0, function* () {
const device = yield BluetoothLe.requestDevice(options);
return device;

@@ -382,5 +391,5 @@ });

var _a;
return __awaiter$1(this, void 0, void 0, function* () {
return __awaiter(this, void 0, void 0, function* () {
(_a = this.scanListener) === null || _a === void 0 ? void 0 : _a.remove();
this.scanListener = BluetoothLe$1.addListener('onScanResult', (result) => {
this.scanListener = BluetoothLe.addListener('onScanResult', (result) => {
result.manufacturerData = this.convertObject(result.manufacturerData);

@@ -393,3 +402,3 @@ result.serviceData = this.convertObject(result.serviceData);

});
yield BluetoothLe$1.requestLEScan(options);
yield BluetoothLe.requestLEScan(options);
});

@@ -399,6 +408,6 @@ }

var _a;
return __awaiter$1(this, void 0, void 0, function* () {
return __awaiter(this, void 0, void 0, function* () {
(_a = this.scanListener) === null || _a === void 0 ? void 0 : _a.remove();
this.scanListener = null;
yield BluetoothLe$1.stopLEScan();
yield BluetoothLe.stopLEScan();
});

@@ -408,7 +417,7 @@ }

var _a;
return __awaiter$1(this, void 0, void 0, function* () {
return __awaiter(this, void 0, void 0, function* () {
if (onDisconnect) {
const key = `disconnected|${deviceId}`;
(_a = this.eventListeners.get(key)) === null || _a === void 0 ? void 0 : _a.remove();
const listener = BluetoothLe$1.addListener(key, () => {
const listener = BluetoothLe.addListener(key, () => {
onDisconnect(deviceId);

@@ -418,13 +427,13 @@ });

}
yield BluetoothLe$1.connect({ deviceId });
yield BluetoothLe.connect({ deviceId });
});
}
disconnect(deviceId) {
return __awaiter$1(this, void 0, void 0, function* () {
yield BluetoothLe$1.disconnect({ deviceId });
return __awaiter(this, void 0, void 0, function* () {
yield BluetoothLe.disconnect({ deviceId });
});
}
read(deviceId, service, characteristic) {
return __awaiter$1(this, void 0, void 0, function* () {
const result = yield BluetoothLe$1.read({
return __awaiter(this, void 0, void 0, function* () {
const result = yield BluetoothLe.read({
deviceId,

@@ -438,3 +447,3 @@ service,

write(deviceId, service, characteristic, value) {
return __awaiter$1(this, void 0, void 0, function* () {
return __awaiter(this, void 0, void 0, function* () {
let writeValue = value;

@@ -445,3 +454,3 @@ if (core.Capacitor.getPlatform() !== 'web') {

}
yield BluetoothLe$1.write({
yield BluetoothLe.write({
deviceId,

@@ -455,3 +464,3 @@ service,

writeWithoutResponse(deviceId, service, characteristic, value) {
return __awaiter$1(this, void 0, void 0, function* () {
return __awaiter(this, void 0, void 0, function* () {
let writeValue = value;

@@ -462,3 +471,3 @@ if (core.Capacitor.getPlatform() !== 'web') {

}
yield BluetoothLe$1.writeWithoutResponse({
yield BluetoothLe.writeWithoutResponse({
deviceId,

@@ -473,10 +482,10 @@ service,

var _a;
return __awaiter$1(this, void 0, void 0, function* () {
return __awaiter(this, void 0, void 0, function* () {
const key = `notification|${deviceId}|${service}|${characteristic}`;
(_a = this.eventListeners.get(key)) === null || _a === void 0 ? void 0 : _a.remove();
const listener = BluetoothLe$1.addListener(key, (event) => {
const listener = BluetoothLe.addListener(key, (event) => {
callback(this.convertValue(event === null || event === void 0 ? void 0 : event.value));
});
this.eventListeners.set(key, listener);
yield BluetoothLe$1.startNotifications({
yield BluetoothLe.startNotifications({
deviceId,

@@ -490,7 +499,7 @@ service,

var _a;
return __awaiter$1(this, void 0, void 0, function* () {
return __awaiter(this, void 0, void 0, function* () {
const key = `notification|${service}|${characteristic}`;
(_a = this.eventListeners.get(key)) === null || _a === void 0 ? void 0 : _a.remove();
this.eventListeners.delete(key);
yield BluetoothLe$1.stopNotifications({
yield BluetoothLe.stopNotifications({
deviceId,

@@ -525,3 +534,3 @@ service,

exports.BleClient = BleClient;
exports.BluetoothLe = BluetoothLe;
exports.BluetoothLe = BluetoothLe$1;
exports.BluetoothLeWeb = BluetoothLeWeb;

@@ -528,0 +537,0 @@ exports.dataViewToHexString = dataViewToHexString;

{
"name": "@capacitor-community/bluetooth-le",
"version": "0.3.0",
"description": "Capacitor Bluetooth Low Energy Plugin",
"version": "0.4.0",
"description": "Capacitor plugin for Bluetooth Low Energy ",
"main": "dist/plugin.cjs.js",

@@ -38,24 +38,24 @@ "module": "dist/esm/index.js",

"devDependencies": {
"@capacitor/android": "^2.4.6",
"@capacitor/core": "^2.4.6",
"@capacitor/docgen": "^0.0.15",
"@capacitor/ios": "^2.4.6",
"@capacitor/android": "^2.4.7",
"@capacitor/core": "^2.4.7",
"@capacitor/docgen": "^0.0.16",
"@capacitor/ios": "^2.4.7",
"@ionic/eslint-config": "^0.3.0",
"@ionic/prettier-config": "^1.0.1",
"@ionic/swiftlint-config": "^1.1.2",
"@rollup/plugin-node-resolve": "^11.1.1",
"@rollup/plugin-node-resolve": "^11.2.0",
"@types/jest": "^26.0.20",
"eslint": "^7.18.0",
"eslint": "^7.22.0",
"jest": "^26.6.3",
"prettier": "^2.2.1",
"prettier-plugin-java": "^1.0.1",
"prettier-plugin-java": "^1.0.2",
"rimraf": "^3.0.2",
"rollup": "^2.38.1",
"standard-version": "^9.1.0",
"rollup": "^2.41.2",
"standard-version": "^9.1.1",
"swiftlint": "^1.0.1",
"ts-jest": "^26.5.0",
"typescript": "~4.2.2"
"ts-jest": "^26.5.3",
"typescript": "~4.2.3"
},
"peerDependencies": {
"@capacitor/core": "^2.4.6"
"@capacitor/core": "^2.4.7"
},

@@ -71,3 +71,4 @@ "files": [

"plugin",
"native"
"native",
"bluetooth"
],

@@ -74,0 +75,0 @@ "capacitor": {

@@ -5,3 +5,3 @@ <p align="center"><br><img src="https://user-images.githubusercontent.com/236501/85893648-1c92e880-b7a8-11ea-926d-95355b8175c7.png" width="128" height="128" /></p>

<p align="center">
Capacitor Bluetooth Low Energy Plugin
Capacitor plugin for Bluetooth Low Energy
</p>

@@ -17,3 +17,3 @@

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
<a href="#contributors-"><img src="https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square" /></a>
<a href="#contributors-"><img src="https://img.shields.io/badge/all%20contributors-2-orange?style=flat-square" /></a>
<!-- ALL-CONTRIBUTORS-BADGE:END -->

@@ -62,4 +62,9 @@ </p>

```
npm install @capacitor-community/bluetooth-le
# for Capacitor v2
npm install @capacitor-community/bluetooth-le@latest
npx cap sync
# for Capacitor v3
npm install @capacitor-community/bluetooth-le@next
npx cap sync
```

@@ -96,3 +101,3 @@

On Android, register the plugin in your main activity:
On Android, register the plugin in your main activity (this is only required for Capacitor 2):

@@ -197,3 +202,3 @@ `./android/app/src/main/java/<PATH>/MainActivity.java`:

export async function main() {
export async function main(): Promise<void> {
try {

@@ -259,3 +264,3 @@ await BleClient.initialize();

let heartRate: number;
if (rate16Bits) {
if (rate16Bits > 0) {
heartRate = value.getUint16(1, true);

@@ -276,3 +281,3 @@ } else {

export async function scan() {
export async function scan(): Promise<void> {
try {

@@ -312,3 +317,3 @@ await BleClient.initialize();

Initialize Bluetooth Low Energy (BLE). If it fails, BLE might be unavailable on this device.
On Android it will ask for the location permission. On iOS it will ask for the Bluetooth permission.
On **Android** it will ask for the location permission. On **iOS** it will ask for the Bluetooth permission.
For an example, see [usage](#usage).

@@ -325,3 +330,3 @@

Reports whether BLE is enabled on this device.
Always returns `true` on web.
Always returns `true` on **web**.

@@ -339,3 +344,3 @@ **Returns:** <code>Promise&lt;boolean&gt;</code>

Register a callback function that will be invoked when BLE is enabled (true) or disabled (false) on this device.
Not available on web (the callback will never be invoked).
Not available on **web** (the callback will never be invoked).

@@ -383,3 +388,3 @@ | Param | Type | Description |

Scanning will continue until `stopLEScan` is called. For an example, see [usage](#usage).
**NOTE**: Use with care on web platform, the required API is still behind a flag in most browsers.
**NOTE**: Use with care on **web** platform, the required API is still behind a flag in most browsers.

@@ -521,7 +526,7 @@ | Param | Type |

| Prop | Type | Description |
| -------------- | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| **`deviceId`** | <code>string</code> | ID of the device, which will be needed for further calls. On Android this is the BLE MAC address. On iOS and web it is an identifier. |
| **`name`** | <code>string</code> | Name of the device. |
| **`uuids`** | <code>string[]</code> | |
| Prop | Type | Description |
| -------------- | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`deviceId`** | <code>string</code> | ID of the device, which will be needed for further calls. On **Android** this is the BLE MAC address. On **iOS** and **web** it is an identifier. |
| **`name`** | <code>string</code> | Name of the peripheral device. |
| **`uuids`** | <code>string[]</code> | |

@@ -535,3 +540,3 @@ #### RequestBleDeviceOptions

| **`namePrefix`** | <code>string</code> | Filter devices by name prefix |
| **`optionalServices`** | <code>string[]</code> | For web, all services that will be used have to be listed under services or optionalServices, e.g. [numberToUUID(0x180f)] (see [UUID format](#uuid-format)) |
| **`optionalServices`** | <code>string[]</code> | For **web**, all services that will be used have to be listed under services or optionalServices, e.g. [numberToUUID(0x180f)] (see [UUID format](#uuid-format)) |
| **`allowDuplicates`** | <code>boolean</code> | Normally scans will discard the second and subsequent advertisements from a single device. If you need to receive them, set allowDuplicates to true (only applicable in `requestLEScan`). (default: false) |

@@ -542,11 +547,12 @@ | **`scanMode`** | <code><a href="#scanmode">ScanMode</a></code> | Android scan mode (default: <a href="#scanmode">ScanMode.SCAN_MODE_BALANCED</a>) |

| Prop | Type | Description |
| ---------------------- | ----------------------------------------------------------------- | ------------------------------------------------------------------------- |
| **`device`** | <code><a href="#bledevice">BleDevice</a></code> | The device that was found in the scan |
| **`rssi`** | <code>number</code> | Received Signal Strength Indication |
| **`txPower`** | <code>number</code> | Transmit power in dBm. A value of 127 indicates that it is not available. |
| **`manufacturerData`** | <code>{ [key: string]: <a href="#dataview">DataView</a>; }</code> | Manufacturer data, key is a company identifier and value is the data |
| **`serviceData`** | <code>{ [key: string]: <a href="#dataview">DataView</a>; }</code> | Service data, key is a service UUID and value is the data |
| **`uuids`** | <code>string[]</code> | Advertised services |
| **`rawAdvertisement`** | <code><a href="#dataview">DataView</a></code> | Raw advertisement data (Android only) |
| Prop | Type | Description |
| ---------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`device`** | <code><a href="#bledevice">BleDevice</a></code> | The peripheral device that was found in the scan. **Android** and **web**: `device.name` is always identical to `localName`. **iOS**: `device.name` is identical to `localName` the first time a device is discovered, but after connecting `device.name` is the cached GAP name in subsequent scans. |
| **`localName`** | <code>string</code> | The name of the peripheral device from the advertisement data. |
| **`rssi`** | <code>number</code> | Received Signal Strength Indication. |
| **`txPower`** | <code>number</code> | Transmit power in dBm. A value of 127 indicates that it is not available. |
| **`manufacturerData`** | <code>{ [key: string]: <a href="#dataview">DataView</a>; }</code> | Manufacturer data, key is a company identifier and value is the data. |
| **`serviceData`** | <code>{ [key: string]: <a href="#dataview">DataView</a>; }</code> | Service data, key is a service UUID and value is the data. |
| **`uuids`** | <code>string[]</code> | Advertised services. |
| **`rawAdvertisement`** | <code><a href="#dataview">DataView</a></code> | Raw advertisement data (**Android** only). |

@@ -628,2 +634,3 @@ #### DataView

<td align="center"><a href="https://github.com/pwespi"><img src="https://avatars2.githubusercontent.com/u/24232962?v=4?s=100" width="100px;" alt=""/><br /><sub><b>pwespi</b></sub></a><br /><a href="https://github.com/capacitor-community/bluetooth-le/commits?author=pwespi" title="Code">💻</a></td>
<td align="center"><a href="https://twitter.com/dennisameling"><img src="https://avatars.githubusercontent.com/u/17739158?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Dennis Ameling</b></sub></a><br /><a href="https://github.com/capacitor-community/bluetooth-le/commits?author=dennisameling" title="Code">💻</a></td>
</tr>

@@ -630,0 +637,0 @@ </table>

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc