Skip to content

Add source files #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from Nov 16, 2017
Merged

Add source files #1

merged 12 commits into from Nov 16, 2017

Conversation

ghost
Copy link

@ghost ghost commented Oct 2, 2017

Add source files to M24SR64-Y library.
Examples available for Discovery L475VG IOT board.

This PR removed an issue in this library.

Copy link
Member

@fpistm fpistm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First quick review.

General comment:
Please review indentation, sometimes tab, sometimes 2 spaces or more. Preferred 2 spaces instead of tab (same as core).
Review also indentation alignments.

Thanks

README.md Outdated
The WriteURIMail sketch writes a Mail tag on the device. It records a mail with the recipient, the subject and the body of the message.
the WriteText sketch writes a Text tag on the device. It records a simple text message.

We can see on the monitor window the message "Sytstem init done!" when the NFC module is started and ready.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reword (please avoid use of "we"):
When the NFC module is started and ready, the message "Sytstem init done!" is displayed on the monitor window.

README.md Outdated
You can't write tag with a total size (protocol + payload) greater than 246 bytes.
This is the limitation one Iblock command on M24SR device. This limitation is also
in the variant.h file, the I2C buffer have a limited size.
This library was tested on DISCO_L475VG_IOT_board, it's may not work on other board.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should work with each board including M24SR? or using the NFC shield?
So?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course but we tested only on DISCO L475 IOT. The sentence will be removed.

const uint8_t M24SR_ADDR=0xAC;
const int DEFAULT_GPO_PIN=PE4;
const int DEFAULT_RF_DISABLE_PIN=PE2;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All those parameters are dedicatedt toL4 disco IOT. Add a comment to mention that user have to update them according to the board tested and that those one are for L4 IOT

* Choose the type, the data and the length of the Mime by changing
* the content of mime_type and data, the length is automatic.
*
* We can see on the monitor window the message "Sytstem init done!" when the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reword

* Check the pinout and the I2C interface used for communication.
* Choose the name of the application by changing the content of text_write.
*
* We can see on the monitor window the message "Sytstem init done!" when the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reword

******************************************************************************
*/

#ifndef X_NUCLEO_NFC01A1_M24SR_NDEFNFCTAGM24SR_H_
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove X_NUCLEO_NFC01A1_M24SR


};

#endif /* X_NUCLEO_NFC01A1_M24SR_NDEFNFCTAGM24SR_H_ */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

src/m24sr_def.h Outdated

#endif /* __DRV_M24SR_H */

/******************* (C) COPYRIGHT 2013 STMicroelectronics *****END OF FILE****/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove date to avoid misalignment

* You can also write an AAR tag with your smartphone.
* On Android, donwload the NFC Tools.
* Then start the app, check if NFC is activated on your smartphone.
* Choose "ecrire" and then select the AAR tag.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And for english smartphone?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caught ;)

README.md Outdated
## Important note

Before using this library, install the ArduinoSTL library.
Make sure to include the patch number with commit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems difficult to apply for non github user.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree but we have no choice.
@cparata push a PR but we are waiting the merge.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, use this PR to test: stm32duino/Arduino_Core_STM32#129
This allow to use STL without Arduino STL.
Build ok by removing all ArduinoSTL.h include in NFC sketches.

Copy link

@VVESTM VVESTM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

I made a first test with nfc and I have bad results. See my comments on examples/WriteText/WriteText.ino, they apply to all examples.

To test, I have :
* This PR
* stm32duino core + stm32duino/Arduino_Core_STM32#120
* ArduinoSTL lib + mike-matera/ArduinoSTL#12

* If you want to read tag in RF mode (with smartphone) unplug the USB on the board.
* The board should be power-off, or RF mode will not be available.
*
* You can write a Text tag with your smartphone.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Description not clear. In this case, the sample will write a text on the chip, then, it will read it to check if it is OK. With a smartphone, we will be able to check that text has been updated.
The read / write functionality from the smartphone is not dependent of the Arduino sketche...


