diff options
| -rw-r--r-- | embassy-net-nrf91/src/context.rs | 12 | ||||
| -rw-r--r-- | examples/nrf9160/src/bin/modem_tcp_client.rs | 1 |
2 files changed, 13 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 | ||
diff --git a/examples/nrf9160/src/bin/modem_tcp_client.rs b/examples/nrf9160/src/bin/modem_tcp_client.rs index 929883884..495ee26dd 100644 --- a/examples/nrf9160/src/bin/modem_tcp_client.rs +++ b/examples/nrf9160/src/bin/modem_tcp_client.rs | |||
| @@ -163,6 +163,7 @@ async fn main(spawner: Spawner) { | |||
| 163 | apn: b"iot.nat.es", | 163 | apn: b"iot.nat.es", |
| 164 | auth_prot: context::AuthProt::Pap, | 164 | auth_prot: context::AuthProt::Pap, |
| 165 | auth: Some((b"orange", b"orange")), | 165 | auth: Some((b"orange", b"orange")), |
| 166 | pin: None, | ||
| 166 | }, | 167 | }, |
| 167 | stack | 168 | stack |
| 168 | ))); | 169 | ))); |
