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

cc2uart

v0.0.3

Published

Use the TI CC2540 Bluetooth Low Energy UART interface

Downloads

4

Readme

cc2uart -- node-cc2540

node.js support for the TI CC2540 UART service. The CC2540 is programmable so there is no guarantee this works with all boards with the CC2540 chip.

This module is built on noble so it should work where ever noble works.

See also nrfuart if using the nRF8001 or nRF51822 chip.

Tested configurations

A USB to Bluetooth 4.0 gadget similar to this is required to add BLE support to systems without Bluetooth 4.0/BLE hardware.

Laptop running Ubuntu Linux 14.04

Laptop running Ubuntu 14.04 <-> BLE <-> CC2540 <-> Arduino Uno

Ubuntu 14.04 includes bluez 4.101 which is sufficient for this module. Install the following packages before installing cc2uart.

sudo apt-get install bluetooth bluez-utils libbluetooth-dev

Raspberry Pi running Raspbian Linux

The tested device is a Raspberry Pi Model B running a fresh installation of Raspian release 2015-02-16. Be sure to do the usual post-installation steps such as "sudo apt-get update", "sudo apt-get upgrade", and "sudo raspi-config".

The next step is to install node.js. The version of node.js in the Raspian repo is too old so install a recent version.

wget http://node-arm.herokuapp.com/node_0.10.36_armhf.deb
sudo dpkg -i node_0.10.36_armhf.deb

Install bluez 4.99 from the Raspian repo. Testing has shown this version works with BLE and noble. This is much easier and faster than install bluez 5.x from source code.

sudo apt-get install bluez bluez-tools libbluetooth-dev

If bluez 4.99 does not work, remove it then install bluez 5.x as described below. Remember, do the next block of commands only if BLE is not working.

sudo apt-get remove bluez bluez-tools libbluetooth-dev
# Reference: http://www.elinux.org/RPi_Bluetooth_LE
sudo apt-get install libdbus-1-dev libdbus-glib-1-dev libglib2.0-dev \
libical-dev libreadline-dev libudev-dev libusb-dev make
mkdir bluez
cd bluez
wget https://www.kernel.org/pub/linux/bluetooth/bluez-5.28.tar.xz
tar xf bluez-5.28.tar.xz
cd bluez-5.28
./configure --disable-systemd --enable-library
# The next step takes a long time.
make
sudo make install
sudo hciconfig hci0 up

Install this module

npm install cc2uart 

Use this module

This program sends a test pattern and displays anything that comes back.

var cc2uart = require('cc2uart');

cc2uart.discoverAll(function(ble_uart) {
    // enable disconnect notifications
    ble_uart.on('disconnect', function() {
        console.log('disconnected!');
    });

    // connect and setup
    ble_uart.connectAndSetup(function() {
        var writeCount = 0;

        console.log('connected!');

        ble_uart.readSystemId(function(sysID) {
            console.log('System ID:', sysID);
        });

        ble_uart.on('data', function(data) {
            console.log('received:', data.toString());
        });

        setInterval(function() {
            var TESTPATT = 'Hello world! ' + writeCount.toString();
            ble_uart.write(TESTPATT, function() {
                console.log('data sent:', TESTPATT);
                writeCount++;
            });
        }, 3000);
    });
});