Przeglądaj źródła

Update to bit_lib

Willy-JL 1 rok temu
rodzic
commit
8561f6b9aa

+ 2 - 2
nfc_magic/lib/magic/protocols/gen4/gen4_poller.c

@@ -89,7 +89,7 @@ NfcCommand gen4_poller_detect_callback(NfcGenericEvent event, void* context) {
         do {
             bit_buffer_append_byte(gen4_poller_detect_ctx->tx_buffer, GEN4_CMD_PREFIX);
             uint8_t pwd_arr[4] = {};
-            nfc_util_num2bytes(gen4_poller_detect_ctx->password, COUNT_OF(pwd_arr), pwd_arr);
+            bit_lib_num_to_bytes_be(gen4_poller_detect_ctx->password, COUNT_OF(pwd_arr), pwd_arr);
             bit_buffer_append_bytes(gen4_poller_detect_ctx->tx_buffer, pwd_arr, COUNT_OF(pwd_arr));
             bit_buffer_append_byte(gen4_poller_detect_ctx->tx_buffer, GEN4_CMD_GET_CFG);
 
@@ -434,7 +434,7 @@ NfcCommand gen4_poller_write_handler(Gen4Poller* instance) {
 
     memcpy(instance->config, gen4_poller_default_config, sizeof(gen4_poller_default_config));
     uint8_t password_arr[4] = {};
-    nfc_util_num2bytes(instance->password, sizeof(password_arr), password_arr);
+    bit_lib_num_to_bytes_be(instance->password, sizeof(password_arr), password_arr);
     memcpy(&instance->config[2], password_arr, sizeof(password_arr));
     memset(&instance->config[7], 0, 17);
     if(instance->protocol == NfcProtocolMfClassic) {

+ 8 - 8
nfc_magic/lib/magic/protocols/gen4/gen4_poller_i.c

@@ -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);
@@ -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);
@@ -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);
@@ -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;
@@ -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(

+ 2 - 2
nfc_magic/scenes/nfc_magic_scene_key_input.c

@@ -32,11 +32,11 @@ bool nfc_magic_scene_key_input_on_event(void* context, SceneManagerEvent event)
     if(event.type == SceneManagerEventTypeCustom) {
         if(event.event == NfcMagicAppCustomEventByteInputDone) {
             if(scene_manager_has_previous_scene(instance->scene_manager, NfcMagicSceneGen4Menu)) {
-                instance->gen4_password_new = nfc_util_bytes2num(
+                instance->gen4_password_new = bit_lib_bytes_to_num_be(
                     instance->byte_input_store, NFC_MAGIC_APP_BYTE_INPUT_STORE_SIZE);
                 scene_manager_next_scene(instance->scene_manager, NfcMagicSceneChangeKey);
             } else {
-                instance->gen4_password = nfc_util_bytes2num(
+                instance->gen4_password = bit_lib_bytes_to_num_be(
                     instance->byte_input_store, NFC_MAGIC_APP_BYTE_INPUT_STORE_SIZE);
                 scene_manager_next_scene(instance->scene_manager, NfcMagicSceneCheck);
             }