diff options
| author | Ulf Lilleengen <[email protected]> | 2024-09-26 15:41:21 +0200 |
|---|---|---|
| committer | Ulf Lilleengen <[email protected]> | 2024-09-26 15:48:10 +0200 |
| commit | f19718b4f0400dec4e64d32d649c6b0d9eb554e5 (patch) | |
| tree | 413cd96a795f01a51cbd27a594bbc94502df96a8 /embassy-net-nrf91/src/context.rs | |
| parent | 8a5d1454a40f8de7217d9bcbbe54ac9998340ab8 (diff) | |
Add config option for setting SIM pin
Diffstat (limited to 'embassy-net-nrf91/src/context.rs')
| -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 8b45919ef..2dda615c1 100644 --- a/embassy-net-nrf91/src/context.rs +++ b/embassy-net-nrf91/src/context.rs | |||
| @@ -21,6 +21,8 @@ pub struct Config<'a> { | |||
| 21 | pub auth_prot: AuthProt, | 21 | pub auth_prot: AuthProt, |
| 22 | /// Credentials. | 22 | /// Credentials. |
| 23 | pub auth: Option<(&'a [u8], &'a [u8])>, | 23 | pub auth: Option<(&'a [u8], &'a [u8])>, |
| 24 | /// SIM pin | ||
| 25 | pub pin: Option<&'a [u8]>, | ||
| 24 | } | 26 | } |
| 25 | 27 | ||
| 26 | /// Authentication protocol. | 28 | /// Authentication protocol. |
| @@ -133,6 +135,16 @@ impl<'a> Control<'a> { | |||
| 133 | // info!("RES2: {}", unsafe { core::str::from_utf8_unchecked(&buf[..n]) }); | 135 | // info!("RES2: {}", unsafe { core::str::from_utf8_unchecked(&buf[..n]) }); |
| 134 | CommandParser::parse(&buf[..n]).expect_identifier(b"OK").finish()?; | 136 | CommandParser::parse(&buf[..n]).expect_identifier(b"OK").finish()?; |
| 135 | 137 | ||
| 138 | if let Some(pin) = config.pin { | ||
| 139 | let op = CommandBuilder::create_set(&mut cmd, true) | ||
| 140 | .named("+CPIN") | ||
| 141 | .with_string_parameter(pin) | ||
| 142 | .finish() | ||
| 143 | .map_err(|_| Error::BufferTooSmall)?; | ||
| 144 | let _ = self.control.at_command(op, &mut buf).await; | ||
| 145 | // Ignore ERROR which means no pin required | ||
| 146 | } | ||
| 147 | |||
| 136 | Ok(()) | 148 | Ok(()) |
| 137 | } | 149 | } |
| 138 | 150 | ||
