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

espruino-ble-uart

v1.0.3

Published

This is an Espruino Web Tool that implements the Nordic UART Service (NUS) by Nordic Semiconductors for BLE use. This allows BLE devices to communicate using UART via Bluetooth Low Energy.

Downloads

9

Readme

Short Description:

This is an Espruino Web Tool that implements the Nordic UART Service (NUS) by Nordic Semiconductors for BLE use. This allows BLE devices to communicate using UART via Bluetooth Low Energy.

This can be used with or without an Espruino board, this module searches for all NUS enabled devices.

Author:

The module is written by Gordon Williams (github.com/gfwilliams) for Espruino and is distributed under the Apache 2.0 License. I have merely uploaded and documented it for ease of use.

Installation:

In your terminal :

$  npm add espruino-ble-uart

Usage:

In your JavaScript code:

const uart = require( "espruino-ble-uart")

Available functions:
  1. connect : Connect to a new device - this creates a separate connection to the one write and eval use.

    Usage: uart.connect(your_function)

  2. write : Write to a device and call back when the data is written. Creates a connection if it doesn't exist

  3. eval : Evaluate an expression and call cb with the result. Creates a connection if it doesn't exist

  4. isConnected : Did write and eval manage to create a connection?

  5. getConnection : get the connection used by write and eval

  6. close : Close the connection used by write and eval

  7. modal: Utility function to fade out everything on the webpage and display a window saying 'Click to continue'. When clicked it'll disappear and 'callback' will be called. This is useful because you can't initialise Web Bluetooth unless you're doing so in response to a user input.

    Usage: uart.modal(your_function)

    modal : function(callback) {
       var e = document.createElement('div');
        e.style = 'position:absolute;top:0px;left:0px;right:0px;bottom:0px;opacity:0.5;z-index:100;background:black;';
        e.innerHTML = '<div style="position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);font-family: Sans-Serif;font-size:400%;color:white;">Click to Continue...</div>';
        e.onclick = function(evt) {
        callback();
        evt.preventDefault();
        document.body.removeChild(e);
        };
        document.body.appendChild(e);
    }
  8. setTime : Write the current time to the device. Note: This is for Espruino devices

    Usage: uart.setTime(your_function)

    setTime : function(cb) {
      var d = new Date();
      var cmd = 'setTime('+(d.getTime()/1000)+');';
      // in 1v93 we have timezones too
      cmd += 'if (E.setTimeZone) E.setTimeZone('+d.getTimezoneOffset()/-60+');\n';
      write(cmd, cb);
    }

Note on console output:

<UART> Web Serial not supported, No navigator.serial - Web Serial not enabled Refers to the USB Serial port, if you are using BLE this message is irrelevant.