Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'unleashed/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
xMasterX committed Mar 20, 2024
2 parents d1e10a4 + 139cc3c commit 1c28870
Show file tree
Hide file tree
Showing 88 changed files with 487 additions and 214 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ static void nfc_scene_read_setup_view(NfcApp* instance) {
popup_set_icon(instance->popup, 0, 8, &I_NFC_manual_60x50);
popup_set_header(instance->popup, "Unlocking", 97, 15, AlignCenter, AlignTop);
popup_set_text(
instance->popup, "Apply card to\nFlipper's back", 97, 27, AlignCenter, AlignTop);
instance->popup, "Hold card next\nto Flipper's back", 94, 27, AlignCenter, AlignTop);
} else {
popup_set_header(instance->popup, "Don't move", 85, 27, AlignCenter, AlignTop);
popup_set_icon(instance->popup, 12, 20, &A_Loading_24);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ static void nfc_render_mf_ultralight_pages_count(const MfUltralightData* data, F

void nfc_render_mf_ultralight_pwd_pack(const MfUltralightData* data, FuriString* str) {
bool all_pages = mf_ultralight_is_all_data_read(data);
furi_string_cat_printf(str, "\e#%s pages unlocked!", all_pages ? "All" : "Not all");
if(all_pages) {
furi_string_cat_printf(str, "\e#All Pages Are Unlocked!");
} else {
furi_string_cat_printf(str, "\e#Some Pages Are Locked!");
}

MfUltralightConfigPages* config;
mf_ultralight_get_config_page(data, &config);
Expand Down
2 changes: 1 addition & 1 deletion applications/main/nfc/plugins/supported_cards/myki.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static bool myki_parse(const NfcDevice* device, FuriString* parsed_data) {
// Stored card number doesn't include check digit
card_number += myki_calculate_luhn(card_number);

furi_string_set(parsed_data, "\e#myki\n");
furi_string_set(parsed_data, "\e#myki\nNo.: ");

// Stylise card number according to the physical card
char card_string[20];
Expand Down
2 changes: 1 addition & 1 deletion applications/main/nfc/plugins/supported_cards/opal.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ static bool opal_parse(const NfcDevice* device, FuriString* parsed_data) {

furi_string_printf(
parsed_data,
"\e#Opal: $%s%ld.%02hu\n3085 22%02hhu %04hu %03hu%01hhu\n%s, %s\n",
"\e#Opal: $%s%ld.%02hu\nNo.: 3085 22%02hhu %04hu %03hu%01hhu\n%s, %s\n",
sign,
balance_dollars,
balance_cents,
Expand Down
2 changes: 1 addition & 1 deletion applications/main/nfc/plugins/supported_cards/plantain.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ static bool plantain_parse(const NfcDevice* device, FuriString* parsed_data) {
}

furi_string_printf(
parsed_data, "\e#Plantain\nN:%llu-\nBalance:%lu\n", card_number, balance);
parsed_data, "\e#Plantain\nNo.: %llu?\nBalance:%lu\n", card_number, balance);
parsed = true;
} while(false);

Expand Down
2 changes: 1 addition & 1 deletion applications/main/nfc/plugins/supported_cards/two_cities.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ static bool two_cities_parse(const NfcDevice* device, FuriString* parsed_data) {

furi_string_printf(
parsed_data,
"\e#Troika+Plantain\nPN: %llu-\nPB: %lu rur.\nTN: %lu\nTB: %u rur.\n",
"\e#Troika+Plantain\nPN: %llu?\nPB: %lu rur.\nTN: %lu\nTB: %u rur.\n",
card_number,
balance,
troika_number,
Expand Down
3 changes: 2 additions & 1 deletion applications/main/nfc/scenes/nfc_scene_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ ADD_SCENE(nfc, mf_classic_mfkey_nonces_info, MfClassicMfkeyNoncesInfo)
ADD_SCENE(nfc, mf_classic_mfkey_complete, MfClassicMfkeyComplete)
ADD_SCENE(nfc, mf_classic_update_initial, MfClassicUpdateInitial)
ADD_SCENE(nfc, mf_classic_update_initial_success, MfClassicUpdateInitialSuccess)
ADD_SCENE(nfc, mf_classic_update_initial_wrong_card, MfClassicUpdateInitialWrongCard)
ADD_SCENE(nfc, mf_classic_write_initial, MfClassicWriteInitial)
ADD_SCENE(nfc, mf_classic_write_initial_success, MfClassicWriteInitialSuccess)
ADD_SCENE(nfc, mf_classic_write_initial_fail, MfClassicWriteInitialFail)
ADD_SCENE(nfc, mf_classic_wrong_card, MfClassicWrongCard)
ADD_SCENE(nfc, mf_classic_write_initial_wrong_card, MfClassicWriteInitialWrongCard)

ADD_SCENE(nfc, mf_classic_keys, MfClassicKeys)
ADD_SCENE(nfc, mf_classic_keys_list, MfClassicKeysList)
Expand Down
2 changes: 1 addition & 1 deletion applications/main/nfc/scenes/nfc_scene_detect.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void nfc_scene_detect_on_enter(void* context) {
popup_reset(instance->popup);
popup_set_header(instance->popup, "Reading", 97, 15, AlignCenter, AlignTop);
popup_set_text(
instance->popup, "Apply card to\nFlipper's back", 97, 27, AlignCenter, AlignTop);
instance->popup, "Hold card next\nto Flipper's back", 94, 27, AlignCenter, AlignTop);
popup_set_icon(instance->popup, 0, 8, &I_NFC_manual_60x50);
view_dispatcher_switch_to_view(instance->view_dispatcher, NfcViewPopup);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ void nfc_scene_mf_classic_keys_warn_duplicate_on_enter(void* context) {
// Setup view
Popup* popup = instance->popup;
popup_set_icon(popup, 83, 22, &I_WarningDolphinFlip_45x42);
popup_set_header(popup, "Key already exists!", 64, 3, AlignCenter, AlignTop);
popup_set_header(popup, "Key Already Exists!", 64, 3, AlignCenter, AlignTop);
popup_set_text(
popup,
"Please enter a\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void nfc_scene_mf_classic_mfkey_complete_on_enter(void* context) {
NfcApp* instance = context;

widget_add_string_element(
instance->widget, 64, 0, AlignCenter, AlignTop, FontPrimary, "Complete!");
instance->widget, 64, 0, AlignCenter, AlignTop, FontPrimary, "Completed!");
widget_add_string_multiline_element(
instance->widget,
64,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static void nfc_scene_mf_classic_update_initial_setup_view(NfcApp* instance) {

if(state == NfcSceneMfClassicUpdateInitialStateCardSearch) {
popup_set_text(
instance->popup, "Apply the initial\ncard only", 128, 32, AlignRight, AlignCenter);
instance->popup, "Use the source\ncard only", 128, 32, AlignRight, AlignCenter);
popup_set_icon(instance->popup, 0, 8, &I_NFC_manual_60x50);
} else {
popup_set_header(popup, "Updating\nDon't move...", 52, 32, AlignLeft, AlignCenter);
Expand Down Expand Up @@ -111,14 +111,16 @@ bool nfc_scene_mf_classic_update_initial_on_event(void* context, SceneManagerEve
nfc_scene_mf_classic_update_initial_setup_view(instance);
consumed = true;
} else if(event.event == NfcCustomEventWrongCard) {
scene_manager_next_scene(instance->scene_manager, NfcSceneMfClassicWrongCard);
scene_manager_next_scene(
instance->scene_manager, NfcSceneMfClassicUpdateInitialWrongCard);
consumed = true;
} else if(event.event == NfcCustomEventWorkerExit) {
if(nfc_save_shadow_file(instance)) {
scene_manager_next_scene(
instance->scene_manager, NfcSceneMfClassicUpdateInitialSuccess);
} else {
scene_manager_next_scene(instance->scene_manager, NfcSceneMfClassicWrongCard);
scene_manager_next_scene(
instance->scene_manager, NfcSceneMfClassicUpdateInitialWrongCard);
consumed = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#include "../nfc_app_i.h"

void nfc_scene_mf_classic_update_initial_wrong_card_widget_callback(
GuiButtonType result,
InputType type,
void* context) {
NfcApp* instance = context;
if(type == InputTypeShort) {
view_dispatcher_send_custom_event(instance->view_dispatcher, result);
}
}

void nfc_scene_mf_classic_update_initial_wrong_card_on_enter(void* context) {
NfcApp* instance = context;
Widget* widget = instance->widget;

notification_message(instance->notifications, &sequence_error);

widget_add_icon_element(widget, 83, 22, &I_WarningDolphinFlip_45x42);
widget_add_string_element(widget, 3, 4, AlignLeft, AlignTop, FontPrimary, "Wrong Card!");
widget_add_string_multiline_element(
widget,
4,
17,
AlignLeft,
AlignTop,
FontSecondary,
"Data management\nis only possible\nwith source card");
widget_add_button_element(
widget,
GuiButtonTypeLeft,
"Retry",
nfc_scene_mf_classic_update_initial_wrong_card_widget_callback,
instance);

// Setup and start worker
view_dispatcher_switch_to_view(instance->view_dispatcher, NfcViewWidget);
}

bool nfc_scene_mf_classic_update_initial_wrong_card_on_event(
void* context,
SceneManagerEvent event) {
NfcApp* instance = context;
bool consumed = false;

if(event.type == SceneManagerEventTypeCustom) {
if(event.event == GuiButtonTypeLeft) {
consumed = scene_manager_previous_scene(instance->scene_manager);
}
}
return consumed;
}

void nfc_scene_mf_classic_update_initial_wrong_card_on_exit(void* context) {
NfcApp* instance = context;

widget_reset(instance->widget);
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static void nfc_scene_mf_classic_write_initial_setup_view(NfcApp* instance) {
if(state == NfcSceneMfClassicWriteInitialStateCardSearch) {
popup_set_header(instance->popup, "Writing", 95, 20, AlignCenter, AlignCenter);
popup_set_text(
instance->popup, "Apply the initial\ncard only", 95, 38, AlignCenter, AlignCenter);
instance->popup, "Use the source\ncard only", 95, 38, AlignCenter, AlignCenter);
popup_set_icon(instance->popup, 0, 8, &I_NFC_manual_60x50);
} else {
popup_set_header(popup, "Writing\nDon't move...", 52, 32, AlignLeft, AlignCenter);
Expand Down Expand Up @@ -115,7 +115,8 @@ bool nfc_scene_mf_classic_write_initial_on_event(void* context, SceneManagerEven
nfc_scene_mf_classic_write_initial_setup_view(instance);
consumed = true;
} else if(event.event == NfcCustomEventWrongCard) {
scene_manager_next_scene(instance->scene_manager, NfcSceneMfClassicWrongCard);
scene_manager_next_scene(
instance->scene_manager, NfcSceneMfClassicWriteInitialWrongCard);
consumed = true;
} else if(event.event == NfcCustomEventPollerSuccess) {
scene_manager_next_scene(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "../nfc_app_i.h"

void nfc_scene_mf_classic_wrong_card_widget_callback(
void nfc_scene_mf_classic_write_initial_wrong_card_widget_callback(
GuiButtonType result,
InputType type,
void* context) {
Expand All @@ -10,35 +10,35 @@ void nfc_scene_mf_classic_wrong_card_widget_callback(
}
}

void nfc_scene_mf_classic_wrong_card_on_enter(void* context) {
void nfc_scene_mf_classic_write_initial_wrong_card_on_enter(void* context) {
NfcApp* instance = context;
Widget* widget = instance->widget;

notification_message(instance->notifications, &sequence_error);

widget_add_icon_element(widget, 83, 22, &I_WarningDolphinFlip_45x42);
widget_add_string_element(
widget, 3, 4, AlignLeft, AlignTop, FontPrimary, "This is wrong card");
widget, 3, 4, AlignLeft, AlignTop, FontPrimary, "Use The Source Card!");
widget_add_string_multiline_element(
widget,
4,
17,
AlignLeft,
AlignTop,
FontSecondary,
"Data management\nis only possible\nwith initial card");
"Go to NFC Magic\napp if you want to\nwrite blanks");
widget_add_button_element(
widget,
GuiButtonTypeLeft,
"Retry",
nfc_scene_mf_classic_wrong_card_widget_callback,
nfc_scene_mf_classic_write_initial_wrong_card_widget_callback,
instance);

// Setup and start worker
view_dispatcher_switch_to_view(instance->view_dispatcher, NfcViewWidget);
}

bool nfc_scene_mf_classic_wrong_card_on_event(void* context, SceneManagerEvent event) {
bool nfc_scene_mf_classic_write_initial_wrong_card_on_event(void* context, SceneManagerEvent event) {
NfcApp* instance = context;
bool consumed = false;

Expand All @@ -50,7 +50,7 @@ bool nfc_scene_mf_classic_wrong_card_on_event(void* context, SceneManagerEvent e
return consumed;
}

void nfc_scene_mf_classic_wrong_card_on_exit(void* context) {
void nfc_scene_mf_classic_write_initial_wrong_card_on_exit(void* context) {
NfcApp* instance = context;

widget_reset(instance->widget);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ void nfc_scene_mf_ultralight_unlock_warn_on_enter(void* context) {
for(size_t i = 0; i < sizeof(nfc->mf_ul_auth->password.data); i++) {
furi_string_cat_printf(password_str, "%02X ", nfc->mf_ul_auth->password.data[i]);
}
furi_string_cat_str(password_str, "?\nCaution, a wrong password\ncan block the card!");
furi_string_cat_str(password_str, "\nWarning: incorrect password\nwill block the card!");
nfc_text_store_set(nfc, furi_string_get_cstr(password_str));
furi_string_free(password_str);

const char* message = (type == MfUltralightAuthTypeReader) ? "Password captured!" :
"Risky function!";
const char* message = (type == MfUltralightAuthTypeReader) ? "Password Captured!" :
"Risky Action!";
dialog_ex_set_header(dialog_ex, message, 64, 0, AlignCenter, AlignTop);
dialog_ex_set_text(dialog_ex, nfc->text_store, 64, 12, AlignCenter, AlignTop);
dialog_ex_set_text(dialog_ex, nfc->text_store, 64, 10, AlignCenter, AlignTop);
dialog_ex_set_left_button_text(dialog_ex, "Cancel");
dialog_ex_set_right_button_text(dialog_ex, "Continue");

if(type == MfUltralightAuthTypeReader) {
notification_message(nfc->notifications, &sequence_set_green_255);
}
} else {
dialog_ex_set_header(dialog_ex, "Risky function!", 64, 4, AlignCenter, AlignTop);
dialog_ex_set_header(dialog_ex, "Risky action!", 64, 4, AlignCenter, AlignTop);
dialog_ex_set_text(
dialog_ex, "Wrong password\ncan block your\ncard.", 4, 18, AlignLeft, AlignTop);
dialog_ex_set_icon(dialog_ex, 83, 22, &I_WarningDolphinFlip_45x42);
Expand Down
2 changes: 1 addition & 1 deletion applications/main/nfc/scenes/nfc_scene_slix_unlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void nfc_scene_slix_unlock_on_enter(void* context) {
popup_set_icon(instance->popup, 0, 8, &I_NFC_manual_60x50);
popup_set_header(instance->popup, "Unlocking", 97, 15, AlignCenter, AlignTop);
popup_set_text(
instance->popup, "Apply card to\nFlipper's back", 97, 27, AlignCenter, AlignTop);
instance->popup, "Hold card next\nto Flipper's back", 94, 27, AlignCenter, AlignTop);
view_dispatcher_switch_to_view(instance->view_dispatcher, NfcViewPopup);

instance->poller = nfc_poller_alloc(instance->nfc, NfcProtocolSlix);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ if (badusb.isConnected()) {
badusb.println("Flipper Name: " + flipper.getName());
badusb.println("Battery level: " + to_string(flipper.getBatteryCharge()) + "%");

// Alt+Numpad method works only on Windows!!!
badusb.altPrintln("This was printed with Alt+Numpad method!");

// There's also badusb.print() and badusb.altPrint()
// which don't add the return at the end

notify.success();
} else {
print("USB not connected");
Expand Down
16 changes: 10 additions & 6 deletions applications/system/js_app/examples/apps/Scripts/keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@ keyboard.setHeader("Example Text Input");

// Default text is optional
let text = keyboard.text(100, "Default text", true);
// Returns undefined when pressing back
print("Got text:", text);

keyboard.setHeader("Example Byte Input");

// Default data is optional
let data = keyboard.byte(6, Uint8Array([1, 2, 3, 4, 5, 6]));
data = Uint8Array(data);
let result = "0x";
for (let i = 0; i < data.byteLength; i++) {
if (data[i] < 0x10) result += "0";
result += to_hex_string(data[i]);
let result = keyboard.byte(6, Uint8Array([1, 2, 3, 4, 5, 6]));
// Returns undefined when pressing back
if (result !== undefined) {
let data = Uint8Array(result);
result = "0x";
for (let i = 0; i < data.byteLength; i++) {
if (data[i] < 0x10) result += "0";
result += to_hex_string(data[i]);
}
}
print("Got data:", result);
19 changes: 19 additions & 0 deletions applications/system/js_app/examples/apps/Scripts/stringutils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
let sampleText = "Hello, World!";

let lengthOfText = "Length of text: " + to_string(sampleText.length);
print(lengthOfText);

let start = 7;
let end = 12;
let substringResult = sampleText.slice(start, end);
print(substringResult);

let searchStr = "World";
let result2 = to_string(sampleText.indexOf(searchStr));
print(result2);

let upperCaseText = "Text in upper case: " + to_upper_case(sampleText);
print(upperCaseText);

let lowerCaseText = "Text in lower case: " + to_lower_case(sampleText);
print(lowerCaseText);
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ submenu.addItem("Item 3", 2);
submenu.setHeader("Select an option:");

let result = submenu.show();

// Returns undefined when pressing back
print("Result:", result);
Loading

0 comments on commit 1c28870

Please sign in to comment.