Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into fav
  • Loading branch information
Willy-JL committed Apr 30, 2024
2 parents 21fe6c6 + 2d90599 commit 26aace2
Show file tree
Hide file tree
Showing 17 changed files with 142 additions and 98 deletions.
2 changes: 1 addition & 1 deletion .github/workflow_data/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
for i, commit in enumerate(event["commits"]):
msg = commit['message'].splitlines()[0].replace("`", "").replace("_", "\_")
msg = msg[:50] + ("..." if len(msg) > 50 else "")
desc += f"\n[`{commit['id'][:7]}`]({commit['url']}): {msg} - [__{commit['author'].get('username')}__](https://github.com/{commit['author'].get('username')})"
desc += f"\n[`{commit['id'][:8]}`]({commit['url']}): {msg} - [__{commit['author'].get('username')}__](https://github.com/{commit['author'].get('username')})"
if len(desc) > 2020:
desc = desc.rsplit("\n", 1)[0] + f"\n+ {count - i} more commits"
break
Expand Down
2 changes: 1 addition & 1 deletion applications/external
Submodule external updated 41 files
+34 −0 .utils/.check-merge.sh
+9 −3 .utils/.subtree-subdir-helper.sh
+1 −1 .utils/add-subtree.sh
+3 −20 .utils/update-subtree.sh
+38 −16 gps_nmea/README.md
+5 −6 gps_nmea/gps.c
+7 −4 gps_nmea/gps_uart.c
+4 −4 gps_nmea/gps_uart.h
+30 −0 magspoof/.github/ISSUE_TEMPLATE/bug_report.md
+20 −0 magspoof/.github/ISSUE_TEMPLATE/feature_request.md
+1 −1 magspoof/README.md
+2 −2 magspoof/application.fam
+61 −52 magspoof/helpers/mag_helpers.c
+4 −4 magspoof/helpers/mag_helpers.h
+32 −11 magspoof/helpers/mag_types.h
+28 −48 magspoof/mag.c
+28 −6 magspoof/mag_device.c
+5 −0 magspoof/mag_device.h
+15 −10 magspoof/mag_i.h
+116 −0 magspoof/mag_state.c
+42 −0 magspoof/mag_state.h
+3 −2 magspoof/scenes/mag_scene_config.h
+2 −2 magspoof/scenes/mag_scene_emulate.c
+35 −28 magspoof/scenes/mag_scene_emulate_config.c
+4 −1 magspoof/scenes/mag_scene_file_select.c
+4 −4 magspoof/scenes/mag_scene_saved_menu.c
+177 −0 magspoof/scenes/mag_scene_settings.c
+16 −1 magspoof/scenes/mag_scene_start.c
+13 −0 picopass/application.fam
+23 −0 picopass/picopass.c
+8 −0 picopass/picopass_i.h
+1 −0 picopass/plugin/.gitsubtree
+14 −0 picopass/plugin/README.md
+20 −0 picopass/plugin/interface.h
+152 −0 picopass/plugin/wiegand.c
+24 −0 picopass/scenes/picopass_scene_card_menu.c
+1 −0 picopass/scenes/picopass_scene_config.h
+22 −1 picopass/scenes/picopass_scene_device_info.c
+54 −0 picopass/scenes/picopass_scene_formats.c
+1 −1 seader/application.fam
+1 −1 seader/seader.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,27 @@ static const struct {
char* name;
RgbColor color;
} lcd_colors[] = {
{"Off", {0, 0, 0}}, {"Orange", {255, 69, 0}}, {"Red", {255, 0, 0}},
{"Maroon", {128, 0, 0}}, {"Yellow", {255, 255, 0}}, {"Olive", {128, 128, 0}},
{"Lime", {0, 255, 0}}, {"Green", {0, 128, 0}}, {"Aqua", {0, 255, 127}},
{"Cyan", {0, 210, 210}}, {"Azure", {0, 127, 255}}, {"Teal", {0, 128, 128}},
{"Blue", {0, 0, 255}}, {"Navy", {0, 0, 128}}, {"Purple", {128, 0, 128}},
{"Fuchsia", {255, 0, 255}}, {"Pink", {173, 31, 173}}, {"Brown", {165, 42, 42}},
// clang-format off
{"Off", {0, 0, 0}},
{"Orange", {255, 69, 0}},
{"Red", {255, 0, 0}},
{"Maroon", {128, 0, 0}},
{"Yellow", {255, 255, 0}},
{"Olive", {128, 128, 0}},
{"Lime", {0, 255, 0}},
{"Green", {0, 128, 0}},
{"Aqua", {0, 255, 127}},
{"Cyan", {0, 210, 210}},
{"Azure", {0, 127, 255}},
{"Teal", {0, 128, 128}},
{"Blue", {0, 0, 255}},
{"Navy", {0, 0, 128}},
{"Purple", {128, 0, 128}},
{"Fuchsia", {255, 0, 255}},
{"Pink", {173, 31, 173}},
{"Brown", {165, 42, 42}},
{"White", {255, 192, 203}},
// clang-format on
};
static const size_t lcd_sz = COUNT_OF(lcd_colors);
static void momentum_app_scene_misc_screen_lcd_color_changed(VariableItem* item, uint8_t led) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,27 @@ static const struct {
char* name;
Rgb565Color color;
} vgm_colors[] = {
{"Orange", {0xFC00}}, {"Black", {0x0000}}, {"Red", {0xF800}}, {"Maroon", {0x8000}},
{"Yellow", {0xFFE0}}, {"Olive", {0x8400}}, {"Lime", {0x07E0}}, {"Green", {0x0400}},
{"Aqua", {0x07EF}}, {"Cyan", {0x069A}}, {"Azure", {0x03FF}}, {"Teal", {0x0410}},
{"Blue", {0x001F}}, {"Navy", {0x0010}}, {"Purple", {0x8010}}, {"Fuchsia", {0xF81F}},
{"Pink", {0xA8F5}}, {"Brown", {0xA145}}, {"White", {0xFFFF}},
// clang-format off
{"Orange", {0xFC00}},
{"Black", {0x0000}},
{"Red", {0xF800}},
{"Maroon", {0x8000}},
{"Yellow", {0xFFE0}},
{"Olive", {0x8400}},
{"Lime", {0x07E0}},
{"Green", {0x0400}},
{"Aqua", {0x07EF}},
{"Cyan", {0x069A}},
{"Azure", {0x03FF}},
{"Teal", {0x0410}},
{"Blue", {0x001F}},
{"Navy", {0x0010}},
{"Purple", {0x8010}},
{"Fuchsia", {0xF81F}},
{"Pink", {0xA8F5}},
{"Brown", {0xA145}},
{"White", {0xFFFF}},
// clang-format on
};
static const size_t vgm_colors_count = COUNT_OF(vgm_colors);
static void momentum_app_scene_misc_vgm_foreground_changed(VariableItem* item) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "../iso14443_4a/iso14443_4a_render.h"

