Skip to content

Commit

Permalink
Merge remote-tracking branch 'OFW/astra/3817-ibutton-crash' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
xMasterX committed Apr 27, 2024
2 parents c157ca9 + 379e8d2 commit e7ef923
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 7 deletions.
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
9 changes: 9 additions & 0 deletions lib/toolbox/protocols/protocol_dict.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,15 @@ LevelDuration protocol_dict_encoder_yield(ProtocolDict* dict, size_t protocol_in
}
}

void protocol_dict_render_uid(ProtocolDict* dict, FuriString* result, size_t protocol_index) {
furi_check(protocol_index < dict->count);
ProtocolRenderData fn = dict->base[protocol_index]->render_uid;

if(fn) {
return fn(dict->data[protocol_index], result);
}
}

void protocol_dict_render_data(ProtocolDict* dict, FuriString* result, size_t protocol_index) {
furi_check(protocol_index < dict->count);
ProtocolRenderData fn = dict->base[protocol_index]->render_data;
Expand Down
2 changes: 2 additions & 0 deletions lib/toolbox/protocols/protocol_dict.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ bool protocol_dict_encoder_start(ProtocolDict* dict, size_t protocol_index);

LevelDuration protocol_dict_encoder_yield(ProtocolDict* dict, size_t protocol_index);

void protocol_dict_render_uid(ProtocolDict* dict, FuriString* result, size_t protocol_index);

void protocol_dict_render_data(ProtocolDict* dict, FuriString* result, size_t protocol_index);

void protocol_dict_render_brief_data(ProtocolDict* dict, FuriString* result, size_t protocol_index);
Expand Down
3 changes: 2 additions & 1 deletion targets/f18/api_symbols.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
entry,status,name,type,params
Version,+,61.1,,
Version,+,61.2,,
Header,+,applications/services/bt/bt_service/bt.h,,
Header,+,applications/services/cli/cli.h,,
Header,+,applications/services/cli/cli_vcp.h,,
Expand Down Expand Up @@ -2251,6 +2251,7 @@ Function,+,protocol_dict_get_validate_count,uint32_t,"ProtocolDict*, size_t"
Function,+,protocol_dict_get_write_data,_Bool,"ProtocolDict*, size_t, void*"
Function,+,protocol_dict_render_brief_data,void,"ProtocolDict*, FuriString*, size_t"
Function,+,protocol_dict_render_data,void,"ProtocolDict*, FuriString*, size_t"
Function,+,protocol_dict_render_uid,void,"ProtocolDict*, FuriString*, size_t"
Function,+,protocol_dict_set_data,void,"ProtocolDict*, size_t, const uint8_t*, size_t"
Function,-,pulse_reader_alloc,PulseReader*,"const GpioPin*, uint32_t"
Function,-,pulse_reader_free,void,PulseReader*
Expand Down
3 changes: 2 additions & 1 deletion targets/f7/api_symbols.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
entry,status,name,type,params
Version,+,61.1,,
Version,+,61.2,,
Header,+,applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h,,
Header,+,applications/services/bt/bt_service/bt.h,,
Header,+,applications/services/cli/cli.h,,
Expand Down Expand Up @@ -2898,6 +2898,7 @@ Function,+,protocol_dict_get_validate_count,uint32_t,"ProtocolDict*, size_t"
Function,+,protocol_dict_get_write_data,_Bool,"ProtocolDict*, size_t, void*"
Function,+,protocol_dict_render_brief_data,void,"ProtocolDict*, FuriString*, size_t"
Function,+,protocol_dict_render_data,void,"ProtocolDict*, FuriString*, size_t"
Function,+,protocol_dict_render_uid,void,"ProtocolDict*, FuriString*, size_t"
Function,+,protocol_dict_set_data,void,"ProtocolDict*, size_t, const uint8_t*, size_t"
Function,-,pulse_reader_alloc,PulseReader*,"const GpioPin*, uint32_t"
Function,-,pulse_reader_free,void,PulseReader*
Expand Down

0 comments on commit e7ef923

Please sign in to comment.