2020-04-16 12:56 AM
Hi all:
I want to read mailbox message from nfc tag at nfc reader side.
But i cann't find an example of how to read it, i find an api rfalST25xVPollerReadMessage, but don't know how to use it. Can anyone share it?
Solved! Go to Solution.
2020-04-16 11:54 AM
Hi,
#define ST25DV04K_SYSTEM_CONFIG_MB_MODE 0x0D
#define ST25DV04K_REG_MB_MODE_FTM_AUTHORIZED 1U
#define ST25DV04K_DYN_REG_MB_CTRL 0x0D
#define ST25DV04K_REG_MB_CTRL_DYN_MB_EN 1U
uint8_t pointer;
uint8_t reg;
static uint8_t pwd[8] = {0,0,0,0,0,0,0,0};
uint8_t pwdLen = 8;
uint8_t pwdNum = 0;
uint8_t msgLen;
ReturnCode err;
uint16_t rcvLen;
static uint8_t rxBuf[256];
/* Open RF configuration security session */
err = rfalST25xVPollerPresentPassword(RFAL_NFCV_REQ_FLAG_DEFAULT, uid, pwdNum, pwd, pwdLen);
/* set MB_MODE to 1: Enabling fast transfer mode is authorized.*/
pointer = ST25DV04K_SYSTEM_CONFIG_MB_MODE;
reg = ST25DV04K_REG_MB_MODE_FTM_AUTHORIZED;
err = rfalST25xVPollerWriteConfiguration(RFAL_NFCV_REQ_FLAG_DEFAULT, uid, pointer, reg);
/* set MB_EN to 1: Enable FTM. Read, update and write */
pointer = ST25DV04K_DYN_REG_MB_CTRL;
err = rfalST25xVPollerFastReadDynamicConfiguration(RFAL_NFCV_REQ_FLAG_DEFAULT, uid, pointer, ®);
reg |= ST25DV04K_REG_MB_CTRL_DYN_MB_EN;
err = rfalST25xVPollerFastWriteDynamicConfiguration(RFAL_NFCV_REQ_FLAG_DEFAULT, uid, pointer, reg);
/* Read Msg Len */
err = rfalST25xVPollerFastReadMessageLength(RFAL_NFCV_REQ_FLAG_DEFAULT, uid, &msgLen);
/* Read Msg */
err = rfalST25xVPollerReadMessage(RFAL_NFCV_REQ_FLAG_DEFAULT, uid, 0,0, rxBuf, sizeof(rxBuf), &rcvLen);
Rgds
BT
2020-04-16 07:23 AM
Hi,
please check 5.1.2 of the DS of e.g. ST25DV64K. The last paragraph details an example usage. The functions more or less directly translate into rfal calls to:
rfalST25xVPollerWriteDynamicConfiguration(), rfalST25xVPollerReadMessage(), rfalST25xVPollerWriteMessage(), rfalST25xVPollerReadDynamicConfiguration().
Before reading / writing the mailbox please make sure to have the ST25DV in the right state: Maybe present the PW, maybe disable EH to avoid RF noise, initialize mailbox by setting MB_EN 0->1.
Regards, Ulysses
2020-04-16 11:54 AM
Hi,
#define ST25DV04K_SYSTEM_CONFIG_MB_MODE 0x0D
#define ST25DV04K_REG_MB_MODE_FTM_AUTHORIZED 1U
#define ST25DV04K_DYN_REG_MB_CTRL 0x0D
#define ST25DV04K_REG_MB_CTRL_DYN_MB_EN 1U
uint8_t pointer;
uint8_t reg;
static uint8_t pwd[8] = {0,0,0,0,0,0,0,0};
uint8_t pwdLen = 8;
uint8_t pwdNum = 0;
uint8_t msgLen;
ReturnCode err;
uint16_t rcvLen;
static uint8_t rxBuf[256];
/* Open RF configuration security session */
err = rfalST25xVPollerPresentPassword(RFAL_NFCV_REQ_FLAG_DEFAULT, uid, pwdNum, pwd, pwdLen);
/* set MB_MODE to 1: Enabling fast transfer mode is authorized.*/
pointer = ST25DV04K_SYSTEM_CONFIG_MB_MODE;
reg = ST25DV04K_REG_MB_MODE_FTM_AUTHORIZED;
err = rfalST25xVPollerWriteConfiguration(RFAL_NFCV_REQ_FLAG_DEFAULT, uid, pointer, reg);
/* set MB_EN to 1: Enable FTM. Read, update and write */
pointer = ST25DV04K_DYN_REG_MB_CTRL;
err = rfalST25xVPollerFastReadDynamicConfiguration(RFAL_NFCV_REQ_FLAG_DEFAULT, uid, pointer, ®);
reg |= ST25DV04K_REG_MB_CTRL_DYN_MB_EN;
err = rfalST25xVPollerFastWriteDynamicConfiguration(RFAL_NFCV_REQ_FLAG_DEFAULT, uid, pointer, reg);
/* Read Msg Len */
err = rfalST25xVPollerFastReadMessageLength(RFAL_NFCV_REQ_FLAG_DEFAULT, uid, &msgLen);
/* Read Msg */
err = rfalST25xVPollerReadMessage(RFAL_NFCV_REQ_FLAG_DEFAULT, uid, 0,0, rxBuf, sizeof(rxBuf), &rcvLen);
Rgds
BT
2020-04-16 11:04 PM
Hi Brian:
Thanks!
It helps. I want to ask some detail. Where does parameter uid of these functions come from?
I guess function rfalNfcvPollerCheckPresence, and it returns a structure of rfalNfcvInventoryRes which has a field of UID.right?
And i follows exampleRfalPoller.c in RFAL librariy which ST SW provides. In the state EXAMPLE_RFAL_POLLER_STATE_DATAEXCHANGE_START, i invoke
rfalST25xVPollerReadMessage to get message from the tag. Is that work?
Best Regards,
Johnson
2020-04-16 11:13 PM
Hi:
Your info is at tag side. But i am interested in the reader side.
But your reply is stall valuable.
you metion " disable EH to avoid RF noise" , do you mean when i operate nfc tag, i should disable EH mode each i want to read mailbox message sent by reader.
2020-04-17 12:37 AM
Hi
Internally the RFAL is divided into three sub layers:
The exampleRfalPoller.c aims to demonstrate RF AL sub layer API. I would recommend to rather use the RF High Layer API and to use the demo.c provided within the poller demo in X-CUBE-NFC3 (ST25R95 reader), X-CUBE-NFC5 (ST25R3911B reader) or X-CUBE-NFC6 (ST25R3916 reader).
In this demo.c file, a default demoNfcv() function is provided. You can simply modify this demoNfcv() function to add you code. This function has a nfcvDev parameter and the uid is nfcvDev->InvRes.UID.
Rgds
BT
2020-04-17 02:04 AM
Hi,
well I regard my answer as being from the reader side - the reader does drive the RF communication and I hinted on the to be used reader/rfal functions. But Brian below already went into the details of usage.
Regarding Energy Harvesting disable: If you are anyhow powered at the time of communication it is probably safer to disable it during that time. Any change of power drawn will affect the reader field and could be see by the receiver inside the reader. I think it is not strictly necessary and maybe you are not able to observe an effect. But depending on your actual design it may have an effect.
There is an appnote discussing such effects: AN4913 "Energy harvesting delivery impact on ST25DVxxx behavior during RF communication"
Regards, Ulrich