Skip to content

Commit

Permalink
Extract hardcoded socket count
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Oct 9, 2023
1 parent a61d111 commit f75d5f3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/board/wifi/ap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use gui::widgets::wifi::WifiState;
use crate::{
board::{
hal::{radio::Wifi, Rng},
wifi::net_task,
wifi::{net_task, STACK_SOCKET_COUNT},
},
task_control::{TaskControlToken, TaskController},
};
Expand Down Expand Up @@ -76,7 +76,7 @@ impl ApState {
init: EspWifiInitialization,
config: Config,
wifi: &'static mut Wifi,
resources: &'static mut StackResources<3>,
resources: &'static mut StackResources<STACK_SOCKET_COUNT>,
mut rng: Rng,
) -> Self {
info!("Configuring AP");
Expand Down
12 changes: 10 additions & 2 deletions src/board/wifi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ pub unsafe fn as_static_mut<T>(what: &mut T) -> &'static mut T {
pub mod ap;
pub mod sta;

const STACK_SOCKET_COUNT: usize = 3;

#[derive(Default, PartialEq)]
pub enum GenericConnectionState {
Sta(sta::ConnectionState),
Expand Down Expand Up @@ -70,8 +72,14 @@ impl WifiHandle {
enum WifiDriverState {
Uninitialized(WifiInitResources),
Initialized(EspWifiInitialization),
Ap(MaybeUninit<ApState>, Box<StackResources<3>>),
Sta(MaybeUninit<StaState>, Box<StackResources<3>>),
Ap(
MaybeUninit<ApState>,
Box<StackResources<STACK_SOCKET_COUNT>>,
),
Sta(
MaybeUninit<StaState>,
Box<StackResources<STACK_SOCKET_COUNT>>,
),
}

impl WifiDriverState {
Expand Down
4 changes: 2 additions & 2 deletions src/board/wifi/sta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
board::{
hal::{radio::Wifi, Rng},
initialized::Board,
wifi::net_task,
wifi::{net_task, STACK_SOCKET_COUNT},
},
states::display_message,
task_control::{TaskControlToken, TaskController},
Expand Down Expand Up @@ -281,7 +281,7 @@ impl StaState {
init: EspWifiInitialization,
config: Config,
wifi: &'static mut Wifi,
resources: &'static mut StackResources<3>,
resources: &'static mut StackResources<STACK_SOCKET_COUNT>,
mut rng: Rng,
) -> Self {
info!("Configuring STA");
Expand Down

0 comments on commit f75d5f3

Please sign in to comment.