1
mirror of https://github.com/DarkFlippers/unleashed-firmware.git synced 2025-12-12 04:34:43 +04:00

NFC: FeliCa Protocol Expose Read Block API and Allow Specifying Service (#4074)

* add one parameter to the rdbl and expose
* Bump api version and format sources

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
Zinong Li
2025-02-24 16:07:45 -05:00
committed by GitHub
parent 9f5e93bed8
commit 145184f0f2
6 changed files with 27 additions and 21 deletions

View File

@@ -118,7 +118,8 @@ NfcCommand felica_poller_state_handler_auth_internal(FelicaPoller* instance) {
blocks[1] = FELICA_BLOCK_INDEX_WCNT;
blocks[2] = FELICA_BLOCK_INDEX_MAC_A;
FelicaPollerReadCommandResponse* rx_resp;
error = felica_poller_read_blocks(instance, sizeof(blocks), blocks, &rx_resp);
error = felica_poller_read_blocks(
instance, sizeof(blocks), blocks, FELICA_SERVICE_RO_ACCESS, &rx_resp);
if(error != FelicaErrorNone || rx_resp->SF1 != 0 || rx_resp->SF2 != 0) break;
if(felica_check_mac(
@@ -174,7 +175,7 @@ NfcCommand felica_poller_state_handler_auth_external(FelicaPoller* instance) {
if(error != FelicaErrorNone || tx_resp->SF1 != 0 || tx_resp->SF2 != 0) break;
FelicaPollerReadCommandResponse* rx_resp;
error = felica_poller_read_blocks(instance, 1, blocks, &rx_resp);
error = felica_poller_read_blocks(instance, 1, blocks, FELICA_SERVICE_RO_ACCESS, &rx_resp);
if(error != FelicaErrorNone || rx_resp->SF1 != 0 || rx_resp->SF2 != 0) break;
instance->data->data.fs.state.SF1 = 0;
@@ -203,7 +204,8 @@ NfcCommand felica_poller_state_handler_read_blocks(FelicaPoller* instance) {
}
FelicaPollerReadCommandResponse* response;
FelicaError error = felica_poller_read_blocks(instance, block_count, block_list, &response);
FelicaError error = felica_poller_read_blocks(
instance, block_count, block_list, FELICA_SERVICE_RO_ACCESS, &response);
if(error == FelicaErrorNone) {
block_count = (response->SF1 == 0) ? response->block_count : block_count;
uint8_t* data_ptr =

View File

@@ -56,6 +56,23 @@ typedef struct {
*/
FelicaError felica_poller_activate(FelicaPoller* instance, FelicaData* data);
/**
* @brief Performs felica read operation for blocks provided as parameters
*
* @param[in, out] instance pointer to the instance to be used in the transaction.
* @param[in] block_count Amount of blocks involved in reading procedure
* @param[in] block_numbers Array with block indexes according to felica docs
* @param[in] service_code Service code for the read operation
* @param[out] response_ptr Pointer to the response structure
* @return FelicaErrorNone on success, an error code on failure.
*/
FelicaError felica_poller_read_blocks(
FelicaPoller* instance,
const uint8_t block_count,
const uint8_t* const block_numbers,
uint16_t service_code,
FelicaPollerReadCommandResponse** const response_ptr);
#ifdef __cplusplus
}
#endif

View File

@@ -134,6 +134,7 @@ FelicaError felica_poller_read_blocks(
FelicaPoller* instance,
const uint8_t block_count,
const uint8_t* const block_numbers,
uint16_t service_code,
FelicaPollerReadCommandResponse** const response_ptr) {
furi_assert(instance);
furi_assert(block_count <= 4);
@@ -143,7 +144,7 @@ FelicaError felica_poller_read_blocks(
felica_poller_prepare_tx_buffer(
instance,
FELICA_CMD_READ_WITHOUT_ENCRYPTION,
FELICA_SERVICE_RO_ACCESS,
service_code,
block_count,
block_numbers,
0,

View File

@@ -70,21 +70,6 @@ FelicaError felica_poller_polling(
const FelicaPollerPollingCommand* cmd,
FelicaPollerPollingResponse* resp);
/**
* @brief Performs felica read operation for blocks provided as parameters
*
* @param[in, out] instance pointer to the instance to be used in the transaction.
* @param[in] block_count Amount of blocks involved in reading procedure
* @param[in] block_numbers Array with block indexes according to felica docs
* @param[out] response_ptr Pointer to the response structure
* @return FelicaErrorNone on success, an error code on failure.
*/
FelicaError felica_poller_read_blocks(
FelicaPoller* instance,
const uint8_t block_count,
const uint8_t* const block_numbers,
FelicaPollerReadCommandResponse** const response_ptr);
/**
* @brief Performs felica write operation with data provided as parameters
*