void loop() {
const char *text_write = "hello world welcome on earth"; // Text to write in the tag
char text_read[255]; // Text read in the tag
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be good to initialize this value. (in case we see something in case of error during reading)

//read the txt message and print it
nfcTag.readTxt(text_read);
SerialPort.println("Message content :");
SerialPort.println(text_read);
Copy link

@VVESTM VVESTM Oct 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need a strcmp to compare to the written message.

In my case, the read message is always empty... Perhaps I missed something in the way to test the NFC, but even in this case, we should get an error.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One other change, is to perform the test in the setup as it is done only one

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VVESTM

There is a problem with the library. My release was ready since the last week before the PR of the I2C on IT. So it broke the library communication.
I must find a patch...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds strange that the I2C IT broke it.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it is a mismatch between i2c working with IT now and i2c buffer size. There are still I2C_TXRX_BUFFER_SIZE defined to 32 for example...
(I have tried to set it to 255 but it is not working).

Then, as mentioned by @fpistm, it can be good to have something more flexible. (Avoid to use a big buffer if not needed)

Copy link
Author

@ghost ghost Oct 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confirm the problem is in the I2C layer. It is not the buffer size the problem.

From the datasheet of the module we can read:

A restart during a command and response exchange is not supported by the M24SR64-Y.
After a command, the I2C host can execute a Polling sequence to determine when the
response is available.
Polling sequence: Loop on START (S) + DeviceSelect with RW=0 + read NACK/ACK + STOP(P)
The response is available as soon as the M24SR64-Y sends an ACK ( host read will a '0').

That means the I2C goes in READY state but with AF (Acknowledge failure) error when it is waiting a response from the module because the module returns NACK. As the error code is not checked then the Wire library returns OK to the NFC driver but the module it is not ready yet!

The quick solution is to check the errorCode parameter in i2c_master_read(). But I saw other problems in the twi.c file. I will open an issue to expose to you those problems. (And I know I validated the PR but too quickly I think).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My 2 cents:
I think it is ok to exit i2c_master_read as soon as I2C READY internal state is reached
To check whether device is ready before sending a new command, the below API shall be used:
i2c_status_e i2c_IsDeviceReady(i2c_t *obj, uint8_t devAddr, uint32_t trials)
It is up to the device driver to use this API when needed (as recommended by spec) before sending a new I2C command. I have seen EEPROM where is sometimes takes 5 or 6 checks before the device is actually ready ...

Signed-off-by: fpr <[email protected]>
@ghost
Copy link
Author

ghost commented Oct 12, 2017

PR updated:

  • fixes remarks from @fpistm and @VVESTM
  • works with STL PR. Library ArduinoSTL isn't required anymore.
  • I2C reworked to use this PR. This PR can be definitively abandoned and closed.

However, this PR needs to be validated with the fix of this issue before to be merged.

@ghost ghost requested review from fpistm and VVESTM October 12, 2017 14:53
@ghost
Copy link
Author

ghost commented Oct 17, 2017

Updated to work with I2C IT mode.

@ghost
Copy link
Author

ghost commented Nov 7, 2017

Library updated with the last modification of the Wire library (PR).

fpr added 9 commits November 8, 2017 14:56
Signed-off-by: fpr <[email protected]>
Signed-off-by: fpr <[email protected]>
Signed-off-by: fpr <[email protected]>
Signed-off-by: fpr <[email protected]>
Signed-off-by: fpr <[email protected]>
Signed-off-by: fpr <[email protected]>
Signed-off-by: fpr <[email protected]>
@ghost
Copy link
Author

ghost commented Nov 8, 2017

Updated to match with the latest version of this PR.

cparata
cparata previously requested changes Nov 8, 2017
Copy link
Contributor

@cparata cparata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to add in the examples also the settings for X-NUCLEO-NFC01A1 as we did for SPBTLE-RF library, so we have a porting that works fine with both Discovery IoT Node and X-NUCLEO-NFC01A1.

@cparata cparata dismissed their stale review November 9, 2017 09:23

I decided to create a dedicated package for X-NUCLEO-NFC01A1 derived from M24SR64-Y library.

Copy link
Member

@fpistm fpistm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok for me. Wait merge of stm32duino/Arduino_Core_STM32#131 before merge this one

@fpistm fpistm merged commit 8a03355 into stm32duino:master Nov 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants