This commit is contained in:
Willy-JL
2023-08-03 12:09:59 +02:00
25 changed files with 427 additions and 286 deletions

View File

@@ -19,9 +19,8 @@
#define TAG "SubGhz_Device_CC1101_Ext"
#define SUBGHZ_DEVICE_CC1101_EXT_TX_GPIO &gpio_ext_pb2
#define SUBGHZ_DEVICE_CC1101_EXT_EXTENDED_RANGE false
#define SUBGHZ_DEVICE_CC1101_EXT_E07M20S_AMP_GPIO &gpio_ext_pc3
#define SUBGHZ_DEVICE_CC1101_EXT_FORCE_EXTENDED_RANGE false
#define SUBGHZ_DEVICE_CC1101_CONFIG_VER 1
@@ -201,7 +200,6 @@ bool subghz_device_cc1101_ext_alloc(SubGhzDeviceConf* conf) {
subghz_device_cc1101_ext->regulation = SubGhzDeviceCC1101ExtRegulationTxRx;
subghz_device_cc1101_ext->async_mirror_pin = NULL;
subghz_device_cc1101_ext->g0_pin = SUBGHZ_DEVICE_CC1101_EXT_TX_GPIO;
subghz_device_cc1101_ext->async_rx.capture_delta_duration = 0;
subghz_device_cc1101_ext->power_amp = false;
subghz_device_cc1101_ext->extended_range = false;
if(conf) {
@@ -213,6 +211,8 @@ bool subghz_device_cc1101_ext_alloc(SubGhzDeviceConf* conf) {
}
}
subghz_device_cc1101_ext->async_rx.capture_delta_duration = 0;
subghz_device_cc1101_ext->spi_bus_handle =
(XTREME_SETTINGS()->spi_cc1101_handle == SpiDefault ?
&furi_hal_spi_bus_handle_external :
@@ -229,7 +229,6 @@ bool subghz_device_cc1101_ext_alloc(SubGhzDeviceConf* conf) {
}
furi_hal_spi_bus_handle_init(subghz_device_cc1101_ext->spi_bus_handle);
if(subghz_device_cc1101_ext->power_amp) {
furi_hal_gpio_init_simple(
SUBGHZ_DEVICE_CC1101_EXT_E07M20S_AMP_GPIO, GpioModeOutputPushPull);
@@ -241,6 +240,7 @@ bool subghz_device_cc1101_ext_alloc(SubGhzDeviceConf* conf) {
void subghz_device_cc1101_ext_free() {
furi_assert(subghz_device_cc1101_ext != NULL);
furi_hal_spi_bus_handle_deinit(subghz_device_cc1101_ext->spi_bus_handle);
free(subghz_device_cc1101_ext);
@@ -486,14 +486,16 @@ bool subghz_device_cc1101_ext_is_frequency_valid(uint32_t value) {
}
bool subghz_device_cc1101_ext_is_tx_allowed(uint32_t value) {
if(!(SUBGHZ_DEVICE_CC1101_EXT_EXTENDED_RANGE) &&
if(!(SUBGHZ_DEVICE_CC1101_EXT_FORCE_EXTENDED_RANGE ||
subghz_device_cc1101_ext->extended_range) &&
!(value >= 299999755 && value <= 350000335) && // was increased from 348 to 350
!(value >= 386999938 && value <= 467750000) && // was increased from 464 to 467.75
!(value >= 778999847 && value <= 928000000)) {
FURI_LOG_I(TAG, "Frequency blocked - outside default range");
return false;
} else if(
(SUBGHZ_DEVICE_CC1101_EXT_EXTENDED_RANGE) &&
(SUBGHZ_DEVICE_CC1101_EXT_FORCE_EXTENDED_RANGE ||
subghz_device_cc1101_ext->extended_range) &&
!subghz_device_cc1101_ext_is_frequency_valid(value)) {
FURI_LOG_I(TAG, "Frequency blocked - outside extended range");
return false;
@@ -583,7 +585,7 @@ void subghz_device_cc1101_ext_start_async_rx(
furi_hal_bus_enable(FuriHalBusTIM17);
// Configure TIM
//Set the timer resolution to 2 <EFBFBD>s
//Set the timer resolution to 2 us
LL_TIM_SetPrescaler(TIM17, (64 << 1) - 1);
LL_TIM_SetCounterMode(TIM17, LL_TIM_COUNTERMODE_UP);
LL_TIM_SetAutoReload(TIM17, 0xFFFF);
@@ -764,7 +766,7 @@ bool subghz_device_cc1101_ext_start_async_tx(SubGhzDeviceCC1101ExtCallback callb
furi_hal_bus_enable(FuriHalBusTIM17);
// Configure TIM
// Set the timer resolution to 2 <EFBFBD>s
// Set the timer resolution to 2 us
LL_TIM_SetPrescaler(TIM17, (64 << 1) - 1);
LL_TIM_SetCounterMode(TIM17, LL_TIM_COUNTERMODE_UP);
LL_TIM_SetAutoReload(TIM17, 0xFFFF);

View File

@@ -1,7 +1,6 @@
#include "hid.h"
#include "views.h"
#include <notification/notification_messages.h>
#include <dolphin/dolphin.h>
#define TAG "HidApp"
@@ -404,8 +403,6 @@ int32_t hid_usb_app(void* p) {
bt_hid_connection_status_changed_callback(BtStatusConnected, app);
dolphin_deed(DolphinDeedPluginStart);
view_dispatcher_run(app->view_dispatcher);
furi_hal_usb_set_config(usb_mode_prev, NULL);
@@ -444,8 +441,6 @@ int32_t hid_ble_app(void* p) {
furi_hal_bt_start_advertising();
bt_set_status_changed_callback(app->bt, bt_hid_connection_status_changed_callback, app);
dolphin_deed(DolphinDeedPluginStart);
view_dispatcher_run(app->view_dispatcher);
bt_set_status_changed_callback(app->bt, NULL, NULL);

View File

@@ -61,6 +61,8 @@ typedef enum {
InfraredEditModeNone,
InfraredEditModeRename,
InfraredEditModeDelete,
InfraredEditModeMove,
InfraredEditModeMoveSelectDest
} InfraredEditMode;
typedef struct {
@@ -70,6 +72,7 @@ typedef struct {
InfraredEditTarget edit_target : 8;
InfraredEditMode edit_mode : 8;
int32_t current_button_index;
int32_t current_button_index_move_orig;
uint32_t last_transmit_time;
} InfraredAppState;

View File

@@ -108,6 +108,21 @@ bool infrared_remote_delete_button(InfraredRemote* remote, size_t index) {
return infrared_remote_store(remote);
}
bool infrared_remote_move_button(InfraredRemote* remote, size_t index_orig, size_t index_dest) {
furi_assert(index_orig < InfraredButtonArray_size(remote->buttons));
furi_assert(index_dest <= InfraredButtonArray_size(remote->buttons));
if(index_orig == index_dest) {
return true;
}
InfraredRemoteButton* button;
InfraredButtonArray_pop_at(&button, remote->buttons, index_orig);
if(index_orig > index_dest)
InfraredButtonArray_push_at(remote->buttons, index_dest, button);
else
InfraredButtonArray_push_at(remote->buttons, index_dest - 1, button);
return infrared_remote_store(remote);
}
bool infrared_remote_store(InfraredRemote* remote) {
Storage* storage = furi_record_open(RECORD_STORAGE);
FlipperFormat* ff = flipper_format_file_alloc(storage);

View File

@@ -23,6 +23,7 @@ bool infrared_remote_find_button_by_name(InfraredRemote* remote, const char* nam
bool infrared_remote_add_button(InfraredRemote* remote, const char* name, InfraredSignal* signal);
bool infrared_remote_rename_button(InfraredRemote* remote, const char* new_name, size_t index);
bool infrared_remote_delete_button(InfraredRemote* remote, size_t index);
bool infrared_remote_move_button(InfraredRemote* remote, size_t index_orig, size_t index_dest);
bool infrared_remote_store(InfraredRemote* remote);
bool infrared_remote_load(InfraredRemote* remote, FuriString* path);

View File

@@ -7,6 +7,8 @@ ADD_SCENE(infrared, edit_delete_done, EditDeleteDone)
ADD_SCENE(infrared, edit_button_select, EditButtonSelect)
ADD_SCENE(infrared, edit_rename, EditRename)
ADD_SCENE(infrared, edit_rename_done, EditRenameDone)
ADD_SCENE(infrared, edit_move, EditMove)
ADD_SCENE(infrared, edit_move_done, EditMoveDone)
ADD_SCENE(infrared, learn, Learn)
ADD_SCENE(infrared, learn_done, LearnDone)
ADD_SCENE(infrared, learn_enter_name, LearnEnterName)

View File

@@ -3,6 +3,7 @@
typedef enum {
SubmenuIndexAddButton,
SubmenuIndexRenameButton,
SubmenuIndexMoveButton,
SubmenuIndexDeleteButton,
SubmenuIndexRenameRemote,
SubmenuIndexDeleteRemote,
@@ -30,6 +31,12 @@ void infrared_scene_edit_on_enter(void* context) {
SubmenuIndexRenameButton,
infrared_scene_edit_submenu_callback,
context);
submenu_add_item(
submenu,
"Move Button",
SubmenuIndexMoveButton,
infrared_scene_edit_submenu_callback,
context);
submenu_add_item(
submenu,
"Delete Button",
@@ -74,6 +81,11 @@ bool infrared_scene_edit_on_event(void* context, SceneManagerEvent event) {
infrared->app_state.edit_mode = InfraredEditModeRename;
scene_manager_next_scene(scene_manager, InfraredSceneEditButtonSelect);
consumed = true;
} else if(submenu_index == SubmenuIndexMoveButton) {
infrared->app_state.edit_target = InfraredEditTargetButton;
infrared->app_state.edit_mode = InfraredEditModeMove;
scene_manager_next_scene(scene_manager, InfraredSceneEditButtonSelect);
consumed = true;
} else if(submenu_index == SubmenuIndexDeleteButton) {
infrared->app_state.edit_target = InfraredEditTargetButton;
infrared->app_state.edit_mode = InfraredEditModeDelete;

View File

@@ -11,9 +11,23 @@ void infrared_scene_edit_button_select_on_enter(void* context) {
InfraredRemote* remote = infrared->remote;
InfraredAppState* app_state = &infrared->app_state;
const char* header = infrared->app_state.edit_mode == InfraredEditModeRename ?
"Rename Button:" :
"Delete Button:";
const char* header = NULL;
switch(infrared->app_state.edit_mode) {
case InfraredEditModeRename:
header = "Rename Button:";
break;
case InfraredEditModeDelete:
header = "Delete Button:";
break;
case InfraredEditModeMove:
header = "Select Button to Move:";
break;
case InfraredEditModeMoveSelectDest:
case InfraredEditModeNone:
default:
header = "Move Button Before:";
break;
}
submenu_set_header(submenu, header);
const size_t button_count = infrared_remote_get_button_count(remote);
@@ -26,7 +40,14 @@ void infrared_scene_edit_button_select_on_enter(void* context) {
infrared_scene_edit_button_select_submenu_callback,
context);
}
if(infrared->app_state.edit_mode == InfraredEditModeMoveSelectDest) {
submenu_add_item(
submenu,
"-- Move to the end --",
button_count,
infrared_scene_edit_button_select_submenu_callback,
context);
}
if(button_count && app_state->current_button_index != InfraredButtonIndexNone) {
submenu_set_selected_item(submenu, app_state->current_button_index);
app_state->current_button_index = InfraredButtonIndexNone;
@@ -48,6 +69,12 @@ bool infrared_scene_edit_button_select_on_event(void* context, SceneManagerEvent
scene_manager_next_scene(scene_manager, InfraredSceneEditRename);
} else if(edit_mode == InfraredEditModeDelete) {
scene_manager_next_scene(scene_manager, InfraredSceneEditDelete);
} else if(edit_mode == InfraredEditModeMove) {
app_state->current_button_index_move_orig = event.event;
app_state->edit_mode = InfraredEditModeMoveSelectDest;
scene_manager_next_scene(scene_manager, InfraredSceneEditButtonSelect);
} else if(edit_mode == InfraredEditModeMoveSelectDest) {
scene_manager_next_scene(scene_manager, InfraredSceneEditMove);
} else {
furi_assert(0);
}

View File

@@ -0,0 +1,103 @@
#include "../infrared_i.h"
static void infrared_scene_edit_move_dialog_result_callback(DialogExResult result, void* context) {
Infrared* infrared = context;
view_dispatcher_send_custom_event(infrared->view_dispatcher, result);
}
void infrared_scene_edit_move_on_enter(void* context) {
Infrared* infrared = context;
DialogEx* dialog_ex = infrared->dialog_ex;
InfraredRemote* remote = infrared->remote;
const InfraredEditTarget edit_target = infrared->app_state.edit_target;
if(edit_target == InfraredEditTargetButton) {
int32_t current_button_index = infrared->app_state.current_button_index_move_orig;
furi_assert(current_button_index != InfraredButtonIndexNone);
dialog_ex_set_header(dialog_ex, "Move Button?", 64, 0, AlignCenter, AlignTop);
InfraredRemoteButton* current_button =
infrared_remote_get_button(remote, current_button_index);
InfraredSignal* signal = infrared_remote_button_get_signal(current_button);
if(infrared_signal_is_raw(signal)) {
const InfraredRawSignal* raw = infrared_signal_get_raw_signal(signal);
infrared_text_store_set(
infrared,
0,
"%s\nRAW\n%ld samples",
infrared_remote_button_get_name(current_button),
raw->timings_size);
} else {
const InfraredMessage* message = infrared_signal_get_message(signal);
infrared_text_store_set(
infrared,
0,
"%s\n%s\nA=0x%0*lX C=0x%0*lX",
infrared_remote_button_get_name(current_button),
infrared_get_protocol_name(message->protocol),
ROUND_UP_TO(infrared_get_protocol_address_length(message->protocol), 4),
message->address,
ROUND_UP_TO(infrared_get_protocol_command_length(message->protocol), 4),
message->command);
}
} else {
furi_assert(0);
}
dialog_ex_set_text(dialog_ex, infrared->text_store[0], 64, 31, AlignCenter, AlignCenter);
dialog_ex_set_icon(dialog_ex, 0, 0, NULL);
dialog_ex_set_left_button_text(dialog_ex, "Cancel");
dialog_ex_set_right_button_text(dialog_ex, "Move");
dialog_ex_set_result_callback(dialog_ex, infrared_scene_edit_move_dialog_result_callback);
dialog_ex_set_context(dialog_ex, context);
view_dispatcher_switch_to_view(infrared->view_dispatcher, InfraredViewDialogEx);
}
bool infrared_scene_edit_move_on_event(void* context, SceneManagerEvent event) {
Infrared* infrared = context;
SceneManager* scene_manager = infrared->scene_manager;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == DialogExResultLeft) {
scene_manager_previous_scene(scene_manager);
consumed = true;
} else if(event.event == DialogExResultRight) {
bool success = false;
InfraredRemote* remote = infrared->remote;
InfraredAppState* app_state = &infrared->app_state;
const InfraredEditTarget edit_target = app_state->edit_target;
if(edit_target == InfraredEditTargetButton) {
furi_assert(app_state->current_button_index != InfraredButtonIndexNone);
success = infrared_remote_move_button(
remote,
app_state->current_button_index_move_orig,
app_state->current_button_index);
app_state->current_button_index_move_orig = InfraredButtonIndexNone;
app_state->current_button_index = InfraredButtonIndexNone;
} else {
furi_assert(0);
}
if(success) {
scene_manager_next_scene(scene_manager, InfraredSceneEditMoveDone);
} else {
const uint32_t possible_scenes[] = {InfraredSceneRemoteList, InfraredSceneStart};
scene_manager_search_and_switch_to_previous_scene_one_of(
scene_manager, possible_scenes, COUNT_OF(possible_scenes));
}
consumed = true;
}
}
return consumed;
}
void infrared_scene_edit_move_on_exit(void* context) {
Infrared* infrared = context;
UNUSED(infrared);
}

View File

@@ -0,0 +1,48 @@
#include "../infrared_i.h"
void infrared_scene_edit_move_done_on_enter(void* context) {
Infrared* infrared = context;
Popup* popup = infrared->popup;
popup_set_icon(popup, 0, 2, &I_DolphinMafia_115x62);
popup_set_header(popup, "Moved", 83, 19, AlignLeft, AlignBottom);
popup_set_callback(popup, infrared_popup_closed_callback);
popup_set_context(popup, context);
popup_set_timeout(popup, 1500);
popup_enable_timeout(popup);
view_dispatcher_switch_to_view(infrared->view_dispatcher, InfraredViewPopup);
}
bool infrared_scene_edit_move_done_on_event(void* context, SceneManagerEvent event) {
Infrared* infrared = context;
SceneManager* scene_manager = infrared->scene_manager;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == InfraredCustomEventTypePopupClosed) {
const InfraredEditTarget edit_target = infrared->app_state.edit_target;
if(edit_target == InfraredEditTargetButton) {
scene_manager_search_and_switch_to_previous_scene(
scene_manager, InfraredSceneRemote);
} else if(edit_target == InfraredEditTargetRemote) {
const uint32_t possible_scenes[] = {InfraredSceneStart, InfraredSceneRemoteList};
if(!scene_manager_search_and_switch_to_previous_scene_one_of(
scene_manager, possible_scenes, COUNT_OF(possible_scenes))) {
view_dispatcher_stop(infrared->view_dispatcher);
}
} else {
furi_assert(0);
}
consumed = true;
}
}
return consumed;
}
void infrared_scene_edit_move_done_on_exit(void* context) {
Infrared* infrared = context;
UNUSED(infrared);
}

View File

@@ -146,7 +146,7 @@ static void nfc_cli_apdu(Cli* cli, FuriString* args) {
resp_size = (tx_rx.rx_bits / 8) * 2;
if(!resp_size) {
printf("No response\r\n");
break;
continue;
}
resp_buffer = malloc(resp_size);
uint8_to_hex_chars(tx_rx.rx_data, resp_buffer, resp_size);

View File

@@ -41,6 +41,14 @@ const char* const debug_counter_text[DEBUG_COUNTER_COUNT] = {
"+5",
"+10",
};
const uint32_t debug_counter_val[DEBUG_COUNTER_COUNT] = {
1,
2,
3,
4,
5,
10,
};
static void subghz_scene_radio_settings_set_device(VariableItem* item) {
SubGhz* subghz = variable_item_get_context(item);
@@ -69,48 +77,9 @@ static void subghz_scene_receiver_config_set_debug_counter(VariableItem* item) {
uint8_t index = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, debug_counter_text[index]);
switch(index) {
case 0:
furi_hal_subghz_set_rolling_counter_mult(1);
break;
case 1:
furi_hal_subghz_set_rolling_counter_mult(2);
break;
case 2:
furi_hal_subghz_set_rolling_counter_mult(3);
break;
case 3:
furi_hal_subghz_set_rolling_counter_mult(4);
break;
case 4:
furi_hal_subghz_set_rolling_counter_mult(5);
break;
case 5:
furi_hal_subghz_set_rolling_counter_mult(10);
break;
default:
break;
}
furi_hal_subghz_set_rolling_counter_mult(debug_counter_val[index]);
}
// static void subghz_scene_receiver_config_set_ext_mod_power(VariableItem* item) {
// SubGhz* subghz = variable_item_get_context(item);
// uint8_t index = variable_item_get_current_value_index(item);
// variable_item_set_current_value_text(item, ext_mod_power_text[index]);
// furi_hal_subghz_set_external_power_disable(index == 1);
// if(index == 1) {
// furi_hal_subghz_disable_ext_power();
// } else {
// furi_hal_subghz_enable_ext_power();
// }
// subghz->last_settings->external_module_power_5v_disable = index == 1;
// subghz_last_settings_save(subghz->last_settings);
// }
static void subghz_scene_reciever_config_set_ext_mod_power_amp_text(VariableItem* item) {
SubGhz* subghz = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);
@@ -184,59 +153,18 @@ void subghz_scene_radio_settings_on_enter(void* context) {
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, timestamp_names_text[value_index]);
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
item = variable_item_list_add(
variable_item_list,
"Counter Incr.",
DEBUG_COUNTER_COUNT,
subghz_scene_receiver_config_set_debug_counter,
subghz);
switch(furi_hal_subghz_get_rolling_counter_mult()) {
case 1:
value_index = 0;
break;
case 2:
value_index = 1;
break;
case 3:
value_index = 2;
break;
case 4:
value_index = 3;
break;
case 5:
value_index = 4;
break;
case 10:
value_index = 5;
break;
default:
break;
}
} else {
item = variable_item_list_add(
variable_item_list,
"Counter Incr.",
3,
subghz_scene_receiver_config_set_debug_counter,
subghz);
switch(furi_hal_subghz_get_rolling_counter_mult()) {
case 1:
value_index = 0;
break;
case 2:
value_index = 1;
break;
case 3:
value_index = 2;
break;
default:
// Reset to default value
value_index = 0;
furi_hal_subghz_set_rolling_counter_mult(1);
break;
}
}
item = variable_item_list_add(
variable_item_list,
"Counter Incr.",
furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug) ? DEBUG_COUNTER_COUNT : 3,
subghz_scene_receiver_config_set_debug_counter,
subghz);
value_index = value_index_uint32(
furi_hal_subghz_get_rolling_counter_mult(),
debug_counter_val,
furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug) ? DEBUG_COUNTER_COUNT : 3);
furi_hal_subghz_set_rolling_counter_mult(debug_counter_val[value_index]);
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, debug_counter_text[value_index]);

View File

@@ -39,7 +39,7 @@ static const DolphinDeedWeight dolphin_deed_weights[] = {
{1, DolphinAppPlugin}, // DolphinDeedGpioUartBridge
{1, DolphinAppPlugin}, // DolphinDeedPluginStart
{2, DolphinAppPlugin}, // DolphinDeedPluginStart
};
static uint8_t dolphin_deed_limits[] = {

View File

@@ -4,6 +4,7 @@
#include <furi.h>
#include <assets_icons.h>
/** ByteInput type */
struct ByteInput {
View* view;
};
@@ -61,11 +62,11 @@ static const ByteInputKey keyboard_keys_row_2[] = {
{enter_symbol, 95, 17},
};
/**
* @brief Get row size
*
* @param row_index Index of row
* @return uint8_t Row size
/** Get row size
*
* @param row_index Index of row
*
* @return uint8_t Row size
*/
static uint8_t byte_input_get_row_size(uint8_t row_index) {
uint8_t row_size = 0;
@@ -84,11 +85,11 @@ static uint8_t byte_input_get_row_size(uint8_t row_index) {
return row_size;
}
/**
* @brief Get row pointer
*
* @param row_index Index of row
* @return const ByteInputKey* Row pointer
/** Get row pointer
*
* @param row_index Index of row
*
* @return const ByteInputKey* Row pointer
*/
static const ByteInputKey* byte_input_get_row(uint8_t row_index) {
const ByteInputKey* row = NULL;
@@ -107,12 +108,12 @@ static const ByteInputKey* byte_input_get_row(uint8_t row_index) {
return row;
}
/**
* @brief Get text from nibble
*
* @param byte byte value
* @param high_nibble Get from high nibble, otherwise low nibble
* @return char nibble text
/** Get text from nibble
*
* @param byte byte value
* @param high_nibble Get from high nibble, otherwise low nibble
*
* @return char nibble text
*/
static char byte_input_get_nibble_text(uint8_t byte, bool high_nibble) {
if(high_nibble) {
@@ -151,11 +152,10 @@ static char byte_input_get_nibble_text(uint8_t byte, bool high_nibble) {
const char num_to_char[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
/**
* @brief Draw input box (common view)
*
* @param canvas
* @param model
/** Draw input box (common view)
*
* @param canvas The canvas
* @param model The model
*/
static void byte_input_draw_input(Canvas* canvas, ByteInputModel* model) {
const uint8_t text_x = 8;
@@ -263,11 +263,10 @@ static void byte_input_draw_input(Canvas* canvas, ByteInputModel* model) {
}
}
/**
* @brief Draw input box (selected view)
*
* @param canvas
* @param model
/** Draw input box (selected view)
*
* @param canvas The canvas
* @param model The model
*/
static void byte_input_draw_input_selected(Canvas* canvas, ByteInputModel* model) {
const uint8_t text_x = 7;
@@ -324,13 +323,12 @@ static void byte_input_draw_input_selected(Canvas* canvas, ByteInputModel* model
canvas_invert_color(canvas);
}
/**
* @brief Set nibble at position
*
* @param data where to set nibble
* @param position byte position
* @param value char value
* @param high_nibble set high nibble
/** Set nibble at position
*
* @param data where to set nibble
* @param position byte position
* @param value char value
* @param high_nibble set high nibble
*/
static void byte_input_set_nibble(uint8_t* data, uint8_t position, char value, bool high_nibble) {
switch(value) {
@@ -368,29 +366,28 @@ static void byte_input_set_nibble(uint8_t* data, uint8_t position, char value, b
}
}
/**
* @brief What currently selected
*
* @return true - keyboard selected, false - input selected
/** What currently selected
*
* @param model The model
*
* @return true - keyboard selected, false - input selected
*/
static bool byte_input_keyboard_selected(ByteInputModel* model) {
return model->selected_row >= 0;
}
/**
* @brief Do transition from keyboard
*
* @param model
/** Do transition from keyboard
*
* @param model The model
*/
static void byte_input_transition_from_keyboard(ByteInputModel* model) {
model->selected_row += 1;
model->selected_high_nibble = true;
}
/**
* @brief Increase selected byte position
*
* @param model
/** Increase selected byte position
*
* @param model The model
*/
static void byte_input_inc_selected_byte(ByteInputModel* model) {
if(model->selected_byte < model->bytes_count - 1) {
@@ -409,18 +406,17 @@ static void byte_input_inc_selected_byte(ByteInputModel* model) {
static void byte_input_inc_selected_byte_mini(ByteInputModel* model) {
if((model->selected_byte < model->bytes_count - 1) || model->selected_high_nibble) {
if(!model->selected_high_nibble) {
model->selected_high_nibble = !model->selected_high_nibble;
model->selected_high_nibble = !model->selected_high_nibble; //-V547
byte_input_inc_selected_byte(model);
} else {
model->selected_high_nibble = !model->selected_high_nibble;
model->selected_high_nibble = !model->selected_high_nibble; //-V547
}
}
}
/**
* @brief Decrease selected byte position
*
* @param model
/** Decrease selected byte position
*
* @param model The model
*/
static void byte_input_dec_selected_byte(ByteInputModel* model) {
if(model->selected_byte > 0) {
@@ -438,18 +434,17 @@ static void byte_input_dec_selected_byte(ByteInputModel* model) {
static void byte_input_dec_selected_byte_mini(ByteInputModel* model) {
if(model->selected_byte > 0 || !model->selected_high_nibble) {
if(model->selected_high_nibble) {
model->selected_high_nibble = !model->selected_high_nibble;
model->selected_high_nibble = !model->selected_high_nibble; //-V547
byte_input_dec_selected_byte(model);
} else {
model->selected_high_nibble = !model->selected_high_nibble;
model->selected_high_nibble = !model->selected_high_nibble; //-V547
}
}
}
/**
* @brief Call input callback
*
* @param model
/** Call input callback
*
* @param model The model
*/
static void byte_input_call_input_callback(ByteInputModel* model) {
if(model->input_callback != NULL) {
@@ -457,10 +452,9 @@ static void byte_input_call_input_callback(ByteInputModel* model) {
}
}
/**
* @brief Call changed callback
*
* @param model
/** Call changed callback
*
* @param model The model
*/
static void byte_input_call_changed_callback(ByteInputModel* model) {
if(model->changed_callback != NULL) {
@@ -468,8 +462,9 @@ static void byte_input_call_changed_callback(ByteInputModel* model) {
}
}
/**
* @brief Clear selected byte
/** Clear selected byte
*
* @param model The model
*/
static void byte_input_clear_selected_byte(ByteInputModel* model) {
@@ -479,10 +474,9 @@ static void byte_input_clear_selected_byte(ByteInputModel* model) {
byte_input_call_changed_callback(model);
}
/**
* @brief Handle up button
*
* @param model
/** Handle up button
*
* @param model The model
*/
static void byte_input_handle_up(ByteInputModel* model) {
if(model->selected_row > -2) {
@@ -500,10 +494,9 @@ static void byte_input_handle_up(ByteInputModel* model) {
}
}
/**
* @brief Handle down button
*
* @param model
/** Handle down button
*
* @param model The model
*/
static void byte_input_handle_down(ByteInputModel* model) {
if(model->selected_row != -2) {
@@ -527,10 +520,9 @@ static void byte_input_handle_down(ByteInputModel* model) {
}
}
/**
* @brief Handle left button
*
* @param model
/** Handle left button
*
* @param model The model
*/
static void byte_input_handle_left(ByteInputModel* model) { // XXX
if(byte_input_keyboard_selected(model)) {
@@ -548,10 +540,9 @@ static void byte_input_handle_left(ByteInputModel* model) { // XXX
}
}
/**
* @brief Handle right button
*
* @param model
/** Handle right button
*
* @param model The model
*/
static void byte_input_handle_right(ByteInputModel* model) { // XXX
if(byte_input_keyboard_selected(model)) {
@@ -569,10 +560,9 @@ static void byte_input_handle_right(ByteInputModel* model) { // XXX
}
}
/**
* @brief Handle OK button
*
* @param model
/** Handle OK button
*
* @param model The model
*/
static void byte_input_handle_ok(ByteInputModel* model) {
if(byte_input_keyboard_selected(model)) {
@@ -600,11 +590,10 @@ static void byte_input_handle_ok(ByteInputModel* model) {
}
}
/**
* @brief Draw callback
*
* @param canvas
* @param _model
/** Draw callback
*
* @param canvas The canvas
* @param _model The model
*/
static void byte_input_view_draw_callback(Canvas* canvas, void* _model) {
ByteInputModel* model = _model;
@@ -698,13 +687,13 @@ static void byte_input_view_draw_callback(Canvas* canvas, void* _model) {
}
}
/**
* @brief Input callback
*
* @param event
* @param context
* @return true
* @return false
/** Input callback
*
* @param event The event
* @param context The context
*
* @return true
* @return false
*/
static bool byte_input_view_input_callback(InputEvent* event, void* context) {
ByteInput* byte_input = context;
@@ -773,10 +762,9 @@ static bool byte_input_view_input_callback(InputEvent* event, void* context) {
return consumed;
}
/**
* @brief Reset all input-related data in model
*
* @param model ByteInputModel
/** Reset all input-related data in model
*
* @param model The model
*/
static void byte_input_reset_model_input_data(ByteInputModel* model) {
model->bytes = NULL;
@@ -788,11 +776,6 @@ static void byte_input_reset_model_input_data(ByteInputModel* model) {
model->first_visible_byte = 0;
}
/**
* @brief Allocate and initialize byte input. This byte input is used to enter bytes.
*
* @return ByteInput instance pointer
*/
ByteInput* byte_input_alloc() {
ByteInput* byte_input = malloc(sizeof(ByteInput));
byte_input->view = view_alloc();
@@ -816,38 +799,17 @@ ByteInput* byte_input_alloc() {
return byte_input;
}
/**
* @brief Deinitialize and free byte input
*
* @param byte_input Byte input instance
*/
void byte_input_free(ByteInput* byte_input) {
furi_assert(byte_input);
view_free(byte_input->view);
free(byte_input);
}
/**
* @brief Get byte input view
*
* @param byte_input byte input instance
* @return View instance that can be used for embedding
*/
View* byte_input_get_view(ByteInput* byte_input) {
furi_assert(byte_input);
return byte_input->view;
}
/**
* @brief Deinitialize and free byte input
*
* @param byte_input byte input instance
* @param input_callback input callback fn
* @param changed_callback changed callback fn
* @param callback_context callback context
* @param bytes buffer to use
* @param bytes_count buffer length
*/
void byte_input_set_result_callback(
ByteInput* byte_input,
ByteInputCallback input_callback,
@@ -869,12 +831,6 @@ void byte_input_set_result_callback(
true);
}
/**
* @brief Set byte input header text
*
* @param byte_input byte input instance
* @param text text to be shown
*/
void byte_input_set_header_text(ByteInput* byte_input, const char* text) {
with_view_model(
byte_input->view, ByteInputModel * model, { model->header = text; }, true);

View File

@@ -6,6 +6,7 @@
#include <gui/gui.h>
#include <gui/view_holder.h>
#include <gui/modules/loading.h>
#include <dolphin/dolphin.h>
#define TAG "LoaderApplications"
@@ -119,6 +120,8 @@ static void loader_pubsub_callback(const void* message, void* context) {
static void loader_applications_start_app(LoaderApplicationsApp* app) {
const char* name = furi_string_get_cstr(app->fap_path);
// dolphin_deed(DolphinDeedPluginStart);
// load app
FuriThreadId thread_id = furi_thread_get_current_id();
FuriPubSubSubscription* subscription =
@@ -154,4 +157,4 @@ static int32_t loader_applications_thread(void* p) {
}
return 0;
}
}

View File

@@ -14,7 +14,7 @@ static void loader_cli_print_usage() {
}
static void loader_cli_list() {
printf("Applications:\r\n");
printf("Apps:\r\n");
for(size_t i = 0; i < FLIPPER_APPS_COUNT; i++) {
printf("\t%s\r\n", FLIPPER_APPS[i].name);
}

View File

@@ -6,7 +6,7 @@
#include <input/input.h>
#include <gui/gui_i.h>
#include <u8g2_glue.h>
#include <lib/toolbox/float_tools.h>
#include "notification.h"
#include "notification_messages.h"
#include "notification_app.h"
@@ -105,7 +105,10 @@ static void notification_reset_notification_led_layer(NotificationLedLayer* laye
furi_hal_light_set(layer->light, layer->value[LayerInternal]);
}
static void notification_reset_notification_layer(NotificationApp* app, uint8_t reset_mask) {
static void notification_reset_notification_layer(
NotificationApp* app,
uint8_t reset_mask,
float display_brightness_set) {
if(reset_mask & reset_blink_mask) {
furi_hal_light_blink_stop();
}
@@ -125,6 +128,9 @@ static void notification_reset_notification_layer(NotificationApp* app, uint8_t
notification_sound_off();
}
if(reset_mask & reset_display_mask) {
if(!float_is_equal(display_brightness_set, app->settings.display_brightness)) {
furi_hal_light_set(LightBacklight, app->settings.display_brightness * 0xFF);
}
furi_timer_start(app->display_timer, notification_settings_display_off_delay_ticks(app));
}
}
@@ -213,13 +219,14 @@ static void notification_process_notification_message(
notification_apply_notification_led_layer(
&app->display,
notification_message->data.led.value * display_brightness_setting);
reset_mask |= reset_display_mask;
} else {
reset_mask &= ~reset_display_mask;
notification_reset_notification_led_layer(&app->display);
if(furi_timer_is_running(app->display_timer)) {
furi_timer_stop(app->display_timer);
}
}
reset_mask |= reset_display_mask;
break;
case NotificationMessageTypeLedDisplayBacklightEnforceOn:
furi_assert(app->display_led_lock < UINT8_MAX);
@@ -371,7 +378,7 @@ static void notification_process_notification_message(
}
if(reset_notifications) {
notification_reset_notification_layer(app, reset_mask);
notification_reset_notification_layer(app, reset_mask, display_brightness_setting);
}
}

View File

@@ -170,8 +170,6 @@ const AboutDialogScreen about_screens[] = {
compliance_screen,
address_screen};
const size_t about_screens_count = sizeof(about_screens) / sizeof(AboutDialogScreen);
int32_t about_settings_app(void* p) {
UNUSED(p);
DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS);
@@ -193,7 +191,7 @@ int32_t about_settings_app(void* p) {
int32_t ret = 0;
while(1) {
if(screen_index >= about_screens_count - 1) {
if(screen_index >= COUNT_OF(about_screens) - 1) {
dialog_message_set_buttons(message, "Back", NULL, NULL);
} else {
dialog_message_set_buttons(message, "Back", NULL, "Next");
@@ -209,7 +207,7 @@ int32_t about_settings_app(void* p) {
screen_index--;
}
} else if(screen_result == DialogMessageButtonRight) {
if(screen_index < about_screens_count - 1) {
if(screen_index < COUNT_OF(about_screens) - 1) {
screen_index++;
}
} else if(screen_result == DialogMessageButtonBack) {

View File

@@ -24,10 +24,10 @@ void furi_hal_info_get(PropertyValueCallback out, char sep, void* context) {
// Device Info version
if(sep == '.') {
property_value_out(&property_context, NULL, 2, "format", "major", "3");
property_value_out(&property_context, NULL, 2, "format", "minor", "2");
property_value_out(&property_context, NULL, 2, "format", "minor", "3");
} else {
property_value_out(&property_context, NULL, 3, "device", "info", "major", "2");
property_value_out(&property_context, NULL, 3, "device", "info", "minor", "3");
property_value_out(&property_context, NULL, 3, "device", "info", "minor", "4");
}
// Model name
@@ -298,6 +298,7 @@ void furi_hal_info_get(PropertyValueCallback out, char sep, void* context) {
property_value_out(&property_context, NULL, 2, "radio", "alive", "false");
}
// RTC flags
property_value_out(
&property_context,
"%u",
@@ -305,8 +306,52 @@ void furi_hal_info_get(PropertyValueCallback out, char sep, void* context) {
"system",
"debug",
furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug));
property_value_out(
&property_context, "%u", 2, "system", "lock", furi_hal_rtc_is_flag_set(FuriHalRtcFlagLock));
property_value_out(
&property_context,
"%u",
2,
"system",
"orient",
furi_hal_rtc_is_flag_set(FuriHalRtcFlagHandOrient));
property_value_out(
&property_context,
"%u",
3,
"system",
"sleep",
"legacy",
furi_hal_rtc_is_flag_set(FuriHalRtcFlagLegacySleep));
property_value_out(
&property_context,
"%u",
2,
"system",
"stealth",
furi_hal_rtc_is_flag_set(FuriHalRtcFlagStealthMode));
property_value_out(
&property_context, "%u", 3, "system", "heap", "track", furi_hal_rtc_get_heap_track_mode());
property_value_out(&property_context, "%u", 2, "system", "boot", furi_hal_rtc_get_boot_mode());
property_value_out(
&property_context,
"%u",
3,
"system",
"locale",
"time",
furi_hal_rtc_get_locale_timeformat());
property_value_out(
&property_context,
"%u",
3,
"system",
"locale",
"date",
furi_hal_rtc_get_locale_dateformat());
property_value_out(
&property_context, "%u", 3, "system", "locale", "unit", furi_hal_rtc_get_locale_units());
property_value_out(
&property_context, "%u", 3, "system", "log", "level", furi_hal_rtc_get_log_level());

View File

@@ -34,6 +34,7 @@ typedef enum {
FuriHalVersionColorUnknown = 0x00,
FuriHalVersionColorBlack = 0x01,
FuriHalVersionColorWhite = 0x02,
FuriHalVersionColorTransparent = 0x03,
} FuriHalVersionColor;
/** Device Regions */

View File

@@ -28,7 +28,7 @@ typedef enum {
FuriThreadPriorityNormal = 16, /**< Normal */
FuriThreadPriorityHigh = 17, /**< High */
FuriThreadPriorityHighest = 18, /**< Highest */
FuriThreadPriorityIsr = 32, /**< Deffered Isr (highest possible) */
FuriThreadPriorityIsr = (configMAX_PRIORITIES - 1), /**< Deferred ISR (highest possible) */
} FuriThreadPriority;
/** FuriThread anonymous structure */

View File

@@ -1025,30 +1025,14 @@ void nfc_worker_mf_classic_dict_attack(NfcWorker* nfc_worker) {
deactivated = true;
}
if(!mf_classic_is_key_found(data, i, MfClassicKeyB)) {
if(mf_classic_is_key_found(data, i, MfClassicKeyA)) {
uint64_t found_key;
if(nfc_worker_mf_get_b_key_from_sector_trailer(
&tx_rx, i, key, &found_key)) {
FURI_LOG_D(TAG, "Found B key via reading sector %d", i);
mf_classic_set_key_found(data, i, MfClassicKeyB, found_key);
if(nfc_worker->state == NfcWorkerStateMfClassicDictAttack) {
nfc_worker->callback(NfcWorkerEventFoundKeyB, nfc_worker->context);
}
nfc_worker_mf_classic_key_attack(nfc_worker, found_key, &tx_rx, i + 1);
break;
}
}
if(mf_classic_authenticate_skip_activate(
&tx_rx, block_num, key, MfClassicKeyB, !deactivated, cuid)) {
&tx_rx, block_num, key, MfClassicKeyB, !deactivated, cuid)) { //-V547
FURI_LOG_D(TAG, "Key B found: %012llX", key);
mf_classic_set_key_found(data, i, MfClassicKeyB, key);
nfc_worker->callback(NfcWorkerEventFoundKeyB, nfc_worker->context);
nfc_worker_mf_classic_key_attack(nfc_worker, key, &tx_rx, i + 1);
}
deactivated = true;
deactivated = true; //-V1048
} else {
// If the key B is marked as found and matches the searching key, invalidate it
MfClassicSectorTrailer* sec_trailer =
@@ -1060,12 +1044,12 @@ void nfc_worker_mf_classic_dict_attack(NfcWorker* nfc_worker) {
if(mf_classic_is_key_found(data, i, MfClassicKeyB) &&
memcmp(sec_trailer->key_b, current_key, 6) == 0) {
if(!mf_classic_authenticate_skip_activate(
&tx_rx, block_num, key, MfClassicKeyB, !deactivated, cuid)) {
&tx_rx, block_num, key, MfClassicKeyB, !deactivated, cuid)) { //-V547
mf_classic_set_key_not_found(data, i, MfClassicKeyB);
FURI_LOG_D(TAG, "Key %dB not found in attack", i);
}
furi_hal_nfc_sleep();
deactivated = true;
deactivated = true; //-V1048
}
}
if(mf_classic_is_key_found(data, i, MfClassicKeyA) &&

View File

@@ -18,7 +18,6 @@ typedef struct SubGhzDeviceRegistry SubGhzDeviceRegistry;
typedef struct SubGhzDevice SubGhzDevice;
typedef struct SubGhzDeviceConf SubGhzDeviceConf;
// typedef bool (*SubGhzBegin)(void);
typedef bool (*SubGhzBegin)(SubGhzDeviceConf* conf);
typedef void (*SubGhzEnd)(void);
typedef bool (*SubGhzIsConnect)(void);
@@ -96,4 +95,4 @@ struct SubGhzDeviceConf {
uint8_t ver;
bool extended_range;
bool power_amp;
};
};

View File

@@ -17,6 +17,7 @@ OTP_COLORS = {
"unknown": 0x00,
"black": 0x01,
"white": 0x02,
"transparent": 0x03,
}
OTP_REGIONS = {

View File

@@ -82,6 +82,9 @@ fbtenv_restore_env()
fbtenv_check_sourced()
{
if [ -n "${FBT_SKIP_CHECK_SOURCED:-""}" ]; then
return 0;
fi
case "${ZSH_EVAL_CONTEXT:-""}" in *:file:*)
setopt +o nomatch; # disabling 'no match found' warning in zsh
return 0;;
@@ -210,7 +213,7 @@ fbtenv_download_toolchain_tar()
return 0;
}
fbtenv_remove_old_tooclhain()
fbtenv_remove_old_toolchain()
{
printf "Removing old toolchain..";
rm -rf "${TOOLCHAIN_ARCH_DIR:?}";
@@ -241,12 +244,14 @@ fbtenv_unpack_toolchain()
fbtenv_cleanup()
{
printf "Cleaning up..";
if [ -n "${FBT_TOOLCHAIN_PATH:-""}" ]; then
rm -rf "${FBT_TOOLCHAIN_PATH:?}/toolchain/"*.tar.gz;
printf "Cleaning up..";
rm -rf "${FBT_TOOLCHAIN_PATH:?}/toolchain/"*.part;
if [ -z "${FBT_PRESERVE_TAR:-""}" ]; then
rm -rf "${FBT_TOOLCHAIN_PATH:?}/toolchain/"*.tar.gz;
fi
echo "done";
fi
echo "done";
trap - 2;
return 0;
}
@@ -299,16 +304,22 @@ fbtenv_download_toolchain()
fbtenv_curl_wget_check || return 1;
fbtenv_download_toolchain_tar || return 1;
fi
fbtenv_remove_old_tooclhain;
fbtenv_remove_old_toolchain;
fbtenv_unpack_toolchain || return 1;
fbtenv_cleanup;
return 0;
}
fbtenv_print_version()
fbtenv_print_config()
{
if [ -n "$FBT_VERBOSE" ]; then
if [ -n "${FBT_VERBOSE:-""}" ]; then
echo "FBT: using toolchain version $(cat "$TOOLCHAIN_ARCH_DIR/VERSION")";
if [ -n "${FBT_SKIP_CHECK_SOURCED:-""}" ]; then
echo "FBT: fbtenv will not check if it is sourced or not";
fi
if [ -n "${FBT_PRESERVE_TAR:-""}" ]; then
echo "FBT: toolchain archives will be saved";
fi
fi
}
@@ -326,7 +337,7 @@ fbtenv_main()
fbtenv_check_env_vars || return 1;
fbtenv_check_download_toolchain || return 1;
fbtenv_set_shell_prompt;
fbtenv_print_version;
fbtenv_print_config;
PATH="$TOOLCHAIN_ARCH_DIR/python/bin:$PATH";
PATH="$TOOLCHAIN_ARCH_DIR/bin:$PATH";
PATH="$TOOLCHAIN_ARCH_DIR/protobuf/bin:$PATH";