Skip to content

Commit

Permalink
Merge branch 'dev' into release-candidate
Browse files Browse the repository at this point in the history
  • Loading branch information
skotopes committed Dec 23, 2021
2 parents 2ee2e8f + 0c7a38b commit 208ea6f
Show file tree
Hide file tree
Showing 152 changed files with 17,162 additions and 1,333 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* text=auto
* text=auto eol=lf
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@
[submodule "lib/libusb_stm32"]
path = lib/libusb_stm32
url = https://github.com/flipperdevices/libusb_stm32.git
[submodule "lib/FreeRTOS-Kernel"]
path = lib/FreeRTOS-Kernel
url = https://github.com/FreeRTOS/FreeRTOS-Kernel.git
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ endif

.PHONY: flash_radio
flash_radio:
@$(PROJECT_ROOT)/scripts/flash.py core2radio 0x080CA000 $(COPRO_DIR)/stm32wb5x_BLE_Stack_full_fw.bin
@$(PROJECT_ROOT)/scripts/flash.py core2radio 0x080D7000 $(COPRO_DIR)/stm32wb5x_BLE_Stack_light_fw.bin
@$(PROJECT_ROOT)/scripts/ob.py set

.PHONY: flash_radio_fus
Expand Down
6 changes: 6 additions & 0 deletions applications/applications.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ extern int32_t desktop_srv(void* p);
extern int32_t accessor_app(void* p);
extern int32_t archive_app(void* p);
extern int32_t bad_usb_app(void* p);
extern int32_t u2f_app(void* p);
extern int32_t uart_echo_app(void* p);
extern int32_t blink_test_app(void* p);
extern int32_t bt_debug_app(void* p);
Expand Down Expand Up @@ -154,6 +155,11 @@ const FlipperApplication FLIPPER_APPS[] = {
#ifdef APP_BAD_USB
{.app = bad_usb_app, .name = "Bad USB", .stack_size = 2048, .icon = &A_BadUsb_14},
#endif

#ifdef APP_U2F
{.app = u2f_app, .name = "U2F", .stack_size = 2048, .icon = &A_U2F_14},
#endif

};

const size_t FLIPPER_APPS_COUNT = sizeof(FLIPPER_APPS) / sizeof(FlipperApplication);
Expand Down
9 changes: 8 additions & 1 deletion applications/applications.mk
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ APP_DISPLAY_TEST = 1
APP_BLE_HID = 1
APP_USB_MOUSE = 1
APP_BAD_USB = 1
APP_U2F = 1
APP_UART_ECHO = 1
endif

Expand Down Expand Up @@ -165,7 +166,13 @@ APP_BAD_USB ?= 0
ifeq ($(APP_BAD_USB), 1)
CFLAGS += -DAPP_BAD_USB
SRV_GUI = 1
endif
endif

APP_U2F ?= 0
ifeq ($(APP_U2F), 1)
CFLAGS += -DAPP_U2F
SRV_GUI = 1
endif

APP_BLE_HID ?=0
ifeq ($(APP_BLE_HID), 1)
Expand Down
5 changes: 5 additions & 0 deletions applications/bad_usb/bad_usb_script.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ typedef struct {
} DuckyKey;