#define MF_DESFIRE_RENDER_MAX_RECORD_SIZE (256U)

void nfc_render_mf_desfire_info(
const MfDesfireData* data,
NfcProtocolFormatType format_type,
Expand Down Expand Up @@ -212,8 +214,6 @@ void nfc_render_mf_desfire_file_settings_data(
uint32_t record_count = 1;
uint32_t record_size = 0;

const uint32_t total_size = simple_array_get_count(data->data);

switch(settings->type) {
case MfDesfireFileTypeStandard:
case MfDesfireFileTypeBackup:
Expand Down Expand Up @@ -257,17 +257,14 @@ void nfc_render_mf_desfire_file_settings_data(
return;
}

// Limit record size
bool trim_data = record_size > MF_DESFIRE_RENDER_MAX_RECORD_SIZE;
if(trim_data) {
record_size = MF_DESFIRE_RENDER_MAX_RECORD_SIZE;
}

for(uint32_t rec = 0; rec < record_count; rec++) {
const uint32_t size_offset = rec * record_size;
const uint32_t size_remaining = total_size > size_offset ? total_size - size_offset : 0;

if(size_remaining < record_size) {
furi_string_cat_printf(
str, "record %lu (partial %lu of %lu)\n", rec, size_remaining, record_size);
record_size = size_remaining;
} else {
furi_string_cat_printf(str, "record %lu\n", rec);
}
furi_string_cat_printf(str, "record %lu\n", rec);

for(uint32_t ch = 0; ch < record_size; ch += 4) {
furi_string_cat_printf(str, "%03lx|", ch);
Expand Down Expand Up @@ -296,6 +293,9 @@ void nfc_render_mf_desfire_file_settings_data(

furi_string_push_back(str, '\n');
}
if(trim_data) {
furi_string_cat_str(str, "...");
}

furi_string_push_back(str, '\n');
}
Expand Down
12 changes: 6 additions & 6 deletions applications/system/findmy/findmy_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,17 @@ bool findmy_state_load(FindMyState* out_state) {
if(!flipper_format_read_uint32(file, "transmit_power", &tmp, 1)) break;
state.transmit_power = tmp;

if(!flipper_format_read_bool(file, "show_mac", &state.show_mac, 1)) {
// Support migrating from old config
state.show_mac = false;
if(!flipper_format_read_uint32(file, "tag_type", &tmp, 1)) {
tmp = FindMyTypeApple;
flipper_format_rewind(file);
}
state.tag_type = tmp;

if(!flipper_format_read_uint32(file, "tag_type", &tmp, 1)) {
if(!flipper_format_read_bool(file, "show_mac", &state.show_mac, 1)) {
// Support migrating from old config
tmp = FindMyTypeApple;
state.show_mac = false;
flipper_format_rewind(file);
}
state.tag_type = tmp;

if(!flipper_format_read_hex(file, "mac", state.mac, sizeof(state.mac))) break;

Expand Down Expand Up @@ -162,6 +161,7 @@ void findmy_state_save(FindMyState* state) {
if(!flipper_format_write_uint32(file, "transmit_power", &tmp, 1)) break;

tmp = state->tag_type;
FURI_LOG_E("tag_type at save", "%ld", tmp);
if(!flipper_format_write_uint32(file, "tag_type", &tmp, 1)) break;

if(!flipper_format_write_bool(file, "show_mac", &state->show_mac, 1)) break;
Expand Down
10 changes: 3 additions & 7 deletions lib/ibutton/protocols/dallas/protocol_ds1971.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,19 +218,15 @@ void dallas_ds1971_render_uid(FuriString* result, const iButtonProtocolData* pro

void dallas_ds1971_render_data(FuriString* result, const iButtonProtocolData* protocol_data) {
const DS1971ProtocolData* data = protocol_data;
FuriString* data_string = furi_string_alloc();

furi_string_cat_printf(result, "\e#Memory Data\n--------------------\n");

pretty_format_bytes_hex_canonical(
data_string,
result,
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) {
Expand Down
10 changes: 3 additions & 7 deletions lib/ibutton/protocols/dallas/protocol_ds1992.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,19 +191,15 @@ void dallas_ds1992_render_uid(FuriString* result, const iButtonProtocolData* pro

void dallas_ds1992_render_data(FuriString* result, const iButtonProtocolData* protocol_data) {
const DS1992ProtocolData* data = protocol_data;
FuriString* data_string = furi_string_alloc();

furi_string_cat_printf(result, "\e#Memory Data\n--------------------\n");

pretty_format_bytes_hex_canonical(
data_string,
result,
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) {
Expand Down
9 changes: 2 additions & 7 deletions lib/ibutton/protocols/dallas/protocol_ds1996.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,19 +217,14 @@ void dallas_ds1996_render_uid(FuriString* result, const iButtonProtocolData* pro
void dallas_ds1996_render_data(FuriString* result, const iButtonProtocolData* protocol_data) {
const DS1996ProtocolData* data = protocol_data;

FuriString* data_string = furi_string_alloc();
furi_string_cat_printf(result, "\e#Memory Data\n--------------------\n");

pretty_format_bytes_hex_canonical(
data_string,
result,
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) {
Expand Down
7 changes: 2 additions & 5 deletions lib/ibutton/protocols/misc/protocol_cyfral.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,18 +325,15 @@ static LevelDuration protocol_cyfral_encoder_yield(ProtocolCyfral* proto) {
return result;
}

static void protocol_cyfral_render_uid(FuriString* result, ProtocolCyfral* proto) {
static void protocol_cyfral_render_uid(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]);
}
}

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]);
}
protocol_cyfral_render_uid(proto, result);
}

const ProtocolBase ibutton_protocol_misc_cyfral = {
Expand Down
11 changes: 11 additions & 0 deletions lib/ibutton/protocols/misc/protocol_group_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,16 @@ static bool ibutton_protocol_group_misc_load(
}
}

static void ibutton_protocol_group_misc_render_uid(
iButtonProtocolGroupMisc* group,
const iButtonProtocolData* data,
iButtonProtocolLocalId id,
FuriString* result) {
const size_t data_size = protocol_dict_get_data_size(group->dict, id);
protocol_dict_set_data(group->dict, id, data, data_size);
protocol_dict_render_uid(group->dict, result, id);
}

static void ibutton_protocol_group_misc_render_data(
iButtonProtocolGroupMisc* group,
const iButtonProtocolData* data,
Expand Down Expand Up @@ -283,6 +293,7 @@ const iButtonProtocolGroupBase ibutton_protocol_group_misc = {
.save = (iButtonProtocolGroupSaveFunc)ibutton_protocol_group_misc_save,
.load = (iButtonProtocolGroupLoadFunc)ibutton_protocol_group_misc_load,

.render_uid = (iButtonProtocolGroupRenderFunc)ibutton_protocol_group_misc_render_uid,
.render_data = (iButtonProtocolGroupRenderFunc)ibutton_protocol_group_misc_render_data,
.render_brief_data =
(iButtonProtocolGroupRenderFunc)ibutton_protocol_group_misc_render_brief_data,
Expand Down
77 changes: 42 additions & 35 deletions lib/nfc/protocols/mf_desfire/mf_desfire_poller_i.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ MfDesfireError mf_desfire_send_chunks(
const size_t rx_capacity_remaining =
bit_buffer_get_capacity_bytes(rx_buffer) - bit_buffer_get_size_bytes(rx_buffer);

if(rx_size <= rx_capacity_remaining) {
if(rx_size - 1 <= rx_capacity_remaining) {
bit_buffer_append_right(rx_buffer, instance->rx_buffer, sizeof(uint8_t));
} else {
FURI_LOG_W(TAG, "RX buffer overflow: ignoring %zu bytes", rx_size);
FURI_LOG_W(TAG, "RX buffer overflow: ignoring %zu bytes", rx_size - 1);
}
}
} while(false);
Expand Down Expand Up @@ -327,36 +327,63 @@ MfDesfireError mf_desfire_poller_read_file_settings_multi(
return error;
}

MfDesfireError mf_desfire_poller_read_file_data(
static MfDesfireError mf_desfire_poller_read_file(
MfDesfirePoller* instance,
MfDesfireFileId id,
uint8_t read_cmd,
uint32_t offset,
size_t size,
MfDesfireFileData* data) {
furi_check(instance);
furi_check(data);

bit_buffer_reset(instance->input_buffer);
bit_buffer_append_byte(instance->input_buffer, MF_DESFIRE_CMD_READ_DATA);
bit_buffer_append_byte(instance->input_buffer, id);
bit_buffer_append_bytes(instance->input_buffer, (const uint8_t*)&offset, 3);
bit_buffer_append_bytes(instance->input_buffer, (const uint8_t*)&size, 3);
MfDesfireError error = MfDesfireErrorNone;
simple_array_init(data->data, size);

MfDesfireError error;
size_t buffer_capacity = bit_buffer_get_capacity_bytes(instance->result_buffer);
uint32_t current_offset = offset;
uint32_t bytes_read = 0;

do {
error = mf_desfire_send_chunks(instance, instance->input_buffer, instance->result_buffer);
while(bytes_read < size) {
size_t bytes_to_read = MIN(buffer_capacity, size - bytes_read);
bit_buffer_reset(instance->input_buffer);
bit_buffer_append_byte(instance->input_buffer, read_cmd);
bit_buffer_append_byte(instance->input_buffer, id);
bit_buffer_append_bytes(instance->input_buffer, (const uint8_t*)&current_offset, 3);
bit_buffer_append_bytes(instance->input_buffer, (const uint8_t*)&bytes_to_read, 3);

error = mf_desfire_send_chunks(instance, instance->input_buffer, instance->result_buffer);
if(error != MfDesfireErrorNone) break;

if(!mf_desfire_file_data_parse(data, instance->result_buffer)) {
size_t bytes_received = bit_buffer_get_size_bytes(instance->result_buffer);
if(bytes_received != bytes_to_read) {
FURI_LOG_W(TAG, "Read %zu out of %zu bytes", bytes_received, bytes_to_read);
error = MfDesfireErrorProtocol;
break;
}
} while(false);

uint8_t* file_data = simple_array_get_data(data->data);
bit_buffer_write_bytes(instance->result_buffer, &file_data[current_offset], bytes_to_read);
bytes_read += bytes_to_read;
current_offset += bytes_to_read;
}

if(error != MfDesfireErrorNone) {
simple_array_reset(data->data);
}

return error;
}

MfDesfireError mf_desfire_poller_read_file_data(
MfDesfirePoller* instance,
MfDesfireFileId id,
uint32_t offset,
size_t size,
MfDesfireFileData* data) {
return mf_desfire_poller_read_file(instance, id, MF_DESFIRE_CMD_READ_DATA, offset, size, data);
}

MfDesfireError mf_desfire_poller_read_file_value(
MfDesfirePoller* instance,
MfDesfireFileId id,
Expand Down Expand Up @@ -389,28 +416,8 @@ MfDesfireError mf_desfire_poller_read_file_records(
uint32_t offset,
size_t size,
MfDesfireFileData* data) {
furi_check(instance);
furi_check(data);

bit_buffer_reset(instance->input_buffer);
bit_buffer_append_byte(instance->input_buffer, MF_DESFIRE_CMD_READ_RECORDS);
bit_buffer_append_byte(instance->input_buffer, id);
bit_buffer_append_bytes(instance->input_buffer, (const uint8_t*)&offset, 3);
bit_buffer_append_bytes(instance->input_buffer, (const uint8_t*)&size, 3);

MfDesfireError error;

do {
error = mf_desfire_send_chunks(instance, instance->input_buffer, instance->result_buffer);

if(error != MfDesfireErrorNone) break;

if(!mf_desfire_file_data_parse(data, instance->result_buffer)) {
error = MfDesfireErrorProtocol;
}
} while(false);

return error;
return mf_desfire_poller_read_file(
instance, id, MF_DESFIRE_CMD_READ_RECORDS, offset, size, data);
}

MfDesfireError mf_desfire_poller_read_file_data_multi(
Expand Down
Loading

0 comments on commit 26aace2

Please sign in to comment.