# @kano/devices-sdk

> Allows the detection and comunication with Kano devices.

Latest version **1.0.1** (published 2018-10-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install @kano/devices-sdk
pnpm add @kano/devices-sdk
yarn add @kano/devices-sdk
bun add @kano/devices-sdk
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2018-10-15 |
| First published | 2018-10-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 202.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Kano Computing |
| Maintainers | alicemarshall, denis95, kanocomputing, marcus7777, nectarsoft, paulmck21, paulvarache, rpazdera |

## Links

- npm: https://www.npmjs.com/package/@kano/devices-sdk
- npm.io page: https://npm.io/package/@kano/devices-sdk

## Dependencies (2)

- [jszip](https://npm.io/package/jszip.md) ^3.1.5
- [@kano/common](https://npm.io/package/@kano/common.md) ^1.0.2

## Recent versions

- 1.0.1 (latest) — 2018-10-15

## README

# kano-devices-sdk

Allows the detection and comunication with Kano devices.

## Platform independance

This SDK aims to be platform independant as it doesn't implement any Bluetooth, Wi-FI or serial communication.
Instead it provides classes expecting a mixin for a BLEDevice/SerialDevice/WiFIDevice to be provided.

## Platform support

Some platforms are already supported and available in the `platforms` directory.

### Nodejs

Bluetooth communication is supported in a nodejs environment using the modules `noble` or `noble-uwp`. These modules will need to be installed in your project.

### Cordova

Bluetooth communication is supported in a cordova environment using the plugin cordova-plugin-bluetoothle.

## Example


```js
import Devices from '../kano-devices/sdk/kano-devices-sdk.js';
// Pltform specific bluetooth watcher and device mixin
import Watcher from './ble-watcher.js';
import BLEDeviceMixin from './ble-device.js';

const DevicesManager = new Devices({
    bluetooth: {
        watcher: new Watcher(),
        deviceMixin: BLEDeviceMixin,
    },
});

export default DevicesManager;

```

Example of a mixin for the BLEDevice:

```js
// Return a function that will receive the Device class. It needs to extends it, implement the bluetooth methods and return the BLEDevice class
const BLEDeviceMixin = (Device) => {
    class BLEDevice extends Device {
        // Will receive the device object the watcher found
        constructor(device) {
            super();
            this.type = 'ble-device';
            // Do something with the device object
        }
        // Implement here the methods
    }
    return BLEDevice;
};

export default BLEDeviceMixin;

```

## Connection lifecycle

A BLEDevice must track the state of its connection following this State Machine Diagram:

![](./Connection-state-machine.png)

### Possible future applications:

 - Write a websocket adapter

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