static const DuckyKey ducky_keys[] = {
{"CTRL-ALT", KEY_MOD_LEFT_CTRL | KEY_MOD_LEFT_ALT},
{"CTRL-SHIFT", KEY_MOD_LEFT_CTRL | KEY_MOD_LEFT_SHIFT},
{"ALT-SHIFT", KEY_MOD_LEFT_ALT | KEY_MOD_LEFT_SHIFT},
{"ALT-GUI", KEY_MOD_LEFT_ALT | KEY_MOD_LEFT_GUI},

{"CTRL", KEY_MOD_LEFT_CTRL},
{"CONTROL", KEY_MOD_LEFT_CTRL},
{"SHIFT", KEY_MOD_LEFT_SHIFT},
Expand Down
6 changes: 3 additions & 3 deletions applications/debug_tools/usb_test.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include <furi.h>
#include <furi-hal.h>

#include <gui/view.h>
#include <gui/view_dispatcher.h>
#include <gui/modules/submenu.h>
#include <gui/gui.h>
#include <cmsis_os.h>

typedef struct {
Gui* gui;
Expand Down Expand Up @@ -35,7 +35,7 @@ void usb_test_submenu_callback(void* context, uint32_t index) {
} else if(index == UsbTestSubmenuIndexHid) {
furi_hal_usb_set_config(&usb_hid);
} else if(index == UsbTestSubmenuIndexHidU2F) {
//furi_hal_usb_set_config(UsbModeU2F);
furi_hal_usb_set_config(&usb_hid_u2f);
}
}

Expand Down Expand Up @@ -67,7 +67,7 @@ UsbTestApp* usb_test_app_alloc() {
submenu_add_item(
app->submenu, "HID KB+Mouse", UsbTestSubmenuIndexHid, usb_test_submenu_callback, app);
submenu_add_item(
app->submenu, "TODO: HID U2F", UsbTestSubmenuIndexHidU2F, usb_test_submenu_callback, app);
app->submenu, "HID U2F", UsbTestSubmenuIndexHidU2F, usb_test_submenu_callback, app);
view_set_previous_callback(submenu_get_view(app->submenu), usb_test_exit);
view_dispatcher_add_view(app->view_dispatcher, 0, submenu_get_view(app->submenu));

Expand Down
3 changes: 2 additions & 1 deletion applications/desktop/scenes/desktop_scene_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ bool desktop_scene_debug_on_event(void* context, SceneManagerEvent event) {
case DesktopDebugEventDeed:
dolphin_deed(dolphin, DolphinDeedIButtonEmulate);
desktop_debug_get_dolphin_data(desktop->debug_view);
desktop_start_new_idle_animation(desktop->animation);
consumed = true;
break;

case DesktopDebugEventWrongDeed:
dolphin_deed(dolphin, DolphinDeedWrong);
desktop_debug_get_dolphin_data(desktop->debug_view);
desktop_start_new_idle_animation(desktop->animation);
consumed = true;
break;

Expand All @@ -59,5 +61,4 @@ bool desktop_scene_debug_on_event(void* context, SceneManagerEvent event) {
void desktop_scene_debug_on_exit(void* context) {
Desktop* desktop = (Desktop*)context;
desktop_debug_reset_screen_idx(desktop->debug_view);
desktop_start_new_idle_animation(desktop->animation);
}
9 changes: 9 additions & 0 deletions applications/gui/scene_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,12 @@ bool scene_manager_search_and_switch_to_another_scene(

return true;
}

void scene_manager_stop(SceneManager* scene_manager) {
furi_assert(scene_manager);

if(SceneManagerIdStack_size(scene_manager->scene_id_stack)) {
uint32_t cur_scene_id = *SceneManagerIdStack_back(scene_manager->scene_id_stack);
scene_manager->scene_handlers->on_exit_handlers[cur_scene_id](scene_manager->context);
}
}
6 changes: 6 additions & 0 deletions applications/gui/scene_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ bool scene_manager_search_and_switch_to_another_scene(
SceneManager* scene_manager,
uint32_t scene_id);

/** Exit from current scene
*
* @param scene_manager SceneManager instance
*/
void scene_manager_stop(SceneManager* scene_manager);

#ifdef __cplusplus
}
#endif
2 changes: 1 addition & 1 deletion applications/irda/scene/irda-app-scene-edit-rename.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void IrdaAppSceneEditRename::on_enter(IrdaApp* app) {
app,
app->get_text_store(0),
enter_name_length,
false);
true);

view_manager->switch_to(IrdaAppViewManager::ViewType::TextInput);
}
Expand Down
19 changes: 13 additions & 6 deletions applications/nfc/nfc_device.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "nfc_device.h"
#include "nfc_types.h"

#include <lib/toolbox/path.h>
#include <lib/flipper_file/flipper_file.h>
Expand Down Expand Up @@ -29,7 +30,7 @@ void nfc_device_prepare_format_string(NfcDevice* dev, string_t format_string) {
} else if(dev->format == NfcDeviceSaveFormatBankCard) {
string_set_str(format_string, "Bank card");
} else if(dev->format == NfcDeviceSaveFormatMifareUl) {
string_set_str(format_string, "Mifare Ultralight");
string_set_str(format_string, nfc_mf_ul_type(dev->dev_data.mf_ul_data.type, true));
} else {
string_set_str(format_string, "Unknown");
}
Expand All @@ -40,14 +41,20 @@ bool nfc_device_parse_format_string(NfcDevice* dev, string_t format_string) {
dev->format = NfcDeviceSaveFormatUid;
dev->dev_data.nfc_data.protocol = NfcDeviceProtocolUnknown;
return true;
} else if(string_start_with_str_p(format_string, "Bank card")) {
}
if(string_start_with_str_p(format_string, "Bank card")) {
dev->format = NfcDeviceSaveFormatBankCard;
dev->dev_data.nfc_data.protocol = NfcDeviceProtocolEMV;
return true;
} else if(string_start_with_str_p(format_string, "Mifare Ultralight")) {
dev->format = NfcDeviceSaveFormatMifareUl;
dev->dev_data.nfc_data.protocol = NfcDeviceProtocolMifareUl;
return true;
}
// Check Mifare Ultralight types
for(MfUltralightType type = MfUltralightTypeUnknown; type < MfUltralightTypeNum; type++) {
if(string_start_with_str_p(format_string, nfc_mf_ul_type(type, true))) {
dev->format = NfcDeviceSaveFormatMifareUl;
dev->dev_data.nfc_data.protocol = NfcDeviceProtocolMifareUl;
dev->dev_data.mf_ul_data.type = type;
return true;
}
}
return false;
}
Expand Down
20 changes: 18 additions & 2 deletions applications/nfc/nfc_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,28 @@ static inline const char* nfc_get_nfca_type(rfalNfcaListenDeviceType type) {
}
}

