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]]
|
[[package]]
|
||||||
name = "embassy-sync"
|
name = "embassy-sync"
|
||||||
version = "0.5.0"
|
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 = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"critical-section",
|
"critical-section",
|
||||||
@ -801,7 +801,7 @@ dependencies = [
|
|||||||
"const-decoder",
|
"const-decoder",
|
||||||
"embassy-executor",
|
"embassy-executor",
|
||||||
"embassy-net",
|
"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",
|
"embassy-time",
|
||||||
"embedded-io-async",
|
"embedded-io-async",
|
||||||
"embedded-tls",
|
"embedded-tls",
|
||||||
|
@ -4,13 +4,17 @@ version = "0.1.0"
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = [ "Marvin Drescher <m@sparv.in>" ]
|
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
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
const-decoder = "0.3.0"
|
const-decoder = "0.3.0"
|
||||||
embassy-executor = { version = "0.5.0", features = ["nightly", "integrated-timers", "arch-riscv32", "executor-thread"] }
|
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-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" }
|
embassy-time = { version = "0.3.0" }
|
||||||
embedded-io-async = "0.6.1"
|
embedded-io-async = "0.6.1"
|
||||||
embedded-tls = { version = "0.17.0", default-features = false, features = ["embedded-io-adapters"] }
|
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(trait_alias)]
|
||||||
#![feature(generic_arg_infer)]
|
#![feature(generic_arg_infer)]
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
use core::mem::{self, MaybeUninit};
|
use core::mem::{MaybeUninit};
|
||||||
|
|
||||||
use alloc::borrow::Cow;
|
use alloc::borrow::Cow;
|
||||||
use alloc::boxed::Box;
|
use alloc::boxed::Box;
|
||||||
@ -26,17 +26,16 @@ use esp_backtrace as _;
|
|||||||
use esp_hal::adc::{AdcPin, Attenuation, ADC};
|
use esp_hal::adc::{AdcPin, Attenuation, ADC};
|
||||||
use esp_hal::clock::CpuClock;
|
use esp_hal::clock::CpuClock;
|
||||||
use esp_hal::gpio::{
|
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::systimer::SystemTimer;
|
||||||
use esp_hal::{adc::AdcConfig, clock::ClockControl};
|
use esp_hal::{adc::AdcConfig, clock::ClockControl};
|
||||||
use esp_hal::{embassy, prelude::*, rmt, Rmt, Rng, Rtc, IO};
|
use esp_hal::{embassy, prelude::*, rmt, Rmt, Rng, Rtc, IO};
|
||||||
use esp_hal_smartled::SmartLedsAdapter;
|
use esp_hal_smartled::SmartLedsAdapter;
|
||||||
use esp_hal_smartled::*;
|
use esp_hal_smartled::*;
|
||||||
use esp_println::logger::init_logger;
|
use esp_println::logger::init_logger;
|
||||||
use esp_println::println;
|
use esp_wifi::wifi::{ClientConfiguration, Configuration};
|
||||||
use esp_wifi::wifi::{get_random, ClientConfiguration, Configuration};
|
|
||||||
use esp_wifi::wifi::{WifiController, WifiDevice, WifiEvent, WifiStaDevice, WifiState};
|
use esp_wifi::wifi::{WifiController, WifiDevice, WifiEvent, WifiStaDevice, WifiState};
|
||||||
use esp_wifi::{initialize as initialize_wifi, EspWifiInitFor};
|
use esp_wifi::{initialize as initialize_wifi, EspWifiInitFor};
|
||||||
use log::{debug, error, info, trace};
|
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 mut timer_group0 = esp_hal::timer::TimerGroup::new(peripherals.TIMG0, &clocks);
|
||||||
let timer_group1 = esp_hal::timer::TimerGroup::new(peripherals.TIMG1, &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;
|
let mut wdt1 = timer_group1.wdt;
|
||||||
|
|
||||||
// Disable watchdog timers
|
// 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 embassy_time::{with_timeout, Duration, Instant, TimeoutError, Timer};
|
||||||
use embedded_tls::{Aes128GcmSha256, NoVerify, TlsConfig, TlsConnection, TlsContext, TlsError};
|
use embedded_tls::{Aes128GcmSha256, NoVerify, TlsConfig, TlsConnection, TlsContext, TlsError};
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
use esp_println::println;
|
use log::{debug, error, info};
|
||||||
use log::{debug, error, info, trace};
|
|
||||||
use rand::rngs::StdRng;
|
use rand::rngs::StdRng;
|
||||||
use rand::{CryptoRng, RngCore, SeedableRng};
|
use rand::{CryptoRng, RngCore, SeedableRng};
|
||||||
use rust_mqtt::client::client::MqttClient;
|
use rust_mqtt::client::client::MqttClient;
|
||||||
use rust_mqtt::client::client_config::ClientConfig;
|
use rust_mqtt::client::client_config::ClientConfig;
|
||||||
use rust_mqtt::packet::v5::reason_codes::ReasonCode;
|
use rust_mqtt::packet::v5::reason_codes::ReasonCode;
|
||||||
use rust_mqtt::tests;
|
|
||||||
use rust_mqtt::utils::rng_generator::CountingRng;
|
use rust_mqtt::utils::rng_generator::CountingRng;
|
||||||
|
|
||||||
use crate::{NetworkStack, DATA, HAS_IP_ADDRESS};
|
use crate::{NetworkStack, DATA, HAS_IP_ADDRESS};
|
||||||
@ -75,12 +73,12 @@ const MQTT_SERVER_PORT: u16 = 1883;
|
|||||||
|
|
||||||
pub async fn send_message(
|
pub async fn send_message(
|
||||||
stack: NetworkStack,
|
stack: NetworkStack,
|
||||||
mut messages: impl Iterator<Item = (&str, &[u8])>,
|
messages: impl Iterator<Item = (&str, &[u8])>,
|
||||||
mut rng: impl CryptoRng + RngCore,
|
rng: impl CryptoRng + RngCore,
|
||||||
) -> core::result::Result<(), SendError> {
|
) -> core::result::Result<(), SendError> {
|
||||||
async fn inner(
|
async fn inner(
|
||||||
stack: NetworkStack,
|
stack: NetworkStack,
|
||||||
mut messages: impl Iterator<Item = (&str, &[u8])>,
|
messages: impl Iterator<Item = (&str, &[u8])>,
|
||||||
mut rng: impl CryptoRng + RngCore,
|
mut rng: impl CryptoRng + RngCore,
|
||||||
) -> core::result::Result<(), SendError> {
|
) -> core::result::Result<(), SendError> {
|
||||||
let begin = Instant::now();
|
let begin = Instant::now();
|
||||||
@ -126,7 +124,7 @@ pub async fn send_message(
|
|||||||
let mut tls_write_record_buffer = [0; TLS_BUF_LEN];
|
let mut tls_write_record_buffer = [0; TLS_BUF_LEN];
|
||||||
|
|
||||||
#[cfg(feature = "tls")]
|
#[cfg(feature = "tls")]
|
||||||
let mut tls = {
|
let tls = {
|
||||||
let config = TlsConfig::new();
|
let config = TlsConfig::new();
|
||||||
let mut tls = TlsConnection::new(
|
let mut tls = TlsConnection::new(
|
||||||
socket,
|
socket,
|
||||||
@ -140,7 +138,7 @@ pub async fn send_message(
|
|||||||
tls
|
tls
|
||||||
};
|
};
|
||||||
#[cfg(feature = "tls")]
|
#[cfg(feature = "tls")]
|
||||||
let mut mqtt_backend = tls;
|
let mqtt_backend = tls;
|
||||||
#[cfg(not(feature = "tls"))]
|
#[cfg(not(feature = "tls"))]
|
||||||
let mut mqtt_backend = socket;
|
let mut mqtt_backend = socket;
|
||||||
let after_tls = Instant::now();
|
let after_tls = Instant::now();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user