Actually use a random seed in Wi-Fi examples (#2718)

This commit is contained in:
Jesse Braham 2024-12-10 03:02:05 -08:00 committed by GitHub
parent d2f15d69d7
commit f6126502ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 12 additions and 28 deletions

View File

@ -67,15 +67,11 @@ async fn main(spawner: Spawner) -> ! {
esp_alloc::heap_allocator!(72 * 1024); esp_alloc::heap_allocator!(72 * 1024);
let timg0 = TimerGroup::new(peripherals.TIMG0); let timg0 = TimerGroup::new(peripherals.TIMG0);
let mut rng = Rng::new(peripherals.RNG);
let init = &*mk_static!( let init = &*mk_static!(
EspWifiController<'static>, EspWifiController<'static>,
init( init(timg0.timer0, rng.clone(), peripherals.RADIO_CLK).unwrap()
timg0.timer0,
Rng::new(peripherals.RNG),
peripherals.RADIO_CLK,
)
.unwrap()
); );
let wifi = peripherals.WIFI; let wifi = peripherals.WIFI;
@ -102,7 +98,7 @@ async fn main(spawner: Spawner) -> ! {
dns_servers: Default::default(), dns_servers: Default::default(),
}); });
let seed = 1234; // very random, very secure seed let seed = (rng.random() as u64) << 32 | rng.random() as u64;
// Init network stack // Init network stack
let stack = &*mk_static!( let stack = &*mk_static!(

View File

@ -71,15 +71,11 @@ async fn main(spawner: Spawner) -> ! {
esp_alloc::heap_allocator!(72 * 1024); esp_alloc::heap_allocator!(72 * 1024);
let timg0 = TimerGroup::new(peripherals.TIMG0); let timg0 = TimerGroup::new(peripherals.TIMG0);
let mut rng = Rng::new(peripherals.RNG);
let init = &*mk_static!( let init = &*mk_static!(
EspWifiController<'static>, EspWifiController<'static>,
init( init(timg0.timer0, rng.clone(), peripherals.RADIO_CLK).unwrap()
timg0.timer0,
Rng::new(peripherals.RNG),
peripherals.RADIO_CLK,
)
.unwrap()
); );
let wifi = peripherals.WIFI; let wifi = peripherals.WIFI;
@ -104,7 +100,7 @@ async fn main(spawner: Spawner) -> ! {
}); });
let sta_config = embassy_net::Config::dhcpv4(Default::default()); let sta_config = embassy_net::Config::dhcpv4(Default::default());
let seed = 1234; // very random, very secure seed let seed = (rng.random() as u64) << 32 | rng.random() as u64;
// Init network stacks // Init network stacks
let ap_stack = &*mk_static!( let ap_stack = &*mk_static!(

View File

@ -94,15 +94,11 @@ async fn main(spawner: Spawner) -> ! {
let server_address: Ipv4Address = HOST_IP.parse().expect("Invalid HOST_IP address"); let server_address: Ipv4Address = HOST_IP.parse().expect("Invalid HOST_IP address");
let timg0 = TimerGroup::new(peripherals.TIMG0); let timg0 = TimerGroup::new(peripherals.TIMG0);
let mut rng = Rng::new(peripherals.RNG);
let init = &*mk_static!( let init = &*mk_static!(
EspWifiController<'static>, EspWifiController<'static>,
init( init(timg0.timer0, rng.clone(), peripherals.RADIO_CLK).unwrap()
timg0.timer0,
Rng::new(peripherals.RNG),
peripherals.RADIO_CLK,
)
.unwrap()
); );
let wifi = peripherals.WIFI; let wifi = peripherals.WIFI;
@ -122,7 +118,7 @@ async fn main(spawner: Spawner) -> ! {
let config = embassy_net::Config::dhcpv4(Default::default()); let config = embassy_net::Config::dhcpv4(Default::default());
let seed = 1234; // very random, very secure seed let seed = (rng.random() as u64) << 32 | rng.random() as u64;
// Init network stack // Init network stack
let stack = &*mk_static!( let stack = &*mk_static!(

View File

@ -56,15 +56,11 @@ async fn main(spawner: Spawner) -> ! {
esp_alloc::heap_allocator!(72 * 1024); esp_alloc::heap_allocator!(72 * 1024);
let timg0 = TimerGroup::new(peripherals.TIMG0); let timg0 = TimerGroup::new(peripherals.TIMG0);
let mut rng = Rng::new(peripherals.RNG);
let init = &*mk_static!( let init = &*mk_static!(
EspWifiController<'static>, EspWifiController<'static>,
init( init(timg0.timer0, rng.clone(), peripherals.RADIO_CLK).unwrap()
timg0.timer0,
Rng::new(peripherals.RNG),
peripherals.RADIO_CLK,
)
.unwrap()
); );
let wifi = peripherals.WIFI; let wifi = peripherals.WIFI;
@ -84,7 +80,7 @@ async fn main(spawner: Spawner) -> ! {
let config = embassy_net::Config::dhcpv4(Default::default()); let config = embassy_net::Config::dhcpv4(Default::default());
let seed = 1234; // very random, very secure seed let seed = (rng.random() as u64) << 32 | rng.random() as u64;
// Init network stack // Init network stack
let stack = &*mk_static!( let stack = &*mk_static!(