Skip to content

Commit

Permalink
Merge branch 'release-candidate' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
skotopes committed Dec 28, 2021
2 parents a426762 + bb650c4 commit 8042f94
Show file tree
Hide file tree
Showing 168 changed files with 17,283 additions and 1,430 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
5 changes: 2 additions & 3 deletions applications/desktop/desktop.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "portmacro.h"
#include "storage/filesystem-api-defines.h"
#include "storage/storage.h"
#include <furi-hal-lock.h>
#include <stdint.h>
#include <power/power_service/power.h>
#include "helpers/desktop_animation.h"
Expand Down Expand Up @@ -155,14 +154,14 @@ int32_t desktop_srv(void* p) {

bool loaded = LOAD_DESKTOP_SETTINGS(&desktop->settings);
if(!loaded) {
furi_hal_lock_set(false);
furi_hal_rtc_reset_flag(FuriHalRtcFlagLock);
memset(&desktop->settings, 0, sizeof(desktop->settings));
SAVE_DESKTOP_SETTINGS(&desktop->settings);
}

scene_manager_next_scene(desktop->scene_manager, DesktopSceneMain);

if(furi_hal_lock_get()) {
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagLock)) {
furi_hal_usb_disable();
scene_manager_set_scene_state(
desktop->scene_manager, DesktopSceneLocked, DesktopLockedWithPin);
Expand Down
2 changes: 1 addition & 1 deletion applications/desktop/helpers/desktop_animation.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void desktop_start_new_idle_animation(DesktopAnimation* animation) {
DolphinStats stats = dolphin_stats(dolphin);
furi_record_close("dolphin");

furi_assert((stats.level >= 1) && (stats.level <= 3));
furi_check((stats.level >= 1) && (stats.level <= 3));

AnimationList_t animation_list;
AnimationList_init(animation_list);
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);
}
3 changes: 1 addition & 2 deletions applications/desktop/scenes/desktop_scene_lock_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include "../views/desktop_lock_menu.h"
#include <toolbox/saved_struct.h>
#include <stdbool.h>
#include <furi-hal-lock.h>

void desktop_scene_lock_menu_callback(DesktopLockMenuEvent event, void* context) {
Desktop* desktop = (Desktop*)context;
Expand Down Expand Up @@ -33,7 +32,7 @@ bool desktop_scene_lock_menu_on_event(void* context, SceneManagerEvent event) {
break;
case DesktopLockMenuEventPinLock:
if(desktop->settings.pincode.length > 0) {
furi_hal_lock_set(true);
furi_hal_rtc_set_flag(FuriHalRtcFlagLock);
furi_hal_usb_disable();
scene_manager_set_scene_state(
desktop->scene_manager, DesktopSceneLocked, DesktopLockedWithPin);
Expand Down
3 changes: 1 addition & 2 deletions applications/desktop/scenes/desktop_scene_locked.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include "../views/desktop_locked.h"
#include "desktop/helpers/desktop_animation.h"
#include "desktop/views/desktop_main.h"
#include <furi-hal-lock.h>

void desktop_scene_locked_callback(DesktopLockedEvent event, void* context) {
Desktop* desktop = (Desktop*)context;
Expand Down Expand Up @@ -56,7 +55,7 @@ static bool desktop_scene_locked_check_pin(Desktop* desktop, DesktopMainEvent ev
if(match) {
desktop->pincode_buffer.length = 0;
furi_hal_usb_enable();
furi_hal_lock_set(false);
furi_hal_rtc_reset_flag(FuriHalRtcFlagLock);
desktop_main_unlocked(desktop->main_view);
}

Expand Down
3 changes: 1 addition & 2 deletions applications/dolphin/passport/passport.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ int32_t passport_app(void* p) {
gui_add_view_port(gui, view_port, GuiLayerFullscreen);
view_port_update(view_port);

osStatus_t status = osSemaphoreAcquire(semaphore, osWaitForever);
furi_assert(status == osOK);
furi_check(osSemaphoreAcquire(semaphore, osWaitForever) == osOK);

gui_remove_view_port(gui, view_port);
view_port_free(view_port);
Expand Down
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
Loading

0 comments on commit 8042f94

Please sign in to comment.