Skip to content

Commit

Permalink
Merge pull request #576 from Cypherock/fix/inheritance/no-wallet-beep…
Browse files Browse the repository at this point in the history
…-sound
  • Loading branch information
TejasvOnly authored Nov 14, 2024
2 parents 79d1533 + 080a62c commit fcaeb36
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 15 deletions.
12 changes: 12 additions & 0 deletions apps/inheritance_app/inheritance_auth_wallet.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <stdbool.h>
#include <stdint.h>
#include <string.h>

#include "bip39.h"
#include "card_fetch_data.h"
Expand Down Expand Up @@ -178,6 +179,15 @@ static void auth_wallet_handle_errors() {
}
LOG_ERROR("inheritance_auth_wallet error code:%d ", auth_wallet_error.type);

// Display any error msg if exists
if (0 != strlen(error_screen.core_error_msg)) {
if (error_screen.ring_buzzer) {
buzzer_start(BUZZER_DURATION);
}
delay_scr_init(error_screen.core_error_msg, DELAY_SHORT);
clear_core_error_screen();
}

switch (type) {
case AUTH_WALLET_USER_ABORT_ERROR: {
// Error already sent to host, nothing to do here
Expand Down Expand Up @@ -460,6 +470,8 @@ auth_wallet_error_type_e inheritance_auth_wallet(inheritance_query_t *query) {
auth_wallet_get_pairs() && auth_wallet_get_signature() && send_result()) {
delay_scr_init(ui_text_inheritance_wallet_auth_success, DELAY_TIME);
SET_ERROR_TYPE(AUTH_WALLET_OK);
} else {
delay_scr_init(ui_text_inheritance_wallet_auth_fail, DELAY_TIME);
}
auth_wallet_handle_errors();
memzero(auth, sizeof(auth_wallet_config_t));
Expand Down
8 changes: 7 additions & 1 deletion apps/inheritance_app/inheritance_decrypt_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
#include "card_fetch_data.h"
#include "card_operation_typedefs.h"
#include "constant_texts.h"
#include "core_error.h"
#include "core_session.h"
#include "inheritance/core.pb.h"
#include "inheritance/decrypt_data_with_pin.pb.h"
Expand Down Expand Up @@ -603,13 +604,18 @@ static bool decrypt_data(void) {
status = false;
break;
}

if (!decrypt_message_data()) {
status = false;
break;
}

} while (0);
delay_scr_init(ui_text_processing, DELAY_SHORT);

// Display Processing only if proceeding with flow
if (status) {
delay_scr_init(ui_text_processing, DELAY_SHORT);
}
return status;
}

Expand Down
19 changes: 18 additions & 1 deletion apps/inheritance_app/inheritance_encrypt_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@
*****************************************************************************/

#include <stdint.h>
#include <string.h>

