|
|
@@ -3,7 +3,7 @@
|
|
|
#include "bit_buffer.h"
|
|
|
#include "protocols/gen4/gen4_poller.h"
|
|
|
#include <nfc/protocols/iso14443_3a/iso14443_3a_poller.h>
|
|
|
-#include <nfc/helpers/nfc_util.h>
|
|
|
+#include <bit_lib.h>
|
|
|
|
|
|
#define GEN4_CMD_PREFIX (0xCF)
|
|
|
|
|
|
@@ -44,7 +44,7 @@ Gen4PollerError gen4_poller_set_shadow_mode(
|
|
|
|
|
|
do {
|
|
|
uint8_t password_arr[4] = {};
|
|
|
- nfc_util_num2bytes(password, COUNT_OF(password_arr), password_arr);
|
|
|
+ bit_lib_num_to_bytes_be(password, COUNT_OF(password_arr), password_arr);
|
|
|
bit_buffer_append_byte(instance->tx_buffer, GEN4_CMD_PREFIX);
|
|
|
bit_buffer_append_bytes(instance->tx_buffer, password_arr, COUNT_OF(password_arr));
|
|
|
bit_buffer_append_byte(instance->tx_buffer, GEN4_CMD_SET_SHD_MODE);
|
|
|
@@ -58,7 +58,7 @@ Gen4PollerError gen4_poller_set_shadow_mode(
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- uint16_t response = bit_buffer_get_size_bytes(instance->rx_buffer);
|
|
|
+ size_t response = bit_buffer_get_size_bytes(instance->rx_buffer);
|
|
|
|
|
|
FURI_LOG_D(TAG, "Card response: 0x%02X, Shadow mode set: 0x%02X", response, mode);
|
|
|
|
|
|
@@ -81,7 +81,7 @@ Gen4PollerError gen4_poller_set_direct_write_block_0_mode(
|
|
|
|
|
|
do {
|
|
|
uint8_t password_arr[4] = {};
|
|
|
- nfc_util_num2bytes(password, COUNT_OF(password_arr), password_arr);
|
|
|
+ bit_lib_num_to_bytes_be(password, COUNT_OF(password_arr), password_arr);
|
|
|
bit_buffer_append_byte(instance->tx_buffer, GEN4_CMD_PREFIX);
|
|
|
bit_buffer_append_bytes(instance->tx_buffer, password_arr, COUNT_OF(password_arr));
|
|
|
bit_buffer_append_byte(instance->tx_buffer, GEN4_CMD_SET_DW_BLOCK_0);
|
|
|
@@ -94,7 +94,7 @@ Gen4PollerError gen4_poller_set_direct_write_block_0_mode(
|
|
|
ret = gen4_poller_process_error(error);
|
|
|
break;
|
|
|
}
|
|
|
- uint16_t response = bit_buffer_get_size_bytes(instance->rx_buffer);
|
|
|
+ size_t response = bit_buffer_get_size_bytes(instance->rx_buffer);
|
|
|
|
|
|
FURI_LOG_D(
|
|
|
TAG, "Card response: 0x%02X, Direct write to block 0 mode set: 0x%02X", response, mode);
|
|
|
@@ -116,7 +116,7 @@ Gen4PollerError
|
|
|
|
|
|
do {
|
|
|
uint8_t password_arr[4] = {};
|
|
|
- nfc_util_num2bytes(password, COUNT_OF(password_arr), password_arr);
|
|
|
+ bit_lib_num_to_bytes_be(password, COUNT_OF(password_arr), password_arr);
|
|
|
bit_buffer_append_byte(instance->tx_buffer, GEN4_CMD_PREFIX);
|
|
|
bit_buffer_append_bytes(instance->tx_buffer, password_arr, COUNT_OF(password_arr));
|
|
|
bit_buffer_append_byte(instance->tx_buffer, GEN4_CMD_GET_CFG);
|
|
|
@@ -131,7 +131,7 @@ Gen4PollerError
|
|
|
|
|
|
size_t rx_bytes = bit_buffer_get_size_bytes(instance->rx_buffer);
|
|
|
|
|
|
- if(rx_bytes != CONFIG_SIZE_MAX || rx_bytes != CONFIG_SIZE_MIN) {
|
|
|
+ if((rx_bytes != CONFIG_SIZE_MAX) && (rx_bytes != CONFIG_SIZE_MIN)) {
|
|
|
ret = Gen4PollerErrorProtocol;
|
|
|
break;
|
|
|
}
|
|
|
@@ -148,7 +148,7 @@ Gen4PollerError
|
|
|
|
|
|
do {
|
|
|
uint8_t password_arr[4] = {};
|
|
|
- nfc_util_num2bytes(password, COUNT_OF(password_arr), password_arr);
|
|
|
+ bit_lib_num_to_bytes_be(password, COUNT_OF(password_arr), password_arr);
|
|
|
bit_buffer_append_byte(instance->tx_buffer, GEN4_CMD_PREFIX);
|
|
|
bit_buffer_append_bytes(instance->tx_buffer, password_arr, COUNT_OF(password_arr));
|
|
|
bit_buffer_append_byte(instance->tx_buffer, GEN4_CMD_GET_REVISION);
|
|
|
@@ -183,7 +183,7 @@ Gen4PollerError gen4_poller_set_config(
|
|
|
|
|
|
do {
|
|
|
uint8_t password_arr[4] = {};
|
|
|
- nfc_util_num2bytes(password, COUNT_OF(password_arr), password_arr);
|
|
|
+ bit_lib_num_to_bytes_be(password, COUNT_OF(password_arr), password_arr);
|
|
|
bit_buffer_append_byte(instance->tx_buffer, GEN4_CMD_PREFIX);
|
|
|
bit_buffer_append_bytes(instance->tx_buffer, password_arr, COUNT_OF(password_arr));
|
|
|
uint8_t fuse_config = fuse ? GEN4_CMD_FUSE_CFG : GEN4_CMD_SET_CFG;
|
|
|
@@ -198,7 +198,7 @@ Gen4PollerError gen4_poller_set_config(
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- uint16_t response = bit_buffer_get_size_bytes(instance->rx_buffer);
|
|
|
+ size_t response = bit_buffer_get_size_bytes(instance->rx_buffer);
|
|
|
|
|
|
FURI_LOG_D(TAG, "Card response to set default config command: 0x%02X", response);
|
|
|
|
|
|
@@ -221,7 +221,7 @@ Gen4PollerError gen4_poller_write_block(
|
|
|
|
|
|
do {
|
|
|
uint8_t password_arr[4] = {};
|
|
|
- nfc_util_num2bytes(password, COUNT_OF(password_arr), password_arr);
|
|
|
+ bit_lib_num_to_bytes_be(password, COUNT_OF(password_arr), password_arr);
|
|
|
bit_buffer_append_byte(instance->tx_buffer, GEN4_CMD_PREFIX);
|
|
|
bit_buffer_append_bytes(instance->tx_buffer, password_arr, COUNT_OF(password_arr));
|
|
|
bit_buffer_append_byte(instance->tx_buffer, GEN4_CMD_WRITE);
|
|
|
@@ -253,12 +253,12 @@ Gen4PollerError
|
|
|
|
|
|
do {
|
|
|
uint8_t password_arr[4] = {};
|
|
|
- nfc_util_num2bytes(pwd_current, COUNT_OF(password_arr), password_arr);
|
|
|
+ bit_lib_num_to_bytes_be(pwd_current, COUNT_OF(password_arr), password_arr);
|
|
|
bit_buffer_append_byte(instance->tx_buffer, GEN4_CMD_PREFIX);
|
|
|
bit_buffer_append_bytes(instance->tx_buffer, password_arr, COUNT_OF(password_arr));
|
|
|
|
|
|
bit_buffer_append_byte(instance->tx_buffer, GEN4_CMD_SET_PWD);
|
|
|
- nfc_util_num2bytes(pwd_new, COUNT_OF(password_arr), password_arr);
|
|
|
+ bit_lib_num_to_bytes_be(pwd_new, COUNT_OF(password_arr), password_arr);
|
|
|
bit_buffer_append_bytes(instance->tx_buffer, password_arr, COUNT_OF(password_arr));
|
|
|
|
|
|
Iso14443_3aError error = iso14443_3a_poller_send_standard_frame(
|
|
|
@@ -269,7 +269,7 @@ Gen4PollerError
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- uint16_t response = bit_buffer_get_size_bytes(instance->rx_buffer);
|
|
|
+ size_t response = bit_buffer_get_size_bytes(instance->rx_buffer);
|
|
|
|
|
|
FURI_LOG_D(
|
|
|
TAG,
|