diff options
| author | Dario Nieuwenhuis <[email protected]> | 2024-09-11 22:06:26 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2024-09-16 21:17:11 +0200 |
| commit | be0d9775e3bcc3c1bd1448e357d7c6cd67b68991 (patch) | |
| tree | 5e8c444b233a86ade113b096ab1e2934b7bbc7bd /examples/nrf9160 | |
| parent | 7648d42b7f23a2caad29ed6e16123b088ccdc8b5 (diff) | |
net: refactor to simplify lifetimes/generics.
Diffstat (limited to 'examples/nrf9160')
| -rw-r--r-- | examples/nrf9160/src/bin/modem_tcp_client.rs | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/examples/nrf9160/src/bin/modem_tcp_client.rs b/examples/nrf9160/src/bin/modem_tcp_client.rs index 5335b6b51..929883884 100644 --- a/examples/nrf9160/src/bin/modem_tcp_client.rs +++ b/examples/nrf9160/src/bin/modem_tcp_client.rs | |||
| @@ -46,15 +46,15 @@ async fn modem_task(runner: Runner<'static>) -> ! { | |||
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | #[embassy_executor::task] | 48 | #[embassy_executor::task] |
| 49 | async fn net_task(stack: &'static Stack<embassy_net_nrf91::NetDriver<'static>>) -> ! { | 49 | async fn net_task(mut runner: embassy_net::Runner<'static, embassy_net_nrf91::NetDriver<'static>>) -> ! { |
| 50 | stack.run().await | 50 | runner.run().await |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | #[embassy_executor::task] | 53 | #[embassy_executor::task] |
| 54 | async fn control_task( | 54 | async fn control_task( |
| 55 | control: &'static context::Control<'static>, | 55 | control: &'static context::Control<'static>, |
| 56 | config: context::Config<'static>, | 56 | config: context::Config<'static>, |
| 57 | stack: &'static Stack<embassy_net_nrf91::NetDriver<'static>>, | 57 | stack: Stack<'static>, |
| 58 | ) { | 58 | ) { |
| 59 | unwrap!(control.configure(&config).await); | 59 | unwrap!(control.configure(&config).await); |
| 60 | unwrap!( | 60 | unwrap!( |
| @@ -150,15 +150,9 @@ async fn main(spawner: Spawner) { | |||
| 150 | 150 | ||
| 151 | // Init network stack | 151 | // Init network stack |
| 152 | static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new(); | 152 | static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new(); |
| 153 | static STACK: StaticCell<Stack<embassy_net_nrf91::NetDriver<'static>>> = StaticCell::new(); | 153 | let (stack, runner) = embassy_net::new(device, config, RESOURCES.init(StackResources::<2>::new()), seed); |
| 154 | let stack = &*STACK.init(Stack::new( | ||
| 155 | device, | ||
| 156 | config, | ||
| 157 | RESOURCES.init(StackResources::<2>::new()), | ||
| 158 | seed, | ||
| 159 | )); | ||
| 160 | 154 | ||
| 161 | unwrap!(spawner.spawn(net_task(stack))); | 155 | unwrap!(spawner.spawn(net_task(runner))); |
| 162 | 156 | ||
| 163 | static CONTROL: StaticCell<context::Control<'static>> = StaticCell::new(); | 157 | static CONTROL: StaticCell<context::Control<'static>> = StaticCell::new(); |
| 164 | let control = CONTROL.init(context::Control::new(control, 0).await); | 158 | let control = CONTROL.init(context::Control::new(control, 0).await); |