#include "bignum.h"
#include "card_fetch_data.h"
#include "constant_texts.h"
#include "core_error.h"
#include "core_session.h"
#include "inheritance/common.pb.h"
#include "inheritance/core.pb.h"
Expand All @@ -80,6 +82,7 @@
#include "ui_core_confirm.h"
#include "ui_delay.h"
#include "ui_input_text.h"
#include "ui_message.h"
#include "utils.h"
#include "verify_pin_flow.h"
#include "wallet.h"
Expand Down Expand Up @@ -315,6 +318,16 @@ static void encryption_handle_errors() {
LOG_ERROR("inheritance_encrypt_data Error Code:%d Flow Tag:%d ",
encryption_error.type,
encryption_error.flow);

// Display any error msg if exists
if (0 != strlen(error_screen.core_error_msg)) {
if (error_screen.ring_buzzer) {
buzzer_start(BUZZER_DURATION);
}
delay_scr_init(error_screen.core_error_msg, DELAY_TIME);
clear_core_error_screen();
}

encryption_error_type_e type = encryption_error.type;
switch (type) {
case ENCRYPTION_ERROR_DEFAULT:
Expand Down Expand Up @@ -650,6 +663,7 @@ static bool encrypt_data(void) {
status = false;
break;
}

if (!serialize_message_data()) {
status = false;
break;
Expand All @@ -671,7 +685,10 @@ static bool encrypt_data(void) {
}
} while (0);

delay_scr_init(ui_text_processing, DELAY_TIME);
// Display Processing only if proceeding with flow
if (status) {
delay_scr_init(ui_text_processing, DELAY_SHORT);
}
return status;
}

Expand Down
10 changes: 3 additions & 7 deletions common/core/core_error.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
/*****************************************************************************
* EXTERN VARIABLES
*****************************************************************************/
error_screen_t error_screen;

/*****************************************************************************
* PRIVATE MACROS AND DEFINES
Expand All @@ -81,12 +82,6 @@
/*****************************************************************************
* PRIVATE TYPEDEFS
*****************************************************************************/
typedef struct {
char core_error_msg[60]; /**< Buffer to store the error message that needs to
be displayed */
bool ring_buzzer; /**< Configuration parameter to record if buzzer is required
while the error is being displayed */
} error_screen_t;

/*****************************************************************************
* STATIC FUNCTION PROTOTYPES
Expand All @@ -107,7 +102,6 @@ static void display_core_error();
/*****************************************************************************
* STATIC VARIABLES
*****************************************************************************/
static error_screen_t error_screen = {0};

/*****************************************************************************
* GLOBAL VARIABLES
Expand Down Expand Up @@ -182,6 +176,8 @@ void handle_core_errors() {
}

display_core_error();
// clear error_screen after display
clear_core_error_screen();
return;
}

Expand Down
7 changes: 7 additions & 0 deletions common/core/core_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,17 @@
/*****************************************************************************
* TYPEDEFS
*****************************************************************************/
typedef struct {
char core_error_msg[60]; /**< Buffer to store the error message that needs to
be displayed */
bool ring_buzzer; /**< Configuration parameter to record if buzzer is required
while the error is being displayed */
} error_screen_t;

/*****************************************************************************
* EXPORTED VARIABLES
*****************************************************************************/
extern error_screen_t error_screen;

/*****************************************************************************
* GLOBAL FUNCTION PROTOTYPES
Expand Down
1 change: 1 addition & 0 deletions src/card_operations/card_fetch_wallet_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ bool card_fetch_wallet_name(const uint8_t *wallet_id, char *wallet_name) {
}

if (0 == strlen(wallet_name)) {
buzzer_start(BUZZER_DURATION);
delay_scr_init(ui_text_wallet_doesnt_exists_on_this_card, DELAY_TIME);
return false;
}
Expand Down
12 changes: 6 additions & 6 deletions src/wallet/verify_pin_flow.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,13 @@ static bool get_verified_pin(const uint8_t *wallet_id,
}

if (COMPLETED == current_state) {
return true;
} else if (reject_cb && EARLY_EXIT == current_state) {
// Inform the host of any rejection
reject_cb(ERROR_COMMON_ERROR_USER_REJECTION_TAG,
ERROR_USER_REJECTION_CONFIRMATION);
return false;
}
return true;
return false;
}

/*****************************************************************************
Expand All @@ -272,15 +272,15 @@ bool verify_pin(const uint8_t *wallet_id,
if ((NULL == wallet_id) || (NULL == pin_out)) {
return false;
}

bool status = false;
clear_wallet_data();
mnemonic_clear();

if (!get_verified_pin(wallet_id, PIN_INPUT, pin_out, reject_cb)) {
return false;
if (get_verified_pin(wallet_id, PIN_INPUT, pin_out, reject_cb)) {
status = true;
}

mnemonic_clear();
clear_wallet_data();
return true;
return status;
}

0 comments on commit fcaeb36

Please sign in to comment.