diff --git a/.cargo/config.toml b/.cargo/config.toml index 738e73c..85213bd 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -20,7 +20,4 @@ rustflags = [ target = "riscv32imc-unknown-none-elf" [unstable] -build-std = [ - # "alloc", - "core", -] +build-std = ["alloc", "core"] diff --git a/Cargo.toml b/Cargo.toml index cd039d7..263569d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ esp-hal-embassy = { version = "0.1.0", features = [ "time-timg0", ] } -esp-backtrace = { version = "0.12.0", features = [ +esp-backtrace = { version = "0.12.1", features = [ "exception-handler", "panic-handler", "println", @@ -59,7 +59,7 @@ embedded-graphics = { version = "0.8.1", features = ["nalgebra_support"] } #higher level embedded-hal traits for wifi, bluetooth, ect -embedded-svc = { version = "0.27.1", default-features = false, optional = true } +embedded-svc = { version = "0.28.0", default-features = false, optional = true } embedded-io = "0.6.1" embedded-io-async = "0.6.1" embedded-hal = "1.0.0" @@ -67,7 +67,7 @@ embedded-hal-async = "^1.0" embedded-hal-bus = { version = "0.2.0", features = ["async"] } # no_std http/s requests. -reqwless = { version = "0.12.0", optional = true } +reqwless = { version = "0.12.0", optional = true, features = ["alloc"] } # heapless = { version = "0.8.0", default-features = false } @@ -109,7 +109,7 @@ overflow-checks = false opt-level = 3 [features] -default = ["log", "net"] +default = ["log", "net", "alloc"] alloc = ["dep:esp-alloc"] diff --git a/src/lib.rs b/src/lib.rs index 1e287d8..5c2697e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,8 +6,8 @@ // #[cfg(feature = "adc")] // pub mod adc; -// #[cfg(feature = "alloc")] -// pub mod alloc; +#[cfg(feature = "alloc")] +pub mod alloc; pub mod blink; pub mod display; pub mod errors; diff --git a/src/main.rs b/src/main.rs index 8d81f6a..58f6af1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -46,8 +46,8 @@ async fn main(spawner: Spawner) -> ! { info!("Logger is setup"); println!("Hello world!"); - // #[cfg(feature = "alloc")] - // spotify_mini::alloc::init_heap(); + #[cfg(feature = "alloc")] + teeny::alloc::init_heap(); let peripherals = Peripherals::take(); @@ -189,11 +189,18 @@ async fn main(spawner: Spawner) -> ! { debug!("HttpClient created"); + let token = "TOKEN_GOES_HERE"; + + let mut string: String<64> = String::new(); + + string.push_str("Bearer ").unwrap(); + string.push_str(token).unwrap(); + let headers = [ - ("user-agent", "teeny/0.1.0"), - ("Host", "example.com"), - ("accept", "application/json"), - // ("connection", "close"), + ("User-Agent", "teeny/0.1.0"), + ("Accept", "*/*"), + ("Connection", "close"), + ("Authorization", string.as_str()), ]; let mut header_buf = [0; 1024]; @@ -202,13 +209,13 @@ async fn main(spawner: Spawner) -> ! { .request(Method::GET, "https://example.com") .await .unwrap() - .content_type(reqwless::headers::ContentType::TextPlain) + .path("/v1/artists/0TnOYISbd1XYRBk9myaseg") .headers(&headers); - debug!("Request sent"); - let response = request.send(&mut header_buf).await.unwrap(); + debug!("Request sent"); + let content_len = response.content_length.unwrap(); debug!("Response Recieved"); @@ -216,11 +223,11 @@ async fn main(spawner: Spawner) -> ! { let mut buf = [0; 50 * 1024]; if let Err(e) = response.body().reader().read_to_end(&mut buf).await { - error!("{e:?}"); + error!("Error: {e:?}"); break; } - print!("{:#?}", core::str::from_utf8(&buf[..content_len]).unwrap()); + println!("{:#?}", core::str::from_utf8(&buf[..content_len]).unwrap()); Timer::after(Duration::from_secs(3)).await; }