@matfire/ionic_bluetooth_classic
TypeScript icon, indicating that this package has built-in type declarations

0.0.6 • Public • Published

bluetooth

bluetooth classic discovery and communication

currently only works on Android, IOS coming eventually

Install

npm install @matfire/ionic_bluetooth_classic
npx cap sync

Permissions

Android

add the following lines to your AndroidManifest.xml file:

    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

API

checkPermissions()

checkPermissions() => Promise<PermissionStatus>

Returns: Promise<PermissionStatus>


requestPermissions()

requestPermissions() => Promise<PermissionStatus>

Returns: Promise<PermissionStatus>


startListening()

startListening() => Promise<boolean>

Returns: Promise<boolean>


stopListening()

stopListening() => Promise<boolean>

Returns: Promise<boolean>


write(...)

write(data: { message: string; }) => Promise<boolean>
Param Type
data { message: string; }

Returns: Promise<boolean>


addListener('deviceConnectionStatusChanged', ...)

addListener(eventName: 'deviceConnectionStatusChanged', listenerFunc: ({ data }: { data: IDeviceStatus; }) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
Param Type
eventName 'deviceConnectionStatusChanged'
listenerFunc ({ data }: { data: IDeviceStatus; }) => void

Returns: Promise<PluginListenerHandle> & PluginListenerHandle


addListener('deviceDataReceived', ...)

addListener(eventName: 'deviceDataReceived', listenerFunc: ({ data }: { data: IDataReceived; }) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
Param Type
eventName 'deviceDataReceived'
listenerFunc ({ data }: { data: IDataReceived; }) => void

Returns: Promise<PluginListenerHandle> & PluginListenerHandle


addListener('deviceDiscovered', ...)

addListener(eventName: 'deviceDiscovered', listenerFunc: ({ device }: { device: IDevice; }) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
Param Type
eventName 'deviceDiscovered'
listenerFunc ({ device }: { device: IDevice; }) => void

Returns: Promise<PluginListenerHandle> & PluginListenerHandle


getPairedDevices()

getPairedDevices() => Promise<{ devices: any[]; }>

Returns: Promise<{ devices: any[]; }>


connect(...)

connect(data: { deviceId: string; appUUID: string; }) => Promise<boolean>
Param Type
data { deviceId: string; appUUID: string; }

Returns: Promise<boolean>


disconnect()

disconnect() => Promise<boolean>

Returns: Promise<boolean>


Interfaces

PermissionStatus

Prop Type
bluetooth PermissionState
location PermissionState

PluginListenerHandle

Prop Type
remove () => Promise<void>

IDeviceStatus

Prop Type
deviceId string
status DeviceStatus

IDataReceived

Prop Type
bytes string
size number

IDevice

Prop Type
address string
name string

Type Aliases

PermissionState

'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'

Enums

DeviceStatus

Members Value
DISCONNECTED 0
CONNECTED 1
CONNECTING 2

Package Sidebar

Install

npm i @matfire/ionic_bluetooth_classic

Weekly Downloads

1

Version

0.0.6

License

MIT

Unpacked Size

55.5 kB

Total Files

32

Last publish

Collaborators

  • matfire