mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-22 20:43:07 +00:00
[FL-3679] iButton new UI (#3471)
* iButton new UI * UI final touches * Satisfy PVS Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
parent
70f93a48f5
commit
4883383b20
29 changed files with 280 additions and 75 deletions
|
@ -17,5 +17,6 @@ ADD_SCENE(ibutton, delete_confirm, DeleteConfirm)
|
|||
ADD_SCENE(ibutton, delete_success, DeleteSuccess)
|
||||
ADD_SCENE(ibutton, retry_confirm, RetryConfirm)
|
||||
ADD_SCENE(ibutton, exit_confirm, ExitConfirm)
|
||||
ADD_SCENE(ibutton, read_exit_confirm, ReadExitConfirm)
|
||||
ADD_SCENE(ibutton, view_data, ViewData)
|
||||
ADD_SCENE(ibutton, rpc, Rpc)
|
||||
|
|
|
@ -7,23 +7,33 @@ void ibutton_scene_delete_confirm_on_enter(void* context) {
|
|||
Widget* widget = ibutton->widget;
|
||||
|
||||
FuriString* tmp = furi_string_alloc();
|
||||
FuriString* uid = furi_string_alloc();
|
||||
|
||||
widget_add_button_element(widget, GuiButtonTypeLeft, "Back", ibutton_widget_callback, context);
|
||||
widget_add_button_element(
|
||||
widget, GuiButtonTypeRight, "Delete", ibutton_widget_callback, context);
|
||||
|
||||
furi_string_printf(tmp, "\e#Delete %s?\e#", ibutton->key_name);
|
||||
furi_string_printf(tmp, "\e#Delete %s?\e#\n", ibutton->key_name);
|
||||
|
||||
ibutton_protocols_render_uid(ibutton->protocols, key, uid);
|
||||
|
||||
furi_string_cat_printf(
|
||||
uid,
|
||||
"\n%s %s",
|
||||
ibutton_protocols_get_manufacturer(ibutton->protocols, ibutton_key_get_protocol_id(key)),
|
||||
ibutton_protocols_get_name(ibutton->protocols, ibutton_key_get_protocol_id(key)));
|
||||
|
||||
furi_string_cat(tmp, uid);
|
||||
|
||||
widget_add_text_box_element(
|
||||
widget, 0, 0, 128, 23, AlignCenter, AlignCenter, furi_string_get_cstr(tmp), false);
|
||||
widget, 0, 0, 128, 64, AlignCenter, AlignTop, furi_string_get_cstr(tmp), false);
|
||||
|
||||
furi_string_reset(tmp);
|
||||
ibutton_protocols_render_brief_data(ibutton->protocols, key, tmp);
|
||||
|
||||
widget_add_string_multiline_element(
|
||||
widget, 128 / 2, 24, AlignCenter, AlignTop, FontSecondary, furi_string_get_cstr(tmp));
|
||||
furi_string_reset(uid);
|
||||
|
||||
view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewWidget);
|
||||
furi_string_free(tmp);
|
||||
furi_string_free(uid);
|
||||
}
|
||||
|
||||
bool ibutton_scene_delete_confirm_on_event(void* context, SceneManagerEvent event) {
|
||||
|
|
|
@ -21,17 +21,20 @@ void ibutton_scene_emulate_on_enter(void* context) {
|
|||
|
||||
widget_add_icon_element(widget, 3, 10, &I_iButtonKey_49x44);
|
||||
|
||||
furi_string_printf(
|
||||
tmp,
|
||||
"%s\n[%s]",
|
||||
furi_string_empty(ibutton->file_path) ? "Unsaved Key" : ibutton->key_name,
|
||||
ibutton_protocols_get_name(ibutton->protocols, ibutton_key_get_protocol_id(key)));
|
||||
if(furi_string_empty(ibutton->file_path)) {
|
||||
furi_string_printf(
|
||||
tmp,
|
||||
"Unsaved\n%s",
|
||||
ibutton_protocols_get_name(ibutton->protocols, ibutton_key_get_protocol_id(key)));
|
||||
} else {
|
||||
furi_string_printf(tmp, "%s", ibutton->key_name);
|
||||
}
|
||||
|
||||
widget_add_text_box_element(
|
||||
widget, 52, 38, 75, 26, AlignCenter, AlignCenter, furi_string_get_cstr(tmp), true);
|
||||
widget, 52, 23, 75, 26, AlignCenter, AlignTop, furi_string_get_cstr(tmp), false);
|
||||
|
||||
widget_add_string_multiline_element(
|
||||
widget, 88, 10, AlignCenter, AlignTop, FontPrimary, "iButton\nemulating");
|
||||
widget, 88, 10, AlignCenter, AlignTop, FontPrimary, "Emulating");
|
||||
|
||||
ibutton_worker_emulate_set_callback(ibutton->worker, ibutton_scene_emulate_callback, ibutton);
|
||||
ibutton_worker_emulate_start(ibutton->worker, key);
|
||||
|
|
|
@ -8,21 +8,24 @@ void ibutton_scene_info_on_enter(void* context) {
|
|||
const iButtonProtocolId protocol_id = ibutton_key_get_protocol_id(key);
|
||||
|
||||
FuriString* tmp = furi_string_alloc();
|
||||
FuriString* brief_data = furi_string_alloc();
|
||||
|
||||
furi_string_printf(
|
||||
tmp,
|
||||
"\e#%s [%s]\e#",
|
||||
"Name:%s\n\e#%s %s\e#\n",
|
||||
ibutton->key_name,
|
||||
ibutton_protocols_get_manufacturer(ibutton->protocols, protocol_id),
|
||||
ibutton_protocols_get_name(ibutton->protocols, protocol_id));
|
||||
|
||||
ibutton_protocols_render_brief_data(ibutton->protocols, key, brief_data);
|
||||
|
||||
furi_string_cat(tmp, brief_data);
|
||||
|
||||
widget_add_text_box_element(
|
||||
widget, 0, 2, 128, 12, AlignLeft, AlignTop, furi_string_get_cstr(tmp), true);
|
||||
widget, 0, 0, 128, 64, AlignLeft, AlignTop, furi_string_get_cstr(tmp), false);
|
||||
|
||||
furi_string_reset(tmp);
|
||||
ibutton_protocols_render_brief_data(ibutton->protocols, key, tmp);
|
||||
|
||||
widget_add_string_multiline_element(
|
||||
widget, 0, 16, AlignLeft, AlignTop, FontSecondary, furi_string_get_cstr(tmp));
|
||||
furi_string_reset(brief_data);
|
||||
|
||||
if(ibutton_protocols_get_features(ibutton->protocols, protocol_id) &
|
||||
iButtonProtocolFeatureExtData) {
|
||||
|
@ -32,6 +35,7 @@ void ibutton_scene_info_on_enter(void* context) {
|
|||
|
||||
view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewWidget);
|
||||
furi_string_free(tmp);
|
||||
furi_string_free(brief_data);
|
||||
}
|
||||
|
||||
bool ibutton_scene_info_on_event(void* context, SceneManagerEvent event) {
|
||||
|
|
|
@ -12,9 +12,9 @@ void ibutton_scene_read_on_enter(void* context) {
|
|||
iButtonKey* key = ibutton->key;
|
||||
iButtonWorker* worker = ibutton->worker;
|
||||
|
||||
popup_set_header(popup, "iButton", 95, 26, AlignCenter, AlignBottom);
|
||||
popup_set_text(popup, "Apply key to\nFlipper's back", 95, 30, AlignCenter, AlignTop);
|
||||
popup_set_icon(popup, 0, 5, &I_DolphinWait_61x59);
|
||||
popup_set_header(popup, "Reading", 95, 26, AlignCenter, AlignBottom);
|
||||
popup_set_text(popup, "Connect key\nwith pogo pins", 95, 30, AlignCenter, AlignTop);
|
||||
popup_set_icon(popup, 0, 10, &I_DolphinWait_59x54);
|
||||
|
||||
view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewPopup);
|
||||
|
||||
|
|
|
@ -14,13 +14,10 @@ void ibutton_scene_read_error_on_enter(void* context) {
|
|||
widget_add_button_element(
|
||||
widget, GuiButtonTypeRight, "More", ibutton_widget_callback, context);
|
||||
|
||||
widget_add_string_element(
|
||||
widget, 128 / 2, 2, AlignCenter, AlignTop, FontPrimary, "Read Error");
|
||||
|
||||
ibutton_protocols_render_error(ibutton->protocols, key, tmp);
|
||||
|
||||
widget_add_string_multiline_element(
|
||||
widget, 128 / 2, 16, AlignCenter, AlignTop, FontSecondary, furi_string_get_cstr(tmp));
|
||||
widget_add_text_box_element(
|
||||
widget, 0, 0, 128, 48, AlignCenter, AlignTop, furi_string_get_cstr(tmp), false);
|
||||
|
||||
ibutton_notification_message(ibutton, iButtonNotificationMessageError);
|
||||
ibutton_notification_message(ibutton, iButtonNotificationMessageRedOn);
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
#include "../ibutton_i.h"
|
||||
|
||||
static void ibutton_scene_read_exit_confirm_widget_callback(
|
||||
GuiButtonType result,
|
||||
InputType type,
|
||||
void* context) {
|
||||
iButton* ibutton = context;
|
||||
if(type == InputTypeShort) {
|
||||
view_dispatcher_send_custom_event(ibutton->view_dispatcher, result);
|
||||
}
|
||||
}
|
||||
|
||||
void ibutton_scene_read_exit_confirm_on_enter(void* context) {
|
||||
iButton* ibutton = context;
|
||||
Widget* widget = ibutton->widget;
|
||||
|
||||
widget_add_button_element(
|
||||
widget,
|
||||
GuiButtonTypeLeft,
|
||||
"Exit",
|
||||
ibutton_scene_read_exit_confirm_widget_callback,
|
||||
ibutton);
|
||||
widget_add_button_element(
|
||||
widget,
|
||||
GuiButtonTypeRight,
|
||||
"Stay",
|
||||
ibutton_scene_read_exit_confirm_widget_callback,
|
||||
ibutton);
|
||||
widget_add_string_element(
|
||||
widget, 64, 19, AlignCenter, AlignBottom, FontPrimary, "Retry Reading?");
|
||||
widget_add_string_element(
|
||||
widget, 64, 31, AlignCenter, AlignBottom, FontSecondary, "All unsaved data will be lost!");
|
||||
|
||||
view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewWidget);
|
||||
}
|
||||
|
||||
bool ibutton_scene_read_exit_confirm_on_event(void* context, SceneManagerEvent event) {
|
||||
iButton* ibutton = context;
|
||||
SceneManager* scene_manager = ibutton->scene_manager;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeBack) {
|
||||
consumed = true; // Ignore Back button presses
|
||||
} else if(event.type == SceneManagerEventTypeCustom) {
|
||||
consumed = true;
|
||||
if(event.event == GuiButtonTypeLeft) {
|
||||
scene_manager_search_and_switch_to_previous_scene(scene_manager, iButtonSceneRead);
|
||||
} else if(event.event == GuiButtonTypeRight) {
|
||||
scene_manager_previous_scene(scene_manager);
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void ibutton_scene_read_exit_confirm_on_exit(void* context) {
|
||||
iButton* ibutton = context;
|
||||
widget_reset(ibutton->widget);
|
||||
}
|
|
@ -30,19 +30,10 @@ void ibutton_scene_read_key_menu_on_enter(void* context) {
|
|||
ibutton_scene_read_key_menu_submenu_callback,
|
||||
ibutton);
|
||||
|
||||
if(features & iButtonProtocolFeatureExtData) {
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"View Data",
|
||||
SubmenuIndexViewData,
|
||||
ibutton_scene_read_key_menu_submenu_callback,
|
||||
ibutton);
|
||||
}
|
||||
|
||||
if(features & iButtonProtocolFeatureWriteBlank) {
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Write Blank",
|
||||
"Write ID",
|
||||
SubmenuIndexWriteBlank,
|
||||
ibutton_scene_read_key_menu_submenu_callback,
|
||||
ibutton);
|
||||
|
@ -51,12 +42,21 @@ void ibutton_scene_read_key_menu_on_enter(void* context) {
|
|||
if(features & iButtonProtocolFeatureWriteCopy) {
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Write Copy",
|
||||
"Full Write on Same Type",
|
||||
SubmenuIndexWriteCopy,
|
||||
ibutton_scene_read_key_menu_submenu_callback,
|
||||
ibutton);
|
||||
}
|
||||
|
||||
if(features & iButtonProtocolFeatureExtData) {
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Data Info",
|
||||
SubmenuIndexViewData,
|
||||
ibutton_scene_read_key_menu_submenu_callback,
|
||||
ibutton);
|
||||
}
|
||||
|
||||
submenu_set_selected_item(
|
||||
submenu, scene_manager_get_scene_state(ibutton->scene_manager, iButtonSceneReadKeyMenu));
|
||||
view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewSubmenu);
|
||||
|
|
|
@ -18,9 +18,9 @@ void ibutton_scene_read_success_on_enter(void* context) {
|
|||
|
||||
furi_string_printf(
|
||||
tmp,
|
||||
"%s[%s]",
|
||||
ibutton_protocols_get_name(ibutton->protocols, protocol_id),
|
||||
ibutton_protocols_get_manufacturer(ibutton->protocols, protocol_id));
|
||||
"%s %s",
|
||||
ibutton_protocols_get_manufacturer(ibutton->protocols, protocol_id),
|
||||
ibutton_protocols_get_name(ibutton->protocols, protocol_id));
|
||||
|
||||
widget_add_string_element(
|
||||
widget, 0, 2, AlignLeft, AlignTop, FontPrimary, furi_string_get_cstr(tmp));
|
||||
|
@ -44,7 +44,7 @@ bool ibutton_scene_read_success_on_event(void* context, SceneManagerEvent event)
|
|||
|
||||
if(event.type == SceneManagerEventTypeBack) {
|
||||
consumed = true;
|
||||
scene_manager_next_scene(scene_manager, iButtonSceneExitConfirm);
|
||||
scene_manager_next_scene(scene_manager, iButtonSceneReadExitConfirm);
|
||||
} else if(event.type == SceneManagerEventTypeCustom) {
|
||||
consumed = true;
|
||||
if(event.event == GuiButtonTypeRight) {
|
||||
|
|
|
@ -21,12 +21,16 @@ void ibutton_scene_saved_key_menu_on_enter(void* context) {
|
|||
|
||||
if(features & iButtonProtocolFeatureWriteBlank) {
|
||||
submenu_add_item(
|
||||
submenu, "Write Blank", SubmenuIndexWriteBlank, ibutton_submenu_callback, ibutton);
|
||||
submenu, "Write ID", SubmenuIndexWriteBlank, ibutton_submenu_callback, ibutton);
|
||||
}
|
||||
|
||||
if(features & iButtonProtocolFeatureWriteCopy) {
|
||||
submenu_add_item(
|
||||
submenu, "Write Copy", SubmenuIndexWriteCopy, ibutton_submenu_callback, ibutton);
|
||||
submenu,
|
||||
"Full Write on Same Type",
|
||||
SubmenuIndexWriteCopy,
|
||||
ibutton_submenu_callback,
|
||||
ibutton);
|
||||
}
|
||||
|
||||
submenu_add_item(submenu, "Edit", SubmenuIndexEdit, ibutton_submenu_callback, ibutton);
|
||||
|
|
|
@ -40,25 +40,24 @@ void ibutton_scene_write_on_enter(void* context) {
|
|||
|
||||
widget_add_icon_element(widget, 3, 10, &I_iButtonKey_49x44);
|
||||
|
||||
furi_string_printf(
|
||||
tmp,
|
||||
"%s\n[%s]",
|
||||
ibutton->key_name,
|
||||
ibutton_protocols_get_name(ibutton->protocols, protocol_id));
|
||||
if(furi_string_empty(ibutton->file_path)) {
|
||||
furi_string_printf(
|
||||
tmp, "Unsaved\n%s", ibutton_protocols_get_name(ibutton->protocols, protocol_id));
|
||||
} else {
|
||||
furi_string_printf(tmp, "%s", ibutton->key_name);
|
||||
}
|
||||
|
||||
widget_add_text_box_element(
|
||||
widget, 52, 38, 75, 26, AlignCenter, AlignCenter, furi_string_get_cstr(tmp), true);
|
||||
widget, 52, 23, 75, 26, AlignCenter, AlignTop, furi_string_get_cstr(tmp), false);
|
||||
|
||||
ibutton_worker_write_set_callback(worker, ibutton_scene_write_callback, ibutton);
|
||||
|
||||
furi_string_set(tmp, "iButton\nwriting ");
|
||||
|
||||
if(ibutton->write_mode == iButtonWriteModeBlank) {
|
||||
furi_string_cat(tmp, "Blank");
|
||||
furi_string_set(tmp, "Writing ID");
|
||||
ibutton_worker_write_blank_start(worker, key);
|
||||
|
||||
} else if(ibutton->write_mode == iButtonWriteModeCopy) {
|
||||
furi_string_cat(tmp, "Copy");
|
||||
furi_string_set(tmp, "Full Writing");
|
||||
ibutton_worker_write_copy_start(worker, key);
|
||||
}
|
||||
|
||||
|
|
BIN
assets/icons/Dolphin/DolphinWait_59x54.png
Normal file
BIN
assets/icons/Dolphin/DolphinWait_59x54.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
|
@ -287,6 +287,17 @@ bool ibutton_protocols_load(iButtonProtocols* protocols, iButtonKey* key, const
|
|||
return success;
|
||||
}
|
||||
|
||||
void ibutton_protocols_render_uid(
|
||||
iButtonProtocols* protocols,
|
||||
const iButtonKey* key,
|
||||
FuriString* result) {
|
||||
const iButtonProtocolId id = ibutton_key_get_protocol_id(key);
|
||||
const iButtonProtocolData* data = ibutton_key_get_protocol_data(key);
|
||||
|
||||
GET_PROTOCOL_GROUP(id);
|
||||
GROUP_BASE->render_uid(GROUP_DATA, data, PROTOCOL_ID, result);
|
||||
}
|
||||
|
||||
void ibutton_protocols_render_data(
|
||||
iButtonProtocols* protocols,
|
||||
const iButtonKey* key,
|
||||
|
|
|
@ -133,6 +133,17 @@ bool ibutton_protocols_save(
|
|||
*/
|
||||
bool ibutton_protocols_load(iButtonProtocols* protocols, iButtonKey* key, const char* file_name);
|
||||
|
||||
/**
|
||||
* Format a string containing defice UID
|
||||
* @param [in] protocols pointer to an iButtonProtocols object
|
||||
* @param [in] key pointer to the key to be rendered
|
||||
* @param [out] result pointer to the FuriString instance (must be initialized)
|
||||
*/
|
||||
void ibutton_protocols_render_uid(
|
||||
iButtonProtocols* protocols,
|
||||
const iButtonKey* key,
|
||||
FuriString* result);
|
||||
|
||||
/**
|
||||
* Format a string containing device full data
|
||||
* @param [in] protocols pointer to an iButtonProtocols object
|
||||
|
|
|
@ -208,15 +208,26 @@ bool dallas_common_is_valid_crc(const DallasCommonRomData* rom_data) {
|
|||
return crc_calculated == crc_received;
|
||||
}
|
||||
|
||||
void dallas_common_render_uid(FuriString* result, const DallasCommonRomData* rom_data) {
|
||||
furi_string_cat_printf(result, "ID: ");
|
||||
for(size_t i = 0; i < sizeof(DallasCommonRomData); ++i) {
|
||||
furi_string_cat_printf(result, "%02X ", rom_data->bytes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void dallas_common_render_brief_data(
|
||||
FuriString* result,
|
||||
const DallasCommonRomData* rom_data,
|
||||
const uint8_t* mem_data,
|
||||
size_t mem_size,
|
||||
const char* mem_name) {
|
||||
UNUSED(mem_data);
|
||||
|
||||
furi_string_cat_printf(result, "ID: ");
|
||||
for(size_t i = 0; i < sizeof(rom_data->bytes); ++i) {
|
||||
furi_string_cat_printf(result, "%02X ", rom_data->bytes[i]);
|
||||
}
|
||||
furi_string_cat_printf(result, "\nFamily Code: %02X\n", rom_data->bytes[0]);
|
||||
|
||||
const char* size_prefix = "";
|
||||
size_t mem_size_bits = mem_size * BITS_IN_BYTE;
|
||||
|
@ -229,28 +240,23 @@ void dallas_common_render_brief_data(
|
|||
mem_size_bits /= BITS_IN_KBIT;
|
||||
}
|
||||
|
||||
furi_string_cat_printf(
|
||||
result, "\nInternal %s: %zu %sbit\n", mem_name, mem_size_bits, size_prefix);
|
||||
|
||||
for(size_t i = 0; i < DALLAS_COMMON_BRIEF_HEAD_COUNT; ++i) {
|
||||
furi_string_cat_printf(result, "%02X ", mem_data[i]);
|
||||
}
|
||||
|
||||
furi_string_cat_printf(result, "[ . . . ]");
|
||||
|
||||
for(size_t i = mem_size - DALLAS_COMMON_BRIEF_TAIL_COUNT; i < mem_size; ++i) {
|
||||
furi_string_cat_printf(result, " %02X", mem_data[i]);
|
||||
}
|
||||
furi_string_cat_printf(result, "%s: %zu %sbit\n", mem_name, mem_size_bits, size_prefix);
|
||||
}
|
||||
|
||||
void dallas_common_render_crc_error(FuriString* result, const DallasCommonRomData* rom_data) {
|
||||
furi_string_set(result, "CRC Error\n");
|
||||
furi_string_set(result, "\e#CRC Error\e#\n");
|
||||
|
||||
const size_t data_size = sizeof(DallasCommonRomData);
|
||||
|
||||
for(size_t i = 0; i < data_size; ++i) {
|
||||
furi_string_cat_printf(result, (i < data_size - 1) ? "%02X " : "%02X", rom_data->bytes[i]);
|
||||
furi_string_cat_printf(
|
||||
result, (i < data_size - 1) ? "%02X " : "\e!%02X\e!", rom_data->bytes[i]);
|
||||
}
|
||||
|
||||
furi_string_cat_printf(
|
||||
result,
|
||||
"\nExpected CRC: \e!%02X\e!",
|
||||
maxim_crc8(rom_data->bytes, sizeof(DallasCommonRomData) - 1, MAXIM_CRC8_INIT));
|
||||
}
|
||||
|
||||
void dallas_common_apply_edits(DallasCommonRomData* rom_data, uint8_t family_code) {
|
||||
|
|
|
@ -96,6 +96,8 @@ bool dallas_common_load_rom_data(
|
|||
/* Miscellaneous */
|
||||
bool dallas_common_is_valid_crc(const DallasCommonRomData* rom_data);
|
||||
|
||||
void dallas_common_render_uid(FuriString* result, const DallasCommonRomData* rom_data);
|
||||
|
||||
void dallas_common_render_brief_data(
|
||||
FuriString* result,
|
||||
const DallasCommonRomData* rom_data,
|
||||
|
|
|
@ -30,6 +30,7 @@ typedef struct {
|
|||
iButtonProtocolDallasEmulateFunc emulate;
|
||||
iButtonProtocolDallasSaveFunc save;
|
||||
iButtonProtocolDallasLoadFunc load;
|
||||
iButtonProtocolDallasRenderDataFunc render_uid;
|
||||
iButtonProtocolDallasRenderDataFunc render_data;
|
||||
iButtonProtocolDallasRenderDataFunc render_brief_data;
|
||||
iButtonProtocolDallasRenderDataFunc render_error;
|
||||
|
|
|
@ -35,6 +35,7 @@ static bool dallas_ds1971_write_copy(OneWireHost*, iButtonProtocolData*);
|
|||
static void dallas_ds1971_emulate(OneWireSlave*, iButtonProtocolData*);
|
||||
static bool dallas_ds1971_load(FlipperFormat*, uint32_t, iButtonProtocolData*);
|
||||
static bool dallas_ds1971_save(FlipperFormat*, const iButtonProtocolData*);
|
||||
static void dallas_ds1971_render_uid(FuriString*, const iButtonProtocolData*);
|
||||
static void dallas_ds1971_render_data(FuriString*, const iButtonProtocolData*);
|
||||
static void dallas_ds1971_render_brief_data(FuriString*, const iButtonProtocolData*);
|
||||
static void dallas_ds1971_render_error(FuriString*, const iButtonProtocolData*);
|
||||
|
@ -58,6 +59,7 @@ const iButtonProtocolDallasBase ibutton_protocol_ds1971 = {
|
|||
.emulate = dallas_ds1971_emulate,
|
||||
.save = dallas_ds1971_save,
|
||||
.load = dallas_ds1971_load,
|
||||
.render_uid = dallas_ds1971_render_uid,
|
||||
.render_data = dallas_ds1971_render_data,
|
||||
.render_brief_data = dallas_ds1971_render_brief_data,
|
||||
.render_error = dallas_ds1971_render_error,
|
||||
|
@ -209,14 +211,26 @@ bool dallas_ds1971_save(FlipperFormat* ff, const iButtonProtocolData* protocol_d
|
|||
return success;
|
||||
}
|
||||
|
||||
void dallas_ds1971_render_uid(FuriString* result, const iButtonProtocolData* protocol_data) {
|
||||
const DS1971ProtocolData* data = protocol_data;
|
||||
dallas_common_render_uid(result, &data->rom_data);
|
||||
}
|
||||
|
||||
void dallas_ds1971_render_data(FuriString* result, const iButtonProtocolData* protocol_data) {
|
||||
const DS1971ProtocolData* data = protocol_data;
|
||||
FuriString* data_string = furi_string_alloc();
|
||||
|
||||
pretty_format_bytes_hex_canonical(
|
||||
result,
|
||||
data_string,
|
||||
DS1971_DATA_BYTE_COUNT,
|
||||
PRETTY_FORMAT_FONT_MONOSPACE,
|
||||
data->eeprom_data,
|
||||
DS1971_EEPROM_DATA_SIZE);
|
||||
|
||||
furi_string_cat_printf(result, "\e#Memory Data\n--------------------\n");
|
||||
furi_string_cat_printf(result, "%s", furi_string_get_cstr(data_string));
|
||||
|
||||
furi_string_free(data_string);
|
||||
}
|
||||
|
||||
void dallas_ds1971_render_brief_data(FuriString* result, const iButtonProtocolData* protocol_data) {
|
||||
|
|
|
@ -27,6 +27,7 @@ static bool dallas_ds1990_write_blank(OneWireHost*, iButtonProtocolData*);
|
|||
static void dallas_ds1990_emulate(OneWireSlave*, iButtonProtocolData*);
|
||||
static bool dallas_ds1990_load(FlipperFormat*, uint32_t, iButtonProtocolData*);
|
||||
static bool dallas_ds1990_save(FlipperFormat*, const iButtonProtocolData*);
|
||||
static void dallas_ds1990_render_uid(FuriString*, const iButtonProtocolData*);
|
||||
static void dallas_ds1990_render_brief_data(FuriString*, const iButtonProtocolData*);
|
||||
static void dallas_ds1990_render_error(FuriString*, const iButtonProtocolData*);
|
||||
static bool dallas_ds1990_is_data_valid(const iButtonProtocolData*);
|
||||
|
@ -46,6 +47,7 @@ const iButtonProtocolDallasBase ibutton_protocol_ds1990 = {
|
|||
.emulate = dallas_ds1990_emulate,
|
||||
.save = dallas_ds1990_save,
|
||||
.load = dallas_ds1990_load,
|
||||
.render_uid = dallas_ds1990_render_uid,
|
||||
.render_data = NULL, /* No data to render */
|
||||
.render_brief_data = dallas_ds1990_render_brief_data,
|
||||
.render_error = dallas_ds1990_render_error,
|
||||
|
@ -117,12 +119,20 @@ bool dallas_ds1990_load(
|
|||
return dallas_common_load_rom_data(ff, format_version, &data->rom_data);
|
||||
}
|
||||
|
||||
void dallas_ds1990_render_uid(FuriString* result, const iButtonProtocolData* protocol_data) {
|
||||
const DS1990ProtocolData* data = protocol_data;
|
||||
|
||||
dallas_common_render_uid(result, &data->rom_data);
|
||||
}
|
||||
|
||||
void dallas_ds1990_render_brief_data(FuriString* result, const iButtonProtocolData* protocol_data) {
|
||||
const DS1990ProtocolData* data = protocol_data;
|
||||
|
||||
furi_string_cat_printf(result, "ID: ");
|
||||
for(size_t i = 0; i < sizeof(DallasCommonRomData); ++i) {
|
||||
furi_string_cat_printf(result, "%02X ", data->rom_data.bytes[i]);
|
||||
}
|
||||
furi_string_cat_printf(result, "\nFamily Code: %02X\n", data->rom_data.bytes[0]);
|
||||
}
|
||||
|
||||
void dallas_ds1990_render_error(FuriString* result, const iButtonProtocolData* protocol_data) {
|
||||
|
|
|
@ -36,6 +36,7 @@ static bool dallas_ds1992_write_copy(OneWireHost*, iButtonProtocolData*);
|
|||
static void dallas_ds1992_emulate(OneWireSlave*, iButtonProtocolData*);
|
||||
static bool dallas_ds1992_load(FlipperFormat*, uint32_t, iButtonProtocolData*);
|
||||
static bool dallas_ds1992_save(FlipperFormat*, const iButtonProtocolData*);
|
||||
static void dallas_ds1992_render_uid(FuriString*, const iButtonProtocolData*);
|
||||
static void dallas_ds1992_render_data(FuriString*, const iButtonProtocolData*);
|
||||
static void dallas_ds1992_render_brief_data(FuriString*, const iButtonProtocolData*);
|
||||
static void dallas_ds1992_render_error(FuriString*, const iButtonProtocolData*);
|
||||
|
@ -57,6 +58,7 @@ const iButtonProtocolDallasBase ibutton_protocol_ds1992 = {
|
|||
.emulate = dallas_ds1992_emulate,
|
||||
.save = dallas_ds1992_save,
|
||||
.load = dallas_ds1992_load,
|
||||
.render_uid = dallas_ds1992_render_uid,
|
||||
.render_data = dallas_ds1992_render_data,
|
||||
.render_brief_data = dallas_ds1992_render_brief_data,
|
||||
.render_error = dallas_ds1992_render_error,
|
||||
|
@ -182,14 +184,26 @@ bool dallas_ds1992_save(FlipperFormat* ff, const iButtonProtocolData* protocol_d
|
|||
return success;
|
||||
}
|
||||
|
||||
void dallas_ds1992_render_uid(FuriString* result, const iButtonProtocolData* protocol_data) {
|
||||
const DS1992ProtocolData* data = protocol_data;
|
||||
dallas_common_render_uid(result, &data->rom_data);
|
||||
}
|
||||
|
||||
void dallas_ds1992_render_data(FuriString* result, const iButtonProtocolData* protocol_data) {
|
||||
const DS1992ProtocolData* data = protocol_data;
|
||||
FuriString* data_string = furi_string_alloc();
|
||||
|
||||
pretty_format_bytes_hex_canonical(
|
||||
result,
|
||||
data_string,
|
||||
DS1992_DATA_BYTE_COUNT,
|
||||
PRETTY_FORMAT_FONT_MONOSPACE,
|
||||
data->sram_data,
|
||||
DS1992_SRAM_DATA_SIZE);
|
||||
|
||||
furi_string_cat_printf(result, "\e#Memory Data\n--------------------\n");
|
||||
furi_string_cat_printf(result, "%s", furi_string_get_cstr(data_string));
|
||||
|
||||
furi_string_free(data_string);
|
||||
}
|
||||
|
||||
void dallas_ds1992_render_brief_data(FuriString* result, const iButtonProtocolData* protocol_data) {
|
||||
|
|
|
@ -33,6 +33,7 @@ static bool dallas_ds1996_write_copy(OneWireHost*, iButtonProtocolData*);
|
|||
static void dallas_ds1996_emulate(OneWireSlave*, iButtonProtocolData*);
|
||||
static bool dallas_ds1996_load(FlipperFormat*, uint32_t, iButtonProtocolData*);
|
||||
static bool dallas_ds1996_save(FlipperFormat*, const iButtonProtocolData*);
|
||||
static void dallas_ds1996_render_uid(FuriString*, const iButtonProtocolData*);
|
||||
static void dallas_ds1996_render_data(FuriString*, const iButtonProtocolData*);
|
||||
static void dallas_ds1996_render_brief_data(FuriString*, const iButtonProtocolData*);
|
||||
static void dallas_ds1996_render_error(FuriString*, const iButtonProtocolData*);
|
||||
|
@ -53,6 +54,7 @@ const iButtonProtocolDallasBase ibutton_protocol_ds1996 = {
|
|||
.emulate = dallas_ds1996_emulate,
|
||||
.save = dallas_ds1996_save,
|
||||
.load = dallas_ds1996_load,
|
||||
.render_uid = dallas_ds1996_render_uid,
|
||||
.render_data = dallas_ds1996_render_data,
|
||||
.render_brief_data = dallas_ds1996_render_brief_data,
|
||||
.render_error = dallas_ds1996_render_error,
|
||||
|
@ -207,15 +209,27 @@ bool dallas_ds1996_save(FlipperFormat* ff, const iButtonProtocolData* protocol_d
|
|||
return success;
|
||||
}
|
||||
|
||||
void dallas_ds1996_render_uid(FuriString* result, const iButtonProtocolData* protocol_data) {
|
||||
const DS1996ProtocolData* data = protocol_data;
|
||||
dallas_common_render_uid(result, &data->rom_data);
|
||||
}
|
||||
|
||||
void dallas_ds1996_render_data(FuriString* result, const iButtonProtocolData* protocol_data) {
|
||||
const DS1996ProtocolData* data = protocol_data;
|
||||
|
||||
FuriString* data_string = furi_string_alloc();
|
||||
|
||||
pretty_format_bytes_hex_canonical(
|
||||
result,
|
||||
data_string,
|
||||
DS1996_DATA_BYTE_COUNT,
|
||||
PRETTY_FORMAT_FONT_MONOSPACE,
|
||||
data->sram_data,
|
||||
DS1996_SRAM_DATA_SIZE);
|
||||
|
||||
furi_string_cat_printf(result, "\e#Memory Data\n--------------------\n");
|
||||
furi_string_cat_printf(result, "%s", furi_string_get_cstr(data_string));
|
||||
|
||||
furi_string_free(data_string);
|
||||
}
|
||||
|
||||
void dallas_ds1996_render_brief_data(FuriString* result, const iButtonProtocolData* protocol_data) {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "../blanks/tm2004.h"
|
||||
|
||||
#define DALLAS_GENERIC_FAMILY_CODE 0x00U
|
||||
#define DALLAS_GENERIC_FAMILY_NAME "DSGeneric"
|
||||
#define DALLAS_GENERIC_FAMILY_NAME "(non-specific)"
|
||||
|
||||
typedef struct {
|
||||
OneWireSlave* bus;
|
||||
|
@ -24,6 +24,7 @@ static bool ds_generic_write_blank(OneWireHost*, iButtonProtocolData*);
|
|||
static void ds_generic_emulate(OneWireSlave*, iButtonProtocolData*);
|
||||
static bool ds_generic_load(FlipperFormat*, uint32_t, iButtonProtocolData*);
|
||||
static bool ds_generic_save(FlipperFormat*, const iButtonProtocolData*);
|
||||
static void ds_generic_render_uid(FuriString*, const iButtonProtocolData*);
|
||||
static void ds_generic_render_brief_data(FuriString*, const iButtonProtocolData*);
|
||||
static void ds_generic_render_error(FuriString*, const iButtonProtocolData*);
|
||||
static bool ds_generic_is_data_valid(const iButtonProtocolData*);
|
||||
|
@ -44,6 +45,7 @@ const iButtonProtocolDallasBase ibutton_protocol_ds_generic = {
|
|||
.save = ds_generic_save,
|
||||
.load = ds_generic_load,
|
||||
.render_data = NULL, /* No data to render */
|
||||
.render_uid = ds_generic_render_uid,
|
||||
.render_brief_data = ds_generic_render_brief_data,
|
||||
.render_error = ds_generic_render_error,
|
||||
.is_valid = ds_generic_is_data_valid,
|
||||
|
@ -111,9 +113,15 @@ bool ds_generic_load(
|
|||
return dallas_common_load_rom_data(ff, format_version, &data->rom_data);
|
||||
}
|
||||
|
||||
void ds_generic_render_uid(FuriString* result, const iButtonProtocolData* protocol_data) {
|
||||
const DallasGenericProtocolData* data = protocol_data;
|
||||
dallas_common_render_uid(result, &data->rom_data);
|
||||
}
|
||||
|
||||
void ds_generic_render_brief_data(FuriString* result, const iButtonProtocolData* protocol_data) {
|
||||
const DallasGenericProtocolData* data = protocol_data;
|
||||
|
||||
furi_string_cat_printf(result, "ID: ");
|
||||
for(size_t i = 0; i < sizeof(DallasCommonRomData); ++i) {
|
||||
furi_string_cat_printf(result, "%02X ", data->rom_data.bytes[i]);
|
||||
}
|
||||
|
|
|
@ -51,6 +51,12 @@ static bool ibutton_protocol_group_dallas_get_id_by_name(
|
|||
return true;
|
||||
}
|
||||
|
||||
// Handle files that refer to Dallas "Raw Data" as DSGeneric
|
||||
if(strcmp(name, "DSGeneric") == 0) {
|
||||
*id = iButtonProtocolDSGeneric;
|
||||
return true;
|
||||
}
|
||||
|
||||
for(iButtonProtocolLocalId i = 0; i < iButtonProtocolDSMax; ++i) {
|
||||
if(strcmp(ibutton_protocols_dallas[i]->name, name) == 0) {
|
||||
*id = i;
|
||||
|
@ -212,6 +218,18 @@ static bool ibutton_protocol_group_dallas_load(
|
|||
return ibutton_protocols_dallas[id]->load(ff, version, data);
|
||||
}
|
||||
|
||||
static void ibutton_protocol_group_dallas_render_uid(
|
||||
iButtonProtocolGroupDallas* group,
|
||||
const iButtonProtocolData* data,
|
||||
iButtonProtocolLocalId id,
|
||||
FuriString* result) {
|
||||
UNUSED(group);
|
||||
furi_assert(id < iButtonProtocolDSMax);
|
||||
const iButtonProtocolDallasBase* protocol = ibutton_protocols_dallas[id];
|
||||
furi_assert(protocol->render_uid);
|
||||
protocol->render_uid(result, data);
|
||||
}
|
||||
|
||||
static void ibutton_protocol_group_dallas_render_data(
|
||||
iButtonProtocolGroupDallas* group,
|
||||
const iButtonProtocolData* data,
|
||||
|
@ -298,6 +316,7 @@ const iButtonProtocolGroupBase ibutton_protocol_group_dallas = {
|
|||
.save = (iButtonProtocolGroupSaveFunc)ibutton_protocol_group_dallas_save,
|
||||
.load = (iButtonProtocolGroupLoadFunc)ibutton_protocol_group_dallas_load,
|
||||
|
||||
.render_uid = (iButtonProtocolGroupRenderFunc)ibutton_protocol_group_dallas_render_uid,
|
||||
.render_data = (iButtonProtocolGroupRenderFunc)ibutton_protocol_group_dallas_render_data,
|
||||
.render_brief_data =
|
||||
(iButtonProtocolGroupRenderFunc)ibutton_protocol_group_dallas_render_brief_data,
|
||||
|
|
|
@ -325,7 +325,15 @@ static LevelDuration protocol_cyfral_encoder_yield(ProtocolCyfral* proto) {
|
|||
return result;
|
||||
}
|
||||
|
||||
static void protocol_cyfral_render_uid(FuriString* result, ProtocolCyfral* proto) {
|
||||
furi_string_cat_printf(result, "ID: ");
|
||||
for(size_t i = 0; i < CYFRAL_DATA_SIZE; ++i) {
|
||||
furi_string_cat_printf(result, "%02X ", ((uint8_t*)&proto->data)[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static void protocol_cyfral_render_brief_data(ProtocolCyfral* proto, FuriString* result) {
|
||||
furi_string_cat_printf(result, "ID: ");
|
||||
for(size_t i = 0; i < CYFRAL_DATA_SIZE; ++i) {
|
||||
furi_string_cat_printf(result, "%02X ", ((uint8_t*)&proto->data)[i]);
|
||||
}
|
||||
|
@ -348,5 +356,6 @@ const ProtocolBase ibutton_protocol_misc_cyfral = {
|
|||
.start = (ProtocolEncoderStart)protocol_cyfral_encoder_start,
|
||||
.yield = (ProtocolEncoderYield)protocol_cyfral_encoder_yield,
|
||||
},
|
||||
.render_uid = (ProtocolRenderData)protocol_cyfral_render_uid,
|
||||
.render_brief_data = (ProtocolRenderData)protocol_cyfral_render_brief_data,
|
||||
};
|
||||
|
|
|
@ -301,12 +301,17 @@ static LevelDuration protocol_metakom_encoder_yield(ProtocolMetakom* proto) {
|
|||
return result;
|
||||
}
|
||||
|
||||
static void protocol_metakom_render_brief_data(ProtocolMetakom* proto, FuriString* result) {
|
||||
static void protocol_metakom_render_uid(ProtocolMetakom* proto, FuriString* result) {
|
||||
furi_string_cat_printf(result, "ID: ");
|
||||
for(size_t i = 0; i < METAKOM_DATA_SIZE; ++i) {
|
||||
furi_string_cat_printf(result, "%02X ", ((uint8_t*)&proto->data)[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static void protocol_metakom_render_brief_data(ProtocolMetakom* proto, FuriString* result) {
|
||||
protocol_metakom_render_uid(proto, result);
|
||||
}
|
||||
|
||||
const ProtocolBase ibutton_protocol_misc_metakom = {
|
||||
.name = "Metakom",
|
||||
.manufacturer = "Metakom",
|
||||
|
@ -324,5 +329,6 @@ const ProtocolBase ibutton_protocol_misc_metakom = {
|
|||
.start = (ProtocolEncoderStart)protocol_metakom_encoder_start,
|
||||
.yield = (ProtocolEncoderYield)protocol_metakom_encoder_yield,
|
||||
},
|
||||
.render_uid = (ProtocolRenderData)protocol_metakom_render_uid,
|
||||
.render_brief_data = (ProtocolRenderData)protocol_metakom_render_brief_data,
|
||||
};
|
||||
|
|
|
@ -93,6 +93,7 @@ typedef struct {
|
|||
iButtonProtocolGroupSaveFunc save;
|
||||
iButtonProtocolGroupLoadFunc load;
|
||||
|
||||
iButtonProtocolGroupRenderFunc render_uid;
|
||||
iButtonProtocolGroupRenderFunc render_data;
|
||||
iButtonProtocolGroupRenderFunc render_brief_data;
|
||||
iButtonProtocolGroupRenderFunc render_error;
|
||||
|
|
|
@ -40,6 +40,7 @@ typedef struct {
|
|||
ProtocolGetData get_data;
|
||||
ProtocolDecoder decoder;
|
||||
ProtocolEncoder encoder;
|
||||
ProtocolRenderData render_uid;
|
||||
ProtocolRenderData render_data;
|
||||
ProtocolRenderData render_brief_data;
|
||||
ProtocolWriteData write_data;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
entry,status,name,type,params
|
||||
Version,+,61.0,,
|
||||
Version,+,61.1,,
|
||||
Header,+,applications/services/bt/bt_service/bt.h,,
|
||||
Header,+,applications/services/cli/cli.h,,
|
||||
Header,+,applications/services/cli/cli_vcp.h,,
|
||||
|
|
|
|
@ -1,5 +1,5 @@
|
|||
entry,status,name,type,params
|
||||
Version,+,61.0,,
|
||||
Version,+,61.1,,
|
||||
Header,+,applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h,,
|
||||
Header,+,applications/services/bt/bt_service/bt.h,,
|
||||
Header,+,applications/services/cli/cli.h,,
|
||||
|
@ -1894,6 +1894,7 @@ Function,+,ibutton_protocols_read,_Bool,"iButtonProtocols*, iButtonKey*"
|
|||
Function,+,ibutton_protocols_render_brief_data,void,"iButtonProtocols*, const iButtonKey*, FuriString*"
|
||||
Function,+,ibutton_protocols_render_data,void,"iButtonProtocols*, const iButtonKey*, FuriString*"
|
||||
Function,+,ibutton_protocols_render_error,void,"iButtonProtocols*, const iButtonKey*, FuriString*"
|
||||
Function,+,ibutton_protocols_render_uid,void,"iButtonProtocols*, const iButtonKey*, FuriString*"
|
||||
Function,+,ibutton_protocols_save,_Bool,"iButtonProtocols*, const iButtonKey*, const char*"
|
||||
Function,+,ibutton_protocols_write_blank,_Bool,"iButtonProtocols*, iButtonKey*"
|
||||
Function,+,ibutton_protocols_write_copy,_Bool,"iButtonProtocols*, iButtonKey*"
|
||||
|
|
|
Loading…
Reference in a new issue