Can anyone provide an example of api rfalST25xVPollerReadMessage?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎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.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-16 11:54 AM
Hi,
- Open RF user security session with rfalST25xVPollerPresentPassword with pwdNum=0 (RF_PWD_0), pwd=your passwd and pwdLen=8
- Authorize the enabling of the MB (set MB_MODE bit to 1 in MB_MODE register thanks to rfalST25xVPollerWriteConfiguration)
- Read the current value of the MB_CTRL_Dyn register with rfalST25xVPollerReadDynamicConfiguration
- set MB_EN bit to 1 and write the updated value to MB_CTRL_Dyn register with rfalST25xVPollerWriteDynamicConfiguration
- read the length of the mailbox message with rfalST25xVPollerReadMessageLength or rfalST25xVPollerFastReadMessageLength (double speed)
- read the mailbox message with rfalST25xVPollerReadMessage or rfalST25xVPollerFastReadMessage
#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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-16 7: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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-16 11:54 AM
Hi,
- Open RF user security session with rfalST25xVPollerPresentPassword with pwdNum=0 (RF_PWD_0), pwd=your passwd and pwdLen=8
- Authorize the enabling of the MB (set MB_MODE bit to 1 in MB_MODE register thanks to rfalST25xVPollerWriteConfiguration)
- Read the current value of the MB_CTRL_Dyn register with rfalST25xVPollerReadDynamicConfiguration
- set MB_EN bit to 1 and write the updated value to MB_CTRL_Dyn register with rfalST25xVPollerWriteDynamicConfiguration
- read the length of the mailbox message with rfalST25xVPollerReadMessageLength or rfalST25xVPollerFastReadMessageLength (double speed)
- read the mailbox message with rfalST25xVPollerReadMessage or rfalST25xVPollerFastReadMessage
#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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-17 12:37 AM
Hi
Internally the RFAL is divided into three sub layers:
- RF HL - RF Higher Layer with RFAL NFC API
- RF AL - RF Abstraction Layer
- RF HAL - RF Hardware Abstraction Layer
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-17 2: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
