Modified ISO15692-A.h CompareUid, temporary fix to Sl2s2002.c and Vicinity.c

This commit is contained in:
Federico Cerutti
2018-11-10 18:51:19 +01:00
committed by Thorsten
parent db9dc8efd8
commit 10ad3cb491
4 changed files with 42 additions and 35 deletions
@@ -95,20 +95,8 @@ void ISO15693CopyUid(uint8_t* DstUid, uint8_t* SrcUid)
}
INLINE
bool ISO15693Addressed(uint8_t* Buffer, uint8_t* MyUid) {
if (Buffer[0] & ISO15693_REQ_FLAG_ADDRESS) {
/* Addressed mode */
if ( ISO15693CompareUid(&Buffer[2], MyUid) ) {
/* Our UID addressed */
return true;
} else {
/* Our UID not addressed */
return false;
}
} else {
/* Non-Addressed mode */
return true;
}
bool ISO15693Addressed(uint8_t* Buffer) {
return (Buffer[0] & ISO15693_REQ_FLAG_ADDRESS); /* if the flag is set, the command is addressed */
}
// (FrameBuf[0] & ISO15693_REQ_FLAG_ADDRESS) && ISO15693CompareUid(&FrameBuf[2], Uid)
+12 -6
View File
@@ -62,11 +62,13 @@ uint16_t Sl2s2002AppProcess(uint8_t* FrameBuf, uint16_t FrameBytes)
ISO15693CopyUid(&FrameBuf[2], Uid);
ResponseByteCount = 10;
} else if (Command == ISO15693_CMD_STAY_QUIET) {
if (ISO15693Addressed(FrameBuf, Uid)) {
/* TODO: check for unaddressed requests */
if (ISO15693Addressed(FrameBuf) && ISO15693CompareUid(&FrameBuf[2], Uid)) {
State = STATE_QUIET;
}
} else if (Command == ISO15693_CMD_GET_SYS_INFO) {
if (ISO15693Addressed(FrameBuf, Uid)) {
/* TODO: check for unaddressed requests */
if (ISO15693Addressed(FrameBuf) && ISO15693CompareUid(&FrameBuf[2], Uid)) {
FrameBuf[0] = 0; /* Flags */
FrameBuf[1] = 0x0F; /* InfoFlags */
ISO15693CopyUid(&FrameBuf[2], Uid);
@@ -78,7 +80,8 @@ uint16_t Sl2s2002AppProcess(uint8_t* FrameBuf, uint16_t FrameBytes)
ResponseByteCount = 15;
}
} else if (Command == ISO15693_CMD_READ_SINGLE) {
if (ISO15693Addressed(FrameBuf, Uid)) {
/* TODO: check for unaddressed requests */
if (ISO15693Addressed(FrameBuf) && ISO15693CompareUid(&FrameBuf[2], Uid)) {
uint8_t PageAddress = FrameBuf[10];
if (FrameBuf[0] & ISO15693_REQ_FLAG_OPTION)
{
@@ -93,7 +96,8 @@ uint16_t Sl2s2002AppProcess(uint8_t* FrameBuf, uint16_t FrameBytes)
}
}
} else if (Command == ISO15693_CMD_READ_MULTIPLE) {
if (ISO15693Addressed(FrameBuf, Uid)) {
/* TODO: check for unaddressed requests */
if (ISO15693Addressed(FrameBuf) && ISO15693CompareUid(&FrameBuf[2], Uid)) {
uint16_t PageAddress = FrameBuf[10];
uint16_t PageAddressCount = FrameBuf[11] + 1;
@@ -116,7 +120,8 @@ uint16_t Sl2s2002AppProcess(uint8_t* FrameBuf, uint16_t FrameBytes)
FrameBuf[0] = 0; /* Flags */
}
} else if (Command == ISO15693_CMD_GET_BLOCK_SEC) {
if (ISO15693Addressed(FrameBuf, Uid)) {
/* TODO: check for unaddressed requests */
if (ISO15693Addressed(FrameBuf) && ISO15693CompareUid(&FrameBuf[2], Uid)) {
uint8_t PageAddressStart = FrameBuf[10];
uint8_t PageAddressCount = FrameBuf[11] + 1;
FrameBuf[0] = 0; /* Flags */
@@ -133,7 +138,8 @@ uint16_t Sl2s2002AppProcess(uint8_t* FrameBuf, uint16_t FrameBytes)
case STATE_QUIET:
if (Command == ISO15693_CMD_RESET_TO_READY) {
if (ISO15693Addressed(FrameBuf, Uid)) {
/* TODO: check for unaddressed requests */
if (ISO15693Addressed(FrameBuf) && ISO15693CompareUid(&FrameBuf[2], Uid)) {
FrameBuf[0] = 0;
ResponseByteCount = 1;
State = STATE_READY;
@@ -84,17 +84,21 @@ uint16_t TITagitstandardAppProcess(uint8_t* FrameBuf, uint16_t FrameBytes)
} else if (Command == ISO15693_CMD_STAY_QUIET) {
if (ISO15693Addressed(FrameBuf,Uid)) {
if (ISO15693Addressed(FrameBuf) && ISO15693CompareUid(&FrameBuf[2], Uid)) {
State = STATE_QUIET;
}
} else if (Command == ISO15693_CMD_READ_SINGLE) {
uint8_t *FramePtr;
uint8_t PageAddress;
if (ISO15693Addressed(FrameBuf,Uid))
PageAddress = FrameBuf[10]; /* when receiving an addressed request pick block number from the 10th byte in the request*/
if (ISO15693Addressed(FrameBuf))
if (ISO15693CompareUid(&FrameBuf[2], Uid)) /* read is addressed to us */
PageAddress = FrameBuf[10]; /* when receiving an addressed request pick block number from the 10th byte in the request*/
else { /* we are not the addressee of the read command */
ResponseByteCount = 0;
break;
}
else
PageAddress = FrameBuf[2];
@@ -124,13 +128,19 @@ uint16_t TITagitstandardAppProcess(uint8_t* FrameBuf, uint16_t FrameBytes)
uint8_t PageAddress;
if (ISO15693Addressed(FrameBuf, Uid)) {
PageAddress = FrameBuf[10]; /*when receiving anaddressed request pick block number from 10th byte in the request*/
Dataptr = &FrameBuf[11];
} else {
PageAddress = FrameBuf[2]; /*when receiving an unanaddressed request pick block number from 2nd byte in the request*/
Dataptr = &FrameBuf[3];
}
if (ISO15693Addressed(FrameBuf))
if (ISO15693CompareUid(&FrameBuf[2], Uid)) {/* write is addressed to us */
PageAddress = FrameBuf[10]; /*when receiving an addressed request pick block number from 10th byte in the request*/
Dataptr = &FrameBuf[11];
}
else { /* we are not the addressee of the write command */
ResponseByteCount = 0;
break;
}
else {
PageAddress = FrameBuf[2];
Dataptr = &FrameBuf[3];
}
MemoryWriteBlock(Dataptr, PageAddress * BYTES_PER_PAGE, BYTES_PER_PAGE);
FrameBuf[0] = 0x00;
@@ -142,7 +152,7 @@ uint16_t TITagitstandardAppProcess(uint8_t* FrameBuf, uint16_t FrameBytes)
case STATE_QUIET:
if (Command == ISO15693_CMD_RESET_TO_READY) {
if (ISO15693Addressed(FrameBuf, Uid)) {
if (ISO15693Addressed(FrameBuf)) {
FrameBuf[0] = 0;
ResponseByteCount = 1;
State = STATE_READY;
@@ -61,11 +61,13 @@ uint16_t VicinityAppProcess(uint8_t* FrameBuf, uint16_t FrameBytes)
ISO15693CopyUid(&FrameBuf[2], Uid);
ResponseByteCount = 10;
} else if (Command == ISO15693_CMD_STAY_QUIET) {
if (ISO15693Addressed(FrameBuf, Uid)) {
/* TODO: check for unaddressed requests */
if (ISO15693Addressed(FrameBuf) && ISO15693CompareUid(&FrameBuf[2], Uid)) {
State = STATE_QUIET;
}
} else if (Command == ISO15693_CMD_GET_SYS_INFO) {
if (ISO15693Addressed(FrameBuf, Uid)) {
/* TODO: check for unaddressed requests */
if (ISO15693Addressed(FrameBuf) && ISO15693CompareUid(&FrameBuf[2], Uid)) {
FrameBuf[0] = 0; /* Flags */
FrameBuf[1] = 0; /* InfoFlags */
ISO15693CopyUid(&FrameBuf[2], Uid);
@@ -81,7 +83,8 @@ uint16_t VicinityAppProcess(uint8_t* FrameBuf, uint16_t FrameBytes)
case STATE_QUIET:
if (Command == ISO15693_CMD_RESET_TO_READY) {
MemoryReadBlock(Uid, MEM_UID_ADDRESS, ActiveConfiguration.UidSize);
if (ISO15693Addressed(FrameBuf, Uid)) {
/* TODO: check for unaddressed requests */
if (ISO15693Addressed(FrameBuf) && ISO15693CompareUid(&FrameBuf[2], Uid)) {
FrameBuf[0] = 0;
ResponseByteCount = 1;
State = STATE_READY;