chore: fad
This commit is contained in:
parent
8dfbf88db8
commit
d6dd2d90e4
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -416,7 +416,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "embassy-sync"
|
||||
version = "0.5.0"
|
||||
source = "git+https://github.com/embassy-rs/embassy.git?rev=4b4777e#4b4777e6bb813dbde3f8ec05ff81cadbcb41bee0"
|
||||
source = "git+https://github.com/embassy-rs/embassy.git?rev=4b4777#4b4777e6bb813dbde3f8ec05ff81cadbcb41bee0"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"critical-section",
|
||||
@ -801,7 +801,7 @@ dependencies = [
|
||||
"const-decoder",
|
||||
"embassy-executor",
|
||||
"embassy-net",
|
||||
"embassy-sync 0.5.0 (git+https://github.com/embassy-rs/embassy.git?rev=4b4777e)",
|
||||
"embassy-sync 0.5.0 (git+https://github.com/embassy-rs/embassy.git?rev=4b4777)",
|
||||
"embassy-time",
|
||||
"embedded-io-async",
|
||||
"embedded-tls",
|
||||
|
@ -4,13 +4,17 @@ version = "0.1.0"
|
||||
edition = "2021"
|
||||
authors = [ "Marvin Drescher <m@sparv.in>" ]
|
||||
|
||||
[[bin]]
|
||||
name = "esp"
|
||||
path = "src/main.rs"
|
||||
test = false
|
||||
bench = false
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
const-decoder = "0.3.0"
|
||||
embassy-executor = { version = "0.5.0", features = ["nightly", "integrated-timers", "arch-riscv32", "executor-thread"] }
|
||||
embassy-net = { version = "0.4.0", features = ["dhcpv4", "dhcpv4-hostname", "dns", "medium-ip", "proto-ipv4", "proto-ipv6", "tcp", "udp"] }
|
||||
embassy-sync = { git = "https://github.com/embassy-rs/embassy.git", rev = "4b4777e" }
|
||||
embassy-sync = { git = "https://github.com/embassy-rs/embassy.git", rev = "4b4777" }
|
||||
embassy-time = { version = "0.3.0" }
|
||||
embedded-io-async = "0.6.1"
|
||||
embedded-tls = { version = "0.17.0", default-features = false, features = ["embedded-io-adapters"] }
|
||||
|
11
src/main.rs
11
src/main.rs
@ -9,7 +9,7 @@
|
||||
#![feature(trait_alias)]
|
||||
#![feature(generic_arg_infer)]
|
||||
extern crate alloc;
|
||||
use core::mem::{self, MaybeUninit};
|
||||
use core::mem::{MaybeUninit};
|
||||
|
||||
use alloc::borrow::Cow;
|
||||
use alloc::boxed::Box;
|
||||
@ -26,17 +26,16 @@ use esp_backtrace as _;
|
||||
use esp_hal::adc::{AdcPin, Attenuation, ADC};
|
||||
use esp_hal::clock::CpuClock;
|
||||
use esp_hal::gpio::{
|
||||
Analog, AnalogPin, AnyPin, GpioPin, OpenDrain, Output, OutputSignal, PushPull,
|
||||
Analog, AnyPin, GpioPin, Output, PushPull,
|
||||
};
|
||||
use esp_hal::peripherals::{Peripherals, ADC1, ADC2, TIMG0};
|
||||
use esp_hal::peripherals::{Peripherals, ADC1};
|
||||
use esp_hal::systimer::SystemTimer;
|
||||
use esp_hal::{adc::AdcConfig, clock::ClockControl};
|
||||
use esp_hal::{embassy, prelude::*, rmt, Rmt, Rng, Rtc, IO};
|
||||
use esp_hal_smartled::SmartLedsAdapter;
|
||||
use esp_hal_smartled::*;
|
||||
use esp_println::logger::init_logger;
|
||||
use esp_println::println;
|
||||
use esp_wifi::wifi::{get_random, ClientConfiguration, Configuration};
|
||||
use esp_wifi::wifi::{ClientConfiguration, Configuration};
|
||||
use esp_wifi::wifi::{WifiController, WifiDevice, WifiEvent, WifiStaDevice, WifiState};
|
||||
use esp_wifi::{initialize as initialize_wifi, EspWifiInitFor};
|
||||
use log::{debug, error, info, trace};
|
||||
@ -211,7 +210,7 @@ fn main() -> ! {
|
||||
let mut timer_group0 = esp_hal::timer::TimerGroup::new(peripherals.TIMG0, &clocks);
|
||||
let timer_group1 = esp_hal::timer::TimerGroup::new(peripherals.TIMG1, &clocks);
|
||||
{
|
||||
let mut wdt0 = &mut timer_group0.wdt;
|
||||
let wdt0 = &mut timer_group0.wdt;
|
||||
let mut wdt1 = timer_group1.wdt;
|
||||
|
||||
// Disable watchdog timers
|
||||
|
14
src/mqtt.rs
14
src/mqtt.rs
@ -5,14 +5,12 @@ use embassy_net::{dns::Error as DnsError, tcp::ConnectError};
|
||||
use embassy_time::{with_timeout, Duration, Instant, TimeoutError, Timer};
|
||||
use embedded_tls::{Aes128GcmSha256, NoVerify, TlsConfig, TlsConnection, TlsContext, TlsError};
|
||||
use esp_backtrace as _;
|
||||
use esp_println::println;
|
||||
use log::{debug, error, info, trace};
|
||||
use log::{debug, error, info};
|
||||
use rand::rngs::StdRng;
|
||||
use rand::{CryptoRng, RngCore, SeedableRng};
|
||||
use rust_mqtt::client::client::MqttClient;
|
||||
use rust_mqtt::client::client_config::ClientConfig;
|
||||
use rust_mqtt::packet::v5::reason_codes::ReasonCode;
|
||||
use rust_mqtt::tests;
|
||||
use rust_mqtt::utils::rng_generator::CountingRng;
|
||||
|
||||
use crate::{NetworkStack, DATA, HAS_IP_ADDRESS};
|
||||
@ -75,12 +73,12 @@ const MQTT_SERVER_PORT: u16 = 1883;
|
||||
|
||||
pub async fn send_message(
|
||||
stack: NetworkStack,
|
||||
mut messages: impl Iterator<Item = (&str, &[u8])>,
|
||||
mut rng: impl CryptoRng + RngCore,
|
||||
messages: impl Iterator<Item = (&str, &[u8])>,
|
||||
rng: impl CryptoRng + RngCore,
|
||||
) -> core::result::Result<(), SendError> {
|
||||
async fn inner(
|
||||
stack: NetworkStack,
|
||||
mut messages: impl Iterator<Item = (&str, &[u8])>,
|
||||
messages: impl Iterator<Item = (&str, &[u8])>,
|
||||
mut rng: impl CryptoRng + RngCore,
|
||||
) -> core::result::Result<(), SendError> {
|
||||
let begin = Instant::now();
|
||||
@ -126,7 +124,7 @@ pub async fn send_message(
|
||||
let mut tls_write_record_buffer = [0; TLS_BUF_LEN];
|
||||
|
||||
#[cfg(feature = "tls")]
|
||||
let mut tls = {
|
||||
let tls = {
|
||||
let config = TlsConfig::new();
|
||||
let mut tls = TlsConnection::new(
|
||||
socket,
|
||||
@ -140,7 +138,7 @@ pub async fn send_message(
|
||||
tls
|
||||
};
|
||||
#[cfg(feature = "tls")]
|
||||
let mut mqtt_backend = tls;
|
||||
let mqtt_backend = tls;
|
||||
#[cfg(not(feature = "tls"))]
|
||||
let mut mqtt_backend = socket;
|
||||
let after_tls = Instant::now();
|
||||
|
Loading…
x
Reference in New Issue
Block a user