Created
July 3, 2015 18:20
-
-
Save 9SQ/7a30432e671935788f5c to your computer and use it in GitHub Desktop.
RC-S620/SでTargetとして動作させる(特定のカードをエミュレート)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// add under "int RCS620S::initDevice(void){...}" | |
void RCS620S::tgInitTarget(const uint8_t* idm, const uint8_t* pmm, const uint8_t* rfu) | |
{ | |
uint8_t response[RCS620S_MAX_RW_RESPONSE_LEN]; | |
uint16_t responseLen; | |
uint8_t command[RCS620S_MAX_RW_RESPONSE_LEN] = {0x00}; | |
uint8_t start[2] = {0xd4, 0x8c}; // command code & sub command code | |
uint8_t activated[1] = {0x02}; // Activated limit | |
uint8_t params106[6] = {0x00, 0x04, 0x00, 0x00, 0x00, 0x40}; // 106kbpsParams(6byte) | |
memcpy(&command[ 0], start, 2); | |
memcpy(&command[ 2], activated, 1); | |
memcpy(&command[ 3], params106, 6); | |
memcpy(&command[ 9], idm, 8); // NFCID2t(IDm) | |
memcpy(&command[17], pmm, 8); // PAD(PMm) | |
memcpy(&command[25], rfu, 2); // RFU(System Code) | |
memcpy(&command[27], idm, 8); // NFCID3t(IDm) | |
rwCommand(command, 37, response, &responseLen); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// add under "int initDevice(void);" | |
void tgInitTarget(const uint8_t* idm, const uint8_t* pmm, const uint8_t* rfu); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "RCS620Smod.h" | |
#include <inttypes.h> | |
#define COMMAND_TIMEOUT 400 | |
RCS620S rcs620s; | |
void setup() | |
{ | |
int ret; | |
Serial.begin(115200); | |
ret = rcs620s.initDevice(); | |
while (!ret) {} | |
} | |
void loop(){ | |
rcs620s.tgInitTarget((const uint8_t*)"\x01\x02\x03\x04\x05\x06\x07\x08", // IDm | |
(const uint8_t*)"\x01\x02\x03\x04\x05\x06\x07\x08", // PMm | |
(const uint8_t*)"\x01\x02"); // System Code | |
rcs620s.rfOff(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment