aboutsummaryrefslogtreecommitdiff
path: root/src/device.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/device.rs')
-rw-r--r--src/device.rs37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/device.rs b/src/device.rs
index 4032db6..1e347f4 100644
--- a/src/device.rs
+++ b/src/device.rs
@@ -1240,6 +1240,41 @@ impl Storage {
result.and(Ok(StorageProductionInfo::from(raw_data)))
}
+ /// Clears the warning for a new SD card.
+ ///
+ /// The Storage status contains a field for a new SD card warning. After a factory reset, the
+ /// field is set to true. After filling the SD card with random data, it is set to false.
+ /// This method can be used to set it to false without filling the SD card with random data.
+ ///
+ /// # Errors
+ ///
+ /// - [`InvalidString`][] if the provided password contains a null byte
+ /// - [`WrongPassword`][] if the provided admin password is wrong
+ ///
+ /// # Example
+ ///
+ /// ```no_run
+ /// # use nitrokey::CommandError;
+ ///
+ /// # fn try_main() -> Result<(), CommandError> {
+ /// let device = nitrokey::Storage::connect()?;
+ /// match device.clear_new_sd_card_warning("12345678") {
+ /// Ok(()) => println!("Cleared the new SD card warning."),
+ /// Err(err) => println!("Could not set the clear the new SD card warning: {}", err),
+ /// };
+ /// # Ok(())
+ /// # }
+ /// ```
+ ///
+ /// [`InvalidString`]: enum.CommandError.html#variant.InvalidString
+ /// [`WrongPassword`]: enum.CommandError.html#variant.WrongPassword
+ pub fn clear_new_sd_card_warning(&self, admin_pin: &str) -> Result<(), CommandError> {
+ let admin_pin = get_cstring(admin_pin)?;
+ get_command_result(unsafe {
+ nitrokey_sys::NK_clear_new_sd_card_warning(admin_pin.as_ptr())
+ })
+ }
+
/// Blinks the red and green LED alternatively and infinitely until the device is reconnected.
pub fn wink(&self) -> Result<(), CommandError> {
get_command_result(unsafe { nitrokey_sys::NK_wink() })
@@ -1297,7 +1332,7 @@ impl From<nitrokey_sys::NK_storage_ProductionTest> for StorageProductionInfo {
manufacturing_month: data.SD_Card_ManufacturingMonth_u8,
oem: data.SD_Card_OEM_u16,
manufacturer: data.SD_Card_Manufacturer_u8,
- }
+ },
}
}
}