easyhack/easytool/easycard.h

48 lines
1.3 KiB
C

#ifndef EASYCARD_H
#define EASYCARD_H
#include "utils.h"
#define EASY_TT_MRT_ENTER 0x00
#define EASY_TT_MRT_REENTER 0x80
#define EASY_TT_MRT_EXIT 0x11
#define EASY_TT_PURCHASE 0x20
extern const struct value_string easy_tt_names[];
extern const struct value_string taipei_mrt_stn_id[];
/* Sector 0 of Block 2 seems to contain manufacturing timestamp */
struct easy_block2sec0 {
uint8_t unknown[6];
uint8_t timestamp[3];
uint8_t unknown2[7];
} __attribute__ ((packed));
/* Sector 2 of Block 15 */
struct easy_block15sec2 {
uint8_t unknown[11];
uint8_t day_of_month;
uint8_t unknown2; /* always 0x3d? */
uint16_t sum_of_day; /* sum of all shop purchases on a day */
uint8_t unknown3;
} __attribute__ ((packed));
/* storage of a transaction log record on the transponder itself */
struct easy_log_rec {
uint8_t trans_id;
uint8_t unknown;
uint8_t timestamp[3]; /* seconds since January 1st 1970 / 256 */
uint8_t trans_type;
uint16_t amount; /* transaction amount / value */
uint16_t remaining; /* remaining value on card _after_ trans */
uint8_t unknown2;
uint8_t station_code; /* MRT station code */
uint16_t reader_code; /* unique code of RFID reader */
uint8_t unknown3[2];
} __attribute__ ((packed));
time_t easy_timestamp2time(const uint8_t *easy_ts);
#endif /* EASYCARD_H */