Compare commits

..

2 Commits

Author SHA1 Message Date
Wyatt J. Miller
7684a61296 updated async-std crate 2020-12-27 22:18:18 -05:00
Wyatt J. Miller
15917726d7 updated reqwest create, added async features 2020-12-20 14:24:24 -05:00
5 changed files with 24 additions and 26 deletions

View File

@ -15,15 +15,6 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name : Install ARM compiler
run: sudo apt-get install gcc-arm-linux-gnueabihf -y
- name: Set ARM compiler as environment variable
run: export CC=arm-linux-gnueabihf-gcc
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: armv7-unknown-linux-gnueabihf
override: true
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Build - name: Build
run: cargo build --verbose run: cargo build --verbose

View File

@ -2,7 +2,7 @@
authors = ["Wyatt J. Miller <wjmiller2016@gmail.com>"] authors = ["Wyatt J. Miller <wjmiller2016@gmail.com>"]
edition = "2018" edition = "2018"
name = "bleak" name = "bleak"
version = "0.3.0" version = "0.3.1"
[dependencies] [dependencies]
chrono = "0.4.11" chrono = "0.4.11"
@ -15,12 +15,15 @@ serde_json = "1.0.53"
smart-leds = "0.3.0" smart-leds = "0.3.0"
ws2812-spi = "0.3.0" ws2812-spi = "0.3.0"
[dependencies.async-std]
version = "1.8.0"
[dependencies.rppal] [dependencies.rppal]
features = ["hal"] features = ["hal"]
version = "0.11.3" version = "0.11.3"
[dependencies.reqwest] [dependencies.reqwest]
version = "0.9.24" version = "0.10.9"
[dependencies.openssl] [dependencies.openssl]
features = ["vendored"] features = ["vendored"]

View File

@ -1,5 +1,7 @@
![Bleak logo](docs/img/bleak_logo.png) ![Bleak logo](docs/img/bleak_logo.png)
[![Build Status](https://cicd.wyattjmiller.com/api/badges/wyatt/bleak/status.svg)](https://cicd.wyattjmiller.com/wyatt/bleak)
Change the aura of the room with your smart TV! Change the aura of the room with your smart TV!
This project is licensed by the [Mozilla Public License v2](https://www.mozilla.org/en-US/MPL/2.0/). A copy of this license is in the project's root directory for your convenience. This project is licensed by the [Mozilla Public License v2](https://www.mozilla.org/en-US/MPL/2.0/). A copy of this license is in the project's root directory for your convenience.
@ -8,18 +10,21 @@ The logo is licensed by the [CC BY-NC-ND 4.0](https://creativecommons.org/licens
## What is this?? ## What is this??
This came from an idea in high school where one could change a channel and some LEDs could change color based on the channel selected. This project is just that, only with smart TV's (see the [supported devices](#smart-tv-support) for a list of supported devices). One changes the application to Netflix, the LEDs turn red. Another changes the application to Hulu, the LEDs turn green. This came from an idea in high school where one could change a channel and some LEDs could change color. This project is just that, only with Smart TV's (Roku TV's and Roku devices supported). One changes the application to Netflix, the LEDs turn red. Another changes the application to Hulu, the LEDs turn green.
## How does it work? ## How does it work?
`bleak` sends out a network request to your smart TV's IP address that you specify in a JSON file, which is read by `bleak`, and based on that response, the LEDs will change color. These requests happen at one second intervals. `bleak` sends out a API request to your Roku TV/Roku device you specify in a JSON file, which is read by `bleak`, and based on that response, the LEDs will change color. These requests happen at one second intervals.
TL;DR
Read the source code.
## Pre-requisites ## Pre-requisites
* A Raspberry Pi (tested with a Raspberry Pi 4) * A Raspberry Pi (tested with a Raspberry Pi 4)
* A WS2818 LED light strip (you can order this from [Amazon](https://www.amazon.com/s?k=ws2818+led+strip)) * A WS2818 LED light strip (you can order this from [Amazon](https://www.amazon.com/s?k=ws2818+led+strip))
* Rust 1.40+ (this is the version of Rust `bleak` was written in) However, any version of Rust 2018 will most likely be fine * Rust 1.40+ (this is the version of Rust `bleak` was written in) However, any version of Rust 2018 will most likely be fine
* [Supported](#smart-tv-support) smart TV
## Installation ## Installation
@ -101,7 +106,7 @@ or you can:
to run this program as one is hacking away. to run this program as one is hacking away.
I wrote a systemd service file so starting and stopping would be like I'm starting and stopping any service on a Linux machine. I also didn't like `bleak` taking control of my terminal session :) I wrote a systmed service file so starting and stopping would be like I'm starting and stopping any service on a Linux machine. I also didn't like `bleak` taking control of my terminal session :)
## Troubleshooting ## Troubleshooting
@ -114,17 +119,13 @@ If you find any other issues with `bleak`, please send them my way in the form o
## Smart TV support ## Smart TV support
Supported: In development:
* Roku devices and Roku TV's * Roku devices and Roku TV's
In development:
* Apple TV 4K/HD
Future possibilities: Future possibilities:
* Samsung TV (probably utilizing SmartThings API) * Samsung SmartThings TV
* Android TV * Android TV
* Amazon's Fire TV * Amazon's Fire TV

View File

@ -1,3 +1,4 @@
use async_std::{prelude::*, task};
use std::fs::File; use std::fs::File;
use std::io::Read; use std::io::Read;
use std::path::Path; use std::path::Path;
@ -38,7 +39,7 @@ impl Configuration {
port = self.port port = self.port
); );
let response = request::get_request(&request); let response = task::block_on(request::get_request(&request));
match response { match response {
Ok(res) => { Ok(res) => {
@ -61,7 +62,7 @@ impl Configuration {
port = self.port port = self.port
); );
let response = request::get_request(&request); let response = task::block_on(request::get_request(&request));
match response { match response {
Ok(res) => { Ok(res) => {
let document = Document::from_read(res) let document = Document::from_read(res)

View File

@ -1,4 +1,6 @@
pub fn get_request(request: &String) -> Result<reqwest::Response, reqwest::Error> { use async_std::{prelude::*, io};
let response = reqwest::get(request);
pub async fn get_request(request: &String) -> io::Result<reqwest::Response, reqwest::Error> {
let response = reqwest::get(request).await?;
response response
} }