A RESTful HTTP server daemon for the blink(1) LED USB device. Written in Modern C++.
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.
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.
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
yum install boost-devel
cd ./blink1d make # 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 0.0.0.0:9080 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
curl localhost:9080/on curl localhost:9080/off
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
# 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:
# NOT YET IMPLEMENTED # 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
-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)
Free and Open Source software
❤️ @ Winter Hackathon 2018 🦄
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.