capacitor-bluetooth-classic-basic
v0.0.4
Published
A work in progress capacitor plugin that communicates with legacy bluetooth
Downloads
8
Readme
capacitor-bluetooth-classic-basic
A work in progress capacitor plugin that communicates with legacy bluetooth
Install
npm install capacitor-bluetooth-classic-basic
npx cap sync
API
echo(...)
startDiscovering(...)
cancelDiscovering()
connectToDevice(...)
disconnectFromDevice()
sendDataToDevice(...)
addListener('discoveryStartEvent', ...)
addListener('discoveryStopEvent', ...)
addListener('deviceFoundEvent', ...)
addListener('deviceRecvDataEvent', ...)
- Interfaces
echo(...)
echo(options: { value: string; }) => Promise<{ value: string; }>
| Param | Type |
| ------------- | ------------------------------- |
| options
| { value: string; } |
Returns: Promise<{ value: string; }>
startDiscovering(...)
startDiscovering(options?: { periodically: boolean; } | undefined) => Promise<{ status: number; message: string; }>
Start the discovering process for finding bluetooth devices.
| Param | Type |
| ------------- | --------------------------------------- |
| options
| { periodically: boolean; } |
Returns: Promise<{ status: number; message: string; }>
cancelDiscovering()
cancelDiscovering() => Promise<any>
Cancels the discovering process for finding bluetooth devices.
Returns: Promise<any>
connectToDevice(...)
connectToDevice(options: { address: string; }) => Promise<{ status: string; }>
Connects to the specified device with the address.
| Param | Type |
| ------------- | --------------------------------- |
| options
| { address: string; } |
Returns: Promise<{ status: string; }>
disconnectFromDevice()
disconnectFromDevice() => Promise<{ status: string; }>
Disconnects the current connected device.
Returns: Promise<{ status: string; }>
sendDataToDevice(...)
sendDataToDevice(options: { data: string; }) => Promise<{ status: string; }>
Sends data to the connected device.
| Param | Type |
| ------------- | ------------------------------ |
| options
| { data: string; } |
Returns: Promise<{ status: string; }>
addListener('discoveryStartEvent', ...)
addListener(eventName: 'discoveryStartEvent', callback: () => void) => Promise<PluginListenerHandle> & PluginListenerHandle
DiscoveryStartEvent
| Param | Type |
| --------------- | ---------------------------------- |
| eventName
| 'discoveryStartEvent' |
| callback
| () => void |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
addListener('discoveryStopEvent', ...)
addListener(eventName: 'discoveryStopEvent', callback: () => void) => Promise<PluginListenerHandle> & PluginListenerHandle
DiscoveryStopEvent
| Param | Type |
| --------------- | --------------------------------- |
| eventName
| 'discoveryStopEvent' |
| callback
| () => void |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
addListener('deviceFoundEvent', ...)
addListener(eventName: 'deviceFoundEvent', callback: (device: Device) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
DeviceFoundListener
| Param | Type | Description |
| --------------- | -------------------------------------------------------------- | ---------------- |
| eventName
| 'deviceFoundEvent' | DeviceFoundEvent |
| callback
| (device: Device) => void | Callback |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
addListener('deviceRecvDataEvent', ...)
addListener(eventName: 'deviceRecvDataEvent', callback: (data: DeviceData) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
DeviceRecvDataListener
| Param | Type | Description |
| --------------- | -------------------------------------------------------------------- | ------------------- |
| eventName
| 'deviceRecvDataEvent' | DeviceRecvDataEvent |
| callback
| (data: DeviceData) => void | Callback |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
Interfaces
PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| remove
| () => Promise<void> |
Device
| Prop | Type |
| ------------- | ------------------- |
| name
| string |
| type
| number |
| address
| string |
| rssi
| number |
DeviceData
| Prop | Type |
| ---------- | ------------------- |
| data
| string |