A RESTful blink(1) daemon written in modern C++

lotus 982d30bbb2 updated makefile and readme 1 year ago
inc 269dfc8600 consolidated headers 1 year ago
.clang_complete 08d1265315 fixed namespace issue, included clang_complete file 1 year ago
.gitignore 0b44f172f6 added comments, updated readme, added gitignore 1 year ago
LICENSE.md 8f63e056ac added license file and readme 1 year ago
README.md 982d30bbb2 updated makefile and readme 1 year ago
blink-device.cpp 70f7e119f7 removed blink1 system libs, fixed makefile 1 year ago
blink-server.cpp 70f7e119f7 removed blink1 system libs, fixed makefile 1 year ago
makefile 982d30bbb2 updated makefile and readme 1 year ago



A RESTful HTTP server daemon for the blink(1) LED USB device. Written in Modern C++.



"Wow! It totally sucks less than those other blink(1) servers!" - Someone (probably)


  • Predefined basic color routes
  • Use custom RGB, Hex, or CYMK colors
  • Compiles to native multithreaded code
  • Easy on resources


I was unimpressed with the flexibility of the official blink(1) servers in the official GitHub repository. I wanted my server to have the same flexibility as the command-line blink1-tool. While this project uses boost::asio instead of c++11 threads the http lib I was using (Pistache) relied on the linux epoll() syscall making it less portable.

Getting Started

If you are on Linux or OpenBSD (AMD64), simply download the binary release and start her up! I would like to support an ARM build for Raspberry Pi's as well soon. If you wish to compile for your specific platform, clone this repo and follow along with the directions below.

While I only plan on supporting Linux and OpenBSD this project should work on other platforms as well.

Prerequisites / Dependencies

  • Crow (HTTP Server)
  • CLI11 (CLI arg parser)
  • blink1-tool (C library)
  • Boost development headers
  • A modern C++ compiler (I've tested using Clang 6 and GCC 8)

If you want to take the easy route, you can run the included setup script:

# still need to write ^_^
cd ./blink1d/scripts
# Needs root priv to install packages
sudo ./install-prereqs.sh

Install prerequisites manually:


sudo apt-get install build-essential libboost-all-dev libtcmalloc-minimal4 && sudo ln -s /usr/lib/libtcmalloc_minimal.so.4 /usr/lib/libtcmalloc_minimal.so


pkg_add boost


yum install boost-devel


cd ./blink1d
# start the server
./blink1d -v

   __   ___      __   ___   __
  / /  / (_)__  / /__<  /__/ /
 / _ \/ / / _ \/  '_// / _  /
project licensed under the 3-clause BSD license
site: git.zerohack.xyz/lotus/blink1d
cores detected: 4
threading enabled: true
using: 4 thread(s)
running on port: 9080
fade value set to: 1000ms
(2018-12-21 22:28:17) [INFO    ] Crow/0.1 server is running at using 4 threads
(2018-12-21 22:28:17) [INFO    ] Call `app.loglevel(crow::LogLevel::Warning)` to hide Info level logs.

You should now be able to curl the server on default port 9080

Try it!



curl localhost:9080/on
curl localhost:9080/off

Predefined Colors:

curl localhost:9080/basic/red
curl localhost:9080/basic/green
curl localhost:9080/basic/blue
curl localhost:9080/basic/white
curl localhost:9080/basic/yellow
curl localhost:9080/basic/orange
curl localhost:9080/basic/pink
curl localhost:9080/basic/purple
curl localhost:9080/basic/cyan
curl localhost:9080/basic/magenta

Custom Colors:

# turn white
curl localhost:9080/custom/rgb/255/255/255
# turn off
curl localhost:9080/custom/rgb/0/0/0

# Use Hex Colors
# (white)
curl localhost:9080/custom/hex/FFFFFF
# (off)
curl localhost:9080/custom/hex/000000

# Use CMYK Colors (Cyan / Magenta / Yellow / Key)
# (white)
curl localhost:9080/custom/cmyk/255/255/255/255
# (off)
curl localhost:9080/custom/cmyk/0/0/0/0
# (green)
curl localhost:9080/custom/cmyk/76/0/76/20

Adding Pulsing / Blinking / Sequences:


# Blink
# (first set a color)
curl localhost:9080/on
# (now tell it to blink with an interval of 500ms)
curl localhost:9080/blink/500

# "Pulse" (Fade)
# (same as blink)
curl localhost:9080/pulse/500

# Rainbow
# (transitions through all of the rainbow colors)
curl localhost:9080/rainbow

Command line flags

-v --verbose (Print debugging output to console)

-p --port (specify a network port to run on [default 9080])

-t --thread (detects number of cores and threads appropriately)

-f --fade (default = 1000 ms)

Know Bugs

  • Issue with crow signal handler on BSD (to workaround use inside tmux)

Built With

Free and Open Source software +

❤️ @ Winter Hackathon 2018 🦄


Feel free to submit a PR and we'll review it! :)

License / Disclaimer

This project is licensed under the 3-clause BSD license. (See LICENSE.md)

Also, I probably wouldn't expose this server on the internet. Use at your own risk.