diff options
| author | Ulf Lilleengen <[email protected]> | 2024-09-06 09:52:26 +0200 |
|---|---|---|
| committer | Ulf Lilleengen <[email protected]> | 2024-09-06 09:52:26 +0200 |
| commit | 5e74434cb8b89b62f7bc0d2a9ab90d94aa11fe4b (patch) | |
| tree | 2b3b7ddc1d867f16954f6ef6bcd614ee8de134de /embassy-net-nrf91/src | |
| parent | ac7ebea762519505a0ea54ce753ec2a9fc67dfe9 (diff) | |
Ensure modem is enabled in run()
Diffstat (limited to 'embassy-net-nrf91/src')
| -rw-r--r-- | embassy-net-nrf91/src/context.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/embassy-net-nrf91/src/context.rs b/embassy-net-nrf91/src/context.rs index d5d088ec0..2f2452bd0 100644 --- a/embassy-net-nrf91/src/context.rs +++ b/embassy-net-nrf91/src/context.rs | |||
| @@ -303,6 +303,18 @@ impl<'a> Control<'a> { | |||
| 303 | 303 | ||
| 304 | /// Run a control loop for this context, ensuring that reaattach is handled. | 304 | /// Run a control loop for this context, ensuring that reaattach is handled. |
| 305 | pub async fn run<F: Fn(&Status)>(&self, reattach: F) -> Result<(), Error> { | 305 | pub async fn run<F: Fn(&Status)>(&self, reattach: F) -> Result<(), Error> { |
| 306 | let mut cmd: [u8; 256] = [0; 256]; | ||
| 307 | let mut buf: [u8; 256] = [0; 256]; | ||
| 308 | |||
| 309 | // Make sure modem is enabled | ||
| 310 | let op = CommandBuilder::create_set(&mut cmd, true) | ||
| 311 | .named("+CFUN") | ||
| 312 | .with_int_parameter(1) | ||
| 313 | .finish() | ||
| 314 | .map_err(|_| Error::BufferTooSmall)?; | ||
| 315 | |||
| 316 | let n = self.control.at_command(op, &mut buf).await; | ||
| 317 | CommandParser::parse(&buf[..n]).expect_identifier(b"OK").finish()?; | ||
| 306 | let status = self.wait_attached().await?; | 318 | let status = self.wait_attached().await?; |
| 307 | let mut fd = self.control.open_raw_socket().await; | 319 | let mut fd = self.control.open_raw_socket().await; |
| 308 | reattach(&status); | 320 | reattach(&status); |
