mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-07-23 01:18:12 -07:00
Merge branch 'dev' of https://github.com/DarkFlippers/unleashed-firmware into xfw-dev
This commit is contained in:
@@ -8,13 +8,13 @@ typedef enum {
|
||||
LFRFIDEventStopMode = (1 << 1),
|
||||
LFRFIDEventRead = (1 << 2),
|
||||
LFRFIDEventWrite = (1 << 3),
|
||||
LFRFIDEventWriteWithPass = (1 << 4),
|
||||
LFRFIDEventWriteAndSetPass = (1 << 4),
|
||||
LFRFIDEventEmulate = (1 << 5),
|
||||
LFRFIDEventReadRaw = (1 << 6),
|
||||
LFRFIDEventEmulateRaw = (1 << 7),
|
||||
LFRFIDEventAll =
|
||||
(LFRFIDEventStopThread | LFRFIDEventStopMode | LFRFIDEventRead | LFRFIDEventWrite |
|
||||
LFRFIDEventWriteWithPass | LFRFIDEventEmulate | LFRFIDEventReadRaw |
|
||||
LFRFIDEventWriteAndSetPass | LFRFIDEventEmulate | LFRFIDEventReadRaw |
|
||||
LFRFIDEventEmulateRaw),
|
||||
} LFRFIDEventType;
|
||||
|
||||
@@ -71,7 +71,7 @@ void lfrfid_worker_write_start(
|
||||
furi_thread_flags_set(furi_thread_get_id(worker->thread), LFRFIDEventWrite);
|
||||
}
|
||||
|
||||
void lfrfid_worker_write_with_pass_start(
|
||||
void lfrfid_worker_write_and_set_pass_start(
|
||||
LFRFIDWorker* worker,
|
||||
LFRFIDProtocol protocol,
|
||||
LFRFIDWorkerWriteCallback callback,
|
||||
@@ -80,7 +80,7 @@ void lfrfid_worker_write_with_pass_start(
|
||||
worker->protocol = protocol;
|
||||
worker->write_cb = callback;
|
||||
worker->cb_ctx = context;
|
||||
furi_thread_flags_set(furi_thread_get_id(worker->thread), LFRFIDEventWriteWithPass);
|
||||
furi_thread_flags_set(furi_thread_get_id(worker->thread), LFRFIDEventWriteAndSetPass);
|
||||
}
|
||||
|
||||
void lfrfid_worker_emulate_start(LFRFIDWorker* worker, LFRFIDProtocol protocol) {
|
||||
@@ -159,7 +159,8 @@ static int32_t lfrfid_worker_thread(void* thread_context) {
|
||||
// switch mode
|
||||
if(flags & LFRFIDEventRead) worker->mode_index = LFRFIDWorkerRead;
|
||||
if(flags & LFRFIDEventWrite) worker->mode_index = LFRFIDWorkerWrite;
|
||||
if(flags & LFRFIDEventWriteWithPass) worker->mode_index = LFRFIDWorkerWriteWithPass;
|
||||
if(flags & LFRFIDEventWriteAndSetPass)
|
||||
worker->mode_index = LFRFIDWorkerWriteAndSetPass;
|
||||
if(flags & LFRFIDEventEmulate) worker->mode_index = LFRFIDWorkerEmulate;
|
||||
if(flags & LFRFIDEventReadRaw) worker->mode_index = LFRFIDWorkerReadRaw;
|
||||
if(flags & LFRFIDEventEmulateRaw) worker->mode_index = LFRFIDWorkerEmulateRaw;
|
||||
|
||||
@@ -107,14 +107,14 @@ void lfrfid_worker_write_start(
|
||||
void* context);
|
||||
|
||||
/**
|
||||
* @brief Start write with pass mode
|
||||
* @brief Start write and set pass mode
|
||||
*
|
||||
* @param worker
|
||||
* @param protocol
|
||||
* @param callback
|
||||
* @param context
|
||||
*/
|
||||
void lfrfid_worker_write_with_pass_start(
|
||||
void lfrfid_worker_write_and_set_pass_start(
|
||||
LFRFIDWorker* worker,
|
||||
LFRFIDProtocol protocol,
|
||||
LFRFIDWorkerWriteCallback callback,
|
||||
|
||||
@@ -22,7 +22,7 @@ typedef enum {
|
||||
LFRFIDWorkerIdle,
|
||||
LFRFIDWorkerRead,
|
||||
LFRFIDWorkerWrite,
|
||||
LFRFIDWorkerWriteWithPass,
|
||||
LFRFIDWorkerWriteAndSetPass,
|
||||
LFRFIDWorkerEmulate,
|
||||
LFRFIDWorkerReadRaw,
|
||||
LFRFIDWorkerEmulateRaw,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include "lfrfid/lfrfid_i.h"
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
#include "lfrfid_worker_i.h"
|
||||
@@ -48,6 +49,15 @@ void lfrfid_worker_delay(LFRFIDWorker* worker, uint32_t milliseconds) {
|
||||
}
|
||||
}
|
||||
|
||||
void t5577_trace(LFRFIDT5577 t5577, const char* message) {
|
||||
if(furi_log_get_level() == FuriLogLevelTrace) {
|
||||
FURI_LOG_T(TAG, "%s", message);
|
||||
for(uint8_t i = 0; i < 8; i++) FURI_LOG_T(TAG, "\nBlock %u %08lX", i, t5577.block[i]);
|
||||
FURI_LOG_T(TAG, "Mask: %u", t5577.mask);
|
||||
FURI_LOG_T(TAG, "Blocks to write: %lu", t5577.blocks_to_write);
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************************************/
|
||||
/********************************************** READ **********************************************/
|
||||
/**************************************************************************************************/
|
||||
@@ -574,7 +584,7 @@ static void lfrfid_worker_mode_write_process(LFRFIDWorker* worker) {
|
||||
free(read_data);
|
||||
}
|
||||
|
||||
static void lfrfid_worker_mode_write_with_pass_process(LFRFIDWorker* worker) {
|
||||
static void lfrfid_worker_mode_write_and_set_pass_process(LFRFIDWorker* worker) {
|
||||
LFRFIDProtocol protocol = worker->protocol;
|
||||
LFRFIDWriteRequest* request = malloc(sizeof(LFRFIDWriteRequest));
|
||||
request->write_type = LFRFIDWriteTypeT5577;
|
||||
@@ -592,18 +602,22 @@ static void lfrfid_worker_mode_write_with_pass_process(LFRFIDWorker* worker) {
|
||||
|
||||
if(can_be_written) {
|
||||
while(!lfrfid_worker_check_for_stop(worker)) {
|
||||
FURI_LOG_D(TAG, "Data write");
|
||||
FURI_LOG_D(TAG, "Data write with pass");
|
||||
|
||||
uint8_t size;
|
||||
const uint32_t* password_list = t5577_get_default_passwords(&size);
|
||||
LfRfid* app = worker->cb_ctx;
|
||||
uint32_t pass = (app->password[0] << 24) | (app->password[1] << 16) |
|
||||
(app->password[2] << 8) | (app->password[3]);
|
||||
|
||||
uint32_t pass = password_list[rand() % size];
|
||||
request->t5577.mask = 0b10000001;
|
||||
for(uint8_t i = 0; i < request->t5577.blocks_to_write; i++)
|
||||
request->t5577.mask |= (1 << i);
|
||||
|
||||
request->t5577.mask = 0b1111111;
|
||||
request->t5577.block[0] |= 0b10000;
|
||||
request->t5577.block[0] |= (1 << 4);
|
||||
request->t5577.block[7] = pass;
|
||||
|
||||
t5577_write_with_mask(&request->t5577, 0, 0);
|
||||
t5577_trace(request->t5577, "Write with password");
|
||||
|
||||
t5577_write_with_mask(&request->t5577, 0, true, 0);
|
||||
|
||||
ProtocolId read_result = PROTOCOL_NO;
|
||||
LFRFIDWorkerReadState state = lfrfid_worker_read_internal(
|
||||
@@ -719,7 +733,7 @@ const LFRFIDWorkerModeType lfrfid_worker_modes[] = {
|
||||
[LFRFIDWorkerIdle] = {.process = NULL},
|
||||
[LFRFIDWorkerRead] = {.process = lfrfid_worker_mode_read_process},
|
||||
[LFRFIDWorkerWrite] = {.process = lfrfid_worker_mode_write_process},
|
||||
[LFRFIDWorkerWriteWithPass] = {.process = lfrfid_worker_mode_write_with_pass_process},
|
||||
[LFRFIDWorkerWriteAndSetPass] = {.process = lfrfid_worker_mode_write_and_set_pass_process},
|
||||
[LFRFIDWorkerEmulate] = {.process = lfrfid_worker_mode_emulate_process},
|
||||
[LFRFIDWorkerReadRaw] = {.process = lfrfid_worker_mode_read_raw_process},
|
||||
[LFRFIDWorkerEmulateRaw] = {.process = lfrfid_worker_mode_emulate_raw_process},
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "t5577.h"
|
||||
#include <furi.h>
|
||||
#include <furi_hal_rfid.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#define T5577_TIMING_WAIT_TIME 400
|
||||
#define T5577_TIMING_START_GAP 30
|
||||
@@ -16,30 +17,6 @@
|
||||
#define T5577_BLOCKS_IN_PAGE_0 8
|
||||
#define T5577_BLOCKS_IN_PAGE_1 4
|
||||
|
||||
//TODO: use .txt file in resources for passwords.
|
||||
const uint32_t default_passwords[] = {
|
||||
0x51243648, 0x000D8787, 0x19920427, 0x50524F58, 0xF9DCEBA0, 0x65857569, 0x05D73B9F, 0x89A69E60,
|
||||
0x314159E0, 0xAA55BBBB, 0xA5B4C3D2, 0x1C0B5848, 0x00434343, 0x444E4752, 0x4E457854, 0x44B44CAE,
|
||||
0x88661858, 0xE9920427, 0x575F4F4B, 0x50520901, 0x20206666, 0x65857569, 0x5469616E, 0x7686962A,
|
||||
0xC0F5009A, 0x07CEE75D, 0xfeedbeef, 0xdeadc0de, 0x00000000, 0x11111111, 0x22222222, 0x33333333,
|
||||
0x44444444, 0x55555555, 0x66666666, 0x77777777, 0x88888888, 0x99999999, 0xAAAAAAAA, 0xBBBBBBBB,
|
||||
0xCCCCCCCC, 0xDDDDDDDD, 0xEEEEEEEE, 0xFFFFFFFF, 0xa0a1a2a3, 0xb0b1b2b3, 0x50415353, 0x00000001,
|
||||
0x00000002, 0x0000000a, 0x0000000b, 0x01020304, 0x02030405, 0x03040506, 0x04050607, 0x05060708,
|
||||
0x06070809, 0x0708090A, 0x08090A0B, 0x090A0B0C, 0x0A0B0C0D, 0x0B0C0D0E, 0x0C0D0E0F, 0x01234567,
|
||||
0x12345678, 0x10000000, 0x20000000, 0x30000000, 0x40000000, 0x50000000, 0x60000000, 0x70000000,
|
||||
0x80000000, 0x90000000, 0xA0000000, 0xB0000000, 0xC0000000, 0xD0000000, 0xE0000000, 0xF0000000,
|
||||
0x10101010, 0x01010101, 0x11223344, 0x22334455, 0x33445566, 0x44556677, 0x55667788, 0x66778899,
|
||||
0x778899AA, 0x8899AABB, 0x99AABBCC, 0xAABBCCDD, 0xBBCCDDEE, 0xCCDDEEFF, 0x0CB7E7FC, 0xFABADA11,
|
||||
0x87654321, 0x12341234, 0x69696969, 0x12121212, 0x12344321, 0x1234ABCD, 0x11112222, 0x13131313,
|
||||
0x10041004, 0x31415926, 0xabcd1234, 0x20002000, 0x19721972, 0xaa55aa55, 0x55aa55aa, 0x4f271149,
|
||||
0x07d7bb0b, 0x9636ef8f, 0xb5f44686, 0x9E3779B9, 0xC6EF3720, 0x7854794A, 0xF1EA5EED, 0x69314718,
|
||||
0x57721566, 0x93C467E3, 0x27182818, 0x50415353};
|
||||
|
||||
const uint32_t* t5577_get_default_passwords(uint8_t* len) {
|
||||
*len = sizeof(default_passwords) / sizeof(uint32_t);
|
||||
return default_passwords;
|
||||
}
|
||||
|
||||
static void t5577_start() {
|
||||
furi_hal_rfid_tim_read_start(125000, 0.5);
|
||||
|
||||
@@ -145,7 +122,7 @@ void t5577_write_with_pass(LFRFIDT5577* data, uint32_t password) {
|
||||
t5577_stop();
|
||||
}
|
||||
|
||||
void t5577_write_with_mask(LFRFIDT5577* data, uint8_t page, uint32_t password) {
|
||||
void t5577_write_with_mask(LFRFIDT5577* data, uint8_t page, bool with_pass, uint32_t password) {
|
||||
t5577_start();
|
||||
FURI_CRITICAL_ENTER();
|
||||
|
||||
@@ -157,7 +134,7 @@ void t5577_write_with_mask(LFRFIDT5577* data, uint8_t page, uint32_t password) {
|
||||
bool need_to_write = mask & 1;
|
||||
mask >>= 1;
|
||||
if(!need_to_write) continue;
|
||||
t5577_write_block_pass(page, i, false, data->block[i], true, password);
|
||||
t5577_write_block_pass(page, i, false, data->block[i], with_pass, password);
|
||||
}
|
||||
t5577_write_reset();
|
||||
FURI_CRITICAL_EXIT();
|
||||
|
||||
@@ -45,8 +45,6 @@ typedef struct {
|
||||
uint8_t mask;
|
||||
} LFRFIDT5577;
|
||||
|
||||
const uint32_t* t5577_get_default_passwords(uint8_t* len);
|
||||
|
||||
/**
|
||||
* @brief Write T5577 tag data to tag
|
||||
*
|
||||
@@ -56,7 +54,7 @@ void t5577_write(LFRFIDT5577* data);
|
||||
|
||||
void t5577_write_with_pass(LFRFIDT5577* data, uint32_t password);
|
||||
|
||||
void t5577_write_with_mask(LFRFIDT5577* data, uint8_t page, uint32_t password);
|
||||
void t5577_write_with_mask(LFRFIDT5577* data, uint8_t page, bool with_pass, uint32_t password);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user