@capacitor-community/bluetooth-le
Advanced tools
Comparing version 1.3.1 to 1.4.0
@@ -5,2 +5,14 @@ # Changelog | ||
## [1.4.0](https://github.com/capacitor-community/bluetooth-le/compare/v1.3.1...v1.4.0) (2021-09-24) | ||
### Features | ||
* **all:** add getServices method ([#200](https://github.com/capacitor-community/bluetooth-le/issues/200)) ([557ef12](https://github.com/capacitor-community/bluetooth-le/commit/557ef12ee960f0e78d10dbf0b0045a4be8eccb0c)) | ||
### Bug Fixes | ||
* **android:** make core-ktx version configurable and set default to 1.6.0 ([#199](https://github.com/capacitor-community/bluetooth-le/issues/199)) ([f1357d9](https://github.com/capacitor-community/bluetooth-le/commit/f1357d939e4528dd316e4a89683b81e300af5d0c)) | ||
### [1.3.1](https://github.com/capacitor-community/bluetooth-le/compare/v1.3.0...v1.3.1) (2021-09-22) | ||
@@ -7,0 +19,0 @@ |
@@ -289,2 +289,25 @@ { | ||
{ | ||
"name": "getServices", | ||
"signature": "(deviceId: string) => Promise<BleService[]>", | ||
"parameters": [ | ||
{ | ||
"name": "deviceId", | ||
"docs": "The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))", | ||
"type": "string" | ||
} | ||
], | ||
"returns": "Promise<BleService[]>", | ||
"tags": [ | ||
{ | ||
"name": "param", | ||
"text": "deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))" | ||
} | ||
], | ||
"docs": "Get services and characteristics of device.", | ||
"complexTypes": [ | ||
"BleService" | ||
], | ||
"slug": "getservices" | ||
}, | ||
{ | ||
"name": "readRssi", | ||
@@ -1353,2 +1376,145 @@ "signature": "(deviceId: string) => Promise<number>", | ||
] | ||
}, | ||
{ | ||
"name": "BleService", | ||
"slug": "bleservice", | ||
"docs": "", | ||
"tags": [], | ||
"methods": [], | ||
"properties": [ | ||
{ | ||
"name": "uuid", | ||
"tags": [], | ||
"docs": "", | ||
"complexTypes": [], | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "characteristics", | ||
"tags": [], | ||
"docs": "", | ||
"complexTypes": [ | ||
"BleCharacteristic" | ||
], | ||
"type": "BleCharacteristic[]" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "BleCharacteristic", | ||
"slug": "blecharacteristic", | ||
"docs": "", | ||
"tags": [], | ||
"methods": [], | ||
"properties": [ | ||
{ | ||
"name": "uuid", | ||
"tags": [], | ||
"docs": "", | ||
"complexTypes": [], | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "properties", | ||
"tags": [], | ||
"docs": "", | ||
"complexTypes": [ | ||
"BleCharacteristicProperties" | ||
], | ||
"type": "BleCharacteristicProperties" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "BleCharacteristicProperties", | ||
"slug": "blecharacteristicproperties", | ||
"docs": "", | ||
"tags": [], | ||
"methods": [], | ||
"properties": [ | ||
{ | ||
"name": "broadcast", | ||
"tags": [], | ||
"docs": "", | ||
"complexTypes": [], | ||
"type": "boolean" | ||
}, | ||
{ | ||
"name": "read", | ||
"tags": [], | ||
"docs": "", | ||
"complexTypes": [], | ||
"type": "boolean" | ||
}, | ||
{ | ||
"name": "writeWithoutResponse", | ||
"tags": [], | ||
"docs": "", | ||
"complexTypes": [], | ||
"type": "boolean" | ||
}, | ||
{ | ||
"name": "write", | ||
"tags": [], | ||
"docs": "", | ||
"complexTypes": [], | ||
"type": "boolean" | ||
}, | ||
{ | ||
"name": "notify", | ||
"tags": [], | ||
"docs": "", | ||
"complexTypes": [], | ||
"type": "boolean" | ||
}, | ||
{ | ||
"name": "indicate", | ||
"tags": [], | ||
"docs": "", | ||
"complexTypes": [], | ||
"type": "boolean" | ||
}, | ||
{ | ||
"name": "authenticatedSignedWrites", | ||
"tags": [], | ||
"docs": "", | ||
"complexTypes": [], | ||
"type": "boolean" | ||
}, | ||
{ | ||
"name": "reliableWrite", | ||
"tags": [], | ||
"docs": "", | ||
"complexTypes": [], | ||
"type": "boolean | undefined" | ||
}, | ||
{ | ||
"name": "writableAuxiliaries", | ||
"tags": [], | ||
"docs": "", | ||
"complexTypes": [], | ||
"type": "boolean | undefined" | ||
}, | ||
{ | ||
"name": "extendedProperties", | ||
"tags": [], | ||
"docs": "", | ||
"complexTypes": [], | ||
"type": "boolean | undefined" | ||
}, | ||
{ | ||
"name": "notifyEncryptionRequired", | ||
"tags": [], | ||
"docs": "", | ||
"complexTypes": [], | ||
"type": "boolean | undefined" | ||
}, | ||
{ | ||
"name": "indicateEncryptionRequired", | ||
"tags": [], | ||
"docs": "", | ||
"complexTypes": [], | ||
"type": "boolean | undefined" | ||
} | ||
] | ||
} | ||
@@ -1355,0 +1521,0 @@ ], |
import type { DisplayStrings } from './config'; | ||
import type { BleDevice, RequestBleDeviceOptions, ScanResult } from './definitions'; | ||
import type { BleDevice, BleService, RequestBleDeviceOptions, ScanResult } from './definitions'; | ||
export interface BleClientInterface { | ||
@@ -88,2 +88,7 @@ /** | ||
/** | ||
* Get services and characteristics of device. | ||
* @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan)) | ||
*/ | ||
getServices(deviceId: string): Promise<BleService[]>; | ||
/** | ||
* Read the RSSI value of a connected device. | ||
@@ -159,2 +164,3 @@ * Not available on web. | ||
disconnect(deviceId: string): Promise<void>; | ||
getServices(deviceId: string): Promise<BleService[]>; | ||
readRssi(deviceId: string): Promise<number>; | ||
@@ -161,0 +167,0 @@ read(deviceId: string, service: string, characteristic: string): Promise<DataView>; |
@@ -135,2 +135,9 @@ import { Capacitor } from '@capacitor/core'; | ||
} | ||
async getServices(deviceId) { | ||
const services = await this.queue(async () => { | ||
const result = await BluetoothLe.getServices({ deviceId }); | ||
return result.services; | ||
}); | ||
return services; | ||
} | ||
async readRssi(deviceId) { | ||
@@ -137,0 +144,0 @@ const value = await this.queue(async () => { |
@@ -78,2 +78,27 @@ import type { PluginListenerHandle } from '@capacitor/core'; | ||
} | ||
export interface BleService { | ||
readonly uuid: string; | ||
readonly characteristics: BleCharacteristic[]; | ||
} | ||
export interface BleCharacteristic { | ||
readonly uuid: string; | ||
readonly properties: BleCharacteristicProperties; | ||
} | ||
export interface BleCharacteristicProperties { | ||
readonly broadcast: boolean; | ||
readonly read: boolean; | ||
readonly writeWithoutResponse: boolean; | ||
readonly write: boolean; | ||
readonly notify: boolean; | ||
readonly indicate: boolean; | ||
readonly authenticatedSignedWrites: boolean; | ||
readonly reliableWrite?: boolean; | ||
readonly writableAuxiliaries?: boolean; | ||
readonly extendedProperties?: boolean; | ||
readonly notifyEncryptionRequired?: boolean; | ||
readonly indicateEncryptionRequired?: boolean; | ||
} | ||
export interface BleServices { | ||
services: BleService[]; | ||
} | ||
export interface ReadOptions { | ||
@@ -183,2 +208,3 @@ deviceId: string; | ||
disconnect(options: DeviceIdOptions): Promise<void>; | ||
getServices(options: DeviceIdOptions): Promise<BleServices>; | ||
readRssi(options: DeviceIdOptions): Promise<ReadRssiResult>; | ||
@@ -185,0 +211,0 @@ read(options: ReadOptions): Promise<ReadResult>; |
@@ -1,4 +0,3 @@ | ||
/// <reference types="web-bluetooth" /> | ||
import { WebPlugin } from '@capacitor/core'; | ||
import type { BleDevice, BluetoothLePlugin, BooleanResult, DeviceIdOptions, GetConnectedDevicesOptions, GetDevicesOptions, GetDevicesResult, ReadOptions, ReadResult, ReadRssiResult, RequestBleDeviceOptions, WriteOptions } from './definitions'; | ||
import type { BleDevice, BleServices, BluetoothLePlugin, BooleanResult, DeviceIdOptions, GetConnectedDevicesOptions, GetDevicesOptions, GetDevicesResult, ReadOptions, ReadResult, ReadRssiResult, RequestBleDeviceOptions, WriteOptions } from './definitions'; | ||
export declare class BluetoothLeWeb extends WebPlugin implements BluetoothLePlugin { | ||
@@ -26,3 +25,5 @@ private deviceMap; | ||
disconnect(options: DeviceIdOptions): Promise<void>; | ||
getCharacteristic(options: ReadOptions | WriteOptions): Promise<BluetoothRemoteGATTCharacteristic | undefined>; | ||
getServices(options: DeviceIdOptions): Promise<BleServices>; | ||
private getProperties; | ||
private getCharacteristic; | ||
readRssi(_options: DeviceIdOptions): Promise<ReadRssiResult>; | ||
@@ -29,0 +30,0 @@ read(options: ReadOptions): Promise<ReadResult>; |
@@ -149,2 +149,31 @@ import { WebPlugin } from '@capacitor/core'; | ||
} | ||
async getServices(options) { | ||
var _a, _b; | ||
const services = (_b = (await ((_a = this.getDeviceFromMap(options.deviceId).gatt) === null || _a === void 0 ? void 0 : _a.getPrimaryServices()))) !== null && _b !== void 0 ? _b : []; | ||
const bleServices = []; | ||
for (const service of services) { | ||
const characteristics = await service.getCharacteristics(); | ||
const bleCharacteristics = characteristics.map((characteristic) => { | ||
return { | ||
uuid: characteristic.uuid, | ||
properties: this.getProperties(characteristic), | ||
}; | ||
}); | ||
bleServices.push({ uuid: service.uuid, characteristics: bleCharacteristics }); | ||
} | ||
return { services: bleServices }; | ||
} | ||
getProperties(characteristic) { | ||
return { | ||
broadcast: characteristic.properties.broadcast, | ||
read: characteristic.properties.read, | ||
writeWithoutResponse: characteristic.properties.writeWithoutResponse, | ||
write: characteristic.properties.write, | ||
notify: characteristic.properties.notify, | ||
indicate: characteristic.properties.indicate, | ||
authenticatedSignedWrites: characteristic.properties.authenticatedSignedWrites, | ||
reliableWrite: characteristic.properties.reliableWrite, | ||
writableAuxiliaries: characteristic.properties.writableAuxiliaries, | ||
}; | ||
} | ||
async getCharacteristic(options) { | ||
@@ -151,0 +180,0 @@ var _a; |
@@ -100,3 +100,3 @@ 'use strict'; | ||
if (enabled) { | ||
return throat__default['default'](1); | ||
return throat__default["default"](1); | ||
} | ||
@@ -249,2 +249,9 @@ else { | ||
} | ||
async getServices(deviceId) { | ||
const services = await this.queue(async () => { | ||
const result = await BluetoothLe$1.getServices({ deviceId }); | ||
return result.services; | ||
}); | ||
return services; | ||
} | ||
async readRssi(deviceId) { | ||
@@ -520,2 +527,31 @@ const value = await this.queue(async () => { | ||
} | ||
async getServices(options) { | ||
var _a, _b; | ||
const services = (_b = (await ((_a = this.getDeviceFromMap(options.deviceId).gatt) === null || _a === void 0 ? void 0 : _a.getPrimaryServices()))) !== null && _b !== void 0 ? _b : []; | ||
const bleServices = []; | ||
for (const service of services) { | ||
const characteristics = await service.getCharacteristics(); | ||
const bleCharacteristics = characteristics.map((characteristic) => { | ||
return { | ||
uuid: characteristic.uuid, | ||
properties: this.getProperties(characteristic), | ||
}; | ||
}); | ||
bleServices.push({ uuid: service.uuid, characteristics: bleCharacteristics }); | ||
} | ||
return { services: bleServices }; | ||
} | ||
getProperties(characteristic) { | ||
return { | ||
broadcast: characteristic.properties.broadcast, | ||
read: characteristic.properties.read, | ||
writeWithoutResponse: characteristic.properties.writeWithoutResponse, | ||
write: characteristic.properties.write, | ||
notify: characteristic.properties.notify, | ||
indicate: characteristic.properties.indicate, | ||
authenticatedSignedWrites: characteristic.properties.authenticatedSignedWrites, | ||
reliableWrite: characteristic.properties.reliableWrite, | ||
writableAuxiliaries: characteristic.properties.writableAuxiliaries, | ||
}; | ||
} | ||
async getCharacteristic(options) { | ||
@@ -522,0 +558,0 @@ var _a; |
@@ -96,3 +96,3 @@ var capacitorCommunityBluetoothLe = (function (exports, core, throat) { | ||
if (enabled) { | ||
return throat__default['default'](1); | ||
return throat__default["default"](1); | ||
} | ||
@@ -245,2 +245,9 @@ else { | ||
} | ||
async getServices(deviceId) { | ||
const services = await this.queue(async () => { | ||
const result = await BluetoothLe$1.getServices({ deviceId }); | ||
return result.services; | ||
}); | ||
return services; | ||
} | ||
async readRssi(deviceId) { | ||
@@ -516,2 +523,31 @@ const value = await this.queue(async () => { | ||
} | ||
async getServices(options) { | ||
var _a, _b; | ||
const services = (_b = (await ((_a = this.getDeviceFromMap(options.deviceId).gatt) === null || _a === void 0 ? void 0 : _a.getPrimaryServices()))) !== null && _b !== void 0 ? _b : []; | ||
const bleServices = []; | ||
for (const service of services) { | ||
const characteristics = await service.getCharacteristics(); | ||
const bleCharacteristics = characteristics.map((characteristic) => { | ||
return { | ||
uuid: characteristic.uuid, | ||
properties: this.getProperties(characteristic), | ||
}; | ||
}); | ||
bleServices.push({ uuid: service.uuid, characteristics: bleCharacteristics }); | ||
} | ||
return { services: bleServices }; | ||
} | ||
getProperties(characteristic) { | ||
return { | ||
broadcast: characteristic.properties.broadcast, | ||
read: characteristic.properties.read, | ||
writeWithoutResponse: characteristic.properties.writeWithoutResponse, | ||
write: characteristic.properties.write, | ||
notify: characteristic.properties.notify, | ||
indicate: characteristic.properties.indicate, | ||
authenticatedSignedWrites: characteristic.properties.authenticatedSignedWrites, | ||
reliableWrite: characteristic.properties.reliableWrite, | ||
writableAuxiliaries: characteristic.properties.writableAuxiliaries, | ||
}; | ||
} | ||
async getCharacteristic(options) { | ||
@@ -631,3 +667,3 @@ var _a; | ||
}({}, capacitorExports, throat)); | ||
})({}, capacitorExports, throat); | ||
//# sourceMappingURL=plugin.js.map |
{ | ||
"name": "@capacitor-community/bluetooth-le", | ||
"version": "1.3.1", | ||
"version": "1.4.0", | ||
"description": "Capacitor plugin for Bluetooth Low Energy ", | ||
@@ -13,3 +13,3 @@ "main": "dist/plugin.cjs.js", | ||
"verify:android": "cd android && ./gradlew clean build test && cd ..", | ||
"verify:web": "npm run build", | ||
"verify:web": "npm run test:coverage && npm run build", | ||
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint ios", | ||
@@ -41,21 +41,21 @@ "fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- lint --fix --format ios", | ||
"devDependencies": { | ||
"@capacitor/android": "^3.1.2", | ||
"@capacitor/cli": "^3.1.2", | ||
"@capacitor/core": "^3.1.2", | ||
"@capacitor/android": "^3.2.3", | ||
"@capacitor/cli": "^3.2.3", | ||
"@capacitor/core": "^3.2.3", | ||
"@capacitor/docgen": "^0.0.17", | ||
"@capacitor/ios": "^3.1.2", | ||
"@capacitor/ios": "^3.2.3", | ||
"@ionic/eslint-config": "^0.3.0", | ||
"@ionic/prettier-config": "^2.0.0", | ||
"@ionic/swiftlint-config": "^1.1.2", | ||
"@types/jest": "^27.0.1", | ||
"@types/jest": "^27.0.2", | ||
"eslint": "^7.32.0", | ||
"jest": "^27.0.6", | ||
"prettier": "^2.3.2", | ||
"prettier-plugin-java": "^1.3.1", | ||
"jest": "^27.2.1", | ||
"prettier": "^2.4.1", | ||
"prettier-plugin-java": "^1.4.0", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.56.2", | ||
"rollup": "^2.57.0", | ||
"standard-version": "^9.3.1", | ||
"swiftlint": "^1.0.1", | ||
"ts-jest": "^27.0.5", | ||
"typescript": "~4.3.5" | ||
"typescript": "~4.4.3" | ||
}, | ||
@@ -62,0 +62,0 @@ "peerDependencies": { |
@@ -59,2 +59,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> | ||
- [`disconnect(...)`](#disconnect) | ||
- [`getServices(...)`](#getservices) | ||
- [`readRssi(...)`](#readrssi) | ||
@@ -470,2 +471,18 @@ - [`read(...)`](#read) | ||
### getServices(...) | ||
```typescript | ||
getServices(deviceId: string) => Promise<BleService[]> | ||
``` | ||
Get services and characteristics of device. | ||
| Param | Type | Description | | ||
| -------------- | ------------------- | -------------------------------------------------------------------------------------------------------------- | | ||
| **`deviceId`** | <code>string</code> | The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan)) | | ||
**Returns:** <code>Promise<BleService[]></code> | ||
--- | ||
### readRssi(...) | ||
@@ -658,2 +675,33 @@ | ||
#### BleService | ||
| Prop | Type | | ||
| --------------------- | -------------------------------- | | ||
| **`uuid`** | <code>string</code> | | ||
| **`characteristics`** | <code>BleCharacteristic[]</code> | | ||
#### BleCharacteristic | ||
| Prop | Type | | ||
| ---------------- | ----------------------------------------------------------------------------------- | | ||
| **`uuid`** | <code>string</code> | | ||
| **`properties`** | <code><a href="#blecharacteristicproperties">BleCharacteristicProperties</a></code> | | ||
#### BleCharacteristicProperties | ||
| Prop | Type | | ||
| -------------------------------- | -------------------- | | ||
| **`broadcast`** | <code>boolean</code> | | ||
| **`read`** | <code>boolean</code> | | ||
| **`writeWithoutResponse`** | <code>boolean</code> | | ||
| **`write`** | <code>boolean</code> | | ||
| **`notify`** | <code>boolean</code> | | ||
| **`indicate`** | <code>boolean</code> | | ||
| **`authenticatedSignedWrites`** | <code>boolean</code> | | ||
| **`reliableWrite`** | <code>boolean</code> | | ||
| **`writableAuxiliaries`** | <code>boolean</code> | | ||
| **`extendedProperties`** | <code>boolean</code> | | ||
| **`notifyEncryptionRequired`** | <code>boolean</code> | | ||
| **`indicateEncryptionRequired`** | <code>boolean</code> | | ||
### Enums | ||
@@ -660,0 +708,0 @@ |
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
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
440138
4031
765