# pebblebee-bluetooth-web-sdk

> Tools to connect and manage bluetooth devices

Latest version **1.0.6** (published 2023-05-23) · ISC license · 0 weekly downloads

## Install

```sh
npm install pebblebee-bluetooth-web-sdk
pnpm add pebblebee-bluetooth-web-sdk
yarn add pebblebee-bluetooth-web-sdk
bun add pebblebee-bluetooth-web-sdk
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2023-05-23 |
| First published | 2023-05-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 13.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | pb-tomas-gargiulo |

## Links

- npm: https://www.npmjs.com/package/pebblebee-bluetooth-web-sdk
- Repository: https://github.com/PebbleBee/pebblebee-bluetooth-web-sdk
- Homepage: https://github.com/PebbleBee/pebblebee-bluetooth-web-sdk#readme
- Issues: https://github.com/PebbleBee/pebblebee-bluetooth-web-sdk/issues
- npm.io page: https://npm.io/package/pebblebee-bluetooth-web-sdk

## Dependencies (3)

- [typescript](https://npm.io/package/typescript.md) ^5.0.4
- [@types/node](https://npm.io/package/@types/node.md) ^20.2.3
- [@types/web-bluetooth](https://npm.io/package/@types/web-bluetooth.md) ^0.0.17

## Recent versions

- 1.0.6 (latest) — 2023-05-23
- 1.0.5 — 2023-05-23
- 1.0.4 — 2023-05-23
- 1.0.3 — 2023-05-23
- 1.0.2 — 2023-05-23
- 1.0.1 — 2023-05-23
- 1.0.0 — 2023-05-23

## README

# pebblebee-bluetooth-web-sdk

This project provides a set of functions and tools to simplify the use of the web bluetooth api to connect and manage Pebblebee device

## Important notes

- In order for the API to work, it has to be used on web site using HTTPS. It won't work on HTTP

- To connect to a device an User gesture required, like a button or click

- it has to be used on a browser that supports the Web bluetooth api

  https://developer.mozilla.org/en-US/docs/Web/API/Web_Bluetooth_API

## Functions

### bluetoothAvailable()

    Returns a boolean that represents if bluetooth is available for the browser

##### response

```javascript
    {
        //in case of error it will be false
        btAvailable: boolean
        error: boolean,
        message: string
    }
```

### connectToDeviceByMac(macAddress, deviceDisconnectedCallback)

    This function will the search devices dialog of the OS, onces the user selects one, it will return the select device object (BluetoothDevice).

##### Params

```javascript
    //used to filter the results that show in the connection dialog. 
    //hexadecimal, valid formats XXXXXXXXXXXX XX:XX:XX:XX:XX:XX XX-XX-XX-XX-XX-XX
    macAddress: string
    //This function will be invoque in case the device disconnects
    deviceDisconnectedCallback: function () => void
```

##### response

```javascript
    {
        device: BluetoothDevice | undefined,
        error: boolean,
        message: string
    }
```

### getBatteryPercentage(device)

    This function connect to the device battery service and parse the battery level into a percentage.

##### Params

```javascript
    //The device that the action is perfomed on
    device: BluetoothDevice 
```

##### response

```javascript
    {
        //if there is and error this will be 0
        batteryPercentage: number,
        error: boolean,
        message: string
    }
```

### buzz(device)

    This function will connect to the device and send a "buzz" command to it

##### Params

```javascript
    //The device that the action is perfomed on
    device: BluetoothDevice;
```

##### response

```javascript
    {
        error: boolean,
        message: string
    }

```

### stopBuzz(device)

    This function will connect to the device and send a "stop buzzing" command to it

#### Params

```javascript
    //The device that the action is perfomed on
    device: BluetoothDevice

```

##### response

```javascript
    {
        error: boolean,
        message: string
    }

```


```

---
_Source: https://npm.io/package/pebblebee-bluetooth-web-sdk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
