mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-22 16:22:17 +00:00
wip: add async-wifi support to S3-BOX
This commit is contained in:
parent
2d27a17c37
commit
4e017f989d
2 changed files with 47 additions and 1 deletions
|
@ -75,6 +75,9 @@ esp32-s3-box-3 = [
|
||||||
"esp-hal/esp32s3",
|
"esp-hal/esp32s3",
|
||||||
"esp-hal/unstable", # required for PSRAM support
|
"esp-hal/unstable", # required for PSRAM support
|
||||||
"esp-hal/psram",
|
"esp-hal/psram",
|
||||||
|
"esp-wifi/esp32s3",
|
||||||
|
"static_cell",
|
||||||
|
"embassy-net",
|
||||||
"embedded-hal",
|
"embedded-hal",
|
||||||
"embedded-hal-bus",
|
"embedded-hal-bus",
|
||||||
"esp-alloc",
|
"esp-alloc",
|
||||||
|
@ -155,6 +158,19 @@ esp-hal = { version = "1.0.0-beta.0", optional = true }
|
||||||
esp-alloc = { version = "0.7", optional = true }
|
esp-alloc = { version = "0.7", optional = true }
|
||||||
esp-println = { version = "0.14.0", features = ["log-04"], optional = true }
|
esp-println = { version = "0.14.0", features = ["log-04"], optional = true }
|
||||||
esp-backtrace = { version = "0.16.0", optional = true, features = ["panic-handler", "println"] }
|
esp-backtrace = { version = "0.16.0", optional = true, features = ["panic-handler", "println"] }
|
||||||
|
esp-wifi = { version = "0.14.1", optional = true, features = [
|
||||||
|
"builtin-scheduler",
|
||||||
|
"esp-alloc",
|
||||||
|
"smoltcp",
|
||||||
|
"wifi",
|
||||||
|
] }
|
||||||
|
static_cell = { version = "2.1.0", optional = true, features = ["nightly"] }
|
||||||
|
embassy-net = { version = "0.7.0", optional = true, features = [
|
||||||
|
"dhcpv4",
|
||||||
|
"medium-ethernet",
|
||||||
|
"tcp",
|
||||||
|
"udp",
|
||||||
|
] }
|
||||||
|
|
||||||
mipidsi = { version = "0.9.0", optional = true }
|
mipidsi = { version = "0.9.0", optional = true }
|
||||||
embedded-graphics-core = { version = "0.4", optional = true }
|
embedded-graphics-core = { version = "0.4", optional = true }
|
||||||
|
|
|
@ -58,8 +58,38 @@ pub fn init() {
|
||||||
}))
|
}))
|
||||||
.expect("backend already initialized");
|
.expect("backend already initialized");
|
||||||
}
|
}
|
||||||
|
macro_rules! mk_static {
|
||||||
|
($t:ty, $val:expr) => {{
|
||||||
|
static STATIC_CELL: static_cell::StaticCell<$t> = static_cell::StaticCell::new();
|
||||||
|
STATIC_CELL.init($val)
|
||||||
|
}};
|
||||||
|
}
|
||||||
|
|
||||||
|
use esp_wifi::wifi;
|
||||||
|
use esp_wifi::{
|
||||||
|
wifi::{ClientConfiguration, Configuration, WifiController, WifiEvent, WifiState},
|
||||||
|
EspWifiController,
|
||||||
|
};
|
||||||
|
use esp_hal::{rng::Rng, timer::timg::TimerGroup};
|
||||||
|
|
||||||
|
impl EspBackend {
|
||||||
|
pub fn wifi<'a>(&self, ssid: &'a str, password: &'a str) -> (wifi::WifiController<'a>, wifi::WifiDevice<'a>) {
|
||||||
|
// Initialize the Wi-Fi controller and device.
|
||||||
|
let peripherals = self.peripherals.borrow_mut().take().expect("Peripherals already taken");
|
||||||
|
let mut rng = Rng::new(peripherals.RNG);
|
||||||
|
let timer1 = TimerGroup::new(peripherals.TIMG0);
|
||||||
|
let wifi_init = &*mk_static!(
|
||||||
|
EspWifiController<'static>,
|
||||||
|
esp_wifi::init(timer1.timer0, rng.clone(), peripherals.RADIO_CLK).unwrap()
|
||||||
|
);
|
||||||
|
let (mut wifi_controller, interfaces) = esp_wifi::wifi::new(&wifi_init, peripherals.WIFI)
|
||||||
|
.expect("Failed to initialize WIFI controller");
|
||||||
|
let config = embassy_net::Config::dhcpv4(Default::default());
|
||||||
|
let wifi_device = interfaces.sta;
|
||||||
|
(wifi_controller, wifi_device)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
impl slint::platform::Platform for EspBackend {
|
|
||||||
fn create_window_adapter(
|
fn create_window_adapter(
|
||||||
&self,
|
&self,
|
||||||
) -> Result<Rc<dyn slint::platform::WindowAdapter>, slint::PlatformError> {
|
) -> Result<Rc<dyn slint::platform::WindowAdapter>, slint::PlatformError> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue