I am using an ACS ACR1283L device to read/write to MIFARE PLUS S cards. I can successfully connect and get the card UID
Code to connect
void multithread:: CardConnect(QString s)
{
LONG lReturn;
DWORD dwAP;
lReturn = SCardConnect(hSC,
reinterpret_cast<LPCTSTR>(s.unicode()),
SCARD_SHARE_SHARED,
SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1,
&hCardHandle,
&dwAP);
if(SCARD_S_SUCCESS != lReturn)
{
std::cout << "Failed SCardConnect\n";
}
else
{
return Status = true;
// Use the connection.
// Display the active protocol.
switch (dwAP)
{
case SCARD_PROTOCOL_T0:
std::cout << "Active protocol T0\n";
break;
case SCARD_PROTOCOL_T1:
std::cout << "Active protocol T1\n";
break;
case SCARD_PROTOCOL_UNDEFINED:
std::cout << "Active protocol is undefined\n";
break;
default:
std::cout << "Active protocol unnegotiated or unknown\n";
break;
}
}
}
Code to get the card uid
void multithread::CardTransmit()
{
BYTE pbRecv[258];
BYTE pbSend[] = {0xFF, 0xCA, 0x00, 0x00, 0x00};
DWORD dwSend,dwRecv;
dwSend = sizeof(pbSend);
dwRecv = sizeof(pbRecv);
LONG lReturn = SCardTransmit(hCardHandle,
SCARD_PCI_T1,
pbSend,
dwSend,
nullptr,
pbRecv,
&dwRecv);
if(SCARD_S_SUCCESS != lReturn)
{
qDebug() << "Failed SCardTransmit";
}
else
{
QByteArray qdb = QByteArray(reinterpret_cast<char*>(pbRecv));
qdb.chop(1);
cardUID = QString(qdb.toHex());
qDebug() << "Card uid: "<< cardUID;
}
}
At this point I authenticate the card.
Code to authenticate
bool multithread::CardAuthenticate(int blockNo)
{
// Authenticate the card
BYTE authCmd[] = {0x60, 0xC2, 0x00, 0xFF, 0x00, 0x00, 0x05, 0x10, 0x00, 0x00, 0x00};
BYTE key[6] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66}; // Replace with actual key
BYTE response[256];
DWORD responseLen = sizeof(response);
LONG lReturn = SCardTransmit(hCardHandle, SCARD_PCI_T1, authCmd, sizeof(authCmd), NULL, response, &responseLen);
if(SCARD_S_SUCCESS != lReturn)
{
qDebug() << "Failed SCardTransmit\n";
return false;
}
else
{
qDebug() << "Success Authentication";
return true;
}
}
I get "Success Authentication" but after that I am not able to write any data to the card and I don't understand why. I read in internet that if I switch from SLO to SL1 then I can treat the card as if it were a MIFARE classic instead of MIFARE PLUS S. Unfortunately my experience on this is too poor and I am unable to do. I would have some help in switch from SL0 to SL1 and write a basic data