Skip to content

Commit

Permalink
Show firmware version in status
Browse files Browse the repository at this point in the history
  • Loading branch information
afilini committed May 8, 2024
1 parent 3ce7f53 commit bdc1056
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 11 deletions.
1 change: 1 addition & 0 deletions firmware/src/handlers/idle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub async fn handle_idle(
.nfc
.send(Reply::Info(DeviceInfo::new_unlocked_initialized(
wallet.network(),
env!("CARGO_PKG_VERSION")
)))
.await
.unwrap();
Expand Down
4 changes: 3 additions & 1 deletion firmware/src/handlers/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ pub async fn handle_init(
Some(model::Request::GetInfo) => {
peripherals
.nfc
.send(model::Reply::Info(DeviceInfo::new_locked_uninitialized()))
.send(model::Reply::Info(DeviceInfo::new_locked_uninitialized(env!("CARGO_PKG_VERSION"))))
.await
.unwrap();
peripherals.nfc_finished.recv().await.unwrap();
Expand Down Expand Up @@ -374,6 +374,7 @@ pub async fn handle_locked(
.nfc
.send(model::Reply::Info(DeviceInfo::new_locked_initialized(
config.network,
env!("CARGO_PKG_VERSION")
)))
.await
.unwrap();
Expand Down Expand Up @@ -565,6 +566,7 @@ pub async fn handle_unverified_config(
.send(model::Reply::Info(DeviceInfo::new_unverified_config(
config.network,
config.pair_code.is_some(),
env!("CARGO_PKG_VERSION")
)))
.await
.unwrap();
Expand Down
6 changes: 4 additions & 2 deletions firmware/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,10 +461,12 @@ mod app {
}

#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
fn panic(info: &core::panic::PanicInfo) -> ! {
log::error!("PANIC LOCATION: {:?}", info.location());

// NOTE: this adds a ton of extra code, probably to debug-format errors
#[cfg(feature = "panic-log")]
log::error!("PANIC: {:?}", _info);
log::error!("PANIC: {:?}", info);

#[cfg(feature = "emulator")]
{
Expand Down
2 changes: 2 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,12 @@

devShells.default = pkgs.mkShell {
buildInputs = defaultDeps ++ [ rust ];
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
};
devShells.embedded = pkgs.mkShell {
buildInputs = defaultDeps ++ embeddedDeps ++ [ packages.hal ];

LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
CC_thumbv7em_none_eabihf = "${pkgs.gcc-arm-embedded}/bin/arm-none-eabi-gcc";
};
devShells.android = pkgs.mkShell rec {
Expand Down
20 changes: 12 additions & 8 deletions model/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -793,37 +793,41 @@ pub enum InitializationStatus {
}

impl DeviceInfo {
pub fn new_locked_uninitialized() -> Self {
pub fn new_locked_uninitialized(version: &'static str) -> Self {
DeviceInfo {
initialized: InitializationStatus::Uninitialized,
firmware_version: Some(env!("CARGO_PKG_VERSION").to_string()),
firmware_version: Some(version.to_string()),
}
}

pub fn new_locked_initialized(network: bitcoin::Network) -> Self {
pub fn new_locked_initialized(network: bitcoin::Network, version: &'static str) -> Self {
DeviceInfo {
initialized: InitializationStatus::Initialized {
unlocked: false,
network,
},
firmware_version: Some(env!("CARGO_PKG_VERSION").to_string()),
firmware_version: Some(version.to_string()),
}
}

pub fn new_unverified_config(network: bitcoin::Network, with_code: bool) -> Self {
pub fn new_unverified_config(
network: bitcoin::Network,
with_code: bool,
version: &'static str,
) -> Self {
DeviceInfo {
initialized: InitializationStatus::Unverified { with_code, network },
firmware_version: Some(env!("CARGO_PKG_VERSION").to_string()),
firmware_version: Some(version.to_string()),
}
}

pub fn new_unlocked_initialized(network: bitcoin::Network) -> Self {
pub fn new_unlocked_initialized(network: bitcoin::Network, version: &'static str) -> Self {
DeviceInfo {
initialized: InitializationStatus::Initialized {
unlocked: true,
network,
},
firmware_version: Some(env!("CARGO_PKG_VERSION").to_string()),
firmware_version: Some(version.to_string()),
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,18 +193,21 @@ impl PortalSdk {
unverified: None,
unlocked,
network: Some(network),
version: device_info.firmware_version,
}),
InitializationStatus::Uninitialized => Ok(CardStatus {
initialized: false,
unverified: None,
unlocked: true,
network: None,
version: device_info.firmware_version,
}),
InitializationStatus::Unverified { with_code, network } => Ok(CardStatus {
initialized: false,
unverified: Some(with_code),
unlocked: true,
network: Some(network),
version: device_info.firmware_version,
}),
}
}
Expand Down Expand Up @@ -694,6 +697,7 @@ pub struct CardStatus {
pub unverified: Option<bool>,
pub unlocked: bool,
pub network: Option<model::bitcoin::Network>,
pub version: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
Expand Down

0 comments on commit bdc1056

Please sign in to comment.