static inline const char* nfc_get_protocol(NfcProtocol protocol) {
static inline const char* nfc_guess_protocol(NfcProtocol protocol) {
if(protocol == NfcDeviceProtocolEMV) {
return "EMV bank card";
} else if(protocol == NfcDeviceProtocolMifareUl) {
return "Mifare Ultralight";
return "Mifare Ultral/NTAG";
} else {
return "Unrecognized";
}
}

static inline const char* nfc_mf_ul_type(MfUltralightType type, bool full_name) {
if(type == MfUltralightTypeNTAG213) {
return "NTAG213";
} else if(type == MfUltralightTypeNTAG215) {
return "NTAG215";
} else if(type == MfUltralightTypeNTAG216) {
return "NTAG216";
} else if(type == MfUltralightTypeUL11 && full_name) {
return "Mifare Ultralight 11";
} else if(type == MfUltralightTypeUL21 && full_name) {
return "Mifare Ultralight 21";
} else {
return "Mifare Ultralight";
}
}
13 changes: 9 additions & 4 deletions applications/nfc/nfc_worker.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ void nfc_worker_read_mifare_ul(NfcWorker* nfc_worker) {
FURI_LOG_D(
TAG,
"Mifare Ultralight Type: %d, Pages: %d",
mf_ul_read.type,
mf_ul_read.data.type,
mf_ul_read.pages_to_read);
FURI_LOG_D(TAG, "Reading signature ...");
tx_len = mf_ul_prepare_read_signature(tx_buff);
Expand Down Expand Up @@ -629,16 +629,21 @@ void nfc_worker_emulate_mifare_ul(NfcWorker* nfc_worker) {
tx_len = mf_ul_prepare_emulation_response(
rx_buff, *rx_len, tx_buff, &mf_ul_emulate);
if(tx_len > 0) {
err =
furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false);
if(tx_len < 8) {
err = furi_hal_nfc_raw_bitstream_exchange(
tx_buff, tx_len, &rx_buff, &rx_len, false);
*rx_len /= 8;
} else {
err = furi_hal_nfc_data_exchange(
tx_buff, tx_len / 8, &rx_buff, &rx_len, false);
}
if(err == ERR_NONE) {
continue;
} else {
FURI_LOG_D(TAG, "Communication error: %d", err);
break;
}
} else {
FURI_LOG_D(TAG, "Not valid command: %02X", rx_buff[0]);
furi_hal_nfc_deactivate();
break;
}
Expand Down
16 changes: 8 additions & 8 deletions applications/nfc/scenes/nfc_scene_delete.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ void nfc_scene_delete_on_enter(void* context) {
}
widget_add_string_element(nfc->widget, 64, 21, AlignCenter, AlignTop, FontSecondary, uid_str);

if(data->protocol > NfcDeviceProtocolUnknown) {
const char* protocol_name = NULL;
if(data->protocol == NfcDeviceProtocolEMV) {
protocol_name = nfc_guess_protocol(data->protocol);
} else if(data->protocol == NfcDeviceProtocolMifareUl) {
protocol_name = nfc_mf_ul_type(nfc->dev->dev_data.mf_ul_data.type, false);
}
if(protocol_name) {
widget_add_string_element(
nfc->widget,
10,
32,
AlignLeft,
AlignTop,
FontSecondary,
nfc_get_protocol(data->protocol));
nfc->widget, 10, 32, AlignLeft, AlignTop, FontSecondary, protocol_name);
}
// TODO change dinamically
widget_add_string_element(nfc->widget, 118, 32, AlignRight, AlignTop, FontSecondary, "NFC-A");
Expand Down
16 changes: 8 additions & 8 deletions applications/nfc/scenes/nfc_scene_device_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ void nfc_scene_device_info_on_enter(void* context) {
}
widget_add_string_element(nfc->widget, 64, 21, AlignCenter, AlignTop, FontSecondary, uid_str);

if(data->protocol > NfcDeviceProtocolUnknown) {
const char* protocol_name = NULL;
if(data->protocol == NfcDeviceProtocolEMV) {
protocol_name = nfc_guess_protocol(data->protocol);
} else if(data->protocol == NfcDeviceProtocolMifareUl) {
protocol_name = nfc_mf_ul_type(nfc->dev->dev_data.mf_ul_data.type, false);
}
if(protocol_name) {
widget_add_string_element(
nfc->widget,
10,
32,
AlignLeft,
AlignTop,
FontSecondary,
nfc_get_protocol(data->protocol));
nfc->widget, 10, 32, AlignLeft, AlignTop, FontSecondary, protocol_name);
}
// TODO change dinamically
widget_add_string_element(nfc->widget, 118, 32, AlignRight, AlignTop, FontSecondary, "NFC-A");
Expand Down
4 changes: 2 additions & 2 deletions applications/nfc/scenes/nfc_scene_read_card_success.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void nfc_scene_read_card_success_on_enter(void* context) {
nfc,
NFC_SCENE_READ_SUCCESS_SHIFT "%s\n" NFC_SCENE_READ_SUCCESS_SHIFT
"ATQA: %02X%02X SAK: %02X\nUID: %02X %02X %02X %02X",
nfc_get_protocol(data->protocol),
nfc_guess_protocol(data->protocol),
data->atqa[0],
data->atqa[1],
data->sak,
Expand All @@ -41,7 +41,7 @@ void nfc_scene_read_card_success_on_enter(void* context) {
NFC_SCENE_READ_SUCCESS_SHIFT
"%s\n" NFC_SCENE_READ_SUCCESS_SHIFT
"ATQA: %02X%02X SAK: %02X\nUID: %02X %02X %02X %02X %02X %02X %02X",
nfc_get_protocol(data->protocol),
nfc_guess_protocol(data->protocol),
data->atqa[0],
data->atqa[1],
data->sak,
Expand Down
5 changes: 3 additions & 2 deletions applications/nfc/scenes/nfc_scene_read_mifare_ul_success.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ void nfc_scene_read_mifare_ul_success_on_enter(void* context) {

// Setup dialog view
NfcDeviceCommonData* data = &nfc->dev->dev_data.nfc_data;
MifareUlData* mf_ul_data = &nfc->dev->dev_data.mf_ul_data;
DialogEx* dialog_ex = nfc->dialog_ex;
dialog_ex_set_left_button_text(dialog_ex, "Retry");
dialog_ex_set_right_button_text(dialog_ex, "More");
dialog_ex_set_center_button_text(dialog_ex, "Data");
dialog_ex_set_header(dialog_ex, "Mifare Ultralight", 22, 8, AlignLeft, AlignCenter);
dialog_ex_set_header(
dialog_ex, nfc_mf_ul_type(mf_ul_data->type, true), 64, 8, AlignCenter, AlignCenter);
dialog_ex_set_icon(dialog_ex, 8, 13, &I_Medium_chip_22x21);
// Display UID
nfc_text_store_set(
Expand All @@ -54,7 +56,6 @@ void nfc_scene_read_mifare_ul_success_on_enter(void* context) {
dialog_ex_set_result_callback(dialog_ex, nfc_scene_read_mifare_ul_success_dialog_callback);

// Setup TextBox view
MifareUlData* mf_ul_data = &nfc->dev->dev_data.mf_ul_data;
TextBox* text_box = nfc->text_box;
text_box_set_context(text_box, nfc);
text_box_set_exit_callback(text_box, nfc_scene_read_mifare_ul_success_text_box_callback);
Expand Down
2 changes: 1 addition & 1 deletion applications/nfc/scenes/nfc_scene_scripts_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void nfc_scene_scripts_menu_on_enter(void* context) {
nfc);
submenu_add_item(
submenu,
"Read Mifare Ultralight",
"Read Mifare Ultral/Ntag",
SubmenuIndexMifareUltralight,
nfc_scene_scripts_menu_submenu_callback,
nfc);
Expand Down
2 changes: 1 addition & 1 deletion applications/power/power_service/power.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void power_draw_battery_callback(Canvas* canvas, void* context) {
furi_assert(context);
Power* power = context;
canvas_draw_icon(canvas, 0, 0, &I_Battery_26x8);
canvas_draw_box(canvas, 2, 2, power->info.charge / 5, 4);
canvas_draw_box(canvas, 2, 2, (power->info.charge + 4) / 5, 4);
}

static ViewPort* power_battery_view_port_alloc(Power* power) {
Expand Down
5 changes: 3 additions & 2 deletions applications/rpc/rpc.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#include "rpc_i.h"

#include <pb.h>
#include <pb_decode.h>
#include <pb_encode.h>

#include <status.pb.h>
#include <storage.pb.h>
#include <flipper.pb.h>
#include <cmsis_os.h>
#include <cmsis_os2.h>
#include <portmacro.h>

#include <furi.h>

#include <cli/cli.h>
Expand Down
Loading

0 comments on commit 208ea6f

Please sign in to comment.