Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bleat

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bleat

Abstraction library for hiding differences in JavaScript BLE APIs

  • 0.0.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

bleat

Circle CI Bower npm Licence MIT

Bleat (Blutooth Low Energy Abstraction Tool) provides a simplified BLE layer which uses adapters to abstract the usage of BLE in JavaScript on different platforms.

Roadmap

Basic BLE layer
  • Central Mode
    • Device Scan
    • Advertised Service UUIDs
    • Connect/Disconnect
    • List Services/Characteristics/Descriptors
    • Read/Write/Notify Characteristics
    • Read/Write Descriptors
  • Peripheral Mode
    • Advertising
Adapters

Installation

npm install bleat
      -or-
bower install bleat

Usage

The main bleat.js file offers the BLE layer while each bleat.<platform>.js file represents an adapter. The bleat.min.js file is a minified version of the BLE layer and all adapters.

Files follow the UMD (https://github.com/umdjs/umd), so should work with AMD (requirejs), CommonJS (node) and plain JavaScript projects.

Include (or require) the bleat.js file before the adapter you wish to use or include the minified file offering all adapters.

e.g.

<script src="path/to/bleat.js"></script>
<script src="path/to/bleat.<adapter>.js"></script>
      -or-
<script src="path/to/bleat.min.js"></script>

API

bleat

bleat.init

Initialise bleat.

void bleat.init([readyFn], [errorFn], [adapterName]);

function readyFn(): callback function once init has completed

function errorFn(message): callback function for all errors while bleating

string adapterName: when multiple adapters available, specify which to use

bleat.startScan

Start scanning for devices.

void bleat.startScan(foundFn);

function foundFn(device): callback function for each device discovered.

bleat.stopScan

Stop scanning for devices.

void bleat.stopScan();

device

string device.address: uuid of device

string device.name: name of device

bool device.connected: whether device is connected

string array device.serviceUUIDs: array of advertised services

object services: map of device services keyed on service uuid (available once connected)

device.hasService

Returns whether a device has the specified service.

bool device.hasService(serviceUUID);

string serviceUUID: service to search for

device.connect

Connect to the device.

void device.connect(connectFn, disconnectFn);

function connectFn(): callback once connected

function disconnectFn(): callback when disconnected

device.disconnect

Disconnect from device.

void device.disconnect();

Service

string uuid: uuid of service

bool primary: whether service is primary or not

object characteristics: map of service characteristics keyed on characteristic uuid

Characteristic

string uuid: uuid of characteristic

string array properties: characteristic properties

object descriptors: map of characteristic descriptors keyed on descriptor uuid

characteristic.read

Read value of characteristic.

void characteristic.read(completeFn);

function completeFn(ArrayBuffer): callback function containing value

characteristic.write

Write value to characteristic.

void characteristic.write(bufferView, completeFn);

DataView bufferView: value to write

function completeFn(): callback function once completed

characteristic.enableNotify

Enable notifications when characteristic value changes.

void characteristic.enableNotify(notifyFn);

function notifyFn(ArrayBuffer): callback function containing value when changes

characteristic.disableNotify

Disable characteristic notifications.

void characteristic.disableNotify(completeFn);

function completeFn(): callback function once completed

Descriptor

string uuid: uuid of descriptor

descriptor.read

Read value of descriptor.

void descriptor.read(completeFn);

function completeFn(ArrayBuffer): callback function containing value

descriptor.write

Write value to descriptor.

void descriptor.write(bufferView, completeFn);

DataView bufferView: value to write function completeFn(): callback function once completed

Keywords

FAQs

Package last updated on 19 Apr 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc