[FL-3666] NFC API improvements (#3214)
* drivers: expose st25r3916 driver API * nfc poller: add start with custom callback * mf classic: rework sync API with poller custom start * mf ultralight: rework sync API with poller custom start * iso14443_3a poller: remove unused col res state * nfc: rework nfc poller custom start * mf ultralight: rename sync API * mf classic: rename sync API * iso14443-3a: rename sync API * nfc: remove async prefix in internal functions * nfc: expose internal API * nfc: fix sync api include and docs * targets: fix f18 build * nfc: rework NfcGenericEventEx type * nfc poller: add documentation * iso14443-3a poller: add documentation * felica poller: add documentation * iso14443_3b poller: add documentation * so14443_4a poller: add documentation * iso14443_4b poller: add documentation * iso15693 poller: add documentation * slix poller: add documentation * mf desfire poller: add documentation * mf ultralight poller: fix API and add documentation * mf classic poller: add documentation Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -71,7 +71,7 @@ static NfcCommand st25tb_poller_run(NfcGenericEvent event, void* context) {
|
||||
|
||||
if(nfc_event->type == NfcEventTypePollerReady) {
|
||||
if(instance->state != St25tbPollerStateActivated) {
|
||||
St25tbError error = st25tb_poller_async_activate(instance, instance->data);
|
||||
St25tbError error = st25tb_poller_activate(instance, instance->data);
|
||||
|
||||
if(error == St25tbErrorNone) {
|
||||
instance->st25tb_event.type = St25tbPollerEventTypeReady;
|
||||
@@ -106,7 +106,7 @@ static bool st25tb_poller_detect(NfcGenericEvent event, void* context) {
|
||||
furi_assert(instance->state == St25tbPollerStateIdle);
|
||||
|
||||
if(nfc_event->type == NfcEventTypePollerReady) {
|
||||
St25tbError error = st25tb_poller_async_initiate(instance, NULL);
|
||||
St25tbError error = st25tb_poller_initiate(instance, NULL);
|
||||
protocol_detected = (error == St25tbErrorNone);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,23 @@ typedef struct {
|
||||
St25tbPollerEventData* data;
|
||||
} St25tbPollerEvent;
|
||||
|
||||
St25tbError st25tb_poller_send_frame(
|
||||
St25tbPoller* instance,
|
||||
const BitBuffer* tx_buffer,
|
||||
BitBuffer* rx_buffer,
|
||||
uint32_t fwt);
|
||||
|
||||
St25tbError st25tb_poller_initiate(St25tbPoller* instance, uint8_t* chip_id);
|
||||
|
||||
St25tbError st25tb_poller_activate(St25tbPoller* instance, St25tbData* data);
|
||||
|
||||
St25tbError st25tb_poller_get_uid(St25tbPoller* instance, uint8_t* uid);
|
||||
|
||||
St25tbError
|
||||
st25tb_poller_read_block(St25tbPoller* instance, uint32_t* block, uint8_t block_number);
|
||||
|
||||
St25tbError st25tb_poller_halt(St25tbPoller* instance);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -22,7 +22,7 @@ static St25tbError st25tb_poller_prepare_trx(St25tbPoller* instance) {
|
||||
furi_assert(instance);
|
||||
|
||||
if(instance->state == St25tbPollerStateIdle) {
|
||||
return st25tb_poller_async_activate(instance, NULL);
|
||||
return st25tb_poller_activate(instance, NULL);
|
||||
}
|
||||
|
||||
return St25tbErrorNone;
|
||||
@@ -85,7 +85,7 @@ St25tbType st25tb_get_type_from_uid(const uint8_t uid[ST25TB_UID_SIZE]) {
|
||||
}
|
||||
}
|
||||
|
||||
St25tbError st25tb_poller_async_initiate(St25tbPoller* instance, uint8_t* chip_id) {
|
||||
St25tbError st25tb_poller_initiate(St25tbPoller* instance, uint8_t* chip_id) {
|
||||
// Send Initiate()
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->nfc);
|
||||
@@ -117,7 +117,7 @@ St25tbError st25tb_poller_async_initiate(St25tbPoller* instance, uint8_t* chip_i
|
||||
return ret;
|
||||
}
|
||||
|
||||
St25tbError st25tb_poller_async_activate(St25tbPoller* instance, St25tbData* data) {
|
||||
St25tbError st25tb_poller_activate(St25tbPoller* instance, St25tbData* data) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->nfc);
|
||||
|
||||
@@ -126,7 +126,7 @@ St25tbError st25tb_poller_async_activate(St25tbPoller* instance, St25tbData* dat
|
||||
St25tbError ret;
|
||||
|
||||
do {
|
||||
ret = st25tb_poller_async_initiate(instance, &data->chip_id);
|
||||
ret = st25tb_poller_initiate(instance, &data->chip_id);
|
||||
if(ret != St25tbErrorNone) {
|
||||
break;
|
||||
}
|
||||
@@ -162,7 +162,7 @@ St25tbError st25tb_poller_async_activate(St25tbPoller* instance, St25tbData* dat
|
||||
}
|
||||
instance->state = St25tbPollerStateActivated;
|
||||
|
||||
ret = st25tb_poller_async_get_uid(instance, data->uid);
|
||||
ret = st25tb_poller_get_uid(instance, data->uid);
|
||||
if(ret != St25tbErrorNone) {
|
||||
instance->state = St25tbPollerStateActivationFailed;
|
||||
break;
|
||||
@@ -171,7 +171,7 @@ St25tbError st25tb_poller_async_activate(St25tbPoller* instance, St25tbData* dat
|
||||
|
||||
bool read_blocks = true;
|
||||
for(uint8_t i = 0; i < st25tb_get_block_count(data->type); i++) {
|
||||
ret = st25tb_poller_async_read_block(instance, &data->blocks[i], i);
|
||||
ret = st25tb_poller_read_block(instance, &data->blocks[i], i);
|
||||
if(ret != St25tbErrorNone) {
|
||||
read_blocks = false;
|
||||
break;
|
||||
@@ -180,14 +180,13 @@ St25tbError st25tb_poller_async_activate(St25tbPoller* instance, St25tbData* dat
|
||||
if(!read_blocks) {
|
||||
break;
|
||||
}
|
||||
ret = st25tb_poller_async_read_block(
|
||||
instance, &data->system_otp_block, ST25TB_SYSTEM_OTP_BLOCK);
|
||||
ret = st25tb_poller_read_block(instance, &data->system_otp_block, ST25TB_SYSTEM_OTP_BLOCK);
|
||||
} while(false);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
St25tbError st25tb_poller_async_get_uid(St25tbPoller* instance, uint8_t uid[ST25TB_UID_SIZE]) {
|
||||
St25tbError st25tb_poller_get_uid(St25tbPoller* instance, uint8_t* uid) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->nfc);
|
||||
|
||||
@@ -221,7 +220,7 @@ St25tbError st25tb_poller_async_get_uid(St25tbPoller* instance, uint8_t uid[ST25
|
||||
}
|
||||
|
||||
St25tbError
|
||||
st25tb_poller_async_read_block(St25tbPoller* instance, uint32_t* block, uint8_t block_number) {
|
||||
st25tb_poller_read_block(St25tbPoller* instance, uint32_t* block, uint8_t block_number) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->nfc);
|
||||
furi_assert(block);
|
||||
|
||||
@@ -34,23 +34,6 @@ struct St25tbPoller {
|
||||
|
||||
const St25tbData* st25tb_poller_get_data(St25tbPoller* instance);
|
||||
|
||||
St25tbError st25tb_poller_async_initiate(St25tbPoller* instance, uint8_t* chip_id);
|
||||
|
||||
St25tbError st25tb_poller_async_activate(St25tbPoller* instance, St25tbData* data);
|
||||
|
||||
St25tbError st25tb_poller_async_get_uid(St25tbPoller* instance, uint8_t uid[ST25TB_UID_SIZE]);
|
||||
|
||||
St25tbError
|
||||
st25tb_poller_async_read_block(St25tbPoller* instance, uint32_t* block, uint8_t block_number);
|
||||
|
||||
St25tbError st25tb_poller_halt(St25tbPoller* instance);
|
||||
|
||||
St25tbError st25tb_poller_send_frame(
|
||||
St25tbPoller* instance,
|
||||
const BitBuffer* tx_buffer,
|
||||
BitBuffer* rx_buffer,
|
||||
uint32_t fwt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user