implement sim card pin/puk unlock and management.
lock state detection
check Modem.State for Locked state, then query Modem.UnlockRequired to determine lock type:
MM_MODEM_LOCK_SIM_PIN — needs pin
MM_MODEM_LOCK_SIM_PUK — needs puk + new pin
MM_MODEM_LOCK_SIM_PIN2, MM_MODEM_LOCK_SIM_PUK2 — secondary pin/puk
api
pub async fn unlock_pin(&self, pin: &str) -> Result<()>;
pub async fn unlock_puk(&self, puk: &str, new_pin: &str) -> Result<()>;
pub async fn set_pin_enabled(&self, pin: &str, enabled: bool) -> Result<()>;
pub async fn change_pin(&self, old: &str, new: &str) -> Result<()>;
error handling
map mm errors to typed variants:
- wrong pin →
ModemError::WrongPin
- pin required →
ModemError::PinRequired
- puk required →
ModemError::PukRequired
- sim not inserted →
ModemError::NoSim
retry tracking
Sim.UnlockRetries property gives remaining attempts before lockout. surface this in error messages or as a query method.
implement sim card pin/puk unlock and management.
lock state detection
check
Modem.StateforLockedstate, then queryModem.UnlockRequiredto determine lock type:MM_MODEM_LOCK_SIM_PIN— needs pinMM_MODEM_LOCK_SIM_PUK— needs puk + new pinMM_MODEM_LOCK_SIM_PIN2,MM_MODEM_LOCK_SIM_PUK2— secondary pin/pukapi
error handling
map mm errors to typed variants:
ModemError::WrongPinModemError::PinRequiredModemError::PukRequiredModemError::NoSimretry tracking
Sim.UnlockRetriesproperty gives remaining attempts before lockout. surface this in error messages or as a query method.