pezi / dart_periphery

dart_periphery is a Dart port of the native c-periphery library
BSD 3-Clause "New" or "Revised" License
36 stars 9 forks source link

Added the basic structure to work with PN532 and did some refactoring #6

Closed UliPrantz closed 2 years ago

UliPrantz commented 2 years ago

I added the basic file structure and files to work with the PN532. Currently only reading passiv targets is supported but adding more commands is just simple porting from already existent PN532 implementations into the pn532.dart file. All the underlying communication and encoding is already tested and implemented in the spi_impl.dart and i2c_impl.dart files. If anyone needs a UART implementation feel free to add one by extending the BaseProtocol class defined in base_protocol.dart. I would always recommend using some more wires and go with the much more reliable SPI protocol and using at least the IRQ pin.

Also currently the reset procedure defined in the BaseProtocol doesn't seem to actual reset the board but I don't know why at the moment maybe somebody can contribute to this.

UliPrantz commented 2 years ago

I just saw that you made your own version of the dart ByteBuffer (actually it seems like it is the ByteBuffer class of dart with some little changes I guess?!) class which is somehow used to read 8 bit and 16 bit values but I really don't know where it's used and how it actually works. I added a Uint8 class which I guess does the same job and could easily be abstracted to work reading x bytes and replace the ByteBuffer class. I also already added tests for the Uint8 class. If you want I could make an 8 and 16 bit Uint version but you would have to refactor your code to work with these classes or refactor my code to work with your class. Let me know what you think and how you would like to approach this.

UliPrantz commented 2 years ago

Just added capabilities for the PN532 driver to also read and write to Mifare and NTag cards and also added support for Uint8, Uint16, Uint32 by abstracting the Uint8 class to a general Uint class and extending it. If needed support for int8, int16, int32 can be added analog.

I just couldn't test the write and read commands yet also a small explanation in the README.md how to use and wire up the PN532 would be great. Maybe somebody else could do it and test it since I'm currently don't have access to a PN532 board.

pezi commented 2 years ago

Thanks for you contribution - I will review and merge your changes probably this coming weekend,

pezi commented 2 years ago

Thanks for great work, I merged your project yesterday (v0.8.29). A little example would be nice for the readme file

[PN532](https://github.com/pezi/dart_periphery/pull/6) NFC Reader Module, Thanks to UliPrantz! 

like for the ohter sensors

* [SGP30](https://github.com/pezi/dart_periphery/blob/main/example/i2c_sgp30.dart): tVOC and eCO2 Gas Sensor

The readme links currently to the pull request.