mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-21 07:41:51 +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
|
@ -58,8 +58,38 @@ pub fn init() {
|
|||
}))
|
||||
.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(
|
||||
&self,
|
||||
) -> Result<Rc<dyn slint::platform::WindowAdapter>, slint::PlatformError> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue