Skip to content

Commit

Permalink
Fix for #153 (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
akopachov authored Jun 5, 2023
1 parent 123f421 commit 9713ccb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions features_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@
// List of compatible firmwares
#define TOTP_FIRMWARE_OFFICIAL_STABLE (1)
#define TOTP_FIRMWARE_OFFICIAL_DEV (2)
#define TOTP_FIRMWARE_XTREME (3)
#define TOTP_FIRMWARE_XTREME_UL (3)
// End of list

// Checking FlipC.org definitions (https://github.com/playmean/fap-list/issues/9)
#if defined(TARGET_FIRMWARE_OFFICIAL)
#define TOTP_TARGET_FIRMWARE TOTP_FIRMWARE_OFFICIAL_STABLE
#elif defined(TARGET_FIRMWARE_UNLEASHED)
#define TOTP_TARGET_FIRMWARE TOTP_FIRMWARE_OFFICIAL_DEV
#define TOTP_TARGET_FIRMWARE TOTP_FIRMWARE_XTREME_UL
#elif defined(TARGET_FIRMWARE_XTREME)
#define TOTP_TARGET_FIRMWARE TOTP_FIRMWARE_XTREME
#define TOTP_TARGET_FIRMWARE TOTP_FIRMWARE_XTREME_UL
#endif
// End of FlipC.org definition checks

// If target firmware is not yet set, default it to Xtreme as I'm using it, and it is cool :)
// If target firmware is not yet set, default it to Xtreme\Unleashed as I'm using it, and it is cool :)
#ifndef TOTP_TARGET_FIRMWARE
#define TOTP_TARGET_FIRMWARE TOTP_FIRMWARE_XTREME
#define TOTP_TARGET_FIRMWARE TOTP_FIRMWARE_XTREME_UL
#endif

// List of available font for TOTP code
Expand Down
2 changes: 1 addition & 1 deletion services/crypto/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ CryptoSeedIVResult
max_i = uid_size;
}

const uint8_t* uid = furi_hal_version_uid();
const uint8_t* uid = (const uint8_t*)UID64_BASE;
for(uint8_t i = 0; i < max_i; i++) {
plugin_state->iv[i] = plugin_state->iv[i] ^ uid[i];
}
Expand Down
14 changes: 7 additions & 7 deletions workers/bt_type_code/bt_type_code.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "../type-code-common.h"
#include "../../features_config.h"

#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_XTREME
#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_XTREME_UL
#define TOTP_BT_WORKER_BT_ADV_NAME_MAX_LEN FURI_HAL_BT_ADV_NAME_LENGTH
#define TOTP_BT_WORKER_BT_MAC_ADDRESS_LEN GAP_MAC_ADDR_SIZE
#endif
Expand All @@ -29,7 +29,7 @@ struct TotpBtTypeCodeWorkerContext {
Bt* bt;
bool is_advertising;
bool is_connected;
#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_XTREME
#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_XTREME_UL
char previous_bt_name[TOTP_BT_WORKER_BT_ADV_NAME_MAX_LEN];
uint8_t previous_bt_mac[TOTP_BT_WORKER_BT_MAC_ADDRESS_LEN];
#endif
Expand All @@ -39,7 +39,7 @@ static inline bool totp_type_code_worker_stop_requested() {
return furi_thread_flags_get() & TotpBtTypeCodeWorkerEventStop;
}

#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_XTREME
#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_XTREME_UL
static void totp_type_code_worker_bt_set_app_mac(uint8_t* mac) {
uint8_t max_i;
size_t uid_size = furi_hal_version_uid_size();
Expand All @@ -49,7 +49,7 @@ static void totp_type_code_worker_bt_set_app_mac(uint8_t* mac) {
max_i = TOTP_BT_WORKER_BT_MAC_ADDRESS_LEN;
}

const uint8_t* uid = furi_hal_version_uid();
const uint8_t* uid = (const uint8_t*)UID64_BASE;
memcpy(mac, uid, max_i);
for(uint8_t i = max_i; i < TOTP_BT_WORKER_BT_MAC_ADDRESS_LEN; i++) {
mac[i] = 0;
Expand Down Expand Up @@ -161,7 +161,7 @@ TotpBtTypeCodeWorkerContext* totp_bt_type_code_worker_init() {
furi_delay_ms(200);
bt_keys_storage_set_storage_path(context->bt, HID_BT_KEYS_STORAGE_PATH);

#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_XTREME
#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_XTREME_UL
memcpy(
&context->previous_bt_name[0],
furi_hal_bt_get_profile_adv_name(FuriHalBtProfileHidKeyboard),
Expand All @@ -184,7 +184,7 @@ TotpBtTypeCodeWorkerContext* totp_bt_type_code_worker_init() {

furi_hal_bt_start_advertising();

#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_XTREME
#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_XTREME_UL
bt_enable_peer_key_update(context->bt);
#endif

Expand All @@ -211,7 +211,7 @@ void totp_bt_type_code_worker_free(TotpBtTypeCodeWorkerContext* context) {
furi_delay_ms(200);
bt_keys_storage_set_default_path(context->bt);

#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_XTREME
#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_XTREME_UL
furi_hal_bt_set_profile_adv_name(FuriHalBtProfileHidKeyboard, context->previous_bt_name);
furi_hal_bt_set_profile_mac_addr(FuriHalBtProfileHidKeyboard, context->previous_bt_mac);
#endif
Expand Down

0 comments on commit 9713ccb

Please sign in to comment.