Skip to content

Instantly share code, notes, and snippets.

@9SQ 9SQ/RCS620mod.cpp
Created Jul 3, 2015

Embed
What would you like to do?
RC-S620/SでTargetとして動作させる(特定のカードをエミュレート)
// 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);
}
// add under "int initDevice(void);"
void tgInitTarget(const uint8_t* idm, const uint8_t* pmm, const uint8_t* rfu);
#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
You can’t perform that action at this time.