@nosslabs/bluetooth-classic
v1.1.1
Published
Simple and straightforward implementation of classic bluetooth communication
Downloads
17
Readme
@nossdev/bluetooth-classic
Simple and straightforward implementation of classic bluetooth communication
Install
npm install @nossdev/bluetooth-classic
npx cap syncAPI
scan(...)pair(...)connect(...)write(...)read(...)readUntil(...)disconnect()isEnabled()enable()addListener(BluetoothState | 'bluetoothState', ...)removeAllListeners()checkPermissions()requestPermissions()- Interfaces
- Type Aliases
scan(...)
scan(options?: ScanOptions | undefined) => Promise<ScanResult>| Param | Type |
| ------------- | --------------------------------------------------- |
| options | ScanOptions |
Returns: Promise<ScanResult>
pair(...)
pair(options: PairOptions) => Promise<void>| Param | Type |
| ------------- | --------------------------------------------------- |
| options | PairOptions |
connect(...)
connect(options: ConnectOptions) => Promise<void>| Param | Type |
| ------------- | --------------------------------------------------------- |
| options | ConnectOptions |
write(...)
write(options: WriteOptions) => Promise<void>| Param | Type |
| ------------- | ----------------------------------------------------- |
| options | WriteOptions |
read(...)
read(options?: ReadOptions | undefined) => Promise<ReadResult>| Param | Type |
| ------------- | --------------------------------------------------- |
| options | ReadOptions |
Returns: Promise<ReadResult>
readUntil(...)
readUntil(options: ReadUntilOptions) => Promise<ReadResult>| Param | Type |
| ------------- | ------------------------------------------------------------- |
| options | ReadUntilOptions |
Returns: Promise<ReadResult>
disconnect()
disconnect() => Promise<void>isEnabled()
isEnabled() => Promise<{ enabled: boolean; }>Returns: Promise<{ enabled: boolean; }>
enable()
enable() => Promise<{ enabled: boolean; }>Returns: Promise<{ enabled: boolean; }>
addListener(BluetoothState | 'bluetoothState', ...)
addListener(eventName: BluetoothState | 'bluetoothState', listenerFunc: (data: BluetoothStateEvent) => void) => Promise<PluginListenerHandle>| Param | Type |
| ------------------ | -------------------------------------------------------------------------------------- |
| eventName | BluetoothState | 'bluetoothState' |
| listenerFunc | (data: BluetoothStateEvent) => void |
Returns: Promise<PluginListenerHandle>
removeAllListeners()
removeAllListeners() => Promise<void>checkPermissions()
checkPermissions() => Promise<PermissionStatus>Returns: Promise<PermissionStatus>
requestPermissions()
requestPermissions() => Promise<PermissionStatus>Returns: Promise<PermissionStatus>
Interfaces
ScanResult
| Prop | Type |
| ------------- | ------------------------------ |
| devices | BluetoothDevice[] |
BluetoothDevice
| Prop | Type |
| ----------------- | --------------------------------------------------------------- |
| name | string |
| type | DeviceType |
| state | DeviceState |
| address | string |
| addressType | DeviceAddressType |
ScanOptions
| Prop | Type |
| -------------- | ------------------- |
| duration | number |
PairOptions
| Prop | Type |
| ------------- | ------------------- |
| address | string |
ConnectOptions
| Prop | Type |
| ------------- | ------------------- |
| address | string |
WriteOptions
| Prop | Type |
| ---------- | --------------------- |
| data | number[] |
ReadResult
| Prop | Type |
| ---------- | --------------------- |
| data | number[] |
ReadOptions
| Prop | Type |
| ------------- | ------------------- |
| timeout | number |
ReadUntilOptions
| Prop | Type |
| --------------- | --------------------- |
| delimiter | number[] |
PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| remove | () => Promise<void> |
PermissionStatus
| Prop | Type |
| ------------ | ---------------------------------------------- |
| status | 'granted' | 'denied' | 'prompt' |
Type Aliases
DeviceType
'classic' | 'le' | 'dual' | 'unknown'
DeviceState
'none' | 'bonded' | 'bonding' | 'unknown'
DeviceAddressType
'public' | 'random' | 'anonymous' | 'unknown'
BluetoothState
'on' | 'off' | 'turning_on' | 'turning_off'
BluetoothStateEvent
{ value: BluetoothState }
