npm package: @posx/capacitor-usb-printer
Description: Capacitor plugin for USB ESC/POS thermal printer via Android USB Host API
Author: posx team
Latest version: 0.0.8

# @posx/capacitor-usb-printer

Capacitor plugin for

## Install

```bash
npm install @posx/capacitor-usb-printer
npx cap sync
```

## API

<docgen-index>

* [`listDevices()`](#listdevices)
* [`requestPermission(...)`](#requestpermission)
* [`connect(...)`](#connect)
* [`disconnect(...)`](#disconnect)
* [`print(...)`](#print)
* [`getStatus(...)`](#getstatus)
* [`addListener('deviceAttached', ...)`](#addlistenerdeviceattached-)
* [`addListener('deviceDetached', ...)`](#addlistenerdevicedetached-)
* [Interfaces](#interfaces)

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

### listDevices()

```typescript
listDevices() => Promise<{ devices: UsbDevice[]; }>
```

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

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


### requestPermission(...)

```typescript
requestPermission(options: { deviceId: number; }) => Promise<{ granted: boolean; }>
```

| Param         | Type                               |
| ------------- | ---------------------------------- |
| **`options`** | <code>{ deviceId: number; }</code> |

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

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


### connect(...)

```typescript
connect(options: { deviceId: number; }) => Promise<{ connected: boolean; }>
```

| Param         | Type                               |
| ------------- | ---------------------------------- |
| **`options`** | <code>{ deviceId: number; }</code> |

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

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


### disconnect(...)

```typescript
disconnect(options: { deviceId: number; }) => Promise<void>
```

| Param         | Type                               |
| ------------- | ---------------------------------- |
| **`options`** | <code>{ deviceId: number; }</code> |

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


### print(...)

```typescript
print(options: { deviceId: number; data: string; }) => Promise<void>
```

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

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


### getStatus(...)

```typescript
getStatus(options: { deviceId: number; }) => Promise<{ connected: boolean; deviceName: string; serialNumber: string; }>
```

| Param         | Type                               |
| ------------- | ---------------------------------- |
| **`options`** | <code>{ deviceId: number; }</code> |

**Returns:** <code>Promise&lt;{ connected: boolean; deviceName: string; serialNumber: string; }&gt;</code>

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


### addListener('deviceAttached', ...)

```typescript
addListener(eventName: 'deviceAttached', listenerFunc: (device: UsbDevice) => void) => Promise<PluginListenerHandle>
```

| Param              | Type                                                                 |
| ------------------ | -------------------------------------------------------------------- |
| **`eventName`**    | <code>'deviceAttached'</code>                                        |
| **`listenerFunc`** | <code>(device: <a href="#usbdevice">UsbDevice</a>) =&gt; void</code> |

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

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


### addListener('deviceDetached', ...)

```typescript
addListener(eventName: 'deviceDetached', listenerFunc: (device: UsbDevice) => void) => Promise<PluginListenerHandle>
```

| Param              | Type                                                                 |
| ------------------ | -------------------------------------------------------------------- |
| **`eventName`**    | <code>'deviceDetached'</code>                                        |
| **`listenerFunc`** | <code>(device: <a href="#usbdevice">UsbDevice</a>) =&gt; void</code> |

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

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


### Interfaces


#### UsbDevice

| Prop                   | Type                |
| ---------------------- | ------------------- |
| **`deviceId`**         | <code>number</code> |
| **`vendorId`**         | <code>number</code> |
| **`productId`**        | <code>number</code> |
| **`deviceName`**       | <code>string</code> |
| **`portPath`**         | <code>string</code> |
| **`manufacturerName`** | <code>string</code> |
| **`productName`**      | <code>string</code> |
| **`serialNumber`**     | <code>string</code> |


#### PluginListenerHandle

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

</docgen-api>