Command-line tools and C library for blink(1) USB RGB LED
Go to file
Tod Kurt 2edcb01fe7 implement fixes for issue #72
- handle unknown URIs in /blink/*
- explicitly set headers content-type application/json and x-content-type-options nosniff
- remove potential XSS vector of echoing uri in JSON response
- removed list of URIs in /blink1 status message as it created bad json
2024-03-07 21:56:23 -08:00
.github/workflows macos CI: lets try blink1control-tool builds again 2022-04-13 08:35:58 -07:00
blink1-mini-tool blink1-mini-tool update for wrt-based devices 2014-12-11 17:10:27 -08:00
blink1control-tool reduce down libcurl deps 2022-04-13 10:02:55 -07:00
blink1raw added blink1raw from frederick 2012-12-06 11:29:19 -08:00
docs update makingreleases doc 2023-11-23 11:47:26 -08:00
hidapi@d3013f0af3 update to hidapi-0.14.0 2023-11-23 12:06:18 -08:00
patches add fixes for FreeBSD, addressing #12,#13,#17 2018-12-09 10:30:57 -08:00
scripts Fix for loops to work more generally.... (#25) 2019-08-24 12:40:50 -07:00
server implement fixes for issue #72 2024-03-07 21:56:23 -08:00
.gitignore Generate self contained source archives 2022-01-05 15:31:01 +01:00
.gitmodules fix hidapi submodule url 2019-11-23 20:34:36 -08:00
51-blink1.rules update docs a bit 2020-09-02 16:02:33 -07:00
Dockerfile-ubuntu added cirrus ci 2019-11-30 10:00:44 -08:00
LICENSE.txt add dual license, fix #39 2022-01-10 21:24:02 -08:00
Makefile add missing LDFLAGS to library build 2024-01-08 11:24:58 +01:00
README.md small windows compile readme fix 2023-11-23 11:46:43 -08:00
blink1-lib-lowlevel-hidapi.h blink1-lib: small cleanup 2022-07-15 11:34:08 -07:00
blink1-lib-lowlevel-hiddata.h minor hiddata fix 2020-08-25 13:45:48 -07:00
blink1-lib.c small cleanup 2023-11-26 22:03:45 -08:00
blink1-lib.h blink1-lib: small cleanup 2022-07-15 11:34:08 -07:00
blink1-tool.c prevent --readnote and --writenote from being used on older devices, for issue #65 2023-11-26 17:28:15 -08:00
hiddata.c blink1-lib: fixed hiddata.c to work with mk2 (&mk1), USB_RECIP_DEVICE -> USB_RECIP_INTERFACE 2013-12-17 15:13:48 -08:00
hiddata.h blink1-tool: big revamp to use HIDAPI or hiddata, see Makefile USBLIB_TYPE option 2013-11-05 17:56:51 -08:00

README.md

Command-line Tools and C library for blink(1) USB RGB LED

Build Status linux Build Status macos Build Status windows

This is an official collection of C/C++ commandline tools for controlling the blink1 USB RGB LED.

This code lives at https://github.com/todbot/blink1-tool.

For pre-built binaries, see the Releases page.

The current tools are:

  • blink1-tool -- command-line tool for controlling blink(1)
  • blink1control-tool -- blink1-tool for use with Blink1Control (uses HTTP REST API)
  • blink1-tiny-server -- (README) Simple HTTP API server to control blink1, uses blink1-lib
  • blink1-lib -- C library for controlling blink(1)
  • blink1-mini-tool -- commandline tool using libusb-0.1 and minimal deps
  • blink1raw -- small example commandline tool using Linux hidraw

Type make help for a full list.

Also see in this directory:

  • scripts -- examples shell scripts using blink1-tool

Supported platforms

Supported platforms for blink1-tool and blink1-lib:

  • Mac OS X 10.6.8, 10.7+
  • Windows XP+ (built with MinGW & MSYS)
  • Linux (most all, primary development on Ubuntu)
  • FreeBSD 8.2+
  • Raspberry Pi (Raspian)
  • BeagleBone (Ubuntu)
  • OpenWRT / DD-WRT
  • ... just about anything else with Gnu Make & a C-compiler

In general, the blink1-tool builds as a static binary where possible, eliminating the need for shared library dependencies on the target. However, static builds can be problematic for some systems with different libusb implementations, so doing make EXEFLAGS= will generally build a non-static version.

OS-specific Notes

Linux (including Raspberry Pi)

To use blink(1) as a non-root user, udev rules must be installed. On Debian-like systems (Ubuntu, Raspian), these udev rules are installed with:

sudo cp 51-blink1.rules /etc/udev/rules.d/51-blink1.rules
sudo udevadm control --reload
sudo udevadm trigger

Building from source

In general you can do:

git clone https://github.com/todbot/blink1-tool
cd blink1-tool
make

On Linux you will need to install some requirements beforehand.

If your OS is not detected automatically, you can force it with something like:

OS=linux make

To see the supported platforms, please consult the Makefile

Build variants

There are two primary USB libraries that blink1-tool can be built for:

  • USBLIB_TYPE=HIDAPI -- Uses the feature-rich cross-platform hidapi library (default)
  • USBLIB_TYPE=HIDDATA -- Uses a simple, cross-platform hiddata library (included)

For Linux, there are to HIDAPI_TYPEs you can choose from:

  • HIDAPI_TYPE=HIDRAW -- Uses standard hidraw kernel API for HID devices (default)
  • HIDAPI_TYPE=LIBUSB -- Uses lower-level libusb commands (good for older Linuxes)

To compile for a particular USBLIB_TYPE or HIDAPI_TYPE, specify them when buildling:

HIDAPI_TYPE=LIBUSB make

OS-specific prerequisites for compiling

If you have the ability to compile programs on your system, you may already have everything you need to compile blink1-tool.

Linux (Debian-flavored, including Raspberry Pi)

  • In a terminal, install pre-reqs and build:
  • sudo apt-get install libudev-dev pkg-config build-essential
  • sudo apt-get install libusb-1.0-0-dev (optional, only for libusb variant)
  • cd blink1-tool
  • make
  • HIDAPI_TYPE=libusb make (if you instead you want libusb version)

FreeBSD

  • Install pre-reqs and build:
  • sudo pkg install gmake gcc git libiconv
  • cd blink1-tool
  • gmake
  • sudo ./blink1-tool --red --flash 3

MacOS

  • Xcode
  • In Terminal, setup Xcode and build:
  • xcode-select --install
  • cd blink1-tool
  • make

Windows

  • Install Visual Studio 2017 or 2019
  • Install MSYS2: https://www.msys2.org/
  • In MSYS2 bash shell:
  • pacman -S base-devel make git zip unzip mingw-w64-x86_64-gcc
  • export PATH=${PATH}:/c/msys64/mingw64/bin
  • export PATH=${PATH}:"/c/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin"
  • export PATH=${PATH}:'/c/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64'"
  • make

Other OSes

See the blink1-tool/Makefile for details

Using blink1-lib in your C/C++ project

See Makefile for your platform

Docker and blink(1)

[this may be out of date after the repo move]

To build the image from the Dockerfile

  • docker build -t robtec/blink1 .

Running the container

  • docker run -d --privileged robtec/blink1

Note the --privileged tag, docker needs this to access the hosts USB controllers

Docker resources