From 3d4159009066e58eb8bcea7e5542e21c9afb78c2 Mon Sep 17 00:00:00 2001 From: RebornedBrain Date: Mon, 3 Jun 2024 16:25:58 +0300 Subject: [PATCH] Added new function which returns end block for write operation --- lib/nfc/protocols/mf_ultralight/mf_ultralight.c | 16 ++++++++++++++++ lib/nfc/protocols/mf_ultralight/mf_ultralight.h | 2 ++ .../mf_ultralight/mf_ultralight_poller.c | 2 +- targets/f7/api_symbols.csv | 3 ++- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/nfc/protocols/mf_ultralight/mf_ultralight.c b/lib/nfc/protocols/mf_ultralight/mf_ultralight.c index 74436dc08..6300801ab 100644 --- a/lib/nfc/protocols/mf_ultralight/mf_ultralight.c +++ b/lib/nfc/protocols/mf_ultralight/mf_ultralight.c @@ -570,6 +570,22 @@ uint16_t mf_ultralight_get_config_page_num(MfUltralightType type) { return mf_ultralight_features[type].config_page; } +uint8_t mf_ultralight_get_write_end_page(MfUltralightType type) { + furi_check(type < MfUltralightTypeNum); + furi_assert( + type == MfUltralightTypeUL11 || type == MfUltralightTypeUL21 || + type == MfUltralightTypeNTAG213 || type == MfUltralightTypeNTAG215 || + type == MfUltralightTypeNTAG216); + + uint8_t end_page = mf_ultralight_get_config_page_num(type); + if(type == MfUltralightTypeNTAG213 || type == MfUltralightTypeNTAG215 || + type == MfUltralightTypeNTAG216) { + end_page -= 1; + } + + return end_page; +} + uint8_t mf_ultralight_get_pwd_page_num(MfUltralightType type) { furi_check(type < MfUltralightTypeNum); diff --git a/lib/nfc/protocols/mf_ultralight/mf_ultralight.h b/lib/nfc/protocols/mf_ultralight/mf_ultralight.h index 5e348a0c9..6c6a83a17 100644 --- a/lib/nfc/protocols/mf_ultralight/mf_ultralight.h +++ b/lib/nfc/protocols/mf_ultralight/mf_ultralight.h @@ -210,6 +210,8 @@ uint32_t mf_ultralight_get_feature_support_set(MfUltralightType type); uint16_t mf_ultralight_get_config_page_num(MfUltralightType type); +uint8_t mf_ultralight_get_write_end_page(MfUltralightType type); + uint8_t mf_ultralight_get_pwd_page_num(MfUltralightType type); bool mf_ultralight_is_page_pwd_or_pack(MfUltralightType type, uint16_t page_num); diff --git a/lib/nfc/protocols/mf_ultralight/mf_ultralight_poller.c b/lib/nfc/protocols/mf_ultralight/mf_ultralight_poller.c index 0c7f9f803..bc4ebd515 100644 --- a/lib/nfc/protocols/mf_ultralight/mf_ultralight_poller.c +++ b/lib/nfc/protocols/mf_ultralight/mf_ultralight_poller.c @@ -616,7 +616,7 @@ static NfcCommand mf_ultralight_poller_handler_write_pages(MfUltralightPoller* i do { const MfUltralightData* write_data = instance->mfu_event.data->write_data; - uint8_t end_page = mf_ultralight_get_config_page_num(write_data->type) - 1; + uint8_t end_page = mf_ultralight_get_write_end_page(write_data->type); if(instance->current_page == end_page) { instance->state = MfUltralightPollerStateWriteSuccess; break; diff --git a/targets/f7/api_symbols.csv b/targets/f7/api_symbols.csv index e2e94d063..e6334c1e6 100644 --- a/targets/f7/api_symbols.csv +++ b/targets/f7/api_symbols.csv @@ -1,5 +1,5 @@ entry,status,name,type,params -Version,+,63.0,, +Version,+,64.0,, Header,+,applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h,, Header,+,applications/services/bt/bt_service/bt.h,, Header,+,applications/services/bt/bt_service/bt_keys_storage.h,, @@ -2533,6 +2533,7 @@ Function,+,mf_ultralight_get_pages_total,uint16_t,MfUltralightType Function,+,mf_ultralight_get_pwd_page_num,uint8_t,MfUltralightType Function,+,mf_ultralight_get_type_by_version,MfUltralightType,MfUltralightVersion* Function,+,mf_ultralight_get_uid,const uint8_t*,"const MfUltralightData*, size_t*" +Function,+,mf_ultralight_get_write_end_page,uint8_t,MfUltralightType Function,+,mf_ultralight_is_all_data_read,_Bool,const MfUltralightData* Function,+,mf_ultralight_is_counter_configured,_Bool,const MfUltralightData* Function,+,mf_ultralight_is_equal,_Bool,"const MfUltralightData*, const MfUltralightData*"