npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bluetooth-websocket-api

v0.0.2

Published

Bluetooth Websocket API - a JavaScript library that provides a simple WebSocket API to find, connect and interact with Bluetooth devices.

Downloads

12

Readme

Bluetooth Websocket API

The Bluetooth WebSocket API is an abstraction layer on top of the Web Bluetooth JavaScript API. The Web Bluetooth API allows websites to connect and interact with Bluetooth Low Energy devices. The library does not introduces a new API but extends the JavaScript functions as WebSocket messages. This can be handy when you want to write Bluetooth enabled webapps and already have an implementation on the server.

As the Bluetooth operations are dictated by the server, the front-end setup is straight forward. The Bluetooth search command, connect and communication are all initiated by the server side.

There are many different protocols on top of the WebSocket standard. The library has been designed while having this in mind, hence there is a separation between the library core and WebSocket adapter. Today Phoenix framework WebSocket channels are supported.

Requirements

  • Android6.0+, Chrome OS or OS X. The full list of supported hardware is all the time updated by the Web Bluetooth workgroup
  • Chrome v50+
  • HTTPS due to WebBluetooth security requirements

Features/Usage

This library consists of three parts:

  • Core

    Handles the Web Bluetooth API and maps functions to the WebSocket adapter.

  • Adapter

    WebSocket specific implementation, formats and sends the messages back/forth between Core and the server.

  • App

    An example app of usage is included in the repo, this can be used together with the Phoenix server reference app Bluetooth WebSocket Server.

Below is a simplified chart showing the different Bluetooth messages passed through the library. socket_message

For more detail of each socket event please see the Wiki page Wiki - Socket messages specification.

Installation of reference app

To start your app

Install node_module with npm install

To use SSL on localhost with WebBluetoothAPI

  1. Generate key with openssl genrsa -out localhost.key 2048
  2. Generate cert with openssl req -new -x509 -key localhost.key -out localhost.cert -days 3650 -subj /CN=localhost
  3. Put them in a directory /keys/
  4. Start server with node server.js

Now you can visit localhost:3000 with SSL from your browser.

To build js file when you update

  1. Update source file of app/app/js
  2. Run build with npm run build
  3. The file will be created to dist/app.js

To start your HTTPS server on local:

node server.js

Now you can visit localhost:3000/app from your browser.

Of course you can use your apache server.

Caution

  • The value should be encoded with base64 when you read/write value.
  • Adapter#requestDevice() method should be fired by click event (due to WebBluetoothAPI specification).
  • characteristicvaluechanged event is fired by after not only its value changes but also a value change notification/indication (due to WebBluetoothAPI specification).

Licence

MIT

Author

HIGH MOBILITY

Recruit Technologies (@tkybpp)