talking to the broker properly now

This commit is contained in:
Priec
2025-10-04 23:00:56 +02:00
parent 948602bd1e
commit a3954ea3e8
5 changed files with 47 additions and 28 deletions

View File

@@ -7,6 +7,7 @@ ESP_LOG="info"
[build] [build]
rustflags = [ rustflags = [
"-C", "link-arg=-nostartfiles", "-C", "link-arg=-nostartfiles",
"-C", "link-arg=-Tdefmt.x",
"-Z", "stack-protector=all", "-Z", "stack-protector=all",
] ]

View File

@@ -1,2 +1,4 @@
SSID = "nazov_wifi_siete" SSID = "nazov_wifi_siete"
PASSWORD = "heslo_od_wifi" PASSWORD = "heslo_od_wifi"
BROKER_IP= "5.196.78.28"
BROKER_PORT= "1883"

60
final/Cargo.lock generated
View File

@@ -205,6 +205,16 @@ dependencies = [
"thiserror", "thiserror",
] ]
[[package]]
name = "defmt-rtt"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2cac3b8a5644a9e02b75085ebad3b6deafdbdbdec04bb25086523828aa4dfd1"
dependencies = [
"critical-section",
"defmt 1.0.1",
]
[[package]] [[package]]
name = "delegate" name = "delegate"
version = "0.13.4" version = "0.13.4"
@@ -1167,6 +1177,32 @@ dependencies = [
"unicode-ident", "unicode-ident",
] ]
[[package]]
name = "projekt_final"
version = "0.1.0"
dependencies = [
"critical-section",
"defmt 1.0.1",
"defmt-rtt",
"dotenvy",
"embassy-executor",
"embassy-net",
"embassy-time 0.5.0",
"embedded-io",
"embedded-io-async",
"esp-alloc",
"esp-backtrace",
"esp-bootloader-esp-idf",
"esp-hal",
"esp-hal-embassy",
"esp-println",
"esp-wifi",
"log",
"rust-mqtt",
"smoltcp",
"static_cell",
]
[[package]] [[package]]
name = "quote" name = "quote"
version = "1.0.41" version = "1.0.41"
@@ -1379,30 +1415,6 @@ dependencies = [
"winapi-util", "winapi-util",
] ]
[[package]]
name = "test1"
version = "0.1.0"
dependencies = [
"critical-section",
"dotenvy",
"embassy-executor",
"embassy-net",
"embassy-time 0.5.0",
"embedded-io",
"embedded-io-async",
"esp-alloc",
"esp-backtrace",
"esp-bootloader-esp-idf",
"esp-hal",
"esp-hal-embassy",
"esp-println",
"esp-wifi",
"log",
"rust-mqtt",
"smoltcp",
"static_cell",
]
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "2.0.17" version = "2.0.17"

View File

@@ -1,11 +1,11 @@
[package] [package]
edition = "2021" edition = "2021"
name = "test1" name = "projekt_final"
rust-version = "1.86" rust-version = "1.86"
version = "0.1.0" version = "0.1.0"
[[bin]] [[bin]]
name = "test1" name = "projekt_final"
path = "./src/bin/main.rs" path = "./src/bin/main.rs"
[dependencies] [dependencies]
@@ -67,6 +67,8 @@ smoltcp = { version = "0.12.0", default-features = false, features = [
] } ] }
static_cell = "2.1.1" static_cell = "2.1.1"
rust-mqtt = { version = "0.3.0", default-features = false, features = ["no_std"] } rust-mqtt = { version = "0.3.0", default-features = false, features = ["no_std"] }
defmt = "1.0.1"
defmt-rtt = "1.0.0"
[build-dependencies] [build-dependencies]
dotenvy = "0.15.7" dotenvy = "0.15.7"

View File

@@ -17,6 +17,8 @@ use esp_wifi::{
wifi::{ClientConfiguration, Configuration, WifiController, WifiDevice, WifiEvent, WifiState}, wifi::{ClientConfiguration, Configuration, WifiController, WifiDevice, WifiEvent, WifiState},
}; };
use log::info; use log::info;
use projekt_final::mqtt::client::mqtt_task;
use defmt_rtt as _;
extern crate alloc; extern crate alloc;
@@ -89,8 +91,8 @@ async fn main(spawner: Spawner) -> ! {
Timer::after(Duration::from_millis(500)).await; Timer::after(Duration::from_millis(500)).await;
} }
// Stack is ready - Add rust-mqtt task here spawner.spawn(mqtt_task(stack)).expect("failed to spawn MQTT task");
// spawner.spawn(mqtt_task(stack)).ok(); info!("MQTT task started");
loop { loop {
Timer::after(Duration::from_secs(60)).await; Timer::after(Duration::from_secs(60)).await;