New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ember-bluetooth

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-bluetooth

The default blueprint for ember-cli addons.

  • 0.1.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

ember-bluetooth

This is an ongoing effort to build an easy-to-use addon to intereact with bluetooth devices within ember apps.

Web Bluetooth API

Web Bluetooth - Draft Community Group Report

Web Bluetooth Samples

Google Chrome - Bluetooth samples

Installation

ember install ember-bluetooth

Usage

Inject the bluetooth service

import Ember from 'ember';

export default Ember.Component.extend({
  bluetooth: Ember.inject.service(),
  ...
});

Connect a device.

IMPORTANT! This action should be the result of an user intereaction, otherwise the API will block the connection

<button class="btn" {{action "connect"}}><span>Connect!</span></button>
import Ember from 'ember';

export default Ember.Component.extend({
  bluetooth: Ember.inject.service(),

  actions: {
    connect() {
      this.get('bluetooth')
      .connectDevice({ filters: [{ services: ['battery_service'] }] })
      .then((device) => {
        console.log(`Connected to device: ${JSON.stringify(device)}`);
      });
    }
  }
});

Request a service/characteristic

This must be done after the connection.

import Ember from 'ember';

export default Ember.Component.extend({
  bluetooth: Ember.inject.service(),

  actions: {
   ...

   readValue() {
    this.get('bluetooth')
      .readValue('battery_service', 'battery_level')
      .then(value => {
       console.log(value);
      });
    }
  }
});

You can also request notification if a characteristic changes

import Ember from 'ember';

export default Ember.Component.extend({
  bluetooth: Ember.inject.service(),

 _handleValueEvent(event) {
    let batteryLevel = event.target.value.getUint8(0);
    console.log(batteryLevel);
  },

  actions: {
   ...

    startNotifications() {
      this.get('bluetooth')
        .startNotifications('battery_service', 'battery_level', (event) => this._handleValueEvent(event));
    }
  }
});

You can stop the notification ( not yet implemented in the Web Bluetooth API)

import Ember from 'ember';

export default Ember.Component.extend({
  bluetooth: Ember.inject.service(),

  actions: {
   ...

     stopNotifications() {
       this.get('bluetooth').stopNotifications();
     }
  }
});

Running

Running Tests

  • npm test (Runs ember try:each to test your addon against multiple Ember versions)
  • ember test
  • ember test --server

Building

  • ember build

For more information on using ember-cli, visit https://ember-cli.com/.

Keywords

FAQs

Package last updated on 08 Mar 2017

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