npm package: @matfire/ionic_bluetooth_classic
Description: bluetooth discovery and communication
Latest version: 0.0.6

# bluetooth

bluetooth classic discovery and communication

**currently only works on Android, IOS coming eventually**

## Install

```bash
npm install @matfire/ionic_bluetooth_classic
npx cap sync
```

### Permissions

#### Android

add the following lines to your AndroidManifest.xml file:

```xml
    <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

<docgen-index>

* [`checkPermissions()`](#checkpermissions)
* [`requestPermissions()`](#requestpermissions)
* [`startListening()`](#startlistening)
* [`stopListening()`](#stoplistening)
* [`write(...)`](#write)
* [`addListener('deviceConnectionStatusChanged', ...)`](#addlistenerdeviceconnectionstatuschanged)
* [`addListener('deviceDataReceived', ...)`](#addlistenerdevicedatareceived)
* [`addListener('deviceDiscovered', ...)`](#addlistenerdevicediscovered)
* [`getPairedDevices()`](#getpaireddevices)
* [`connect(...)`](#connect)
* [`disconnect()`](#disconnect)
* [Interfaces](#interfaces)
* [Type Aliases](#type-aliases)
* [Enums](#enums)

</docgen-index>

<docgen-api>
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->

### checkPermissions()

```typescript
checkPermissions() => Promise<PermissionStatus>
```

**Returns:** <code>Promise&lt;<a href="#permissionstatus">PermissionStatus</a>&gt;</code>

--------------------


### requestPermissions()

```typescript
requestPermissions() => Promise<PermissionStatus>
```

**Returns:** <code>Promise&lt;<a href="#permissionstatus">PermissionStatus</a>&gt;</code>

--------------------


### startListening()

```typescript
startListening() => Promise<boolean>
```

**Returns:** <code>Promise&lt;boolean&gt;</code>

--------------------


### stopListening()

```typescript
stopListening() => Promise<boolean>
```

**Returns:** <code>Promise&lt;boolean&gt;</code>

--------------------


### write(...)

```typescript
write(data: { message: string; }) => Promise<boolean>
```

| Param      | Type                              |
| ---------- | --------------------------------- |
| **`data`** | <code>{ message: string; }</code> |

**Returns:** <code>Promise&lt;boolean&gt;</code>

--------------------


### addListener('deviceConnectionStatusChanged', ...)

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

| Param              | Type                                                                                      |
| ------------------ | ----------------------------------------------------------------------------------------- |
| **`eventName`**    | <code>'deviceConnectionStatusChanged'</code>                                              |
| **`listenerFunc`** | <code>({ data }: { data: <a href="#idevicestatus">IDeviceStatus</a>; }) =&gt; void</code> |

**Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt; & <a href="#pluginlistenerhandle">PluginListenerHandle</a></code>

--------------------


### addListener('deviceDataReceived', ...)

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

| Param              | Type                                                                                      |
| ------------------ | ----------------------------------------------------------------------------------------- |
| **`eventName`**    | <code>'deviceDataReceived'</code>                                                         |
| **`listenerFunc`** | <code>({ data }: { data: <a href="#idatareceived">IDataReceived</a>; }) =&gt; void</code> |

**Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt; & <a href="#pluginlistenerhandle">PluginListenerHandle</a></code>

--------------------


### addListener('deviceDiscovered', ...)

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

| Param              | Type                                                                              |
| ------------------ | --------------------------------------------------------------------------------- |
| **`eventName`**    | <code>'deviceDiscovered'</code>                                                   |
| **`listenerFunc`** | <code>({ device }: { device: <a href="#idevice">IDevice</a>; }) =&gt; void</code> |

**Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt; & <a href="#pluginlistenerhandle">PluginListenerHandle</a></code>

--------------------


### getPairedDevices()

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

**Returns:** <code>Promise&lt;{ devices: any[]; }&gt;</code>

--------------------


### connect(...)

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

| Param      | Type                                                |
| ---------- | --------------------------------------------------- |
| **`data`** | <code>{ deviceId: string; appUUID: string; }</code> |

**Returns:** <code>Promise&lt;boolean&gt;</code>

--------------------


### disconnect()

```typescript
disconnect() => Promise<boolean>
```

**Returns:** <code>Promise&lt;boolean&gt;</code>

--------------------


### Interfaces


#### PermissionStatus

| Prop            | Type                                                        |
| --------------- | ----------------------------------------------------------- |
| **`bluetooth`** | <code><a href="#permissionstate">PermissionState</a></code> |
| **`location`**  | <code><a href="#permissionstate">PermissionState</a></code> |


#### PluginListenerHandle

| Prop         | Type                                      |
| ------------ | ----------------------------------------- |
| **`remove`** | <code>() =&gt; Promise&lt;void&gt;</code> |


#### IDeviceStatus

| Prop           | Type                                                  |
| -------------- | ----------------------------------------------------- |
| **`deviceId`** | <code>string</code>                                   |
| **`status`**   | <code><a href="#devicestatus">DeviceStatus</a></code> |


#### IDataReceived

| Prop        | Type                |
| ----------- | ------------------- |
| **`bytes`** | <code>string</code> |
| **`size`**  | <code>number</code> |


#### IDevice

| Prop          | Type                |
| ------------- | ------------------- |
| **`address`** | <code>string</code> |
| **`name`**    | <code>string</code> |


### Type Aliases


#### PermissionState

<code>'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'</code>


### Enums


#### DeviceStatus

| Members            | Value          |
| ------------------ | -------------- |
| **`DISCONNECTED`** | <code>0</code> |
| **`CONNECTED`**    | <code>1</code> |
| **`CONNECTING`**   | <code>2</code> |

</docgen-api>