mirror of
https://github.com/embassy-rs/embassy.git
synced 2025-10-02 06:40:32 +00:00
Merge pull request #3376 from embassy-rs/nrf91-sim-pin
Add config option for setting SIM pin
This commit is contained in:
commit
eb91089a6c
@ -21,6 +21,8 @@ pub struct Config<'a> {
|
|||||||
pub auth_prot: AuthProt,
|
pub auth_prot: AuthProt,
|
||||||
/// Credentials.
|
/// Credentials.
|
||||||
pub auth: Option<(&'a [u8], &'a [u8])>,
|
pub auth: Option<(&'a [u8], &'a [u8])>,
|
||||||
|
/// SIM pin
|
||||||
|
pub pin: Option<&'a [u8]>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Authentication protocol.
|
/// Authentication protocol.
|
||||||
@ -133,6 +135,16 @@ impl<'a> Control<'a> {
|
|||||||
// info!("RES2: {}", unsafe { core::str::from_utf8_unchecked(&buf[..n]) });
|
// info!("RES2: {}", unsafe { core::str::from_utf8_unchecked(&buf[..n]) });
|
||||||
CommandParser::parse(&buf[..n]).expect_identifier(b"OK").finish()?;
|
CommandParser::parse(&buf[..n]).expect_identifier(b"OK").finish()?;
|
||||||
|
|
||||||
|
if let Some(pin) = config.pin {
|
||||||
|
let op = CommandBuilder::create_set(&mut cmd, true)
|
||||||
|
.named("+CPIN")
|
||||||
|
.with_string_parameter(pin)
|
||||||
|
.finish()
|
||||||
|
.map_err(|_| Error::BufferTooSmall)?;
|
||||||
|
let _ = self.control.at_command(op, &mut buf).await;
|
||||||
|
// Ignore ERROR which means no pin required
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,6 +163,7 @@ async fn main(spawner: Spawner) {
|
|||||||
apn: b"iot.nat.es",
|
apn: b"iot.nat.es",
|
||||||
auth_prot: context::AuthProt::Pap,
|
auth_prot: context::AuthProt::Pap,
|
||||||
auth: Some((b"orange", b"orange")),
|
auth: Some((b"orange", b"orange")),
|
||||||
|
pin: None,
|
||||||
},
|
},
|
||||||
stack
|
stack
|
||||||
)));
|
)));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user